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


C# Element.Flatten方法代码示例

本文整理汇总了C#中Element.Flatten方法的典型用法代码示例。如果您正苦于以下问题:C# Element.Flatten方法的具体用法?C# Element.Flatten怎么用?C# Element.Flatten使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Element的用法示例。


在下文中一共展示了Element.Flatten方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: FindCheckpoints

 private void FindCheckpoints(Element root, List<CheckpointLocation> locations)
 {
     foreach (Element e in root.Flatten())
       {
     if (e is Placemark)
       FindCheckpoints((Placemark)e, locations);
       }
       //if (e is Document)
       //  FindCheckpoints((Document)e, locations);
       //else if (e is Folder)
       //  FindCheckpoints((Folder)e, locations);
 }
开发者ID:JornWildt,项目名称:racetrack,代码行数:12,代码来源:CheckpointLocationsLoader.cs

示例2: ExtractGeometries

        public void ExtractGeometries(Element kml)
        {
            _geometrys = new Dictionary<Placemark, List<IGeometry>>();

            //todo handle other geom types
            foreach (var f in kml.Flatten().OfType<Polygon>())
            {
                ProcessPolygonGeometry(f);
            }

            foreach (var f in kml.Flatten().OfType<LineString>())
            {
                ProcessLineStringGeometry(f);
            }

            foreach (var f in kml.Flatten().OfType<Point>())
            {
                ProcessPointGeometry(f);
            }

            foreach (var f in kml.Flatten().OfType<LinearRing>())
            {
                ProcessLinearRingGeometry(f);
            }

            foreach (var f in kml.Flatten().OfType<MultipleGeometry>())
            {
                ProcessMuiltipleGeometry(f);
            }
        }
开发者ID:geobabbler,项目名称:SharpMap,代码行数:30,代码来源:KmlProvider.cs

示例3: ExtractStyles

        //todo needs buffing up
        private void ExtractStyles(Element kml)
        {
            _kmlStyles = new Dictionary<string, VectorStyle>();

            _kmlStyles.Add(DefaultStyleId, DefaultVectorStyle());
            _kmlStyles.Add(DefaultPointStyleId, DefaultPointStyle());

            foreach (var style in kml.Flatten().OfType<Style>())
            {
                if (string.IsNullOrEmpty(style.Id))
                    continue;

                var vectorStyle = new VectorStyle();
                vectorStyle.Enabled = true;

                if (style.Polygon != null)
                {

                    if (style.Polygon.Fill != null)
                    {
                        if (style.Polygon.Fill.Value)
                        {
                            var color = new SolidBrush(Color.FromArgb(style.Polygon.Color.Value.Argb));
                            //fill the polygon
                            vectorStyle.Fill = color;
                            vectorStyle.PointColor = color; //Color.FromArgb(100, color.R, color.G, color.B)
                        }
                        else
                        {
                            //don't fill it 
                            var color = new SolidBrush(Color.Transparent);
                            vectorStyle.Fill = color; //Color.FromArgb(100, color.R, color.G, color.B)
                            vectorStyle.PointColor = color;
                        }
                    }
                    else
                    {
                        var color = new SolidBrush(Color.FromArgb(style.Polygon.Color.Value.Argb));
                        //fill the polygon
                        vectorStyle.Fill = color;
                        vectorStyle.PointColor = color; //Color.FromArgb(100, color.R, color.G, color.B)
                    }

                    vectorStyle.EnableOutline = true;
                }

                if (style.Line != null)
                {
                    if (style.Line.Width != null)
                    {
                        var linePen = new Pen(
                            Color.FromArgb(style.Line.Color != null
                                ? style.Line.Color.Value.Argb
                                : Color.Black.ToArgb()), (float)style.Line.Width);

                        vectorStyle.Line = linePen;
                        vectorStyle.Outline = linePen;
                    }
                }

                try
                {
                    var symbolDict = new Dictionary<string, Image>();

                    if (style.Icon != null && style.Icon.Icon != null && style.Icon.Icon.Href != null)
                    {
                        if (symbolDict.ContainsKey(style.Icon.Icon.Href.ToString()))
                        {
                            vectorStyle.Symbol = symbolDict[style.Icon.Icon.Href.ToString()];
                        }
                        else
                        {
                            var newSymbol = GetImageFromUrl(style.Icon.Icon.Href);
                            symbolDict.Add(style.Icon.Icon.Href.ToString(), newSymbol);
                            vectorStyle.Symbol = newSymbol;
                        }

                        vectorStyle.SymbolScale = 1f;
                    }
                }
                catch (Exception ex)
                {

                    Trace.WriteLine(ex.Message);
                }


                _kmlStyles.Add(style.Id, vectorStyle);

            }
        }
开发者ID:geobabbler,项目名称:SharpMap,代码行数:92,代码来源:KmlProvider.cs

示例4: ExtractStyleMaps

        private void ExtractStyleMaps(Element kml)
        {
            _styleMaps = new List<StyleMap>();
            foreach (var style in kml.Flatten().OfType<StyleMapCollection>())
            {
                var styleMap = new StyleMap { Id = style.Id };
                _styleMaps.Add(styleMap);
                style.ToList().ForEach(x =>
                {
                    if (x.State != null)

                        switch (x.State.Value)
                        {
                            case StyleState.Normal:
                                styleMap.NormalStyleUrl = x.StyleUrl.ToString().Replace("#", "");
                                break;
                            case StyleState.Highlight:
                                styleMap.HighlightStyleUrl = x.StyleUrl.ToString().Replace("#", "");
                                break;
                        }

                });
            }
        }
开发者ID:geobabbler,项目名称:SharpMap,代码行数:24,代码来源:KmlProvider.cs


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