Poängräkning fungerar i RoundRunning

This commit is contained in:
2025-10-06 07:04:20 +02:00
parent b567291063
commit 5689765451
13 changed files with 111 additions and 12 deletions

0
Example.cs Normal file
View File

View File

@ -5,5 +5,5 @@ namespace GreadyPoang.Services;
public class ObjectMessageService : IObjectMessageService
{
public RoundBuilderGroup CurrentGroup { get; set; }
public bool Delivered { get; set; }
public bool Delivered { get; set; } = false;
}

View File

@ -0,0 +1,30 @@
using Common.Library;
using GreadyPoang.Services;
namespace GreadyPoang.ViewModelLayer;
public class MainPageViewModel : ViewModelBase
{
private readonly AppShellViewModel _appShell;
private readonly IObjectMessageService _messageService;
public MainPageViewModel(
AppShellViewModel appShell,
IObjectMessageService messageService
) : base()
{
_appShell = appShell;
_messageService = messageService;
}
public void InitMessage()
{
if (_appShell.RoundRunningVisible == false)
{
_messageService.Delivered = true;
}
}
}

View File

@ -1,5 +1,6 @@
using Common.Library;
using GreadyPoang.EntityLayer;
using GreadyPoang.Services;
using System.Collections.ObjectModel;
@ -13,10 +14,16 @@ public class ParticipantViewModel : ViewModelBase
}
public ParticipantViewModel(IRepository<Participant> repo, IMethodSharingService<Participant> sharingService) : base()
public ParticipantViewModel(
IRepository<Participant> repo,
IMethodSharingService<Participant> sharingService,
AppShellViewModel appShell,
IObjectMessageService objectMessage) : base()
{
_Repository = repo;
_sharingService = sharingService;
_appShell = appShell;
_objectMessage = objectMessage;
}
#endregion
@ -26,6 +33,8 @@ public class ParticipantViewModel : ViewModelBase
private ObservableCollection<Participant> _ParticipantList = new();
private readonly IRepository<Participant>? _Repository;
private readonly IMethodSharingService<Participant> _sharingService;
private readonly AppShellViewModel _appShell;
private readonly IObjectMessageService _objectMessage;
#endregion
#region public Properties
@ -55,6 +64,10 @@ public class ParticipantViewModel : ViewModelBase
#region Get Method
public ObservableCollection<Participant> Get()
{
if (_appShell.RoundRunningVisible == false)
{
_objectMessage.Delivered = true;
}
ParticipantList = _sharingService.Get();
return ParticipantList;
}

View File

@ -62,6 +62,7 @@ public class RoundRunningViewModel : ViewModelBase
RebuildRequested?.Invoke(this, EventArgs.Empty);
}
// Översta raden
public ObservableCollection<RoundBuilderElement> RoundElements
{
get { return _roundElements; }
@ -72,6 +73,7 @@ public class RoundRunningViewModel : ViewModelBase
}
}
// Nedersta strukturen
public Collection<PlayerColumn> PlayerColumns
{
get { return _playerColumns; }
@ -122,7 +124,7 @@ public class RoundRunningViewModel : ViewModelBase
}
foreach (var item in _objectMessage.CurrentGroup.Elements)
{
_roundElements.Add(item);
RoundElements.Add(item);
}
// Räkna ut vem som är nästa spelare
@ -138,6 +140,10 @@ public class RoundRunningViewModel : ViewModelBase
var localElements = _combined.roundBuilderElementsTotalById(_objectMessage.CurrentGroup.GameRoundId);
FillupResultTable(localElements);
foreach (var col in _playerColumns)
{
RoundElements.FirstOrDefault(e => e.ParticipantId == col.PlayerId).GameRegPoints = col.PlayerPoints;
}
TriggerRebuild();
}
return RoundElements;
@ -206,8 +212,6 @@ public class RoundRunningViewModel : ViewModelBase
return -1;
}
private void FillupResultTable(IEnumerable<RoundBuilderElement> elements)
{
if (_playerColumns != null)

View File

@ -1,4 +1,5 @@
using GreadyPoang.DataLayer.Database;
using System.Diagnostics;
namespace GreadyPoang;
@ -11,6 +12,18 @@ public partial class App : Application
InitializeComponent();
dataContext.Database.EnsureCreated();
_services = services;
AppDomain.CurrentDomain.UnhandledException += (sender, e) =>
{
if (Debugger.IsAttached)
Debugger.Break();
};
TaskScheduler.UnobservedTaskException += (sender, e) =>
{
if (Debugger.IsAttached)
Debugger.Break();
};
}
protected override Window CreateWindow(IActivationState? activationState)

View File

@ -0,0 +1,15 @@
using GreadyPoang.Services;
using GreadyPoang.ViewModelLayer;
namespace GreadyPoang.CommandClasses;
public class MainPageViewModelCommands : MainPageViewModel
{
public MainPageViewModelCommands(
AppShellViewModel appShell,
IObjectMessageService messageService
) : base(appShell, messageService)
{
}
}

View File

@ -1,5 +1,6 @@
using Common.Library;
using GreadyPoang.EntityLayer;
using GreadyPoang.Services;
using GreadyPoang.ViewModelLayer;
using System.Windows.Input;
@ -13,7 +14,11 @@ public class ParticipantViewModelCommands : ParticipantViewModel
{
}
public ParticipantViewModelCommands(IRepository<Participant> repo, IMethodSharingService<Participant> sharingService) : base(repo, sharingService)
public ParticipantViewModelCommands(
IRepository<Participant> repo,
IMethodSharingService<Participant> sharingService,
AppShellViewModel appShell,
IObjectMessageService objectMessage) : base(repo, sharingService, appShell, objectMessage)
{
}

View File

@ -57,7 +57,7 @@ public class RoundRunningViewModelCommands : RoundRunningViewModel
{
base.StoreAndHandlePoints();
//await Shell.Current.GoToAsync("..");
await Shell.Current.GoToAsync("Påbörja eller fortsätt Runda");
// await Shell.Current.GoToAsync("RoundRunningPage");
}
private async Task ToggleSplash()

View File

@ -3,6 +3,8 @@
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:partial="clr-namespace:GreadyPoang.ViewsPartial"
x:Class="GreadyPoang.MainPage"
xmlns:vm ="clr-namespace:GreadyPoang.CommandClasses"
x:DataType="vm:MainPageViewModelCommands"
Background="LightCyan"
Title="{StaticResource ApplicationTitle}">
<Grid Style="{StaticResource Grid.Page}">
@ -12,7 +14,8 @@
ViewDescription="Välkommen till Gready">
</partial:HeaderView>
<Image Source="snurrtarning.gif"
<Image
Source="snurrtarning.gif"
IsAnimationPlaying="True"
HorizontalOptions="Center"
VerticalOptions="Center"

View File

@ -1,11 +1,23 @@
namespace GreadyPoang;
using GreadyPoang.CommandClasses;
namespace GreadyPoang;
public partial class MainPage : ContentPage
{
private readonly MainPageViewModelCommands _mainPage;
public MainPage()
public MainPage(
MainPageViewModelCommands mainPage)
{
InitializeComponent();
BindingContext = mainPage;
_mainPage = mainPage;
}
protected override void OnAppearing()
{
base.OnAppearing();
_mainPage.InitMessage();
}
}

View File

@ -68,6 +68,7 @@ public static class MauiProgram
builder.Services.AddSingleton<SplashViewModelCommands>();
builder.Services.AddSingleton<ISplashService, SplashService>();
builder.Services.AddSingleton<MainPageViewModelCommands>();
#if DEBUG

View File

@ -83,13 +83,16 @@
</Entry>
</Grid>
<Button Text="Register Points"
WidthRequest="100"
Style="{StaticResource HoverButtonRedStyle}"
Command="{Binding StoreAndHandlePointsCommand}"/>
<VerticalStackLayout>
<Button Text="Visa Splash"
<VerticalStackLayout >
<Button Text="Visa Splash"
WidthRequest="100"
Style="{StaticResource HoverButtonBlueStyle}"
Command="{Binding OnSplashClickedCommand}"/>
<Button Text="Återgå"
WidthRequest="100"
Style="{StaticResource HoverButtonBlueStyle}"
Command="{Binding GobackCommand}"
IsVisible="{Binding GobackVisible}" />