private async Task <ContentDialogResult> ShowContentDialog(ContentDialog contentDialog) { // First ContentDialog is shown as InPlace. if (ContentDialogBorder.Child == null) { ContentDialogBorder.Child = contentDialog; } var viewModel = DataContext as MainViewModel; hotKey?.Dispose(); viewModel.IsShowingContentDialog = true; var currentElement = FocusManager.GetFocusedElement(this); contentDialog.Focus(); var result = await contentDialog.ShowAsync(ContentDialogPlacement.InPlace); TryRegisterHotKey(viewModel.Settings.HotKey, out hotKey); viewModel.IsShowingContentDialog = false; currentElement?.Focus(); if (ContentDialogBorder.Child == contentDialog) { ContentDialogBorder.Child = null; } return(result); }
private void LoadOptions() { var settings = Properties.Settings.Default; (App.Current as App).ChangeTheme(settings.Theme); this.Opacity = (double)settings.Opacity; if (settings.WindowPosition.X >= 0) { Left = settings.WindowPosition.X; } if (settings.WindowPosition.Y >= 0) { Top = Properties.Settings.Default.WindowPosition.Y; } if (hotKey != null) { hotKey.Pressed -= HotKey_Pressed; hotKey.Dispose(); } try { hotKey = new HotKey.HotKey(this, (ModifierKeys)settings.HotKeyModifiers, HotKeyConverter.ConvertFromString(settings.HotKeyCharacter)); hotKey.Pressed += HotKey_Pressed; } catch { MessageBox.Show("Hot-key is already in use. Please use another key.", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning); } (NotifyIcon.ContextMenu.Items[0] as MenuItem).InputGestureText = new OptionsViewModel().HotKeyDescription; }