diff --git a/Borepin/Borepin/Converter/MachineStateColorConverter.cs b/Borepin/Borepin/Converter/MachineStateColorConverter.cs index a587b28..1857137 100644 --- a/Borepin/Borepin/Converter/MachineStateColorConverter.cs +++ b/Borepin/Borepin/Converter/MachineStateColorConverter.cs @@ -1,4 +1,5 @@ -using System; +using FabAccessAPI.Schema; +using System; using System.Globalization; using Xamarin.Forms; @@ -8,9 +9,9 @@ namespace Borepin.Converter { public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { - switch((FabAccessAPI.Schema.Machine.MachineState)value) + switch((Machine.MachineState)value) { - case (FabAccessAPI.Schema.Machine.MachineState.free): + case Machine.MachineState.free: return (Color)Application.Current.Resources["FirstColor"]; default: return (Color)Application.Current.Resources["SixthColor"]; diff --git a/Borepin/Borepin/Converter/MachineStateStringConverter.cs b/Borepin/Borepin/Converter/MachineStateStringConverter.cs index 6ffc35b..618765f 100644 --- a/Borepin/Borepin/Converter/MachineStateStringConverter.cs +++ b/Borepin/Borepin/Converter/MachineStateStringConverter.cs @@ -1,4 +1,5 @@ -using System; +using FabAccessAPI.Schema; +using System; using System.Globalization; using Xamarin.Forms; @@ -8,19 +9,19 @@ namespace Borepin.Converter { public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { - switch((FabAccessAPI.Schema.Machine.MachineState)value) + switch((Machine.MachineState)value) { - case (FabAccessAPI.Schema.Machine.MachineState.free): + case Machine.MachineState.free: return "Free"; - case (FabAccessAPI.Schema.Machine.MachineState.inUse): + case Machine.MachineState.inUse: return "In Use"; - case (FabAccessAPI.Schema.Machine.MachineState.toCheck): + case Machine.MachineState.toCheck: return "To Check"; - case (FabAccessAPI.Schema.Machine.MachineState.reserved): + case Machine.MachineState.reserved: return "Reserved"; - case (FabAccessAPI.Schema.Machine.MachineState.blocked): + case Machine.MachineState.blocked: return "Blocked"; - case (FabAccessAPI.Schema.Machine.MachineState.disabled): + case Machine.MachineState.disabled: return "Disabled"; default: return "Unknown"; diff --git a/Borepin/Borepin/Model/ConnectionDataVisualize.cs b/Borepin/Borepin/Model/ConnectionDataVisualize.cs new file mode 100644 index 0000000..6692a61 --- /dev/null +++ b/Borepin/Borepin/Model/ConnectionDataVisualize.cs @@ -0,0 +1,54 @@ +using FabAccessAPI; +using Prism.Mvvm; + +namespace Borepin.Model +{ + public class ConnectionDataVisualize : BindableBase + { + #region Private Fields + public readonly ConnectionData _ConnectionData; + #endregion + + #region Constructors + public ConnectionDataVisualize(ConnectionData connectionData) + { + _ConnectionData = connectionData; + + LoadData(); + } + #endregion + + #region Methods + public async void LoadData() + { + + Host = _ConnectionData.Host.Host; + Port = _ConnectionData.Host.Port; + Username = _ConnectionData.Username; + } + #endregion + + #region Fields + private string _Host; + public string Host + { + get => _Host; + set => SetProperty(ref _Host, value); + } + + private int _Port; + public int Port + { + get => _Port; + set => SetProperty(ref _Port, value); + } + + private string _Username; + public string Username + { + get => _Username; + set => SetProperty(ref _Username, value); + } + #endregion + } +} diff --git a/Borepin/Borepin/PageModel/MachineListPageModel.cs b/Borepin/Borepin/PageModel/MachineListPageModel.cs index b02599d..023938f 100644 --- a/Borepin/Borepin/PageModel/MachineListPageModel.cs +++ b/Borepin/Borepin/PageModel/MachineListPageModel.cs @@ -12,20 +12,14 @@ using System; using NaturalSort.Extension; using System.Linq; using Borepin.Service; -using Xamarin.Forms; namespace Borepin.PageModel { public class MachineListPageModel : ConnectionModelBase { - #region Private Fields - private Machine _NextMachine; - #endregion - #region Constructors public MachineListPageModel(INavigationService navigationService, IPageDialogService pageDialogService, IAPIService apiService) : base(navigationService, pageDialogService, apiService) { - SelectInstanceCommand = new DelegateCommand(SelectInstanceCommandExecute); ScanCodeCommand = new DelegateCommand(async () => await ScanCodeCommandExecute().ConfigureAwait(false)); RefreshCommand = new DelegateCommand(async ()=> await RefreshCommandExecute().ConfigureAwait(true)); } @@ -44,21 +38,24 @@ namespace Borepin.PageModel { if(!((InUseInterface_Proxy)machine.Inuse).IsNull) { - MachineListItemViewModel new_viewmodel = new MachineListItemViewModel(machine) + MachineListItemViewModel new_viewmodel = new MachineListItemViewModel(_NavigationService, _PageDialogService) { - IsUserAssigned = true, + IsInUseByMe = true, }; + await new_viewmodel.LoadInstance(machine).ConfigureAwait(false); viewmodel_list_user_assigned.Add(new_viewmodel); } else { - viewmodel_list_not_user_assigned.Add(new MachineListItemViewModel(machine)); + MachineListItemViewModel new_viewmodel = new MachineListItemViewModel(_NavigationService, _PageDialogService); + await new_viewmodel.LoadInstance(machine).ConfigureAwait(false); + viewmodel_list_not_user_assigned.Add(new_viewmodel); } } List viewmodel_list_sorted = new List(); - viewmodel_list_sorted.AddRange(viewmodel_list_user_assigned.OrderBy(x => x.Name, StringComparison.OrdinalIgnoreCase.WithNaturalSort())); - viewmodel_list_sorted.AddRange(viewmodel_list_not_user_assigned.OrderBy(x => x.Name, StringComparison.OrdinalIgnoreCase.WithNaturalSort())); + viewmodel_list_sorted.AddRange(viewmodel_list_user_assigned.OrderBy(x => x.Machine.Name, StringComparison.OrdinalIgnoreCase.WithNaturalSort())); + viewmodel_list_sorted.AddRange(viewmodel_list_not_user_assigned.OrderBy(x => x.Machine.Name, StringComparison.OrdinalIgnoreCase.WithNaturalSort())); MachineListItemViewModel_List = viewmodel_list_sorted; } #endregion @@ -96,31 +93,6 @@ namespace Borepin.PageModel IsRefreshing = false; } - private ICommand _SelectInstanceCommand; - public ICommand SelectInstanceCommand - { - get => _SelectInstanceCommand; - set => SetProperty(ref _SelectInstanceCommand, value); - } - public void SelectInstanceCommandExecute(object obj) - { - MachineListItemViewModel viewmodel = obj as MachineListItemViewModel; - - NavigationParameters parameters = new NavigationParameters - { - { "instance", viewmodel.Instance.Id }, - }; - - Device.BeginInvokeOnMainThread(async () => - { - INavigationResult result = await _NavigationService.NavigateAsync($"MachinePage", parameters).ConfigureAwait(false); - if (result.Exception != null) - { - Log.Fatal(result.Exception, "Navigating failed"); - } - }); - } - private ICommand _ScanCodeCommand; public ICommand ScanCodeCommand { @@ -156,38 +128,8 @@ namespace Borepin.PageModel return; } - _NextMachine = machine; IsBusy = false; } #endregion - - #region IPageLifecycleAware - public void OnAppearing() - { - if(_NextMachine != null) - { - NavigationParameters parameters = new NavigationParameters - { - { "id", _NextMachine.Id}, - }; - - _NextMachine = null; - - Device.BeginInvokeOnMainThread(async () => - { - INavigationResult result = await _NavigationService.NavigateAsync("MachinePage", parameters).ConfigureAwait(false); - if (result.Exception != null) - { - Log.Fatal(result.Exception, "Navigating failed"); - } - }); - } - } - - public void OnDisappearing() - { - - } - #endregion } } diff --git a/Borepin/Borepin/PageModel/ServerListPageModel.cs b/Borepin/Borepin/PageModel/ServerListPageModel.cs index facc9c3..b2d4bb2 100644 --- a/Borepin/Borepin/PageModel/ServerListPageModel.cs +++ b/Borepin/Borepin/PageModel/ServerListPageModel.cs @@ -37,7 +37,8 @@ namespace Borepin.PageModel IList list = await _LoginStorageService.GetList().ConfigureAwait(false); if (_API.IsConnected) { - ActiveConnection = new ServerListItemViewModel(_API.ConnectionData); + ActiveConnection = new ServerListItemViewModel(_NavigationService, _PageDialogService); + await ActiveConnection.LoadInstance(_API.ConnectionData).ConfigureAwait(false); list.Remove(_API.ConnectionData); @@ -48,7 +49,13 @@ namespace Borepin.PageModel HasActiveConnection = false; } - ServerListItemViewModel_List = list.Select(x => new ServerListItemViewModel(x)).ToList(); + ServerListItemViewModel_List = new List(); + foreach (ConnectionData connectionData in list) + { + ServerListItemViewModel serverListItemViewModel = new ServerListItemViewModel(_NavigationService, _PageDialogService); + await serverListItemViewModel.LoadInstance(connectionData).ConfigureAwait(false); + ServerListItemViewModel_List.Add(serverListItemViewModel); + } IsBusy = false; } diff --git a/Borepin/Borepin/View/MachineListItemView.xaml b/Borepin/Borepin/View/MachineListItemView.xaml index 2f2f836..bd4ffac 100644 --- a/Borepin/Borepin/View/MachineListItemView.xaml +++ b/Borepin/Borepin/View/MachineListItemView.xaml @@ -23,12 +23,12 @@ -