/// <inheritdoc/> public SizeD GetPreferredSize(ILabel label, ILabelStyle style) { var preferredTextSize = textStyle.Renderer.GetPreferredSize(label, textStyle); var insets = ((AnnotationLabelStyle)style).Insets; return(new SizeD(2 * insets + preferredTextSize.Width, 2 * insets + preferredTextSize.Height)); }
public MyEditLabelHelper(ILabelOwner owner, ILabel label, ILabelModelParameter firstLabelParam, ILabelStyle firstLabelStyle) { this.owner = owner; this.label = label; this.firstLabelParam = firstLabelParam; this.firstLabelStyle = firstLabelStyle; TextBoxBackground = Color.LightGray; TextBoxForeground = Color.DarkSlateGray; }
/// <summary> /// Initializes a new Label instance /// </summary> /// <param name="text">Text to write</param> /// <param name="labelpoint">Position of label</param> /// <param name="rotation">Rotation</param> /// <param name="priority">Label priority used for collision detection</param> /// <param name="collisionbox">Box around label for collision detection</param> /// <param name="style">The style of the label</param> public Label(string text, System.Drawing.PointF labelpoint, float rotation, int priority, LabelBox collisionbox, ILabelStyle style) { _Text = text; _LabelPoint = labelpoint; _Rotation = rotation; _Priority = priority; _box = collisionbox; _Style = style; }
public CityLabelStyle([NotNull] ILabelStyle innerLabelStyle) { if (innerLabelStyle == null) { throw new ArgumentNullException("innerLabelStyle"); } InnerLabelStyle = innerLabelStyle; ConnectorEdgeStyle = new PolylineEdgeStyle(); OwnerPortLocation = LabelPortLocation = FreeNodePortLocationModel.NodeCenterAnchored; }
public void SetObjects(object @object) { ILabelStyle style = @object as ILabelStyle; if (style != null) { this.m_pTextSymbol = (style.Symbol as IClone).Clone() as ITextSymbol; this.m_pOverposterLayerProperties = (style.BasicOverposterLayerProperties as IClone).Clone() as IBasicOverposterLayerProperties; } }
/// <summary> /// Initializes the styles for nodes, edges and labels. /// </summary> private void InitializeStyles() { edgeLabelStyle = new LabelControlLabelStyle("EdgeLabelStyle"); nodeLabelStyle = new LevelOfDetailLabelStyleDecorator { HideThreshold = 0.5, WrappedStyle = new CalloutLabelStyleDecorator { WrappedStyle = new LabelControlLabelStyle("NodeLabelStyle") } }; }
/// <summary> /// Draws preview based on the specified expression string /// </summary> internal static void DrawPreview(ILabelStyle category, IFeatureSet sf, PictureBox canvas, string expression, bool forceDrawing, bool renderGrid = false, bool basePoint = false) { string s = GetLabelText(sf, expression); if (s.Trim() == string.Empty) { s = ""; } var img = new Bitmap(canvas.ClientRectangle.Width, canvas.ClientRectangle.Height); Graphics g = Graphics.FromImage(img); if (renderGrid) { RenderGrid(img, g); } var pntOrigin = new Point((canvas.ClientRectangle.Right + canvas.ClientRectangle.Left) / 2, (canvas.ClientRectangle.Bottom + canvas.ClientRectangle.Top) / 2); g.InterpolationMode = InterpolationMode.HighQualityBicubic; g.SmoothingMode = SmoothingMode.HighQuality; // drawing the label var style = new LabelStyleRenderer(category); if (sf.Labels.Items.Count > 0 || forceDrawing) { // drawing base point if (basePoint) { Pen pen = new Pen(Color.Black, 2); var rect = new Rectangle(pntOrigin.X, pntOrigin.Y, 2, 2); g.DrawEllipse(pen, rect); pen.Dispose(); } style.Draw(g, pntOrigin, s, true, 0); } if (canvas.Image != null) { canvas.Image.Dispose(); } canvas.Image = img; }
/// <summary> /// Adds a <see cref="IOptionItem"/>s that are bound to the label's <see cref="ILabel.Style"/> /// to the builder. /// </summary> /// <param name="context">The context to use for building.</param> /// <param name="label">The current label instance.</param> protected virtual void AddStyleItems(IOptionBuilderContext context, ILabel label) { //style group... //retrieve current style... ILabelStyle style = label.Style; if (style != null) { //retrieve OptionBuilder from style IOptionBuilder styleBuilder = GetStyleOptionBuilder(context, style); if (styleBuilder != null) { styleBuilder.AddItems(context.CreateChildContext(DefaultLabelPropertyMapBuilder.StyleProperty), style.GetType(), style); } } }
/// <summary> /// Initializes new instance of the FontGradientForm class /// </summary> /// <param name="labels">To set parameters for</param> /// <param name="fontGradient"></param> public FontGradientForm(ILabelStyle labels, bool fontGradient) { InitializeComponent(); _fontGradient = fontGradient; _labels = labels; _noEvents = true; icbFontGradient.ComboStyle = ImageComboStyle.LinearGradient; icbFontGradient.SelectedIndex = 0; Text = fontGradient ? "Font gradient" : "Frame gradient"; _noEvents = false; Settings2Ui(); }
/// <summary> /// Copy one node label. /// </summary> /// <param name="pageView">The view (i.e. target) graph.</param> /// <param name="nodeLabelLayout">The layout of the label.</param> /// <param name="modelLabel">The model (i.e. original) label.</param> /// <param name="layoutNode">The node in the layout graph. </param> /// <param name="viewNode">The node in the view graph.</param> /// <returns>The copied label.</returns> private ILabel CopyNodeLabel(IGraph pageView, INodeLabelLayout nodeLabelLayout, ILabel modelLabel, Node layoutNode, INode viewNode) { INodeInfo nodeInfo = result.GetNodeInfo(layoutNode); ILabelDefaults labelDefaults; // determine the style for the label switch (nodeInfo.Type) { case NodeType.Group: labelDefaults = GroupNodeDefaults.Labels; break; case NodeType.Connector: labelDefaults = ConnectorNodeDefaults.Labels; break; case NodeType.Proxy: labelDefaults = ProxyNodeDefaults.Labels; break; case NodeType.ProxyReference: labelDefaults = ProxyReferenceNodeDefaults.Labels; break; default: labelDefaults = NormalNodeDefaults.Labels; break; } ILabelModelParameter parameter = labelDefaults.LayoutParameter != NullLabelModelParameter ? labelDefaults.GetLayoutParameterInstance(viewNode) : (ILabelModelParameter)nodeLabelLayout.ModelParameter; ILabelStyle style = labelDefaults.Style != NullLabelStyle ? labelDefaults.GetStyleInstance(viewNode) : (ILabelStyle)(modelLabel != null ? modelLabel.Style.Clone() : pageView.NodeDefaults.Labels.Style); string text = modelLabel != null ? modelLabel.Text : null; object tag = modelLabel != null ? modelLabel.Tag : null; // create a new label in the view graph using the style, // the text and tag from the original label and the layout from the layout graph ILabel viewLabel = pageView.AddLabel(viewNode, text, parameter, style); viewLabel.Tag = tag; return(viewLabel); }
/// <summary> /// Copy one edge label. /// </summary> /// <param name="pageView">The view (i.e. target) graph.</param> /// <param name="edgeLabelLayout">The layout of the label.</param> /// <param name="modelLabel">The original label.</param> /// <param name="viewEdge">The copied edge (from the view graph).</param> /// <param name="labelDefaults"></param> /// <returns>The copied label.</returns> private ILabel CopyEdgeLabel(IGraph pageView, IEdgeLabelLayout edgeLabelLayout, ILabel modelLabel, IEdge viewEdge, ILabelDefaults labelDefaults) { // get the style from edgeLabelStyle property. If none is set get it from the original (model) label. ILabelStyle style = (ILabelStyle)(labelDefaults.Style != NullLabelStyle ? labelDefaults.GetStyleInstance(viewEdge) : modelLabel.Style.Clone()); ILabelModelParameter parameter = labelDefaults.LayoutParameter != NullLabelModelParameter ? labelDefaults.GetLayoutParameterInstance(viewEdge) : (ILabelModelParameter)edgeLabelLayout.ModelParameter; // create a new label in the view graph using the style, // the text from the original label and the layout from the layout graph ILabel viewLabel = pageView.AddLabel(viewEdge, modelLabel.Text, parameter, style); viewLabel.Tag = modelLabel.Tag; return(viewLabel); }
/// <summary> /// Create a proxy reference node, i.e., a node referencing a proxy node. /// </summary> /// <remarks> /// This implementation copies the labels of the represented node and applies the <c>ProxyReferenceNodeStyle</c>. /// </remarks> /// <param name="pageLayoutGraph">The layout graph representing the current page</param> /// <param name="layoutNode">The node of the layout graph that should be copied</param> /// <param name="pageView">The <see cref="IGraph"/> that is built to show the multi-page layout in a graph canvas</param> /// <returns>The created node</returns> /// <seealso cref="CreateNodeCore"/> protected INode CreateProxyReferenceNode(LayoutGraph pageLayoutGraph, Node layoutNode, IGraph pageView) { INode representedNode = GetRepresentedNode(layoutNode); INode viewNode = CreateNodeCore(pageLayoutGraph, pageView, layoutNode, representedNode, true, ProxyReferenceNodeDefaults); INodeInfo nodeInfo = result.GetNodeInfo(layoutNode); Node referencingNode = nodeInfo.ReferencingNode; int targetPage = result.GetNodeInfo(referencingNode).PageNo; ILabelStyle style = ProxyNodeDefaults.Labels.Style != NullLabelStyle ? ProxyNodeDefaults.Labels.GetStyleInstance(viewNode) : pageView.NodeDefaults.Labels.GetStyleInstance(viewNode); ILabelModelParameter parameter = ProxyNodeDefaults.Labels.LayoutParameter != NullLabelModelParameter ? ProxyNodeDefaults.Labels.GetLayoutParameterInstance(viewNode) : pageView.NodeDefaults.Labels.GetLayoutParameterInstance(viewNode); pageView.AddLabel(viewNode, "p" + targetPage, parameter, style); return(viewNode); }
private ILabelStyle GetCurrentStyle(ILabel item, ILabelStyle style) { var annotationLabelStyle = style as AnnotationLabelStyle; var nodeOwner = item.Owner as INode; if (annotationLabelStyle == null || nodeOwner == null) { return(VoidLabelStyle.Instance); } left = item.GetLayout().GetCenter().X > nodeOwner.Layout.GetCenter().X; insets = annotationLabelStyle.Insets; var delegateStyle = annotationLabelStyle.DelegateStyle; delegateStyle.IconStyle = left ? annotationLabelStyle.leftAnnotationStyle : annotationLabelStyle.rightAnnotationStyle; delegateStyle.LabelConnectorLocation = left ? FreeNodePortLocationModel.NodeLeftAnchored : FreeNodePortLocationModel.NodeRightAnchored; return(delegateStyle); }
/// <summary> /// Builds the property for the labels's <see cref="ILabel.Style"/>. /// </summary> protected virtual void BuildLabelStylesProperty(IPropertyBuildContext <ILabel> context) { context.AddEntry(LabelStyleProperty, new ValueGetterDelegate <Type>(delegate { var type = context.CurrentInstance.Style.GetType(); while (!type.IsPublic) { type = type.BaseType; } return(type); }) , new ValueSetterDelegate <Type>(delegate(Type value) { IGraph graph = context.Lookup(typeof(IGraph)) as IGraph; ILabelStyle style = Activator.CreateInstance(value) as ILabelStyle; if (graph != null && style != null) { graph.SetStyle(context.CurrentInstance, style); } }), null); }
/// <summary> /// Constructor for editing single category /// </summary> public LabelStyleForm(IAppContext context, ILayer layer, ILabelStyle lb) { InitializeComponent(); InitLayer(context, layer); _categoryEdited = true; Initialize(lb); tabControlAdv1.SelectedIndex = tabNumber; // expression isn't available for the categories if (_categoryEdited) { tabControlAdv1.TabPages.Remove(tabVisibility); tabControlAdv1.TabPages.Remove(tabPosition); tabControlAdv1.TabPages.Remove(tabExpression); } lblResult.Visible = false; btnApply.Visible = false; }
private ILabelStyle GetCurrentStyle(ILabel item, ILabelStyle style) { var labelStyle = style as ChoreographyMessageLabelStyle; if (labelStyle == null) { return(VoidLabelStyle.Instance); } north = true; messageColor = BpmnConstants.DefaultInitiatingMessageColor; messageOutline = null; var node = item.Owner as INode; if (node != null) { north = item.GetLayout().GetCenter().Y < node.Layout.GetCenter().Y; var nodeStyle = node.Style as ChoreographyNodeStyle; if (nodeStyle != null) { var responseMessage = nodeStyle.InitiatingAtTop ^ north; messageColor = responseMessage ? nodeStyle.ResponseColor : nodeStyle.InitiatingColor; messageOutline = nodeStyle.messagePen; } } messageOutline = messageOutline ?? new Pen(BpmnConstants.DefaultMessageOutline, 1); var delegateStyle = labelStyle.delegateStyle; delegateStyle.IconStyle = labelStyle.messageStyle; labelStyle.messageStyle.Icon = IconFactory.CreateMessage(messageOutline, messageColor); delegateStyle.LabelConnectorLocation = north ? FreeNodePortLocationModel.NodeBottomAnchored : FreeNodePortLocationModel.NodeTopAnchored; delegateStyle.NodeConnectorLocation = north ? FreeNodePortLocationModel.NodeTopAnchored : FreeNodePortLocationModel.NodeBottomAnchored; return(delegateStyle); }
/// <inheritdoc/> public IVisibilityTestable GetVisibilityTestable(ILabel item, ILabelStyle style) { return(adapter.Renderer.GetVisibilityTestable(item, adapter)); }
/// <inheritdoc/> public IBoundsProvider GetBoundsProvider(ILabel item, ILabelStyle style) { return(adapter.Renderer.GetBoundsProvider(item, adapter)); }
/// <inheritdoc/> public IVisualCreator GetVisualCreator(ILabel item, ILabelStyle style) { return(adapter.Renderer.GetVisualCreator(item, adapter)); }
/// <inheritdoc/> public ILookup GetContext(ILabel item, ILabelStyle style) { var delegateStyle = GetCurrentStyle(item, style); return(delegateStyle.Renderer.GetContext(item, delegateStyle)); }
/// <inheritdoc/> public IMarqueeTestable GetMarqueeTestable(ILabel item, ILabelStyle style) { var delegateStyle = GetCurrentStyle(item, style); return(delegateStyle.Renderer.GetMarqueeTestable(item, delegateStyle)); }
private Label CreateLabel(ILabelLayer layer, Geometry feature, string text, float rotation, ILabelStyle style, Map map, Graphics g) { System.Drawing.SizeF size = g.MeasureString(text, style.Font); System.Drawing.PointF position = map.WorldToImage(feature.GetBoundingBox().GetCentroid()); position.X = position.X - size.Width * (short)style.HorizontalAlignment * 0.5f; position.Y = position.Y - size.Height * (short)style.VerticalAlignment * 0.5f; if (position.X - size.Width > map.Size.Width || position.X + size.Width < 0 || position.Y - size.Height > map.Size.Height || position.Y + size.Height < 0) { return(null); } else { SharpMap.Rendering.Label lbl; if (!style.CollisionDetection) { lbl = new Label(text, position, rotation, layer.Priority, null, style); } else { //Collision detection is enabled so we need to measure the size of the string lbl = new Label(text, position, rotation, layer.Priority, new LabelBox(position.X - size.Width * 0.5f - style.CollisionBuffer.Width, position.Y + size.Height * 0.5f + style.CollisionBuffer.Height, size.Width + 2f * style.CollisionBuffer.Width, size.Height + style.CollisionBuffer.Height * 2f), style); } if (feature.GetType() == typeof(SharpMap.Geometries.LineString)) { SharpMap.Geometries.LineString line = feature as SharpMap.Geometries.LineString; if (line.Length / map.PixelSize > size.Width) //Only label feature if it is long enough { CalculateLabelOnLinestring(line, ref lbl, map); } else { return(null); } } return(lbl); } }
/// <inheritdoc/> public IBoundsProvider GetBoundsProvider(ILabel item, ILabelStyle style) { var delegateStyle = GetCurrentStyle(item, style); return(delegateStyle.Renderer.GetBoundsProvider(item, delegateStyle)); }
/// <inheritdoc/> public IVisualCreator GetVisualCreator(ILabel item, ILabelStyle style) { label = item; labelStyle = style; return(this); }
private SharpMap.Rendering.Label CreateLabel(IGeometry feature,string text, float rotation, ILabelStyle style, IMap map, System.Drawing.Graphics g) { System.Drawing.SizeF size = g.MeasureString(text, style.Font); System.Drawing.PointF position = map.WorldToImage(feature.EnvelopeInternal.Centre); position.X = position.X - size.Width * (short)style.HorizontalAlignment * 0.5f; position.Y = position.Y - size.Height * (short)style.VerticalAlignment * 0.5f; if (position.X-size.Width > map.Size.Width || position.X+size.Width < 0 || position.Y-size.Height > map.Size.Height || position.Y+size.Height < 0) return null; else { SharpMap.Rendering.Label lbl; if (!style.CollisionDetection) lbl = new SharpMap.Rendering.Label(text, position, rotation, this.Priority, null, style); else { //Collision detection is enabled so we need to measure the size of the string lbl = new SharpMap.Rendering.Label(text, position, rotation, this.Priority, new SharpMap.Rendering.LabelBox(position.X - size.Width * 0.5f - style.CollisionBuffer.Width, position.Y + size.Height * 0.5f + style.CollisionBuffer.Height, size.Width + 2f * style.CollisionBuffer.Width, size.Height + style.CollisionBuffer.Height * 2f), style); } if (feature.GetType() == typeof(ILineString)) { ILineString line = feature as ILineString; if (line.Length / map.PixelSize > size.Width) //Only label feature if it is long enough CalculateLabelOnLinestring(line, ref lbl, map); else return null; } return lbl; } }
/// <inheritdoc/> public ILookup GetContext(ILabel item, ILabelStyle style) { return(adapter.Renderer.GetContext(item, adapter)); }
/// <inheritdoc/> public IHitTestable GetHitTestable(ILabel item, ILabelStyle style) { return(adapter.Renderer.GetHitTestable(item, adapter)); }
/// <inheritdoc/> public IVisibilityTestable GetVisibilityTestable(ILabel item, ILabelStyle style) { var delegateStyle = GetCurrentStyle(item, style); return(delegateStyle.Renderer.GetVisibilityTestable(item, delegateStyle)); }
/// <inheritdoc/> public IMarqueeTestable GetMarqueeTestable(ILabel item, ILabelStyle style) { return(adapter.Renderer.GetMarqueeTestable(item, adapter)); }
public void RenderLayer(ILabelLayer layer, Map map, Graphics g) { if (layer.Style.Enabled && layer.Style.MaxVisible >= map.Zoom && layer.Style.MinVisible < map.Zoom) { if (layer.DataSource == null) { throw (new ApplicationException("DataSource property not set on layer '" + layer.LayerName + "'")); } g.TextRenderingHint = layer.TextRenderingHint; g.SmoothingMode = layer.SmoothingMode; SharpMap.Geometries.BoundingBox envelope = map.Envelope; //View to render if (layer.CoordinateTransformation != null) { envelope = GeometryTransform.TransformBox(envelope, layer.CoordinateTransformation.MathTransform.Inverse()); } FeatureDataSet ds = new FeatureDataSet(); layer.DataSource.Open(); layer.DataSource.ExecuteIntersectionQuery(envelope, ds); layer.DataSource.Close(); if (ds.Tables.Count == 0) { //base.Render(g, map); return; } FeatureDataTable features = (FeatureDataTable)ds.Tables[0]; //Initialize label collection List <Label> labels = new List <Label>(); LabelLayer.GetLabelMethod lblDelegate = layer.LabelStringDelegate; //List<System.Drawing.Rectangle> LabelBoxes; //Used for collision detection //Render labels for (int i = 0; i < features.Count; i++) { FeatureDataRow feature = features[i]; if (layer.CoordinateTransformation != null) { features[i].Geometry = GeometryTransform.TransformGeometry(features[i].Geometry, layer.CoordinateTransformation.MathTransform); } ILabelStyle style = null; if (layer.Theme != null) //If thematics is enabled, lets override the style { style = layer.Theme.GetStyle(feature); } else { style = layer.Style; } float rotation = 0; if (!String.IsNullOrEmpty(layer.RotationColumn)) { float.TryParse(feature[layer.RotationColumn].ToString(), NumberStyles.Any, Map.numberFormat_EnUS, out rotation); } string text; if (lblDelegate != null) { text = lblDelegate(feature); } else { text = feature[layer.LabelColumn].ToString(); } if (text != null && text != String.Empty) { if (feature.Geometry is GeometryCollection) { if (layer.MultipartGeometryBehaviour == SharpMap.Layers.LabelLayer.MultipartGeometryBehaviourEnum.All) { foreach (SharpMap.Geometries.Geometry geom in (feature.Geometry as GeometryCollection)) { SharpMap.Rendering.Label lbl = CreateLabel(layer, geom, text, rotation, style, map, g); if (lbl != null) { labels.Add(lbl); } } } else if (layer.MultipartGeometryBehaviour == SharpMap.Layers.LabelLayer.MultipartGeometryBehaviourEnum.CommonCenter) { Label lbl = CreateLabel(layer, feature.Geometry, text, rotation, style, map, g); if (lbl != null) { labels.Add(lbl); } } else if (layer.MultipartGeometryBehaviour == SharpMap.Layers.LabelLayer.MultipartGeometryBehaviourEnum.First) { if ((feature.Geometry as GeometryCollection).Collection.Count > 0) { SharpMap.Rendering.Label lbl = CreateLabel(layer, (feature.Geometry as GeometryCollection).Collection[0], text, rotation, style, map, g); if (lbl != null) { labels.Add(lbl); } } } else if (layer.MultipartGeometryBehaviour == SharpMap.Layers.LabelLayer.MultipartGeometryBehaviourEnum.Largest) { GeometryCollection coll = (feature.Geometry as GeometryCollection); if (coll.NumGeometries > 0) { double largestVal = 0; int idxOfLargest = 0; for (int j = 0; j < coll.NumGeometries; j++) { SharpMap.Geometries.Geometry geom = coll.Geometry(j); if (geom is Geometries.LineString && ((Geometries.LineString)geom).Length > largestVal) { largestVal = ((Geometries.LineString)geom).Length; idxOfLargest = j; } if (geom is Geometries.MultiLineString && ((Geometries.MultiLineString)geom).Length > largestVal) { largestVal = ((Geometries.LineString)geom).Length; idxOfLargest = j; } if (geom is Geometries.Polygon && ((Geometries.Polygon)geom).Area > largestVal) { largestVal = ((Geometries.Polygon)geom).Area; idxOfLargest = j; } if (geom is Geometries.MultiPolygon && ((Geometries.MultiPolygon)geom).Area > largestVal) { largestVal = ((Geometries.MultiPolygon)geom).Area; idxOfLargest = j; } } SharpMap.Rendering.Label lbl = CreateLabel(layer, coll.Geometry(idxOfLargest), text, rotation, style, map, g); if (lbl != null) { labels.Add(lbl); } } } } else { SharpMap.Rendering.Label lbl = CreateLabel(layer, feature.Geometry, text, rotation, style, map, g); if (lbl != null) { labels.Add(lbl); } } } } if (labels.Count > 0) //We have labels to render... { if (layer.Style.CollisionDetection && layer.LabelFilter != null) { layer.LabelFilter(labels); } for (int i = 0; i < labels.Count; i++) { VectorRenderer.DrawLabel(g, labels[i].LabelPoint, labels[i].Style.Offset, labels[i].Style.Font, labels[i].Style.ForeColor, labels[i].Style.BackColor, layer.Style.Halo, labels[i].Rotation, labels[i].Text, map); } } labels = null; } //base.Render(g, map); }
/// <inheritdoc/> public SizeD GetPreferredSize(ILabel label, ILabelStyle style) { return(adapter.Renderer.GetPreferredSize(label, adapter)); }
/// <summary> /// Renders the layer /// </summary> /// <param name="g">Graphics object reference</param> /// <param name="map">Map which is rendered</param> public override void OnRender(System.Drawing.Graphics g, IMap map) { if (Style.Enabled && Style.MaxVisible >= map.Zoom && Style.MinVisible < map.Zoom) { if (DataSource == null) throw (new ApplicationException("DataSource property not set on layer '" + Name + "'")); g.TextRenderingHint = TextRenderingHint; g.SmoothingMode = SmoothingMode; var features = Parent.GetFeatures(map.Envelope); if (!features.Any()) { return; } //Initialize label collection var labels = new List<Rendering.Label>(); //List<System.Drawing.Rectangle> LabelBoxes; //Used for collision detection //Render labels IGeometry geometry; foreach (var feature in features) { if (CoordinateTransformation != null) { geometry = GeometryTransform.TransformGeometry(feature.Geometry, this.CoordinateTransformation.MathTransform); } else { geometry = feature.Geometry; } ILabelStyle style; if (Theme != null) //If thematics is enabled, lets override the style style = Theme.GetStyle(feature) as LabelStyle; else style = Style; float rotation = 0; if (!String.IsNullOrEmpty(RotationColumn)) rotation = FeatureAttributeAccessorHelper.GetAttributeValue<float>(feature, RotationColumn, 0f); string text = GetText(feature); if (!string.IsNullOrEmpty(text)) { if (geometry is IGeometryCollection) { if (MultipartGeometryBehaviour == MultipartGeometryBehaviourEnum.All) { foreach (IGeometry geom in (geometry as IGeometryCollection)) { Label lbl = CreateLabel(geom, text, rotation, style, map, g); if (lbl != null) labels.Add(lbl); } } else if (MultipartGeometryBehaviour == MultipartGeometryBehaviourEnum.CommonCenter) { Label lbl = CreateLabel(geometry, text, rotation, style, map, g); if (lbl != null) labels.Add(lbl); } else if (MultipartGeometryBehaviour == MultipartGeometryBehaviourEnum.First) { if ((geometry as IGeometryCollection).Geometries.Length > 0) { Label lbl = CreateLabel((geometry as IGeometryCollection).Geometries[0], text, rotation, style, map, g); if (lbl != null) labels.Add(lbl); } } else if (MultipartGeometryBehaviour == MultipartGeometryBehaviourEnum.Largest) { var coll = (geometry as IGeometryCollection); if (coll.NumGeometries > 0) { double largestVal = 0; int idxOfLargest = 0; for (int j = 0; j < coll.NumGeometries; j++) { IGeometry geom = coll.Geometries[j]; if (geom is ILineString && ((ILineString)geom).Length > largestVal) { largestVal = ((ILineString)geom).Length; idxOfLargest = j; } if (geom is IMultiLineString && ((IMultiLineString)geom).Length > largestVal) { largestVal = ((ILineString)geom).Length; idxOfLargest = j; } if (geom is IPolygon && ((IPolygon)geom).Area > largestVal) { largestVal = ((IPolygon)geom).Area; idxOfLargest = j; } if (geom is IMultiPolygon && ((IMultiPolygon)geom).Area > largestVal) { largestVal = ((IMultiPolygon)geom).Area; idxOfLargest = j; } } Label lbl = CreateLabel(coll.Geometries[idxOfLargest], text, rotation, style, map, g); if (lbl != null) labels.Add(lbl); } } } else { var lbl = CreateLabel(geometry, text, rotation, style, map, g); if (lbl != null) labels.Add(lbl); } } } if (labels.Count > 0) //We have labels to render... { if (this.Style.CollisionDetection && this.labelFilter!=null) this.labelFilter(labels); for (int i = 0; i < labels.Count;i++ ) VectorRenderingHelper.DrawLabel(g, labels[i].LabelPoint, labels[i].Style.Offset, labels[i].Style.Font, labels[i].Style.ForeColor, labels[i].Style.BackColor, Style.Halo, labels[i].Rotation, labels[i].Text, map); } labels = null; } }