Exemplo n.º 1
0
        //Показать сообщение с кнопками
        public static DialogResult ShowQuery(string message, DialogButtons buttons)
        {
            DebugHelper.WriteTraceEntry("----------");
            DebugHelper.WriteTraceEntry("ShowQuery called");

            (new InputPanel()).Enabled = false;
            //using (new WaitWrapper(true))
            {
                DebugHelper.WriteTraceEntry("ShowQuery beginning");
                if (_masterForm == null)
                {
                    throw new ApplicationException("DialogControl not initialized.");
                }

                if (_masterForm.InvokeRequired)
                {
                    return
                        ((DialogResult)
                         _masterForm.Invoke((showMessageDelegate)showMessage, new object[] { message, buttons }));
                }
                else
                {
                    return(showMessage(message, buttons));
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Gets the <see cref="ButtonConfiguration"/>s for the specified <paramref name="buttons"/>.
        /// </summary>
        /// <param name="buttons"> The <see cref="DialogButtons"/> that should be displayed. </param>
        /// <returns> A collection of <see cref="ButtonConfiguration"/>. </returns>
        /// <remarks> To have no buttons the only flag has to be <see cref="DialogButtons.None"/>. If other flags are set, then the respective buttons will be shown. </remarks>
        internal static IEnumerable <ButtonConfiguration> GetConfiguration(DialogButtons buttons)
        {
            if (buttons.Equals(DialogButtons.None))
            {
                yield break;
            }

            if (buttons.HasFlag(DialogButtons.Ok))
            {
                yield return(DefaultButtonConfigurations.OkButtonConfiguration);
            }
            if (buttons.HasFlag(DialogButtons.Cancel))
            {
                yield return(DefaultButtonConfigurations.CancelButtonConfiguration);
            }
            if (buttons.HasFlag(DialogButtons.Yes))
            {
                yield return(DefaultButtonConfigurations.YesButtonConfiguration);
            }
            if (buttons.HasFlag(DialogButtons.No))
            {
                yield return(DefaultButtonConfigurations.NoButtonConfiguration);
            }
            if (buttons.HasFlag(DialogButtons.Save))
            {
                yield return(DefaultButtonConfigurations.SaveButtonConfiguration);
            }
            if (buttons.HasFlag(DialogButtons.Close))
            {
                yield return(DefaultButtonConfigurations.CloseButtonConfiguration);
            }
        }
Exemplo n.º 3
0
 ///<inheritdoc/>
 public void ShowModal(string title, string text, DialogButtons buttons, Action <DialogResult> callback)
 {
     Title    = title;
     Text     = text;
     Buttons  = buttons;
     Callback = callback;
 }
Exemplo n.º 4
0
        private static DialogResult showMessage(string message, DialogButtons buttons)
        {
            DebugHelper.WriteTraceEntry("DialogControl showMessage invoked");
            DialogControl control = new DialogControl();

            control._dialogresult = DialogResult.None;
            AddControlToForm(control);
            DebugHelper.WriteTraceEntry("DialogControl control to form added");
            control.Show(message, buttons);

            DebugHelper.WriteTraceEntry("DialogControl resume layout");
            DebugHelper.WriteTraceEntry("DialogControl MSG cycle beginning");
            DebugHelper.FlushTraceBuffer();

            MSG msg = new MSG();

            while (GetMessage(out msg, IntPtr.Zero, 0, 0))
            {
                TranslateMessage(ref msg);
                DispatchMessage(ref msg);

                if (control._dialogresult != DialogResult.None)
                {
                    break;
                }
            }

            RemoveControlFromForm(control);
            DialogResult res = control._dialogresult;

            control.Dispose();

            return(res);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Показать сообщение с текстом и кнопками
        /// </summary>
        /// <param name="message"></param>
        /// <param name="buttons"></param>
        private void Show(string message, DialogButtons buttons)
        {
            DebugHelper.WriteTraceEntry("Menu Hiding");

            /*
             * button1.Size = new Size(UISettings.CalcPix(button1.Width), UISettings.CalcPix(button1.Height));
             * button2.Size = new Size(UISettings.CalcPix(button2.Width), UISettings.CalcPix(button2.Height));
             * button3.Size = new Size(UISettings.CalcPix(button3.Width), UISettings.CalcPix(button3.Height));
             */
            if (((UIViewBase)ViewManager.CurrentView).HaveWinFormsControls)
            {
                CreateScreenshot();
            }
            else
            {
                PrepareBackground();
            }
            _menu            = _masterForm.Menu;
            _masterForm.Menu = null;
            DebugHelper.WriteTraceEntry("Menu Hide");
            DebugHelper.WriteTraceEntry("Call overloaded Show()");
            //PrepareBackground();
            DebugHelper.WriteTraceEntry("Background prepared");

            DebugHelper.WriteTraceEntry("Canvas pre suspended");
            Canvas.SuspendLayout();
            switch (buttons)
            {
            case DialogButtons.OK:
                button1.Visible      = true;
                button2.Visible      = false;
                button3.Visible      = false;
                button1.Text         = "OK";
                _button1DialogResult = DialogResult.OK;
                break;

            case DialogButtons.YesNo:
                button1.Visible      = true;
                button2.Visible      = true;
                button3.Visible      = false;
                button1.Text         = Resources.Yes;
                button2.Text         = Resources.No;
                _button1DialogResult = DialogResult.Yes;
                _button2DialogResult = DialogResult.No;
                break;
            }
            DebugHelper.WriteTraceEntry("Canvas pre resumed");
            //this.Canvas.RecalcDPIScaling();
            Canvas.ResumeLayout();
            DebugHelper.WriteTraceEntry("Canvas resumed");

            _message = message;
            initImages();
            CalcContentRectangle();
            //button1.Location = new Point((ClientRectangle.Width - button1.Width)/2, ClientRectangle.Height/10*7);

            MessageBeep(32);
            DebugHelper.WriteTraceEntry("Start before Show()");
            Show();
        }
Exemplo n.º 6
0
        /// <summary>
        /// Gets the correct dialog layout for the provided button enum.
        /// </summary>
        /// <param name="buttons">An enumeration containing the possible button arrangements.</param>
        /// <returns>An usercontrol that provides the dialog layout.</returns>
        private UserControl GetDialogLayout(DialogButtons buttons)
        {
            switch (buttons)
            {
                case DialogButtons.Ok:
                    return new OkLayout();

                case DialogButtons.OkCancel:
                    return new OkCancelLayout();

                case DialogButtons.AbortRetryIgnore:
                    return new AbortRetryIgnoreLayout();

                case DialogButtons.YesNoCancel:
                    return new YesNoCancelLayout();

                case DialogButtons.YesNo:
                    return new YesNoLayout();

                case DialogButtons.RetryCancel:
                    return new RetryCancelLayout();

                default:
                    return null;
            }
        }
Exemplo n.º 7
0
        async public Task <DialogResult> ShowAsync(string message, string title, DialogButtons buttons)
        {
            if (string.IsNullOrEmpty(message))
            {
                throw new ArgumentException(
                          "The specified message cannot be null or empty.", "message");
            }
            if (string.IsNullOrEmpty(title))
            {
                throw new ArgumentException(
                          "The specified title cannot be null or empty.", "title");
            }
            MessageBoxResult result = MessageBoxResult.None;

            // Determine whether the calling thread is the thread
            // associated with the Dispatcher.
            if (this.Dispatcher.CheckAccess())
            {
                result = MessageBox.Show(message, title, (MessageBoxButton)buttons);
            }
            else
            {
                // Execute asynchronously on the thread the Dispatcher is associated with.
                await this.Dispatcher.InvokeAsync(() =>
                {
                    result = MessageBox.Show(message, title,
                                             (MessageBoxButton)buttons);
                });
            }

            return((DialogResult)result);
        }
Exemplo n.º 8
0
 public void InitilizeButtonChoices(DialogButtons buttons)
 {
     Buttons = buttons;
     if ((buttons == DialogButtons.Ok) || (buttons == DialogButtons.OkCancel))
     {
         TextBlockButton buttonOk =
             SetButton(new TextBlockButton(), "buttonOk", "Ok");
         buttonOk.Click += buttonOk_Selected;
         stackPanel.Children.Add(buttonOk);
     }
     if (buttons == DialogButtons.OkCancel)
     {
         TextBlockButton buttonCancel =
             SetButton(new TextBlockButton(), "buttonCancel", "Cancel");
         buttonCancel.Click += buttonCancel_Selected;
         stackPanel.Children.Add(buttonCancel);
     }
     if (buttons == DialogButtons.YesNo)
     {
         TextBlockButton buttonYes =
             SetButton(new TextBlockButton(), "buttonYes", "Yes");
         buttonYes.Click += buttonYes_Selected;
         stackPanel.Children.Add(buttonYes);
     }
     if (buttons == DialogButtons.YesNo)
     {
         TextBlockButton buttonNo =
             SetButton(new TextBlockButton(), "buttonNo", "No");
         buttonNo.Click += buttonCancel_Selected;
         stackPanel.Children.Add(buttonNo);
     }
     stackPanel.UpdateLayout();
 }
Exemplo n.º 9
0
        private void SetupButtons(DialogButtons buttons)
        {
            switch (buttons)
            {
            case DialogButtons.Default:
                OKButton.Visibility     = Visibility.Collapsed;
                CancelButton.Visibility = Visibility.Collapsed;
                YesButton.Visibility    = Visibility.Collapsed;
                NoButton.Visibility     = Visibility.Collapsed;
                break;

            case DialogButtons.OKCancel:
                DefaultOKButton.Visibility = Visibility.Collapsed;
                OKButton.Visibility        = Visibility.Visible;
                CancelButton.Visibility    = Visibility.Visible;
                break;

            case DialogButtons.OKOnly:
                DefaultOKButton.Visibility = Visibility.Collapsed;
                OKButton.Visibility        = Visibility.Visible;
                break;

            case DialogButtons.YesNo:
                DefaultOKButton.Visibility = Visibility.Collapsed;
                YesButton.Visibility       = Visibility.Visible;
                NoButton.Visibility        = Visibility.Visible;
                break;
            }
        }
Exemplo n.º 10
0
        /// <summary>
        /// Creates string for some predefined buttons (English)
        /// </summary>
        /// <param name="buttons">DialogButtons enumeration value</param>
        /// <returns>String array for desired buttons</returns>
        public static string[] GetButtonDefaultStrings(DialogButtons buttons)
        {
            switch (buttons)
            {
            case DialogButtons.Ok:
                return(new string[] { "Ok" });

            case DialogButtons.OkCancel:
                return(new string[] { "Ok", "Cancel" });

            case DialogButtons.YesNo:
                return(new string[] { "Yes", "No" });

            case DialogButtons.YesNoCancel:
                return(new string[] { "Yes", "No", "Cancel" });

            case DialogButtons.RetryCancel:
                return(new string[] { "Retry", "Cancel" });

            case DialogButtons.AbortRetryIgnore:
                return(new string[] { "Abort", "Retry", "Ignore" });

            default:
                throw new InvalidOperationException("There are no default string translations for this button configuration.");
            }
        }
        public DialogWindowWithButton(string content, DialogButtons dialogButtons, bool hideInputTextBox = false)
        {
            InitializeComponent();
            ContentTextBlock.Text = content;
            if (Global.FontFamily != null)
            {
                FontFamily = Global.FontFamily;
            }
            switch (dialogButtons)
            {
            case DialogButtons.OK:
                CancelButton.Visibility = Visibility.Collapsed;
                break;

            case DialogButtons.Cancel:
                OKButton.Visibility = Visibility.Collapsed;
                break;

            case DialogButtons.OKCancel:
                break;
            }
            if (hideInputTextBox)
            {
                InputTextBox.Visibility = Visibility.Collapsed;
                Grid.SetRowSpan(ContentTextBlock, 2);
            }
        }
Exemplo n.º 12
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            DialogButtons buttons = (DialogButtons)value;

            switch (ButtonType)
            {
            case DialogButton.Ok:
            {
                if ((buttons & DialogButtons.Ok) == DialogButtons.Ok)
                {
                    return(Visibility.Visible);
                }
                else
                {
                    return(Visibility.Collapsed);
                }
            }

            case DialogButton.Cancel:
            {
                if ((buttons & DialogButtons.Cancel) == DialogButtons.Cancel)
                {
                    return(Visibility.Visible);
                }
                else
                {
                    return(Visibility.Collapsed);
                }
            }

            default:
                throw new NotImplementedException();
            }
        }
Exemplo n.º 13
0
        /// <summary>
        /// Displays the specified content in a child window.
        /// </summary>
        /// <param name="content">The content to be displayed.</param>
        /// <param name="buttons">One of the <see cref="DialogButtons" /> values that specifies which buttons to display in the message box.</param>
        /// <param name="callback">The delegate that is called when the dialog box closes.</param>
        public void Show(object content, DialogButtons buttons, DialogCompletedDelegate callback)
        {
            Argument.IsNotNull("content", content);
            this.VerifyAccess();

            HostDialogWindow dialog = new HostDialogWindow();

            // store a reference to the content in the tag, so we can
            // return it to the caller in the callback method.
            dialog.Tag = content;

            UserControl uc = this.GetDialogLayout(buttons);
            if (uc != null)
            {
                uc.DataContext = content;
                dialog.Content = uc;
            }
            else
            {
                dialog.Content = content;
            }

            dialog.CompletedCallback = callback;
            dialog.Show();
        }
Exemplo n.º 14
0
        public static void Show(string msg, string title = null, DialogButtons buttons = DialogButtons.YesNo)
        {
            if (title != null)
            {
                MsgForm.Title = title;
            }
            _lastClickedButton = DialogButton.None;
            byte[] bytes = Encoding.Default.GetBytes(msg);
            string text  = Encoding.UTF8.GetString(bytes);

            MsgLabel.Text       = text;
            YesButton.Click    += YesButton_Click;
            NoButton.Click     += NoButton_Click;
            CancelButton.Click += CancelButton_Click;

            if (buttons == DialogButtons.YesNoCancel)
            {
                CancelButton.Visible = true;
            }
            else
            {
                CancelButton.Visible = false;
            }

            Visible = true;
        }
Exemplo n.º 15
0
        public DialogForm(DialogBase content, DialogButtons buttons)
            : this(content)
        {
            bool btnOK = (buttons & DialogButtons.Ok) == DialogButtons.Ok;
            bool btnCancel = (buttons & DialogButtons.Cancel) == DialogButtons.Cancel;
            bool btnApply = (buttons & DialogButtons.Apply) == DialogButtons.Apply;

            if(!btnApply)
            {
                if(!btnCancel)
                {
                    _btnOK.Left = _btnApply.Left;
                }
                else
                {
                    _btnOK.Left = _btnCancel.Left;
                    _btnCancel.Left = _btnApply.Left;
                }
            }
            else
            {
                if(!btnCancel)
                {
                    _btnOK.Left = _btnCancel.Left;
                }
            }
            _btnOK.Visible = btnOK;
            _btnCancel.Visible = btnCancel;
            _btnApply.Visible = btnApply;
        }
Exemplo n.º 16
0
        public DialogForm(DialogBase content, DialogButtons buttons)
            : this(content)
        {
            bool btnOK     = (buttons & DialogButtons.Ok) == DialogButtons.Ok;
            bool btnCancel = (buttons & DialogButtons.Cancel) == DialogButtons.Cancel;
            bool btnApply  = (buttons & DialogButtons.Apply) == DialogButtons.Apply;

            if (!btnApply)
            {
                if (!btnCancel)
                {
                    _btnOK.Left = _btnApply.Left;
                }
                else
                {
                    _btnOK.Left     = _btnCancel.Left;
                    _btnCancel.Left = _btnApply.Left;
                }
            }
            else
            {
                if (!btnCancel)
                {
                    _btnOK.Left = _btnCancel.Left;
                }
            }
            _btnOK.Visible     = btnOK;
            _btnCancel.Visible = btnCancel;
            _btnApply.Visible  = btnApply;
        }
Exemplo n.º 17
0
        public ServerScreen(ScreenComponent manager)
            : base(manager, new Point(400, 300))
        {
            Controls.Add(new Panel(manager)
            {
                Position = new Rectangle(20, 20, 360, 40)
            });
            Controls.Add(new Label(manager)
            {
                Text = "Server", Position = new Rectangle(40, 30, 0, 0)
            });
            Controls.Add(new LoadingIcon(manager)
            {
                Position = new Rectangle(330, 30, 32, 24)
            });

            Controls.Add(counter = new Label(manager)
            {
                Position = new Rectangle(40, 80, 0, 0)
            });

            DialogButtons buttons = new DialogButtons(manager)
            {
                Position = new Rectangle(20, 300 - 70, 360, 50)
            };

            buttons.Items.Add(cancelItem);
            buttons.Items.Add(startItem);
            Controls.Add(buttons);

            buttons.SelectedItem = cancelItem;

            buttons.OnInteract += OnInteract;
        }
Exemplo n.º 18
0
        private void SelectedButton(DialogButtons db)
        {
            switch (db)
            {
            case DialogButtons.Ok:
                SetButtonVisibility(true, false, false, false, false, false);
                break;

            case DialogButtons.OkCancel:
                SetButtonVisibility(true, false, false, false, false, true);
                break;

            case DialogButtons.YesNoCancel:
                SetButtonVisibility(false, true, true, false, false, true);
                break;

            case DialogButtons.YesNo:
                SetButtonVisibility(false, true, true, false, false, false);
                break;

            case DialogButtons.ApplyCancel:
                SetButtonVisibility(false, false, false, true, false, true);
                break;

            case DialogButtons.SaveCancel:
                SetButtonVisibility(false, false, false, false, true, true);
                break;
            }
        }
Exemplo n.º 19
0
 public static void QueueAlert(string message, DialogButtons dialogButtons = DialogButtons.Ok)
 {
     if (!IsEnabled)
     {
         return;
     }
     Alerts.Enqueue(new Alert(message, dialogButtons));
 }
Exemplo n.º 20
0
        /// <summary>
        /// Configures the BloxDialogViewModel.
        /// </summary>
        public void Configure(string header, string message, DialogButtons buttons, Action onButtonOneClick, Action onButtonTwoClick)
        {
            DialogHeader  = header;
            DialogMessage = message;

            OnButtonOneAction = onButtonOneClick;
            OnButtonTwoAction = onButtonTwoClick;
        }
Exemplo n.º 21
0
        /// <summary>
        ///     Shows a dialog.
        /// </summary>
        /// <param name="message">The message.</param>
        /// <param name="dialogButtons">The buttons to display.</param>
        /// <returns>
        ///     the dialog result.
        /// </returns>
        public DialogResult ShowDialog(string message, DialogButtons dialogButtons)
        {
            var viewModel = new MessageBoxViewModel(ApplicationInfo.ProductTitle, message, dialogButtons);

            this._windowManager.ShowDialog(viewModel);

            return(viewModel.DialogResult);
        }
Exemplo n.º 22
0
 public PopupDialog(string message, string header, DialogButtons buttons)
 {
     InitializeComponent();
     MessageText.Text     = message;
     MessageHeader.Header = header;
     SetupButtons(buttons);
     new Helpers.UIScaler(this);
 }
Exemplo n.º 23
0
 /// <summary>
 /// Default Constructor that initializes this form
 /// </summary>
 /// <param name="type">Type of this form</param>
 /// <param name="buttons">Buttons to show for user</param>
 /// <param name="title">Title of this form</param>
 /// <param name="message">Message to show for user</param>
 public DialogForm( DialogType type, DialogButtons buttons, string title, string message )
 {
     InitializeComponent();
     this.Title = title;
     this.txtMessage.Text = message;
     ConfigureButtons( buttons );
     ConfigureIcon( type );
 }
Exemplo n.º 24
0
        public static Task <DialogResult?> OpenTextDialog(this IDialogService dialogService, string title,
                                                          string text, DialogButtons buttons, bool showDontAsk = false)
        {
            // create view model
            var viewModel = new DialogTextViewModel(title, text, buttons, showDontAsk);

            // return dialog
            return(dialogService.Show <DialogText>(viewModel));
        }
        public static IEnumerable <DialogCommand> GetCommands(this DialogButtons dialogButtons)
        {
            var okCommand = new DialogCommand {
                Text = "_OK", Result = MessageBoxResult.OK
            };
            var cancelCommand = new DialogCommand {
                Text = "_Cancel", Result = MessageBoxResult.Cancel, IsDefault = true
            };
            var noCommand = new DialogCommand {
                Text = "_No", Result = MessageBoxResult.No
            };
            var yesCommand = new DialogCommand {
                Text = "_Yes", Result = MessageBoxResult.Yes
            };

            switch (dialogButtons)
            {
            case DialogButtons.Ok:
                okCommand.IsDefault = true;
                yield return(okCommand);

                break;

            case DialogButtons.OkCancel:
                yield return(okCommand);

                yield return(cancelCommand);

                break;

            case DialogButtons.YesNoCancel:
                yield return(yesCommand);

                yield return(noCommand);

                yield return(cancelCommand);

                break;

            case DialogButtons.YesNo:
                noCommand.IsDefault = true;
                yield return(yesCommand);

                yield return(noCommand);

                break;

            case DialogButtons.None:
                break;

            case DialogButtons.Custom:
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(dialogButtons), dialogButtons, null);
            }
        }
Exemplo n.º 26
0
        public DialogTextViewModel(string title, string content, DialogButtons buttons, bool showCheckbox)
        {
            Title   = title;
            Content = content;

            OkButtonVisibility     = buttons.HasFlag(DialogButtons.Ok) ? Visibility.Visible : Visibility.Collapsed;
            NoButtonVisibility     = buttons.HasFlag(DialogButtons.No) ? Visibility.Visible : Visibility.Collapsed;
            CancelButtonVisibility = buttons.HasFlag(DialogButtons.Cancel) ? Visibility.Visible : Visibility.Collapsed;
            CheckboxVisibility     = showCheckbox ? Visibility.Visible : Visibility.Collapsed;
        }
Exemplo n.º 27
0
        public static DialogButton?Show(string message, DialogButtons dialogButtons = DialogButtons.Ok)
        {
            if (!IsEnabled)
            {
                return(null);
            }
            Window window = Application.Current.Windows.Cast <Window>().SingleOrDefault(x => x.IsActive);

            return(PosDialogWindow.ShowDialog(message, Types.Strings.ManagerAlert, dialogButtons));
        }
Exemplo n.º 28
0
 public static DialogResult DisplayDialog(string message, string caption, DialogButtons buttons, int timeout)
 {
     // We won't be able to take this during a page transition.  This is good!
     // Conversly, no new pages can be navigated while this is present.
     lock (syncObj)
     {
         DialogResult result = MediaCenterEnvironment.Dialog(message, caption, buttons, timeout, true);
         return(result);
     }
 }
Exemplo n.º 29
0
        public async Task <DialogResult> ShowMessage(string message, string title,
                                                     DialogButtons buttons = DialogButtons.OkCancel)
        {
            MessageDialogStyle dialogStyle;
            var dialogSettings = new MetroDialogSettings
            {
                AnimateShow = true,
                AnimateHide = true,
                ColorScheme = MetroDialogColorScheme.Accented
            };

            switch (buttons)
            {
            case DialogButtons.YesNo:
                dialogStyle = MessageDialogStyle.AffirmativeAndNegative;
                dialogSettings.AffirmativeButtonText = "Yes";
                dialogSettings.NegativeButtonText    = "No";
                break;

            case DialogButtons.OkCancel:
                dialogStyle = MessageDialogStyle.AffirmativeAndNegative;
                dialogSettings.AffirmativeButtonText = "Ok";
                dialogSettings.NegativeButtonText    = "Cancel";
                break;

            case DialogButtons.Ok:
                dialogStyle = MessageDialogStyle.Affirmative;
                dialogSettings.AffirmativeButtonText = "Ok";
                break;

            default:
                throw new InvalidOperationException("Unknown DialogButtons option");
            }

            var dialogResult = await _window.ShowMessageAsync(title, message, dialogStyle, dialogSettings);

            switch (buttons)
            {
            case DialogButtons.YesNo:
                return(dialogResult == MessageDialogResult.Affirmative
                        ? DialogResult.Yes
                        : DialogResult.No);

            case DialogButtons.OkCancel:
                return(dialogResult == MessageDialogResult.Affirmative
                        ? DialogResult.Ok
                        : DialogResult.Cancel);

            case DialogButtons.Ok:
                return(DialogResult.Ok);

            default:
                throw new InvalidOperationException();
            }
        }
Exemplo n.º 30
0
 /// <summary>
 /// Shows a message dialog.
 /// </summary>
 /// <param name="dialogManager"> The extended <see cref="IDialogManager"/>. </param>
 /// <param name="messageModels"> A collection of <see cref="MessageDialogModel"/>s for the dialog. </param>
 /// <param name="buttons"> The <see cref="DialogButtons"/> to display. Default is <see cref="DialogButtons.Ok"/>. </param>
 /// <param name="displayLocation"> The <see cref="DialogDisplayLocation"/> of the dialog. Default is <see cref="DialogDisplayLocation.Window"/>. </param>
 /// <param name="displayBehavior"> The <see cref="DialogDisplayBehavior"/> of the dialog. Default is <see cref="DialogDisplayBehavior.Show"/>. </param>
 /// <param name="dialogOptions"> The <see cref="DialogOptions"/> of the dialog. Default is <see cref="DialogOptions.None"/>. </param>
 /// <param name="cancellationToken"> An external <see cref="CancellationToken"/> used to cancel the dialog. </param>
 /// <returns> An awaitable <see cref="DialogTask"/>. </returns>
 public static DialogTask ShowMessage
 (
     this IDialogManager dialogManager,
     ICollection <MessageDialogModel> messageModels,
     DialogButtons buttons = DialogButtons.Ok,
     DialogDisplayLocation displayLocation = DialogDisplayLocation.Window,
     DialogDisplayBehavior displayBehavior = DialogDisplayBehavior.Show,
     DialogOptions dialogOptions           = DialogOptions.None,
     CancellationToken cancellationToken   = default
 )
 => dialogManager.ShowMessage(messageModels, DefaultButtonConfigurations.GetConfiguration(buttons), displayLocation, displayBehavior, dialogOptions, cancellationToken);
Exemplo n.º 31
0
        public LulDialogResult Show(string title, string message, DialogButtons messageBoxButtons)
        {
            DataContext = new MessageBoxViewModel(title, message, messageBoxButtons);

            ShowDialog();

            return(new LulDialogResult
            {
                DialogResult = DialogResult
            });
        }
Exemplo n.º 32
0
 /// <summary>
 /// Shows a message dialog.
 /// </summary>
 /// <param name="dialogManager"> The extended <see cref="IDialogManager"/>. </param>
 /// <param name="messageModel"> The <see cref="MessageDialogModel"/> of the dialog. </param>
 /// <param name="buttons"> The <see cref="DialogButtons"/> to display. Default is <see cref="DialogButtons.Ok"/>. </param>
 /// <param name="displayLocation"> The <see cref="DialogDisplayLocation"/> of the dialog. Default is <see cref="DialogDisplayLocation.Window"/>. </param>
 /// <param name="displayBehavior"> The <see cref="DialogDisplayBehavior"/> of the dialog. Default is <see cref="DialogDisplayBehavior.Show"/>. </param>
 /// <param name="dialogOptions"> The <see cref="DialogOptions"/> of the dialog. Default is <see cref="DialogOptions.None"/>. </param>
 /// <param name="cancellationToken"> An external <see cref="CancellationToken"/> used to cancel the dialog. </param>
 /// <returns> An awaitable <see cref="DialogTask"/>. </returns>
 public static DialogTask ShowMessage
 (
     this IDialogManager dialogManager,
     MessageDialogModel messageModel,
     DialogButtons buttons = DialogButtons.Ok,
     DialogDisplayLocation displayLocation = DialogDisplayLocation.Window,
     DialogDisplayBehavior displayBehavior = DialogDisplayBehavior.Show,
     DialogOptions dialogOptions           = DialogOptions.None,
     CancellationToken cancellationToken   = default
 )
 => dialogManager.ShowMessage(new[] { messageModel }, buttons, displayLocation, displayBehavior, dialogOptions, cancellationToken);
Exemplo n.º 33
0
        protected virtual IDialogOption CreateDialogOption <TView>(string title, object dataContext, object parameters,
                                                                   DialogButtons buttons = DialogButtons.OkCancel)
        {
            var view = GetView <TView>();

            if (dataContext != null)
            {
                view.DataContext = dataContext;
            }
            return(CreateDialogOption(title, view, parameters, buttons));
        }
Exemplo n.º 34
0
        public static DialogButton Show(string message,
                                        string messageTitle         = "Info",
                                        DialogButtons dialogButtons = DialogButtons.Ok,
                                        DialogType dialogType       = DialogType.Info)
        {
            using (var msg = new FlatMessageBox(message, messageTitle, dialogButtons, dialogType))
            {
                msg.ShowDialog();

                return(msg.SelectedDialogButton);
            }
        }
Exemplo n.º 35
0
        public ClientScreen(ScreenComponent manager) : base(manager, new Point(400, 360))
        {
            Controls.Add(new Panel(manager) { Position = new Rectangle(20, 20, 360, 40) });
            Controls.Add(new Label(manager) { Text = "Verbinden", Position = new Rectangle(40, 30, 0, 0) });
            Controls.Add(new LoadingIcon(manager) { Position = new Rectangle(330, 30, 32, 24) });

            Controls.Add(status = new Label(manager) { Position = new Rectangle(40, 80, 0, 0) });

            DialogButtons buttons = new DialogButtons(manager) { Position = new Rectangle(20, 300 - 70, 360, 50) };
            buttons.Items.Add(cancelItem);
            Controls.Add(buttons);

            buttons.SelectedItem = cancelItem;

            buttons.OnInteract += OnInteract;
        }
Exemplo n.º 36
0
 /// <summary>
 /// This method configure the buttons of this window according the buttons that was sent by parameter
 /// </summary>
 /// <param name="buttons">Buttons Type</param>
 private void ConfigureButtons( DialogButtons buttons )
 {
     switch ( buttons )
     {
         case DialogButtons.ok:
             btnCancelNo.Visibility = Visibility.Collapsed;
             btnOkYes.Focus();
             break;
         case DialogButtons.yes_no:
             txtCancelNo.Text = "No";
             txtOkYes.Text = "Yes";
             btnCancelNo.Focus();
             break;
         default:
             btnCancelNo.Focus();
             break;
     }
 }
Exemplo n.º 37
0
        /// <summary>
        ///     Shows a dialog.
        /// </summary>
        /// <param name="message">The message.</param>
        /// <param name="dialogButtons">The buttons to display.</param>
        /// <returns>
        ///     the dialog result.
        /// </returns>
        public DialogResult ShowDialog(string message, DialogButtons dialogButtons)
        {
            var viewModel = new MessageBoxViewModel(ApplicationInfo.ProductTitle, message, dialogButtons);

            this._windowManager.ShowDialog(viewModel);

            return viewModel.DialogResult;
        }
Exemplo n.º 38
0
        //Показать сообщение с кнопками
        public static DialogResult ShowQuery(string message, DialogButtons buttons)
        {
            DebugHelper.WriteTraceEntry("----------");
            DebugHelper.WriteTraceEntry("ShowQuery called");

            (new InputPanel()).Enabled = false;
            //using (new WaitWrapper(true))
            {
                DebugHelper.WriteTraceEntry("ShowQuery beginning");
                if (_masterForm == null)
                    throw new ApplicationException("DialogControl not initialized.");

                if (_masterForm.InvokeRequired)
                {
                    return
                        (DialogResult)
                        _masterForm.Invoke((showMessageDelegate)showMessage, new object[] { message, buttons });
                }
                else
                {
                    return showMessage(message, buttons);
                }
            }
        }
Exemplo n.º 39
0
 public static DialogResult DisplayDialog(string message, string caption, DialogButtons buttons, int timeout)
 {
     Debug.Assert(Microsoft.MediaCenter.UI.Application.ApplicationThread == Thread.CurrentThread);
     // We won't be able to take this during a page transition.  This is good!
     // Conversly, no new pages can be navigated while this is present.
     lock (syncObj)
     {
         DialogResult result = MediaCenterEnvironment.Dialog(message, caption, buttons, timeout, true);
         return result;
     }
 }
 /// <summary>
 ///     Initialisiert eine neue Instanz der <see cref="T:System.Object" />-Klasse.
 /// </summary>
 /// <param name="subject">The subject.</param>
 /// <param name="message">The message.</param>
 /// <param name="dialogButtons">The message box buttons.</param>
 public MessageBoxViewModel(string subject, string message, DialogButtons dialogButtons = DialogButtons.OK)
 {
     Subject = subject;
     Message = message;
     DialogButtons = dialogButtons;
 }
Exemplo n.º 41
0
        private static DialogResult showMessage(string message, DialogButtons buttons)
        {
            DebugHelper.WriteTraceEntry("DialogControl showMessage invoked");
            DialogControl control = new DialogControl();
            control._dialogresult = DialogResult.None;
            AddControlToForm(control);
            DebugHelper.WriteTraceEntry("DialogControl control to form added");
            control.Show(message, buttons);

            DebugHelper.WriteTraceEntry("DialogControl resume layout");
            DebugHelper.WriteTraceEntry("DialogControl MSG cycle beginning");
            DebugHelper.FlushTraceBuffer();

            MSG msg = new MSG();
            while (GetMessage(out msg, IntPtr.Zero, 0, 0))
            {
                TranslateMessage(ref msg);
                DispatchMessage(ref msg);

                if (control._dialogresult != DialogResult.None)
                    break;
            }

            RemoveControlFromForm(control);
            DialogResult res = control._dialogresult;
            control.Dispose();

            return res;
        }
Exemplo n.º 42
0
        /// <summary>
        /// Показать сообщение с текстом и кнопками
        /// </summary>
        /// <param name="message"></param>
        /// <param name="buttons"></param>
        private void Show(string message, DialogButtons buttons)
        {
            DebugHelper.WriteTraceEntry("Menu Hiding");
            /*
            button1.Size = new Size(UISettings.CalcPix(button1.Width), UISettings.CalcPix(button1.Height));
            button2.Size = new Size(UISettings.CalcPix(button2.Width), UISettings.CalcPix(button2.Height));
            button3.Size = new Size(UISettings.CalcPix(button3.Width), UISettings.CalcPix(button3.Height));
            */
            if (((UIViewBase)ViewManager.CurrentView).HaveWinFormsControls)
                CreateScreenshot();
            else
                PrepareBackground();
            _menu = _masterForm.Menu;
            _masterForm.Menu = null;
            DebugHelper.WriteTraceEntry("Menu Hide");
            DebugHelper.WriteTraceEntry("Call overloaded Show()");
            //PrepareBackground();
            DebugHelper.WriteTraceEntry("Background prepared");

            DebugHelper.WriteTraceEntry("Canvas pre suspended");
            Canvas.SuspendLayout();
            switch (buttons)
            {
                case DialogButtons.OK:
                    button1.Visible = true;
                    button2.Visible = false;
                    button3.Visible = false;
                    button1.Text = "OK";
                    _button1DialogResult = DialogResult.OK;
                    break;
                case DialogButtons.YesNo:
                    button1.Visible = true;
                    button2.Visible = true;
                    button3.Visible = false;
                    button1.Text = Resources.Yes;
                    button2.Text = Resources.No;
                    _button1DialogResult = DialogResult.Yes;
                    _button2DialogResult = DialogResult.No;
                    break;
            }
            DebugHelper.WriteTraceEntry("Canvas pre resumed");
            //this.Canvas.RecalcDPIScaling();
            Canvas.ResumeLayout();
            DebugHelper.WriteTraceEntry("Canvas resumed");

            _message = message;
            initImages();
            CalcContentRectangle();
            //button1.Location = new Point((ClientRectangle.Width - button1.Width)/2, ClientRectangle.Height/10*7);

            MessageBeep(32);
            DebugHelper.WriteTraceEntry("Start before Show()");
            Show();
        }
Exemplo n.º 43
0
        public DialogViewModel(string title, string message, string messageHint = null, DialogButtons buttons = DialogButtons.OK, IDialogService dialogService = null)
            : base(title, dialogService)
        {
            this.Title = title;
            this.Message = message;
            this.MessageHint = messageHint;

            if (buttons == DialogButtons.OK || buttons == DialogButtons.OKCancel)
            {
                this.PositiveButtonTitle = "_OK";
                this.NegativeButtonTitle = "_Cancel";
                this.IsPositiveButtonVisible = true;
                this.IsNegativeButtonVisible = (buttons == DialogButtons.OKCancel);
            }
            else if (buttons == DialogButtons.YesNo)
            {
                this.PositiveButtonTitle = "_Yes";
                this.NegativeButtonTitle = "_No";
                this.IsPositiveButtonVisible = true;
                this.IsNegativeButtonVisible = true;
            }
        }