diff --git a/GreadyPoang.ViewModelLayer/ViewModelClasses/InfoPopupViewModel.cs b/GreadyPoang.ViewModelLayer/ViewModelClasses/InfoPopupViewModel.cs index 66fdd39..fe8f3c5 100644 --- a/GreadyPoang.ViewModelLayer/ViewModelClasses/InfoPopupViewModel.cs +++ b/GreadyPoang.ViewModelLayer/ViewModelClasses/InfoPopupViewModel.cs @@ -31,7 +31,6 @@ public partial class InfoPopupViewModel : ObservableObject, IQueryAttributable [RelayCommand] private async Task Cancel() { - //await _popupService.ClosePopupAsync(Shell.Current); _popupEvent.RaiseInfoPopupClose(PopupId); } diff --git a/GreadyPoang.ViewModelLayer/ViewModelClasses/ParticipantViewModel.cs b/GreadyPoang.ViewModelLayer/ViewModelClasses/ParticipantViewModel.cs index a0c8c62..02772c2 100644 --- a/GreadyPoang.ViewModelLayer/ViewModelClasses/ParticipantViewModel.cs +++ b/GreadyPoang.ViewModelLayer/ViewModelClasses/ParticipantViewModel.cs @@ -23,15 +23,12 @@ public partial class ParticipantViewModel : BaseViewModel IMethodSharingService sharingService, IPopupService popupService, IPopupEventHub popupEvent - //, - //InfoPopupViewModel infoPopupViewModel ) : base() { _Repository = repo; _sharingService = sharingService; _popupService = popupService; _popupEvent = popupEvent; - //_infoPopupViewModel = infoPopupViewModel; ParticipantObject = new Participant(); ParticipantList = new ObservableCollection(); IsSaveCommandEnabled = true; @@ -55,13 +52,11 @@ public partial class ParticipantViewModel : BaseViewModel #endregion + public bool PopupVisad { get; set; } [ObservableProperty] private bool isSaveCommandEnabled; - public bool PopupVisad { get; set; } - - #region Get Method public ObservableCollection Get() { @@ -131,25 +126,6 @@ public partial class ParticipantViewModel : BaseViewModel } - - //[RelayCommand(CanExecute = nameof(IsSaveCommandEnabled))] - //private async Task Save() - //{ - // if (_Repository == null || ParticipantObject == null) - // { - // return false; - // } - // var tmpTask = _Repository.Save(ParticipantObject); - // int tmp = tmpTask.GetAwaiter().GetResult(); - // if (tmp != -1) - // { - // ParticipantObject = new Participant(); - // this.Get(); - // await Shell.Current.GoToAsync(".."); - // } - // return tmp != -1; - //} - [RelayCommand] private void DeleteAsync(Participant pp) { @@ -173,11 +149,6 @@ public partial class ParticipantViewModel : BaseViewModel }, loadingMessage: "Laddar data..."); } - //private void ClosePopup() - //{ - // _popupService.ClosePopupAsync(Shell.Current).GetAwaiter().GetResult(); - //} - private async void infoPopupViewModel_ClosePopupRequested(object? sender, PopupCloseEventArgs e) { if (e.PopupId != _activePopupId) diff --git a/GreadyPoang.ViewModelLayer/ViewModelClasses/RoundRunningViewModel.cs b/GreadyPoang.ViewModelLayer/ViewModelClasses/RoundRunningViewModel.cs index a4bea12..c091cfd 100644 --- a/GreadyPoang.ViewModelLayer/ViewModelClasses/RoundRunningViewModel.cs +++ b/GreadyPoang.ViewModelLayer/ViewModelClasses/RoundRunningViewModel.cs @@ -51,9 +51,6 @@ public partial class RoundRunningViewModel : ObservableObject private readonly IPopupService _popupService; private readonly IPopupEventHub _popupEvent; - //private ObservableCollection _GameRoundList = new(); - //private ObservableCollection _ParticipantList = new(); - [ObservableProperty] private ObservableCollection roundElements; [ObservableProperty] @@ -72,11 +69,9 @@ public partial class RoundRunningViewModel : ObservableObject } - - public ObservableCollection Get() + public void Get() { - if (_objectMessage.CurrentGroup != null) { //CurrentGroup är satt frÃ¥n RoundStarting ViewModel @@ -109,7 +104,6 @@ public partial class RoundRunningViewModel : ObservableObject } TriggerRebuild(); } - return RoundElements; } [RelayCommand] @@ -248,8 +242,9 @@ public partial class RoundRunningViewModel : ObservableObject if (player.PlayerPoints > 10000) { var winner = RoundElements.FirstOrDefault(e => e.ParticipantId == player.PlayerId); + var oldStatus = winner.Status; winner.Status = GamePointStatus.Winning; - if (playerPointsOld < 10000) + if (playerPointsOld < 10000 && oldStatus != winner.Status) { Show_a_Popup( player.PlayerName, @@ -265,7 +260,6 @@ public partial class RoundRunningViewModel : ObservableObject } } } - //oldPart = element.ParticipantId; if (!PlayerColumns.Contains(player)) { diff --git a/GreadyPoang.ViewModelLayer/ViewModelClasses/RoundStartingViewModel.cs b/GreadyPoang.ViewModelLayer/ViewModelClasses/RoundStartingViewModel.cs index 4b84b0d..f4cf789 100644 --- a/GreadyPoang.ViewModelLayer/ViewModelClasses/RoundStartingViewModel.cs +++ b/GreadyPoang.ViewModelLayer/ViewModelClasses/RoundStartingViewModel.cs @@ -203,18 +203,15 @@ public partial class RoundStartingViewModel : ObservableObject } [RelayCommand] - public async Task RoundSelected(RoundBuilderElement element) + public async Task RoundSelected(RoundBuilderElement element) { - bool goneOk = false; var rbGroup = GameRoundList.FirstOrDefault(g => g.GameRoundId == element.GameRoundId); Debug.WriteLine($"Du valde raden med Runda {element.GameRoundId} och spelare: {element.ParticipantName}"); if (rbGroup != null) { _objectMessage.CurrentGroup = rbGroup; await Shell.Current.GoToAsync("//RoundRunningView"); - goneOk = true; } - return goneOk; } [RelayCommand] diff --git a/GreadyPoang/Views/RoundRunningView.xaml.cs b/GreadyPoang/Views/RoundRunningView.xaml.cs index 4be0d73..4998953 100644 --- a/GreadyPoang/Views/RoundRunningView.xaml.cs +++ b/GreadyPoang/Views/RoundRunningView.xaml.cs @@ -10,18 +10,22 @@ public partial class RoundRunningView : ContentPage InitializeComponent(); ViewModel = viewModel; ViewModel.RebuildRequested += ViewModel_RebuildRequested; + this.Loaded += OnPageLoaded; + } + + private void OnPageLoaded(object? sender, EventArgs e) + { + ViewModel.Get(); } protected override void OnAppearing() { base.OnAppearing(); BindingContext = ViewModel; - ViewModel.Get(); - //BuildScoreGrid(ViewModel.PlayerColumns); // <-- här bygger du layouten - - } + + private void ViewModel_RebuildRequested(object? sender, EventArgs e) { BuildScoreGrid(ViewModel.PlayerColumns); // <-- här bygger du layouten