Poängräkning fungerar i RoundRunning
This commit is contained in:
0
Example.cs
Normal file
0
Example.cs
Normal file
@ -5,5 +5,5 @@ namespace GreadyPoang.Services;
|
|||||||
public class ObjectMessageService : IObjectMessageService
|
public class ObjectMessageService : IObjectMessageService
|
||||||
{
|
{
|
||||||
public RoundBuilderGroup CurrentGroup { get; set; }
|
public RoundBuilderGroup CurrentGroup { get; set; }
|
||||||
public bool Delivered { get; set; }
|
public bool Delivered { get; set; } = false;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -1,5 +1,6 @@
|
|||||||
using Common.Library;
|
using Common.Library;
|
||||||
using GreadyPoang.EntityLayer;
|
using GreadyPoang.EntityLayer;
|
||||||
|
using GreadyPoang.Services;
|
||||||
using System.Collections.ObjectModel;
|
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;
|
_Repository = repo;
|
||||||
_sharingService = sharingService;
|
_sharingService = sharingService;
|
||||||
|
_appShell = appShell;
|
||||||
|
_objectMessage = objectMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@ -26,6 +33,8 @@ public class ParticipantViewModel : ViewModelBase
|
|||||||
private ObservableCollection<Participant> _ParticipantList = new();
|
private ObservableCollection<Participant> _ParticipantList = new();
|
||||||
private readonly IRepository<Participant>? _Repository;
|
private readonly IRepository<Participant>? _Repository;
|
||||||
private readonly IMethodSharingService<Participant> _sharingService;
|
private readonly IMethodSharingService<Participant> _sharingService;
|
||||||
|
private readonly AppShellViewModel _appShell;
|
||||||
|
private readonly IObjectMessageService _objectMessage;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region public Properties
|
#region public Properties
|
||||||
@ -55,6 +64,10 @@ public class ParticipantViewModel : ViewModelBase
|
|||||||
#region Get Method
|
#region Get Method
|
||||||
public ObservableCollection<Participant> Get()
|
public ObservableCollection<Participant> Get()
|
||||||
{
|
{
|
||||||
|
if (_appShell.RoundRunningVisible == false)
|
||||||
|
{
|
||||||
|
_objectMessage.Delivered = true;
|
||||||
|
}
|
||||||
ParticipantList = _sharingService.Get();
|
ParticipantList = _sharingService.Get();
|
||||||
return ParticipantList;
|
return ParticipantList;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -62,6 +62,7 @@ public class RoundRunningViewModel : ViewModelBase
|
|||||||
RebuildRequested?.Invoke(this, EventArgs.Empty);
|
RebuildRequested?.Invoke(this, EventArgs.Empty);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Översta raden
|
||||||
public ObservableCollection<RoundBuilderElement> RoundElements
|
public ObservableCollection<RoundBuilderElement> RoundElements
|
||||||
{
|
{
|
||||||
get { return _roundElements; }
|
get { return _roundElements; }
|
||||||
@ -72,6 +73,7 @@ public class RoundRunningViewModel : ViewModelBase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Nedersta strukturen
|
||||||
public Collection<PlayerColumn> PlayerColumns
|
public Collection<PlayerColumn> PlayerColumns
|
||||||
{
|
{
|
||||||
get { return _playerColumns; }
|
get { return _playerColumns; }
|
||||||
@ -122,7 +124,7 @@ public class RoundRunningViewModel : ViewModelBase
|
|||||||
}
|
}
|
||||||
foreach (var item in _objectMessage.CurrentGroup.Elements)
|
foreach (var item in _objectMessage.CurrentGroup.Elements)
|
||||||
{
|
{
|
||||||
_roundElements.Add(item);
|
RoundElements.Add(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Räkna ut vem som är nästa spelare
|
// Räkna ut vem som är nästa spelare
|
||||||
@ -138,6 +140,10 @@ public class RoundRunningViewModel : ViewModelBase
|
|||||||
var localElements = _combined.roundBuilderElementsTotalById(_objectMessage.CurrentGroup.GameRoundId);
|
var localElements = _combined.roundBuilderElementsTotalById(_objectMessage.CurrentGroup.GameRoundId);
|
||||||
|
|
||||||
FillupResultTable(localElements);
|
FillupResultTable(localElements);
|
||||||
|
foreach (var col in _playerColumns)
|
||||||
|
{
|
||||||
|
RoundElements.FirstOrDefault(e => e.ParticipantId == col.PlayerId).GameRegPoints = col.PlayerPoints;
|
||||||
|
}
|
||||||
TriggerRebuild();
|
TriggerRebuild();
|
||||||
}
|
}
|
||||||
return RoundElements;
|
return RoundElements;
|
||||||
@ -206,8 +212,6 @@ public class RoundRunningViewModel : ViewModelBase
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private void FillupResultTable(IEnumerable<RoundBuilderElement> elements)
|
private void FillupResultTable(IEnumerable<RoundBuilderElement> elements)
|
||||||
{
|
{
|
||||||
if (_playerColumns != null)
|
if (_playerColumns != null)
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
using GreadyPoang.DataLayer.Database;
|
using GreadyPoang.DataLayer.Database;
|
||||||
|
using System.Diagnostics;
|
||||||
|
|
||||||
namespace GreadyPoang;
|
namespace GreadyPoang;
|
||||||
|
|
||||||
@ -11,6 +12,18 @@ public partial class App : Application
|
|||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
dataContext.Database.EnsureCreated();
|
dataContext.Database.EnsureCreated();
|
||||||
_services = services;
|
_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)
|
protected override Window CreateWindow(IActivationState? activationState)
|
||||||
|
|||||||
15
GreadyPoang/CommandClasses/MainPageViewModelCommands.cs
Normal file
15
GreadyPoang/CommandClasses/MainPageViewModelCommands.cs
Normal 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)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,5 +1,6 @@
|
|||||||
using Common.Library;
|
using Common.Library;
|
||||||
using GreadyPoang.EntityLayer;
|
using GreadyPoang.EntityLayer;
|
||||||
|
using GreadyPoang.Services;
|
||||||
using GreadyPoang.ViewModelLayer;
|
using GreadyPoang.ViewModelLayer;
|
||||||
using System.Windows.Input;
|
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)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -57,7 +57,7 @@ public class RoundRunningViewModelCommands : RoundRunningViewModel
|
|||||||
{
|
{
|
||||||
base.StoreAndHandlePoints();
|
base.StoreAndHandlePoints();
|
||||||
//await Shell.Current.GoToAsync("..");
|
//await Shell.Current.GoToAsync("..");
|
||||||
await Shell.Current.GoToAsync("Påbörja eller fortsätt Runda");
|
// await Shell.Current.GoToAsync("RoundRunningPage");
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task ToggleSplash()
|
private async Task ToggleSplash()
|
||||||
|
|||||||
@ -3,6 +3,8 @@
|
|||||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||||
xmlns:partial="clr-namespace:GreadyPoang.ViewsPartial"
|
xmlns:partial="clr-namespace:GreadyPoang.ViewsPartial"
|
||||||
x:Class="GreadyPoang.MainPage"
|
x:Class="GreadyPoang.MainPage"
|
||||||
|
xmlns:vm ="clr-namespace:GreadyPoang.CommandClasses"
|
||||||
|
x:DataType="vm:MainPageViewModelCommands"
|
||||||
Background="LightCyan"
|
Background="LightCyan"
|
||||||
Title="{StaticResource ApplicationTitle}">
|
Title="{StaticResource ApplicationTitle}">
|
||||||
<Grid Style="{StaticResource Grid.Page}">
|
<Grid Style="{StaticResource Grid.Page}">
|
||||||
@ -12,7 +14,8 @@
|
|||||||
ViewDescription="Välkommen till Gready">
|
ViewDescription="Välkommen till Gready">
|
||||||
|
|
||||||
</partial:HeaderView>
|
</partial:HeaderView>
|
||||||
<Image Source="snurrtarning.gif"
|
<Image
|
||||||
|
Source="snurrtarning.gif"
|
||||||
IsAnimationPlaying="True"
|
IsAnimationPlaying="True"
|
||||||
HorizontalOptions="Center"
|
HorizontalOptions="Center"
|
||||||
VerticalOptions="Center"
|
VerticalOptions="Center"
|
||||||
|
|||||||
@ -1,11 +1,23 @@
|
|||||||
namespace GreadyPoang;
|
using GreadyPoang.CommandClasses;
|
||||||
|
|
||||||
|
namespace GreadyPoang;
|
||||||
|
|
||||||
public partial class MainPage : ContentPage
|
public partial class MainPage : ContentPage
|
||||||
{
|
{
|
||||||
|
private readonly MainPageViewModelCommands _mainPage;
|
||||||
|
|
||||||
public MainPage()
|
public MainPage(
|
||||||
|
MainPageViewModelCommands mainPage)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
BindingContext = mainPage;
|
||||||
|
_mainPage = mainPage;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnAppearing()
|
||||||
|
{
|
||||||
|
base.OnAppearing();
|
||||||
|
_mainPage.InitMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -68,6 +68,7 @@ public static class MauiProgram
|
|||||||
builder.Services.AddSingleton<SplashViewModelCommands>();
|
builder.Services.AddSingleton<SplashViewModelCommands>();
|
||||||
builder.Services.AddSingleton<ISplashService, SplashService>();
|
builder.Services.AddSingleton<ISplashService, SplashService>();
|
||||||
|
|
||||||
|
builder.Services.AddSingleton<MainPageViewModelCommands>();
|
||||||
|
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
|
|||||||
@ -83,13 +83,16 @@
|
|||||||
</Entry>
|
</Entry>
|
||||||
</Grid>
|
</Grid>
|
||||||
<Button Text="Register Points"
|
<Button Text="Register Points"
|
||||||
|
WidthRequest="100"
|
||||||
Style="{StaticResource HoverButtonRedStyle}"
|
Style="{StaticResource HoverButtonRedStyle}"
|
||||||
Command="{Binding StoreAndHandlePointsCommand}"/>
|
Command="{Binding StoreAndHandlePointsCommand}"/>
|
||||||
<VerticalStackLayout>
|
<VerticalStackLayout >
|
||||||
<Button Text="Visa Splash"
|
<Button Text="Visa Splash"
|
||||||
|
WidthRequest="100"
|
||||||
Style="{StaticResource HoverButtonBlueStyle}"
|
Style="{StaticResource HoverButtonBlueStyle}"
|
||||||
Command="{Binding OnSplashClickedCommand}"/>
|
Command="{Binding OnSplashClickedCommand}"/>
|
||||||
<Button Text="Återgå"
|
<Button Text="Återgå"
|
||||||
|
WidthRequest="100"
|
||||||
Style="{StaticResource HoverButtonBlueStyle}"
|
Style="{StaticResource HoverButtonBlueStyle}"
|
||||||
Command="{Binding GobackCommand}"
|
Command="{Binding GobackCommand}"
|
||||||
IsVisible="{Binding GobackVisible}" />
|
IsVisible="{Binding GobackVisible}" />
|
||||||
|
|||||||
Reference in New Issue
Block a user