public RoundedRectangleGeometry(Rect bounds, double radius) { var segments = new PathSegments(); segments.AddRange(CreateRoundedRectangle(bounds, radius)); Figures = new PathFigures { new PathFigure { StartPoint = bounds.TopLeft + new Point(radius,0), Segments = segments } }; }
public PathFigure Convert(Microsoft.Msagl.Core.Geometry.Curves.ICurve curve) { var segments = new PathSegments(); segments.AddRange(Flatten(curve).Select(s => TransformSegment(s))); return(new PathFigure { StartPoint = Convert(curve.Start), Segments = segments, IsClosed = false, IsFilled = false }); }
/// <summary> /// Retrieves the next path segment from the stack as a string. /// Returns null if none exist. /// </summary> /// <returns></returns> public List <string> GetPathSegments() { if (Path != null) { PathSegments.Add(Path.ToString()); } if (MemoryMappedFileManager != null) { PathSegments.AddRange(MemoryMappedFileManager.GetFileContent()); } return(PathSegments); }
/// <summary> /// Create a border geometry with a 'pointer'. /// </summary> /// <param name="ha">The horizontal alignment.</param> /// <param name="va">The vertical alignment.</param> /// <param name="width">The width.</param> /// <param name="height">The height.</param> /// <param name="margin">The margin.</param> /// <returns>The border geometry.</returns> private Geometry CreatePointerBorderGeometry( HorizontalAlignment ha, VerticalAlignment va, double width, double height, out Thickness margin) { Point[] points = null; var m = Distance; margin = new Thickness(); if (ha == HorizontalAlignment.Center && va == VerticalAlignment.Bottom) { var x1 = width; var x2 = x1 / 2; var y1 = height; margin = new Thickness(0, 0, 0, m); points = new[] { new Point(0, 0), new Point(x1, 0), new Point(x1, y1), new Point(x2 + (m / 2), y1), new Point(x2, y1 + m), new Point(x2 - (m / 2), y1), new Point(0, y1) }; } else if (ha == HorizontalAlignment.Center && va == VerticalAlignment.Top) { var x1 = width; var x2 = x1 / 2; var y0 = m; var y1 = m + height; margin = new Thickness(0, m, 0, 0); points = new[] { new Point(0, y0), new Point(x2 - (m / 2), y0), new Point(x2, 0), new Point(x2 + (m / 2), y0), new Point(x1, y0), new Point(x1, y1), new Point(0, y1) }; } else if (ha == HorizontalAlignment.Left && va == VerticalAlignment.Center) { var x0 = m; var x1 = m + width; var y1 = height; var y2 = y1 / 2; margin = new Thickness(m, 0, 0, 0); points = new[] { new Point(0, y2), new Point(x0, y2 - (m / 2)), new Point(x0, 0), new Point(x1, 0), new Point(x1, y1), new Point(x0, y1), new Point(x0, y2 + (m / 2)) }; } else if (ha == HorizontalAlignment.Right && va == VerticalAlignment.Center) { var x1 = width; var y1 = height; var y2 = y1 / 2; margin = new Thickness(0, 0, m, 0); points = new[] { new Point(x1 + m, y2), new Point(x1, y2 + (m / 2)), new Point(x1, y1), new Point(0, y1), new Point(0, 0), new Point(x1, 0), new Point(x1, y2 - (m / 2)) }; } else if (ha == HorizontalAlignment.Left && va == VerticalAlignment.Top) { m *= 0.67; var x0 = m; var x1 = m + width; var y0 = m; var y1 = m + height; margin = new Thickness(m, m, 0, 0); points = new[] { new Point(0, 0), new Point(m * 2, y0), new Point(x1, y0), new Point(x1, y1), new Point(x0, y1), new Point(x0, m * 2) }; } else if (ha == HorizontalAlignment.Right && va == VerticalAlignment.Top) { m *= 0.67; var x1 = width; var y0 = m; var y1 = m + height; margin = new Thickness(0, m, m, 0); points = new[] { new Point(x1 + m, 0), new Point(x1, y0 + m), new Point(x1, y1), new Point(0, y1), new Point(0, y0), new Point(x1 - m, y0) }; } else if (ha == HorizontalAlignment.Left && va == VerticalAlignment.Bottom) { m *= 0.67; var x0 = m; var x1 = m + width; var y1 = height; margin = new Thickness(m, 0, 0, m); points = new[] { new Point(0, y1 + m), new Point(x0, y1 - m), new Point(x0, 0), new Point(x1, 0), new Point(x1, y1), new Point(x0 + m, y1) }; } else if (ha == HorizontalAlignment.Right && va == VerticalAlignment.Bottom) { m *= 0.67; var x1 = width; var y1 = height; margin = new Thickness(0, 0, m, m); points = new[] { new Point(x1 + m, y1 + m), new Point(x1 - m, y1), new Point(0, y1), new Point(0, 0), new Point(x1, 0), new Point(x1, y1 - m) }; } if (points == null) { return(null); } var pc = new List <Point>(points.Length); foreach (var p in points) { pc.Add(p); } var segments = new PathSegments(); segments.AddRange(pc.Select(p => new LineSegment { Point = p })); var pf = new PathFigure { StartPoint = points[0], Segments = segments, IsClosed = true }; return(new PathGeometry { Figures = new PathFigures { pf } }); }