本文整理汇总了C#中System.Windows.Media.PointCollection.get_Count方法的典型用法代码示例。如果您正苦于以下问题:C# PointCollection.get_Count方法的具体用法?C# PointCollection.get_Count怎么用?C# PointCollection.get_Count使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Media.PointCollection
的用法示例。
在下文中一共展示了PointCollection.get_Count方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ClipPolygon
private PointCollection ClipPolygon(Polygon polygon, double Left, double Top, double Right, double Bottom)
{
Point point;
Point point2;
PointCollection clippedPolygon = new PointCollection();
double xTop = 0.0;
double yLeft = 0.0;
double xBottom = 0.0;
double yRight = 0.0;
int num5 = 0;
int num6 = -1;
double num7 = 0.0;
double num8 = 0.0;
double num9 = 0.0;
double num10 = 0.0;
for (int i = 0; i < polygon.get_Points().get_Count(); i++)
{
point = polygon.get_Points().get_Item(i);
if (point.get_X() < num7)
{
num7 = point.get_X();
}
if (point.get_X() > num8)
{
num8 = point.get_X();
}
if (point.get_Y() < num9)
{
num9 = point.get_Y();
}
if (point.get_Y() > num10)
{
num10 = point.get_Y();
}
if (((Left <= point.get_X()) && (point.get_X() <= Right)) && ((Top <= point.get_Y()) && (point.get_Y() <= Bottom)))
{
num6 = i;
break;
}
}
if (num6 == -1)
{
for (int k = 0; k < polygon.get_Points().get_Count(); k++)
{
point = polygon.get_Points().get_Item(k);
point2 = (k == (polygon.get_Points().get_Count() - 1)) ? polygon.get_Points().get_Item(0) : polygon.get_Points().get_Item(k + 1);
this.CalculateLineIntersection(point, point2, ref yLeft, ref xTop, ref yRight, ref xBottom, Left, Top, Right, Bottom);
if (((((Top <= yLeft) && (yLeft <= Bottom)) && (((point.get_X() < Left) && (Left < point2.get_X())) || ((point2.get_X() < Left) && (Left < point.get_X())))) || (((Left <= xTop) && (xTop <= Right)) && (((point.get_Y() < Top) && (Top < point2.get_Y())) || ((point2.get_Y() < Top) && (Top < point.get_Y()))))) || ((((Top <= yRight) && (yRight <= Bottom)) && (((point.get_X() < Right) && (Right < point2.get_X())) || ((point2.get_X() < Right) && (Right < point.get_X())))) || (((Left <= xBottom) && (xBottom <= Right)) && (((point.get_Y() < Bottom) && (Bottom < point2.get_Y())) || ((point2.get_Y() < Bottom) && (Bottom < point.get_Y()))))))
{
this.ClipLine(point, point2, yLeft, xTop, yRight, xBottom, Left, Top, Right, Bottom, ref clippedPolygon);
num5 = clippedPolygon.get_Count();
num6 = (k == (polygon.get_Points().get_Count() - 1)) ? 0 : (k + 1);
break;
}
}
}
if (num6 == -1)
{
if (((num7 <= Left) && (Right <= num8)) && ((num9 <= Top) && (Bottom <= num10)))
{
clippedPolygon.Add(new Point(Left, Top));
clippedPolygon.Add(new Point(Right, Top));
clippedPolygon.Add(new Point(Right, Bottom));
clippedPolygon.Add(new Point(Left, Bottom));
}
return clippedPolygon;
}
for (int j = num6; j < (polygon.get_Points().get_Count() + num6); j++)
{
point = polygon.get_Points().get_Item((j < polygon.get_Points().get_Count()) ? j : (j - polygon.get_Points().get_Count()));
point2 = ((j + 1) < polygon.get_Points().get_Count()) ? polygon.get_Points().get_Item(j + 1) : polygon.get_Points().get_Item((j + 1) - polygon.get_Points().get_Count());
this.CalculateLineIntersection(point, point2, ref yLeft, ref xTop, ref yRight, ref xBottom, Left, Top, Right, Bottom);
if (((Left <= point.get_X()) && (point.get_X() <= Right)) && ((Top <= point.get_Y()) && (point.get_Y() <= Bottom)))
{
if (((clippedPolygon.get_Count() == 0) || (clippedPolygon.get_Item(clippedPolygon.get_Count() - 1).get_X() != point.get_X())) || (clippedPolygon.get_Item(clippedPolygon.get_Count() - 1).get_Y() != point.get_Y()))
{
clippedPolygon.Add(point);
}
if (((point2.get_X() < Left) || (Right < point2.get_X())) || ((point2.get_Y() < Top) || (Bottom < point2.get_Y())))
{
if (((Top <= yLeft) && (yLeft <= Bottom)) && ((point2.get_X() < Left) && (Left < point.get_X())))
{
clippedPolygon.Add(new Point(Left, yLeft));
}
else if (((Left <= xTop) && (xTop <= Right)) && ((point2.get_Y() < Top) && (Top < point.get_Y())))
{
clippedPolygon.Add(new Point(xTop, Top));
}
else if (((Top <= yRight) && (yRight <= Bottom)) && ((point.get_X() < Right) && (Right < point2.get_X())))
{
clippedPolygon.Add(new Point(Right, yRight));
}
else if (((Left <= xBottom) && (xBottom <= Right)) && ((point.get_Y() < Bottom) && (Bottom < point2.get_Y())))
{
clippedPolygon.Add(new Point(xBottom, Bottom));
}
}
}
else
{
//.........这里部分代码省略.........
示例2: ClipLine
private void ClipLine(Point point, Point NextPoint, double yLeft, double xTop, double yRight, double xBottom, double Left, double Top, double Right, double Bottom, ref PointCollection ClippedPolygon)
{
if ((xTop == Left) && (yLeft == Top))
{
if (((ClippedPolygon.get_Count() == 0) || (ClippedPolygon.get_Item(ClippedPolygon.get_Count() - 1).get_X() != Left)) || (ClippedPolygon.get_Item(ClippedPolygon.get_Count() - 1).get_Y() != Top))
{
ClippedPolygon.Add(new Point(Left, Top));
}
}
else if ((xTop == Right) && (yRight == Top))
{
if (((ClippedPolygon.get_Count() == 0) || (ClippedPolygon.get_Item(ClippedPolygon.get_Count() - 1).get_X() != Right)) || (ClippedPolygon.get_Item(ClippedPolygon.get_Count() - 1).get_Y() != Top))
{
ClippedPolygon.Add(new Point(Right, Top));
}
}
else if ((xBottom == Right) && (yRight == Bottom))
{
if (((ClippedPolygon.get_Count() == 0) || (ClippedPolygon.get_Item(ClippedPolygon.get_Count() - 1).get_X() != Right)) || (ClippedPolygon.get_Item(ClippedPolygon.get_Count() - 1).get_Y() != Bottom))
{
ClippedPolygon.Add(new Point(Right, Bottom));
}
}
else if ((xBottom == Left) && (yLeft == Bottom))
{
if (((ClippedPolygon.get_Count() == 0) || (ClippedPolygon.get_Item(ClippedPolygon.get_Count() - 1).get_X() != Left)) || (ClippedPolygon.get_Item(ClippedPolygon.get_Count() - 1).get_Y() != Bottom))
{
ClippedPolygon.Add(new Point(Left, Bottom));
}
}
else if (((Top <= yLeft) && (yLeft <= Bottom)) && ((Left <= xTop) && (xTop <= Right)))
{
if (((point.get_X() < Left) && (point.get_Y() > Top)) && ((NextPoint.get_X() > Left) && (NextPoint.get_Y() < Top)))
{
ClippedPolygon.Add(new Point(Left, yLeft));
ClippedPolygon.Add(new Point(xTop, Top));
}
else if (((point.get_X() > Left) && (point.get_Y() < Top)) && ((NextPoint.get_Y() > Top) && (NextPoint.get_X() < Left)))
{
ClippedPolygon.Add(new Point(xTop, Top));
ClippedPolygon.Add(new Point(Left, yLeft));
}
}
else if (((Left <= xTop) && (xTop <= Right)) && ((Top <= yRight) && (yRight <= Bottom)))
{
if (((point.get_X() > Right) && (point.get_Y() > Top)) && ((NextPoint.get_X() < Right) && (NextPoint.get_Y() < Top)))
{
ClippedPolygon.Add(new Point(Right, yRight));
ClippedPolygon.Add(new Point(xTop, Top));
}
else if (((point.get_X() < Right) && (point.get_Y() < Top)) && ((NextPoint.get_X() > Right) && (NextPoint.get_Y() > Top)))
{
ClippedPolygon.Add(new Point(xTop, Top));
ClippedPolygon.Add(new Point(Right, yRight));
}
}
else if (((Left <= xBottom) && (xBottom <= Right)) && ((Top <= yRight) && (yRight <= Bottom)))
{
if (((point.get_X() > Right) && (point.get_Y() < Bottom)) && ((NextPoint.get_X() < Right) && (NextPoint.get_Y() > Bottom)))
{
ClippedPolygon.Add(new Point(Right, yRight));
ClippedPolygon.Add(new Point(xBottom, Bottom));
}
else if (((point.get_X() < Right) && (point.get_Y() > Bottom)) && ((NextPoint.get_X() > Right) && (NextPoint.get_Y() < Bottom)))
{
ClippedPolygon.Add(new Point(xBottom, Bottom));
ClippedPolygon.Add(new Point(Right, yRight));
}
}
else if (((Left <= xBottom) && (xBottom <= Right)) && ((Top <= yLeft) && (yLeft <= Bottom)))
{
if (((point.get_X() < Left) && (point.get_Y() < Bottom)) && ((NextPoint.get_X() > Left) && (NextPoint.get_Y() > Bottom)))
{
ClippedPolygon.Add(new Point(Left, yLeft));
ClippedPolygon.Add(new Point(xBottom, Bottom));
}
else if (((point.get_X() > Left) && (point.get_Y() > Bottom)) && ((NextPoint.get_X() < Left) && (NextPoint.get_Y() < Bottom)))
{
ClippedPolygon.Add(new Point(xBottom, Bottom));
ClippedPolygon.Add(new Point(Left, yLeft));
}
}
else if (((Left <= xTop) && (xTop <= Right)) && ((Left <= xBottom) && (xBottom <= Right)))
{
if ((point.get_Y() < Top) && (NextPoint.get_Y() > Bottom))
{
ClippedPolygon.Add(new Point(xTop, Top));
ClippedPolygon.Add(new Point(xBottom, Bottom));
}
else if ((point.get_Y() > Bottom) && (NextPoint.get_Y() < Top))
{
ClippedPolygon.Add(new Point(xBottom, Bottom));
ClippedPolygon.Add(new Point(xTop, Top));
}
}
else if (((Top <= yLeft) && (yLeft <= Bottom)) && ((Top <= yRight) && (yRight <= Bottom)))
{
if ((point.get_X() < Left) && (NextPoint.get_X() > Right))
{
ClippedPolygon.Add(new Point(Left, yLeft));
//.........这里部分代码省略.........