| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334 |
- /*******************************************************************************
- * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
- * 类的信息:
- * 1.程序名称:FormBase.cs
- * 2.功能描述:扩展的窗口:便于修改背景颜色及字体、颜色
- * 编辑履历:
- * 作者 日期 版本 修改内容
- * 陈晓野 2014/08/13 1.00 新建
- *******************************************************************************/
- using System;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Windows.Forms;
- using Dongke.IBOSS.PRD.Basics.Library;
- namespace Dongke.IBOSS.PRD.Basics.BaseControls
- {
- /// <summary>
- /// 扩展的窗口
- /// </summary>
- public partial class FormBase : DKForm
- {
- #region 成员变量
- private string _statusStripTip;
- private FormWindowState _formWindowState = FormWindowState.Normal;
- private bool _statusStripVisible = true;
- private DataSet _dataSource = null; // 窗体的数据源
- #endregion 成员变量
- #region 构造函数
- /// <summary>
- /// 构造函数
- /// </summary>
- public FormBase()
- {
- InitializeComponent();
- base.IsSaveFormSize = true;
- base.IsSaveFormLocation = true;
- this.dkStatusStrip.TabStop = false;
- }
- #endregion 构造函数
- #region 窗体属性
- /// <summary>
- /// 窗体的数据源的取得和设定
- /// </summary>
- [Browsable(true)]
- [DefaultValue(null)]
- [Description("窗体的数据源的取得和设定。")]
- public DataSet DataSource
- {
- get
- {
- return _dataSource;
- }
- set
- {
- _dataSource = value;
- }
- }
- [Browsable(true)]
- [DefaultValue(typeof(bool), "true")]
- public bool StatusSizingGrip
- {
- get
- {
- return this.dkStatusStrip.SizingGrip;
- }
- set
- {
- this.dkStatusStrip.SizingGrip = value;
- if (value)
- {
- this.FormBorderStyle = FormBorderStyle.Sizable;
- }
- else
- {
- this.FormBorderStyle = FormBorderStyle.FixedSingle;
- }
- this.MaximizeBox = value;
- }
- }
- /// <summary>
- /// 状态栏
- /// </summary>
- [Browsable(true)]
- [DefaultValue(typeof(string), "")]
- public string StatusStripTitle
- {
- get
- {
- return this.dkStatusStrip.TitleText;
- }
- set
- {
- this.dkStatusStrip.TitleText = value;
- }
- }
- //private bool vv = true;
- /// <summary>
- /// 状态栏显示设置
- /// </summary>
- [Browsable(true)]
- [Description("状态栏是否显示设定和取得。")]
- [DefaultValue(true)]
- public bool StatusStripVisible
- {
- get
- {
- return _statusStripVisible;
- }
- set
- {
- if (value)
- {
- this.Controls.Add(dkStatusStrip);
- this.Controls.SetChildIndex(dkStatusStrip, 0);
- this.dkStatusStrip.IsTimer = true;
- }
- else
- {
- this.Controls.Remove(dkStatusStrip);
- this.dkStatusStrip.IsTimer = false;
- }
- this.dkStatusStrip.Visible = value;
- _statusStripVisible = value;
- }
- }
- /// <summary>
- /// 状态栏背景色
- /// </summary>
- [Browsable(true)]
- public Color StatusBackColor
- {
- get
- {
- return this.dkStatusStrip.BackColor;
- }
- set
- {
- this.dkStatusStrip.BackColor = value;
- }
- }
- [Browsable(true)]
- public string StatusStripTip
- {
- get
- {
- return _statusStripTip;
- }
- set
- {
- this._statusStripTip = value;
- this.toolTipStatusStrip.SetToolTip(this.dkStatusStrip, _statusStripTip);
- }
- }
- /// <summary>
- /// 状态栏的时间可见设置
- /// </summary>
- [Browsable(true)]
- [DefaultValue(typeof(bool), "true")]
- public bool StatusTimerVisible
- {
- get
- {
- return this.dkStatusStrip.IsTimer;
- }
- set
- {
- this.dkStatusStrip.IsTimer = value;
- }
- }
- ///// <summary>
- ///// 窗体是否可以改变大小
- ///// </summary>
- //[Browsable(true)]
- //[DefaultValue(typeof(bool), "true")]
- //public bool ReSize
- //{
- // get
- // {
- // return this.StatusSizingGrip;
- // }
- // set
- // {
- // this.StatusSizingGrip = value;
- // if (value)
- // {
- // this.FormBorderStyle = FormBorderStyle.Sizable;
- // }
- // else
- // {
- // this.FormBorderStyle = FormBorderStyle.FixedSingle;
- // }
- // this.MaximizeBox = value;
- // }
- //}
- /// <summary>
- /// 通信状态Lable的值设定和取得
- /// </summary>
- [Browsable(true)]
- [Description("通信状态Lable的值设定和取得。")]
- public string StatusText
- {
- get
- {
- return this.dkStatusStrip.StatusText;
- }
- set
- {
- this.dkStatusStrip.StatusText = value;
- }
- }
- #endregion 窗体属性
- #region 公共方法
- /// <summary>
- /// 开始进程
- /// </summary>
- public override void StartProgress()
- {
- base.StartProgress();
- this.dkStatusStrip.IsCommunicate = true;
- }
- /// <summary>
- /// 结束进程
- /// </summary>
- public override void EndProgress()
- {
- base.EndProgress();
- this.dkStatusStrip.IsCommunicate = false;
- }
- /// <summary>
- /// 进程中设置提示信息
- /// </summary>
- /// <param name="text"></param>
- public void SetProgressText(string text)
- {
- this.StatusStripTitle = text;
- }
- /// <summary>
- /// 激活窗体
- /// </summary>
- public void ActivateForm()
- {
- this.Visible = true;
- if (this.WindowState == FormWindowState.Minimized)
- {
- this.WindowState = this._formWindowState;
- }
- this.Activate();
- }
- #endregion
- #region 事件处理
- /// <summary>
- /// 画面显示大小改变
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void FormBase_SizeChanged(object sender, EventArgs e)
- {
- if (this.WindowState != FormWindowState.Minimized)
- {
- this._formWindowState = this.WindowState;
- }
- }
- #endregion
- #region 重写方法或者函数
- /// <summary>
- /// 重写Form的OnLoad事件
- /// </summary>
- /// <param name="e"></param>
- protected override void OnLoad(EventArgs e)
- {
- base.OnLoad(e);
- //datagridview控件设置保存
- Control[] controls = this.GetControls(this, typeof(C_DataGridView));
- foreach (C_DataGridView dgv in controls)
- {
- if (dgv.IsSaveDataGridViewSetting)
- {
- GridSettingManager.InitializeGridSetting(dgv, this.Name + dgv.Name);
- }
- }
- }
- /// <summary>
- /// 重写Form的OnFormClosed事件
- /// </summary>
- /// <param name="e"></param>
- protected override void OnFormClosed(FormClosedEventArgs e)
- {
- // datagridview控件设置保存(TODO)
- Control[] items = this.GetControls(this, typeof(C_DataGridView));
- foreach (C_DataGridView grd in items)
- {
- if (grd.IsSaveDataGridViewSetting)
- {
- GridSettingManager.SaveGridSetting(grd, this.Name + grd.Name);
- }
- }
- base.OnFormClosed(e);
- }
- #endregion
- }
- }
|