ThreeButtonMessageBox.cs
上传用户:szltgg
上传日期:2019-05-16
资源大小:604k
文件大小:5k
源码类别:

Telnet服务器

开发平台:

C#

  1. /*
  2. * Copyright (c) 2005 Poderosa Project, All Rights Reserved.
  3. * $Id: ThreeButtonMessageBox.cs,v 1.2 2005/04/20 08:45:45 okajima Exp $
  4. */
  5. using System;
  6. using System.Drawing;
  7. using System.Collections;
  8. using System.ComponentModel;
  9. using System.Windows.Forms;
  10. using Poderosa;
  11. namespace Poderosa.Forms
  12. {
  13. /// <summary>
  14. /// ThreeButtonMessageBox 偺奣梫偺愢柧偱偡丅
  15. /// </summary>
  16. internal class ThreeButtonMessageBox : System.Windows.Forms.Form
  17. {
  18. private System.Windows.Forms.Button _button1;
  19. private System.Windows.Forms.Button _button2;
  20. private System.Windows.Forms.Button _button3;
  21. private System.Windows.Forms.Label _message;
  22. /// <summary>
  23. /// 昁梫側僨僓僀僫曄悢偱偡丅
  24. /// </summary>
  25. private System.ComponentModel.Container components = null;
  26. public ThreeButtonMessageBox()
  27. {
  28. //
  29. // Windows 僼僅乕儉 僨僓僀僫 僒億乕僩偵昁梫偱偡丅
  30. //
  31. InitializeComponent();
  32. //
  33. // TODO: InitializeComponent 屇傃弌偟偺屻偵丄僐儞僗僩儔僋僞 僐乕僪傪捛壛偟偰偔偩偝偄丅
  34. //
  35. }
  36. /// <summary>
  37. /// 巊梡偝傟偰偄傞儕僜乕僗偵屻張棟傪幚峴偟傑偡丅
  38. /// </summary>
  39. protected override void Dispose( bool disposing )
  40. {
  41. if( disposing )
  42. {
  43. if(components != null)
  44. {
  45. components.Dispose();
  46. }
  47. }
  48. base.Dispose( disposing );
  49. }
  50. #region Windows Form Designer generated code
  51. /// <summary>
  52. /// 僨僓僀僫 僒億乕僩偵昁梫側儊僜僢僪偱偡丅偙偺儊僜僢僪偺撪梕傪
  53. /// 僐乕僪 僄僨傿僞偱曄峏偟側偄偱偔偩偝偄丅
  54. /// </summary>
  55. private void InitializeComponent()
  56. {
  57. this._button1 = new System.Windows.Forms.Button();
  58. this._button2 = new System.Windows.Forms.Button();
  59. this._button3 = new System.Windows.Forms.Button();
  60. this._message = new System.Windows.Forms.Label();
  61. this.SuspendLayout();
  62. // 
  63. // _button1
  64. // 
  65. this._button1.DialogResult = System.Windows.Forms.DialogResult.Yes;
  66. this._button1.Location = new System.Drawing.Point(8, 56);
  67. this._button1.Name = "_button1";
  68. this._button1.FlatStyle = FlatStyle.System;
  69. this._button1.Size = new System.Drawing.Size(96, 23);
  70. this._button1.TabIndex = 0;
  71. // 
  72. // _button2
  73. // 
  74. this._button2.DialogResult = System.Windows.Forms.DialogResult.No;
  75. this._button2.Location = new System.Drawing.Point(112, 56);
  76. this._button2.Name = "_button2";
  77. this._button2.FlatStyle = FlatStyle.System;
  78. this._button2.Size = new System.Drawing.Size(96, 23);
  79. this._button2.TabIndex = 1;
  80. // 
  81. // _button3
  82. // 
  83. this._button3.DialogResult = System.Windows.Forms.DialogResult.Cancel;
  84. this._button3.Location = new System.Drawing.Point(216, 56);
  85. this._button3.Name = "_button3";
  86. this._button3.FlatStyle = FlatStyle.System;
  87. this._button3.Size = new System.Drawing.Size(96, 23);
  88. this._button3.TabIndex = 2;
  89. // 
  90. // _message
  91. // 
  92. this._message.Location = new System.Drawing.Point(64, 8);
  93. this._message.Name = "_message";
  94. this._message.Size = new System.Drawing.Size(232, 48);
  95. this._message.TabIndex = 3;
  96. this._message.TextAlign = System.Drawing.ContentAlignment.TopLeft;
  97. // 
  98. // ThreeButtonMessageBox
  99. // 
  100. this.AcceptButton = this._button1;
  101. this.AutoScaleBaseSize = new System.Drawing.Size(5, 12);
  102. this.CancelButton = this._button3;
  103. this.ClientSize = new System.Drawing.Size(322, 85);
  104. this.Controls.AddRange(new System.Windows.Forms.Control[] {
  105.   this._message,
  106.   this._button3,
  107.   this._button2,
  108.   this._button1});
  109. this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
  110. this.MaximizeBox = false;
  111. this.MinimizeBox = false;
  112. this.Name = "ThreeButtonMessageBox";
  113. this.ShowInTaskbar = false;
  114. this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
  115. this.ResumeLayout(false);
  116. }
  117. #endregion
  118. public string YesButtonText {
  119. get {
  120. return _button1.Text;
  121. }
  122. set {
  123. _button1.Text = value;
  124. }
  125. }
  126. public string NoButtonText {
  127. get {
  128. return _button2.Text;
  129. }
  130. set {
  131. _button2.Text = value;
  132. }
  133. }
  134. public string CancelButtonText {
  135. get {
  136. return _button3.Text;
  137. }
  138. set {
  139. _button3.Text = value;
  140. }
  141. }
  142. public string Message {
  143. get {
  144. return _message.Text;
  145. }
  146. set {
  147. _message.Text = value;
  148. }
  149. }
  150. protected override void OnPaint(PaintEventArgs a) {
  151. base.OnPaint(a);
  152. //傾僀僐儞偺昤夋丂.NET Framework偩偗偱僔僗僥儉偱帩偭偰偄傞傾僀僐儞偺儘乕僪偼偱偒側偄傛偆偩
  153. if(_questionIcon==null) LoadQuestionIcon();
  154. a.Graphics.DrawIcon(_questionIcon, 16, 8); 
  155. }
  156. private static Icon _questionIcon;
  157. private static void LoadQuestionIcon() {
  158. IntPtr hIcon = Win32.LoadIcon(IntPtr.Zero, new IntPtr(Win32.IDI_QUESTION));
  159. _questionIcon = Icon.FromHandle(hIcon);
  160. }
  161. }
  162. }