public BrushParameter() { _color1 = Color.Black; _color2 = Color.Empty; _mode = LinearGradientMode.Vertical; }
public LinearGradientBrush (RectangleF rect, Color color1, Color color2, LinearGradientMode linearGradientMode) { Status status = GDIPlus.GdipCreateLineBrushFromRect (ref rect, color1.ToArgb (), color2.ToArgb (), linearGradientMode, WrapMode.Tile, out nativeObject); GDIPlus.CheckStatus (status); rectangle = rect; }
public HeaderPanel() : base() { InitializeComponent(); this.Font = new Font(SystemFonts.CaptionFont, SystemFonts.CaptionFont.Style); this.mfnt_CaptionFont = this.Font; this.mstr_CaptionText = this.GetType().Name; this.mint_CaptionHeight = SystemInformation.CaptionHeight; this.mclr_CaptionBeginColor = Color.FromKnownColor(KnownColor.InactiveCaption); this.mclr_CaptionEndColor = Color.FromKnownColor(KnownColor.ActiveCaption); this.menm_CaptionGradientMode = LinearGradientMode.Vertical; this.menm_CaptionPosition = HeaderPanelCaptionPositions.Top; this.menm_BorderStyle = HeaderPanelBorderStyles.Shadow; base.BorderStyle = 0; this.mclr_BorderColor = Color.FromKnownColor(KnownColor.ActiveCaption); this.mclr_StartColor = Color.FromKnownColor(KnownColor.Window); this.mclr_EndColor = Color.FromKnownColor(KnownColor.Window); this.menm_GradientMode = LinearGradientMode.Vertical; this.SetStyle(ControlStyles.ResizeRedraw, true); this.SetStyle(ControlStyles.UserPaint, true); this.SetStyle(ControlStyles.AllPaintingInWmPaint, true); this.SetStyle(ControlStyles.DoubleBuffer, true); }
public GradientStyle(Color light, Color dark, LinearGradientMode mode) { Type = GradientType.LinearGradientMode; FirstColor = dark; SecondColor = light; GradMode = mode; }
private void Init(float x1, float y1, Color color1, float x2, float y2, Color color2, LinearGradientMode linearGradientMode) { _gradientRectangle = new RectangleF(x1, y1, x2-x1, y2-y1); PointF [] points; switch (linearGradientMode) { case LinearGradientMode.Horizontal : Init(x1, y1, color1, x2, y1, color2, false); break; case LinearGradientMode.Vertical : Init(x1, y1, color1, x1, y2, color2, false); break; case LinearGradientMode.BackwardDiagonal : points = GetMedianeEnclosingRect(x1, y1, x2, y2, false); Init(points[0].X, points[0].Y, color2, points[1].X, points[1].Y, color1, false); break; case LinearGradientMode.ForwardDiagonal : points = GetMedianeEnclosingRect(x1, y1, x2, y2, true); Init(points[0].X, points[0].Y, color1, points[1].X, points[1].Y, color2, false); break; default : throw new ArgumentException("LinearGradientMode"); } }
internal static void RenderBackgroundInternal( Graphics g, Rectangle rect, Color baseColor, Color borderColor, Color innerBorderColor, RoundStyle style, int roundWidth, bool drawBorder, bool drawGlass, LinearGradientMode mode) { RenderBackgroundInternal( g, rect, baseColor, borderColor, innerBorderColor, style, 8, 0.45f, drawBorder, drawGlass, mode); }
public Form1() { InitializeComponent(); logPanel = new loginPanel(); logPanel.Parent = this; logPanel.Dock = DockStyle.Fill; this.Controls.Add(logPanel); this.menuStrip1.Visible = false; this.splitContainer1.Visible = false; logPanel.Button.Click += new EventHandler(Button_Click); logPanel.PassBox.KeyPress+=new KeyPressEventHandler(PassBox_KeyPress); this.GradientColorOne = Color.Indigo; this.GradientColorTwo = Color.Navy; this.lgm = LinearGradientMode.ForwardDiagonal; currentPath = Path.GetDirectoryName( Application.ExecutablePath); absolutePath = Path.Combine(currentPath,relativePath); connectionString = string.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data source={0}", absolutePath); connection = new OleDbConnection(connectionString); cmpIgrac1 = new cmpIgrac(); System.Threading.Thread.Sleep(200); cmpIgrac2 = new cmpIgrac(); cmpOneGB.Text = cmpIgrac1.Ime.ToUpper(); cmpTwoGB.Text = cmpIgrac2.Ime.ToUpper(); cmpOneBodovi._Text = string.Format("{0}",0); cmpTwoBodovi._Text = string.Format("{0}",0); }
private void FillWithDoubleGradient(Color beginColor, Color middleColor, Color endColor, Graphics g, Rectangle bounds, int firstGradientWidth, int secondGradientWidth, LinearGradientMode mode, bool flipHorizontal) { if ((bounds.Width != 0) && (bounds.Height != 0)) { Rectangle rect = bounds; Rectangle rectangle2 = bounds; bool flag = true; if (mode == LinearGradientMode.Horizontal) { if (flipHorizontal) { Color color = endColor; endColor = beginColor; beginColor = color; } rectangle2.Width = firstGradientWidth; rect.Width = secondGradientWidth + 1; rect.X = bounds.Right - rect.Width; flag = bounds.Width > (firstGradientWidth + secondGradientWidth); } else { rectangle2.Height = firstGradientWidth; rect.Height = secondGradientWidth + 1; rect.Y = bounds.Bottom - rect.Height; flag = bounds.Height > (firstGradientWidth + secondGradientWidth); } if (flag) { using (Brush brush = new SolidBrush(middleColor)) { g.FillRectangle(brush, bounds); } using (Brush brush2 = new LinearGradientBrush(rectangle2, beginColor, middleColor, mode)) { g.FillRectangle(brush2, rectangle2); } using (LinearGradientBrush brush3 = new LinearGradientBrush(rect, middleColor, endColor, mode)) { if (mode == LinearGradientMode.Horizontal) { rect.X++; rect.Width--; } else { rect.Y++; rect.Height--; } g.FillRectangle(brush3, rect); return; } } using (Brush brush4 = new LinearGradientBrush(bounds, beginColor, endColor, mode)) { g.FillRectangle(brush4, bounds); } } }
public static void drawGrad(Color c1, Color c2, Rectangle rect, Graphics gr2, LinearGradientMode lgw) { using (LinearGradientBrush lgb = new LinearGradientBrush(rect, c1, c2, lgw)) gr2.FillRectangle(lgb, rect); }
public GradientTab(Color first, Color second, LinearGradientMode lnrMode, Color textColor, Color selectedTextColor, FontStyle fontStyle) { _colorStart = first; _colorEnd = second; _gradientStyle = lnrMode; _tabPageTextColor = textColor; _tabPageSelectedTextColor = selectedTextColor; _selectedTabFontStyle = fontStyle; }
public MyGradientStyle(Color primaryColor, Color secondaryColor, LinearGradientMode gradientMode) { this.primaryColor = primaryColor; this.secondaryColor = secondaryColor; this.gradientMode = gradientMode; Rectangle initialRectangle = new Rectangle(0, 0, 1, 1); CreateGradient(initialRectangle); }
public LinearGradientBrush(RectangleF rect, Color color1, Color color2, LinearGradientMode linearGradientMode) { this.rect = rect; this.color1 = color1; this.color2 = color2; this.mode = linearGradientMode; this.angle = 0.0f; this.isAngleScaleable = false; }
public static void SafelyDrawLinearGradient(Rectangle rectangle, Color startColor, Color endColor, LinearGradientMode mode, Graphics graphics) { if (rectangle.Width > 0 && rectangle.Height > 0) { using (LinearGradientBrush brush = new LinearGradientBrush(rectangle, startColor, endColor, mode)) { graphics.FillRectangle(brush, rectangle); } } }
void SetDataSource(LinearGradientMode selected) { this.BeginUpdate(); Items.Clear(); foreach (LinearGradientMode o in Enum.GetValues(typeof(LinearGradientMode))) Items.Add(o); SelectedItem = selected; this.EndUpdate(); }
public LinearGradientBrush(PointF point1, PointF point2, Color color1, Color color2) { this.rect = new RectangleF(point1.X, point1.Y, point2.X - point1.X, point2.Y - point1.Y); this.color1 = color1; this.color2 = color2; this.mode = LinearGradientMode.Horizontal; this.angle = 0.0f; this.isAngleScaleable = false; }
public CaptionGradient(Color firstActive, Color secondActive, Color firstInactive, Color secondInactive, LinearGradientMode lnrMode, Color activeTextColor, Color inactiveTextColor, FontStyle fontStyle) { _activeCaptionColorStart = firstActive; _activeCaptionColorEnd = secondActive; _inactiveCaptionColorStart = firstInactive; _inactiveCaptionColorEnd = secondInactive; _captionGradientStyle = lnrMode; _activeCaptionTextColor = activeTextColor; _inactiveCaptionTextColor = inactiveTextColor; _activeCaptionFontStyle = fontStyle; }
/// <summary> /// Dibuja un rectángulo redondeado con un gradiante /// </summary> public static void FillRoundedRectangle(Graphics grpCanvas, int intLeft, int intTop, int intWidth, int intHeight, int intArcWidth, int intArcAngle, Color clrBackground, Color clrGradient, LinearGradientMode intMode, Pen penBorder) { using (GraphicsPath pthRectangle = GetRoundedPath(intLeft, intTop, intWidth, intHeight, intArcWidth, intArcAngle)) using (LinearGradientBrush brsGradient = new LinearGradientBrush(new Rectangle(0, 0, intWidth, intHeight), clrBackground, clrGradient, intMode)) { // Dibuja el rectángulo con su fondo grpCanvas.FillPath(brsGradient, pthRectangle); // Dibuja el borde grpCanvas.DrawPath(penBorder, pthRectangle); } }
private Bitmap DrawGradient(Color fromColor, Color toColor, LinearGradientMode gradientMode) { Bitmap bmp = new Bitmap(Width, Height); Rectangle rect = new Rectangle(0, 0, bmp.Width, bmp.Height); using (Graphics g = Graphics.FromImage(bmp)) using (LinearGradientBrush brush = new LinearGradientBrush(rect, fromColor, toColor, gradientMode)) { g.FillRectangle(brush, rect); } return bmp; }
/// <summary> /// Fills the specified <paramref name="path"/> either with a gradient background or a solid one. /// </summary> /// <param name="g">The <see cref="Graphics"/> object used to draw.</param> /// <param name="path">The <see cref="GraphicsPath"/> to fill.</param> /// <param name="colorStart">The start color.</param> /// <param name="colorEnd">The end color if drawing a gradient background.</param> /// <param name="mode">The <see cref="LinearGradientMode"/> to use.</param> /// <exception cref="ArgumentNullException">If <paramref name="path"/> is null.</exception> public static void FillBackground( Graphics g, GraphicsPath path, Color colorStart, Color colorEnd, LinearGradientMode? mode) { if (path == null) { throw new ArgumentNullException("path", "parameter 'path' cannot be null."); } RectangleF rect = path.GetBounds(); if (!CheckParams(g, path.GetBounds()) || colorStart == Color.Empty) { return; } if (colorEnd == Color.Empty) { if (colorStart != Color.Transparent) { using (SolidBrush brush = new SolidBrush(colorStart)) { g.FillPath(brush, path); } } } else { rect.Height += 2; rect.Y--; using (LinearGradientBrush brush = new LinearGradientBrush( rect, colorStart, colorEnd, mode.GetValueOrDefault(LinearGradientMode.Vertical))) { g.FillPath(brush, path); } } }
// Methods public Shape() { base.Paint += new PaintEventHandler(this.Shape_Paint); this._Corners = new CornersProperty(); this._FocalPoints = new cFocalPoints(0.5, 0.5, 0.0, 0.0); this._BorderStyle = DashStyle.Solid; this._RadiusInner = 0f; this._BorderShow = true; this._BorderWidth = 2f; this._ColorFillSolid = SystemColors.Control; Color[] S0 = new Color[] { Color.White, Color.White }; this._ColorFillBlend = new cBlendItems(S0, new float[] { 0f, 1f }); this._FillType = eFillType.Solid; this._FillTypeLinear = LinearGradientMode.Horizontal; this._BorderColor = Color.Black; this._RegionClip = false; this.InitializeComponent(); this.SetStyle(ControlStyles.SupportsTransparentBackColor, true); this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true); this.SetStyle(ControlStyles.AllPaintingInWmPaint, true); }
/// <summary> /// Represents a Rectangle on the keyboard which can be drawn to a Bitmap. /// By default, a rectangle is the entire keyboard's size. /// </summary> /// <param name="keyboard">The keyboard this rectangle will be used for</param> /// <param name="x"></param> /// <param name="y"></param> /// <param name="colors">An array of colors the ColorBlend will use</param> /// <param name="gradientMode"></param> public KeyboardRectangle(KeyboardProvider keyboard, int x, int y, List<Color> colors, LinearGradientMode gradientMode) { _keyboard = keyboard; _rotationProgress = 0; _blinkWorker.DoWork += BlinkWorker_DoWork; Scale = 4; X = x; Y = y; Width = keyboard.Width*Scale; Height = keyboard.Height*Scale; Visible = true; Opacity = 255; ContainedBrush = true; GradientMode = gradientMode; Rotate = false; LoopSpeed = 1; Colors = colors; }
public SolidElement(SolidElement prototype): base(prototype) { mBlend = prototype.Blend; mCustomBrush = prototype.CustomBrush; mDrawBackground = prototype.DrawBackground; mDrawBorder = prototype.DrawBorder; mDrawGradient = prototype.DrawGradient; mBackColor = prototype.BackColor; mGradientColor = prototype.GradientColor; mGradientMode = prototype.GradientMode; mRotation = prototype.Rotation; mTransformPath = prototype.TransformPath; mTransformRectangle = prototype.TransformRectangle; mTransformInternalRectangle = prototype.TransformInternalRectangle; if (prototype.Label != null) Label = (TextLabel) prototype.Label.Clone(); if (prototype.Image != null) Image = (Image) prototype.Image.Clone(); mStencilItem = prototype.StencilItem; //if (prototype.StencilItem != null) mStencilItem = (StencilItem) prototype.StencilItem.Clone(); mInternalRectangle = prototype.InternalRectangle; }
public LinearGradientBrush(RectangleF rect, Color color1, Color color2, LinearGradientMode linearGradientMode) : this(rect, color1, color2, GetAngle(linearGradientMode), false) { }
internal void RenderBackgroundInternal( Graphics g, Rectangle rect, Color baseColor, Color borderColor, Color innerBorderColor, float basePosition, bool drawBorder, LinearGradientMode mode) { if (drawBorder) { rect.Width--; rect.Height--; } if (rect.Width <= 0 || rect.Height <= 0) { return; } using (LinearGradientBrush brush = new LinearGradientBrush( rect, Color.Transparent, Color.Transparent, mode)) { Color[] colors = new Color[4]; colors[0] = GetColor(baseColor, 0, 35, 24, 9); colors[1] = GetColor(baseColor, 0, 13, 8, 3); colors[2] = baseColor; colors[3] = GetColor(baseColor, 0, 68, 69, 54); ColorBlend blend = new ColorBlend(); blend.Positions = new float[] { 0.0f, basePosition, basePosition + 0.05f, 1.0f }; blend.Colors = colors; brush.InterpolationColors = blend; g.FillRectangle(brush, rect); } if (baseColor.A > 80) { Rectangle rectTop = rect; if (mode == LinearGradientMode.Vertical) { rectTop.Height = (int)(rectTop.Height * basePosition); } else { rectTop.Width = (int)(rect.Width * basePosition); } using (SolidBrush brushAlpha = new SolidBrush(Color.FromArgb(80, 255, 255, 255))) { g.FillRectangle(brushAlpha, rectTop); } } if (drawBorder) { using (Pen pen = new Pen(borderColor)) { g.DrawRectangle(pen, rect); } rect.Inflate(-1, -1); using (Pen pen = new Pen(innerBorderColor)) { g.DrawRectangle(pen, rect); } } }
/// <summary> /// Creates a new instance of the <see cref="T:Common.Drawing.Drawing2D.LinearGradientBrush" /> based on a /// rectangle, starting and ending colors, and an orientation mode. /// </summary> /// <param name="rect"> /// A <see cref="T:Common.Drawing.RectangleF" /> structure that specifies the bounds of the linear /// gradient. /// </param> /// <param name="color1"> /// A <see cref="T:Common.Drawing.Color" /> structure that represents the starting color for the /// gradient. /// </param> /// <param name="color2"> /// A <see cref="T:Common.Drawing.Color" /> structure that represents the ending color for the /// gradient. /// </param> /// <param name="linearGradientMode"> /// A <see cref="T:Common.Drawing.Drawing2D.LinearGradientMode" /> enumeration element /// that specifies the orientation of the gradient. The orientation determines the starting and ending points of the /// gradient. For example, LinearGradientMode.ForwardDiagonal specifies that the starting point is the upper-left /// corner of the rectangle and the ending point is the lower-right corner of the rectangle. /// </param> public LinearGradientBrush(RectangleF rect, Color color1, Color color2, LinearGradientMode linearGradientMode) { WrappedLinearGradientBrush = new System.Drawing.Drawing2D.LinearGradientBrush(rect, color1, color2, (System.Drawing.Drawing2D.LinearGradientMode)linearGradientMode); }
internal void RenderTabBackgroundInternal(Graphics g, Rectangle rect, Color baseColor, Color borderColor, float basePosition, LinearGradientMode mode) { using (GraphicsPath graphicsPath = CreateTabPath(rect)) { using (LinearGradientBrush linearGradientBrush = new LinearGradientBrush(rect, Color.Transparent, Color.Transparent, mode)) { Color[] colors = new Color[4] { GetColor(baseColor, 0, 35, 24, 9), GetColor(baseColor, 0, 13, 8, 3), baseColor, GetColor(baseColor, 0, 68, 69, 54) }; ColorBlend colorBlend = new ColorBlend(); colorBlend.Positions = new float[4] { 0f, basePosition, basePosition + 0.05f, 1f }; colorBlend.Colors = colors; linearGradientBrush.InterpolationColors = colorBlend; g.FillPath(linearGradientBrush, graphicsPath); } if (baseColor.A > 80) { Rectangle rect2 = rect; if (mode == LinearGradientMode.Vertical) { rect2.Height = (int)((float)rect2.Height * basePosition); } else { rect2.Width = (int)((float)rect.Width * basePosition); } using (SolidBrush brush = new SolidBrush(Color.FromArgb(80, 255, 255, 255))) { g.FillRectangle(brush, rect2); } } rect.Inflate(-1, -1); using (GraphicsPath graphicsPath2 = CreateTabPath(rect)) { using (Pen pen = new Pen(Color.FromArgb(255, 255, 255))) { if (base.Multiline) { g.DrawPath(pen, graphicsPath2); } else { g.DrawLines(pen, graphicsPath2.PathPoints); } } } using (Pen pen = new Pen(borderColor)) { if (base.Multiline) { g.DrawPath(pen, graphicsPath); } g.DrawLines(pen, graphicsPath.PathPoints); } } }
/// <summary> /// Renders the background of the caption bar /// </summary> /// <param name="graphics">The Graphics to draw on.</param> /// <param name="bounds">Rectangle structure that specifies the location of the caption bar.</param> /// <param name="beginColor">The starting color of the gradient used on the caption bar</param> /// <param name="middleColor">The middle color of the gradient used on the caption bar</param> /// <param name="endColor">The end color of the gradient used on the caption bar</param> /// <param name="linearGradientMode">Specifies the type of fill a Pen object uses to fill lines.</param> /// <param name="flipHorizontal"></param> protected static void RenderDoubleBackgroundGradient(Graphics graphics, Rectangle bounds, Color beginColor, Color middleColor, Color endColor, LinearGradientMode linearGradientMode, bool flipHorizontal) { RenderDoubleBackgroundGradient( graphics, bounds, beginColor, middleColor, endColor, 12, 12, linearGradientMode, flipHorizontal); }
// Create a linear gradient brush. Returns null if the // toolkit does not support linear gradient brushes. public virtual IToolkitBrush CreateLinearGradientBrush (RectangleF rect, Color color1, Color color2, LinearGradientMode mode) { return(null); }
private void DrawTab(Graphics g, TabVS2005 tab) { Rectangle rectTabOrigin = GetTabRectangle(tab); if (rectTabOrigin.IsEmpty) { return; } DockState dockState = tab.Content.DockHandler.DockState; IDockContent content = tab.Content; GraphicsPath path = GetTabOutline(tab, false, true); Color startColor = DockPanel.Skin.AutoHideStripSkin.TabGradient.StartColor; Color endColor = DockPanel.Skin.AutoHideStripSkin.TabGradient.EndColor; LinearGradientMode gradientMode = DockPanel.Skin.AutoHideStripSkin.TabGradient.LinearGradientMode; g.FillPath(new LinearGradientBrush(rectTabOrigin, startColor, endColor, gradientMode), path); g.DrawPath(PenTabBorder, path); // Set no rotate for drawing icon and text using (Matrix matrixRotate = g.Transform) { g.Transform = MatrixIdentity; // Draw the icon Rectangle rectImage = rectTabOrigin; rectImage.X += ImageGapLeft; rectImage.Y += ImageGapTop; int imageHeight = rectTabOrigin.Height - ImageGapTop - ImageGapBottom; int imageWidth = ImageWidth; if (imageHeight > ImageHeight) { imageWidth = ImageWidth * (imageHeight / ImageHeight); } rectImage.Height = imageHeight; rectImage.Width = imageWidth; rectImage = GetTransformedRectangle(dockState, rectImage); if (dockState == DockState.DockLeftAutoHide || dockState == DockState.DockRightAutoHide) { // The DockState is DockLeftAutoHide or DockRightAutoHide, so rotate the image 90 degrees to the right. Rectangle rectTransform = RtlTransform(rectImage, dockState); Point[] rotationPoints = { new Point(rectTransform.X + rectTransform.Width, rectTransform.Y), new Point(rectTransform.X + rectTransform.Width, rectTransform.Y + rectTransform.Height), new Point(rectTransform.X, rectTransform.Y) }; using (Icon rotatedIcon = new Icon(((Form)content).Icon, 16, 16)) { g.DrawImage(rotatedIcon.ToBitmap(), rotationPoints); } } else { // Draw the icon normally without any rotation. g.DrawIcon(((Form)content).Icon, RtlTransform(rectImage, dockState)); } // Draw the text Rectangle rectText = rectTabOrigin; rectText.X += ImageGapLeft + imageWidth + ImageGapRight + TextGapLeft; rectText.Width -= ImageGapLeft + imageWidth + ImageGapRight + TextGapLeft; rectText = RtlTransform(GetTransformedRectangle(dockState, rectText), dockState); Color textColor = DockPanel.Skin.AutoHideStripSkin.TabGradient.TextColor; if (dockState == DockState.DockLeftAutoHide || dockState == DockState.DockRightAutoHide) { g.DrawString(content.DockHandler.TabText, TextFont, new SolidBrush(textColor), rectText, StringFormatTabVertical); } else { g.DrawString(content.DockHandler.TabText, TextFont, new SolidBrush(textColor), rectText, StringFormatTabHorizontal); } // Set rotate back g.Transform = matrixRotate; } }
public static string ExtractLinearGradient(LinearGradientMode gradientMode, Color backColor, Color gradientColor) { StringBuilder gradient = new StringBuilder(); gradient.Append("<linearGradient id=\"\" gradientUnits=\"objectBoundingBox\" "); //Rotate if not horizontal gradient switch (gradientMode) { case System.Drawing.Drawing2D.LinearGradientMode.BackwardDiagonal: gradient.Append("gradientTransform=\"rotate(225)\""); break; case System.Drawing.Drawing2D.LinearGradientMode.ForwardDiagonal: gradient.Append("gradientTransform=\"rotate(45)\""); break; case System.Drawing.Drawing2D.LinearGradientMode.Vertical: gradient.Append("gradientTransform=\"rotate(90)\""); break; } gradient.Append(">"); //Add the 2 stops - change for blends here gradient.Append("\r"); gradient.Append("\t"); gradient.Append("<stop offset=\"0%\" style=\"stop-color:"); gradient.Append(GetCompatibleColor(backColor)); gradient.Append("\"/>"); gradient.Append("\r"); gradient.Append("\t"); gradient.Append("<stop offset=\"100%\" style=\"stop-color:"); gradient.Append(GetCompatibleColor(gradientColor)); gradient.Append("\"/>"); gradient.Append("</linearGradient>"); return gradient.ToString(); }
public static Image DrawBorder(Image img, Color fromBorderColor, Color toBorderColor, LinearGradientMode gradientType, int borderSize, BorderType borderType) { int width = img.Width; int height = img.Height; if (borderType == BorderType.Outside) { width += borderSize * 2; height += borderSize * 2; } using (LinearGradientBrush brush = new LinearGradientBrush(new Rectangle(0, 0, width, height), fromBorderColor, toBorderColor, gradientType)) using (Pen borderPen = new Pen(brush, borderSize) { Alignment = PenAlignment.Inset }) { return(DrawBorder(img, borderPen, borderType)); } }
private LinearGradientBrush GetBrush(SvgLinearGradientElement res, RectangleF bounds) { //LinearGradientBrush brush = new LinearGradientBrush(new RectangleF(fEffectiveLeft - 1, // fEffectiveTop - 1, fEffectiveWidth + 2, fEffectiveHeight + 2), // Color.White, Color.White, mode); XmlNodeList stops = res.Stops; ColorBlend cb = new ColorBlend(); //List<Color> adjcolors = new List<Color>(); //List<float> adjpositions = new List<float>(); //GetColorsAndPositions(stops, adjpositions, adjcolors); var gradientStops = this.GetGradientStops(stops); if (gradientStops == null || gradientStops.Count == 0) { return(null); } float fLeft = (float)res.X1.AnimVal.Value; float fRight = (float)res.X2.AnimVal.Value; float fTop = (float)res.Y1.AnimVal.Value; float fBottom = (float)res.Y2.AnimVal.Value; bool bForceUserSpaceOnUse = (fLeft > 1 || fRight > 1 || fTop > 1 || fBottom > 1); float fEffectiveLeft = fLeft; float fEffectiveRight = fRight; float fEffectiveTop = fTop; float fEffectiveBottom = fBottom; if (res.GradientUnits.AnimVal.Equals((ushort)SvgUnitType.ObjectBoundingBox) && !bForceUserSpaceOnUse) { if (res.SpreadMethod.AnimVal.Equals((ushort)SvgSpreadMethod.Pad)) { fEffectiveRight = bounds.Right; fEffectiveLeft = bounds.Left; } else { fEffectiveLeft = bounds.Left + fLeft * (bounds.Width); fEffectiveRight = bounds.Left + fRight * (bounds.Width); } fEffectiveTop = bounds.Top + fTop * (bounds.Height); fEffectiveBottom = bounds.Top + fBottom * (bounds.Height); } LinearGradientMode mode = LinearGradientMode.Horizontal; if (fTop == fBottom) { mode = LinearGradientMode.Horizontal; } else { if (fLeft == fRight) { mode = LinearGradientMode.Vertical; } else { if (fLeft < fRight) { mode = LinearGradientMode.ForwardDiagonal; } else { mode = LinearGradientMode.BackwardDiagonal; } } } float fEffectiveWidth = fEffectiveRight - fEffectiveLeft; if (fEffectiveWidth <= 0) { fEffectiveWidth = bounds.Width; } float fEffectiveHeight = fEffectiveBottom - fEffectiveTop; if (fEffectiveHeight <= 0) { fEffectiveHeight = bounds.Height; } int stopCount = gradientStops.Count; var colors = new Color[stopCount]; var positions = new float[stopCount]; for (int i = 0; i < stopCount; i++) { var gradientStop = gradientStops[i]; colors[i] = gradientStop.Color; positions[i] = gradientStop.Offset; } //LinearGradientBrush brush = new LinearGradientBrush(new PointF(fLeft, fTop), // new PointF(fRight, fBottom), gradientStops[0].Color, gradientStops[stopCount - 1].Color); LinearGradientBrush brush = new LinearGradientBrush(new RectangleF(fEffectiveLeft - 1, fEffectiveTop - 1, fEffectiveWidth + 2, fEffectiveHeight + 2), Color.Transparent, Color.Transparent, mode); if (res.GradientUnits.AnimVal.Equals((ushort)SvgUnitType.ObjectBoundingBox) && !bForceUserSpaceOnUse) { if (res.SpreadMethod.AnimVal.Equals((ushort)SvgSpreadMethod.Pad)) { for (int i = 0; i < stopCount; i++) { if (fLeft == fRight) { positions[i] = fTop + positions[i] * (fBottom - fTop); } else { positions[i] = fLeft + positions[i] * (fRight - fLeft); } } // this code corrects the values again... fix int nSize = colors.Length; if (positions[0] > 0.0) { ++nSize; } if (positions[colors.Length - 1] < 1) { ++nSize; } Color[] readjcolors = new Color[nSize]; float[] readjpositions = new float[nSize]; if (positions[0] > 0.0) { positions.CopyTo(readjpositions, 1); colors.CopyTo(readjcolors, 1); readjcolors[0] = readjcolors[1]; readjpositions[0] = 0; } else { positions.CopyTo(readjpositions, 0); colors.CopyTo(readjcolors, 0); } if (positions[colors.Length - 1] < 1) { readjcolors[nSize - 1] = readjcolors[nSize - 2]; readjpositions[nSize - 1] = 1; } cb.Colors = readjcolors; cb.Positions = readjpositions; } else { cb.Colors = colors; cb.Positions = positions; } } else { cb.Colors = colors; cb.Positions = positions; } brush.InterpolationColors = cb; if (res.SpreadMethod.AnimVal.Equals((ushort)SvgSpreadMethod.Reflect)) { brush.WrapMode = WrapMode.TileFlipXY; } else if (res.SpreadMethod.AnimVal.Equals((ushort)SvgSpreadMethod.Repeat)) { brush.WrapMode = WrapMode.Tile; } else if (res.SpreadMethod.AnimVal.Equals((ushort)SvgSpreadMethod.Pad)) { brush.WrapMode = WrapMode.Tile; } Matrix OriginalMatrix = brush.Transform.Clone(); OriginalMatrix.Multiply(GetTransformMatrix(res)); brush.Transform = OriginalMatrix; if (string.Equals(res.GetPropertyValue("color-interpolation"), CssConstants.ValLinearRgb, StringComparison.OrdinalIgnoreCase)) { brush.GammaCorrection = true; } else { brush.GammaCorrection = false; } return(brush); }
public static Image DrawBorder(Image img, Color fromBorderColor, Color toBorderColor, LinearGradientMode gradientType, int borderSize, BorderType borderType) { int width = img.Width; int height = img.Height; if (borderType == BorderType.Outside) { width += borderSize * 2; height += borderSize * 2; } using (LinearGradientBrush brush = new LinearGradientBrush(new Rectangle(0, 0, width, height), fromBorderColor, toBorderColor, gradientType)) using (Pen borderPen = new Pen(brush, borderSize) { Alignment = PenAlignment.Inset }) { return DrawBorder(img, borderPen, borderType); } }
public LinearGradientBrush(Rectangle rect, Color color1, Color color2, LinearGradientMode linearGradientMode) : this((RectangleF)rect, color1, color2, linearGradientMode) { }
public LinearGradientBrush(Rectangle rect, Color color1, Color color2, LinearGradientMode linearGradientMode) : this(new RectangleF(rect.X, rect.Y, rect.Width, rect.Height), color1, color2, linearGradientMode) { }
internal void RenderBackgroundInternal( Graphics g, Rectangle rect, Color baseColor, Color borderColor, Color innerBorderColor, RoundStyle style, int roundWidth, //圆角半径 float basePosition, bool drawBorder, bool drawGlass, LinearGradientMode mode) { if (drawBorder)//是否画边框 { rect.Width--; rect.Height--; } using (LinearGradientBrush brush = new LinearGradientBrush(rect, Color.Transparent, Color.Transparent, mode)) { Color[] colors = new Color[4]; colors[0] = GetColor(baseColor, 0, 35, 24, 9); colors[1] = GetColor(baseColor, 0, 0, 0, 0); colors[2] = baseColor; colors[3] = GetColor(baseColor, 0, 0, 0, 0); ColorBlend blend = new ColorBlend(); blend.Positions = new float[] { 0.0f, basePosition, basePosition, 1.0f }; blend.Colors = colors; brush.InterpolationColors = blend; if (style != RoundStyle.None) { using (GraphicsPath path = GraphicsPathHelper.CreatePath(rect, roundWidth, style, false)) { g.FillPath(brush, path); } if (baseColor.A > 80) { Rectangle rectTop = rect; if (mode == LinearGradientMode.Vertical) { // rectTop.Height = (int)(rectTop.Height * basePosition); } else { // rectTop.Width = (int)(rect.Width * basePosition); } using (GraphicsPath pathTop = GraphicsPathHelper.CreatePath( rectTop, roundWidth, RoundStyle.Top, false)) { using (SolidBrush brushAlpha = new SolidBrush(Color.FromArgb(80, 255, 255, 255))) { g.FillPath(brushAlpha, pathTop); } } } } } }
/// <summary> /// 画panel背景 /// </summary> /// <param name="graphics">画布</param> /// <param name="bounds">范围</param> /// <param name="beginColor">渐变开始颜色</param> /// <param name="endColor">渐变结束颜色</param> /// <param name="linearGradientMode">渐变方向</param> protected static void RenderBackgroundGradient(Graphics graphics, Rectangle bounds, Color beginColor, Color endColor, LinearGradientMode linearGradientMode) { if (graphics == null) { throw new Exception(); } if (bounds.Width <= 0 || bounds.Height <= 0) { return; } using (LinearGradientBrush linearGradientBrush = new LinearGradientBrush(bounds, beginColor, endColor, linearGradientMode)) { if (IsZeroWidthOrHeight(bounds)) { return; } linearGradientBrush.TranslateTransform((float)(bounds.Location.X + bounds.Width), (float)(bounds.Y - bounds.Height)); graphics.FillRectangle(linearGradientBrush, new Rectangle(Point.Empty, bounds.Size)); } }
internal void RenderBackgroundInternal(Graphics g, Rectangle rect, Color baseColor, Color borderColor, Color innerBorderColor, CSharpWin.RoundStyle style, int roundWidth, float basePosition, bool drawBorder, bool drawGlass, LinearGradientMode mode) { if (drawBorder) { rect.Width--; rect.Height--; } if ((rect.Width > 0) && (rect.Height > 0)) { using (LinearGradientBrush brush = new LinearGradientBrush(rect, Color.Transparent, Color.Transparent, mode)) { Rectangle rectTop; SolidBrush brushAlpha; RectangleF glassRect; Pen pen; Color[] colors = new Color[] { this.GetColor(baseColor, 0, 0x23, 0x18, 9), this.GetColor(baseColor, 0, 13, 8, 3), baseColor, this.GetColor(baseColor, 0, 0x44, 0x45, 0x36) }; ColorBlend blend = new ColorBlend(); float[] arrays = new float[4]; arrays[1] = basePosition; arrays[2] = basePosition + 0.05f; arrays[3] = 1f; blend.Positions = arrays; blend.Colors = colors; brush.InterpolationColors = blend; if (style != CSharpWin.RoundStyle.None) { GraphicsPath path; using (path = GraphicsPathHelper.CreatePath(rect, roundWidth, style, false)) { g.FillPath(brush, path); } if (baseColor.A > 80) { rectTop = rect; if (mode == LinearGradientMode.Vertical) { rectTop.Height = (int)(rectTop.Height * basePosition); } else { rectTop.Width = (int)(rect.Width * basePosition); } using (GraphicsPath pathTop = GraphicsPathHelper.CreatePath(rectTop, roundWidth, CSharpWin.RoundStyle.Top, false)) { using (brushAlpha = new SolidBrush(Color.FromArgb(80, 0xff, 0xff, 0xff))) { g.FillPath(brushAlpha, pathTop); } } } if (drawGlass) { glassRect = rect; if (mode == LinearGradientMode.Vertical) { glassRect.Y = rect.Y + (rect.Height * basePosition); glassRect.Height = (rect.Height - (rect.Height * basePosition)) * 2f; } else { glassRect.X = rect.X + (rect.Width * basePosition); glassRect.Width = (rect.Width - (rect.Width * basePosition)) * 2f; } this.DrawGlass(g, glassRect, 170, 0); } if (drawBorder) { using (path = GraphicsPathHelper.CreatePath(rect, roundWidth, style, false)) { using (pen = new Pen(borderColor)) { g.DrawPath(pen, path); } } rect.Inflate(-1, -1); using (path = GraphicsPathHelper.CreatePath(rect, roundWidth, style, false)) { using (pen = new Pen(innerBorderColor)) { g.DrawPath(pen, path); } } } } else { g.FillRectangle(brush, rect); if (baseColor.A > 80) { rectTop = rect; if (mode == LinearGradientMode.Vertical) { rectTop.Height = (int)(rectTop.Height * basePosition); } else { rectTop.Width = (int)(rect.Width * basePosition); } using (brushAlpha = new SolidBrush(Color.FromArgb(80, 0xff, 0xff, 0xff))) { g.FillRectangle(brushAlpha, rectTop); } } if (drawGlass) { glassRect = rect; if (mode == LinearGradientMode.Vertical) { glassRect.Y = rect.Y + (rect.Height * basePosition); glassRect.Height = (rect.Height - (rect.Height * basePosition)) * 2f; } else { glassRect.X = rect.X + (rect.Width * basePosition); glassRect.Width = (rect.Width - (rect.Width * basePosition)) * 2f; } this.DrawGlass(g, glassRect, 200, 0); } if (drawBorder) { using (pen = new Pen(borderColor)) { g.DrawRectangle(pen, rect); } rect.Inflate(-1, -1); using (pen = new Pen(innerBorderColor)) { g.DrawRectangle(pen, rect); } } } } } }
/// <summary> /// 颜色渐变效果 /// </summary> /// <param name="rec">坐标和大小</param> /// <param name="_JBColorOne">起始渐变颜色</param> /// <param name="_JBColorTwo">中间渐变颜色</param> /// <param name="_JBColorThree">结束渐变颜色</param> /// <param name="lgm">渐变方向</param> /// <returns></returns> private LinearGradientBrush ColorGradient(Rectangle rec, Color _JBColorOne, Color _JBColorTwo, Color _JBColorThree, LinearGradientMode lgm) { LinearGradientBrush lb = new LinearGradientBrush(rec, _JBColorOne, _JBColorTwo, lgm); Color[] colors = new Color[3]; colors[0] = _JBColorOne; colors[1] = _JBColorTwo; colors[2] = _JBColorThree; ColorBlend blend = new ColorBlend(); blend.Positions = new float[] { 0.0f, 0.5f, 1.0f }; blend.Colors = colors; lb.InterpolationColors = blend; return(lb); }
/// <summary> /// Renders the panels background /// </summary> /// <param name="graphics">The Graphics to draw on.</param> /// <param name="bounds">Rectangle structure that specifies the backgrounds location.</param> /// <param name="beginColor">The starting color of the gradient used on the panels background</param> /// <param name="endColor">The end color of the gradient used on the panels background</param> /// <param name="linearGradientMode">Specifies the type of fill a Pen object uses to fill lines.</param> protected static void RenderBackgroundGradient(Graphics graphics, Rectangle bounds, Color beginColor, Color endColor, LinearGradientMode linearGradientMode) { if (graphics == null) { throw new ArgumentException( string.Format( System.Globalization.CultureInfo.CurrentUICulture, Resources.IDS_ArgumentException, typeof(Graphics).Name)); } if (IsZeroWidthOrHeight(bounds)) { return; } using (LinearGradientBrush linearGradientBrush = new LinearGradientBrush(bounds, beginColor, endColor, linearGradientMode)) { graphics.FillRectangle(linearGradientBrush, bounds); } }
/// <summary> /// 지정된 상태, 범위를 사용하여 버튼 컨트롤을 그립니다. /// </summary> /// <param name="g">버튼를 그릴 때 사용되는 System.Drawing.Graphics입니다.</param> /// <param name="bounds">버튼의 범위를 지정하는 System.Drawing.Rectangle입니다.</param> /// <param name="backColor">버튼의 배경색을 지정하는 System.Drawing.Color입니다.</param> /// <param name="focused">버튼에 포커스 사각형을 그리려면 true이고, 그렇지 않으면 false입니다.</param> /// <param name="pressed">버튼이 눌린 상태라면 true이고, 그렇지 않으면 false입니다.</param> /// <param name="hot">버튼에 마우스가 올려진 상태라면 true이고, 그렇지 않으면 false입니다.</param> /// <param name="enabled">버튼이 활성화 된 상태라면 true이고, 그렇지 않으면 false입니다.</param> public static void DrawRoundButton(Graphics g, Rectangle bounds, Color backColor, bool focused, bool pressed, bool hot, bool enabled, bool gradient, LinearGradientMode linearGradientMode) { if (bounds.Width == 0 || bounds.Height == 0) { return; } bounds.Width--; bounds.Height--; int radius = UiControlRenderer.RoundButtonRadius; using (GraphicsPath path = CreateRoundPath(bounds, radius)) using (Pen linePen = new Pen(Color.Transparent, 1.0f)) using (SolidBrush brush = new SolidBrush(backColor)) { g.SmoothingMode = SmoothingMode.HighQuality; g.FillPath(brush, path); Color brightGradientColor = pressed ? UiControlRenderer.RoundButtonGradientDarkColor : UiControlRenderer.RoundButtonGradientBrightColor; Color darkGradientColor = pressed ? UiControlRenderer.RoundButtonGradientBrightColor : UiControlRenderer.RoundButtonGradientDarkColor; if (gradient) { using (LinearGradientBrush gradientBrush = new LinearGradientBrush(bounds, brightGradientColor, darkGradientColor, linearGradientMode)) { g.FillPath(gradientBrush, path); } } if (!enabled) { brush.Color = backColor.GetBrightness() < 0.5 ? UiControlRenderer.RoundButtonDisabledBrightOverayColor : UiControlRenderer.RoundButtonDisabledDarkOverayColor; g.FillPath(brush, path); } else { if (pressed) { linePen.Color = UiControlRenderer.RoundButtonPressShadowColor; Rectangle pressBounds = bounds; pressBounds.X++; pressBounds.Y++; using (GraphicsPath pressPath = CreateRoundPath(pressBounds, radius)) { g.DrawPath(linePen, pressPath); } } if (hot) { brush.Color = backColor.GetBrightness() < 0.5 ? UiControlRenderer.RoundButtonHotBrightOverayColor : UiControlRenderer.RoundButtonHotDarkOverayColor; g.FillPath(brush, path); } } linePen.Color = UiControlRenderer.RoundButtonBorderColor; g.DrawPath(linePen, path); if (focused) { linePen.DashStyle = DashStyle.Dash; linePen.Color = UiControlRenderer.RoundButtonFocusedBorderLineColor; g.DrawPath(linePen, path); } g.SmoothingMode = SmoothingMode.None; } }
private static void RenderDoubleBackgroundGradient(Graphics graphics, Rectangle bounds, Color beginColor, Color middleColor, Color endColor, int firstGradientWidth, int secondGradientWidth, LinearGradientMode mode, bool flipHorizontal) { if ((bounds.Width != 0) && (bounds.Height != 0)) { Rectangle rectangle1 = bounds; Rectangle rectangle2 = bounds; bool flag1 = true; if (mode == LinearGradientMode.Horizontal) { if (flipHorizontal) { Color color1 = endColor; endColor = beginColor; beginColor = color1; } rectangle2.Width = firstGradientWidth; rectangle1.Width = secondGradientWidth + 1; rectangle1.X = bounds.Right - rectangle1.Width; flag1 = bounds.Width > (firstGradientWidth + secondGradientWidth); } else { rectangle2.Height = firstGradientWidth; rectangle1.Height = secondGradientWidth + 1; rectangle1.Y = bounds.Bottom - rectangle1.Height; flag1 = bounds.Height > (firstGradientWidth + secondGradientWidth); } if (flag1) { using (Brush brush1 = new SolidBrush(middleColor)) { graphics.FillRectangle(brush1, bounds); } using (Brush brush2 = new LinearGradientBrush(rectangle2, beginColor, middleColor, mode)) { graphics.FillRectangle(brush2, rectangle2); } using (LinearGradientBrush brush3 = new LinearGradientBrush(rectangle1, middleColor, endColor, mode)) { if (mode == LinearGradientMode.Horizontal) { rectangle1.X++; rectangle1.Width--; } else { rectangle1.Y++; rectangle1.Height--; } graphics.FillRectangle(brush3, rectangle1); return; } } using (Brush brush4 = new LinearGradientBrush(bounds, beginColor, endColor, mode)) { graphics.FillRectangle(brush4, bounds); } } }
public static Bitmap FillImageBackground(Image img, Color fromColor, Color toColor, LinearGradientMode gradientType) { Bitmap result = img.CreateEmptyBitmap(); using (Graphics g = Graphics.FromImage(result)) using (LinearGradientBrush brush = new LinearGradientBrush(new Rectangle(0, 0, result.Width, result.Height), fromColor, toColor, gradientType)) using (img) { g.FillRectangle(brush, 0, 0, result.Width, result.Height); g.SetHighQuality(); g.DrawImage(img, 0, 0, result.Width, result.Height); } return(result); }
public LinearGradientBrush(RectangleF rect, Color color1, Color color2, LinearGradientMode linearGradientMode) : this(rect, color1, color2, linearGradientMode.ToAngle(), true) { mode = linearGradientMode; }
public static Bitmap FillBackground(Image img, Color fromColor, Color toColor, LinearGradientMode gradientType) { using (LinearGradientBrush brush = new LinearGradientBrush(new Rectangle(0, 0, img.Width, img.Height), fromColor, toColor, gradientType)) { return(FillBackground(img, brush)); } }
public static Bitmap FillBackground(Image img, Color fromColor, Color toColor, LinearGradientMode gradientType) { using (LinearGradientBrush brush = new LinearGradientBrush(new Rectangle(0, 0, img.Width, img.Height), fromColor, toColor, gradientType)) { return FillBackground(img, brush); } }
internal static void RenderBackgroundInternal( Graphics g, Rectangle rect, Color baseColor, Color borderColor, Color innerBorderColor, RoundStyle style, int roundWidth, float basePosition, bool drawBorder, bool drawGlass, LinearGradientMode mode) { if (drawBorder) { rect.Width--; rect.Height--; } if (rect.Width == 0 || rect.Height == 0) { return; } using (LinearGradientBrush brush = new LinearGradientBrush( rect, Color.Transparent, Color.Transparent, mode)) { Color[] colors = new Color[4]; colors[0] = GetColor(baseColor, 0, 35, 24, 9); colors[1] = GetColor(baseColor, 0, 13, 8, 3); colors[2] = baseColor; colors[3] = GetColor(baseColor, 0, 35, 24, 9); ColorBlend blend = new ColorBlend(); blend.Positions = new float[] { 0.0f, basePosition, basePosition + 0.05f, 1.0f }; blend.Colors = colors; brush.InterpolationColors = blend; if (style != RoundStyle.None) { using (GraphicsPath path = GraphicsPathHelper.CreatePath(rect, roundWidth, style, false)) { g.FillPath(brush, path); } if (drawGlass) { if (baseColor.A > 80) { Rectangle rectTop = rect; if (mode == LinearGradientMode.Vertical) { rectTop.Height = (int)(rectTop.Height * basePosition); } else { rectTop.Width = (int)(rect.Width * basePosition); } using (GraphicsPath pathTop = GraphicsPathHelper.CreatePath( rectTop, roundWidth, RoundStyle.Top, false)) { using (SolidBrush brushAlpha = new SolidBrush(Color.FromArgb(128, 255, 255, 255))) { g.FillPath(brushAlpha, pathTop); } } } RectangleF glassRect = rect; if (mode == LinearGradientMode.Vertical) { glassRect.Y = rect.Y + rect.Height * basePosition; glassRect.Height = (rect.Height - rect.Height * basePosition) * 2; } else { glassRect.X = rect.X + rect.Width * basePosition; glassRect.Width = (rect.Width - rect.Width * basePosition) * 2; } ControlPaintEx.DrawGlass(g, glassRect, 170, 0); } if (drawBorder) { using (GraphicsPath path = GraphicsPathHelper.CreatePath(rect, roundWidth, style, false)) { using (Pen pen = new Pen(borderColor)) { g.DrawPath(pen, path); } } rect.Inflate(-1, -1); using (GraphicsPath path = GraphicsPathHelper.CreatePath(rect, roundWidth, style, false)) { using (Pen pen = new Pen(innerBorderColor)) { g.DrawPath(pen, path); } } } } else { g.FillRectangle(brush, rect); if (drawGlass) { if (baseColor.A > 80) { Rectangle rectTop = rect; if (mode == LinearGradientMode.Vertical) { rectTop.Height = (int)(rectTop.Height * basePosition); } else { rectTop.Width = (int)(rect.Width * basePosition); } using (SolidBrush brushAlpha = new SolidBrush(Color.FromArgb(128, 255, 255, 255))) { g.FillRectangle(brushAlpha, rectTop); } } RectangleF glassRect = rect; if (mode == LinearGradientMode.Vertical) { glassRect.Y = rect.Y + rect.Height * basePosition; glassRect.Height = (rect.Height - rect.Height * basePosition) * 2; } else { glassRect.X = rect.X + rect.Width * basePosition; glassRect.Width = (rect.Width - rect.Width * basePosition) * 2; } ControlPaintEx.DrawGlass(g, glassRect, 200, 0); } if (drawBorder) { using (Pen pen = new Pen(borderColor)) { g.DrawRectangle(pen, rect); } rect.Inflate(-1, -1); using (Pen pen = new Pen(innerBorderColor)) { g.DrawRectangle(pen, rect); } } } } }