Updates referencesource to .NET 4.7
[mono.git] / mcs / class / referencesource / System.Web.DataVisualization / Common / General / ChartAreaCollection.cs
1 //-------------------------------------------------------------
2 // <copyright company=\92Microsoft Corporation\92>
3 //   Copyright © Microsoft Corporation. All Rights Reserved.
4 // </copyright>
5 //-------------------------------------------------------------
6 // @owner=alexgor, deliant
7 //=================================================================
8 //  File:               ChartAreaCollection.cs
9 //
10 //  Namespace:  System.Web.UI.WebControls[Windows.Forms].Charting
11 //
12 //      Classes:        ChartAreaCollection
13 //
14 //  Purpose:    ChartAreaCollection class represents a strongly 
15 //              typed collection of ChartArea objects.
16 //
17 //      Reviewed:       GS - Aug 8, 2002
18 //                              AG - Aug 8, 2002
19 //              AG - Microsoft 16, 2007
20 //
21 //===================================================================
22
23
24 #region Used namespaces
25
26 using System;
27 using System.Collections;
28 using System.Drawing;
29 using System.ComponentModel;
30
31
32 #endregion
33
34 #if Microsoft_CONTROL
35         namespace System.Windows.Forms.DataVisualization.Charting
36 #else
37 namespace System.Web.UI.DataVisualization.Charting
38
39 #endif
40 {
41         /// <summary>
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.
45         /// </summary>
46 #if ASPPERM_35
47         [AspNetHostingPermission(System.Security.Permissions.SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
48     [AspNetHostingPermission(System.Security.Permissions.SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
49 #endif
50     public class ChartAreaCollection : ChartNamedElementCollection<ChartArea>
51         {
52
53                 #region Constructors
54
55         /// <summary>
56         /// Initializes a new instance of the <see cref="ChartAreaCollection"/> class.
57         /// </summary>
58         /// <param name="chartPicture">Parent chart picture.</param>
59                 internal ChartAreaCollection(ChartPicture chartPicture) : base(chartPicture)
60                 {
61                 }
62
63         #endregion
64
65         #region Properties
66         /// <summary>
67         /// Gets the default chart area name.
68         /// </summary>
69         internal string DefaultNameReference 
70         {
71             get { return this.Count > 0 ? this[0].Name : String.Empty; }
72         }
73         #endregion
74
75         #region Methods
76
77         /// <summary>
78         /// Creates a new ChartArea with the specified name and adds it to the collection.
79         /// </summary>
80         /// <param name="name">The new chart area name.</param>
81         /// <returns></returns>
82         public ChartArea Add(string name) 
83         {
84             ChartArea area = new ChartArea(name);
85             this.Add(area);
86             return area;
87         }
88
89         #endregion
90
91         #region Event handlers
92         /// <summary>
93         /// Updates the ChartArea alignment references to another chart areas.
94         /// </summary>
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)
98         {
99             foreach (ChartArea chartArea in this)
100                 if (chartArea.AlignWithChartArea == e.OldName)
101                     chartArea.AlignWithChartArea = e.NewName;
102         }
103
104         #endregion
105
106     }
107 }