コード例 #1
0
ファイル: MyMessageBox.cs プロジェクト: secsome/PaletteStudio
        public MyMessageBox(string title, string content, MyMessageBoxButtons buttons)
        {
            InitializeComponent();
            Text             = title;
            rtxbMessage.Text = content;
            btnOK.Text       = Language.DICT["MsgbtnOK"];
            btnYes.Text      = Language.DICT["MsgbtnYes"];
            btnNo.Text       = Language.DICT["MsgbtnNo"];
            btnCancel.Text   = Language.DICT["MsgbtnCancel"];
            switch (buttons)
            {
            case MyMessageBoxButtons.OK:
                btnOK.Visible     = true;
                btnYes.Visible    = false;
                btnNo.Visible     = false;
                btnCancel.Visible = false;
                break;

            case MyMessageBoxButtons.YesNo:
                btnYes.Location   = btnNo.Location;
                btnNo.Location    = btnCancel.Location;
                btnOK.Visible     = false;
                btnYes.Visible    = true;
                btnNo.Visible     = true;
                btnCancel.Visible = false;
                break;

            case MyMessageBoxButtons.YesNoCancel:
                btnOK.Visible     = false;
                btnYes.Visible    = true;
                btnNo.Visible     = true;
                btnCancel.Visible = true;
                break;
            }
        }
コード例 #2
0
        /// <summary>
        /// 显示消息框
        /// </summary>
        /// <param name="message">消息内容</param>
        /// <param name="title">标题</param>
        /// <param name="buttons">显示哪些按钮</param>
        /// <param name="defaultButton">默认响应回车的按钮</param>
        /// <returns>点击OK这返回DialogResults.Ok,点击Yes返回DialogResults.Yes,点击No返回DialogResults.No,否则返回DialogResults.Cancel</returns>
        internal static DialogResults ShowMyDialog(string message, string title, MyMessageBoxButtons buttons, MyMessageBoxButton defaultButton)
        {
            MyMessageBox mymesaagebox = new MyMessageBox(message, title, buttons, defaultButton);
            bool?        dialogresult = mymesaagebox.ShowDialog();

            return(mymesaagebox.WindowResult);
        }
コード例 #3
0
 private MyMessageBox(string message, string title, MyMessageBoxButtons buttons, MyMessageBoxButton defaultButton)
 {
     InitializeComponent();
     DefaultButton       = defaultButton;
     messagetextBox.Text = message ?? string.Empty;
     Title       = title ?? string.Empty;
     ButtonPanel = buttons;
 }
コード例 #4
0
        /// <summary>
        /// Display message window with message, title and button (max 3). Returns myResult.
        /// </summary>
        /// <param name="message">Type string. Text to display as massage</param>
        /// <param name="caption">Type string. Text to display as title of window</param>
        /// <param name="buttons">Type array of string. Texts to display in new button controls</param>
        /// <returns></returns>
        public static MessageBoxResult Show(string message, string caption, MyMessageBoxButtons buttons)
        {
            MyMessageBox    box      = new MyMessageBox();
            ControlTemplate template = (ControlTemplate)box.FindResource("MyMessageButtonControlTemplate");

            box.messageText.Text             = message;
            box.messageBoxTitleLabel.Content = caption;


            switch (buttons)
            {
            case MyMessageBoxButtons.Ok:
                box.buttonsStackPanel.Children.Add(MyMessageBox.createButton("OK", template));
                break;

            case MyMessageBoxButtons.OkAnuluj:
                box.buttonsStackPanel.Children.Add(MyMessageBox.createButton("OK", template));
                box.buttonsStackPanel.Children.Add(MyMessageBox.createButton("ANULUJ", template));
                box.buttonsStackPanel.Children[1].Focus();
                break;

            case MyMessageBoxButtons.PominAnuluj:
                box.buttonsStackPanel.Children.Add(MyMessageBox.createButton("POMIŃ", template));
                box.buttonsStackPanel.Children.Add(MyMessageBox.createButton("ANULUJ", template));
                break;

            case MyMessageBoxButtons.Popraw:
                box.buttonsStackPanel.Children.Add(MyMessageBox.createButton("POPRAW", template));
                break;

            case MyMessageBoxButtons.PominPopraw:
                box.buttonsStackPanel.Children.Add(MyMessageBox.createButton("POPRAW", template));
                box.buttonsStackPanel.Children.Add(MyMessageBox.createButton("POMIŃ", template));
                break;

            case MyMessageBoxButtons.Usun:
                box.buttonsStackPanel.Children.Add(MyMessageBox.createButton("USUŃ", template));
                break;

            case MyMessageBoxButtons.UsunPopraw:
                box.buttonsStackPanel.Children.Add(MyMessageBox.createButton("POPRAW", template));
                box.buttonsStackPanel.Children.Add(MyMessageBox.createButton("USUŃ", template));
                break;

            case MyMessageBoxButtons.UsunAnuluj:
                box.buttonsStackPanel.Children.Add(MyMessageBox.createButton("ANULUJ", template));
                box.buttonsStackPanel.Children.Add(MyMessageBox.createButton("USUŃ", template));
                break;

            case MyMessageBoxButtons.TakNie:
                box.buttonsStackPanel.Children.Add(MyMessageBox.createButton("TAK", template));
                box.buttonsStackPanel.Children.Add(MyMessageBox.createButton("NIE", template));
                break;
            }
            box.ShowDialog();
            return(result);
        }
コード例 #5
0
ファイル: DevMessageBox.cs プロジェクト: xuanximoming/key
        public static DialogResult Show(string msg, string caption, MyMessageBoxButtons btns)
        {
            try
            {
                DevMessageBox aDevMessageBox = new DevMessageBox(msg, caption, btns);

                DialogResult dr = aDevMessageBox.ShowDialog();

                return(dr);
            }
            catch (Exception ce)
            {
                throw ce;
            }
        }
コード例 #6
0
        /// <summary>
        /// Constructs a MyMessageBox object.
        /// </summary>
        /// <param name="message">The message to display.</param>
        /// <param name="caption">The string displayed in the title bar.</param>
        /// <param name="details">The string displayed in the details view.</param>
        /// <param name="buttons">The buttons to display on the dialog.</param>
        /// <param name="icon">The icon to display on the dialog.</param>
        /// <param name="defaultButton">The default button.</param>
        public MyMessageBox(string message, string caption, string details, MyMessageBoxButtons buttons, MyMessageBoxIcon icon, MyMessageBoxDefaultButton defaultButton) :
            this()
        {
            this.message.Text = message;

            this.Text = caption;

            detailsBox.Text      = details.Replace("\n", "\r\n");
            this.details.Visible = !details.Equals(string.Empty);

            switch (buttons)
            {
            case MyMessageBoxButtons.OK:
                ok.Visible = true;
                break;

            case MyMessageBoxButtons.OKCancel:
                ok.Visible = cancel.Visible = true;
                break;

            case MyMessageBoxButtons.YesNo:
                yes.Visible = no.Visible = true;
                break;
            }

            switch (icon)
            {
            case MyMessageBoxIcon.Information:
                messageIcon.Image = Win32Window.IconToAlphaBitmap(SystemIcons.Information);
                break;

            case MyMessageBoxIcon.Question:
                messageIcon.Image = Win32Window.IconToAlphaBitmap(SystemIcons.Question);
                break;

            case MyMessageBoxIcon.Error:
                messageIcon.Image = Win32Window.IconToAlphaBitmap(SystemIcons.Error);
                break;

            case MyMessageBoxIcon.Warning:
                messageIcon.Image = Win32Window.IconToAlphaBitmap(SystemIcons.Warning);
                break;
            }

            this.defaultButton = defaultButton;
        }
コード例 #7
0
ファイル: DevMessageBox.cs プロジェクト: xuanximoming/key
 public DevMessageBox(string _msg, string _caption,
                      MyMessageBoxButtons _btns)
 {
     InitializeComponent();
     try
     {
         initForm();//初始化
         //this.SetIconInfo(_icontype);
         this.SetMessageInfo(_msg);
         this.SetButtonInfo(_btns);
         this.Text = _caption;
         this.groupControlContainer.Text = this.Text;
     }
     catch (Exception ce)
     {
         throw ce;
     }
 }
コード例 #8
0
        private MyMessageBox(string text, string caption, MyMessageBoxButtons option)
        {
            InitializeComponent();
            flowLayoutPanel2.Controls.Clear();

            this.label1.Text   = text;
            this.StartPosition = FormStartPosition.CenterParent;

            switch (option)
            {
            case MyMessageBoxButtons.YesNo:
                Button btn_no = new Button();
                btn_no.BackColor = Color.FromArgb(224, 224, 224);
                btn_no.FlatStyle = FlatStyle.Flat;
                btn_no.FlatAppearance.BorderSize = 0;
                btn_no.Text         = ResourceCulture.GetString("btn_no");
                btn_no.DialogResult = DialogResult.No;
                this.flowLayoutPanel2.Controls.Add(btn_no);

                Button btn_yes = new Button();
                btn_yes.BackColor = Color.FromArgb(224, 224, 224);
                btn_yes.FlatStyle = FlatStyle.Flat;
                btn_yes.FlatAppearance.BorderSize = 0;
                btn_yes.Text         = ResourceCulture.GetString("btn_yes");
                btn_yes.DialogResult = DialogResult.Yes;
                this.flowLayoutPanel2.Controls.Add(btn_yes);
                break;

            case MyMessageBoxButtons.OK:
                Button btn_ok = new Button();
                btn_ok.BackColor = Color.FromArgb(224, 224, 224);
                btn_ok.FlatStyle = FlatStyle.Flat;
                btn_ok.FlatAppearance.BorderSize = 0;
                btn_ok.Text         = ResourceCulture.GetString("btn_ok");
                btn_ok.DialogResult = DialogResult.OK;
                this.flowLayoutPanel2.Controls.Add(btn_ok);
                break;

            default:
                break;
            }
        }
コード例 #9
0
ファイル: DevMessageBox.cs プロジェクト: xuanximoming/key
        public void SetButtonInfo(MyMessageBoxButtons kind)
        {
            try
            {
                Collection <SimpleButton> buttonInfoControls = new Collection <SimpleButton>();
                switch (kind)
                {
                case MyMessageBoxButtons.Ok:
                    buttonInfoControls.Add(CreateButton(s_OkCaption, DialogResult.OK));
                    break;

                case MyMessageBoxButtons.OkCancel:
                    buttonInfoControls.Add(CreateButton(s_OkCaption, DialogResult.OK));
                    buttonInfoControls.Add(CreateButton(s_CancelCaption, DialogResult.Cancel));
                    break;

                case MyMessageBoxButtons.YesNo:
                    buttonInfoControls.Add(CreateButton(s_YesCaption, DialogResult.Yes));
                    buttonInfoControls.Add(CreateButton(s_NoCaption, DialogResult.No));
                    break;

                case MyMessageBoxButtons.YesNoCancel:
                    buttonInfoControls.Add(CreateButton(s_YesCaption, DialogResult.Yes));
                    buttonInfoControls.Add(CreateButton(s_NoCaption, DialogResult.No, false));
                    buttonInfoControls.Add(CreateButton(s_CancelCaption, DialogResult.Cancel));
                    break;

                case MyMessageBoxButtons.Yes:
                    buttonInfoControls.Add(CreateButton(s_YesCaption, DialogResult.Yes));
                    break;

                default:
                    break;
                }
                DrawButtonInfo(buttonInfoControls);
            }
            catch (Exception ce)
            {
                throw ce;
            }
        }
コード例 #10
0
        public static DialogResult Show(string text, string caption, MyMessageBoxButtons option = MyMessageBoxButtons.OK)
        {
            var msgBox = new MyMessageBox(text, caption, option);

            return(msgBox.ShowDialog());
        }
コード例 #11
0
ファイル: Connecting.cs プロジェクト: RoDaniel/featurehouse
 private void displayMessage( string message, string title, string details, MyMessageBoxButtons buttons, MyMessageBoxIcon icon, MyMessageBoxDefaultButton defaultButton )
 {
     MyMessageBox mmb = new MyMessageBox( message, title, details, buttons, icon, defaultButton );
        messageDialogResult = mmb.ShowDialog();
        messageEvent.Set();
 }
コード例 #12
0
ファイル: MyMessageBox.cs プロジェクト: RoDaniel/featurehouse
 public MyMessageBox(string message, string caption, string details, MyMessageBoxButtons buttons, MyMessageBoxIcon icon, MyMessageBoxDefaultButton defaultButton)
     : this()
 {
     this.message.Text = message;
        this.Text = caption;
        detailsBox.Text = details.Replace("\n", "\r\n");
        this.details.Visible = !details.Equals(string.Empty);
        switch (buttons)
        {
     case MyMessageBoxButtons.OK:
      ok.Visible = true;
      break;
     case MyMessageBoxButtons.OKCancel:
      ok.Visible = cancel.Visible = true;
      break;
     case MyMessageBoxButtons.YesNo:
      yes.Visible = no.Visible = true;
      break;
        }
        switch (icon)
        {
     case MyMessageBoxIcon.Information:
      messageIcon.Image = Win32Window.IconToAlphaBitmap(SystemIcons.Information);
      break;
     case MyMessageBoxIcon.Question:
      messageIcon.Image = Win32Window.IconToAlphaBitmap(SystemIcons.Question);
      break;
     case MyMessageBoxIcon.Error:
      messageIcon.Image = Win32Window.IconToAlphaBitmap(SystemIcons.Error);
      break;
     case MyMessageBoxIcon.Warning:
      messageIcon.Image = Win32Window.IconToAlphaBitmap(SystemIcons.Warning);
      break;
        }
        this.defaultButton = defaultButton;
 }
コード例 #13
0
ファイル: MyMessageBox.cs プロジェクト: RoDaniel/featurehouse
 public MyMessageBox(string message, string caption, string details, MyMessageBoxButtons buttons, MyMessageBoxIcon icon)
     : this(message, caption, details, buttons, icon, MyMessageBoxDefaultButton.Button1)
 {
 }
コード例 #14
0
 /// <summary>
 /// 显示消息框
 /// </summary>
 /// <param name="message">消息内容</param>
 /// <param name="title">标题</param>
 /// <param name="buttons">显示哪些按钮</param>
 /// <param name="defaultButton">默认响应回车的按钮</param>
 /// <returns>点击OK这返回DialogResults.Ok,点击Yes返回DialogResults.Yes,点击No返回DialogResults.No,否则返回DialogResults.Cancel</returns>
 public static DialogResults Show(string message, string title, MyMessageBoxButtons buttons, MyMessageBoxButton defaultButton)
 {
     return(MyMessageBox.ShowMyDialog(message, title, buttons, defaultButton));
 }
コード例 #15
0
ファイル: MyMessageBox.cs プロジェクト: secsome/PaletteStudio
        public static DialogResult Show(string title, string content, MyMessageBoxButtons buttons = MyMessageBoxButtons.OK)
        {
            MyMessageBox myMessageBox = new MyMessageBox(title, content, buttons);

            return(myMessageBox.ShowDialog());
        }
コード例 #16
0
 /// <summary>
 /// Constructs a MyMessageBox object.
 /// </summary>
 /// <param name="message">The message to display.</param>
 /// <param name="caption">The string displayed in the title bar.</param>
 /// <param name="details">The string displayed in the details view.</param>
 /// <param name="buttons">The buttons to display on the dialog.</param>
 /// <param name="icon">The icon to display on the dialog.</param>
 public MyMessageBox(string message, string caption, string details, MyMessageBoxButtons buttons, MyMessageBoxIcon icon) :
     this(message, caption, details, buttons, icon, MyMessageBoxDefaultButton.Button1)
 {
 }