// 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: Every property in the chart references images by names.
// This means that you can set MarkerImage property to a
// full image path or URL. In case when the user wants to
// dynamically generate an image or load it from other
// location (like database) you can use named image
// collection which is exposed as Images property of the
// chart. Any Image can be added to this collection with
// unique name and than this name can be used in all the
// chart properties which require image names.
//
using System.ComponentModel;
namespace FastReport.DataVisualization.Charting
{
///
/// The NamedImagesCollection class is a strongly typed collection of NamedImage
/// objects.
///
public class NamedImagesCollection : ChartNamedElementCollection
{
#region Constructor
///
/// Constructor
///
internal NamedImagesCollection() : base(null)
{
}
#endregion
}
///
/// The NamedImage class stores a single Image with its unique name.
///
[
SRDescription("DescriptionAttributeNamedImage_NamedImage"),
DefaultProperty("Name"),
]
public class NamedImage : ChartNamedElement
{
#region Fields
private string _name = string.Empty;
private System.Drawing.Image _image = null;
#endregion
#region Constructor
///
/// NamedImage constructor.
///
public NamedImage()
{
}
///
/// NamedImage constructor.
///
/// Image name.
/// Image object.
public NamedImage(string name, System.Drawing.Image image)
{
this._name = name;
this._image = image;
}
#endregion
#region Properties
///
/// Gets or sets the image name.
///
[
Bindable(false),
SRDescription("DescriptionAttributeNamedImage_Name"),
]
public override string Name
{
get
{
return _name;
}
set
{
_name = value;
CallOnModifing();
}
}
///
/// Gets or sets the image object.
///
[
Bindable(false),
SRDescription("DescriptionAttributeNamedImage_Image"),
]
public System.Drawing.Image Image
{
get
{
return _image;
}
set
{
_image = value;
CallOnModifing();
}
}
#endregion
#region IDisposable Members
///
/// Releases unmanaged and - optionally - managed resources
///
/// true to release both managed and unmanaged resources; false to release only unmanaged resources.
protected override void Dispose(bool disposing)
{
if (disposing)
{
// Dispose managed resources
if (_image != null)
{
_image.Dispose();
_image = null;
}
}
base.Dispose(disposing);
}
#endregion
}
}