本文整理汇总了C#中System.Windows.Media.PathFigure类的典型用法代码示例。如果您正苦于以下问题:C# PathFigure类的具体用法?C# PathFigure怎么用?C# PathFigure使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PathFigure类属于System.Windows.Media命名空间,在下文中一共展示了PathFigure类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
开发者ID:Eddie104,项目名称:Libra-CSharp,代码行数:34,代码来源:GraphicsHelper.cs
示例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);
}
开发者ID:PlastecProfiles,项目名称:ComputationalGeometry,代码行数:28,代码来源:MainWindow.xaml.cs
示例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);
}
}
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:31,代码来源:PolyQuadraticBezierSegmentFigureLogic.cs
示例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;
}
开发者ID:NKnusperer,项目名称:DEISE,代码行数:26,代码来源:PathFinder.cs
示例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();
}
开发者ID:qq5013,项目名称:AGV_Server,代码行数:31,代码来源:RouteManage.xaml.cs
示例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);
}
开发者ID:mrkcass,项目名称:SuffixTreeExplorer,代码行数:27,代码来源:Draw.cs
示例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;
}
开发者ID:Corantin,项目名称:Cegep,代码行数:28,代码来源:Superposition.xaml.cs
示例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);
}
开发者ID:Walt-D-Cat,项目名称:NetTopologySuite,代码行数:38,代码来源:PolygonWpfPathGeometry.cs
示例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;
}
开发者ID:pottereric,项目名称:Synopsis,代码行数:35,代码来源:ArcAdder.cs
示例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;
}
开发者ID:hehaiyang7133862,项目名称:VICO_Current,代码行数:28,代码来源:geometryLine.cs
示例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());
}
开发者ID:CodeByBerglund,项目名称:nai-framework,代码行数:8,代码来源:SineCurve.cs
示例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;
}
开发者ID:Motaz-Al-Zoubi,项目名称:xaml-sdk,代码行数:32,代码来源:TelerikLogo.cs
示例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);
}
开发者ID:dfr0,项目名称:moon,代码行数:33,代码来源:video-player.cs
示例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;
}
开发者ID:bisato,项目名称:DW.WPFToolkit,代码行数:31,代码来源:PathCalculator.cs
示例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;
}
开发者ID:andyyou,项目名称:WPF-samples,代码行数:31,代码来源:Custom.cs
示例16: RenderPolygon
private void RenderPolygon(DrawingContext drawingContext)
{
var fillBrush = Brushes.LawnGreen;
var borderPen = new Pen(Brushes.Black,1.0);
PathFigure myPathFigure = new PathFigure();
myPathFigure.StartPoint = maxPoints[0];
//PolyLineSegment seg = new PolyLineSegment(
PathSegmentCollection myPathSegmentCollection = new PathSegmentCollection();
for (int i = 1; i < maxPoints.Count; i++)
{
myPathSegmentCollection.Add(new LineSegment(maxPoints[i], true));
}
for (int i = minPoints.Count - 1; i >= 0; i--)
{
myPathSegmentCollection.Add(new LineSegment(minPoints[i], true));
}
myPathFigure.Segments = myPathSegmentCollection;
PathGeometry myPathGeometry = new PathGeometry();
myPathGeometry.Figures.Add(myPathFigure);
drawingContext.DrawGeometry(fillBrush, borderPen, myPathGeometry);
}
开发者ID:ActivePHOENiX,项目名称:NAudio,代码行数:28,代码来源:WaveformVisual.cs
示例17: Triangle
public Triangle()
{
InitializeComponent();
l1 = new LineSegment();
l2 = new LineSegment();
f = new PathFigure();
f.Segments.Add(l1);
f.Segments.Add(l2);
f.IsClosed = true;
PathGeometry g = new PathGeometry();
g.Figures.Add(f);
Path p = new Path();
this.SetBinding(FillProperty, new Binding("Fill") { Source = p, Mode = BindingMode.TwoWay });
this.SetBinding(StrokeProperty, new Binding("Stroke") { Source = p, Mode = BindingMode.TwoWay });
this.SetBinding(StrokeThicknessProperty, new Binding("StrokeThickness") { Source = p, Mode = BindingMode.TwoWay });
p.Data = g;
this.Fill = new SolidColorBrush(Colors.White);
this.Stroke = new SolidColorBrush(Colors.Black);
this.LayoutRoot.Children.Add(p);
}
开发者ID:satomacoto,项目名称:Silverlight-Graph,代码行数:26,代码来源:Triangle.xaml.cs
示例18: OnRender
protected override void OnRender(System.Windows.Media.DrawingContext drawingContext)
{
base.OnRender(drawingContext);
// allows the points to be rendered as an image that can be further manipulated
PathGeometry geometry = new PathGeometry();
this.Siz
// Add all points to the geometry
foreach (Points pointXY in _points)
{
PathFigure figure = new PathFigure();
figure.StartPoint = pointXY.FromPoint;
figure.Segments.Add(new LineSegment(pointXY.ToPoint, true));
geometry.Figures.Add(figure);
}
// Add the first point to close the gap from the graph's end point
// to graph's start point
PathFigure lastFigure = new PathFigure();
lastFigure.StartPoint = _points[_points.Count - 1].FromPoint;
lastFigure.Segments.Add(new LineSegment(_firstPoint, true));
geometry.Figures.Add(lastFigure);
// Create a new drawing and drawing group in order to apply
// a custom drawing effect
GeometryDrawing drawing = new GeometryDrawing(this.Pen.Brush, this.Pen, geometry);
DrawingGroup drawingGroup = new DrawingGroup();
drawingGroup.Children.Add(drawing);
}
开发者ID:valentine-palazkov,项目名称:tictactoe-wpf,代码行数:32,代码来源:BoardCellView.xaml.cs
示例19: GetPathFigure
public PathFigure GetPathFigure(Point start, Point end)
{
var tickFigure = new PathFigure();
tickFigure.StartPoint = start;
tickFigure.Segments.Add(new LineSegment { Point = end });
return tickFigure;
}
开发者ID:garyjohnson,项目名称:wpnest,代码行数:7,代码来源:ThermostatTickCreator.cs
示例20: StartDrawItem
public void StartDrawItem(DesignItem clickedOn, Type createItemType, IDesignPanel panel, System.Windows.Input.MouseEventArgs e)
{
var createdItem = CreateItem(panel.Context, createItemType);
var startPoint = e.GetPosition(clickedOn.View);
var operation = PlacementOperation.TryStartInsertNewComponents(clickedOn,
new DesignItem[] { createdItem },
new Rect[] { new Rect(startPoint.X, startPoint.Y, double.NaN, double.NaN) },
PlacementType.AddItem);
if (operation != null) {
createdItem.Services.Selection.SetSelectedComponents(new DesignItem[] { createdItem });
operation.Commit();
}
createdItem.Properties[Shape.StrokeProperty].SetValue(Brushes.Black);
createdItem.Properties[Shape.StrokeThicknessProperty].SetValue(2d);
createdItem.Properties[Shape.StretchProperty].SetValue(Stretch.None);
var figure = new PathFigure();
var geometry = new PathGeometry();
var geometryDesignItem = createdItem.Services.Component.RegisterComponentForDesigner(geometry);
var figureDesignItem = createdItem.Services.Component.RegisterComponentForDesigner(figure);
createdItem.Properties[Path.DataProperty].SetValue(geometry);
//geometryDesignItem.Properties[PathGeometry.FiguresProperty].CollectionElements.Add(figureDesignItem);
figureDesignItem.Properties[PathFigure.StartPointProperty].SetValue(new Point(0,0));
new DrawPathMouseGesture(figure, createdItem, clickedOn.View, changeGroup, this.ExtendedItem.GetCompleteAppliedTransformationToView()).Start(panel, (MouseButtonEventArgs) e);
}
开发者ID:modulexcite,项目名称:WpfDesigner,代码行数:28,代码来源:DrawPathExtension.cs
注:本文中的System.Windows.Media.PathFigure类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论