首次提交:添加src文件夹代码
This commit is contained in:
108
Cowain.Bake.UI/ProductManagement/ViewModels/DBLogViewModel.cs
Normal file
108
Cowain.Bake.UI/ProductManagement/ViewModels/DBLogViewModel.cs
Normal file
@@ -0,0 +1,108 @@
|
||||
using Cowain.Bake.BLL;
|
||||
using Cowain.Bake.Common;
|
||||
using Cowain.Bake.Common.Core;
|
||||
using Cowain.Bake.Common.Enums;
|
||||
using Cowain.Bake.Model;
|
||||
using HandyControl.Controls;
|
||||
using Prism.Commands;
|
||||
using Prism.Regions;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Unity;
|
||||
|
||||
namespace Cowain.Bake.UI.ProductManagement.ViewModels
|
||||
{
|
||||
public class DBLogViewModel: ViewModelBase
|
||||
{
|
||||
public DBLogViewModel(IUnityContainer unityContainer, IRegionManager regionManager) : base(unityContainer, regionManager)
|
||||
{
|
||||
this.PageTitle = "日志查询";
|
||||
SetCombox();
|
||||
}
|
||||
private ObservableCollection<TLog> logList;
|
||||
public ObservableCollection<TLog> LogList
|
||||
{
|
||||
get => logList ?? (logList = new ObservableCollection<TLog>());
|
||||
set { SetProperty(ref logList, value); }
|
||||
}
|
||||
private DateTime _startTime = DateTime.Now.AddHours(-4);
|
||||
public DateTime StartDatetime
|
||||
{
|
||||
get { return _startTime; }
|
||||
set { SetProperty(ref _startTime, DateTime.Parse(value.ToString("yyyy-MM-dd HH:mm:ss"))); }
|
||||
}
|
||||
|
||||
private DateTime _endTime = DateTime.Now.AddHours(4);
|
||||
public DateTime EndDatetime
|
||||
{
|
||||
get { return _endTime; }
|
||||
set { SetProperty(ref _endTime, DateTime.Parse(value.ToString("yyyy-MM-dd HH:mm:ss"))); }
|
||||
}
|
||||
private string _logText=string.Empty;
|
||||
public string LogText
|
||||
{
|
||||
get { return _logText; }
|
||||
set { SetProperty(ref _logText, value); }
|
||||
}
|
||||
|
||||
public string selectLogLevel;
|
||||
public string SelectLogLevel
|
||||
{
|
||||
get => selectLogLevel;
|
||||
set => SetProperty(ref selectLogLevel, value);
|
||||
}
|
||||
|
||||
private List<string> listLogLevel;
|
||||
public List<string> ListLogLevel
|
||||
{
|
||||
get => listLogLevel;
|
||||
set => SetProperty(ref listLogLevel, value);
|
||||
}
|
||||
|
||||
private void SetCombox()
|
||||
{
|
||||
ListLogLevel = new List<string>();
|
||||
|
||||
foreach (E_LogType level in System.Enum.GetValues(typeof(E_LogType)))
|
||||
{
|
||||
ListLogLevel.Add(level.GetDescription());
|
||||
}
|
||||
|
||||
SelectLogLevel = E_LogType.Operate.GetDescription();
|
||||
}
|
||||
|
||||
public DelegateCommand<object> QueryCommand => new DelegateCommand<object>((x) =>
|
||||
{
|
||||
logList.Clear();
|
||||
E_LogType logType = EnumHelper.GetValueByDescription<E_LogType>(SelectLogLevel);
|
||||
//var list = EnumHelper.GetEnumList<E_LogType>().Where(item => item.EnumDesc == SelectLogLevel);
|
||||
//string level = list.FirstOrDefault().EnumString;
|
||||
var logService = _unityContainer.Resolve<LogService>();
|
||||
List<Model.TLog> logListTemporary;
|
||||
//if (string.IsNullOrEmpty(level))
|
||||
//{
|
||||
// //logListTemporary = logService.QueryByTime(StartDatetime, EndDatetime);
|
||||
// LogHelper.Instance.Warn("日志级别不能为空",null, true);
|
||||
// return;
|
||||
//}
|
||||
//else
|
||||
{
|
||||
logListTemporary = logService.QueryByTimeAndText(StartDatetime, EndDatetime, logType);
|
||||
}
|
||||
if (logListTemporary.Count != 0)
|
||||
{
|
||||
logListTemporary.ForEach(item => logList.Add(item));
|
||||
Growl.Success("查询完成!");
|
||||
}
|
||||
else
|
||||
{
|
||||
Growl.Success("没有数据!");
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
//using GalaSoft.MvvmLight.Command;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Unity;
|
||||
using Cowain.Bake.Model;
|
||||
using System.Collections.ObjectModel;
|
||||
using Cowain.Bake.BLL;
|
||||
using Prism.Commands;
|
||||
|
||||
namespace Cowain.Bake.UI.ProductManagement.ViewModels
|
||||
{
|
||||
public class DisableStoveViewModel
|
||||
{
|
||||
private IUnityContainer _unityContainer;
|
||||
//public RelayCommand SaveCommand { get; set; }
|
||||
public DisableStoveViewModel(IUnityContainer unityContainer)
|
||||
{
|
||||
_unityContainer = unityContainer;
|
||||
DisplayInfo();
|
||||
}
|
||||
public ObservableCollection<TStation> MachineList { get; set; } = new ObservableCollection<TStation>();
|
||||
public DelegateCommand<object> SaveCommand => new DelegateCommand<object>((x) =>
|
||||
{
|
||||
foreach (var item in MachineList)
|
||||
{
|
||||
_unityContainer.Resolve<StationService>().UpdateEnableStatus(item);
|
||||
}
|
||||
Common.Core.CommonCoreHelper.Instance.MainViewAutoEvent.Set();
|
||||
HandyControl.Controls.Growl.Success("保存成功!");
|
||||
});
|
||||
private void DisplayInfo()
|
||||
{
|
||||
_unityContainer.Resolve<StationService>().GetAll().ForEach(item => MachineList.Add(item));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
using Cowain.Bake.BLL;
|
||||
using Cowain.Bake.Common;
|
||||
using Cowain.Bake.Common.Core;
|
||||
using Cowain.Bake.Common.Enums;
|
||||
using Cowain.Bake.Model;
|
||||
using Prism.Commands;
|
||||
using Prism.Regions;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using Unity;
|
||||
|
||||
namespace Cowain.Bake.UI.ProductManagement.ViewModels
|
||||
{
|
||||
public class EleTableViewModel : ViewModelBase
|
||||
{
|
||||
public string selectStationId;
|
||||
public string SelectStationId
|
||||
{
|
||||
get => selectStationId;
|
||||
set => SetProperty(ref selectStationId, value);
|
||||
}
|
||||
|
||||
private List<string> listStationId;
|
||||
public List<string> ListStationId
|
||||
{
|
||||
get => listStationId;
|
||||
set => SetProperty(ref listStationId, value);
|
||||
}
|
||||
|
||||
private ObservableCollection<TElectricEnergy> eleList;
|
||||
public ObservableCollection<TElectricEnergy> EellList
|
||||
{
|
||||
get => eleList ?? (eleList = new ObservableCollection<TElectricEnergy>());
|
||||
set { SetProperty(ref eleList, value); }
|
||||
}
|
||||
//IUnityContainer _unityContainer ;
|
||||
List<TElectricEnergy> queryData = null;
|
||||
List<TStation> _stations = null;
|
||||
public EleTableViewModel(IUnityContainer unityContainer, IRegionManager regionManager) : base(unityContainer, regionManager)
|
||||
{
|
||||
_unityContainer = unityContainer;
|
||||
_stations = _unityContainer.Resolve<StationService>().GetStationsByType((int)EStationType.Stove);
|
||||
this.PageTitle = "电表查询";
|
||||
SetCombox();
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void SetCombox()
|
||||
{
|
||||
ListStationId = new List<string>();
|
||||
|
||||
foreach (var station in _stations)
|
||||
{
|
||||
ListStationId.Add(station.Desc);
|
||||
}
|
||||
|
||||
selectStationId = ListStationId[0];
|
||||
}
|
||||
|
||||
public DelegateCommand<object> QueryCommand => new DelegateCommand<object>((x) =>
|
||||
{
|
||||
EellList.Clear();
|
||||
var station = _stations.Where(s=>s.Desc == selectStationId).FirstOrDefault();
|
||||
queryData = _unityContainer.Resolve<ElectricEnergyService>().Query(station.Id, StartTime, EndTime);
|
||||
if (0 == queryData.Count)
|
||||
{
|
||||
HandyControl.Controls.MessageBox.Warning("查询数据为空!");
|
||||
return;
|
||||
}
|
||||
queryData.ForEach(item => EellList.Add(item));
|
||||
});
|
||||
|
||||
public DelegateCommand<object> ExportCommand => new DelegateCommand<object>((x) =>
|
||||
{
|
||||
if (0 == queryData.Count)
|
||||
{
|
||||
HandyControl.Controls.MessageBox.Warning("数据为空,请先查询数据!");
|
||||
return;
|
||||
}
|
||||
|
||||
CSVHelper.WriteDataTableToCsv(queryData, new List<string>() { "序号", "烤箱编号", "A相电流" , "B相电流", "C相电流","A相电压", "B相电压", "C相电压", "电能","创建时间" });
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,158 @@
|
||||
using Cowain.Bake.Common;
|
||||
using Cowain.Bake.Common.Core;
|
||||
using Cowain.Bake.Common.Enums;
|
||||
using Cowain.Bake.BLL;
|
||||
using Cowain.Bake.Model;
|
||||
using HandyControl.Controls;
|
||||
using Prism.Commands;
|
||||
using Prism.Mvvm;
|
||||
using Prism.Regions;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Unity;
|
||||
|
||||
namespace Cowain.Bake.UI.ProductManagement.ViewModels
|
||||
{
|
||||
public class TaskMaintainViewModel : ViewModelBase //BindableBase
|
||||
{
|
||||
private string _title;
|
||||
public string Title
|
||||
{
|
||||
get { return _title; }
|
||||
set { SetProperty(ref _title, value); }
|
||||
}
|
||||
|
||||
private TTaskType selectTask;
|
||||
public TTaskType SelectTask
|
||||
{
|
||||
get => selectTask ?? (selectTask = new TTaskType());
|
||||
set
|
||||
{
|
||||
SetProperty(ref selectTask, value);
|
||||
}
|
||||
}
|
||||
|
||||
private TTaskType _editTask;
|
||||
public TTaskType EditTask
|
||||
{
|
||||
get => _editTask ?? (_editTask = new TTaskType());
|
||||
set
|
||||
{
|
||||
SetProperty(ref _editTask, value);
|
||||
}
|
||||
}
|
||||
|
||||
private ObservableCollection<TTaskType> _taskList;
|
||||
public ObservableCollection<TTaskType> TaskList
|
||||
{
|
||||
//get { return _taskList; }
|
||||
get => _taskList ?? (_taskList = new ObservableCollection<TTaskType>());
|
||||
set { SetProperty(ref _taskList, value); }
|
||||
}
|
||||
|
||||
private List<string> machineList;
|
||||
public List<string> MachineList
|
||||
{
|
||||
get => machineList ?? (machineList = new List<string>());
|
||||
set { SetProperty(ref machineList, value); }
|
||||
}
|
||||
|
||||
private List<string> _palletStatusList;
|
||||
public List<string> PalletStatusList
|
||||
{
|
||||
get => _palletStatusList ?? (_palletStatusList = new List<string>());
|
||||
set { SetProperty(ref _palletStatusList, value); }
|
||||
}
|
||||
|
||||
|
||||
public TaskMaintainViewModel(IUnityContainer unityContainer, IRegionManager regionManager) : base(unityContainer, regionManager)
|
||||
{
|
||||
_taskList = new ObservableCollection<TTaskType>();
|
||||
_unityContainer = unityContainer;
|
||||
_regionManager = regionManager;
|
||||
PalletStatusList = EPalletStatus.Loading.GetListDesc();
|
||||
MachineList = EnumHelper.GetDescriptions<EStationType>();
|
||||
Refresh();
|
||||
}
|
||||
|
||||
public DelegateCommand EnableCommand => new DelegateCommand(() =>
|
||||
{
|
||||
if (SelectTask != null && SelectTask.Id > 0)
|
||||
{
|
||||
var tServices = _unityContainer.Resolve<TaskTypeService>();
|
||||
|
||||
var res = tServices.UpdateEnableTask(SelectTask.Id, !SelectTask.Enable);
|
||||
if (res > 0)
|
||||
{
|
||||
Growl.Success("是否启用任务修改完成!");
|
||||
Refresh();
|
||||
}
|
||||
else
|
||||
{
|
||||
Growl.Fatal("是否启用任务失败!");
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
public DelegateCommand SelectCommand => new DelegateCommand(() =>
|
||||
{
|
||||
if (SelectTask != null && SelectTask.Id > 0)
|
||||
{
|
||||
//深拷贝
|
||||
EditTask = BasicFramework.DeepCopy<TTaskType>(SelectTask);
|
||||
}
|
||||
});
|
||||
|
||||
public DelegateCommand AddCommand => new DelegateCommand(() =>
|
||||
{
|
||||
var result = HandyControl.Controls.MessageBox.Ask($@"是否确定要添加任务?", "操作提示");
|
||||
if (result == System.Windows.MessageBoxResult.Cancel)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var res = _unityContainer.Resolve<TaskTypeService>().AddTaskConfig(EditTask);
|
||||
if (res > 0)
|
||||
{
|
||||
Growl.Success("任务添加完成!");
|
||||
Refresh();
|
||||
}
|
||||
else
|
||||
{
|
||||
Growl.Fatal("任务添加失败!");
|
||||
}
|
||||
});
|
||||
|
||||
public DelegateCommand EditCommand => new DelegateCommand(() =>
|
||||
{
|
||||
var result = HandyControl.Controls.MessageBox.Ask($@"是否确定要修改任务?", "操作提示");
|
||||
if (result == System.Windows.MessageBoxResult.Cancel)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var res = _unityContainer.Resolve<TaskTypeService>().EditTaskConfig(EditTask);
|
||||
if (res > 0)
|
||||
{
|
||||
Growl.Success("任务修改完成!");
|
||||
Refresh();
|
||||
}
|
||||
else
|
||||
{
|
||||
Growl.Fatal("任务修改失败,优先级不存在!");
|
||||
}
|
||||
});
|
||||
|
||||
public override void Refresh()
|
||||
{
|
||||
TaskList.Clear();
|
||||
List<TTaskType> list = _unityContainer.Resolve<TaskTypeService>().GetAll();
|
||||
list.ForEach(p => TaskList.Add(p));
|
||||
}
|
||||
}
|
||||
}
|
||||
215
Cowain.Bake.UI/ProductManagement/ViewModels/TaskViewModel.cs
Normal file
215
Cowain.Bake.UI/ProductManagement/ViewModels/TaskViewModel.cs
Normal file
@@ -0,0 +1,215 @@
|
||||
using Cowain.Bake.BLL;
|
||||
using Cowain.Bake.Common;
|
||||
using Cowain.Bake.Common.Core;
|
||||
using Cowain.Bake.Common.Enums;
|
||||
using Cowain.Bake.Common.Interface;
|
||||
using Cowain.Bake.Model;
|
||||
using HandyControl.Controls;
|
||||
using Prism.Commands;
|
||||
using Prism.Regions;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using Unity;
|
||||
|
||||
namespace Cowain.Bake.UI.ProductManagement.ViewModels
|
||||
{
|
||||
public class TaskViewModel: ViewModelBase, INavigationAware
|
||||
{
|
||||
//
|
||||
private DateTime _startTime = DateTime.Now.AddHours(-4);
|
||||
public new DateTime StartTime
|
||||
{
|
||||
get { return _startTime; }
|
||||
set { SetProperty(ref _startTime, value); }
|
||||
}
|
||||
|
||||
private DateTime _endTime = DateTime.Now.AddHours(10);
|
||||
public new DateTime EndTime
|
||||
{
|
||||
get { return _endTime; }
|
||||
set { SetProperty(ref _endTime, value); }
|
||||
}
|
||||
|
||||
private ObservableCollection<TTaskRecord> _taskList;
|
||||
public ObservableCollection<TTaskRecord> TaskList
|
||||
{
|
||||
get => _taskList ?? (_taskList = new ObservableCollection<TTaskRecord>());
|
||||
set { SetProperty(ref _taskList, value); }
|
||||
}
|
||||
|
||||
private ObservableCollection<TTaskStep> _taskStepList;
|
||||
public ObservableCollection<TTaskStep> TaskStepList
|
||||
{
|
||||
get => _taskStepList ?? (_taskStepList = new ObservableCollection<TTaskStep>());
|
||||
set { SetProperty(ref _taskStepList, value); }
|
||||
}
|
||||
private TTaskStep _selectTaskStep;
|
||||
public TTaskStep SelectTaskStep
|
||||
{
|
||||
get => _selectTaskStep ?? (_selectTaskStep = new TTaskStep());
|
||||
set
|
||||
{
|
||||
SetProperty(ref _selectTaskStep, value);
|
||||
}
|
||||
}
|
||||
|
||||
private TTaskRecord _selectTaskRecord;
|
||||
public TTaskRecord SelectTaskRecord
|
||||
{
|
||||
get => _selectTaskRecord ?? (_selectTaskRecord = new TTaskRecord());
|
||||
set
|
||||
{
|
||||
SetProperty(ref _selectTaskRecord, value);
|
||||
}
|
||||
}
|
||||
//public Dictionary<int, string> SexDict { get; } = new Dictionary<int, string>();
|
||||
public TaskViewModel(IUnityContainer unityContainer, IRegionManager regionManager) : base(unityContainer, regionManager)
|
||||
{
|
||||
this.PageTitle = "调度记录";
|
||||
|
||||
//var models =_unityContainer.Resolve<RgvActionService>().GetAll();
|
||||
//foreach(var item in models)
|
||||
//{
|
||||
// SexDict.Add(item.Cmd, item.Desc);
|
||||
//}
|
||||
}
|
||||
public DelegateCommand SelectCommand => new DelegateCommand(() =>
|
||||
{
|
||||
if (SelectTaskRecord != null && SelectTaskRecord.Id > 0)
|
||||
{
|
||||
TaskStepList.Clear();
|
||||
var models = _unityContainer.Resolve<TaskStepService>().GetTaskAllStep(SelectTaskRecord.Id);
|
||||
models.ForEach(item => TaskStepList.Add(item));
|
||||
}
|
||||
});
|
||||
|
||||
public DelegateCommand SendCommand => new DelegateCommand(() =>
|
||||
{
|
||||
if (null == SelectTaskRecord
|
||||
|| 0 == SelectTaskRecord.Id
|
||||
|| 0 == SelectTaskRecord.Target)
|
||||
{
|
||||
HandyControl.Controls.MessageBox.Info("请选择任务!", "提示");
|
||||
return;
|
||||
}
|
||||
|
||||
if ((int)ETaskStatus.ExecutionCompleted == SelectTaskRecord.Status)
|
||||
{
|
||||
HandyControl.Controls.MessageBox.Warning("已经完成的任务不能再发送!", "警告");
|
||||
return;
|
||||
}
|
||||
|
||||
if (SelectTaskStep != null)
|
||||
{
|
||||
if ((ETaskStep)SelectTaskStep.StepId == ETaskStep.None
|
||||
|| (ETaskStep)SelectTaskStep.StepId == ETaskStep.Unexecuted
|
||||
|| (ETaskStep)SelectTaskStep.StepId == ETaskStep.Finish)
|
||||
{
|
||||
HandyControl.Controls.MessageBox.Warning("请选择任务步骤!");
|
||||
return;
|
||||
}
|
||||
|
||||
if (System.Windows.MessageBoxResult.OK ==
|
||||
HandyControl.Controls.MessageBox.Ask($"你确定重新发送【{((ETaskStep)SelectTaskStep.StepId).GetDescription()}】指令到PLC?", "发送指令"))
|
||||
{
|
||||
if(_unityContainer.Resolve<ICommonFun>().ManualTaskCmd(SelectTaskRecord, (short)SelectTaskStep.StepId))
|
||||
{
|
||||
HandyControl.Controls.MessageBox.Info("发送成功");
|
||||
}
|
||||
else
|
||||
{
|
||||
HandyControl.Controls.MessageBox.Fatal("发送失败,请重新发送!","警示");
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
public async override void Refresh()
|
||||
{
|
||||
TaskList.Clear();
|
||||
|
||||
var listTask = await System.Threading.Tasks.Task.Run(() =>
|
||||
{
|
||||
//从数据库查询任务
|
||||
return _unityContainer.Resolve<TaskRecordService>().GetAllTaskRun();
|
||||
});
|
||||
listTask = UpdetaListStatus(listTask);
|
||||
listTask.ForEach(x => TaskList.Add(x));
|
||||
}
|
||||
|
||||
public DelegateCommand<object> QueryCommand => new DelegateCommand<object>((x) =>
|
||||
{
|
||||
TaskList.Clear();
|
||||
var queryTask = _unityContainer.Resolve<TaskRecordService>().Query(StartTime, EndTime);
|
||||
|
||||
if (0 != queryTask.Count)
|
||||
{
|
||||
queryTask = UpdetaListStatus(queryTask);
|
||||
queryTask.ForEach(item => TaskList.Add(item));
|
||||
Growl.Success("查询完成!");
|
||||
}
|
||||
else
|
||||
{
|
||||
Growl.Success("没有数据!");
|
||||
}
|
||||
});
|
||||
public List<TTaskRecord> UpdetaListStatus(List<TTaskRecord> taskRunList)
|
||||
{
|
||||
foreach (var item in taskRunList)
|
||||
{
|
||||
if (item.Status != (int)ETaskStatus.ExecutionCompleted)
|
||||
{
|
||||
item.Status = (int)ETaskStatus.None;
|
||||
}
|
||||
}
|
||||
return taskRunList;
|
||||
}
|
||||
public DelegateCommand<object> DeleteCommand => new DelegateCommand<object>((x) =>
|
||||
{
|
||||
var result = HandyControl.Controls.MessageBox.Ask($@"是否确定要删除任务?", "操作提示");
|
||||
if (result == System.Windows.MessageBoxResult.Cancel)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var taskService = _unityContainer.Resolve<TaskRecordService>();
|
||||
var task = x as TTaskRecord;
|
||||
if (task != null)
|
||||
{
|
||||
int delCount = taskService.DeleteTask(task.Id);
|
||||
if (delCount > 0)
|
||||
{
|
||||
//如果是未执行完成的任务,要清除主界面
|
||||
if (task.Status != (int)ETaskStatus.ExecutionCompleted)
|
||||
{
|
||||
task.StepId = (int)ETaskStep.None;
|
||||
CommonCoreHelper.Instance.BlockTask.Add(task);
|
||||
}
|
||||
|
||||
LogHelper.Instance.Debug($"删除了一条任务,取盘位置{task.Source},放盘位置{task.Target},托盘ID{task.PalletId}");
|
||||
Growl.Success("任务删除完成!");
|
||||
this.Refresh();
|
||||
}
|
||||
else
|
||||
{
|
||||
Growl.Success("任务删除失败!");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
void INavigationAware.OnNavigatedTo(NavigationContext navigationContext)
|
||||
{
|
||||
// 导航到当前页面时的处理逻辑,先执行构造方法,再执行本方法
|
||||
}
|
||||
|
||||
bool INavigationAware.IsNavigationTarget(NavigationContext navigationContext)
|
||||
{
|
||||
return false; //false:表示每次导航都创建新实例,不重用旧实例; true:用旧实例,不会执行构造方法
|
||||
}
|
||||
|
||||
void INavigationAware.OnNavigatedFrom(NavigationContext navigationContext)
|
||||
{
|
||||
//相当于析构方法,退出时(切换时)再执行。
|
||||
// 在这里添加释放旧视图实例资源的代码
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user