StringToColorConverter.cs 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. using OpenSEMI.ClientBase;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Diagnostics;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. using System.Windows.Data;
  9. using System.Windows.Media;
  10. namespace CyberX8_Themes.Converters
  11. {
  12. public class StringToColorConverter : IValueConverter
  13. {
  14. public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
  15. {
  16. switch (value.ToString())
  17. {
  18. case "Information":
  19. return new SolidColorBrush(Colors.Green);
  20. case "Warning":
  21. return new SolidColorBrush((Color)ColorConverter.ConvertFromString("#ffd400"));
  22. case "Alarm":
  23. return new SolidColorBrush(Colors.Red);
  24. default:
  25. return new SolidColorBrush(Colors.Silver);
  26. }
  27. }
  28. public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
  29. {
  30. if (!(value is bool))
  31. return false;
  32. return !(bool)value;
  33. }
  34. }
  35. public class StringToColorConverter1 : IValueConverter
  36. {
  37. public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
  38. {
  39. switch (value.ToString())
  40. {
  41. case "Normal":
  42. return new SolidColorBrush(Colors.Lime);
  43. case "Warning":
  44. return new SolidColorBrush(Colors.Yellow);
  45. case "Error":
  46. return new SolidColorBrush(Colors.Red);
  47. default:
  48. return new SolidColorBrush(Colors.Gray);
  49. }
  50. }
  51. public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
  52. {
  53. if (!(value is bool))
  54. return false;
  55. return !(bool)value;
  56. }
  57. }
  58. public class StringToColorConverter2 : IValueConverter
  59. {
  60. public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
  61. {
  62. switch (value.ToString())
  63. {
  64. case "Full":
  65. return new SolidColorBrush(Colors.Lime);
  66. case "Empty":
  67. return new SolidColorBrush(Colors.Red);
  68. case "Warning":
  69. return new SolidColorBrush(Colors.Yellow);
  70. default:
  71. return new SolidColorBrush(Colors.Gray);
  72. }
  73. }
  74. public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
  75. {
  76. if (!(value is bool))
  77. return false;
  78. return !(bool)value;
  79. }
  80. }
  81. public class StringToColorConverter3 : IValueConverter
  82. {
  83. public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
  84. {
  85. switch ((int)value)
  86. {
  87. //Idle / No Process Job
  88. case 1:
  89. LinearGradientBrush linearGradientBrush1 = new LinearGradientBrush();
  90. linearGradientBrush1.GradientStops.Add(new GradientStop((Color)ColorConverter.ConvertFromString("#FFB88700"), 0));
  91. linearGradientBrush1.GradientStops.Add(new GradientStop((Color)ColorConverter.ConvertFromString("#FFF7E0A0"), 0.5));
  92. linearGradientBrush1.GradientStops.Add(new GradientStop((Color)ColorConverter.ConvertFromString("#FFB88700"), 1));
  93. linearGradientBrush1.StartPoint = new System.Windows.Point(1, 0.5);
  94. linearGradientBrush1.EndPoint = new System.Windows.Point(0, 0.5);
  95. return linearGradientBrush1;
  96. //Idle /Process Job
  97. case 2:
  98. LinearGradientBrush linearGradientBrush2 = new LinearGradientBrush();
  99. linearGradientBrush2.GradientStops.Add(new GradientStop((Color)ColorConverter.ConvertFromString("#FF3333FF"), 0));
  100. linearGradientBrush2.GradientStops.Add(new GradientStop((Color)ColorConverter.ConvertFromString("#FFE1E1FF"), 0.5));
  101. linearGradientBrush2.GradientStops.Add(new GradientStop((Color)ColorConverter.ConvertFromString("#FF3333FF"), 1));
  102. linearGradientBrush2.StartPoint = new System.Windows.Point(1, 0.5);
  103. linearGradientBrush2.EndPoint = new System.Windows.Point(0, 0.5);
  104. return linearGradientBrush2;
  105. //InProcess
  106. case 3:
  107. LinearGradientBrush linearGradientBrush3 = new LinearGradientBrush();
  108. linearGradientBrush3.GradientStops.Add(new GradientStop(Colors.Cyan, 0));
  109. linearGradientBrush3.GradientStops.Add(new GradientStop((Color)ColorConverter.ConvertFromString("#FFE7F5F9"), 0.5));
  110. linearGradientBrush3.GradientStops.Add(new GradientStop(Colors.Cyan, 1));
  111. linearGradientBrush3.StartPoint = new System.Windows.Point(1, 0.5);
  112. linearGradientBrush3.EndPoint = new System.Windows.Point(0, 0.5);
  113. return linearGradientBrush3;
  114. //Completed
  115. case 4:
  116. LinearGradientBrush linearGradientBrush4 = new LinearGradientBrush();
  117. linearGradientBrush4.GradientStops.Add(new GradientStop((Color)ColorConverter.ConvertFromString("#FF00B400"), 0));
  118. linearGradientBrush4.GradientStops.Add(new GradientStop((Color)ColorConverter.ConvertFromString("#FFA9FFA9"), 0.5));
  119. linearGradientBrush4.GradientStops.Add(new GradientStop((Color)ColorConverter.ConvertFromString("#FF00B400"), 1));
  120. linearGradientBrush4.StartPoint = new System.Windows.Point(1, 0.5);
  121. linearGradientBrush4.EndPoint = new System.Windows.Point(0, 0.5);
  122. return linearGradientBrush4;
  123. //Failed
  124. case 5:
  125. LinearGradientBrush linearGradientBrush5 = new LinearGradientBrush();
  126. linearGradientBrush5.GradientStops.Add(new GradientStop(Colors.Red, 0));
  127. linearGradientBrush5.GradientStops.Add(new GradientStop((Color)ColorConverter.ConvertFromString("#FFFFD7D7"), 0.5));
  128. linearGradientBrush5.GradientStops.Add(new GradientStop(Colors.Red, 1));
  129. linearGradientBrush5.StartPoint = new System.Windows.Point(1, 0.5);
  130. linearGradientBrush5.EndPoint = new System.Windows.Point(0, 0.5);
  131. return linearGradientBrush5;
  132. //Dummy wafer
  133. case 6:
  134. LinearGradientBrush linearGradientBrush6 = new LinearGradientBrush();
  135. linearGradientBrush6.GradientStops.Add(new GradientStop(Colors.DarkKhaki, 0));
  136. linearGradientBrush6.GradientStops.Add(new GradientStop(Colors.Khaki, 0.5));
  137. linearGradientBrush6.GradientStops.Add(new GradientStop(Colors.DarkKhaki, 1));
  138. linearGradientBrush6.StartPoint = new System.Windows.Point(1, 0.5);
  139. linearGradientBrush6.EndPoint = new System.Windows.Point(0, 0.5);
  140. return linearGradientBrush6;
  141. //Failed
  142. case 7:
  143. LinearGradientBrush linearGradientBrush7 = new LinearGradientBrush();
  144. linearGradientBrush7.GradientStops.Add(new GradientStop(Colors.DarkGray, 0));
  145. linearGradientBrush7.GradientStops.Add(new GradientStop(Colors.LightGray, 0.5));
  146. linearGradientBrush7.GradientStops.Add(new GradientStop(Colors.DarkGray, 1));
  147. linearGradientBrush7.StartPoint = new System.Windows.Point(1, 0.5);
  148. linearGradientBrush7.EndPoint = new System.Windows.Point(0, 0.5);
  149. return linearGradientBrush7;
  150. //Failed
  151. case 8:
  152. LinearGradientBrush linearGradientBrush8 = new LinearGradientBrush();
  153. linearGradientBrush8.GradientStops.Add(new GradientStop(Colors.DarkOrange, 0));
  154. linearGradientBrush8.GradientStops.Add(new GradientStop(Colors.Orange, 0.5));
  155. linearGradientBrush8.GradientStops.Add(new GradientStop(Colors.DarkOrange, 1));
  156. linearGradientBrush8.StartPoint = new System.Windows.Point(1, 0.5);
  157. linearGradientBrush8.EndPoint = new System.Windows.Point(0, 0.5);
  158. return linearGradientBrush8;
  159. //Empty
  160. default:
  161. LinearGradientBrush linearGradientBrush = new LinearGradientBrush();
  162. linearGradientBrush.GradientStops.Add(new GradientStop((Color)ColorConverter.ConvertFromString("#00B88700"), 0));
  163. linearGradientBrush.GradientStops.Add(new GradientStop((Color)ColorConverter.ConvertFromString("#00F7E0A0"), 0.5));
  164. linearGradientBrush.GradientStops.Add(new GradientStop((Color)ColorConverter.ConvertFromString("#00B88700"), 1));
  165. linearGradientBrush.StartPoint = new System.Windows.Point(1, 0.5);
  166. linearGradientBrush.EndPoint = new System.Windows.Point(0, 0.5);
  167. return linearGradientBrush;
  168. }
  169. }
  170. public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
  171. {
  172. if (!(value is bool))
  173. return false;
  174. return !(bool)value;
  175. }
  176. }
  177. }