CheckAccessModeConverter.cs 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Globalization;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using System.Windows.Data;
  8. using Aitex.Core.RT.Device.Unit;
  9. using ExtendedGrid.Microsoft.Windows.Controls;
  10. namespace MECF.Framework.UI.Client.Ctrlib.Converter
  11. {
  12. public class CheckAccessModeConverter : IValueConverter
  13. {
  14. public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
  15. {
  16. if (value.ToString().ToUpper() == LPAccessMode.AUTO.ToString())
  17. {
  18. return true;
  19. }
  20. else
  21. {
  22. return false;
  23. }
  24. }
  25. public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
  26. {
  27. string str = string.Empty;
  28. if ((bool)value)
  29. {
  30. str = LPAccessMode.AUTO.ToString().ToLower();
  31. return char.ToUpper(str[0]) + str.Substring(1);
  32. }
  33. else
  34. {
  35. str = LPAccessMode.MANUAL.ToString().ToLower();
  36. return char.ToUpper(str[0]) + str.Substring(1);
  37. }
  38. }
  39. }
  40. public class InvertCheckAccessModeConverter : IValueConverter
  41. {
  42. public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
  43. {
  44. if (value.ToString().ToUpper() == LPAccessMode.AUTO.ToString())
  45. {
  46. return false;
  47. }
  48. else
  49. {
  50. return true;
  51. }
  52. }
  53. public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
  54. {
  55. string str = string.Empty;
  56. if ((bool)value)
  57. {
  58. str = LPAccessMode.AUTO.ToString().ToLower();
  59. return char.ToUpper(str[0]) + str.Substring(1);
  60. }
  61. else
  62. {
  63. str = LPAccessMode.MANUAL.ToString().ToLower();
  64. return char.ToUpper(str[0]) + str.Substring(1);
  65. }
  66. }
  67. }
  68. }