public void Release() { if (_lineSymbol != null) { _lineSymbol.Release(); } if (_textSymbol != null) { _textSymbol.Release(); } _lineSymbol = null; _textSymbol = null; }
public void Release() { if (_symbol is ISymbol) { _symbol.Release(); } _symbol = null; _labelStrings.Clear(); }
private void RendererBox_DrawItem(object sender, DrawItemEventArgs e) { if (e.Index >= RendererBox.Items.Count || e.Index < 0) { return; } object item = RendererBox.Items[e.Index]; if (item is RendererItem) { SolidBrush b, f; if ((e.State & DrawItemState.Selected) != 0) { b = (SolidBrush)Brushes.DarkBlue; f = (SolidBrush)Brushes.White; } else { b = (SolidBrush)Brushes.White; f = (SolidBrush)Brushes.Black; } using (System.Drawing.Font font = new Font("Arial", 10)) { e.Graphics.FillRectangle(b, e.Bounds); Rectangle rect = new Rectangle(e.Bounds.X + 20, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height); e.Graphics.DrawString(item.ToString(), font, f, rect); rect = new Rectangle(5, e.Bounds.Y + 2, 11, 11); e.Graphics.DrawImage( (((RendererItem)item).ShowLegend ? global::gView.Carto.Rendering.UI.Properties.Resources.CollapseIcon : global::gView.Carto.Rendering.UI.Properties.Resources.ExpandIcon), rect); } } else if (item is LegendItem) { Rectangle rect = new Rectangle(20, e.Bounds.Top, 30, 20); ILegendItem legendItem = ((LegendItem)item).Item; if (legendItem != null) { if (legendItem is ISymbol) { if (legendItem is ITextSymbol) { ITextSymbol ts = ((ISymbol)legendItem).Clone() as ITextSymbol; if (ts != null) { ts.Text = "Abc"; ts.TextSymbolAlignment = TextSymbolAlignment.Center; ts.Angle = 0; ts.HorizontalOffset = ts.VerticalOffset = 0; SymbolPreview.Draw(e.Graphics, rect, ts); ts.Release(); } } else { SymbolPreview.Draw(e.Graphics, rect, (ISymbol)legendItem); } } if (legendItem.LegendLabel != String.Empty) { using (Font font = new Font("Arial", 9)) { e.Graphics.DrawString(legendItem.LegendLabel, font, Brushes.Black, 52, e.Bounds.Top + e.Bounds.Height / 2 - font.Height / 2); SizeF stringSize = e.Graphics.MeasureString(legendItem.LegendLabel, font); RendererBox.HorizontalExtent = (int)Math.Max(RendererBox.HorizontalExtent, 52 + stringSize.Width); } } } } }