CellPadding: IGxRectF;
The CellPadding property determines the visualizer legend area, which contains items.
To determine horizontal and vertical element paddings inside the legend with intervals, use IVZIntervalsLegend.CellSpacing.
Executing the example requires a form containing the components:
ReportBox with the ReportBox1 identifier
UiReport with the UiReport1 identifier that is a data source for ReportBox1.
It is also required to have:
A regular report with a table. One of table dimensions has the Background Color metric type. The regular report is a data source for UiReport1.
The Marker.png graphic image in the root of the disc C.
Add links to the Drawing, Express, Tab, Visualizators system assemblies.
Sub UserProc;
Var
Report: IPrxReport;
TS: ITabSheet;
Grid: IEaxGrid;
Pos, CellPadPos: IGxRectF;
Visualizer: IPrxVisualizerLegend;
i: Integer;
VZLegend: IVZIntervalsLegend;
VZLegendBase: IVZLegendBase;
Color: IGxColor;
Pen: IGxPenBase;
LegItem: IVZLegendItem;
ResourceImage: IVZResourceImage;
Begin
// Get regular report
Report := UiReport1.Report;
// Get active report sheet
TS := (Report.ActiveSheet As IPrxTable) As ITabSheet;
// Insert table legend to report
Pos := New GxRectF.Create(0, 0, 0, 0);
Pos.Left := TS.View.Selection.Range.Location.X;
Pos.Top := TS.View.Selection.Range.Location.Y;
Pos.Width := TS.View.Selection.Range.Width;
Pos.Height := TS.View.Selection.Range.Height;
TS.Objects.Add("PrxVisualizerLegend", Pos);
Visualizer := TS.Objects.Item(TS.Objects.Count - 1).Extension As IPrxVisualizerLegend;
Grid := Report.DataArea.Views.Item(0) As IEaxGrid;
i := Grid.Legends.Add(Grid.IndicatorLegendAssignment(EaxGridIndicatorType.BackgroundColor));
Visualizer.SetEaxObjectLegend(Grid, EaxGridIndicatorType.BackgroundColor);
// Get table legend with intervals
VZLegend := Visualizer.PlacedControl As IVZIntervalsLegend;
VZLegendBase := VZLegend As IVZLegendBase;
// Create lines for header and footer
Color := New GxColor.CreateRGB(120, 0, 120);
Pen := New GxPen.CreateSolid(Color, 5);
VZLegendBase.HeaderLine := Pen;
VZLegendBase.Footer := VZLegendBase.Header;
VZLegendBase.FooterLine := Pen;
// Change location of objects inside tooltip and fill color
CellPadPos := New GxRectF.Create(20, 100, 100, 0);
VZLegend.CellPadding := CellPadPos;
VZLegend.ColorApplying := LegendColorApplying.Background;
VZLegend.Style.Background := New GxSolidBrush.Create(GxColor.FromName("Yellow"));
// Create a collection of legend items and add the first item to it
VZLegend.Items := New VZLegendItems.Create;
LegItem := New VZLegendItem.Create;
LegItem.Text := "TEXT";
LegItem.Color := GxColor.FromName("Blue");
VZLegend.Items.Add(LegItem);
// Align item left
VZLegend.HorizontalCellsAligment := LegendItemsHorizontalAlignment.Right;
// Create a legend marker and apply to legend item
VZLegend.Marker := New VZIntervalsLegendMarker.Create;
ResourceImage := New VZResourceImage.Create;
ResourceImage.Bitmap := New GxBitmap.CreateFromFile("C:\Marker.png");
VZLegend.Marker.Image := ResourceImage;
VZLegend.Marker.Mask := ResourceImage;
VZLegend.Marker.Marker := VisualizatorSizeMarkerShape.Custom;
// Refresh visualizer
Visualizer.Update;
End Sub UserProc;
After executing the example a map legend is created in the table cell range selected by a user. The legend has yellow background, one item aligned right, blue item marker. The marker is imported from the file.
See also: