Esempio n. 1
0
        /// <summary>
        /// Shows message window.
        /// </summary>
        /// <param name="mainWindow">Required param. Gets form information</param>
        /// <param name="title">Required param. Message title</param>
        /// <param name="prompt">Required param. Message prompt</param>
        /// <param name="messageButtons">Optional param. Message buttons. Default OK</param>
        /// <returns></returns>
        public static MessageResult Show(Window mainWindow, string title, string prompt, MessageButtons messageButtons = MessageButtons.OK, MessageIcon messageIcon = MessageIcon.None)
        {
            _mainWindow = mainWindow;
            emptyWindow = new Window();
            //emptyWindow.WindowStartupLocation = WindowStartupLocation.CenterOwner;
            emptyWindow.WindowState = mainWindow.WindowState;
            emptyWindow.Height = _mainWindow.Height;
            emptyWindow.Width = mainWindow.Width;
            emptyWindow.Top = mainWindow.Top;
            emptyWindow.Left = mainWindow.Left;
            emptyWindow.WindowStyle = WindowStyle.None;
            emptyWindow.ResizeMode = ResizeMode.NoResize;
            emptyWindow.Background = new SolidColorBrush(Colors.Transparent);
            emptyWindow.AllowsTransparency = true;
            emptyWindow.ShowInTaskbar = false;

            var content = mainWindow.Content;

            if (content is Grid)
            {
                Grid grd = (Grid)content;
                base_grid = new Grid() { Name = "grd_message" };
                RowDefinition rd = new RowDefinition();
                rd.Height = new GridLength(10, GridUnitType.Star);
                ColumnDefinition cd = new ColumnDefinition();
                cd.Width = new GridLength(10, GridUnitType.Star);
                base_grid.RowDefinitions.Add(rd);
                base_grid.ColumnDefinitions.Add(cd);
                CreateMainGrid(emptyWindow, title, prompt, messageButtons, messageIcon);
                base_grid.Children.Add(main_grid);
                emptyWindow.Content = base_grid;
                emptyWindow.ShowDialog();
            }
            return Result;
        }
 public SessionMessage(MessageType messageType, MessageBehaviors behavior, string message, string key,string caption, MessageButton? messageButtons, MessageIcon? messageIcon)
 {
     if (behavior == MessageBehaviors.Modal && (!messageButtons.HasValue || !messageIcon.HasValue))
     {
         messageButtons = messageButtons ?? MessageButton.Ok;
         if(!messageIcon.HasValue)
         {
             switch(messageType)
             {
                 case MessageType.Error:
                     messageIcon = MessageIcon.Error;
                     break;
                 case MessageType.Info:
                     messageIcon = MessageIcon.Information;
                     break;
                 case MessageType.Success:
                     messageIcon = MessageIcon.Success;
                     break;
                 case MessageType.Warning:
                     messageIcon = MessageIcon.Warning;
                     break;
                 default:
                     messageIcon = MessageIcon.Information;
                     break;
             }
         }
     }
     Key = key;
     Message = message;
     Caption = caption;
     Type = messageType;
     Behavior = behavior;
     Buttons = messageButtons;
     Icon = messageIcon;
 }
 MessageResult IMessageBoxService.Show(string messageBoxText, string caption, MessageButton button, MessageIcon icon, MessageResult defaultResult) {
     var owner = AssociatedObject.With(x => Window.GetWindow(x));
     if(owner == null)
         return MessageBox.Show(messageBoxText, caption, button.ToMessageBoxButton(), icon.ToMessageBoxImage(), defaultResult.ToMessageBoxResult()).ToMessageResult();
     else
         return MessageBox.Show(owner, messageBoxText, caption, button.ToMessageBoxButton(), icon.ToMessageBoxImage(), defaultResult.ToMessageBoxResult()).ToMessageResult();
 }
        private void ShowDialog(Window parent, MessageIcon icon, string title, string content, MessageChoice choices, string help, bool enableDontAsk, MessageChoice defaultChoice)
        {
            if (IsSet(choices, MessageChoice.Yes | MessageChoice.OK) || (choices == MessageChoice.Help))
                throw new ArgumentException();

            _view = CreateWindow(parent);

            Icon = icon;
            Title = title;
            Content = content;
            Choices = new List<ICommand>();
            EnableDontAskAgain = enableDontAsk;
            Result = MessageChoice.None;

            if (!string.IsNullOrEmpty(help))
                HelpMessage = help;

            if (IsSet(choices, MessageChoice.Yes))
                Choices.Add(new ChoiceCommand(CloseCommand, defaultChoice == MessageChoice.Yes, false, "Yes", MessageChoice.Yes));

            if (IsSet(choices, MessageChoice.No))
                Choices.Add(new ChoiceCommand(CloseCommand, defaultChoice == MessageChoice.No, !IsSet(choices, MessageChoice.Cancel), "No", MessageChoice.No));

            if (IsSet(choices, MessageChoice.OK))
                Choices.Add(new ChoiceCommand(CloseCommand, choices == MessageChoice.OK || defaultChoice == MessageChoice.OK, !IsSet(choices, MessageChoice.Cancel), "OK", MessageChoice.OK));

            if (IsSet(choices, MessageChoice.Cancel))
                Choices.Add(new ChoiceCommand(CloseCommand, choices == MessageChoice.Cancel || defaultChoice == MessageChoice.Cancel, true, "Cancel", MessageChoice.Cancel));

            if (IsSet(choices, MessageChoice.Help))
                Choices.Add(new ChoiceCommand(HelpCommand, choices == MessageChoice.Help || defaultChoice == MessageChoice.Help, false, "Help", MessageChoice.Help));

            _view.ShowDialog();
        }
Esempio n. 5
0
        public MessageResult ProcessMessage(InstallMessage messageType, Record messageRecord, MessageButtons buttons, MessageIcon icon, MessageDefaultButton defaultButton)
        {
            try
            {
                this.progressCounter.ProcessMessage(messageType, messageRecord);
                this.progressBar.Value = (int)(this.progressBar.Minimum + this.progressCounter.Progress * (this.progressBar.Maximum - this.progressBar.Minimum));
                this.progressLabel.Text = "" + (int)Math.Round(100 * this.progressCounter.Progress) + "%";

                switch (messageType)
                {
                    case InstallMessage.Error:
                    case InstallMessage.Warning:
                    case InstallMessage.Info:
                        string message = String.Format("{0}: {1}", messageType, messageRecord);
                        this.LogMessage(message);
                        break;
                }

                if (this.canceled)
                {
                    this.canceled = false;
                    return MessageResult.Cancel;
                }
            }
            catch (Exception ex)
            {
                this.LogMessage(ex.ToString());
                this.LogMessage(ex.StackTrace);
            }

            Application.DoEvents();

            return MessageResult.OK;
        }
 public MessageResult Show(string messageBoxText, string caption, MessageButton button, MessageIcon icon, MessageResult defaultResult) {
     MessageBoxTest = messageBoxText;
     Caption = caption;
     Button = button;
     Icon = icon;
     DefaultResult = defaultResult;
     ShowCount++;
     return Result;
 }
Esempio n. 7
0
        public static Result ShowMessageBox(string message, string caption, MessageType messageType, MessageIcon messageIcon)
        {
            MessageBoxButton messageButton = MessageBoxButton.OK;
            switch (messageType)
            {
                case MessageType.OK:
                    messageButton = MessageBoxButton.OK;
                    break;
                case MessageType.OkCancel:
                    messageButton = MessageBoxButton.OKCancel;
                    break;
                case MessageType.YesNo:
                    messageButton = MessageBoxButton.YesNo;
                    break;
                case MessageType.YesNoCancel:
                    messageButton = MessageBoxButton.YesNoCancel;
                    break;
                default:
                    break;
            }

            MessageBoxImage messageImage = MessageBoxImage.Information;
            switch (messageIcon)
            {
                case MessageIcon.Information:
                    messageImage = MessageBoxImage.Information;
                    break;
                case MessageIcon.Warning:
                    messageImage = MessageBoxImage.Warning;
                    break;
                case MessageIcon.Error:
                    messageImage = MessageBoxImage.Error;
                    break;
                case MessageIcon.Question:
                    messageImage = MessageBoxImage.Question;
                    break;
                default:
                    break;
            }

            switch (MessageBox.Show(message, caption, messageButton, messageImage))
            {
                case MessageBoxResult.OK:
                    return Result.Ok;
                case MessageBoxResult.Cancel:
                    return Result.Cancel;
                case MessageBoxResult.Yes:
                    return Result.Yes;
                case MessageBoxResult.No:
                    return Result.No;
                case MessageBoxResult.None:
                    return Result.None;
                default:
                    return Result.None;
            }
        }
Esempio n. 8
0
 public static MessageResult ExternalUILogger(
     InstallMessage messageType,
     string message,
     MessageButtons buttons,
     MessageIcon icon,
     MessageDefaultButton defaultButton)
 {
     Console.WriteLine("{0}: {1}", messageType, message);
     return MessageResult.None;
 }
Esempio n. 9
0
        public CustomMessageBox()
        {
            m_messageBoxButtons = MessageBoxButtons.OK;
            m_messageBoxDefaultButton = MessageBoxDefaultButton.Button1;
            m_messageIcon = MessageIcon.None;
            m_messageBoxOptions = 0;
            m_helpNavigator = HelpNavigator.Topic;
            m_variableDictionary = new Dictionary<string, object>();

            InitializeComponent();
        }
        public MessageResult Show(string message, string title, MessageIcon icon, MessageOptions option)
        {
            if (_viewModel == null)
                _viewModel = new MessageBoxViewModel(message, title, option, icon);
            else
                _viewModel.Update(message, title, option, icon);

            DispatcherHelper.UIDispatcher.Invoke(DispatcherPriority.Normal, new Action(() =>
                {
                    ServiceManager.GetService<IViewService>().OpenDialog(_viewModel);
                }));

            return _viewModel.Result;
        }
Esempio n. 11
0
        /// <summary>
        /// Processes the message.
        /// </summary>
        /// <param name="messageType">Type of the message.</param>
        /// <param name="messageRecord">The message record.</param>
        /// <param name="buttons">The buttons.</param>
        /// <param name="icon">The icon.</param>
        /// <param name="defaultButton">The default button.</param>
        /// <returns></returns>
        public override MessageResult ProcessMessage(InstallMessage messageType, Record messageRecord, MessageButtons buttons, MessageIcon icon, MessageDefaultButton defaultButton)
        {
            switch (messageType)
            {
                case InstallMessage.ActionStart:
                    {

                        try
                        {
                            //messageRecord[0] - is reserved for FormatString value

                            string message = null;

                            bool simple = true;
                            if (simple)
                            {
                                for (int i = messageRecord.FieldCount - 1; i > 0; i--)
                                {
                                    message = messageRecord[i].ToString();
                                }
                            }
                            else
                            {
                                message = messageRecord.FormatString;
                                if (message.IsNotEmpty())
                                {
                                    for (int i = 1; i < messageRecord.FieldCount; i++)
                                    {
                                        message = message.Replace("[" + i + "]", messageRecord[i].ToString());
                                    }
                                }
                                else
                                {
                                    message = messageRecord[messageRecord.FieldCount - 1].ToString();
                                }
                            }

                            if (message.IsNotEmpty())
                                currentAction.Text = message;
                        }
                        catch { }
                    }
                    break;
            }
            return MessageResult.OK;
        }
Esempio n. 12
0
        public override MessageResult ProcessMessage(InstallMessage messageType, Record messageRecord, MessageButtons buttons, MessageIcon icon, MessageDefaultButton defaultButton)
        {
            switch (messageType)
            {
                case InstallMessage.ActionStart:
                    {

                        try
                        {
                            var message = messageRecord[messageRecord.FieldCount - 1].ToString();

                            if (message.IsNotEmpty())
                                currentAction.Text = message;
                        }
                        catch { }
                    }
                    break;
            }
            return MessageResult.OK;
        }
Esempio n. 13
0
 public static MessageResult ExternalUIRecordLogger(
     InstallMessage messageType,
     Record messageRecord,
     MessageButtons buttons,
     MessageIcon icon,
     MessageDefaultButton defaultButton)
 {
     if (messageRecord != null)
     {
         if (messageRecord.FormatString.Length == 0 && messageRecord.FieldCount > 0)
         {
             messageRecord.FormatString = "1: [1]   2: [2]   3: [3]   4: [4]  5: [5]";
         }
         Console.WriteLine("{0}: {1}", messageType, messageRecord.ToString());
     }
     else
     {
         Console.WriteLine("{0}: (null)", messageType);
     }
     return MessageResult.None;
 }
 public MessageBoxViewModel(string message, string title, MessageOptions option, MessageIcon icon)
 {
     Update(message, title, option, icon);
 }
Esempio n. 15
0
        private MessageResult OnMessage(InstallMessage messageType, Deployment.WindowsInstaller.Record messageRecord, MessageButtons buttons, MessageIcon icon, MessageDefaultButton defaultButton)
        {
            switch (messageType)
            {
                case InstallMessage.FatalExit:
                case InstallMessage.Error:
                    return this.OnError(messageRecord);

                case InstallMessage.Warning:
                    return this.OnWarning(messageRecord);

                case InstallMessage.User:
                    return this.OnInformation(messageRecord);

                default:
                    return MessageResult.None;
            }
        }
Esempio n. 16
0
 public static MessageResult ExternalUI(InstallMessage messageType, string message, MessageButtons buttons, MessageIcon icon,
     MessageDefaultButton defaultButton)
 {
     return MessageResult.OK;
 }
        //========= CONSTRUCTORS =========
        #region Constructors

        /**<summary>Constructs and sets up the message box.</summary>*/
        private TriggerMessageBox(MessageIcon icon, string title, string message, MessageBoxButton buttons, string buttonName1 = null, string buttonName2 = null, string buttonName3 = null)
        {
            InitializeComponent();
            this.buttons  = buttons;
            this.icon     = icon;
            this.minWidth = 280;

            #region Load Message Icons
            switch (icon)
            {
            case MessageIcon.Info:
                this.Icon = new BitmapImage(new Uri("pack://application:,,,/Resources/Icons/InfoIcon.png"));
                break;

            case MessageIcon.Question:
                this.Icon = new BitmapImage(new Uri("pack://application:,,,/Resources/Icons/QuestionIcon.png"));
                break;

            case MessageIcon.Warning:
                this.Icon = new BitmapImage(new Uri("pack://application:,,,/Resources/Icons/WarningIcon.png"));
                break;

            case MessageIcon.Error:
                this.Icon = new BitmapImage(new Uri("pack://application:,,,/Resources/Icons/ErrorIcon.png"));
                break;
            }
            #endregion

            // Setup the buttons
            switch (buttons)
            {
                #region MessageBoxButton.OK
            case MessageBoxButton.OK:
                button1.IsDefault  = true;
                button1.Content    = "OK";
                button1.Tag        = MessageBoxResult.OK;
                button2.Visibility = Visibility.Collapsed;
                button3.Visibility = Visibility.Collapsed;
                minWidth          -= 85 * 2;
                result             = MessageBoxResult.OK;
                if (buttonName1 != null)
                {
                    button1.Content = buttonName1;
                }
                break;

                #endregion
                #region MessageBoxButton.OKCancel
            case MessageBoxButton.OKCancel:
                button1.IsDefault  = true;
                button1.Content    = "OK";
                button1.Tag        = MessageBoxResult.OK;
                button2.IsCancel   = true;
                button2.Content    = "Cancel";
                button2.Tag        = MessageBoxResult.Cancel;
                button3.Visibility = Visibility.Collapsed;
                minWidth          -= 85;
                result             = MessageBoxResult.Cancel;
                if (buttonName1 != null)
                {
                    button1.Content = buttonName1;
                }
                if (buttonName2 != null)
                {
                    button2.Content = buttonName2;
                }
                break;

                #endregion
                #region MessageBoxButton.YesNo
            case MessageBoxButton.YesNo:
                button1.IsDefault  = true;
                button1.Content    = "Yes";
                button1.Tag        = MessageBoxResult.Yes;
                button2.IsCancel   = true;
                button2.Content    = "No";
                button2.Tag        = MessageBoxResult.No;
                button3.Visibility = Visibility.Collapsed;
                minWidth          -= 85;
                result             = MessageBoxResult.No;
                if (buttonName1 != null)
                {
                    button1.Content = buttonName1;
                }
                if (buttonName2 != null)
                {
                    button2.Content = buttonName2;
                }
                break;

                #endregion
                #region MessageBoxButton.YesNoCancel
            case MessageBoxButton.YesNoCancel:
                button1.IsDefault = true;
                button1.Content   = "Yes";
                button1.Tag       = MessageBoxResult.Yes;
                button2.Content   = "No";
                button2.Tag       = MessageBoxResult.No;
                button3.IsCancel  = true;
                button3.Content   = "Cancel";
                button3.Tag       = MessageBoxResult.Cancel;
                result            = MessageBoxResult.Cancel;
                if (buttonName1 != null)
                {
                    button1.Content = buttonName1;
                }
                if (buttonName2 != null)
                {
                    button2.Content = buttonName2;
                }
                if (buttonName3 != null)
                {
                    button3.Content = buttonName3;
                }
                break;
                #endregion
            }

            this.Title = title;
            this.textBlockMessage.Text = message;
        }
Esempio n. 18
0
 MessageResult OnUIUpdate(InstallMessage messageType, string message, MessageButtons buttons, MessageIcon icon, MessageDefaultButton defaultButton)
 {
     if (cancelled && installing)
     {
         installing = false;
         return(MessageResult.Cancel);
     }
     return(MessageResult.OK);
 }
Esempio n. 19
0
 public void ShowMessage(string title, TimeSpan timeSpan, MessageIcon icon = MessageIcon.Info)
 {
     MainViewModel.Current.ShowTip(title, icon);
     Task.Delay(timeSpan).ContinueWith(_ => MainViewModel.Current.HideTip());
 }
Esempio n. 20
0
 public MessageResult ProcessMessage(InstallMessage messageType, Record messageRecord, MessageButtons buttons, MessageIcon icon, MessageDefaultButton defaultButton)
 {
     return((MessageResult)MessageBox.Show(
                _shell.shellView,
                messageRecord.ToString(),
                "[ErrorDlg_Title]".LocalizeWith(_shell.Runtime.Localize),
                (MessageBoxButtons)(int)buttons,
                (MessageBoxIcon)(int)icon,
                (MessageBoxDefaultButton)(int)defaultButton));
 }
 /**<summary>Shows the message box.</summary>*/
 public static MessageBoxResult Show(Window window, MessageIcon icon, string message, MessageBoxButton buttons)
 {
     return(Show(window, icon, message, "", buttons));
 }
Esempio n. 22
0
        public AppDialogMessage(string message, string title, MessageButtons buttons, MessageIcon icon)
        {
            InitializeComponent();
            CenterOnParent();

            this.message = message;
            this.Title   = title;
            this.buttons = buttons;
            this.icon    = icon;

            Loaded += OnLoaded;
        }
Esempio n. 23
0
        public static MessageResult Show(string message, string title, MessageButtons buttons, MessageIcon icon)
        {
            AppDialogMessage dialog = new AppDialogMessage(message, title, buttons, icon);

            dialog.ShowDialog();
            return(dialog.Result);
        }
Esempio n. 24
0
 /// <summary>
 /// Processes information and progress messages sent to the user interface.
 /// <para> This method directly mapped to the
 /// <see cref="T:Microsoft.Deployment.WindowsInstaller.IEmbeddedUI.ProcessMessage" />.</para>
 /// </summary>
 /// <param name="messageType">Type of the message.</param>
 /// <param name="messageRecord">The message record.</param>
 /// <param name="buttons">The buttons.</param>
 /// <param name="icon">The icon.</param>
 /// <param name="defaultButton">The default button.</param>
 /// <returns></returns>
 public override MessageResult ProcessMessage(InstallMessage messageType, Record messageRecord, MessageButtons buttons, MessageIcon icon, MessageDefaultButton defaultButton)
 => model?.ProcessMessage(messageType, messageRecord, CurrentStatus.Text) ?? MessageResult.None;
Esempio n. 25
0
 public Notification(MessageIcon icon, string message)
 {
     Icon         = icon;
     this.time    = DateTime.Now;
     this.message = message;
 }
Esempio n. 26
0
 /// <summary>
 /// Processes information and progress messages sent to the user interface.
 /// <para> This method directly mapped to the
 /// <see cref="T:Microsoft.Deployment.WindowsInstaller.IEmbeddedUI.ProcessMessage" />.</para>
 /// </summary>
 /// <param name="messageType">Type of the message.</param>
 /// <param name="messageRecord">The message record.</param>
 /// <param name="buttons">The buttons.</param>
 /// <param name="icon">The icon.</param>
 /// <param name="defaultButton">The default button.</param>
 /// <returns></returns>
 virtual public MessageResult ProcessMessage(InstallMessage messageType, Record messageRecord, MessageButtons buttons, MessageIcon icon, MessageDefaultButton defaultButton)
 {
     return(MessageResult.OK);
 }
Esempio n. 27
0
        private void ShowWarning(string message, MessageIcon icon)
        {
            var iconName = icon == MessageIcon.Info ?
                "Vector.Info" : icon == MessageIcon.Error ?
                "Vector.Error" : "Vector.Warning";

            Dispatcher.Invoke(() =>
            {
                WarningViewBox.Child = (Canvas)FindResource(iconName);
                WarningTextBlock.Text = message;

                WarningGrid.BeginStoryboard(FindResource("ShowWarningStoryboard") as Storyboard);
            });
        }
Esempio n. 28
0
 public void AddNotification(string message, MessageIcon icon)
 {
     notifications.Add(new Notification(message: message, icon: icon));
 }
Esempio n. 29
0
 /// <summary>
 /// Creating meeage icon
 /// </summary>
 /// <param name="iconType"></param>
 /// <returns></returns>
 static TextBlock CreateIcon(MessageIcon iconType)
 {
     if (iconType == MessageIcon.Error)
     {
         TextBlock icon = new TextBlock();
         icon.Text = "⊗";
         icon.Height = 62;
         icon.Width = 74;
         icon.FontSize = 98;
         icon.Foreground = new SolidColorBrush(Colors.Red);
         icon.LineStackingStrategy = LineStackingStrategy.BlockLineHeight;
         icon.LineHeight = 74;
         return icon;
     }
     return new TextBlock();
 }
 /// <summary>
 /// 远程消息弹框
 /// </summary>
 /// <param name="syncContext"></param>
 /// <param name="text"></param>
 /// <param name="title"></param>
 /// <param name="icon"></param>
 public void RemoteMessageBox(SessionSyncContext syncContext, string text, string title, MessageIcon icon)
 {
     HasComWithSendTo(syncContext.Session, MessageHead.S_MAIN_MESSAGEBOX,
                      new MessagePack()
     {
         MessageTitle = title,
         MessageBody  = text,
         MessageIcon  = (byte)icon
     });
 }
Esempio n. 31
0
        /// <summary>
        /// Processes the message.
        /// </summary>
        /// <param name="messageType">Type of the message.</param>
        /// <param name="messageRecord">The message record.</param>
        /// <param name="buttons">The buttons.</param>
        /// <param name="icon">The icon.</param>
        /// <param name="defaultButton">The default button.</param>
        /// <returns></returns>
        public override MessageResult ProcessMessage(InstallMessage messageType, Record messageRecord, MessageButtons buttons, MessageIcon icon, MessageDefaultButton defaultButton)
        {
            switch (messageType)
            {
            case InstallMessage.InstallStart:
            case InstallMessage.InstallEnd:
            {
                waitPrompt.Visible = false;
            }
            break;

            case InstallMessage.ActionStart:
            {
                try
                {
                    //messageRecord[0] - is reserved for FormatString value

                    string message = null;

                    bool simple = true;
                    if (simple)
                    {
                        /*
                         * messageRecord[2] unconditionally contains the string to display
                         *
                         * Examples:
                         *
                         * messageRecord[0]    "Action 23:14:50: [1]. [2]"
                         * messageRecord[1]    "InstallFiles"
                         * messageRecord[2]    "Copying new files"
                         * messageRecord[3]    "File: [1],  Directory: [9],  Size: [6]"
                         *
                         * messageRecord[0]    "Action 23:15:21: [1]. [2]"
                         * messageRecord[1]    "RegisterUser"
                         * messageRecord[2]    "Registering user"
                         * messageRecord[3]    "[1]"
                         *
                         */
                        if (messageRecord.FieldCount >= 3)
                        {
                            message = messageRecord[2].ToString();
                        }
                    }
                    else
                    {
                        message = messageRecord.FormatString;
                        if (message.IsNotEmpty())
                        {
                            for (int i = 1; i < messageRecord.FieldCount; i++)
                            {
                                message = message.Replace("[" + i + "]", messageRecord[i].ToString());
                            }
                        }
                        else
                        {
                            message = messageRecord[messageRecord.FieldCount - 1].ToString();
                        }
                    }

                    if (message.IsNotEmpty())
                    {
                        currentAction.Text = currentActionLabel.Text + " " + message;
                    }
                }
                catch { }
            }
            break;
            }
            return(MessageResult.OK);
        }
Esempio n. 32
0
 MessageResult IMessageBoxService.Show(string messageBoxText, string caption, MessageButton button, MessageIcon icon, MessageResult defaultResult) {
     return XtraMessageBox.Show(messageBoxText, caption, button.ToMessageBoxButtons(), icon.ToMessageBoxIcon(), defaultResult.ToMessageBoxDefaultButton(button)).ToMessageResult();
 }
        void ReleaseDesignerOutlets()
        {
            if (Category != null)
            {
                Category.Dispose();
                Category = null;
            }

            if (Details != null)
            {
                Details.Dispose();
                Details = null;
            }

            if (DetailView != null)
            {
                DetailView.Dispose();
                DetailView = null;
            }

            if (HeaderHeight != null)
            {
                HeaderHeight.Dispose();
                HeaderHeight = null;
            }

            if (Loader != null)
            {
                Loader.Dispose();
                Loader = null;
            }

            if (MessageIcon != null)
            {
                MessageIcon.Dispose();
                MessageIcon = null;
            }

            if (ReceiptDate != null)
            {
                ReceiptDate.Dispose();
                ReceiptDate = null;
            }

            if (RichContentView != null)
            {
                RichContentView.Dispose();
                RichContentView = null;
            }

            if (Sender != null)
            {
                Sender.Dispose();
                Sender = null;
            }

            if (Subject != null)
            {
                Subject.Dispose();
                Subject = null;
            }

            if (TextView != null)
            {
                TextView.Dispose();
                TextView = null;
            }

            if (Toolbar != null)
            {
                Toolbar.Dispose();
                Toolbar = null;
            }

            if (ToolbarBottom != null)
            {
                ToolbarBottom.Dispose();
                ToolbarBottom = null;
            }

            if (TransitionButton != null)
            {
                TransitionButton.Dispose();
                TransitionButton = null;
            }

            if (WebView != null)
            {
                WebView.Dispose();
                WebView = null;
            }
        }
Esempio n. 34
0
        public static Result ShowMessageBox(string message, string caption, MessageType messageType, MessageIcon messageIcon)
        {
            MessageBoxButton messageButton = MessageBoxButton.OK;

            switch (messageType)
            {
            case MessageType.OK:
                messageButton = MessageBoxButton.OK;
                break;

            case MessageType.OkCancel:
                messageButton = MessageBoxButton.OKCancel;
                break;

            case MessageType.YesNo:
                messageButton = MessageBoxButton.YesNo;
                break;

            case MessageType.YesNoCancel:
                messageButton = MessageBoxButton.YesNoCancel;
                break;

            default:
                break;
            }

            MessageBoxImage messageImage = MessageBoxImage.Information;

            switch (messageIcon)
            {
            case MessageIcon.Information:
                messageImage = MessageBoxImage.Information;
                break;

            case MessageIcon.Warning:
                messageImage = MessageBoxImage.Warning;
                break;

            case MessageIcon.Error:
                messageImage = MessageBoxImage.Error;
                break;

            case MessageIcon.Question:
                messageImage = MessageBoxImage.Question;
                break;

            default:
                break;
            }

            switch (MessageBox.Show(message, caption, messageButton, messageImage))
            {
            case MessageBoxResult.OK:
                return(Result.Ok);

            case MessageBoxResult.Cancel:
                return(Result.Cancel);

            case MessageBoxResult.Yes:
                return(Result.Yes);

            case MessageBoxResult.No:
                return(Result.No);

            case MessageBoxResult.None:
                return(Result.None);

            default:
                return(Result.None);
            }
        }
Esempio n. 35
0
        /// <summary>
        /// Handler for external UI messages.
        /// </summary>
        /// <param name="messageType">The type of message.</param>
        /// <param name="messageRecord">The message details.</param>
        /// <param name="buttons">Buttons to show (unused).</param>
        /// <param name="icon">The icon to show (unused).</param>
        /// <param name="defaultButton">The default button (unused).</param>
        /// <returns>How the message was handled.</returns>
        public MessageResult UIRecordHandler(
            InstallMessage messageType,
            Record messageRecord,
            MessageButtons buttons,
            MessageIcon icon,
            MessageDefaultButton defaultButton)
        {
#if False
            Console.WriteLine("Message type {0}: {1}", messageType.ToString(), this.session.FormatRecord(messageRecord));
#endif

            if (!this.session.IsClosed && 1 <= messageRecord.FieldCount)
            {
                switch (messageType)
                {
                    case InstallMessage.ActionStart:
                        // only try to interpret the messages if they're coming from WixRunImmediateUnitTests
                        string action = messageRecord.GetString(1);
                        this.runningTests = Constants.LuxCustomActionName == action;
                        return MessageResult.OK;

                    case InstallMessage.User:
                        if (this.runningTests)
                        {
                            string message = messageRecord.ToString();
                            int id = messageRecord.GetInteger(1);

                            if (Constants.TestIdMinimumSuccess <= id && Constants.TestIdMaximumSuccess >= id)
                            {
                                this.OnMessage(NitVerboses.TestPassed(message));
                                ++this.passes;
                            }
                            else if (Constants.TestIdMinimumFailure <= id && Constants.TestIdMaximumFailure >= id)
                            {
                                this.OnMessage(NitErrors.TestFailed(message));
                                ++this.failures;
                            }
                        }

                        return MessageResult.OK;

                    case InstallMessage.Error:
                    case InstallMessage.FatalExit:
                        this.OnMessage(NitErrors.PackageFailed(this.session.FormatRecord(messageRecord)));
                        return MessageResult.Error;
                }
            }

            return MessageResult.OK;
        }
Esempio n. 36
0
        /// <summary>
        /// Processes information and progress messages sent to the user interface.
        /// <para> This method directly mapped to the
        /// <see cref="T:Microsoft.Deployment.WindowsInstaller.IEmbeddedUI.ProcessMessage" />.</para>
        /// </summary>
        /// <param name="messageType">Type of the message.</param>
        /// <param name="messageRecord">The message record.</param>
        /// <param name="buttons">The buttons.</param>
        /// <param name="icon">The icon.</param>
        /// <param name="defaultButton">The default button.</param>
        /// <returns></returns>
        public MessageResult ProcessMessage(InstallMessage messageType, Record messageRecord, MessageButtons buttons, MessageIcon icon, MessageDefaultButton defaultButton)
        {
            try
            {
                UACRevealer.Exit();

                this.progressCounter.ProcessMessage(messageType, messageRecord);

                OnProgress((int)Math.Round(100 * this.progressCounter.Progress));

                switch (messageType)
                {
                case InstallMessage.Progress: break;

                case InstallMessage.Error:
                case InstallMessage.Warning:
                case InstallMessage.User:
                case InstallMessage.Info:
                default:
                {
                    if (messageType.IsOneOf(InstallMessage.Error, InstallMessage.Warning, InstallMessage.User))
                    {
                        MessageBox.Show(
                            this.shellView,
                            messageRecord.ToString(),
                            "[ErrorDlg_Title]".LocalizeWith(Runtime.Localize),
                            (MessageBoxButtons)(int)buttons,
                            (MessageBoxIcon)(int)icon,
                            (MessageBoxDefaultButton)(int)defaultButton);
                    }

                    if (messageType == InstallMessage.Info)
                    {
                        string msg_data = messageRecord.ToString();
                        if (msg_data.Contains("User canceled installation") ||
                            msg_data.Contains("User cancelled installation"))         //there is no other way
                        {
                            UserInterrupted = true;
                        }
                    }

                    if (messageType == InstallMessage.Error)
                    {
                        ErrorDetected = true;
                        Errors.Add(messageRecord.ToString());
                    }

                    if (messageType == InstallMessage.InstallEnd)
                    {
                        try
                        {
                            string lastValue = messageRecord[messageRecord.FieldCount].ToString();         //MSI record is actually 1-based
                            ErrorDetected   = (lastValue == "3");
                            UserInterrupted = (lastValue == "2");
                        }
                        catch { }        //nothing we can do really
                        finished = true;
                    }

                    this.LogMessage("{0}: {1}", messageType, messageRecord);
                    break;
                }
                }

                if (this.canceled)
                {
                    return(MessageResult.Cancel);
                }
            }
            catch (Exception ex)
            {
                this.LogMessage(ex.ToString());
                this.LogMessage(ex.StackTrace);
            }

            var result = MessageResult.OK;

            InUIThread(() =>
            {
                if (CurrentDialog != null)
                {
                    result = CurrentDialog.ProcessMessage(messageType, messageRecord, buttons, icon, defaultButton);
                }
            });
            return(result);
        }
Esempio n. 37
0
 /// <summary>
 /// Processes information and progress messages sent to the user interface.
 /// </summary>
 /// <param name="messageType">Message type.</param>
 /// <param name="messageRecord">Record that contains message data.</param>
 /// <param name="buttons">Message buttons.</param>
 /// <param name="icon">Message box icon.</param>
 /// <param name="defaultButton">Message box default button.</param>
 /// <returns>
 /// Result of processing the message.
 /// </returns>
 /// <remarks>
 /// <p>
 /// Win32 MSI API:
 /// <a href="http://msdn.microsoft.com/library/en-us/msi/setup/embeddeduihandler.asp">EmbeddedUIHandler</a></p>
 /// </remarks>
 public MessageResult ProcessMessage(InstallMessage messageType, Record messageRecord, MessageButtons buttons, MessageIcon icon, MessageDefaultButton defaultButton)
 {
     return shell.ProcessMessage(messageType, messageRecord, buttons, icon, defaultButton);
 }
Esempio n. 38
0
 public static Task Show(string message, MessageIcon messageIcon, Window window,
                         MessageButton messageButton = MessageButton.OKCancel, string title = "HATE")
 {
     _ = _Show(message, messageButton, messageIcon, title, window);
     return(Task.CompletedTask);
 }
        public void Update(string message, string title, MessageOptions option, MessageIcon icon)
        {
            if (String.IsNullOrWhiteSpace(message))
                throw new ArgumentException("message");
            if (String.IsNullOrWhiteSpace(title))
                throw new ArgumentException("title");
            if (option == MessageOptions.None)
                throw new ArgumentException("option");
            if (icon == MessageIcon.None)
                throw new ArgumentException("icon");

            Title = title;
            Message = message;
            Option = option;
            Result = MessageResult.None;

            switch (icon)
            {
                case MessageIcon.Question:
                    Icon = SystemIcons.Question;
                    break;
                case MessageIcon.Information:
                    Icon = SystemIcons.Information;
                    break;
                case MessageIcon.Warning:
                    Icon = SystemIcons.Warning;
                    break;
                case MessageIcon.Error:
                    Icon = SystemIcons.Error;
                    break;
                default:
                    throw new NotImplementedException(icon.ToString());
            }
        }
Esempio n. 40
0
 public static async Task <MessageResult> Show(string message, MessageButton messageButton,
                                               MessageIcon messageIcon, Window window, string title = "HATE")
 {
     return(await _Show(message, messageButton, messageIcon, title, window));
 }
Esempio n. 41
0
 /// <summary>
 /// Processes information and progress messages sent to the user interface.
 /// <para> This method directly mapped to the
 /// <see cref="T:Microsoft.Deployment.WindowsInstaller.IEmbeddedUI.ProcessMessage" />.</para>
 /// </summary>
 /// <param name="messageType">Type of the message.</param>
 /// <param name="messageRecord">The message record.</param>
 /// <param name="buttons">The buttons.</param>
 /// <param name="icon">The icon.</param>
 /// <param name="defaultButton">The default button.</param>
 /// <returns></returns>
 public virtual MessageResult ProcessMessage(InstallMessage messageType, Record messageRecord, MessageButtons buttons, MessageIcon icon, MessageDefaultButton defaultButton)
 {
     return MessageResult.OK;
 }
Esempio n. 42
0
        private MessageResponse ShowMessage(string message, string title, MessageOptions buttons, MessageIcon icon)
        {
            var interaction = new MessageInteraction(message, title, buttons, icon);

            _interactionInvoker.Invoke(interaction);
            return(interaction.Response);
        }
 public static MessageResult ShowMessage(this IMessageBoxService service, string messageBoxText, string caption, MessageButton button, MessageIcon icon) {
     VerifyService(service);
     return service.Show(messageBoxText, caption, button, icon, MessageResult.None);
 }
Esempio n. 44
0
 /// <summary>
 /// Processes information and progress messages sent to the user interface.
 /// </summary>
 /// <param name="messageType">Message type.</param>
 /// <param name="messageRecord">Record that contains message data.</param>
 /// <param name="buttons">Message box buttons.</param>
 /// <param name="icon">Message box icon.</param>
 /// <param name="defaultButton">Message box default button.</param>
 /// <returns>Result of processing the message.</returns>
 public MessageResult ProcessMessage(InstallMessage messageType, Record messageRecord,
     MessageButtons buttons, MessageIcon icon, MessageDefaultButton defaultButton)
 {
     // Synchronously send the message to the setup wizard window on its thread.
     object result = this.setupWizard.Dispatcher.Invoke(DispatcherPriority.Send,
         new Func<MessageResult>(delegate()
         {
             return this.setupWizard.ProcessMessage(messageType, messageRecord, buttons, icon, defaultButton);
         }));
     return (MessageResult) result;
 }
Esempio n. 45
0
        /// <summary>
        /// Creating content of the message
        /// </summary>
        /// <param name="_title"></param>
        /// <param name="_message"></param>
        /// <param name="window"></param>
        /// <param name="messageButtons"></param>
        /// <param name="messageIcon"></param>
        static void CreateContentGrid(string _title, string _message, Window window,
            MessageButtons messageButtons = MessageButtons.OK,
            MessageIcon messageIcon = MessageIcon.None)
        {
            content_grid = new Grid();
            content_grid.Background = new SolidColorBrush(Colors.White);
            RowDefinition rd = new RowDefinition();
            rd.Height = new GridLength(40, GridUnitType.Star);
            rd.MinHeight = 40;

            RowDefinition rd1 = new RowDefinition();
            rd1.Height = GridLength.Auto;

            RowDefinition rd2 = new RowDefinition();
            rd2.Height = new GridLength(42, GridUnitType.Star);
            rd2.MinHeight = 42;

            ColumnDefinition cd = new ColumnDefinition();
            cd.Width = new GridLength(50, GridUnitType.Star);

            ColumnDefinition cd1 = new ColumnDefinition();
            cd1.Width = new GridLength(100);

            content_grid.ColumnDefinitions.Add(cd);
            content_grid.ColumnDefinitions.Add(cd1);

            content_grid.RowDefinitions.Add(rd);
            content_grid.RowDefinitions.Add(rd1);
            content_grid.RowDefinitions.Add(rd2);
            //Creating title
            Label title = new Label() { FontSize = 32, FontWeight = FontWeights.Light, VerticalAlignment = VerticalAlignment.Center, VerticalContentAlignment = System.Windows.VerticalAlignment.Center };
            title.Content = _title.ToString();
            Grid.SetRow(title, 0);
            content_grid.Children.Add(title);

            //Creating message
            StackPanel stc = new StackPanel();
            Grid.SetRow(stc, 1);
            TextBlock message = new TextBlock() { Margin = new Thickness(5, 5, 5, 5), FontSize = 16, TextWrapping = TextWrapping.Wrap };
            //message.MaxHeight = _mainWindow.Height - 120;
            message.Text = _message;
            message.TextWrapping = TextWrapping.Wrap;
            ScrollViewer scroll = new ScrollViewer();
            scroll.VerticalScrollBarVisibility = ScrollBarVisibility.Auto;
            scroll.HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled;
            scroll.Content = message;
            scroll.MaxHeight = _mainWindow.Height - 120;
            stc.Children.Add(scroll);
            content_grid.Children.Add(stc);

            //Creating message Icon
            StackPanel stc1 = new StackPanel();
            Grid.SetRow(stc1, 1);
            Grid.SetColumn(stc1, 1);
            switch (messageIcon)
            {
                case MessageIcon.Exclamation:
                    stc1.Children.Add(new Icons.Controls.ExclamationMark());
                    break;
                case MessageIcon.Error:
                    stc1.Children.Add(new Icons.Controls.Error());
                    break;
                case MessageIcon.Information:
                    stc1.Children.Add(new Icons.Controls.InformationMark());
                    break;
                case MessageIcon.Question:
                    stc1.Children.Add(new Icons.Controls.QuestionMark());
                    break;
            }
            content_grid.Children.Add(stc1);

            //Creating buttons
            //StackPanel stc2 = new StackPanel() { Orientation = Orientation.Horizontal, HorizontalAlignment = HorizontalAlignment.Right, };
            //Grid.SetRow(stc2, 2);
            //CButton btn_ok = new CButton();
            //btn_ok.Content = "OK";
            //btn_ok.Height = 30;
            //btn_ok.Width = 80;
            //btn_ok.Margin = new Thickness(0, 0, 10, 0);
            //btn_ok.OnClick += CButton_Loaded_1;
            //stc2.Children.Add();
            content_grid.Children.Add(CreateButtons(messageButtons));
            content_grid.Width = (window.Width * 70 / 100);

            Grid.SetRow(content_grid, 1);
            Grid content_grid1 = new Grid();
            content_grid1.Background = new SolidColorBrush(Colors.White);
            Grid.SetRow(content_grid1, 1);
            main_grid.Children.Add(content_grid1);
            main_grid.Children.Add(content_grid);
        }
Esempio n. 46
0
        public void ShowMessage(string Message, MessageBoxIcon Icon, MessageIcon MIcon, bool IsTimerEnabled, bool IsAboutBox, bool CloseButton)
        {
            if (IsTimerEnabled)
            {
                MsgTimer.Start();
            }
            if (IsAboutBox)
            {
                MsgLbl.Hide();
                PicStrips.BackColor = Color.DeepSkyBlue;

            }
            else
            {
                MsgLbl.Show();
                MsgLbl.Text = Message;

                #region MessageBoxIcon
                if (Icon == MessageBoxIcon.Error)
                {
                    PicStrips.BackColor = Color.Red;
                }

                if (Icon == MessageBoxIcon.Information)
                {
                    PicStrips.BackColor = Color.DeepSkyBlue;
                }

                if (Icon == MessageBoxIcon.Question)
                {
                    PicStrips.BackColor = Color.DeepSkyBlue;
                }

                if (Icon == MessageBoxIcon.Successful)
                {
                    PicStrips.BackColor = Color.SeaGreen;
                }

                if (Icon == MessageBoxIcon.Warning)
                {
                    PicStrips.BackColor = Color.Yellow;
                }
                #endregion

                #region MessageIcon
                {

                    if (MIcon == MessageIcon.Decryption)
                    {
                        AppLogo.BackgroundImage = Chiave.Properties.Resources.Pic_UnLock;
                    }

                    if (MIcon == MessageIcon.Encryption)
                    {
                        AppLogo.BackgroundImage = Chiave.Properties.Resources.Pic_Lock;
                    }

                    if (MIcon == MessageIcon.Options)
                    {
                        AppLogo.BackgroundImage = Chiave.Properties.Resources.Pic_Options;
                    }

                    if (MIcon == MessageIcon.Wipe)
                    {
                        AppLogo.BackColor = Color.Yellow;
                    }
                }
            }

                #endregion

            MsgPnl.Show();
            MsgPnl.BringToFront();
        }
Esempio n. 47
0
 /// <summary>
 /// Creating main grid
 /// </summary>
 /// <param name="window"></param>
 /// <param name="title"></param>
 /// <param name="prompt"></param>
 /// <param name="messageButtons"></param>
 static void CreateMainGrid(Window window, string title, string prompt, MessageButtons messageButtons, MessageIcon messageIcon)
 {
     main_grid = new Grid();
     RowDefinition rd = new RowDefinition();
     rd.Height = new GridLength(32, GridUnitType.Star);
     RowDefinition rd1 = new RowDefinition();
     rd1.Height = GridLength.Auto;
     RowDefinition rd2 = new RowDefinition();
     rd2.Height = new GridLength(32, GridUnitType.Star);
     main_grid.RowDefinitions.Add(rd);
     main_grid.RowDefinitions.Add(rd1);
     main_grid.RowDefinitions.Add(rd2);
     CreateBackgroundGrid();
     CreateContentGrid(title, prompt, window, messageButtons, messageIcon);
 }
Esempio n. 48
0
        public MessageDialogResult ShowDialog(Window owner, string message, string title, MessageButtons buttons, MessageIcon icon)
        {
            if (owner == null)
            {
                var windowInteropHelper = new WindowInteropHelper(this);
                windowInteropHelper.Owner = Process.GetCurrentProcess().MainWindowHandle;
            }
            else
            {
                this.Owner = owner;
            }

            return(ShowDialog(message, title, buttons, icon));
        }
Esempio n. 49
0
 public static void SetMessage(MessageType messageType, MessageBehaviors behavior, string message, string key,string caption, MessageButton? messageButtons, MessageIcon? messageIcon)
 {
     if (caption == null || caption.Trim() == string.Empty)
         caption = messageType.ToString();
     if (!messageButtons.HasValue)
         messageButtons = MessageButton.Ok;
     if (!messageIcon.HasValue)
     {
         switch (messageType)
         {
             case MessageType.Error:
                 messageIcon = MessageIcon.Error;
                 break;
             case MessageType.Warning:
                 messageIcon = MessageIcon.Warning;
                 break;
             case MessageType.Info:
                 messageIcon = MessageIcon.Information;
                 break;
         }
     }
     SessionMessage sessionMessage = new SessionMessage(messageType, behavior, message, key,caption, messageButtons, messageIcon);
     ISessionMessageProvider provider = IoC.GetService<ISessionMessageProvider>();
     provider.SetMessage(sessionMessage);
 }
Esempio n. 50
0
        private void ShowMessage(string text, string title, MessageOptions buttons, MessageIcon icon)
        {
            var messageInteraction = new MessageInteraction(text, title, buttons, icon);

            _interactionInvoker.Invoke(messageInteraction);
        }
Esempio n. 51
0
 /// <summary>
 /// Processes information and progress messages sent to the user interface.
 /// </summary>
 /// <param name="messageType">Message type.</param>
 /// <param name="messageRecord">Record that contains message data.</param>
 /// <param name="buttons">Message buttons.</param>
 /// <param name="icon">Message box icon.</param>
 /// <param name="defaultButton">Message box default button.</param>
 /// <returns>
 /// Result of processing the message.
 /// </returns>
 /// <remarks>
 /// <p>
 /// Win32 MSI API:
 /// <a href="http://msdn.microsoft.com/library/en-us/msi/setup/embeddeduihandler.asp">EmbeddedUIHandler</a></p>
 /// </remarks>
 public MessageResult ProcessMessage(InstallMessage messageType, Record messageRecord, MessageButtons buttons, MessageIcon icon, MessageDefaultButton defaultButton)
 {
     return(shell.ProcessMessage(messageType, messageRecord, buttons, icon, defaultButton));
 }
        /// <summary>
        /// Processes the message.
        /// </summary>
        /// <param name="messageType">Type of the message.</param>
        /// <param name="messageRecord">The message record.</param>
        /// <param name="buttons">The buttons.</param>
        /// <param name="icon">The icon.</param>
        /// <param name="defaultButton">The default button.</param>
        /// <returns></returns>
        public override MessageResult ProcessMessage(InstallMessage messageType, Record messageRecord, MessageButtons buttons, MessageIcon icon, MessageDefaultButton defaultButton)
        {
            switch (messageType)
            {
            case InstallMessage.ActionStart:
            {
                try
                {
                    //messageRecord[0] - is reserved for FormatString value

                    string message = null;

                    bool simple = true;
                    if (simple)
                    {
                        for (int i = messageRecord.FieldCount - 1; i > 0; i--)
                        {
                            message = messageRecord[i].ToString();
                        }
                    }
                    else
                    {
                        message = messageRecord.FormatString;
                        if (message.IsNotEmpty())
                        {
                            for (int i = 1; i < messageRecord.FieldCount; i++)
                            {
                                message = message.Replace("[" + i + "]", messageRecord[i].ToString());
                            }
                        }
                        else
                        {
                            message = messageRecord[messageRecord.FieldCount - 1].ToString();
                        }
                    }


                    if (message.IsNotEmpty())
                    {
                        currentAction.Text = currentActionLabel.Text + " " + message;
                    }
                }
                catch { }
            }
            break;
            }
            return(MessageResult.OK);
        }
Esempio n. 53
0
 MessageResult IMessageBoxService.Show(string messageBoxText, string caption, MessageButton button, MessageIcon icon, MessageResult defaultResult)
 {
     MessageBoxText = messageBoxText;
     Caption        = caption;
     Button         = button;
     Icon           = icon;
     DefaultResult  = defaultResult;
     return(Result);
 }
Esempio n. 54
0
        public MessageDialogResult ShowDialog(string message, string title, MessageButtons buttons, MessageIcon icon)
        {
            this.Title = title;
            this.MessageTextBlock.Text = message;

            if (buttons == MessageButtons.OK)
            {
                this.YesButton.Visibility    = Visibility.Collapsed;
                this.NoButton.Visibility     = Visibility.Collapsed;
                this.CancelButton.Visibility = Visibility.Collapsed;
            }
            else if (buttons == MessageButtons.OKCancel)
            {
                this.YesButton.Visibility = Visibility.Collapsed;
                this.NoButton.Visibility  = Visibility.Collapsed;
            }
            else if (buttons == MessageButtons.YesNoCancel)
            {
                this.OKButton.Visibility = Visibility.Collapsed;
            }
            else if (buttons == MessageButtons.YesNo)
            {
                this.OKButton.Visibility     = Visibility.Collapsed;
                this.CancelButton.Visibility = Visibility.Collapsed;
            }

            if (icon == MessageIcon.Error)
            {
                this.MessageImage.Source = iconToImageSource(SystemIcons.Error);
            }
            else if (icon == MessageIcon.Warning)
            {
                this.MessageImage.Source = iconToImageSource(SystemIcons.Warning);
            }
            else if (icon == MessageIcon.Information)
            {
                this.MessageImage.Source = iconToImageSource(SystemIcons.Information);
            }
            else
            {
                this.MessageImage.Visibility = Visibility.Collapsed;
            }

            this.ShowDialog();
            return(dialogResult);
        }
 internal static MessageChoice Show(Window parent, MessageIcon icon, string title, string content, MessageChoice choices, string help, bool enableDontAsk, MessageChoice defaultChoice)
 {
     var window = new DialogViewModel();
     window.ShowDialog(parent, icon, title, content, choices, help, enableDontAsk, defaultChoice);
     return window.Result;
 }
Esempio n. 56
0
        private void SetControlLocationSize(MessageIcon icon, MessageButton btn)
        {
            Size messageSize = TextRenderer.MeasureText(lblMsg.Text, lblMsg.Font);

            int fmwith   = this.Width;
            int fmheight = this.Height;

            lblMsg.Width = messageSize.Width;
            if (icon == MessageIcon.None)
            {
                pictureEditIcon.Hide();
                lblMsg.Left = 8;
                fmwith      = lblMsg.Width + 8 + 8;

                if (fmwith < 75 + 75 + 16)
                {
                    fmwith       = 75 + 75 + 16;
                    lblMsg.Width = fmwith - 8 - 8;
                }
            }
            else
            {
                pictureEditIcon.Left = 8;
                lblMsg.Left          = pictureEditIcon.Left + pictureEditIcon.Width + 2;
                fmwith = pictureEditIcon.Left + pictureEditIcon.Width + 2 + lblMsg.Width + 8;
                if (fmwith < 75 + 75 + 16)
                {
                    fmwith       = 75 + 75 + 16;
                    lblMsg.Width = fmwith - pictureEditIcon.Left - pictureEditIcon.Width - 2 - 8;
                }
            }

            lblMsg.Top          = 8;
            lblMsg.Height       = messageSize.Height > pictureEditIcon.Height ? messageSize.Height : pictureEditIcon.Height;
            fmheight            = 8 + lblMsg.Height + 3 + 25 + 8;
            pictureEditIcon.Top = 8 + lblMsg.Height / 2 - pictureEditIcon.Height / 2;

            btnOK.Height     = 25;
            btnCancel.Height = 25;
            btnOK.Top        = 8 + lblMsg.Height + 3;
            btnCancel.Top    = btnOK.Top;
            btnOK.Width      = 75;
            btnCancel.Width  = 75;

            switch (btn)
            {
            case MessageButton.None:
                btnOK.Hide();
                btnCancel.Hide();
                break;

            case MessageButton.Ok:
                btnCancel.Hide();
                btnOK.Show();
                btnOK.Left = fmwith - 8 - btnOK.Width;
                break;

            case MessageButton.Cancel:
                btnOK.Hide();
                btnCancel.Show();
                btnCancel.Left = fmwith - 8 - btnCancel.Width;
                break;

            case MessageButton.OkCancel:
                btnOK.Show();
                btnCancel.Show();
                btnCancel.Left = fmwith - 8 - btnCancel.Width;
                btnOK.Left     = btnCancel.Left - 3 - btnOK.Width;
                break;
            }

            this.ClientSize = new Size(fmwith, fmheight);
        }
Esempio n. 57
0
 public Notification(MessageIcon icon, String textMessage) : this()
 {
     Init(textMessage, icon);
 }
Esempio n. 58
0
        /// <summary>
        /// Processes information and progress messages sent to the user interface.
        /// <para> This method directly mapped to the
        /// <see cref="T:Microsoft.Deployment.WindowsInstaller.IEmbeddedUI.ProcessMessage" />.</para>
        /// </summary>
        /// <param name="messageType">Type of the message.</param>
        /// <param name="messageRecord">The message record.</param>
        /// <param name="buttons">The buttons.</param>
        /// <param name="icon">The icon.</param>
        /// <param name="defaultButton">The default button.</param>
        /// <returns></returns>
        public MessageResult ProcessMessage(InstallMessage messageType, Record messageRecord, MessageButtons buttons, MessageIcon icon, MessageDefaultButton defaultButton)
        {
            try
            {
                this.progressCounter.ProcessMessage(messageType, messageRecord);

                if (CurrentDialog != null)
                {
                    InUIThread(() => CurrentDialog.OnProgress((int)Math.Round(100 * this.progressCounter.Progress)));
                }

                switch (messageType)
                {
                case InstallMessage.Progress: break;

                case InstallMessage.Error:
                case InstallMessage.Warning:
                case InstallMessage.Info:
                default:
                {
                    if (messageType == InstallMessage.Info)
                    {
                        if (messageRecord.ToString().Contains("User canceled installation"))         //there is no other way
                        {
                            UserInterrupted = true;
                        }
                    }

                    if (messageType == InstallMessage.Error)
                    {
                        ErrorDetected = true;
                    }

                    if (messageType == InstallMessage.InstallEnd)
                    {
                        try
                        {
                            string lastValue = messageRecord[messageRecord.FieldCount].ToString();         //MSI record is actually 1-based
                            ErrorDetected   = (lastValue == "3");
                            UserInterrupted = (lastValue == "2");
                        }
                        catch { }        //nothing we can do really
                        finished = true;
                    }

                    this.LogMessage("{0}: {1}", messageType, messageRecord);
                    break;
                }
                }

                if (this.canceled)
                {
                    return(MessageResult.Cancel);
                }
            }
            catch (Exception ex)
            {
                this.LogMessage(ex.ToString());
                this.LogMessage(ex.StackTrace);
            }

            var result = MessageResult.OK;

            InUIThread(() =>
            {
                if (CurrentDialog != null)
                {
                    result = CurrentDialog.ProcessMessage(messageType, messageRecord, buttons, icon, defaultButton);
                }
            });
            return(result);
        }
Esempio n. 59
0
 public DialogMessage(string caption, string message, MessageIcon icon)
 {
     Caption = caption;
     Message = message;
     Icon = icon;
 }
Esempio n. 60
0
 public Notification(MessageIcon icon, String textMessage, int timeInterval) : this(icon, textMessage)
 {
     timer1.Interval = timeInterval;
 }