// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
//
// Purpose: ChartAreaCollection class represents a strongly
// typed collection of ChartArea objects.
//
using System;
namespace FastReport.DataVisualization.Charting
{
///
/// The ChartAreaCollection class represents a strongly typed collection of
/// ChartArea objects. Each chart area has a unique name in the collection
/// and can be retrieved by name or by index.
///
public class ChartAreaCollection : ChartNamedElementCollection
{
#region Constructors
///
/// Initializes a new instance of the class.
///
/// Parent chart picture.
internal ChartAreaCollection(ChartPicture chartPicture) : base(chartPicture)
{
}
#endregion
#region Properties
///
/// Gets the default chart area name.
///
internal string DefaultNameReference
{
get { return this.Count > 0 ? this[0].Name : String.Empty; }
}
#endregion
#region Methods
///
/// Creates a new ChartArea with the specified name and adds it to the collection.
///
/// The new chart area name.
///
public ChartArea Add(string name)
{
ChartArea area = new ChartArea(name);
this.Add(area);
return area;
}
#endregion
#region Event handlers
///
/// Updates the ChartArea alignment references to another chart areas.
///
/// The sender.
/// The instance containing the event data.
internal void ChartAreaNameReferenceChanged(object sender, NameReferenceChangedEventArgs e)
{
foreach (ChartArea chartArea in this)
if (chartArea.AlignWithChartArea == e.OldName)
chartArea.AlignWithChartArea = e.NewName;
}
#endregion
}
}