public XNAMessageBox(WindowManager windowManager, string caption, string description, DXMessageBoxButtons messageBoxButtons) : base(windowManager) { this.caption = caption; this.description = description; this.messageBoxButtons = messageBoxButtons; }
public DXMessageBox(string message, string caption, DXMessageBoxButtons buttons = DXMessageBoxButtons.OK) { Buttons = buttons; Modal = true; HasFooter = true; TitleLabel.Text = caption; Parent = ActiveScene; MessageBoxList.Add(this); Label = new DXLabel { AutoSize = false, Location = new Point(10, 35), Parent = this, Text = message, DrawFormat = TextFormatFlags.VerticalCenter | TextFormatFlags.HorizontalCenter }; Label.Size = new Size(380, DXLabel.GetSize(message, Label.Font, Label.Outline).Height); SetClientSize(Label.Size); Label.Location = ClientArea.Location; Location = new Point((ActiveScene.DisplayArea.Width - DisplayArea.Width) / 2, (ActiveScene.DisplayArea.Height - DisplayArea.Height) / 2); switch (Buttons) { case DXMessageBoxButtons.OK: OKButton = new DXButton { Location = new Point((Size.Width - 80) / 2, Size.Height - 43), Size = new Size(80, DefaultHeight), Parent = this, Label = { Text = "OK" } }; OKButton.MouseClick += (o, e) => Dispose(); break; case DXMessageBoxButtons.YesNo: YesButton = new DXButton { Location = new Point((Size.Width) / 2 - 80 - 10, Size.Height - 43), Size = new Size(80, DefaultHeight), Parent = this, Label = { Text = "Yes" } }; YesButton.MouseClick += (o, e) => Dispose(); NoButton = new DXButton { Location = new Point(Size.Width / 2 + 10, Size.Height - 43), Size = new Size(80, DefaultHeight), Parent = this, Label = { Text = "No" } }; NoButton.MouseClick += (o, e) => Dispose(); break; case DXMessageBoxButtons.Cancel: CancelButton = new DXButton { Location = new Point((Size.Width - 80) / 2, Size.Height - 43), Size = new Size(80, DefaultHeight), Parent = this, Label = { Text = "Cancel" } }; CancelButton.MouseClick += (o, e) => Dispose(); break; } BringToFront(); }
protected override void Dispose(bool disposing) { base.Dispose(disposing); if (disposing) { if (Label != null) { if (!Label.IsDisposed) { Label.Dispose(); } Label = null; } if (OKButton != null) { if (!OKButton.IsDisposed) { OKButton.Dispose(); } OKButton = null; } if (CancelButton != null) { if (!CancelButton.IsDisposed) { CancelButton.Dispose(); } CancelButton = null; } if (NoButton != null) { if (!NoButton.IsDisposed) { NoButton.Dispose(); } NoButton = null; } if (YesButton != null) { if (!YesButton.IsDisposed) { YesButton.Dispose(); } YesButton = null; } if (HiddenBox != null) { DXTextBox.ActiveTextBox = HiddenBox; HiddenBox = null; } Buttons = DXMessageBoxButtons.None; MessageBoxList.Remove(this); } }