aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.Stubs
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2018-07-03 17:15:11 +0300
committerRoy Ben-Shabat <Roy@Twine-s.com>2018-07-03 17:15:11 +0300
commit39c49d522d68a591d60aecdeab8149f1bb04415c (patch)
tree380740ed10aed79aa531009703c641158f0938d7 /Software/Visual_Studio/Tango.Stubs
parent856773f7eafb9d04500ede0cfae9c0e75231418b (diff)
downloadTango-39c49d522d68a591d60aecdeab8149f1bb04415c.tar.gz
Tango-39c49d522d68a591d60aecdeab8149f1bb04415c.zip
Stubs working good on Machine Studio...
Diffstat (limited to 'Software/Visual_Studio/Tango.Stubs')
-rw-r--r--Software/Visual_Studio/Tango.Stubs/ViewModels/StubsViewVM.cs35
-rw-r--r--Software/Visual_Studio/Tango.Stubs/Views/StubsView.xaml.cs5
2 files changed, 24 insertions, 16 deletions
diff --git a/Software/Visual_Studio/Tango.Stubs/ViewModels/StubsViewVM.cs b/Software/Visual_Studio/Tango.Stubs/ViewModels/StubsViewVM.cs
index dbcf0887b..64f5a2913 100644
--- a/Software/Visual_Studio/Tango.Stubs/ViewModels/StubsViewVM.cs
+++ b/Software/Visual_Studio/Tango.Stubs/ViewModels/StubsViewVM.cs
@@ -419,8 +419,6 @@ namespace Tango.Stubs.ViewModels
Examples = Examples.OrderBy(x => x.Name).ToList();
- Application.Current.Exit += Current_Exit;
-
LogManager.RegisterLogger(new Logging.FileLogger() { Enabled = true });
LogManager.Log("Application Started!");
}
@@ -546,6 +544,8 @@ namespace Tango.Stubs.ViewModels
File.WriteAllText(SelectedCodeTab.File, SelectedCodeTab.Code);
await Task.Delay(1000);
Status = "Ready";
+
+ SaveSettings();
}
}
}
@@ -567,10 +567,21 @@ namespace Tango.Stubs.ViewModels
SelectedCodeTab.File = dlg.FileName;
await Task.Delay(1000);
Status = "Ready";
+
+ SaveSettings();
}
}
}
+ public void SaveSettings()
+ {
+ _settings.AutoLogResponse = AppendLogAuto;
+ _settings.SelectedPort = SelectedPort;
+ _settings.BaudRate = BaudRate;
+ _settings.LastTabs = CodeTabs.Select(x => x.File).ToList();
+ _settings.Save();
+ }
+
/// <summary>
/// Opens a script from HD.
/// </summary>
@@ -623,7 +634,7 @@ namespace Tango.Stubs.ViewModels
}
catch (Exception ex)
{
- MessageBox.Show(ex.ToString(), "Tango");
+ AppendTextLog(ex.Message);
}
}
@@ -646,6 +657,12 @@ namespace Tango.Stubs.ViewModels
if (SelectedCodeTab.Errors.Count > 0) return;
+ if (MachineOperator == null || MachineOperator.State != TransportComponentState.Connected)
+ {
+ AppendTextLog("Machine operator is not initialized or connected. Could not execute script.");
+ return;
+ }
+
IsRunning = true;
SelectedCodeTab.IsRunning = true;
_logTextBox.Text = (DateTime.Now.ToTimeString() + ": ") + "Executing script '" + SelectedCodeTab.Title + "'..." + Environment.NewLine;
@@ -687,7 +704,6 @@ namespace Tango.Stubs.ViewModels
{
IsRunning = false;
SelectedCodeTab.IsRunning = false;
- MessageBox.Show(ex.Message, "Tango");
}
});
}
@@ -807,17 +823,6 @@ namespace Tango.Stubs.ViewModels
Status = "Completed";
}
- private void Current_Exit(object sender, ExitEventArgs e)
- {
- LogManager.OverrideQueue = true;
- LogManager.Log("Application Terminated");
- _settings.AutoLogResponse = AppendLogAuto;
- _settings.SelectedPort = SelectedPort;
- _settings.BaudRate = BaudRate;
- _settings.LastTabs = CodeTabs.Select(x => x.File).ToList();
- _settings.Save();
- }
-
private void AppendTextLog(String log)
{
LogManager.Log(log);
diff --git a/Software/Visual_Studio/Tango.Stubs/Views/StubsView.xaml.cs b/Software/Visual_Studio/Tango.Stubs/Views/StubsView.xaml.cs
index 0f772f4ba..8c0619fdf 100644
--- a/Software/Visual_Studio/Tango.Stubs/Views/StubsView.xaml.cs
+++ b/Software/Visual_Studio/Tango.Stubs/Views/StubsView.xaml.cs
@@ -34,7 +34,10 @@ namespace Tango.Stubs.Views
_vm = DataContext as StubsViewVM;
_vm.SetLogTextBox(txtLog);
-
+ var source = tabControl.ItemsSource;
+ tabControl.ItemsSource = null;
+ tabControl.ItemsSource = source;
+ tabControl.SelectedIndex = 0;
};
}