58 lines
2.0 KiB
C#
58 lines
2.0 KiB
C#
using Notifications.Wpf.Core;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using Prism.Dialogs;
|
|
|
|
namespace UIShare.ViewModelBase
|
|
{
|
|
public abstract class DialogViewModelBase : BindableBase,IDialogAware
|
|
{
|
|
public DialogCloseListener RequestClose { get; set; }
|
|
public IEventAggregator _eventAggregator;
|
|
public IDialogService _dialogService;
|
|
private INotificationManager _notificationManager;
|
|
public DialogViewModelBase(IContainerProvider containerProvider)
|
|
{
|
|
_eventAggregator = containerProvider.Resolve<IEventAggregator>();
|
|
_dialogService = containerProvider.Resolve<IDialogService>();
|
|
_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("MessageBoxView", dialogParams, result =>
|
|
{
|
|
callback();
|
|
});
|
|
}
|
|
|
|
protected void ShowErrorMessageBox(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("MessageBoxView", dialogParams, result =>
|
|
{
|
|
callback();
|
|
});
|
|
}
|
|
|
|
#region Dialog
|
|
|
|
public virtual bool CanCloseDialog() => true;
|
|
public virtual void OnDialogClosed() { }
|
|
public virtual void OnDialogOpened(IDialogParameters parameters) { }
|
|
#endregion
|
|
}
|
|
}
|