DKToolStrip.cs 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /*******************************************************************************
  2. * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:DKToolStrip.cs
  5. * 2.功能描述:扩展的工具栏控件:便于修改背景颜色及字体、颜色
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 陈晓野 2014/08/13 1.00 新建
  9. *******************************************************************************/
  10. using System.Collections.Generic;
  11. using System.Windows.Forms;
  12. namespace Dongke.IBOSS.PRD.Basics.BaseControls
  13. {
  14. /// <summary>
  15. /// 扩展的工具栏控件
  16. /// </summary>
  17. public abstract partial class DKToolStrip : ToolStrip, IDKControl
  18. {
  19. #region 成员变量
  20. // 异步处理开始时,控件状态
  21. private Dictionary<ToolStripItem, bool> _beginAsyncStatus;
  22. #endregion
  23. #region 控件构造函数
  24. public DKToolStrip()
  25. {
  26. InitializeComponent();
  27. this.Font = ControlsConst.FONT_SYSTEM_DEFAULT;
  28. }
  29. #endregion
  30. #region 控件属性
  31. #endregion
  32. #region 公有方法
  33. /// <summary>
  34. /// 异步处理开始
  35. /// </summary>
  36. public void BeginAsync()
  37. {
  38. if (_beginAsyncStatus == null)
  39. {
  40. _beginAsyncStatus = new Dictionary<ToolStripItem, bool>();
  41. }
  42. foreach (ToolStripItem item in this.Items)
  43. {
  44. if (item is ToolStripSeparator
  45. || item is ToolStripLabel
  46. || item is ToolStripProgressBar
  47. )
  48. {
  49. }
  50. else if (item is ToolStripTextBox)
  51. {
  52. ToolStripTextBox tst = (item as ToolStripTextBox);
  53. _beginAsyncStatus.Add(tst, tst.ReadOnly);
  54. tst.ReadOnly = true;
  55. }
  56. else
  57. {
  58. _beginAsyncStatus.Add(item, item.Enabled);
  59. item.Enabled = false;
  60. }
  61. }
  62. }
  63. /// <summary>
  64. /// 异步处理结束
  65. /// </summary>
  66. public void EndAsync()
  67. {
  68. foreach (ToolStripItem item in _beginAsyncStatus.Keys)
  69. {
  70. if (item is ToolStripSeparator
  71. || item is ToolStripLabel
  72. || item is ToolStripProgressBar
  73. )
  74. {
  75. }
  76. else if (item is ToolStripTextBox)
  77. {
  78. ToolStripTextBox tst = (item as ToolStripTextBox);
  79. tst.ReadOnly = _beginAsyncStatus[item];
  80. }
  81. else
  82. {
  83. item.Enabled = _beginAsyncStatus[item];
  84. }
  85. }
  86. _beginAsyncStatus.Clear();
  87. }
  88. #endregion
  89. }
  90. }