1 //-------------------------------------------------------------
2 // <copyright company=’Microsoft Corporation’>
3 // Copyright © Microsoft Corporation. All Rights Reserved.
5 //-------------------------------------------------------------
6 // @owner=alexgor, deliant
7 //=================================================================
10 // Namespace: System.Web.UI.WebControls[Windows.Forms].Charting.Data
12 // Classes: DataPoint, DataPointCustomProperties, DataPointCollection,
13 // DataPointComparer, DataPoint3D, CustomProperties
15 // Purpose: Classes related to the Data Points:
16 // DataPointCollection - data points collection class
17 // DataPoint - data point properties and methods
18 // DataPointCustomProperties - data point & series properties
19 // DataPointComparer - used for sorting data points in series
21 // Reviewed: AG - Aug 1, 2002, GS - Aug 7, 2002
23 //===================================================================
26 #region Used namespaces
29 using System
.Collections
;
30 using System
.Collections
.Specialized
;
31 using System
.ComponentModel
;
32 using System
.ComponentModel
.Design
;
34 using System
.Data
.Common
;
36 using System
.Drawing
.Design
;
37 using System
.Drawing
.Drawing2D
;
38 using System
.Globalization
;
39 using System
.Diagnostics
.CodeAnalysis
;
40 using System
.Collections
.Generic
;
41 using System
.Collections
.ObjectModel
;
45 using System
.Windows
.Forms
.DataVisualization
.Charting
;
46 using System
.Windows
.Forms
.DataVisualization
.Charting
.Data
;
47 using System
.Windows
.Forms
.DataVisualization
.Charting
.ChartTypes
;
48 using System
.Windows
.Forms
.DataVisualization
.Charting
.Utilities
;
49 using System
.Windows
.Forms
.DataVisualization
.Charting
.Borders3D
;
52 using System
.ComponentModel
.Design
.Serialization
;
53 using System
.Reflection
;
55 using System
.Windows
.Forms
.Design
;
59 using System
.Web
.UI
.DataVisualization
.Charting
;
60 using System
.Web
.UI
.DataVisualization
.Charting
.Utilities
;
69 namespace System
.Windows
.Forms
.DataVisualization
.Charting
71 namespace System
.Web
.UI
.DataVisualization
.Charting
74 #region CustomProperties enumeration
77 /// Enumeration of common properties names.
79 internal enum CommonCustomProperties
93 BackImageTransparentColor
,
103 MarkerImageTransparentColor
,
118 LegendMapAreaAttributes
,
123 LabelMapAreaAttributes
,
126 LabelBorderDashStyle
,
134 /// Data points comparer class
137 SRDescription("DescriptionAttributeDataPointComparer_DataPointComparer")
139 public class DataPointComparer
: IComparer
<DataPoint
>
144 private PointSortOrder _sortingOrder
= PointSortOrder
.Ascending
;
146 // Sorting value index
147 private int _sortingValueIndex
= 1;
154 /// Private default constructor.
156 private DataPointComparer()
161 /// Data points comparer class constructor.
163 /// <param name="series">Data series.</param>
164 /// <param name="sortOrder">Sorting order.</param>
165 /// <param name="sortBy">Value used for sorting ("X", "Y or Y1", "Y2", ...).</param>
167 [AspNetHostingPermission(System
.Security
.Permissions
.SecurityAction
.InheritanceDemand
, Level
= AspNetHostingPermissionLevel
.Minimal
)]
168 [AspNetHostingPermission(System
.Security
.Permissions
.SecurityAction
.LinkDemand
, Level
= AspNetHostingPermissionLevel
.Minimal
)]
170 public DataPointComparer(Series series
, PointSortOrder sortOrder
, string sortBy
)
172 // Check if sorting value is valid
173 sortBy
= sortBy
.ToUpper(System
.Globalization
.CultureInfo
.InvariantCulture
);
174 if(String
.Compare(sortBy
, "X", StringComparison
.Ordinal
) == 0)
176 _sortingValueIndex
= -1;
178 else if (String
.Compare(sortBy
, "Y", StringComparison
.Ordinal
) == 0)
180 _sortingValueIndex
= 0;
182 else if (String
.Compare(sortBy
, "AXISLABEL", StringComparison
.Ordinal
) == 0)
184 _sortingValueIndex
= -2;
186 else if(sortBy
.Length
== 2 &&
187 sortBy
.StartsWith("Y", StringComparison
.Ordinal
) &&
188 Char
.IsDigit(sortBy
[1]))
190 _sortingValueIndex
= Int32
.Parse(sortBy
.Substring(1), System
.Globalization
.CultureInfo
.InvariantCulture
) - 1;
194 throw(new ArgumentException( SR
.ExceptionDataPointConverterInvalidSorting
, "sortBy"));
197 // Check if data series support as many Y values as required
198 if(_sortingValueIndex
> 0 && _sortingValueIndex
>= series
.YValuesPerPoint
)
200 throw(new ArgumentException( SR
.ExceptionDataPointConverterUnavailableSorting(sortBy
, series
.YValuesPerPoint
.ToString(System
.Globalization
.CultureInfo
.InvariantCulture
) ), "sortBy"));
203 this._sortingOrder
= sortOrder
;
208 #region Comparing method
211 /// Compares two data points.
213 /// <param name="x">First data point.</param>
214 /// <param name="y">Second data point.</param>
215 /// <returns>If the two values are equal, it returns zero. If point 1 is greater than point 2,
216 /// it returns a positive integer; otherwise, it returns a negative integer.
218 public int Compare(DataPoint x
, DataPoint y
)
223 if(_sortingValueIndex
== -1)
225 result
= x
.XValue
.CompareTo(y
.XValue
);
227 // Compare Axis Label value
228 else if(_sortingValueIndex
== -2)
230 result
= string.Compare(x
.AxisLabel
, y
.AxisLabel
, StringComparison
.CurrentCulture
);
232 // Compare one of the Y value(s)
235 result
= x
.YValues
[_sortingValueIndex
].CompareTo(y
.YValues
[_sortingValueIndex
]);
238 // Invert result depending on the sorting order
239 if(this._sortingOrder
== PointSortOrder
.Descending
)
251 /// A collection of data points.
254 SRDescription("DescriptionAttributeDataPointCollection_DataPointCollection"),
257 [AspNetHostingPermission(System
.Security
.Permissions
.SecurityAction
.InheritanceDemand
, Level
= AspNetHostingPermissionLevel
.Minimal
)]
258 [AspNetHostingPermission(System
.Security
.Permissions
.SecurityAction
.LinkDemand
, Level
= AspNetHostingPermissionLevel
.Minimal
)]
260 #if !Microsoft_CONTROL
263 public class DataPointCollection
: ChartElementCollection
<DataPoint
>
267 // Reference to the sereies of data points
268 internal Series series
= null;
272 #region Constructors and Initialization
275 /// Data Point Collection object constructor.
277 /// <param name="series">Series object, which the Data Point Collection belongs to.</param>
278 internal DataPointCollection(Series series
) : base(series
)
280 this.series
= series
;
284 /// Initialize data point series and name.
286 /// <param name="dataPoint">Reference to the data point object to initialize.</param>
287 internal void DataPointInit(ref DataPoint dataPoint
)
289 DataPointInit(this.series
, ref dataPoint
);
293 /// Initialize data point series and name.
295 /// <param name="series">Series the data point belongs to.</param>
296 /// <param name="dataPoint">Reference to the data point object to initialize.</param>
297 internal static void DataPointInit(Series series
, ref DataPoint dataPoint
)
299 dataPoint
.series
= series
;
301 if(dataPoint
.AxisLabel
.Length
> 0 && series
!= null)
303 series
.noLabelsInPoints
= false;
306 #if Microsoft_CONTROL
307 // Set flag that tooltips flags should be recalculated
308 if(dataPoint
.ToolTip
.Length
> 0 &&
309 dataPoint
.LegendToolTip
.Length
> 0 &&
310 dataPoint
.LabelToolTip
.Length
> 0 &&
311 series
!= null && series
.Chart
!= null && series
.Chart
.selection
!= null)
313 series
.Chart
.selection
.enabledChecked
= false;
320 #region Data point binding, adding and inserting methods
323 /// Adds the new DataPoint to a collection and sets its Y values.
325 /// <param name="y">The y.</param>
326 /// <returns></returns>
327 [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly",
328 Justification
= "X and Y are cartesian coordinates and well understood")]
329 public DataPoint
Add(params double[] y
)
331 DataPoint point
= new DataPoint(0, y
);
337 /// Parse the input parameter with other point attribute binding rule
338 /// in format: PointProperty=Field[{Format}] [,PointProperty=Field[{Format}]].
339 /// For example: "Tooltip=Price{C1},Url=WebSiteName".
341 /// <param name="otherFields">Other fields parameter.</param>
342 /// <param name="otherAttributeNames">Returns array of attribute names.</param>
343 /// <param name="otherFieldNames">Returns array of field names.</param>
344 /// <param name="otherValueFormat">Returns array of format strings.</param>
345 internal static void ParsePointFieldsParameter(
347 ref string[] otherAttributeNames
,
348 ref string[] otherFieldNames
,
349 ref string[] otherValueFormat
)
351 if(otherFields
!= null && otherFields
.Length
> 0)
353 // Split string by comma
354 otherAttributeNames
= otherFields
.Replace(",,", "\n").Split(',');
355 otherFieldNames
= new string[otherAttributeNames
.Length
];
356 otherValueFormat
= new string[otherAttributeNames
.Length
];
358 // Loop through all strings
359 for(int index
= 0; index
< otherAttributeNames
.Length
; index
++)
361 // Split string by equal sign
362 int equalSignIndex
= otherAttributeNames
[index
].IndexOf('=');
363 if(equalSignIndex
> 0)
365 otherFieldNames
[index
] = otherAttributeNames
[index
].Substring(equalSignIndex
+ 1);
366 otherAttributeNames
[index
] = otherAttributeNames
[index
].Substring(0, equalSignIndex
);
370 throw (new ArgumentException(SR
.ExceptionParameterFormatInvalid
, "otherFields"));
373 // Check if format string was specified
374 int bracketIndex
= otherFieldNames
[index
].IndexOf('{');
375 if(bracketIndex
> 0 && otherFieldNames
[index
][otherFieldNames
[index
].Length
- 1] == '}')
377 otherValueFormat
[index
] = otherFieldNames
[index
].Substring(bracketIndex
+ 1);
378 otherValueFormat
[index
] = otherValueFormat
[index
].Trim('{', '}');
379 otherFieldNames
[index
] = otherFieldNames
[index
].Substring(0, bracketIndex
);
382 // Trim and replace new line character
383 otherAttributeNames
[index
] = otherAttributeNames
[index
].Trim().Replace("\n", ",");
384 otherFieldNames
[index
] = otherFieldNames
[index
].Trim().Replace("\n", ",");
385 if ( otherValueFormat
[index
] != null )
386 otherValueFormat
[index
] = otherValueFormat
[index
].Trim().Replace("\n", ",");
392 /// Data bind X, Y and other values (like Tooltip, LabelStyle,...) of the data points to the data source.
393 /// Data source can be the Ole(SQL)DataReader, DataView, DataSet, DataTable or DataRow.
395 /// <param name="dataSource">Data source.</param>
396 /// <param name="xField">Name of the field for X values.</param>
397 /// <param name="yFields">Comma separated names of the fields for Y values.</param>
398 /// <param name="otherFields">Other point properties binding rule in format: PointProperty=Field[{Format}] [,PointProperty=Field[{Format}]]. For example: "Tooltip=Price{C1},Url=WebSiteName".</param>
399 [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly",
400 Justification
= "X and Y are cartesian coordinates and well understood")]
401 public void DataBind(IEnumerable dataSource
, string xField
, string yFields
, string otherFields
)
404 if (dataSource
== null)
405 throw new ArgumentNullException("dataSource", SR
.ExceptionDataPointInsertionNoDataSource
);
406 if (dataSource
is string)
407 throw (new ArgumentException(SR
.ExceptionDataBindSeriesToString
, "dataSource"));
409 throw new ArgumentNullException("yFields");
411 // Convert comma separated Y values field names string to array of names
412 string[] yFieldNames
= yFields
.Replace(",,", "\n").Split(',');
413 for(int index
= 0; index
< yFieldNames
.Length
; index
++)
415 yFieldNames
[index
] = yFieldNames
[index
].Replace("\n", ",");
418 if (yFieldNames
.GetLength(0) > series
.YValuesPerPoint
)
419 throw (new ArgumentOutOfRangeException("yFields", SR
.ExceptionDataPointYValuesCountMismatch(series
.YValuesPerPoint
.ToString(System
.Globalization
.CultureInfo
.InvariantCulture
))));
421 // Convert other fields/properties names to two arrays of names
422 string[] otherAttributeNames
= null;
423 string[] otherFieldNames
= null;
424 string[] otherValueFormat
= null;
425 ParsePointFieldsParameter(
427 ref otherAttributeNames
,
429 ref otherValueFormat
);
431 // Remove all existing data points
434 // Get and reset enumerator
435 IEnumerator enumerator
= GetDataSourceEnumerator(dataSource
);
436 if (enumerator
.GetType() != typeof(System
.Data
.Common
.DbEnumerator
))
442 // Some enumerators may not support Resetting
443 catch (InvalidOperationException
)
446 catch (NotImplementedException
)
449 catch (NotSupportedException
)
455 bool valueExsist
= true;
456 object[] yValuesObj
= new object[yFieldNames
.Length
];
457 object xValueObj
= null;
458 bool autoDetectType
= true;
460 this.SuspendUpdates();
465 // Move to the next objects in the enumerations
468 valueExsist
= enumerator
.MoveNext();
471 // Auto detect valu(s) type
474 autoDetectType
= false;
475 AutoDetectValuesType(this.series
, enumerator
, xField
, enumerator
, yFieldNames
[0]);
478 // Create and initialize data point
481 DataPoint newDataPoint
= new DataPoint(series
);
482 bool emptyValues
= false;
484 // Set X to the value provided
485 if (xField
.Length
> 0)
487 xValueObj
= ConvertEnumerationItem(enumerator
.Current
, xField
);
488 if (IsEmptyValue(xValueObj
))
496 if (yFieldNames
.Length
== 0)
498 yValuesObj
[0] = ConvertEnumerationItem(enumerator
.Current
, null);
499 if (IsEmptyValue(yValuesObj
[0]))
507 for (int i
= 0; i
< yFieldNames
.Length
; i
++)
509 yValuesObj
[i
] = ConvertEnumerationItem(enumerator
.Current
, yFieldNames
[i
]);
510 if (IsEmptyValue(yValuesObj
[i
]))
519 if (otherAttributeNames
!= null &&
520 otherAttributeNames
.Length
> 0)
522 for (int i
= 0; i
< otherFieldNames
.Length
; i
++)
524 // Get object by field name
525 object obj
= ConvertEnumerationItem(enumerator
.Current
, otherFieldNames
[i
]);
526 if (!IsEmptyValue(obj
))
528 newDataPoint
.SetPointCustomProperty(
530 otherAttributeNames
[i
],
531 otherValueFormat
[i
]);
536 // IsEmpty value was detected
539 if (xValueObj
!= null)
541 newDataPoint
.SetValueXY(xValueObj
, yValuesObj
);
545 newDataPoint
.SetValueXY(0, yValuesObj
);
547 DataPointInit(ref newDataPoint
);
548 newDataPoint
.IsEmpty
= true;
549 this.Add(newDataPoint
);
553 if (xValueObj
!= null)
555 newDataPoint
.SetValueXY(xValueObj
, yValuesObj
);
559 newDataPoint
.SetValueXY(0, yValuesObj
);
561 DataPointInit(ref newDataPoint
);
562 this.Add(newDataPoint
);
566 } while (valueExsist
);
571 this.ResumeUpdates();
576 /// Data bind Y values of the data points to the data source.
577 /// Data source can be the Array, Collection, Ole(SQL)DataReader, DataView, DataSet, DataTable or DataRow.
579 /// <param name="yValue">One or more enumerable objects with Y values.</param>
580 [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly",
581 Justification
= "Y is a cartesian coordinate and well understood")]
582 public void DataBindY(params IEnumerable
[] yValue
)
584 DataBindXY(null, yValue
);
588 /// Data bind X and Y values of the data points to the data source.
589 /// Data source can be the Array, Collection, Ole(SQL)DataReader, DataView, DataSet, DataTable or DataRow.
591 /// <param name="xValue">Enumerable objects with X values.</param>
592 /// <param name="yValues">One or more enumerable objects with Y values.</param>
593 [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly",
594 Justification
= "X and Y are cartesian coordinates and well understood")]
595 public void DataBindXY(IEnumerable xValue
, params IEnumerable
[] yValues
)
597 // Y value must be provided
598 if (yValues
== null ||
599 yValues
.Length
==1 && yValues
[0]==null)
600 throw new ArgumentNullException("yValues");
601 if (yValues
.GetLength(0) == 0)
602 throw new ArgumentException(SR
.ExceptionDataPointBindingYValueNotSpecified
, "yValues");
604 // Double check that a string object is not provided for data binding
605 for(int i
= 0; i
< yValues
.Length
; i
++)
607 if(yValues
[i
] is string)
609 throw (new ArgumentException(SR
.ExceptionDataBindYValuesToString
, "yValues"));
613 // Check if number of Y values do not out of range
614 if(yValues
.GetLength(0) > series
.YValuesPerPoint
)
616 throw(new ArgumentOutOfRangeException("yValues", SR
.ExceptionDataPointYValuesBindingCountMismatch( series
.YValuesPerPoint
.ToString(System
.Globalization
.CultureInfo
.InvariantCulture
) ) ) );
619 // Remove all existing data points
622 // Reset X, Y enumerators
623 IEnumerator xEnumerator
= null;
624 IEnumerator
[] yEnumerator
= new IEnumerator
[yValues
.GetLength(0)];
627 // Double check that a string object is not provided for data binding
630 throw (new ArgumentException(SR
.ExceptionDataBindXValuesToString
, "xValue"));
633 // Get and reset Y values enumerators
634 xEnumerator
= GetDataSourceEnumerator(xValue
);
635 if(xEnumerator
.GetType() != typeof(System
.Data
.Common
.DbEnumerator
))
640 for(int i
= 0; i
< yValues
.Length
; i
++)
642 // Get and reset Y values enumerators
643 yEnumerator
[i
] = GetDataSourceEnumerator(yValues
[i
]);
644 if(yEnumerator
[i
].GetType() != typeof(System
.Data
.Common
.DbEnumerator
))
646 yEnumerator
[i
].Reset();
651 bool xValueExsist
= false;
652 bool yValueExsist
= true;
653 object[] yValuesObj
= new object[series
.YValuesPerPoint
];
654 object xValueObj
= null;
655 bool autoDetectType
= true;
662 // Move to the next objects in the enumerations
664 for (int i
= 0; i
< yValues
.Length
; i
++)
668 yValueExsist
= yEnumerator
[i
].MoveNext();
673 xValueExsist
= xEnumerator
.MoveNext();
674 if (yValueExsist
&& !xValueExsist
)
676 throw (new ArgumentOutOfRangeException("xValue", SR
.ExceptionDataPointInsertionXValuesQtyIsLessYValues
));
680 // Auto detect value(s) type
683 autoDetectType
= false;
684 AutoDetectValuesType(this.series
, xEnumerator
, null, yEnumerator
[0], null);
687 // Create and initialize data point
688 if (xValueExsist
|| yValueExsist
)
690 DataPoint newDataPoint
= new DataPoint(series
);
691 bool emptyValues
= false;
693 // Set X to the value provided
696 xValueObj
= ConvertEnumerationItem(xEnumerator
.Current
, null);
697 if (xValueObj
is System
.DBNull
|| xValueObj
== null)
705 for (int i
= 0; i
< yValues
.Length
; i
++)
707 yValuesObj
[i
] = ConvertEnumerationItem(yEnumerator
[i
].Current
, null);
708 if (yValuesObj
[i
] is System
.DBNull
|| yValuesObj
[i
] == null)
715 // IsEmpty value was detected
718 if (xValueObj
!= null)
720 newDataPoint
.SetValueXY(xValueObj
, yValuesObj
);
724 newDataPoint
.SetValueXY(0, yValuesObj
);
726 DataPointInit(ref newDataPoint
);
727 newDataPoint
.IsEmpty
= true;
728 this.Add(newDataPoint
);
732 if (xValueObj
!= null)
734 newDataPoint
.SetValueXY(xValueObj
, yValuesObj
);
738 newDataPoint
.SetValueXY(0, yValuesObj
);
740 DataPointInit(ref newDataPoint
);
741 this.Add(newDataPoint
);
746 } while (xValueExsist
|| yValueExsist
);
751 this.ResumeUpdates();
756 /// Data bind Y values of the data points to the data source.
757 /// Data source can be the Array, Collection, Ole(SQL)DataReader, DataView, DataSet, DataTable or DataRow.
759 /// <param name="yValue">Enumerable objects with Y values.</param>
760 /// <param name="yFields">Name of the fields for Y values.</param>
761 [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly",
762 Justification
= "X and Y are cartesian coordinates and well understood")]
763 public void DataBindY(IEnumerable yValue
, string yFields
)
765 DataBindXY(null, null, yValue
, yFields
);
769 /// Data bind X and Y values of the data points to the data source.
770 /// Data source can be the Array, Collection, Ole(SQL)DataReader, DataView, DataSet, DataTable or DataRow.
772 /// <param name="xValue">Enumerable object with X values.</param>
773 /// <param name="xField">Name of the field for X values.</param>
774 /// <param name="yValue">Enumerable objects with Y values.</param>
775 /// <param name="yFields">Comma separated names of the fields for Y values.</param>
776 [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly",
777 Justification
= "X and Y are cartesian coordinates and well understood")]
778 public void DataBindXY(IEnumerable xValue
, string xField
, IEnumerable yValue
, string yFields
)
781 if (xValue
is string)
782 throw new ArgumentException(SR
.ExceptionDataBindXValuesToString
, "xValue");
784 throw new ArgumentNullException("yValue", SR
.ExceptionDataPointInsertionYValueNotSpecified
);
785 if (yValue
is string)
786 throw new ArgumentException(SR
.ExceptionDataBindYValuesToString
, "yValue");
788 throw new ArgumentOutOfRangeException("yFields", SR
.ExceptionDataPointYValuesCountMismatch(series
.YValuesPerPoint
.ToString(System
.Globalization
.CultureInfo
.InvariantCulture
)));
790 // Convert comma separated field names string to array of names
791 string[] yFieldNames
= yFields
.Replace(",,", "\n").Split(',');;
792 for(int index
= 0; index
< yFieldNames
.Length
; index
++)
794 yFieldNames
[index
] = yFieldNames
[index
].Replace("\n", ",");
796 if (yFieldNames
.GetLength(0) > series
.YValuesPerPoint
)
797 throw new ArgumentOutOfRangeException("yFields", SR
.ExceptionDataPointYValuesCountMismatch(series
.YValuesPerPoint
.ToString(System
.Globalization
.CultureInfo
.InvariantCulture
)));
799 // Remove all existing data points
802 // Reset X, Y enumerators
803 IEnumerator xEnumerator
= null;
804 IEnumerator yEnumerator
= GetDataSourceEnumerator(yValue
);
806 if(yEnumerator
.GetType() != typeof(System
.Data
.Common
.DbEnumerator
))
815 xEnumerator
= GetDataSourceEnumerator(xValue
);
816 if(xEnumerator
.GetType() != typeof(System
.Data
.Common
.DbEnumerator
))
823 xEnumerator
= yEnumerator
;
828 bool xValueExsist
= false;
829 bool yValueExsist
= true;
830 object[] yValuesObj
= new object[yFieldNames
.Length
];
831 object xValueObj
= null;
832 bool autoDetectType
= true;
834 this.SuspendUpdates();
839 // Move to the next objects in the enumerations
842 yValueExsist
= yEnumerator
.MoveNext();
846 if (xValue
!= yValue
)
848 xValueExsist
= xEnumerator
.MoveNext();
849 if (yValueExsist
&& !xValueExsist
)
851 throw (new ArgumentOutOfRangeException("xValue", SR
.ExceptionDataPointInsertionXValuesQtyIsLessYValues
));
856 xValueExsist
= yValueExsist
;
860 // Auto detect valu(s) type
863 autoDetectType
= false;
864 AutoDetectValuesType(this.series
, xEnumerator
, xField
, yEnumerator
, yFieldNames
[0]);
867 // Create and initialize data point
868 if (xValueExsist
|| yValueExsist
)
870 DataPoint newDataPoint
= new DataPoint(series
);
871 bool emptyValues
= false;
873 // Set X to the value provided or use sequence numbers starting with 1
876 xValueObj
= ConvertEnumerationItem(xEnumerator
.Current
, xField
);
877 if (IsEmptyValue(xValueObj
))
885 if (yFieldNames
.Length
== 0)
887 yValuesObj
[0] = ConvertEnumerationItem(yEnumerator
.Current
, null);
888 if (IsEmptyValue(yValuesObj
[0]))
896 for (int i
= 0; i
< yFieldNames
.Length
; i
++)
898 yValuesObj
[i
] = ConvertEnumerationItem(yEnumerator
.Current
, yFieldNames
[i
]);
899 if (IsEmptyValue(yValuesObj
[i
]))
907 // IsEmpty value was detected
910 if (xValueObj
!= null)
912 newDataPoint
.SetValueXY(xValueObj
, yValuesObj
);
916 newDataPoint
.SetValueXY(0, yValuesObj
);
918 DataPointInit(ref newDataPoint
);
919 newDataPoint
.IsEmpty
= true;
920 this.Add(newDataPoint
);
924 if (xValueObj
!= null)
926 newDataPoint
.SetValueXY(xValueObj
, yValuesObj
);
930 newDataPoint
.SetValueXY(0, yValuesObj
);
932 DataPointInit(ref newDataPoint
);
933 this.Add(newDataPoint
);
937 } while (xValueExsist
|| yValueExsist
);
942 this.ResumeUpdates();
947 /// Returns true if objet represents an empty value.
949 /// <param name="val">Value to test.</param>
950 /// <returns>True if empty.</returns>
951 internal static bool IsEmptyValue(object val
)
953 if(val
is System
.DBNull
|| val
== null)
957 if(val
is double && double.IsNaN((double)val
))
961 if(val
is Single
&& Single
.IsNaN((Single
)val
))
970 /// Adds one data point with one Y value.
972 /// <param name="yValue">Y value of the data point.</param>
973 /// <returns>Index of newly added data point.</returns>
974 [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly",
975 Justification
= "Y is a cartesian coordinate and well understood")]
976 public int AddY(double yValue
)
978 // Create new point object
979 DataPoint newDataPoint
= new DataPoint(series
);
980 newDataPoint
.SetValueY(yValue
);
981 DataPointInit(ref newDataPoint
);
987 /// Adds one data point with one or more Y values.
989 /// <param name="yValue">List of Y values of the data point.</param>
990 /// <returns>Index of newly added data point.</returns>
991 [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly",
992 Justification
= "Y is a cartesian coordinate and well understood")]
993 public int AddY(params object[] yValue
)
996 if (yValue
== null ||
997 yValue
.Length
==1 && yValue
[0]==null)
998 throw new ArgumentNullException("yValue");
1000 // Auto detect DateTime values type
1001 if(this.series
.YValueType
== ChartValueType
.Auto
&&
1002 yValue
.Length
> 0 &&
1005 if (yValue
[0] is DateTime
)
1007 this.series
.YValueType
= ChartValueType
.DateTime
;
1008 this.series
.autoYValueType
= true;
1010 else if (yValue
[0] is DateTimeOffset
)
1012 this.series
.YValueType
= ChartValueType
.DateTimeOffset
;
1013 this.series
.autoYValueType
= true;
1017 // Create new point object
1018 DataPoint newDataPoint
= new DataPoint(series
);
1019 newDataPoint
.SetValueY(yValue
);
1020 DataPointInit(ref newDataPoint
);
1026 /// Adds one data point with X value and one Y value.
1028 /// <param name="yValue">Y value of the data point.</param>
1029 /// <param name="xValue">X value of the data point.</param>
1030 /// <returns>Index of newly added data poit.</returns>
1031 [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly",
1032 Justification
= "X and Y are cartesian coordinates and well understood")]
1033 public int AddXY(double xValue
, double yValue
)
1035 // Create new point object
1036 DataPoint newDataPoint
= new DataPoint(series
);
1037 newDataPoint
.SetValueXY(xValue
, yValue
);
1038 DataPointInit(ref newDataPoint
);
1044 /// Adds one data point with X value and one or more Y values.
1046 /// <param name="yValue">List of Y values of the data point.</param>
1047 /// <param name="xValue">X value of the data point.</param>
1048 /// <returns>Index of newly added data poit.</returns>
1049 [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly",
1050 Justification
= "X and Y are cartesian coordinates and well understood")]
1051 public int AddXY(object xValue
, params object[] yValue
)
1054 // Auto detect DateTime and String values type
1055 if(this.series
.XValueType
== ChartValueType
.Auto
)
1057 if(xValue
is DateTime
)
1059 this.series
.XValueType
= ChartValueType
.DateTime
;
1061 if(xValue
is DateTimeOffset
)
1063 this.series
.XValueType
= ChartValueType
.DateTimeOffset
;
1065 if(xValue
is string)
1067 this.series
.XValueType
= ChartValueType
.String
;
1070 this.series
.autoXValueType
= true;
1073 if(this.series
.YValueType
== ChartValueType
.Auto
&&
1074 yValue
.Length
> 0 &&
1077 if (yValue
[0] is DateTime
)
1079 this.series
.YValueType
= ChartValueType
.DateTime
;
1080 this.series
.autoYValueType
= true;
1082 else if (yValue
[0] is DateTimeOffset
)
1084 this.series
.YValueType
= ChartValueType
.DateTimeOffset
;
1085 this.series
.autoYValueType
= true;
1089 // Create new point object
1090 DataPoint newDataPoint
= new DataPoint(series
);
1091 newDataPoint
.SetValueXY(xValue
, yValue
);
1092 DataPointInit(ref newDataPoint
);
1098 /// Insert one data point with X value and one or more Y values.
1100 /// <param name="index">Index after which to insert the data point.</param>
1101 /// <param name="xValue">X value of the data point.</param>
1102 /// <param name="yValue">List of Y values of the data point.</param>
1103 [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly",
1104 Justification
= "X and Y are cartesian coordinates and well understood")]
1105 public void InsertXY(int index
, object xValue
, params object[] yValue
)
1107 DataPoint newDataPoint
= new DataPoint(series
);
1108 newDataPoint
.SetValueXY(xValue
, yValue
);
1109 DataPointInit(ref newDataPoint
);
1110 this.Insert(index
, newDataPoint
);
1114 /// Insert one data point with one or more Y values.
1116 /// <param name="index">Index after which to insert the data point.</param>
1117 /// <param name="yValue">List of Y values of the data point.</param>
1118 [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly",
1119 Justification
= "Y is a cartesian coordinate and well understood")]
1120 public void InsertY(int index
, params object[] yValue
)
1122 DataPoint newDataPoint
= new DataPoint(series
);
1123 newDataPoint
.SetValueY(yValue
);
1124 DataPointInit(ref newDataPoint
);
1125 this.Insert(index
, newDataPoint
);
1129 /// Get data source enumerator object helper function.
1131 /// <param name="dataSource">Data source.</param>
1132 /// <returns>Returns data source enumerator.</returns>
1133 internal static IEnumerator
GetDataSourceEnumerator(IEnumerable dataSource
)
1135 DataView dataView
= dataSource
as DataView
;
1136 if(dataView
!= null)
1138 return dataView
.GetEnumerator();
1140 DataSet dataSet
= dataSource
as DataSet
;
1143 if(dataSet
.Tables
.Count
> 0)
1145 return dataSet
.Tables
[0].Rows
.GetEnumerator();
1149 return dataSource
.GetEnumerator();
1153 /// Convert enumeration item object from DataRow and DataRowView
1154 /// to the actual value of specified column in row
1156 /// <param name="item">Enumeration item.</param>
1157 /// <param name="fieldName">Converted item.</param>
1158 /// <returns></returns>
1159 internal static object ConvertEnumerationItem(object item
, string fieldName
)
1161 object result
= item
;
1163 // If original object is DataRow
1164 DataRow dataRow
= item
as DataRow
;
1167 if(fieldName
!= null && fieldName
.Length
> 0)
1169 // Check if specified column exist
1171 if (dataRow
.Table
.Columns
.Contains(fieldName
))
1173 result
= dataRow
[fieldName
];
1178 // Try to treat field name as column index number
1180 failed
= !int.TryParse(fieldName
, NumberStyles
.Any
, CultureInfo
.InvariantCulture
, out columnIndex
);
1182 if (!failed
&& columnIndex
< dataRow
.Table
.Columns
.Count
&& columnIndex
>= 0)
1184 result
= dataRow
[columnIndex
];
1190 throw(new ArgumentException( SR
.ExceptionColumnNameNotFound( fieldName
) ) );
1195 // Get first column value if name not specified
1196 result
= dataRow
[0];
1200 // If original object is DataRowView
1202 DataRowView dataRowView
= item
as DataRowView
;
1203 if(dataRowView
!= null)
1205 if(fieldName
!= null && fieldName
.Length
> 0)
1207 // Check if specified column exist
1209 if (dataRowView
.DataView
.Table
.Columns
.Contains(fieldName
))
1211 result
= dataRowView
[fieldName
];
1216 // Try to treat field name as column index number
1218 failed
= !int.TryParse(fieldName
, NumberStyles
.Any
, CultureInfo
.InvariantCulture
, out columnIndex
);
1219 if (!failed
&& columnIndex
< dataRowView
.DataView
.Table
.Columns
.Count
&& columnIndex
>= 0)
1221 result
= dataRowView
[columnIndex
];
1227 throw(new ArgumentException( SR
.ExceptionColumnNameNotFound(fieldName
)));
1232 // Get first column value if name not specified
1233 result
= dataRowView
[0];
1237 // If original object is DbDataRecord
1238 DbDataRecord dbDataRecord
= item
as DbDataRecord
;
1239 if(dbDataRecord
!= null)
1241 if(fieldName
!= null && fieldName
.Length
> 0)
1243 // Check if specified column exist
1245 if(!Char
.IsNumber(fieldName
, 0))
1249 result
= dbDataRecord
[fieldName
];
1252 catch (IndexOutOfRangeException
)
1260 // Try to treat field name as column index number
1264 bool parseSucceed
= int.TryParse(fieldName
, NumberStyles
.Any
, CultureInfo
.InvariantCulture
, out columnIndex
);
1268 result
= dbDataRecord
[columnIndex
];
1276 catch (IndexOutOfRangeException
)
1284 throw(new ArgumentException( SR
.ExceptionColumnNameNotFound(fieldName
)));
1290 // Get first column value if name not specified
1291 result
= dbDataRecord
[0];
1296 if (fieldName
!= null && fieldName
.Length
> 0)
1298 PropertyDescriptor descriptor
= TypeDescriptor
.GetProperties(item
).Find(fieldName
, true);
1299 if (descriptor
!= null)
1301 result
= descriptor
.GetValue(item
);
1302 return result
?? null;
1311 /// Auto detects the X and Y(s) values type
1313 /// <param name="series">Series the values type is detected for.</param>
1314 /// <param name="xEnumerator">X values enumerator.</param>
1315 /// <param name="xField">X value field.</param>
1316 /// <param name="yEnumerator">Y values enumerator.</param>
1317 /// <param name="yField">Y value field.</param>
1318 internal static void AutoDetectValuesType(
1320 IEnumerator xEnumerator
,
1322 IEnumerator yEnumerator
,
1325 if(series
.XValueType
== ChartValueType
.Auto
)
1327 series
.XValueType
= GetValueType(xEnumerator
, xField
);
1328 if(series
.XValueType
!= ChartValueType
.Auto
)
1330 series
.autoXValueType
= true;
1333 if(series
.YValueType
== ChartValueType
.Auto
)
1335 series
.YValueType
= GetValueType(yEnumerator
, yField
);
1336 if(series
.YValueType
!= ChartValueType
.Auto
)
1338 series
.autoYValueType
= true;
1344 /// Return value type.
1346 /// <param name="enumerator">Values enumerator.</param>
1347 /// <param name="field">Value field.</param>
1348 private static ChartValueType
GetValueType(IEnumerator enumerator
, string field
)
1350 ChartValueType type
= ChartValueType
.Auto
;
1351 Type columnDataType
= null;
1354 if(enumerator
== null)
1359 // Check if current enumeration element is available
1362 if(enumerator
.Current
== null)
1367 catch(InvalidOperationException
)
1373 // If original object is DataRow
1374 if(enumerator
.Current
is DataRow
)
1376 if(field
!= null && field
.Length
> 0)
1378 // Check if specified column exist
1380 if(((DataRow
)enumerator
.Current
).Table
.Columns
.Contains(field
))
1382 columnDataType
= ((DataRow
)enumerator
.Current
).Table
.Columns
[field
].DataType
;
1386 // Try to treat field as column number
1390 bool parseSucceed
= int.TryParse(field
, NumberStyles
.Any
, CultureInfo
.InvariantCulture
, out columnIndex
);
1394 columnDataType
= ((DataRow
)enumerator
.Current
).Table
.Columns
[columnIndex
].DataType
;
1405 throw(new ArgumentException( SR
.ExceptionColumnNameNotFound(field
)));
1409 else if(((DataRow
)enumerator
.Current
).Table
.Columns
.Count
> 0)
1411 columnDataType
= ((DataRow
)enumerator
.Current
).Table
.Columns
[0].DataType
;
1415 // If original object is DataRowView
1416 else if(enumerator
.Current
is DataRowView
)
1418 if(field
!= null && field
.Length
> 0)
1420 // Check if specified column exist
1422 if(((DataRowView
)enumerator
.Current
).DataView
.Table
.Columns
.Contains(field
))
1424 columnDataType
= ((DataRowView
)enumerator
.Current
).DataView
.Table
.Columns
[field
].DataType
;
1428 // Try to treat field as column number
1432 bool parseSucceed
= int.TryParse(field
, NumberStyles
.Any
, CultureInfo
.InvariantCulture
, out columnIndex
);
1435 columnDataType
= ((DataRowView
)enumerator
.Current
).DataView
.Table
.Columns
[columnIndex
].DataType
;
1446 throw(new ArgumentException(SR
.ExceptionColumnNameNotFound(field
)));
1450 else if(((DataRowView
)enumerator
.Current
).DataView
.Table
.Columns
.Count
> 0)
1452 columnDataType
= ((DataRowView
)enumerator
.Current
).DataView
.Table
.Columns
[0].DataType
;
1456 // If original object is DbDataRecord
1457 else if(enumerator
.Current
is DbDataRecord
)
1459 if(field
!= null && field
.Length
> 0)
1462 int columnIndex
= 0;
1463 if(!Char
.IsNumber(field
, 0))
1465 columnIndex
= ((DbDataRecord
)enumerator
.Current
).GetOrdinal(field
);
1466 columnDataType
= ((DbDataRecord
)enumerator
.Current
).GetFieldType(columnIndex
);
1470 // Try to treat field as column number
1473 failed
= !int.TryParse(field
, NumberStyles
.Any
, CultureInfo
.InvariantCulture
, out columnIndex
);
1477 columnDataType
= ((DbDataRecord
)enumerator
.Current
).GetFieldType(columnIndex
);
1483 throw(new ArgumentException(SR
.ExceptionColumnNameNotFound(field
)));
1487 else if(((DbDataRecord
)enumerator
.Current
).FieldCount
> 0)
1489 columnDataType
= ((DbDataRecord
)enumerator
.Current
).GetFieldType(0);
1492 // Try detecting simple data types
1495 if (field
!= null && field
.Length
> 0)
1497 PropertyDescriptor descriptor
= TypeDescriptor
.GetProperties(enumerator
.Current
).Find(field
, true);
1498 if (descriptor
!= null)
1500 columnDataType
= descriptor
.PropertyType
;
1503 if ( columnDataType
== null )
1505 columnDataType
= enumerator
.Current
.GetType();
1510 if(columnDataType
!= null)
1512 if(columnDataType
== typeof(DateTime
))
1513 type
= ChartValueType
.DateTime
;
1514 else if (columnDataType
== typeof(DateTimeOffset
))
1515 type
= ChartValueType
.DateTimeOffset
;
1516 else if (columnDataType
== typeof(TimeSpan
))
1517 type
= ChartValueType
.Time
;
1518 else if (columnDataType
== typeof(Double
))
1519 type
= ChartValueType
.Double
;
1520 else if (columnDataType
== typeof(Int32
))
1521 type
= ChartValueType
.Int32
;
1522 else if(columnDataType
== typeof(Int64
))
1523 type
= ChartValueType
.Int64
;
1524 else if(columnDataType
== typeof(Single
))
1525 type
= ChartValueType
.Single
;
1526 else if(columnDataType
== typeof(String
))
1527 type
= ChartValueType
.String
;
1528 else if(columnDataType
== typeof(UInt32
))
1529 type
= ChartValueType
.UInt32
;
1530 else if(columnDataType
== typeof(UInt64
))
1531 type
= ChartValueType
.UInt64
;
1539 #region DataPoint finding functions
1542 /// Find all the points that equal to the specified value starting from the specified index.
1544 /// <param name="valueToFind">Point value to find.</param>
1545 /// <param name="useValue">Which point value to use (X, Y1, Y2,...).</param>
1546 /// <param name="startIndex">Index of the point to start looking from.</param>
1547 /// <returns>Enumerator of datapoints.</returns>
1548 public IEnumerable
<DataPoint
> FindAllByValue(double valueToFind
, string useValue
, int startIndex
)
1550 // Loop through all points from specified index
1551 for (int i
= startIndex
; i
< this.Count
; i
++)
1553 DataPoint point
= this[i
];
1554 if (point
.GetValueByName(useValue
) == valueToFind
)
1562 /// Find all the points that equal to the specified value.
1564 /// <param name="valueToFind">Point value to find.</param>
1565 /// <param name="useValue">Which point value to use (X, Y1, Y2,...).</param>
1566 /// <returns>Enumerator of datapoints.</returns>
1567 public IEnumerable
<DataPoint
> FindAllByValue(double valueToFind
, string useValue
)
1569 // Loop through all points from specified index
1570 for (int i
= 0; i
< this.Count
; i
++)
1572 DataPoint point
= this[i
];
1573 if (point
.GetValueByName(useValue
) == valueToFind
)
1581 /// Find all the points that equal to the specified value.
1583 /// <param name="valueToFind">Point value to find.</param>
1584 /// <returns>Enumerator of datapoints.</returns>
1585 public IEnumerable
<DataPoint
> FindAllByValue(double valueToFind
)
1587 return FindAllByValue(valueToFind
, "Y");
1591 /// Find the first point that equals to the specified value starting from the specified index.
1593 /// <param name="valueToFind">Point value to find.</param>
1594 /// <param name="useValue">Which point value to use (X, Y1, Y2,...).</param>
1595 /// <param name="startIndex">Index of the point to start looking from.</param>
1596 /// <returns>Datapoint which matches the value. Null if there is no match.</returns>
1597 public DataPoint
FindByValue(double valueToFind
, string useValue
, int startIndex
)
1600 if (useValue
== null)
1601 throw new ArgumentNullException("useValue");
1602 if (startIndex
< 0 || startIndex
>= this.Count
)
1603 throw new ArgumentOutOfRangeException("startIndex");
1605 // Loop through all points from specified index
1606 for (int i
= startIndex
; i
< this.Count
; i
++)
1608 DataPoint point
= this[i
];
1609 if (point
.GetValueByName(useValue
) == valueToFind
)
1615 // Nothing was found
1620 /// Find the first point that equals to the specified value.
1622 /// <param name="valueToFind">Point value to find.</param>
1623 /// <param name="useValue">Which point value to use (X, Y1, Y2,...).</param>
1624 /// <returns>Datapoint which matches the value. Null if there is no match.</returns>
1625 public DataPoint
FindByValue(double valueToFind
, string useValue
)
1627 return FindByValue(valueToFind
, useValue
, 0);
1631 /// Find the first point that equals to the specified value.
1633 /// <param name="valueToFind">Point value to find.</param>
1634 /// <returns>Datapoint which matches the value. Null if there is no match.</returns>
1635 public DataPoint
FindByValue(double valueToFind
)
1637 return FindByValue(valueToFind
, "Y");
1641 /// Find point with the maximum value starting from specified index.
1643 /// <param name="useValue">Which point value to use (X, Y1, Y2,...).</param>
1644 /// <param name="startIndex">Index of the point to start looking from.</param>
1645 /// <returns>Datapoint with the maximum value.</returns>
1646 public DataPoint
FindMaxByValue(string useValue
, int startIndex
)
1649 if (useValue
== null)
1650 throw new ArgumentNullException("useValue");
1651 if (startIndex
< 0 || startIndex
>= this.Count
)
1652 throw new ArgumentOutOfRangeException("startIndex");
1654 bool isYValue
= useValue
.StartsWith("Y", StringComparison
.OrdinalIgnoreCase
);
1655 double maxValue
= double.MinValue
;
1656 DataPoint maxPoint
= null;
1658 for (int i
= startIndex
; i
< this.Count
; i
++)
1660 DataPoint point
= this[i
];
1662 // Skip empty points when searching for the Y values
1663 if (point
.IsEmpty
&& isYValue
)
1666 double pointValue
= point
.GetValueByName(useValue
);
1668 if (maxValue
< pointValue
)
1670 maxValue
= pointValue
;
1679 /// Find point with the maximum value.
1681 /// <param name="useValue">Which point value to use (X, Y1, Y2,...).</param>
1682 /// <returns>Datapoint with the maximum value.</returns>
1683 public DataPoint
FindMaxByValue(string useValue
)
1685 return FindMaxByValue(useValue
, 0);
1689 /// Find data point with the maximum value.
1691 /// <returns>Datapoint with the maximum value.</returns>
1692 public DataPoint
FindMaxByValue()
1694 return FindMaxByValue("Y");
1698 /// Find point with the Min value starting from specified index.
1700 /// <param name="useValue">Which point value to use (X, Y1, Y2,...).</param>
1701 /// <param name="startIndex">Index of the point to start looking from.</param>
1702 /// <returns>Datapoint with the Min value.</returns>
1703 public DataPoint
FindMinByValue(string useValue
, int startIndex
)
1705 if (useValue
== null)
1706 throw new ArgumentNullException("useValue");
1707 if (startIndex
< 0 || startIndex
>= this.Count
)
1708 throw new ArgumentOutOfRangeException("startIndex");
1710 bool isYValue
= useValue
.StartsWith("Y", StringComparison
.OrdinalIgnoreCase
);
1711 double minValue
= double.MaxValue
;
1712 DataPoint minPoint
= null;
1714 for (int i
= startIndex
; i
< this.Count
; i
++)
1716 DataPoint point
= this[i
];
1718 // Skip empty points when searching for the Y values
1719 if (point
.IsEmpty
&& isYValue
)
1722 double pointValue
= point
.GetValueByName(useValue
);
1724 if (minValue
> pointValue
)
1726 minValue
= pointValue
;
1735 /// Find point with the Min value.
1737 /// <param name="useValue">Which point value to use (X, Y1, Y2,...).</param>
1738 /// <returns>Datapoint with the Min value.</returns>
1739 public DataPoint
FindMinByValue(string useValue
)
1741 return FindMinByValue(useValue
, 0);
1745 /// Find point with the Min value
1747 /// <returns>Datapoint with the Min value.</returns>
1748 public DataPoint
FindMinByValue()
1750 return FindMinByValue("Y");
1755 #region Collection<T> overrides
1758 /// Initializes the specified item.
1760 /// <param name="item">The item.</param>
1761 internal override void Initialize(DataPoint item
)
1763 DataPointInit(ref item
);
1764 base.Initialize(item
);
1767 #if Microsoft_CONTROL
1769 /// Removes all elements from the <see cref="T:System.Collections.ObjectModel.Collection`1"/>.
1771 protected override void ClearItems()
1774 // Refresh Minimum and Maximum from data
1775 // after recalc and set data
1776 if (Common
!= null && Common
.ChartPicture
!= null)
1778 Common
.ChartPicture
.ResetMinMaxFromData();
1789 /// Stores values and properties of a DataPoint of a Series.
1792 SRDescription("DescriptionAttributeDataPoint_DataPoint"),
1793 DefaultProperty("YValues"),
1794 TypeConverter(Editors
.DataPointConverter
.Convertor
)
1797 [AspNetHostingPermission(System
.Security
.Permissions
.SecurityAction
.InheritanceDemand
, Level
= AspNetHostingPermissionLevel
.Minimal
)]
1798 [AspNetHostingPermission(System
.Security
.Permissions
.SecurityAction
.LinkDemand
, Level
= AspNetHostingPermissionLevel
.Minimal
)]
1800 #if !Microsoft_CONTROL
1803 public class DataPoint
: DataPointCustomProperties
1808 private double _xValue
;
1811 private double[] _yValue
= new double[1];
1813 // Pre calculated (during painting) relative position of data point
1814 internal PointF positionRel
= PointF
.Empty
;
1816 // VSTS:199794 - Accessibility needs the last rendered label content to be exposed.
1817 // The current label content evaluation is scattered over different chart types and cannot be isolated without risk of regression.
1818 // This variable will cache the label content taken just before drawing.
1819 internal string _lastLabelText
= String
.Empty
;
1823 #region Constructors
1826 /// DataPoint object constructor.
1828 public DataPoint() : base(null, true)
1830 _yValue
= new double[1];
1834 /// DataPoint object constructor.
1836 /// <param name="series">series object, which the DataPoint belongs to.</param>
1837 public DataPoint(Series series
) : base(series
, true)
1839 // Create Y value(s) array
1840 _yValue
= new double[series
.YValuesPerPoint
];
1845 /// DataPoint object constructor.
1847 /// <param name="xValue">X value.</param>
1848 /// <param name="yValue">Y value.</param>
1849 [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly",
1850 Justification
= "X and Y are cartesian coordinates and well understood")]
1851 public DataPoint(double xValue
, double yValue
)
1855 this._yValue
= new double[1];
1856 this._yValue
[0] = yValue
;
1859 this._xValue
= xValue
;
1863 /// DataPoint object constructor.
1865 /// <param name="xValue">X value.</param>
1866 /// <param name="yValues">Array of Y values.</param>
1867 [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly",
1868 Justification
= "X and Y are cartesian coordinates and well understood")]
1869 public DataPoint(double xValue
, double[] yValues
)
1873 this._yValue
= yValues
;
1876 this._xValue
= xValue
;
1880 /// DataPoint object constructor.
1883 /// This method is only used during the Windows Forms serialization of the chart.
1885 /// <param name="xValue">X value.</param>
1886 /// <param name="yValues">String of comma separated Y values.</param>
1887 [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly",
1888 Justification
= "X and Y are cartesian coordinates and well understood")]
1889 [EditorBrowsable(EditorBrowsableState
.Never
)]
1890 public DataPoint(double xValue
, string yValues
)
1893 string[] values
= yValues
.Split(',');
1895 // Create Y value(s) array
1896 _yValue
= new double[values
.Length
];
1898 for (int index
= 0; index
< values
.Length
; index
++)
1900 _yValue
[index
] = CommonElements
.ParseDouble(values
[index
], true);
1904 this._xValue
= xValue
;
1909 #region Data point methods
1912 /// Sets the specified data point attribute to the specified value.
1914 /// <param name="obj">Attribute value.</param>
1915 /// <param name="propertyName">Attribute name.</param>
1916 /// <param name="format">Value format.</param>
1917 internal void SetPointCustomProperty(
1919 string propertyName
,
1922 // Convert value to string
1923 string stringValue
= obj
as string;
1924 if(stringValue
== null)
1926 double doubleObj
= double.NaN
;
1927 ChartValueType valueType
= ChartValueType
.Auto
;
1930 doubleObj
= ((DateTime
)obj
).ToOADate();
1931 valueType
= ChartValueType
.Date
;
1935 doubleObj
= this.ConvertValue(obj
);
1938 // Try converting to string
1939 if( !double.IsNaN(doubleObj
) )
1943 stringValue
= ValueConverter
.FormatValue(
1950 ChartElementType
.DataPoint
);
1952 catch(FormatException
)
1954 // Use basic string converter
1955 stringValue
= obj
.ToString();
1960 // Use basic string converter
1961 stringValue
= obj
.ToString();
1965 // Assign data point attribute by name
1966 if(stringValue
.Length
> 0)
1968 if(String
.Compare(propertyName
, "AxisLabel", StringComparison
.OrdinalIgnoreCase
) == 0)
1970 this.AxisLabel
= stringValue
;
1972 else if (String
.Compare(propertyName
, "Tooltip", StringComparison
.OrdinalIgnoreCase
) == 0)
1974 this.ToolTip
= stringValue
;
1976 #if !Microsoft_CONTROL
1977 else if(String
.Compare(propertyName
, "Url", StringComparison
.OrdinalIgnoreCase
) == 0)
1979 this.Url
= stringValue
;
1981 else if (String
.Compare(propertyName
, "PostBackValue", StringComparison
.OrdinalIgnoreCase
) == 0)
1983 this.PostBackValue
= stringValue
;
1985 else if (String
.Compare(propertyName
, "LabelUrl", StringComparison
.OrdinalIgnoreCase
) == 0)
1987 this.LabelUrl
= stringValue
;
1989 else if (String
.Compare(propertyName
, "LabelPostBackValue", StringComparison
.OrdinalIgnoreCase
) == 0)
1991 this.LabelPostBackValue
= stringValue
;
1993 else if (String
.Compare(propertyName
, "LegendUrl", StringComparison
.OrdinalIgnoreCase
) == 0)
1995 this.LegendUrl
= stringValue
;
1997 else if (String
.Compare(propertyName
, "LegendPostBackValue", StringComparison
.OrdinalIgnoreCase
) == 0)
1999 this.LegendPostBackValue
= stringValue
;
2001 #endif // !Microsoft_CONTROL
2002 else if (String
.Compare(propertyName
, "Label", StringComparison
.OrdinalIgnoreCase
) == 0)
2004 this.Label
= stringValue
;
2006 else if (String
.Compare(propertyName
, "LegendTooltip", StringComparison
.OrdinalIgnoreCase
) == 0)
2008 this.LegendToolTip
= stringValue
;
2010 else if (String
.Compare(propertyName
, "LegendText", StringComparison
.OrdinalIgnoreCase
) == 0)
2012 this.LegendText
= stringValue
;
2014 else if (String
.Compare(propertyName
, "LabelToolTip", StringComparison
.OrdinalIgnoreCase
) == 0)
2016 this.LabelToolTip
= stringValue
;
2020 this[propertyName
] = stringValue
;
2027 /// Converts object to double.
2029 /// <param name="value">Object to convert.</param>
2030 /// <returns>Double value.</returns>
2031 private double ConvertValue(object value)
2040 return (double)value;
2042 else if(value is Single
)
2044 return (double)((float)value);
2046 else if(value is Decimal
)
2048 return (double)((Decimal
)value);
2050 else if(value is Int32
)
2052 return (double)((Int32
)value);
2054 else if(value is UInt32
)
2056 return (double)((UInt32
)value);
2058 else if(value is Int64
)
2060 return (double)((Int64
)value);
2062 else if(value is UInt64
)
2064 return (double)((UInt64
)value);
2066 else if(value is Byte
)
2068 return (double)((Byte
)value);
2070 else if(value is SByte
)
2072 return (double)((SByte
)value);
2074 else if(value is Boolean
)
2076 return ((Boolean
)value) ? 1.0 : 0.0;
2080 string stringValue
= "";
2081 stringValue
= value.ToString();
2082 return CommonElements
.ParseDouble(stringValue
);
2087 /// Set X value and one or more Y values of the data point.
2089 /// <param name="xValue">X value of the data point.</param>
2090 /// <param name="yValue">List of Y values of the data point.</param>
2091 [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly",
2092 Justification
= "X and Y are cartesian coordinates and well understood")]
2093 public void SetValueXY(object xValue
, params object[] yValue
)
2097 throw new ArgumentNullException("xValue");
2099 // Set Y value first
2102 // Check if parameters type matches with series type
2103 Type paramType
= xValue
.GetType();
2104 if(base.series
!= null)
2106 base.series
.CheckSupportedTypes(paramType
);
2109 // Save value in the array
2110 if(paramType
== typeof(String
))
2112 AxisLabel
= (string)xValue
;
2114 else if(paramType
== typeof(DateTime
))
2116 this._xValue
= ((DateTime
)xValue
).ToOADate();
2120 this._xValue
= ConvertValue(xValue
);
2123 // Get Date or Time if required
2124 if(base.series
!= null && xValue
is DateTime
)
2126 if(base.series
.XValueType
== ChartValueType
.Date
)
2128 DateTime time
= new DateTime(
2129 ((DateTime
)xValue
).Year
,
2130 ((DateTime
)xValue
).Month
,
2131 ((DateTime
)xValue
).Day
,
2136 this._xValue
= time
.ToOADate();
2138 else if(base.series
.XValueType
== ChartValueType
.Time
)
2140 DateTime time
= new DateTime(
2144 ((DateTime
)xValue
).Hour
,
2145 ((DateTime
)xValue
).Minute
,
2146 ((DateTime
)xValue
).Second
,
2147 ((DateTime
)xValue
).Millisecond
);
2148 this._xValue
= time
.ToOADate();
2152 // Check if one of Y values are not avilable
2154 foreach(double d
in this._yValue
)
2163 // Set point empty flag and values to zero
2166 this.IsEmpty
= true;
2167 for(int valueIndex
= 0; valueIndex
< this._yValue
.Length
; valueIndex
++)
2169 this._yValue
[valueIndex
] = 0.0;
2175 /// Set one or more Y values of the data point.
2177 /// <param name="yValue">List of Y values of the data point.</param>
2178 [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly",
2179 Justification
= "Y is a cartesian coordinate and well understood")]
2180 public void SetValueY(params object[] yValue
)
2184 throw new ArgumentNullException("yValue");
2186 // Check number of parameters. Should be more than 0 and
2187 if(yValue
.Length
== 0 || (base.series
!= null && yValue
.Length
> base.series
.YValuesPerPoint
))
2188 throw(new ArgumentOutOfRangeException("yValue", SR
.ExceptionDataPointYValuesSettingCountMismatch(base.series
.YValuesPerPoint
.ToString(System
.Globalization
.CultureInfo
.InvariantCulture
))));
2190 // Check if there is a Null Y value
2191 for( int i
= 0 ; i
< yValue
.Length
; i
++ )
2193 if(yValue
[i
] == null || yValue
[i
] is System
.DBNull
)
2198 this.IsEmpty
= true;
2203 // Check if parameters type matches with series type
2204 Type paramType
= yValue
[0].GetType();
2205 if(base.series
!= null)
2207 base.series
.CheckSupportedTypes(paramType
);
2210 // Make sure the Y values array is big enough
2211 if (this._yValue
.Length
< yValue
.Length
)
2213 this._yValue
= new double[yValue
.Length
];
2216 // Save value in the array
2217 if(paramType
== typeof(String
))
2221 for (int i
= 0; i
< yValue
.Length
; i
++)
2223 this._yValue
[i
] = CommonElements
.ParseDouble((string)yValue
[i
]);
2228 // Get reference to the chart object
2229 if (Common
!=null && Common
.ChartPicture
!=null && Common
.ChartPicture
.SuppressExceptions
)
2231 this.IsEmpty
= true;
2232 for (int i
= 0; i
< yValue
.Length
; i
++)
2239 throw (new ArgumentException( SR
.ExceptionDataPointYValueStringFormat
));
2244 else if(paramType
== typeof(DateTime
))
2246 for( int i
= 0 ; i
< yValue
.Length
; i
++ )
2248 if(yValue
[i
] == null ||
2249 (yValue
[i
] is double && ((double)yValue
[i
]) == 0.0) )
2251 this._yValue
[i
] = DateTime
.Now
.ToOADate();
2255 this._yValue
[i
] = ((DateTime
)yValue
[i
]).ToOADate();
2261 for( int i
= 0 ; i
< yValue
.Length
; i
++ )
2263 this._yValue
[i
] = ConvertValue(yValue
[i
]);
2267 // Get Date or Time if required
2268 if(base.series
!= null)
2270 for( int i
= 0 ; i
< yValue
.Length
; i
++ )
2272 if(yValue
[i
] == null ||
2273 (yValue
[i
] is double && ((double)yValue
[i
]) == 0.0) )
2275 if(base.series
.YValueType
== ChartValueType
.Date
)
2277 this._yValue
[i
] = Math
.Floor(this._yValue
[i
]);
2279 else if(base.series
.YValueType
== ChartValueType
.Time
)
2281 this._yValue
[i
] = this._xValue
- Math
.Floor(this._yValue
[i
]);
2286 if(base.series
.YValueType
== ChartValueType
.Date
)
2289 if (yValue
[i
] is DateTime
)
2290 yDate
= (DateTime
)yValue
[i
];
2291 else if (yValue
[i
] is Double
)
2292 yDate
= DateTime
.FromOADate((Double
)yValue
[i
]);
2294 yDate
= Convert
.ToDateTime(yValue
[i
], CultureInfo
.InvariantCulture
); //This will throw an exception in case when the yValue type is not compatible with the DateTime
2296 DateTime date
= new DateTime(
2305 this._yValue
[i
] = date
.ToOADate();
2307 else if (base.series
.YValueType
== ChartValueType
.Time
)
2310 if (yValue
[i
] is DateTime
)
2311 yTime
= (DateTime
)yValue
[i
];
2312 if (yValue
[i
] is Double
)
2313 yTime
= DateTime
.FromOADate((Double
)yValue
[i
]);
2315 yTime
= Convert
.ToDateTime(yValue
[i
], CultureInfo
.InvariantCulture
); //This will throw an exception in case when the yValue type is not compatible with the DateTime
2317 DateTime time
= new DateTime(
2326 this._yValue
[i
] = time
.ToOADate();
2335 /// Creates an exact copy of this DataPoint object.
2337 /// <returns>An exact copy of this DataPoint object.</returns>
2338 public DataPoint
Clone()
2340 // Create new data point
2341 DataPoint clonePoint
= new DataPoint();
2343 // Reset series pointer
2344 clonePoint
.series
= null;
2345 clonePoint
.pointCustomProperties
= this.pointCustomProperties
;
2348 clonePoint
._xValue
= this.XValue
;
2349 clonePoint
._yValue
= new double[this._yValue
.Length
];
2350 this._yValue
.CopyTo(clonePoint
._yValue
, 0);
2351 clonePoint
.tempColorIsSet
= this.tempColorIsSet
;
2352 clonePoint
.isEmptyPoint
= this.isEmptyPoint
;
2355 foreach(object key
in this.properties
.Keys
)
2357 clonePoint
.properties
.Add(key
, this.properties
[key
]);
2364 /// Resize Y values array.
2366 /// <param name="newSize">New number of Y values in array.</param>
2367 internal void ResizeYValueArray(int newSize
)
2370 double[] newArray
= new Double
[newSize
];
2375 for(int i
= 0; i
< ((_yValue
.Length
< newSize
) ? _yValue
.Length
: newSize
); i
++)
2377 newArray
[i
] = _yValue
[i
];
2385 /// Helper function, which returns point value by it's name.
2387 /// <param name="valueName">Point value names. X, Y, Y2,...</param>
2388 /// <returns>Point value.</returns>
2389 public double GetValueByName(string valueName
)
2392 if (valueName
== null)
2393 throw new ArgumentNullException("valueName");
2395 valueName
= valueName
.ToUpper(System
.Globalization
.CultureInfo
.InvariantCulture
);
2396 if(String
.Compare(valueName
, "X", StringComparison
.Ordinal
) == 0)
2400 else if (valueName
.StartsWith("Y", StringComparison
.Ordinal
))
2403 if(valueName
.Length
== 1)
2405 return this.YValues
[0];
2412 yIndex
= Int32
.Parse(valueName
.Substring(1), System
.Globalization
.CultureInfo
.InvariantCulture
) - 1;
2414 catch(System
.Exception
)
2416 throw(new ArgumentException( SR
.ExceptionDataPointValueNameInvalid
, "valueName"));
2421 throw(new ArgumentException( SR
.ExceptionDataPointValueNameYIndexIsNotPositive
, "valueName"));
2424 if(yIndex
>= this.YValues
.Length
)
2426 throw(new ArgumentException( SR
.ExceptionDataPointValueNameYIndexOutOfRange
, "valueName"));
2429 return this.YValues
[yIndex
];
2434 throw(new ArgumentException( SR
.ExceptionDataPointValueNameInvalid
, "valueName"));
2439 /// Replaces predefined keyword inside the string with their values.
2441 /// <param name="strOriginal">Original string with keywords.</param>
2442 /// <returns>Modified string.</returns>
2443 internal override string ReplaceKeywords(string strOriginal
)
2445 // Nothing to process
2446 if(strOriginal
== null || strOriginal
.Length
== 0)
2449 // Replace all "\n" strings with '\n' character
2450 string result
= strOriginal
;
2451 result
= result
.Replace("\\n", "\n");
2453 // #LABEL - point label
2454 result
= result
.Replace(KeywordName
.Label
, this.Label
);
2456 // #LEGENDTEXT - series name
2457 result
= result
.Replace(KeywordName
.LegendText
, this.LegendText
);
2459 // #AXISLABEL - series name
2460 result
= result
.Replace(KeywordName
.AxisLabel
, this.AxisLabel
);
2462 // #CUSTOMPROPERTY - one of the custom properties by name
2463 result
= DataPoint
.ReplaceCustomPropertyKeyword(result
, this);
2465 if(this.series
!= null)
2467 // #INDEX - point index
2468 result
= result
.Replace(KeywordName
.Index
, this.series
.Points
.IndexOf(this).ToString(System
.Globalization
.CultureInfo
.InvariantCulture
));
2470 // Replace series keywords
2471 result
= this.series
.ReplaceKeywords(result
);
2473 // #PERCENT - percentage of Y value from total
2474 result
= this.series
.ReplaceOneKeyword(
2478 ChartElementType
.DataPoint
,
2480 KeywordName
.Percent
,
2481 (this.YValues
[0]/(this.series
.GetTotalYValue())),
2482 ChartValueType
.Double
,
2485 // #VAL[X] - point value X, Y, Y2, ...
2486 if(this.series
.XValueType
== ChartValueType
.String
)
2488 result
= result
.Replace(KeywordName
.ValX
, this.AxisLabel
);
2492 result
= this.series
.ReplaceOneKeyword(
2496 ChartElementType
.DataPoint
,
2500 this.series
.XValueType
,
2504 // remove keywords #VAL? for unexisted Y value indices
2505 for (int index
= this.YValues
.Length
; index
<= 7; index
++)
2507 result
= this.RemoveOneKeyword(result
, KeywordName
.ValY
+ index
+ 1, SR
.FormatErrorString
);
2510 for(int index
= 1; index
<= this.YValues
.Length
; index
++)
2512 result
= this.series
.ReplaceOneKeyword(
2516 ChartElementType
.DataPoint
,
2518 KeywordName
.ValY
+ index
,
2519 this.YValues
[index
- 1],
2520 this.series
.YValueType
,
2524 result
= this.series
.ReplaceOneKeyword(
2528 ChartElementType
.DataPoint
,
2532 this.series
.YValueType
,
2535 result
= this.series
.ReplaceOneKeyword(
2539 ChartElementType
.DataPoint
,
2543 this.series
.YValueType
,
2551 /// Removes one keyword from format string.
2553 /// <param name="strOriginal">Original format string</param>
2554 /// <param name="keyword">The keyword</param>
2555 /// <param name="strToReplace">String to replace the keyword.</param>
2556 /// <returns>Modified format string</returns>
2557 private string RemoveOneKeyword(string strOriginal
, string keyword
, string strToReplace
)
2559 string result
= strOriginal
;
2561 while ((keyIndex
= result
.IndexOf(keyword
, StringComparison
.Ordinal
)) != -1)
2563 // Get optional format
2564 int keyEndIndex
= keyIndex
+ keyword
.Length
;
2565 if (result
.Length
> keyEndIndex
&& result
[keyEndIndex
] == '{')
2567 int formatEnd
= result
.IndexOf('}', keyEndIndex
);
2568 if (formatEnd
== -1)
2570 throw (new InvalidOperationException(SR
.ExceptionDataSeriesKeywordFormatInvalid(result
)));
2573 keyEndIndex
= formatEnd
+ 1;
2575 // Remove keyword string (with optional format)
2576 result
= result
.Remove(keyIndex
, keyEndIndex
- keyIndex
);
2577 if (!String
.IsNullOrEmpty(strToReplace
))
2579 result
= result
.Insert(keyIndex
, strToReplace
);
2587 /// Replaces all "#CUSTOMPROPERTY(XXX)" (where XXX is the custom attribute name)
2588 /// keywords in the string provided.
2590 /// <param name="originalString">String where the keyword need to be replaced.</param>
2591 /// <param name="properties">DataPoint or Series properties class.</param>
2592 /// <returns>Converted string.</returns>
2593 internal static string ReplaceCustomPropertyKeyword(string originalString
, DataPointCustomProperties properties
)
2595 string result
= originalString
;
2596 int keyStartIndex
= -1;
2597 while ((keyStartIndex
= result
.IndexOf(KeywordName
.CustomProperty
, StringComparison
.Ordinal
)) >= 0)
2599 string attributeValue
= string.Empty
;
2600 string attributeName
= string.Empty
;
2602 // Forward to the end of the keyword
2603 int keyEndIndex
= keyStartIndex
+ KeywordName
.CustomProperty
.Length
;
2605 // An opening bracket '(' must follow
2606 if (result
.Length
> keyEndIndex
&& result
[keyEndIndex
] == '(')
2609 int attributeNameStartIndex
= keyEndIndex
;
2611 // Search for the closing bracket
2612 int closingBracketIndex
= result
.IndexOf(')', keyEndIndex
);
2613 if (closingBracketIndex
>= keyEndIndex
)
2615 keyEndIndex
= closingBracketIndex
+ 1;
2616 attributeName
= result
.Substring(attributeNameStartIndex
, keyEndIndex
- attributeNameStartIndex
- 1);
2618 // Get attribute value
2619 if (properties
.IsCustomPropertySet(attributeName
))
2621 attributeValue
= properties
.GetCustomProperty(attributeName
);
2625 // In case of the DataPoint check if the attribute is set in the parent series
2626 DataPoint dataPoint
= properties
as DataPoint
;
2627 if (dataPoint
!= null && dataPoint
.series
!= null)
2629 if (dataPoint
.series
.IsCustomPropertySet(attributeName
))
2631 attributeValue
= dataPoint
.series
.GetCustomProperty(attributeName
);
2638 // Remove keyword string with attribute name
2639 result
= result
.Remove(keyStartIndex
, keyEndIndex
- keyStartIndex
);
2641 // Insert value of the custom attribute
2642 result
= result
.Insert(keyStartIndex
, attributeValue
);
2649 /// Returns a <see cref="T:System.String"/> that represents the current <see cref="T:System.Object"/>.
2652 /// A <see cref="T:System.String"/> that represents the current <see cref="T:System.Object"/>.
2654 internal override string ToStringInternal()
2656 StringBuilder sb
= new StringBuilder();
2657 sb
.AppendFormat(CultureInfo
.CurrentCulture
, "{{X={0}, ", XValue
);
2658 if (YValues
.Length
== 1)
2660 sb
.AppendFormat(CultureInfo
.CurrentCulture
, "Y={0}", YValues
[0]);
2665 for (int i
= 0; i
< YValues
.Length
; i
++)
2667 sb
.AppendFormat(CultureInfo
.CurrentCulture
, "{0}", YValues
[i
]);
2669 sb
.AppendFormat(CultureInfo
.CurrentCulture
, ", {0}", YValues
[i
]);
2673 return sb
.ToString();
2677 #region DataPoint Properties
2681 /// X value of the data point.
2684 SRCategory("CategoryAttributeData"),
2686 SRDescription("DescriptionAttributeDataPoint_XValue"),
2687 TypeConverter(typeof(DataPointValueConverter
)),
2688 DefaultValue(typeof(double), "0.0"),
2691 #if Microsoft_CONTROL
2692 DesignerSerializationVisibility(DesignerSerializationVisibility
.Hidden
),
2694 PersistenceMode(PersistenceMode
.Attribute
)
2697 public double XValue
2706 this.Invalidate(false);
2711 /// List of Y values of the data point.
2714 SRCategory("CategoryAttributeData"),
2715 SRDescription("DescriptionAttributeDataPoint_YValues"),
2718 #if Microsoft_CONTROL
2719 DesignerSerializationVisibility(DesignerSerializationVisibility
.Hidden
),
2721 PersistenceMode(PersistenceMode
.Attribute
),
2723 TypeConverter(typeof(DoubleArrayConverter
)),
2724 Editor(typeof(UITypeEditor
), typeof(UITypeEditor
)),
2725 RefreshProperties(RefreshProperties
.All
),
2726 SerializationVisibilityAttribute(SerializationVisibility
.Attribute
)
2728 [SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")]
2729 public double[] YValues
2740 for(int i
=0; i
< _yValue
.Length
; i
++)
2749 this.Invalidate(false);
2754 /// A flag which indicates whether the data point is empty.
2757 SRCategory("CategoryAttributeData"),
2760 SRDescription("DescriptionAttributeDataPoint_Empty"),
2761 #if !Microsoft_CONTROL
2762 PersistenceMode(PersistenceMode
.Attribute
),
2770 return base.isEmptyPoint
;
2774 base.isEmptyPoint
= value;
2775 this.Invalidate(true);
2780 /// Name of the data point. This field is reserved for internal use only.
2783 SRCategory("CategoryAttributeData"),
2786 SRDescription("DescriptionAttributeDataPoint_Name"),
2787 DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility
.Hidden
),
2788 SerializationVisibilityAttribute(SerializationVisibility
.Hidden
)
2790 public override string Name
2798 //Dont call the base method - the names don't need to be unique
2807 /// Stores properties of one Data Point and Data series.
2810 SRDescription("DescriptionAttributeDataPointCustomProperties_DataPointCustomProperties"),
2811 DefaultProperty("LabelStyle"),
2812 TypeConverter(Editors
.DataPointCustomPropertiesConverter
.Convertor
)
2814 #if Microsoft_CONTROL
2815 public class DataPointCustomProperties
: ChartNamedElement
2818 [AspNetHostingPermission(System
.Security
.Permissions
.SecurityAction
.InheritanceDemand
, Level
= AspNetHostingPermissionLevel
.Minimal
)]
2819 [AspNetHostingPermission(System
.Security
.Permissions
.SecurityAction
.LinkDemand
, Level
= AspNetHostingPermissionLevel
.Minimal
)]
2821 public class DataPointCustomProperties
: ChartNamedElement
, IChartMapArea
2824 #region Fields and enumerations
2826 // True indicates data point properties. Otherwise - series.
2827 internal bool pointCustomProperties
= true;
2829 // Reference to the data point series
2830 internal Series series
= null;
2832 // Storage for the custom properties names/values
2833 internal Hashtable properties
= new Hashtable();
2835 // Flag indicating that temp. color was set
2836 internal bool tempColorIsSet
= false;
2838 // Design time custom properties data
2839 internal CustomProperties customProperties
= null;
2841 // IsEmpty point indicator
2842 internal bool isEmptyPoint
= false;
2846 #region Constructors
2849 /// DataPointCustomProperties constructor.
2851 public DataPointCustomProperties()
2853 // Initialize the data series
2855 this.customProperties
= new CustomProperties(this);
2859 /// DataPointCustomProperties constructor.
2861 /// <param name="series">The series which the data point belongs to.</param>
2862 /// <param name="pointProperties">Indicates whether this is a data point custom properties.</param>
2863 public DataPointCustomProperties(Series series
, bool pointProperties
): base( series
, String
.Empty
)
2865 // Initialize the data series
2866 this.series
= series
;
2867 this.pointCustomProperties
= pointProperties
;
2868 this.customProperties
= new CustomProperties(this);
2873 #region Custom Properties methods
2876 /// Checks if custom property with specified name was set.
2878 /// <param name="name">Name of the custom property to check.</param>
2879 /// <returns>True if custom property was set.</returns>
2880 virtual public bool IsCustomPropertySet(string name
)
2882 return properties
.ContainsKey(name
);
2886 /// Checks if the custom property with specified name was set.
2888 /// <param name="property">The CommonCustomProperties object to check for.</param>
2889 /// <returns>True if attribute was set.</returns>
2890 internal bool IsCustomPropertySet(CommonCustomProperties property
)
2892 return properties
.ContainsKey((int)property
);
2896 /// Delete the data point custom property with the specified name.
2898 /// <param name="name">Name of the property to delete.</param>
2899 virtual public void DeleteCustomProperty(string name
)
2903 throw (new ArgumentNullException(SR
.ExceptionAttributeNameIsEmpty
));
2906 // Check if trying to delete the common attribute
2907 string[] AttributesNames
= CommonCustomProperties
.GetNames(typeof(CommonCustomProperties
));
2908 foreach(string commonName
in AttributesNames
)
2910 if(name
== commonName
)
2912 DeleteCustomProperty((CommonCustomProperties
)Enum
.Parse(typeof(CommonCustomProperties
), commonName
));
2917 properties
.Remove(name
);
2921 /// Delete Data Point attribute with specified name.
2923 /// <param name="property">ID of the attribute to delete.</param>
2924 internal void DeleteCustomProperty(CommonCustomProperties property
)
2926 // Check if trying to delete the common attribute from the series
2927 if(!this.pointCustomProperties
)
2929 throw(new ArgumentException( SR
.ExceptionAttributeUnableToDelete
));
2933 properties
.Remove((int)property
);
2937 /// Gets the data point custom property with the specified name.
2939 /// <param name="name">Name of the property to get.</param>
2940 /// <returns>Returns the data point custom property with the specified name. If the requested one is not set,
2941 /// the default custom property of the data series will be returned.</returns>
2942 virtual public string GetCustomProperty(string name
)
2944 if(!IsCustomPropertySet(name
) && this.pointCustomProperties
)
2946 // Check if we are in serialization mode
2947 bool serializing
= false;
2949 if(Chart
!= null && Chart
.serializing
)
2957 if(this.isEmptyPoint
)
2959 // Return empty point properties from series
2960 return (string)series
.EmptyPointStyle
.properties
[name
];
2963 // Return properties from series
2964 return (string)series
.properties
[name
];
2968 // Return default properties
2969 return (string)Series
.defaultCustomProperties
[name
];
2973 return (string)properties
[name
];
2978 /// Checks if data is currently serialized.
2980 /// <returns>True if serialized.</returns>
2981 internal bool IsSerializing()
2983 // Check if series object is provided
2989 // Check if we are in serialization mode
2992 return Chart
.serializing
;
3001 /// Returns an attribute object of the Data Point. If required attribute is not set
3002 /// in the Data Point the default attribute of the Data series is returned.
3004 /// <param name="attrib">Attribute name ID.</param>
3005 /// <returns>Attribute value.</returns>
3006 internal object GetAttributeObject(CommonCustomProperties attrib
)
3008 // Get series properties
3009 if(!this.pointCustomProperties
|| series
== null)
3011 return properties
[(int)attrib
];
3014 // Get data point properties
3015 if(properties
.Count
== 0 || !IsCustomPropertySet(attrib
))
3017 // Check if we are in serialization mode
3018 bool serializing
= false;
3021 serializing
= Chart
.serializing
;
3026 if(this.isEmptyPoint
)
3028 // Return empty point properties from series
3029 return series
.EmptyPointStyle
.properties
[(int)attrib
];
3032 // Return properties from series
3033 return series
.properties
[(int)attrib
];
3037 // Return default properties
3038 return Series
.defaultCustomProperties
.properties
[(int)attrib
];
3041 return properties
[(int)attrib
];
3045 /// Sets a custom property of the data point.
3047 /// <param name="name">Property name.</param>
3048 /// <param name="propertyValue">Property value.</param>
3049 virtual public void SetCustomProperty(string name
, string propertyValue
)
3051 properties
[name
] = propertyValue
;
3055 /// Sets an attribute of the Data Point as an object.
3057 /// <param name="attrib">Attribute name ID.</param>
3058 /// <param name="attributeValue">Attribute new value.</param>
3059 internal void SetAttributeObject(CommonCustomProperties attrib
, object attributeValue
)
3061 properties
[(int)attrib
] = attributeValue
;
3065 /// Set the default properties of the data point.
3066 /// <param name="clearAll">Indicates that previous properties must be cleared.</param>
3068 virtual public void SetDefault(bool clearAll
)
3070 // If setting defaults for the data series - clear all properties and initialize common one
3071 if(!this.pointCustomProperties
)
3078 // !!! IMPORTANT !!!
3079 // After changing the default value of the common attribute you must also
3080 // change the DefaultAttribute of the property representing this attribute.
3081 if(!IsCustomPropertySet(CommonCustomProperties
.ToolTip
))
3082 SetAttributeObject(CommonCustomProperties
.ToolTip
, "");
3083 if(!IsCustomPropertySet(CommonCustomProperties
.LegendToolTip
))
3084 SetAttributeObject(CommonCustomProperties
.LegendToolTip
, "");
3085 if(!IsCustomPropertySet(CommonCustomProperties
.Color
))
3086 SetAttributeObject(CommonCustomProperties
.Color
, Color
.Empty
);
3087 if(!IsCustomPropertySet(CommonCustomProperties
.IsValueShownAsLabel
))
3088 SetAttributeObject(CommonCustomProperties
.IsValueShownAsLabel
, false);
3089 if(!IsCustomPropertySet(CommonCustomProperties
.MarkerStyle
))
3090 SetAttributeObject(CommonCustomProperties
.MarkerStyle
, MarkerStyle
.None
);
3091 if(!IsCustomPropertySet(CommonCustomProperties
.MarkerSize
))
3092 SetAttributeObject(CommonCustomProperties
.MarkerSize
, 5);
3093 if(!IsCustomPropertySet(CommonCustomProperties
.MarkerImage
))
3094 SetAttributeObject(CommonCustomProperties
.MarkerImage
, "");
3095 if(!IsCustomPropertySet(CommonCustomProperties
.Label
))
3096 SetAttributeObject(CommonCustomProperties
.Label
, "");
3097 if(!IsCustomPropertySet(CommonCustomProperties
.BorderWidth
))
3098 SetAttributeObject(CommonCustomProperties
.BorderWidth
, 1);
3099 if(!IsCustomPropertySet(CommonCustomProperties
.BorderDashStyle
))
3100 SetAttributeObject(CommonCustomProperties
.BorderDashStyle
, ChartDashStyle
.Solid
);
3103 if(!IsCustomPropertySet(CommonCustomProperties
.AxisLabel
))
3104 SetAttributeObject(CommonCustomProperties
.AxisLabel
, "");
3105 if(!IsCustomPropertySet(CommonCustomProperties
.LabelFormat
))
3106 SetAttributeObject(CommonCustomProperties
.LabelFormat
, "");
3107 if(!IsCustomPropertySet(CommonCustomProperties
.BorderColor
))
3108 SetAttributeObject(CommonCustomProperties
.BorderColor
, Color
.Empty
);
3109 if(!IsCustomPropertySet(CommonCustomProperties
.BackImage
))
3110 SetAttributeObject(CommonCustomProperties
.BackImage
, "");
3111 if(!IsCustomPropertySet(CommonCustomProperties
.BackImageWrapMode
))
3112 SetAttributeObject(CommonCustomProperties
.BackImageWrapMode
, ChartImageWrapMode
.Tile
);
3113 if(!IsCustomPropertySet(CommonCustomProperties
.BackImageAlignment
))
3114 SetAttributeObject(CommonCustomProperties
.BackImageAlignment
, ChartImageAlignmentStyle
.TopLeft
);
3115 if(!IsCustomPropertySet(CommonCustomProperties
.BackImageTransparentColor
))
3116 SetAttributeObject(CommonCustomProperties
.BackImageTransparentColor
, Color
.Empty
);
3117 if(!IsCustomPropertySet(CommonCustomProperties
.BackGradientStyle
))
3118 SetAttributeObject(CommonCustomProperties
.BackGradientStyle
, GradientStyle
.None
);
3119 if(!IsCustomPropertySet(CommonCustomProperties
.BackSecondaryColor
))
3120 SetAttributeObject(CommonCustomProperties
.BackSecondaryColor
, Color
.Empty
);
3121 if(!IsCustomPropertySet(CommonCustomProperties
.BackHatchStyle
))
3122 SetAttributeObject(CommonCustomProperties
.BackHatchStyle
, ChartHatchStyle
.None
);
3123 if(!IsCustomPropertySet(CommonCustomProperties
.Font
))
3124 SetAttributeObject(CommonCustomProperties
.Font
, null);
3125 if(!IsCustomPropertySet(CommonCustomProperties
.MarkerImageTransparentColor
))
3126 SetAttributeObject(CommonCustomProperties
.MarkerImageTransparentColor
, Color
.Empty
);
3127 if(!IsCustomPropertySet(CommonCustomProperties
.MarkerColor
))
3128 SetAttributeObject(CommonCustomProperties
.MarkerColor
, Color
.Empty
);
3129 if(!IsCustomPropertySet(CommonCustomProperties
.MarkerBorderColor
))
3130 SetAttributeObject(CommonCustomProperties
.MarkerBorderColor
, Color
.Empty
);
3131 if(!IsCustomPropertySet(CommonCustomProperties
.MarkerBorderWidth
))
3132 SetAttributeObject(CommonCustomProperties
.MarkerBorderWidth
, 1);
3133 if(!IsCustomPropertySet(CommonCustomProperties
.MapAreaAttributes
))
3134 SetAttributeObject(CommonCustomProperties
.MapAreaAttributes
, "");
3135 if (!IsCustomPropertySet(CommonCustomProperties
.PostBackValue
))
3136 SetAttributeObject(CommonCustomProperties
.PostBackValue
, "");
3138 if (!IsCustomPropertySet(CommonCustomProperties
.LabelForeColor
))
3139 SetAttributeObject(CommonCustomProperties
.LabelForeColor
, Color
.Black
);
3140 if (!IsCustomPropertySet(CommonCustomProperties
.LabelAngle
))
3141 SetAttributeObject(CommonCustomProperties
.LabelAngle
, 0);
3142 if (!IsCustomPropertySet(CommonCustomProperties
.LabelToolTip
))
3143 SetAttributeObject(CommonCustomProperties
.LabelToolTip
, "");
3144 if(!IsCustomPropertySet(CommonCustomProperties
.LabelUrl
))
3145 SetAttributeObject(CommonCustomProperties
.LabelUrl
, "");
3146 if (!IsCustomPropertySet(CommonCustomProperties
.LabelPostBackValue
))
3147 SetAttributeObject(CommonCustomProperties
.LabelPostBackValue
, "");
3148 if (!IsCustomPropertySet(CommonCustomProperties
.LabelMapAreaAttributes
))
3149 SetAttributeObject(CommonCustomProperties
.LabelMapAreaAttributes
, "");
3150 if(!IsCustomPropertySet(CommonCustomProperties
.LabelBackColor
))
3151 SetAttributeObject(CommonCustomProperties
.LabelBackColor
, Color
.Empty
);
3152 if(!IsCustomPropertySet(CommonCustomProperties
.LabelBorderWidth
))
3153 SetAttributeObject(CommonCustomProperties
.LabelBorderWidth
, 1);
3154 if(!IsCustomPropertySet(CommonCustomProperties
.LabelBorderDashStyle
))
3155 SetAttributeObject(CommonCustomProperties
.LabelBorderDashStyle
, ChartDashStyle
.Solid
);
3156 if(!IsCustomPropertySet(CommonCustomProperties
.LabelBorderColor
))
3157 SetAttributeObject(CommonCustomProperties
.LabelBorderColor
, Color
.Empty
);
3159 if(!IsCustomPropertySet(CommonCustomProperties
.Url
))
3160 SetAttributeObject(CommonCustomProperties
.Url
, "");
3161 if(!IsCustomPropertySet(CommonCustomProperties
.LegendUrl
))
3162 SetAttributeObject(CommonCustomProperties
.LegendUrl
, "");
3163 if (!IsCustomPropertySet(CommonCustomProperties
.LegendPostBackValue
))
3164 SetAttributeObject(CommonCustomProperties
.LegendPostBackValue
, "");
3165 if (!IsCustomPropertySet(CommonCustomProperties
.LegendText
))
3166 SetAttributeObject(CommonCustomProperties
.LegendText
, "");
3167 if(!IsCustomPropertySet(CommonCustomProperties
.LegendMapAreaAttributes
))
3168 SetAttributeObject(CommonCustomProperties
.LegendMapAreaAttributes
, "");
3169 if(!IsCustomPropertySet(CommonCustomProperties
.IsVisibleInLegend
))
3170 SetAttributeObject(CommonCustomProperties
.IsVisibleInLegend
, true);
3173 // If setting defaults for the data point - clear all properties
3182 #region DataPointCustomProperties Properties
3185 /// Indexer of the custom properties. Returns the DataPointCustomProperties object by index.
3187 /// <param name="index">Index of the custom property.</param>
3188 public string this[int index
]
3192 int currentIndex
= 0;
3193 foreach(object key
in properties
.Keys
)
3195 if(currentIndex
== index
)
3197 string keyStr
= key
as string;
3202 else if (key
is int)
3204 return Enum
.GetName(typeof(CommonCustomProperties
), key
);
3206 return key
.ToString();
3210 // we can't throw IndexOutOfRangeException here, it is reserved
3212 throw (new InvalidOperationException());
3217 /// Indexer of the custom properties. Returns the DataPointCustomProperties object by name.
3219 /// <param name="name">Name of the custom property.</param>
3220 public string this[string name
]
3224 // If attribute is not set in data point - try getting it from the series
3225 if(!IsCustomPropertySet(name
) && this.pointCustomProperties
)
3227 if(this.isEmptyPoint
)
3229 return (string)series
.EmptyPointStyle
.properties
[name
];
3232 return (string)series
.properties
[name
];
3234 return (string)properties
[name
];
3238 properties
[name
] = value;
3239 this.Invalidate(true);
3244 /// The text of the data point label.
3247 Editor(Editors
.KeywordsStringEditor
.Editor
, Editors
.KeywordsStringEditor
.Base
),
3248 #if !Microsoft_CONTROL
3249 PersistenceMode(PersistenceMode
.Attribute
),
3251 SRCategory("CategoryAttributeLabel"),
3253 SRDescription("DescriptionAttributeLabel"),
3255 virtual public string Label
3259 if(this.pointCustomProperties
)
3261 if(properties
.Count
!= 0 && IsCustomPropertySet(CommonCustomProperties
.Label
))
3263 return (string)GetAttributeObject(CommonCustomProperties
.Label
);
3271 if(this.isEmptyPoint
)
3273 return (string)series
.EmptyPointStyle
.GetAttributeObject(CommonCustomProperties
.Label
);
3276 return series
.label
;
3281 return series
.label
;
3286 // Replace NULL with empty string
3289 value = string.Empty
;
3292 if (this.pointCustomProperties
)
3293 SetAttributeObject(CommonCustomProperties
.Label
, value);
3295 series
.label
= value;
3297 this.Invalidate(true);
3302 /// The text of X axis label for the data point.
3305 SRCategory("CategoryAttributeMisc"),
3307 SRDescription("DescriptionAttributeAxisLabel"),
3308 Editor(Editors
.KeywordsStringEditor
.Editor
, Editors
.KeywordsStringEditor
.Base
),
3309 #if !Microsoft_CONTROL
3310 PersistenceMode(PersistenceMode
.Attribute
)
3313 virtual public string AxisLabel
3317 if(this.pointCustomProperties
)
3319 if(properties
.Count
!= 0 && IsCustomPropertySet(CommonCustomProperties
.AxisLabel
))
3321 return (string)GetAttributeObject(CommonCustomProperties
.AxisLabel
);
3329 if(this.isEmptyPoint
)
3331 return (string)series
.EmptyPointStyle
.GetAttributeObject(CommonCustomProperties
.AxisLabel
);
3334 return series
.axisLabel
;
3340 return series
.axisLabel
;
3345 // Replace NULL with empty string
3348 value = string.Empty
;
3351 if(this.pointCustomProperties
)
3352 SetAttributeObject(CommonCustomProperties
.AxisLabel
, value);
3354 series
.axisLabel
= value;
3356 // Set flag that there are non-empy axis labels in series or points
3357 if(value.Length
> 0 && series
!= null)
3359 series
.noLabelsInPoints
= false;
3362 this.Invalidate(false);
3367 /// Format string of the data point label.
3371 SRCategory("CategoryAttributeLabel"),
3373 SRDescription("DescriptionAttributeLabelFormat"),
3374 #if !Microsoft_CONTROL
3375 PersistenceMode(PersistenceMode
.Attribute
),
3378 public string LabelFormat
3382 if(this.pointCustomProperties
)
3384 if(properties
.Count
!= 0 && IsCustomPropertySet(CommonCustomProperties
.LabelFormat
))
3386 return (string)GetAttributeObject(CommonCustomProperties
.LabelFormat
);
3394 if(this.isEmptyPoint
)
3396 return (string)series
.EmptyPointStyle
.GetAttributeObject(CommonCustomProperties
.LabelFormat
);
3399 return series
.labelFormat
;
3404 return series
.labelFormat
;
3409 // Replace NULL with empty string
3412 value = string.Empty
;
3415 if(this.pointCustomProperties
)
3416 SetAttributeObject(CommonCustomProperties
.LabelFormat
, value);
3418 series
.labelFormat
= value;
3419 this.Invalidate(false);
3424 /// A flag which indicates whether to show the data point's value on the label.
3428 SRCategory("CategoryAttributeLabel"),
3430 SRDescription("DescriptionAttributeShowLabelAsValue"),
3431 #if !Microsoft_CONTROL
3432 PersistenceMode(PersistenceMode
.Attribute
)
3435 public bool IsValueShownAsLabel
3439 if(this.pointCustomProperties
)
3441 if(properties
.Count
!= 0 && IsCustomPropertySet(CommonCustomProperties
.IsValueShownAsLabel
))
3443 return (bool)GetAttributeObject(CommonCustomProperties
.IsValueShownAsLabel
);
3451 if(this.isEmptyPoint
)
3453 return (bool)series
.EmptyPointStyle
.GetAttributeObject(CommonCustomProperties
.IsValueShownAsLabel
);
3456 return series
.showLabelAsValue
;
3462 return series
.showLabelAsValue
;
3467 if(this.pointCustomProperties
)
3468 SetAttributeObject(CommonCustomProperties
.IsValueShownAsLabel
, value);
3470 series
.showLabelAsValue
= value;
3471 this.Invalidate(false);
3476 /// Color of the data point.
3479 SRCategory("CategoryAttributeAppearance"),
3481 SRDescription("DescriptionAttributeColor4"),
3482 TypeConverter(typeof(ColorConverter
)),
3483 Editor(Editors
.ChartColorEditor
.Editor
, Editors
.ChartColorEditor
.Base
),
3484 #if !Microsoft_CONTROL
3485 PersistenceMode(PersistenceMode
.Attribute
)
3492 if(this.pointCustomProperties
)
3494 if(properties
.Count
!= 0 && IsCustomPropertySet(CommonCustomProperties
.Color
))
3496 return (Color
)GetAttributeObject(CommonCustomProperties
.Color
);
3504 if(this.isEmptyPoint
)
3506 return (Color
)series
.EmptyPointStyle
.GetAttributeObject(CommonCustomProperties
.Color
);
3509 return series
.color
;
3514 return series
.color
;
3519 // Remove the temp color flag
3520 this.tempColorIsSet
= false;
3522 if(value == Color
.Empty
&& this.pointCustomProperties
)
3524 DeleteCustomProperty(CommonCustomProperties
.Color
);
3528 if(this.pointCustomProperties
)
3529 SetAttributeObject(CommonCustomProperties
.Color
, value);
3531 series
.color
= value;
3532 this.Invalidate(true);
3538 /// Border color of the data point.
3541 SRCategory("CategoryAttributeAppearance"),
3543 SRDescription("DescriptionAttributeBorderColor"),
3544 TypeConverter(typeof(ColorConverter
)),
3545 Editor(Editors
.ChartColorEditor
.Editor
, Editors
.ChartColorEditor
.Base
),
3546 #if !Microsoft_CONTROL
3547 PersistenceMode(PersistenceMode
.Attribute
)
3550 public Color BorderColor
3554 if(this.pointCustomProperties
)
3556 if(properties
.Count
!= 0 && IsCustomPropertySet(CommonCustomProperties
.BorderColor
))
3558 return (Color
)GetAttributeObject(CommonCustomProperties
.BorderColor
);
3566 if(this.isEmptyPoint
)
3568 return (Color
)series
.EmptyPointStyle
.GetAttributeObject(CommonCustomProperties
.BorderColor
);
3571 return series
.borderColor
;
3576 return series
.borderColor
;
3581 if(this.pointCustomProperties
)
3582 SetAttributeObject(CommonCustomProperties
.BorderColor
, value);
3584 series
.borderColor
= value;
3585 this.Invalidate(true);
3590 /// Border style of the data point.
3593 SRCategory("CategoryAttributeAppearance"),
3595 SRDescription("DescriptionAttributeBorderDashStyle"),
3596 #if !Microsoft_CONTROL
3597 PersistenceMode(PersistenceMode
.Attribute
)
3600 public ChartDashStyle BorderDashStyle
3604 if(this.pointCustomProperties
)
3606 if(properties
.Count
!= 0 && IsCustomPropertySet(CommonCustomProperties
.BorderDashStyle
))
3608 return (ChartDashStyle
)GetAttributeObject(CommonCustomProperties
.BorderDashStyle
);
3614 return ChartDashStyle
.Solid
;
3616 if(this.isEmptyPoint
)
3618 return (ChartDashStyle
)series
.EmptyPointStyle
.GetAttributeObject(CommonCustomProperties
.BorderDashStyle
);
3621 return series
.borderDashStyle
;
3627 return series
.borderDashStyle
;
3632 if(this.pointCustomProperties
)
3633 SetAttributeObject(CommonCustomProperties
.BorderDashStyle
, value);
3635 series
.borderDashStyle
= value;
3636 this.Invalidate(true);
3641 /// Border width of the data point.
3644 SRCategory("CategoryAttributeAppearance"),
3646 SRDescription("DescriptionAttributeBorderWidth"),
3647 #if !Microsoft_CONTROL
3648 PersistenceMode(PersistenceMode
.Attribute
)
3651 public int BorderWidth
3655 if(this.pointCustomProperties
)
3657 if(properties
.Count
!= 0 && IsCustomPropertySet(CommonCustomProperties
.BorderWidth
))
3659 return (int)GetAttributeObject(CommonCustomProperties
.BorderWidth
);
3667 if(this.isEmptyPoint
)
3669 return (int)series
.EmptyPointStyle
.GetAttributeObject(CommonCustomProperties
.BorderWidth
);
3672 return series
.borderWidth
;
3678 return series
.borderWidth
;
3685 throw (new ArgumentOutOfRangeException("value", SR
.ExceptionBorderWidthIsNotPositive
));
3687 if(this.pointCustomProperties
)
3688 SetAttributeObject(CommonCustomProperties
.BorderWidth
, value);
3690 series
.borderWidth
= value;
3691 this.Invalidate(true);
3696 /// Background image of the data point.
3699 SRCategory("CategoryAttributeAppearance"),
3701 SRDescription("DescriptionAttributeBackImage"),
3702 Editor(Editors
.ImageValueEditor
.Editor
, Editors
.ImageValueEditor
.Base
),
3703 #if !Microsoft_CONTROL
3704 PersistenceMode(PersistenceMode
.Attribute
),
3707 public string BackImage
3711 if(this.pointCustomProperties
)
3713 if(properties
.Count
!= 0 && IsCustomPropertySet(CommonCustomProperties
.BackImage
))
3715 return (string)GetAttributeObject(CommonCustomProperties
.BackImage
);
3723 if(this.isEmptyPoint
)
3725 return (string)series
.EmptyPointStyle
.GetAttributeObject(CommonCustomProperties
.BackImage
);
3728 return series
.backImage
;
3734 return series
.backImage
;
3739 // Replace NULL with empty string
3742 value = string.Empty
;
3745 if(this.pointCustomProperties
)
3746 SetAttributeObject(CommonCustomProperties
.BackImage
, value);
3748 series
.backImage
= value;
3749 this.Invalidate(true);
3754 /// Gets or sets the drawing mode of the background image.
3757 /// A <see cref="ChartImageWrapMode"/> value that defines the drawing mode of the image.
3760 SRCategory("CategoryAttributeAppearance"),
3762 SRDescription("DescriptionAttributeImageWrapMode"),
3763 #if !Microsoft_CONTROL
3764 PersistenceMode(PersistenceMode
.Attribute
)
3767 public ChartImageWrapMode BackImageWrapMode
3771 if(this.pointCustomProperties
)
3773 if(properties
.Count
!= 0 && IsCustomPropertySet(CommonCustomProperties
.BackImageWrapMode
))
3775 return (ChartImageWrapMode
)GetAttributeObject(CommonCustomProperties
.BackImageWrapMode
);
3781 return ChartImageWrapMode
.Tile
;
3783 if(this.isEmptyPoint
)
3785 return (ChartImageWrapMode
)series
.EmptyPointStyle
.GetAttributeObject(CommonCustomProperties
.BackImageWrapMode
);
3788 return series
.backImageWrapMode
;
3794 return series
.backImageWrapMode
;
3799 if(this.pointCustomProperties
)
3800 SetAttributeObject(CommonCustomProperties
.BackImageWrapMode
, value);
3802 series
.backImageWrapMode
= value;
3803 this.Invalidate(true);
3808 /// Gets or sets a color which will be replaced with a transparent color while drawing the background image.
3811 /// A <see cref="Color"/> value which will be replaced with a transparent color while drawing the image.
3814 SRCategory("CategoryAttributeAppearance"),
3816 NotifyParentPropertyAttribute(true),
3817 SRDescription("DescriptionAttributeImageTransparentColor"),
3818 TypeConverter(typeof(ColorConverter
)),
3819 Editor(Editors
.ChartColorEditor
.Editor
, Editors
.ChartColorEditor
.Base
),
3820 #if !Microsoft_CONTROL
3821 PersistenceMode(PersistenceMode
.Attribute
)
3824 public Color BackImageTransparentColor
3828 if(this.pointCustomProperties
)
3830 if(properties
.Count
!= 0 && IsCustomPropertySet(CommonCustomProperties
.BackImageTransparentColor
))
3832 return (Color
)GetAttributeObject(CommonCustomProperties
.BackImageTransparentColor
);
3840 if(this.isEmptyPoint
)
3842 return (Color
)series
.EmptyPointStyle
.GetAttributeObject(CommonCustomProperties
.BackImageTransparentColor
);
3845 return series
.backImageTransparentColor
;
3851 return series
.backImageTransparentColor
;
3856 if(this.pointCustomProperties
)
3857 SetAttributeObject(CommonCustomProperties
.BackImageTransparentColor
, value);
3859 series
.backImageTransparentColor
= value;
3860 this.Invalidate(true);
3865 /// Gets or sets the alignment of the background image which is used by ClampUnscale drawing mode.
3868 SRCategory("CategoryAttributeAppearance"),
3870 NotifyParentPropertyAttribute(true),
3871 SRDescription("DescriptionAttributeBackImageAlign"),
3872 #if !Microsoft_CONTROL
3873 PersistenceMode(PersistenceMode
.Attribute
)
3876 public ChartImageAlignmentStyle BackImageAlignment
3880 if(this.pointCustomProperties
)
3882 if(properties
.Count
!= 0 && IsCustomPropertySet(CommonCustomProperties
.BackImageAlignment
))
3884 return (ChartImageAlignmentStyle
)GetAttributeObject(CommonCustomProperties
.BackImageAlignment
);
3890 return ChartImageAlignmentStyle
.TopLeft
;
3892 if(this.isEmptyPoint
)
3894 return (ChartImageAlignmentStyle
)series
.EmptyPointStyle
.GetAttributeObject(CommonCustomProperties
.BackImageAlignment
);
3897 return series
.backImageAlignment
;
3903 return series
.backImageAlignment
;
3908 if(this.pointCustomProperties
)
3909 SetAttributeObject(CommonCustomProperties
.BackImageAlignment
, value);
3911 series
.backImageAlignment
= value;
3912 this.Invalidate(true);
3917 /// Gets or sets the background gradient style.
3920 SRCategory("CategoryAttributeAppearance"),
3922 SRDescription("DescriptionAttributeBackGradientStyle"),
3923 #if !Microsoft_CONTROL
3924 PersistenceMode(PersistenceMode
.Attribute
),
3926 Editor(Editors
.GradientEditor
.Editor
, Editors
.GradientEditor
.Base
)
3928 public GradientStyle BackGradientStyle
3932 if(this.pointCustomProperties
)
3934 if(properties
.Count
!= 0 && IsCustomPropertySet(CommonCustomProperties
.BackGradientStyle
))
3936 return (GradientStyle
)GetAttributeObject(CommonCustomProperties
.BackGradientStyle
);
3942 return GradientStyle
.None
;
3944 if(this.isEmptyPoint
)
3946 return (GradientStyle
)series
.EmptyPointStyle
.GetAttributeObject(CommonCustomProperties
.BackGradientStyle
);
3949 return series
.backGradientStyle
;
3955 return series
.backGradientStyle
;
3960 if(this.pointCustomProperties
)
3961 SetAttributeObject(CommonCustomProperties
.BackGradientStyle
, value);
3963 series
.backGradientStyle
= value;
3964 this.Invalidate(true);
3969 /// Gets or sets the secondary background color.
3972 SRCategory("CategoryAttributeAppearance"),
3974 SRDescription("DescriptionAttributeBackSecondaryColor"),
3975 TypeConverter(typeof(ColorConverter
)),
3976 Editor(Editors
.ChartColorEditor
.Editor
, Editors
.ChartColorEditor
.Base
),
3977 #if !Microsoft_CONTROL
3978 PersistenceMode(PersistenceMode
.Attribute
)
3981 public Color BackSecondaryColor
3985 if(this.pointCustomProperties
)
3987 if(properties
.Count
!= 0 && IsCustomPropertySet(CommonCustomProperties
.BackSecondaryColor
))
3989 return (Color
)GetAttributeObject(CommonCustomProperties
.BackSecondaryColor
);
3997 if(this.isEmptyPoint
)
3999 return (Color
)series
.EmptyPointStyle
.GetAttributeObject(CommonCustomProperties
.BackSecondaryColor
);
4002 return series
.backSecondaryColor
;
4008 return series
.backSecondaryColor
;
4013 if(this.pointCustomProperties
)
4014 SetAttributeObject(CommonCustomProperties
.BackSecondaryColor
, value);
4016 series
.backSecondaryColor
= value;
4017 this.Invalidate(true);
4022 /// Gets or sets the background hatch style.
4025 SRCategory("CategoryAttributeAppearance"),
4027 SRDescription("DescriptionAttributeBackHatchStyle"),
4028 #if !Microsoft_CONTROL
4029 PersistenceMode(PersistenceMode
.Attribute
),
4031 Editor(Editors
.HatchStyleEditor
.Editor
, Editors
.HatchStyleEditor
.Base
)
4033 public ChartHatchStyle BackHatchStyle
4037 if(this.pointCustomProperties
)
4039 if(properties
.Count
!= 0 && IsCustomPropertySet(CommonCustomProperties
.BackHatchStyle
))
4041 return (ChartHatchStyle
)GetAttributeObject(CommonCustomProperties
.BackHatchStyle
);
4047 return ChartHatchStyle
.None
;
4049 if(this.isEmptyPoint
)
4051 return (ChartHatchStyle
)series
.EmptyPointStyle
.GetAttributeObject(CommonCustomProperties
.BackHatchStyle
);
4054 return series
.backHatchStyle
;
4060 return series
.backHatchStyle
;
4065 if(this.pointCustomProperties
)
4066 SetAttributeObject(CommonCustomProperties
.BackHatchStyle
, value);
4068 series
.backHatchStyle
= value;
4069 this.Invalidate(true);
4074 /// Gets or sets the font of the data point.
4077 SRCategory("CategoryAttributeLabelAppearance"),
4079 SRDescription("DescriptionAttributeFont"),
4080 #if !Microsoft_CONTROL
4081 PersistenceMode(PersistenceMode
.Attribute
)
4088 if(this.pointCustomProperties
)
4090 if(properties
.Count
!= 0 && IsCustomPropertySet(CommonCustomProperties
.Font
))
4092 Font font
= GetAttributeObject(CommonCustomProperties
.Font
) as Font
;
4099 return series
.FontCache
.DefaultFont
;
4102 if(this.isEmptyPoint
)
4104 return series
.EmptyPointStyle
.Font
;
4116 if(this.pointCustomProperties
)
4117 SetAttributeObject(CommonCustomProperties
.Font
, value);
4119 series
.font
= value;
4120 this.Invalidate(false);
4125 /// Gets or sets the label color.
4128 SRCategory("CategoryAttributeLabelAppearance"),
4130 SRDescription("DescriptionAttributeFontColor"),
4131 TypeConverter(typeof(ColorConverter
)),
4132 Editor(Editors
.ChartColorEditor
.Editor
, Editors
.ChartColorEditor
.Base
),
4133 #if !Microsoft_CONTROL
4134 PersistenceMode(PersistenceMode
.Attribute
)
4137 public Color LabelForeColor
4141 if(this.pointCustomProperties
)
4143 if(properties
.Count
!= 0 && IsCustomPropertySet(CommonCustomProperties
.LabelForeColor
))
4145 Color color
= (Color
)GetAttributeObject(CommonCustomProperties
.LabelForeColor
);
4154 if(this.isEmptyPoint
)
4156 return (Color
)series
.EmptyPointStyle
.GetAttributeObject(CommonCustomProperties
.LabelForeColor
);
4159 return series
.fontColor
;
4165 return series
.fontColor
;
4170 if(this.pointCustomProperties
)
4171 SetAttributeObject(CommonCustomProperties
.LabelForeColor
, value);
4173 series
.fontColor
= value;
4174 this.Invalidate(false);
4179 /// Gets or sets the angle of the label.
4182 SRCategory("CategoryAttributeLabelAppearance"),
4184 SRDescription(SR
.Keys
.DescriptionAttributeLabel_FontAngle
),
4185 #if !Microsoft_CONTROL
4186 PersistenceMode(PersistenceMode
.Attribute
),
4189 public int LabelAngle
4193 if(this.pointCustomProperties
)
4195 if(properties
.Count
!= 0 && IsCustomPropertySet(CommonCustomProperties
.LabelAngle
))
4197 return (int)GetAttributeObject(CommonCustomProperties
.LabelAngle
);
4205 if(this.isEmptyPoint
)
4207 return (int)series
.EmptyPointStyle
.GetAttributeObject(CommonCustomProperties
.LabelAngle
);
4210 return series
.fontAngle
;
4216 return series
.fontAngle
;
4221 if(value < -90 || value > 90)
4223 throw (new ArgumentOutOfRangeException("value", SR
.ExceptionAngleRangeInvalid
));
4225 if(this.pointCustomProperties
)
4226 SetAttributeObject(CommonCustomProperties
.LabelAngle
, value);
4228 series
.fontAngle
= value;
4229 this.Invalidate(false);
4234 /// Gets or sets the marker style.
4237 SRCategory("CategoryAttributeMarker"),
4239 SRDescription("DescriptionAttributeMarkerStyle4"),
4240 #if !Microsoft_CONTROL
4241 PersistenceMode(PersistenceMode
.Attribute
),
4243 Editor(Editors
.MarkerStyleEditor
.Editor
, Editors
.MarkerStyleEditor
.Base
),
4244 RefreshProperties(RefreshProperties
.All
)
4246 public MarkerStyle MarkerStyle
4250 if(this.pointCustomProperties
)
4252 if(properties
.Count
!= 0 && IsCustomPropertySet(CommonCustomProperties
.MarkerStyle
))
4254 return (MarkerStyle
)GetAttributeObject(CommonCustomProperties
.MarkerStyle
);
4260 return MarkerStyle
.None
;
4262 if(this.isEmptyPoint
)
4264 return (MarkerStyle
)series
.EmptyPointStyle
.GetAttributeObject(CommonCustomProperties
.MarkerStyle
);
4267 return series
.markerStyle
;
4273 return series
.markerStyle
;
4278 if(this.pointCustomProperties
)
4279 SetAttributeObject(CommonCustomProperties
.MarkerStyle
, value);
4281 series
.markerStyle
= value;
4283 Series thisSeries
= this as Series
;
4284 if(thisSeries
!= null)
4286 thisSeries
.tempMarkerStyleIsSet
= false;
4288 this.Invalidate(true);
4293 /// Gets or sets the size of the marker.
4296 SRCategory("CategoryAttributeMarker"),
4298 SRDescription("DescriptionAttributeMarkerSize"),
4299 #if !Microsoft_CONTROL
4300 PersistenceMode(PersistenceMode
.Attribute
),
4302 RefreshProperties(RefreshProperties
.All
)
4304 public int MarkerSize
4308 if(this.pointCustomProperties
)
4310 if(properties
.Count
!= 0 && IsCustomPropertySet(CommonCustomProperties
.MarkerSize
))
4312 return (int)GetAttributeObject(CommonCustomProperties
.MarkerSize
);
4320 if(this.isEmptyPoint
)
4322 return (int)series
.EmptyPointStyle
.GetAttributeObject(CommonCustomProperties
.MarkerSize
);
4325 return series
.markerSize
;
4331 return series
.markerSize
;
4336 if(this.pointCustomProperties
)
4337 SetAttributeObject(CommonCustomProperties
.MarkerSize
, value);
4339 series
.markerSize
= value;
4340 this.Invalidate(true);
4345 /// Gets or sets the marker image.
4348 SRCategory("CategoryAttributeMarker"),
4350 SRDescription("DescriptionAttributeMarkerImage"),
4351 Editor(Editors
.ImageValueEditor
.Editor
, Editors
.ImageValueEditor
.Base
),
4352 #if !Microsoft_CONTROL
4353 PersistenceMode(PersistenceMode
.Attribute
),
4355 RefreshProperties(RefreshProperties
.All
)
4357 public string MarkerImage
4361 if(this.pointCustomProperties
)
4363 if(properties
.Count
!= 0 && IsCustomPropertySet(CommonCustomProperties
.MarkerImage
))
4365 return (string)GetAttributeObject(CommonCustomProperties
.MarkerImage
);
4373 if(this.isEmptyPoint
)
4375 return (string)series
.EmptyPointStyle
.GetAttributeObject(CommonCustomProperties
.MarkerImage
);
4378 return series
.markerImage
;
4384 return series
.markerImage
;
4389 // Replace NULL with empty string
4392 value = string.Empty
;
4395 if(this.pointCustomProperties
)
4396 SetAttributeObject(CommonCustomProperties
.MarkerImage
, value);
4398 series
.markerImage
= value;
4399 this.Invalidate(true);
4404 /// Gets or sets the color which will be replaced with a transparent color while drawing the marker image.
4407 SRCategory("CategoryAttributeMarker"),
4409 SRDescription("DescriptionAttributeImageTransparentColor"),
4410 TypeConverter(typeof(ColorConverter
)),
4411 Editor(Editors
.ChartColorEditor
.Editor
, Editors
.ChartColorEditor
.Base
),
4412 #if !Microsoft_CONTROL
4413 PersistenceMode(PersistenceMode
.Attribute
),
4415 RefreshProperties(RefreshProperties
.All
)
4417 public Color MarkerImageTransparentColor
4421 if(this.pointCustomProperties
)
4423 if(properties
.Count
!= 0 && IsCustomPropertySet(CommonCustomProperties
.MarkerImageTransparentColor
))
4425 return (Color
)GetAttributeObject(CommonCustomProperties
.MarkerImageTransparentColor
);
4433 if(this.isEmptyPoint
)
4435 return (Color
)series
.EmptyPointStyle
.GetAttributeObject(CommonCustomProperties
.MarkerImageTransparentColor
);
4438 return series
.markerImageTransparentColor
;
4444 return series
.markerImageTransparentColor
;
4449 if(this.pointCustomProperties
)
4450 SetAttributeObject(CommonCustomProperties
.MarkerImageTransparentColor
, value);
4452 series
.markerImageTransparentColor
= value;
4453 this.Invalidate(true);
4458 /// Gets or sets the marker color.
4461 SRCategory("CategoryAttributeMarker"),
4463 SRDescription("DescriptionAttributeMarkerColor3"),
4464 TypeConverter(typeof(ColorConverter
)),
4465 Editor(Editors
.ChartColorEditor
.Editor
, Editors
.ChartColorEditor
.Base
),
4466 #if !Microsoft_CONTROL
4467 PersistenceMode(PersistenceMode
.Attribute
),
4469 RefreshProperties(RefreshProperties
.All
)
4471 public Color MarkerColor
4475 if(this.pointCustomProperties
)
4477 if(properties
.Count
!= 0 && IsCustomPropertySet(CommonCustomProperties
.MarkerColor
))
4479 return (Color
)GetAttributeObject(CommonCustomProperties
.MarkerColor
);
4487 if(this.isEmptyPoint
)
4489 return (Color
)series
.EmptyPointStyle
.GetAttributeObject(CommonCustomProperties
.MarkerColor
);
4492 return series
.markerColor
;
4498 return series
.markerColor
;
4503 if(this.pointCustomProperties
)
4504 SetAttributeObject(CommonCustomProperties
.MarkerColor
, value);
4506 series
.markerColor
= value;
4507 this.Invalidate(true);
4512 /// Gets or sets the border color of the marker.
4515 SRCategory("CategoryAttributeMarker"),
4517 SRDescription("DescriptionAttributeMarkerBorderColor"),
4518 TypeConverter(typeof(ColorConverter
)),
4519 Editor(Editors
.ChartColorEditor
.Editor
, Editors
.ChartColorEditor
.Base
),
4520 #if !Microsoft_CONTROL
4521 PersistenceMode(PersistenceMode
.Attribute
),
4523 RefreshProperties(RefreshProperties
.All
)
4525 public Color MarkerBorderColor
4529 if(this.pointCustomProperties
)
4531 if(properties
.Count
!= 0 && IsCustomPropertySet(CommonCustomProperties
.MarkerBorderColor
))
4533 return (Color
)GetAttributeObject(CommonCustomProperties
.MarkerBorderColor
);
4541 if(this.isEmptyPoint
)
4543 return (Color
)series
.EmptyPointStyle
.GetAttributeObject(CommonCustomProperties
.MarkerBorderColor
);
4546 return series
.markerBorderColor
;
4552 return series
.markerBorderColor
;
4557 if(this.pointCustomProperties
)
4558 SetAttributeObject(CommonCustomProperties
.MarkerBorderColor
, value);
4560 series
.markerBorderColor
= value;
4561 this.Invalidate(true);
4568 /// Gets or sets the border width of the marker.
4572 SRCategory("CategoryAttributeMarker"),
4574 SRDescription("DescriptionAttributeMarkerBorderWidth"),
4575 #if !Microsoft_CONTROL
4576 PersistenceMode(PersistenceMode
.Attribute
)
4579 public int MarkerBorderWidth
4583 if(this.pointCustomProperties
)
4585 if(properties
.Count
!= 0 && IsCustomPropertySet(CommonCustomProperties
.MarkerBorderWidth
))
4587 return (int)GetAttributeObject(CommonCustomProperties
.MarkerBorderWidth
);
4595 if(this.isEmptyPoint
)
4597 return (int)series
.EmptyPointStyle
.GetAttributeObject(CommonCustomProperties
.MarkerBorderWidth
);
4600 return series
.markerBorderWidth
;
4606 return series
.markerBorderWidth
;
4613 throw (new ArgumentOutOfRangeException("value", SR
.ExceptionBorderWidthIsNotPositive
));
4615 if(this.pointCustomProperties
)
4616 SetAttributeObject(CommonCustomProperties
.MarkerBorderWidth
, value);
4618 series
.markerBorderWidth
= value;
4619 this.Invalidate(true);
4626 /// Gets or sets the extended custom properties of the data point.
4627 /// Extended custom properties can be specified in the following format:
4628 /// AttrName1=Value1, AttrName2=Value2, ...
4631 SRCategory("CategoryAttributeMisc"),
4633 SRDescription("DescriptionAttributeCustomAttributesExtended"),
4635 RefreshProperties(RefreshProperties
.All
),
4636 NotifyParentPropertyAttribute(true),
4637 DesignOnlyAttribute(true),
4638 DesignerSerializationVisibility(DesignerSerializationVisibility
.Hidden
),
4639 SerializationVisibilityAttribute(SerializationVisibility
.Hidden
),
4640 EditorBrowsableAttribute(EditorBrowsableState
.Never
),
4641 DisplayName("CustomProperties")
4643 public CustomProperties CustomPropertiesExtended
4647 customProperties
= value;
4651 return customProperties
;
4656 /// Gets or sets the custom properties of the data point.
4657 /// Custom properties can be specified in the following format:
4658 /// AttrName1=Value1, AttrName2=Value2, ...
4661 SRCategory("CategoryAttributeMisc"),
4664 SRDescription("DescriptionAttributeCustomAttributesExtended"),
4666 #if !Microsoft_CONTROL
4667 PersistenceMode(PersistenceMode
.Attribute
)
4670 public string CustomProperties
4674 // Save all custom properties in a string
4676 string[] attributesNames
= CommonCustomProperties
.GetNames(typeof(CommonCustomProperties
));
4677 for(int i
= properties
.Count
- 1; i
>= 0; i
--)
4681 string attributeName
= this[i
];
4683 // Check if attribute is custom
4684 bool customAttribute
= true;
4685 foreach(string name
in attributesNames
)
4687 if(String
.Compare(attributeName
, name
, StringComparison
.OrdinalIgnoreCase
) == 0)
4689 customAttribute
= false;
4694 // Add custom attribute to the string
4695 if(customAttribute
&& properties
[attributeName
] != null)
4697 if(result
.Length
> 0)
4701 string attributeValue
= properties
[attributeName
].ToString().Replace(",", "\\,");
4702 attributeValue
= attributeValue
.Replace("=", "\\=");
4704 result
+= attributeName
+ "=" + attributeValue
;
4713 // Replace NULL with empty string
4716 value = string.Empty
;
4719 // Copy all common properties to the new collection
4720 Hashtable newAttributes
= new Hashtable();
4721 Array enumValues
= Enum
.GetValues(typeof(CommonCustomProperties
));
4722 foreach(object val
in enumValues
)
4724 if(IsCustomPropertySet((CommonCustomProperties
)val
))
4726 newAttributes
[(int)val
] = properties
[(int)val
];
4730 if(value.Length
> 0)
4732 // Replace commas in value string
4733 value = value.Replace("\\,", "\\x45");
4734 value = value.Replace("\\=", "\\x46");
4736 // Add new custom properties
4737 string[] nameValueStrings
= value.Split(',');
4738 foreach(string nameValue
in nameValueStrings
)
4740 string[] values
= nameValue
.Split('=');
4743 if(values
.Length
!= 2)
4745 throw(new FormatException( SR
.ExceptionAttributeInvalidFormat
));
4748 // Check for empty name or value
4749 values
[0] = values
[0].Trim();
4750 values
[1] = values
[1].Trim();
4751 if(values
[0].Length
== 0)
4753 throw(new FormatException( SR
.ExceptionAttributeInvalidFormat
));
4756 // Check if value already defined
4757 foreach(object existingAttributeName
in newAttributes
.Keys
)
4759 string existingAttributeNameStr
= existingAttributeName
as string;
4760 if (existingAttributeNameStr
!= null)
4762 if (String
.Compare(existingAttributeNameStr
, values
[0], StringComparison
.OrdinalIgnoreCase
) == 0)
4764 throw(new FormatException( SR
.ExceptionAttributeNameIsNotUnique(values
[0] ) ) );
4769 string newValue
= values
[1].Replace("\\x45", ",");
4770 newAttributes
[values
[0]] = newValue
.Replace("\\x46", "=");
4774 properties
= newAttributes
;
4775 this.Invalidate(true);
4781 #region IMapAreaAttributesutes Properties implementation
4787 SRCategory("CategoryAttributeMapArea"),
4789 SRDescription("DescriptionAttributeToolTip"),
4790 Editor(Editors
.KeywordsStringEditor
.Editor
, Editors
.KeywordsStringEditor
.Base
),
4791 #if !Microsoft_CONTROL
4793 PersistenceMode(PersistenceMode
.Attribute
)
4796 public string ToolTip
4800 if(this.pointCustomProperties
)
4801 SetAttributeObject(CommonCustomProperties
.ToolTip
, value);
4803 series
.toolTip
= value;
4805 #if Microsoft_CONTROL
4806 if(Chart
!= null && Chart
.selection
!= null)
4808 Chart
.selection
.enabledChecked
= false;
4814 if(this.pointCustomProperties
)
4816 if(properties
.Count
!= 0 && IsCustomPropertySet(CommonCustomProperties
.ToolTip
))
4818 return (String
)GetAttributeObject(CommonCustomProperties
.ToolTip
);
4826 if(this.isEmptyPoint
)
4828 return (string)series
.EmptyPointStyle
.GetAttributeObject(CommonCustomProperties
.ToolTip
);
4831 return series
.toolTip
;
4837 return series
.toolTip
;
4842 #if !Microsoft_CONTROL
4845 /// URL target of the area.
4848 SRCategory("CategoryAttributeMapArea"),
4850 SRDescription("DescriptionAttributeUrl"),
4852 #if !Microsoft_CONTROL
4853 PersistenceMode(PersistenceMode
.Attribute
),
4854 Editor(Editors
.UrlValueEditor
.Editor
, Editors
.UrlValueEditor
.Base
)
4861 if(this.pointCustomProperties
)
4862 SetAttributeObject(CommonCustomProperties
.Url
, value);
4868 if(this.pointCustomProperties
)
4870 if(properties
.Count
!= 0 && IsCustomPropertySet(CommonCustomProperties
.Url
))
4872 return (String
)GetAttributeObject(CommonCustomProperties
.Url
);
4880 if(this.isEmptyPoint
)
4882 return (string)series
.EmptyPointStyle
.GetAttributeObject(CommonCustomProperties
.Url
);
4897 /// Other attributes of the area.
4900 SRCategory("CategoryAttributeMapArea"),
4902 SRDescription("DescriptionAttributeMapAreaAttributes"),
4904 PersistenceMode(PersistenceMode
.Attribute
),
4905 Editor(Editors
.KeywordsStringEditor
.Editor
, Editors
.KeywordsStringEditor
.Base
)
4907 public string MapAreaAttributes
4911 if(this.pointCustomProperties
)
4912 SetAttributeObject(CommonCustomProperties
.MapAreaAttributes
, value);
4914 series
.mapAreaAttributes
= value;
4918 if(this.pointCustomProperties
)
4920 if(properties
.Count
!= 0 && IsCustomPropertySet(CommonCustomProperties
.MapAreaAttributes
))
4922 return (String
)GetAttributeObject(CommonCustomProperties
.MapAreaAttributes
);
4930 if(this.isEmptyPoint
)
4932 return (string)series
.EmptyPointStyle
.GetAttributeObject(CommonCustomProperties
.MapAreaAttributes
);
4935 return series
.mapAreaAttributes
;
4940 return series
.mapAreaAttributes
;
4946 /// Gets or sets the postback value which can be processed on click event.
4948 /// <value>The value which is passed to click event as argument.</value>
4950 [SRCategory(SR
.Keys
.CategoryAttributeMapArea
)]
4951 [SRDescription(SR
.Keys
.DescriptionAttributePostBackValue
)]
4952 [Editor(Editors
.KeywordsStringEditor
.Editor
, Editors
.KeywordsStringEditor
.Base
)]
4953 public string PostBackValue
4957 if (this.pointCustomProperties
)
4959 if (properties
.Count
!= 0 && IsCustomPropertySet(CommonCustomProperties
.PostBackValue
))
4961 return (String
)GetAttributeObject(CommonCustomProperties
.PostBackValue
);
4965 if (IsSerializing())
4969 if (this.isEmptyPoint
)
4971 return (string)series
.EmptyPointStyle
.GetAttributeObject(CommonCustomProperties
.PostBackValue
);
4974 return series
.postbackValue
;
4979 return series
.postbackValue
;
4984 if (this.pointCustomProperties
)
4985 SetAttributeObject(CommonCustomProperties
.PostBackValue
, value);
4987 series
.postbackValue
= value;
4996 /// Replaces predefined keyword inside the string with their values.
4998 /// <param name="strOriginal">Original string with keywords.</param>
4999 /// <returns>Modified string.</returns>
5000 internal virtual string ReplaceKeywords(string strOriginal
)
5007 #region Legend properties
5010 /// Indicates whether the item is shown in the legend.
5013 SRCategory("CategoryAttributeLegend"),
5016 SRDescription("DescriptionAttributeShowInLegend"),
5017 #if !Microsoft_CONTROL
5019 PersistenceMode(PersistenceMode
.Attribute
)
5022 public bool IsVisibleInLegend
5026 if(this.pointCustomProperties
)
5028 if(properties
.Count
!= 0 && IsCustomPropertySet(CommonCustomProperties
.IsVisibleInLegend
))
5030 return (bool)GetAttributeObject(CommonCustomProperties
.IsVisibleInLegend
);
5038 if(this.isEmptyPoint
)
5040 return (bool)series
.EmptyPointStyle
.GetAttributeObject(CommonCustomProperties
.IsVisibleInLegend
);
5043 return series
.showInLegend
;
5048 return series
.showInLegend
;
5053 if(this.pointCustomProperties
)
5054 SetAttributeObject(CommonCustomProperties
.IsVisibleInLegend
, value);
5056 series
.showInLegend
= value;
5057 this.Invalidate(true);
5062 /// Text of the item in the legend
5065 SRCategory("CategoryAttributeLegend"),
5067 SRDescription("DescriptionAttributeLegendText"),
5068 Editor(Editors
.KeywordsStringEditor
.Editor
, Editors
.KeywordsStringEditor
.Base
),
5069 #if !Microsoft_CONTROL
5071 PersistenceMode(PersistenceMode
.Attribute
)
5074 public string LegendText
5078 if(this.pointCustomProperties
)
5079 SetAttributeObject(CommonCustomProperties
.LegendText
, value);
5081 series
.legendText
= value;
5082 this.Invalidate(true);
5086 if(this.pointCustomProperties
)
5088 if(properties
.Count
!= 0 && IsCustomPropertySet(CommonCustomProperties
.LegendText
))
5090 return (String
)GetAttributeObject(CommonCustomProperties
.LegendText
);
5098 if(this.isEmptyPoint
)
5100 return (string)series
.EmptyPointStyle
.GetAttributeObject(CommonCustomProperties
.LegendText
);
5103 return series
.legendText
;
5108 return series
.legendText
;
5114 /// Tooltip of the item in the legend
5117 SRCategory("CategoryAttributeLegend"),
5119 SRDescription("DescriptionAttributeLegendToolTip"),
5120 Editor(Editors
.KeywordsStringEditor
.Editor
, Editors
.KeywordsStringEditor
.Base
),
5121 #if !Microsoft_CONTROL
5123 PersistenceMode(PersistenceMode
.Attribute
)
5126 public string LegendToolTip
5130 if(this.pointCustomProperties
)
5131 SetAttributeObject(CommonCustomProperties
.LegendToolTip
, value);
5133 series
.legendToolTip
= value;
5135 #if Microsoft_CONTROL
5136 if(Chart
!= null && Chart
.selection
!= null)
5138 Chart
.selection
.enabledChecked
= false;
5144 if(this.pointCustomProperties
)
5146 if(properties
.Count
!= 0 && IsCustomPropertySet(CommonCustomProperties
.LegendToolTip
))
5148 return (String
)GetAttributeObject(CommonCustomProperties
.LegendToolTip
);
5156 if(this.isEmptyPoint
)
5158 return (string)series
.EmptyPointStyle
.GetAttributeObject(CommonCustomProperties
.LegendToolTip
);
5161 return series
.legendToolTip
;
5167 return series
.legendToolTip
;
5175 /// Background color of the data point label.
5178 SRCategory("CategoryAttributeLabelAppearance"),
5180 SRDescription("DescriptionAttributeLabelBackColor"),
5181 TypeConverter(typeof(ColorConverter
)),
5182 Editor(Editors
.ChartColorEditor
.Editor
, Editors
.ChartColorEditor
.Base
),
5183 DefaultValue(typeof(Color
), ""),
5184 #if !Microsoft_CONTROL
5185 PersistenceMode(PersistenceMode
.Attribute
)
5188 public Color LabelBackColor
5192 if(this.pointCustomProperties
)
5194 if(properties
.Count
!= 0 && IsCustomPropertySet(CommonCustomProperties
.LabelBackColor
))
5196 return (Color
)GetAttributeObject(CommonCustomProperties
.LabelBackColor
);
5204 if(this.isEmptyPoint
)
5206 return (Color
)series
.EmptyPointStyle
.GetAttributeObject(CommonCustomProperties
.LabelBackColor
);
5209 return series
.labelBackColor
;
5214 return series
.labelBackColor
;
5219 if(this.pointCustomProperties
)
5220 SetAttributeObject(CommonCustomProperties
.LabelBackColor
, value);
5222 series
.labelBackColor
= value;
5223 this.Invalidate(true);
5228 /// Border color of the data point label.
5231 SRCategory("CategoryAttributeLabelAppearance"),
5233 SRDescription("DescriptionAttributeBorderColor"),
5234 TypeConverter(typeof(ColorConverter
)),
5235 Editor(Editors
.ChartColorEditor
.Editor
, Editors
.ChartColorEditor
.Base
),
5236 DefaultValue(typeof(Color
), ""),
5237 #if !Microsoft_CONTROL
5238 PersistenceMode(PersistenceMode
.Attribute
)
5241 public Color LabelBorderColor
5245 if(this.pointCustomProperties
)
5247 if(properties
.Count
!= 0 && IsCustomPropertySet(CommonCustomProperties
.LabelBorderColor
))
5249 return (Color
)GetAttributeObject(CommonCustomProperties
.LabelBorderColor
);
5257 if(this.isEmptyPoint
)
5259 return (Color
)series
.EmptyPointStyle
.GetAttributeObject(CommonCustomProperties
.LabelBorderColor
);
5262 return series
.labelBorderColor
;
5267 return series
.labelBorderColor
;
5272 if(this.pointCustomProperties
)
5273 SetAttributeObject(CommonCustomProperties
.LabelBorderColor
, value);
5275 series
.labelBorderColor
= value;
5276 this.Invalidate(true);
5281 /// Border style of the label.
5284 SRCategory("CategoryAttributeLabelAppearance"),
5286 SRDescription("DescriptionAttributeLabelBorderDashStyle"),
5287 #if !Microsoft_CONTROL
5288 DefaultValue(ChartDashStyle
.Solid
),
5289 PersistenceMode(PersistenceMode
.Attribute
)
5292 public ChartDashStyle LabelBorderDashStyle
5296 if(this.pointCustomProperties
)
5298 if(properties
.Count
!= 0 && IsCustomPropertySet(CommonCustomProperties
.LabelBorderDashStyle
))
5300 return (ChartDashStyle
)GetAttributeObject(CommonCustomProperties
.LabelBorderDashStyle
);
5306 return ChartDashStyle
.Solid
;
5308 if(this.isEmptyPoint
)
5310 return (ChartDashStyle
)series
.EmptyPointStyle
.GetAttributeObject(CommonCustomProperties
.LabelBorderDashStyle
);
5313 return series
.labelBorderDashStyle
;
5319 return series
.labelBorderDashStyle
;
5324 if(this.pointCustomProperties
)
5325 SetAttributeObject(CommonCustomProperties
.LabelBorderDashStyle
, value);
5327 series
.labelBorderDashStyle
= value;
5328 this.Invalidate(true);
5333 /// Border width of the label.
5336 SRCategory("CategoryAttributeLabelAppearance"),
5338 SRDescription("DescriptionAttributeBorderWidth"),
5339 #if !Microsoft_CONTROL
5341 PersistenceMode(PersistenceMode
.Attribute
)
5344 public int LabelBorderWidth
5348 if(this.pointCustomProperties
)
5350 if(properties
.Count
!= 0 && IsCustomPropertySet(CommonCustomProperties
.LabelBorderWidth
))
5352 return (int)GetAttributeObject(CommonCustomProperties
.LabelBorderWidth
);
5360 if(this.isEmptyPoint
)
5362 return (int)series
.EmptyPointStyle
.GetAttributeObject(CommonCustomProperties
.LabelBorderWidth
);
5365 return series
.labelBorderWidth
;
5371 return series
.labelBorderWidth
;
5378 throw(new ArgumentOutOfRangeException("value", SR
.ExceptionLabelBorderIsNotPositive
));
5380 if(this.pointCustomProperties
)
5381 SetAttributeObject(CommonCustomProperties
.LabelBorderWidth
, value);
5383 series
.labelBorderWidth
= value;
5384 this.Invalidate(true);
5389 /// Tooltip of the data point label.
5392 SRCategory("CategoryAttributeLabel"),
5394 SRDescription("DescriptionAttributeLabelToolTip"),
5395 Editor(Editors
.KeywordsStringEditor
.Editor
, Editors
.KeywordsStringEditor
.Base
),
5396 #if !Microsoft_CONTROL
5398 PersistenceMode(PersistenceMode
.Attribute
)
5401 public string LabelToolTip
5405 if(this.pointCustomProperties
)
5406 SetAttributeObject(CommonCustomProperties
.LabelToolTip
, value);
5408 series
.labelToolTip
= value;
5410 #if Microsoft_CONTROL
5411 if(Chart
!= null && Chart
.selection
!= null)
5413 Chart
.selection
.enabledChecked
= false;
5419 if(this.pointCustomProperties
)
5421 if(properties
.Count
!= 0 && IsCustomPropertySet(CommonCustomProperties
.LabelToolTip
))
5423 return (String
)GetAttributeObject(CommonCustomProperties
.LabelToolTip
);
5431 if(this.isEmptyPoint
)
5433 return (string)series
.EmptyPointStyle
.GetAttributeObject(CommonCustomProperties
.LabelToolTip
);
5436 return series
.labelToolTip
;
5442 return series
.labelToolTip
;
5448 #if !Microsoft_CONTROL
5451 /// URL target of the item in the legend.
5454 SRCategory("CategoryAttributeLegend"),
5456 SRDescription("DescriptionAttributeLegendUrl"),
5458 PersistenceMode(PersistenceMode
.Attribute
),
5459 Editor(Editors
.UrlValueEditor
.Editor
, Editors
.UrlValueEditor
.Base
),
5460 SuppressMessage("Microsoft.Design", "CA1056:UriPropertiesShouldNotBeStrings")
5462 public string LegendUrl
5466 if(this.pointCustomProperties
)
5467 SetAttributeObject(CommonCustomProperties
.LegendUrl
, value);
5469 series
.legendUrl
= value;
5473 if(this.pointCustomProperties
)
5475 if(properties
.Count
!= 0 && IsCustomPropertySet(CommonCustomProperties
.LegendUrl
))
5477 return (String
)GetAttributeObject(CommonCustomProperties
.LegendUrl
);
5485 if(this.isEmptyPoint
)
5487 return (string)series
.EmptyPointStyle
.GetAttributeObject(CommonCustomProperties
.LegendUrl
);
5490 return series
.legendUrl
;
5495 return series
.legendUrl
;
5502 #if !Microsoft_CONTROL
5505 /// Other attributes of the legend map area.
5508 SRCategory("CategoryAttributeLegend"),
5510 SRDescription("DescriptionAttributeMapAreaAttributes"),
5512 PersistenceMode(PersistenceMode
.Attribute
),
5513 Editor(Editors
.KeywordsStringEditor
.Editor
, Editors
.KeywordsStringEditor
.Base
)
5515 public string LegendMapAreaAttributes
5519 if(this.pointCustomProperties
)
5520 SetAttributeObject(CommonCustomProperties
.LegendMapAreaAttributes
, value);
5522 series
.legendMapAreaAttributes
= value;
5526 if(this.pointCustomProperties
)
5528 if(properties
.Count
!= 0 && IsCustomPropertySet(CommonCustomProperties
.LegendMapAreaAttributes
))
5530 return (String
)GetAttributeObject(CommonCustomProperties
.LegendMapAreaAttributes
);
5538 if(this.isEmptyPoint
)
5540 return (string)series
.EmptyPointStyle
.GetAttributeObject(CommonCustomProperties
.LegendMapAreaAttributes
);
5543 return series
.legendMapAreaAttributes
;
5549 return series
.legendMapAreaAttributes
;
5555 /// Gets or sets the postback value which can be processed on click event.
5557 /// <value>The value which is passed to click event as argument.</value>
5559 [SRCategory("CategoryAttributeLegend")]
5560 [SRDescription(SR
.Keys
.DescriptionAttributePostBackValue
)]
5561 [Editor(Editors
.KeywordsStringEditor
.Editor
, Editors
.KeywordsStringEditor
.Base
)]
5562 public string LegendPostBackValue
5566 if (this.pointCustomProperties
)
5568 if (properties
.Count
!= 0 && IsCustomPropertySet(CommonCustomProperties
.LegendPostBackValue
))
5570 return (String
)GetAttributeObject(CommonCustomProperties
.LegendPostBackValue
);
5574 if (IsSerializing())
5578 if (this.isEmptyPoint
)
5580 return (string)series
.EmptyPointStyle
.GetAttributeObject(CommonCustomProperties
.LegendPostBackValue
);
5583 return series
.legendPostbackValue
;
5588 return series
.legendPostbackValue
;
5593 if (this.pointCustomProperties
)
5594 SetAttributeObject(CommonCustomProperties
.LegendPostBackValue
, value);
5596 series
.legendPostbackValue
= value;
5600 #endif // !Microsoft_CONTROL
5604 #if !Microsoft_CONTROL
5607 /// URL target of the data point label.
5610 SRCategory("CategoryAttributeMapArea"),
5612 SRDescription("DescriptionAttributeUrl"),
5614 PersistenceMode(PersistenceMode
.Attribute
),
5615 Editor(Editors
.UrlValueEditor
.Editor
, Editors
.UrlValueEditor
.Base
),
5616 SuppressMessage("Microsoft.Design", "CA1056:UriPropertiesShouldNotBeStrings")
5618 public string LabelUrl
5622 if(this.pointCustomProperties
)
5623 SetAttributeObject(CommonCustomProperties
.LabelUrl
, value);
5625 series
.labelUrl
= value;
5629 if(this.pointCustomProperties
)
5631 if(properties
.Count
!= 0 && IsCustomPropertySet(CommonCustomProperties
.LabelUrl
))
5633 return (String
)GetAttributeObject(CommonCustomProperties
.LabelUrl
);
5641 if(this.isEmptyPoint
)
5643 return (string)series
.EmptyPointStyle
.GetAttributeObject(CommonCustomProperties
.LabelUrl
);
5646 return series
.labelUrl
;
5651 return series
.labelUrl
;
5656 #endif //if !Microsoft_CONTROL
5658 #if !Microsoft_CONTROL
5661 /// Other attributes of the data point label.
5664 SRCategory("CategoryAttributeLabel"),
5666 SRDescription("DescriptionAttributeMapAreaAttributes"),
5668 PersistenceMode(PersistenceMode
.Attribute
)
5670 public string LabelMapAreaAttributes
5674 if(this.pointCustomProperties
)
5675 SetAttributeObject(CommonCustomProperties
.LabelMapAreaAttributes
, value);
5677 series
.labelMapAreaAttributes
= value;
5681 if(this.pointCustomProperties
)
5683 if(properties
.Count
!= 0 && IsCustomPropertySet(CommonCustomProperties
.LabelMapAreaAttributes
))
5685 return (String
)GetAttributeObject(CommonCustomProperties
.LabelMapAreaAttributes
);
5693 if(this.isEmptyPoint
)
5695 return (string)series
.EmptyPointStyle
.GetAttributeObject(CommonCustomProperties
.LabelMapAreaAttributes
);
5698 return series
.labelMapAreaAttributes
;
5704 return series
.labelMapAreaAttributes
;
5710 /// Gets or sets the postback value which can be processed on click event.
5712 /// <value>The value which is passed to click event as argument.</value>
5714 [SRCategory("CategoryAttributeLabel")]
5715 [SRDescription(SR
.Keys
.DescriptionAttributePostBackValue
)]
5716 [Editor(Editors
.KeywordsStringEditor
.Editor
, Editors
.KeywordsStringEditor
.Base
)]
5717 public string LabelPostBackValue
5721 if (this.pointCustomProperties
)
5723 if (properties
.Count
!= 0 && IsCustomPropertySet(CommonCustomProperties
.LabelPostBackValue
))
5725 return (String
)GetAttributeObject(CommonCustomProperties
.LabelPostBackValue
);
5729 if (IsSerializing())
5733 if (this.isEmptyPoint
)
5735 return (string)series
.EmptyPointStyle
.GetAttributeObject(CommonCustomProperties
.LabelPostBackValue
);
5738 return series
.labelPostbackValue
;
5743 return series
.labelPostbackValue
;
5748 if (this.pointCustomProperties
)
5749 SetAttributeObject(CommonCustomProperties
.LabelPostBackValue
, value);
5751 series
.labelPostbackValue
= value;
5756 #endif // !Microsoft_CONTROL
5762 #region Serialization control
5766 private bool CheckIfSerializationRequired(CommonCustomProperties attribute
)
5768 if(this is DataPoint
)
5770 return IsCustomPropertySet(attribute
);
5774 object attr1
= this.GetAttributeObject(attribute
);
5775 object attr2
= Series
.defaultCustomProperties
.GetAttributeObject(attribute
);
5776 if(attr1
== null || attr2
== null)
5780 return ! attr1
.Equals(attr2
);
5784 private void ResetProperty(CommonCustomProperties attribute
)
5786 if(this is DataPoint
)
5788 DeleteCustomProperty(attribute
);
5792 this.SetAttributeObject(attribute
, Series
.defaultCustomProperties
.GetAttributeObject(attribute
));
5797 /// Returns true if property should be serialized.
5800 internal bool ShouldSerializeLabel()
5802 if(this.pointCustomProperties
)
5803 return CheckIfSerializationRequired(CommonCustomProperties
.Label
);
5805 return !String
.IsNullOrEmpty(series
.label
);
5809 /// Returns true if property should be serialized.
5812 internal bool ShouldSerializeAxisLabel()
5814 if(this.pointCustomProperties
)
5815 return CheckIfSerializationRequired(CommonCustomProperties
.AxisLabel
);
5817 return !String
.IsNullOrEmpty(series
.axisLabel
);
5821 /// Returns true if property should be serialized.
5824 internal bool ShouldSerializeLabelFormat()
5826 if(this.pointCustomProperties
)
5827 return CheckIfSerializationRequired(CommonCustomProperties
.LabelFormat
);
5829 return !String
.IsNullOrEmpty(series
.labelFormat
);
5833 /// Returns true if property should be serialized.
5836 internal bool ShouldSerializeIsValueShownAsLabel()
5838 if(this.pointCustomProperties
)
5839 return CheckIfSerializationRequired(CommonCustomProperties
.IsValueShownAsLabel
);
5841 return series
.showLabelAsValue
!= false;
5845 /// Returns true if property should be serialized.
5848 internal bool ShouldSerializeColor()
5850 if(this.pointCustomProperties
)
5851 return CheckIfSerializationRequired(CommonCustomProperties
.Color
);
5853 return series
.color
!= Color
.Empty
;
5857 /// Returns true if property should be serialized.
5860 internal bool ShouldSerializeBorderColor()
5862 if(this.pointCustomProperties
)
5863 return CheckIfSerializationRequired(CommonCustomProperties
.BorderColor
);
5865 return series
.borderColor
!= Color
.Empty
;
5869 /// Returns true if property should be serialized.
5872 internal bool ShouldSerializeBorderDashStyle()
5874 if(this.pointCustomProperties
)
5875 return CheckIfSerializationRequired(CommonCustomProperties
.BorderDashStyle
);
5877 return series
.borderDashStyle
!= ChartDashStyle
.Solid
;
5881 /// Returns true if property should be serialized.
5884 internal bool ShouldSerializeBorderWidth()
5886 if(this.pointCustomProperties
)
5887 return CheckIfSerializationRequired(CommonCustomProperties
.BorderWidth
);
5889 return series
.borderWidth
!= 1;
5893 /// Returns true if property should be serialized.
5896 internal bool ShouldSerializeMarkerBorderWidth()
5898 if(this.pointCustomProperties
)
5899 return CheckIfSerializationRequired(CommonCustomProperties
.MarkerBorderWidth
);
5901 return series
.markerBorderWidth
!= 1;
5905 /// Returns true if property should be serialized.
5908 internal bool ShouldSerializeBackImage()
5910 if(this.pointCustomProperties
)
5911 return CheckIfSerializationRequired(CommonCustomProperties
.BackImage
);
5913 return !String
.IsNullOrEmpty(series
.backImage
);
5917 /// Returns true if property should be serialized.
5920 internal bool ShouldSerializeBackImageWrapMode()
5922 if(this.pointCustomProperties
)
5923 return CheckIfSerializationRequired(CommonCustomProperties
.BackImageWrapMode
);
5925 return series
.backImageWrapMode
!= ChartImageWrapMode
.Tile
;
5929 /// Returns true if property should be serialized.
5932 internal bool ShouldSerializeBackImageTransparentColor()
5934 if(this.pointCustomProperties
)
5935 return CheckIfSerializationRequired(CommonCustomProperties
.BackImageTransparentColor
);
5937 return series
.backImageTransparentColor
!= Color
.Empty
;
5941 /// Returns true if property should be serialized.
5944 internal bool ShouldSerializeBackImageAlignment()
5946 if(this.pointCustomProperties
)
5947 return CheckIfSerializationRequired(CommonCustomProperties
.BackImageAlignment
);
5949 return series
.backImageAlignment
!= ChartImageAlignmentStyle
.TopLeft
;
5953 /// Returns true if property should be serialized.
5956 internal bool ShouldSerializeBackGradientStyle()
5958 if(this.pointCustomProperties
)
5959 return CheckIfSerializationRequired(CommonCustomProperties
.BackGradientStyle
);
5961 return series
.backGradientStyle
!= GradientStyle
.None
;
5965 /// Returns true if property should be serialized.
5968 internal bool ShouldSerializeBackSecondaryColor()
5970 if(this.pointCustomProperties
)
5971 return CheckIfSerializationRequired(CommonCustomProperties
.BackSecondaryColor
);
5973 return series
.backSecondaryColor
!= Color
.Empty
;
5977 /// Returns true if property should be serialized.
5980 internal bool ShouldSerializeBackHatchStyle()
5982 if(this.pointCustomProperties
)
5983 return CheckIfSerializationRequired(CommonCustomProperties
.BackHatchStyle
);
5985 return series
.backHatchStyle
!= ChartHatchStyle
.None
;
5989 /// Returns true if property should be serialized.
5992 internal bool ShouldSerializeFont()
5994 if(this.pointCustomProperties
)
5995 return CheckIfSerializationRequired(CommonCustomProperties
.Font
);
5998 return series
.font
!= series
.FontCache
.DefaultFont
;
6003 /// Returns true if property should be serialized.
6005 internal bool ShouldSerializeLabelForeColor()
6007 if(this.pointCustomProperties
)
6008 return CheckIfSerializationRequired(CommonCustomProperties
.LabelForeColor
);
6010 return series
.fontColor
!= Color
.Black
;
6014 /// Returns true if property should be serialized.
6017 internal bool ShouldSerializeLabelAngle()
6019 if(this.pointCustomProperties
)
6020 return CheckIfSerializationRequired(CommonCustomProperties
.LabelAngle
);
6022 return series
.fontAngle
!= 0f
;
6026 /// Returns true if property should be serialized.
6029 internal bool ShouldSerializeMarkerStyle()
6031 if(this.pointCustomProperties
)
6032 return CheckIfSerializationRequired(CommonCustomProperties
.MarkerStyle
);
6034 return series
.markerStyle
!= MarkerStyle
.None
;
6038 /// Returns true if property should be serialized.
6041 internal bool ShouldSerializeMarkerSize()
6043 if(this.pointCustomProperties
)
6044 return CheckIfSerializationRequired(CommonCustomProperties
.MarkerSize
);
6046 return series
.markerSize
!= 5;
6050 /// Returns true if property should be serialized.
6053 internal bool ShouldSerializeMarkerImage()
6055 if(this.pointCustomProperties
)
6056 return CheckIfSerializationRequired(CommonCustomProperties
.MarkerImage
);
6058 return !String
.IsNullOrEmpty(series
.markerImage
);
6062 /// Returns true if property should be serialized.
6065 internal bool ShouldSerializeMarkerImageTransparentColor()
6067 if(this.pointCustomProperties
)
6068 return CheckIfSerializationRequired(CommonCustomProperties
.MarkerImageTransparentColor
);
6070 return series
.markerImageTransparentColor
!= Color
.Empty
;
6074 /// Returns true if property should be serialized.
6077 internal bool ShouldSerializeMarkerColor()
6079 if(this.pointCustomProperties
)
6080 return CheckIfSerializationRequired(CommonCustomProperties
.MarkerColor
);
6082 return series
.markerColor
!= Color
.Empty
;
6086 /// Returns true if property should be serialized.
6089 internal bool ShouldSerializeMarkerBorderColor()
6091 if(this.pointCustomProperties
)
6092 return CheckIfSerializationRequired(CommonCustomProperties
.MarkerBorderColor
);
6094 return series
.markerBorderColor
!= Color
.Empty
;
6098 /// Returns true if property should be serialized.
6101 internal bool ShouldSerializeToolTip()
6103 if(this.pointCustomProperties
)
6104 return CheckIfSerializationRequired(CommonCustomProperties
.ToolTip
);
6106 return !String
.IsNullOrEmpty(series
.toolTip
);
6109 #if !Microsoft_CONTROL
6112 /// Returns true if property should be serialized.
6115 internal bool ShouldSerializeUrl()
6117 if(this.pointCustomProperties
)
6118 return CheckIfSerializationRequired(CommonCustomProperties
.Url
);
6120 return !String
.IsNullOrEmpty(series
.url
);
6124 /// Returns true if property should be serialized.
6127 internal bool ShouldSerializeMapAreaAttributes()
6129 if(this.pointCustomProperties
)
6130 return CheckIfSerializationRequired(CommonCustomProperties
.MapAreaAttributes
);
6132 return !String
.IsNullOrEmpty(series
.mapAreaAttributes
);
6136 /// Returns true if property should be serialized.
6138 internal bool ShouldSerializePostBackValue()
6140 if (this.pointCustomProperties
)
6141 return CheckIfSerializationRequired(CommonCustomProperties
.PostBackValue
);
6143 return !String
.IsNullOrEmpty(series
.postbackValue
);
6147 /// Returns true if property should be serialized.
6150 internal bool ShouldSerializeLegendUrl()
6152 if(this.pointCustomProperties
)
6153 return CheckIfSerializationRequired(CommonCustomProperties
.LegendUrl
);
6155 return !String
.IsNullOrEmpty(series
.legendUrl
);
6159 /// Returns true if property should be serialized.
6162 internal bool ShouldSerializeLegendMapAreaAttributes()
6164 if(this.pointCustomProperties
)
6165 return CheckIfSerializationRequired(CommonCustomProperties
.LegendMapAreaAttributes
);
6167 return !String
.IsNullOrEmpty(series
.legendMapAreaAttributes
);
6173 /// Returns true if property should be serialized.
6176 internal bool ShouldSerializeLabelUrl()
6178 if(this.pointCustomProperties
)
6179 return CheckIfSerializationRequired(CommonCustomProperties
.LabelUrl
);
6181 return !String
.IsNullOrEmpty(series
.labelUrl
);
6185 /// Returns true if property should be serialized.
6188 internal bool ShouldSerializeLabelMapAreaAttributes()
6190 if(this.pointCustomProperties
)
6191 return CheckIfSerializationRequired(CommonCustomProperties
.LabelMapAreaAttributes
);
6193 return !String
.IsNullOrEmpty(series
.labelMapAreaAttributes
);
6198 #endif // !Microsoft_CONTROL
6201 /// Returns true if property should be serialized.
6204 internal bool ShouldSerializeIsVisibleInLegend()
6206 if(this.pointCustomProperties
)
6207 return CheckIfSerializationRequired(CommonCustomProperties
.IsVisibleInLegend
);
6209 return series
.showInLegend
!= true;
6213 /// Returns true if property should be serialized.
6216 internal bool ShouldSerializeLegendText()
6218 if(this.pointCustomProperties
)
6219 return CheckIfSerializationRequired(CommonCustomProperties
.LegendText
);
6221 return !String
.IsNullOrEmpty(series
.legendText
);
6225 /// Returns true if property should be serialized.
6228 internal bool ShouldSerializeLegendToolTip()
6230 if(this.pointCustomProperties
)
6231 return CheckIfSerializationRequired(CommonCustomProperties
.LegendToolTip
);
6233 return !String
.IsNullOrEmpty(series
.legendToolTip
);
6239 /// Returns true if property should be serialized.
6242 internal bool ShouldSerializeLabelToolTip()
6244 if(this.pointCustomProperties
)
6245 return CheckIfSerializationRequired(CommonCustomProperties
.LabelToolTip
);
6247 return !String
.IsNullOrEmpty(series
.labelToolTip
);
6251 /// Returns true if property should be serialized.
6254 internal bool ShouldSerializeLabelBackColor()
6256 if(this.pointCustomProperties
)
6257 return CheckIfSerializationRequired(CommonCustomProperties
.LabelBackColor
);
6259 return series
.labelBackColor
!= Color
.Empty
;
6263 /// Returns true if property should be serialized.
6266 internal bool ShouldSerializeLabelBorderColor()
6268 if(this.pointCustomProperties
)
6269 return CheckIfSerializationRequired(CommonCustomProperties
.LabelBorderColor
);
6271 return series
.labelBorderColor
!= Color
.Empty
;
6275 /// Returns true if property should be serialized.
6278 internal bool ShouldSerializeLabelBorderDashStyle()
6280 if(this.pointCustomProperties
)
6281 return CheckIfSerializationRequired(CommonCustomProperties
.LabelBorderDashStyle
);
6283 return series
.labelBorderDashStyle
!= ChartDashStyle
.Solid
;
6287 /// Returns true if property should be serialized.
6290 internal bool ShouldSerializeLabelBorderWidth()
6292 if(this.pointCustomProperties
)
6293 return CheckIfSerializationRequired(CommonCustomProperties
.LabelBorderWidth
);
6295 return series
.labelBorderWidth
!= 1;
6300 /// Resets property to its default value.
6303 internal void ResetLabel()
6305 if(this.pointCustomProperties
)
6306 ResetProperty(CommonCustomProperties
.Label
);
6312 /// Resets property to its default value.
6315 internal void ResetAxisLabel()
6317 if(this.pointCustomProperties
)
6318 ResetProperty(CommonCustomProperties
.AxisLabel
);
6320 series
.axisLabel
= "";
6324 /// Resets property to its default value.
6327 internal void ResetLabelFormat()
6329 if(this.pointCustomProperties
)
6330 ResetProperty(CommonCustomProperties
.LabelFormat
);
6332 series
.labelFormat
= "";
6336 /// Resets property to its default value.
6339 public void ResetIsValueShownAsLabel()
6341 if(this.pointCustomProperties
)
6342 ResetProperty(CommonCustomProperties
.IsValueShownAsLabel
);
6344 series
.IsValueShownAsLabel
= false;
6348 /// Resets property to its default value.
6351 internal void ResetColor()
6353 if(this.pointCustomProperties
)
6354 ResetProperty(CommonCustomProperties
.Color
);
6356 series
.color
= Color
.Empty
;
6360 /// Resets property to its default value.
6363 internal void ResetBorderColor()
6365 if(this.pointCustomProperties
)
6366 ResetProperty(CommonCustomProperties
.BorderColor
);
6368 series
.borderColor
= Color
.Empty
;
6372 /// Resets property to its default value.
6375 internal void ResetBorderDashStyle()
6377 if(this.pointCustomProperties
)
6378 ResetProperty(CommonCustomProperties
.BorderDashStyle
);
6380 series
.borderDashStyle
= ChartDashStyle
.Solid
;
6384 /// Resets property to its default value.
6387 internal void ResetBorderWidth()
6389 if(this.pointCustomProperties
)
6390 ResetProperty(CommonCustomProperties
.BorderWidth
);
6392 series
.borderWidth
= 1;
6398 /// Resets property to its default value.
6401 internal void ResetMarkerBorderWidth()
6403 if(this.pointCustomProperties
)
6404 ResetProperty(CommonCustomProperties
.MarkerBorderWidth
);
6406 series
.markerBorderWidth
= 1;
6412 /// Resets property to its default value.
6415 internal void ResetBackImage()
6417 if(this.pointCustomProperties
)
6418 ResetProperty(CommonCustomProperties
.BackImage
);
6420 series
.backImage
= "";
6424 /// Resets property to its default value.
6427 internal void ResetBackImageWrapMode()
6429 if(this.pointCustomProperties
)
6430 ResetProperty(CommonCustomProperties
.BackImageWrapMode
);
6432 series
.backImageWrapMode
= ChartImageWrapMode
.Tile
;
6436 /// Resets property to its default value.
6439 internal void ResetBackImageTransparentColor()
6441 if(this.pointCustomProperties
)
6442 ResetProperty(CommonCustomProperties
.BackImageTransparentColor
);
6444 series
.backImageTransparentColor
= Color
.Empty
;
6448 /// Resets property to its default value.
6451 internal void ResetBackSecondaryColor()
6453 if(this.pointCustomProperties
)
6454 ResetProperty(CommonCustomProperties
.BackSecondaryColor
);
6456 series
.backSecondaryColor
= Color
.Empty
;
6460 /// Resets property to its default value.
6463 internal void ResetBackHatchStyle()
6465 if(this.pointCustomProperties
)
6466 ResetProperty(CommonCustomProperties
.BackHatchStyle
);
6468 series
.backHatchStyle
= ChartHatchStyle
.None
;
6472 /// Resets property to its default value.
6475 internal void ResetFont()
6477 if (this.pointCustomProperties
)
6478 ResetProperty(CommonCustomProperties
.Font
);
6481 series
.font
= series
.FontCache
.DefaultFont
;
6487 /// Resets property to its default value.
6490 internal void ResetLabelAngle()
6492 if(this.pointCustomProperties
)
6493 ResetProperty(CommonCustomProperties
.LabelAngle
);
6495 series
.fontAngle
= 0;
6499 /// Resets property to its default value.
6502 internal void ResetMarkerStyle()
6504 if(this.pointCustomProperties
)
6505 ResetProperty(CommonCustomProperties
.MarkerStyle
);
6507 series
.markerStyle
= MarkerStyle
.None
;
6511 /// Resets property to its default value.
6514 internal void ResetMarkerSize()
6516 if(this.pointCustomProperties
)
6517 ResetProperty(CommonCustomProperties
.MarkerSize
);
6519 series
.markerSize
= 5;
6523 /// Resets property to its default value.
6526 internal void ResetMarkerImage()
6528 if(this.pointCustomProperties
)
6529 ResetProperty(CommonCustomProperties
.MarkerImage
);
6531 series
.markerImage
= "";
6535 /// Resets property to its default value.
6538 internal void ResetMarkerImageTransparentColor()
6540 if(this.pointCustomProperties
)
6541 ResetProperty(CommonCustomProperties
.MarkerImageTransparentColor
);
6543 series
.markerImageTransparentColor
= Color
.Empty
;
6547 /// Resets property to its default value.
6550 internal void ResetMarkerColor()
6552 if(this.pointCustomProperties
)
6553 ResetProperty(CommonCustomProperties
.MarkerColor
);
6555 series
.markerColor
= Color
.Empty
;
6559 /// Resets property to its default value.
6562 internal void ResetMarkerBorderColor()
6564 if(this.pointCustomProperties
)
6565 ResetProperty(CommonCustomProperties
.MarkerBorderColor
);
6567 series
.markerBorderColor
= Color
.Empty
;
6571 /// Resets property to its default value.
6574 internal void ResetToolTip()
6576 if(this.pointCustomProperties
)
6577 ResetProperty(CommonCustomProperties
.ToolTip
);
6579 series
.toolTip
= "";
6581 #if Microsoft_CONTROL
6582 if(Chart
!= null && Chart
.selection
!= null)
6584 Chart
.selection
.enabledChecked
= false;
6589 #if !Microsoft_CONTROL
6592 /// Resets property to its default value.
6595 internal void ResetUrl()
6597 if(this.pointCustomProperties
)
6598 ResetProperty(CommonCustomProperties
.Url
);
6604 /// Resets property to its default value.
6607 internal void ResetMapAreaAttributes()
6609 if(this.pointCustomProperties
)
6610 ResetProperty(CommonCustomProperties
.MapAreaAttributes
);
6612 series
.mapAreaAttributes
= "";
6616 /// Resets property to its default value.
6618 internal void ResetPostBackValue()
6620 if (this.pointCustomProperties
)
6621 ResetProperty(CommonCustomProperties
.PostBackValue
);
6623 series
.postbackValue
= "";
6627 /// Resets property to its default value.
6630 internal void ResetLegendUrl()
6632 if(this.pointCustomProperties
)
6633 ResetProperty(CommonCustomProperties
.LegendUrl
);
6635 series
.legendUrl
= "";
6639 /// Resets property to its default value.
6642 internal void ResetLegendMapAreaAttributes()
6644 if(this.pointCustomProperties
)
6645 ResetProperty(CommonCustomProperties
.LegendMapAreaAttributes
);
6647 series
.legendMapAreaAttributes
= "";
6653 /// Resets property to its default value.
6656 internal void ResetLabelUrl()
6658 if(this.pointCustomProperties
)
6659 ResetProperty(CommonCustomProperties
.LabelUrl
);
6661 series
.labelUrl
= "";
6665 /// Resets property to its default value.
6668 internal void ResetLabelMapAreaAttributes()
6670 if(this.pointCustomProperties
)
6671 ResetProperty(CommonCustomProperties
.LabelMapAreaAttributes
);
6673 series
.labelMapAreaAttributes
= "";
6677 #endif // !Microsoft_CONTROL
6680 /// Resets property to its default value.
6683 public void ResetIsVisibleInLegend()
6685 if(this.pointCustomProperties
)
6686 ResetProperty(CommonCustomProperties
.IsVisibleInLegend
);
6688 series
.showInLegend
= true;
6692 /// Resets property to its default value.
6695 internal void ResetLegendText()
6697 if(this.pointCustomProperties
)
6698 ResetProperty(CommonCustomProperties
.LegendText
);
6700 series
.legendText
= "";
6704 /// Resets property to its default value.
6707 internal void ResetLegendToolTip()
6709 if(this.pointCustomProperties
)
6710 ResetProperty(CommonCustomProperties
.LegendToolTip
);
6712 series
.legendToolTip
= "";
6714 #if Microsoft_CONTROL
6715 if(Chart
!= null && Chart
.selection
!= null)
6717 Chart
.selection
.enabledChecked
= false;
6725 /// Resets property to its default value.
6728 internal void ResetLabelBackColor()
6730 if(this.pointCustomProperties
)
6731 ResetProperty(CommonCustomProperties
.LabelBackColor
);
6733 series
.labelBackColor
= Color
.Empty
;
6737 /// Resets property to its default value.
6740 internal void ResetLabelBorderColor()
6742 if(this.pointCustomProperties
)
6743 ResetProperty(CommonCustomProperties
.LabelBorderColor
);
6745 series
.labelBorderColor
= Color
.Empty
;
6749 /// Resets property to its default value.
6752 internal void ResetLabelBorderDashStyle()
6754 if(this.pointCustomProperties
)
6755 ResetProperty(CommonCustomProperties
.LabelBorderDashStyle
);
6757 series
.labelBorderDashStyle
= ChartDashStyle
.Solid
;
6761 /// Resets property to its default value.
6764 internal void ResetLabelBorderWidth()
6766 if(this.pointCustomProperties
)
6767 ResetProperty(CommonCustomProperties
.LabelBorderWidth
);
6769 series
.labelBorderWidth
= 1;
6773 /// Resets property to its default value.
6776 internal void ResetLabelToolTip()
6778 if(this.pointCustomProperties
)
6779 ResetProperty(CommonCustomProperties
.LabelToolTip
);
6781 series
.labelToolTip
= "";
6783 #if Microsoft_CONTROL
6784 if(Chart
!= null && Chart
.selection
!= null)
6786 Chart
.selection
.enabledChecked
= false;
6795 #region Invalidating method
6798 /// Invalidate chart area.
6800 /// <param name="invalidateLegend">Invalidate legend area only.</param>
6801 [SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", Justification
= "This parameter is used when compiling for the Microsoft version of Chart")]
6802 internal void Invalidate(bool invalidateLegend
)
6804 #if Microsoft_CONTROL
6805 if(this.series
!= null)
6807 series
.Invalidate(true, invalidateLegend
);
6811 Series thisSeries
= this as Series
;
6812 if (thisSeries
!= null)
6814 thisSeries
.Invalidate(true, invalidateLegend
);
6824 /// Class stores additional information about the data point in 3D space.
6826 internal class DataPoint3D
6831 /// Reference to the 2D data point object
6833 internal DataPoint dataPoint
= null;
6836 /// Data point index.
6838 internal int index
= 0;
6841 /// Point X position in relative coordinates.
6843 internal double xPosition
= 0.0;
6846 /// Point Y position in relative coordinates.
6848 internal double yPosition
= 0.0;
6851 /// Point X center position in relative coordinates. Used for side-by-side charts.
6853 internal double xCenterVal
= 0.0;
6856 /// Point Z position in relative coordinates.
6858 internal float zPosition
= 0f
;
6863 internal double width
= 0.0;
6868 internal double height
= 0.0;
6873 internal float depth
= 0f
;
6876 /// Indicates that point belongs to indexed series.
6878 internal bool indexedSeries
= false;
6884 /// Design-time representation of the CustomProperties.
6885 /// This class is used instead of the string "CustomProperties"
6886 /// property at design time and supports expandable list
6887 /// of custom properties.
6889 [ TypeConverter(typeof(CustomPropertiesTypeConverter
)) ]
6890 [EditorBrowsable(EditorBrowsableState
.Never
)]
6892 [AspNetHostingPermission(System
.Security
.Permissions
.SecurityAction
.InheritanceDemand
, Level
= AspNetHostingPermissionLevel
.Minimal
)]
6893 [AspNetHostingPermission(System
.Security
.Permissions
.SecurityAction
.LinkDemand
, Level
= AspNetHostingPermissionLevel
.Minimal
)]
6895 public class CustomProperties
6899 // Reference to the properties class
6900 internal DataPointCustomProperties m_DataPointCustomProperties
= null;
6902 #endregion // Fields
6909 /// <param name="properties">Attributes object.</param>
6910 internal CustomProperties(DataPointCustomProperties properties
)
6912 this.m_DataPointCustomProperties
= properties
;
6915 #endregion // Constructor
6919 internal virtual DataPointCustomProperties DataPointCustomProperties
6923 return this.m_DataPointCustomProperties
;
6927 this.m_DataPointCustomProperties
= value;
6932 #endregion //Properties
6937 /// Gets a comma separated string of user defined custom properties.
6939 /// <returns>Comma separated string of user defined custom properties.</returns>
6940 internal virtual string GetUserDefinedCustomProperties()
6942 return GetUserDefinedCustomProperties(true);
6946 /// Gets a comma separated string of user defined or non-user defined custom properties.
6948 /// <param name="userDefined">True if user defined properties must be returned.</param>
6949 /// <returns>Comma separated string of user defined custom properties.</returns>
6950 internal virtual string GetUserDefinedCustomProperties(bool userDefined
)
6952 // Get comma separated string of custom properties
6953 string customAttribute
= this.DataPointCustomProperties
.CustomProperties
;
6954 string userDefinedCustomAttribute
= string.Empty
;
6956 // Get custom attribute registry
6957 CustomPropertyRegistry registry
= (CustomPropertyRegistry
)this.DataPointCustomProperties
.Common
.container
.GetService(typeof(CustomPropertyRegistry
));
6959 // Replace commas in value string
6960 customAttribute
= customAttribute
.Replace("\\,", "\\x45");
6961 customAttribute
= customAttribute
.Replace("\\=", "\\x46");
6963 // Split custom properties by commas into individual properties
6964 if(customAttribute
.Length
> 0)
6966 string[] nameValueStrings
= customAttribute
.Split(',');
6967 foreach(string nameValue
in nameValueStrings
)
6969 string[] values
= nameValue
.Split('=');
6972 if(values
.Length
!= 2)
6974 throw(new FormatException(SR
.ExceptionAttributeInvalidFormat
));
6977 // Check for empty name or value
6978 values
[0] = values
[0].Trim();
6979 values
[1] = values
[1].Trim();
6980 if(values
[0].Length
== 0)
6982 throw(new FormatException(SR
.ExceptionAttributeInvalidFormat
));
6985 // Check if attribute is registered or user defined
6986 bool userDefinedAttribute
= true;
6987 foreach(CustomPropertyInfo info
in registry
.registeredCustomProperties
)
6989 if(string.Compare(info
.Name
, values
[0], StringComparison
.OrdinalIgnoreCase
) == 0)
6991 userDefinedAttribute
= false;
6995 // Copy attribute into the output string
6996 if(userDefinedAttribute
== userDefined
)
6998 if(userDefinedCustomAttribute
.Length
> 0)
7000 userDefinedCustomAttribute
+= ", ";
7003 string val
= values
[1].Replace("\\x45", ",");
7004 val
= val
.Replace("\\x46", "=");
7005 userDefinedCustomAttribute
+= values
[0] + "=" + val
;
7010 return userDefinedCustomAttribute
;
7014 /// Sets user defined custom properties without cleaning registered properties.
7016 /// <param name="val">New user defined properties.</param>
7017 internal virtual void SetUserDefinedAttributes(string val
)
7019 // Get non-user defined custom properties
7020 string properties
= GetUserDefinedCustomProperties(false);
7022 // Check if new string is empty
7025 // Add comma at the end
7026 if(properties
.Length
> 0)
7031 // Add new user defined properties
7035 // Set new custom attribute string
7036 this.DataPointCustomProperties
.CustomProperties
= properties
;
7040 #endregion // Methods