public static void RenderEllipseGlass(Graphics g, Rectangle ownerRect, GlassPosition position, float positionFactor, Color glassColor, int alphaCenter, int alphaSurround) { if (!(positionFactor > 0 && positionFactor < 1)) throw new ArgumentException("positionFactor must be between 0 and 1, but not include 0 and 1. ", "positionFactor"); ownerRect.Height--; ownerRect.Width--; if (ownerRect.Width < 1 || ownerRect.Height < 1) return; using (GraphicsPath gp = new GraphicsPath()) { gp.AddEllipse(ownerRect); using (PathGradientBrush pb = new PathGradientBrush(gp)) { pb.CenterPoint = GetEllipseGlassCenterPoint(ownerRect, position, positionFactor); pb.CenterColor = Color.FromArgb(alphaCenter, glassColor); pb.SurroundColors = new Color[] { Color.FromArgb(alphaSurround, glassColor) }; using (NewSmoothModeGraphics ng = new NewSmoothModeGraphics(g, SmoothingMode.AntiAlias)) { g.FillPath(pb, gp); } } } }
public static void RenderBorder(Graphics g, Rectangle rect, Color borderColor, ButtonBorderType borderType, int radius, RoundStyle roundType) { rect.Width--; rect.Height--; bool simpleRect = (borderType == ButtonBorderType.Rectangle && (roundType == RoundStyle.None || radius < 2)); SmoothingMode newMode = simpleRect ? SmoothingMode.HighSpeed : SmoothingMode.AntiAlias; using (NewSmoothModeGraphics ng = new NewSmoothModeGraphics(g, newMode)) { using (Pen p = new Pen(borderColor)) { if (simpleRect) { g.DrawRectangle(p, rect); } else if (borderType == ButtonBorderType.Ellipse) { g.DrawEllipse(p, rect); } else { using (GraphicsPath path = GraphicsPathHelper.CreateRoundedRect(rect, radius, roundType, false)) { g.DrawPath(p, path); } } } } }
public static void RenderFlatBackground(Graphics g, Rectangle rect, Color backColor, ButtonBorderType borderType, int radius, RoundStyle roundType) { SmoothingMode newMode; bool simpleRect = (borderType == ButtonBorderType.Rectangle && (roundType == RoundStyle.None || radius < 2)); if (simpleRect) { newMode = SmoothingMode.HighSpeed; } else { newMode = SmoothingMode.AntiAlias; rect.Width--; rect.Height--; } using (NewSmoothModeGraphics ng = new NewSmoothModeGraphics(g, newMode)) { using (SolidBrush sb = new SolidBrush(backColor)) { if (simpleRect) { g.FillRectangle(sb, rect); } else if (borderType == ButtonBorderType.Ellipse) { g.FillEllipse(sb, rect); } else { using (GraphicsPath path = GraphicsPathHelper.CreateRoundedRect(rect, radius, roundType, false)) { g.FillPath(sb, path); } } } } }
public static void RenderResizeGrid(Graphics g, Rectangle rect, Color color, ResizeGridLocation location) { int x, y; Point[] ps; switch (location) { case ResizeGridLocation.BottomLeft: x = rect.Left + 1; y = rect.Bottom - 12; ps = new Point[]{ new Point(x+1,y+1), new Point(x+1,y+5), new Point(x+1,y+9), new Point(x+5,y+5), new Point(x+5,y+9), new Point(x+9,y+9)}; break; case ResizeGridLocation.TopLeft: x = rect.Left + 1; y = rect.Top + 1; ps = new Point[]{ new Point(x+1,y+1), new Point(x+1,y+5), new Point(x+1,y+9), new Point(x+5,y+1), new Point(x+5,y+5), new Point(x+9,y+1)}; break; case ResizeGridLocation.TopRight: x = rect.Right - 12; y = rect.Top + 1; ps = new Point[]{ new Point(x+1,y+1), new Point(x+5,y+1), new Point(x+5,y+5), new Point(x+9,y+1), new Point(x+9,y+5), new Point(x+9,y+9)}; break; default: x = rect.Right - 12; y = rect.Bottom - 12; ps = new Point[]{ new Point(x+9,y+1), new Point(x+9,y+5), new Point(x+9,y+9), new Point(x+5,y+5), new Point(x+5,y+9), new Point(x+1,y+9)}; break; } using (NewSmoothModeGraphics ng = new NewSmoothModeGraphics(g, SmoothingMode.HighSpeed)) { using (Pen p = new Pen(color)) { for (int i = 0; i < ps.Length; i++) { g.DrawLine(p, ps[i].X, ps[i].Y - 1, ps[i].X, ps[i].Y + 1); g.DrawLine(p, ps[i].X - 1, ps[i].Y, ps[i].X + 1, ps[i].Y); } } } }
public static void RenderLinearGradientBackground(Graphics g, Rectangle rect, Color color1, Color color2, float angle, int radius, RoundStyle roundType) { SmoothingMode newMode; bool simpleRect = (roundType == RoundStyle.None || radius < 2); if (simpleRect) { newMode = SmoothingMode.HighSpeed; } else { newMode = SmoothingMode.AntiAlias; rect.Width--; rect.Height--; } if (rect.Width < 1 || rect.Height < 1) return; using (NewSmoothModeGraphics ng = new NewSmoothModeGraphics(g, newMode)) { using (LinearGradientBrush lb = new LinearGradientBrush( rect, color1, color2, angle)) { if (simpleRect) { g.FillRectangle(lb, rect); } else { using (GraphicsPath path = GraphicsPathHelper.CreateRoundedRect(rect, radius, roundType, false)) { g.FillPath(lb, path); } } } } }
public static void RenderFocusRect(Graphics g, Rectangle rect, int inflateAmount, Color color) { using (NewSmoothModeGraphics ng = new NewSmoothModeGraphics(g, SmoothingMode.HighSpeed)) { rect.Width--; rect.Height--; rect.Inflate(-inflateAmount, -inflateAmount); using (Pen p = new Pen(color)) { p.DashStyle = DashStyle.Dot; g.DrawRectangle(p, rect); } } }
public static void RenderCheckRect(Graphics g, Rectangle rect, SmartCheckBoxThemeBase xtheme, bool enable, CheckState checkState, SmartButtonState state) { if (rect.Width < 1 || rect.Height < 1) return; // get back-color Color backColor; if (!enable) { backColor = xtheme.CheckRectBackColorDisabled; } else { switch (state) { case SmartButtonState.Hover: backColor = xtheme.CheckRectBackColorHighLight; break; case SmartButtonState.Pressed: backColor = xtheme.CheckRectBackColorPressed; break; default: backColor = xtheme.CheckRectBackColorNormal; break; } } // get outter-rect-color Color rectColor = enable ? xtheme.CheckRectColor : xtheme.CheckRectColorDisabled; // get inner-flag-color Color flagColor = enable ? xtheme.CheckFlagColor : xtheme.CheckFlagColorDisabled; using (NewSmoothModeGraphics ng = new NewSmoothModeGraphics(g, SmoothingMode.HighSpeed)) { // draw check rect backcolor using (SolidBrush sb = new SolidBrush(backColor)) { g.FillRectangle(sb, rect); } // draw check rect border using (Pen p = new Pen(rectColor)) { rect.Height--; rect.Width--; g.DrawRectangle(p, rect); // high light if (xtheme.HighLightCheckRect && state == SmartButtonState.Hover && enable) { using (Pen p2 = new Pen(Color.FromArgb(40, rectColor))) { p2.Width = 3; p2.Alignment = PenAlignment.Center; g.DrawRectangle(p2, rect); } } rect.Height++; rect.Width++; } // draw Indeterminate flag if (checkState == CheckState.Indeterminate) { rect.Inflate(-xtheme.InnerRectInflate, -xtheme.InnerRectInflate); using (SolidBrush sb = new SolidBrush(flagColor)) { g.FillRectangle(sb, rect); } } } // draw check flag if (checkState == CheckState.Checked) { using (NewSmoothModeGraphics ng = new NewSmoothModeGraphics(g, SmoothingMode.AntiAlias)) { rect.Inflate(-2, -2); rect.Height -= 3; rect.Width--; PointF p1 = new PointF(rect.X, rect.Y + rect.Height / 2.0f); PointF p2 = new PointF(rect.X + rect.Width / 3.0f, rect.Bottom); PointF p3 = new PointF(rect.Right + 1, rect.Y - 1); using (Pen p = new Pen(flagColor)) { p.Width = 1.6f; p.StartCap = LineCap.Round; p.EndCap = LineCap.Round; g.DrawLines(p, new PointF[] { p1, p2, p3 }); p2.Y += 1.8f; g.DrawLines(p, new PointF[] { p1, p2, p3 }); } } } }
protected override void OnPaintBackground(Graphics g, Rectangle clipRect) { base.OnPaintBackground(g, clipRect); if (XTheme.DrawBackground) { RenderBackground(g); } if (XTheme.DrawExtraMiddleLine) { using (NewSmoothModeGraphics ng = new NewSmoothModeGraphics(g, SmoothingMode.HighSpeed)) { using (SolidBrush sb = new SolidBrush(XTheme.ExtraMiddleLineColor)) { g.FillRectangle(sb, ExtraMiddleLineRect); } } } }
public static void RenderRadioMark(Graphics g, Rectangle rect, SmartRadioButtonThemeBase xtheme, bool enable, bool selected, SmartButtonState state) { if (rect.Width < 1 || rect.Height < 1) return; // get back-color Color backColor; if (!enable) { backColor = xtheme.RadioMarkBackColorDisabled; } else { switch (state) { case SmartButtonState.Hover: backColor = xtheme.RadioMarkBackColorHighLight; break; case SmartButtonState.Pressed: backColor = xtheme.RadioMarkBackColorPressed; break; default: backColor = xtheme.RadioMarkBackColorNormal; break; } } // get outter-circle-color Color circleColor = enable ? xtheme.OutterCircleColor : xtheme.OutterCircleColorDisabled; // get inner-spot-color Color innerColor = enable ? xtheme.InnerSpotColor : xtheme.InnerSpotColorDisabled; using (NewSmoothModeGraphics ng = new NewSmoothModeGraphics(g, SmoothingMode.AntiAlias)) { // draw background Rectangle r1 = rect; r1.Width--; r1.Height--; if (r1.Width > 0 && r1.Height > 0) { using (SolidBrush sb = new SolidBrush(backColor)) { g.FillEllipse(sb, r1); } } // draw outter circle using (Pen p = new Pen(circleColor)) { g.DrawEllipse(p, rect); } // draw high-light-outter-circle if (xtheme.HighLightOutterCircle && state == SmartButtonState.Hover) { using (Pen p = new Pen(Color.FromArgb(xtheme.OutterCircleHighLightAlpha, circleColor))) { p.Width = 3; p.Alignment = PenAlignment.Center; g.DrawEllipse(p, rect); } } // draw inner spot if (selected) { rect.Inflate(-xtheme.InnerSpotInflate, -xtheme.InnerSpotInflate); using (SolidBrush sb = new SolidBrush(innerColor)) { g.FillEllipse(sb, rect); } // draw glass on inner spot if (xtheme.ShowGlassOnInnerSpot) { GlassPainter.RenderEllipseGlass(g, rect, GlassPosition.Top, 0.2f, Color.White, 160, 20); } } } }
private void DrawBarBottomRegion(Graphics g) { // bottom region using (SolidBrush sb = new SolidBrush(BarBottomRegionBackColor)) { using (NewSmoothModeGraphics newGP = new NewSmoothModeGraphics(g, SmoothingMode.HighSpeed)) { g.FillRectangle(sb, BarBottomRegionBounds); } } }