using Prism.Ioc;
using Prism.Services.Dialogs;
using System.Windows;
using WorkStation.Client.ViewModels.Dialogs;
using WorkStation.Client.Views;
using WorkStation.Client.Views.Dialogs;

namespace WorkStation.Client
{
    /// <summary>
    /// Interaction logic for App.xaml
    /// </summary>
    public partial class App
    {
        protected override Window CreateShell()
        {
            return Container.Resolve<MainWindow>();
        }
        protected override void OnInitialized()
        {

            // 从依赖注入容器中解析出 IDialogService 实例（用于显示对话框）
            var dialogService = Container.Resolve<IDialogService>();

            // 显示登录对话框（"LoginView" 是注册的视图名称）
            dialogService.ShowDialog("LoginView", result =>
            {
                // 当对话框返回结果为 "OK" 时（例如用户点击了“登录”按钮）
                if (result.Result == ButtonResult.OK)
                {
                    // 调用基类的 OnInitialized 方法，继续执行应用程序初始化逻辑
                    base.OnInitialized();
                }
            });
        }
        protected override void RegisterTypes(IContainerRegistry containerRegistry)
        {
            //注册登录弹窗
            containerRegistry.RegisterDialog<LoginView, LoginViewModel>();
        }
    }
}
