MoLineDataConvert.cs 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Windows.Data;
  6. using Aitex.Core.UI.ControlDataContext;
  7. using System.Windows.Media;
  8. namespace Aitex.Core.UI.Converters
  9. {
  10. public class MoNameConvert : IValueConverter
  11. {
  12. public object Convert(object MoLineData, Type targetType, object parameter, System.Globalization.CultureInfo culture)
  13. {
  14. string name="名字";
  15. if (MoLineData != null)
  16. {
  17. name = (MoLineData as MOLineDataItem).DisplayName.Replace("_", "__");
  18. }
  19. return name;
  20. }
  21. public object ConvertBack(object value, Type targetTypes, object parameter, System.Globalization.CultureInfo culture)
  22. {
  23. return null;
  24. }
  25. }
  26. public class MoSourceHeightConvert : IValueConverter
  27. {
  28. public object Convert(object MoLineData, Type targetType, object parameter, System.Globalization.CultureInfo culture)
  29. {
  30. double height = 37;
  31. if (MoLineData != null)
  32. {
  33. height = 4 + (MoLineData as MOLineDataItem).MoRemainedPercentage * (37 - 4);
  34. if (height > 37) height = 37;
  35. if (height < 4) height = 4;
  36. }
  37. return height;
  38. }
  39. public object ConvertBack(object value, Type targetTypes, object parameter, System.Globalization.CultureInfo culture)
  40. {
  41. return null;
  42. }
  43. }
  44. public class MoSourceCanvasTopConvert : IValueConverter
  45. {
  46. public object Convert(object MoLineData, Type targetType, object parameter, System.Globalization.CultureInfo culture)
  47. {
  48. double top = 237;
  49. if (MoLineData != null)
  50. {
  51. top = 273 - (MoLineData as MOLineDataItem).MoRemainedPercentage * (273 - 237);
  52. if (top < 237) top = 237;
  53. if (top > 273) top = 273;
  54. }
  55. return top;
  56. }
  57. public object ConvertBack(object value, Type targetTypes, object parameter, System.Globalization.CultureInfo culture)
  58. {
  59. return null;
  60. }
  61. }
  62. public class MoColorConvert : IValueConverter
  63. {
  64. public object Convert(object MoLineData, Type targetType, object parameter, System.Globalization.CultureInfo culture)
  65. {
  66. SolidColorBrush color = Brushes.Green ;
  67. if (MoLineData != null)
  68. {
  69. if ((MoLineData as MOLineDataItem).IsMoRemainedWeightAlarm)
  70. {
  71. color = Brushes.Pink;
  72. }
  73. else
  74. {
  75. color = Brushes.Green;
  76. }
  77. }
  78. return color;
  79. }
  80. public object ConvertBack(object value, Type targetTypes, object parameter, System.Globalization.CultureInfo culture)
  81. {
  82. return null;
  83. }
  84. }
  85. }