blob: 387a70d331443043b794c38282d44f4205a9d477 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
using System;
using System.Globalization;
using System.Windows;
using System.Windows.Data;
namespace MaterialDesignThemes.Wpf.Converters
{
public class PointValueConverter : IMultiValueConverter
{
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
{
if (values?.Length == 2 && values[0] != null && values[1] != null)
{
double x, y;
if (double.TryParse(values[0].ToString(), out x) &&
double.TryParse(values[1].ToString(), out y))
return new Point(x, y);
}
return new Point();
}
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
{
if (value is Point)
{
var point = (Point) value;
return new object[] { point.X, point.Y };
}
return new object[0];
}
}
}
|