PropertyPanelVisible.cs 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. using ComPDFKitViewer.AnnotEvent;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Globalization;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. using System.Windows;
  9. using System.Windows.Data;
  10. using System.Windows.Media;
  11. namespace PDF_Office.DataConvert
  12. {
  13. public class PropertyPanelVisible : IValueConverter
  14. {
  15. public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
  16. {
  17. if(value is string)
  18. {
  19. var panelType = (string)value;
  20. if(parameter.ToString() == panelType)
  21. switch(panelType)
  22. {
  23. case "HighLight":
  24. return Visibility.Visible;
  25. default:
  26. break;
  27. }
  28. }
  29. return Visibility.Collapsed;
  30. }
  31. public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
  32. {
  33. throw new NotImplementedException();
  34. }
  35. }
  36. public class CheckToVisibleMutiConvert : IMultiValueConverter
  37. {
  38. public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
  39. {
  40. for (int i = 0; i < values.Length; i++)
  41. {
  42. if ((bool)values[i] == true)
  43. return Visibility.Collapsed;
  44. }
  45. return Visibility.Visible;
  46. }
  47. public object[] ConvertBack(object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture)
  48. {
  49. throw new NotImplementedException();
  50. }
  51. }
  52. public class ColorToBrushConverter : IValueConverter
  53. {
  54. public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
  55. {
  56. if (value is Color)
  57. {
  58. return new SolidColorBrush((Color)value);
  59. }
  60. return Brushes.Transparent;
  61. }
  62. public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
  63. {
  64. throw new NotImplementedException();
  65. }
  66. }
  67. public class AnnotArgsTypeConverter : IValueConverter
  68. {
  69. public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
  70. {
  71. if (value is AnnotArgsType)
  72. {
  73. if (parameter is string)
  74. {
  75. var args = (AnnotArgsType)value;
  76. if ((string)parameter == "AnnotHighlight" && args == AnnotArgsType.AnnotHighlight)
  77. {
  78. return Visibility.Visible;
  79. }
  80. if ((string)parameter == "AnnotUnderline" && args == AnnotArgsType.AnnotUnderline)
  81. {
  82. return Visibility.Visible;
  83. }
  84. if ((string)parameter == "AnnotSquiggly" && args == AnnotArgsType.AnnotSquiggly)
  85. {
  86. return Visibility.Visible;
  87. }
  88. if ((string)parameter == "AnnotStrikeout" && args == AnnotArgsType.AnnotStrikeout)
  89. {
  90. return Visibility.Visible;
  91. }
  92. if ((string)parameter == "AnnotSticky" && args == AnnotArgsType.AnnotSticky)
  93. {
  94. return Visibility.Visible;
  95. }
  96. }
  97. }
  98. return Visibility.Collapsed;
  99. }
  100. public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
  101. {
  102. throw new NotImplementedException();
  103. }
  104. }
  105. }