public void DialogBoxIcon(DialogBoxIconType icon) { switch (icon) { case DialogBoxIconType.Application: _dialogBoxIconsPic.Image = SystemIcons.Application.ToBitmap(); break; case DialogBoxIconType.Exclamation: _dialogBoxIconsPic.Image = SystemIcons.Exclamation.ToBitmap(); break; case DialogBoxIconType.Error: _dialogBoxIconsPic.Image = SystemIcons.Error.ToBitmap(); break; case DialogBoxIconType.Info: _dialogBoxIconsPic.Image = SystemIcons.Information.ToBitmap(); break; case DialogBoxIconType.Question: _dialogBoxIconsPic.Image = SystemIcons.Question.ToBitmap(); break; case DialogBoxIconType.Shield: _dialogBoxIconsPic.Image = SystemIcons.Shield.ToBitmap(); break; case DialogBoxIconType.Warning: _dialogBoxIconsPic.Image = SystemIcons.Warning.ToBitmap(); break; } }
public DialogWindow(string msg, string title, DialogBoxIconType icon) { FormBorderStyle = FormBorderStyle.None; BackColor = Color.White; AutoSize = true; StartPosition = FormStartPosition.CenterScreen; BackgroundImage = Resources.apple; BackgroundImageLayout = ImageLayout.Stretch; _dialogMsgLabel = new Label { Location = new Point(55, 94), Font = new Font("Arial", 14), AutoSize = true, Text = msg, BackColor = Color.Transparent }; Controls.Add(_dialogMsgLabel); _dialogBoxIconsPic = new PictureBox { Location = new Point(13, 88), BackColor = Color.Transparent }; var dialogHeaderPanel = new Panel { Location = new Point(0, 0), Size = new Size(this.Width + 5, 50), BackColor = System.Drawing.Color.CornflowerBlue, AutoSize = true }; _dialogCloseIconPic = new PictureBox { Location = new Point(this.Width - 40, 11), SizeMode = PictureBoxSizeMode.StretchImage, Size = new Size(33, 33), Image = Resources.CloseIcona, Cursor = Cursors.Hand, BackColor = Color.Transparent }; _dialogCloseIconPic.Click += _DialogCloseIconPic_Click; _dialogCloseIconPic.MouseHover += _DialogCloseIconPic_MouseHover; _dialogCloseIconPic.MouseLeave += _DialogCloseIconPic_MouseLeave; this.Load += DialogWindow_Load; _dialogTitleLabel = new Label() { Location = new Point(6, 8), AutoSize = true, Font = new Font("Courier New", 14) , Text = title, ForeColor = Color.White }; this.Controls.Add(_dialogBoxIconsPic); dialogHeaderPanel.Controls.Add(_dialogCloseIconPic); dialogHeaderPanel.Controls.Add(_dialogTitleLabel); Controls.Add(dialogHeaderPanel); DialogBoxIcon(icon); }