Nu fungerar RoundRunningView med minimal codeBehind
This commit is contained in:
@ -7,6 +7,7 @@ using GreadyPoang.EntityLayer;
|
||||
using GreadyPoang.Services;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Diagnostics;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace GreadyPoang.ViewModelLayer;
|
||||
|
||||
@ -14,6 +15,7 @@ public partial class RoundRunningViewModel : ObservableObject
|
||||
{
|
||||
|
||||
public event EventHandler RebuildRequested;
|
||||
public ICommand OnLoadedCommand { get; }
|
||||
|
||||
public RoundRunningViewModel() : base()
|
||||
{
|
||||
@ -41,6 +43,8 @@ public partial class RoundRunningViewModel : ObservableObject
|
||||
BuilderObject = new();
|
||||
_popupEvent.InfoPopupCloseRequested += infoPopupViewModel_ClosePopupRequested;
|
||||
PopupVisad = false;
|
||||
OnLoadedCommand = new AsyncRelayCommand(OnLoadedAsync, () => true);
|
||||
|
||||
}
|
||||
|
||||
private readonly IRepository<GameRound>? _roundsRepo;
|
||||
@ -57,19 +61,20 @@ public partial class RoundRunningViewModel : ObservableObject
|
||||
private Collection<PlayerColumn> playerColumns;
|
||||
[ObservableProperty]
|
||||
private RoundBuilderElement builderObject;
|
||||
public ObservableCollection<ScoreColumn> ScoreColumns { get; } = new ObservableCollection<ScoreColumn>();
|
||||
|
||||
|
||||
|
||||
private string _activePopupId;
|
||||
|
||||
public bool PopupVisad { get; set; }
|
||||
|
||||
|
||||
public void TriggerRebuild()
|
||||
private async Task OnLoadedAsync()
|
||||
{
|
||||
// Trigga eventet
|
||||
RebuildRequested?.Invoke(this, EventArgs.Empty);
|
||||
await Get();
|
||||
}
|
||||
|
||||
|
||||
public void Get()
|
||||
public async Task Get()
|
||||
{
|
||||
|
||||
if (_objectMessage.CurrentGroup != null)
|
||||
@ -102,10 +107,13 @@ public partial class RoundRunningViewModel : ObservableObject
|
||||
{
|
||||
RoundElements.FirstOrDefault(e => e.ParticipantId == col.PlayerId).GameRegPoints = col.PlayerPoints;
|
||||
}
|
||||
TriggerRebuild();
|
||||
//TriggerRebuild();
|
||||
BuildScore(playerColumns);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[RelayCommand]
|
||||
private void StoreAndHandlePointsAsync()
|
||||
{
|
||||
@ -154,7 +162,8 @@ public partial class RoundRunningViewModel : ObservableObject
|
||||
{
|
||||
RoundElements.FirstOrDefault(e => e.ParticipantId == col.PlayerId).GameRegPoints = col.PlayerPoints;
|
||||
}
|
||||
TriggerRebuild();
|
||||
// TriggerRebuild();
|
||||
BuildScore(playerColumns);
|
||||
Shell.Current.GoToAsync("..").GetAwaiter().GetResult();
|
||||
|
||||
}
|
||||
@ -290,6 +299,38 @@ public partial class RoundRunningViewModel : ObservableObject
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void BuildScore(IEnumerable<PlayerColumn> columns)
|
||||
{
|
||||
ScoreColumns.Clear();
|
||||
|
||||
|
||||
foreach (var column in columns)
|
||||
{
|
||||
var scoreColumn = new ScoreColumn
|
||||
{
|
||||
PlayerName = column.PlayerName
|
||||
};
|
||||
|
||||
scoreColumn.Cells.Add(new ScoreCell
|
||||
{
|
||||
Text = column.PlayerName,
|
||||
IsHeader = true
|
||||
});
|
||||
|
||||
foreach (var value in System.Linq.Enumerable.Reverse(column.Values))
|
||||
{
|
||||
scoreColumn.Cells.Add(new ScoreCell
|
||||
{
|
||||
Text = value,
|
||||
IsHeader = false
|
||||
});
|
||||
}
|
||||
|
||||
ScoreColumns.Add(scoreColumn);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user