namespace ConfigFileManager.Controls; /// /// Interaction logic for ConfigFilePlot.xaml /// public partial class ConfigFilePlot : UserControl { public ConfigFilePlot() { InitializeComponent(); this.UpdateBar.Visibility = Visibility.Collapsed; } public DeviceInfo_VM DeviceInfo { get { return (DeviceInfo_VM)GetValue(DeviceInfoProperty); } set { SetValue(DeviceInfoProperty, value); } } public static readonly DependencyProperty DeviceInfoProperty = DependencyProperty.Register("DeviceInfo", typeof(DeviceInfo_VM), typeof(ConfigFilePlot), new PropertyMetadata(default)); public ICommand UpdateCommand { get { return (ICommand)GetValue(UpdateCommandProperty); } set { SetValue(UpdateCommandProperty, value); } } public static readonly DependencyProperty UpdateCommandProperty = DependencyProperty.Register("UpdateCommand", typeof(ICommand), typeof(ConfigFilePlot), new PropertyMetadata(default)); public ICommand MigrateCommand { get { return (ICommand)GetValue(MigrateCommandProperty); } set { SetValue(MigrateCommandProperty, value); } } public static readonly DependencyProperty MigrateCommandProperty = DependencyProperty.Register("MigrateCommand", typeof(ICommand), typeof(ConfigFilePlot), new PropertyMetadata(default)); public ICommand CheckRecipeCommand { get { return (ICommand)GetValue(CheckRecipeCommandProperty); } set { SetValue(CheckRecipeCommandProperty, value); } } public static readonly DependencyProperty CheckRecipeCommandProperty = DependencyProperty.Register("CheckRecipeCommand", typeof(ICommand), typeof(ConfigFilePlot), new PropertyMetadata(default)); public ICommand CheckConfigCommand { get { return (ICommand)GetValue(CheckConfigCommandProperty); } set { SetValue(CheckConfigCommandProperty, value); } } public static readonly DependencyProperty CheckConfigCommandProperty = DependencyProperty.Register("CheckConfigCommand", typeof(ICommand), typeof(ConfigFilePlot), new PropertyMetadata(default)); public bool IsUpdate { get { return (bool)GetValue(IsUpdateProperty); } set { SetValue(IsUpdateProperty, value); } } // Using a DependencyProperty as the backing store for IsUpdate. This enables animation, styling, binding, etc... public static readonly DependencyProperty IsUpdateProperty = DependencyProperty.Register("IsUpdate", typeof(bool), typeof(ConfigFilePlot), new PropertyMetadata(false, IsUpdatingChangedCallback)); private static void IsUpdatingChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e) { if (d is not ConfigFilePlot plot) return; if (e.NewValue is not bool updateStaus) return; switch (updateStaus) { case true: plot.UpdateBar.Visibility = Visibility.Visible; plot.ConfigButton.IsEnabled = false; plot.RecipeButton.IsEnabled = false; plot.MigrateButton.IsEnabled = false; break; case false: plot.UpdateBar.Visibility = Visibility.Collapsed; plot.ConfigButton.IsEnabled = true; plot.RecipeButton.IsEnabled = true; plot.MigrateButton.IsEnabled = true; break; } plot.UpdateBar.Visibility = updateStaus switch { true => Visibility.Visible, false => Visibility.Collapsed }; } }