// (c) Copyright Microsoft Corporation. // This source is subject to the Microsoft Public License (Ms-PL). // Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details. // All other rights reserved. using System.Diagnostics.CodeAnalysis; namespace System.Windows.Controls.DataVisualization.Charting { /// /// Represents a data point used for a bubble series. /// /// Preview [TemplateVisualState(Name = DataPoint.StateCommonNormal, GroupName = DataPoint.GroupCommonStates)] [TemplateVisualState(Name = DataPoint.StateCommonMouseOver, GroupName = DataPoint.GroupCommonStates)] [TemplateVisualState(Name = DataPoint.StateSelectionUnselected, GroupName = DataPoint.GroupSelectionStates)] [TemplateVisualState(Name = DataPoint.StateSelectionSelected, GroupName = DataPoint.GroupSelectionStates)] [TemplateVisualState(Name = DataPoint.StateRevealShown, GroupName = DataPoint.GroupRevealStates)] [TemplateVisualState(Name = DataPoint.StateRevealHidden, GroupName = DataPoint.GroupRevealStates)] public class BubbleDataPoint : DataPoint { #region public double Size /// /// Gets or sets the size value of the bubble data point. /// public double Size { get { return (double)GetValue(SizeProperty); } set { SetValue(SizeProperty, value); } } /// /// Identifies the Size dependency property. /// public static readonly DependencyProperty SizeProperty = DependencyProperty.Register( "Size", typeof(double), typeof(BubbleDataPoint), new PropertyMetadata(0.0, OnSizePropertyChanged)); /// /// SizeProperty property changed handler. /// /// BubbleDataPoint that changed its Size. /// Event arguments. private static void OnSizePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { BubbleDataPoint source = (BubbleDataPoint)d; double oldValue = (double)e.OldValue; double newValue = (double)e.NewValue; source.OnSizePropertyChanged(oldValue, newValue); } /// /// SizeProperty property changed handler. /// /// Old value. /// New value. private void OnSizePropertyChanged(double oldValue, double newValue) { RoutedPropertyChangedEventHandler handler = SizePropertyChanged; if (handler != null) { handler(this, new RoutedPropertyChangedEventArgs(oldValue, newValue)); } if (this.State == DataPointState.Created) { this.ActualSize = newValue; } } /// /// This event is raised when the size property is changed. /// internal event RoutedPropertyChangedEventHandler SizePropertyChanged; #endregion public double Size #region public double ActualSize /// /// Gets or sets the actual size of the bubble data point. /// public double ActualSize { get { return (double)GetValue(ActualSizeProperty); } set { SetValue(ActualSizeProperty, value); } } /// /// Identifies the ActualSize dependency property. /// public static readonly DependencyProperty ActualSizeProperty = DependencyProperty.Register( "ActualSize", typeof(double), typeof(BubbleDataPoint), new PropertyMetadata(0.0, OnActualSizePropertyChanged)); /// /// ActualSizeProperty property changed handler. /// /// BubbleDataPoint that changed its ActualSize. /// Event arguments. private static void OnActualSizePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { BubbleDataPoint source = (BubbleDataPoint)d; double oldValue = (double)e.OldValue; double newValue = (double)e.NewValue; source.OnActualSizePropertyChanged(oldValue, newValue); } /// /// ActualSizeProperty property changed handler. /// /// Old value. /// New value. private void OnActualSizePropertyChanged(double oldValue, double newValue) { RoutedPropertyChangedEventHandler handler = ActualSizePropertyChanged; if (handler != null) { handler(this, new RoutedPropertyChangedEventArgs(oldValue, newValue)); } } /// /// This event is raised when the actual size property is changed. /// internal event RoutedPropertyChangedEventHandler ActualSizePropertyChanged; #endregion public double ActualSize #if !SILVERLIGHT /// /// Initializes the static members of the BubbleDataPoint class. /// [SuppressMessage("Microsoft.Performance", "CA1810:InitializeReferenceTypeStaticFieldsInline", Justification = "Dependency properties are initialized in-line.")] static BubbleDataPoint() { DefaultStyleKeyProperty.OverrideMetadata(typeof(BubbleDataPoint), new FrameworkPropertyMetadata(typeof(BubbleDataPoint))); } #endif /// /// Initializes a new instance of the bubble data point. /// public BubbleDataPoint() { #if SILVERLIGHT this.DefaultStyleKey = typeof(BubbleDataPoint); #endif } } }