终端一体化运控平台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

121 line
5.1 KiB

  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  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 BPASmartClient.CustomResource.UserControls
  17. {
  18. /// <summary>
  19. /// MaterialStock.xaml 的交互逻辑
  20. /// </summary>
  21. public partial class MaterialStock : UserControl
  22. {
  23. public MaterialStock()
  24. {
  25. InitializeComponent();
  26. }
  27. [Category("运行状态")]
  28. public bool IsRunning
  29. {
  30. get { return (bool)GetValue(IsRunningProperty); }
  31. set { SetValue(IsRunningProperty, value); }
  32. }
  33. public static readonly DependencyProperty IsRunningProperty =
  34. DependencyProperty.Register("IsRunning", typeof(bool), typeof(MaterialStock), new PropertyMetadata(default(bool), new PropertyChangedCallback(OnRunningChanged)));
  35. private static void OnRunningChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
  36. {
  37. VisualStateManager.GoToState(d as MaterialStock, (bool)e.NewValue ? "RunState" : "Stop", false);
  38. }
  39. [Category("报警状态")]
  40. public bool IsFaultState
  41. {
  42. get { return (bool)GetValue(IsFaultStateProperty); }
  43. set { SetValue(IsFaultStateProperty, value); }
  44. }
  45. public static readonly DependencyProperty IsFaultStateProperty =
  46. DependencyProperty.Register("IsFaultState", typeof(bool), typeof(MaterialStock), new PropertyMetadata(default(bool), new PropertyChangedCallback(OnFaultStateChanged)));
  47. private static void OnFaultStateChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
  48. {
  49. VisualStateManager.GoToState(d as MaterialStock, (bool)e.NewValue ? "FaultState" : "NormalState", false);
  50. }
  51. [Category("料仓打开状态")]
  52. public bool IsOpenState
  53. {
  54. get { return (bool)GetValue(IsOpenStateProperty); }
  55. set { SetValue(IsOpenStateProperty, value); }
  56. }
  57. public static readonly DependencyProperty IsOpenStateProperty =
  58. DependencyProperty.Register("IsOpenState", typeof(bool), typeof(MaterialStock), new PropertyMetadata(default(bool), new PropertyChangedCallback(OnOpenStateChanged)));
  59. private static void OnOpenStateChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
  60. {
  61. VisualStateManager.GoToState(d as MaterialStock, (bool)e.NewValue ? "OpenState" : "CloseState", false);
  62. }
  63. [Category("下料状态")]
  64. public bool IsLayOffState
  65. {
  66. get { return (bool)GetValue(IsLayOffStateProperty); }
  67. set { SetValue(IsLayOffStateProperty, value); }
  68. }
  69. public static readonly DependencyProperty IsLayOffStateProperty =
  70. DependencyProperty.Register("IsLayOffState", typeof(bool), typeof(MaterialStock), new PropertyMetadata(default(bool), new PropertyChangedCallback(OnLayOffStateChanged)));
  71. private static void OnLayOffStateChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
  72. {
  73. VisualStateManager.GoToState(d as MaterialStock, (bool)e.NewValue ? "LayOffState" : "LayStopState", false);
  74. if ((d as MaterialStock)?.IsLayOffState == true)
  75. {
  76. (d as MaterialStock).arrow.Visibility = Visibility.Visible;
  77. }
  78. else if ((d as MaterialStock)?.IsLayOffState == false)
  79. {
  80. (d as MaterialStock).arrow.Visibility = Visibility.Collapsed;
  81. }
  82. }
  83. [Category("物料重量")]
  84. public double MaterialWeight
  85. {
  86. get { return (double)GetValue(MaterialWeightProperty); }
  87. set { SetValue(MaterialWeightProperty, value); }
  88. }
  89. public static readonly DependencyProperty MaterialWeightProperty =
  90. DependencyProperty.Register("MaterialWeight", typeof(double), typeof(MaterialStock), new PropertyMetadata(default(double), new PropertyChangedCallback(OnWeightChanged)));
  91. private static void OnWeightChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
  92. {
  93. (d as MaterialStock).stockWeight.Text = e.NewValue.ToString();
  94. }
  95. [Category("物料名称")]
  96. public string MaterialName
  97. {
  98. get { return (string)GetValue(MaterialNameProperty); }
  99. set { SetValue(MaterialNameProperty, value); }
  100. }
  101. public static readonly DependencyProperty MaterialNameProperty =
  102. DependencyProperty.Register("MaterialName", typeof(string), typeof(MaterialStock), new PropertyMetadata(default(string), new PropertyChangedCallback(OnNameChanged)));
  103. private static void OnNameChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
  104. {
  105. (d as MaterialStock).stockName.Text = e.NewValue.ToString();
  106. }
  107. }
  108. }