Grid Summary Represents the Grid class.
Signature
public class Grid : Panel
Namespace cAlgo.API
Examples Example 1 (C#) Example 2 (PYTHON)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83 using cAlgo.API ;
namespace cAlgo
{
// This sample shows how to use Grid panel control
[Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
public class GridSample : Indicator
{
[Parameter("Grid Rows #", DefaultValue = 10)]
public int GridRowsNumber { get ; set ; }
[Parameter("Grid Columns #", DefaultValue = 2)]
public int GridColumnsNumber { get ; set ; }
[Parameter("Grid Row Length", DefaultValue = 2)]
public int GridRowLength { get ; set ; }
[Parameter("Grid Row Length Unit Type", DefaultValue = GridUnitType.Auto)]
public GridUnitType GridRowLengthUnitType { get ; set ; }
[Parameter("Grid Column Length", DefaultValue = 2)]
public int GridColumnLength { get ; set ; }
[Parameter("Grid Column Length Unit Type", DefaultValue = GridUnitType.Auto)]
public GridUnitType GridColumnLengthUnitType { get ; set ; }
protected override void Initialize ()
{
var grid = new Grid ( GridRowsNumber , GridColumnsNumber )
{
BackgroundColor = Color . Gold ,
Opacity = 0.6 ,
HorizontalAlignment = HorizontalAlignment . Center ,
VerticalAlignment = VerticalAlignment . Center ,
ShowGridLines = true ,
};
for ( int iRow = 0 ; iRow < GridRowsNumber ; iRow ++ )
{
var row = grid . Rows [ iRow ];
SetGridRowLength ( row );
for ( int iColumn = 0 ; iColumn < GridColumnsNumber ; iColumn ++ )
{
var column = grid . Columns [ iColumn ];
SetGridColumnLength ( column );
grid . AddChild ( new TextBlock
{
Text = string . Format ( "Row {0} and Column {1}" , iRow , iColumn ),
Margin = 5 ,
ForegroundColor = Color . Black ,
FontWeight = FontWeight . ExtraBold
}, iRow , iColumn );
}
}
Chart . AddControl ( grid );
}
private void SetGridRowLength ( GridRow row )
{
switch ( GridRowLengthUnitType )
{
case GridUnitType . Auto :
row . SetHeightToAuto ();
break ;
case GridUnitType . Pixel :
row . SetHeightInPixels ( GridRowLength );
break ;
case GridUnitType . Star :
row . SetHeightInStars ( GridRowLength );
break ;
}
}
private void SetGridColumnLength ( GridColumn column )
{
switch ( GridColumnLengthUnitType )
{
case GridUnitType . Auto :
column . SetWidthToAuto ();
break ;
case GridUnitType . Pixel :
column . SetWidthInPixels ( GridColumnLength );
break ;
case GridUnitType . Star :
column . SetWidthInStars ( GridColumnLength );
break ;
}
}
public override void Calculate ( int index )
{
}
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42 import clr
clr . AddReference ( "cAlgo.API" )
from cAlgo.API import *
# GridRowsNumber, GridColumnsNumber, GridRowLength, GridRowLengthUnitType, GridColumnLength,
# and GridColumnLengthUnitType are parameters of indicator defined on it's C# file.
class Test ():
def initialize ( self ):
grid = Grid ( api . GridRowsNumber , api . GridColumnsNumber )
grid . BackgroundColor = Color . Gold
grid . Opacity = 0.6
grid . HorizontalAlignment = HorizontalAlignment . Center
grid . VerticalAlignment = VerticalAlignment . Center
grid . ShowGridLines = True
for iRow in range ( api . GridRowsNumber ):
row = grid . Rows [ iRow ]
self . set_grid_row_length ( row )
for iColumn in range ( api . GridColumnsNumber ):
column = grid . Columns [ iColumn ]
self . set_grid_column_length ( column )
textBlock = TextBlock ()
textBlock . Text = f "Row { iRow } and Column { iColumn } "
textBlock . Margin = Thickness ( 5 )
textBlock . ForegroundColor = Color . Black
textBlock . FontWeight = FontWeight . ExtraBold
grid . AddChild ( textBlock , iRow , iColumn )
api . Chart . AddControl ( grid )
def set_grid_row_length ( self , row ):
match api . GridRowLengthUnitType :
case GridUnitType . Auto :
row . SetHeightToAuto ()
case GridUnitType . Pixel :
row . SetHeightInPixels ( api . GridRowLength )
case GridUnitType . Star :
row . SetHeightInStars ( api . GridRowLength )
def set_grid_column_length ( self , column ):
match api . GridColumnLengthUnitType :
case GridUnitType . Auto :
column . SetWidthToAuto ()
case GridUnitType . Pixel :
column . SetWidthInPixels ( api . GridColumnLength )
case GridUnitType . Star :
column . SetWidthInStars ( api . GridColumnLength )
See Also Methods AddChild (2) AddChild (1 of 2)
Summary
Adds a child element.
Signature
public void AddChild ( ControlBase child , int row , int column )
Parameters
Name Type Description child ControlBase The child. row int The row. column int The column.
Return Value
void
AddChild (2 of 2)
Summary
Adds the child.
Signature
public void AddChild ( ControlBase child , int row , int column , int rowSpan , int columnSpan )
Parameters
Name Type Description child ControlBase The child. row int The row. column int The column. rowSpan int The row span. columnSpan int The column span.
Return Value
void
AddRow Summary
Adds a row.
Signature
Return Value
GridRow
AddColumn Summary
Adds a column.
Signature
public GridColumn AddColumn ()
Return Value
GridColumn
AddRows Summary
Adds a rows.
Signature
public void AddRows ( int count )
Parameters
Name Type Description count int The count.
Return Value
void
AddColumns Summary
Adds columns.
Signature
public void AddColumns ( int count )
Parameters
Name Type Description count int The count.
Return Value
void
RemoveRowAt Summary
Removes the row.
Signature
public void RemoveRowAt ( int index )
Parameters
Name Type Description index int The index.
Return Value
void
GetChildPosition Summary
Returns a child position info if exists otherwise null.
Signature
public GridChildPositionInfo ? GetChildPosition ( ControlBase child )
Parameters
Name Type Description child ControlBase Child control
Return Value
GridChildPositionInfo?
RemoveColumnAt Summary
Removes a column.
Signature
public void RemoveColumnAt ( int index )
Parameters
Name Type Description index int The index.
Return Value
void
CreateGridRow Signature
private SmallGridRow CreateGridRow ()
Return Value
SmallGridRow
CreateGridColumn Signature
private SmallGridColumn CreateGridColumn ()
Return Value
SmallGridColumn
Properties Rows Summary
Gets the read only list of the grid rows.
Signature
public IReadonlyList < GridRow > Rows { get ;}
Return Value
IReadonlyList
Columns Summary
Gets the read only list of the grid columns.
Signature
public IReadonlyList < GridColumn > Columns { get ;}
Return Value
IReadonlyList
ShowGridLines Summary
Defines if the grid lines are visible.
Signature
public bool ShowGridLines { get ; set ;}
Return Value
bool