PMCounterComponent.xaml.cs 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. using Aitex.Core.UI.MVVM;
  2. using Aitex.Core.Utilities;
  3. using CyberX8_Core;
  4. using MECF.Framework.Common.CommonData.Reservoir;
  5. using MECF.Framework.Common.OperationCenter;
  6. using MECF.Framework.Common.RecipeCenter;
  7. using MECF.Framework.UI.Core.Control;
  8. using System;
  9. using System.Collections.Generic;
  10. using System.Collections.ObjectModel;
  11. using System.Linq;
  12. using System.Reflection;
  13. using System.Text;
  14. using System.Threading.Tasks;
  15. using System.Windows;
  16. using System.Windows.Controls;
  17. using System.Windows.Data;
  18. using System.Windows.Documents;
  19. using System.Windows.Input;
  20. using System.Windows.Media;
  21. using System.Windows.Media.Imaging;
  22. using System.Windows.Navigation;
  23. using System.Windows.Shapes;
  24. namespace CyberX8_Themes.UserControls
  25. {
  26. /// <summary>
  27. /// PMCounterComponent.xaml 的交互逻辑
  28. /// </summary>
  29. public partial class PMCounterComponent : UserControl
  30. {
  31. public PMCounterComponent()
  32. {
  33. InitializeComponent();
  34. KeyDownCommand = new DelegateCommand<object[]>(KeyDownAction);
  35. }
  36. [IgnorePropertyChange]
  37. public ICommand KeyDownCommand { get; private set; }
  38. public static readonly DependencyProperty ComponentNodesProperty = DependencyProperty.
  39. Register("ComponentNodes", typeof(ObservableCollection<PMCounterNode>), typeof(PMCounterComponent));
  40. public ObservableCollection<PMCounterNode> ComponentNodes
  41. {
  42. get { return (ObservableCollection<PMCounterNode>)this.GetValue(ComponentNodesProperty); }
  43. set { this.SetValue(ComponentNodesProperty, value); }
  44. }
  45. private void KeyDownAction(object[] param)
  46. {
  47. if (param.Length > 2)
  48. {
  49. string PMCounterName = (string)param[0];
  50. if(PMCounterName.Length < 7) //修改的是metal
  51. {
  52. string CounterName = (string)param[1];
  53. string NewValue = (string)param[2];
  54. //根据输入的newvalue在后台更新PMCounterComponent的新值并执行对应的操作
  55. InvokeClient.Instance.Service.DoOperation($"{PMCounterName}.UpdateMetalUsage", PMCounterName, CounterName, NewValue);
  56. }
  57. else //修改的是reservoir
  58. {
  59. string CounterName = (string)param[1];
  60. string NewValue = (string)param[2];
  61. //根据输入的newvalue在后台更新PMCounterComponent的新值并执行对应的操作
  62. InvokeClient.Instance.Service.DoOperation($"{PMCounterName}.UpdateReservoirUsage", PMCounterName, CounterName, NewValue);
  63. }
  64. }
  65. }
  66. }
  67. }