Browse Source

1. disable run button while running
2. update version

Robert 1 year ago
parent
commit
3825d4336d

+ 1 - 1
GitVersion.yml

@@ -1,6 +1,6 @@
 assembly-versioning-scheme: MajorMinorPatch
 assembly-informational-format: '{ShortSha}'
-next-version: 1.0.5
+next-version: 1.0.6
 branches: {}
 ignore:
   sha: []

+ 4 - 4
MesAdaptor/Properties/AssemblyInfo.cs

@@ -31,7 +31,7 @@ using System.Runtime.InteropServices;
 //
 // You can specify all the values or you can default the Build and Revision Numbers
 // by using the '*' as shown below:
-// [assembly: AssemblyVersion("1.0.4.0")]
-[assembly: AssemblyVersion("1.0.4.0")]
-[assembly: AssemblyFileVersion("1.0.4.0")]
-[assembly: AssemblyInformationalVersion("9cc0bed")]
+// [assembly: AssemblyVersion("1.0.5.0")]
+[assembly: AssemblyVersion("1.0.5.0")]
+[assembly: AssemblyFileVersion("1.0.5.0")]
+[assembly: AssemblyInformationalVersion("3508d8d")]

+ 1 - 0
ST-LINK_MES/MainWindow.xaml

@@ -88,6 +88,7 @@
                 VerticalAlignment="Center"
                 Text="0%" />
             <Button
+                x:Name="uxRunBtn"
                 Grid.Column="2"
                 Background="LightSkyBlue"
                 Click="uxRunBtn_Click"

+ 40 - 27
ST-LINK_MES/MainWindow.xaml.cs

@@ -101,41 +101,54 @@ namespace ST_LINK_MES
             uxBinFilePath.Text = dlg.FileName;
         }
 
-        private void uxRunBtn_Click(object sender, RoutedEventArgs e)
+        private async void uxRunBtn_Click(object sender, RoutedEventArgs e)
         {
-            uxTerminal.Document.Blocks.Clear();
-
-            if (string.IsNullOrEmpty(uxSN.Text))
+            uxRunBtn.IsEnabled = false;
+            try
             {
-                AddTerminalMsg("ERROR: SN Should not be empty");
-                return;
-            }
+                uxTerminal.Document.Blocks.Clear();
 
-            if (!ValidateSN())
-            {
-                return;
-            }
+                if (string.IsNullOrEmpty(uxSN.Text))
+                {
+                    AddTerminalMsg("ERROR: SN Should not be empty");
+                    return;
+                }
 
-            string filePath = uxBinFilePath.Text;
-            if (!File.Exists(filePath))
-            {
-                AddTerminalMsg("ERROR: Program file not found");
-                return;
-            }
+                if (!ValidateSN())
+                {
+                    return;
+                }
 
-            string cliPath = stlinkService.CliPath;
-            if (!File.Exists(filePath))
+                string filePath = uxBinFilePath.Text;
+                if (!File.Exists(filePath))
+                {
+                    AddTerminalMsg("ERROR: Program file not found");
+                    return;
+                }
+
+                string cliPath = stlinkService.CliPath;
+                if (!File.Exists(filePath))
+                {
+                    AddTerminalMsg("ERROR: ST-LINK_CLI not found");
+                    return;
+                }
+
+                fileRrecordService.Start(uxSN.Text);
+                var task = new Task(() =>
+                {
+                    StartProgram(filePath);
+                });
+                await task;
+                //task.Start();
+            }
+            catch (Exception error)
             {
-                AddTerminalMsg("ERROR: ST-LINK_CLI not found");
-                return;
+                MessageBox.Show(error.Message);
             }
-
-            fileRrecordService.Start(uxSN.Text);
-            var task = new Task(() =>
+            finally
             {
-                StartProgram(filePath);
-            });
-            task.Start();
+                uxRunBtn.IsEnabled = true;
+            }
         }
 
         private void StartProgram(string filePath)

+ 4 - 4
ST-LINK_MES/Properties/AssemblyInfo.cs

@@ -50,7 +50,7 @@ using System.Windows;
 //
 // You can specify all the values or you can default the Build and Revision Numbers
 // by using the '*' as shown below:
-// [assembly: AssemblyVersion("1.0.4.0")]
-[assembly: AssemblyVersion("1.0.4.0")]
-[assembly: AssemblyFileVersion("1.0.4.0")]
-[assembly: AssemblyInformationalVersion("9cc0bed")]
+// [assembly: AssemblyVersion("1.0.5.0")]
+[assembly: AssemblyVersion("1.0.5.0")]
+[assembly: AssemblyFileVersion("1.0.5.0")]
+[assembly: AssemblyInformationalVersion("3508d8d")]