diff --git a/Sources/LeagueOfLegends.sln b/Sources/LeagueOfLegends.sln index de98555..0570b00 100644 --- a/Sources/LeagueOfLegends.sln +++ b/Sources/LeagueOfLegends.sln @@ -17,7 +17,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StubLib", "StubLib\StubLib. EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "View", "View\View.csproj", "{E247FCE5-AD0E-4E6B-BD8C-D01E99BE059C}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ViewModel", "ViewModel\ViewModel.csproj", "{C118DE32-F945-4ED9-8E2E-B6A9EA7B9B17}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ViewModels", "ViewModels\ViewModels.csproj", "{571BD072-7A40-4900-BCD3-30A81DFCE449}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -45,10 +45,10 @@ Global {E247FCE5-AD0E-4E6B-BD8C-D01E99BE059C}.Debug|Any CPU.Build.0 = Debug|Any CPU {E247FCE5-AD0E-4E6B-BD8C-D01E99BE059C}.Release|Any CPU.ActiveCfg = Release|Any CPU {E247FCE5-AD0E-4E6B-BD8C-D01E99BE059C}.Release|Any CPU.Build.0 = Release|Any CPU - {C118DE32-F945-4ED9-8E2E-B6A9EA7B9B17}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {C118DE32-F945-4ED9-8E2E-B6A9EA7B9B17}.Debug|Any CPU.Build.0 = Debug|Any CPU - {C118DE32-F945-4ED9-8E2E-B6A9EA7B9B17}.Release|Any CPU.ActiveCfg = Release|Any CPU - {C118DE32-F945-4ED9-8E2E-B6A9EA7B9B17}.Release|Any CPU.Build.0 = Release|Any CPU + {571BD072-7A40-4900-BCD3-30A81DFCE449}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {571BD072-7A40-4900-BCD3-30A81DFCE449}.Debug|Any CPU.Build.0 = Debug|Any CPU + {571BD072-7A40-4900-BCD3-30A81DFCE449}.Release|Any CPU.ActiveCfg = Release|Any CPU + {571BD072-7A40-4900-BCD3-30A81DFCE449}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Sources/View/MauiProgram.cs b/Sources/View/MauiProgram.cs index 8563f67..8298437 100644 --- a/Sources/View/MauiProgram.cs +++ b/Sources/View/MauiProgram.cs @@ -2,7 +2,7 @@ using Model; using StubLib; using View.Page; -using ViewModel; +using ViewModels; using CommunityToolkit.Maui; using View.ModelViewPage; namespace View; @@ -20,10 +20,11 @@ public static class MauiProgram fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular"); fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold"); }); - + builder.Services.AddSingleton().AddSingleton(); builder.Services.AddTransient(); builder.Services.AddTransient(); + builder.Services.AddTransient(); #if DEBUG builder.Logging.AddDebug(); diff --git a/Sources/View/ModelViewPage/ChampionDetailViewM.cs b/Sources/View/ModelViewPage/ChampionDetailViewM.cs index 55849e5..b5f399d 100644 --- a/Sources/View/ModelViewPage/ChampionDetailViewM.cs +++ b/Sources/View/ModelViewPage/ChampionDetailViewM.cs @@ -1,6 +1,6 @@ using System; using View.Page; -using ViewModel; +using ViewModels; namespace View.ModelViewPage { diff --git a/Sources/View/ModelViewPage/ChampionsViewM.cs b/Sources/View/ModelViewPage/ChampionsViewM.cs index 122c5a0..dbc889f 100644 --- a/Sources/View/ModelViewPage/ChampionsViewM.cs +++ b/Sources/View/ModelViewPage/ChampionsViewM.cs @@ -1,24 +1,29 @@ using System; -using ViewModel; +using ViewModels; using View.Page; using Model; using System.Windows.Input; using static StubLib.StubData; +using System.Collections.ObjectModel; namespace View.ModelViewPage { public class ChampionsViewM { - public ICommand NextPageCommand { get; private set; } + public Command NextPageCommand { get; private set; } public Command PreviousPageCommand { get; } public Command EditChampionCommand { get; } public ChampionManagerVM championManagerVm { get; } + public Command DeleteChampionCommand { get; private set; } + public ChampionsViewM(ChampionManagerVM championManager) + { championManagerVm = championManager; PushToDetailCommand = new Command(PushToDetail); - NextPageCommand = new Command(NextPage); + DeleteChampionCommand = new Command(async (ChampionVm obj) => await championManagerVm.DeleteChampion(obj)); + NextPageCommand = new Command(NextPage, CanExecuteNext); PreviousPageCommand = new Command(PreviousPage, CanExecutePrevious); AddChampionCommand = new Command(Addchampion); @@ -38,11 +43,16 @@ namespace View.ModelViewPage { return championManagerVm.Index > 1; } + private bool CanExecuteNext() + { + var val = (this.championManagerVm.Index) < this.championManagerVm.PageTotale; + return val; + } void RefreshCanExecute() { PreviousPageCommand.ChangeCanExecute(); - + NextPageCommand.ChangeCanExecute(); } public Command PushToDetailCommand { get; } @@ -57,7 +67,7 @@ namespace View.ModelViewPage { Shell.Current.Navigation.PushAsync(page: new AddChampionPage(new EditChampionViewM(championManagerVm, new EditChampionVm(null), null))); } - + } } diff --git a/Sources/View/ModelViewPage/EditChampionViewM.cs b/Sources/View/ModelViewPage/EditChampionViewM.cs index d42fc31..b6cecb9 100644 --- a/Sources/View/ModelViewPage/EditChampionViewM.cs +++ b/Sources/View/ModelViewPage/EditChampionViewM.cs @@ -1,5 +1,7 @@ using System; -using ViewModel; +using System.Collections.ObjectModel; +using Model; +using ViewModels; namespace View.ModelViewPage { @@ -24,15 +26,21 @@ namespace View.ModelViewPage private ChampionManagerVM Manager; public EditChampionVm EditableChampion { get; } private ChampionVm ChampionVM; + public Command SaveChampionCommand { get; } + private async void SaveChampion() { Manager.SaveChampion(EditableChampion, ChampionVM); await Shell.Current.Navigation.PopAsync(); } - + public ReadOnlyDictionary Characteristics + { + get => Characteristics; + } + private async Task PickIcon() diff --git a/Sources/View/Page/AddChampionPage.xaml b/Sources/View/Page/AddChampionPage.xaml index 5147793..7e13817 100644 --- a/Sources/View/Page/AddChampionPage.xaml +++ b/Sources/View/Page/AddChampionPage.xaml @@ -17,13 +17,13 @@ @@ -32,11 +32,33 @@ - - + +