ListCountToVisible.cs.cs 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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;
  8. using System.Windows.Data;
  9. namespace PDF_Master.DataConvert
  10. {
  11. public class ListCountToVisible : IValueConverter
  12. {
  13. public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
  14. {
  15. if (value == null)
  16. {
  17. return Visibility.Collapsed;
  18. }
  19. else
  20. {
  21. if ((int)value == 0)
  22. {
  23. return Visibility.Visible;
  24. }
  25. else
  26. {
  27. return Visibility.Collapsed;
  28. }
  29. }
  30. }
  31. public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
  32. {
  33. throw new NotImplementedException();
  34. }
  35. }
  36. public class MergeListCountToBool : IValueConverter
  37. {
  38. public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
  39. {
  40. if (value == null)
  41. {
  42. return false;
  43. }
  44. else
  45. {
  46. if ((int)value >=2)
  47. {
  48. return true;
  49. }
  50. else
  51. {
  52. return false;
  53. }
  54. }
  55. }
  56. public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
  57. {
  58. throw new NotImplementedException();
  59. }
  60. }
  61. public class ListCountAndBoolToVisible : IMultiValueConverter
  62. {
  63. public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
  64. {
  65. if (values[0] == null || values[1] == null)
  66. {
  67. return Visibility.Collapsed;
  68. }
  69. else
  70. {
  71. if ((int)values[0] == 0 && (bool)values[1])
  72. {
  73. return Visibility.Collapsed;
  74. }
  75. if ((int)values[0] == 0)
  76. {
  77. return Visibility.Visible;
  78. }
  79. else
  80. {
  81. return Visibility.Collapsed;
  82. }
  83. }
  84. }
  85. public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
  86. {
  87. throw new NotImplementedException();
  88. }
  89. }
  90. }