12345678910111213141516171819202122232425262728293031323334353637 |
- using System;
- using System.Globalization;
- using System.Windows;
- using System.Windows.Data;
- namespace Aitex.Sorter.UI.Converter
- {
- public class WaferIDConverter : IMultiValueConverter
- {
- public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
- {
- if (values[0] == null || values[0] == DependencyProperty.UnsetValue || values[1] == null || values[1] == DependencyProperty.UnsetValue)
- {
- return -1;
- }
- var obj = values[0];
- var collection = (Array)values[1];
- var index = collection.Length - Array.IndexOf(collection, obj) - 1;
- if (targetType == typeof(int))
- {
- return index;
- }
- else if (targetType == typeof(string))
- {
- return (index + 1).ToString();
- }
- return index;
- }
- public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
- {
- throw new NotImplementedException();
- }
- }
- }
|