using Prism.Commands;
using Prism.Ioc;
using Prism.Mvvm;
using StartServerWPF.Modules.Main.ViewModels;
using System.Windows;

namespace StartServerWPF.ViewModels
{
    public class MainWindowViewModel : BindableBase
    {
        private string _title = "StartServerWPF";
        private readonly IContainerProvider _containerProvider;

        public string Title
        {
            get { return _title; }
            set { SetProperty(ref _title, value); }
        }      
       public DelegateCommand ExitCommand => new(() =>
        {
            if (MessageBox.Show("是否退出程序？", "警告", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.Yes)
            {
                var main = _containerProvider.Resolve<MainViewModel>();
                 main.OneKeyStop();
                Application.Current.Shutdown();
            }
        });

        public MainWindowViewModel(IContainerProvider containerProvider)
        {
            this._containerProvider = containerProvider;
        }



    }
}
