private void OnTargetMachineButtonClick(object sender, RibbonControlEventArgs e) { try { var dialog = new TargetMachinePane(); System.Windows.Interop.WindowInteropHelper helper = new System.Windows.Interop.WindowInteropHelper(dialog); helper.Owner = (IntPtr)ThisAddIn.ExcelApplication.Hwnd; var viewModel = new TargetMachineViewModel(Common.Globals.TargetMachine.DisplayValue); viewModel.RequestClose += new EventHandler(dialog.OnRequestClose); dialog.DataContext = viewModel; dialog.ShowDialog(); // WPF dialog does not have dialog result if (dialog.DialogResult.HasValue && dialog.DialogResult.Value) { this.TargetMachineChanged.OnFire(Common.Globals.TargetMachine, new EventArgs()); } viewModel.RequestClose -= new EventHandler(dialog.OnRequestClose); dialog.Close(); } catch (CustomException ex) { Ribbon.ShowError(ex.HasCustomMessage ? ex.Message : Resources.DefaultErrorMessage); } catch (Exception exception) { Logger.LogException(exception); Ribbon.ShowError(Resources.DefaultErrorMessage); } }
public MachineNameChangeHandler(TargetMachineViewModel targetMachineViewModel) { this.parent = targetMachineViewModel; }