//The MIT License(MIT) //Copyright(c) 2016 Alberto Rodriguez & LiveCharts Contributors //Permission is hereby granted, free of charge, to any person obtaining a copy //of this software and associated documentation files (the "Software"), to deal //in the Software without restriction, including without limitation the rights //to use, copy, modify, merge, publish, distribute, sublicense, and/or sell //copies of the Software, and to permit persons to whom the Software is //furnished to do so, subject to the following conditions: //The above copyright notice and this permission notice shall be included in all //copies or substantial portions of the Software. //THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR //IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, //FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE //AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER //LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, //OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE //SOFTWARE. using System; using System.Collections.Generic; using System.ComponentModel; using System.Globalization; using System.Windows; using System.Windows.Controls; using System.Windows.Data; namespace LiveCharts.Wpf { /// /// The default legend control, by default a new instance of this control is created for every chart that requires a legend. /// public partial class DefaultLegend : IChartLegend { private List _series; /// /// Initializes a new instance of DefaultLegend class /// public DefaultLegend() { InitializeComponent(); DataContext = this; } /// /// Property changed event /// public event PropertyChangedEventHandler PropertyChanged; /// /// Gets the series displayed in the legend. /// public List Series { get { return _series; } set { _series = value; OnPropertyChanged("Series"); } } /// /// The orientation property /// public static readonly DependencyProperty OrientationProperty = DependencyProperty.Register( "Orientation", typeof (Orientation?), typeof (DefaultLegend), new PropertyMetadata(null)); /// /// Gets or sets the orientation of the legend, default is null, if null LiveCharts will decide which orientation to use, based on the Chart.Legend location property. /// public Orientation? Orientation { get { return (Orientation) GetValue(OrientationProperty); } set { SetValue(OrientationProperty, value); } } /// /// The internal orientation property /// public static readonly DependencyProperty InternalOrientationProperty = DependencyProperty.Register( "InternalOrientation", typeof (Orientation), typeof (DefaultLegend), new PropertyMetadata(default(Orientation))); /// /// Gets or sets the internal orientation. /// /// /// The internal orientation. /// public Orientation InternalOrientation { get { return (Orientation) GetValue(InternalOrientationProperty); } set { SetValue(InternalOrientationProperty, value); } } /// /// The bullet size property /// public static readonly DependencyProperty BulletSizeProperty = DependencyProperty.Register( "BulletSize", typeof(double), typeof(DefaultLegend), new PropertyMetadata(15d)); /// /// Gets or sets the bullet size, the bullet size modifies the drawn shape size. /// public double BulletSize { get { return (double)GetValue(BulletSizeProperty); } set { SetValue(BulletSizeProperty, value); } } /// /// Called when [property changed]. /// /// Name of the property. protected virtual void OnPropertyChanged(string propertyName = null) { if (PropertyChanged != null) PropertyChanged.Invoke(this, new PropertyChangedEventArgs(propertyName)); } } /// /// /// /// public class OrientationConverter : IMultiValueConverter { /// /// Converts source values to a value for the binding target. The data binding engine calls this method when it propagates the values from source bindings to the binding target. /// /// The array of values that the source bindings in the produces. The value indicates that the source binding has no value to provide for conversion. /// The type of the binding target property. /// The converter parameter to use. /// The culture to use in the converter. /// /// A converted value.If the method returns null, the valid null value is used.A return value of . indicates that the converter did not produce a value, and that the binding will use the if it is available, or else will use the default value.A return value of . indicates that the binding does not transfer the value or use the or the default value. /// public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) { if (values[0] == DependencyProperty.UnsetValue) return null; return (Orientation?) values[0] ?? (Orientation) values[1]; } /// /// Converts a binding target value to the source binding values. /// /// The value that the binding target produces. /// The array of types to convert to. The array length indicates the number and types of values that are suggested for the method to return. /// The converter parameter to use. /// The culture to use in the converter. /// /// An array of values that have been converted from the target value back to the source values. /// /// public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) { throw new NotImplementedException(); } } }