protected void DrawArc (DrawingContext dc, Point start, Point end, Size size, SweepDirection sweepDirection) { var figure = new PathFigure (); figure.StartPoint = start; figure.Segments.Add (new ArcSegment () { Point = end, Size = size, SweepDirection = sweepDirection } ); var geometry = new PathGeometry (); geometry.Figures.Add (figure); dc.DrawGeometry (null, new Pen (Colors.Black, 2), geometry); }
protected override void OnRender (DrawingContext dc) { base.OnRender (dc); var figure = new PathFigure () { StartPoint = new Point (0, 0.3 * Height) }; figure.Segments.Add (new LineSegment () { Point = new Point (3, 0.3 * Height) }); figure.Segments.Add (new LineSegment () { Point = new Point (6, Height) }); figure.Segments.Add (new LineSegment () { Point = new Point (10, 0) }); figure.Segments.Add (new LineSegment () { Point = new Point (Width + 2, 0) }); var geometry = new PathGeometry (); geometry.Figures.Add (figure); dc.DrawGeometry (null, new Pen (Colors.Black, 2), geometry); }
public CommaArea () { var figure = new PathFigure (); figure.StartPoint = new Point (4, 2); figure.Segments.Add (new ArcSegment () { Point = new Point (2, 2), Size = new Size (1, 1), RotationAngle = Math.PI, IsLargeArc = true, SweepDirection = SweepDirection.Clockwise } ); figure.Segments.Add (new ArcSegment () { Point = new Point (4, 2), Size = new Size (1, 1), RotationAngle = Math.PI, IsLargeArc = true, SweepDirection = SweepDirection.Clockwise } ); figure.Segments.Add (new ArcSegment () { Point = new Point (2, 6), Size = new Size (12, 12), RotationAngle = Math.PI, IsLargeArc = false, SweepDirection = SweepDirection.Clockwise } ); var geometry = new PathGeometry (); geometry.Figures.Add (figure); var path = new Path (); path.Data = geometry; Content = path; HeightRequest = 3; WidthRequest = 3; VerticalAlignment = VerticalAlignment.Bottom; Margin = new Thickness (2, 0, 2, 0); }
private static Button CloseButton () { var figure1 = new PathFigure (); figure1.StartPoint = new Point (0, 0); figure1.Segments.Add (new LineSegment () { Point = new Point(7,7)}); var figure2 = new PathFigure (); figure2.StartPoint = new Point (7, 0); figure2.Segments.Add (new LineSegment () { Point = new Point(0,7)}); var pathGeomentry = new PathGeometry (); pathGeomentry.Figures.Add (figure1); pathGeomentry.Figures.Add (figure2); var path = new Path (); path.WidthRequest = 7; path.HeightRequest = 7; path.Stroke = Colors.White; path.StrokeThickness = 2; path.Data = pathGeomentry; var button = new Button () { Content = path }; button.Padding = new Thickness (4); button.BorderColor = new Color (0x1f, 0x42, 0x6f); button.BorderThickness = 1; button.Background = GetTitleBrush (); return button; }
private void DrawFigure (PathFigure figure) { cr.MoveTo (figure.StartPoint.X, figure.StartPoint.Y); foreach (var segment in figure.Segments) { DrawSegment (segment); } if (figure.IsClosed) cr.ClosePath (); }
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); }
protected override void OnRender (DrawingContext dc) { if (Child == null) return; var x = BorderThickness / 2; var y = BorderThickness / 2; var width = Width - BorderThickness; var height = Height - BorderThickness; var figure = new PathFigure (); figure.StartPoint = new Point (x + CornerRadius.TopLeft, y); figure.IsClosed = true; figure.Segments.Add (new LineSegment () { Point = new Point(x + width - CornerRadius.TopRight, y)}); if (CornerRadius.TopRight > 0) { figure.Segments.Add (new ArcSegment () { Point = new Point(x + width, y + CornerRadius.TopRight), Size = new Size(CornerRadius.TopRight, CornerRadius.TopRight), SweepDirection = SweepDirection.Clockwise, IsLargeArc = false } ); } figure.Segments.Add (new LineSegment () { Point = new Point(x + width, y + height - CornerRadius.BottomRight) }); if (CornerRadius.BottomRight > 0) { figure.Segments.Add (new ArcSegment () { Point = new Point(x + width - CornerRadius.BottomRight, y + height), Size = new Size(CornerRadius.BottomRight, CornerRadius.BottomRight), SweepDirection = SweepDirection.Clockwise, IsLargeArc = false } ); } figure.Segments.Add (new LineSegment () { Point = new Point(x + CornerRadius.BottomLeft, y + height) }); if (CornerRadius.BottomLeft > 0) { figure.Segments.Add (new ArcSegment () { Point = new Point(x, y + height - CornerRadius.BottomLeft), Size = new Size(CornerRadius.BottomLeft, CornerRadius.BottomLeft), SweepDirection = SweepDirection.Clockwise, IsLargeArc = false } ); } figure.Segments.Add (new LineSegment () { Point = new Point(x, y + CornerRadius.TopLeft) }); if (CornerRadius.TopLeft > 0) { figure.Segments.Add (new ArcSegment () { Point = new Point(x + CornerRadius.TopLeft, y), Size = new Size(CornerRadius.TopLeft, CornerRadius.TopLeft), SweepDirection = SweepDirection.Clockwise, IsLargeArc = false } ); } var path = new PathGeometry (); path.Figures.Add (figure); //todo: resove it var brush = Background; if (brush is LinearGradientBrush) { var b = brush as LinearGradientBrush; var newBrush = new LinearGradientBrush () { StartPoint = new Point (b.StartPoint.X * width, b.StartPoint.Y * height), EndPoint = new Point (b.EndPoint.X * width, b.EndPoint.Y * height) }; newBrush.GradientStops.AddRange (b.GradientStops); brush = newBrush; } dc.DrawGeometry (brush, new Pen (BorderColor, BorderThickness), path); }