本文整理汇总了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);
}
示例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);
}
}
示例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);
}
}
示例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;
}
});
}
}