1 //-------------------------------------------------------------
2 // <copyright company=
\92Microsoft Corporation
\92>
3 // Copyright © Microsoft Corporation. All Rights Reserved.
5 //-------------------------------------------------------------
6 // @owner=alexgor, deliant
7 //=================================================================
8 // File: ChartAreaCollection.cs
10 // Namespace: System.Web.UI.WebControls[Windows.Forms].Charting
12 // Classes: ChartAreaCollection
14 // Purpose: ChartAreaCollection class represents a strongly
15 // typed collection of ChartArea objects.
17 // Reviewed: GS - Aug 8, 2002
19 // AG - Microsoft 16, 2007
21 //===================================================================
24 #region Used namespaces
27 using System.Collections;
29 using System.ComponentModel;
35 namespace System.Windows.Forms.DataVisualization.Charting
37 namespace System.Web.UI.DataVisualization.Charting
42 /// The ChartAreaCollection class represents a strongly typed collection of
43 /// ChartArea objects. Each chart area has a unique name in the collection
44 /// and can be retrieved by name or by index.
47 [AspNetHostingPermission(System.Security.Permissions.SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
48 [AspNetHostingPermission(System.Security.Permissions.SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
50 public class ChartAreaCollection : ChartNamedElementCollection<ChartArea>
56 /// Initializes a new instance of the <see cref="ChartAreaCollection"/> class.
58 /// <param name="chartPicture">Parent chart picture.</param>
59 internal ChartAreaCollection(ChartPicture chartPicture) : base(chartPicture)
67 /// Gets the default chart area name.
69 internal string DefaultNameReference
71 get { return this.Count > 0 ? this[0].Name : String.Empty; }
78 /// Creates a new ChartArea with the specified name and adds it to the collection.
80 /// <param name="name">The new chart area name.</param>
81 /// <returns></returns>
82 public ChartArea Add(string name)
84 ChartArea area = new ChartArea(name);
91 #region Event handlers
93 /// Updates the ChartArea alignment references to another chart areas.
95 /// <param name="sender">The sender.</param>
96 /// <param name="e">The <see cref="Charting.NameReferenceChangedEventArgs"/> instance containing the event data.</param>
97 internal void ChartAreaNameReferenceChanged(object sender, NameReferenceChangedEventArgs e)
99 foreach (ChartArea chartArea in this)
100 if (chartArea.AlignWithChartArea == e.OldName)
101 chartArea.AlignWithChartArea = e.NewName;