/******************************************************************************* * 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 { /// /// 扩展的窗口 /// public partial class FormBase : DKForm { #region 成员变量 private string _statusStripTip; private FormWindowState _formWindowState = FormWindowState.Normal; private bool _statusStripVisible = true; private DataSet _dataSource = null; // 窗体的数据源 #endregion 成员变量 #region 构造函数 /// /// 构造函数 /// public FormBase() { InitializeComponent(); base.IsSaveFormSize = true; base.IsSaveFormLocation = true; this.dkStatusStrip.TabStop = false; } #endregion 构造函数 #region 窗体属性 /// /// 窗体的数据源的取得和设定 /// [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; } } /// /// 状态栏 /// [Browsable(true)] [DefaultValue(typeof(string), "")] public string StatusStripTitle { get { return this.dkStatusStrip.TitleText; } set { this.dkStatusStrip.TitleText = value; } } //private bool vv = true; /// /// 状态栏显示设置 /// [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; } } /// /// 状态栏背景色 /// [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); } } /// /// 状态栏的时间可见设置 /// [Browsable(true)] [DefaultValue(typeof(bool), "true")] public bool StatusTimerVisible { get { return this.dkStatusStrip.IsTimer; } set { this.dkStatusStrip.IsTimer = value; } } ///// ///// 窗体是否可以改变大小 ///// //[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; // } //} /// /// 通信状态Lable的值设定和取得 /// [Browsable(true)] [Description("通信状态Lable的值设定和取得。")] public string StatusText { get { return this.dkStatusStrip.StatusText; } set { this.dkStatusStrip.StatusText = value; } } #endregion 窗体属性 #region 公共方法 /// /// 开始进程 /// public override void StartProgress() { base.StartProgress(); this.dkStatusStrip.IsCommunicate = true; } /// /// 结束进程 /// public override void EndProgress() { base.EndProgress(); this.dkStatusStrip.IsCommunicate = false; } /// /// 进程中设置提示信息 /// /// public void SetProgressText(string text) { this.StatusStripTitle = text; } /// /// 激活窗体 /// public void ActivateForm() { this.Visible = true; if (this.WindowState == FormWindowState.Minimized) { this.WindowState = this._formWindowState; } this.Activate(); } #endregion #region 事件处理 /// /// 画面显示大小改变 /// /// /// private void FormBase_SizeChanged(object sender, EventArgs e) { if (this.WindowState != FormWindowState.Minimized) { this._formWindowState = this.WindowState; } } #endregion #region 重写方法或者函数 /// /// 重写Form的OnLoad事件 /// /// 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); } } } /// /// 重写Form的OnFormClosed事件 /// /// 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 } }