BoatElevatorMap.xaml.cs 6.1 KB

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