StatusControl.xaml.cs 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. using ivf_tl_Operate.Converts;
  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 ivf_tl_Operate.CustomUserControls
  17. {
  18. /// <summary>
  19. /// StatusControl.xaml 的交互逻辑
  20. /// </summary>
  21. public partial class StatusControl : UserControl
  22. {
  23. public StatusControl()
  24. {
  25. InitializeComponent();
  26. }
  27. /// <summary>
  28. /// 系统正在报警数量
  29. /// </summary>
  30. public int Count
  31. {
  32. get { return (int)GetValue(CountProperty); }
  33. set { SetValue(CountProperty, value); }
  34. }
  35. public static readonly DependencyProperty CountProperty =
  36. DependencyProperty.Register("Count", typeof(int), typeof(StatusControl), new PropertyMetadata(0, new PropertyChangedCallback(OnCountPropertyChangedCallback)));
  37. private static void OnCountPropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
  38. {
  39. var source = d as StatusControl;
  40. var number = (int)e.NewValue;
  41. if (number > 0)
  42. {
  43. //source._abnormalText.Content = $"系统异常({number})";
  44. source._abnormalText.Content = $"{KeyToStringConvert.GetLanguageStringByKey("C0270")}({number})";
  45. source._normal.Visibility = Visibility.Collapsed;
  46. source._abnormal.Visibility = Visibility.Visible;
  47. }
  48. else
  49. {
  50. source._normal.Visibility = Visibility.Visible;
  51. source._abnormal.Visibility = Visibility.Collapsed;
  52. }
  53. }
  54. }
  55. }