本文整理汇总了C#中System.Windows.Media.PathGeometry.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# PathGeometry.ToString方法的具体用法?C# PathGeometry.ToString怎么用?C# PathGeometry.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Media.PathGeometry
的用法示例。
在下文中一共展示了PathGeometry.ToString方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetAllToTogether
public string GetAllToTogether(string[] paths)
{
PathGeometry result = new PathGeometry();
foreach (var item in paths)
{
result.AddGeometry ( PathGeometry.Parse(item));
}
return result.ToString();
}
示例2: CreateAutoShape
private void CreateAutoShape(object sender, RoutedEventArgs e)
{
PathGeometry sendingPath = new PathGeometry();
PathFigure pathFigure = new PathFigure();
pathFigure.StartPoint = new Point(47.7778, 48.6667);
pathFigure.IsClosed = true;
LineSegment lineSegment1 = new LineSegment();
lineSegment1.Point = new Point(198, 48.6667);
pathFigure.Segments.Add(lineSegment1);
LineSegment lineSegment2 = new LineSegment();
lineSegment2.Point = new Point(198, 102);
pathFigure.Segments.Add(lineSegment2);
BezierSegment bezierSegment1 = new BezierSegment();
bezierSegment1.Point1 = new Point(174.889, 91.3334);
bezierSegment1.Point2 = new Point(157.111, 79.7778);
bezierSegment1.Point3 = new Point(110.889, 114.444);
pathFigure.Segments.Add(bezierSegment1);
BezierSegment bezierSegment2 = new BezierSegment();
bezierSegment2.Point1 = new Point(64.667, 149.111);
bezierSegment2.Point2 = new Point(58.4444, 130.444);
bezierSegment2.Point3 = new Point(47.7778, 118.889);
pathFigure.Segments.Add(bezierSegment2);
sendingPath.Figures.Add(pathFigure);
PathGeometry pathGeometry = new PathGeometry();
if (sendingPath.FillRule != null)
pathGeometry.FillRule = sendingPath.FillRule;
else pathGeometry.FillRule = FillRule.Nonzero;
pathGeometry.Figures = sendingPath.Figures;
var newThumb = new SandRibbonInterop.AutoShape();
var safePathGeometry = (Geometry)(new GeometryConverter().ConvertFromString(pathGeometry.ToString()));
var safePathData = new PathGeometry();
safePathData.AddGeometry(safePathGeometry);
newThumb.PathData = safePathData;
newThumb.Background = Brushes.LightGreen;
newThumb.Foreground = Brushes.Green;
newThumb.StrokeThickness = 5;
newThumb.Height = 100;
newThumb.Width = 100;
Commands.AddAutoShape.Execute(newThumb);
}
示例3: PointsToPath
/// <summary>
/// Преобразует набор точек в путь
/// </summary>
/// <param name="points">Коллекция точек</param>
/// <param name="pathKind">Тип пути - Линия(замкнутая/открытая), либо Эллипс</param>
/// <returns></returns>
public static string PointsToPath(PointCollection points, PathKind pathKind) {
var enumerable = points.ToArray();
if (!enumerable.Any()) {
return string.Empty;
}
switch (pathKind) {
case PathKind.Ellipse: {
var radiusX = (enumerable[1].X - enumerable[0].X) / 2;
var radiusY = (enumerable[2].Y - enumerable[1].Y) / 2;
var center = new Point(enumerable[1].X - radiusX, enumerable[2].Y - radiusY);
var geometry = new EllipseGeometry(center: center, radiusX: radiusX, radiusY: radiusY);
return geometry.GetFlattenedPathGeometry().ToString(CultureInfo.InvariantCulture);
}
default: {
var start = enumerable[0];
var segments = new List<LineSegment>();
for (var i = 1; i < enumerable.Length; i++) {
segments.Add(new LineSegment(new Point(enumerable[i].X, enumerable[i].Y), true));
}
var figure = new PathFigure(start, segments, (pathKind == PathKind.ClosedLine));
var geometry = new PathGeometry();
geometry.Figures.Add(figure);
return geometry.ToString(CultureInfo.InvariantCulture);
}
}
}