/**/ #endregion #region Constructor /// <summary> /// Initializes a new instance of the <see cref="ZeroitMetroCheckBox" /> class. /// </summary> public ZeroitMetroCheckBox() { this.rect = new Rectangle(0, 0, 16, 16); this.CurrentState = ZeroitMetroCheckBox.MouseState.None; this._Text = this.Name; this._Style = Design.Style.Light; this._DrawBorders = true; this._Checked = true; this._CheckOnClick = true; this._UseFullDetectionArea = false; this.ColorScheme = new ZeroitMetroCheckBox.MainColorScheme(); this.Size = new System.Drawing.Size(115, 18); this.SetStyle(ControlStyles.UserPaint | ControlStyles.ResizeRedraw | ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer, true); this.UpdateStyles(); this.FixBug(); }
/// <summary> /// Raises the <see cref="E:System.Windows.Forms.Control.MouseUp" /> event. /// </summary> /// <param name="e">A <see cref="T:System.Windows.Forms.MouseEventArgs" /> that contains the event data.</param> protected override void OnMouseUp(MouseEventArgs e) { ZeroitMetroCheckBox.CheckedChangedEventHandler checkedChangedEventHandler; if (this.UseFullDetectionArea) { if (this.CheckOnClick) { if (this.Checked) { this.Checked = false; } else if (!this.Checked) { this.Checked = true; } checkedChangedEventHandler = this.CheckedChanged; if (checkedChangedEventHandler != null) { checkedChangedEventHandler(this, new EventArgs()); } this.Invalidate(); } } else if (this.rect.Contains(e.Location)) { if (this.CheckOnClick) { if (this.Checked) { this.Checked = false; } else if (!this.Checked) { this.Checked = true; } checkedChangedEventHandler = this.CheckedChanged; if (checkedChangedEventHandler != null) { checkedChangedEventHandler(this, new EventArgs()); } this.Invalidate(); } } this.CurrentState = ZeroitMetroCheckBox.MouseState.Over; base.OnMouseUp(e); }
/// <summary> /// Raises the <see cref="E:System.Windows.Forms.Control.MouseLeave" /> event. /// </summary> /// <param name="e">An <see cref="T:System.EventArgs" /> that contains the event data.</param> protected override void OnMouseLeave(EventArgs e) { this.CurrentState = ZeroitMetroCheckBox.MouseState.None; this.Invalidate(); base.OnMouseLeave(e); }
/// <summary> /// Raises the <see cref="E:System.Windows.Forms.Control.MouseEnter" /> event. /// </summary> /// <param name="e">An <see cref="T:System.EventArgs" /> that contains the event data.</param> protected override void OnMouseEnter(EventArgs e) { this.CurrentState = ZeroitMetroCheckBox.MouseState.Over; this.Invalidate(); base.OnMouseEnter(e); }