AddPalletView.xaml.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  1. using MaterialDesignThemes.Wpf;
  2. using Prism.Commands;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.ComponentModel;
  6. using System.Linq;
  7. using System.Runtime.CompilerServices;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. using System.Windows;
  11. using System.Windows.Controls;
  12. using System.Windows.Data;
  13. using System.Windows.Documents;
  14. using System.Windows.Input;
  15. using System.Windows.Media;
  16. using System.Windows.Media.Imaging;
  17. using System.Windows.Navigation;
  18. using System.Windows.Shapes;
  19. using TeamAAS_VP.Enums;
  20. namespace TeamAAS_VP.Controls
  21. {
  22. /// <summary>
  23. /// AddPalletView.xaml 的交互逻辑
  24. /// </summary>
  25. public partial class AddPalletView : UserControl, INotifyPropertyChanged
  26. {
  27. public AddPalletView()
  28. {
  29. InitializeComponent();
  30. DataContext = this;
  31. }
  32. private int _SelectPageIndex=0;
  33. /// <summary>
  34. /// Page选择的索引
  35. /// </summary>
  36. public int SelectPageIndex
  37. {
  38. get { return _SelectPageIndex; }
  39. set { SetProperty(ref _SelectPageIndex, value); }
  40. }
  41. private bool _IsCheckModel1=true;
  42. /// <summary>
  43. /// Pallet选择的模式(普通托盘)
  44. /// </summary>
  45. public bool IsCheckModel1
  46. {
  47. get { return _IsCheckModel1; }
  48. set { SetProperty(ref _IsCheckModel1, value); }
  49. }
  50. private bool _IsCheckModel2=false;
  51. /// <summary>
  52. /// Pallet选择的模式(组合托盘)
  53. /// </summary>
  54. public bool IsCheckModel2
  55. {
  56. get { return _IsCheckModel2; }
  57. set { SetProperty(ref _IsCheckModel2, value); }
  58. }
  59. private CoordinateModel _CoordinateModel= CoordinateModel.Orthogonality;
  60. /// <summary>
  61. /// 坐标系模式
  62. /// </summary>
  63. public CoordinateModel CoordinateModel
  64. {
  65. get { return _CoordinateModel; }
  66. set { SetProperty(ref _CoordinateModel, value); }
  67. }
  68. private bool _Checked1=true;
  69. /// <summary>
  70. /// 正交坐标系
  71. /// </summary>
  72. public bool Checked1
  73. {
  74. get { return _Checked1; }
  75. set
  76. {
  77. SetProperty(ref _Checked1, value);
  78. if (value)
  79. {
  80. Checked2 = false;
  81. CoordinateModel = CoordinateModel.Orthogonality;
  82. }
  83. }
  84. }
  85. private bool _Checked2=false;
  86. /// <summary>
  87. /// 切变坐标系
  88. /// </summary>
  89. public bool Checked2
  90. {
  91. get { return _Checked2; }
  92. set
  93. {
  94. SetProperty(ref _Checked2, value);
  95. if (value)
  96. {
  97. Checked1 = false;
  98. CoordinateModel = CoordinateModel.Shear;
  99. }
  100. }
  101. }
  102. private string _PalletName;
  103. /// <summary>
  104. /// 托盘的名称
  105. /// </summary>
  106. public string PalletName
  107. {
  108. get { return _PalletName; }
  109. set { SetProperty(ref _PalletName, value); }
  110. }
  111. private Visibility _BackButtonVisibility=Visibility.Collapsed;
  112. /// <summary>
  113. /// 上一步
  114. /// </summary>
  115. public Visibility BackButtonVisibility
  116. {
  117. get { return _BackButtonVisibility; }
  118. set { SetProperty(ref _BackButtonVisibility, value); }
  119. }
  120. private Visibility _NextButtonVisibility = Visibility.Visible;
  121. /// <summary>
  122. /// 下一步
  123. /// </summary>
  124. public Visibility NextButtonVisibility
  125. {
  126. get { return _NextButtonVisibility; }
  127. set { SetProperty(ref _NextButtonVisibility, value); }
  128. }
  129. private Visibility _OKButtonVisibility = Visibility.Collapsed;
  130. /// <summary>
  131. /// 确定
  132. /// </summary>
  133. public Visibility OKButtonVisibility
  134. {
  135. get { return _OKButtonVisibility; }
  136. set { SetProperty(ref _OKButtonVisibility, value); }
  137. }
  138. private Visibility _CancelButtonVisibility = Visibility.Visible;
  139. /// <summary>
  140. /// 取消
  141. /// </summary>
  142. public Visibility CancelButtonVisibility
  143. {
  144. get { return _CancelButtonVisibility; }
  145. set { SetProperty(ref _CancelButtonVisibility, value); }
  146. }
  147. private DelegateCommand _GoBack;
  148. public DelegateCommand GoBack =>
  149. _GoBack ?? (_GoBack = new DelegateCommand(ExecuteGoBack));
  150. /// <summary>
  151. /// 上一步
  152. /// </summary>
  153. void ExecuteGoBack()
  154. {
  155. if (SelectPageIndex == 1)
  156. {
  157. //进入托盘模式选择界面
  158. SelectPageIndex = 0;
  159. BackButtonVisibility = Visibility.Collapsed;
  160. NextButtonVisibility = Visibility.Visible;
  161. OKButtonVisibility = Visibility.Collapsed;
  162. CancelButtonVisibility = Visibility.Visible;
  163. }
  164. else if (SelectPageIndex == 2)
  165. {
  166. if (IsCheckModel1)
  167. {
  168. //进入托盘模式选择界面
  169. SelectPageIndex = 0;
  170. BackButtonVisibility = Visibility.Collapsed;
  171. NextButtonVisibility = Visibility.Visible;
  172. OKButtonVisibility = Visibility.Collapsed;
  173. CancelButtonVisibility = Visibility.Visible;
  174. }
  175. else
  176. {
  177. //进入坐标系模式选择界面
  178. SelectPageIndex = 1;
  179. BackButtonVisibility = Visibility.Visible;
  180. NextButtonVisibility = Visibility.Visible;
  181. OKButtonVisibility = Visibility.Collapsed;
  182. CancelButtonVisibility = Visibility.Visible;
  183. }
  184. }
  185. }
  186. private DelegateCommand _GoNext;
  187. public DelegateCommand GoNext =>
  188. _GoNext ?? (_GoNext = new DelegateCommand(ExecuteGoNext));
  189. /// <summary>
  190. /// 下一步
  191. /// </summary>
  192. void ExecuteGoNext()
  193. {
  194. if (SelectPageIndex==0)
  195. {
  196. if (IsCheckModel1)
  197. {
  198. //进入输入名称界面
  199. SelectPageIndex = 2;
  200. BackButtonVisibility= Visibility.Visible;
  201. NextButtonVisibility= Visibility.Collapsed;
  202. OKButtonVisibility = Visibility.Visible;
  203. CancelButtonVisibility = Visibility.Visible;
  204. }
  205. else
  206. {
  207. //进入坐标系模式选择界面
  208. SelectPageIndex = 1;
  209. BackButtonVisibility = Visibility.Visible;
  210. NextButtonVisibility = Visibility.Visible;
  211. OKButtonVisibility = Visibility.Collapsed;
  212. CancelButtonVisibility = Visibility.Visible;
  213. }
  214. }
  215. else if (SelectPageIndex == 1)
  216. {
  217. //进入输入名称界面
  218. SelectPageIndex = 2;
  219. BackButtonVisibility = Visibility.Visible;
  220. NextButtonVisibility = Visibility.Collapsed;
  221. OKButtonVisibility = Visibility.Visible;
  222. CancelButtonVisibility = Visibility.Visible;
  223. }
  224. }
  225. #region 属性通知
  226. /// <summary>
  227. /// Occurs when a property value changes.
  228. /// </summary>
  229. public event PropertyChangedEventHandler PropertyChanged;
  230. /// <summary>
  231. /// Checks if a property already matches a desired value. Sets the property and
  232. /// notifies listeners only when necessary.
  233. /// </summary>
  234. /// <typeparam name="T">Type of the property.</typeparam>
  235. /// <param name="storage">Reference to a property with both getter and setter.</param>
  236. /// <param name="value">Desired value for the property.</param>
  237. /// <param name="propertyName">Name of the property used to notify listeners. This
  238. /// value is optional and can be provided automatically when invoked from compilers that
  239. /// support CallerMemberName.</param>
  240. /// <returns>True if the value was changed, false if the existing value matched the
  241. /// desired value.</returns>
  242. protected virtual bool SetProperty<T>(ref T storage, T value, [CallerMemberName] string propertyName = null)
  243. {
  244. if (EqualityComparer<T>.Default.Equals(storage, value)) return false;
  245. storage = value;
  246. RaisePropertyChanged(propertyName);
  247. return true;
  248. }
  249. /// <summary>
  250. /// Checks if a property already matches a desired value. Sets the property and
  251. /// notifies listeners only when necessary.
  252. /// </summary>
  253. /// <typeparam name="T">Type of the property.</typeparam>
  254. /// <param name="storage">Reference to a property with both getter and setter.</param>
  255. /// <param name="value">Desired value for the property.</param>
  256. /// <param name="propertyName">Name of the property used to notify listeners. This
  257. /// value is optional and can be provided automatically when invoked from compilers that
  258. /// support CallerMemberName.</param>
  259. /// <param name="onChanged">Action that is called after the property value has been changed.</param>
  260. /// <returns>True if the value was changed, false if the existing value matched the
  261. /// desired value.</returns>
  262. protected virtual bool SetProperty<T>(ref T storage, T value, Action onChanged, [CallerMemberName] string propertyName = null)
  263. {
  264. if (EqualityComparer<T>.Default.Equals(storage, value)) return false;
  265. storage = value;
  266. onChanged?.Invoke();
  267. RaisePropertyChanged(propertyName);
  268. return true;
  269. }
  270. /// <summary>
  271. /// Raises this object's PropertyChanged event.
  272. /// </summary>
  273. /// <param name="propertyName">Name of the property used to notify listeners. This
  274. /// value is optional and can be provided automatically when invoked from compilers
  275. /// that support <see cref="CallerMemberNameAttribute"/>.</param>
  276. protected void RaisePropertyChanged([CallerMemberName] string propertyName = null)
  277. {
  278. OnPropertyChanged(new PropertyChangedEventArgs(propertyName));
  279. }
  280. /// <summary>
  281. /// Raises this object's PropertyChanged event.
  282. /// </summary>
  283. /// <param name="args">The PropertyChangedEventArgs</param>
  284. protected virtual void OnPropertyChanged(PropertyChangedEventArgs args)
  285. {
  286. PropertyChanged?.Invoke(this, args);
  287. }
  288. #endregion
  289. }
  290. }