#pragma warning disable S1541 // Methods and properties should not be too complex
        void MessageBoxView_OnPreviewKeyDown(object sender, KeyEventArgs e)
#pragma warning restore S1541 // Methods and properties should not be too complex
        {
            if ((Keyboard.Modifiers == (ModifierKeys.Alt | ModifierKeys.Control)) && (e.Key == Key.F4) && Application.Current != null)
            {
                CloseAllWindows();
            }

            if (e.Key == Key.Escape)
            {
                var messageBoxViewModel = DataContext as MessageBoxViewModel;
                if (messageBoxViewModel != null && messageBoxViewModel.IsYesButtonVisible)
                {
                    BtnYesCommand.Focusable = false;
                    BtnYesCommand.Focus();
                }
                if (messageBoxViewModel != null && messageBoxViewModel.IsOkButtonVisible)
                {
                    BtnOkCommand.Focusable = false;
                    BtnOkCommand.Focus();
                }
                if (messageBoxViewModel != null && messageBoxViewModel.IsCancelButtonVisible)
                {
                    BtnCancelCommand.Focusable = true;
                    BtnCancelCommand.Focus();
                }
                if (messageBoxViewModel != null && messageBoxViewModel.IsNoButtonVisible)
                {
                    BtnNoCommand.Focusable = true;
                    BtnNoCommand.Focus();
                }
            }
        }
        void MessageBoxView_OnLoaded(object sender, RoutedEventArgs e)
        {
            var messageBoxViewModel = DataContext as MessageBoxViewModel;

            if (messageBoxViewModel != null && messageBoxViewModel.IsYesButtonVisible)
            {
                BtnYesCommand.Focusable = true;
                BtnYesCommand.Focus();
            }
            if (messageBoxViewModel != null && messageBoxViewModel.IsOkButtonVisible)
            {
                BtnOkCommand.Focusable = true;
                BtnOkCommand.Focus();
            }
        }
Exemple #3
0
        private void MessageBoxView_OnPreviewKeyDown(object sender, KeyEventArgs e)
        {
            if ((Keyboard.Modifiers == (ModifierKeys.Alt | ModifierKeys.Control)) && (e.Key == Key.F4))
            {
                if (Application.Current != null)
                {
                    var windowCollection = Application.Current.Windows;

                    foreach (var window in windowCollection)
                    {
                        var window1 = window as Window;

                        if (window1 != null && window1.Name != "MainViewWindow")
                        {
                            window1.Close();
                        }
                    }
                }
            }
            if (e.Key == Key.Escape)
            {
                var messageBoxViewModel = DataContext as MessageBoxViewModel;
                if (messageBoxViewModel != null && messageBoxViewModel.IsYesButtonVisible)
                {
                    BtnYesCommand.Focusable = false;
                    BtnYesCommand.Focus();
                }
                if (messageBoxViewModel != null && messageBoxViewModel.IsOkButtonVisible)
                {
                    BtnOkCommand.Focusable = false;
                    BtnOkCommand.Focus();
                }
                if (messageBoxViewModel != null && messageBoxViewModel.IsCancelButtonVisible)
                {
                    BtnCancelCommand.Focusable = true;
                    BtnCancelCommand.Focus();
                }
                if (messageBoxViewModel != null && messageBoxViewModel.IsNoButtonVisible)
                {
                    BtnNoCommand.Focusable = true;
                    BtnNoCommand.Focus();
                }
            }
        }