Anchors

View as Markdown

Definition

Returns a custom collection of ChartAnchors which will represent various points of the drawing tool.

You must declare this property with the chart anchors used in the drawing tool which you plan on using for iteration. Doing so will expose a simple enumerator which will allow you to to iterate over the chart anchors in which have been defined in this interface.

Property Value

A virtual IEnumerable interface consisting of ChartAnchors

Syntax

You must override this property using the following syntax:

public override IEnumerable\<chartanchor\> Anchors \{ \}

Examples

1//defines the chart anchors used for the drawing tool
2public ChartAnchor StartAnchor { get; set; }
3public ChartAnchor MiddleAnchor { get; set; }
4public ChartAnchor EndAnchor { get; set; }
5
6//create a collection of chart anchors used for a simple iteration
7public override IEnumerable<chartanchor> Anchors
8{
9 get
10 {
11 return new[] { StartAnchor, MiddleAnchor, EndAnchor };
12 }
13}
14
15//setup our chart anchor instances and assign a display name to each
16protected override void OnStateChange()
17{
18 if (State == State.SetDefaults)
19 {
20 Name = "My Drawing Tool";
21
22 StartAnchor = new ChartAnchor();
23 MiddleAnchor = new ChartAnchor();
24 EndAnchor = new ChartAnchor();
25
26 StartAnchor.DisplayName = "My Start Anchor";
27 MiddleAnchor.DisplayName = "My Middle Anchor";
28 EndAnchor.DisplayName = "My End Anchor";
29 }
30}
31
32//for each render pass, print out the display name of the chart anchors
33protected override void OnRender(ChartControl chartControl, ChartScale chartScale)
34{
35 foreach (ChartAnchor anchor in Anchors)
36 {
37 Print(anchor.DisplayName);
38 }
39}