//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 Windows.UI.Xaml;
using LiveCharts.Uwp.Components.MultiBinding;
using LiveCharts.Uwp.Components;
namespace LiveCharts.Uwp
{
///
///
///
///
///
///
public partial class DefaultGeoMapTooltip
{
///
/// Initializes a new instance of the class.
///
public DefaultGeoMapTooltip()
{
InitializeComponent();
DataContext = this;
}
///
/// The corner radius property
///
public static readonly DependencyProperty CornerRadiusProperty = DependencyProperty.Register(
"CornerRadius", typeof (double), typeof (DefaultGeoMapTooltip), new PropertyMetadata(4d));
///
/// 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 : MultiValueConverterBase
{
///
/// Modifies the source data before passing it to the target for display in the UI.
///
/// The source data being passed to the target.
/// The of data expected by the target dependency property.
/// An optional parameter to be used in the converter logic.
/// The culture of the conversion.
///
/// The value to be passed to the target dependency property.
///
public override 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);
}
///
/// Modifies the target data before passing it to the source object. This method is called only in bindings.
///
/// The target data being passed to the source.
/// The of data expected by the source object.
/// An optional parameter to be used in the converter logic.
/// The culture of the conversion.
///
/// The value to be passed to the source object.
///
///
public override Object[] ConvertBack(Object value, Type targetType, Object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}