ChannelComparision.xaml.cs 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. namespace HistoryView.Controls.Configs;
  2. public partial class ChannelComparision : UserControl
  3. {
  4. public ChannelComparision()
  5. {
  6. InitializeComponent();
  7. }
  8. public TempConfigSubChannel Source
  9. {
  10. get { return (TempConfigSubChannel)GetValue(SourceProperty); }
  11. set { SetValue(SourceProperty, value); }
  12. }
  13. public static readonly DependencyProperty SourceProperty =
  14. DependencyProperty.Register("Source", typeof(TempConfigSubChannel), typeof(ChannelComparision), new PropertyMetadata(default, TempChangedCallback));
  15. public TempConfigSubChannel Target
  16. {
  17. get { return (TempConfigSubChannel)GetValue(TargetProperty); }
  18. set { SetValue(TargetProperty, value); }
  19. }
  20. public static readonly DependencyProperty TargetProperty =
  21. DependencyProperty.Register("Target", typeof(TempConfigSubChannel), typeof(ChannelComparision), new PropertyMetadata(default, TempChangedCallback));
  22. static void TempChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
  23. {
  24. if (d is not ChannelComparision act)
  25. return;
  26. if (act.Target is null || act.Source is null)
  27. return;
  28. Compare(act, act.Source, act.Target);
  29. }
  30. private static void Compare(ChannelComparision act, TempConfigSubChannel source, TempConfigSubChannel target)
  31. {
  32. act.Index.Background = new SolidColorBrush(Colors.Transparent);
  33. act.SetPoint.Background = new SolidColorBrush(Colors.Transparent);
  34. act.CapsWarning.Background = new SolidColorBrush(Colors.Transparent);
  35. act.FloorWarning.Background = new SolidColorBrush(Colors.Transparent);
  36. act.UpperLimit.Background = new SolidColorBrush(Colors.Transparent);
  37. act.LowerLimit.Background = new SolidColorBrush(Colors.Transparent);
  38. act.Running_P.Background = new SolidColorBrush(Colors.Transparent);
  39. act.Running_I.Background = new SolidColorBrush(Colors.Transparent);
  40. act.Running_D.Background = new SolidColorBrush(Colors.Transparent);
  41. act.SetpointUpRate.Background = new SolidColorBrush(Colors.Transparent);
  42. act.SetpointDownRate.Background = new SolidColorBrush(Colors.Transparent);
  43. if (source.SetPoint != target.SetPoint)
  44. act.SetPoint.Background = (Brush)App.Current.Resources["LightWarningColor"];
  45. if (source.CapsWarning != target.CapsWarning)
  46. act.CapsWarning.Background = (Brush)App.Current.Resources["LightWarningColor"];
  47. if (source.FloorWarning != target.FloorWarning)
  48. act.FloorWarning.Background = (Brush)App.Current.Resources["LightWarningColor"];
  49. if (source.Caps != target.Caps)
  50. act.UpperLimit.Background = (Brush)App.Current.Resources["LightWarningColor"];
  51. if (source.Floor != target.Floor)
  52. act.LowerLimit.Background = (Brush)App.Current.Resources["LightWarningColor"];
  53. if (source.Running_P != target.Running_P)
  54. act.Running_P.Background = (Brush)App.Current.Resources["LightWarningColor"];
  55. if (source.Running_I != target.Running_I)
  56. act.Running_I.Background = (Brush)App.Current.Resources["LightWarningColor"];
  57. if (source.Running_D != target.Running_D)
  58. act.Running_D.Background = (Brush)App.Current.Resources["LightWarningColor"];
  59. if (source.SetpointUpRate != target.SetpointUpRate)
  60. act.SetpointUpRate.Background = (Brush)App.Current.Resources["LightWarningColor"];
  61. if (source.SetpointDownRate != target.SetpointDownRate)
  62. act.SetpointDownRate.Background = (Brush)App.Current.Resources["LightWarningColor"];
  63. }
  64. }