1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- using System;
- using System.Collections.Generic;
- using System.Globalization;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Data;
- using System.Windows.Media;
- namespace FurnaceUI.Converter
- {
- public class IsMultiSavedConverter : IMultiValueConverter
- {
- public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
- {
- if (values.Length == 2)
- {
- if (values[0] is string)
- {
- double tempValue = double.NaN;
- double.TryParse((string)values[0], out tempValue);
- if (tempValue != double.NaN && Math.Abs(tempValue) < 0.000001)
- { return true; }
- else
- {
- if (values[1] is bool)
- {
- if ((bool)values[1])
- return true;
- else
- return false;
- }
- }
- }
- if (values[1] is bool)
- {
- if ((bool)values[1])
- return true;
- else
- return false;
- }
- }
- return true;
- }
- public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
- {
- throw new NotImplementedException();
- }
- }
- public class IsMultiSavedColorConverter : IMultiValueConverter
- {
- public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
- {
- if (values.Length == 2)
- {
- if (values[0] is string)
- {
- double tempValue = double.NaN;
- double.TryParse((string)values[0], out tempValue);
- if (tempValue != double.NaN && Math.Abs(tempValue) < 0.000001)
- { return new SolidColorBrush(Colors.Transparent); }
- else
- {
- if (values[1] is bool)
- {
- if ((bool)values[1])
- return new SolidColorBrush(Colors.Transparent);
- else
- return new SolidColorBrush(Colors.Yellow);
- }
- }
- }
- if (values[1] is bool)
- {
- if ((bool)values[1])
- return new SolidColorBrush(Colors.Transparent);
- else
- return new SolidColorBrush(Colors.Yellow);
- }
- }
- return new SolidColorBrush(Colors.Transparent);
- }
- public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
- {
- throw new NotImplementedException();
- }
- }
- }
|