public void Update(GeneralPath path, double pathThickness, Color color) { if (this.path == null || !this.path.Equals(path)) { this.graphicsPath = path.CreatePath(new Matrix()); } this.path = path; this.pathThickness = (float)pathThickness; if (!this.color.Equals(color)) { brush = new LinearGradientBrush(new Point(0, 0), new Point(200, 200), Color.FromArgb((byte)Math.Max(0, color.A - 50), (byte)Math.Min(255, color.R * 1.7), (byte)Math.Min(255, color.G * 1.7), (byte)Math.Min(255, color.B * 1.7)), Color.FromArgb((byte)Math.Max(0, color.A - 50), (byte)Math.Min(255, color.R * 1.4), (byte)Math.Min(255, color.G * 1.4), (byte)Math.Min(255, color.B * 1.4))) { WrapMode = WrapMode.TileFlipXY }; } this.color = color; }
public override Visual CreateVisual(IRenderContext context) { VisualGroup container = new VisualGroup(); var bounds = Bounds; var width = bounds.Width; var height = bounds.Height; var cornerSize = Math.Min(width, height) * 0.4; var path = new GeneralPath(); path.MoveTo(0, 0); path.LineTo(width - cornerSize, 0); path.LineTo(width, cornerSize); path.LineTo(width, height); path.LineTo(0, height); path.Close(); container.Add(path.CreatePath(Brush, Pen, new Matrix2D(), FillMode.Always)); path = new GeneralPath(); path.MoveTo(width - cornerSize, 0); path.LineTo(width - cornerSize, cornerSize); path.LineTo(width, cornerSize); container.Add(path.CreatePath(null, Pen, new Matrix2D(), FillMode.Never)); container.SetRenderDataCache(new PathIconState(width, height, Pen, Brush)); container.SetCanvasArrangeRect(bounds.ToRectD()); return(container); }
public override Visual CreateVisual(IRenderContext context) { VisualGroup container = new VisualGroup(); var bounds = Bounds; var width = bounds.Width; var height = bounds.Height; var path = new GeneralPath(); path.MoveTo(0, TopLeftRadius); path.QuadTo(0, 0, TopLeftRadius, 0); path.LineTo(width - TopRightRadius, 0); path.QuadTo(width, 0, width, TopRightRadius); path.LineTo(width, height - BottomRightRadius); path.QuadTo(width, height, width - BottomRightRadius, height); path.LineTo(BottomLeftRadius, height); path.QuadTo(0, height, 0, height - BottomRightRadius); path.Close(); var pathVisual = path.CreatePath(Brush, Pen, new Matrix2D(), FillMode.Always); container.Add(pathVisual); container.SetRenderDataCache(new PathIconState(width, height, Pen, Brush)); container.SetCanvasArrangeRect(bounds.ToRectD()); return(container); }
protected override VisualGroup CreateVisual(IRenderContext context, IStripe stripe) { IRectangle layout = stripe.Layout.ToRectD(); GeneralPath outline = CreatePath(stripe, layout); var visual = outline.CreatePath(StripeDescriptor.BackgroundBrush, new Pen(StripeDescriptor.BorderBrush, StripeDescriptor.BorderThickness.Left), null, FillMode.Always); var cc = new VisualGroup(); cc.Add(visual); cc.SetCanvasArrangeRect(layout.ToRectD()); return(cc); }