private void button3_Click(object sender, EventArgs e) { var strokeStylePropertiesFlat = new D2D.StrokeStyleProperties(); strokeStylePropertiesFlat.StartCap = D2D.CapStyle.Flat; strokeStylePropertiesFlat.EndCap = D2D.CapStyle.Flat; var strokeStylePropertiesRound = new D2D.StrokeStyleProperties(); strokeStylePropertiesRound.StartCap = D2D.CapStyle.Round; strokeStylePropertiesRound.EndCap = D2D.CapStyle.Round; var strokeStylePropertiesSquare = new D2D.StrokeStyleProperties(); strokeStylePropertiesSquare.StartCap = D2D.CapStyle.Square; strokeStylePropertiesSquare.EndCap = D2D.CapStyle.Round; var strokeStylePropertiesTriangle = new D2D.StrokeStyleProperties(); strokeStylePropertiesTriangle.StartCap = D2D.CapStyle.Triangle; strokeStylePropertiesTriangle.EndCap = D2D.CapStyle.Round; var strokeStyleFlat = new StrokeStyle(factory, strokeStylePropertiesFlat); var strokeStyleRound = new StrokeStyle(factory, strokeStylePropertiesRound); var strokeStyleSquare = new StrokeStyle(factory, strokeStylePropertiesSquare); var strokeStyleTriangle = new StrokeStyle(factory, strokeStylePropertiesTriangle); var brush = new D2D.SolidColorBrush(_renderTarget, new SharpDX.Mathematics.Interop.RawColor4(1, 0, 0, 1)); _renderTarget.BeginDraw(); _renderTarget.Clear(new RawColor4(0.752F, 0.862F, 0752F, 0)); _renderTarget.DrawLine(new RawVector2(100, 50), new RawVector2(200, 50), brush, 10, strokeStyleFlat); _renderTarget.DrawLine(new RawVector2(100, 100), new RawVector2(200, 100), brush, 10, strokeStyleRound); _renderTarget.DrawLine(new RawVector2(100, 150), new RawVector2(200, 150), brush, 10, strokeStyleSquare); _renderTarget.DrawLine(new RawVector2(100, 200), new RawVector2(200, 200), brush, 10, strokeStyleTriangle); _renderTarget.EndDraw(); }
private void button5_Click(object sender, EventArgs e) { var textformat = new DW.TextFormat(dwfactory, "宋体", 20); var brush = new D2D.SolidColorBrush(_renderTarget, new SharpDX.Mathematics.Interop.RawColor4(1, 0, 0, 1)); _renderTarget.BeginDraw(); _renderTarget.Clear(new RawColor4(0.752F, 0.862F, 0752F, 0)); textformat.FlowDirection = DW.FlowDirection.TopToBottom; textformat.ReadingDirection = DW.ReadingDirection.RightToLeft; _renderTarget.DrawText("-20", textformat, new RawRectangleF(0, 0, 200, 200), brush); _renderTarget.EndDraw(); }
private void button1_Click(object sender, EventArgs e) { var ellipse = new D2D.Ellipse(new SharpDX.Mathematics.Interop.RawVector2(100, 100), 10, 10); var brush = new D2D.SolidColorBrush(_renderTarget, new SharpDX.Mathematics.Interop.RawColor4(1, 0, 0, 1)); _renderTarget.BeginDraw(); _renderTarget.Clear(new RawColor4(0.752F, 0.862F, 0752F, 0)); _renderTarget.DrawEllipse(ellipse, brush, 1); _renderTarget.FillEllipse(ellipse, brush); _renderTarget.EndDraw(); }
private void button2_Click(object sender, EventArgs e) { if (_renderTarget == null) { return; } _renderTarget.BeginDraw(); var brush = new D2D.SolidColorBrush(_renderTarget, new SharpDX.Mathematics.Interop.RawColor4(0, 1, 0, 1)); _renderTarget.Clear(new RawColor4(0.752F, 0.862F, 0752F, 0)); _renderTarget.DrawLine(new RawVector2(10, 10), new RawVector2(100, 100), brush, 10); _renderTarget.EndDraw(); }
private void button4_Click(object sender, EventArgs e) { var strokeStyleProperties = new D2D.StrokeStyleProperties(); float[] dashes = { 20, 10 }; strokeStyleProperties.DashStyle = D2D.DashStyle.Custom; //strokeStyleProperties.DashCap = D2D.CapStyle.Square; //strokeStyleProperties.DashOffset = 5; var strokeStyle = new StrokeStyle(factory, strokeStyleProperties, dashes); strokeStyle.GetDashes(dashes, 2); var brush = new D2D.SolidColorBrush(_renderTarget, new SharpDX.Mathematics.Interop.RawColor4(0.439F, 0.501F, 0.564F, 1)); _renderTarget.BeginDraw(); _renderTarget.Clear(new RawColor4(0.752F, 0.862F, 0752F, 0)); _renderTarget.DrawLine(new RawVector2(100, 50), new RawVector2(500, 50), brush, 0.5F, strokeStyle); _renderTarget.EndDraw(); }