mirror of
https://gitlab.com/fabinfra/fabaccess/borepin.git
synced 2025-04-20 02:16:30 +02:00
Added Wrapper Classes for UI Bindings
This commit is contained in:
parent
8ffb9ef134
commit
b0049f1803
127
Borepin/Borepin/Model/MachineVisualize.cs
Normal file
127
Borepin/Borepin/Model/MachineVisualize.cs
Normal file
@ -0,0 +1,127 @@
|
||||
using FabAccessAPI.Schema;
|
||||
using Prism.Mvvm;
|
||||
using static FabAccessAPI.Schema.Machine;
|
||||
|
||||
namespace Borepin.Model
|
||||
{
|
||||
public class MachineVisualize : BindableBase
|
||||
{
|
||||
#region Private Properties
|
||||
public Machine _Machine { get; private set; }
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
public MachineVisualize(Machine machine)
|
||||
{
|
||||
_Machine = machine;
|
||||
|
||||
LoadData();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
public void LoadData()
|
||||
{
|
||||
ID = _Machine.Id;
|
||||
Space = new SpaceVisualize(_Machine.Space);
|
||||
Name = _Machine.Name;
|
||||
Description = _Machine.Description;
|
||||
State = _Machine.State;
|
||||
Manager = new UserVisualize(_Machine.Manager);
|
||||
|
||||
CanUse = _Machine.Use != null;
|
||||
CanInUse = _Machine.Inuse != null;
|
||||
CanTransfer = _Machine.Transfer != null;
|
||||
CanCheck = _Machine.Check != null;
|
||||
CanManage = _Machine.Manage != null;
|
||||
CanAdmin = _Machine.Admin != null;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
private UUID _ID;
|
||||
public UUID ID
|
||||
{
|
||||
get => _ID;
|
||||
set => SetProperty(ref _ID, value);
|
||||
}
|
||||
|
||||
private SpaceVisualize _Space;
|
||||
public SpaceVisualize Space
|
||||
{
|
||||
get => _Space;
|
||||
set => SetProperty(ref _Space, value);
|
||||
}
|
||||
|
||||
private string _Name;
|
||||
public string Name
|
||||
{
|
||||
get => _Name;
|
||||
set => SetProperty(ref _Name, value);
|
||||
}
|
||||
|
||||
private string _Description;
|
||||
public string Description
|
||||
{
|
||||
get => _Description;
|
||||
set => SetProperty(ref _Description, value);
|
||||
}
|
||||
|
||||
private MachineState _State;
|
||||
public MachineState State
|
||||
{
|
||||
get => _State;
|
||||
set => SetProperty(ref _State, value);
|
||||
}
|
||||
|
||||
private UserVisualize _Manager;
|
||||
public UserVisualize Manager
|
||||
{
|
||||
get => _Manager;
|
||||
set => SetProperty(ref _Manager, value);
|
||||
}
|
||||
|
||||
private bool _CanUse;
|
||||
public bool CanUse
|
||||
{
|
||||
get => _CanUse;
|
||||
set => SetProperty(ref _CanUse, value);
|
||||
}
|
||||
|
||||
private bool _CanInUse;
|
||||
public bool CanInUse
|
||||
{
|
||||
get => _CanInUse;
|
||||
set => SetProperty(ref _CanInUse, value);
|
||||
}
|
||||
|
||||
private bool _CanTransfer;
|
||||
public bool CanTransfer
|
||||
{
|
||||
get => _CanTransfer;
|
||||
set => SetProperty(ref _CanTransfer, value);
|
||||
}
|
||||
|
||||
private bool _CanCheck;
|
||||
public bool CanCheck
|
||||
{
|
||||
get => _CanCheck;
|
||||
set => SetProperty(ref _CanCheck, value);
|
||||
}
|
||||
|
||||
private bool _CanManage;
|
||||
public bool CanManage
|
||||
{
|
||||
get => _CanManage;
|
||||
set => SetProperty(ref _CanManage, value);
|
||||
}
|
||||
|
||||
private bool _CanAdmin;
|
||||
public bool CanAdmin
|
||||
{
|
||||
get => _CanAdmin;
|
||||
set => SetProperty(ref _CanAdmin, value);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
52
Borepin/Borepin/Model/SpaceVisualize.cs
Normal file
52
Borepin/Borepin/Model/SpaceVisualize.cs
Normal file
@ -0,0 +1,52 @@
|
||||
using FabAccessAPI.Schema;
|
||||
using Prism.Mvvm;
|
||||
|
||||
namespace Borepin.Model
|
||||
{
|
||||
public class SpaceVisualize : BindableBase
|
||||
{
|
||||
#region Private Properties
|
||||
public Space _Space { get; private set; }
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
public SpaceVisualize(Space space)
|
||||
{
|
||||
_Space = space;
|
||||
LoadData();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region LoadData
|
||||
public void LoadData()
|
||||
{
|
||||
ID = _Space.Id;
|
||||
Name = _Space.Name;
|
||||
Info = _Space.Info;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
private UUID _ID;
|
||||
public UUID ID
|
||||
{
|
||||
get => _ID;
|
||||
set => SetProperty(ref _ID, value);
|
||||
}
|
||||
|
||||
private string _Name;
|
||||
public string Name
|
||||
{
|
||||
get => _Name;
|
||||
set => SetProperty(ref _Name, value);
|
||||
}
|
||||
|
||||
private string _Info;
|
||||
public string Info
|
||||
{
|
||||
get => _Info;
|
||||
set => SetProperty(ref _Info, value);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
52
Borepin/Borepin/Model/UserVisualize.cs
Normal file
52
Borepin/Borepin/Model/UserVisualize.cs
Normal file
@ -0,0 +1,52 @@
|
||||
using FabAccessAPI.Schema;
|
||||
using Prism.Mvvm;
|
||||
|
||||
namespace Borepin.Model
|
||||
{
|
||||
public class UserVisualize : BindableBase
|
||||
{
|
||||
#region Private Properties
|
||||
public User _User { get; private set; }
|
||||
#endregion
|
||||
|
||||
#region Contructors
|
||||
public UserVisualize(User user)
|
||||
{
|
||||
_User = user;
|
||||
LoadData();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region LoadData
|
||||
public void LoadData()
|
||||
{
|
||||
ID = _User.Id;
|
||||
Username = _User.Username;
|
||||
Space = new SpaceVisualize(_User.Space);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
private UUID _ID;
|
||||
public UUID ID
|
||||
{
|
||||
get => _ID;
|
||||
set => SetProperty(ref _ID, value);
|
||||
}
|
||||
|
||||
private string _Username;
|
||||
public string Username
|
||||
{
|
||||
get => _Username;
|
||||
set => SetProperty(ref _Username, value);
|
||||
}
|
||||
|
||||
private SpaceVisualize _Space;
|
||||
public SpaceVisualize Space
|
||||
{
|
||||
get => _Space;
|
||||
set => SetProperty(ref _Space, value);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
19
Borepin/Borepin/Page/StartUpDistributorPage.xaml
Normal file
19
Borepin/Borepin/Page/StartUpDistributorPage.xaml
Normal file
@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||
xmlns:views="clr-namespace:Borepin.View"
|
||||
x:Class="Borepin.Page.StartUpDistributorPage"
|
||||
xmlns:converters="clr-namespace:Borepin.Converter">
|
||||
<ContentPage.Resources>
|
||||
<ResourceDictionary>
|
||||
<converters:InvertBoolConverter x:Key="InvertBoolConverter"/>
|
||||
</ResourceDictionary>
|
||||
</ContentPage.Resources>
|
||||
<ContentPage.Content>
|
||||
<StackLayout Padding="20">
|
||||
<StackLayout IsVisible="{Binding IsBusy}">
|
||||
<ActivityIndicator IsRunning="{Binding IsBusy}"></ActivityIndicator>
|
||||
</StackLayout>
|
||||
</StackLayout>
|
||||
</ContentPage.Content>
|
||||
</ContentPage>
|
20
Borepin/Borepin/Page/StartUpDistributorPage.xaml.cs
Normal file
20
Borepin/Borepin/Page/StartUpDistributorPage.xaml.cs
Normal file
@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using Xamarin.Forms;
|
||||
using Xamarin.Forms.Xaml;
|
||||
|
||||
namespace Borepin.Page
|
||||
{
|
||||
[XamlCompilation(XamlCompilationOptions.Compile)]
|
||||
public partial class StartUpDistributorPage : ContentPage
|
||||
{
|
||||
public StartUpDistributorPage()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
@ -6,6 +6,7 @@ using System.Windows.Input;
|
||||
using FabAccessAPI.Schema;
|
||||
using Borepin.Service.BFFH;
|
||||
using static FabAccessAPI.Schema.MachineSystem;
|
||||
using Borepin.Model;
|
||||
|
||||
namespace Borepin.PageModel
|
||||
{
|
||||
@ -14,6 +15,7 @@ namespace Borepin.PageModel
|
||||
#region Private Properties
|
||||
private IBFFHService _BFFHService;
|
||||
private UUID _ID;
|
||||
private Machine _Machine;
|
||||
#endregion
|
||||
|
||||
#region Contructors
|
||||
@ -33,15 +35,17 @@ namespace Borepin.PageModel
|
||||
|
||||
IInfoInterface info = await machineSystem.Info();
|
||||
|
||||
MachineItem = (await info.GetMachine(_ID)).Item1;
|
||||
_Machine = (await info.GetMachine(_ID)).Item1;
|
||||
MachineItem = new MachineVisualize(_Machine);
|
||||
MachineItem.LoadData();
|
||||
|
||||
IsBusy = false;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
private Machine _MachineItem;
|
||||
public Machine MachineItem
|
||||
private MachineVisualize _MachineItem;
|
||||
public MachineVisualize MachineItem
|
||||
{
|
||||
get => _MachineItem;
|
||||
set => SetProperty(ref _MachineItem, value);
|
||||
@ -59,7 +63,7 @@ namespace Borepin.PageModel
|
||||
|
||||
private async void UseMachineCommandExecuted()
|
||||
{
|
||||
Machine.IUseInterface useInterface = MachineItem.Use;
|
||||
Machine.IUseInterface useInterface = _Machine.Use;
|
||||
|
||||
await useInterface.Use();
|
||||
}
|
||||
@ -73,7 +77,7 @@ namespace Borepin.PageModel
|
||||
|
||||
private async void GiveBackMachineCommandExecuted()
|
||||
{
|
||||
Machine.IInUseInterface inUseInterface = MachineItem.Inuse;
|
||||
Machine.IInUseInterface inUseInterface = _Machine.Inuse;
|
||||
|
||||
await inUseInterface.GiveBack();
|
||||
}
|
||||
@ -87,7 +91,7 @@ namespace Borepin.PageModel
|
||||
|
||||
public override void OnNavigatedTo(INavigationParameters parameters)
|
||||
{
|
||||
MachineItem = parameters["instance"] as Machine;
|
||||
_ID = parameters["id"] as UUID;
|
||||
|
||||
IsBusy = true;
|
||||
Task.Run(LoadData);
|
||||
|
43
Borepin/Borepin/PageModel/StartUpDistributorPageModel.cs
Normal file
43
Borepin/Borepin/PageModel/StartUpDistributorPageModel.cs
Normal file
@ -0,0 +1,43 @@
|
||||
using Borepin.Base;
|
||||
using Borepin.Service.Connections;
|
||||
using Prism.Navigation;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Borepin.PageModel
|
||||
{
|
||||
public class StartUpDistributorPageModel : PageModelBase
|
||||
{
|
||||
#region Private Properties
|
||||
private readonly IConnectionService _ConnectionService;
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
public StartUpDistributorPageModel(INavigationService navigationService, IConnectionService connectionService) : base(navigationService)
|
||||
{
|
||||
_ConnectionService = connectionService;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Data
|
||||
public override Task LoadData()
|
||||
{
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
#endregion
|
||||
|
||||
#region INavigationAware
|
||||
public override void OnNavigatedFrom(INavigationParameters parameters)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void OnNavigatedTo(INavigationParameters parameters)
|
||||
{
|
||||
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user