Updates referencesource to .NET 4.7
[mono-project.git] / mcs / class / referencesource / System.Web.DataVisualization / Common / General / NamedImageCollection.cs
blob01af71e1d5ce5c33318b430b94d0096afcc4bb8e
1 //-------------------------------------------------------------
2 // <copyright company=’Microsoft Corporation’>
3 // Copyright © Microsoft Corporation. All Rights Reserved.
4 // </copyright>
5 //-------------------------------------------------------------
6 // @owner=alexgor, deliant
7 //=================================================================
8 // File: NamedImagesCollection.cs
9 //
10 // Namespace: System.Windows.Forms.DataVisualization.Charting.ChartTypes
12 // Classes: NamedImagesCollection, NamedImage
14 // Purpose: Every property in the chart references images by names.
15 // This means that you can set MarkerImage property to a
16 // full image path or URL. In case when the user wants to
17 // dynamically generate an image or load it from other
18 // location (like database) you can use named image
19 // collection which is exposed as Images property of the
20 // chart. Any Image can be added to this collection with
21 // unique name and than this name can be used in all the
22 // chart properties which require image names.
24 // Reviewed: AG - Microsoft 14, 2007
26 //===================================================================
28 #region Used namespaces
30 using System;
31 using System.Collections;
32 using System.Drawing;
33 using System.ComponentModel;
34 using System.Globalization;
35 using System.Reflection;
36 using System.ComponentModel.Design.Serialization;
38 #endregion
40 #if Microsoft_CONTROL
41 namespace System.Windows.Forms.DataVisualization.Charting
42 #else
43 namespace System.Web.UI.DataVisualization.Charting
44 #endif
46 /// <summary>
47 /// The NamedImagesCollection class is a strongly typed collection of NamedImage
48 /// objects.
49 /// </summary>
50 #if ASPPERM_35
51 [AspNetHostingPermission(System.Security.Permissions.SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
52 [AspNetHostingPermission(System.Security.Permissions.SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
53 #endif
54 public class NamedImagesCollection : ChartNamedElementCollection<NamedImage>
56 #region Constructor
58 /// <summary>
59 /// Constructor
60 /// </summary>
61 internal NamedImagesCollection() : base(null)
65 #endregion
69 /// <summary>
70 /// The NamedImage class stores a single Image with its unique name.
71 /// </summary>
73 SRDescription("DescriptionAttributeNamedImage_NamedImage"),
74 DefaultProperty("Name"),
76 #if ASPPERM_35
77 [AspNetHostingPermission(System.Security.Permissions.SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
78 [AspNetHostingPermission(System.Security.Permissions.SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
79 #endif
80 public class NamedImage : ChartNamedElement
82 #region Fields
84 private string _name = string.Empty;
85 private System.Drawing.Image _image = null;
87 #endregion
89 #region Constructor
91 /// <summary>
92 /// NamedImage constructor.
93 /// </summary>
94 public NamedImage()
98 /// <summary>
99 /// NamedImage constructor.
100 /// </summary>
101 /// <param name="name">Image name.</param>
102 /// <param name="image">Image object.</param>
103 public NamedImage(string name, System.Drawing.Image image)
105 this._name = name;
106 this._image = image;
109 #endregion
111 #region Properties
113 /// <summary>
114 /// Gets or sets the image name.
115 /// </summary>
117 Bindable(false),
118 SRDescription("DescriptionAttributeNamedImage_Name"),
120 public override string Name
124 return _name;
128 _name = value;
132 /// <summary>
133 /// Gets or sets the image object.
134 /// </summary>
136 Bindable(false),
137 SRDescription("DescriptionAttributeNamedImage_Image"),
139 public System.Drawing.Image Image
143 return _image;
147 _image = value;
151 #endregion
154 #region IDisposable Members
155 /// <summary>
156 /// Releases unmanaged and - optionally - managed resources
157 /// </summary>
158 /// <param name="disposing"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
159 protected override void Dispose(bool disposing)
161 if (disposing)
163 // Dispose managed resources
164 if (_image != null)
166 _image.Dispose();
167 _image = null;
170 base.Dispose(disposing);
173 #endregion