void FillIn2(D2DGraphics g, Color boxColor) { RawRectangleF rect = new RawRectangleF(0, 0, Width, Height); RadialGradientBrushProperties props2 = new RadialGradientBrushProperties() { Center = new RawVector2((rect.Left + rect.Right) / 2, (rect.Top + rect.Bottom) / 2), GradientOriginOffset = new RawVector2(0, 0), RadiusX = Width / 2, RadiusY = Height / 2 }; GradientStop[] gradientStops2 = new GradientStop[2]; gradientStops2[0].Color = GDIDataD2DUtils.TransToRawColor4(Color.FromArgb(55, boxColor.R, boxColor.G, boxColor.B)); gradientStops2[0].Position = 0f; //gradientStops2[1].Color = GDIDataD2DUtils.TransToRawColor4(Color.FromArgb(40, 0,0,255)); //gradientStops2[1].Position = 0.5f; gradientStops2[1].Color = GDIDataD2DUtils.TransToRawColor4(Color.FromArgb(55, boxColor.R, boxColor.G, boxColor.B)); gradientStops2[1].Position = 1f; // GradientStopCollection gradientStopCollection2 = new GradientStopCollection(g.RenderTarget, gradientStops2, Gamma.StandardRgb, ExtendMode.Clamp); RadialGradientBrush radialGradientBrush = new RadialGradientBrush(g.RenderTarget, props2, gradientStopCollection2); g.RenderTarget.FillRectangle(rect, radialGradientBrush); gradientStopCollection2.Dispose(); radialGradientBrush.Dispose(); }
public void Dispose() { if (GradientStopCollection != null && !GradientStopCollection.Disposed) { GradientStopCollection.Dispose(); } GC.SuppressFinalize(this); }
private void Selector_D2DPaint(D2DGraphics g) { if (!IsSelected) { return; } g.RenderTarget.AntialiasMode = AntialiasMode.Aliased; RawRectangleF rect = new RawRectangleF(1, 1, selector.Width - 2, selector.Height - 9); RawColor4 rawColor = GDIDataD2DUtils.TransToRawColor4(SelectorColor); SolidColorBrush brush = new SolidColorBrush(g.RenderTarget, rawColor); RoundedRectangle rounderRect = new RoundedRectangle { RadiusX = 1, RadiusY = 1, Rect = rect }; g.RenderTarget.DrawRoundedRectangle(rounderRect, brush, 2f); brush.Dispose(); // GradientStop[] gradientStops = new GradientStop[2]; gradientStops[0].Color = new RawColor4(0, 0, 0, 0.1f); gradientStops[0].Position = 0f; gradientStops[1].Color = new RawColor4(0, 0, 0, 0); gradientStops[1].Position = 1f; // GradientStopCollection gradientStopCollection = new GradientStopCollection(g.RenderTarget, gradientStops, Gamma.StandardRgb, ExtendMode.Clamp); // rect = new RawRectangleF(0, selector.Height - 9, selector.Width - 1, selector.Height - 1); LinearGradientBrushProperties props = new LinearGradientBrushProperties() { StartPoint = new RawVector2(rect.Left, rect.Top), EndPoint = new RawVector2(rect.Left, rect.Bottom) }; SharpDX.Direct2D1.LinearGradientBrush linearGradientBrush = new SharpDX.Direct2D1.LinearGradientBrush(g.RenderTarget, props, gradientStopCollection); g.RenderTarget.FillRectangle(rect, linearGradientBrush); gradientStopCollection.Dispose(); linearGradientBrush.Dispose(); //Graphics gdiGraphics = g.CreateGdiGraphics(); //gdiGraphics.SmoothingMode = SmoothingMode.HighQuality; //RectangleF rect1 = new RectangleF(0, 0, (float)Math.Ceiling(Width - 1), (float)Math.Ceiling(Height - 1)); //Pen pen = new Pen(Color.FromArgb(255, 191, 152, 90), 1f); //DrawUtils.DrawRoundRectangle(gdiGraphics, Pens.Gold, rect1, 4); //g.RelaseGdiGraphics(gdiGraphics); //pen.Dispose(); }
public override Brush GetBrush(RenderTarget target) { if (this.target != null && target != this.target) { if (stopCollection != null) { stopCollection.Dispose(); stopCollection = null; } } if (stops == null) { return(null); } if (stopCollection == null) { stopCollection = new GradientStopCollection(target, stops, ExtendMode.Clamp); } this.brush = new LinearGradientBrush(target, prop, stopCollection); this.target = target; return(brush); }
void FillIn(D2DGraphics g, Color boxColor) { RawRectangleF rect = new RawRectangleF(FillMargin.left + 1, FillMargin.top + 1, Width - FillMargin.right, Height - FillMargin.bottom); RawColor4 rawColor = GDIDataD2DUtils.TransToRawColor4(boxColor); SolidColorBrush brush = new SolidColorBrush(g.RenderTarget, rawColor); g.RenderTarget.DrawRectangle(rect, brush, 1); brush.Dispose(); // RawRectangleF fillRect = new RawRectangleF(FillMargin.left, FillMargin.top, Width - FillMargin.right, Height - FillMargin.bottom); g.RenderTarget.AntialiasMode = AntialiasMode.PerPrimitive; GradientStop[] gradientStops = new GradientStop[3]; gradientStops[0].Color = GDIDataD2DUtils.TransToRawColor4(Color.FromArgb(255, boxColor.R, boxColor.G, boxColor.B)); gradientStops[0].Position = 0f; gradientStops[1].Color = GDIDataD2DUtils.TransToRawColor4(Color.FromArgb(20, boxColor.R, boxColor.G, boxColor.B)); gradientStops[1].Position = 0.5f; gradientStops[2].Color = GDIDataD2DUtils.TransToRawColor4(Color.FromArgb(0, boxColor.R, boxColor.G, boxColor.B)); gradientStops[2].Position = 1f; // GradientStopCollection gradientStopCollection = new GradientStopCollection(g.RenderTarget, gradientStops, Gamma.StandardRgb, ExtendMode.Clamp); LinearGradientBrushProperties props = new LinearGradientBrushProperties() { StartPoint = new RawVector2(fillRect.Left, fillRect.Top), EndPoint = new RawVector2(fillRect.Right, fillRect.Bottom) }; SharpDX.Direct2D1.LinearGradientBrush linearGradientBrush = new SharpDX.Direct2D1.LinearGradientBrush(g.RenderTarget, props, gradientStopCollection); g.RenderTarget.FillRectangle(fillRect, linearGradientBrush); gradientStopCollection.Dispose(); linearGradientBrush.Dispose(); }