using HistoryView.Controls;

namespace HistoryView.Views;

public partial class Window1 : Window, IDialogWindow
{
    public Window1()
    {
        InitializeComponent();
        Loaded += SubWindowStyle_Loaded;

    }

    public override void OnApplyTemplate()
    {
        base.OnApplyTemplate();
        _header = (Header)GetTemplateChild("ThemeHeader");
    }
    Header? _header;
    private void SubWindowStyle_Loaded(object sender, RoutedEventArgs e)
    {
        if (_header is null)
            return;

        if (DataContext is not IDialogAwareTitle dialog)
            return;
        _header.Title = dialog.Title;
    }


    public IDialogResult? Result { get; set; } = new DialogResult();

    private void This_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
    {
        try
        {
            if (e.MouseDevice.DirectlyOver is Border border && border.Parent is Header)
                this.DragMove();
        }
        catch
        {
        }
    }
}
