aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.Touch/Converters/NotZeroConverter.cs
blob: 2c206fd9a6d0222f27b4a0853aa4b0552f0b3128 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
using System;
using System.Globalization;
using System.Windows.Data;

namespace Tango.Touch.Converters
{
    public class NotZeroConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (double.TryParse((value ?? "").ToString(), out double val))
            {
                return Math.Abs(val) > 0.0;
            }
            return null;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return Binding.DoNothing;
        }
    }
}