Draw(Graphics: IGxGraphics; Rect: IGxRectF);
Graphics. Graphic context for rendering.
Rect. Real rectangle where a legend is rendered.
The Draw method draws a legend in the specified rectangle.
Executing the example requires a form, a button named Button1 on the form, the UiMap component named UiMap1 that is a data source for the MapBox component. The UiMap1 component must have a connected map that contains a map factor only.The ImageBox component named ImageBox1 must also be available.
Sub Button1OnClick(Sender: Object; Args: IMouseEventArgs);
Var
Map: IMap;
Layer: IMapLayer;
Legend: IMapLegend;
BitMap: IGxBitmap;
Graphics: IGxGraphics;
Rect: IGxRectF;
Begin
Map := UiMap1.Map;
Legend := New DxMapLegend.Create As IMapLegend;
Map.View.Legend := Legend;
Legend.Visible := True;
Layer := Map.Layers.FindByName("Regions");
Legend.Visual := Layer.Visuals.Item(0);
BitMap := GxBitmap.CreateNew(ImageBox1.ClientWidth, ImageBox1.ClientHeight, GxPixelFormat.Format32bppArgb);
Graphics := GxGraphicsClass.FromImage(BitMap);
Rect := New GxRectF.Create(0, 0, ImageBox1.Width, ImageBox1.Height);
Legend.Draw(Graphics, Rect);
ImageBox1.Image := BitMap;
End Sub Button1OnClick;
After executing the example the ImageBox1 component stores a drawn map legend.
See also: