/// ------------------------------------------------------------------------------------ protected override void OnPaintBackground(PaintEventArgs e) { base.OnPaintBackground(e); if (m_mouseOver || Checked) { m_state = (m_mouseDown ? PaintState.HotDown : PaintState.Hot); } else { m_state = PaintState.Normal; } if (DrawBackground != null && DrawBackground(this, e, m_state)) { return; } var rc = ClientRectangle; using (SolidBrush br = new SolidBrush(BackColor)) e.Graphics.FillRectangle(br, rc); if (m_state != PaintState.Normal) { PaintingHelper.DrawHotBackground(e.Graphics, rc, m_state); } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Draws the button with an image. /// </summary> /// ------------------------------------------------------------------------------------ public void DrawArrow(PaintEventArgs e) { Rectangle rc = ClientRectangle; // If possible, render the button with visual styles. Otherwise, // paint the plain Windows 2000 push button. VisualStyleElement element = GetCorrectVisualStyleArrowElement(); if (PaintingHelper.CanPaintVisualStyle(element)) { VisualStyleRenderer renderer = new VisualStyleRenderer(element); renderer.DrawParentBackground(e.Graphics, rc, this); renderer.DrawBackground(e.Graphics, rc); return; } if (!Font.SizeInPoints.Equals(12)) { Font = new Font(Font.FontFamily, 12, GraphicsUnit.Point); } ControlPaint.DrawButton(e.Graphics, rc, (m_state == PaintState.HotDown ? ButtonState.Pushed : ButtonState.Normal)); // In the Marlette font, '3' is the left arrow and '4' is the right. var arrowGlyph = (m_drawLeftArrowButton ? "3" : "4"); var clr = (Enabled ? SystemColors.ControlText : SystemColors.GrayText); // The 'r' in the Marlette font is the close button symbol 'X' TextRenderer.DrawText(e.Graphics, arrowGlyph, Font, rc, clr, fTxtFmtflags); }
/// ------------------------------------------------------------------------------------ private void DrawMinimalistButton(Graphics g, Rectangle rc) { var element = GetVisualStyleComboButton(); rc = AdjustRectToDefaultComboButtonWidth(rc); if (element != VisualStyleElement.ComboBox.DropDownButton.Normal && element != VisualStyleElement.ComboBox.DropDownButton.Disabled && PaintingHelper.CanPaintVisualStyle(element)) { var renderer = new VisualStyleRenderer(element); renderer.DrawBackground(g, rc); } else { var pen = (element == VisualStyleElement.ComboBox.DropDownButton.Disabled ? SystemPens.GrayText : SystemPens.WindowText); var x = rc.X + (int)Math.Round((rc.Width - 7) / 2f, MidpointRounding.AwayFromZero); var y = rc.Y + (int)Math.Round((rc.Height - 4) / 2f, MidpointRounding.AwayFromZero); g.DrawLine(pen, x, y, x + 6, y++); g.DrawLine(pen, x + 1, y, x + 5, y++); g.DrawLine(pen, x + 2, y, x + 4, y); g.DrawLine(pen, x + 3, y, x + 3, y + 1); return; } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Paint a faint line between the source translation and the source tooltip and /// shortcut keys text boxes. /// </summary> /// ------------------------------------------------------------------------------------ private void HandleGroupSrcTranslationPaint(object sender, PaintEventArgs e) { using (var pen = new Pen(PaintingHelper.CalculateColor(Color.Black, Color.White, 45))) { e.Graphics.DrawLine(pen, _textBoxSrcTranslation.Left, _textBoxSrcTranslation.Bottom + 5, _textBoxSrcTranslation.Right - 1, _textBoxSrcTranslation.Bottom + 5); } }
/// ------------------------------------------------------------------------------------ private bool DrawVisualStyledButton(LmButtonColumn.ButtonType buttonStyle, IDeviceContext g, Rectangle rcbtn) { VisualStyleElement element = (buttonStyle == LmButtonColumn.ButtonType.VisualStyleCombo ? GetVisualStyleComboButton() : GetVisualStylePushButton()); if (!PaintingHelper.CanPaintVisualStyle(element)) { return(false); } VisualStyleRenderer renderer = new VisualStyleRenderer(element); rcbtn = AdjustRectToDefaultComboButtonWidth(rcbtn); renderer.DrawBackground(g, rcbtn); return(true); }
/// ------------------------------------------------------------------------------------ private void InitializeColorsAndFonts() { _textBoxSrcTranslation.BackColor = PaintingHelper.CalculateColor(SystemColors.Control, Color.White, 140); _textBoxSrcToolTip.BackColor = _textBoxSrcTranslation.BackColor; _textBoxSrcShortcutKeys.BackColor = _textBoxSrcTranslation.BackColor; btnCopyText.BackColor = _textBoxSrcTranslation.BackColor; btnCopyToolTip.BackColor = _textBoxSrcTranslation.BackColor; btnCopyShortcutKeys.BackColor = _textBoxSrcTranslation.BackColor; _grid.Font = DefaultDisplayFont; _grid.ColumnHeadersDefaultCellStyle.Font = DefaultDisplayFont; _shortcutKeysDropDown.Font = DefaultDisplayFont; _textBoxSrcTranslation.Font = DefaultDisplayFont; _colSrcToolTip.DefaultCellStyle.Font = DefaultDisplayFont; _colTgtToolTip.DefaultCellStyle.Font = DefaultDisplayFont; _treeView.Font = DefaultDisplayFont; _textBoxSrcToolTip.Font = new Font(DefaultDisplayFont.FontFamily, _textBoxSrcToolTip.Font.SizeInPoints, FontStyle.Regular); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Paints the background of the OK and Reset buttons. /// </summary> /// ------------------------------------------------------------------------------------ private bool HandleDrawButtonBackground(XButton btn, PaintEventArgs e, PaintState state) { if (state == PaintState.Hot || state == PaintState.HotDown) { return(false); } var rc = btn.ClientRectangle; Color clr = PaintingHelper.CalculateColor(Color.White, BackColor, 100); using (SolidBrush br = new SolidBrush(clr)) e.Graphics.FillRectangle(br, rc); rc.Width--; rc.Height--; clr = PaintingHelper.CalculateColor(Color.Black, BackColor, 70); using (Pen pen = new Pen(clr)) e.Graphics.DrawRectangle(pen, rc); //btn.DrawText(e); return(true); }