namespace HistoryView.Controls;

public partial class FullConfig : UserControl
{
    public FullConfig()
    {
        InitializeComponent();
    }

    public TempConfig Source
    {
        get { return (TempConfig)GetValue(SourceProperty); }
        set { SetValue(SourceProperty, value); }
    }

    public static readonly DependencyProperty SourceProperty =
        DependencyProperty.Register("Source", typeof(TempConfig), typeof(FullConfig), new PropertyMetadata(default));

    public ICommand Export
    {
        get { return (ICommand)GetValue(ExportProperty); }
        set { SetValue(ExportProperty, value); }
    }

    public static readonly DependencyProperty ExportProperty =
        DependencyProperty.Register("Export", typeof(ICommand), typeof(FullConfig), new PropertyMetadata(default));

    public ICommand SetAsCurrentConfig
    {
        get { return (ICommand)GetValue(SetAsCurrentConfigProperty); }
        set { SetValue(SetAsCurrentConfigProperty, value); }
    }

    public static readonly DependencyProperty SetAsCurrentConfigProperty =
        DependencyProperty.Register("SetAsCurrentConfig", typeof(ICommand), typeof(FullConfig), new PropertyMetadata(default));

    private void Button_Click(object sender, RoutedEventArgs e)
    {
        foreach (var item in FindVisualChildren.Find<Expander>(this.Items))
        {
            item.IsExpanded = false;
        }
    }

    private void Button_Click_1(object sender, RoutedEventArgs e)
    {
        foreach (var item in FindVisualChildren.Find<Expander>(this.Items))
        {
            item.IsExpanded = true;
        }
    }
}
