using Notifications.Wpf.Core;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UIShare.GlobalVariable;

namespace UIShare.ViewModelBase
{
    public abstract class NavigateViewModelBase : BindableBase, INavigationAware
    {
        public DialogCloseListener RequestClose { get; set; }
        public IEventAggregator _eventAggregator;
        public IDialogService _dialogService;
        public IRegionManager _regionManager;
        public IModuleManager _moduleManager;
        private INotificationManager _notificationManager;
        private GlobalInfo _globalInfo;
        public NavigateViewModelBase(IContainerProvider containerProvider)
        {
            _globalInfo=containerProvider.Resolve<GlobalInfo>();
            _eventAggregator = containerProvider.Resolve<IEventAggregator>();
            _dialogService = containerProvider.Resolve<IDialogService>();
            _moduleManager = containerProvider.Resolve<IModuleManager>();
            _regionManager = containerProvider.Resolve<IRegionManager>();
            _notificationManager = containerProvider.Resolve<INotificationManager>();
        }

        protected void ShowInfoMessageBox(string Message,Action callback)
        {
            var dialogParams = new DialogParameters();
            dialogParams.Add("Title", "提示");
            dialogParams.Add("Message", Message);
            dialogParams.Add("Icon", "info");
            dialogParams.Add("ShowOk", true);
            _dialogService.ShowDialog("MessageBox", dialogParams, result =>
            {
                callback();
            });
        }
        protected void ShowErrorMessageBox(string Message,Action callback)
        {
            var dialogParams = new DialogParameters();
            dialogParams.Add("Title", "错误");
            dialogParams.Add("Message", Message);
            dialogParams.Add("Icon", "error");
            dialogParams.Add("ShowOk", true);
            _dialogService.ShowDialog("MessageBox", dialogParams, result =>
            {
                callback();
            });
        }
        #region Navigation

        public virtual void OnNavigatedTo(NavigationContext navigationContext) { }

        public virtual bool IsNavigationTarget(NavigationContext navigationContext) => true;

        public virtual void OnNavigatedFrom(NavigationContext navigationContext) { }

        #endregion
    }

}
