PropertyPanelVisible.cs 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. using System.Windows.Media;
  10. namespace PDF_Office.DataConvert
  11. {
  12. public class PropertyPanelVisible : IValueConverter
  13. {
  14. public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
  15. {
  16. if(value is string)
  17. {
  18. var panelType = (string)value;
  19. if(parameter.ToString() == panelType)
  20. switch(panelType)
  21. {
  22. case "HighLight":
  23. return Visibility.Visible;
  24. default:
  25. break;
  26. }
  27. }
  28. return Visibility.Collapsed;
  29. }
  30. public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
  31. {
  32. throw new NotImplementedException();
  33. }
  34. }
  35. public class CheckToVisibleMutiConvert : IMultiValueConverter
  36. {
  37. public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
  38. {
  39. for (int i = 0; i < values.Length; i++)
  40. {
  41. if ((bool)values[i] == true)
  42. return Visibility.Collapsed;
  43. }
  44. return Visibility.Visible;
  45. }
  46. public object[] ConvertBack(object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture)
  47. {
  48. throw new NotImplementedException();
  49. }
  50. }
  51. public class ColorToBrushConverter : IValueConverter
  52. {
  53. public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
  54. {
  55. if (value is Color)
  56. {
  57. return new SolidColorBrush((Color)value);
  58. }
  59. return Brushes.Transparent;
  60. }
  61. public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
  62. {
  63. throw new NotImplementedException();
  64. }
  65. }
  66. }