borepin/Borepin/Borepin/PageModel/MachinePageModel.cs

116 lines
3.0 KiB
C#
Raw Normal View History

2021-03-30 13:33:58 +02:00
using Borepin.Base;
using Borepin.Model;
2021-02-09 15:25:22 +01:00
using Prism.Commands;
2020-11-13 23:11:27 +01:00
using Prism.Navigation;
2021-03-30 13:33:58 +02:00
using System.Threading.Tasks;
2020-11-13 23:11:27 +01:00
using System.Windows.Input;
namespace Borepin.PageModel
{
2021-03-30 13:33:58 +02:00
public class MachinePageModel : PageModelBase
2020-11-13 23:11:27 +01:00
{
2021-03-30 13:33:58 +02:00
#region Contructors
public MachinePageModel(INavigationService navigationService) : base(navigationService)
2020-11-13 23:11:27 +01:00
{
2021-02-09 15:25:22 +01:00
UseMachineCommand = new DelegateCommand(UseMachineCommandExecuted);
GiveBackMachineCommand = new DelegateCommand(GiveBackMachineCommandExecuted);
2020-11-13 23:11:27 +01:00
}
2021-03-30 13:33:58 +02:00
#endregion
2020-11-13 23:11:27 +01:00
2021-03-30 13:33:58 +02:00
#region Data
2021-03-31 23:32:03 +02:00
public override Task LoadData()
2021-03-30 13:33:58 +02:00
{
2021-09-11 13:53:40 +02:00
//Name = MachineItem.MInfo.Name;
2021-02-09 15:25:22 +01:00
2021-03-30 13:33:58 +02:00
IsBusy = false;
2021-03-31 23:32:03 +02:00
return Task.CompletedTask;
2021-03-30 13:33:58 +02:00
}
2021-03-31 23:32:03 +02:00
2021-03-30 13:33:58 +02:00
#endregion
#region Properties
2021-09-11 13:53:40 +02:00
//private Machine _MachineItem;
//public Machine MachineItem
//{
// get => _MachineItem;
// set => SetProperty(ref _MachineItem, value);
//}
2020-11-17 23:40:33 +01:00
2021-02-09 15:25:22 +01:00
private string _Name;
public string Name
2020-11-17 23:40:33 +01:00
{
2021-02-09 15:25:22 +01:00
get => _Name;
set => SetProperty(ref _Name, value);
2020-11-17 23:40:33 +01:00
}
2021-02-09 15:25:22 +01:00
private bool _CanUse;
public bool CanUse
2020-11-17 23:40:33 +01:00
{
2021-02-09 15:25:22 +01:00
get => _CanUse;
set => SetProperty(ref _CanUse, value);
2020-11-17 23:40:33 +01:00
}
2021-02-09 15:25:22 +01:00
private bool _CanGiveBack;
public bool CanGiveBack
2020-11-17 23:40:33 +01:00
{
2021-02-09 15:25:22 +01:00
get => _CanGiveBack;
set => SetProperty(ref _CanGiveBack, value);
2020-11-17 23:40:33 +01:00
}
2021-02-09 15:25:22 +01:00
#endregion
2020-11-17 23:40:33 +01:00
2021-02-09 15:25:22 +01:00
#region Commands
2020-11-17 23:40:33 +01:00
private ICommand _UseMachineCommand;
public ICommand UseMachineCommand
{
get => _UseMachineCommand;
set => SetProperty(ref _UseMachineCommand, value);
}
2021-02-09 15:25:22 +01:00
private async void UseMachineCommandExecuted()
2020-11-17 23:40:33 +01:00
{
2021-09-11 13:53:40 +02:00
//GiveBack = await MachineItem.Instance.Use();
//CanGiveBack = GiveBack != null;
2021-02-09 15:25:22 +01:00
2021-09-11 13:53:40 +02:00
//MachineItem.MInfo = await MachineItem.Instance.GetMInfo();
2021-02-09 15:25:22 +01:00
2021-09-11 13:53:40 +02:00
//CanUse = MachineItem.MInfo.State == FabAccessAPI.Schema.Machine.MachineState.free;
2020-11-17 23:40:33 +01:00
}
private ICommand _GiveBackMachineCommand;
public ICommand GiveBackMachineCommand
{
get => _GiveBackMachineCommand;
set => SetProperty(ref _GiveBackMachineCommand, value);
}
2021-02-09 15:25:22 +01:00
private async void GiveBackMachineCommandExecuted()
2020-11-17 23:40:33 +01:00
{
2021-09-11 13:53:40 +02:00
//await GiveBack.Ret();
2020-11-17 23:40:33 +01:00
2021-09-11 13:53:40 +02:00
//GiveBack = null;
//CanGiveBack = GiveBack != null;
2020-11-17 23:40:33 +01:00
2021-09-11 13:53:40 +02:00
//MachineItem.MInfo = await MachineItem.Instance.GetMInfo();
2020-11-17 23:40:33 +01:00
2021-09-11 13:53:40 +02:00
//CanUse = MachineItem.MInfo.State == FabAccessAPI.Schema.Machine.MachineState.free;
2020-11-17 23:40:33 +01:00
}
2021-02-09 15:25:22 +01:00
#endregion
2020-11-17 23:40:33 +01:00
2021-03-30 13:33:58 +02:00
#region INavigationService
public override void OnNavigatedFrom(INavigationParameters parameters)
2020-11-17 23:40:33 +01:00
{
}
2021-03-30 13:33:58 +02:00
public override void OnNavigatedTo(INavigationParameters parameters)
2020-11-17 23:40:33 +01:00
{
2021-09-11 13:53:40 +02:00
//MachineItem = parameters["instance"] as Machine;
2021-02-09 15:25:22 +01:00
2021-03-30 13:33:58 +02:00
IsBusy = true;
Task.Run(LoadData);
2020-11-17 23:40:33 +01:00
}
2021-02-09 15:25:22 +01:00
#endregion
2020-11-13 23:11:27 +01:00
}
}