RecipeModeControl.xaml.cs 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. using MECF.Framework.Common.OperationCenter;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using System.Windows;
  8. using System.Windows.Controls;
  9. using System.Windows.Data;
  10. using System.Windows.Documents;
  11. using System.Windows.Input;
  12. using System.Windows.Media;
  13. using System.Windows.Media.Imaging;
  14. using System.Windows.Navigation;
  15. using System.Windows.Shapes;
  16. namespace CyberX8_Themes.UserControls
  17. {
  18. /// <summary>
  19. /// RecipeModeControl.xaml 的交互逻辑
  20. /// </summary>
  21. public partial class RecipeModeControl : UserControl
  22. {
  23. public RecipeModeControl()
  24. {
  25. InitializeComponent();
  26. }
  27. public static readonly DependencyProperty ModuleNameProperty = DependencyProperty.Register(
  28. "ModuleName", typeof(string), typeof(RecipeModeControl), new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.AffectsRender));
  29. /// <summary>
  30. /// 模块名称
  31. /// </summary>
  32. public string ModuleName
  33. {
  34. get
  35. {
  36. return (string)this.GetValue(ModuleNameProperty);
  37. }
  38. set
  39. {
  40. this.SetValue(ModuleNameProperty, value);
  41. }
  42. }
  43. public static readonly DependencyProperty IsEngineeringProperty = DependencyProperty.Register(
  44. "IsEngineering", typeof(bool), typeof(RecipeModeControl), new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsRender));
  45. /// <summary>
  46. /// IsEngineering
  47. /// </summary>
  48. public bool IsEngineering
  49. {
  50. get
  51. {
  52. return (bool)this.GetValue(IsEngineeringProperty);
  53. }
  54. set
  55. {
  56. this.SetValue(IsEngineeringProperty, value);
  57. }
  58. }
  59. public static readonly DependencyProperty IsProductionProperty = DependencyProperty.Register(
  60. "IsProduction", typeof(bool), typeof(RecipeModeControl), new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsRender));
  61. /// <summary>
  62. /// IsProduction
  63. /// </summary>
  64. public bool IsProduction
  65. {
  66. get
  67. {
  68. return (bool)this.GetValue(IsProductionProperty);
  69. }
  70. set
  71. {
  72. this.SetValue(IsProductionProperty, value);
  73. }
  74. }
  75. public static readonly DependencyProperty RecipeModeValueProperty = DependencyProperty.Register(
  76. "RecipeModeValue", typeof(string), typeof(RecipeModeControl), new FrameworkPropertyMetadata("", new PropertyChangedCallback(OnItemsSourceChanged)));
  77. /// <summary>
  78. /// OpertationModeValue
  79. /// </summary>
  80. public string RecipeModeValue
  81. {
  82. get
  83. {
  84. return (string)this.GetValue(RecipeModeValueProperty);
  85. }
  86. set
  87. {
  88. this.SetValue(RecipeModeValueProperty, value);
  89. }
  90. }
  91. private static void OnItemsSourceChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
  92. {
  93. if (e.NewValue != null)
  94. {
  95. string currentMode = (string)e.NewValue;
  96. switch (currentMode)
  97. {
  98. case "Engineering":
  99. d.SetValue(IsEngineeringProperty, true);
  100. d.SetValue(IsProductionProperty, false);
  101. break;
  102. case "Production":
  103. d.SetValue(IsEngineeringProperty, false);
  104. d.SetValue(IsProductionProperty, true);
  105. break;
  106. default:
  107. break;
  108. }
  109. }
  110. }
  111. private void Engineering_Click(object sender, RoutedEventArgs e)
  112. {
  113. InvokeClient.Instance.Service.DoOperation($"{ModuleName}.EngineeringModeAction");
  114. }
  115. private void Production_Click(object sender, RoutedEventArgs e)
  116. {
  117. InvokeClient.Instance.Service.DoOperation($"{ModuleName}.ProductionModeAction");
  118. }
  119. }
  120. }