From 965ffea7baa3f0ed55d8f7a6a7f6c57f76e3642c Mon Sep 17 00:00:00 2001 From: Yan Maniez Date: Wed, 17 Apr 2019 09:11:53 +0200 Subject: [PATCH] Test + OrderBy --- .../AideDeJeu/Tools/NotifyTaskCompletion.cs | 10 ++++---- AideDeJeu/AideDeJeu/ViewModels/Navigator.cs | 24 ++++++++++++++++++- .../PlayerCharacterEditorViewModel.cs | 2 +- AideDeJeu/AideDeJeu/Views/MainPage.xaml | 19 +++++++++++++++ 4 files changed, 49 insertions(+), 6 deletions(-) diff --git a/AideDeJeu/AideDeJeu/Tools/NotifyTaskCompletion.cs b/AideDeJeu/AideDeJeu/Tools/NotifyTaskCompletion.cs index 85a31c64..63b558fe 100644 --- a/AideDeJeu/AideDeJeu/Tools/NotifyTaskCompletion.cs +++ b/AideDeJeu/AideDeJeu/Tools/NotifyTaskCompletion.cs @@ -6,19 +6,21 @@ namespace AideDeJeu.Tools { public class NotifyTaskCompletion : INotifyPropertyChanged { - public NotifyTaskCompletion(Task task) + private bool ContinueOnCapturedContext = false; + public NotifyTaskCompletion(Task task, bool continueOnCapturedContext = false) { Task = task; + ContinueOnCapturedContext = continueOnCapturedContext; if (task != null && !task.IsCompleted) { - var _ = WatchTaskAsync(task); + var _ = WatchTaskAsync(task, continueOnCapturedContext); } } - private async Task WatchTaskAsync(Task task) + private async Task WatchTaskAsync(Task task, bool continueOnCapturedContext = false) { try { - await task.ConfigureAwait(false); + await task.ConfigureAwait(continueOnCapturedContext); } catch { diff --git a/AideDeJeu/AideDeJeu/ViewModels/Navigator.cs b/AideDeJeu/AideDeJeu/ViewModels/Navigator.cs index 4eaca46b..69be8e53 100644 --- a/AideDeJeu/AideDeJeu/ViewModels/Navigator.cs +++ b/AideDeJeu/AideDeJeu/ViewModels/Navigator.cs @@ -1,4 +1,5 @@ -using AideDeJeu.Views; +using AideDeJeu.Tools; +using AideDeJeu.Views; using AideDeJeuLib; using Rg.Plugins.Popup.Services; using System; @@ -48,10 +49,31 @@ namespace AideDeJeu.ViewModels } } + //private NotifyTaskCompletion _TestNotify = null; + //public NotifyTaskCompletion TestNotify + //{ + // get + // { + // return _TestNotify; + // } + // set + // { + // SetProperty(ref _TestNotify, value); + // } + //} + + //public async Task TestGotoAsync() + //{ + // var page = new Views.MainTabbedPage(); + // Device.BeginInvokeOnMainThread(async() => + // await Navigation.PushAsync(page, true)); + // return true; + //} public async Task GotoLibraryPageAsync() { //await Navigation.PushAsync(new Views.ItemDetailPage(),true); await Navigation.PushAsync(new Views.MainTabbedPage(), true); + //TestNotify = new NotifyTaskCompletion(TestGotoAsync(), true); } private Command _BookmarksCommand = null; diff --git a/AideDeJeu/AideDeJeu/ViewModels/PlayerCharacterEditorViewModel.cs b/AideDeJeu/AideDeJeu/ViewModels/PlayerCharacterEditorViewModel.cs index 9ce788e5..a5fce83b 100644 --- a/AideDeJeu/AideDeJeu/ViewModels/PlayerCharacterEditorViewModel.cs +++ b/AideDeJeu/AideDeJeu/ViewModels/PlayerCharacterEditorViewModel.cs @@ -252,7 +252,7 @@ namespace AideDeJeu.ViewModels expandedRaces.Add(new ExpandedRaceItem() { Race = race, SubRace = null }); } } - return expandedRaces; + return expandedRaces.OrderBy(r => Tools.Helpers.RemoveDiacritics(r.Name)).ToList(); //return await context.Races.Where(r => !r.HasSubRaces).OrderBy(r => Tools.Helpers.RemoveDiacritics(r.Name)).ToListAsync().ConfigureAwait(false); } } diff --git a/AideDeJeu/AideDeJeu/Views/MainPage.xaml b/AideDeJeu/AideDeJeu/Views/MainPage.xaml index 26d5b3dd..f0527e7a 100644 --- a/AideDeJeu/AideDeJeu/Views/MainPage.xaml +++ b/AideDeJeu/AideDeJeu/Views/MainPage.xaml @@ -65,7 +65,26 @@ +