protected override void OnMouseClick(MouseEventArgs e) { base.OnMouseClick(e); var loc = e.Location; if (_minimizeButton.Contains(loc) && OnMinimizeClicked != null) { OnMinimizeClicked(this, e); } if (_maximizeButton.Contains(loc) && OnMaximizeClicked != null) { OnMaximizeClicked(this, e); var hostForm = this.FindForm(); if (hostForm.WindowState == FormWindowState.Maximized) { _maximizeButton.Image = _maximizeImg; } else { _maximizeButton.Image = _normalImg; } Invalidate(_maximizeButton.Boundary); } if (_closeButton.Contains(loc) && OnCloseClicked != null) { OnCloseClicked(this, e); } }
private void RedrawIfButtonHoverStateChange(TitleBarControlButton btn, Point location) { var isMouseHover = btn.Contains(location); if (isMouseHover != btn.IsMouseHover) { btn.IsMouseHover = isMouseHover; Invalidate(btn.Boundary); } }