Added StartUpDistributerPage

This commit is contained in:
TheJoKlLa 2021-09-20 00:29:51 +02:00
parent d780c7c96b
commit 89660160cf
8 changed files with 86 additions and 44 deletions

View File

@ -26,7 +26,7 @@ namespace Borepin
{ {
InitializeComponent(); InitializeComponent();
Prism.Navigation.INavigationResult result = await NavigationService.NavigateAsync("/MainPage/NavigationPage/SetUpProcess_WelcomePage"); Prism.Navigation.INavigationResult result = await NavigationService.NavigateAsync("/MainPage/NavigationPage/StartUpDistributorPage");
if (!result.Success) if (!result.Success)
{ {
System.Diagnostics.Debugger.Break(); System.Diagnostics.Debugger.Break();
@ -36,6 +36,8 @@ namespace Borepin
protected override void RegisterTypes(IContainerRegistry containerRegistry) protected override void RegisterTypes(IContainerRegistry containerRegistry)
{ {
// Register Navigation // Register Navigation
containerRegistry.RegisterForNavigation<StartUpDistributorPage, StartUpDistributorPageModel>();
containerRegistry.RegisterForNavigation<NavigationPage>(); containerRegistry.RegisterForNavigation<NavigationPage>();
containerRegistry.RegisterForNavigation<MainPage, MainPagePageModel>(); containerRegistry.RegisterForNavigation<MainPage, MainPagePageModel>();
containerRegistry.RegisterForNavigation<MachinePage, MachinePageModel>(); containerRegistry.RegisterForNavigation<MachinePage, MachinePageModel>();
@ -44,7 +46,6 @@ namespace Borepin
containerRegistry.RegisterForNavigation<ServerListPage, ServerListPageModel>(); containerRegistry.RegisterForNavigation<ServerListPage, ServerListPageModel>();
containerRegistry.RegisterForNavigation<ServerPage, ServerPageModel>(); containerRegistry.RegisterForNavigation<ServerPage, ServerPageModel>();
containerRegistry.RegisterForNavigation<ListPage, ListPageModel>(); containerRegistry.RegisterForNavigation<ListPage, ListPageModel>();
containerRegistry.RegisterForNavigation<TestPage, TestPageModel>();
containerRegistry.RegisterForNavigation<WelcomePage, WelcomePageModel>("SetUpProcess_WelcomePage"); containerRegistry.RegisterForNavigation<WelcomePage, WelcomePageModel>("SetUpProcess_WelcomePage");
containerRegistry.RegisterForNavigation<ScanPage, ScanPageModel>("SetUpProcess_ScanPage"); containerRegistry.RegisterForNavigation<ScanPage, ScanPageModel>("SetUpProcess_ScanPage");
@ -53,6 +54,7 @@ namespace Borepin
containerRegistry.RegisterForNavigation<HostSelectPage, HostSelectPageModel>("AddServerProcess_HostSelectPage"); containerRegistry.RegisterForNavigation<HostSelectPage, HostSelectPageModel>("AddServerProcess_HostSelectPage");
containerRegistry.RegisterForNavigation<LoginChoosePage, LoginChoosePageModel>("AddServerProcess_LoginChoosePage"); containerRegistry.RegisterForNavigation<LoginChoosePage, LoginChoosePageModel>("AddServerProcess_LoginChoosePage");
//containerRegistry.RegisterForNavigation<TestPage, TestPageModel>();
// Register Dialog // Register Dialog
containerRegistry.RegisterDialog<ConfirmDialog, ConfirmDialogModel>(); containerRegistry.RegisterDialog<ConfirmDialog, ConfirmDialogModel>();

View File

@ -7,7 +7,7 @@ namespace Borepin.Model
public class MachineVisualize : BindableBase public class MachineVisualize : BindableBase
{ {
#region Private Properties #region Private Properties
public Machine _Machine { get; private set; } public readonly Machine _Machine;
#endregion #endregion
#region Constructors #region Constructors
@ -22,8 +22,8 @@ namespace Borepin.Model
#region Methods #region Methods
public void LoadData() public void LoadData()
{ {
ID = _Machine.Id; //ID = _Machine.Id;
Space = new SpaceVisualize(_Machine.Space); //Space = new SpaceVisualize(_Machine.Space);
Name = _Machine.Name; Name = _Machine.Name;
Description = _Machine.Description; Description = _Machine.Description;
State = _Machine.State; State = _Machine.State;

View File

@ -6,7 +6,7 @@ namespace Borepin.Model
public class SpaceVisualize : BindableBase public class SpaceVisualize : BindableBase
{ {
#region Private Properties #region Private Properties
public Space _Space { get; private set; } public readonly Space _Space;
#endregion #endregion
#region Constructors #region Constructors
@ -20,7 +20,7 @@ namespace Borepin.Model
#region LoadData #region LoadData
public void LoadData() public void LoadData()
{ {
ID = _Space.Id; //ID = _Space.Id;
Name = _Space.Name; Name = _Space.Name;
Info = _Space.Info; Info = _Space.Info;
} }

View File

@ -6,7 +6,7 @@ namespace Borepin.Model
public class UserVisualize : BindableBase public class UserVisualize : BindableBase
{ {
#region Private Properties #region Private Properties
public User _User { get; private set; } public readonly User _User;
#endregion #endregion
#region Contructors #region Contructors
@ -20,9 +20,9 @@ namespace Borepin.Model
#region LoadData #region LoadData
public void LoadData() public void LoadData()
{ {
ID = _User.Id; //ID = _User.Id;
Username = _User.Username; Username = _User.Username;
Space = new SpaceVisualize(_User.Space); //Space = new SpaceVisualize(_User.Space);
} }
#endregion #endregion

View File

@ -4,11 +4,12 @@
x:Class="Borepin.Page.MachinePage" x:Class="Borepin.Page.MachinePage"
xmlns:converters="clr-namespace:Borepin.Converter"> xmlns:converters="clr-namespace:Borepin.Converter">
<NavigationPage.TitleView> <NavigationPage.TitleView>
<Label Text="{Binding Machine.State}" FontAttributes="Bold" HorizontalOptions="End" HorizontalTextAlignment="Center" VerticalTextAlignment="Center" WidthRequest="150" Margin="7.5" VerticalOptions="FillAndExpand" FontSize="Small" BackgroundColor="{StaticResource NinthColor}"/> <Label Text="{Binding MachineItem.State, Converter={StaticResource MachineStateStringConverter}}" FontAttributes="Bold" HorizontalOptions="End" HorizontalTextAlignment="Center" VerticalTextAlignment="Center" WidthRequest="150" Margin="7.5" VerticalOptions="FillAndExpand" FontSize="Small" BackgroundColor="{Binding MachineItem.State, Converter={StaticResource MachineStateColorConverter}}"/>
</NavigationPage.TitleView> </NavigationPage.TitleView>
<ContentPage.Resources> <ContentPage.Resources>
<ResourceDictionary> <ResourceDictionary>
<converters:MachineStateColorConverter x:Key="MachineStateColorConverter"/> <converters:MachineStateColorConverter x:Key="MachineStateColorConverter"/>
<converters:MachineStateStringConverter x:Key="MachineStateStringConverter"/>
<converters:IsNotNullBoolConverter x:Key="IsNotNullBoolConverter"/> <converters:IsNotNullBoolConverter x:Key="IsNotNullBoolConverter"/>
<converters:InvertBoolConverter x:Key="InvertBoolConverter"/> <converters:InvertBoolConverter x:Key="InvertBoolConverter"/>
</ResourceDictionary> </ResourceDictionary>
@ -19,7 +20,7 @@
<ActivityIndicator IsRunning="{Binding IsBusy}"></ActivityIndicator> <ActivityIndicator IsRunning="{Binding IsBusy}"></ActivityIndicator>
</StackLayout> </StackLayout>
<StackLayout IsVisible="{Binding IsBusy, Converter={StaticResource InvertBoolConverter}}"> <StackLayout IsVisible="{Binding IsBusy, Converter={StaticResource InvertBoolConverter}}">
<Label Text="{Binding Name}" Style="{StaticResource LabelStyle_Title}"/> <Label Text="{Binding MachineItem.Name}" Style="{StaticResource LabelStyle_Title}"/>
<Button Text="Use" Command="{Binding UseMachineCommand}" IsVisible="{Binding MachineItem.CanUse}" Style="{StaticResource Style_Button_Primary}"/> <Button Text="Use" Command="{Binding UseMachineCommand}" IsVisible="{Binding MachineItem.CanUse}" Style="{StaticResource Style_Button_Primary}"/>
<Button Text="GiveBack" Command="{Binding GiveBackMachineCommand}" IsVisible="{Binding MachineItem.CanInUse}" Style="{StaticResource Style_Button_Primary}"/> <Button Text="GiveBack" Command="{Binding GiveBackMachineCommand}" IsVisible="{Binding MachineItem.CanInUse}" Style="{StaticResource Style_Button_Primary}"/>

View File

@ -1,7 +1,11 @@
using Borepin.Base; using Borepin.Base;
using Borepin.Model;
using Borepin.Service.Connections; using Borepin.Service.Connections;
using Prism.Commands;
using Prism.Navigation; using Prism.Navigation;
using System.Collections.Generic;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Input;
namespace Borepin.PageModel namespace Borepin.PageModel
{ {
@ -15,16 +19,51 @@ namespace Borepin.PageModel
public StartUpDistributorPageModel(INavigationService navigationService, IConnectionService connectionService) : base(navigationService) public StartUpDistributorPageModel(INavigationService navigationService, IConnectionService connectionService) : base(navigationService)
{ {
_ConnectionService = connectionService; _ConnectionService = connectionService;
DistributePageCommand = new DelegateCommand<string>(DistributePageCommandExecuted);
DistributePageCommand.Execute(null);
} }
#endregion #endregion
#region Data #region LoadData
public override Task LoadData() public override Task LoadData()
{ {
return Task.CompletedTask; return Task.CompletedTask;
} }
#endregion #endregion
#region Command
private ICommand _DistributePageCommand;
public ICommand DistributePageCommand
{
get => _DistributePageCommand;
set => SetProperty(ref _DistributePageCommand, value);
}
private async void DistributePageCommandExecuted(string view)
{
List<Connection> connection_list = await _ConnectionService.GetConnectionList();
if (connection_list.Count == 0)
{
INavigationResult result = await _NavigationService.NavigateAsync("MainPage/NavigationPage/SetUpProcess_WelcomePage");
if (!result.Success)
{
System.Diagnostics.Debugger.Break();
}
}
else
{
INavigationResult result = await _NavigationService.NavigateAsync("MainPage/NavigationPage/ServerListPage");
if (!result.Success)
{
System.Diagnostics.Debugger.Break();
}
}
}
#endregion
#region Properties #region Properties
#endregion #endregion

View File

@ -1,28 +1,37 @@
using Borepin.Model; using Prism.Mvvm;
using Prism.Mvvm; using FabAccessAPI.Schema;
namespace Borepin.ViewModel namespace Borepin.ViewModel
{ {
public class ServerListItemViewModel : BindableBase public class MachineListItemViewModel : BindableBase
{ {
public ServerListItemViewModel(Connection instance) public MachineListItemViewModel(Machine instance)
{ {
_Instance = instance; _Instance = instance;
Address = instance.Address.ToString();
Name = instance.Name;
State = instance.State;
} }
private Connection _Instance; private Machine _Instance;
public Connection Instance public Machine Instance
{ {
get => _Instance; get => _Instance;
set => SetProperty(ref _Instance, value); set => SetProperty(ref _Instance, value);
} }
private string _Address; private string _Name;
public string Address public string Name
{ {
get => _Address; get => _Name;
set => SetProperty(ref _Address, value); set => SetProperty(ref _Name, value);
}
private Machine.MachineState _State;
public Machine.MachineState State
{
get => _State;
set => SetProperty(ref _State, value);
} }
} }
} }

View File

@ -1,37 +1,28 @@
using Prism.Mvvm; using Borepin.Model;
using FabAccessAPI.Schema; using Prism.Mvvm;
namespace Borepin.ViewModel namespace Borepin.ViewModel
{ {
public class MachineListItemViewModel : BindableBase public class ServerListItemViewModel : BindableBase
{ {
public MachineListItemViewModel(Machine instance) public ServerListItemViewModel(Connection instance)
{ {
_Instance = instance; _Instance = instance;
Address = instance.Address.ToString();
Name = instance.Name;
State = instance.State;
} }
private Machine _Instance; private Connection _Instance;
public Machine Instance public Connection Instance
{ {
get => _Instance; get => _Instance;
set => SetProperty(ref _Instance, value); set => SetProperty(ref _Instance, value);
} }
private string _Name; private string _Address;
public string Name public string Address
{ {
get => _Name; get => _Address;
set => SetProperty(ref _Name, value); set => SetProperty(ref _Address, value);
}
private Machine.MachineState _State;
public Machine.MachineState State
{
get => _State;
set => SetProperty(ref _State, value);
} }
} }
} }