public static void FillRectangle(IGraphics g, RectangleF rect, IFillElement fillElement) { int val2 = 4; int numberOfColors = fillElement.NumberOfColors; Color[] colorStops = new Color[Math.Min(Math.Max(numberOfColors, 1), val2)]; float[] colorOffsets = new float[Math.Min(Math.Max(numberOfColors, 1), val2)]; FillPrimitiveImpl.FillColorStopsAndOffsets(colorStops, colorOffsets, numberOfColors, fillElement); switch (fillElement.GradientStyle) { case GradientStyles.Solid: g.FillRectangle(rect, fillElement.BackColor); break; case GradientStyles.Linear: case GradientStyles.Radial: if (numberOfColors < 2 || numberOfColors == 2 && fillElement.BackColor == fillElement.BackColor2) { g.FillRectangle(rect, fillElement.BackColor); break; } g.FillGradientRectangle(rect, colorStops, colorOffsets, fillElement.GradientStyle, fillElement.GradientAngle, fillElement.GradientPercentage, fillElement.GradientPercentage2); break; case GradientStyles.Glass: g.FillGlassRectangle(Rectangle.Round(rect), fillElement.BackColor, fillElement.BackColor2, fillElement.BackColor3, fillElement.BackColor4, fillElement.GradientPercentage, fillElement.GradientPercentage2); break; case GradientStyles.OfficeGlass: g.FillOfficeGlassRectangle(Rectangle.Round(rect), fillElement.BackColor, fillElement.BackColor2, fillElement.BackColor3, fillElement.BackColor4, fillElement.GradientPercentage, fillElement.GradientPercentage2, true); break; case GradientStyles.OfficeGlassRect: g.FillOfficeGlassRectangle(Rectangle.Round(rect), fillElement.BackColor, fillElement.BackColor2, fillElement.BackColor3, fillElement.BackColor4, fillElement.GradientPercentage, fillElement.GradientPercentage2, false); break; case GradientStyles.Gel: g.FillGellRectangle(Rectangle.Round(rect), colorStops, fillElement.GradientPercentage, fillElement.GradientPercentage2); break; case GradientStyles.Vista: g.FillVistaRectangle(Rectangle.Round(rect), fillElement.BackColor, fillElement.BackColor2, fillElement.BackColor3, fillElement.BackColor4, fillElement.GradientPercentage, fillElement.GradientPercentage2); break; } }
public void PaintFill(IGraphics graphics, GraphicsPath clippingPath, RectangleF paintRect) { graphics.ChangeSmoothingMode(this.fillElement.SmoothingMode); if (clippingPath != null) { graphics.PushCurrentClippingPath(clippingPath); } if (this.fillElement.GradientStyle == GradientStyles.Radial) { RadGdiGraphics radGdiGraphics = graphics as RadGdiGraphics; if (radGdiGraphics != null) { int val2 = 4; int numberOfColors = this.fillElement.NumberOfColors; Color[] colorStops = new Color[Math.Min(Math.Max(numberOfColors, 1), val2)]; float[] colorOffsets = new float[Math.Min(Math.Max(numberOfColors, 1), val2)]; FillPrimitiveImpl.FillColorStopsAndOffsets(colorStops, colorOffsets, numberOfColors, this.fillElement); radGdiGraphics.FillGradientPath(clippingPath, paintRect, colorStops, colorOffsets, this.fillElement.GradientStyle, this.fillElement.GradientAngle, this.fillElement.GradientPercentage, this.fillElement.GradientPercentage2); } } else if (this.fillElement.GradientStyle == GradientStyles.Linear) { using (PathGradientBrush pathGradientBrush = new PathGradientBrush(clippingPath)) { pathGradientBrush.CenterPoint = new PointF(paintRect.X + paintRect.Width / 2f, paintRect.Y + paintRect.Height / 2f); pathGradientBrush.CenterColor = this.fillElement.BackColor2; pathGradientBrush.SurroundColors = new Color[1] { this.fillElement.BackColor }; pathGradientBrush.SetBlendTriangularShape(this.fillElement.GradientPercentage, this.fillElement.GradientPercentage2); ((Graphics)graphics.UnderlayGraphics).FillPath((Brush)pathGradientBrush, clippingPath); } } else { this.FillRectangle(graphics, paintRect); } if (clippingPath != null) { graphics.PopCurrentClippingPath(); } graphics.RestoreSmoothingMode(); }