BoatElevatorMap.xaml.cs 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. 
  2. using Aitex.Core.Common;
  3. using Aitex.Core.UI.MVVM;
  4. using MECF.Framework.Common.Equipment;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Collections.ObjectModel;
  8. using System.ComponentModel;
  9. using System.Linq;
  10. using System.Text;
  11. using System.Threading;
  12. using System.Threading.Tasks;
  13. using System.Windows;
  14. using System.Windows.Controls;
  15. using System.Windows.Data;
  16. using System.Windows.Documents;
  17. using System.Windows.Input;
  18. using System.Windows.Media;
  19. using System.Windows.Media.Animation;
  20. using System.Windows.Navigation;
  21. using System.Windows.Shapes;
  22. namespace Aitex.Core.UI.Control
  23. {
  24. /// <summary>
  25. /// ATMDualArmRobot.xaml 的交互逻辑
  26. /// </summary>
  27. public partial class BoatElevatorMap : UserControl, INotifyPropertyChanged
  28. {
  29. protected readonly int MoveTime = 300;
  30. private const int AnimationTimeout = 3000; // seconds
  31. private SolidColorBrush SDBrush = new SolidColorBrush(Color.FromArgb(255, 251, 147, 85));
  32. private SolidColorBrush FDBrush = new SolidColorBrush(Color.FromArgb(255, 170, 147, 255));
  33. private SolidColorBrush PDBrush = new SolidColorBrush(Color.FromArgb(255, 2, 255, 255));
  34. private SolidColorBrush M1Brush = new SolidColorBrush(Color.FromArgb(255, 3, 149, 255));
  35. private SolidColorBrush M2Brush = new SolidColorBrush(Color.FromArgb(255, 255, 111, 171));
  36. private SolidColorBrush NoneBrush = new SolidColorBrush(Color.FromArgb(255, 213, 210, 200));
  37. public WaferInfo[] RobotWafers
  38. {
  39. get { return (WaferInfo[])GetValue(RobotWafersProperty); }
  40. set { SetValue(RobotWafersProperty, value); }
  41. }
  42. // Using a DependencyProperty as the backing store for RobotWafers. This enables animation, styling, binding, etc...
  43. public static readonly DependencyProperty RobotWafersProperty =
  44. DependencyProperty.Register("RobotWafers", typeof(WaferInfo[]), typeof(BoatElevatorMap), new PropertyMetadata(null, PropertyChangedCallback));
  45. public List<string> BoatWafers
  46. {
  47. get { return (List<string>)GetValue(BoatWafersProperty); }
  48. set { SetValue(BoatWafersProperty, value); }
  49. }
  50. // Using a DependencyProperty as the backing store for RobotWafers. This enables animation, styling, binding, etc...
  51. public static readonly DependencyProperty BoatWafersProperty =
  52. DependencyProperty.Register("BoatWafers", typeof(List<string>), typeof(BoatElevatorMap), new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.AffectsRender, BoatWafersPropertyChangedCallback));
  53. public event PropertyChangedEventHandler PropertyChanged;
  54. static void PropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
  55. {
  56. var self = (BoatElevatorMap)d;
  57. }
  58. static void BoatWafersPropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
  59. {
  60. var self = (BoatElevatorMap)d;
  61. }
  62. public BoatElevatorMap()
  63. {
  64. #if DEBUG
  65. System.Diagnostics.PresentationTraceSources.DataBindingSource.Switch.Level = System.Diagnostics.SourceLevels.Critical;
  66. #endif
  67. InitializeComponent();
  68. rootCanvas.DataContext = this;
  69. bgImage = new System.Windows.Media.Imaging.BitmapImage(new Uri(@"pack://application:,,,/FurnaceUI;component/Resources/Images/Controls3/Boat.png"));
  70. }
  71. private System.Windows.Media.Imaging.BitmapImage bgImage;
  72. protected override void OnRender(DrawingContext drawingContext)
  73. {
  74. if (DesignerProperties.GetIsInDesignMode(this) || BoatWafers == null)
  75. {
  76. return;
  77. }
  78. int indexWafer = 0;
  79. if (bgImage != null)
  80. {
  81. drawingContext.DrawImage(bgImage, new Rect(13, 50, 150, 600));
  82. }
  83. int fristY = 610;
  84. foreach (var item in BoatWafers)
  85. {
  86. if (item == "----" || string.IsNullOrEmpty(item))
  87. {
  88. // drawingContext.DrawEllipse(NoneBrush, new Pen(NoneBrush, 1), new Point(85, fristY - indexWafer * 3), 60, 30);
  89. }
  90. else
  91. {
  92. if (item.StartsWith("P"))
  93. {
  94. drawingContext.DrawEllipse(PDBrush, new Pen(NoneBrush, 1), new Point(85, fristY - indexWafer * 3), 60, 30);
  95. }
  96. else if (item == "SD")
  97. {
  98. drawingContext.DrawEllipse(SDBrush, new Pen(NoneBrush, 1), new Point(85, fristY - indexWafer * 3), 60, 30);
  99. }
  100. else if (item == "FD" || item == "ED")
  101. {
  102. drawingContext.DrawEllipse(FDBrush, new Pen(NoneBrush, 1), new Point(85, fristY - indexWafer * 3), 60, 30);
  103. }
  104. else if (item == "M1")
  105. {
  106. drawingContext.DrawEllipse(M1Brush, new Pen(NoneBrush, 1), new Point(85, fristY - indexWafer * 3), 60, 30);
  107. }
  108. else if (item == "M2")
  109. {
  110. drawingContext.DrawEllipse(M2Brush, new Pen(NoneBrush, 1), new Point(85, fristY - indexWafer * 3), 60, 30);
  111. }
  112. }
  113. indexWafer += 1;
  114. }
  115. base.OnRender(drawingContext);
  116. }
  117. private int oldCurrentValue = 0;
  118. int oldX = 0;
  119. private void Invoke(Action action)
  120. {
  121. Dispatcher.Invoke(action);
  122. }
  123. private void LogMsg(string msg)
  124. {
  125. var source = "ATMRobot";
  126. Console.WriteLine("{0} {1}", source, msg);
  127. }
  128. }
  129. }