public override void DrawEllipse (Brush brush, Pen pen, Point center, double radiusX, double radiusY) { cr.Save (); cr.Translate (center.X, center.Y); cr.Scale (1, radiusY / radiusX); if (brush != null) { if (brush is SolidColorBrush) { var b = brush as SolidColorBrush; cr.Color = new Cairo.Color (b.Color.R, b.Color.G, b.Color.B, b.Color.Alfa); cr.Arc (0, 0, radiusX, 0, 2 * Math.PI); cr.Fill (); } } if (pen != null) { cr.Color = new Cairo.Color (pen.Color.R, pen.Color.G, pen.Color.B, pen.Color.Alfa); cr.LineWidth = pen.Thickness; cr.Arc (0, 0, radiusX - pen.Thickness / 2, 0, 2 * Math.PI); cr.Stroke (); } cr.Restore (); }
public override void DrawLine (Pen pen, Point point0, Point point2) { cr.Color = new Cairo.Color (pen.Color.R, pen.Color.G, pen.Color.B, pen.Color.Alfa); cr.LineWidth = pen.Thickness; cr.MoveTo (point0.X, point0.Y); cr.LineTo (point2.X, point2.Y); cr.Stroke (); }
public override void DrawRectangle (Brush brush, Pen pen, Rect rectangle) { if (brush != null) { if (brush is SolidColorBrush) { var b = brush as SolidColorBrush; cr.Color = new Cairo.Color (b.Color.R, b.Color.G, b.Color.B, b.Color.Alfa); cr.Rectangle (rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height); cr.Fill (); } else if (brush is LinearGradientBrush) { var b = brush as LinearGradientBrush; var pattern = new Cairo.LinearGradient (b.StartPoint.X, b.StartPoint.Y, b.EndPoint.X, b.EndPoint.Y); foreach (var stop in b.GradientStops) { pattern.AddColorStop (stop.Offset, new Cairo.Color (stop.Color.R, stop.Color.G, stop.Color.B, stop.Color.Alfa)); } cr.Pattern = pattern; cr.Rectangle (rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height); cr.Fill (); } } if (pen != null) { cr.Color = new Cairo.Color (pen.Color.R, pen.Color.G, pen.Color.B, pen.Color.Alfa); cr.LineWidth = pen.Thickness; cr.Rectangle (rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height); cr.Stroke (); } }
public override void DrawRoundedRectangle (Brush brush, Pen pen, Rect rectangle, double radiusX, double radiusY) { var figure = new PathFigure (); figure.StartPoint = new Point (rectangle.X + radiusX, rectangle.Y); figure.Segments.Add (new LineSegment () { Point = new Point(rectangle.X + rectangle.Width - radiusX, rectangle.Y) }); figure.Segments.Add (new ArcSegment () { Point = new Point(rectangle.X + rectangle.Width, rectangle.Y + radiusY), Size = new Size(radiusX, radiusY), SweepDirection = SweepDirection.Clockwise, IsLargeArc = false } ); figure.Segments.Add (new LineSegment () { Point = new Point(rectangle.X + rectangle.Width, rectangle.Y + rectangle.Height - radiusY) }); figure.Segments.Add (new ArcSegment () { Point = new Point(rectangle.X + rectangle.Width - radiusX, rectangle.Y + rectangle.Height), Size = new Size(radiusX, radiusY), SweepDirection = SweepDirection.Clockwise, IsLargeArc = false } ); figure.Segments.Add (new LineSegment () { Point = new Point(rectangle.X + radiusX, rectangle.Y + rectangle.Height) }); figure.Segments.Add (new ArcSegment () { Point = new Point(rectangle.X, rectangle.Y + rectangle.Height - radiusY), Size = new Size(radiusX, radiusY), SweepDirection = SweepDirection.Clockwise, IsLargeArc = false } ); figure.Segments.Add (new LineSegment () { Point = new Point(rectangle.X, rectangle.Y + radiusY) }); figure.Segments.Add (new ArcSegment () { Point = new Point(rectangle.X + radiusX, rectangle.Y), Size = new Size(radiusX, radiusY), SweepDirection = SweepDirection.Clockwise, IsLargeArc = false } ); var path = new PathGeometry (); path.Figures.Add (figure); }
public abstract void DrawGeometry (Brush brush, Pen pen, Geometry geometry);
public abstract void DrawRoundedRectangle (Brush brush, Pen pen, Rect rectangle, double radiusX, double radiusY);
public abstract void DrawRectangle (Brush brush, Pen pen, Rect rectangle);
public abstract void DrawEllipse (Brush brush, Pen pen, Point center, double radiusX, double radiusY);
public abstract void DrawLine (Pen pen, Point point0, Point point1);