MessageBox.cs 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  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 Novell, Inc.
  21. //
  22. // Authors:
  23. // Jordi Mas i Hernandez, [email protected]
  24. //
  25. // TODO:
  26. // - Complete the implementation when the Button class is available
  27. //
  28. //
  29. // $Revision: 1.1 $
  30. // $Modtime: $
  31. // $Log: MessageBox.cs,v $
  32. // Revision 1.1 2004/07/26 11:41:35 jordi
  33. // initial messagebox implementation
  34. //
  35. //
  36. // INCOMPLETE
  37. using System;
  38. using System.Drawing;
  39. namespace System.Windows.Forms
  40. {
  41. public class MessageBox
  42. {
  43. private class MessageBoxForm : Form
  44. {
  45. public MessageBoxForm (IWin32Window owner, string text, string caption,
  46. MessageBoxButtons buttons, MessageBoxIcon icon)
  47. {
  48. }
  49. public MessageBoxForm (IWin32Window owner, string text, string caption,
  50. MessageBoxButtons buttons, MessageBoxIcon icon,
  51. MessageBoxDefaultButton defaultButton, MessageBoxOptions options)
  52. {
  53. }
  54. public DialogResult RunDialog ()
  55. {
  56. return DialogResult.OK;
  57. }
  58. }
  59. private MessageBox ()
  60. {
  61. }
  62. public static DialogResult Show (string text)
  63. {
  64. MessageBoxForm form = new MessageBoxForm (null, text, string.Empty,
  65. MessageBoxButtons.OK, MessageBoxIcon.None);
  66. return form.RunDialog ();
  67. }
  68. public static DialogResult Show (IWin32Window owner, string text)
  69. {
  70. MessageBoxForm form = new MessageBoxForm (owner, text, string.Empty,
  71. MessageBoxButtons.OK, MessageBoxIcon.None);
  72. return form.RunDialog ();
  73. }
  74. public static DialogResult Show (string text, string caption)
  75. {
  76. MessageBoxForm form = new MessageBoxForm (null, text, caption,
  77. MessageBoxButtons.OK, MessageBoxIcon.None);
  78. return form.RunDialog ();
  79. }
  80. public static DialogResult Show (string text, string caption, MessageBoxButtons buttons)
  81. {
  82. MessageBoxForm form = new MessageBoxForm (null, text, caption,
  83. buttons, MessageBoxIcon.None);
  84. return form.RunDialog ();
  85. }
  86. public static DialogResult Show (IWin32Window owner, string text, string caption,
  87. MessageBoxButtons buttons)
  88. {
  89. MessageBoxForm form = new MessageBoxForm (owner, text, caption,
  90. buttons, MessageBoxIcon.None);
  91. return form.RunDialog ();
  92. }
  93. public static DialogResult Show (IWin32Window owner, string text, string caption,
  94. MessageBoxButtons buttons, MessageBoxIcon icon)
  95. {
  96. MessageBoxForm form = new MessageBoxForm (owner, text, caption,
  97. buttons, icon);
  98. return form.RunDialog ();
  99. }
  100. public static DialogResult Show (IWin32Window owner, string text, string caption)
  101. {
  102. MessageBoxForm form = new MessageBoxForm (owner, text, caption,
  103. MessageBoxButtons.OK, MessageBoxIcon.None);
  104. return form.RunDialog ();
  105. }
  106. public static DialogResult Show (string text, string caption, MessageBoxButtons buttons,
  107. MessageBoxIcon icon)
  108. {
  109. MessageBoxForm form = new MessageBoxForm (null, text, caption,
  110. buttons, icon);
  111. return form.RunDialog ();
  112. }
  113. public static DialogResult Show (string text, string caption, MessageBoxButtons buttons,
  114. MessageBoxIcon icon, MessageBoxDefaultButton defaultButton)
  115. {
  116. MessageBoxForm form = new MessageBoxForm (null, text, caption,
  117. buttons, icon, defaultButton, MessageBoxOptions.DefaultDesktopOnly);
  118. return form.RunDialog ();
  119. }
  120. public static DialogResult Show (IWin32Window owner, string text, string caption,
  121. MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton)
  122. {
  123. MessageBoxForm form = new MessageBoxForm (owner, text, caption,
  124. buttons, icon, defaultButton, MessageBoxOptions.DefaultDesktopOnly);
  125. return form.RunDialog ();
  126. }
  127. public static DialogResult
  128. Show (string text, string caption,
  129. MessageBoxButtons buttons, MessageBoxIcon icon,
  130. MessageBoxDefaultButton defaultButton, MessageBoxOptions options)
  131. {
  132. MessageBoxForm form = new MessageBoxForm (null, text, caption,
  133. buttons, icon, defaultButton, options);
  134. return form.RunDialog ();
  135. }
  136. public static DialogResult Show (IWin32Window owner, string text, string caption,
  137. MessageBoxButtons buttons, MessageBoxIcon icon,
  138. MessageBoxDefaultButton defaultButton, MessageBoxOptions options)
  139. {
  140. MessageBoxForm form = new MessageBoxForm (owner, text, caption,
  141. buttons, icon, defaultButton, options);
  142. return form.RunDialog ();
  143. }
  144. }
  145. }