本文整理汇总了C#中ITheme.GetStyle方法的典型用法代码示例。如果您正苦于以下问题:C# ITheme.GetStyle方法的具体用法?C# ITheme.GetStyle怎么用?C# ITheme.GetStyle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ITheme
的用法示例。
在下文中一共展示了ITheme.GetStyle方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateStyleMethod
private static Func<IFeature, IStyle> CreateStyleMethod(IStyle style, ITheme theme)
{
if (theme == null)
return (row) => style;
else
return (row) => theme.GetStyle(row);
}
示例2: DrawSegment
private static void DrawSegment(VectorLayer segmentsLayer, INetworkCoverage coverage, ITheme theme, int segmentNumber, IList<double> allBranchLocationValues, bool firstSegment, bool lastSegment, Graphics graphics, INetworkSegment segment, VectorStyle defaultStyle, double offset)
{
var valueAtStart = allBranchLocationValues[segmentNumber * 2];
var value = allBranchLocationValues[segmentNumber * 2 + 1];
var valueAtEnd = allBranchLocationValues[segmentNumber * 2 + 2];
// extract based on valueAtStart and valueAtEnd the colors from the
var styleStart = (theme != null) ? (VectorStyle)theme.GetStyle(valueAtStart) : segmentsLayer.Style;
var themeStyle = (theme != null) ? (VectorStyle)theme.GetStyle(value) : segmentsLayer.Style;
var styleEnd = (theme != null) ? (VectorStyle)theme.GetStyle(valueAtEnd) : segmentsLayer.Style;
// check if within limits (preventing GDI+ overflow on 'ultrazoom')
var strokes = Transform.TransformToImage((ILineString)segment.Geometry, segmentsLayer.Map);
if (strokes.Any(s => !graphics.ClipBounds.Contains(s))) return;
if (firstSegment && lastSegment)
{
// 1 segment; render segement based on coverage.Locations.InterpolationType
if (coverage.Locations.ExtrapolationType == ExtrapolationType.None)
{
VectorRenderingHelper.RenderGeometry(graphics, segmentsLayer.Map, segment.Geometry, defaultStyle, null,
true);
return;
}
if (coverage.Locations.ExtrapolationType == ExtrapolationType.Linear)
{
VectorRenderingHelper.RenderGeometry(graphics, segmentsLayer.Map, segment.Geometry, themeStyle, null, true);
return;
}
// todo use proper colors/styles from Theme; now 'via' styles are ignored.
var kcolors = new[]
{
((SolidBrush) styleStart.Fill).Color, ((SolidBrush) themeStyle.Fill).Color,
((SolidBrush) styleEnd.Fill).Color
};
var kpositions = new[] { 0.0F, (float)((offset - segment.Chainage) / segment.Length), 1.0F };
DrawStrokesLinear(graphics, strokes, (int)themeStyle.Line.Width, kcolors, kpositions);
return;
}
var positions = new[]
{
0.0F, (float) ((offset - segment.Chainage)/segment.Length),
(float) ((offset - segment.Chainage)/segment.Length), 1.0F
};
var colors = CreateBeginEndColors(coverage, firstSegment, lastSegment, GetStyleColor(themeStyle), GetStyleColor(styleStart), GetStyleColor(styleEnd), GetStyleColor(defaultStyle));
// todo use proper colors/styles from Theme; now 'via' styles are ignored.
if (!segment.Geometry.IsEmpty)
{
DrawStrokesLinear(graphics, strokes, (int)themeStyle.Line.Width, colors, positions);
}
}
示例3: RenderInternal
/// <summary>
/// Method to render this layer to the map, applying <paramref name="theme"/>.
/// </summary>
/// <param name="g">The graphics object</param>
/// <param name="map">The map object</param>
/// <param name="envelope">The envelope to render</param>
/// <param name="theme">The theme to apply</param>
protected void RenderInternal(Graphics g, Map map, Envelope envelope, ITheme theme)
{
var ds = new FeatureDataSet();
lock (_dataSource)
{
DataSource.Open();
DataSource.ExecuteIntersectionQuery(envelope, ds);
DataSource.Close();
}
double scale = map.MapScale;
double zoom = map.Zoom;
foreach (FeatureDataTable features in ds.Tables)
{
// Transform geometries if necessary
if (CoordinateTransformation != null)
{
for (int i = 0; i < features.Count; i++)
{
features[i].Geometry = ToTarget(features[i].Geometry);
}
}
//Linestring outlines is drawn by drawing the layer once with a thicker line
//before drawing the "inline" on top.
if (Style.EnableOutline)
{
for (int i = 0; i < features.Count; i++)
{
var feature = features[i];
var outlineStyle = theme.GetStyle(feature) as VectorStyle;
if (outlineStyle == null) continue;
if (!(outlineStyle.Enabled && outlineStyle.EnableOutline)) continue;
double compare = outlineStyle.VisibilityUnits == VisibilityUnits.ZoomLevel ? zoom : scale;
if (!(outlineStyle.MinVisible <= compare && compare <= outlineStyle.MaxVisible)) continue;
using (outlineStyle = outlineStyle.Clone())
{
if (outlineStyle != null)
{
//Draw background of all line-outlines first
if (feature.Geometry is ILineString)
{
VectorRenderer.DrawLineString(g, feature.Geometry as ILineString, outlineStyle.Outline,
map, outlineStyle.LineOffset);
}
else if (feature.Geometry is IMultiLineString)
{
VectorRenderer.DrawMultiLineString(g, feature.Geometry as IMultiLineString,
outlineStyle.Outline, map, outlineStyle.LineOffset);
}
}
}
}
}
for (int i = 0; i < features.Count; i++)
{
var feature = features[i];
var style = theme.GetStyle(feature);
if (style == null) continue;
if (!style.Enabled) continue;
double compare = style.VisibilityUnits == VisibilityUnits.ZoomLevel ? zoom : scale;
if (!(style.MinVisible <= compare && compare <= style.MaxVisible)) continue;
IEnumerable<IStyle> stylesToRender = GetStylesToRender(style);
if (stylesToRender == null)
return;
foreach (var vstyle in stylesToRender)
{
if (!(vstyle is VectorStyle) || !vstyle.Enabled)
continue;
using (var clone = (vstyle as VectorStyle).Clone())
{
if (clone != null)
{
RenderGeometry(g, map, feature.Geometry, clone);
}
}
}
}
}
}
示例4: RenderInternal
/// <summary>
/// Method to render this layer to the map, applying <paramref name="theme"/>.
/// </summary>
/// <param name="g">The graphics object</param>
/// <param name="map">The map object</param>
/// <param name="envelope">The envelope to render</param>
/// <param name="theme">The theme to apply</param>
protected void RenderInternal(Graphics g, Map map, Envelope envelope, ITheme theme)
{
IFeatureCollectionSet ds;
lock (_dataSource)
{
ds = new FeatureCollectionSet();
DataSource.Open();
DataSource.ExecuteIntersectionQuery(envelope, ds);
DataSource.Close();
}
foreach (var features in ds)
{
if (CoordinateTransformation != null)
for (int i = 0; i < features.Count; i++)
#if !DotSpatialProjections
features[i].Geometry = GeometryTransform.TransformGeometry(features[i].Geometry,
CoordinateTransformation.
MathTransform,
GeometryServiceProvider.Instance.CreateGeometryFactory((int)CoordinateTransformation.TargetCS.AuthorityCode));
#else
features[i].Geometry = GeometryTransform.TransformGeometry(features[i].Geometry,
CoordinateTransformation.Source,
CoordinateTransformation.Target,
CoordinateTransformation.TargetFactory);
#endif
//Linestring outlines is drawn by drawing the layer once with a thicker line
//before drawing the "inline" on top.
if (Style.EnableOutline)
{
for (int i = 0; i < features.Count; i++)
{
var feature = features[i];
var outlineStyle = theme.GetStyle(feature) as VectorStyle;
if (outlineStyle == null) continue;
if (!(outlineStyle.Enabled && outlineStyle.EnableOutline)) continue;
if (!(outlineStyle.MinVisible <= map.Zoom && map.Zoom <= outlineStyle.MaxVisible)) continue;
using (outlineStyle = outlineStyle.Clone())
{
if (outlineStyle != null)
{
//Draw background of all line-outlines first
if (feature.Geometry is ILineString)
{
VectorRenderer.DrawLineString(g, feature.Geometry as ILineString, outlineStyle.Outline,
map, outlineStyle.LineOffset);
}
else if (feature.Geometry is IMultiLineString)
{
VectorRenderer.DrawMultiLineString(g, feature.Geometry as IMultiLineString,
outlineStyle.Outline, map, outlineStyle.LineOffset);
}
}
}
}
}
for (int i = 0; i < features.Count; i++)
{
var feature = features[i];
var style = theme.GetStyle(feature);
if (style == null) continue;
if (!style.Enabled) continue;
if (!(style.MinVisible <= map.Zoom && map.Zoom <= style.MaxVisible)) continue;
IStyle[] stylesToRender = GetStylesToRender(style);
if (stylesToRender == null)
return;
foreach (var vstyle in stylesToRender)
{
if (!(vstyle is VectorStyle) || !vstyle.Enabled)
continue;
using (var clone = (vstyle as VectorStyle).Clone())
{
if (clone != null)
{
RenderGeometry(g, map, feature.Geometry, clone);
}
}
}
//.........这里部分代码省略.........
示例5: CreateFromSharpmapTheme
public static Func<ExportContext, SharpKml.Dom.Style> CreateFromSharpmapTheme(ITheme theme)
{
if (theme == null)
throw new ArgumentNullException("theme");
return context =>
{
var sharpmapStyle = theme.GetStyle(context.Feature);
return sharpmapStyle != null ? CreateFromSharpmapStyle(sharpmapStyle)(context) : null;
};
}