using System; using System.Collections.Generic; using System.ComponentModel; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; namespace BPASmartClient.CustomResource.UserControls { /// /// MaterialStock.xaml 的交互逻辑 /// public partial class MaterialStock : UserControl { public MaterialStock() { InitializeComponent(); } [Category("运行状态")] public bool IsRunning { get { return (bool)GetValue(IsRunningProperty); } set { SetValue(IsRunningProperty, value); } } public static readonly DependencyProperty IsRunningProperty = DependencyProperty.Register("IsRunning", typeof(bool), typeof(MaterialStock), new PropertyMetadata(default(bool), new PropertyChangedCallback(OnRunningChanged))); private static void OnRunningChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { VisualStateManager.GoToState(d as MaterialStock, (bool)e.NewValue ? "RunState" : "Stop", false); } [Category("报警状态")] public bool IsFaultState { get { return (bool)GetValue(IsFaultStateProperty); } set { SetValue(IsFaultStateProperty, value); } } public static readonly DependencyProperty IsFaultStateProperty = DependencyProperty.Register("IsFaultState", typeof(bool), typeof(MaterialStock), new PropertyMetadata(default(bool), new PropertyChangedCallback(OnFaultStateChanged))); private static void OnFaultStateChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { VisualStateManager.GoToState(d as MaterialStock, (bool)e.NewValue ? "FaultState" : "NormalState", false); } [Category("料仓打开状态")] public bool IsOpenState { get { return (bool)GetValue(IsOpenStateProperty); } set { SetValue(IsOpenStateProperty, value); } } public static readonly DependencyProperty IsOpenStateProperty = DependencyProperty.Register("IsOpenState", typeof(bool), typeof(MaterialStock), new PropertyMetadata(default(bool), new PropertyChangedCallback(OnOpenStateChanged))); private static void OnOpenStateChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { VisualStateManager.GoToState(d as MaterialStock, (bool)e.NewValue ? "OpenState" : "CloseState", false); } [Category("下料状态")] public bool IsLayOffState { get { return (bool)GetValue(IsLayOffStateProperty); } set { SetValue(IsLayOffStateProperty, value); } } public static readonly DependencyProperty IsLayOffStateProperty = DependencyProperty.Register("IsLayOffState", typeof(bool), typeof(MaterialStock), new PropertyMetadata(default(bool), new PropertyChangedCallback(OnLayOffStateChanged))); private static void OnLayOffStateChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { VisualStateManager.GoToState(d as MaterialStock, (bool)e.NewValue ? "LayOffState" : "LayStopState", false); if ((d as MaterialStock)?.IsLayOffState == true) { (d as MaterialStock).arrow.Visibility = Visibility.Visible; } else if ((d as MaterialStock)?.IsLayOffState == false) { (d as MaterialStock).arrow.Visibility = Visibility.Collapsed; } } [Category("物料重量")] public double MaterialWeight { get { return (double)GetValue(MaterialWeightProperty); } set { SetValue(MaterialWeightProperty, value); } } public static readonly DependencyProperty MaterialWeightProperty = DependencyProperty.Register("MaterialWeight", typeof(double), typeof(MaterialStock), new PropertyMetadata(default(double), new PropertyChangedCallback(OnWeightChanged))); private static void OnWeightChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { (d as MaterialStock).stockWeight.Text = e.NewValue.ToString(); } [Category("物料名称")] public string MaterialName { get { return (string)GetValue(MaterialNameProperty); } set { SetValue(MaterialNameProperty, value); } } public static readonly DependencyProperty MaterialNameProperty = DependencyProperty.Register("MaterialName", typeof(string), typeof(MaterialStock), new PropertyMetadata(default(string), new PropertyChangedCallback(OnNameChanged))); private static void OnNameChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { (d as MaterialStock).stockName.Text = e.NewValue.ToString(); } } }