本文整理汇总了C#中System.Windows.Media.Geometry.GetWidenedPathGeometry方法的典型用法代码示例。如果您正苦于以下问题:C# Geometry.GetWidenedPathGeometry方法的具体用法?C# Geometry.GetWidenedPathGeometry怎么用?C# Geometry.GetWidenedPathGeometry使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Media.Geometry
的用法示例。
在下文中一共展示了Geometry.GetWidenedPathGeometry方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: collisionDetect
/// <summary>
/// test collision between two Geometry object
/// </summary>
/// <param name="firstGeometry">first Geometry</param>
/// <param name="secondGeometry">second Geometry</param>
/// <returns>intersection Points</returns>
private Point[] collisionDetect(Geometry firstGeometry, Geometry secondGeometry)
{
Geometry firstPathGeometry = firstGeometry.GetWidenedPathGeometry(new Pen(Brushes.Black, 1.0)); //retrieve PathGeometry class, inherit from Geometry Class
Geometry secondPathGeometry = secondGeometry.GetWidenedPathGeometry(new Pen(Brushes.Black, 1.0));
CombinedGeometry combGeometry = new CombinedGeometry(GeometryCombineMode.Intersect, firstPathGeometry, secondPathGeometry); //inherit from Geometry
PathGeometry combPathGeometry = combGeometry.GetFlattenedPathGeometry();
/*code below retrieve all intersection points of 2 geometry*/
//combPathGeometry.Figures rappresenta una serie di piccoli segmenti geometrici che compongono la geometria
Point[] intersectionPoints = new Point[combPathGeometry.Figures.Count];
//ho inizializzato un'array di punti, però bisogna ancora trovare le coordinate di ognuno di essi
for (int i = 0; i < combPathGeometry.Figures.Count; i++)
{
//crea una piccola geometria a partire dal segmento trovato e ritorna il suo bounding box rettangolare
Rect fig = new PathGeometry(new PathFigure[] { combPathGeometry.Figures[i] }).Bounds;
//trova il punto centrale a partire da questo rettangolo
intersectionPoints[i] = new Point(fig.Left + fig.Width / 2.0, fig.Top + fig.Height / 2.0);
}
return intersectionPoints;
}