TsrToolStrip.cs 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. 
  2. using System.ComponentModel;
  3. using System.Drawing;
  4. using System.Windows.Forms;
  5. namespace Dongke.WinForm.Controls
  6. {
  7. /// <summary>
  8. /// 工具栏对象提供容器
  9. /// </summary>
  10. [ToolboxBitmap(typeof(ToolStrip))]
  11. public class TsrToolStrip : ToolStrip, IDKControl, IAsyncControl
  12. {
  13. #region 构造函数
  14. /// <summary>
  15. /// 工具栏对象提供容器
  16. /// </summary>
  17. public TsrToolStrip()
  18. {
  19. base.BackColor = Color.Transparent;
  20. base.Font = SystemFonts.DefaultFont;
  21. base.AutoSize = false;
  22. base.Height = 33;
  23. base.BackgroundImage = Properties.Resources.ToolStrip_Back_00;
  24. }
  25. #endregion
  26. #region 重写属性
  27. /// <summary>
  28. /// 获取或设置一个值,该值指示是否自动调整控件的大小以显示其完整内容。
  29. /// </summary>
  30. [DefaultValue(false)]
  31. [Browsable(false)]
  32. [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  33. [EditorBrowsable(EditorBrowsableState.Never)]
  34. public override bool AutoSize
  35. {
  36. get
  37. {
  38. return base.AutoSize;
  39. }
  40. set
  41. {
  42. base.AutoSize = value;
  43. }
  44. }
  45. /// <summary>
  46. /// 获取或设置控件的高度。
  47. /// </summary>
  48. [DefaultValue(33)]
  49. [Browsable(false)]
  50. [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  51. [EditorBrowsable(EditorBrowsableState.Never)]
  52. public new int Height
  53. {
  54. get
  55. {
  56. return base.Height;
  57. }
  58. set
  59. {
  60. base.Height = value;
  61. }
  62. }
  63. /// <summary>
  64. /// 获取或设置在控件中显示的背景图像。
  65. /// </summary>
  66. [Browsable(false)]
  67. [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  68. [EditorBrowsable(EditorBrowsableState.Never)]
  69. public override Image BackgroundImage
  70. {
  71. get
  72. {
  73. return base.BackgroundImage;
  74. }
  75. set
  76. {
  77. base.BackgroundImage = value;
  78. }
  79. }
  80. /// <summary>
  81. /// 获取或设置控件的背景色
  82. /// </summary>
  83. [DefaultValue(typeof(Color), "Transparent")]
  84. public new Color BackColor
  85. {
  86. get
  87. {
  88. return base.BackColor;
  89. }
  90. set
  91. {
  92. base.BackColor = value;
  93. }
  94. }
  95. /// <summary>
  96. /// 获取或设置用于在控件中显示文本的字体。
  97. /// </summary>
  98. [DefaultValue(typeof(Font), "宋体, 9pt")]
  99. public override Font Font
  100. {
  101. get
  102. {
  103. return base.Font;
  104. }
  105. set
  106. {
  107. base.Font = value;
  108. }
  109. }
  110. #endregion
  111. #region IAsyncControl 成员
  112. #region 成员变量
  113. /// <summary>
  114. /// 异步处理开始时,控件状态
  115. /// </summary>
  116. private bool _asyncBeginStatus = false;
  117. private bool _asyncBeginFocused = false;
  118. #endregion
  119. #region 公有方法
  120. /// <summary>
  121. /// 开始异步处理
  122. /// </summary>
  123. /// <param name="doFocus">是否处理焦点</param>
  124. public virtual void BeginAsync(ref bool doFocus)
  125. {
  126. this._asyncBeginFocused = false;
  127. if (doFocus && this.Focused)
  128. {
  129. this._asyncBeginFocused = true;
  130. doFocus = false;
  131. }
  132. this._asyncBeginStatus = this.Enabled;
  133. this.Enabled = false;
  134. }
  135. /// <summary>
  136. /// 结束异步处理
  137. /// </summary>
  138. public virtual void EndAsync()
  139. {
  140. this.Enabled = this._asyncBeginStatus;
  141. if (this._asyncBeginFocused)
  142. {
  143. this.Focus();
  144. }
  145. }
  146. #endregion
  147. #endregion
  148. }
  149. }