ConfigFilePlot.xaml.cs 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. using GlobalData;
  2. using System.Windows;
  3. using System.Windows.Controls;
  4. using System.Windows.Input;
  5. namespace ConfigFileManager.Controls;
  6. /// <summary>
  7. /// Interaction logic for ConfigFilePlot.xaml
  8. /// </summary>
  9. public partial class ConfigFilePlot : UserControl
  10. {
  11. public ConfigFilePlot()
  12. {
  13. InitializeComponent();
  14. this.UpdateBar.Visibility = Visibility.Collapsed;
  15. }
  16. public DeviceInfo_VM DeviceInfo
  17. {
  18. get { return (DeviceInfo_VM)GetValue(DeviceInfoProperty); }
  19. set { SetValue(DeviceInfoProperty, value); }
  20. }
  21. public static readonly DependencyProperty DeviceInfoProperty =
  22. DependencyProperty.Register("DeviceInfo", typeof(DeviceInfo_VM), typeof(ConfigFilePlot), new PropertyMetadata(default));
  23. public ICommand UpdateCommand
  24. {
  25. get { return (ICommand)GetValue(UpdateCommandProperty); }
  26. set { SetValue(UpdateCommandProperty, value); }
  27. }
  28. public static readonly DependencyProperty UpdateCommandProperty =
  29. DependencyProperty.Register("UpdateCommand", typeof(ICommand), typeof(ConfigFilePlot), new PropertyMetadata(default));
  30. public ICommand MigrateCommand
  31. {
  32. get { return (ICommand)GetValue(MigrateCommandProperty); }
  33. set { SetValue(MigrateCommandProperty, value); }
  34. }
  35. public static readonly DependencyProperty MigrateCommandProperty =
  36. DependencyProperty.Register("MigrateCommand", typeof(ICommand), typeof(ConfigFilePlot), new PropertyMetadata(default));
  37. public ICommand CheckRecipeCommand
  38. {
  39. get { return (ICommand)GetValue(CheckRecipeCommandProperty); }
  40. set { SetValue(CheckRecipeCommandProperty, value); }
  41. }
  42. public static readonly DependencyProperty CheckRecipeCommandProperty =
  43. DependencyProperty.Register("CheckRecipeCommand", typeof(ICommand), typeof(ConfigFilePlot), new PropertyMetadata(default));
  44. public ICommand CheckConfigCommand
  45. {
  46. get { return (ICommand)GetValue(CheckConfigCommandProperty); }
  47. set { SetValue(CheckConfigCommandProperty, value); }
  48. }
  49. public static readonly DependencyProperty CheckConfigCommandProperty =
  50. DependencyProperty.Register("CheckConfigCommand", typeof(ICommand), typeof(ConfigFilePlot), new PropertyMetadata(default));
  51. public bool IsUpdate
  52. {
  53. get { return (bool)GetValue(IsUpdateProperty); }
  54. set { SetValue(IsUpdateProperty, value); }
  55. }
  56. // Using a DependencyProperty as the backing store for IsUpdate. This enables animation, styling, binding, etc...
  57. public static readonly DependencyProperty IsUpdateProperty =
  58. DependencyProperty.Register("IsUpdate", typeof(bool), typeof(ConfigFilePlot), new PropertyMetadata(false, IsUpdatingChangedCallback));
  59. private static void IsUpdatingChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
  60. {
  61. if (d is not ConfigFilePlot plot)
  62. return;
  63. if (e.NewValue is not bool updateStaus)
  64. return;
  65. plot.UpdateBar.Visibility = updateStaus switch
  66. {
  67. true => Visibility.Visible,
  68. false => Visibility.Collapsed
  69. };
  70. }
  71. }