private void DrawUpDownButton() { bool mouseOver = false; bool mousePress = LeftKeyPressed(); bool mouseInUpButton = false; Rectangle clipRect = _upDownButton.ClientRectangle; RECT windowRect = new RECT(); NativeMethods.Point cursorPoint = new NativeMethods.Point(); NativeMethods.GetCursorPos(ref cursorPoint); NativeMethods.GetWindowRect(_upDownButtonWnd, ref windowRect); mouseOver = NativeMethods.PtInRect(ref windowRect, cursorPoint); cursorPoint.x -= windowRect.Left; cursorPoint.y -= windowRect.Top; mouseInUpButton = cursorPoint.y < clipRect.Height / 2; using (Graphics g = Graphics.FromHwnd(_upDownButtonWnd)) { UpDownButtonPaintEventArgs e = new UpDownButtonPaintEventArgs( g, clipRect, mouseOver, mousePress, mouseInUpButton); _owner.OnPaintUpDownButton(e); } }
private void DrawUpDownButton() { bool mouseOver = false; bool mousePress = this.LeftKeyPressed(); bool mouseInUpButton = false; Rectangle clipRect = this._upDownButton.ClientRectangle; CCWin.Win32.Struct.RECT windowRect = new CCWin.Win32.Struct.RECT(); CCWin.Win32.NativeMethods.Point cursorPoint = new CCWin.Win32.NativeMethods.Point(); CCWin.Win32.NativeMethods.GetCursorPos(ref cursorPoint); CCWin.Win32.NativeMethods.GetWindowRect(this._upDownButtonWnd, ref windowRect); mouseOver = CCWin.Win32.NativeMethods.PtInRect(ref windowRect, cursorPoint); cursorPoint.x -= windowRect.Left; cursorPoint.y -= windowRect.Top; mouseInUpButton = cursorPoint.y < (clipRect.Height / 2); using (Graphics g = Graphics.FromHwnd(this._upDownButtonWnd)) { UpDownButtonPaintEventArgs e = new UpDownButtonPaintEventArgs(g, clipRect, mouseOver, mousePress, mouseInUpButton); this._owner.OnPaintUpDownButton(e); } }
protected virtual void OnPaintUpDownButton(UpDownButtonPaintEventArgs e) { Graphics g = e.Graphics; Rectangle rect = e.ClipRectangle; Color upButtonBaseColor = this._baseColor; Color upButtonBorderColor = this._borderColor; Color upButtonArrowColor = this._arrowColor; Color downButtonBaseColor = this._baseColor; Color downButtonBorderColor = this._borderColor; Color downButtonArrowColor = this._arrowColor; Rectangle upButtonRect = rect; upButtonRect.Y++; upButtonRect.Width -= 2; upButtonRect.Height = (rect.Height / 2) - 2; Rectangle downButtonRect = rect; downButtonRect.Y = upButtonRect.Bottom + 2; downButtonRect.Height = (rect.Height - upButtonRect.Bottom) - 4; downButtonRect.Width -= 2; if (base.Enabled) { if (e.MouseOver) { if (e.MousePress) { if (e.MouseInUpButton) { upButtonBaseColor = this.GetColor(this._baseColor, 0, -35, -24, -9); } else { downButtonBaseColor = this.GetColor(this._baseColor, 0, -35, -24, -9); } } else if (e.MouseInUpButton) { upButtonBaseColor = this.GetColor(this._baseColor, 0, 0x23, 0x18, 9); } else { downButtonBaseColor = this.GetColor(this._baseColor, 0, 0x23, 0x18, 9); } } } else { upButtonBaseColor = SystemColors.Control; upButtonBorderColor = SystemColors.ControlDark; upButtonArrowColor = SystemColors.ControlDark; downButtonBaseColor = SystemColors.Control; downButtonBorderColor = SystemColors.ControlDark; downButtonArrowColor = SystemColors.ControlDark; } g.SmoothingMode = SmoothingMode.AntiAlias; Color backColor = base.Enabled ? base.BackColor : SystemColors.Control; using (SolidBrush brush = new SolidBrush(backColor)) { rect.Inflate(1, 1); g.FillRectangle(brush, rect); } this.RenderButton(g, upButtonRect, upButtonBaseColor, upButtonBorderColor, upButtonArrowColor, ArrowDirection.Up); this.RenderButton(g, downButtonRect, downButtonBaseColor, downButtonBorderColor, downButtonArrowColor, ArrowDirection.Down); UpDownButtonPaintEventHandler handler = base.Events[EventPaintUpDownButton] as UpDownButtonPaintEventHandler; if (handler != null) { handler(this, e); } }
protected virtual void OnPaintUpDownButton( UpDownButtonPaintEventArgs e) { Graphics g = e.Graphics; Rectangle rect = e.ClipRectangle; Color upButtonBaseColor = _baseColor; Color upButtonBorderColor = _borderColor; Color upButtonArrowColor = _arrowColor; Color downButtonBaseColor = _baseColor; Color downButtonBorderColor = _borderColor; Color downButtonArrowColor = _arrowColor; Rectangle upButtonRect = rect; upButtonRect.Y += 1; upButtonRect.Width -= 2; upButtonRect.Height = rect.Height / 2 - 2; Rectangle downButtonRect = rect; downButtonRect.Y = upButtonRect.Bottom + 2; downButtonRect.Height = rect.Height - upButtonRect.Bottom - 4; downButtonRect.Width -= 2; if (Enabled) { if (e.MouseOver) { if (e.MousePress) { if (e.MouseInUpButton) { upButtonBaseColor = GetColor(_baseColor, 0, -35, -24, -9); } else { downButtonBaseColor = GetColor(_baseColor, 0, -35, -24, -9); } } else { if (e.MouseInUpButton) { upButtonBaseColor = GetColor(_baseColor, 0, 35, 24, 9); } else { downButtonBaseColor = GetColor(_baseColor, 0, 35, 24, 9); } } } } else { upButtonBaseColor = SystemColors.Control; upButtonBorderColor = SystemColors.ControlDark; upButtonArrowColor = SystemColors.ControlDark; downButtonBaseColor = SystemColors.Control; downButtonBorderColor = SystemColors.ControlDark; downButtonArrowColor = SystemColors.ControlDark; } g.SmoothingMode = SmoothingMode.AntiAlias; Color backColor = Enabled ? base.BackColor : SystemColors.Control; using (SolidBrush brush = new SolidBrush(backColor)) { rect.Inflate(1, 1); g.FillRectangle(brush, rect); } RenderButton( g, upButtonRect, upButtonBaseColor, upButtonBorderColor, upButtonArrowColor, ArrowDirection.Up); RenderButton( g, downButtonRect, downButtonBaseColor, downButtonBorderColor, downButtonArrowColor, ArrowDirection.Down); UpDownButtonPaintEventHandler handler = base.Events[EventPaintUpDownButton] as UpDownButtonPaintEventHandler; if (handler != null) { handler(this, e); } }