public MessageBoxViewModel(string message, string title, MessageBoxButton buttons)
 {
     this.DisplayName = "";
     Title = title;
     Message = message;
     Buttons = buttons;
 }
        public ZuneMessageBox(string errorMessage, ErrorMode mode, MessageBoxButton buttons)
            : this()
        {
            InitializeComponent();

            switch (mode)
            {
                case ErrorMode.Error:
                    tbMessageTitle.Text = "ERROR";
                    break;
                case ErrorMode.Warning:
                    tbMessageTitle.Text = "WARNING";
                    break;
                case ErrorMode.Info:
                    tbMessageTitle.Text = "INFO";
                    break;
                default:
                    throw new ArgumentOutOfRangeException();
            }

            if (buttons == MessageBoxButton.YesNo)
            {
                btnOk.Content = "YES";
                btnCancel.Content = "NO";
            }

            this.imgErrorIcon.Source = new BitmapImage(new Uri(GetIconUriForErrorMode(mode), UriKind.RelativeOrAbsolute));
            this.tbErrorMessage.Text = errorMessage;
            this.tbErrorMessage.ToolTip = errorMessage;
        }
Example #3
0
		public static async Task<MessageBoxResult> ShowAsync ( string messageBoxText,
															 string caption,
															 MessageBoxButton button )
		{

			MessageDialog md = new MessageDialog ( messageBoxText, caption );
			MessageBoxResult result = MessageBoxResult.None;
			if ( button.HasFlag ( MessageBoxButton.OK ) )
			{
				md.Commands.Add ( new UICommand ( "OK",
					new UICommandInvokedHandler ( ( cmd ) => result = MessageBoxResult.OK ) ) );
			}
			if ( button.HasFlag ( MessageBoxButton.Yes ) )
			{
				md.Commands.Add ( new UICommand ( "Yes",
					new UICommandInvokedHandler ( ( cmd ) => result = MessageBoxResult.Yes ) ) );
			}
			if ( button.HasFlag ( MessageBoxButton.No ) )
			{
				md.Commands.Add ( new UICommand ( "No",
					new UICommandInvokedHandler ( ( cmd ) => result = MessageBoxResult.No ) ) );
			}
			if ( button.HasFlag ( MessageBoxButton.Cancel ) )
			{
				md.Commands.Add ( new UICommand ( "Cancel",
					new UICommandInvokedHandler ( ( cmd ) => result = MessageBoxResult.Cancel ) ) );
				md.CancelCommandIndex = ( uint ) md.Commands.Count - 1;
			}
			var op = await md.ShowAsync ();
			return result;
		}
Example #4
0
 public static MessageBoxResult Show(
     string messageBoxText,
     string caption,
     MessageBoxButton button)
 {
     return ShowCore(messageBoxText, caption, button, MessageDialogImage.None, 0);
 }
Example #5
0
        /// <summary>
        /// Displays a message box that has a message, title bar caption, and button; and that returns a result.
        /// </summary>
        /// <param name="messageBoxText">A System.String that specifies the text to display.</param>
        /// <param name="caption">A System.String that specifies the title bar caption to display.</param>
        /// <param name="button">A System.Windows.MessageBoxButton value that specifies which button or buttons to display.</param>
        /// <returns>A System.Windows.MessageBoxResult value that specifies which message box button is clicked by the user.</returns>
        public static MessageBoxResult Show(string messageBoxText, string caption, MessageBoxButton button)
        {
            CustomMessageBoxWindow msg = new CustomMessageBoxWindow(messageBoxText, caption, button);
            msg.ShowDialog();

            return msg.Result;
        }
Example #6
0
 public static MessageBoxResult Show(string messageBoxText, string caption, MessageBoxButton button, MessageBoxImage icon, MessageBoxResult defaultResult)
 {
     if (_provider != null)
         return _provider.Show(messageBoxText, caption, button, icon, defaultResult);
     else
         return MessageBox.Show(messageBoxText, caption, button, icon, defaultResult);
 }
Example #7
0
 public AlertDialogBackend()
 {
     this.buttons = MessageBoxButton.OKCancel;
     this.icon = MessageBoxImage.None;
     this.options = MessageBoxOptions.None;
     this.defaultResult = MessageBoxResult.Cancel;
 }
Example #8
0
 public MoqPopup(string headerText, string discriptionText, MessageBoxImage imageType, MessageBoxButton buttons)
 {
     Header = headerText;
     Description = discriptionText;
     ImageType = imageType;
     Buttons = buttons;
 }
Example #9
0
 public MessageBoxMessage(string text, string caption, MessageBoxButton button, Action<MessageBoxResult> resultCallback)
 {
     this.Text = text;
     this.Caption = caption;
     this.Button = button;
     this.ResultCallback = resultCallback;
 }
        private static MessageBoxResult DisplayMessage(string message, MessageBoxImage image, MessageBoxButton button, Window owner)
        {
            var dialogOwner = owner;
            var result = MessageBoxResult.None;

            if (dialogOwner != null)
            {
                if (dialogOwner.Dispatcher != null)
                {
                    dialogOwner.Dispatcher.adoptAsync(() =>
                    {
                        result = MessageBox.Show(dialogOwner, message, "MeTL", button, image);
                    });
                } else
                {
                    Application.Current.Dispatcher.adoptAsync(() =>
                    {
                        result = MessageBox.Show(dialogOwner, message, "MeTL", button, image);
                    });

                }
            }
            else
            {
                // calling from non-ui thread
                if (Application.Current != null && Application.Current.Dispatcher != null)
                    Application.Current.Dispatcher.adoptAsync(() =>
                    {
                        dialogOwner = GetMainWindow();
                        result = MessageBox.Show(dialogOwner, message, "MeTL", button, image);
                    });
            }

            return result;
        }
        public static MessageBoxResult Show(
            Action<Window> setOwner,
            string messageBoxText, 
            string caption, 
            MessageBoxButton button, 
            MessageBoxImage icon, 
            MessageBoxResult defaultResult, 
            MessageBoxOptions options)
        {
            if ((options & MessageBoxOptions.DefaultDesktopOnly) == MessageBoxOptions.DefaultDesktopOnly)
            {
                throw new NotImplementedException();
            }

            if ((options & MessageBoxOptions.ServiceNotification) == MessageBoxOptions.ServiceNotification)
            {
                throw new NotImplementedException();
            }

            _messageBoxWindow = new WpfMessageBoxWindow();

            setOwner(_messageBoxWindow);

            PlayMessageBeep(icon);

            _messageBoxWindow._viewModel = new MessageBoxViewModel(_messageBoxWindow, caption, messageBoxText, button, icon, defaultResult, options);
            _messageBoxWindow.DataContext = _messageBoxWindow._viewModel;
            _messageBoxWindow.ShowDialog();
            return _messageBoxWindow._viewModel.Result;
        }
Example #12
0
        public Task<MessageBoxResult> ShowAsync(string message, string title, MessageBoxButton buttons, MessageBoxImage image)
        {
            var tcs = new TaskCompletionSource<MessageBoxResult>();

            _dispatcherService.CurrentDispatcher.BeginInvoke(new Action(() =>
            {
                MessageBoxResult result;
                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)
                {
                    result = MessageBox.Show(activeWindow, message, title, buttons, image);
                }
                else
                {
                    result = MessageBox.Show(message, title, buttons, image);
                }

                tcs.SetResult(result);
            }));


            return tcs.Task;
        }
Example #13
0
 public MessageBoxMessage(string key, string text, string caption, MessageBoxButton button)
     : base(key)
 {
     this.Text = text;
     this.Caption = caption;
     this.Button = button;
 }
        /// <summary>
        ///     Extended MetroMessageBox.
        /// </summary>
        /// <param name="this"></param>
        /// <param name="message"></param>
        /// <param name="title"></param>
        /// <param name="buttons"></param>
        /// <param name="messageBoxType"></param>
        /// <returns></returns>
        public static MessageBoxResult ShowMetroMessageBox(this IWindowManager @this, string message, string title,
            MessageBoxButton buttons, BoxType messageBoxType = BoxType.Default)
        {
            MessageBoxResult retval;
            var shellViewModel = IoC.Get<MainViewModel>();

            try
            {
                if (shellViewModel != null)
                {
                    shellViewModel.ShowOverlay();
                }
                var model = new MetroMessageBoxViewModel(message, title, buttons, messageBoxType);
                Execute.OnUIThread(() => @this.ShowDialog(model));
                retval = model.Result;
            }
            finally
            {
                if (shellViewModel != null)
                {
                    shellViewModel.HideOverlay();
                }
            }

            return retval;
        }
Example #15
0
        public static MessageBoxResult Show(Window parent, string msg, string title, MessageBoxButton btns, MessageBoxImage icon)
        {
            // Create a callback delegate
            _hookProcDelegate = new Win32.WindowsHookProc(HookCallback);

            // Remember the title & message that we'll look for.
            // The hook sees *all* windows, so we need to make sure we operate on the right one.
            _msg = msg;
            _title = title;

            // Set the hook.
            // Suppress "GetCurrentThreadId() is deprecated" warning.
            // It's documented that Thread.ManagedThreadId doesn't work with SetWindowsHookEx()
            #pragma warning disable 0618
            _hHook = Win32.SetWindowsHookEx(Win32.WH_CBT, _hookProcDelegate, IntPtr.Zero, AppDomain.GetCurrentThreadId());
            #pragma warning restore 0618

            // Pop a standard MessageBox. The hook will center it.
             MessageBoxResult rslt;
             if (parent == null)
                 rslt = MessageBox.Show(msg, title, btns, icon);
             else
                 rslt = MessageBox.Show(parent, msg, title, btns, icon);

            // Release hook, clean up (may have already occurred)
            Unhook();

            return rslt;
        }
Example #16
0
        private static MessageChoice GetMessageChoice(MessageBoxButton button)
        {
            MessageChoice choices;
            switch (button)
            {
                case MessageBoxButton.OK:
                    choices = MessageChoice.OK;
                    break;

                case MessageBoxButton.OKCancel:
                    choices = MessageChoice.Cancel | MessageChoice.OK;
                    break;

                case MessageBoxButton.YesNoCancel:
                    choices = MessageChoice.No | MessageChoice.Yes | MessageChoice.Cancel;
                    break;

                case MessageBoxButton.YesNo:
                    choices = MessageChoice.No | MessageChoice.Yes;
                    break;

                default:
                    choices = MessageChoice.None;
                    break;
            }
            return choices;
        }
Example #17
0
        public static MessageBoxResult Show(string messageBoxText, string caption, MessageBoxButton button)
        {
            UIAlertView messageBox;
            if (button == MessageBoxButton.OKCancel)
                messageBox = new UIAlertView (caption, messageBoxText, null, "OK", "Cancel");
            else
                messageBox = new UIAlertView (caption, messageBoxText, null, "OK");
            messageBox.Show ();

            int clicked = -1;

            messageBox.Clicked += (s, buttonArgs) =>
            {
                clicked = buttonArgs.ButtonIndex;
            };
            while (clicked == -1)
            {
                NSRunLoop.Current.RunUntil (NSDate.FromTimeIntervalSinceNow (0.5));
                if (messageBox.BecomeFirstResponder() == false)
                    break;
            }

            if (clicked == 0)
                return MessageBoxResult.OK;
            else
                return MessageBoxResult.Cancel;
        }
Example #18
0
        public static MessageBoxResult Show(Window wOwner, string sMes, string sTit, MessageBoxButton iTip = MessageBoxButton.OK)
        {
            ITCMessageBox view = new ITCMessageBox();
            view.Owner = wOwner;
            if (sMes.IndexOf('\n') == -1)
            {
                while ((sMes.Length - 35) > 0)
                {
                    string sTemp = sMes.Substring(0, 35);
                    int i = sTemp.LastIndexOf(' ');
                    if (i != -1)
                    {
                        sTemp = sMes.Substring(0, i + 1);
                        string sTemp2 = sMes.Substring(i + 1, sMes.Length - (i + 1));
                        view.sMensaje += sTemp + "\n";
                        sMes = sTemp2;
                    }
                    else
                    {
                        sTemp = sMes.Substring(0, 30);
                        string sTemp2 = sMes.Substring(30, sMes.Length - 30);
                        view.sMensaje += sTemp + "\n";
                        sMes = sTemp2;
                    }
                }
            }
            view.sMensaje += sMes;
            view.iTipo = iTip;
            view.sTitulo = sTit;
            view.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterOwner;
            view.ShowDialog();

            return res;
        }
 /// <summary>
 /// <see cref="MakCraft.Behaviors.MessageDialogAction"/> へ渡すパラメーター。
 /// </summary>
 /// <param name="message"></param>
 /// <param name="caption"></param>
 /// <param name="button"></param>
 /// <param name="isDialog"></param>
 public MessageDialogActionParameter(string message, string caption, MessageBoxButton button, bool isDialog)
 {
     Message = message;
     Caption = caption;
     Button = button;
     IsDialog = isDialog;
 }
Example #20
0
        public static async Task<MessageBoxResult> ShowAsync(string messageBoxText,
            string caption,
            MessageBoxButton button = MessageBoxButton.Ok)
        {
            var result = MessageBoxResult.None;
            var md = new MessageDialog(messageBoxText, caption);

            if (button.HasFlag(MessageBoxButton.Ok))
            {
                md.Commands.Add(new UICommand("OK",
                    cmd => result = MessageBoxResult.Ok));
            }
            if (button.HasFlag(MessageBoxButton.Yes))
            {
                md.Commands.Add(new UICommand("Yes",
                    cmd => result = MessageBoxResult.Yes));
            }
            if (button.HasFlag(MessageBoxButton.No))
            {
                md.Commands.Add(new UICommand("No",
                    cmd => result = MessageBoxResult.No));
            }
            if (button.HasFlag(MessageBoxButton.Cancel))
            {
                md.Commands.Add(new UICommand("Cancel",
                    cmd => result = MessageBoxResult.Cancel));
                md.CancelCommandIndex = (uint) md.Commands.Count - 1;
            }
            try
            {
                await md.ShowAsync();
            }
            catch (UnauthorizedAccessException) { }
            return result;
        }
Example #21
0
        public MessageBox(MainWindow owner, string message, string title, MessageBoxButton button)
        {
            InitializeComponent();
            Margin = (owner.WindowState == WindowState.Maximized) ? new Thickness(0, 10, 0, 10) : new Thickness(10);

            this.Width = owner.ActualWidth;
            this.Height = 196;
            this.Left = owner.Location.X;
            this.Top = owner.Location.Y + (owner.ActualHeight - Height) / 2;

            Title.Text = title;
            Message.Text = message;
            Result = MessageBoxResult.None;

            switch (button)
            {
                case MessageBoxButton.OK:
                    ButtonGroup.Children.Remove(Yes);
                    ButtonGroup.Children.Remove(No);
                    ButtonGroup.Children.Remove(Cancel);
                    break;
                case MessageBoxButton.OKCancel:
                    ButtonGroup.Children.Remove(Yes);
                    ButtonGroup.Children.Remove(No);
                    break;
                case MessageBoxButton.YesNo:
                    ButtonGroup.Children.Remove(Okay);
                    ButtonGroup.Children.Remove(Cancel);
                    break;
                case MessageBoxButton.YesNoCancel:
                    ButtonGroup.Children.Remove(Okay);
                    break;
            }
        }
Example #22
0
        public static ICollection<DialogButtonInfo> GetButtons(MessageBoxButton button)
        {
            ICollection<DialogButtonInfo> buttons;
            switch (button)
            {
                case MessageBoxButton.OK:
                    buttons = new[] { ButtonOK };
                    break;

                case MessageBoxButton.OKCancel:
                    buttons = new[] { ButtonOK, ButtonCancel };
                    break;

                case MessageBoxButton.YesNoCancel:
                    buttons = new[] { ButtonYes, ButtonNo, ButtonCancel };
                    break;

                case MessageBoxButton.YesNo:
                    var buttonNo = ButtonNo;
                    buttonNo.IsCancel = true;
                    buttons = new[] { ButtonYes, buttonNo };
                    break;
                default:
                    throw new ArgumentOutOfRangeException(nameof(button), button, null);
            }
            return buttons;
        }
Example #23
0
 internal static MessageBoxResult ShowQuestion(string message, MessageBoxButton messageBoxButton)
 {
     return  MessageBox.Show(message,
                            "Question",
                            messageBoxButton,
                            MessageBoxImage.Question);
 }
Example #24
0
      private static OLEMSGDEFBUTTON ToOleDefault(MessageBoxResult defaultResult, MessageBoxButton button)
      {
         switch (button)
         {
            case MessageBoxButton.OK:
               return OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST;

            case MessageBoxButton.OKCancel:
               if (defaultResult == MessageBoxResult.Cancel)
                  return OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_SECOND;

               return OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST;

            case MessageBoxButton.YesNoCancel:
               if (defaultResult == MessageBoxResult.No)
                  return OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_SECOND;
               if (defaultResult == MessageBoxResult.Cancel)
                  return OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_THIRD;

               return OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST;

            case MessageBoxButton.YesNo:
               if (defaultResult == MessageBoxResult.No)
                  return OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_SECOND;

               return OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST;
         }

         return OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST;
      }
Example #25
0
 public static void Show(string msg, string caption, MessageBoxButton button, MessageImage msgImage, Action<MessageBoxResult> callback)
 {
     DialogMessage result = new DialogMessage(null, msg, callback);
     result.Caption = caption + ";" + ((int)msgImage).ToString();
     result.Button = button;
     AppMessages.SendMessage.Send(result);
 }
Example #26
0
        private static MessageBoxResult ShowCore(
            string messageBoxText,
            string caption,
            MessageBoxButton button,
            MessageDialogImage icon,
            MessageBoxResult defaultResult)
        {
            if (!IsValidMessageBoxButton(button))
            {
                throw new InvalidEnumArgumentException("button", (int)button, typeof(MessageBoxButton));
            }

            if (!IsValidMessageDialogImage(icon))
            {
                throw new InvalidEnumArgumentException("icon", (int)icon, typeof(MessageBoxImage));
            }

            if (!IsValidMessageBoxResult(defaultResult))
            {
                throw new InvalidEnumArgumentException("defaultResult", (int)defaultResult, typeof(MessageBoxResult));
            }

            var dialog = new Dialog(messageBoxText, caption, button, icon, defaultResult);
            var flag = dialog.ShowDialog();
            return flag == true ? MessageBoxResult.No : MessageBoxResult.None;
        }
 public MessageWindow(string text, MessageBoxButton buttons)
 {
     InitializeComponent();
     Message.Text = text;
     if (buttons == MessageBoxButton.OK)
     {
         AcceptButton.Content = "OK";
         AcceptButton.Visibility = Visibility.Visible;
         CancelButton.Visibility = Visibility.Hidden;
         NoButton.Visibility = Visibility.Hidden;
     }
     else if (buttons == MessageBoxButton.OKCancel)
     {
         AcceptButton.Content = "OK";
         AcceptButton.Visibility = Visibility.Visible;
         CancelButton.Visibility = Visibility.Visible;
         NoButton.Visibility = Visibility.Hidden;
     }
     else if (buttons == MessageBoxButton.YesNo)
     {
         AcceptButton.Content = "Yes";
         AcceptButton.Visibility = Visibility.Visible;
         CancelButton.Visibility = Visibility.Hidden;
         NoButton.Visibility = Visibility.Visible;
     }
     else if (buttons == MessageBoxButton.YesNoCancel)
     {
         AcceptButton.Content = "Yes";
         AcceptButton.Visibility = Visibility.Visible;
         CancelButton.Visibility = Visibility.Visible;
         NoButton.Visibility = Visibility.Visible;
     }
 }
Example #28
0
        internal static MessageBoxResult ShowResponse(string message, Response response, MessageBoxButton messageBoxButton)
        {
            MessageBoxImage messageBoxImage = MessageBoxImage.Information;
            string caption = "Information";

            if (response.HasErrors)
            {
                messageBoxImage = MessageBoxImage.Error;
                caption = "Error";
            }
            else if (response.HasWarnings)
            {
                messageBoxImage = MessageBoxImage.Warning;
                caption = "Warning";
            }
            else if (response.HasInformation)
            {
                messageBoxImage = MessageBoxImage.Information;
                caption = "Information";
            }

            string responseMessage = (response.Errors.Aggregate(string.Empty, (result, error) => string.Format("{1}{2}{0}", System.Environment.NewLine, result, error.Message)) + System.Environment.NewLine +
                                      response.Warnings.Aggregate(string.Empty, (result, error) => string.Format("{1}{2}{0}", System.Environment.NewLine, result, error.Message)) + System.Environment.NewLine +
                                      response.Information.Aggregate(string.Empty, (result, error) => string.Format("{1}{2}{0}", System.Environment.NewLine, result, error.Message))).Trim();

            return MessageBox.Show((message + System.Environment.NewLine + responseMessage).Trim(), caption, messageBoxButton, messageBoxImage);
        }
Example #29
0
 private static bool IsValidMessageBoxButton(MessageBoxButton value)
 {
     return value == MessageBoxButton.OK
         || value == MessageBoxButton.OKCancel
         || value == MessageBoxButton.YesNo
         || value == MessageBoxButton.YesNoCancel;
 }
Example #30
0
 public static void ShowAsync(string text, MessageBoxButton button = MessageBoxButton.OK,
     MessageBoxImage image = MessageBoxImage.Information, MessageBoxResult defaultButton = MessageBoxResult.OK)
 {
     new Thread(
         new ThreadStart(delegate { MessageBox.Show(text, Resources.AppName, button, image, defaultButton); }))
         .Start();
 }
Example #31
0
        public static MessageBoxResult Show(string message, string title = null, Window owner = null, MessageBoxButton messageBoxButton = MessageBoxButton.OK, string configKey = null)
        {
            MessageBoxXConfigurations messageBoxXConfigurations = null;

            if (configKey.IsNullOrEmpty())
                messageBoxXConfigurations = new MessageBoxXConfigurations();
            else
            {
                if (!MessageBoxXConfigurations.ContainsKey(configKey))
                    throw new Exception($"Configuration key \"{configKey}\" does not exists.");

                messageBoxXConfigurations = MessageBoxXConfigurations[configKey];
            }

            return CallMsgBox(owner, message, title, messageBoxButton, messageBoxXConfigurations);
        }
Example #32
0
 public MessageBoxMessage(string text, string caption, MessageBoxButton button)
     : this(text, caption, button, MessageBoxImage.None)
 {
 }
 public MessageBoxWindow(string message, string caption, MessageBoxButton buttons, MessageBoxImage image) : this(message, caption, buttons)
 {
     SetIcon(image);
 }
 public MessageBoxWindow(string message, string caption, MessageBoxButton buttons) : this(message, caption)
 {
     SetButtons(buttons);
 }
Example #35
0
 public CustomMessageBox(string title, object content, MessageBoxButton button)
 {
     this.Title            = title;
     this._content         = content;
     this.MessageBoxButton = button;
 }
Example #36
0
        private static MessageBoxResult CallMsgBox(Window owner, string message, string title, MessageBoxButton messageBoxButton, MessageBoxXConfigurations configurations)
        {
            var msb = new MsgBox(owner, message, title, messageBoxButton, configurations);

            WindowX windowX = null;

            if(configurations.InteractOwnerMask && owner != null && owner is WindowX)
                windowX = owner as WindowX;

            if(windowX != null)
                windowX.IsMaskVisible = true;
            msb.ShowDialog();
            if (windowX != null)
                windowX.IsMaskVisible = false;

            return msb.MessageBoxResult;
        }
Example #37
0
        public static MessageBoxResult Show(string message, string title = null, Window owner = null, MessageBoxButton messageBoxButton = MessageBoxButton.OK, MessageBoxXConfigurations configurations = null)
        {
            if (configurations == null)
                configurations = new MessageBoxXConfigurations();

            return CallMsgBox(owner, message, title, messageBoxButton, configurations);
        }
        public static MessageBoxResult ShowMetroMessageBox(this IWindowManager @this, string message, string title, MessageBoxButton buttons)
        {
            MessageBoxResult retval;
            var shellViewModel = IoC.Get<IShell>();

            try
            {
                shellViewModel.ShowOverlay();
                var model = new MetroMessageBoxViewModel(message, title, buttons);
                @this.ShowDialog(model);

                retval = model.Result;
            }
            finally
            {
                shellViewModel.HideOverlay();
            }

            return retval;
        }
Example #39
0
        public MessageBoxResult Show(string message, string caption, MessageBoxButton buttons)
        {
            var result = MessageBox.Show(message, caption, buttons);

            return(result);
        }
Example #40
0
 public static MessageBoxResult Show(string message, string title = null, Window owner = null, MessageBoxButton messageBoxButton = MessageBoxButton.OK)
 {
     return CallMsgBox(owner, message, title, messageBoxButton, new MessageBoxXConfigurations());
 }
Example #41
0
        private void ExecuteError(object sender, ErrorEventArgs e)
        {
            lock (this)
            {
                if (!this.root.Canceled)
                {
                    // If the error is a cancel coming from the engine during apply we want to go back to the preapply state.
                    if (InstallationState.Applying == this.root.State && (int)Error.UserCancelled == e.ErrorCode)
                    {
                        this.root.State = this.root.PreApplyState;
                    }
                    else
                    {
                        this.Message = e.ErrorMessage;

                        if (Display.Full == WixBA.Model.Command.Display)
                        {
                            // On HTTP authentication errors, have the engine try to do authentication for us.
                            if (ErrorType.HttpServerAuthentication == e.ErrorType || ErrorType.HttpProxyAuthentication == e.ErrorType)
                            {
                                e.Result = Result.TryAgain;
                            }
                            else // show an error dialog.
                            {
                                MessageBoxButton msgbox = MessageBoxButton.OK;
                                switch (e.UIHint & 0xF)
                                {
                                case 0:
                                    msgbox = MessageBoxButton.OK;
                                    break;

                                case 1:
                                    msgbox = MessageBoxButton.OKCancel;
                                    break;

                                // There is no 2! That would have been MB_ABORTRETRYIGNORE.
                                case 3:
                                    msgbox = MessageBoxButton.YesNoCancel;
                                    break;

                                case 4:
                                    msgbox = MessageBoxButton.YesNo;
                                    break;
                                    // default: stay with MBOK since an exact match is not available.
                                }

                                MessageBoxResult result = MessageBoxResult.None;
                                WixBA.View.Dispatcher.Invoke((Action) delegate()
                                {
                                    result = MessageBox.Show(WixBA.View, e.ErrorMessage, "WiX Toolset", msgbox, MessageBoxImage.Error);
                                }
                                                             );

                                // If there was a match from the UI hint to the msgbox value, use the result from the
                                // message box. Otherwise, we'll ignore it and return the default to Burn.
                                if ((e.UIHint & 0xF) == (int)msgbox)
                                {
                                    e.Result = (Result)result;
                                }
                            }
                        }
                    }
                }
                else // canceled, so always return cancel.
                {
                    e.Result = Result.Cancel;
                }
            }
        }
Example #42
0
        //Diese Funtion dient zum Testen der Felden unserer verschiedenen Formulare
        // Die liefert den Wert 1, falls alles gut passiert ist. Wenn icht, dann wird der Wert 0 ausgeliefert.
        public int testFormular(List <string> elementeListe)
        {
            //Man nimmt an, alles ist nicht ok am Anfang
            int    testResult = 1;
            string error;
            Dictionary <string, string> dict = new Dictionary <string, string>();

            foreach (string element in elementeListe)
            {
                switch (element)
                {
                case "txtBox_vornameNeuenKontaktErstellen":


                    if (txtBox_vornameNeuenKontaktErstellen.Text == "")
                    {
                        error = "Ihr Vorname muss eingegeben werden!";
                        dict.Add("txtBox_vornameNeuenKontaktErstellen", error);
                    }
                    break;

                case "txtBox_NachnameNeuenKontaktErstellen":


                    if (txtBox_nachnameNeuenKontaktErstellen.Text == "")
                    {
                        error = "Ihr Nachname muss eingegeben werden!";
                        dict.Add("txtBox_nachnameNeuenKontaktErstellen", error);
                    }
                    break;

                case "txtBox_telefonnummerNeuenKontaktErstellen":


                    if (txtBox_telefonnummerNeuenKontaktErstellen.Text == "")
                    {
                        error = "Ihre Telefonnummer muss eingegeben werden!";
                        dict.Add("txtBox_telefonnummerNeuenKontaktErstellen", error);
                    }
                    else
                    {
                        if (!Controllers.testTelefonnummer(txtBox_telefonnummerNeuenKontaktErstellen.Text))
                        {
                            error = "Das Format der Telefonnummer ist nicht korrekt. Ein Beispiel wäre: +491234567890";
                            dict.Add("txtBox_telefonnummerNeuenKontaktErstellen", error);
                        }
                    }
                    break;


                case "txtBox_emailNeuenKontaktErstellen":


                    if (txtBox_emailNeuenKontaktErstellen.Text == "")
                    {
                        error = "Die E-Mail-Adresse muss eingegeben werden!";
                        dict.Add("txtBox_emailNeuenKontaktErstellen", error);
                    }
                    else
                    {
                        if (!Controllers.testEmailAdresse(txtBox_emailNeuenKontaktErstellen.Text))
                        {
                            error = "Überprüfen Sie bitte das Format der eigegebenen E-Mail-Adresse!";
                            dict.Add("txtBox_emailNeuenKontaktErstellen", error);
                        }
                    }
                    break;
                }
            }

            int anzahlDerElemente = dict.Count;

            if (anzahlDerElemente > 0)
            {
                //Es heißt, es gibt ein Problem irgendwo
                testResult = 0;
                //string[] tmp = new string[anzahlDerElemente];
                List <string> tmpl = new List <string>();
                foreach (KeyValuePair <string, string> item in dict)
                {
                    // Console.WriteLine("Key: {0}, Value: {1}", item.Key, item.Value);
                    tmpl.Add(item.Value);

                    Console.WriteLine("Erreur au niveau de: " + item.Key + " contenu erreur: " + item.Value);
                }
                string total = "";
                for (int i = 0; i < tmpl.Count; i++)
                {
                    total = total + tmpl[i] + "\n \n";
                }
                // MessageBox.Show(total);
                // Configure message box
                string           caption = "Falsche oder Fehlende Angaben";
                MessageBoxButton buttons = MessageBoxButton.OK;
                MessageBoxImage  icon    = MessageBoxImage.Exclamation;
                // Show message box
                MessageBoxResult result = MessageBox.Show(total, caption, buttons, icon);
                //MessageBox.Show("Some text", "Some title", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            return(testResult);
        }
Example #43
0
        public static MessageBoxResult Msg(string Message, string Title = "", string Type = "I", MessageBoxButton Botones = MessageBoxButton.OK)
        {
            MessageBoxImage image = MessageBoxImage.Information;

            if (Type == "E")
            {
                image = MessageBoxImage.Error;
            }
            if (Type == "P")
            {
                image = MessageBoxImage.Question;
            }

            return(MessageBox.Show(Message, Title, Botones, image));
        }
Example #44
0
        public MessageBoxResult Show(string message, string caption, MessageBoxButton buttons, MessageBoxImage icon, MessageBoxResult defaultResult)
        {
            var result = MessageBox.Show(message, caption, buttons, icon, defaultResult);

            return(result);
        }
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrEmpty(txtInventName.Text) || string.IsNullOrEmpty(txtManuf.Text) || string.IsNullOrEmpty(txtQty.Text) || string.IsNullOrEmpty(txtProdCode.Text))
            {
                MessageBox.Show("One or more fields are empty!");
            }
            else if (txtSize.Text.Length > 0 && string.IsNullOrEmpty(cmbUnit.Text))
            {
                MessageBox.Show("Unit cannot be empty if size has value!");
                cmbUnit.Focus();
            }
            else if (process == 1)
            {
                MessageBox.Show("Search only works in junction with Edit and Delete Record, please press the reset button if you're trying to add new inventory record!");
            }
            else
            {
                string           sMessageBoxText = "Are all fields correct?";
                string           sCaption        = "Add Inventory";
                MessageBoxButton btnMessageBox   = MessageBoxButton.YesNoCancel;
                MessageBoxImage  icnMessageBox   = MessageBoxImage.Warning;

                MessageBoxResult dr = MessageBox.Show(sMessageBoxText, sCaption, btnMessageBox, icnMessageBox);
                switch (dr)
                {
                case MessageBoxResult.Yes:
                    SqlCeConnection conn = DBUtils.GetDBConnection();
                    conn.Open();
                    using (SqlCeCommand cmd1 = new SqlCeCommand("SELECT COUNT(1) from ApparatusInventory where prodCode = @prodCode", conn))
                    {
                        cmd1.Parameters.AddWithValue("@prodCode", txtProdCode.Text);
                        int count = (int)cmd1.ExecuteScalar();
                        if (count > 0)
                        {
                            MessageBox.Show("Product code already exists! Please choose another and try again.");
                        }
                        else
                        {
                            string unit = "";
                            if (cmbUnit.Text == "N/A")
                            {
                                unit = null;
                            }
                            else
                            {
                                unit = cmbUnit.Text;
                            }
                            using (SqlCeCommand cmd = new SqlCeCommand("INSERT into ApparatusInventory (prodCode, name, manuf, qty, size) VALUES (@prodCode, @inventName, @manuf, @qty, @size)", conn))
                            {
                                cmd.Parameters.AddWithValue("@prodCode", txtProdCode.Text);
                                cmd.Parameters.AddWithValue("@inventName", txtInventName.Text);
                                cmd.Parameters.AddWithValue("@manuf", txtManuf.Text);
                                cmd.Parameters.AddWithValue("@qty", txtQty.Text);
                                if (!string.IsNullOrEmpty(txtSize.Text))
                                {
                                    cmd.Parameters.AddWithValue("@size", txtSize.Text + unit);
                                }
                                else
                                {
                                    cmd.Parameters.AddWithValue("@size", DBNull.Value);
                                }

                                try
                                {
                                    cmd.ExecuteNonQuery();
                                    MessageBox.Show("Added Successfully");
                                    Log = LogManager.GetLogger("addNewApparatus");
                                    Log.Info("Item " + txtProdCode.Text + " has been added to database!");
                                    emptyFields();
                                }
                                catch (SqlCeException ex)
                                {
                                    MessageBox.Show("Error! Log has been updated with the error. ");
                                    Log = LogManager.GetLogger("*");
                                    Log.Error(ex);
                                }
                            }
                        }
                    }
                    break;

                case MessageBoxResult.No: break;
                }
            }
        }
Example #46
0
        public static MessageBoxResult Show(string messageBoxText, FrameworkElement messageBoxContent, MessageBoxButton button)
        {
            MessageBoxWindow msg = new MessageBoxWindow(messageBoxText, messageBoxContent, button);

            _ = msg.ShowDialog();

            msg.RestoreAutoscanList();
            return(msg.Result);
        }
Example #47
0
 public static MessageBoxResult Show(Window owner, string text, string caption, MessageBoxButton buttons, MessageBoxImage icon, MessageBoxResult defResult)
 {
     _owner = new WindowInteropHelper(owner).Handle;
     Initialize();
     return(MessageBox.Show(owner, text, caption, buttons, icon, defResult));
 }
        private void btnDelete_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrEmpty(txtInventName.Text))
            {
                MessageBox.Show("Inventory name field is empty!");
                txtInventName.Focus();
            }
            else if (string.IsNullOrEmpty(txtManuf.Text))
            {
                MessageBox.Show("Manufacturer field is empty!");
                txtManuf.Focus();
            }
            else
            {
                if (process == 1)
                {
                    string           sMessageBoxText = "Do you want to delete this record?";
                    string           sCaption        = "Delete Inventory record";
                    MessageBoxButton btnMessageBox   = MessageBoxButton.YesNoCancel;
                    MessageBoxImage  icnMessageBox   = MessageBoxImage.Warning;

                    MessageBoxResult dr = MessageBox.Show(sMessageBoxText, sCaption, btnMessageBox, icnMessageBox);
                    switch (dr)
                    {
                    case MessageBoxResult.Yes:
                        SqlCeConnection conn = DBUtils.GetDBConnection();
                        conn.Open();
                        using (SqlCeCommand cmd = new SqlCeCommand("INSERT into ArchiveApparatusInventory (prodCode, name, qty, size, manuf) SELECT prodCode, name, qty, size, manuf from ApparatusInventory where name = @inventName and manuf = @manuf", conn))
                        {
                            cmd.Parameters.AddWithValue("@inventName", txtInventName.Text);
                            cmd.Parameters.AddWithValue("@manuf", txtManuf.Text);
                            int result = cmd.ExecuteNonQuery();
                            if (result > 0)
                            {
                                using (SqlCeCommand command = new SqlCeCommand("DELETE from ApparatusInventory where name = @inventName and manuf = @manuf", conn))
                                {
                                    command.Parameters.AddWithValue("@inventName", txtInventName.Text);
                                    command.Parameters.AddWithValue("@manuf", txtManuf.Text);

                                    int query = command.ExecuteNonQuery();
                                    MessageBox.Show("Item has been deleted!");
                                    Log = LogManager.GetLogger("deleteApparatus");
                                    Log.Info("Item " + txtProdCode.Text + " has been archived!");
                                    emptyFields();
                                    enableFields();
                                    process = 0;
                                }
                            }
                            else
                            {
                                MessageBox.Show("Item does not exist!");
                            }
                        }
                        break;

                    case MessageBoxResult.No:
                        break;
                    }
                }
                else
                {
                    MessageBox.Show("Please search the inventory item first before deleting any record!");
                }
            }
        }
Example #49
0
 public static MessageBoxResult Show(string text, string caption, MessageBoxButton buttons)
 {
     Initialize();
     return(MessageBox.Show(text, caption, buttons));
 }
        private void btnEdit_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrEmpty(txtInventName.Text) || string.IsNullOrEmpty(cmbUnit.Text))
            {
                MessageBox.Show("One or more field is empty!");
            }
            else if (txtSize.Text.Length > 0 && string.IsNullOrEmpty(cmbUnit.Text))
            {
                MessageBox.Show("Unit cannot be empty if size has value!");
                cmbUnit.Focus();
            }
            else if (cmbUnit.Text.Length > 0 && string.IsNullOrEmpty(txtSize.Text))
            {
                MessageBox.Show("Size cannot be empty if unit has value!");
                txtSize.Focus();
            }
            else
            {
                if (process == 1)
                {
                    string           sMessageBoxText = "Do you want to update the record?";
                    string           sCaption        = "Edit Record";
                    MessageBoxButton btnMessageBox   = MessageBoxButton.YesNoCancel;
                    MessageBoxImage  icnMessageBox   = MessageBoxImage.Warning;

                    MessageBoxResult dr = MessageBox.Show(sMessageBoxText, sCaption, btnMessageBox, icnMessageBox);
                    switch (dr)
                    {
                    case MessageBoxResult.Yes:
                        SqlCeConnection conn = DBUtils.GetDBConnection();
                        conn.Open();
                        using (SqlCeCommand cmd = new SqlCeCommand("UPDATE ApparatusInventory set size = @size where name = @inventName and manuf = @manuf and prodCode = @prodCode", conn))
                        {
                            cmd.Parameters.AddWithValue("@size", txtSize.Text + cmbUnit.Text);
                            cmd.Parameters.AddWithValue("@inventName", txtInventName.Text);
                            cmd.Parameters.AddWithValue("@manuf", txtManuf.Text);
                            cmd.Parameters.AddWithValue("@prodCode", txtProdCode.Text);

                            try
                            {
                                cmd.ExecuteNonQuery();
                                MessageBox.Show("Updated Successfully");
                                Log = LogManager.GetLogger("editApparatus");
                                Log.Info("Item " + txtProdCode.Text + " records has been modified/updated");
                                emptyFields();
                                enableFields();
                            }
                            catch (SqlCeException ex)
                            {
                                MessageBox.Show("Error! Log has been updated with the error.");
                                Log = LogManager.GetLogger("*");
                                Log.Error(ex, "Query Error");
                            }
                        }
                        break;

                    case MessageBoxResult.No: break;
                    }
                }
                else
                {
                    MessageBox.Show("Please search the inventory item first before editing any record!");
                }
            }
        }
Example #51
0
 public void MaybeCheckMessageBox(MessageBoxButton button, params string[] text)
 {
     CheckAndDismissDialog(text, 65535, button.ToString(), false);
 }
Example #52
0
 public static MessageBoxResult Show(string text, string caption, MessageBoxButton buttons, MessageBoxImage icon, MessageBoxResult defResult, MessageBoxOptions options)
 {
     Initialize();
     return(MessageBox.Show(text, caption, buttons, icon, defResult, options));
 }
Example #53
0
 public static MessageBoxResult Show(string messageBoxText, string caption, MessageBoxImage image, MessageBoxButton button)
 {
     return(Show(messageBoxText, caption, image, ConvertToMessageBoxResults(button)));
 }
Example #54
0
        //
        // 摘要:
        //     显示包含指定文本、标题栏标题和响应按钮的消息框。
        //
        // 参数:
        //   messageBoxText:
        //     要显示的消息。
        //
        //   caption:
        //     消息框的标题。
        //
        //   button:
        //     一个值,用于指示要显示哪个按钮或哪些按钮。
        //
        // 返回结果:
        //     一个值,用于指示用户对消息的响应。
        //
        // 异常:
        //   System.ArgumentNullException:
        //     messageBoxText 为 null。- 或 -caption 为 null。
        //
        //   System.ArgumentException:
        //     button 不是有效的 System.Windows.MessageBoxButton 值。
        public async static Task <MessageBoxResult> Show(string messageBoxText, string caption, MessageBoxButton button)
        {
            if (messageBoxText == null)
            {
                throw new ArgumentNullException("messageBoxText is null");
            }
            if (caption == null)
            {
                throw new ArgumentNullException("caption is null");
            }
            if (button != MessageBoxButton.OK && button != MessageBoxButton.OKCancel)
            {
                throw new ArgumentException("button is null");
            }

            var tcs = new TaskCompletionSource <MessageBoxResult>();

            var dialog = new MessageDialog(messageBoxText, caption);

            dialog.Commands.Add(new UICommand("确定", command =>
            {
                tcs.SetResult((MessageBoxResult)command.Id);
            }, MessageBoxResult.OK));

            if (button == MessageBoxButton.OKCancel)
            {
                dialog.Commands.Add(new UICommand("取消", command =>
                {
                    tcs.SetResult((MessageBoxResult)command.Id);
                }, MessageBoxResult.Cancel));
            }

            dialog.DefaultCommandIndex = 0;
            if (button == MessageBoxButton.OKCancel)
            {
                dialog.CancelCommandIndex = 1;
            }
            else
            {
                dialog.CancelCommandIndex = 0;
            }

            await dialog.ShowAsync();

            return(await tcs.Task);
        }
Example #55
0
        public MessageBoxResult ShowMessageBox(string message, string caption, MessageBoxButton buttons, MessageBoxImage icon)
        {
            MessageBoxWindow msg = new MessageBoxWindow(message, caption, buttons, icon);

            return(SetOwnerAndShow(msg));
        }
 public static MessageBoxResult Question(string title, object content, MessageBoxButton button)
 {
     return(Show(title, content, button));
 }
Example #57
0
 //
 // Summary:
 //     Displays a message box that has a message, title bar caption, and button;
 //     and that returns a result.
 //
 // Parameters:
 //   messageBoxText:
 //     A System.String that specifies the text to display.
 //
 //   caption:
 //     A System.String that specifies the title bar caption to display.
 //
 //   button:
 //     A System.Windows.MessageBoxButton value that specifies which button or buttons
 //     to display.
 //
 // Returns:
 //     A System.Windows.MessageBoxResult value that specifies which message box
 //     button is clicked by the user.
 public static MessageBoxResult Show(string messageBoxText, string caption, MessageBoxButton button)
 {
     return(ShowCore(null, messageBoxText, caption, button));
 }
Example #58
0
 MessageBoxResult IMessageBox.Show(string message, string caption, MessageBoxButton buttons)
 {
     return(MessageBox.Show(message, caption, buttons));
 }
Example #59
0
 //
 // Summary:
 //     Displays a message box in front of the specified window. The message box
 //     displays a message, title bar caption, button, and icon; and accepts a default
 //     message box result, complies with the specified options, and returns a result.
 //
 // Parameters:
 //   owner:
 //     A System.Windows.Window that represents the owner window of the message box.
 //
 //   messageBoxText:
 //     A System.String that specifies the text to display.
 //
 //   caption:
 //     A System.String that specifies the title bar caption to display.
 //
 //   button:
 //     A System.Windows.MessageBoxButton value that specifies which button or buttons
 //     to display.
 //
 //   icon:
 //     A System.Windows.MessageBoxImage value that specifies the icon to display.
 //
 //   defaultResult:
 //     A System.Windows.MessageBoxResult value that specifies the default result
 //     of the message box.
 //
 //   options:
 //     A System.Windows.MessageBoxOptions value object that specifies the options.
 //
 // Returns:
 //     A System.Windows.MessageBoxResult value that specifies which message box
 //     button is clicked by the user.
 public static MessageBoxResult Show(Window owner, string messageBoxText, string caption, MessageBoxButton button, MessageBoxImage icon, MessageBoxResult defaultResult, MessageBoxOptions options)
 {
     return(ShowCore(owner, messageBoxText, caption, button, icon, defaultResult, options));
 }
Example #60
0
 public static Task <MessageBoxResult> ShowQuestionAsync(this MetroWindow window, string message,
                                                         string?details        = null, string?title = null, MessageBoxButton buttons = MessageBoxButton.YesNo,
                                                         MessageBoxImage image = MessageBoxImage.Question)
 {
     return(ShowAsync(window, message, details, title ?? L10n.Message("Confirmation"), buttons, image));
 }