Exemplo n.º 1
0
        /// <summary>
        /// Shows a message in the UI of the specified type.
        /// </summary>
        /// <param name="text">The contents in the message box</param>
        /// <param name="caption">The title of the box</param>
        /// <param name="boxButton">The type of the buttons available</param>
        /// <param name="boxIcon">The icon of the box</param>
        /// <returns></returns>
        public DialogResult Message(string text, string caption,
                                    MessageBoxButtons boxButton, MessageBoxIcon boxIcon)
        {
            DialogResult result = new DialogResult();

            if (boxButton.Equals(MessageBoxButtons.OK) &&
                boxIcon.Equals(MessageBoxIcon.Error))
            {
                result = MessageBox.Show(text, caption, boxButton, boxIcon);
            }

            if (boxButton.Equals(MessageBoxButtons.YesNo) &&
                boxIcon.Equals(MessageBoxIcon.Warning))
            {
                result = MessageBox.Show(text, caption, boxButton, boxIcon);
            }

            if (boxButton.Equals(MessageBoxButtons.OK) &&
                boxIcon.Equals(MessageBoxIcon.Information))
            {
                result = MessageBox.Show(text, caption, boxButton, boxIcon);
            }

            if (boxButton.Equals(MessageBoxButtons.YesNoCancel) &&
                boxIcon.Equals(MessageBoxIcon.Warning))
            {
                result = MessageBox.Show(text, caption, boxButton, boxIcon);
            }
            return(result);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Initializes a new instance of the MessageForm class.
 /// </summary>
 /// <param name="errorMsg">the error Message</param>
 /// <param name="headerText">the Header Text</param>
 /// <param name="errorButtons">errorButtons</param>
 /// <param name="errorType">errorType</param>
 public TerraScanMessageBox(string errorMsg, string headerText, MessageBoxButtons errorButtons, MessageBoxIcon errorType)
 {
     this.InitializeComponent();
     this.formHeaderText = headerText;
     this.errorMessage   = errorMsg.Replace("\\n", "\n");
     if (errorButtons.Equals(MessageBoxButtons.OK))
     {
         this.PanelOk.Visible          = true;
         this.PanelYesNo.Visible       = false;
         this.PanelYesNoCancel.Visible = false;
         this.PanelOkCancel.Visible    = false;
     }
     else if (errorButtons.Equals(MessageBoxButtons.YesNo))
     {
         this.PanelOk.Visible          = false;
         this.PanelYesNo.Visible       = true;
         this.PanelYesNoCancel.Visible = false;
         this.PanelOkCancel.Visible    = false;
     }
     else if (errorButtons.Equals(MessageBoxButtons.YesNoCancel))
     {
         this.PanelOk.Visible          = false;
         this.PanelYesNo.Visible       = false;
         this.PanelYesNoCancel.Visible = true;
         this.PanelOkCancel.Visible    = false;
     }
     else if (errorButtons.Equals(MessageBoxButtons.OKCancel))
     {
         this.PanelOk.Visible          = false;
         this.PanelYesNo.Visible       = false;
         this.PanelYesNoCancel.Visible = false;
         this.PanelOkCancel.Visible    = true;
     }
     else
     {
         this.PanelOk.Visible          = false;
         this.PanelYesNo.Visible       = false;
         this.PanelYesNoCancel.Visible = false;
         this.PanelOkCancel.Visible    = false;
     }
     this.MessageLabel.Text = errorMsg;
     if (this.MessageLabel.Height + 50 >= 120)
     {
         this.Height = this.MessageLabel.Height + 100;
     }
     else
     {
         this.MessageLabel.Height = 153;
     }
     this.ErrorTypeIconPictureBox.Image = this.ErrorTypeIconList.Images[errorType.ToString()];
 }
Exemplo n.º 3
0
        // =================================================================================
        // General and "global" functions 
        // =================================================================================
        #region General

        // Note about thread guards: The prologue "if(InvokeRequired) {something long}" at a start of a function, 
        // makes the function safe to call from another thread.
        // See http://stackoverflow.com/questions/661561/how-to-update-the-gui-from-another-thread-in-c, 
        // "MajesticRa"'s answer near the bottom of first page



        #region MessageDialogs
        // =================================================================================
        // Thread safe dialog box:
        // (see http://stackoverflow.com/questions/559252/does-messagebox-show-automatically-marshall-to-the-ui-thread )

        public DialogResult ShowMessageBox(String message, String header, MessageBoxButtons buttons) {
            if (InvokeRequired) {
                return (DialogResult)Invoke(new PassStringStringReturnDialogResultDelegate(ShowMessageBox), message, header, buttons);
            }
            if (buttons.Equals(MessageBoxButtons.OK)) {
                return ShowSimpleMessageBox(message);
            }
            return MessageBox.Show(this, message, header, buttons);
        }
Exemplo n.º 4
0
        public static DialogResult ShowDialogMessageBox(string text, string title, MessageBoxButtons buttons = MessageBoxButtons.OK, MessageBoxIcon icon = MessageBoxIcon.Error)
        {
            PublicFunction.CloseSpecificProcess("Attention");

            if (newMessageBox == null)
            {
                newMessageBox = new DialogMessageBox();
            }
            newMessageBox.textBoxMessage.Text = text;
            newMessageBox.Text = title;

            if (buttons.Equals(MessageBoxButtons.OK))
            {
                newMessageBox.buttonOK.Visible = true;
            }
            else if (buttons.Equals(MessageBoxButtons.YesNo))
            {
                newMessageBox.buttonYes.Visible = true;
                newMessageBox.buttonNo.Visible  = true;
            }

            newMessageBox.ShowDialog();
            MessageBoxResult = newMessageBox.labelResult.Text;
            newMessageBox    = null; // newMessageBox.Dispose();
                                     // if (IsDebugMode) Trace.WriteLine("DialogMessage : " + MessageBoxResult + "\t" + (newMessageBox) == null);

            switch (MessageBoxResult)
            {
            case "OK":
                return(DialogResult.OK);

            case "Yes":
                return(DialogResult.Yes);

            case "No":
                return(DialogResult.No);

            default:
                return(DialogResult.OK);
            }
        }
Exemplo n.º 5
0
        //Se utilizara para mostrar mensajes de informacion hasta mensajes SI/NO devolviendo su repuesta
        public bool MostrarMsjXtraMessage(string msj, string title, MessageBoxButtons type, MessageBoxIcon icon)
        {
            bool sino = false;

            if (type.Equals(MessageBoxButtons.YesNo))
            {
                DialogResult result = XtraMessageBox.Show(msj, title, type, icon);
                if (DialogResult.Yes == result)
                {
                    sino = true;
                }
                else if (DialogResult.No == result)
                {
                    sino = false;
                }
            }
            else
            {
                XtraMessageBox.Show(msj, title, type, icon);
                sino = true;
            }

            return(sino);
        }
Exemplo n.º 6
0
 private void SetupButtons()
 {
     okButton.Visible  = m_buttons.Equals(MessageBoxButtons.OK);
     yesButton.Visible = m_buttons.Equals(MessageBoxButtons.YesNo);
     noButton.Visible  = m_buttons.Equals(MessageBoxButtons.YesNo);
 }
Exemplo n.º 7
0
 public void SetStyle(MessageBoxButtons Buttons)
 {
     PanelButtonsOK.Visible       = Buttons.Equals(MessageBoxButtons.OK);
     PanelButtonsOKCancel.Visible = Buttons.Equals(MessageBoxButtons.OKCancel);
     PanelButtonsYesNo.Visible    = Buttons.Equals(MessageBoxButtons.YesNo);
 }
        private void message_box_frm_load(global::System.Object sender, System.EventArgs e)
        {
            resources = new ResourceManager(GetType().Namespace + ".strings", Assembly.GetExecutingAssembly());

            SuspendLayout();
            title.Text = titleMsg;
            var   fontToMeasure = new Font(enVars.layoutDesign.fontTitle.Families[0], enVars.layoutDesign.DialogTitleFontSize, System.Drawing.FontStyle.Regular);
            SizeF sizeOfString  = new SizeF();

            sizeOfString   = TextRenderer.MeasureText(titleMsg, fontToMeasure);
            title.Location = new Point(Convert.ToInt32(this.Width / 2 - sizeOfString.Width / 2), this.title.Location.Y);

            fontToMeasure = new Font(enVars.layoutDesign.fontTitle.Families[0], enVars.layoutDesign.RegularTextFontSize, System.Drawing.FontStyle.Regular);
            sizeOfString  = TextRenderer.MeasureText("_", fontToMeasure);

            message.Text = messageText;

            int numLines = Convert.ToInt32(this.messageText.Length / (this.message.Width / sizeOfString.Width)) + 1;

            this.message.Height = Convert.ToInt32(numLines * sizeOfString.Height);


            if (iconImage.Equals(MessageBoxIcon.Information))
            {
                try
                {
                    iconBox.Image = Image.FromFile(enVars.imagesPath + Convert.ToString("information.png"));
                }
                catch (Exception ex)
                {
                }
            }
            else if (iconImage.Equals(MessageBoxIcon.Question))
            {
                try
                {
                    iconBox.Image = Image.FromFile(enVars.imagesPath + Convert.ToString("question.png"));
                }
                catch (Exception ex)
                {
                }
            }
            else if (iconImage.Equals(MessageBoxIcon.Warning))
            {
                try
                {
                    iconBox.Image = Image.FromFile(enVars.imagesPath + Convert.ToString("warning.png"));
                }
                catch (Exception ex)
                {
                }
            }
            else if (iconImage.Equals(MessageBoxIcon.Exclamation))
            {
                try
                {
                    iconBox.Image = Image.FromFile(enVars.imagesPath + Convert.ToString("exclamation.png"));
                }
                catch (Exception ex)
                {
                }
            }
            else if (iconImage.Equals(MessageBoxIcon.Error))
            {
                try
                {
                    iconBox.Image = Image.FromFile(enVars.imagesPath + Convert.ToString("error.png"));
                }
                catch (Exception ex)
                {
                }
            }

            iconBox.SizeMode = PictureBoxSizeMode.StretchImage;
            System.Threading.Thread.CurrentThread.CurrentUICulture = System.Globalization.CultureInfo.GetCultureInfo(enVars.currentLang);
            if (buttons.Equals(MessageBoxButtons.OK))
            {
                ContinueBtn.Visible = true;
                cancelBtn.Visible   = false;

                ContinueBtn.Location = new Point(Convert.ToInt32(this.Width / 2 - this.ContinueBtn.Width / 2), this.ContinueBtn.Location.Y);
            }
            else if (buttons.Equals(MessageBoxButtons.OKCancel))
            {
                ContinueBtn.Text    = resources.GetString("ok");
                ContinueBtn.Visible = true;
                cancelBtn.Text      = resources.GetString("cancel");
                cancelBtn.Visible   = true;
            }
            else if (buttons.Equals(MessageBoxButtons.YesNo))
            {
                ContinueBtn.Text    = resources.GetString("yes");
                ContinueBtn.Visible = true;
                cancelBtn.Text      = resources.GetString("no");
                cancelBtn.Visible   = true;
            }
            else if (buttons.Equals(MessageBoxButtons.RetryCancel))
            {
                ContinueBtn.Text    = resources.GetString("retry");
                ContinueBtn.Visible = true;
                cancelBtn.Text      = resources.GetString("cancel");
                cancelBtn.Visible   = true;
            }

            ResumeLayout();
            Refresh();
        }
Exemplo n.º 9
0
        //Se utilizara para mostrar mensajes de informacion hasta mensajes SI/NO devolviendo su repuesta
        public bool MostrarMsjXtraMessage(string msj, string title, MessageBoxButtons type, MessageBoxIcon icon)
        {
            bool sino = false;

            if (type.Equals(MessageBoxButtons.YesNo))
            {
                DialogResult result = XtraMessageBox.Show(msj, title, type, icon);
                if (DialogResult.Yes == result)
                {
                    sino = true;
                }
                else if (DialogResult.No == result)
                {
                    sino = false;
                }
            }
            else
            {
                XtraMessageBox.Show(msj, title, type, icon);
                sino = true;
            }

            return sino;
        }