using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.Data; using System.Linq; using System.Text; using System.Windows.Forms; namespace POSV.Component { [ToolboxItem(true)] public partial class MainControlBox : BaseUserControl { public MainControlBox() { InitializeComponent(); this.SetStyle(ControlStyles.UserPaint, true); this.SetStyle(ControlStyles.AllPaintingInWmPaint, true); this.SetStyle(ControlStyles.Opaque, true); this.SetStyle(ControlStyles.ResizeRedraw, true); this.SetStyle(ControlStyles.StandardDoubleClick, true); this.SetStyle(ControlStyles.DoubleBuffer, true); this.SetStyle(ControlStyles.SupportsTransparentBackColor, true); this.ForeColor = NewForeColor; this.lblClose.TouchClick += this.OnCloseTouchClick; this.lblMin.TouchClick += this.OnMinTouchClick; this.lblIcon.TouchClick += this.OnIconTouchClick; } protected override void OnLoad(EventArgs e) { base.OnLoad(e); if (this.DesignMode) return; } private string _text = "巨为收银"; /// /// 窗口标题 /// public override string Text { set { this._text = value; this.lblTitle.Text = _text; this.lblTitle.Invalidate(); } get { return this._text; } } public event EventHandler CloseClick; /// /// 关闭按钮事件 /// /// protected virtual void OnCloseClick(EventArgs e) { this._eventAction = ControlBoxEventAction.Closed; CloseClick?.Invoke(this, e); } public event EventHandler MinimizedClick; /// /// 最小化按钮事件 /// /// protected virtual void OnMinimizedClick(EventArgs e) { this._eventAction = ControlBoxEventAction.Minimized; MinimizedClick?.Invoke(this, e); } private void OnMinTouchClick(object sender, EventArgs e) { OnMinimizedClick(e); } public event EventHandler IconClick; private void OnCloseTouchClick(object sender, EventArgs e) { OnCloseClick(e); } private void OnIconTouchClick(object sender, EventArgs e) { OnIconClick(e); } /// /// ICON点击事件 /// /// protected virtual void OnIconClick(EventArgs e) { this._eventAction = ControlBoxEventAction.Icon; IconClick?.Invoke(this, e); } private ControlBoxEventAction _eventAction = ControlBoxEventAction.None; public ControlBoxEventAction Action { get { return _eventAction; } } private Color _foreColor = Color.Black; /// /// 标题的字体颜色 /// public Color NewForeColor { get { return this._foreColor; } set { this._foreColor = value; this.lblTitle.ForeColor = this._foreColor; this.lblTitle.Invalidate(); } } private bool _minimizeBox = true; /// /// 是否显示最小化按钮 /// public bool MinimizeBox { get { return this._minimizeBox; } set { this._minimizeBox = value; this.lblMin.Visible = this._minimizeBox; this.lblMin.Invalidate(); } } private bool _closeBox = true; /// /// 是否显示关闭按钮 /// public bool CloseBox { get { return this._closeBox; } set { this._closeBox = value; this.lblClose.Visible = this._closeBox; this.lblClose.Invalidate(); } } private bool _showNetworkStatus = true; /// /// 是否显示网路连接 /// public bool ShowNetworkStatus { get { return this._showNetworkStatus; } set { this._showNetworkStatus = value; this.lblNetworkStatus.Visible = this._showNetworkStatus; this.lblNetworkStatus.Invalidate(); } } private bool _network = false; /// /// 网络检测默认的标题文字 /// public bool NetworkStatus { set { this._network = value; this.lblNetworkStatus.Symbol = value ? Constant.ONLINE : Constant.OFFLINE; this.lblNetworkStatus.SymbolColor = value ? Color.Green : Color.Red; this.lblNetworkStatus.Invalidate(); } get { return this._network; } } private bool _iconBox = false; /// /// 是否ICON按钮 /// public bool IconBox { get { return this._iconBox; } set { this._iconBox = value; this.lblIcon.Visible = this._iconBox; this.lblIcon.Invalidate(); } } [Editor("DevComponents.DotNetBar.Design.SymbolTypeEditor, DevComponents.DotNetBar.Design", typeof(System.Drawing.Design.UITypeEditor))] public string Icon { get { return this.lblIcon.Symbol; } set { if (value != this.lblIcon.Symbol) { this.lblIcon.Symbol = value; this.lblIcon.Invalidate(); } } } public float IconSize { get { return this.lblIcon.SymbolSize; } set { this.lblIcon.SymbolSize = value; this.lblIcon.Invalidate(); } } public Color IconColor { get { return this.lblIcon.SymbolColor; } set { this.lblIcon.SymbolColor = value; this.lblIcon.Invalidate(); } } } }