PowerConverter.cs 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. using Muchinfo.MTPClient.Data.Enums;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Windows;
  5. using System.Windows.Data;
  6. namespace Muchinfo.MTPClient.Account.Utilities
  7. {
  8. public class PowerConverter : IValueConverter
  9. {
  10. public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
  11. {
  12. if (value is List<int> && parameter != null)
  13. {
  14. TradeTreeMenu itemMenu;
  15. if (Enum.TryParse(parameter.ToString(), out itemMenu))
  16. {
  17. int power = (int)itemMenu;
  18. if ((value as List<int>).Contains(power))
  19. {
  20. return Visibility.Visible;
  21. }
  22. else
  23. {
  24. return Visibility.Collapsed;
  25. }
  26. }
  27. }
  28. return Visibility.Collapsed;
  29. }
  30. public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
  31. {
  32. return 0;
  33. }
  34. }
  35. }