public SizeF Measure(GeoCanvas geoCanvas) { DrawingRectangleF rect; try { rect = geoCanvas.MeasureText(Text, NotifiedGeoFont.ToGeoFont()); } catch (Exception ex) { GisEditor.LoggerManager.Log(LoggerLevel.Debug, ex.Message, new ExceptionInfo(ex)); if (string.IsNullOrEmpty(Text.Trim())) { rect = geoCanvas.MeasureText("a", new GeoFont("ARIAL", 10, NotifiedGeoFont.FontStyles)); } else { rect = geoCanvas.MeasureText(Text, new GeoFont("ARIAL", NotifiedGeoFont.FontSize, NotifiedGeoFont.FontStyles)); } } float width = rect.Width; width += ImageLeftPadding; width += ImageWidth; width += ImageRightPadding; width += TextLeftPadding; width += TextRightPadding; float imageHeight = ImageTopPadding + ImageHeight + ImageBottomPadding; float textHeight = TextTopPadding + rect.Height + TextBottomPadding; float height = imageHeight > textHeight ? imageHeight : textHeight; return(new SizeF(width, height)); }
public LegendItem ToLegendItem() { this.coreItem.TextStyle.Font = NotifiedGeoFont.ToGeoFont(); LegendItem newLegendItem = new LegendItem((int)Width, (int)Height, ImageWidth, ImageHeight, ImageStyle, new TextStyle(Text, NotifiedGeoFont.ToGeoFont(), TextSolidBrush)); newLegendItem.BackgroundMask = BackgroundMask; newLegendItem.BottomPadding = BottomPadding; newLegendItem.ImageBottomPadding = ImageBottomPadding; newLegendItem.ImageJustificationMode = ImageJustificationMode; newLegendItem.ImageLeftPadding = ImageLeftPadding; newLegendItem.ImageStyle = ImageStyle; newLegendItem.ImageMask = ImageMask; newLegendItem.ImageRightPadding = ImageRightPadding; newLegendItem.ImageTopPadding = ImageTopPadding; newLegendItem.LeftPadding = LeftPadding; newLegendItem.RightPadding = RightPadding; newLegendItem.TextBottomPadding = TextBottomPadding; newLegendItem.TextLeftPadding = TextLeftPadding; newLegendItem.TextMask = TextMask; newLegendItem.TextRightPadding = TextRightPadding; newLegendItem.TextTopPadding = TextTopPadding; newLegendItem.TopPadding = TopPadding; if (this.ImageStyle == null) { newLegendItem.ImageStyle = new PointStyle(); } return(newLegendItem); }