コード例 #1
0
ファイル: DialogService.cs プロジェクト: AliBashaSY/Coddee
        private void OnDialogStateChanged(object sender, DialogState e)
        {
            if (sender is IDialog dialog)
            {
                switch (e)
                {
                case DialogState.Active:
                    if (ActiveDialogs.Contains(dialog))
                    {
                        return;
                    }
                    MinimizedDialogs.RemoveIfExists(dialog);
                    ActiveDialogs.Add(dialog);
                    break;

                case DialogState.Minimized:
                    if (MinimizedDialogs.Contains(dialog))
                    {
                        return;
                    }
                    ActiveDialogs.RemoveIfExists(dialog);
                    MinimizedDialogs.Add(dialog);
                    break;

                default:
                    throw new ArgumentOutOfRangeException(nameof(e), e, null);
                }
                DialogStateChanged?.Invoke(this, dialog);
            }
        }
コード例 #2
0
        public static ClickedButton ShowMessageBox(Buttons Button, string Title, string Message, bool ShowInTaskbar = true)
        {
            MessageBox msg = new MessageBox();

            switch (Button)
            {
            case Buttons.OKOnly:
                msg.LB.Visibility = System.Windows.Visibility.Hidden;
                msg.RB.Content    = OKOnlyRightButtonText;
                break;

            case Buttons.OKCancel:
                msg.LB.Content = OKCancelLeftButtonText;
                msg.RB.Content = OKCancelRightButtonText;
                break;

            case Buttons.AcceptDecline:
                msg.LB.Content = AcceptDeclineLeftButtonText;
                msg.RB.Content = AcceptDeclineRightButtonText;
                break;

            case Buttons.YesNo:
                msg.LB.Content = YesNoLeftButtonText;
                msg.RB.Content = YesNoRightButtonText;
                break;

            case Buttons.Custom:
                msg.LB.Content = CustomLeftButtonText;
                msg.RB.Content = CustomRightButtonText;
                break;
            }
            msg.TL.Content = Title;
            msg.ML.Text    = Message;

            msg.Icon = DialogIcon;

            msg.Buttons = Button;

            msg.ShowInTaskbar = ShowInTaskbar;

            DialogStateChanged?.Invoke(msg, new DialogEventArgs(DialogEventArgs.DialogState.Show));

            msg.ShowDialog();

            DialogStateChanged?.Invoke(msg, new DialogEventArgs(DialogEventArgs.DialogState.Close));

            return(msg.Result);
        }
コード例 #3
0
        public static ResultData ShowMessageBoxWithNumeric(string Title, string Message, int DefaultValue, bool ShowInTaskbar = true)
        {
            TextBoxWithMessage Box = new TextBoxWithMessage();

            Box.TL.Content      = Title;
            Box.ML.Text         = Message;
            Box.NumUpDown.Value = DefaultValue;

            Box.Icon = DialogIcon;

            Box.ShowInTaskbar = ShowInTaskbar;

            DialogStateChanged?.Invoke(Box, new DialogEventArgs(DialogEventArgs.DialogState.Show));

            Box.ShowDialog();

            DialogStateChanged?.Invoke(Box, new DialogEventArgs(DialogEventArgs.DialogState.Close));

            return(Box.Result);
        }