ConfigFilePlot.xaml.cs 3.6 KB

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