From 00cfb0906e164487efed62bd6a65cdf681952bd1 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Wed, 1 Aug 2018 11:47:10 +0300 Subject: Implemented reloading of color lab module and research module when machine designer changes machine ! --- .../Tango.MachineStudio.UI/App.xaml.cs | 143 +++++++++++---------- 1 file changed, 75 insertions(+), 68 deletions(-) (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI') diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/App.xaml.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/App.xaml.cs index 99a6174a8..8d5981322 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/App.xaml.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/App.xaml.cs @@ -28,12 +28,12 @@ namespace Tango.MachineStudio.UI /// /// Interaction logic for App.xaml /// - public partial class App : Application + public partial class App : Application { private WpfGlobalExceptionTrapper exceptionTrapper; private LogManager LogManager = LogManager.Default; - protected override void OnStartup(StartupEventArgs e) + protected override void OnStartup(StartupEventArgs e) { #if DEBUG @@ -84,90 +84,97 @@ namespace Tango.MachineStudio.UI { try { - if (Application.Current == null) - { - new Application { ShutdownMode = ShutdownMode.OnExplicitShutdown }; - } - } - catch { } - - try - { - var eventLogger = TangoIOC.Default.GetInstance(); - if (eventLogger != null) + try { - eventLogger.Log(e.Exception, "Application Crashed!"); + if (Application.Current == null) + { + new Application { ShutdownMode = ShutdownMode.OnExplicitShutdown }; + } } - } - catch { } - - Application.Current.Dispatcher.Invoke(() => - { - WorkItem bug = null; - TeamFoundationServiceExtendedClient tfsClient = null; - INotificationProvider notification = null; + catch { } try { - tfsClient = TangoIOC.Default.GetInstance(); - notification = TangoIOC.Default.GetInstance(); - - if (tfsClient != null && tfsClient.IsInitialized) + var eventLogger = TangoIOC.Default.GetInstance(); + if (eventLogger != null) { - bug = tfsClient.CreateBug(); + eventLogger.Log(e.Exception, "Application Crashed!"); } } - catch (Exception ex) + catch { } + + Application.Current.Dispatcher.Invoke(() => { - Debug.WriteLine(ex.ToString()); - } + WorkItem bug = null; + TeamFoundationServiceExtendedClient tfsClient = null; + INotificationProvider notification = null; - ExceptionWindow exWin = new ExceptionWindow(e.Exception, bug != null); - exWin.ShowDialog(); + try + { + tfsClient = TangoIOC.Default.GetInstance(); + notification = TangoIOC.Default.GetInstance(); - switch (exWin.Resolution) - { - case ExceptionResolutions.Ignore: - e.TryRecover = true; - break; - case ExceptionResolutions.Restart: - e.TryRecover = false; - LogManager.Log("User selection was to restart the application. Restarting..."); - Process.Start(Application.ResourceAssembly.Location); - Environment.Exit(0); - break; - case ExceptionResolutions.Shutdown: - e.TryRecover = false; - LogManager.Log("User selection was to shutdown the application. Restarting..."); - Environment.Exit(0); - break; - case ExceptionResolutions.Report: - e.TryRecover = true; - LogManager.Log("User selection was to report the issue."); - - if (bug != null) + if (tfsClient != null && tfsClient.IsInitialized) { - notification.ShowModalDialog(new ReportIssueViewVM(tfsClient.Project, bug), async (vm) => + bug = tfsClient.CreateBug(); + } + } + catch (Exception ex) + { + Debug.WriteLine(ex.ToString()); + } + + ExceptionWindow exWin = new ExceptionWindow(e.Exception, bug != null); + exWin.ShowDialog(); + + switch (exWin.Resolution) + { + case ExceptionResolutions.Ignore: + e.TryRecover = true; + break; + case ExceptionResolutions.Restart: + e.TryRecover = false; + LogManager.Log("User selection was to restart the application. Restarting..."); + Process.Start(Application.ResourceAssembly.Location); + Environment.Exit(0); + break; + case ExceptionResolutions.Shutdown: + e.TryRecover = false; + LogManager.Log("User selection was to shutdown the application. Restarting..."); + Environment.Exit(0); + break; + case ExceptionResolutions.Report: + e.TryRecover = true; + LogManager.Log("User selection was to report the issue."); + + if (bug != null) { - using (notification.PushTaskItem("Uploading bug report...")) + notification.ShowModalDialog(new ReportIssueViewVM(tfsClient.Project, bug), async (vm) => { - try + using (notification.PushTaskItem("Uploading bug report...")) { - tfsClient.FinalizeBug(vm.WorkItem); - await tfsClient.UploadWorkItem(vm.WorkItem); + try + { + tfsClient.FinalizeBug(vm.WorkItem); + await tfsClient.UploadWorkItem(vm.WorkItem); + } + catch (Exception ex) + { + notification.ShowError("An error occurred while trying to create the issue." + Environment.NewLine + ex.Message); + } } - catch (Exception ex) - { - notification.ShowError("An error occurred while trying to create the issue." + Environment.NewLine + ex.Message); - } - } - }, null); - } + }, null); + } - break; - } - }); + break; + } + }); + } + catch (Exception ex) + { + LogManager.Log(ex, "Error in global exception trapper!"); + } } #endregion -- cgit v1.3.1