mirror of
https://gitlab.com/fabinfra/fabaccess/borepin.git
synced 2025-03-13 15:21:45 +01:00
Added: MachineListPage
This commit is contained in:
parent
9bee54f312
commit
6b38fc9d89
@ -50,9 +50,9 @@ namespace Borepin
|
|||||||
// Register Navigation
|
// Register Navigation
|
||||||
containerRegistry.RegisterForNavigation<NavigationPage>();
|
containerRegistry.RegisterForNavigation<NavigationPage>();
|
||||||
containerRegistry.RegisterForNavigation<MainPage, MainPagePageModel>();
|
containerRegistry.RegisterForNavigation<MainPage, MainPagePageModel>();
|
||||||
containerRegistry.RegisterForNavigation<MachinesPage, MachinesPageModel>();
|
|
||||||
containerRegistry.RegisterForNavigation<SettingsPage>();
|
|
||||||
containerRegistry.RegisterForNavigation<MachinePage, MachinePageModel>();
|
containerRegistry.RegisterForNavigation<MachinePage, MachinePageModel>();
|
||||||
|
containerRegistry.RegisterForNavigation<SettingsPage>();
|
||||||
|
containerRegistry.RegisterForNavigation<MachineListPage, MachineListPageModel>();
|
||||||
containerRegistry.RegisterForNavigation<LoginPasswordPage, LoginPasswordPageModel>();
|
containerRegistry.RegisterForNavigation<LoginPasswordPage, LoginPasswordPageModel>();
|
||||||
containerRegistry.RegisterForNavigation<HostSelectPage, HostSelectPageModel>();
|
containerRegistry.RegisterForNavigation<HostSelectPage, HostSelectPageModel>();
|
||||||
containerRegistry.RegisterForNavigation<LoginChoosePage, LoginChoosePageModel>();
|
containerRegistry.RegisterForNavigation<LoginChoosePage, LoginChoosePageModel>();
|
||||||
|
@ -28,8 +28,8 @@
|
|||||||
<PackageReference Include="Xamarin.Forms.EntryAutoComplete" Version="1.0.0" />
|
<PackageReference Include="Xamarin.Forms.EntryAutoComplete" Version="1.0.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Update="Page\MachinesPage.xaml.cs">
|
<Compile Update="Page\MachineListPage.xaml.cs">
|
||||||
<DependentUpon>MachinesPage.xaml</DependentUpon>
|
<DependentUpon>MachineListPage.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Update="Page\SettingsPage.xaml.cs">
|
<Compile Update="Page\SettingsPage.xaml.cs">
|
||||||
<DependentUpon>SettingsPage.xaml</DependentUpon>
|
<DependentUpon>SettingsPage.xaml</DependentUpon>
|
||||||
@ -47,6 +47,9 @@
|
|||||||
<Compile Update="Styles\LightTheme.xaml.cs">
|
<Compile Update="Styles\LightTheme.xaml.cs">
|
||||||
<DependentUpon>LightTheme.xaml</DependentUpon>
|
<DependentUpon>LightTheme.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Update="View\MachineListItemView.xaml.cs">
|
||||||
|
<DependentUpon>MachineListItemView.xaml</DependentUpon>
|
||||||
|
</Compile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<EmbeddedResource Update="Dialog\ConfirmDialog.xaml">
|
<EmbeddedResource Update="Dialog\ConfirmDialog.xaml">
|
||||||
@ -67,9 +70,6 @@
|
|||||||
<EmbeddedResource Update="Page\MachinePage.xaml">
|
<EmbeddedResource Update="Page\MachinePage.xaml">
|
||||||
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
|
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
|
||||||
</EmbeddedResource>
|
</EmbeddedResource>
|
||||||
<EmbeddedResource Update="Page\MachinesPage.xaml">
|
|
||||||
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
|
|
||||||
</EmbeddedResource>
|
|
||||||
<EmbeddedResource Update="Page\MainPage.xaml">
|
<EmbeddedResource Update="Page\MainPage.xaml">
|
||||||
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
|
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
|
||||||
</EmbeddedResource>
|
</EmbeddedResource>
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Text;
|
|
||||||
using Borepin.Model;
|
|
||||||
using Xamarin.Forms;
|
using Xamarin.Forms;
|
||||||
|
|
||||||
namespace Borepin.Converter
|
namespace Borepin.Converter
|
||||||
@ -11,9 +8,9 @@ namespace Borepin.Converter
|
|||||||
{
|
{
|
||||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||||
{
|
{
|
||||||
switch((MachineStates)value)
|
switch((FabAccessAPI.Schema.State)value)
|
||||||
{
|
{
|
||||||
case (MachineStates.Free):
|
case (FabAccessAPI.Schema.State.free):
|
||||||
return (Color)Application.Current.Resources["FirstColor"];
|
return (Color)Application.Current.Resources["FirstColor"];
|
||||||
default:
|
default:
|
||||||
return (Color)Application.Current.Resources["SixthColor"];
|
return (Color)Application.Current.Resources["SixthColor"];
|
||||||
|
35
Borepin/Borepin/Converter/MachineStateStringConverter.cs
Normal file
35
Borepin/Borepin/Converter/MachineStateStringConverter.cs
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
using System;
|
||||||
|
using System.Globalization;
|
||||||
|
using Xamarin.Forms;
|
||||||
|
|
||||||
|
namespace Borepin.Converter
|
||||||
|
{
|
||||||
|
public class MachineStateStringConverter : IValueConverter
|
||||||
|
{
|
||||||
|
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||||
|
{
|
||||||
|
switch((FabAccessAPI.Schema.State)value)
|
||||||
|
{
|
||||||
|
case (FabAccessAPI.Schema.State.free):
|
||||||
|
return "Free";
|
||||||
|
case (FabAccessAPI.Schema.State.inUse):
|
||||||
|
return "In Use";
|
||||||
|
case (FabAccessAPI.Schema.State.toCheck):
|
||||||
|
return "To Check";
|
||||||
|
case (FabAccessAPI.Schema.State.reserved):
|
||||||
|
return "Reserved";
|
||||||
|
case (FabAccessAPI.Schema.State.blocked):
|
||||||
|
return "Blocked";
|
||||||
|
case (FabAccessAPI.Schema.State.disabled):
|
||||||
|
return "Disabled";
|
||||||
|
default:
|
||||||
|
return "Unknown";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,54 +1,8 @@
|
|||||||
using Prism.Mvvm;
|
namespace Borepin.Model
|
||||||
|
|
||||||
namespace Borepin.Model
|
|
||||||
{
|
{
|
||||||
public enum MachineStates
|
public class Machine
|
||||||
{
|
{
|
||||||
Free,
|
public FabAccessAPI.Machine Instance { get; set; }
|
||||||
InUse,
|
public FabAccessAPI.Schema.Machine.MInfo MInfo { get; set; }
|
||||||
ToCheck,
|
|
||||||
Blocked,
|
|
||||||
Disabled,
|
|
||||||
Reserved
|
|
||||||
}
|
|
||||||
|
|
||||||
public class Machine : BindableBase
|
|
||||||
{
|
|
||||||
private string _ID;
|
|
||||||
public string ID
|
|
||||||
{
|
|
||||||
get => _ID;
|
|
||||||
set => SetProperty(ref _ID, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
private MachineStates _State;
|
|
||||||
public MachineStates State
|
|
||||||
{
|
|
||||||
get => _State;
|
|
||||||
set => SetProperty(ref _State, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
private string _Description;
|
|
||||||
public string Description
|
|
||||||
{
|
|
||||||
get => _Description;
|
|
||||||
set => SetProperty(ref _Description, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
private User _User;
|
|
||||||
public User User
|
|
||||||
{
|
|
||||||
get => _User;
|
|
||||||
set => SetProperty(ref _User, value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class User
|
|
||||||
{
|
|
||||||
public string ID { get; set; }
|
|
||||||
|
|
||||||
public string Name { get; set; }
|
|
||||||
|
|
||||||
public string OriginalWorkshop { get; set; }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
22
Borepin/Borepin/Page/MachineListPage.xaml
Normal file
22
Borepin/Borepin/Page/MachineListPage.xaml
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
<?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.MachineListPage">
|
||||||
|
<NavigationPage.TitleView>
|
||||||
|
<Label Text="Machines" HorizontalOptions="End" Margin="0, 0, 10, 0" VerticalOptions="CenterAndExpand" FontSize="Medium" TextColor="{StaticResource FirstColor}"/>
|
||||||
|
</NavigationPage.TitleView>
|
||||||
|
<ContentPage.Content>
|
||||||
|
<StackLayout>
|
||||||
|
<ListView ItemsSource="{Binding MachineListItemViewModel_List}">
|
||||||
|
<ListView.ItemTemplate>
|
||||||
|
<DataTemplate>
|
||||||
|
<ViewCell>
|
||||||
|
<views:MachineListItemView />
|
||||||
|
</ViewCell>
|
||||||
|
</DataTemplate>
|
||||||
|
</ListView.ItemTemplate>
|
||||||
|
</ListView>
|
||||||
|
</StackLayout>
|
||||||
|
</ContentPage.Content>
|
||||||
|
</ContentPage>
|
@ -10,9 +10,9 @@ using Xamarin.Forms.Xaml;
|
|||||||
namespace Borepin.Page
|
namespace Borepin.Page
|
||||||
{
|
{
|
||||||
[XamlCompilation(XamlCompilationOptions.Compile)]
|
[XamlCompilation(XamlCompilationOptions.Compile)]
|
||||||
public partial class MachinesPage : ContentPage
|
public partial class MachineListPage : ContentPage
|
||||||
{
|
{
|
||||||
public MachinesPage()
|
public MachineListPage()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
@ -14,23 +14,10 @@
|
|||||||
</ContentPage.Resources>
|
</ContentPage.Resources>
|
||||||
<ContentPage.Content>
|
<ContentPage.Content>
|
||||||
<StackLayout Padding="20">
|
<StackLayout Padding="20">
|
||||||
<Label Text="{Binding Machine.ID}" Style="{StaticResource LabelStyle_Title}"/>
|
<Label Text="{Binding Name}" Style="{StaticResource LabelStyle_Title}"/>
|
||||||
|
|
||||||
<Label Text="Current User" IsVisible="{Binding Machine.User, Converter={StaticResource IsNotNullBoolConverter}}" Style="{StaticResource LabelStyle_PropertyTitle}"></Label>
|
|
||||||
<Label Text="{Binding Machine.User.Name}" IsVisible="{Binding Machine.User, Converter={StaticResource IsNotNullBoolConverter}}" Style="{StaticResource LabelStyle_PropertyText}"/>
|
|
||||||
|
|
||||||
<Label Text="Description" Style="{StaticResource LabelStyle_PropertyTitle}"></Label>
|
|
||||||
<Label Text="{Binding Machine.Description}" Style="{StaticResource LabelStyle_PropertyText}"/>
|
|
||||||
|
|
||||||
<Button Text="Reserve" Command="{Binding ReserveMachineCommand}" IsVisible="{Binding CanReserve}" Style="{StaticResource ButtonStyle_Primary}"/>
|
|
||||||
|
|
||||||
<Button Text="Use" Command="{Binding UseMachineCommand}" IsVisible="{Binding CanUse}" Style="{StaticResource ButtonStyle_Primary}"/>
|
<Button Text="Use" Command="{Binding UseMachineCommand}" IsVisible="{Binding CanUse}" Style="{StaticResource ButtonStyle_Primary}"/>
|
||||||
<Button Text="GiveBack" Command="{Binding GiveBackMachineCommand}" IsVisible="{Binding CanGiveBack}" Style="{StaticResource ButtonStyle_Primary}"/>
|
<Button Text="GiveBack" Command="{Binding GiveBackMachineCommand}" IsVisible="{Binding CanGiveBack}" Style="{StaticResource ButtonStyle_Primary}"/>
|
||||||
|
|
||||||
<Grid>
|
|
||||||
<Button Grid.Column="0" Text="Disable" Command="{Binding DisableMachineCommand}" IsVisible="{Binding IsAdmin}" Style="{StaticResource ButtonStyle_Admin}"/>
|
|
||||||
<Button Grid.Column="1" Text="Block" Command="{Binding BlockMachineCommand}" IsVisible="{Binding IsAdmin}" Style="{StaticResource ButtonStyle_Admin}"/>
|
|
||||||
</Grid>
|
|
||||||
</StackLayout>
|
</StackLayout>
|
||||||
</ContentPage.Content>
|
</ContentPage.Content>
|
||||||
</ContentPage>
|
</ContentPage>
|
@ -1,43 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8" ?>
|
|
||||||
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
|
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
|
||||||
x:Class="Borepin.Page.MachinesPage"
|
|
||||||
xmlns:converters="clr-namespace:Borepin.Converter">
|
|
||||||
<NavigationPage.TitleView>
|
|
||||||
<Label Text="Machines" HorizontalOptions="End" Margin="0, 0, 10, 0" VerticalOptions="CenterAndExpand" FontSize="Medium" TextColor="{StaticResource FirstColor}"/>
|
|
||||||
</NavigationPage.TitleView>
|
|
||||||
<ContentPage.Resources>
|
|
||||||
<ResourceDictionary>
|
|
||||||
<converters:MachineStateColorConverter x:Key="MachineStateColorConverter"/>
|
|
||||||
</ResourceDictionary>
|
|
||||||
</ContentPage.Resources>
|
|
||||||
<ContentPage.Content>
|
|
||||||
<StackLayout Padding="0, 10, 0, 10">
|
|
||||||
<ListView x:Name="MachineList" ItemsSource="{Binding MachineList}" SelectionMode="None">
|
|
||||||
<ListView.ItemTemplate>
|
|
||||||
<DataTemplate>
|
|
||||||
<ViewCell>
|
|
||||||
<Grid RowSpacing="0">
|
|
||||||
<Grid.ColumnDefinitions>
|
|
||||||
<ColumnDefinition Width="5" />
|
|
||||||
<ColumnDefinition Width="7*" />
|
|
||||||
<ColumnDefinition Width="2*" />
|
|
||||||
<ColumnDefinition Width="1*" />
|
|
||||||
<ColumnDefinition Width="1" />
|
|
||||||
</Grid.ColumnDefinitions>
|
|
||||||
<Grid.RowDefinitions>
|
|
||||||
<RowDefinition Height="*"/>
|
|
||||||
<RowDefinition Height="1"/>
|
|
||||||
</Grid.RowDefinitions>
|
|
||||||
<Label Grid.Row="0" Grid.Column="1" Text="{Binding ID, StringFormat='{0}'}" Style="{StaticResource LabelStyle_Primary}"/>
|
|
||||||
<Label Grid.Row="0" Grid.Column="2" Text="{Binding State, StringFormat='{0}'}" Style="{StaticResource LabelStyle_Second}" HorizontalTextAlignment="End" TextColor="{Binding State, Converter={StaticResource MachineStateColorConverter}}" />
|
|
||||||
<Button Grid.Row="0" Grid.Column="3" Margin="0, 3, 0, 3" Text="->" Command="{Binding BindingContext.GoToMachineCommand, Source={x:Reference MachineList}}" CommandParameter="{Binding .}" Style="{StaticResource ButtonStyle_Primary}"/>
|
|
||||||
<BoxView Grid.Row="1" Grid.ColumnSpan="5" BackgroundColor="{StaticResource FifthColor}"/>
|
|
||||||
</Grid>
|
|
||||||
</ViewCell>
|
|
||||||
</DataTemplate>
|
|
||||||
</ListView.ItemTemplate>
|
|
||||||
</ListView>
|
|
||||||
</StackLayout>
|
|
||||||
</ContentPage.Content>
|
|
||||||
</ContentPage>
|
|
@ -7,7 +7,7 @@
|
|||||||
<MasterDetailPage.Master>
|
<MasterDetailPage.Master>
|
||||||
<ContentPage Title="FabAccess">
|
<ContentPage Title="FabAccess">
|
||||||
<StackLayout>
|
<StackLayout>
|
||||||
<Button Text="Machines" Command="{Binding NavigateCommand}" CommandParameter="MachinesPage" />
|
<Button Text="Machines" Command="{Binding NavigateCommand}" CommandParameter="MachineListPage" />
|
||||||
<Button Text="Settings" Command="{Binding NavigateCommand}" CommandParameter="SettingsPage" />
|
<Button Text="Settings" Command="{Binding NavigateCommand}" CommandParameter="SettingsPage" />
|
||||||
<Button Text="Servers" Command="{Binding NavigateCommand}" CommandParameter="ServerListPage" />
|
<Button Text="Servers" Command="{Binding NavigateCommand}" CommandParameter="ServerListPage" />
|
||||||
</StackLayout>
|
</StackLayout>
|
||||||
|
102
Borepin/Borepin/PageModel/MachineListPageModel.cs
Normal file
102
Borepin/Borepin/PageModel/MachineListPageModel.cs
Normal file
@ -0,0 +1,102 @@
|
|||||||
|
using Borepin.ViewModel;
|
||||||
|
using Prism.Mvvm;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Input;
|
||||||
|
using Prism.Commands;
|
||||||
|
using Prism.Navigation;
|
||||||
|
using Borepin.Service.Connections;
|
||||||
|
using Borepin.Service.BFFH;
|
||||||
|
using Borepin.Model;
|
||||||
|
|
||||||
|
namespace Borepin.PageModel
|
||||||
|
{
|
||||||
|
public class MachineListPageModel : BindableBase, INavigationAware
|
||||||
|
{
|
||||||
|
private readonly INavigationService _NavigationService;
|
||||||
|
private readonly IConnectionService _ConnectionService;
|
||||||
|
private readonly IBFFHService _BFFHService;
|
||||||
|
|
||||||
|
public MachineListPageModel(INavigationService navigationService, IConnectionService connectionService, IBFFHService bffhService)
|
||||||
|
{
|
||||||
|
_NavigationService = navigationService;
|
||||||
|
_ConnectionService = connectionService;
|
||||||
|
_BFFHService = bffhService;
|
||||||
|
|
||||||
|
SelectInstanceCommand = new DelegateCommand<object>(SelectInstanceCommandExecuted);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task<bool> LoadData()
|
||||||
|
{
|
||||||
|
if(_BFFHService.ActiveConnection == null)
|
||||||
|
{
|
||||||
|
return await Task.FromResult(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
FabAccessAPI.Machines machineInterface = await _BFFHService.GetMachineInterface();
|
||||||
|
|
||||||
|
List<Machine> list = new List<Machine>();
|
||||||
|
|
||||||
|
IReadOnlyList<FabAccessAPI.Machine> machine_list = await machineInterface.ListMachines();
|
||||||
|
foreach(FabAccessAPI.Machine machine in machine_list)
|
||||||
|
{
|
||||||
|
list.Add(new Machine() { Instance = machine, MInfo = await machine.GetMInfo() });
|
||||||
|
}
|
||||||
|
|
||||||
|
List<MachineListItemViewModel> viewmodel_list = new List<MachineListItemViewModel>();
|
||||||
|
foreach(Machine machine in list)
|
||||||
|
{
|
||||||
|
viewmodel_list.Add(new MachineListItemViewModel(machine));
|
||||||
|
}
|
||||||
|
|
||||||
|
MachineListItemViewModel_List = viewmodel_list;
|
||||||
|
|
||||||
|
return await Task.FromResult(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Properties
|
||||||
|
private List<MachineListItemViewModel> _MachineListItemViewModel_List;
|
||||||
|
public List<MachineListItemViewModel> MachineListItemViewModel_List
|
||||||
|
{
|
||||||
|
get => _MachineListItemViewModel_List;
|
||||||
|
set => SetProperty(ref _MachineListItemViewModel_List, value);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Commands
|
||||||
|
private ICommand _SelectInstanceCommand;
|
||||||
|
public ICommand SelectInstanceCommand
|
||||||
|
{
|
||||||
|
get => _SelectInstanceCommand;
|
||||||
|
set => SetProperty(ref _SelectInstanceCommand, value);
|
||||||
|
}
|
||||||
|
private async void SelectInstanceCommandExecuted(object obj)
|
||||||
|
{
|
||||||
|
MachineListItemViewModel viewmodel = obj as MachineListItemViewModel;
|
||||||
|
|
||||||
|
NavigationParameters parameters = new NavigationParameters
|
||||||
|
{
|
||||||
|
{ "instance", viewmodel.Instance }
|
||||||
|
};
|
||||||
|
|
||||||
|
INavigationResult result = await _NavigationService.NavigateAsync($"MachinePage", parameters);
|
||||||
|
if (!result.Success)
|
||||||
|
{
|
||||||
|
System.Diagnostics.Debugger.Break();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region INavigationAware
|
||||||
|
public void OnNavigatedFrom(INavigationParameters parameters)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OnNavigatedTo(INavigationParameters parameters)
|
||||||
|
{
|
||||||
|
Task.Run(LoadData);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
@ -1,57 +1,67 @@
|
|||||||
using Borepin.Model;
|
using Borepin.Model;
|
||||||
using Borepin.Service.BFFH;
|
using Borepin.Service.BFFH;
|
||||||
|
using Prism.Commands;
|
||||||
using Prism.Mvvm;
|
using Prism.Mvvm;
|
||||||
using Prism.Navigation;
|
using Prism.Navigation;
|
||||||
|
using System.Threading.Tasks;
|
||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
using Xamarin.Forms;
|
using Xamarin.Forms;
|
||||||
|
using static FabAccessAPI.Schema.Machine.WriteInterface;
|
||||||
|
|
||||||
namespace Borepin.PageModel
|
namespace Borepin.PageModel
|
||||||
{
|
{
|
||||||
public class MachinePageModel : BindableBase, INavigationAware
|
public class MachinePageModel : BindableBase, INavigationAware
|
||||||
{
|
{
|
||||||
private readonly INavigationService _NavigationService;
|
private readonly INavigationService _NavigationService;
|
||||||
private readonly IBFFHService _BFFHService;
|
|
||||||
|
|
||||||
public MachinePageModel(INavigationService navigationService, IBFFHService bffhService)
|
public MachinePageModel(INavigationService navigationService)
|
||||||
{
|
{
|
||||||
_NavigationService = navigationService;
|
_NavigationService = navigationService;
|
||||||
_BFFHService = bffhService;
|
|
||||||
|
|
||||||
ReserveMachineCommand = new Command(ReserveMachineCommandExecuted);
|
UseMachineCommand = new DelegateCommand(UseMachineCommandExecuted);
|
||||||
UseMachineCommand = new Command(UseMachineCommandExecuted);
|
GiveBackMachineCommand = new DelegateCommand(GiveBackMachineCommandExecuted);
|
||||||
GiveBackMachineCommand = new Command(GiveBackMachineCommandExecuted);
|
|
||||||
BlockMachineCommand = new Command(BlockMachineCommandExecuted);
|
|
||||||
DisableMachineCommand = new Command(DisableMachineCommandExecuted);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Machine _Machine;
|
#region Properties
|
||||||
public Machine Machine
|
|
||||||
|
private Machine _MachineItem;
|
||||||
|
public Machine MachineItem
|
||||||
{
|
{
|
||||||
get => _Machine;
|
get => _MachineItem;
|
||||||
set => SetProperty(ref _Machine, value);
|
set => SetProperty(ref _MachineItem, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool _IsValid = false;
|
private string _Name;
|
||||||
public bool IsValid
|
public string Name
|
||||||
{
|
{
|
||||||
get => _IsValid;
|
get => _Name;
|
||||||
set => SetProperty(ref _IsValid, value);
|
set => SetProperty(ref _Name, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
private ICommand _ReserveMachineCommand;
|
private IGiveBack _GiveBack;
|
||||||
public ICommand ReserveMachineCommand
|
//public IGiveBack GiveBack
|
||||||
|
//{
|
||||||
|
// get => _GiveBack;
|
||||||
|
// set => SetProperty(ref _GiveBack, value);
|
||||||
|
//}
|
||||||
|
|
||||||
|
private bool _CanUse;
|
||||||
|
public bool CanUse
|
||||||
{
|
{
|
||||||
get => _ReserveMachineCommand;
|
get => _CanUse;
|
||||||
set => SetProperty(ref _ReserveMachineCommand, value);
|
set => SetProperty(ref _CanUse, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ReserveMachineCommandExecuted()
|
private bool _CanGiveBack;
|
||||||
|
public bool CanGiveBack
|
||||||
{
|
{
|
||||||
//_BFFHInterface.ReserveMachine(Machine.ID);
|
get => _CanGiveBack;
|
||||||
//UpdateMachine();
|
set => SetProperty(ref _CanGiveBack, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Commands
|
||||||
private ICommand _UseMachineCommand;
|
private ICommand _UseMachineCommand;
|
||||||
public ICommand UseMachineCommand
|
public ICommand UseMachineCommand
|
||||||
{
|
{
|
||||||
@ -59,10 +69,14 @@ namespace Borepin.PageModel
|
|||||||
set => SetProperty(ref _UseMachineCommand, value);
|
set => SetProperty(ref _UseMachineCommand, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UseMachineCommandExecuted()
|
private async void UseMachineCommandExecuted()
|
||||||
{
|
{
|
||||||
//_BFFHInterface.UseMachine(Machine.ID);
|
_GiveBack = await MachineItem.Instance.Use();
|
||||||
//UpdateMachine();
|
CanGiveBack = _GiveBack != null;
|
||||||
|
|
||||||
|
MachineItem.MInfo = await MachineItem.Instance.GetMInfo();
|
||||||
|
|
||||||
|
CanUse = MachineItem.MInfo.State == FabAccessAPI.Schema.State.free;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ICommand _GiveBackMachineCommand;
|
private ICommand _GiveBackMachineCommand;
|
||||||
@ -72,147 +86,21 @@ namespace Borepin.PageModel
|
|||||||
set => SetProperty(ref _GiveBackMachineCommand, value);
|
set => SetProperty(ref _GiveBackMachineCommand, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void GiveBackMachineCommandExecuted()
|
private async void GiveBackMachineCommandExecuted()
|
||||||
{
|
{
|
||||||
//_BFFHInterface.GiveBackMachine(Machine.ID);
|
await _GiveBack.Ret();
|
||||||
//UpdateMachine();
|
|
||||||
|
_GiveBack = null;
|
||||||
|
CanGiveBack = _GiveBack != null;
|
||||||
|
|
||||||
|
MachineItem.MInfo = await MachineItem.Instance.GetMInfo();
|
||||||
|
|
||||||
|
CanUse = MachineItem.MInfo.State == FabAccessAPI.Schema.State.free;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ICommand _DisableMachineCommand;
|
#endregion
|
||||||
public ICommand DisableMachineCommand
|
|
||||||
{
|
|
||||||
get => _DisableMachineCommand;
|
|
||||||
set => SetProperty(ref _DisableMachineCommand, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void DisableMachineCommandExecuted()
|
|
||||||
{
|
|
||||||
//if(Machine.State == MachineStates.Disabled)
|
|
||||||
//{
|
|
||||||
// _BFFHInterface.SetStateForce(Machine.ID, MachineStates.Free);
|
|
||||||
//}
|
|
||||||
//else
|
|
||||||
//{
|
|
||||||
// _BFFHInterface.SetStateForce(Machine.ID, MachineStates.Disabled);
|
|
||||||
//}
|
|
||||||
|
|
||||||
//UpdateMachine();
|
|
||||||
}
|
|
||||||
|
|
||||||
private ICommand _BlockMachineCommand;
|
|
||||||
public ICommand BlockMachineCommand
|
|
||||||
{
|
|
||||||
get => _BlockMachineCommand;
|
|
||||||
set => SetProperty(ref _BlockMachineCommand, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void BlockMachineCommandExecuted()
|
|
||||||
{
|
|
||||||
//if (Machine.State == MachineStates.Blocked)
|
|
||||||
//{
|
|
||||||
// _BFFHInterface.SetStateForce(Machine.ID, MachineStates.Free);
|
|
||||||
//}
|
|
||||||
//else
|
|
||||||
//{
|
|
||||||
// _BFFHInterface.SetStateForce(Machine.ID, MachineStates.Blocked);
|
|
||||||
//}
|
|
||||||
|
|
||||||
//UpdateMachine();
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool CanUse
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
//if(Machine == null)
|
|
||||||
//{
|
|
||||||
// return false;
|
|
||||||
//}
|
|
||||||
|
|
||||||
//if(Machine.State == MachineStates.Free)
|
|
||||||
//{
|
|
||||||
// return true;
|
|
||||||
//}
|
|
||||||
|
|
||||||
//if(Machine.State == MachineStates.Reserved)
|
|
||||||
//{
|
|
||||||
// if(Machine.User == _BFFHInterface.ActiveUser)
|
|
||||||
// {
|
|
||||||
// return true;
|
|
||||||
// }
|
|
||||||
// else if(_BFFHInterface.IsAdmin())
|
|
||||||
// {
|
|
||||||
// return true;
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool CanReserve
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
//if (Machine == null)
|
|
||||||
//{
|
|
||||||
// return false;
|
|
||||||
//}
|
|
||||||
|
|
||||||
//if (Machine.State == MachineStates.Free)
|
|
||||||
//{
|
|
||||||
// return true;
|
|
||||||
//}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool CanGiveBack
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
//if (Machine == null)
|
|
||||||
//{
|
|
||||||
// return false;
|
|
||||||
//}
|
|
||||||
|
|
||||||
//if (Machine.State == MachineStates.InUse && Machine.User == _BFFHInterface.ActiveUser)
|
|
||||||
//{
|
|
||||||
// return true;
|
|
||||||
//}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool IsAdmin
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
//if (_BFFHInterface == null)
|
|
||||||
//{
|
|
||||||
// return false;
|
|
||||||
//}
|
|
||||||
|
|
||||||
//if (_BFFHInterface.IsAdmin())
|
|
||||||
//{
|
|
||||||
// return true;
|
|
||||||
//}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void UpdateMachine()
|
|
||||||
{
|
|
||||||
//Machine = BFFHService_OLD.GetMachine(Machine.ID);
|
|
||||||
|
|
||||||
//OnPropertyChanged(new System.ComponentModel.PropertyChangedEventArgs("CanUse"));
|
|
||||||
//OnPropertyChanged(new System.ComponentModel.PropertyChangedEventArgs("CanReserve"));
|
|
||||||
//OnPropertyChanged(new System.ComponentModel.PropertyChangedEventArgs("CanGiveBack"));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
#region INavigationAware
|
||||||
public void OnNavigatedFrom(INavigationParameters parameters)
|
public void OnNavigatedFrom(INavigationParameters parameters)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -220,25 +108,13 @@ namespace Borepin.PageModel
|
|||||||
|
|
||||||
public void OnNavigatedTo(INavigationParameters parameters)
|
public void OnNavigatedTo(INavigationParameters parameters)
|
||||||
{
|
{
|
||||||
//string machineID = parameters["machineID"] as string;
|
MachineItem = parameters["instance"] as Machine;
|
||||||
|
|
||||||
|
Name = MachineItem.MInfo.Name;
|
||||||
|
|
||||||
//if(machineID == null)
|
CanUse = MachineItem.MInfo.State == FabAccessAPI.Schema.State.free;
|
||||||
//{
|
CanGiveBack = _GiveBack != null;
|
||||||
// _IsValid = false;
|
|
||||||
// return;
|
|
||||||
//}
|
|
||||||
|
|
||||||
//try
|
|
||||||
//{
|
|
||||||
// Machine = BFFHService_OLD.GetMachine(machineID);
|
|
||||||
// IsValid = true;
|
|
||||||
|
|
||||||
// UpdateMachine();
|
|
||||||
//}
|
|
||||||
//catch
|
|
||||||
//{
|
|
||||||
// _IsValid = false;
|
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,50 +0,0 @@
|
|||||||
using Borepin.Model;
|
|
||||||
using Prism.Mvvm;
|
|
||||||
using Prism.Navigation;
|
|
||||||
using System.Collections.ObjectModel;
|
|
||||||
using System.Windows.Input;
|
|
||||||
using Xamarin.Forms;
|
|
||||||
|
|
||||||
namespace Borepin.PageModel
|
|
||||||
{
|
|
||||||
public class MachinesPageModel : BindableBase
|
|
||||||
{
|
|
||||||
private readonly INavigationService _NavigationService;
|
|
||||||
|
|
||||||
public MachinesPageModel(INavigationService navigationService)
|
|
||||||
{
|
|
||||||
_NavigationService = navigationService;
|
|
||||||
GoToMachineCommand = new Command<object>(GoToMachineCommandExecuted);
|
|
||||||
}
|
|
||||||
|
|
||||||
private ICommand _GoToMachineCommand;
|
|
||||||
public ICommand GoToMachineCommand
|
|
||||||
{
|
|
||||||
get => _GoToMachineCommand;
|
|
||||||
set => SetProperty(ref _GoToMachineCommand, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
private async void GoToMachineCommandExecuted(object obj)
|
|
||||||
{
|
|
||||||
Machine machine = obj as Machine;
|
|
||||||
|
|
||||||
NavigationParameters navigationParams = new NavigationParameters
|
|
||||||
{
|
|
||||||
{ "machineID", machine.ID }
|
|
||||||
};
|
|
||||||
|
|
||||||
INavigationResult result = await _NavigationService.NavigateAsync($"MachinePage", navigationParams);
|
|
||||||
if (!result.Success)
|
|
||||||
{
|
|
||||||
System.Diagnostics.Debugger.Break();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private ObservableCollection<Machine> _MachineList;
|
|
||||||
public ObservableCollection<Machine> MachineList
|
|
||||||
{
|
|
||||||
get => _MachineList;
|
|
||||||
set => SetProperty(ref _MachineList, value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -77,5 +77,10 @@ namespace Borepin.Service.BFFH
|
|||||||
|
|
||||||
return await Task.FromResult(true);
|
return await Task.FromResult(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Task<FabAccessAPI.Machines> GetMachineInterface()
|
||||||
|
{
|
||||||
|
return _Connection.AccessMachines();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -45,5 +45,7 @@ namespace Borepin.Service.BFFH
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="connection">address + username</param>
|
/// <param name="connection">address + username</param>
|
||||||
Task<bool> Authenticate(Connection connection, string password);
|
Task<bool> Authenticate(Connection connection, string password);
|
||||||
|
|
||||||
|
Task<FabAccessAPI.Machines> GetMachineInterface();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
32
Borepin/Borepin/View/MachineListItemView.xaml
Normal file
32
Borepin/Borepin/View/MachineListItemView.xaml
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ContentView xmlns="http://xamarin.com/schemas/2014/forms"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||||
|
x:Class="Borepin.View.MachineListItemView"
|
||||||
|
xmlns:pagemodel="clr-namespace:Borepin.PageModel"
|
||||||
|
xmlns:converters="clr-namespace:Borepin.Converter">
|
||||||
|
<ContentView.Resources>
|
||||||
|
<ResourceDictionary>
|
||||||
|
<converters:MachineStateColorConverter x:Key="MachineStateColorConverter"/>
|
||||||
|
<converters:MachineStateStringConverter x:Key="MachineStateStringConverter"/>
|
||||||
|
</ResourceDictionary>
|
||||||
|
</ContentView.Resources>
|
||||||
|
<ContentView.Content>
|
||||||
|
<Grid RowSpacing="0">
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="5" />
|
||||||
|
<ColumnDefinition Width="7*" />
|
||||||
|
<ColumnDefinition Width="2*" />
|
||||||
|
<ColumnDefinition Width="1*" />
|
||||||
|
<ColumnDefinition Width="1" />
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="*"/>
|
||||||
|
<RowDefinition Height="1"/>
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<Label Grid.Row="0" Grid.Column="1" Text="{Binding Name}" Style="{StaticResource LabelStyle_Primary}"/>
|
||||||
|
<Label Grid.Row="0" Grid.Column="2" Text="{Binding State, Converter={StaticResource MachineStateStringConverter}}" TextColor="{Binding State, Converter={StaticResource MachineStateColorConverter}}" Style="{StaticResource LabelStyle_Second}" HorizontalTextAlignment="End" />
|
||||||
|
<Button Grid.Row="0" Grid.Column="3" Margin="0, 3, 0, 3" Text="->" Command="{Binding Source={RelativeSource AncestorType={x:Type pagemodel:MachineListPageModel}}, Path=SelectInstanceCommand}" CommandParameter="{Binding .}" Style="{StaticResource ButtonStyle_Primary}"/>
|
||||||
|
<BoxView Grid.Row="1" Grid.ColumnSpan="5" BackgroundColor="{StaticResource FifthColor}"/>
|
||||||
|
</Grid>
|
||||||
|
</ContentView.Content>
|
||||||
|
</ContentView>
|
20
Borepin/Borepin/View/MachineListItemView.xaml.cs
Normal file
20
Borepin/Borepin/View/MachineListItemView.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.View
|
||||||
|
{
|
||||||
|
[XamlCompilation(XamlCompilationOptions.Compile)]
|
||||||
|
public partial class MachineListItemView : ContentView
|
||||||
|
{
|
||||||
|
public MachineListItemView()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
28
Borepin/Borepin/ViewModel/MachineListItemViewModel.cs
Normal file
28
Borepin/Borepin/ViewModel/MachineListItemViewModel.cs
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
using Borepin.Model;
|
||||||
|
using Prism.Mvvm;
|
||||||
|
|
||||||
|
namespace Borepin.ViewModel
|
||||||
|
{
|
||||||
|
public class ServerListItemViewModel : BindableBase
|
||||||
|
{
|
||||||
|
public ServerListItemViewModel(Connection instance)
|
||||||
|
{
|
||||||
|
_Instance = instance;
|
||||||
|
Address = instance.Address.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
private Connection _Instance;
|
||||||
|
public Connection Instance
|
||||||
|
{
|
||||||
|
get => _Instance;
|
||||||
|
set => SetProperty(ref _Instance, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
private string _Address;
|
||||||
|
public string Address
|
||||||
|
{
|
||||||
|
get => _Address;
|
||||||
|
set => SetProperty(ref _Address, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,28 +1,38 @@
|
|||||||
using Borepin.Model;
|
using Borepin.Model;
|
||||||
|
using FabAccessAPI;
|
||||||
using Prism.Mvvm;
|
using Prism.Mvvm;
|
||||||
|
|
||||||
namespace Borepin.ViewModel
|
namespace Borepin.ViewModel
|
||||||
{
|
{
|
||||||
public class ServerListItemViewModel : BindableBase
|
public class MachineListItemViewModel : BindableBase
|
||||||
{
|
{
|
||||||
public ServerListItemViewModel(Connection instance)
|
public MachineListItemViewModel(Model.Machine instance)
|
||||||
{
|
{
|
||||||
_Instance = instance;
|
_Instance = instance;
|
||||||
Address = instance.Address.ToString();
|
|
||||||
|
Name = instance.MInfo.Name;
|
||||||
|
State = instance.MInfo.State;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Connection _Instance;
|
private Model.Machine _Instance;
|
||||||
public Connection Instance
|
public Model.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 FabAccessAPI.Schema.State _State;
|
||||||
|
public FabAccessAPI.Schema.State State
|
||||||
|
{
|
||||||
|
get => _State;
|
||||||
|
set => SetProperty(ref _State, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user