namespace HistoryView.Views.Regions;

public partial class GasPanelHolder : UserControl
{
    public GasPanelHolder()
    {
        InitializeComponent();
        //LoadWindow();
    }
    private void LoadWindow()
    {
        Task.Run(() =>
        {
            if (!BaseConfigFileLoader.Load(out BasicInfo? basicInfo) || basicInfo is null || string.IsNullOrEmpty(basicInfo.GasPanelWindowName))
                return;

            this.Dispatcher.Invoke(() =>
            {
                if (!SetWindow.FindWindow(basicInfo.GasPanelWindowName))
                    return;
                SetWindow.SetParent(panel.Handle);
            });
        });
    }

    private void Button_Click(object sender, RoutedEventArgs e)
    {
        LoadWindow();
    }

    private void UserControl_SizeChanged(object sender, SizeChangedEventArgs e)
    {
        Task.Factory.StartNew(SetWindow.ResizeWindow);
    }

    private void Button_Click_1(object sender, RoutedEventArgs e)
    {
        SetWindow.ExitParent();
    }
}