LanguageResourceConverter.cs 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. using System;
  2. using System.Globalization;
  3. using System.Resources;
  4. using System.Windows.Data;
  5. using Compdfkit_Tools.Helper;
  6. namespace Compdfkit_Tools.Common
  7. {
  8. public class BotaResourceConverter : IValueConverter
  9. {
  10. public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
  11. {
  12. if (parameter == null || string.IsNullOrEmpty(parameter.ToString()))
  13. {
  14. return string.Empty;
  15. }
  16. return LanguageHelper.BotaManager.GetString(parameter.ToString());
  17. }
  18. public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
  19. {
  20. throw new NotSupportedException();
  21. }
  22. }
  23. public class CommonResourceConverter : IValueConverter
  24. {
  25. public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
  26. {
  27. if (parameter == null || string.IsNullOrEmpty(parameter.ToString()))
  28. {
  29. return string.Empty;
  30. }
  31. return LanguageHelper.CommonManager.GetString(parameter.ToString());
  32. }
  33. public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
  34. {
  35. throw new NotSupportedException();
  36. }
  37. }
  38. public class PropertyPanelResourceConverter : IValueConverter
  39. {
  40. public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
  41. {
  42. if (parameter == null || string.IsNullOrEmpty(parameter.ToString()))
  43. {
  44. return string.Empty;
  45. }
  46. return LanguageHelper.PropertyPanelManager.GetString(parameter.ToString());
  47. }
  48. public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
  49. {
  50. throw new NotSupportedException();
  51. }
  52. }
  53. public class ToolBarResourceConverter : IValueConverter
  54. {
  55. public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
  56. {
  57. if (parameter == null || string.IsNullOrEmpty(parameter.ToString()))
  58. {
  59. return string.Empty;
  60. }
  61. return LanguageHelper.ToolBarManager.GetString(parameter.ToString());
  62. }
  63. public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
  64. {
  65. throw new NotSupportedException();
  66. }
  67. }
  68. public class SigResourceConverter : IValueConverter
  69. {
  70. public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
  71. {
  72. if (parameter == null || string.IsNullOrEmpty(parameter.ToString()))
  73. {
  74. return string.Empty;
  75. }
  76. return LanguageHelper.SigManager.GetString(parameter.ToString());
  77. }
  78. public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
  79. {
  80. throw new NotSupportedException();
  81. }
  82. }
  83. }