public DialogResult Notify(string message, string caption = "Notification", int time = 0, bool cancel = false, bool YesNo = false) { using (MetroMessageBox _msgBox = new MetroMessageBox()) { _msgBox.Text = caption; _msgBox.ShadowType = ShadowType; _msgBox.MinimizeBox = false; _msgBox.MaximizeBox = false; if (!cancel) { _msgBox.ControlBox = false; } _msgBox.TopMost = TopMost; _msgBox.Resizable = Resizable; _msgBox.BorderStyle = MetroFramework.Drawing.MetroBorderStyle.FixedSingle; using (MetroStyleManager _styleManager = new MetroStyleManager()) { _styleManager.Owner = _msgBox; _styleManager.Style = Style; _styleManager.Theme = Theme; } if (message.Length == 0) { return(DialogResult.None); } int highestCount = -1; string[] lines = message.Split('\n'); foreach (string line in message.Split('\n')) { if (line.Length > highestCount) { highestCount = line.Length; } } if (highestCount == -1) { highestCount = message.Length; } _msgBox.Size = new Size(highestCount * 8, message.Split('\n').Length * 12 + 120); if (_msgBox.Width < caption.Length * 15) { _msgBox.Width = caption.Length * 15; } if (_msgBox.Width < 200) { _msgBox.Width = 200; } _msgBox.MinimumSize = _msgBox.Size; MetroLabel _msg = new MetroLabel(); _msg.Text = message; _msg.Location = new Point(25, 65); _msg.Size = new Size(_msgBox.Width - 35, message.Split('\n').Length * 12 + 15); _msgBox.Controls.Add(_msg); MetroButton _btnOK = new MetroButton(); _btnOK.Text = YesNo ? "Yes" : "OK"; _btnOK.Location = new Point(_msgBox.Width - 95, _msgBox.Height - 35); _btnOK.Click += (object sender, EventArgs e) => { _msgBox.DialogResult = YesNo ? DialogResult.Yes : DialogResult.OK; _msgBox.Close(); }; _msgBox.Controls.Add(_btnOK); if (cancel || YesNo) { MetroButton _btnCancel = new MetroButton(); _btnCancel.Text = YesNo ? "No" : "Cancel"; _btnCancel.Location = new Point(_msgBox.Width - 95 - _btnOK.Size.Width - 10, _msgBox.Height - 35); _btnCancel.Click += (object sender, EventArgs e) => { _msgBox.DialogResult = YesNo ? DialogResult.No : DialogResult.Cancel; _msgBox.Close(); }; _msgBox.Controls.Add(_btnCancel); } if (time > 0) { System.Windows.Forms.Timer _timer = new System.Windows.Forms.Timer(); _timer.Interval = time; _timer.Tick += (object sender, EventArgs e) => { _timer.Enabled = false; _timer.Dispose(); for (double i = 1; i > 0; i -= 0.1) { _msgBox.Opacity = i; Thread.Sleep(10); } _msgBox.ShadowType = MetroFormShadowType.None; _msgBox.Close(); }; _timer.Enabled = true; } return(_msgBox.ShowDialog()); } }