private PriorityButton GetPriorityButton(TextSymbolAlignment symbolAlignment) { foreach (PriorityButton button in panelContent.Controls) { if (button.SymbolAlignment == symbolAlignment) { return(button); } } return(null); }
private void SetSymbolAlignment(TextSymbolAlignment align) { if (_renderer == null) { return; } if (_renderer.TextSymbol is ILabel) { ((ILabel)_renderer.TextSymbol).TextSymbolAlignment = align; } DrawPreview(); }
private IDrawTextFormat StringFormatFromAlignment(TextSymbolAlignment symbolAlignment) { var format = Current.Engine.CreateDrawTextFormat(); switch (symbolAlignment) { case TextSymbolAlignment.rightAlignOver: format.Alignment = StringAlignment.Far; format.LineAlignment = StringAlignment.Far; break; case TextSymbolAlignment.rightAlignCenter: format.Alignment = StringAlignment.Far; format.LineAlignment = StringAlignment.Center; break; case TextSymbolAlignment.rightAlignUnder: format.Alignment = StringAlignment.Far; format.LineAlignment = StringAlignment.Near; break; case TextSymbolAlignment.Over: format.Alignment = StringAlignment.Center; format.LineAlignment = StringAlignment.Far; break; case TextSymbolAlignment.Center: format.Alignment = StringAlignment.Center; format.LineAlignment = StringAlignment.Center; break; case TextSymbolAlignment.Under: format.Alignment = StringAlignment.Center; format.LineAlignment = StringAlignment.Near; break; case TextSymbolAlignment.leftAlignOver: format.Alignment = StringAlignment.Near; format.LineAlignment = StringAlignment.Far; break; case TextSymbolAlignment.leftAlignCenter: format.Alignment = StringAlignment.Near; format.LineAlignment = StringAlignment.Center; break; case TextSymbolAlignment.leftAlignUnder: format.Alignment = StringAlignment.Near; format.LineAlignment = StringAlignment.Near; break; } return(format); }
public SymbolControl(ISymbol symbol) { if (symbol != null) { _symbol = (ISymbol)symbol.Clone(); if (_symbol is ILabel) { _txtSymbolAlignment = ((ILabel)_symbol).TextSymbolAlignment; ((ILabel)_symbol).TextSymbolAlignment = TextSymbolAlignment.Center; } } InitializeComponent(); }
public SymbolControl(ISymbol symbol) : this() { if (symbol != null) { _symbol = (ISymbol)symbol.Clone(); if (_symbol is ILabel) { _txtSymbolAlignment = ((ILabel)_symbol).TextSymbolAlignment; ((ILabel)_symbol).TextSymbolAlignment = TextSymbolAlignment.Center; } symbolSelectorControl1.SymbolProtoType = _symbol; } }
virtual public void Load(IPersistStream stream) { base.Load(stream); string err = ""; try { System.IO.MemoryStream ms = new System.IO.MemoryStream(); ASCIIEncoding encoder = new ASCIIEncoding(); string soap = (string)stream.Load("font"); // // Im Size muss Punkt und Komma mit Systemeinstellungen // übereinstimmen // XmlDocument doc = new XmlDocument(); doc.LoadXml(soap); XmlNode sizeNode = doc.SelectSingleNode("//Size"); if (sizeNode != null) { sizeNode.InnerText = sizeNode.InnerText.Replace(".", ","); } soap = doc.OuterXml; // // // ms.Write(encoder.GetBytes(soap), 0, soap.Length); ms.Position = 0; SoapFormatter formatter = new SoapFormatter(); _font = (Font)formatter.Deserialize <Font>(ms); this.MaxFontSize = (float)stream.Load("maxfontsize", 0f); this.MinFontSize = (float)stream.Load("minfontsize", 0f); } catch (Exception ex) { err = ex.Message; ex = null; } this.Color = Color.FromArgb((int)stream.Load("color", Color.Red.ToArgb())); HorizontalOffset = (float)stream.Load("xOffset", (float)0); VerticalOffset = (float)stream.Load("yOffset", (float)0); Angle = (float)stream.Load("Angle", (float)0); _align = (TextSymbolAlignment)stream.Load("Alignment", (int)TextSymbolAlignment.Center); }
private void SetSymbolAlignment(TextSymbolAlignment align) { if (_renderer == null) { return; } symbolAlignmentPriorityControl.PrimarySymbolAlignment = align; if (_renderer.TextSymbol is ILabel) { ((ILabel)_renderer.TextSymbol).TextSymbolAlignment = align; ((ILabel)_renderer.TextSymbol).SecondaryTextSymbolAlignments = symbolAlignmentPriorityControl.SecondarySymbolAlignments?.ToArray(); } DrawPreview(); }
public void Draw(IDisplay display, IGeometry geometry, TextSymbolAlignment symbolAlignment) { foreach (SymbolCollectionItem sSym in _symbols) { if (sSym.Symbol == null || !sSym.Visible) { continue; } if (sSym.Symbol is ITextSymbol) { ((ITextSymbol)sSym.Symbol).Draw(display, geometry, symbolAlignment); } else { sSym.Symbol.Draw(display, geometry); } } }
public PriorityButton(TextSymbolAlignment alignment) { this.SymbolAlignment = alignment; }
virtual public void Load(IPersistStream stream) { base.Load(stream); string err = ""; try { System.IO.MemoryStream ms = new System.IO.MemoryStream(); ASCIIEncoding encoder = new ASCIIEncoding(); string soap = (string)stream.Load("font"); // // Im Size muss Punkt und Komma mit Systemeinstellungen // übereinstimmen // XmlDocument doc = new XmlDocument(); doc.LoadXml(soap); XmlNode sizeNode = doc.SelectSingleNode("//Size"); if (sizeNode != null) { sizeNode.InnerText = sizeNode.InnerText.Replace(".", ","); } soap = doc.OuterXml; // // // ms.Write(encoder.GetBytes(soap), 0, soap.Length); ms.Position = 0; SoapFormatter formatter = new SoapFormatter(); _font = (IFont)formatter.Deserialize <IFont>(ms, stream, this); this.MaxFontSize = (float)stream.Load("maxfontsize", 0f); this.MinFontSize = (float)stream.Load("minfontsize", 0f); } catch (Exception ex) { err = ex.Message; ex = null; } this.Color = ArgbColor.FromArgb((int)stream.Load("color", ArgbColor.Red.ToArgb())); HorizontalOffset = (float)stream.Load("xOffset", (float)0); VerticalOffset = (float)stream.Load("yOffset", (float)0); Angle = (float)stream.Load("Angle", (float)0); _align = (TextSymbolAlignment)stream.Load("Alignment", (int)TextSymbolAlignment.Center); var secAlignments = (string)stream.Load("secAlignments", null); if (!String.IsNullOrWhiteSpace(secAlignments)) { try { this.SecondaryTextSymbolAlignments = secAlignments.Split(',') .Select(s => (TextSymbolAlignment)int.Parse(s)) .Distinct() .ToArray(); } catch { } } this.IncludesSuperScript = (bool)stream.Load("includessuperscript", false); }
public void Draw(IDisplay display, IGeometry geometry, TextSymbolAlignment symbolAlignment) { if (_font == null) { return; } if (geometry is IPoint) { #region IPoint double x = ((IPoint)geometry).X; double y = ((IPoint)geometry).Y; display.World2Image(ref x, ref y); IPoint p = new gView.Framework.Geometry.Point(x, y); DrawAtPoint(display, p, _text, 0, StringFormatFromAlignment(symbolAlignment)); #endregion } if (geometry is IMultiPoint) { #region IMultiPoint IMultiPoint pColl = (IMultiPoint)geometry; for (int i = 0; i < pColl.PointCount; i++) { double x = pColl[i].X; double y = pColl[i].Y; display.World2Image(ref x, ref y); IPoint p = new gView.Framework.Geometry.Point(x, y); DrawAtPoint(display, p, _text, 0, StringFormatFromAlignment(symbolAlignment)); } #endregion } else if (geometry is IDisplayPath && ((IDisplayPath)geometry).AnnotationPolygonCollision is AnnotationPolygonCollection) { if (String.IsNullOrEmpty(_text)) { return; } IDisplayPath path = (IDisplayPath)geometry; AnnotationPolygonCollection apc = path.AnnotationPolygonCollision as AnnotationPolygonCollection; var format = StringFormatFromAlignment(symbolAlignment); format.LineAlignment = StringAlignment.Center; format.Alignment = StringAlignment.Center; if (_text.Length == apc.Count) { int drawingLevels = this.DrawingLevels; // Für Blockout und Glowing Text -> Zuerst den Blockout für alle Zeichen... for (int level = 0; level < drawingLevels; level++) { for (int i = 0; i < _text.Length; i++) { AnnotationPolygon ap = apc[i] as AnnotationPolygon; if (ap != null) { var centerPoint = ap.CenterPoint; DrawAtPoint(display, new Geometry.Point(centerPoint.X, centerPoint.Y), _text[i].ToString(), (float)ap.Angle, format, level); } } } } #region Old Method /* #region Text On Path * StringFormat format = stringFormatFromAlignment; * DisplayCharacterRanges ranges = new DisplayCharacterRanges(display.GraphicsContext, _font, format, _text); * * double sizeW = ranges.Width; * double len = path.Length; * double stat0 = len / 2 - sizeW / 2, stat1 = stat0 + sizeW; * if (stat0 < 0) return; * #region Richtung des Textes * Geometry.Point p1_ = SpatialAlgorithms.Algorithm.DisplayPathPoint(path, stat0); * Geometry.Point p2_ = SpatialAlgorithms.Algorithm.DisplayPathPoint(path, stat1); * if (p1_ == null || p2_ == null) * return; * if (p1_.X > p2_.X) * { #region Swap Path Direction * path.ChangeDirection(); #endregion * } #endregion * * AnnotationPolygonCollection charPolygons = new AnnotationPolygonCollection(); * double x, y, angle; * * for (int i = 0; i < _text.Length; i++) * { * RectangleF cSize = ranges[i]; * Geometry.Point p1, p2; * while (true) * { * p1 = SpatialAlgorithms.Algorithm.DisplayPathPoint(path, stat0); * p2 = SpatialAlgorithms.Algorithm.DisplayPathPoint(path, stat0 + cSize.Width); * if (p1 == null || p2 == null) * return; * * angle = Math.Atan2(p2.Y - p1.Y, p2.X - p1.X) * 180.0 / Math.PI; * * x = p1.X; y = p1.Y; * AnnotationPolygon polygon = null; * switch (format.LineAlignment) * { * case StringAlignment.Near: * polygon = new Symbology.AnnotationPolygon((float)x + .1f * cSize.Width, (float)y + .2f * cSize.Height, * .8f * cSize.Width, .6f * cSize.Height); * break; * case StringAlignment.Far: * polygon = new Symbology.AnnotationPolygon((float)x + .1f * cSize.Width, (float)y - .8f * cSize.Height, * .8f * cSize.Width, .6f * cSize.Height); * break; * default: * polygon = new Symbology.AnnotationPolygon((float)x + .1f * cSize.Width, (float)y - .6f * cSize.Height / 2f, * .8f * cSize.Width, .6f * cSize.Height); * break; * } * polygon.Rotate((float)x, (float)y, Angle + angle); * if (charPolygons.CheckCollision(polygon)) * { * stat0 += cSize.Width / 10.0; * continue; * } * charPolygons.Add(polygon); * * //using (System.Drawing.Drawing2D.GraphicsPath grpath = new System.Drawing.Drawing2D.GraphicsPath()) * //{ * // grpath.StartFigure(); * // grpath.AddLine(polygon[0], polygon[1]); * // grpath.AddLine(polygon[1], polygon[2]); * // grpath.AddLine(polygon[2], polygon[3]); * // grpath.CloseFigure(); * * // display.GraphicsContext.FillPath(Brushes.Aqua, grpath); * //} * * break; * } * * if (format.Alignment == StringAlignment.Center) * { * x = p1.X * 0.5 + p2.X * 0.5; * y = p1.Y * 0.5 + p2.Y * 0.5; * } * else if (format.Alignment == StringAlignment.Far) * { * x = p2.X; * y = p2.Y; * } * else * { * x = p1.X; * y = p1.Y; * } * DrawAtPoint(display, new Geometry.Point(x, y), _text[i].ToString(), (float)angle, format); * * stat0 += (double)cSize.Width; * } * //display.GraphicsContext.FillEllipse(Brushes.Green, (float)p1_.X - 3, (float)p1_.Y - 3, 6f, 6f); * //display.GraphicsContext.FillEllipse(Brushes.Blue, (float)p2_.X - 3, (float)p2_.Y - 3, 6f, 6f); #endregion * */ #endregion } else if (geometry is IPolyline) { IPolyline pLine = (IPolyline)geometry; for (int iPath = 0; iPath < pLine.PathCount; iPath++) { IPath path = pLine[iPath]; if (path.PointCount == 0) { continue; } #region Parallel Text IPoint p1 = path[0], p2; for (int iPoint = 1; iPoint < path.PointCount; iPoint++) { p2 = path[iPoint]; double angle = -Math.Atan2(p2.Y - p1.Y, p2.X - p1.X) * 180.0 / Math.PI; if (display.DisplayTransformation.UseTransformation) { angle -= display.DisplayTransformation.DisplayRotation; } var format = StringFormatFromAlignment(symbolAlignment); if (angle < 0) { angle += 360; } if (angle > 90 && angle < 270) { if (format.Alignment != StringAlignment.Center) { // swap points & alignment var p_ = p1; p1 = p2; p2 = p_; if (format.Alignment == StringAlignment.Far) { format.Alignment = StringAlignment.Near; } else if (format.Alignment == StringAlignment.Near) { format.Alignment = StringAlignment.Far; } } angle -= 180; } double x, y; if (format.Alignment == StringAlignment.Center) { x = p1.X * 0.5 + p2.X * 0.5; y = p1.Y * 0.5 + p2.Y * 0.5; } else if (format.Alignment == StringAlignment.Far) { x = p2.X; y = p2.Y; } else { x = p1.X; y = p1.Y; } display.World2Image(ref x, ref y); IPoint p = new gView.Framework.Geometry.Point(x, y); //_text += " " + angle.ToString(); DrawAtPoint(display, p, _text, (float)angle, format); p1 = p2; } #endregion } } else if (geometry is IPolygon) { /* * GraphicsPath path = DisplayOperations.Geometry2GraphicsPath(display, geometry); * * foreach (PointF point in gView.SpatialAlgorithms.Algorithm.LabelPoints(path)) * { * DrawAtPoint(display, new gView.Framework.Geometry.Point(point.X, point.Y), 0, stringFormatFromAlignment); * } * */ } else if (geometry is IAggregateGeometry) { for (int i = 0; i < ((IAggregateGeometry)geometry).GeometryCount; i++) { Draw(display, ((IAggregateGeometry)geometry)[i]); } } }
private AnnotationPolygon AnnotationPolygon(IDisplay display, CanvasSizeF size, float x, float y, TextSymbolAlignment alignment) { float x1 = 0, y1 = 0; switch (alignment) { case TextSymbolAlignment.rightAlignOver: x1 = x - size.Width; y1 = y - size.Height; break; case TextSymbolAlignment.rightAlignCenter: x1 = x - size.Width; y1 = y - size.Height / 2; break; case TextSymbolAlignment.rightAlignUnder: x1 = x - size.Width; y1 = y; break; case TextSymbolAlignment.Over: x1 = x - size.Width / 2; y1 = y - size.Height; break; case TextSymbolAlignment.Center: x1 = x - size.Width / 2; y1 = y - size.Height / 2; break; case TextSymbolAlignment.Under: x1 = x - size.Width / 2; y1 = y; break; case TextSymbolAlignment.leftAlignOver: x1 = x; y1 = y - size.Height; break; case TextSymbolAlignment.leftAlignCenter: x1 = x; y1 = y - size.Height / 2; break; case TextSymbolAlignment.leftAlignUnder: x1 = x; y1 = y; break; } return(new AnnotationPolygon(x1, y1, size.Width, size.Height)); }
private AnnotationPolygon AnnotationPolygon(IDisplay display, string text, float x, float y, TextSymbolAlignment symbolAlignment) { var size = MeasureStringSize(display, text); return(AnnotationPolygon(display, size, x, y, symbolAlignment)); }
public List <IAnnotationPolygonCollision> AnnotationPolygon(IDisplay display, IGeometry geometry, TextSymbolAlignment symbolAlignment) { if (_font == null || _text == null || display.Canvas == null) { return(null); } List <IAnnotationPolygonCollision> polygons = new List <IAnnotationPolygonCollision>(); if (geometry is IPoint) { #region IPoint double x = ((IPoint)geometry).X; double y = ((IPoint)geometry).Y; display.World2Image(ref x, ref y); var annotationPolygon = AnnotationPolygon(display, (float)x, (float)y, symbolAlignment); annotationPolygon.Rotate((float)x, (float)y, Angle); polygons.Add(annotationPolygon); #endregion } else if (geometry is IMultiPoint) { #region IMultipoint IMultiPoint pColl = (IMultiPoint)geometry; for (int i = 0; i < pColl.PointCount; i++) { double x = pColl[i].X; double y = pColl[i].Y; display.World2Image(ref x, ref y); var annotationPolygon = AnnotationPolygon(display, (float)x, (float)y, symbolAlignment); annotationPolygon.Rotate((float)x, (float)y, Angle); polygons.Add(annotationPolygon); } #endregion } else if (geometry is IDisplayPath) { if (String.IsNullOrEmpty(_text)) { return(null); } IDisplayPath path = (IDisplayPath)geometry; #region Text On Path var format = StringFormatFromAlignment(_align); IDisplayCharacterRanges ranges = this.MeasureCharacterWidth(display); float sizeW = ranges.Width; float stat0 = path.Chainage, stat1 = stat0 + sizeW, stat = stat0; if (stat0 < 0) { return(null); } #region Richtung des Textes CanvasPointF?p1_ = path.PointAt(stat0); //SpatialAlgorithms.Algorithm.DisplayPathPoint(path, stat0); CanvasPointF?p2_ = path.PointAt(stat1); //SpatialAlgorithms.Algorithm.DisplayPathPoint(path, stat1); if (!p1_.HasValue || !p2_.HasValue) { return(null); } if (p1_.Value.X > p2_.Value.X) { #region Swap Path Direction path.ChangeDirection(); stat = stat0 = path.Length - stat1; stat1 = stat0 + sizeW; #endregion } #endregion AnnotationPolygonCollection charPolygons = new AnnotationPolygonCollection(); float x, y, angle; for (int i = 0; i < _text.Length; i++) { CanvasRectangleF cSize = ranges[i]; int counter = 0; while (true) { CanvasPointF?p1 = path.PointAt(stat); //SpatialAlgorithms.Algorithm.DisplayPathPoint(path, stat); CanvasPointF?p2 = path.PointAt(stat + cSize.Width); if (!p1.HasValue || !p2.HasValue) { return(null); } angle = (float)(Math.Atan2(p2.Value.Y - p1.Value.Y, p2.Value.X - p1.Value.X) * 180.0 / Math.PI); //float ccc = 0f; //angle = 0f; //for (float xxx = 0f; xxx <= cSize.Width; xxx += cSize.Width / 10f, ccc += 1f) //{ // p2 = path.PointAt(stat + xxx/*cSize.Width*/); //SpatialAlgorithms.Algorithm.DisplayPathPoint(path, stat + cSize.Width); // if (p1 == null || p2 == null) // return null; // angle += (float)(Math.Atan2(((PointF)p2).Y - ((PointF)p1).Y, ((PointF)p2).X - ((PointF)p1).X) * 180.0 / Math.PI); //} //angle /= ccc; x = p1.Value.X; y = p1.Value.Y; AnnotationPolygon polygon = null; switch (format.LineAlignment) { case StringAlignment.Near: polygon = new Symbology.AnnotationPolygon((float)x + .1f * cSize.Width, (float)y + .2f * cSize.Height, .8f * cSize.Width, .6f * cSize.Height); break; case StringAlignment.Far: polygon = new Symbology.AnnotationPolygon((float)x + .1f * cSize.Width, (float)y - .8f * cSize.Height, .8f * cSize.Width, .6f * cSize.Height); break; default: polygon = new Symbology.AnnotationPolygon((float)x + .1f * cSize.Width, (float)y - .6f * cSize.Height / 2f, .8f * cSize.Width, .6f * cSize.Height); break; } polygon.Rotate((float)x, (float)y, Angle + angle); if (charPolygons.CheckCollision(polygon)) { stat += cSize.Width / 10.0f; counter++; if (counter > 7) { return(null); } continue; } charPolygons.Add(polygon); //using (System.Drawing.Drawing2D.GraphicsPath grpath = new System.Drawing.Drawing2D.GraphicsPath()) //{ // grpath.StartFigure(); // grpath.AddLine(polygon[0], polygon[1]); // grpath.AddLine(polygon[1], polygon[2]); // grpath.AddLine(polygon[2], polygon[3]); // grpath.CloseFigure(); // display.GraphicsContext.FillPath(Brushes.Aqua, grpath); //} break; } stat += cSize.Width;// +_font.Height * 0.1f; } if (charPolygons.Count > 0) { #region Glättung //for (int i = 1; i < charPolygons.Count - 1; i++) //{ // double angle0 = ((AnnotationPolygon)charPolygons[i - 1]).Angle; // double angle2 = ((AnnotationPolygon)charPolygons[i + 1]).Angle; // ((AnnotationPolygon)charPolygons[i]).Angle = (angle0 + angle2) * 0.5; // float x0 = ((AnnotationPolygon)charPolygons[i - 1]).X1; // float y0 = ((AnnotationPolygon)charPolygons[i - 1]).Y1; // float x2 = ((AnnotationPolygon)charPolygons[i + 1]).X1; // float y2 = ((AnnotationPolygon)charPolygons[i + 1]).Y1; // ((AnnotationPolygon)charPolygons[i]).X1 = (x0 + x2) * 0.5f; // ((AnnotationPolygon)charPolygons[i]).Y1 = (y0 + y2) * 0.5f; //} #endregion polygons.Add(charPolygons); path.AnnotationPolygonCollision = charPolygons; } #endregion } else if (geometry is IPolyline) { IPolyline pLine = (IPolyline)geometry; for (int iPath = 0; iPath < pLine.PathCount; iPath++) { IPath path = pLine[iPath]; if (path.PointCount == 0) { continue; } #region Simple Method IPoint p1 = path[0], p2; for (int iPoint = 1; iPoint < path.PointCount; iPoint++) { p2 = path[iPoint]; double angle = -Math.Atan2(p2.Y - p1.Y, p2.X - p1.X) * 180.0 / Math.PI; if (display.DisplayTransformation.UseTransformation) { angle -= display.DisplayTransformation.DisplayRotation; } if (angle < 0) { angle += 360; } if (angle > 90 && angle < 270) { angle -= 180; } var format = StringFormatFromAlignment(_align); double x, y; if (format.Alignment == StringAlignment.Center) { x = p1.X * 0.5 + p2.X * 0.5; y = p1.Y * 0.5 + p2.Y * 0.5; } else if (format.Alignment == StringAlignment.Far) { x = p2.X; y = p2.Y; } else { x = p1.X; y = p1.Y; } display.World2Image(ref x, ref y); var annotationPolygon = AnnotationPolygon(display, (float)x, (float)y, symbolAlignment); annotationPolygon.Rotate((float)x, (float)y, Angle); polygons.Add(annotationPolygon); p1 = p2; } #endregion } } return(polygons.Count > 0 ? polygons : null); }
private LabelAppendResult TryAppend(IDisplay display, ITextSymbol symbol, IGeometry geometry, List <IAnnotationPolygonCollision> aPolygons, bool checkForOverlap, TextSymbolAlignment symbolAlignment) { IAnnotationPolygonCollision labelPolyon = null; IEnvelope labelPolyonEnvelope = null; bool outside = true; if (aPolygons != null) { #region Check Outside foreach (IAnnotationPolygonCollision polyCollision in aPolygons) { AnnotationPolygonEnvelope env = polyCollision.Envelope; if (env.MinX < 0 || env.MinY < 0 || env.MaxX > _bitmap.Width || env.MaxY > _bitmap.Height) { return(LabelAppendResult.Outside); } } #endregion foreach (IAnnotationPolygonCollision polyCollision in aPolygons) { AnnotationPolygonEnvelope env = polyCollision.Envelope; //int minx = (int)Math.Max(0, env.MinX); //int maxx = (int)Math.Min(_bm.Width - 1, env.MaxX); //int miny = (int)Math.Max(0, env.MinY); //int maxy = (int)Math.Min(_bm.Height, env.MaxY); //if (minx > _bm.Width || maxx <= 0 || miny > _bm.Height || maxy <= 0) continue; // liegt außerhalb!! int minx = (int)env.MinX, miny = (int)env.MinX, maxx = (int)env.MaxX, maxy = (int)env.MaxY; outside = false; if (!_first && checkForOverlap) { if (_method == OverlapMethod.Pixel) { #region Pixel Methode for (int x = minx; x < maxx; x++) { for (int y = miny; y < maxy; y++) { //if (x < 0 || x >= _bm.Width || y < 0 || y >= _bm.Height) continue; if (polyCollision.Contains(x, y)) { //_bm.SetPixel(x, y, Color.Yellow); if (!_back.Equals(_bitmap.GetPixel(x, y))) { return(LabelAppendResult.Overlap); } } } } #endregion } else { #region Geometrie Methode labelPolyon = polyCollision; foreach (List <IAnnotationPolygonCollision> indexedPolygons in _gridArrayPolygons.Collect(new Envelope(env.MinX, env.MinY, env.MaxX, env.MaxY))) { foreach (IAnnotationPolygonCollision lp in indexedPolygons) { if (lp.CheckCollision(polyCollision) == true) { return(LabelAppendResult.Overlap); } } } #endregion } } else { _first = false; if (_method == OverlapMethod.Geometry) { #region Geometrie Methode labelPolyon = polyCollision; #endregion } } labelPolyonEnvelope = new Envelope(env.MinX, env.MinY, env.MaxX, env.MaxY); } } if (outside) { return(LabelAppendResult.Outside); } if (labelPolyon != null) { List <IAnnotationPolygonCollision> indexedPolygons = _gridArrayPolygons[labelPolyonEnvelope]; indexedPolygons.Add(labelPolyon); //using (System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath()) //{ // path.StartFigure(); // path.AddLine(labelPolyon[0], labelPolyon[1]); // path.AddLine(labelPolyon[1], labelPolyon[2]); // path.AddLine(labelPolyon[2], labelPolyon[3]); // path.CloseFigure(); // _graphics.FillPath(Brushes.Aqua, path); //} } var originalCanvas = display.Canvas; ((Display)display).Canvas = _canvas; symbol.Draw(display, geometry, symbolAlignment); ((Display)display).Canvas = originalCanvas; if (_directDraw) { symbol.Draw(display, geometry, symbolAlignment); } return(LabelAppendResult.Succeeded); }
public List <IAnnotationPolygonCollision> AnnotationPolygon(IDisplay display, IGeometry geometry, TextSymbolAlignment symbolAlignment) { List <IAnnotationPolygonCollision> aPolygons = new List <IAnnotationPolygonCollision>(); foreach (SymbolCollectionItem item in _symbols) { if (item.Symbol is ILabel) { List <IAnnotationPolygonCollision> pList = ((ILabel)item.Symbol).AnnotationPolygon(display, geometry, symbolAlignment); if (pList == null) { continue; } foreach (AnnotationPolygon aPolygon in pList) { if (aPolygons != null) { aPolygons.Add(aPolygon); } } } } return(aPolygons); }
private AnnotationPolygon AnnotationPolygon(IDisplay display, float x, float y, TextSymbolAlignment symbolAlignment) { return(AnnotationPolygon(display, _text, x, y, symbolAlignment)); }