Added: IsBusy

This commit is contained in:
TheJoKlLa 2021-03-30 13:33:58 +02:00
parent 158cab6b23
commit 8d6bd2a1e4
18 changed files with 369 additions and 103 deletions

View File

@ -39,6 +39,7 @@ namespace Borepin
result = await NavigationService.NavigateAsync("/MainPage/NavigationPage/ServerListPage"); result = await NavigationService.NavigateAsync("/MainPage/NavigationPage/ServerListPage");
} }
//result = await NavigationService.NavigateAsync("/NavigationPage/TestPage");
if (!result.Success) if (!result.Success)
{ {
System.Diagnostics.Debugger.Break(); System.Diagnostics.Debugger.Break();
@ -59,6 +60,7 @@ 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>();
// Register Dialog // Register Dialog
containerRegistry.RegisterDialog<ConfirmDialog, ConfirmDialogModel>(); containerRegistry.RegisterDialog<ConfirmDialog, ConfirmDialogModel>();

View File

@ -0,0 +1,48 @@
using Prism.Mvvm;
using Prism.Navigation;
using System.Threading.Tasks;
namespace Borepin.Base
{
/// <summary>
/// Base for all BFFH Based PageModels
/// </summary>
public abstract class PageModelBase : BindableBase, INavigationAware
{
#region Private Properties
protected readonly INavigationService _NavigationService;
#endregion
#region Contructors
public PageModelBase(INavigationService navigationService)
{
_NavigationService = navigationService;
}
#endregion
#region Properties
/// <summary>
/// PageModel is Busy
/// </summary>
private bool _IsBusy = true;
public bool IsBusy
{
get => _IsBusy;
set => SetProperty(ref _IsBusy, value);
}
#endregion
#region Data
/// <summary>
/// Load Data async
/// </summary>
/// <returns></returns>
public abstract Task<bool> LoadData();
#endregion
#region INavigationAware
public abstract void OnNavigatedFrom(INavigationParameters parameters);
public abstract void OnNavigatedTo(INavigationParameters parameters);
#endregion
}
}

View File

@ -82,6 +82,9 @@
<EmbeddedResource Update="Page\SettingsPage.xaml"> <EmbeddedResource Update="Page\SettingsPage.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator> <Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource> </EmbeddedResource>
<EmbeddedResource Update="Page\TestPage.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
<EmbeddedResource Update="Properties\Resources.resx"> <EmbeddedResource Update="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator> <Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput> <LastGenOutput>Resources.Designer.cs</LastGenOutput>
@ -93,6 +96,9 @@
<EmbeddedResource Update="Styles\LightTheme.xaml"> <EmbeddedResource Update="Styles\LightTheme.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator> <Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource> </EmbeddedResource>
<EmbeddedResource Update="View\IsBusyView.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
<EmbeddedResource Update="View\ListItemView.xaml"> <EmbeddedResource Update="View\ListItemView.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator> <Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource> </EmbeddedResource>
@ -101,7 +107,6 @@
</EmbeddedResource> </EmbeddedResource>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Folder Include="Base\" />
<Folder Include="Behaviour\" /> <Folder Include="Behaviour\" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@ -2,21 +2,32 @@
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" <ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:views="clr-namespace:Borepin.View" xmlns:views="clr-namespace:Borepin.View"
x:Class="Borepin.Page.MachineListPage"> x:Class="Borepin.Page.MachineListPage"
xmlns:converters="clr-namespace:Borepin.Converter">
<NavigationPage.TitleView> <NavigationPage.TitleView>
<Label Text="Machines" HorizontalOptions="End" Margin="0, 0, 10, 0" VerticalOptions="CenterAndExpand" FontSize="Medium" TextColor="{StaticResource FirstColor}"/> <Label Text="Machines" HorizontalOptions="End" Margin="0, 0, 10, 0" VerticalOptions="CenterAndExpand" FontSize="Medium" TextColor="{StaticResource FirstColor}"/>
</NavigationPage.TitleView> </NavigationPage.TitleView>
<ContentPage.Resources>
<ResourceDictionary>
<converters:InvertBoolConverter x:Key="InvertBoolConverter"/>
</ResourceDictionary>
</ContentPage.Resources>
<ContentPage.Content> <ContentPage.Content>
<StackLayout> <StackLayout Padding="20">
<ListView ItemsSource="{Binding MachineListItemViewModel_List}"> <StackLayout IsVisible="{Binding IsBusy}">
<ListView.ItemTemplate> <ActivityIndicator IsRunning="{Binding IsBusy}"></ActivityIndicator>
<DataTemplate> </StackLayout>
<ViewCell> <StackLayout IsVisible="{Binding IsBusy, Converter={StaticResource InvertBoolConverter}}">
<views:MachineListItemView /> <ListView ItemsSource="{Binding MachineListItemViewModel_List}">
</ViewCell> <ListView.ItemTemplate>
</DataTemplate> <DataTemplate>
</ListView.ItemTemplate> <ViewCell>
</ListView> <views:MachineListItemView />
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackLayout>
</StackLayout> </StackLayout>
</ContentPage.Content> </ContentPage.Content>
</ContentPage> </ContentPage>

View File

@ -10,14 +10,20 @@
<ResourceDictionary> <ResourceDictionary>
<converters:MachineStateColorConverter x:Key="MachineStateColorConverter"/> <converters:MachineStateColorConverter x:Key="MachineStateColorConverter"/>
<converters:IsNotNullBoolConverter x:Key="IsNotNullBoolConverter"/> <converters:IsNotNullBoolConverter x:Key="IsNotNullBoolConverter"/>
<converters:InvertBoolConverter x:Key="InvertBoolConverter"/>
</ResourceDictionary> </ResourceDictionary>
</ContentPage.Resources> </ContentPage.Resources>
<ContentPage.Content> <ContentPage.Content>
<StackLayout Padding="20"> <StackLayout Padding="20">
<Label Text="{Binding Name}" Style="{StaticResource LabelStyle_Title}"/> <StackLayout IsVisible="{Binding IsBusy}">
<ActivityIndicator IsRunning="{Binding IsBusy}"></ActivityIndicator>
</StackLayout>
<StackLayout IsVisible="{Binding IsBusy, Converter={StaticResource InvertBoolConverter}}">
<Label Text="{Binding Name}" Style="{StaticResource LabelStyle_Title}"/>
<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}"/>
</StackLayout>
</StackLayout> </StackLayout>
</ContentPage.Content> </ContentPage.Content>
</ContentPage> </ContentPage>

View File

@ -2,33 +2,44 @@
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" <ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:views="clr-namespace:Borepin.View" xmlns:views="clr-namespace:Borepin.View"
x:Class="Borepin.Page.ServerListPage"> x:Class="Borepin.Page.ServerListPage"
xmlns:converters="clr-namespace:Borepin.Converter">
<NavigationPage.TitleView> <NavigationPage.TitleView>
<Label Text="Servers" HorizontalOptions="End" Margin="0, 0, 10, 0" VerticalOptions="CenterAndExpand" FontSize="Medium" TextColor="{StaticResource FirstColor}"/> <Label Text="Servers" HorizontalOptions="End" Margin="0, 0, 10, 0" VerticalOptions="CenterAndExpand" FontSize="Medium" TextColor="{StaticResource FirstColor}"/>
</NavigationPage.TitleView> </NavigationPage.TitleView>
<ContentPage.Resources>
<ResourceDictionary>
<converters:InvertBoolConverter x:Key="InvertBoolConverter"/>
</ResourceDictionary>
</ContentPage.Resources>
<ContentPage.Content> <ContentPage.Content>
<StackLayout> <StackLayout Padding="20">
<Label Text="Active Connection" IsVisible="{Binding HasActiveConnection}"/> <StackLayout IsVisible="{Binding IsBusy}">
<ListView ItemsSource="{Binding ActiveConnection}" IsVisible="{Binding HasActiveConnection}"> <ActivityIndicator IsRunning="{Binding IsBusy}"></ActivityIndicator>
<ListView.ItemTemplate> </StackLayout>
<DataTemplate> <StackLayout IsVisible="{Binding IsBusy, Converter={StaticResource InvertBoolConverter}}">
<ViewCell> <Label Text="Active Connection" IsVisible="{Binding HasActiveConnection}"/>
<views:ServerListItemView /> <ListView ItemsSource="{Binding ActiveConnection}" IsVisible="{Binding HasActiveConnection}">
</ViewCell> <ListView.ItemTemplate>
</DataTemplate> <DataTemplate>
</ListView.ItemTemplate> <ViewCell>
</ListView> <views:ServerListItemView />
<Label Text="Last Connections"/> </ViewCell>
<ListView ItemsSource="{Binding ServerListItemViewModel_List}"> </DataTemplate>
<ListView.ItemTemplate> </ListView.ItemTemplate>
<DataTemplate> </ListView>
<ViewCell> <Label Text="Last Connections"/>
<views:ServerListItemView /> <ListView ItemsSource="{Binding ServerListItemViewModel_List}">
</ViewCell> <ListView.ItemTemplate>
</DataTemplate> <DataTemplate>
</ListView.ItemTemplate> <ViewCell>
</ListView> <views:ServerListItemView />
<Button Text="Connect to new Server" Command="{Binding AddInstancesCommand}"/> </ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
<Button Text="Connect to new Server" Command="{Binding AddInstancesCommand}"/>
</StackLayout>
</StackLayout> </StackLayout>
</ContentPage.Content> </ContentPage.Content>
</ContentPage> </ContentPage>

View File

@ -2,18 +2,23 @@
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" <ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Borepin.Page.ServerPage" x:Class="Borepin.Page.ServerPage"
xmlns:converter="clr-namespace:Borepin.Converter"> xmlns:converters="clr-namespace:Borepin.Converter">
<ContentPage.Resources> <ContentPage.Resources>
<ResourceDictionary> <ResourceDictionary>
<converter:InvertBoolConverter x:Key="invertBool" /> <converters:InvertBoolConverter x:Key="InvertBoolConverter"/>
</ResourceDictionary> </ResourceDictionary>
</ContentPage.Resources> </ContentPage.Resources>
<ContentPage.Content> <ContentPage.Content>
<StackLayout> <StackLayout Padding="20">
<Label Text="{Binding Connection_Item.Address}"/> <StackLayout IsVisible="{Binding IsBusy}">
<Button IsVisible="{Binding IsConnected, Converter={StaticResource invertBool}}" Text="Connect" Command="{Binding ConnectCommand}"/> <ActivityIndicator IsRunning="{Binding IsBusy}"></ActivityIndicator>
<Button IsVisible="{Binding IsConnected}" Text="Disconnect" Command="{Binding ConnectCommand}"/> </StackLayout>
<Button Text="Delete" Command="{Binding DeleteCommand}"/> <StackLayout IsVisible="{Binding IsBusy, Converter={StaticResource InvertBoolConverter}}">
<Label Text="{Binding Connection_Item.Address}"/>
<Button IsVisible="{Binding IsConnected, Converter={StaticResource InvertBoolConverter}}" Text="Connect" Command="{Binding ConnectCommand}"/>
<Button IsVisible="{Binding IsConnected}" Text="Disconnect" Command="{Binding ConnectCommand}"/>
<Button Text="Delete" Command="{Binding DeleteCommand}"/>
</StackLayout>
</StackLayout> </StackLayout>
</ContentPage.Content> </ContentPage.Content>
</ContentPage> </ContentPage>

View File

@ -0,0 +1,21 @@
<?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.TestPage"
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 IsVisible="{Binding IsBusy, Converter={StaticResource InvertBoolConverter}}">
<Label Text="TestPage"/>
</StackLayout>
</StackLayout>
</ContentPage.Content>
</ContentPage>

View 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 TestPage : ContentPage
{
public TestPage()
{
InitializeComponent();
}
}
}

View File

@ -1,5 +1,4 @@
using Borepin.ViewModel; using Borepin.ViewModel;
using Prism.Mvvm;
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Input; using System.Windows.Input;
@ -8,53 +7,70 @@ using Prism.Navigation;
using Borepin.Service.Connections; using Borepin.Service.Connections;
using Borepin.Service.BFFH; using Borepin.Service.BFFH;
using Borepin.Model; using Borepin.Model;
using Borepin.Base;
namespace Borepin.PageModel namespace Borepin.PageModel
{ {
public class MachineListPageModel : BindableBase, INavigationAware public class MachineListPageModel : PageModelBase
{ {
private readonly INavigationService _NavigationService; #region Private Properties
private readonly IConnectionService _ConnectionService; private readonly IConnectionService _ConnectionService;
private readonly IBFFHService _BFFHService; private readonly IBFFHService _BFFHService;
#endregion
public MachineListPageModel(INavigationService navigationService, IConnectionService connectionService, IBFFHService bffhService) #region Constructors
public MachineListPageModel(INavigationService navigationService, IConnectionService connectionService, IBFFHService bFFHService) : base(navigationService)
{ {
_NavigationService = navigationService;
_ConnectionService = connectionService; _ConnectionService = connectionService;
_BFFHService = bffhService; _BFFHService = bFFHService;
SelectInstanceCommand = new DelegateCommand<object>(SelectInstanceCommandExecuted); SelectInstanceCommand = new DelegateCommand<object>(SelectInstanceCommandExecuted);
} }
#endregion
private async Task<bool> LoadData() #region Data
public override async Task<bool> LoadData()
{ {
if(_BFFHService.ActiveConnection == null) if (_BFFHService.ActiveConnection == null)
{ {
return await Task.FromResult(true); return await Task.FromResult(true);
} }
else
{
IsConnected = true;
}
FabAccessAPI.Machines machineInterface = await _BFFHService.GetMachineInterface(); FabAccessAPI.Machines machineInterface = await _BFFHService.GetMachineInterface();
List<Machine> list = new List<Machine>(); List<Machine> list = new List<Machine>();
IReadOnlyList<FabAccessAPI.Machine> machine_list = await machineInterface.ListMachines(); IReadOnlyList<FabAccessAPI.Machine> machine_list = await machineInterface.ListMachines();
foreach(FabAccessAPI.Machine machine in machine_list) foreach (FabAccessAPI.Machine machine in machine_list)
{ {
list.Add(new Machine() { Instance = machine, MInfo = await machine.GetMInfo() }); list.Add(new Machine() { Instance = machine, MInfo = await machine.GetMInfo() });
} }
List<MachineListItemViewModel> viewmodel_list = new List<MachineListItemViewModel>(); List<MachineListItemViewModel> viewmodel_list = new List<MachineListItemViewModel>();
foreach(Machine machine in list) foreach (Machine machine in list)
{ {
viewmodel_list.Add(new MachineListItemViewModel(machine)); viewmodel_list.Add(new MachineListItemViewModel(machine));
} }
MachineListItemViewModel_List = viewmodel_list; MachineListItemViewModel_List = viewmodel_list;
IsBusy = false;
return await Task.FromResult(true); return await Task.FromResult(true);
} }
#endregion
#region Properties #region Properties
private bool _IsConnected = false;
public bool IsConnected
{
get => _IsConnected;
set => SetProperty(ref _IsConnected, value);
}
private List<MachineListItemViewModel> _MachineListItemViewModel_List; private List<MachineListItemViewModel> _MachineListItemViewModel_List;
public List<MachineListItemViewModel> MachineListItemViewModel_List public List<MachineListItemViewModel> MachineListItemViewModel_List
{ {
@ -88,13 +104,14 @@ namespace Borepin.PageModel
#endregion #endregion
#region INavigationAware #region INavigationAware
public void OnNavigatedFrom(INavigationParameters parameters) public override void OnNavigatedFrom(INavigationParameters parameters)
{ {
} }
public void OnNavigatedTo(INavigationParameters parameters) public override void OnNavigatedTo(INavigationParameters parameters)
{ {
IsBusy = true;
Task.Run(LoadData); Task.Run(LoadData);
} }
#endregion #endregion

View File

@ -1,26 +1,43 @@
using Borepin.Model; using Borepin.Base;
using Borepin.Model;
using Prism.Commands; using Prism.Commands;
using Prism.Mvvm;
using Prism.Navigation; using Prism.Navigation;
using System.Threading.Tasks;
using System.Windows.Input; using System.Windows.Input;
using static FabAccessAPI.Schema.Machine.WriteInterface; using static FabAccessAPI.Schema.Machine.WriteInterface;
namespace Borepin.PageModel namespace Borepin.PageModel
{ {
public class MachinePageModel : BindableBase, INavigationAware public class MachinePageModel : PageModelBase
{ {
private readonly INavigationService _NavigationService; #region Contructors
public MachinePageModel(INavigationService navigationService) : base(navigationService)
public MachinePageModel(INavigationService navigationService)
{ {
_NavigationService = navigationService;
UseMachineCommand = new DelegateCommand(UseMachineCommandExecuted); UseMachineCommand = new DelegateCommand(UseMachineCommandExecuted);
GiveBackMachineCommand = new DelegateCommand(GiveBackMachineCommandExecuted); GiveBackMachineCommand = new DelegateCommand(GiveBackMachineCommandExecuted);
} }
#endregion
#region Data
public override async Task<bool> LoadData()
{
Name = MachineItem.MInfo.Name;
CanUse = MachineItem.MInfo.State == FabAccessAPI.Schema.State.free;
//if (GiveBack == null)
//{
// GiveBack = await MachineItem.Instance.GetGiveBack();
//}
CanGiveBack = GiveBack != null;
IsBusy = false;
return await Task.FromResult(true);
}
#endregion
#region Properties #region Properties
private Machine _MachineItem; private Machine _MachineItem;
public Machine MachineItem public Machine MachineItem
{ {
@ -36,11 +53,11 @@ namespace Borepin.PageModel
} }
private IGiveBack _GiveBack; private IGiveBack _GiveBack;
//public IGiveBack GiveBack public IGiveBack GiveBack
//{ {
// get => _GiveBack; get => _GiveBack;
// set => SetProperty(ref _GiveBack, value); set => SetProperty(ref _GiveBack, value);
//} }
private bool _CanUse; private bool _CanUse;
public bool CanUse public bool CanUse
@ -55,7 +72,6 @@ namespace Borepin.PageModel
get => _CanGiveBack; get => _CanGiveBack;
set => SetProperty(ref _CanGiveBack, value); set => SetProperty(ref _CanGiveBack, value);
} }
#endregion #endregion
#region Commands #region Commands
@ -68,8 +84,8 @@ namespace Borepin.PageModel
private async void UseMachineCommandExecuted() private async void UseMachineCommandExecuted()
{ {
_GiveBack = await MachineItem.Instance.Use(); GiveBack = await MachineItem.Instance.Use();
CanGiveBack = _GiveBack != null; CanGiveBack = GiveBack != null;
MachineItem.MInfo = await MachineItem.Instance.GetMInfo(); MachineItem.MInfo = await MachineItem.Instance.GetMInfo();
@ -85,10 +101,10 @@ namespace Borepin.PageModel
private async void GiveBackMachineCommandExecuted() private async void GiveBackMachineCommandExecuted()
{ {
await _GiveBack.Ret(); await GiveBack.Ret();
_GiveBack = null; GiveBack = null;
CanGiveBack = _GiveBack != null; CanGiveBack = GiveBack != null;
MachineItem.MInfo = await MachineItem.Instance.GetMInfo(); MachineItem.MInfo = await MachineItem.Instance.GetMInfo();
@ -97,20 +113,18 @@ namespace Borepin.PageModel
#endregion #endregion
#region INavigationAware #region INavigationService
public void OnNavigatedFrom(INavigationParameters parameters) public override void OnNavigatedFrom(INavigationParameters parameters)
{ {
} }
public void OnNavigatedTo(INavigationParameters parameters) public override void OnNavigatedTo(INavigationParameters parameters)
{ {
MachineItem = parameters["instance"] as Machine; MachineItem = parameters["instance"] as Machine;
Name = MachineItem.MInfo.Name;
CanUse = MachineItem.MInfo.State == FabAccessAPI.Schema.State.free; IsBusy = true;
CanGiveBack = _GiveBack != null; Task.Run(LoadData);
} }
#endregion #endregion
} }

View File

@ -9,26 +9,30 @@ using Prism.Commands;
using Prism.Navigation; using Prism.Navigation;
using Borepin.Service.Connections; using Borepin.Service.Connections;
using Borepin.Service.BFFH; using Borepin.Service.BFFH;
using Borepin.Base;
namespace Borepin.PageModel namespace Borepin.PageModel
{ {
public class ServerListPageModel : BindableBase, INavigationAware public class ServerListPageModel : PageModelBase
{ {
private readonly INavigationService _NavigationService; #region Private Properties
private readonly IConnectionService _ConnectionService; private readonly IConnectionService _ConnectionService;
private readonly IBFFHService _BFFHService; private readonly IBFFHService _BFFHService;
#endregion
public ServerListPageModel(INavigationService navigationService, IConnectionService connectionService, IBFFHService bffhService) #region Constructors
public ServerListPageModel(INavigationService navigationService, IConnectionService connectionService, IBFFHService bffhService) : base(navigationService)
{ {
_NavigationService = navigationService;
_ConnectionService = connectionService; _ConnectionService = connectionService;
_BFFHService = bffhService; _BFFHService = bffhService;
AddInstancesCommand = new DelegateCommand(AddInstancesCommandExecuted); AddInstancesCommand = new DelegateCommand(AddInstancesCommandExecuted);
SelectInstanceCommand = new DelegateCommand<object>(SelectInstanceCommandExecuted); SelectInstanceCommand = new DelegateCommand<object>(SelectInstanceCommandExecuted);
} }
#endregion
private async Task<bool> LoadData() #region Data
public override async Task<bool> LoadData()
{ {
List<Connection> list = await _ConnectionService.GetConnectionList(); List<Connection> list = await _ConnectionService.GetConnectionList();
if (_BFFHService.ActiveConnection != null) if (_BFFHService.ActiveConnection != null)
@ -47,12 +51,12 @@ namespace Borepin.PageModel
HasActiveConnection = false; HasActiveConnection = false;
} }
//list = (List<Connection>)list.OrderBy(x => x.LastTime);
ServerListItemViewModel_List = list.Select(x => new ServerListItemViewModel(x)).ToList(); ServerListItemViewModel_List = list.Select(x => new ServerListItemViewModel(x)).ToList();
IsBusy = false;
return await Task.FromResult(true); return await Task.FromResult(true);
} }
#endregion
#region Properties #region Properties
private List<ServerListItemViewModel> _ServerListItemViewModel_List; private List<ServerListItemViewModel> _ServerListItemViewModel_List;
@ -117,13 +121,14 @@ namespace Borepin.PageModel
#endregion #endregion
#region INavigationAware #region INavigationAware
public void OnNavigatedFrom(INavigationParameters parameters) public override void OnNavigatedFrom(INavigationParameters parameters)
{ {
} }
public void OnNavigatedTo(INavigationParameters parameters) public override void OnNavigatedTo(INavigationParameters parameters)
{ {
IsBusy = true;
Task.Run(LoadData); Task.Run(LoadData);
} }
#endregion #endregion

View File

@ -1,4 +1,5 @@
using Borepin.Model; using Borepin.Base;
using Borepin.Model;
using Borepin.Service.BFFH; using Borepin.Service.BFFH;
using Borepin.Service.Connections; using Borepin.Service.Connections;
using Borepin.Service.Credentials; using Borepin.Service.Credentials;
@ -11,17 +12,18 @@ using System.Windows.Input;
namespace Borepin.PageModel namespace Borepin.PageModel
{ {
public class ServerPageModel : BindableBase, INavigationAware public class ServerPageModel : PageModelBase
{ {
private readonly INavigationService _NavigationService; #region Private Properties
private readonly IDialogService _DialogService; private readonly IDialogService _DialogService;
private readonly IConnectionService _ConnectionService; private readonly IConnectionService _ConnectionService;
private readonly IBFFHService _BFFHService; private readonly IBFFHService _BFFHService;
private readonly ICredentialService _CredentialService; private readonly ICredentialService _CredentialService;
#endregion
public ServerPageModel(INavigationService navigationService, IDialogService dialogService, IConnectionService connectionService, IBFFHService bffhService, ICredentialService credentialService) #region Constructors
public ServerPageModel(INavigationService navigationService, IDialogService dialogService, IConnectionService connectionService, IBFFHService bffhService, ICredentialService credentialService) : base(navigationService)
{ {
_NavigationService = navigationService;
_DialogService = dialogService; _DialogService = dialogService;
_ConnectionService = connectionService; _ConnectionService = connectionService;
@ -31,6 +33,14 @@ namespace Borepin.PageModel
ConnectCommand = new DelegateCommand(async () => await ConnectCommandExecuted()); ConnectCommand = new DelegateCommand(async () => await ConnectCommandExecuted());
DeleteCommand = new DelegateCommand(DeleteCommandExecuted); DeleteCommand = new DelegateCommand(DeleteCommandExecuted);
} }
#endregion
#region Data
public override Task<bool> LoadData()
{
throw new System.NotImplementedException();
}
#endregion
#region Properties #region Properties
private Connection _Connection_Item; private Connection _Connection_Item;
@ -58,6 +68,8 @@ namespace Borepin.PageModel
private async Task ConnectCommandExecuted() private async Task ConnectCommandExecuted()
{ {
IsBusy = true;
if(IsConnected) if(IsConnected)
{ {
_BFFHService.Disconnect(); _BFFHService.Disconnect();
@ -71,6 +83,8 @@ namespace Borepin.PageModel
IsConnected = true; IsConnected = true;
} }
IsBusy = false;
} }
private ICommand _DeleteCommand; private ICommand _DeleteCommand;
@ -122,16 +136,16 @@ namespace Borepin.PageModel
#endregion #endregion
#region INavigationAware #region INavigationAware
public void OnNavigatedFrom(INavigationParameters parameters) public override void OnNavigatedFrom(INavigationParameters parameters)
{ {
} }
public void OnNavigatedTo(INavigationParameters parameters) public override void OnNavigatedTo(INavigationParameters parameters)
{ {
Connection_Item = parameters["instance"] as Connection; Connection_Item = parameters["instance"] as Connection;
if(_BFFHService.ActiveConnection != null && Connection_Item != null) if (_BFFHService.ActiveConnection != null && Connection_Item != null)
{ {
IsConnected = Connection_Item.Equals(_BFFHService.ActiveConnection); IsConnected = Connection_Item.Equals(_BFFHService.ActiveConnection);
} }
@ -139,6 +153,8 @@ namespace Borepin.PageModel
{ {
IsConnected = false; IsConnected = false;
} }
IsBusy = false;
} }
#endregion #endregion
} }

View File

@ -0,0 +1,39 @@
using Borepin.Base;
using Prism.Navigation;
using System.Threading.Tasks;
namespace Borepin.PageModel
{
class TestPageModel : PageModelBase
{
#region Contructors
public TestPageModel(INavigationService navigationService) : base(navigationService)
{
}
#endregion
#region Data
public override async Task<bool> LoadData()
{
await Task.Delay(3000);
IsBusy = false;
return await Task.FromResult(true);
}
#endregion
#region INavigationService
public override void OnNavigatedFrom(INavigationParameters parameters)
{
}
public override void OnNavigatedTo(INavigationParameters parameters)
{
IsBusy = true;
Task.Run(LoadData);
}
#endregion
}
}

View File

@ -0,0 +1,10 @@
<?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.IsBusyView">
<ContentView.Content>
<StackLayout>
<Label Text="IsBusy" />
</StackLayout>
</ContentView.Content>
</ContentView>

View 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 IsBusyView : ContentView
{
public IsBusyView()
{
InitializeComponent();
}
}
}

View File

@ -113,6 +113,22 @@ namespace FabAccessAPI
return writeCap.Use(); return writeCap.Use();
} }
/// <summary>
/// Try to get a GiveBack capability for a machine.
/// </summary>
/// <returns>Capability to give back the machine or null</returns>
/// <exception cref="UnauthorizedException"></exception>
public Task<Schema.Machine.WriteInterface.IGiveBack> GetGiveBack()
{
var writeCap = _machine.Write;
if (writeCap == null)
{
throw new UnauthorizedException();
}
return writeCap.GetGiveBack();
}
/// <summary> /// <summary>
/// Try to reserve a machine. Throws a UnauthorizedException if the user does not have the required /// Try to reserve a machine. Throws a UnauthorizedException if the user does not have the required
/// permissions to use this machine. /// permissions to use this machine.

@ -1 +1 @@
Subproject commit 4adb05341763b96a43440a6a96e0d9959ba71e89 Subproject commit 2dc488d13b2a8eaa743fb759b4929d50843ccb23