4.7.2 Chart ToolBar

From MultiCharts
Jump to navigation Jump to search

The studies can activate and access the toolbar for the chart. Such a toolbar can contain custom controls. Thus it is possible to let the user set the necessary values, colors, styles, etc., for the data shown by an indicator in a fast and convenient manner. Access to the toolbar is performed via the ChartToolBar property that is returned by the ICustomToolBar interface. This interface contains methods for accessing the toolbar and the property for manipulating visibility of this toolbar. Access to the toolbar is performed by calling one of the following methods:

  1. void AccessToolBar(ToolBarAction action);
  2. void AccessToolBarAsync(ToolBarAction action);

The difference between these two methods is the delegate of public delegate void ToolBarAction(ToolStrip tb) type will be executed synchronously when void AccessToolBar(ToolBarAction action); and asynchronously when void AccessToolBarAsync(ToolBarAction action) is used.

The reason for using a delegate instead of calling the toolbar directly is simple: the study is calculated in its thread while chart toolbar as well chart controls are working in the main thread (UI).

The delegate accepts a single argument of System.Windows.Forms.ToolStrip, the type that is familiar to those who have dealt with toolbar creation for WinForms windows. More information about this type and its methods can be found on msdn.

NOTE:A pre-built indicator _Chart_ToolBar_Example_ and a signal _ChartToolBar_Trading_ may be used as examples.