diff --git a/Borepin/Borepin.UWP/Package.appxmanifest b/Borepin/Borepin.UWP/Package.appxmanifest index 837242f..f509582 100644 --- a/Borepin/Borepin.UWP/Package.appxmanifest +++ b/Borepin/Borepin.UWP/Package.appxmanifest @@ -53,5 +53,7 @@ + + \ No newline at end of file diff --git a/Borepin/Borepin/App.xaml.cs b/Borepin/Borepin/App.xaml.cs index 400aa87..0ef9f00 100644 --- a/Borepin/Borepin/App.xaml.cs +++ b/Borepin/Borepin/App.xaml.cs @@ -12,6 +12,7 @@ using Borepin.PageModel.AddServerProcess; using System; using Borepin.Service.Storage; using NLog; +using Borepin.Service.ErrorMessage; namespace Borepin { @@ -69,6 +70,7 @@ namespace Borepin #region Register Service containerRegistry.RegisterSingleton(); + containerRegistry.RegisterSingleton(); // NEED PLATFORM SPECIFIC SERVICE // IPreferenceStorageService diff --git a/Borepin/Borepin/Base/ConnectionModelBase.cs b/Borepin/Borepin/Base/ConnectionModelBase.cs index a07360e..de1759a 100644 --- a/Borepin/Borepin/Base/ConnectionModelBase.cs +++ b/Borepin/Borepin/Base/ConnectionModelBase.cs @@ -1,5 +1,6 @@ using Borepin.Service; using FabAccessAPI; +using NLog; using Prism.Navigation; using Prism.Services; using System; @@ -30,49 +31,29 @@ namespace Borepin.Base #endregion #region Methods - public async void OnConnectionStatusChanged(object sender, ConnectionStatusChange args) + public async void OnConnectionStatusChanged(object sender, ConnectionStatusChanged args) { switch(args) { - case ConnectionStatusChange.Connected: + case ConnectionStatusChanged.Connected: IsConnected = true; + IsConnecting = false; try { await LoadAPIData().ConfigureAwait(false); } - catch + catch(Exception exception) { - IsConnected = false; - await _API.Disconnect().ConfigureAwait(false); - _API.UnbindAllEvents(); + Log.Warn("Load API Data failed", exception); } break; - case ConnectionStatusChange.Reconnected: - try - { - await ReloadAPIData().ConfigureAwait(false); - } - catch - { - IsConnected = false; - await _API.Disconnect().ConfigureAwait(false); - _API.UnbindAllEvents(); - } - break; - case ConnectionStatusChange.ConnectionLoss: - try - { - await _API.Reconnect().ConfigureAwait(false); - } - catch - { - IsConnected = false; - await _API.Disconnect().ConfigureAwait(false); - _API.UnbindAllEvents(); - } - break; - case ConnectionStatusChange.Disconnected: + case ConnectionStatusChanged.ConnectionLoss: IsConnected = false; + IsConnecting = true; + break; + case ConnectionStatusChanged.Disconnected: + IsConnected = false; + IsConnecting = false; break; } } @@ -81,22 +62,28 @@ namespace Borepin.Base { return Task.CompletedTask; } - public virtual Task ReloadAPIData() - { - return Task.CompletedTask; - } #endregion #region Fields /// /// PageModel is Connected /// - private bool _IsConnected = true; + private bool _IsConnected = false; public bool IsConnected { get => _IsConnected; set => SetProperty(ref _IsConnected, value); } + + /// + /// PageModel is Connecting + /// + private bool _IsConnecting = false; + public bool IsConnecting + { + get => _IsConnecting; + set => SetProperty(ref _IsConnecting, value); + } #endregion #region INavigationAware @@ -110,11 +97,9 @@ namespace Borepin.Base { await LoadAPIData().ConfigureAwait(false); } - catch(Exception ex) + catch(Exception exception) { - IsConnected = false; - await _API.Disconnect().ConfigureAwait(false); - _API.UnbindAllEvents(); + Log.Warn("Load API Data failed", exception); } } } diff --git a/Borepin/Borepin/Base/ErrorMessages.cs b/Borepin/Borepin/Base/ErrorMessages.cs new file mode 100644 index 0000000..c53a915 --- /dev/null +++ b/Borepin/Borepin/Base/ErrorMessages.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Borepin.Base +{ + public static class ErrorMessages + { + + } +} diff --git a/Borepin/Borepin/Converter/AllTrueBoolConverter.cs b/Borepin/Borepin/Converter/AllTrueBoolConverter.cs new file mode 100644 index 0000000..0cfaae5 --- /dev/null +++ b/Borepin/Borepin/Converter/AllTrueBoolConverter.cs @@ -0,0 +1,35 @@ +using System; +using System.Globalization; +using Xamarin.Forms; + +namespace Borepin.Converter +{ + public class AllTrueBoolConverter : IMultiValueConverter + { + public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) + { + if (values == null || !targetType.IsAssignableFrom(typeof(bool))) + { + return false; + } + + foreach (var value in values) + { + if (!(value is bool b)) + { + return false; + } + else if (!b) + { + return false; + } + } + return true; + } + + public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) + { + throw new NotSupportedException(); + } + } +} diff --git a/Borepin/Borepin/Page/AddUserPage.xaml b/Borepin/Borepin/Page/AddUserPage.xaml index 9cdceb5..3ec8089 100644 --- a/Borepin/Borepin/Page/AddUserPage.xaml +++ b/Borepin/Borepin/Page/AddUserPage.xaml @@ -3,29 +3,30 @@ xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="Borepin.Page.AddUserPage" xmlns:converters="clr-namespace:Borepin.Converter" - xmlns:resource_text="clr-namespace:Borepin.Resources.Text" + xmlns:resource_text="clr-namespace:Borepin.Resources.Text" + xmlns:views="clr-namespace:Borepin.View" Title="{x:Static resource_text:TextResource.TITLE_AddUser}"> + - - - - - - + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + diff --git a/Borepin/Borepin/Page/MachinePage.xaml b/Borepin/Borepin/Page/MachinePage.xaml index 3a0576f..99ebf23 100644 --- a/Borepin/Borepin/Page/MachinePage.xaml +++ b/Borepin/Borepin/Page/MachinePage.xaml @@ -3,51 +3,61 @@ xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="Borepin.Page.MachinePage" xmlns:converters="clr-namespace:Borepin.Converter" - xmlns:resource_text="clr-namespace:Borepin.Resources.Text" + xmlns:resource_text="clr-namespace:Borepin.Resources.Text" + xmlns:views="clr-namespace:Borepin.View" Title="{x:Static resource_text:TextResource.TITLE_Machine}"> - - + + - + + + - - - + + + + + + + + +