LanguageResourceConverter.cs 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  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. public class DocInfoResourceConverter : IValueConverter
  84. {
  85. public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
  86. {
  87. if (parameter == null || string.IsNullOrEmpty(parameter.ToString()))
  88. {
  89. return string.Empty;
  90. }
  91. return LanguageHelper.DocInfoManager.GetString(parameter.ToString());
  92. }
  93. public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
  94. {
  95. throw new NotSupportedException();
  96. }
  97. }
  98. public class SecurityResourceConverter : IValueConverter
  99. {
  100. public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
  101. {
  102. if (parameter == null || string.IsNullOrEmpty(parameter.ToString()))
  103. {
  104. return string.Empty;
  105. }
  106. return LanguageHelper.SecurityManager.GetString(parameter.ToString());
  107. }
  108. public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
  109. {
  110. throw new NotSupportedException();
  111. }
  112. }
  113. public class DocEditorResourceConverter : IValueConverter
  114. {
  115. public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
  116. {
  117. if (parameter == null || string.IsNullOrEmpty(parameter.ToString()))
  118. {
  119. return string.Empty;
  120. }
  121. return LanguageHelper.DocEditorManager.GetString(parameter.ToString());
  122. }
  123. public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
  124. {
  125. throw new NotSupportedException();
  126. }
  127. }
  128. }