本文整理汇总了C#中Segment.Center方法的典型用法代码示例。如果您正苦于以下问题:C# Segment.Center方法的具体用法?C# Segment.Center怎么用?C# Segment.Center使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Segment
的用法示例。
在下文中一共展示了Segment.Center方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: addTitleBufferElement
private void addTitleBufferElement(Graphics g, Feature feature, TitleStyle titleStyle, BoundingRectangle viewBox, double scaleFactor)
{
ICoordinate targetCoordinate = PlanimetryEnvironment.NewCoordinate(0, 0);
Segment s;
SizeF size;
using (Font f = titleStyle.GetFont())
size = g.MeasureString(feature.Title, f, new PointF(0, 0), _titleStringFormat);
switch (feature.FeatureType)
{
case FeatureType.Polyline:
if (!titleStyle.LeadAlong)
{
foreach (LinePath path in feature.Polyline.Paths)
{
if (path.Vertices.Count > 2)
targetCoordinate = path.Vertices[path.Vertices.Count / 2 - 1];
else
{
s = new Segment(path.Vertices[0].X, path.Vertices[0].Y,
path.Vertices[1].X, path.Vertices[1].Y);
targetCoordinate = s.Center();
}
addTitleBufferElement(titleStyle, targetCoordinate, size, scaleFactor, feature);
}
}
else
{
int i = 0;
foreach (LinePath path in feature.Polyline.Paths)
{
FollowingTitle followingTitle =
getFollowingTitle(g, path, feature.PolylinePartLengths[i], feature.Title, titleStyle, viewBox, scaleFactor);
if (followingTitle != null)
_titleBuffer.Add(new TitleBufferElement(followingTitle, titleStyle, _titleCount++));
i++;
}
}
return;
case FeatureType.Polygon:
//if (feature.Polygon.Contours.Count > 0)
// targetPoint = feature.Polygon.Contours[0].RibsCentroid();
//else
// return;
//break;
if (feature.Polygon.Contours.Count > 0)
try
{
targetCoordinate = feature.Polygon.PointOnSurface();
}
catch(InvalidOperationException)
{
//interior point of the polygon for some reason (usually singular) can not be found
return;
}
else
return;
break;
case FeatureType.Point:
targetCoordinate = feature.Point.Coordinate;
//targetPoint.Y += size.Height / scaleFactor / 2;
break;
case FeatureType.MultiPoint:
if (titleStyle.LeadAlong)
{
foreach (ICoordinate p in feature.MultiPoint.Points)
{
targetCoordinate = p;
targetCoordinate.Y += size.Height / scaleFactor / 2;
addTitleBufferElement(titleStyle, targetCoordinate, size, scaleFactor, feature);
}
return;
}
else
targetCoordinate = PlanimetryAlgorithms.GetCentroid(feature.MultiPoint.Points);
break;
}
addTitleBufferElement(titleStyle, targetCoordinate, size, scaleFactor, feature);
}