Example #1
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            string            parameterString = parameter as string;
            MessageDialogType input           = (MessageDialogType)value;

            return(input == MessageDialogType.Success ? Success : Error);
        }
Example #2
0
        public MessageDialogViewModel(MessageDialogType messageDialogType)
        {
            switch (messageDialogType)
            {
            case MessageDialogType.None:
                break;

            case MessageDialogType.Information:
                ShowIconInformation = true;
                break;

            case MessageDialogType.Warning:
                ShowIconWarning = true;
                break;

            case MessageDialogType.Error:
                ShowIconError = true;
                break;

            case MessageDialogType.Question:
                ShowIconQuestion = true;
                break;

            case MessageDialogType.Success:
                ShowIconSuccess = true;
                break;

            default:
                break;
            }

            OkCommand     = ReactiveCommand.Create(() => OnOk());
            CancelCommand = ReactiveCommand.Create(() => OnCancel());
        }
Example #3
0
        public static int ShowMessage(IServiceProvider serviceProvider, MessageDialogType messageType,
                                      string title, string message)
        {
            if (message == null)
            {
                throw new ArgumentNullException(nameof(message));
            }
            bool isDefaultTitle = false;

            if (String.IsNullOrEmpty(title))
            {
                title          = "Tizen Plugin";
                isDefaultTitle = true;
            }
            OLEMSGICON   icon;
            OLEMSGBUTTON button;

            switch (messageType)
            {
            case MessageDialogType.Debug:
                icon   = OLEMSGICON.OLEMSGICON_NOICON;
                button = OLEMSGBUTTON.OLEMSGBUTTON_OK;
                break;

            case MessageDialogType.Info:
                icon   = OLEMSGICON.OLEMSGICON_INFO;
                button = OLEMSGBUTTON.OLEMSGBUTTON_OK;
                break;

            case MessageDialogType.Warning:
                if (isDefaultTitle)
                {
                    title += " Warning";
                }
                icon   = OLEMSGICON.OLEMSGICON_WARNING;
                button = OLEMSGBUTTON.OLEMSGBUTTON_OK;
                break;

            case MessageDialogType.Error:
                if (isDefaultTitle)
                {
                    title += " Error";
                }
                icon   = OLEMSGICON.OLEMSGICON_CRITICAL;
                button = OLEMSGBUTTON.OLEMSGBUTTON_OK;
                break;

            case MessageDialogType.Question:
                icon   = OLEMSGICON.OLEMSGICON_QUERY;
                button = OLEMSGBUTTON.OLEMSGBUTTON_YESNO;
                break;

            default:
                icon   = OLEMSGICON.OLEMSGICON_NOICON;
                button = OLEMSGBUTTON.OLEMSGBUTTON_OK;
                break;
            }
            return(VsShellUtilities.ShowMessageBox(serviceProvider, message, title, icon, button,
                                                   OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST));
        }
Example #4
0
        /// <summary>
        /// MessageBox
        /// </summary>
        /// <param name="title">Dialog Title</param>
        /// <param name="message">May contain \n.</param>
        /// <param name="dialogType">Ok, OkCancel, YesNo, YesNoCancel.</param>
        /// <param name="iconType">Info, Warning, Error, Question.</param>
        /// <param name="defaultButton">Cancel_No, Ok_Yes, No_In_Yes_No_Cancel.</param>
        /// <returns>If Type is OkCancel or YesNo returns true when clicking OK or YES otherwise returns false.</returns>
        public static bool MessageBox(string title, string message, MessageDialogType dialogType,
                                      MessageDialogIconType iconType, MessageDialogDefaultButton defaultButton)
        {
            string dialogTypeStr;
            string iconTypeStr;


            switch (dialogType)
            {
            default:
            case MessageDialogType.Ok: dialogTypeStr = "ok"; break;

            case MessageDialogType.OkCancel: dialogTypeStr = "okcancel"; break;

            case MessageDialogType.YesNo: dialogTypeStr = "yesno"; break;

            case MessageDialogType.YesNoCancel: dialogTypeStr = "yesnocancel"; break;
            }

            switch (iconType)
            {
            default:
            case MessageDialogIconType.Info: iconTypeStr = "info"; break;

            case MessageDialogIconType.Warning: iconTypeStr = "warning"; break;

            case MessageDialogIconType.Error: iconTypeStr = "error"; break;

            case MessageDialogIconType.Question: iconTypeStr = "question"; break;
            }

            int result = tinyfd_messageBox(title, message, dialogTypeStr, iconTypeStr, (int)defaultButton);

            return(result == 1);
        }
Example #5
0
        public MessageDialog(MessageDialogType messageType,
                             Exception exception,
                             string messageCode,
                             string strMsg,
                             params object[] buttonLabels)
        {
            InitializeComponent();

            if (exception != null)
            {
                m_messageType = MessageDialogType.Error;
                m_message     = exception.Message;
            }
            else
            {
                m_messageType = messageType;
            }

            m_buttonLabels = buttonLabels;

            if (!string.IsNullOrEmpty(strMsg))
            {
                m_message = strMsg;
            }
            else
            {
                m_message = string.IsNullOrEmpty(messageCode) ? string.Empty : ConfigData.Current.SysMessage.GetMessage(messageCode);
            }

            DialogInit();
        }
Example #6
0
        /// <summary>
        /// Render all messages that have been set during execution of the controller action.
        /// </summary>
        /// <param name="htmlHelper"></param>
        /// <returns></returns>
        public static HtmlString RenderMessages(this HtmlHelper htmlHelper, MessageDialogType type = MessageDialogType.AdminLTE)
        {
            var messages = String.Empty;

            foreach (var messageType in Enum.GetNames(typeof(MessageType)))
            {
                var message = htmlHelper.ViewContext.ViewData.ContainsKey(messageType)
                                ? htmlHelper.ViewContext.ViewData[messageType]
                                : htmlHelper.ViewContext.TempData.ContainsKey(messageType)
                                    ? htmlHelper.ViewContext.TempData[messageType]
                                    : null;
                if (message != null)
                {
                    var lowermessage = messageType.ToLowerInvariant();

                    MessageType msgType = (MessageType)Enum.Parse(typeof(MessageType), messageType, true);

                    var messageTitle = msgType.GetDisplayValue();

                    var messageBoxBuilder = new TagBuilder("div");

                    if (type == MessageDialogType.BootStrap)
                    {
                        messageBoxBuilder.AddCssClass(string.Format("alert alert-{0} fade in", lowermessage));
                        messageBoxBuilder.InnerHtml = string.Format("<button class='close' data-dismiss='alert' aria-label='close'>&times;</button><strong>{0}</strong> {1}", messageTitle, message.ToString());
                    }
                    else
                    {
                        messageBoxBuilder.AddCssClass(string.Format("alert alert-{0} fade in", lowermessage));
                        string msgicon = "";
                        switch (lowermessage)
                        {
                        case "danger":
                            msgicon = "fa-ban";
                            break;

                        case "info":
                            msgicon = "fa-info";
                            break;

                        case "warning":
                            msgicon = "fa-warning";
                            break;

                        case "success":
                            msgicon = "fa-check";
                            break;

                        default:
                            break;
                        }
                        messageBoxBuilder.InnerHtml =
                            string.Format("<button type = 'button' class='close' data-dismiss='alert' aria-hidden='true'>&times;</button>" +
                                          "<h4><i class='icon fa {0}'></i> {1}</h4>{2}", msgicon, messageTitle, message.ToString());
                    }
                    messages += messageBoxBuilder.ToString();
                }
            }
            return(MvcHtmlString.Create(messages));
        }
Example #7
0
        private void Show(MessageDialogType type, string caption, string text, ButtonsType buttons, Action <ResponseType> callback)
        {
            Application.Invoke(delegate {
                using var dialog = CreateMessageDialog(type, caption, text, buttons);

                ResponseType result = (ResponseType)dialog.Run();
                dialog.Hide();
                callback.Invoke(result);
            });
Example #8
0
 private static FormMessage CreateMessageForm(MessageDialogType type, string title, string text)
 {
     return(new FormMessage(title, text, type switch {
         MessageDialogType.Error => MessageBoxIcon.Error,
         MessageDialogType.Warning => MessageBoxIcon.Warning,
         MessageDialogType.Information => MessageBoxIcon.Information,
         MessageDialogType.Question => MessageBoxIcon.Question,
         _ => MessageBoxIcon.None
     }));
Example #9
0
        private MessageDialog CreateMessageDialog(MessageDialogType type, string caption, string text, ButtonsType buttons)
        {
            var messageType = type switch {
                MessageDialogType.Error => MessageType.Error,
                MessageDialogType.Warning => MessageType.Warning,
                MessageDialogType.Information => MessageType.Info,
                MessageDialogType.Question => MessageType.Question,
                _ => MessageType.Other
            };

            return(GtkUtils.CreateMessageDialog(window, messageType, caption, text, buttons));
        }
Example #10
0
        public void ShowMessageDialog(MessageDialogType type, string message, string title)
        {
            var image = type switch
            {
                MessageDialogType.Information => MessageBoxImage.Information,
                MessageDialogType.Warning => MessageBoxImage.Warning,
                MessageDialogType.Error => MessageBoxImage.Error,
                _ => throw new ArgumentException("Message dialog type is invalid", nameof(type))
            };

            MessageBox.Show(message, title, MessageBoxButton.OK, image);
        }
Example #11
0
        /// <summary>
        /// Show MessageBox 메시지박스
        /// </summary>
        /// <param name="messageType"></param>
        /// <param name="messageCode"></param>
        /// <param name="strMsg"></param>
        /// <param name="buttonLabels">표시 되는 버튼만큼 버튼글자</param>
        /// <returns></returns>
        public DialogResult ShowMessageBox(MessageDialogType messageType, string messageCode,
                                           string strMsg, string[] buttonLabels)
        {
            Form f = (Form)ChildManager;

            if (f == null || f.IsDisposed || f.Disposing)
            {
                return(new MessageDialog(messageType, null, messageCode, strMsg, buttonLabels).ShowDialog());
            }
            return(new MessageDialog(messageType, null, messageCode, strMsg, buttonLabels).ShowDialog((Form)ChildManager));
            //return new MessageBoxDialog(messageType, messageCode, strMsg, buttonLabels).ShowDialog((Form)ChildManager);
        }
Example #12
0
        public static int ShowMessage(MessageDialogType messageType, string title, string message)
        {
            var vsPackage = instance;

            if (vsPackage != null)
            {
                return(ShellHelper.ShowMessage(vsPackage, messageType, title, message));
            }
            if (messageType != MessageDialogType.Question)
            {
                MessageBox.Show(message, title);
            }
            return(-1);
        }
Example #13
0
        public MessageDialog(MessageDialogType messageType, string messageCode, string strMsg, params object[] buttonLabels)
            : this()
        {
            m_messageType  = messageType;
            m_buttonLabels = buttonLabels;

            if (!string.IsNullOrEmpty(strMsg))
            {
                m_message = strMsg;
            }
            else
            {
                m_message = ConfigData.Current.SysMessage.GetMessage(messageCode);
            }
        }
Example #14
0
        public ButtonResult ShowMessage(string message, string title, MessageDialogType messageDialogType)
        {
            MessageContent messageContent = new MessageContent()
            {
                Message            = message,
                Title              = title,
                MessageDialogValue = messageDialogType
            };

            IDialogResult dialogResult = null;

            _dialogService.ShowDialog(nameof(MessageDialog), new DialogParameters {
                { "MessageContent", messageContent }
            }, result => dialogResult = result);

            return(dialogResult.Result);
        }
Example #15
0
        public MessageDialogResult ShowMessageDialog(string title, string message, MessageDialogType type = MessageDialogType.Ok, MessageDialogResult defaultResult = MessageDialogResult.Ok)
        {
            switch (type)
            {
            case MessageDialogType.Ok:
                if (string.IsNullOrEmpty(title))
                {
                    MessageBox.Show(message);
                }
                else
                {
                    MessageBox.Show(message, title);
                }
                return(MessageDialogResult.Ok);

            case MessageDialogType.OkCancel:
                var result = MessageBox.Show(message, title, MessageBoxButton.OKCancel);

                switch (result)
                {
                case MessageBoxResult.OK:
                    return(MessageDialogResult.Ok);

                case MessageBoxResult.Cancel:
                default:
                    return(MessageDialogResult.Cancel);
                }

            case MessageDialogType.YesNo:
                result = MessageBox.Show(message, title, MessageBoxButton.YesNo);

                switch (result)
                {
                case MessageBoxResult.Yes:
                    return(MessageDialogResult.Yes);

                case MessageBoxResult.No:
                default:
                    return(MessageDialogResult.No);
                }
            }

            return(defaultResult);
        }
Example #16
0
        public static async Task <bool> Show(string title, string message, MessageDialogType messageDialogType)
        {
            dialogManager = Locator.Current.GetService <IDialogManager>();
            var vm = new MessageDialogViewModel(messageDialogType)
            {
                Title = title, Message = message
            };

            var dialog = new DialogMessage
            {
                DataContext = vm
            };

            observableSubs = Observable.Merge(vm.OkCommand, vm.CancelCommand)
                             .Take(1)
                             .Subscribe(r => OnClose(r));

            return(await dialogManager.ShowChildDialogAsync <bool>(dialog));
        }
Example #17
0
        public override DataTemplate SelectTemplate(object item, DependencyObject container)
        {
            MessageDialogType messageDialogType = ((MessageDialogViewModel)item).MessageDialogValue;

            switch (messageDialogType)
            {
            case MessageDialogType.OkOnly:
            {
                return(OkOnlyTemplate);
            }

            case MessageDialogType.OkCancel:
            {
                return(OkCancelTemplate);
            }

            case MessageDialogType.YesNo:
            {
                return(YesNoTemplate);
            }
            }

            return(base.SelectTemplate(item, container));
        }
Example #18
0
        private static (MessageDialogType, string) GetMessageDialogProperties(string text)
        {
            MessageDialogType type = MessageDialogType.None;

            int pipe = text.IndexOf('|');

            if (pipe != -1)
            {
                type = text.Substring(0, pipe) switch {
                    "error" => MessageDialogType.Error,
                    "warning" => MessageDialogType.Warning,
                    "info" => MessageDialogType.Information,
                    "question" => MessageDialogType.Question,
                    _ => MessageDialogType.None
                };

                if (type != MessageDialogType.None)
                {
                    text = text.Substring(pipe + 1);
                }
            }

            return(type, text);
        }
Example #19
0
        public static Task <MessageBoxResult> ShowAsync(
            string header,
            string content,
            MessageBoxButton button     = MessageBoxButton.OK,
            MessageDialogType type      = MessageDialogType.Light,
            System.Windows.Window owner = null)
        {
            TaskCompletionSource <MessageBoxResult> taskCompletionSource = new TaskCompletionSource <MessageBoxResult>();

            if (owner == null)
            {
                owner = Application.Current.Windows.OfType <Window>().SingleOrDefault(x => x.IsActive);
            }

            MessageDialog messageDialog = new MessageDialog()
            {
                Content = content
            };

            OverlayWindow window = new OverlayWindow()
            {
                Content = messageDialog,
                Owner   = owner
            };

            switch (type)
            {
            case MessageDialogType.Accent:
                window.Style = (Style)window.FindResource("AccentOverlayWindowStyle");
                break;

            case MessageDialogType.Dark:
                window.Style = (Style)window.FindResource("DarkOverlayWindowStyle");
                break;
            }

            messageDialog.Header = new TextBlock()
            {
                Style = (Style)window.FindResource("HeaderTextStyle"),
                Text  = header
            };

            if ((button == MessageBoxButton.OK) ||
                (button == MessageBoxButton.OKCancel))
            {
                messageDialog.Items.Add(
                    new MessageDialogButton()
                {
                    Command = new DelegateCommand(
                        () =>
                    {
                        if (!taskCompletionSource.Task.IsCompleted)
                        {
                            window.Close();
                            taskCompletionSource.SetResult(MessageBoxResult.OK);
                        }
                    }),
                    Content = "Ok"
                });
            }

            if ((button == MessageBoxButton.YesNo) ||
                (button == MessageBoxButton.YesNoCancel))
            {
                messageDialog.Items.Add(
                    new MessageDialogButton()
                {
                    Command = new DelegateCommand(
                        () =>
                    {
                        if (!taskCompletionSource.Task.IsCompleted)
                        {
                            window.Close();
                            taskCompletionSource.SetResult(MessageBoxResult.Yes);
                        }
                    }),
                    Content = "Yes"
                });
                messageDialog.Items.Add(
                    new MessageDialogButton()
                {
                    Command = new DelegateCommand(
                        () =>
                    {
                        if (!taskCompletionSource.Task.IsCompleted)
                        {
                            window.Close();
                            taskCompletionSource.SetResult(MessageBoxResult.No);
                        }
                    }),
                    Content = "No"
                });
            }

            if ((button == MessageBoxButton.OKCancel) ||
                (button == MessageBoxButton.YesNoCancel))
            {
                messageDialog.Items.Add(
                    new MessageDialogButton()
                {
                    Command = new DelegateCommand(
                        () =>
                    {
                        if (!taskCompletionSource.Task.IsCompleted)
                        {
                            window.Close();
                            taskCompletionSource.SetResult(MessageBoxResult.Cancel);
                        }
                    }),
                    Content = "Cancel"
                });
            }

            messageDialog.CancelCommandIndex = messageDialog.Items.Count - 1;
            window.Show();

            return(taskCompletionSource.Task);
        }
Example #20
0
        public static Task <MessageBoxResult> ShowAsync(
            string header,
            string content,
            IEnumerable <MessageDialogButton> buttons,
            MessageDialogType type      = MessageDialogType.Light,
            System.Windows.Window owner = null,
            int defaultCommandIndex     = 0,
            int cancelCommandIndex      = -1)
        {
            TaskCompletionSource <MessageBoxResult> taskCompletionSource = new TaskCompletionSource <MessageBoxResult>();

            if (owner == null)
            {
                owner = Application.Current.Windows.OfType <Window>().SingleOrDefault(x => x.IsActive);
            }

            MessageDialog messageDialog = new MessageDialog()
            {
                Header  = header,
                Content = content
            };

            OverlayWindow window = new OverlayWindow()
            {
                Content = messageDialog,
                Owner   = owner
            };

            switch (type)
            {
            case MessageDialogType.Accent:
                window.Style = (Style)window.FindResource("AccentOverlayWindowStyle");
                break;

            case MessageDialogType.Dark:
                window.Style = (Style)window.FindResource("DarkOverlayWindowStyle");
                break;
            }

            foreach (MessageDialogButton button in buttons)
            {
                messageDialog.Items.Add(button);
            }

            if (cancelCommandIndex == -1)
            {
                messageDialog.CancelCommandIndex = messageDialog.Items.Count - 1;
            }

            window.Show();

            messageDialog
            .FindVisualChildren <Button>()
            .ToList()
            .ForEach(
                x => x.Click += (sender, e) =>
            {
                if (!taskCompletionSource.Task.IsCompleted)
                {
                    window.Close();
                    taskCompletionSource.SetResult(MessageBoxResult.None);
                }
            });

            return(taskCompletionSource.Task);
        }
Example #21
0
 public MessageDialog(Exception exception)
     : this()
 {
     m_messageType = MessageDialogType.Error;
     m_message     = exception.Message;
 }
Example #22
0
        /// <summary>
        /// 显示确认对话消息
        /// 确认和取消
        /// </summary>
        /// <param name="content">内容</param>
        /// <param name="title">标题</param>
        /// <param name="type">对话类型</param>
        /// <returns></returns>
        public static async Task <MessageDialogResult> ShowMessageAsync(string content, string title, MessageDialogType type)
        {
            MessageDialogResult result = MessageDialogResult.Default;
            var dialog = new MessageDialog(content, title);

            List <UICommand> commandList = new List <UICommand>();

            switch (type)
            {
            case MessageDialogType.OK:
                commandList.Add(new UICommand("确定", cmd => { result = MessageDialogResult.OK; }, commandId: 0));
                break;

            case MessageDialogType.AbortRetryIgnore:
                commandList.Add(new UICommand("中止", cmd => { result = MessageDialogResult.Abort; }, commandId: 0));
                commandList.Add(new UICommand("重试", cmd => { result = MessageDialogResult.Retry; }, commandId: 1));
                commandList.Add(new UICommand("忽略", cmd => { result = MessageDialogResult.Ignore; }, commandId: 2));
                break;

            case MessageDialogType.YesNoCancel:
                commandList.Add(new UICommand("是", cmd => { result = MessageDialogResult.Yes; }, commandId: 0));
                commandList.Add(new UICommand("否", cmd => { result = MessageDialogResult.No; }, commandId: 1));
                commandList.Add(new UICommand("取消", cmd => { result = MessageDialogResult.Cancel; }, commandId: 2));
                break;

            case MessageDialogType.YesNo:
                commandList.Add(new UICommand("是", cmd => { result = MessageDialogResult.Yes; }, commandId: 0));
                commandList.Add(new UICommand("否", cmd => { result = MessageDialogResult.No; }, commandId: 1));
                break;

            case MessageDialogType.RetryCancel:
                commandList.Add(new UICommand("重试", cmd => { result = MessageDialogResult.Retry; }, commandId: 0));
                commandList.Add(new UICommand("取消", cmd => { result = MessageDialogResult.Cancel; }, commandId: 1));
                break;

            case MessageDialogType.OKCancel:
            default:
                commandList.Add(new UICommand("确定", cmd => { result = MessageDialogResult.OK; }, commandId: 0));
                commandList.Add(new UICommand("取消", cmd => { result = MessageDialogResult.Cancel; }, commandId: 1));
                break;
            }

            foreach (var command in commandList)
            {
                dialog.Commands.Add(command);
            }

            //设置默认按钮,不设置的话默认的确认按钮是第一个按钮
            dialog.DefaultCommandIndex = 0;
            dialog.CancelCommandIndex  = (uint)commandList.Count - 1;

            //获取返回值
            await dialog.ShowAsync();

            return(result);
        }
Example #23
0
 public MessageDialogViewModel(MessageDialogType messageDialogType, string message)
 {
     MessageDialogType = messageDialogType;
     Message           = message ?? throw new ArgumentNullException(nameof(message));
 }
Example #24
0
        public static Task<MessageBoxResult> ShowAsync(
            string header,
            string content,
            IEnumerable<MessageDialogButton> buttons,
            MessageDialogType type = MessageDialogType.Light,
            System.Windows.Window owner = null,
            int defaultCommandIndex = 0,
            int cancelCommandIndex = -1)
        {
            TaskCompletionSource<MessageBoxResult> taskCompletionSource = new TaskCompletionSource<MessageBoxResult>();

            if (owner == null)
            {
                owner = Application.Current.Windows.OfType<Window>().SingleOrDefault(x => x.IsActive);
            }

            MessageDialog messageDialog = new MessageDialog()
            {
                Header = header,
                Content = content
            };

            OverlayWindow window = new OverlayWindow()
            {
                Content = messageDialog,
                Owner = owner
            };

            switch (type)
            {
                case MessageDialogType.Accent:
                    window.Style = (Style)window.FindResource("AccentOverlayWindowStyle");
                    break;
                case MessageDialogType.Dark:
                    window.Style = (Style)window.FindResource("DarkOverlayWindowStyle");
                    break;
            }

            foreach (MessageDialogButton button in buttons)
            {
                messageDialog.Items.Add(button);
            }

            if (cancelCommandIndex == -1)
            {
                messageDialog.CancelCommandIndex = messageDialog.Items.Count - 1;
            }

            window.Show();

            messageDialog
                .FindVisualChildren<Button>()
                .ToList()
                .ForEach(
                    x => x.Click += (sender, e) =>
                    {
                        if (!taskCompletionSource.Task.IsCompleted)
                        {
                            window.Close();
                            taskCompletionSource.SetResult(MessageBoxResult.None);
                        }
                    });

            return taskCompletionSource.Task;
        }
Example #25
0
        private void InitDialogByType(MessageDialogType messageType)
        {
            var msgType = messageType == MessageDialogType.YesNoCancel ? MessageDialogType.Question : messageType;

            if (messageType != MessageDialogType.None)
            {
                picMsgIcon.Image = Extensions.ResourceLoad(string.Format("messagedialog_{0}.png", msgType.ToString().ToLower()));
            }

            switch (messageType)
            {
            case MessageDialogType.Question:
                btnYes.Visible         = false;
                btnNoOK.Visible        = true;
                btnCancelClose.Visible = true;

                btnNoOK.Text = m_buttonLabels != null && m_buttonLabels.Length > 0 ?
                               m_buttonLabels[0].ToString() : Properties.Resources.MessageDialog_Button_Yes;
                btnNoOK.Tag = "Yes";

                btnCancelClose.Text = m_buttonLabels != null && m_buttonLabels.Length > 0 ?
                                      m_buttonLabels[1].ToString() : Properties.Resources.MessageDialog_Button_No;
                btnCancelClose.Tag = "No";
                Text = Properties.Resources.MessageDialog_Title_Question;
                break;

            case MessageDialogType.YesNoCancel:
                btnYes.Visible         = true;
                btnNoOK.Visible        = true;
                btnCancelClose.Visible = true;

                btnYes.Text = m_buttonLabels != null && m_buttonLabels.Length > 0 ?
                              m_buttonLabels[0].ToString() : Properties.Resources.MessageDialog_Button_Yes;
                btnYes.Tag = "Yes";

                btnNoOK.Text = m_buttonLabels != null && m_buttonLabels.Length > 0 ?
                               m_buttonLabels[1].ToString() : Properties.Resources.MessageDialog_Button_No;
                btnNoOK.Tag = "No";

                btnCancelClose.Text = m_buttonLabels != null && m_buttonLabels.Length > 0 ?
                                      m_buttonLabels[2].ToString() :
                                      Properties.Resources.MessageDialog_Button_Cancel;
                btnCancelClose.Tag = "Cancel";
                Text = Properties.Resources.MessageDialog_Title_YesNoCancel;
                break;

            case MessageDialogType.Error:
                btnYes.Visible         = false;
                btnNoOK.Visible        = false;
                btnCancelClose.Visible = true;

                btnCancelClose.Text = m_buttonLabels != null && m_buttonLabels.Length > 0 ?
                                      m_buttonLabels[0].ToString() : Properties.Resources.MessageDialog_Button_OK;
                btnCancelClose.Tag = "OK";
                Text = Properties.Resources.MessageDialog_Title_Error;
                break;

            case MessageDialogType.Warning:
                btnYes.Visible         = false;
                btnNoOK.Visible        = false;
                btnCancelClose.Visible = true;

                btnCancelClose.Text = m_buttonLabels != null && m_buttonLabels.Length > 0 ?
                                      m_buttonLabels[0].ToString() : Properties.Resources.MessageDialog_Button_OK;
                btnCancelClose.Tag = "OK";
                Text = Properties.Resources.MessageDialog_Title_Warning;
                break;

            case MessageDialogType.Information:
                btnYes.Visible         = false;
                btnNoOK.Visible        = false;
                btnCancelClose.Visible = true;

                btnCancelClose.Text = m_buttonLabels != null && m_buttonLabels.Length > 0 ?
                                      m_buttonLabels[0].ToString() : Properties.Resources.MessageDialog_Button_OK;
                btnCancelClose.Tag = "OK";
                Text = Properties.Resources.MessageDialog_Title_Information;
                break;

            default:
                break;
            }
        }
        bool?IUIService.ShowMessageDialog(string message, MessageDialogType type, bool canCancel)
        {
            MessageBoxButton button;
            MessageBoxImage  icon;

            switch (type)
            {
            case MessageDialogType.Information:
                button = MessageBoxButton.OK;
                icon   = MessageBoxImage.Information;
                break;

            case MessageDialogType.Warning:
                button = MessageBoxButton.OK;
                icon   = MessageBoxImage.Warning;
                break;

            case MessageDialogType.Error:
                button = MessageBoxButton.OK;
                icon   = MessageBoxImage.Error;
                break;

            case MessageDialogType.Question:
                button = canCancel ? MessageBoxButton.YesNoCancel : MessageBoxButton.YesNo;
                icon   = MessageBoxImage.Question;
                break;

            default:
                throw new InvalidOperationException();
            }

            MessageBoxResult result;

            if (MainWindow != null)
            {
                result = MessageBox.Show(
                    MainWindow,
                    message,
                    Model.SR.DefaultWindowCaption,
                    button,
                    icon);
            }
            else
            {
                result = MessageBox.Show(
                    message,
                    Model.SR.DefaultWindowCaption,
                    button,
                    icon);
            }

            switch (result)
            {
            case MessageBoxResult.None:
                return(null);

            case MessageBoxResult.OK:
                return(true);

            case MessageBoxResult.Cancel:
                return(null);

            case MessageBoxResult.Yes:
                return(true);

            case MessageBoxResult.No:
                return(false);

            default:
                throw new InvalidOperationException();
            }
        }
Example #27
0
 /// <summary>
 /// Show MessageBox 메시지박스
 /// </summary>
 /// <param name="messageType"></param>
 /// <param name="messageCode"></param>
 /// <param name="strMsg"></param>
 /// <param name="buttonLabels">표시 되는 버튼만큼 버튼글자</param>
 /// <returns></returns>
 public DialogResult ShowMessageBox(MessageDialogType messageType, string messageCode, string strMsg, string[] buttonLabels)
 {
     return(new MessageDialog(messageType, null, messageCode, strMsg, buttonLabels).ShowDialog(this));
     //return new MessageBoxDialog(messageType, messageCode, strMsg, buttonLabels).ShowDialog(this);
 }
Example #28
0
        public MessageDialog(string Title, string Message, MessageDialogButtons Buttons, MessageDialogType Type, Brush BackColor)
        {
            InitializeComponent();
            switch (Buttons)
            {
            case MessageDialogButtons.Ok:
                ButtonNo.Visibility  = System.Windows.Visibility.Hidden;
                ButtonYes.Visibility = System.Windows.Visibility.Hidden;
                break;

            case MessageDialogButtons.YesNo:
                ButtonOk.Visibility = System.Windows.Visibility.Hidden;
                break;
            }

            switch (Type)
            {
            case MessageDialogType.Information:
                ImageIcon.Source = (ImageSource)ImageIcon.Resources["ImageHeaderDialogInfo"];
                break;

            case MessageDialogType.Warning:
                ImageIcon.Source = (ImageSource)ImageIcon.Resources["ImageHeaderDialogWarning"];
                break;

            case MessageDialogType.Error:
                ImageIcon.Source = (ImageSource)ImageIcon.Resources["ImageHeaderDialogError"];
                break;
            }

            TextBlockMessage.Text = Message;
            TextBlockTitle.Text   = Title;
            GridTitle.Background  = BackColor;
        }
Example #29
0
        public static Task<MessageBoxResult> ShowAsync(
            string header,
            string content,
            MessageBoxButton button = MessageBoxButton.OK,
            MessageDialogType type = MessageDialogType.Light,
            System.Windows.Window owner = null)
        {
            TaskCompletionSource<MessageBoxResult> taskCompletionSource = new TaskCompletionSource<MessageBoxResult>();

            if (owner == null)
            {
                owner = Application.Current.Windows.OfType<Window>().SingleOrDefault(x => x.IsActive);
            }

            MessageDialog messageDialog = new MessageDialog()
            {
                Content = content
            };

            OverlayWindow window = new OverlayWindow()
            {
                Content = messageDialog,
                Owner = owner
            };

            switch (type)
            {
                case MessageDialogType.Accent:
                    window.Style = (Style)window.FindResource("AccentOverlayWindowStyle");
                    break;
                case MessageDialogType.Dark:
                    window.Style = (Style)window.FindResource("DarkOverlayWindowStyle");
                    break;
            }

            messageDialog.Header = new TextBlock()
            {
                Style = (Style)window.FindResource("HeaderTextStyle"),
                Text = header
            };

            if ((button == MessageBoxButton.OK) ||
                (button == MessageBoxButton.OKCancel))
            {
                messageDialog.Items.Add(
                    new MessageDialogButton()
                    {
                        Command = new DelegateCommand(
                            () =>
                            {
                                if (!taskCompletionSource.Task.IsCompleted)
                                {
                                    window.Close();
                                    taskCompletionSource.SetResult(MessageBoxResult.OK);
                                }
                            }),
                        Content = "Ok"
                    });
            }

            if ((button == MessageBoxButton.YesNo) ||
                (button == MessageBoxButton.YesNoCancel))
            {
                messageDialog.Items.Add(
                    new MessageDialogButton()
                    {
                        Command = new DelegateCommand(
                            () =>
                            {
                                if (!taskCompletionSource.Task.IsCompleted)
                                {
                                    window.Close();
                                    taskCompletionSource.SetResult(MessageBoxResult.Yes);
                                }
                            }),
                        Content = "Yes"
                    });
                messageDialog.Items.Add(
                    new MessageDialogButton()
                    {
                        Command = new DelegateCommand(
                            () =>
                            {
                                if (!taskCompletionSource.Task.IsCompleted)
                                {
                                    window.Close();
                                    taskCompletionSource.SetResult(MessageBoxResult.No);
                                }
                            }),
                        Content = "No"
                    });
            }

            if ((button == MessageBoxButton.OKCancel) ||
                (button == MessageBoxButton.YesNoCancel))
            {
                messageDialog.Items.Add(
                    new MessageDialogButton()
                    {
                        Command = new DelegateCommand(
                            () =>
                            {
                                if (!taskCompletionSource.Task.IsCompleted)
                                {
                                    window.Close();
                                    taskCompletionSource.SetResult(MessageBoxResult.Cancel);
                                }
                            }),
                        Content = "Cancel"
                    });
            }

            messageDialog.CancelCommandIndex = messageDialog.Items.Count - 1;
            window.Show();

            return taskCompletionSource.Task;
        }
Example #30
0
 public void ShowMessageDialog(string text, string caption, MessageDialogType type)
 {
     Console.WriteLine(string.Format("XMA: Message dialog shown: Text: {0}, Caption: {1}", text, caption));
 }
Example #31
0
 public int ShowMessage(MessageDialogType messageType, string message)
 {
     return(ShellHelper.ShowMessage(_package, messageType, "", message));
 }
Example #32
0
 public void ShowMessageDialog(string text, string caption, MessageDialogType type)
 {
     MessageBox.Show(text, caption, MessageBoxButton.OK);
 }