1 // Permission is hereby granted, free of charge, to any person obtaining
2 // a copy of this software and associated documentation files (the
3 // "Software"), to deal in the Software without restriction, including
4 // without limitation the rights to use, copy, modify, merge, publish,
5 // distribute, sublicense, and/or sell copies of the Software, and to
6 // permit persons to whom the Software is furnished to do so, subject to
7 // the following conditions:
8 //
9 // The above copyright notice and this permission notice shall be
10 // included in all copies or substantial portions of the Software.
11 //
12 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
13 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
14 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
15 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
16 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
17 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
18 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19 //
20 // Copyright (c) 2004-2006 Novell, Inc.
21 //
22 // Authors:
23 //	Jordi Mas i Hernandez	(jordi@ximian.com)
24 //	Benjamin Dasnois	(benjamin.dasnois@gmail.com)
25 //	Robert Thompson		(rmt@corporatism.org)
26 //	Peter Bartok		(pbartok@novell.com)
27 //
28 // TODO:
29 //	- Add support for MessageBoxOptions and MessageBoxDefaultButton.
30 //
31 
32 
33 // NOT COMPLETE
34 
35 using System;
36 using System.Drawing;
37 using System.Globalization;
38 using System.Resources;
39 
40 namespace System.Windows.Forms
41 {
42 	public class MessageBox
43 	{
44 		#region Private MessageBoxForm class
45 		internal class MessageBoxForm : Form
46 		{
47 			#region MessageBoxFrom Local Variables
48 			const int space_border = 10;
49 			const int button_width = 86;
50 			const int button_height = 23;
51 			const int button_space = 5;
52 			const int space_image_text= 10;
53 
54 			string			msgbox_text;
55 			bool			size_known	= false;
56 			Icon			icon_image;
57 			RectangleF		text_rect;
58 			MessageBoxButtons	msgbox_buttons;
59 			MessageBoxDefaultButton	msgbox_default;
60 			bool			buttons_placed	= false;
61 			int			button_left;
62 			Button[]		buttons = new Button[4];
63 			bool                    show_help;
64 			string help_file_path;
65 			string help_keyword;
66 			HelpNavigator help_navigator;
67 			object help_param;
68 			AlertType		alert_type;
69 			#endregion	// MessageBoxFrom Local Variables
70 
71 			#region MessageBoxForm Constructors
MessageBoxForm(IWin32Window owner, string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, bool displayHelpButton)72 			public MessageBoxForm (IWin32Window owner, string text, string caption,
73 					       MessageBoxButtons buttons, MessageBoxIcon icon,
74 					       bool displayHelpButton)
75 			{
76 				show_help = displayHelpButton;
77 
78 				switch (icon) {
79 					case MessageBoxIcon.None: {
80 						icon_image = null;
81 						alert_type = AlertType.Default;
82 						break;
83 					}
84 
85 					case MessageBoxIcon.Error: {		// Same as MessageBoxIcon.Hand and MessageBoxIcon.Stop
86 						icon_image = SystemIcons.Error;
87 						alert_type = AlertType.Error;
88 						break;
89 					}
90 
91 					case MessageBoxIcon.Question: {
92  						icon_image = SystemIcons.Question;
93 						alert_type = AlertType.Question;
94 						break;
95 					}
96 
97 					case MessageBoxIcon.Asterisk: {		// Same as MessageBoxIcon.Information
98 						icon_image = SystemIcons.Information;
99 						alert_type = AlertType.Information;
100 						break;
101 					}
102 
103 					case MessageBoxIcon.Warning: {		// Same as MessageBoxIcon.Exclamation:
104 						icon_image = SystemIcons.Warning;
105 						alert_type = AlertType.Warning;
106 						break;
107 					}
108 				}
109 
110 				msgbox_text = text;
111 				msgbox_buttons = buttons;
112 				msgbox_default = MessageBoxDefaultButton.Button1;
113 
114 				if (owner != null) {
115 					Owner = Control.FromHandle(owner.Handle).FindForm();
116 				} else {
117 					if (Application.MWFThread.Current.Context != null) {
118 						Owner = Application.MWFThread.Current.Context.MainForm;
119 					}
120 				}
121 				this.Text = caption;
122 				this.ControlBox = true;
123 				this.MinimizeBox = false;
124 				this.MaximizeBox = false;
125 				this.ShowInTaskbar = (Owner == null);
126 				this.FormBorderStyle = FormBorderStyle.FixedDialog;
127 			}
128 
MessageBoxForm(IWin32Window owner, string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton, MessageBoxOptions options, bool displayHelpButton)129 			public MessageBoxForm (IWin32Window owner, string text, string caption,
130 					MessageBoxButtons buttons, MessageBoxIcon icon,
131 					MessageBoxDefaultButton defaultButton, MessageBoxOptions options, bool displayHelpButton)
132 				: this (owner, text, caption, buttons, icon, displayHelpButton)
133 			{
134 				msgbox_default = defaultButton;
135 			}
136 
MessageBoxForm(IWin32Window owner, string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon)137 			public MessageBoxForm (IWin32Window owner, string text, string caption,
138 					       MessageBoxButtons buttons, MessageBoxIcon icon)
139 				: this (owner, text, caption, buttons, icon, false)
140 			{
141 			}
142 			#endregion	// MessageBoxForm Constructors
143 
144 			#region Protected Instance Properties
145 			protected override CreateParams CreateParams {
146 				get {
147 					CreateParams cp = base.CreateParams;;
148 
149 					cp.Style |= (int)(WindowStyles.WS_DLGFRAME | WindowStyles.WS_CLIPCHILDREN | WindowStyles.WS_CLIPSIBLINGS | WindowStyles.WS_CAPTION);
150 
151 					if (!is_enabled)
152 						cp.Style |= (int)(WindowStyles.WS_DISABLED);
153 
154 					return cp;
155 				}
156 			}
157 			#endregion	// Protected Instance Properties
158 
159 			#region MessageBoxForm Methods
SetHelpData(string file_path, string keyword, HelpNavigator navigator, object param)160 			public void SetHelpData (string file_path, string keyword, HelpNavigator navigator, object param)
161 			{
162 				help_file_path = file_path;
163 				help_keyword = keyword;
164 				help_navigator = navigator;
165 				help_param = param;
166 			}
167 
168 			internal string HelpFilePath {
169 				get { return help_file_path; }
170 			}
171 
172 			internal string HelpKeyword {
173 				get { return help_keyword; }
174 			}
175 
176 			internal HelpNavigator HelpNavigator {
177 				get { return help_navigator; }
178 			}
179 
180 			internal object HelpParam {
181 				get { return help_param; }
182 			}
183 
RunDialog()184 			public DialogResult RunDialog ()
185 			{
186 				this.StartPosition = FormStartPosition.CenterScreen;
187 
188 				if (size_known == false) {
189 					InitFormsSize ();
190 				}
191 
192 				if (Owner != null)
193 					TopMost = Owner.TopMost;
194 
195 				XplatUI.AudibleAlert (alert_type);
196 				this.ShowDialog ();
197 
198 				return this.DialogResult;
199 			}
200 
OnPaintInternal(PaintEventArgs e)201 			internal override void OnPaintInternal (PaintEventArgs e)
202 			{
203 				e.Graphics.DrawString (msgbox_text, this.Font, ThemeEngine.Current.ResPool.GetSolidBrush (Color.Black), text_rect);
204 				if (icon_image != null) {
205 					e.Graphics.DrawIcon(icon_image, space_border, space_border);
206 				}
207 			}
208 
InitFormsSize()209 			private void InitFormsSize ()
210 			{
211 				int tb_width = 0;
212 
213 				// Max width of messagebox must be 60% of screen width
214 				int max_width = (int) (Screen.GetWorkingArea (this).Width * 0.6);
215 				if (max_width > 500) {
216 					float dx;
217 					using (Graphics g = this.CreateGraphics ()) {
218 						dx = g.DpiX;
219 					}
220 					int new_max_width = (int) (dx * 5.0);	// aim for text no wider than 5.0 inches
221 					if (new_max_width < max_width)
222 						max_width = new_max_width;
223 				}
224 				// First we have to know the size of text + image
225 				int iconImageWidth = 0;
226 				if (icon_image != null)
227 					iconImageWidth = icon_image.Width + 10;
228 				Drawing.SizeF tsize = TextRenderer.MeasureText (msgbox_text, this.Font, new Size (max_width - iconImageWidth, int.MaxValue), TextFormatFlags.WordBreak);
229 				text_rect = new RectangleF ();
230 				text_rect.Height = tsize.Height;
231 
232 				if (icon_image != null) {
233 					tsize.Width += iconImageWidth;
234 					if(icon_image.Height > tsize.Height) {
235 						// Place text middle-right
236 						text_rect.Location = new Point (icon_image.Width + space_image_text + space_border, (int)((icon_image.Height/2)-(tsize.Height/2)) + space_border);
237 					} else {
238 						text_rect.Location = new Point (icon_image.Width + space_image_text + space_border, 2 + space_border);
239 					}
240 					if (tsize.Height < icon_image.Height)
241 						tsize.Height = icon_image.Height;
242 				} else {
243 					text_rect.Location = new Point (space_border + button_space, space_border);
244 				}
245 				tsize.Height += space_border * 2;
246 				text_rect.Height += space_border;
247 
248 				// Now we want to know the amount of buttons
249 				int buttoncount;
250 				switch (msgbox_buttons) {
251 					case MessageBoxButtons.OK:
252 						buttoncount = 1;
253 						break;
254 
255 					case MessageBoxButtons.OKCancel:
256 						buttoncount = 2;
257 						break;
258 
259 					case MessageBoxButtons.AbortRetryIgnore:
260 						buttoncount = 3;
261 						break;
262 
263 					case MessageBoxButtons.YesNoCancel:
264 						buttoncount = 3;
265 						break;
266 
267 					case MessageBoxButtons.YesNo:
268 						buttoncount = 2;
269 						break;
270 
271 					case MessageBoxButtons.RetryCancel:
272 						buttoncount = 2;
273 						break;
274 
275 					default:
276 						buttoncount = 0;
277 						break;
278 
279 				}
280 				if (show_help)
281 					buttoncount ++;
282 
283 				// Calculate the width based on amount of buttons
284 				tb_width = (button_width + button_space) * buttoncount;
285 
286 				// The form caption can also make us bigger
287 				SizeF caption = TextRenderer.MeasureString (Text, new Font (DefaultFont, FontStyle.Bold));
288 
289 				// Use the bigger of the caption size (plus some arbitrary borders/close button)
290 				// or the text size, up to 60% of the screen (max_size)
291 				Size new_size = new SizeF (Math.Min (Math.Max (caption.Width + 40, tsize.Width), max_width), tsize.Height).ToSize ();
292 
293 				// Now we choose the good size for the form
294 				if (new_size.Width > tb_width)
295 					this.ClientSize = new Size (new_size.Width + (space_border * 2), Height = new_size.Height + (space_border * 4));
296 				else
297 					this.ClientSize = new Size (tb_width + (space_border * 2), Height = new_size.Height + (space_border * 4));
298 
299 				text_rect.Width = new_size.Width - iconImageWidth;
300 
301 				// Now we set the left of the buttons
302 				button_left = (this.ClientSize.Width / 2) - (tb_width / 2) + 5;
303 				AddButtons ();
304 				size_known = true;
305 
306 				// Still needs to implement defaultButton and options
307 				switch(msgbox_default) {
308 					case MessageBoxDefaultButton.Button2: {
309 						if (this.buttons[1] != null) {
310 							ActiveControl = this.buttons[1];
311 						}
312 						break;
313 					}
314 
315 					case MessageBoxDefaultButton.Button3: {
316 						if (this.buttons[2] != null) {
317 							ActiveControl = this.buttons[2];
318 						}
319 						break;
320 					}
321 				}
322 			}
323 
ProcessDialogKey(Keys keyData)324 			protected override bool ProcessDialogKey(Keys keyData) {
325 				if (keyData == Keys.Escape) {
326 					this.CancelClick(this, null);
327 					return true;
328 				}
329 
330 				if (((keyData & Keys.Modifiers) == Keys.Control) &&
331 					(((keyData & Keys.KeyCode) == Keys.C) ||
332 					 ((keyData & Keys.KeyCode) == Keys.Insert))) {
333 					Copy();
334 				}
335 
336 				return base.ProcessDialogKey (keyData);
337 			}
338 
ProcessDialogChar(char charCode)339 			protected override bool ProcessDialogChar (char charCode)
340 			{
341 				// Shortcut keys, kinda like mnemonics, except you don't have to press Alt
342 				if ((charCode == 'N' || charCode == 'n') && (CancelButton != null && (CancelButton as Button).Text == "No"))
343 					CancelButton.PerformClick ();
344 				else if ((charCode == 'Y' || charCode == 'y') && (AcceptButton as Button).Text == "Yes")
345 					AcceptButton.PerformClick ();
346 				else if ((charCode == 'A' || charCode == 'a') && (CancelButton != null && (CancelButton as Button).Text == "Abort"))
347 					CancelButton.PerformClick ();
348 				else if ((charCode == 'R' || charCode == 'r') && (AcceptButton as Button).Text == "Retry")
349 					AcceptButton.PerformClick ();
350 				else if ((charCode == 'I' || charCode == 'i') && buttons.Length >= 3 && buttons[2].Text == "Ignore")
351 					buttons[2].PerformClick ();
352 
353 				return base.ProcessDialogChar (charCode);
354 			}
355 
Copy()356 			private void Copy ()
357 			{
358 				string separator = "---------------------------" + Environment.NewLine;
359 
360 				System.Text.StringBuilder contents = new System.Text.StringBuilder ();
361 
362 				contents.Append (separator);
363 				contents.Append (this.Text).Append (Environment.NewLine);
364 				contents.Append (separator);
365 				contents.Append (msgbox_text).Append (Environment.NewLine);
366 				contents.Append (separator);
367 
368 				foreach (Button btn in buttons) {
369 					if (btn == null)
370 						break;
371 					contents.Append (btn.Text).Append ("   ");;
372 				}
373 
374 				contents.Append (Environment.NewLine);
375 				contents.Append (separator);
376 
377 				DataObject obj = new DataObject(DataFormats.Text, contents.ToString());
378 				Clipboard.SetDataObject (obj);
379 			}
380 
381 			#endregion	// MessageBoxForm Methods
382 
383 			#region Functions for Adding buttons
AddButtons()384 			private void AddButtons()
385 			{
386 				if (!buttons_placed) {
387 					switch (msgbox_buttons) {
388 						case MessageBoxButtons.OK: {
389 							buttons[0] = AddOkButton (0);
390 							break;
391 						}
392 
393 						case MessageBoxButtons.OKCancel: {
394 							buttons[0] = AddOkButton (0);
395 							buttons[1] = AddCancelButton (1);
396 							break;
397 						}
398 
399 						case MessageBoxButtons.AbortRetryIgnore: {
400 							buttons[0] = AddAbortButton (0);
401 							buttons[1] = AddRetryButton (1);
402 							buttons[2] = AddIgnoreButton (2);
403 							break;
404 						}
405 
406 						case MessageBoxButtons.YesNoCancel: {
407 							buttons[0] = AddYesButton (0);
408 							buttons[1] = AddNoButton (1);
409 							buttons[2] = AddCancelButton (2);
410 							break;
411 						}
412 
413 						case MessageBoxButtons.YesNo: {
414 							buttons[0] = AddYesButton (0);
415 							buttons[1] = AddNoButton (1);
416 							break;
417 						}
418 
419 						case MessageBoxButtons.RetryCancel: {
420 							buttons[0] = AddRetryButton (0);
421 							buttons[1] = AddCancelButton (1);
422 							break;
423 						}
424 					}
425 
426 					if (show_help) {
427 						for (int i = 0; i <= 3; i++) {
428 							if (buttons [i] == null) {
429 								AddHelpButton (i);
430 								break;
431 							}
432 						}
433 					}
434 
435 					buttons_placed = true;
436 				}
437 			}
438 
AddButton(string text, int left, EventHandler click_event)439 			private Button AddButton (string text, int left, EventHandler click_event)
440 			{
441 				Button button = new Button ();
442 				button.Text = Locale.GetText(text);
443 				button.Width = button_width;
444 				button.Height = button_height;
445 				button.Top = this.ClientSize.Height - button.Height - space_border;
446 				button.Left =  ((button_width + button_space) * left) + button_left;
447 
448 				if (click_event != null)
449 					button.Click += click_event;
450 
451 				if ((text == "OK") || (text == "Retry") || (text == "Yes"))
452 					AcceptButton = button;
453 				else if ((text == "Cancel") || (text == "Abort") || (text == "No"))
454 					CancelButton = button;
455 
456 				this.Controls.Add (button);
457 
458 				return button;
459 			}
460 
AddOkButton(int left)461 			private Button AddOkButton (int left)
462 			{
463 				return AddButton ("OK", left, new EventHandler (OkClick));
464 			}
465 
AddCancelButton(int left)466 			private Button AddCancelButton (int left)
467 			{
468 				return AddButton ("Cancel", left, new EventHandler (CancelClick));
469 			}
470 
AddAbortButton(int left)471 			private Button AddAbortButton (int left)
472 			{
473 				return AddButton ("Abort", left, new EventHandler (AbortClick));
474 			}
475 
AddRetryButton(int left)476 			private Button AddRetryButton(int left)
477 			{
478 				return AddButton ("Retry", left, new EventHandler (RetryClick));
479 			}
480 
AddIgnoreButton(int left)481 			private Button AddIgnoreButton (int left)
482 			{
483 				return AddButton ("Ignore", left, new EventHandler (IgnoreClick));
484 			}
485 
AddYesButton(int left)486 			private Button AddYesButton (int left)
487 			{
488 				return AddButton ("Yes", left, new EventHandler (YesClick));
489 			}
490 
AddNoButton(int left)491 			private Button AddNoButton (int left)
492 			{
493 				return AddButton ("No", left, new EventHandler (NoClick));
494 			}
495 
AddHelpButton(int left)496 			private Button AddHelpButton (int left)
497 			{
498 				Button button = AddButton ("Help", left, null);
499 				button.Click += delegate { Owner.RaiseHelpRequested (new HelpEventArgs (Owner.Location)); };
500 				return button;
501 			}
502 			#endregion
503 
504 			#region Button click handlers
OkClick(object sender, EventArgs e)505 			private void OkClick (object sender, EventArgs e)
506 			{
507 				this.DialogResult = DialogResult.OK;
508 				this.Close ();
509 			}
510 
CancelClick(object sender, EventArgs e)511 			private void CancelClick (object sender, EventArgs e)
512 			{
513 				this.DialogResult = DialogResult.Cancel;
514 				this.Close ();
515 			}
516 
AbortClick(object sender, EventArgs e)517 			private void AbortClick (object sender, EventArgs e)
518 			{
519 				this.DialogResult = DialogResult.Abort;
520 				this.Close ();
521 			}
522 
RetryClick(object sender, EventArgs e)523 			private void RetryClick (object sender, EventArgs e)
524 			{
525 				this.DialogResult = DialogResult.Retry;
526 				this.Close ();
527 			}
528 
IgnoreClick(object sender, EventArgs e)529 			private void IgnoreClick (object sender, EventArgs e)
530 			{
531 				this.DialogResult = DialogResult.Ignore;
532 				this.Close ();
533 			}
534 
YesClick(object sender, EventArgs e)535 			private void YesClick (object sender, EventArgs e)
536 			{
537 				this.DialogResult = DialogResult.Yes;
538 				this.Close ();
539 			}
540 
NoClick(object sender, EventArgs e)541 			private void NoClick (object sender, EventArgs e)
542 			{
543 				this.DialogResult = DialogResult.No;
544 				this.Close ();
545 			}
546 			#endregion
547 
548 			#region UIA Framework: Methods, Properties and Events
549 
550 			internal string UIAMessage {
551 				get { return msgbox_text; }
552 			}
553 
554 			internal Rectangle UIAMessageRectangle {
555 				get {
556 					return new Rectangle ((int) text_rect.X,
557 					                      (int) text_rect.Y,
558 					                      (int) text_rect.Width,
559 					                      (int) text_rect.Height);
560 				}
561 			}
562 
563 			internal Rectangle UIAIconRectangle {
564 				get {
565 					return new Rectangle (space_border,
566 					                      space_border,
567 							      icon_image == null ? -1 : icon_image.Width,
568 							      icon_image == null ? -1 : icon_image.Height);
569 				}
570 			}
571 
572 			#endregion
573 		}
574 		#endregion	// Private MessageBoxForm class
575 
576 
577 		#region	Constructors
MessageBox()578 		private MessageBox ()
579 		{
580 		}
581 		#endregion	// Constructors
582 
583 		#region Public Static Methods
Show(string text)584 		public static DialogResult Show (string text)
585 		{
586 			MessageBoxForm form = new MessageBoxForm (null, text, string.Empty, MessageBoxButtons.OK, MessageBoxIcon.None);
587 
588 			return form.RunDialog ();
589 		}
590 
Show(IWin32Window owner, string text)591 		public static DialogResult Show (IWin32Window owner, string text)
592 		{
593 			MessageBoxForm form = new MessageBoxForm (owner, text, string.Empty, MessageBoxButtons.OK, MessageBoxIcon.None);
594 
595 			return form.RunDialog ();
596 		}
597 
Show(string text, string caption)598 		public static DialogResult Show (string text, string caption)
599 		{
600 			MessageBoxForm form = new MessageBoxForm (null, text, caption, MessageBoxButtons.OK, MessageBoxIcon.None);
601 
602 			return form.RunDialog ();
603 		}
604 
Show(string text, string caption, MessageBoxButtons buttons)605 		public static DialogResult Show (string text, string caption, MessageBoxButtons buttons)
606 		{
607 			MessageBoxForm form = new MessageBoxForm (null, text, caption, buttons, MessageBoxIcon.None);
608 
609 			return form.RunDialog ();
610 		}
611 
Show(IWin32Window owner, string text, string caption, MessageBoxButtons buttons)612 		public static DialogResult Show (IWin32Window owner, string text, string caption,
613 						 MessageBoxButtons buttons)
614 		{
615 			MessageBoxForm form = new MessageBoxForm (owner, text, caption, buttons, MessageBoxIcon.None);
616 
617 			return form.RunDialog ();
618 		}
619 
Show(IWin32Window owner, string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon)620 		public static DialogResult Show (IWin32Window owner, string text, string caption,
621 						 MessageBoxButtons buttons, MessageBoxIcon icon)
622 		{
623 			MessageBoxForm form = new MessageBoxForm (owner, text, caption, buttons, icon);
624 
625 			return form.RunDialog ();
626 		}
627 
628 
Show(IWin32Window owner, string text, string caption)629 		public static DialogResult Show (IWin32Window owner, string text, string caption)
630 		{
631 			MessageBoxForm form = new MessageBoxForm (owner, text, caption, MessageBoxButtons.OK, MessageBoxIcon.None);
632 
633 			return form.RunDialog ();
634 		}
635 
636 
Show(string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon)637 		public static DialogResult Show (string text, string caption, MessageBoxButtons buttons,
638 				MessageBoxIcon icon)
639 		{
640 			MessageBoxForm form = new MessageBoxForm (null, text, caption, buttons, icon);
641 
642 			return form.RunDialog ();
643 		}
644 
Show(string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton)645 		public static DialogResult Show (string text, string caption, MessageBoxButtons buttons,
646 						 MessageBoxIcon icon, MessageBoxDefaultButton defaultButton)
647 		{
648 
649 			MessageBoxForm form = new MessageBoxForm (null, text, caption, buttons,
650 								  icon, defaultButton, MessageBoxOptions.DefaultDesktopOnly, false);
651 
652 			return form.RunDialog ();
653 		}
654 
Show(IWin32Window owner, string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton)655 		public static DialogResult Show (IWin32Window owner, string text, string caption,
656 						 MessageBoxButtons buttons, MessageBoxIcon icon,
657 						 MessageBoxDefaultButton defaultButton)
658 		{
659 			MessageBoxForm form = new MessageBoxForm (owner, text, caption, buttons,
660 								  icon, defaultButton, MessageBoxOptions.DefaultDesktopOnly, false);
661 
662 			return form.RunDialog ();
663 		}
664 
Show(string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton, MessageBoxOptions options)665 		public static DialogResult Show (string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon,
666 						 MessageBoxDefaultButton defaultButton, MessageBoxOptions options)
667 		{
668 			MessageBoxForm form = new MessageBoxForm (null, text, caption, buttons,
669 								  icon, defaultButton, options, false);
670 
671 			return form.RunDialog ();
672 		}
673 
Show(IWin32Window owner, string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton, MessageBoxOptions options)674 		public static DialogResult Show (IWin32Window owner, string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon,
675 						 MessageBoxDefaultButton defaultButton, MessageBoxOptions options)
676 		{
677 			MessageBoxForm form = new MessageBoxForm (owner, text, caption, buttons,
678 								  icon, defaultButton, options, false);
679 
680 			return form.RunDialog ();
681 		}
682 		#endregion	// Public Static Methods
683 
Show(string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton, MessageBoxOptions options, bool displayHelpButton)684 		public static DialogResult Show (string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon,
685 						 MessageBoxDefaultButton defaultButton, MessageBoxOptions options,
686 						 bool displayHelpButton)
687 		{
688 			MessageBoxForm form = new MessageBoxForm (null, text, caption, buttons,
689 								  icon, defaultButton, options, displayHelpButton);
690 			return form.RunDialog ();
691 		}
692 
693 		[MonoTODO ("Help is not implemented")]
Show(string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton, MessageBoxOptions options, string helpFilePath)694 		public static DialogResult Show (string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon,
695 						 MessageBoxDefaultButton defaultButton, MessageBoxOptions options,
696 						 string helpFilePath)
697 		{
698 			MessageBoxForm form = new MessageBoxForm (null, text, caption, buttons,
699 								  icon, defaultButton, options, true);
700 			form.SetHelpData (helpFilePath, null, HelpNavigator.TableOfContents, null);
701 			return form.RunDialog ();
702 		}
703 
704 		[MonoTODO ("Help is not implemented")]
Show(string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton, MessageBoxOptions options, string helpFilePath, string keyword)705 		public static DialogResult Show (string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon,
706 						 MessageBoxDefaultButton defaultButton, MessageBoxOptions options,
707 						 string helpFilePath, string keyword)
708 		{
709 			MessageBoxForm form = new MessageBoxForm (null, text, caption, buttons,
710 								  icon, defaultButton, options, true);
711 			form.SetHelpData (helpFilePath, keyword, HelpNavigator.TableOfContents, null);
712 			return form.RunDialog ();
713 		}
714 
715 		[MonoTODO ("Help is not implemented")]
Show(string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton, MessageBoxOptions options, string helpFilePath, HelpNavigator navigator)716 		public static DialogResult Show (string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon,
717 						 MessageBoxDefaultButton defaultButton, MessageBoxOptions options,
718 						 string helpFilePath, HelpNavigator navigator)
719 		{
720 			MessageBoxForm form = new MessageBoxForm (null, text, caption, buttons,
721 								  icon, defaultButton, options, true);
722 			form.SetHelpData (helpFilePath, null, navigator, null);
723 			return form.RunDialog ();
724 		}
725 
726 		[MonoTODO ("Help is not implemented")]
Show(string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton, MessageBoxOptions options, string helpFilePath, HelpNavigator navigator, object param)727 		public static DialogResult Show (string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon,
728 						 MessageBoxDefaultButton defaultButton, MessageBoxOptions options,
729 						 string helpFilePath, HelpNavigator navigator, object param)
730 		{
731 			MessageBoxForm form = new MessageBoxForm (null, text, caption, buttons,
732 								  icon, defaultButton, options, true);
733 			form.SetHelpData (helpFilePath, null, navigator, param);
734 			return form.RunDialog ();
735 		}
736 
737 		[MonoTODO ("Help is not implemented")]
Show(IWin32Window owner, string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton, MessageBoxOptions options, string helpFilePath)738 		public static DialogResult Show (IWin32Window owner, string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon,
739 						 MessageBoxDefaultButton defaultButton, MessageBoxOptions options,
740 						 string helpFilePath)
741 		{
742 			MessageBoxForm form = new MessageBoxForm (owner, text, caption, buttons,
743 								  icon, defaultButton, options, true);
744 			form.SetHelpData (helpFilePath, null, HelpNavigator.TableOfContents, null);
745 			return form.RunDialog ();
746 		}
747 
748 		[MonoTODO ("Help is not implemented")]
Show(IWin32Window owner, string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton, MessageBoxOptions options, string helpFilePath, string keyword)749 		public static DialogResult Show (IWin32Window owner, string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon,
750 						 MessageBoxDefaultButton defaultButton, MessageBoxOptions options,
751 						 string helpFilePath, string keyword)
752 		{
753 			MessageBoxForm form = new MessageBoxForm (owner, text, caption, buttons,
754 								  icon, defaultButton, options, true);
755 			form.SetHelpData (helpFilePath, keyword, HelpNavigator.TableOfContents, null);
756 			return form.RunDialog ();
757 		}
758 
759 		[MonoTODO ("Help is not implemented")]
Show(IWin32Window owner, string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton, MessageBoxOptions options, string helpFilePath, HelpNavigator navigator)760 		public static DialogResult Show (IWin32Window owner, string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon,
761 						 MessageBoxDefaultButton defaultButton, MessageBoxOptions options,
762 						 string helpFilePath, HelpNavigator navigator)
763 		{
764 			MessageBoxForm form = new MessageBoxForm (owner, text, caption, buttons,
765 								  icon, defaultButton, options, true);
766 			form.SetHelpData (helpFilePath, null, navigator, null);
767 			return form.RunDialog ();
768 		}
769 
770 		[MonoTODO ("Help is not implemented")]
Show(IWin32Window owner, string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton, MessageBoxOptions options, string helpFilePath, HelpNavigator navigator, object param)771 		public static DialogResult Show (IWin32Window owner, string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon,
772 						 MessageBoxDefaultButton defaultButton, MessageBoxOptions options,
773 						 string helpFilePath, HelpNavigator navigator, object param)
774 		{
775 			MessageBoxForm form = new MessageBoxForm (owner, text, caption, buttons,
776 								  icon, defaultButton, options, true);
777 			form.SetHelpData (helpFilePath, null, navigator, param);
778 			return form.RunDialog ();
779 		}
780 	}
781 }
782 
783