using System.Windows;
using NPOI.OpenXmlFormats.Spreadsheet;

namespace InABox.DynamicGrid;

public partial class DynamicContentDialog : Window
{
    public static readonly DependencyProperty CanSaveProperty = DependencyProperty.Register(nameof(CanSave), typeof(bool), typeof(DynamicContentDialog));

    public bool ButtonsVisible
    {
        get => Buttons.Visibility == Visibility.Visible;
        set => Buttons.Visibility = value ? Visibility.Visible : Visibility.Collapsed;
    }

    public bool CanSave
    {
        get => (bool)GetValue(CanSaveProperty);
        set => SetValue(CanSaveProperty, value);
    }

    public DynamicContentDialog(FrameworkElement element, bool buttonsVisible = true)
    {
        InitializeComponent();
        ButtonsVisible = buttonsVisible;
        Presenter.Content = element;
    }

    private void OKButton_Click(object sender, RoutedEventArgs e)
    {
        DialogResult = true;
    }

    private void CancelButton_Click(object sender, RoutedEventArgs e)
    {
        DialogResult = false;
    }
}