public void DrawRect(Rect bounds, DrawingStyle style) { OnRendering(bounds); bounds.Offset(0, -_offset); if (style.HasFill) { if (style.CornerRadius.TopLeft > 0) { _g.DrawRoundedRectangle(style.Fill.ToXBrush(bounds.Width, bounds.Height), bounds.ToXRect(), new XSize(style.CornerRadius.TopLeft, style.CornerRadius.TopLeft)); } else { _g.DrawRectangle(style.Fill.ToXBrush(bounds.Width, bounds.Height), bounds.ToXRect()); } } if (style.HasStroke) { if (style.CornerRadius.TopLeft > 0) { _g.DrawRoundedRectangle(new XPen(style.Stroke.ToXColor(), style.StrokeThickness.Left), bounds.ToXRect(), new XSize(style.CornerRadius.TopLeft, style.CornerRadius.TopLeft)); } else { _g.DrawRectangle(new XPen(style.Stroke.ToXColor(), style.StrokeThickness.Left), bounds.ToXRect()); } } }
public override Entity parse(List <string> section) { gatherCodes(section); getCommonCodes(); //Grab inheiritable values first styleName = getCode(" 7", styleName); style = new DrawingStyle(parent.styles[styleName]); //Get possible local overrides style.obliqueAngle = getCode(" 51", style.obliqueAngle); int mirrorValue = getCode(" 71", 0); style.mirrorX = mirrorValue == 2 || mirrorValue == 6; style.mirrorY = mirrorValue == 4 || mirrorValue == 6; //Set entity values start.X = getCode(" 10", start.X); start.Y = getCode(" 20", start.Y); purePosition.X = getCode(" 11", purePosition.X); purePosition.Y = getCode(" 21", purePosition.Y); text = getCode(" 1", text); size = getCode(" 40", size); angle = getCode(" 50", angle); alignmentColIndex = getCode(" 72", alignmentColIndex); alignmentRowIndex = getCode(" 73", alignmentRowIndex); return(this); }
public void DrawText(Rect bounds, string text, DrawingStyle style) { OnRendering(bounds); bounds.Offset(0, -_offset); XFontStyle fontStyle = XFontStyle.Regular; if (style.FontStyle == FontStyles.Italic) { fontStyle = XFontStyle.Italic; if (style.FontWeight == FontWeights.Bold) { fontStyle = XFontStyle.BoldItalic; } } else if (style.FontWeight == FontWeights.Bold) { fontStyle = XFontStyle.BoldItalic; } XFont font = new XFont(style.FontFamily.ToString(), style.FontSize, fontStyle); _g.DrawString(text, font, style.Fill.ToXBrush(bounds.Width, bounds.Height), bounds.ToXRect(), new XStringFormat()); }
public static void ApplyFill(this SKPaint paint, Rect bounds, DrawingStyle style) { paint.Style = SKPaintStyle.Fill; paint.IsAntialias = style.EdgeMode == EdgeMode.Unspecified; if (style.Fill is SolidColorBrush) { paint.Color = style.Fill.ToSKColor(); } else { paint.Shader = style.Fill.ToSkiaShader(bounds.Width, bounds.Height); } if (style.HasOpacity) { paint.ColorFilter = SKColorFilter.CreateBlendMode(SKColors.Transparent.WithAlpha((byte)(style.Opacity * 255d)), SKBlendMode.DstIn); } if (style.Effect != null) { if (style.Effect is DropShadowEffect) { var fx = style.Effect as DropShadowEffect; paint.ImageFilter = SKImageFilter.CreateDropShadow(fx.ShadowDepth.ToFloat(), fx.ShadowDepth.ToFloat(), fx.BlurRadius.ToFloat(), fx.BlurRadius.ToFloat(), fx.Color.ToSKColor(), SKDropShadowImageFilterShadowMode.DrawShadowAndForeground); } } }
/// <summary> /// Draws the specified geometry. /// </summary> /// <param name="bounds">The bounds.</param> /// <param name="geometry">The geometry.</param> /// <param name="style">The style.</param> public void DrawGeometry(Rect bounds, Geometry geometry, DrawingStyle style) { _canvas.ApplyTransform(style.Transform, style.TransformOrigin, bounds); PathGeometry g = geometry as PathGeometry; if (g == null) { g = (geometry as StreamGeometry).GetWidenedPathGeometry(new Pen(Brushes.Chartreuse, 2d)); } SKPath skPath = g.ToSKPath(); skPath.Offset(bounds.TopLeft.ToSKPoint()); if (style.HasFill) { SKPaint paintFill = new SKPaint(); paintFill.ApplyFill(bounds, style); _canvas.DrawPath(skPath, paintFill); } if (style.HasStroke) { SKPaint paintStroke = new SKPaint(); paintStroke.ApplyStroke(bounds, style); _canvas.DrawPath(skPath, paintStroke); } _canvas.ResetMatrix(); }
/// <summary> /// Draws a polygon. /// </summary> /// <param name="bounds">The bounds.</param> /// <param name="points">The points.</param> /// <param name="style">The style.</param> public void DrawPolygon(Rect bounds, Point[] points, DrawingStyle style) { _canvas.ApplyTransform(style.Transform, style.TransformOrigin, bounds); var pp = points.Select(x => x.ToSKPoint()).ToArray(); SKPath path = new SKPath(); path.AddPoly(pp, true); path.Offset(bounds.Left.ToFloat(), bounds.Top.ToFloat()); if (style.HasFill) { SKPaint paintFill = new SKPaint(); paintFill.ApplyFill(bounds, style); _canvas.DrawPath(path, paintFill); } if (style.HasStroke) { SKPaint paintStroke = new SKPaint(); paintStroke.ApplyStroke(bounds, style); _canvas.DrawPath(path, paintStroke); } _canvas.ResetMatrix(); }
public void DrawLine(Rect bounds, Point p1, Point p2, DrawingStyle style) { OnRendering(bounds); bounds.Offset(0, -_offset); _g.DrawLine(new XPen(style.Stroke.ToXColor()), p1.ToXPoint(), p2.ToXPoint()); }
public void DrawImage(Rect bounds, BitmapSource image, DrawingStyle style) { OnRendering(bounds); bounds.Offset(0, -_offset); _g.DrawImage(XImage.FromBitmapSource(image), bounds.ToXRect()); }
public void DrawText(Rect bounds, string text, DrawingStyle style) { if (style.Fill != null) { var fill = style.Fill.ToGdiBrush(bounds.Width, bounds.Height); _g.DrawString(text, System.Drawing.SystemFonts.DefaultFont, fill, bounds.ToGdiRectF()); fill.Dispose(); } }
public void DrawRect(Rect bounds, DrawingStyle style) { _context.PushOpacity(style.Opacity); _context.DrawRectangle(style.Fill, new Pen(style.Stroke, style.StrokeThickness.Left), bounds); _context.Pop(); if (_hasClip) { ClipRect(_clipBounds, new CornerRadius()); } }
void ChangeStyle(DrawingStyle newStyle) { DrawingStyler.style = newStyle; controller.UpdateStyleNextFrame(newStyle); UpdateGraphNowOrNextFrame(); foreach (MenuItem button in styleButtons) { button.Checked = false; } }
protected override void OnRender(IDrawingContext context, Rect bounds, double opacity) { base.OnRender(context, bounds, opacity); Image image = WpfElement as Image; DrawingStyle style = DrawingStyle.FromElement(this); style.Opacity = opacity; context.DrawImage(bounds, image.Source as BitmapSource, style); }
/// <summary> /// Draws a line. /// </summary> /// <param name="bounds">The bounds.</param> /// <param name="p1">The p1.</param> /// <param name="p2">The p2.</param> /// <param name="style">The style.</param> public void DrawLine(Rect bounds, Point p1, Point p2, DrawingStyle style) { _canvas.ApplyTransform(style.Transform, style.TransformOrigin, bounds); SKPaint paint = new SKPaint(); paint.ApplyStroke(bounds, style); _canvas.DrawLine(p1.ToSKPoint(), p2.ToSKPoint(), paint); _canvas.ResetMatrix(); }
protected override void OnRender(IDrawingContext context, Rect bounds, double opacity) { base.OnRender(context, bounds, opacity); Line line = WpfElement as Line; DrawingStyle style = DrawingStyle.FromElement(this); style.Stroke = line.Stroke; style.StrokeThickness = new Thickness(line.StrokeThickness); style.Opacity = opacity; context.DrawLine(bounds, new Point(line.X1, line.Y1), new Point(line.X2, line.Y2), style); }
protected override void OnRender(IDrawingContext context, Rect bounds, double opacity) { base.OnRender(context, bounds, opacity); Rectangle rectangle = WpfElement as Rectangle; DrawingStyle style = DrawingStyle.FromElement(this); style.Fill = rectangle.Fill; style.Stroke = rectangle.Stroke; style.StrokeThickness = new Thickness(rectangle.StrokeThickness); style.Opacity = opacity; context.DrawRect(bounds, style); }
protected override void OnRender(IDrawingContext context, Rect bounds, double opacity) { base.OnRender(context, bounds, opacity); Ellipse ellipse = WpfElement as Ellipse; DrawingStyle style = DrawingStyle.FromElement(this); style.Fill = ellipse.Fill; style.Stroke = ellipse.Stroke; style.StrokeThickness = new Thickness(ellipse.StrokeThickness); style.Opacity = opacity; context.DrawEllipse(bounds, style); }
/// <summary> /// Draws the specified image. /// </summary> /// <param name="bounds">The bounds.</param> /// <param name="image">The image.</param> /// <param name="style">The style.</param> public void DrawImage(Rect bounds, BitmapSource image, DrawingStyle style) { _canvas.ApplyTransform(style.Transform, style.TransformOrigin, bounds); SKPaint paint = new SKPaint(); if (style.HasOpacity) { paint.ColorFilter = SKColorFilter.CreateBlendMode(SKColors.White.WithAlpha((byte)(style.Opacity * 255d)), SKBlendMode.DstIn); } _canvas.DrawBitmap(image.ToSKBitmap(), bounds.ToSKRect(), paint); _canvas.ResetMatrix(); }
protected override void OnRender(IDrawingContext context, Rect bounds, double opacity) { base.OnRender(context, bounds, opacity); Path path = WpfElement as Path; DrawingStyle style = DrawingStyle.FromElement(this); style.Fill = path.Fill; style.Stroke = path.Stroke; style.StrokeThickness = new Thickness(path.StrokeThickness); style.Opacity = opacity; context.DrawGeometry(bounds, path.Data, style); }
public static T Style <T>(this T shape, DrawingStyle drawingStyle, bool cascades = true, Type type = null) where T : Shape { if (type != null && !cascades) { Logger.Fatal($"Setting a type, and cascades = false does nothing!"); } if (type != null) { shape.SetEnvironment(type, EnvironmentKeys.Shape.DrawingStyle, drawingStyle, true); } else { shape.SetEnvironment(EnvironmentKeys.Shape.DrawingStyle, drawingStyle, cascades); } return(shape); }
public void DrawRect(Rect bounds, DrawingStyle style) { if (style.Fill != null) { var fill = style.Fill.ToGdiBrush(bounds.Width, bounds.Height); _g.FillRectangle(fill, bounds.Left.ToFloat(), bounds.Top.ToFloat(), bounds.Width.ToFloat(), bounds.Height.ToFloat()); fill.Dispose(); } if (style.Stroke != null) { System.Drawing.Pen pen = new System.Drawing.Pen(style.Stroke.ToGdiBrush(bounds.Width, bounds.Height), style.StrokeThickness.Left.ToFloat()); _g.DrawRectangle(pen, bounds.Left.ToFloat(), bounds.Top.ToFloat(), bounds.Width.ToFloat(), bounds.Height.ToFloat()); pen.Dispose(); } }
public void DrawEllipse(Rect bounds, DrawingStyle style) { OnRendering(bounds); bounds.Offset(0, -_offset); if (style.HasFill) { _g.DrawEllipse(style.Fill.ToXBrush(bounds.Width, bounds.Height), bounds.ToXRect()); } if (style.HasStroke) { _g.DrawEllipse(new XPen(style.Stroke.ToXColor(), style.StrokeThickness.Left), bounds.ToXRect()); } }
public void WriteTo(XmlWriter xmlWriter) { xmlWriter.WriteStartElement("ThreeDProperties"); { if (Enabled.HasValue) { xmlWriter.WriteElementString("Enabled", Enabled.Value.ToString()); } xmlWriter.WriteElementString("ProjectionMode", ProjectionMode.ToString()); if (ProjectionMode == ProjectionMode3DForRendering.Perspective) { if (Perspective.HasValue) { xmlWriter.WriteElementString("Perspective", Perspective.ToString()); } } if (Rotation.HasValue) { xmlWriter.WriteElementString("Rotation", Rotation.ToString()); } if (Inclination.HasValue) { xmlWriter.WriteElementString("Inclination", Inclination.ToString()); } xmlWriter.WriteElementString("Shading", Shading.ToString()); if (WallThickness.HasValue) { xmlWriter.WriteElementString("WallThickness", WallThickness.ToString()); } //if ( chart type is bar OR column) { xmlWriter.WriteElementString("DrawingStyle", DrawingStyle.ToString()); if (Clustered.HasValue) { xmlWriter.WriteElementString("Clustered", Clustered.ToString()); } } } xmlWriter.WriteEndElement(); }
protected override void OnRender(IDrawingContext context, Rect bounds, double opacity) { base.OnRender(context, bounds, opacity); Polygon polygon = WpfElement as Polygon; if (polygon.Points != null) { DrawingStyle style = DrawingStyle.FromElement(this); style.Fill = polygon.Fill; style.Stroke = polygon.Stroke; style.StrokeThickness = new Thickness(polygon.StrokeThickness); style.Opacity = opacity; context.DrawPolygon(bounds, polygon.Points.ToArray(), style); } }
protected override void OnRender(IDrawingContext context, Rect bounds, double opacity) { base.OnRender(context, bounds, opacity); TextBlock textBlock = WpfElement as TextBlock; DrawingStyle style = DrawingStyle.FromElement(this); style.Fill = textBlock.Foreground; style.FontFamily = textBlock.FontFamily; style.FontSize = textBlock.FontSize; style.FontStyle = textBlock.FontStyle; style.FontWeight = textBlock.FontWeight; style.Opacity = opacity; context.DrawText(bounds, textBlock.Text, style); }
/// <summary> /// Draws the specified text. /// </summary> /// <param name="bounds">The bounds.</param> /// <param name="text">The text.</param> /// <param name="style">The style.</param> public void DrawText(Rect bounds, string text, DrawingStyle style) { _canvas.ApplyTransform(style.Transform, style.TransformOrigin, bounds); SKFontStyleSlant fontStyle = SKFontStyleSlant.Upright; if (style.FontStyle == FontStyles.Italic) { fontStyle = SKFontStyleSlant.Italic; } else if (style.FontStyle == FontStyles.Oblique) { fontStyle = SKFontStyleSlant.Oblique; } var typeFace = SKTypeface.FromFamilyName(style.FontFamily.ToString(), new SKFontStyle(style.FontWeight.ToOpenTypeWeight(), 1, fontStyle)); SKPaint paint = new SKPaint(); paint.Typeface = typeFace; paint.TextSize = style.FontSize.ToFloat(); paint.IsAntialias = style.EdgeMode == EdgeMode.Unspecified; if (style.HasOpacity) { paint.ColorFilter = SKColorFilter.CreateBlendMode(SKColors.White.WithAlpha((byte)(style.Opacity * 255d)), SKBlendMode.DstIn); } if (style.Fill != null) { if (style.Fill is SolidColorBrush) { paint.Color = style.Fill.ToSKColor(); } else { paint.Shader = style.Fill.ToSkiaShader(bounds.Width, bounds.Height); } } _canvas.DrawText(text, bounds.Left.ToFloat(), bounds.Bottom.ToFloat(), paint); _canvas.ResetMatrix(); }
/// <summary> /// Raises the <see cref="E:System.Windows.Forms.Control.Paint" /> event. /// </summary> /// <param name="e">A <see cref="T:System.Windows.Forms.PaintEventArgs" /> that contains the event data.</param> protected override void OnPaint(PaintEventArgs e) { if (IsPlatformSupported) { base.OnPaint(e); } else { if (FlatStyle != FlatStyle.Standard) { FlatStyle = FlatStyle.Standard; } e.Graphics.SmoothingMode = SmoothingMode.HighQuality; e.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit; DrawingStyle.Draw(this, buttonState, e); } }
public void DrawPolygon(Rect bounds, Point[] points, DrawingStyle style) { OnRendering(bounds); bounds.Offset(0, -_offset); _g.TranslateTransform(bounds.Left, bounds.Top); if (style.HasFill) { _g.DrawPolygon(style.Fill.ToXBrush(bounds.Width, bounds.Height), points, XFillMode.Alternate); } if (style.HasStroke) { _g.DrawPolygon(new XPen(style.Stroke.ToXColor()), points); } _g.Restore(); }
public static void ApplyStroke(this SKPaint paint, Rect bounds, DrawingStyle style) { paint.IsAntialias = style.EdgeMode == EdgeMode.Unspecified; paint.Style = SKPaintStyle.Stroke; paint.IsStroke = true; paint.StrokeWidth = style.StrokeThickness.Left.ToFloat(); if (style.Stroke is SolidColorBrush) { paint.Color = style.Stroke.ToSKColor(); } else { paint.Shader = style.Stroke.ToSkiaShader(bounds.Width, bounds.Height); } if (style.HasOpacity) { paint.ColorFilter = SKColorFilter.CreateBlendMode(SKColors.Transparent.WithAlpha((byte)(style.Opacity * 255d)), SKBlendMode.DstIn); } }
protected override void OnRender(IDrawingContext context, Rect bounds, double opacity) { base.OnRender(context, bounds, opacity); Border border = WpfElement as Border; DrawingStyle style = DrawingStyle.FromElement(this); style.CornerRadius = border.CornerRadius; style.Fill = border.Background; style.Stroke = border.BorderBrush; style.StrokeThickness = border.BorderThickness; style.Opacity = opacity; context.DrawRect(bounds, style); if (border.ClipToBounds) { context.ClipRect(bounds, border.CornerRadius); } }
/// <summary> /// Draws results of inspection on image /// </summary> private void DrawResults(Image ioImage, List <Circle2D> correctCircles, List <Circle2D> incorrectCircles) { var defaultStyle = new DrawingStyle { DrawingMode = DrawingMode.HighQuality, Filled = false, Opacity = 1.0f, PointShape = null, PointSize = 2.0f, Thickness = 4.0f }; foreach (var correctCircle in correctCircles) { AVL.DrawCircle(ioImage, correctCircle, null, Pixel.Green, defaultStyle); } foreach (var incorrectCircle in incorrectCircles) { AVL.DrawCircle(ioImage, incorrectCircle, null, Pixel.Red, defaultStyle); } }