//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.Globalization; using System.Windows; using System.Windows.Controls; using System.Windows.Data; namespace LiveCharts.Wpf { public partial class DefaultGeoMapTooltip : UserControl { /// /// Initializes a new instance of the class. /// public DefaultGeoMapTooltip() { InitializeComponent(); SetCurrentValue(CornerRadiusProperty, 4d); DataContext = this; } /// /// The corner radius property /// public static readonly DependencyProperty CornerRadiusProperty = DependencyProperty.Register( "CornerRadius", typeof (double), typeof (DefaultGeoMapTooltip), new PropertyMetadata(default(double))); /// /// Gets or sets the corner radius. /// /// /// The corner radius. /// public double CornerRadius { get { return (double) GetValue(CornerRadiusProperty); } set { SetValue(CornerRadiusProperty, value); } } /// /// The label formatter property /// public static readonly DependencyProperty LabelFormatterProperty = DependencyProperty.Register( "LabelFormatter", typeof (Func), typeof (DefaultGeoMapTooltip), new PropertyMetadata(default(Func))); /// /// Gets or sets the label formatter. /// /// /// The label formatter. /// public Func LabelFormatter { get { return (Func) GetValue(LabelFormatterProperty); } set { SetValue(LabelFormatterProperty, value); } } /// /// The geo data property /// public static readonly DependencyProperty GeoDataProperty = DependencyProperty.Register( "GeoData", typeof (GeoData), typeof (DefaultGeoMapTooltip), new PropertyMetadata(default(GeoData))); /// /// Gets or sets the geo data. /// /// /// The geo data. /// public GeoData GeoData { get { return (GeoData) GetValue(GeoDataProperty); } set { SetValue(GeoDataProperty, value); } } } /// /// /// public class GeoData { /// /// Gets or sets the name. /// /// /// The name. /// public string Name { get; set; } /// /// Gets or sets the value. /// /// /// The value. /// public double Value { get; set; } } /// /// /// /// public class GeoDataLabelConverter : 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) { Func defF = x => x.ToString(CultureInfo.InvariantCulture); var f = values[1] as Func ?? defF; return f(values[0] as double? ?? 0); } /// /// 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(); } } }