public Task<bool?> InitModification(CoreViewModel vm) { var tcs = new TaskCompletionSource<bool?>(); _dispatcherService.CurrentDispatcher.BeginInvoke(new Action(() => { bool? result = null; Window activeWindow = null; for (var i = 0; i < Application.Current.Windows.Count; i++) { var win = Application.Current.Windows[i]; if ((win != null) && (win.IsActive)) { activeWindow = win; break; } } if (activeWindow != null) { var win = new EditWindow(vm) { Owner = activeWindow }; result = win.ShowDialog(); } tcs.SetResult(result); })); return tcs.Task; }
public EditWindow(CoreViewModel coreViewModel) { InitializeComponent(); _coreViewModel = coreViewModel; this.DataContext = coreViewModel; UpdateInputGrid(); UpdateSaveButtonState(); }
private void Initialize() { // Show the window in normal state WindowState = WindowState.Normal; _coreViewModel = new CoreViewModel(); DataContext = _coreViewModel; _coreViewModel.InitializeEnvironmentVariables(); switch (_coreViewModel.InitResult) { case InitResultType.InitOk: break; case InitResultType.AccessDenied: MessageBox.Show("Cannot access Environment variables! Please restart NVM# as an Administrator.", "NVM#"); Application.Current.Shutdown(); break; case InitResultType.OtherError: MessageBox.Show("NVM# encountered an error and needs to close!", "NVM#"); Application.Current.Shutdown(); break; } UserButton.IsChecked = true; SizeChanged += (o, a) => { switch (WindowState) { case WindowState.Maximized: SplitViewMenu.Width = (int)SplitViewMenuWidth.Wide; break; case WindowState.Normal: SplitViewMenu.Width = (int)SplitViewMenuWidth.Narrow; break; } RootGrid.ColumnDefinitions[0] = new ColumnDefinition { Width = new GridLength(SplitViewMenu.Width) }; RootGrid.InvalidateVisual(); }; // Enable the tooltip for SplitView menu buttons only if the SplitView width is narrow SplitViewMenu.SizeChanged += (o, a) => { var isNarrowMenu = (int) SplitViewMenu.Width == (int) SplitViewMenuWidth.Narrow; ToolTipService.SetIsEnabled(UserButton, isNarrowMenu); ToolTipService.SetIsEnabled(SystemButton, isNarrowMenu); ToolTipService.SetIsEnabled(ImportButton, isNarrowMenu); ToolTipService.SetIsEnabled(ExportButton, isNarrowMenu); ToolTipService.SetIsEnabled(AboutButton, isNarrowMenu); }; }
private void Initialize() { // Show the Windows in maximized state WindowState = WindowState.Maximized; _coreViewModel = new CoreViewModel(); DataContext = _coreViewModel; _coreViewModel.InitializeEnvironmentVariables(); switch (_coreViewModel.InitResult) { case InitResultType.InitOk: break; case InitResultType.AccessDenied: MessageBox.Show("Cannot access Environment variables! Please restart NVM# as an Administrator.", "NVM#"); Application.Current.Shutdown(); break; case InitResultType.OtherError: MessageBox.Show("NVM# encountered an error and needs to close!", "NVM#"); Application.Current.Shutdown(); break; } UserButton.IsChecked = true; }