Spelrundebilden påbörjad , kommunikation mellan bilder fungerar
This commit is contained in:
13
GreadyPoang.Services/GreadyPoang.Services.csproj
Normal file
13
GreadyPoang.Services/GreadyPoang.Services.csproj
Normal file
@ -0,0 +1,13 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\GreadyPoang.EntityLayer\GreadyPoang.EntityLayer.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@ -0,0 +1,8 @@
|
||||
using GreadyPoang.EntityLayer;
|
||||
|
||||
namespace GreadyPoang.Services;
|
||||
|
||||
public class ObjectMessageService : IObjectMessageService
|
||||
{
|
||||
public RoundBuilderGroup CurrentGroup { get; set; }
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
using GreadyPoang.EntityLayer;
|
||||
|
||||
namespace GreadyPoang.Services;
|
||||
|
||||
public interface IObjectMessageService
|
||||
{
|
||||
RoundBuilderGroup CurrentGroup { get; set; }
|
||||
|
||||
}
|
||||
@ -10,6 +10,7 @@
|
||||
<ProjectReference Include="..\Common.Library\Common.Library.csproj" />
|
||||
<ProjectReference Include="..\GreadyPoang.DataLayer\GreadyPoang.DataLayer.csproj" />
|
||||
<ProjectReference Include="..\GreadyPoang.EntityLayer\GreadyPoang.EntityLayer.csproj" />
|
||||
<ProjectReference Include="..\GreadyPoang.Services\GreadyPoang.Services.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@ -1,7 +1,9 @@
|
||||
using Common.Library;
|
||||
using GreadyPoang.DataLayer;
|
||||
using GreadyPoang.EntityLayer;
|
||||
using GreadyPoang.Services;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace GreadyPoang.ViewModelLayer;
|
||||
|
||||
@ -17,23 +19,54 @@ public class RoundRunningViewModel : ViewModelBase
|
||||
IRepository<GameRound> roundsRepo,
|
||||
IRepository<GamePoint> pointsRepo,
|
||||
IMethodSharingService<Participant> sharingService,
|
||||
ICombinedRepository combined
|
||||
ICombinedRepository combined,
|
||||
IObjectMessageService objectMessage
|
||||
) : base()
|
||||
{
|
||||
_roundsRepo = roundsRepo;
|
||||
_pointsRepo = pointsRepo;
|
||||
_sharingService = sharingService;
|
||||
_combined = combined;
|
||||
_objectMessage = objectMessage;
|
||||
_roundElements = new ObservableCollection<RoundBuilderElement>();
|
||||
}
|
||||
|
||||
private readonly IRepository<GameRound>? _roundsRepo;
|
||||
private readonly IRepository<GamePoint> _pointsRepo;
|
||||
private readonly IMethodSharingService<Participant> _sharingService;
|
||||
private readonly ICombinedRepository _combined;
|
||||
private readonly IObjectMessageService _objectMessage;
|
||||
private ObservableCollection<RoundBuilderElement> _roundElements;
|
||||
|
||||
private ObservableCollection<RoundBuilderGroup> _GameRoundList = new();
|
||||
private ObservableCollection<Participant> _ParticipantList = new();
|
||||
private ObservableCollection<RoundBuilderElement> _roundElements;
|
||||
|
||||
|
||||
public ObservableCollection<RoundBuilderElement> RoundElements
|
||||
{
|
||||
get { return _roundElements; }
|
||||
set
|
||||
{
|
||||
_roundElements = value;
|
||||
RaisePropertyChanged(nameof(RoundElements));
|
||||
}
|
||||
}
|
||||
|
||||
public ObservableCollection<RoundBuilderElement> Get()
|
||||
{
|
||||
if (_objectMessage.CurrentGroup != null)
|
||||
{
|
||||
Debug.WriteLine($"Chosen round: {_objectMessage.CurrentGroup.GameRoundId}");
|
||||
if (RoundElements.Count > 0)
|
||||
{
|
||||
RoundElements.Clear();
|
||||
}
|
||||
foreach (var item in _objectMessage.CurrentGroup.Elements)
|
||||
{
|
||||
_roundElements.Add(item);
|
||||
}
|
||||
}
|
||||
return RoundElements;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
using Common.Library;
|
||||
using GreadyPoang.DataLayer;
|
||||
using GreadyPoang.EntityLayer;
|
||||
using GreadyPoang.Services;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Diagnostics;
|
||||
|
||||
@ -18,12 +19,14 @@ public class RoundStartingViewModel : ViewModelBase
|
||||
IRepository<GameRound> roundsRepo,
|
||||
IRepository<GamePoint> pointsRepo,
|
||||
IMethodSharingService<Participant> sharingService,
|
||||
ICombinedRepository combined) : base()
|
||||
ICombinedRepository combined,
|
||||
IObjectMessageService objectMessage) : base()
|
||||
{
|
||||
_roundsRepo = roundsRepo;
|
||||
_pointsRepo = pointsRepo;
|
||||
_sharingService = sharingService;
|
||||
_combined = combined;
|
||||
_objectMessage = objectMessage;
|
||||
_roundElements = new ObservableCollection<RoundBuilderElement>();
|
||||
}
|
||||
|
||||
@ -36,6 +39,7 @@ public class RoundStartingViewModel : ViewModelBase
|
||||
private readonly IRepository<GamePoint> _pointsRepo;
|
||||
private readonly IMethodSharingService<Participant> _sharingService;
|
||||
private readonly ICombinedRepository _combined;
|
||||
private readonly IObjectMessageService _objectMessage;
|
||||
private Participant _selectedItem;
|
||||
|
||||
private ObservableCollection<RoundBuilderElement> _roundElements;
|
||||
@ -228,7 +232,13 @@ public class RoundStartingViewModel : ViewModelBase
|
||||
|
||||
public void RoundSelected(RoundBuilderElement element)
|
||||
{
|
||||
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;
|
||||
Shell.Current.GoToAsync("//RoundRunningView");
|
||||
}
|
||||
}
|
||||
|
||||
public void SelectNewlyAddedParticipant(RoundBuilderElement roundBuilder)
|
||||
|
||||
@ -15,6 +15,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GreadyPoang.DataLayer", "Gr
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GreadyPoang.Migrations", "GreadyPoang.Migrations\GreadyPoang.Migrations.csproj", "{56EB8207-E108-4498-82AC-BAC8966D3D2D}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GreadyPoang.Services", "GreadyPoang.Services\GreadyPoang.Services.csproj", "{1C70F0EC-370D-4F48-AEDD-DB171D71EA2A}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@ -46,6 +48,10 @@ Global
|
||||
{56EB8207-E108-4498-82AC-BAC8966D3D2D}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{56EB8207-E108-4498-82AC-BAC8966D3D2D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{56EB8207-E108-4498-82AC-BAC8966D3D2D}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{1C70F0EC-370D-4F48-AEDD-DB171D71EA2A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{1C70F0EC-370D-4F48-AEDD-DB171D71EA2A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{1C70F0EC-370D-4F48-AEDD-DB171D71EA2A}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{1C70F0EC-370D-4F48-AEDD-DB171D71EA2A}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
using Common.Library;
|
||||
using GreadyPoang.DataLayer;
|
||||
using GreadyPoang.EntityLayer;
|
||||
using GreadyPoang.Services;
|
||||
using GreadyPoang.ViewModelLayer;
|
||||
using System.Windows.Input;
|
||||
|
||||
@ -16,7 +17,13 @@ public class RoundRunningViewModelCommands : RoundRunningViewModel
|
||||
IRepository<GameRound> roundsRepo,
|
||||
IRepository<GamePoint> pointsRepo,
|
||||
IMethodSharingService<Participant> sharingService,
|
||||
ICombinedRepository combined) : base(roundsRepo, pointsRepo, sharingService, combined)
|
||||
ICombinedRepository combined,
|
||||
IObjectMessageService objectMessage)
|
||||
: base(roundsRepo,
|
||||
pointsRepo,
|
||||
sharingService,
|
||||
combined,
|
||||
objectMessage)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
using Common.Library;
|
||||
using GreadyPoang.DataLayer;
|
||||
using GreadyPoang.EntityLayer;
|
||||
using GreadyPoang.Services;
|
||||
using GreadyPoang.ViewModelLayer;
|
||||
using System.Windows.Input;
|
||||
|
||||
@ -16,7 +17,13 @@ public class RoundStartingViewModelCommands : RoundStartingViewModel
|
||||
IRepository<GameRound> roundsRepo,
|
||||
IRepository<GamePoint> pointsRepo,
|
||||
IMethodSharingService<Participant> sharingService,
|
||||
ICombinedRepository combined) : base(roundsRepo, pointsRepo, sharingService, combined)
|
||||
ICombinedRepository combined,
|
||||
IObjectMessageService objectMessage)
|
||||
: base(roundsRepo,
|
||||
pointsRepo,
|
||||
sharingService,
|
||||
combined,
|
||||
objectMessage)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@ -69,6 +69,7 @@
|
||||
<ProjectReference Include="..\Common.Library\Common.Library.csproj" />
|
||||
<ProjectReference Include="..\GreadyPoang.DataLayer\GreadyPoang.DataLayer.csproj" />
|
||||
<ProjectReference Include="..\GreadyPoang.EntityLayer\GreadyPoang.EntityLayer.csproj" />
|
||||
<ProjectReference Include="..\GreadyPoang.Services\GreadyPoang.Services.csproj" />
|
||||
<ProjectReference Include="..\GreadyPoang.ViewModelLayer\GreadyPoang.ViewModelLayer.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@ -3,6 +3,7 @@ using GreadyPoang.CommandClasses;
|
||||
using GreadyPoang.DataLayer;
|
||||
using GreadyPoang.DataLayer.Database;
|
||||
using GreadyPoang.EntityLayer;
|
||||
using GreadyPoang.Services;
|
||||
using GreadyPoang.ViewModelLayer;
|
||||
using GreadyPoang.Views;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
@ -45,6 +46,8 @@ public static class MauiProgram
|
||||
builder.Services.AddScoped<RoundStartingViewModelCommands>();
|
||||
builder.Services.AddScoped<RoundStartingView>();
|
||||
|
||||
builder.Services.AddSingleton<IObjectMessageService, ObjectMessageService>();
|
||||
|
||||
builder.Services.AddScoped<RoundRunningViewModelCommands>();
|
||||
builder.Services.AddScoped<RoundRunningView>();
|
||||
|
||||
|
||||
@ -2,11 +2,12 @@
|
||||
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||
xmlns:partial="clr-namespace:GreadyPoang.ViewsPartial"
|
||||
xmlns:model="clr-namespace:GreadyPoang.EntityLayer;assembly=GreadyPoang.EntityLayer"
|
||||
xmlns:vm ="clr-namespace:GreadyPoang.ViewModelLayer;assembly=GreadyPoang.ViewModelLayer"
|
||||
x:Class="GreadyPoang.Views.RoundRunningView"
|
||||
Title="RoundRunningView"
|
||||
x:DataType="vm:RoundRunningViewModel">
|
||||
xmlns:vm ="clr-namespace:GreadyPoang.CommandClasses"
|
||||
xmlns:local="clr-namespace:GreadyPoang.EntityLayer;assembly=GreadyPoang.EntityLayer"
|
||||
xmlns:model="clr-namespace:GreadyPoang.EntityLayer;assembly=GreadyPoang.EntityLayer"
|
||||
x:DataType="vm:RoundRunningViewModelCommands"
|
||||
Title="RoundRunningView">
|
||||
|
||||
<Border Style="{StaticResource Border.Page}" StrokeThickness="4">
|
||||
<Grid Style="{StaticResource Grid.Page}">
|
||||
@ -20,20 +21,20 @@
|
||||
ViewTitle="Starta eller fortsätt en registrerad Runda"
|
||||
ViewDescription="Deltagarna visas först!" />
|
||||
<CollectionView Grid.Row="1"
|
||||
ItemsSource="{Binding Participants}"
|
||||
ItemsSource="{Binding RoundElements}"
|
||||
ItemsLayout="HorizontalList"
|
||||
Margin="5"
|
||||
Padding="3">
|
||||
Margin="5">
|
||||
<CollectionView.ItemTemplate>
|
||||
<DataTemplate x:DataType="model:RoundBuilderElement">
|
||||
<Border BorderColor="Gray" Padding="10" Margin="5">
|
||||
<Border Stroke="Gray" Padding="10" Margin="5">
|
||||
<Border.GestureRecognizers>
|
||||
<TapGestureRecognizer
|
||||
Command="{Binding Source={RelativeSource AncestorType={x:Type ContentPage}}, Path=BindingContext.ParticipantTappedCommand}"
|
||||
CommandParameter="{Binding .}" />
|
||||
</Border.GestureRecognizers>
|
||||
|
||||
<VerticalStackLayout>
|
||||
<VerticalStackLayout VerticalOptions="FillAndExpand">
|
||||
<Label Text="Spelare" />
|
||||
<Label Text="{Binding ParticipantName}" FontAttributes="Bold" />
|
||||
<Label Text="{Binding GameRegPoints, StringFormat='Poäng: {0}'}" />
|
||||
<Label Text="{Binding Status}" />
|
||||
@ -43,6 +44,7 @@
|
||||
</DataTemplate>
|
||||
</CollectionView.ItemTemplate>
|
||||
</CollectionView>
|
||||
<Label Text="{Binding RoundElements.Count, StringFormat='Antal: {0}'}" />
|
||||
</Grid>
|
||||
|
||||
</Border>
|
||||
|
||||
@ -14,7 +14,8 @@ public partial class RoundRunningView : ContentPage
|
||||
{
|
||||
base.OnAppearing();
|
||||
BindingContext = ViewModel;
|
||||
ViewModel.Get();
|
||||
}
|
||||
public RoundRunningViewModelCommands ViewModel { get; set; }
|
||||
public int GameRoundId { get; set; }
|
||||
//public int GameRoundId { get; set; }
|
||||
}
|
||||
Reference in New Issue
Block a user