FormBase.cs 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334
  1. /*******************************************************************************
  2. * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:FormBase.cs
  5. * 2.功能描述:扩展的窗口:便于修改背景颜色及字体、颜色
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 陈晓野 2014/08/13 1.00 新建
  9. *******************************************************************************/
  10. using System;
  11. using System.ComponentModel;
  12. using System.Data;
  13. using System.Drawing;
  14. using System.Windows.Forms;
  15. using Dongke.IBOSS.PRD.Basics.Library;
  16. namespace Dongke.IBOSS.PRD.Basics.BaseControls
  17. {
  18. /// <summary>
  19. /// 扩展的窗口
  20. /// </summary>
  21. public partial class FormBase : DKForm
  22. {
  23. #region 成员变量
  24. private string _statusStripTip;
  25. private FormWindowState _formWindowState = FormWindowState.Normal;
  26. private bool _statusStripVisible = true;
  27. private DataSet _dataSource = null; // 窗体的数据源
  28. #endregion 成员变量
  29. #region 构造函数
  30. /// <summary>
  31. /// 构造函数
  32. /// </summary>
  33. public FormBase()
  34. {
  35. InitializeComponent();
  36. base.IsSaveFormSize = true;
  37. base.IsSaveFormLocation = true;
  38. this.dkStatusStrip.TabStop = false;
  39. }
  40. #endregion 构造函数
  41. #region 窗体属性
  42. /// <summary>
  43. /// 窗体的数据源的取得和设定
  44. /// </summary>
  45. [Browsable(true)]
  46. [DefaultValue(null)]
  47. [Description("窗体的数据源的取得和设定。")]
  48. public DataSet DataSource
  49. {
  50. get
  51. {
  52. return _dataSource;
  53. }
  54. set
  55. {
  56. _dataSource = value;
  57. }
  58. }
  59. [Browsable(true)]
  60. [DefaultValue(typeof(bool), "true")]
  61. public bool StatusSizingGrip
  62. {
  63. get
  64. {
  65. return this.dkStatusStrip.SizingGrip;
  66. }
  67. set
  68. {
  69. this.dkStatusStrip.SizingGrip = value;
  70. if (value)
  71. {
  72. this.FormBorderStyle = FormBorderStyle.Sizable;
  73. }
  74. else
  75. {
  76. this.FormBorderStyle = FormBorderStyle.FixedSingle;
  77. }
  78. this.MaximizeBox = value;
  79. }
  80. }
  81. /// <summary>
  82. /// 状态栏
  83. /// </summary>
  84. [Browsable(true)]
  85. [DefaultValue(typeof(string), "")]
  86. public string StatusStripTitle
  87. {
  88. get
  89. {
  90. return this.dkStatusStrip.TitleText;
  91. }
  92. set
  93. {
  94. this.dkStatusStrip.TitleText = value;
  95. }
  96. }
  97. //private bool vv = true;
  98. /// <summary>
  99. /// 状态栏显示设置
  100. /// </summary>
  101. [Browsable(true)]
  102. [Description("状态栏是否显示设定和取得。")]
  103. [DefaultValue(true)]
  104. public bool StatusStripVisible
  105. {
  106. get
  107. {
  108. return _statusStripVisible;
  109. }
  110. set
  111. {
  112. if (value)
  113. {
  114. this.Controls.Add(dkStatusStrip);
  115. this.Controls.SetChildIndex(dkStatusStrip, 0);
  116. this.dkStatusStrip.IsTimer = true;
  117. }
  118. else
  119. {
  120. this.Controls.Remove(dkStatusStrip);
  121. this.dkStatusStrip.IsTimer = false;
  122. }
  123. this.dkStatusStrip.Visible = value;
  124. _statusStripVisible = value;
  125. }
  126. }
  127. /// <summary>
  128. /// 状态栏背景色
  129. /// </summary>
  130. [Browsable(true)]
  131. public Color StatusBackColor
  132. {
  133. get
  134. {
  135. return this.dkStatusStrip.BackColor;
  136. }
  137. set
  138. {
  139. this.dkStatusStrip.BackColor = value;
  140. }
  141. }
  142. [Browsable(true)]
  143. public string StatusStripTip
  144. {
  145. get
  146. {
  147. return _statusStripTip;
  148. }
  149. set
  150. {
  151. this._statusStripTip = value;
  152. this.toolTipStatusStrip.SetToolTip(this.dkStatusStrip, _statusStripTip);
  153. }
  154. }
  155. /// <summary>
  156. /// 状态栏的时间可见设置
  157. /// </summary>
  158. [Browsable(true)]
  159. [DefaultValue(typeof(bool), "true")]
  160. public bool StatusTimerVisible
  161. {
  162. get
  163. {
  164. return this.dkStatusStrip.IsTimer;
  165. }
  166. set
  167. {
  168. this.dkStatusStrip.IsTimer = value;
  169. }
  170. }
  171. ///// <summary>
  172. ///// 窗体是否可以改变大小
  173. ///// </summary>
  174. //[Browsable(true)]
  175. //[DefaultValue(typeof(bool), "true")]
  176. //public bool ReSize
  177. //{
  178. // get
  179. // {
  180. // return this.StatusSizingGrip;
  181. // }
  182. // set
  183. // {
  184. // this.StatusSizingGrip = value;
  185. // if (value)
  186. // {
  187. // this.FormBorderStyle = FormBorderStyle.Sizable;
  188. // }
  189. // else
  190. // {
  191. // this.FormBorderStyle = FormBorderStyle.FixedSingle;
  192. // }
  193. // this.MaximizeBox = value;
  194. // }
  195. //}
  196. /// <summary>
  197. /// 通信状态Lable的值设定和取得
  198. /// </summary>
  199. [Browsable(true)]
  200. [Description("通信状态Lable的值设定和取得。")]
  201. public string StatusText
  202. {
  203. get
  204. {
  205. return this.dkStatusStrip.StatusText;
  206. }
  207. set
  208. {
  209. this.dkStatusStrip.StatusText = value;
  210. }
  211. }
  212. #endregion 窗体属性
  213. #region 公共方法
  214. /// <summary>
  215. /// 开始进程
  216. /// </summary>
  217. public override void StartProgress()
  218. {
  219. base.StartProgress();
  220. this.dkStatusStrip.IsCommunicate = true;
  221. }
  222. /// <summary>
  223. /// 结束进程
  224. /// </summary>
  225. public override void EndProgress()
  226. {
  227. base.EndProgress();
  228. this.dkStatusStrip.IsCommunicate = false;
  229. }
  230. /// <summary>
  231. /// 进程中设置提示信息
  232. /// </summary>
  233. /// <param name="text"></param>
  234. public void SetProgressText(string text)
  235. {
  236. this.StatusStripTitle = text;
  237. }
  238. /// <summary>
  239. /// 激活窗体
  240. /// </summary>
  241. public void ActivateForm()
  242. {
  243. this.Visible = true;
  244. if (this.WindowState == FormWindowState.Minimized)
  245. {
  246. this.WindowState = this._formWindowState;
  247. }
  248. this.Activate();
  249. }
  250. #endregion
  251. #region 事件处理
  252. /// <summary>
  253. /// 画面显示大小改变
  254. /// </summary>
  255. /// <param name="sender"></param>
  256. /// <param name="e"></param>
  257. private void FormBase_SizeChanged(object sender, EventArgs e)
  258. {
  259. if (this.WindowState != FormWindowState.Minimized)
  260. {
  261. this._formWindowState = this.WindowState;
  262. }
  263. }
  264. #endregion
  265. #region 重写方法或者函数
  266. /// <summary>
  267. /// 重写Form的OnLoad事件
  268. /// </summary>
  269. /// <param name="e"></param>
  270. protected override void OnLoad(EventArgs e)
  271. {
  272. base.OnLoad(e);
  273. //datagridview控件设置保存
  274. Control[] controls = this.GetControls(this, typeof(C_DataGridView));
  275. foreach (C_DataGridView dgv in controls)
  276. {
  277. if (dgv.IsSaveDataGridViewSetting)
  278. {
  279. GridSettingManager.InitializeGridSetting(dgv, this.Name + dgv.Name);
  280. }
  281. }
  282. }
  283. /// <summary>
  284. /// 重写Form的OnFormClosed事件
  285. /// </summary>
  286. /// <param name="e"></param>
  287. protected override void OnFormClosed(FormClosedEventArgs e)
  288. {
  289. // datagridview控件设置保存(TODO)
  290. Control[] items = this.GetControls(this, typeof(C_DataGridView));
  291. foreach (C_DataGridView grd in items)
  292. {
  293. if (grd.IsSaveDataGridViewSetting)
  294. {
  295. GridSettingManager.SaveGridSetting(grd, this.Name + grd.Name);
  296. }
  297. }
  298. base.OnFormClosed(e);
  299. }
  300. #endregion
  301. }
  302. }