当前位置: 首页>>代码示例>>C#>>正文


C# Segment.Center方法代码示例

本文整理汇总了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);
        }
开发者ID:gkrsu,项目名称:maparound.core,代码行数:84,代码来源:FeatureRendering.cs


注:本文中的Segment.Center方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。