本文整理汇总了C#中System.Windows.Media.PathFigure类的典型用法代码示例。如果您正苦于以下问题:C# PathFigure类的具体用法?C# PathFigure怎么用?C# PathFigure使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PathFigure类属于System.Windows.Media命名空间,在下文中一共展示了PathFigure类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Draw
public static void Draw(Canvas canvas, List<LinePoint> points, Brush stroke, bool clear = true)
{
if (clear)
{
canvas.Children.Clear();
}
PathFigureCollection myPathFigureCollection = new PathFigureCollection();
PathGeometry myPathGeometry = new PathGeometry();
foreach (LinePoint p in points)
{
PathFigure myPathFigure = new PathFigure();
myPathFigure.StartPoint = p.StartPoint;
LineSegment myLineSegment = new LineSegment();
myLineSegment.Point = p.EndPoint;
PathSegmentCollection myPathSegmentCollection = new PathSegmentCollection();
myPathSegmentCollection.Add(myLineSegment);
myPathFigure.Segments = myPathSegmentCollection;
myPathFigureCollection.Add(myPathFigure);
}
myPathGeometry.Figures = myPathFigureCollection;
Path myPath = new Path();
myPath.Stroke = stroke == null ? Brushes.Black : stroke;
myPath.StrokeThickness = 1;
myPath.Data = myPathGeometry;
canvas.Children.Add(myPath);
}
示例2: DrawPath
private void DrawPath(IEnumerable<Vector2> path)
{
if (!path.Any())
throw new ArgumentException("Path cannot be empty.");
var figure = new PathFigure();
var start = path.First();
figure.StartPoint = PointFromVector(start);
foreach (var vector in path.Skip(1))
{
var point = PointFromVector(vector);
figure.Segments.Add(new LineSegment(point, true));
}
var geometry = new PathGeometry();
geometry.Figures.Add(figure);
var pathImage = new Path()
{
Stroke = Brushes.Black,
StrokeThickness = 3,
Data = geometry
};
mainCanvas.Children.Add(pathImage);
}
示例3: AddToFigure
internal override void AddToFigure(
Matrix matrix, // The transformation matrix
PathFigure figure, // The figure to add to
ref Point current) // Out: Segment endpoint, not transformed
{
PointCollection points = Points;
if (points != null && points.Count >= 2)
{
if (matrix.IsIdentity)
{
figure.Segments.Add(this);
}
else
{
PointCollection copy = new PointCollection();
Point pt = new Point();
int count = points.Count;
for (int i=0; i<count; i++)
{
pt = points.Internal_GetItem(i);
pt *= matrix;
copy.Add(pt);
}
figure.Segments.Add(new PolyQuadraticBezierSegment(copy, IsStroked, IsSmoothJoin));
}
current = points.Internal_GetItem(points.Count - 1);
}
}
示例4: GetPathGeometry
internal static PathGeometry GetPathGeometry(ConnectorInfo source, ConnectorInfo sink)
{
var rectSource = GetRectWithMargin(source, 0);
var rectSink = GetRectWithMargin(sink, 13);
var startPoint = GetOffsetPoint(source, rectSource);
var endPoint = GetOffsetPoint(sink, rectSink);
var midpoint = CalculateMidpoint(startPoint, new Point(endPoint.X, startPoint.Y));
var distance = CalculateDistance(startPoint, midpoint);
var p1 = CalculateEndpoint(startPoint, distance, GetAngel(source.Orientation));
var p2 = CalculateEndpoint(endPoint, distance, GetAngel(sink.Orientation));
var p3 = endPoint;
var geometry = new PathGeometry();
var pathFigure = new PathFigure();
pathFigure.StartPoint = startPoint;
geometry.Figures.Add(pathFigure);
var bs = new BezierSegment(p1, p2, p3, true);
pathFigure.Segments.Add(bs);
return geometry;
}
示例5: Page_Loaded
/// <summary>
/// 页面加载
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Page_Loaded(object sender, RoutedEventArgs e)
{
IsVirtualMark = new SolidColorBrush(Properties.Settings.Default.MarkVirtualColor);
NotVirtualMark = new SolidColorBrush(Properties.Settings.Default.MarkNotColor);
MarkDiameter = Properties.Settings.Default.MarkDiameter;
RouteColor = new SolidColorBrush(Properties.Settings.Default.RouteColor);
EVirtualMark.Fill = IsVirtualMark;
ENotVirtualMark.Fill = NotVirtualMark;
RecRoute.Fill = RouteColor;
// Create the animation path.
path = new Path();
path.Stroke = RouteColor;
path.StrokeThickness = 3;
animationPath = new PathGeometry();
pFigure = new PathFigure();
route = new PolyLineSegment();
path.Data = animationPath;
pFigure.Segments.Add(route);
animationPath.Figures.Add(pFigure);
MapInit();
//修改日期:2013-12-1
//修改日期:2013-12-30
BindWorkLineCombox();
BindLineCombox(cbRoute_WorkLine.Text.Trim());
LoadAllMark();
}
示例6: DrawUnderlyingPolyline
internal static void DrawUnderlyingPolyline(PathGeometry pg, DEdge edge)
{
IEnumerable<WinPoint> points = edge.GeometryEdge.UnderlyingPolyline.Select(p => WinPoint(p));
PathFigure pf = new PathFigure() { IsFilled = false, IsClosed = false, StartPoint = points.First() };
foreach (WinPoint p in points)
{
if (p != points.First())
pf.Segments.Add(new WinLineSegment() { Point = p });
PathFigure circle = new PathFigure() { IsFilled = false, IsClosed = true, StartPoint = new WinPoint(p.X - edge.RadiusOfPolylineCorner, p.Y) };
circle.Segments.Add(
new ArcSegment()
{
Size = new WinSize(edge.RadiusOfPolylineCorner, edge.RadiusOfPolylineCorner),
SweepDirection = SweepDirection.Clockwise,
Point = new WinPoint(p.X + edge.RadiusOfPolylineCorner, p.Y)
});
circle.Segments.Add(
new ArcSegment()
{
Size = new WinSize(edge.RadiusOfPolylineCorner, edge.RadiusOfPolylineCorner),
SweepDirection = SweepDirection.Clockwise,
Point = new WinPoint(p.X - edge.RadiusOfPolylineCorner, p.Y)
});
pg.Figures.Add(circle);
}
pg.Figures.Add(pf);
}
示例7: Superposition
public Superposition()
{
InitializeComponent();
PathGeometry pathGeometry = new PathGeometry();
PathFigure pathFigure = new PathFigure();
pathFigure.StartPoint = new Point(0,0);
PathSegmentCollection pathSegmentCollection = new PathSegmentCollection();
int maxHeight = (int)this.Height;
int maxWidth = (int)this.Width;
Random rand = new Random();
for (int i = 0; i < 500; i++)
{
LineSegment newSegment = new LineSegment();
newSegment.Point = new Point(rand.Next(0, maxWidth), rand.Next(0, maxHeight));
pathSegmentCollection.Add(newSegment);
}
pathFigure.Segments = pathSegmentCollection;
pathGeometry.Figures.Add(pathFigure);
pathBackground.Data = pathGeometry;
}
示例8: AddRing
//private WpfPoint _lastPoint;
//internal void AddToRing(WpfPoint p, ref GraphicsPath ringPath)
//{
// if (ringPath == null)
// {
// ringPath = new GraphicsPath(FillMode.Alternate);
// ringPath.StartFigure();
// }
// else
// {
// ringPath.AddLine(_lastPoint, p);
// }
// _lastPoint = p;
//}
//internal void EndRing(GraphicsPath ringPath)
//{
// ringPath.CloseFigure();
// if (Path == null)
// Path = ringPath;
// else
// Path.AddPath(ringPath, false);
//}
///<summary>
/// Adds a <see cref="PathFigure"/> representing a polygon ring
/// having the given coordinate sequence to the supplied <see cref="pathGeometry"/>
///</summary>
///<param name="pathGeometry">The path geometry.</param>
///<param name="coordinates">A coordinate sequence</param>
///<returns>The path for the coordinate sequence</returns>
private static void AddRing(PathGeometry pathGeometry, Coordinate[] coordinates)
{
if (coordinates.Length <= 0)
return;
var figure = new PathFigure(ToPoint(coordinates[0]), ToPathSegments(coordinates), true);
pathGeometry.Figures.Add(figure);
}
示例9: AddArc
public PathFigure AddArc(int start, int end)
{
int horizontalPostion = 100;
var startPoint = new Point(horizontalPostion, start);
var endPoint = new Point(horizontalPostion, end);
PathFigure pathFigure = new PathFigure();
pathFigure.StartPoint = startPoint;
ArcSegment arcSeg = new ArcSegment();
arcSeg.Point = endPoint;
arcSeg.Size = new Size(25, 25);
arcSeg.IsLargeArc = true;
arcSeg.SweepDirection = SweepDirection.Clockwise;
arcSeg.RotationAngle = 90;
var arrowhead = new Polygon();
arrowhead.Stroke = Brushes.Black;
arrowhead.StrokeThickness = 2;
arrowhead.Points.Add(new Point(endPoint.X - 4, endPoint.Y));
arrowhead.Points.Add(new Point(endPoint.X + 4, endPoint.Y + 3));
arrowhead.Points.Add(new Point(endPoint.X + 4, endPoint.Y - 3));
arrowhead.Fill = Brushes.Black;
PathSegmentCollection myPathSegmentCollection = new PathSegmentCollection();
myPathSegmentCollection.Add(arcSeg);
pathFigure.Segments = myPathSegmentCollection;
_pathFigureCollection.Add(pathFigure);
_root.Children.Add(arrowhead);
return pathFigure;
}
示例10: geometryLine
public geometryLine(Canvas cvs)
{
rootPanel = cvs;
//myPathFigure = new PathFigure();
myPathGeometry = new PathGeometry();
//myPathGeometry.Figures.Add(myPathFigure);
myPath = new Path();
myPath.Stroke = Brushes.Blue;
myPath.StrokeThickness = 1;
myPath.Data = myPathGeometry;
rootPanel.Children.Add(myPath);
myPathFigureOld = new PathFigure();
myPathGeometryOld = new PathGeometry();
myPathGeometryOld.Figures.Add(myPathFigureOld);
myPathOld = new Path();
myPathOld.Stroke = Brushes.Blue;
myPathOld.StrokeThickness = 1;
myPathOld.Data = myPathGeometryOld;
rootPanel.Children.Add(myPathOld);
myPathFigureTest = new PathFigure();
myPathGeometry.Figures.Add(myPathFigureTest);
isFirstPoint = true;
}
示例11: SineCurve
// Constructor
public SineCurve()
{
polyLineSegment = new PolyLineSegment();
PathFigure = new PathFigure(new Point(), new PathSegment[] { polyLineSegment }, false);
pathGeometry = new PathGeometry(new PathFigure[] { PathFigure });
OnRedrawPropertyChanged(new DependencyPropertyChangedEventArgs());
}
示例12: GetShapeGeometry
public Geometry GetShapeGeometry()
{
PathFigure outer = new PathFigure();
outer.IsClosed = true;
outer.StartPoint = new Point(0, 2.5);
outer.Segments.Add(new LineSegment() { Point = new Point(2.5, 0) });
outer.Segments.Add(new LineSegment() { Point = new Point(5, 2.5) });
outer.Segments.Add(new LineSegment() { Point = new Point(7.5, 0) });
outer.Segments.Add(new LineSegment() { Point = new Point(10, 2.5) });
outer.Segments.Add(new LineSegment() { Point = new Point(9, 3.5) });
outer.Segments.Add(new LineSegment() { Point = new Point(7.5, 2) });
outer.Segments.Add(new LineSegment() { Point = new Point(6, 3.5) });
outer.Segments.Add(new LineSegment() { Point = new Point(8.5, 6) });
outer.Segments.Add(new LineSegment() { Point = new Point(5, 9.5) });
outer.Segments.Add(new LineSegment() { Point = new Point(1.5, 6) });
outer.Segments.Add(new LineSegment() { Point = new Point(4, 3.5) });
outer.Segments.Add(new LineSegment() { Point = new Point(2.5, 2) });
outer.Segments.Add(new LineSegment() { Point = new Point(1, 3.5) });
PathFigure inner = new PathFigure();
inner.StartPoint = new Point(3.5, 6);
inner.IsClosed = true;
inner.Segments.Add(new LineSegment() { Point = new Point(5, 7.5) });
inner.Segments.Add(new LineSegment() { Point = new Point(6.5, 6) });
inner.Segments.Add(new LineSegment() { Point = new Point(5, 4.5) });
PathGeometry logoGeometry = new PathGeometry();
logoGeometry.Figures.Add(inner);
logoGeometry.Figures.Add(outer);
return logoGeometry;
}
示例13: SetPlayShape
private void SetPlayShape()
{
play.Children.Clear ();
Path p = new Path();
PathGeometry geometry = new PathGeometry ();
PathFigure f = new PathFigure ();
f.Segments = new PathSegmentCollection ();
p.Data = geometry;
p.Fill = new SolidColorBrush(Colors.Red);
p.Stroke = new SolidColorBrush(Colors.Black);
geometry.Figures = new PathFigureCollection ();
geometry.Figures.Add(f);
LineSegment m = new LineSegment();
m.Point = new Point(3, 2);
f.Segments.Add(m);
m = new LineSegment();
m.Point = new Point(14, 8.5);
f.Segments.Add(m);
m = new LineSegment();
m.Point = new Point(3, 15);
f.Segments.Add(m);
m = new LineSegment();
m.Point = new Point(3, 2);
f.Segments.Add(m);
play.Children.Add(p);
}
示例14: GetPathFigureLength
internal static double GetPathFigureLength(PathFigure pathFigure)
{
if (pathFigure == null)
return 0;
var isAlreadyFlattened = pathFigure.Segments.All(pathSegment => (pathSegment is PolyLineSegment) || (pathSegment is LineSegment));
var pathFigureFlattened = isAlreadyFlattened ? pathFigure : pathFigure.GetFlattenedPathFigure();
double length = 0;
var pt1 = pathFigureFlattened.StartPoint;
foreach (var pathSegment in pathFigureFlattened.Segments)
{
if (pathSegment is LineSegment)
{
var pt2 = ((LineSegment)pathSegment).Point;
length += (pt2 - pt1).Length;
pt1 = pt2;
}
else if (pathSegment is PolyLineSegment)
{
var pointCollection = ((PolyLineSegment)pathSegment).Points;
foreach (var pt2 in pointCollection)
{
length += (pt2 - pt1).Length;
pt1 = pt2;
}
}
}
return length;
}
示例15: CreateShape
/// <summary>
/// This is where the arrow shape is created.
/// </summary>
/// <returns></returns>
private Geometry CreateShape()
{
double width = _rect.Width;
double height = _rect.Height;
double borderOffset = GetStrokeThickness() / 2d;
PathGeometry g = new PathGeometry();
PathFigure figure = new PathFigure();
figure.IsClosed = true;
figure.StartPoint = new Point(borderOffset, borderOffset);
figure.Segments.Add(new LineSegment(new Point(width - TipOffset + borderOffset, borderOffset), true));
figure.Segments.Add(new LineSegment(new Point(width + borderOffset, height / 2d + borderOffset), true));
figure.Segments.Add(new LineSegment(new Point(width + borderOffset - TipOffset, height + borderOffset), true));
figure.Segments.Add(new LineSegment(new Point(borderOffset, height + borderOffset), true));
g.Figures.Add(figure);
return g;
}