private static DialogResult ShowDoalog(string message, string title, Buttons buttons, Icons icon, AnimateStyle style, ColorTem colorTem) { var msgBox = new MsgBox(); msgBox.ColorTemelat = colorTem ?? msgBox.ColorTemelat; msgBox._lblMessage.Text = message; msgBox._lblTitle.Text = title; msgBox.BackColor = colorTem.BackColor; msgBox.ForeColor = colorTem.ForeColor; msgBox._lblTitle.ForeColor = colorTem.ForeColor; msgBox._lblMessage.ForeColor = colorTem.ForeColor; msgBox._plFooter.BackColor = colorTem.FootBackColor; msgBox.BorderColor = colorTem.BorderColor; Size formSize = msgBox.MessageSize(message, title); msgBox.Size = formSize; msgBox.InitButtons(buttons); foreach (Button btn in msgBox._buttonCollection) { btn.ForeColor = colorTem.ButtonForeColor; btn.FlatAppearance.BorderColor = colorTem.ButtonBorderColor; btn.BackColor = colorTem.ButtonBackColor; } if (icon == Icons.None) { msgBox._plIcon.Hide(); } else { msgBox.InitIcon(icon); } if (style != AnimateStyle.None) { msgBox._timer = new Timer(); switch (style) { case AnimateStyle.SlideDown: msgBox.Size = new Size(formSize.Width, 0); msgBox._timer.Interval = 1; msgBox._timer.Tag = new AnimateMsgBox(formSize, style); break; case AnimateStyle.FadeIn: msgBox.Size = formSize; msgBox.Opacity = 0; msgBox._timer.Interval = 20; msgBox._timer.Tag = new AnimateMsgBox(formSize, style); break; case AnimateStyle.ZoomIn: msgBox.Size = new Size(formSize.Width + 100, formSize.Height + 100); msgBox._timer.Tag = new AnimateMsgBox(formSize, style); msgBox._timer.Interval = 1; break; } msgBox.CenterToParent(formSize); msgBox._timer.Tick += msgBox.timer_Tick; msgBox._timer.Start(); } ShowForm(msgBox); MessageBeep(0); return(msgBox._buttonResult); }
private MsgBox() { InitializeComponent(); ColorTemelat = new ColorTem(); this.BackColor = ColorTemelat.BackColor; this.Width = 400; this._graphics = this.CreateGraphics(); this.SetStyle(ControlStyles.ResizeRedraw, true); var culture = CultureInfo.CurrentUICulture; _lblTitle = new Label { ForeColor = Color.White, Font = TitleFont, Dock = DockStyle.Top, Height = 50, RightToLeft = culture.TextInfo.IsRightToLeft ? RightToLeft.Yes : RightToLeft.No }; _lblMessage = new Label { ForeColor = Color.White, Font = MessageFont, Dock = DockStyle.Fill, RightToLeft = culture.TextInfo.IsRightToLeft ? RightToLeft.Yes : RightToLeft.No }; _flpButtons = new FlowLayoutPanel { FlowDirection = FlowDirection.RightToLeft, Dock = DockStyle.Fill }; _plHeader = new Panel { Dock = DockStyle.Fill, Padding = new Padding(20) }; _plHeader.Controls.Add(_lblMessage); _plHeader.Controls.Add(_lblTitle); _plFooter = new Panel { Dock = DockStyle.Bottom, Padding = new Padding(20), BackColor = ColorTemelat.FootBackColor, Height = 80 }; _plFooter.Controls.Add(_flpButtons); _picIcon = new PictureBox { Width = 32, Height = 32, Location = new Point(30, 50) }; _plIcon = new Panel { Dock = DockStyle.Left, Padding = new Padding(20), Width = 70 }; _plIcon.Controls.Add(_picIcon); var controlCollection = new List <Control> { this, _lblTitle, _lblMessage, _flpButtons, _plHeader, _plFooter, _plIcon, _picIcon }; foreach (Control control in controlCollection) { control.MouseDown += MsgBox_MouseDown; control.MouseMove += MsgBox_MouseMove; } this.Controls.Add(_plHeader); this.Controls.Add(_plIcon); this.Controls.Add(_plFooter); }
public static DialogResult Show(string message, string title, Buttons buttons, Icons icon, AnimateStyle style, ColorTem colorTem) { return(ShowDoalog(message, title, buttons, icon, style, colorTem)); }