private D2D1.StrokeStyle GetStrokeStyle(Stroke strokeStyle) { if (strokeStyle == null) { return(null); } var style = new D2D1.StrokeStyleProperties() { StartCap = strokeStyle.LineCap.ToDx(), EndCap = strokeStyle.LineCap.ToDx(), DashCap = strokeStyle.LineCap.ToDx(), LineJoin = strokeStyle.LineJoin.ToDx(), MiterLimit = strokeStyle.MiterLimit / strokeStyle.Width, DashStyle = strokeStyle.DashArray != null && strokeStyle.DashArray.Length > 0 ? D2D1.DashStyle.Custom : D2D1.DashStyle.Solid, DashOffset = strokeStyle.DashOffset / strokeStyle.Width }; /*if(style.DashStyle==D2D1.DashStyle.Custom) * Debugger.Break();*/ return(style.DashStyle != D2D1.DashStyle.Custom ? new D2D1.StrokeStyle(_dc.Factory, style) : new D2D1.StrokeStyle(_dc.Factory, style, strokeStyle.DashArray.Select(e => e / strokeStyle.Width).ToArray())); }
public Clock(Size clientSize) { ClientSize = clientSize; g_center = new PointF(ClientSize.Width / 2f, ClientSize.Height / 2f); // Create brushes blueBrush1 = new D2D.SolidColorBrush(RenderForm.RenderTarget, new Mathe.RawColor4(0.3f, 0.4f, 0.9f, 1)); blueBrush2 = new D2D.SolidColorBrush(RenderForm.RenderTarget, new Mathe.RawColor4(0.45f, 0.6f, 0.95f, 1)); blueBrush3 = new D2D.SolidColorBrush(RenderForm.RenderTarget, new Mathe.RawColor4(0.6f, 0.8f, 1f, 1)); whiteBrush = new D2D.SolidColorBrush(RenderForm.RenderTarget, new Mathe.RawColor4(1f, 1f, 1f, 0.5f)); redBrush = new D2D.SolidColorBrush(RenderForm.RenderTarget, new Mathe.RawColor4(0.99f, 0.16f, 0.3f, 0.7f)); // Create ellipses ellipseCentre = new D2D.Ellipse(new Mathe.RawVector2(g_center.X, g_center.Y), 120, 120); // Create text formats textFormat = new DW.TextFormat(RenderForm.FactoryWrite, "Berlin Sans FB", 36); strokeProperties = new D2D.StrokeStyleProperties { StartCap = D2D.CapStyle.Round, EndCap = D2D.CapStyle.Triangle }; strokeStyle = new D2D.StrokeStyle(RenderForm.Factory, strokeProperties); strokeProperties2 = new D2D.StrokeStyleProperties { StartCap = D2D.CapStyle.Round, EndCap = D2D.CapStyle.Round, DashStyle = D2D.DashStyle.Dash }; strokeStyle2 = new D2D.StrokeStyle(RenderForm.Factory, strokeProperties2); int len = 110; for (int i = 0; i < 60; i++) { int r = i % 5 == 0 ? 10 : 5; float deg, rad; deg = (i / 60f * 360 - 90); rad = deg / 180 * (float)Math.PI; lim[i] = new PointF(g_center.X + (float)Math.Cos(rad) * (len - r), g_center.Y + (float)Math.Sin(rad) * (len - r)); lim2[i] = new PointF(g_center.X + (float)Math.Cos(rad) * (len), g_center.Y + (float)Math.Sin(rad) * (len)); } sw = new Stopwatch(); sw.Start(); }
public override void Draw() { calculate(); var strokeStyleProperties = new SharpDX.Direct2D1.StrokeStyleProperties(); strokeStyleProperties.DashStyle = SharpDX.Direct2D1.DashStyle.Custom; float[] dashes = { 10, 5 }; //strokeStyleProperties.DashCap = SharpDX.Direct2D1.CapStyle.Square; //strokeStyleProperties.DashOffset = 0.2F; var strokeStyle = new StrokeStyle(cp.factory, strokeStyleProperties, dashes); var brush = new SharpDX.Direct2D1.SolidColorBrush(cp._renderTarget, new RawColor4(0.439F, 0.501F, 0.564F, 1)); for (int i = 0; i < ScaleCount; i++) { cp._renderTarget.DrawLine(listpointS[i], listpointE[i], brush, 0.5F, strokeStyle); } }
public D2D.StrokeStyle GetStroke(HilightType type) { D2D.StrokeStyle stroke; if (this.stroke_cache.TryGetValue(type, out stroke)) { return(stroke); } D2D.StrokeStyleProperties prop = new D2D.StrokeStyleProperties(); prop.DashCap = D2D.CapStyle.Flat; prop.DashOffset = 0; prop.DashStyle = D2D.DashStyle.Solid; prop.EndCap = D2D.CapStyle.Flat; prop.LineJoin = D2D.LineJoin.Miter; prop.MiterLimit = 0; prop.StartCap = D2D.CapStyle.Flat; switch (type) { case HilightType.Sold: case HilightType.Url: case HilightType.Squiggle: prop.DashStyle = D2D.DashStyle.Solid; break; case HilightType.Dash: prop.DashStyle = D2D.DashStyle.Dash; break; case HilightType.DashDot: prop.DashStyle = D2D.DashStyle.DashDot; break; case HilightType.DashDotDot: prop.DashStyle = D2D.DashStyle.DashDotDot; break; case HilightType.Dot: prop.DashStyle = D2D.DashStyle.Dot; break; } stroke = new D2D.StrokeStyle(this.Factory, prop); this.stroke_cache.Add(type, stroke); return(stroke); }
public static SharpDX.Direct2D1.StrokeStyle ToStrokeStyle(this Pen pen, SharpDX.Direct2D1.Factory factory) { SharpDX.Direct2D1.StrokeStyleProperties properties = new SharpDX.Direct2D1.StrokeStyleProperties { DashCap = _dashCapMap[pen.DashCap], DashOffset = pen.DashOffset, DashStyle = _dashStyleMap[pen.DashStyle], EndCap = _lineCapMap[pen.EndCap], LineJoin = _lineJoinMap[pen.LineJoin], MiterLimit = pen.MiterLimit, StartCap = _lineCapMap[pen.StartCap], }; if (pen.DashStyle == DashStyle.Custom) { return(new SharpDX.Direct2D1.StrokeStyle(factory, properties, pen.DashPattern)); } return(new SharpDX.Direct2D1.StrokeStyle(factory, properties)); }
public static D2D.StrokeStyle GetStrokeStyle(this Jupiter.Shapes.Shape shape, D2D.Factory factory) { var properties = new D2D.StrokeStyleProperties(); properties.StartCap = shape.StrokeStartLineCap.ToSharpDX(); properties.EndCap = shape.StrokeEndLineCap.ToSharpDX(); properties.LineJoin = shape.StrokeLineJoin.ToSharpDX(); properties.MiterLimit = (float)shape.StrokeMiterLimit; if (shape.StrokeDashArray.Count > 0) { properties.DashCap = shape.StrokeDashCap.ToSharpDX(); properties.DashOffset = (float)shape.StrokeDashOffset; properties.DashStyle = D2D.DashStyle.Custom; return new D2D.StrokeStyle(factory, properties, shape.StrokeDashArray.Select(d => (float)d).ToArray()); } properties.DashStyle = D2D.DashStyle.Solid; return new D2D.StrokeStyle(factory, properties); }
public static D2D.StrokeStyle GetStrokeStyle(this Jupiter.Shapes.Shape shape, D2D.Factory factory) { var properties = new D2D.StrokeStyleProperties(); properties.StartCap = shape.StrokeStartLineCap.ToSharpDX(); properties.EndCap = shape.StrokeEndLineCap.ToSharpDX(); properties.LineJoin = shape.StrokeLineJoin.ToSharpDX(); properties.MiterLimit = (float)shape.StrokeMiterLimit; if (shape.StrokeDashArray.Count > 0) { properties.DashCap = shape.StrokeDashCap.ToSharpDX(); properties.DashOffset = (float)shape.StrokeDashOffset; properties.DashStyle = D2D.DashStyle.Custom; return(new D2D.StrokeStyle(factory, properties, shape.StrokeDashArray.Select(d => (float)d).ToArray())); } properties.DashStyle = D2D.DashStyle.Solid; return(new D2D.StrokeStyle(factory, properties)); }