Refactoring

This commit is contained in:
TheJoKlLa 2021-09-20 00:52:15 +02:00
parent 89660160cf
commit 832f54a7d9
25 changed files with 103 additions and 301 deletions

View File

@ -45,7 +45,6 @@ namespace Borepin
containerRegistry.RegisterForNavigation<MachineListPage, MachineListPageModel>();
containerRegistry.RegisterForNavigation<ServerListPage, ServerListPageModel>();
containerRegistry.RegisterForNavigation<ServerPage, ServerPageModel>();
containerRegistry.RegisterForNavigation<ListPage, ListPageModel>();
containerRegistry.RegisterForNavigation<WelcomePage, WelcomePageModel>("SetUpProcess_WelcomePage");
containerRegistry.RegisterForNavigation<ScanPage, ScanPageModel>("SetUpProcess_ScanPage");

View File

@ -68,9 +68,6 @@
<EmbeddedResource Update="Page\AddServerProcess\HostSelectPage.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
<EmbeddedResource Update="Page\ListPage.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
<EmbeddedResource Update="Page\AddServerProcess\LoginChoosePage.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
@ -101,9 +98,6 @@
<EmbeddedResource Update="Page\StartUpDistributorPage.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
<EmbeddedResource Update="Page\TestPage.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
<EmbeddedResource Update="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
@ -115,12 +109,6 @@
<EmbeddedResource Update="Styles\LightTheme.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
<EmbeddedResource Update="View\IsBusyView.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
<EmbeddedResource Update="View\ListItemView.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
<EmbeddedResource Update="View\ScanView.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>

View File

@ -1,19 +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"
xmlns:views="clr-namespace:Borepin.View"
x:Class="Borepin.Page.ListPage">
<ContentPage.Content>
<StackLayout>
<ListView ItemsSource="{Binding ListItemViewModel_List}">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<views:ListItemView />
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackLayout>
</ContentPage.Content>
</ContentPage>

View File

@ -1,15 +0,0 @@

using Xamarin.Forms;
using Xamarin.Forms.Xaml;
namespace Borepin.Page
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class ListPage : ContentPage
{
public ListPage()
{
InitializeComponent();
}
}
}

View File

@ -3,14 +3,26 @@
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Borepin.Page.SetUpProcess.ScanPage"
xmlns:i18n="clr-namespace:Borepin.Helpers"
xmlns:views="clr-namespace:Borepin.View">
xmlns:views="clr-namespace:Borepin.View"
xmlns:converters="clr-namespace:Borepin.Converter">
<NavigationPage.TitleView>
<Label Text="FabAccess" HorizontalOptions="End" Margin="0, 0, 10, 0" VerticalOptions="CenterAndExpand" FontSize="Medium" TextColor="{StaticResource FirstColor}"/>
</NavigationPage.TitleView>
<ContentPage.Resources>
<ResourceDictionary>
<converters:InvertBoolConverter x:Key="InvertBoolConverter"/>
</ResourceDictionary>
</ContentPage.Resources>
<ContentPage.Content>
<ScrollView>
<StackLayout Style="{StaticResource Style_StackLayout_Content}">
<StackLayout Padding="20">
<StackLayout IsVisible="{Binding IsBusy}">
<ActivityIndicator IsRunning="{Binding IsBusy}"></ActivityIndicator>
</StackLayout>
<StackLayout IsVisible="{Binding IsBusy, Converter={StaticResource InvertBoolConverter}}">
<views:ScanView />
<Label Text="{i18n:Translate SetUp_ScanPage_Text}" Style="{StaticResource Style_Label_Text}"/>
<Button Text="{i18n:Translate SetUp_ScanPage_Button}" Command="{Binding NextCommand}" Style="{StaticResource Style_Button_Primary}"/>
</StackLayout>
</ScrollView>
</StackLayout>
</ContentPage.Content>
</ContentPage>

View File

@ -1,21 +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.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

@ -1,20 +0,0 @@
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

@ -31,11 +31,12 @@ namespace Borepin.PageModel.AddServerProcess
#endregion
#region LoadData
public override Task LoadData()
public override async Task LoadData()
{
IsBusy = false;
IsBusy = true;
return Task.CompletedTask;
IsBusy = false;
await Task.CompletedTask;
}
#endregion
@ -124,7 +125,8 @@ namespace Borepin.PageModel.AddServerProcess
public override void OnNavigatedTo(INavigationParameters parameters)
{
IsBusy = true;
Task.Run(LoadData);
}
#endregion
}

View File

@ -16,11 +16,12 @@ namespace Borepin.PageModel.AddServerProcess
#endregion
#region LoadData
public override Task LoadData()
public override async Task LoadData()
{
IsBusy = false;
IsBusy = true;
return Task.CompletedTask;
IsBusy = false;
await Task.CompletedTask;
}
#endregion
@ -50,7 +51,8 @@ namespace Borepin.PageModel.AddServerProcess
public override void OnNavigatedTo(INavigationParameters parameters)
{
IsBusy = true;
Task.Run(LoadData);
}
#endregion
}

View File

@ -30,11 +30,12 @@ namespace Borepin.PageModel.AddServerProcess
#endregion
#region LoadData
public override Task LoadData()
public override async Task LoadData()
{
IsBusy = false;
IsBusy = true;
return Task.CompletedTask;
IsBusy = false;
await Task.CompletedTask;
}
#endregion
@ -98,7 +99,8 @@ namespace Borepin.PageModel.AddServerProcess
public override void OnNavigatedTo(INavigationParameters parameters)
{
IsBusy = true;
Task.Run(LoadData);
}
#endregion
}

View File

@ -1,57 +0,0 @@
using Borepin.Model;
using Borepin.ViewModel;
using Prism.Mvvm;
using System.Collections.Generic;
using System.Windows.Input;
using Xamarin.Forms;
namespace Borepin.PageModel
{
public class ListPageModel : BindableBase
{
public ListPageModel()
{
ListItemViewModel_List = new List<ListItemViewModel>()
{
new ListItemViewModel(
new ListItem()
{
Value1 = "ListItem 1"
}),
new ListItemViewModel(
new ListItem()
{
Value1 = "ListItem 2"
}),
new ListItemViewModel(
new ListItem()
{
Value1 = "ListItem 3"
}),
};
SelectListItemCommand = new Command<object>(SelectListItemCommandExecuted);
}
private List<ListItemViewModel> _ListItemViewModel_List;
public List<ListItemViewModel> ListItemViewModel_List
{
get => _ListItemViewModel_List;
set => SetProperty(ref _ListItemViewModel_List, value);
}
private ICommand _SelectListItemCommand;
public ICommand SelectListItemCommand
{
get => _SelectListItemCommand;
set => SetProperty(ref _SelectListItemCommand, value);
}
private void SelectListItemCommandExecuted(object obj)
{
System.Diagnostics.Debugger.Break();
}
}
}

View File

@ -25,9 +25,11 @@ namespace Borepin.PageModel
}
#endregion
#region Data
#region LoadData
public override async Task LoadData()
{
IsBusy = true;
if (_BFFHService.ActiveConnection == null)
{
IsBusy = false;

View File

@ -28,7 +28,7 @@ namespace Borepin.PageModel
}
#endregion
#region Data
#region LoadData
public override async Task LoadData()
{
IsBusy = true;

View File

@ -1,20 +1,31 @@
using Prism.Mvvm;
using Borepin.Base;
using Prism.Navigation;
using System.Threading.Tasks;
using System.Windows.Input;
using Xamarin.Forms;
namespace Borepin.PageModel
{
public class MainPagePageModel : BindableBase
public class MainPagePageModel : PageModelBase
{
private INavigationService _NavigationService;
public MainPagePageModel(INavigationService navigationService)
#region Constructors
public MainPagePageModel(INavigationService navigationService) : base(navigationService)
{
_NavigationService = navigationService;
NavigateCommand = new Command<string>(NavigateCommandExecuted);
}
#endregion
#region LoadData
public override async Task LoadData()
{
IsBusy = true;
IsBusy = false;
await LoadData();
}
#endregion
#region Commands
private ICommand _NavigationCommand;
public ICommand NavigateCommand
@ -31,5 +42,19 @@ namespace Borepin.PageModel
System.Diagnostics.Debugger.Break();
}
}
#endregion
#region INavigationService
public override void OnNavigatedFrom(INavigationParameters parameters)
{
}
public override void OnNavigatedTo(INavigationParameters parameters)
{
IsBusy = true;
Task.Run(LoadData);
}
#endregion
}
}

View File

@ -31,9 +31,11 @@ namespace Borepin.PageModel
}
#endregion
#region Data
#region LoadData
public override async Task LoadData()
{
IsBusy = true;
List<Connection> list = await _ConnectionService.GetConnectionList();
if (_BFFHService.ActiveConnection != null)
{

View File

@ -37,10 +37,13 @@ namespace Borepin.PageModel
}
#endregion
#region Data
public override Task LoadData()
#region LoadData
public override async Task LoadData()
{
throw new System.NotImplementedException();
IsBusy = true;
IsBusy = false;
await LoadData();
}
#endregion
@ -166,7 +169,8 @@ namespace Borepin.PageModel
IsConnected = false;
}
IsBusy = false;
IsBusy = true;
Task.Run(LoadData);
}
#endregion
}

View File

@ -15,10 +15,13 @@ namespace Borepin.PageModel.SetUpProcess
}
#endregion
#region Data
public override Task LoadData()
#region LoadData
public override async Task LoadData()
{
return Task.CompletedTask;
IsBusy = true;
IsBusy = false;
await Task.CompletedTask;
}
#endregion
@ -47,7 +50,8 @@ namespace Borepin.PageModel.SetUpProcess
public override void OnNavigatedTo(INavigationParameters parameters)
{
IsBusy = true;
Task.Run(LoadData);
}
#endregion
}

View File

@ -15,10 +15,13 @@ namespace Borepin.PageModel.SetUpProcess
}
#endregion
#region Data
public override Task LoadData()
#region LoadData
public override async Task LoadData()
{
return Task.CompletedTask;
IsBusy = true;
IsBusy = false;
await Task.CompletedTask;
}
#endregion
@ -47,7 +50,8 @@ namespace Borepin.PageModel.SetUpProcess
public override void OnNavigatedTo(INavigationParameters parameters)
{
IsBusy = true;
Task.Run(LoadData);
}
#endregion
}

View File

@ -27,9 +27,12 @@ namespace Borepin.PageModel
#endregion
#region LoadData
public override Task LoadData()
public override async Task LoadData()
{
return Task.CompletedTask;
IsBusy = true;
IsBusy = false;
await LoadData();
}
#endregion
@ -75,7 +78,8 @@ namespace Borepin.PageModel
public override void OnNavigatedTo(INavigationParameters parameters)
{
IsBusy = true;
Task.Run(LoadData);
}
#endregion
}

View File

@ -1,39 +0,0 @@
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 Task LoadData()
{
Task.Delay(3000);
IsBusy = false;
return Task.CompletedTask;
}
#endregion
#region INavigationService
public override void OnNavigatedFrom(INavigationParameters parameters)
{
}
public override void OnNavigatedTo(INavigationParameters parameters)
{
IsBusy = true;
Task.Run(LoadData);
}
#endregion
}
}

View File

@ -1,10 +0,0 @@
<?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

@ -1,20 +0,0 @@
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

@ -1,12 +0,0 @@
<?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.ListItemView"
xmlns:pagemodel="clr-namespace:Borepin.PageModel">
<ContentView.Content>
<StackLayout Orientation="Horizontal" HorizontalOptions="Center">
<Label Text="{Binding Value}" />
<Button Text="X" Command="{Binding Source={RelativeSource AncestorType={x:Type pagemodel:ListPageModel}}, Path=SelectListItemCommand}" CommandParameter="{Binding .}" />
</StackLayout>
</ContentView.Content>
</ContentView>

View File

@ -1,15 +0,0 @@

using Xamarin.Forms;
using Xamarin.Forms.Xaml;
namespace Borepin.View
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class ListItemView : ContentView
{
public ListItemView()
{
InitializeComponent();
}
}
}

View File

@ -1,20 +0,0 @@
using Borepin.Model;
using Prism.Mvvm;
namespace Borepin.ViewModel
{
public class ListItemViewModel : BindableBase
{
public ListItemViewModel(ListItem listItem)
{
Value = listItem.Value1;
}
private string _Value;
public string Value
{
get => _Value;
set => SetProperty(ref _Value, value);
}
}
}