Framework / Thin Web / Tools / Tools Overview
In This Topic
    Tools Overview
    In This Topic

    Both the Chart and Diagram ThinWeb controls are build using MVC design pattern and share a set of common tools. Each tool generates a client side JScript object that captures tool specific client mouse events and optionally produces an update request to the server. The following sections describe the tools common to both the Chart and Diagram ThinWeb controls in the package.

    Each tool has Enabled property that controls whether the tool is currently active and will process client events. By default this property is set to true meaning that the tool will process events, however you may choose to add disabled tools that the user can later enable by clicking on a button in the integrated toolbar that enables this tool. The following code snippet shows how to add two tools to the collection which are initially disabled:

    C#
    Copy Code

    protected void Page_Load(object sender, EventArgs e)
    {
    if (!NThinChartControl1.Initialized)
    {
    // perform initial initialization here
    NChart chart = NThinChartControl1.Charts[0];
    NBarSeries bar = new NBarSeries();
    bar.Values.Add(10);
    bar.Values.Add(20);
    bar.InteractivityStyles[0] =
    new NInteractivityStyle("Bar 1", CursorType.Hand);
    bar.InteractivityStyles[1] =
    new NInteractivityStyle("Bar 2", CursorType.Hand);
    chart.Series.Add(bar);

    // add tooltip tool
    NTooltipTool tooltipTool = new NTooltipTool();
    tooltipTool.Enabled =
    false;
    NThinChartControl1.Controller.Tools.Add(tooltipTool);
    // add cursor tool
    NCursorTool cursorTool = new NCursorTool();
    cursorTool.Enabled =
    false;
    NThinChartControl1.Controller.Tools.Add(cursorTool);

    // give the user the ability to enable the tooltip / cursor change over bars
    NThinChartControl1.Toolbar.Items.Add(new NToolbarButton(new NToggleTooltipToolAction()));
    NThinChartControl1.Toolbar.Items.Add(
    new NToolbarButton(new NToggleCursorToolAction()));
    }
    }

    Visual Basic
    Copy Code

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    If (Not NThinChartControl1.Initialized) Then

    ' perform initial initialization here
    Dim chart As NChart = NThinChartControl1.Charts(0)
    Dim bar As New NBarSeries

    bar.Values.Add(10)
    bar.Values.Add(20)
    bar.InteractivityStyles(0) =
    New NInteractivityStyle("Bar 1", CursorType.Hand)
    bar.InteractivityStyles(1) =
    New NInteractivityStyle("Bar 2", CursorType.Hand)

    chart.Series.Add(bar)

    ' add tooltip tool
    Dim tooltipTool As New NTooltipTool()
    tooltipTool.Enabled =
    False
    NThinChartControl1.Controller.Tools.Add(tooltipTool)

    ' add cursor tool
    Dim cursorTool As New NCursorTool()
    cursorTool.Enabled = False
    NThinChartControl1.Controller.Tools.Add(cursorTool)

    ' give the user the ability to enable the tooltip / cursors change over bars
    NThinChartControl1.Toolbar.Items.Add(New NToolbarButton(New NToggleTooltipToolAction()))
    NThinChartControl1.Toolbar.Items.Add(
    New NToolbarButton(New NToggleCursorToolAction()))
    End If
    End Sub

    The other common tool property is Exclusive, which is used to mark that when the tool is enabled it should be the only currently active tool. When the user clicks on a toolbar button that enables an exclusive tool all other tool that are marked as exclusive will be disabled. In the context of the code example above if you mark the tooltip and and cursor tools as exclusive:

    C#
    Copy Code

    tooltipTool.Exclusive = true;
    cursorTool.Exclusive = true;

    Visual Basic
    Copy Code
    tooltipTool.Exclusive = True
    cursorTool.Exclusive = True

    The user will still be able to enable the tooltip or cursor tool from the toolbar, but never both of them simulataneously. The following topics discuss the common ThinWeb tools.