201 lines
7.4 KiB
C#
201 lines
7.4 KiB
C#
using Microsoft.Identity.Client.NativeInterop;
|
|
using Prism.Commands;
|
|
using Prism.Mvvm;
|
|
using Prism.Regions;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows;
|
|
using System.Windows.Media;
|
|
|
|
namespace InSituLaboratory.ViewModels.Pages
|
|
{
|
|
public class ViewModelBase : BindableBase, INavigationAware
|
|
{
|
|
public string PageTitle { get; set; } = "页面标题";
|
|
public bool IsCanClose { get; set; } = true;
|
|
|
|
public string SearchKey { get; set; }
|
|
public string PrimaryKey { get; set; }
|
|
|
|
#region 数据下载实体类
|
|
|
|
private bool downloadDataBtnIsEnabled = true;
|
|
public bool DownloadDataBtnIsEnabled
|
|
{
|
|
get { return downloadDataBtnIsEnabled; }
|
|
set { SetProperty(ref downloadDataBtnIsEnabled, value); }
|
|
}
|
|
|
|
|
|
private Visibility downloadDataMsgVisibility = Visibility.Visible;
|
|
public Visibility DownloadDataMsgVisibility
|
|
{
|
|
get { return downloadDataMsgVisibility; }
|
|
set { SetProperty(ref downloadDataMsgVisibility, value); }
|
|
}
|
|
|
|
private string downloadDataMsg;
|
|
|
|
public string DownloadDataMsg
|
|
{
|
|
get { return downloadDataMsg; }
|
|
set { SetProperty(ref downloadDataMsg, value); }
|
|
}
|
|
|
|
private Brush downloadDataMsgForeground;
|
|
|
|
public Brush DownloadDataMsgForeground
|
|
{
|
|
get { return downloadDataMsgForeground; }
|
|
set { SetProperty(ref downloadDataMsgForeground, value); }
|
|
}
|
|
|
|
#endregion
|
|
|
|
public DelegateCommand CloseCommand { get; set; }
|
|
public DelegateCommand RefreshCommand { get; set; }
|
|
public DelegateCommand<object> ModifyCommand { get; set; }
|
|
public DelegateCommand<object> DeleteCommand { get; set; }
|
|
public DelegateCommand DownloadCommand { get; set; }
|
|
public DelegateCommand<object> ConnectionCommand { get; set; }
|
|
public DelegateCommand ReductionCommand { get; set; } //一键还原
|
|
public DelegateCommand StartCommand { get; set; }//一键启动
|
|
public DelegateCommand SynchronizationCommand { get; set; }//时间同步
|
|
|
|
public DelegateCommand<object> SyncCommand { get; set; }//请求当前时序
|
|
|
|
public DelegateCommand<object> RefreshSeCommand { get; set; }//时序刷新
|
|
public DelegateCommand<object> ClearCommand { get; set; }//时序清除
|
|
public DelegateCommand<object> BeginCommand { get; set; }//时序启动
|
|
public DelegateCommand<object> SuspendCommand { get; set; }//时序暂停
|
|
public DelegateCommand<object> SendCommand { get; set; }//时序下发
|
|
|
|
|
|
#region 时序1-5 新增/编辑 删除
|
|
|
|
public DelegateCommand<object> ModifyS1Command { get; set; }
|
|
public DelegateCommand<object> DeleteS1Command { get; set; }
|
|
|
|
|
|
public DelegateCommand<object> ModifyS2Command { get; set; }
|
|
public DelegateCommand<object> DeleteS2Command { get; set; }
|
|
|
|
public DelegateCommand<object> ModifyS3Command { get; set; }
|
|
public DelegateCommand<object> DeleteS3Command { get; set; }
|
|
|
|
public DelegateCommand<object> ModifyS4Command { get; set; }
|
|
public DelegateCommand<object> DeleteS4Command { get; set; }
|
|
|
|
public DelegateCommand<object> ModifyS5Command { get; set; }
|
|
public DelegateCommand<object> DeleteS5Command { get; set; }
|
|
#endregion
|
|
|
|
|
|
IRegionManager _regionManager;
|
|
public ViewModelBase(IRegionManager regionManager)
|
|
{
|
|
_regionManager = regionManager;
|
|
|
|
CloseCommand = new DelegateCommand(DoClose);
|
|
RefreshCommand = new DelegateCommand(Refresh);
|
|
ModifyCommand = new DelegateCommand<object>(DoModify);
|
|
DeleteCommand = new DelegateCommand<object>(DoDelete);
|
|
DownloadCommand = new DelegateCommand(DoDownload);
|
|
ConnectionCommand = new DelegateCommand<object>(DoConnection);
|
|
ReductionCommand = new DelegateCommand(DoReduction);
|
|
StartCommand = new DelegateCommand(DoStart);
|
|
SynchronizationCommand = new DelegateCommand(DoSynchronization);
|
|
SyncCommand = new DelegateCommand<object>(DoSync);
|
|
RefreshSeCommand = new DelegateCommand<object>(DoRefreshSe);
|
|
ClearCommand = new DelegateCommand<object>(DoClear);
|
|
BeginCommand = new DelegateCommand<object>(DoBegin);
|
|
SuspendCommand = new DelegateCommand<object>(DoSuspend);
|
|
SendCommand = new DelegateCommand<object>(DoSend);
|
|
|
|
#region 时序1-5 新增/编辑 删除
|
|
|
|
ModifyS1Command = new DelegateCommand<object>(DoModifyS1);
|
|
DeleteS1Command = new DelegateCommand<object>(DoDeleteS1);
|
|
|
|
ModifyS2Command = new DelegateCommand<object>(DoModifyS2);
|
|
DeleteS2Command = new DelegateCommand<object>(DoDeleteS2);
|
|
|
|
ModifyS3Command = new DelegateCommand<object>(DoModifyS3);
|
|
DeleteS3Command = new DelegateCommand<object>(DoDeleteS3);
|
|
|
|
ModifyS4Command = new DelegateCommand<object>(DoModifyS4);
|
|
DeleteS4Command = new DelegateCommand<object>(DoDeleteS4);
|
|
|
|
ModifyS5Command = new DelegateCommand<object>(DoModifyS5);
|
|
DeleteS5Command = new DelegateCommand<object>(DoDeleteS5);
|
|
#endregion
|
|
}
|
|
|
|
private void DoClose()
|
|
{
|
|
//拿到主区域,从区域里移除对应的页面,根据页面的名称
|
|
var region = _regionManager.Regions["MainRegion"];
|
|
var view = region.Views.Where(v => v.GetType().Name == PageName).FirstOrDefault();
|
|
if (view != null)
|
|
{
|
|
region.Remove(view);
|
|
|
|
}
|
|
}
|
|
public virtual void Refresh() { }
|
|
public virtual void DoModify(object model) { }
|
|
public virtual void DoDelete(object model) { }
|
|
public virtual void DoDownload() { }
|
|
public virtual void DoConnection(object model) { }
|
|
public virtual void DoReduction() { }
|
|
public virtual void DoStart() { }
|
|
public virtual void DoSynchronization() { }
|
|
private string PageName { get; set; }
|
|
public virtual void DoSync(object o) { }
|
|
public virtual void DoRefreshSe(object o) { }
|
|
public virtual void DoClear(object o) { }
|
|
public virtual void DoBegin(object o) { }
|
|
public virtual void DoSuspend(object o) { }
|
|
public virtual void DoSend(object o) { }
|
|
|
|
|
|
#region 时序1-5 新增/编辑 删除
|
|
|
|
public virtual void DoModifyS1(object model) { }
|
|
public virtual void DoDeleteS1(object model) { }
|
|
|
|
|
|
public virtual void DoModifyS2(object model) { }
|
|
public virtual void DoDeleteS2(object model) { }
|
|
|
|
|
|
public virtual void DoModifyS3(object model) { }
|
|
public virtual void DoDeleteS3(object model) { }
|
|
|
|
|
|
public virtual void DoModifyS4(object model) { }
|
|
public virtual void DoDeleteS4(object model) { }
|
|
|
|
|
|
public virtual void DoModifyS5(object model) { }
|
|
public virtual void DoDeleteS5(object model) { }
|
|
#endregion
|
|
|
|
|
|
public void OnNavigatedTo(NavigationContext navigationContext)
|
|
{
|
|
PageName = navigationContext.Uri.ToString();
|
|
}
|
|
|
|
public bool IsNavigationTarget(NavigationContext navigationContext)
|
|
{
|
|
return true;
|
|
}
|
|
|
|
public void OnNavigatedFrom(NavigationContext navigationContext) { }
|
|
}
|
|
}
|