251029
This commit is contained in:
94
FATrace.WPLApp/Core/DialogViewModel.cs
Normal file
94
FATrace.WPLApp/Core/DialogViewModel.cs
Normal file
@@ -0,0 +1,94 @@
|
||||
using Prism.Mvvm;
|
||||
using Prism.Services.Dialogs;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FATrace.WPLApp.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// 弹窗基类
|
||||
/// </summary>
|
||||
public class DialogViewModel : BindableBase, IDialogAware
|
||||
{
|
||||
public string? Title { get; set; }
|
||||
|
||||
public event Action<IDialogResult>? RequestClose;
|
||||
|
||||
/// <summary>
|
||||
/// 调用RequestClose
|
||||
/// </summary>
|
||||
/// <param name="dialogResult"></param>
|
||||
public void RaiseRequestClose(IDialogResult dialogResult)
|
||||
{
|
||||
RequestClose?.Invoke(dialogResult);
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 是否关闭窗口
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool CanCloseDialog()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 关闭时触发
|
||||
/// </summary>
|
||||
public void OnDialogClosed()
|
||||
{
|
||||
OnDialogClosed(ButtonResult.OK);
|
||||
}
|
||||
|
||||
public void OnDialogClosed(ButtonResult result)
|
||||
{
|
||||
RequestClose?.Invoke(new DialogResult(result));
|
||||
}
|
||||
|
||||
public void OnDialogClosed(IDialogResult dialogResult)
|
||||
{
|
||||
RequestClose?.Invoke(dialogResult);
|
||||
}
|
||||
|
||||
//public void OnDialogClosed() => OnDialogClosed(ButtonResult.OK);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 打开时触发
|
||||
/// </summary>
|
||||
/// <param name="parameters"></param>
|
||||
public virtual void OnDialogOpened(IDialogParameters parameters)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public bool IsNotBusy => !IsBusy;
|
||||
private bool isBusy;
|
||||
public bool IsBusy
|
||||
{
|
||||
get => isBusy;
|
||||
set
|
||||
{
|
||||
isBusy = value;
|
||||
RaisePropertyChanged();
|
||||
RaisePropertyChanged(nameof(IsNotBusy));
|
||||
}
|
||||
}
|
||||
|
||||
public virtual async Task SetBusyAsync(Func<Task> func, string loadingMessage = null)
|
||||
{
|
||||
IsBusy = true;
|
||||
try
|
||||
{
|
||||
await func();
|
||||
}
|
||||
finally
|
||||
{
|
||||
IsBusy = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
46
FATrace.WPLApp/Core/NavigationViewModel.cs
Normal file
46
FATrace.WPLApp/Core/NavigationViewModel.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
using Prism.Mvvm;
|
||||
using Prism.Regions;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FATrace.WPLApp.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// 导航的基类
|
||||
/// </summary>
|
||||
public class NavigationViewModel : BindableBase, INavigationAware
|
||||
{
|
||||
/// <summary>
|
||||
/// 是否重用导航对象
|
||||
/// </summary>
|
||||
/// <param name="navigationContext"></param>
|
||||
/// <returns></returns>
|
||||
public virtual bool IsNavigationTarget(NavigationContext navigationContext)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 导航被切换触发
|
||||
/// </summary>
|
||||
/// <param name="navigationContext"></param>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public virtual void OnNavigatedFrom(NavigationContext navigationContext)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 导航被执行触发
|
||||
/// </summary>
|
||||
/// <param name="navigationContext"></param>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public virtual void OnNavigatedTo(NavigationContext navigationContext)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user