public override void PaintControl(RichTextBox control, ControlPaintArgs args) { INode controlNode = new ControlNode(control); IRuleset ruleset = args.StyleSheet.GetRuleset(controlNode); RenderUtilities.ApplyColorProperties(control, ruleset); Rectangle clientRect = control.ClientRectangle; Rectangle borderRect = new Rectangle(clientRect.X - 3, clientRect.Y - 3, clientRect.Width + 6, clientRect.Height + 6); ScrollBars visibleScrollbars = ControlUtilities.GetVisibleScrollBars(control); if (visibleScrollbars.HasFlag(ScrollBars.Vertical)) { borderRect = new Rectangle(borderRect.X, borderRect.Y, borderRect.Width + SystemInformation.VerticalScrollBarWidth, borderRect.Height); } if (visibleScrollbars.HasFlag(ScrollBars.Horizontal)) { borderRect = new Rectangle(borderRect.X, borderRect.Y, borderRect.Width, borderRect.Height + SystemInformation.HorizontalScrollBarHeight); } args.PaintBackground(borderRect); args.PaintBorder(borderRect); }
private void PaintGenericControl(ControlPaintArgs e) { IRuleset ruleset = e.StyleSheet.GetRuleset(new ControlNode(e.Control)); RenderUtilities.ApplyColorProperties(e.Control, ruleset); e.PaintBackground(); e.PaintBorder(); }
// Public members public override void PaintControl(NumericUpDown control, ControlPaintArgs e) { IRuleset ruleset = e.StyleSheet.GetRuleset(control); // Update the color of the NumericUpdateDown, which updates the color of the UpDownEdit (inheriting from TextBox). RenderUtilities.ApplyColorProperties(control, ruleset); // Like TextBoxes, NumericUpDowns are 23 pixels high. // Because the NumericUpDown has BorderStyle.None, we need to adjust it to look like a bordered control. Rectangle clientRect = control.ClientRectangle; int x = clientRect.X - 2; int y = clientRect.Y - 2; int w = clientRect.Width + 3; int h = clientRect.Height + 4; double topWidth = ruleset.BorderTopWidth?.Value ?? 0; double rightWidth = ruleset.BorderRightWidth?.Value ?? 0; double bottomWidth = ruleset.BorderBottomWidth?.Value ?? 0; double leftWidth = ruleset.BorderLeftWidth?.Value ?? 0; if (topWidth <= 1) { topWidth = 0; } if (rightWidth <= 1) { rightWidth = 0; } if (bottomWidth <= 1) { bottomWidth = 0; } if (leftWidth <= 1) { leftWidth = 0; } x -= (int)leftWidth; y -= (int)topWidth; w += (int)leftWidth + (int)rightWidth; h += (int)topWidth + (int)bottomWidth; Rectangle drawRect = new Rectangle(x, y, w, h); e.StyleRenderer.PaintBackground(e.Graphics, drawRect, ruleset); e.StyleRenderer.PaintBorder(e.Graphics, drawRect, ruleset); }
// Public members public override void PaintControl(ComboBox control, ControlPaintArgs e) { IRuleset ruleset = e.StyleSheet.GetRuleset(control); RenderUtilities.ApplyColorProperties(control, ruleset); Rectangle clientRect = control.ClientRectangle; e.PaintBackground(); // Match the foreground bounds of the default control. // The text is cut off behind the drop-down arrow. Rectangle textRect = new Rectangle(clientRect.X + 1, clientRect.Y, clientRect.Width - 21, clientRect.Height); e.PaintText(textRect); PaintDropDownArrow(control, e); e.PaintBorder(); }
// Public members public override void PaintControl(TextBox control, ControlPaintArgs e) { IRuleset ruleset = e.StyleSheet.GetRuleset(control); // Update the color of the TextBox itself. RenderUtilities.ApplyColorProperties(control, ruleset); // Draw the background the TextBox. // The height of regular TextBoxes is 23 pixels, with 3 pixels of horizontal padding. Rectangle clientRect = control.ClientRectangle; int x = clientRect.X - 3; int y = clientRect.Y - 4; int w = clientRect.Width + 6; int h = clientRect.Height + 7; double topWidth = ruleset.BorderTopWidth?.Value ?? 0; double rightWidth = ruleset.BorderRightWidth?.Value ?? 0; double bottomWidth = ruleset.BorderBottomWidth?.Value ?? 0; double leftWidth = ruleset.BorderLeftWidth?.Value ?? 0; if (topWidth <= 1) { topWidth = 0; } if (rightWidth <= 1) { rightWidth = 0; } if (bottomWidth <= 1) { bottomWidth = 0; } if (leftWidth <= 1) { leftWidth = 0; } x -= (int)leftWidth; y -= (int)topWidth; w += (int)leftWidth + (int)rightWidth; h += (int)topWidth + (int)bottomWidth; ScrollBars visibleScrollbars = ControlUtilities.GetVisibleScrollBars(control); if (visibleScrollbars.HasFlag(ScrollBars.Vertical)) { w += SystemInformation.VerticalScrollBarWidth; } if (visibleScrollbars.HasFlag(ScrollBars.Horizontal)) { h += SystemInformation.HorizontalScrollBarHeight; } //GraphicsState graphicsState = graphics.Save(); Rectangle drawRect = new Rectangle(x, y, w, h); //graphics.SetClip(drawRect); e.StyleRenderer.PaintBackground(e.Graphics, drawRect, ruleset); e.StyleRenderer.PaintBorder(e.Graphics, drawRect, ruleset); //graphics.Restore(graphicsState); }