Compare commits
9 Commits
d586c96ddf
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 02a26871c6 | |||
| c00819bec6 | |||
| fa6c1e125f | |||
| 5689765451 | |||
| b567291063 | |||
| a449dbeab3 | |||
| 11f0594233 | |||
| cbf018a890 | |||
| f1077febc4 |
29
Common.Library/BaseClasses/CommonBase.cs
Normal file
29
Common.Library/BaseClasses/CommonBase.cs
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
using System.ComponentModel;
|
||||||
|
|
||||||
|
namespace Common.Library;
|
||||||
|
|
||||||
|
public abstract class CommonBase : INotifyPropertyChanged
|
||||||
|
{
|
||||||
|
#region Constructor
|
||||||
|
protected CommonBase()
|
||||||
|
{
|
||||||
|
Init();
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Init Method
|
||||||
|
public virtual void Init()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
#region RaisePropertyChanged Method
|
||||||
|
public event PropertyChangedEventHandler? PropertyChanged;
|
||||||
|
public virtual void RaisePropertyChanged(string propertyName)
|
||||||
|
{
|
||||||
|
this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
5
Common.Library/BaseClasses/EntityBase.cs
Normal file
5
Common.Library/BaseClasses/EntityBase.cs
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
namespace Common.Library;
|
||||||
|
|
||||||
|
public class EntityBase : CommonBase
|
||||||
|
{
|
||||||
|
}
|
||||||
14
Common.Library/BaseClasses/ViewModelBase.cs
Normal file
14
Common.Library/BaseClasses/ViewModelBase.cs
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
//using GreadyPoang.DataLayer;
|
||||||
|
|
||||||
|
namespace Common.Library;
|
||||||
|
public class ViewModelBase : CommonBase
|
||||||
|
{
|
||||||
|
//private readonly LocalDbService _dbService;
|
||||||
|
|
||||||
|
//public ViewModelBase(LocalDbService dbService)
|
||||||
|
//{
|
||||||
|
// _dbService = dbService;
|
||||||
|
//}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@ -1,15 +1,15 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net9.0</TargetFramework>
|
<TargetFrameworks>
|
||||||
|
net9.0-android;
|
||||||
|
net9.0-ios;
|
||||||
|
net9.0-maccatalyst;
|
||||||
|
net9.0-windows10.0.19041
|
||||||
|
</TargetFrameworks>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="CommunityToolkit.Maui" Version="12.2.0" />
|
|
||||||
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.4.0" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@ -1,39 +0,0 @@
|
|||||||
using CommunityToolkit.Maui.Alerts;
|
|
||||||
using CommunityToolkit.Mvvm.ComponentModel;
|
|
||||||
|
|
||||||
namespace GreadyPoang.Core;
|
|
||||||
public partial class BaseViewModel : ObservableObject
|
|
||||||
{
|
|
||||||
[ObservableProperty]
|
|
||||||
private bool isBusy;
|
|
||||||
|
|
||||||
protected async Task RunAsyncCommand(Func<Task> action, string loadingMessage = null, string errorMessage = "Ett fel inträffade")
|
|
||||||
{
|
|
||||||
if (IsBusy) return;
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
IsBusy = true;
|
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(loadingMessage))
|
|
||||||
await Snackbar.Make(
|
|
||||||
message: loadingMessage,
|
|
||||||
duration: TimeSpan.FromSeconds(2),
|
|
||||||
action: null).Show();
|
|
||||||
|
|
||||||
await action.Invoke();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
await Snackbar.Make(
|
|
||||||
message: $"{errorMessage}: {ex.Message}",
|
|
||||||
duration: TimeSpan.FromSeconds(3),
|
|
||||||
action: () => Console.WriteLine("Åtgärd vald")).Show();
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
IsBusy = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
0
Example.cs
Normal file
0
Example.cs
Normal file
15
GreadyPoang.CommandClasses/GreadyPoang.CommandClasses.csproj
Normal file
15
GreadyPoang.CommandClasses/GreadyPoang.CommandClasses.csproj
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net9.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\Common.Library\Common.Library.csproj" />
|
||||||
|
<ProjectReference Include="..\GreadyPoang.EntityLayer\GreadyPoang.EntityLayer.csproj" />
|
||||||
|
<ProjectReference Include="..\GreadyPoang.ViewModelLayer\GreadyPoang.ViewModelLayer.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
public class BehaviorBase<T> : Behavior<T> where T : BindableObject
|
public class BehaviorBase<T> : Behavior<T> where T : BindableObject
|
||||||
{
|
{
|
||||||
public T AssociatedObject { get; private set; }
|
public T? AssociatedObject { get; private set; }
|
||||||
|
|
||||||
protected override void OnAttachedTo(T bindable)
|
protected override void OnAttachedTo(T bindable)
|
||||||
{
|
{
|
||||||
@ -22,8 +22,9 @@ public class BehaviorBase<T> : Behavior<T> where T : BindableObject
|
|||||||
AssociatedObject = null;
|
AssociatedObject = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnBindingContextChanged(object sender, EventArgs e)
|
void OnBindingContextChanged(object? sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
if (AssociatedObject != null)
|
||||||
BindingContext = AssociatedObject.BindingContext;
|
BindingContext = AssociatedObject.BindingContext;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,13 +1,17 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net9.0</TargetFramework>
|
<TargetFrameworks>
|
||||||
|
net9.0-android;
|
||||||
|
net9.0-ios;
|
||||||
|
net9.0-maccatalyst;
|
||||||
|
net9.0-windows10.0.19041
|
||||||
|
</TargetFrameworks>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.4.0" />
|
|
||||||
<PackageReference Include="Microsoft.Maui.Controls" Version="9.0.100" />
|
<PackageReference Include="Microsoft.Maui.Controls" Version="9.0.100" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|||||||
@ -2,21 +2,27 @@
|
|||||||
|
|
||||||
namespace GreadyPoang.Common;
|
namespace GreadyPoang.Common;
|
||||||
|
|
||||||
public class DigitsOnlyBehavior : Behavior<Entry>
|
public class DigitsOnlyBehavior : Behavior<Entry?>
|
||||||
{
|
{
|
||||||
protected override void OnAttachedTo(Entry entry)
|
protected override void OnAttachedTo(Entry? entry)
|
||||||
|
{
|
||||||
|
if (entry != null)
|
||||||
{
|
{
|
||||||
entry.TextChanged += OnTextChanged;
|
entry.TextChanged += OnTextChanged;
|
||||||
|
}
|
||||||
base.OnAttachedTo(entry);
|
base.OnAttachedTo(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnDetachingFrom(Entry entry)
|
protected override void OnDetachingFrom(Entry? entry)
|
||||||
|
{
|
||||||
|
if (entry != null)
|
||||||
{
|
{
|
||||||
entry.TextChanged -= OnTextChanged;
|
entry.TextChanged -= OnTextChanged;
|
||||||
|
}
|
||||||
base.OnDetachingFrom(entry);
|
base.OnDetachingFrom(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnTextChanged(object sender, TextChangedEventArgs e)
|
private void OnTextChanged(object? sender, TextChangedEventArgs e)
|
||||||
{
|
{
|
||||||
var entry = sender as Entry;
|
var entry = sender as Entry;
|
||||||
if (entry == null) return;
|
if (entry == null) return;
|
||||||
|
|||||||
@ -4,7 +4,7 @@ using System.Windows.Input;
|
|||||||
namespace GreadyPoang.Common;
|
namespace GreadyPoang.Common;
|
||||||
public class EventToCommandBehavior : BehaviorBase<VisualElement>
|
public class EventToCommandBehavior : BehaviorBase<VisualElement>
|
||||||
{
|
{
|
||||||
public string EventName { get; set; }
|
public required string EventName { get; set; }
|
||||||
|
|
||||||
public static readonly BindableProperty CommandProperty =
|
public static readonly BindableProperty CommandProperty =
|
||||||
BindableProperty.Create(nameof(Command), typeof(ICommand), typeof(EventToCommandBehavior));
|
BindableProperty.Create(nameof(Command), typeof(ICommand), typeof(EventToCommandBehavior));
|
||||||
@ -15,8 +15,9 @@ public class EventToCommandBehavior : BehaviorBase<VisualElement>
|
|||||||
set => SetValue(CommandProperty, value);
|
set => SetValue(CommandProperty, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
private EventInfo eventInfo;
|
// Fix for CS8618: Make the field nullable and fix IDE1006: Add '_' prefix
|
||||||
private Delegate eventHandler;
|
private EventInfo? _eventInfo;
|
||||||
|
private Delegate? _eventHandler;
|
||||||
|
|
||||||
protected override void OnAttachedTo(VisualElement bindable)
|
protected override void OnAttachedTo(VisualElement bindable)
|
||||||
{
|
{
|
||||||
@ -25,21 +26,29 @@ public class EventToCommandBehavior : BehaviorBase<VisualElement>
|
|||||||
if (bindable == null || string.IsNullOrEmpty(EventName))
|
if (bindable == null || string.IsNullOrEmpty(EventName))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
eventInfo = bindable.GetType().GetRuntimeEvent(EventName);
|
var runtimeEvent = bindable.GetType().GetRuntimeEvent(EventName);
|
||||||
if (eventInfo == null)
|
if (runtimeEvent == null)
|
||||||
throw new ArgumentException($"Event '{EventName}' not found on type '{bindable.GetType().Name}'");
|
throw new ArgumentException($"Event '{EventName}' not found on type '{bindable.GetType().Name}'");
|
||||||
|
|
||||||
MethodInfo methodInfo = typeof(EventToCommandBehavior).GetTypeInfo().GetDeclaredMethod(nameof(OnEvent));
|
_eventInfo = runtimeEvent;
|
||||||
eventHandler = methodInfo.CreateDelegate(eventInfo.EventHandlerType, this);
|
|
||||||
eventInfo.AddEventHandler(bindable, eventHandler);
|
MethodInfo? methodInfo = typeof(EventToCommandBehavior).GetTypeInfo().GetDeclaredMethod(nameof(OnEvent));
|
||||||
|
if (methodInfo == null)
|
||||||
|
throw new InvalidOperationException($"Method '{nameof(OnEvent)}' not found on type '{typeof(EventToCommandBehavior).Name}'");
|
||||||
|
|
||||||
|
if (_eventInfo.EventHandlerType == null)
|
||||||
|
throw new InvalidOperationException($"EventHandlerType for event '{EventName}' is null on type '{bindable.GetType().Name}'");
|
||||||
|
|
||||||
|
_eventHandler = methodInfo.CreateDelegate(_eventInfo.EventHandlerType, this);
|
||||||
|
_eventInfo.AddEventHandler(bindable, _eventHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnDetachingFrom(VisualElement bindable)
|
protected override void OnDetachingFrom(VisualElement bindable)
|
||||||
{
|
{
|
||||||
base.OnDetachingFrom(bindable);
|
base.OnDetachingFrom(bindable);
|
||||||
|
|
||||||
if (eventInfo != null && eventHandler != null)
|
if (_eventInfo != null && _eventHandler != null)
|
||||||
eventInfo.RemoveEventHandler(bindable, eventHandler);
|
_eventInfo.RemoveEventHandler(bindable, _eventHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnEvent(object sender, object eventArgs)
|
private void OnEvent(object sender, object eventArgs)
|
||||||
|
|||||||
@ -1,12 +0,0 @@
|
|||||||
using System.Globalization;
|
|
||||||
|
|
||||||
namespace GreadyPoang.Common;
|
|
||||||
|
|
||||||
public class HeaderColorConverter : IValueConverter
|
|
||||||
{
|
|
||||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) =>
|
|
||||||
(bool)value ? Colors.DarkGray : Colors.Yellow;
|
|
||||||
|
|
||||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) =>
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
@ -1,35 +0,0 @@
|
|||||||
using System.Windows.Input;
|
|
||||||
|
|
||||||
namespace GreadyPoang.Common;
|
|
||||||
|
|
||||||
public class LoadedBehavior
|
|
||||||
{
|
|
||||||
public static readonly BindableProperty CommandProperty =
|
|
||||||
BindableProperty.CreateAttached(
|
|
||||||
"Command",
|
|
||||||
typeof(ICommand),
|
|
||||||
typeof(LoadedBehavior),
|
|
||||||
null,
|
|
||||||
propertyChanged: OnCommandChanged);
|
|
||||||
|
|
||||||
public static ICommand GetCommand(BindableObject view) =>
|
|
||||||
(ICommand)view.GetValue(CommandProperty);
|
|
||||||
|
|
||||||
public static void SetCommand(BindableObject view, ICommand value) =>
|
|
||||||
view.SetValue(CommandProperty, value);
|
|
||||||
|
|
||||||
private static void OnCommandChanged(BindableObject bindable, object oldValue, object newValue)
|
|
||||||
{
|
|
||||||
if (bindable is VisualElement element && newValue is ICommand command)
|
|
||||||
{
|
|
||||||
element.Loaded += (s, e) =>
|
|
||||||
{
|
|
||||||
if (command.CanExecute(null))
|
|
||||||
{
|
|
||||||
command.Execute(null);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -59,7 +59,7 @@ public class CombinedRepository : ICombinedRepository
|
|||||||
(p.LastName || ' ' || p.FirstName) AS ParticipantName
|
(p.LastName || ' ' || p.FirstName) AS ParticipantName
|
||||||
FROM GamePoints gp
|
FROM GamePoints gp
|
||||||
INNER JOIN (
|
INNER JOIN (
|
||||||
SELECT ParticipantId, GameRoundId, MAX(GamePointId) AS MaxGamePointId, sum(GameRegPoints) AS totPoints
|
SELECT ParticipantId, GameRoundId, MAX(GamePointId) AS MaxGamePointId , sum(GameRegPoints) AS totPoints
|
||||||
FROM GamePoints
|
FROM GamePoints
|
||||||
GROUP BY ParticipantId, GameRoundId
|
GROUP BY ParticipantId, GameRoundId
|
||||||
) latest ON gp.GamePointId = latest.MaxGamePointId
|
) latest ON gp.GamePointId = latest.MaxGamePointId
|
||||||
@ -74,7 +74,7 @@ public class CombinedRepository : ICombinedRepository
|
|||||||
public IEnumerable<RoundBuilderElement> roundBuilderElementsDbById(int GameId)
|
public IEnumerable<RoundBuilderElement> roundBuilderElementsDbById(int GameId)
|
||||||
{
|
{
|
||||||
var result = _context.RoundBuilderElements
|
var result = _context.RoundBuilderElements
|
||||||
.FromSqlRaw($@"
|
.FromSql($@"
|
||||||
SELECT
|
SELECT
|
||||||
gp.GamePointId,
|
gp.GamePointId,
|
||||||
gp.GameRoundId,
|
gp.GameRoundId,
|
||||||
|
|||||||
@ -1,7 +1,12 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net9.0</TargetFramework>
|
<TargetFrameworks>
|
||||||
|
net9.0-android;
|
||||||
|
net9.0-ios;
|
||||||
|
net9.0-maccatalyst;
|
||||||
|
net9.0-windows10.0.19041
|
||||||
|
</TargetFrameworks>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
@ -11,7 +16,6 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.4.0" />
|
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.8">
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.8">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
|||||||
@ -1,42 +1,97 @@
|
|||||||
using CommunityToolkit.Mvvm.ComponentModel;
|
using Common.Library;
|
||||||
using SQLite;
|
using SQLite;
|
||||||
|
|
||||||
namespace GreadyPoang.EntityLayer;
|
namespace GreadyPoang.EntityLayer;
|
||||||
[Table("GamePoint")]
|
[Table("GamePoint")]
|
||||||
public partial class GamePoint : ObservableObject
|
public class GamePoint : EntityBase
|
||||||
{
|
{
|
||||||
public GamePoint()
|
public GamePoint()
|
||||||
{
|
{
|
||||||
GamePointId = 0;
|
_gamePointId = 0;
|
||||||
ParticipantId = 0;
|
_participantId = 0;
|
||||||
GameRoundId = 0;
|
_gameRoundId = 0;
|
||||||
GameDate = DateTime.Now;
|
_gameDate = DateTime.Now;
|
||||||
GameRoundRegNr = 0;
|
_gameRoundRegNr = 0;
|
||||||
GameRegPoints = 0;
|
_gameRegPoints = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
[ObservableProperty]
|
private int _gamePointId;
|
||||||
[property: PrimaryKey, AutoIncrement, Column("GamePointId")]
|
private int _participantId;
|
||||||
private int gamePointId;
|
private int _gameRoundId;
|
||||||
|
private DateTime _gameDate;
|
||||||
|
private int _gameRoundRegNr;
|
||||||
|
private int _gameRegPoints;
|
||||||
|
|
||||||
[ObservableProperty]
|
[PrimaryKey]
|
||||||
[property: Column("ParticipantId")]
|
[AutoIncrement]
|
||||||
private int participantId;
|
[Column("GamePointId")]
|
||||||
|
public int GamePointId
|
||||||
|
{
|
||||||
|
get { return _gamePointId; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_gamePointId = value;
|
||||||
|
RaisePropertyChanged(nameof(GamePointId));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[ObservableProperty]
|
[Column("ParticipantId")]
|
||||||
[property: Column("GameRoundId")]
|
public int ParticipantId
|
||||||
private int gameRoundId;
|
{
|
||||||
|
get { return _participantId; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_participantId = value;
|
||||||
|
RaisePropertyChanged(nameof(ParticipantId));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[Column("GameRoundId")]
|
||||||
|
public int GameRoundId
|
||||||
|
{
|
||||||
|
get { return _gameRoundId; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_gameRoundId = value;
|
||||||
|
RaisePropertyChanged(nameof(GameRoundId));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[ObservableProperty]
|
[Column("GameDate")]
|
||||||
[property: Column("GameDate")]
|
public DateTime GameDate
|
||||||
private DateTime gameDate;
|
{
|
||||||
|
get { return _gameDate; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_gameDate = value;
|
||||||
|
RaisePropertyChanged(nameof(GameDate));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// GameRoundRegNr räknas upp när en spelare får en ny gamepoint inlagd
|
||||||
|
// Alltså hans/hennes senaste i samma runda uppräknad med 1
|
||||||
|
|
||||||
|
[Column("GameRoundRegNr")]
|
||||||
|
public int GameRoundRegNr
|
||||||
|
{
|
||||||
|
get { return _gameRoundRegNr; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_gameRoundRegNr = value;
|
||||||
|
RaisePropertyChanged(nameof(GameRoundRegNr));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Column("GameRegPoints")]
|
||||||
|
public int GameRegPoints
|
||||||
|
{
|
||||||
|
get { return _gameRegPoints; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_gameRegPoints = value;
|
||||||
|
RaisePropertyChanged(nameof(GameRegPoints));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[ObservableProperty]
|
|
||||||
[property: Column("GameRoundRegNr")]
|
|
||||||
private int gameRoundRegNr;
|
|
||||||
|
|
||||||
[ObservableProperty]
|
|
||||||
[property: Column("GameRegPoints")]
|
|
||||||
private int gameRegPoints;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
using CommunityToolkit.Mvvm.ComponentModel;
|
using Common.Library;
|
||||||
using SQLite;
|
using SQLite;
|
||||||
|
|
||||||
namespace GreadyPoang.EntityLayer;
|
namespace GreadyPoang.EntityLayer;
|
||||||
@ -6,34 +6,72 @@ namespace GreadyPoang.EntityLayer;
|
|||||||
|
|
||||||
[Table("GameRound")]
|
[Table("GameRound")]
|
||||||
|
|
||||||
public partial class GameRound : ObservableObject
|
public class GameRound : EntityBase
|
||||||
{
|
{
|
||||||
public GameRound()
|
public GameRound()
|
||||||
{
|
{
|
||||||
GameRoundId = 0;
|
_gameRoundId = 0;
|
||||||
GameRoundStartDate = DateTime.Now;
|
_gameRoundStartDate = DateTime.Now;
|
||||||
GameStatus = GamePointStatus.New;
|
_gameStatus = GamePointStatus.New;
|
||||||
GameRoundFinished = null;
|
_gameRoundFinished = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
[ObservableProperty]
|
private int _gameRoundId;
|
||||||
[property: PrimaryKey, AutoIncrement, Column("GameRoundId")]
|
private DateTime _gameRoundStartDate;
|
||||||
private int gameRoundId;
|
private GamePointStatus _gameStatus;
|
||||||
|
private DateTime? _gameRoundFinished;
|
||||||
|
|
||||||
[ObservableProperty]
|
[Column("GameRoundFinished")]
|
||||||
[property: Column("GameRoundStartDate")]
|
public DateTime? GameRoundFinished
|
||||||
private DateTime gameRoundStartDate;
|
{
|
||||||
|
get { return _gameRoundFinished; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_gameRoundFinished = value;
|
||||||
|
RaisePropertyChanged(nameof(GameRoundFinished));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[ObservableProperty]
|
[Column("GameRoundStartDate")]
|
||||||
[property: Column("GameStatus")]
|
public DateTime GameRoundStartDate
|
||||||
private GamePointStatus gameStatus;
|
{
|
||||||
|
get { return _gameRoundStartDate; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_gameRoundStartDate = value;
|
||||||
|
RaisePropertyChanged(nameof(GameRoundStartDate));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[ObservableProperty]
|
[Column("GameStatus")]
|
||||||
[property: Column("GameRoundFinished")]
|
public GamePointStatus GameStatus
|
||||||
private DateTime? gameRoundFinished;
|
{
|
||||||
|
get { return _gameStatus; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_gameStatus = value;
|
||||||
|
RaisePropertyChanged(nameof(GameStatus));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[PrimaryKey]
|
||||||
|
[AutoIncrement]
|
||||||
|
[Column("GameRoundId")]
|
||||||
|
public int GameRoundId
|
||||||
|
{
|
||||||
|
get { return _gameRoundId; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_gameRoundId = value;
|
||||||
|
RaisePropertyChanged(nameof(GameRoundId));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public string GameRoundStartDateString
|
public string GameRoundStartDateString
|
||||||
{
|
{
|
||||||
get { return GameRoundStartDate.ToString("yyyy-MM-dd"); }
|
get { return _gameRoundStartDate.ToString("yyyy-MM-dd"); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,32 +1,67 @@
|
|||||||
using CommunityToolkit.Mvvm.ComponentModel;
|
using Common.Library;
|
||||||
using SQLite;
|
using SQLite;
|
||||||
|
|
||||||
namespace GreadyPoang.EntityLayer;
|
namespace GreadyPoang.EntityLayer;
|
||||||
[Table("Participants")]
|
[Table("Participants")]
|
||||||
public partial class Participant : ObservableObject
|
public class Participant : EntityBase
|
||||||
{
|
{
|
||||||
public Participant()
|
public Participant()
|
||||||
{
|
{
|
||||||
FirstName = string.Empty;
|
_firstName = string.Empty;
|
||||||
LastName = string.Empty;
|
_lastName = string.Empty;
|
||||||
Email = string.Empty;
|
_email = string.Empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
[ObservableProperty]
|
private int _participantId;
|
||||||
[property: PrimaryKey, AutoIncrement, Column("ParticipantId")]
|
private string _firstName;
|
||||||
private int participantId;
|
private string _lastName;
|
||||||
|
private string _email;
|
||||||
|
|
||||||
[ObservableProperty]
|
[PrimaryKey]
|
||||||
[property: Column("FirstName")]
|
[AutoIncrement]
|
||||||
private string firstName;
|
[Column("ParticipantId")]
|
||||||
|
public int ParticipantId
|
||||||
|
{
|
||||||
|
get { return _participantId; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_participantId = value;
|
||||||
|
RaisePropertyChanged(nameof(ParticipantId));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[ObservableProperty]
|
[Column("FirstName")]
|
||||||
[property: Column("LastName")]
|
public string FirstName
|
||||||
private string lastName;
|
{
|
||||||
|
get { return _firstName; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_firstName = value;
|
||||||
|
RaisePropertyChanged(nameof(FirstName));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[ObservableProperty]
|
[Column("LastName")]
|
||||||
[property: Column("Email")]
|
public string LastName
|
||||||
private string email;
|
{
|
||||||
|
get { return _lastName; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_lastName = value;
|
||||||
|
RaisePropertyChanged(nameof(LastName));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Column("Email")]
|
||||||
|
public string Email
|
||||||
|
{
|
||||||
|
get { return _email; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_email = value;
|
||||||
|
RaisePropertyChanged(nameof(Email));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public string FullName
|
public string FullName
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1,7 +1,12 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net9.0</TargetFramework>
|
<TargetFrameworks>
|
||||||
|
net9.0-android;
|
||||||
|
net9.0-ios;
|
||||||
|
net9.0-maccatalyst;
|
||||||
|
net9.0-windows10.0.19041
|
||||||
|
</TargetFrameworks>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
@ -11,7 +16,6 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.4.0" />
|
|
||||||
<PackageReference Include="sqlite-net-pcl" Version="1.9.172" />
|
<PackageReference Include="sqlite-net-pcl" Version="1.9.172" />
|
||||||
<PackageReference Include="SQLitePCLRaw.bundle_green" Version="2.1.11" />
|
<PackageReference Include="SQLitePCLRaw.bundle_green" Version="2.1.11" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|||||||
@ -1,27 +1,55 @@
|
|||||||
using CommunityToolkit.Mvvm.ComponentModel;
|
using Common.Library;
|
||||||
|
|
||||||
namespace GreadyPoang.EntityLayer;
|
namespace GreadyPoang.EntityLayer;
|
||||||
|
|
||||||
public partial class PlayerColumn : ObservableObject
|
public class PlayerColumn : EntityBase
|
||||||
{
|
{
|
||||||
public PlayerColumn()
|
public PlayerColumn()
|
||||||
{
|
{
|
||||||
PlayerName = string.Empty;
|
_playerName = string.Empty;
|
||||||
Values = new List<string>();
|
_values = new List<string>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
[ObservableProperty]
|
private int _playerId;
|
||||||
private int playerId;
|
private string _playerName;
|
||||||
|
private List<string> _values;
|
||||||
|
public string PlayerName
|
||||||
|
{
|
||||||
|
get { return _playerName; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_playerName = value;
|
||||||
|
RaisePropertyChanged(nameof(PlayerName));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public List<string> Values
|
||||||
|
{
|
||||||
|
get { return _values; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_values = value;
|
||||||
|
RaisePropertyChanged(nameof(Values));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[ObservableProperty]
|
public int PlayerId
|
||||||
private string playerName;
|
{
|
||||||
|
get { return _playerId; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_playerId = value;
|
||||||
|
RaisePropertyChanged(nameof(PlayerId));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[ObservableProperty]
|
private int _playerPoints;
|
||||||
private List<string> values;
|
|
||||||
|
|
||||||
[ObservableProperty]
|
public int PlayerPoints
|
||||||
private int playerPoints;
|
{
|
||||||
|
get { return _playerPoints; }
|
||||||
|
set { _playerPoints = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,55 +1,125 @@
|
|||||||
using CommunityToolkit.Mvvm.ComponentModel;
|
using Common.Library;
|
||||||
|
|
||||||
namespace GreadyPoang.EntityLayer;
|
namespace GreadyPoang.EntityLayer;
|
||||||
|
|
||||||
public partial class RoundBuilderElement : ObservableObject
|
public class RoundBuilderElement : EntityBase
|
||||||
{
|
{
|
||||||
public RoundBuilderElement()
|
public RoundBuilderElement()
|
||||||
{
|
{
|
||||||
ParticipantId = 0;
|
_participantId = 0;
|
||||||
ParticipantName = string.Empty;
|
_participantName = string.Empty;
|
||||||
GameRoundRegNr = 0;
|
_gameRoundRegNr = 0;
|
||||||
GameRegPoints = 0;
|
_gameRegPoints = 0;
|
||||||
Status = GamePointStatus.New;
|
_status = GamePointStatus.New;
|
||||||
GameRoundStartDate = DateTime.MinValue;
|
_gameRoundStartDate = DateTime.MinValue;
|
||||||
GameRoundId = 0;
|
_gameRoundId = 0;
|
||||||
GamePointId = 0;
|
_gamePointId = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
[ObservableProperty]
|
private int _participantId;
|
||||||
private int participantId;
|
private string _participantName;
|
||||||
|
private int _gameRoundRegNr;
|
||||||
|
private int _gameRegPoints;
|
||||||
|
private GamePointStatus _status;
|
||||||
|
private DateTime _gameRoundStartDate;
|
||||||
|
private int _gameRoundId;
|
||||||
|
private int _gamePointId;
|
||||||
|
|
||||||
[ObservableProperty]
|
public int ParticipantId
|
||||||
private string participantName;
|
{
|
||||||
|
get { return _participantId; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_participantId = value;
|
||||||
|
RaisePropertyChanged(nameof(ParticipantId));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[ObservableProperty]
|
|
||||||
private int gameRoundRegNr;
|
|
||||||
|
|
||||||
[ObservableProperty]
|
public string ParticipantName
|
||||||
private int gameRegPoints;
|
{
|
||||||
|
get { return _participantName; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_participantName = value;
|
||||||
|
RaisePropertyChanged(nameof(ParticipantName));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[ObservableProperty]
|
|
||||||
[NotifyPropertyChangedFor(nameof(StatusString))]
|
|
||||||
private GamePointStatus status;
|
|
||||||
|
|
||||||
[ObservableProperty]
|
public int GameRoundRegNr
|
||||||
[NotifyPropertyChangedFor(nameof(GameRoundStartDateString))]
|
{
|
||||||
private DateTime gameRoundStartDate;
|
get { return _gameRoundRegNr; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_gameRoundRegNr = value;
|
||||||
|
RaisePropertyChanged(nameof(GameRoundRegNr));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[ObservableProperty]
|
|
||||||
private int gameRoundId;
|
|
||||||
|
|
||||||
[ObservableProperty]
|
public int GameRegPoints
|
||||||
private int gamePointId;
|
{
|
||||||
|
get { return _gameRegPoints; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_gameRegPoints = value;
|
||||||
|
RaisePropertyChanged(nameof(GameRegPoints));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public GamePointStatus Status
|
||||||
|
{
|
||||||
|
get { return _status; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_status = value;
|
||||||
|
RaisePropertyChanged(nameof(Status));
|
||||||
|
RaisePropertyChanged(nameof(StatusString));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public string StatusString
|
public string StatusString
|
||||||
{
|
{
|
||||||
get { return status.ToString(); }
|
get { return _status.ToString(); }
|
||||||
|
}
|
||||||
|
|
||||||
|
public DateTime GameRoundStartDate
|
||||||
|
{
|
||||||
|
get { return _gameRoundStartDate; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_gameRoundStartDate = value;
|
||||||
|
RaisePropertyChanged(nameof(GameRoundStartDate));
|
||||||
|
RaisePropertyChanged(nameof(GameRoundStartDateString));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GameRoundStartDateString
|
public string GameRoundStartDateString
|
||||||
{
|
{
|
||||||
get { return gameRoundStartDate.ToString("yyyy-MM-dd"); }
|
get { return _gameRoundStartDate.ToString("yyyy-MM-dd"); }
|
||||||
|
}
|
||||||
|
|
||||||
|
public int GameRoundId
|
||||||
|
{
|
||||||
|
get { return _gameRoundId; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_gameRoundId = value;
|
||||||
|
RaisePropertyChanged(nameof(GameRoundId));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public int GamePointId
|
||||||
|
{
|
||||||
|
get { return _gamePointId; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_gamePointId = value;
|
||||||
|
RaisePropertyChanged(nameof(GamePointId));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,26 +1,56 @@
|
|||||||
using CommunityToolkit.Mvvm.ComponentModel;
|
using Common.Library;
|
||||||
|
|
||||||
namespace GreadyPoang.EntityLayer;
|
namespace GreadyPoang.EntityLayer;
|
||||||
|
|
||||||
public partial class RoundBuilderGroup : ObservableObject
|
public class RoundBuilderGroup : EntityBase
|
||||||
{
|
{
|
||||||
public RoundBuilderGroup()
|
public RoundBuilderGroup()
|
||||||
{
|
{
|
||||||
GameRoundId = 0;
|
_gameRoundId = 0;
|
||||||
GameRoundStartDate = DateTime.MinValue;
|
_gameRoundStartDate = DateTime.MinValue;
|
||||||
Status = GamePointStatus.New;
|
_status = GamePointStatus.New;
|
||||||
Elements = new List<RoundBuilderElement>();
|
_elements = new List<RoundBuilderElement>();
|
||||||
|
}
|
||||||
|
private int _gameRoundId;
|
||||||
|
private DateTime _gameRoundStartDate;
|
||||||
|
private GamePointStatus _status;
|
||||||
|
private List<RoundBuilderElement> _elements;
|
||||||
|
public int GameRoundId
|
||||||
|
{
|
||||||
|
get { return _gameRoundId; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_gameRoundId = value;
|
||||||
|
// No need to raise property changed for this example
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public DateTime GameRoundStartDate
|
||||||
|
{
|
||||||
|
get { return _gameRoundStartDate; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_gameRoundStartDate = value;
|
||||||
|
// No need to raise property changed for this example
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public GamePointStatus Status
|
||||||
|
{
|
||||||
|
get { return _status; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_status = value;
|
||||||
|
// No need to raise property changed for this example
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[ObservableProperty]
|
public List<RoundBuilderElement> Elements
|
||||||
private int gameRoundId;
|
{
|
||||||
|
get { return _elements; }
|
||||||
[ObservableProperty]
|
set
|
||||||
private DateTime gameRoundStartDate;
|
{
|
||||||
|
_elements = value;
|
||||||
[ObservableProperty]
|
RaisePropertyChanged(nameof(Elements));
|
||||||
private GamePointStatus _status;
|
// No need to raise property changed for this example
|
||||||
|
}
|
||||||
[ObservableProperty]
|
}
|
||||||
private List<RoundBuilderElement> elements;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,7 +0,0 @@
|
|||||||
namespace GreadyPoang.EntityLayer;
|
|
||||||
|
|
||||||
public class ScoreCell
|
|
||||||
{
|
|
||||||
public string Text { get; set; }
|
|
||||||
public bool IsHeader { get; set; }
|
|
||||||
}
|
|
||||||
@ -1,9 +0,0 @@
|
|||||||
using System.Collections.ObjectModel;
|
|
||||||
|
|
||||||
namespace GreadyPoang.EntityLayer;
|
|
||||||
|
|
||||||
public class ScoreColumn
|
|
||||||
{
|
|
||||||
public string PlayerName { get; set; }
|
|
||||||
public ObservableCollection<ScoreCell> Cells { get; set; } = new();
|
|
||||||
}
|
|
||||||
@ -2,13 +2,17 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net9.0</TargetFramework>
|
<TargetFrameworks>
|
||||||
|
net9.0-android;
|
||||||
|
net9.0-ios;
|
||||||
|
net9.0-maccatalyst;
|
||||||
|
net9.0-windows10.0.19041
|
||||||
|
</TargetFrameworks>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.4.0" />
|
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.8">
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.8">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
|||||||
@ -1,15 +1,16 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net9.0</TargetFramework>
|
<TargetFrameworks>
|
||||||
|
net9.0-android;
|
||||||
|
net9.0-ios;
|
||||||
|
net9.0-maccatalyst;
|
||||||
|
net9.0-windows10.0.19041
|
||||||
|
</TargetFrameworks>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.4.0" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\GreadyPoang.EntityLayer\GreadyPoang.EntityLayer.csproj" />
|
<ProjectReference Include="..\GreadyPoang.EntityLayer\GreadyPoang.EntityLayer.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|||||||
@ -1,6 +0,0 @@
|
|||||||
namespace GreadyPoang.Services;
|
|
||||||
|
|
||||||
public static class LatestPopup
|
|
||||||
{
|
|
||||||
public static string valueGuid = "";
|
|
||||||
}
|
|
||||||
@ -4,5 +4,6 @@ namespace GreadyPoang.Services;
|
|||||||
|
|
||||||
public class ObjectMessageService : IObjectMessageService
|
public class ObjectMessageService : IObjectMessageService
|
||||||
{
|
{
|
||||||
public RoundBuilderGroup CurrentGroup { get; set; }
|
public required RoundBuilderGroup CurrentGroup { get; set; }
|
||||||
|
public bool Delivered { get; set; } = false;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,12 +0,0 @@
|
|||||||
namespace GreadyPoang.Services;
|
|
||||||
|
|
||||||
public class PopupEventHub : IPopupEventHub
|
|
||||||
{
|
|
||||||
public event EventHandler<PopupCloseEventArgs>? InfoPopupCloseRequested;
|
|
||||||
|
|
||||||
public void RaiseInfoPopupClose(string popupId)
|
|
||||||
{
|
|
||||||
InfoPopupCloseRequested?.Invoke(this, new PopupCloseEventArgs(popupId));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,9 +1,10 @@
|
|||||||
using GreadyPoang.EntityLayer;
|
using GreadyPoang.EntityLayer;
|
||||||
|
|
||||||
namespace GreadyPoang.Services;
|
namespace GreadyPoang.Services
|
||||||
|
|
||||||
public interface IObjectMessageService
|
|
||||||
{
|
{
|
||||||
|
public interface IObjectMessageService
|
||||||
|
{
|
||||||
RoundBuilderGroup CurrentGroup { get; set; }
|
RoundBuilderGroup CurrentGroup { get; set; }
|
||||||
|
bool Delivered { get; set; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -1,9 +0,0 @@
|
|||||||
namespace GreadyPoang.Services;
|
|
||||||
|
|
||||||
public interface IPopupEventHub
|
|
||||||
{
|
|
||||||
event EventHandler<PopupCloseEventArgs>? InfoPopupCloseRequested;
|
|
||||||
|
|
||||||
void RaiseInfoPopupClose(string popupId);
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,11 +0,0 @@
|
|||||||
namespace GreadyPoang.Services;
|
|
||||||
|
|
||||||
public class PopupCloseEventArgs : EventArgs
|
|
||||||
{
|
|
||||||
public string PopupId { get; }
|
|
||||||
|
|
||||||
public PopupCloseEventArgs(string popupId)
|
|
||||||
{
|
|
||||||
PopupId = popupId;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,15 +1,16 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net9.0</TargetFramework>
|
<TargetFrameworks>
|
||||||
|
net9.0-android;
|
||||||
|
net9.0-ios;
|
||||||
|
net9.0-maccatalyst;
|
||||||
|
net9.0-windows10.0.19041
|
||||||
|
</TargetFrameworks>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.4.0" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\Common.Library\Common.Library.csproj" />
|
<ProjectReference Include="..\Common.Library\Common.Library.csproj" />
|
||||||
<ProjectReference Include="..\GreadyPoang.DataLayer\GreadyPoang.DataLayer.csproj" />
|
<ProjectReference Include="..\GreadyPoang.DataLayer\GreadyPoang.DataLayer.csproj" />
|
||||||
|
|||||||
@ -0,0 +1,9 @@
|
|||||||
|
namespace GreadyPoang.Core;
|
||||||
|
|
||||||
|
public interface INavigationService
|
||||||
|
{
|
||||||
|
Task NavigateToAsync(string route);
|
||||||
|
Task NavigateToPageAsync(Page page);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
6
GreadyPoang.ViewModelLayer/Interfaces/IPageFactory.cs
Normal file
6
GreadyPoang.ViewModelLayer/Interfaces/IPageFactory.cs
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
namespace GreadyPoang.Core;
|
||||||
|
|
||||||
|
public interface IPageFactory
|
||||||
|
{
|
||||||
|
Page CreateRoundPage();
|
||||||
|
}
|
||||||
9
GreadyPoang.ViewModelLayer/Interfaces/ISplashService.cs
Normal file
9
GreadyPoang.ViewModelLayer/Interfaces/ISplashService.cs
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
|
||||||
|
namespace GreadyPoang.Core;
|
||||||
|
|
||||||
|
public interface ISplashService
|
||||||
|
{
|
||||||
|
Task ShowSplash(string text = "Välkommen!", int durationMs = 3000);
|
||||||
|
Task HideAsync();
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,21 @@
|
|||||||
|
using Common.Library;
|
||||||
|
|
||||||
|
namespace GreadyPoang.ViewModelLayer;
|
||||||
|
|
||||||
|
public class AppShellViewModel : ViewModelBase
|
||||||
|
{
|
||||||
|
|
||||||
|
private bool _roundRounningVisible = true;
|
||||||
|
|
||||||
|
public bool RoundRunningVisible
|
||||||
|
{
|
||||||
|
get { return _roundRounningVisible; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_roundRounningVisible = value;
|
||||||
|
RaisePropertyChanged(nameof(RoundRunningVisible));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -1,50 +0,0 @@
|
|||||||
using CommunityToolkit.Maui;
|
|
||||||
using CommunityToolkit.Mvvm.ComponentModel;
|
|
||||||
using CommunityToolkit.Mvvm.Input;
|
|
||||||
using GreadyPoang.Services;
|
|
||||||
|
|
||||||
namespace GreadyPoang.ViewModelLayer;
|
|
||||||
|
|
||||||
public partial class InfoPopupViewModel : ObservableObject, IQueryAttributable
|
|
||||||
{
|
|
||||||
private readonly IPopupService _popupService;
|
|
||||||
private readonly IPopupEventHub _popupEvent;
|
|
||||||
public string PopupId { get; } = Guid.NewGuid().ToString();
|
|
||||||
|
|
||||||
public event EventHandler ClosePopupRequested;
|
|
||||||
|
|
||||||
[ObservableProperty]
|
|
||||||
private string title;
|
|
||||||
|
|
||||||
[ObservableProperty]
|
|
||||||
private string message;
|
|
||||||
|
|
||||||
[ObservableProperty]
|
|
||||||
private string name;
|
|
||||||
public InfoPopupViewModel(IPopupService popupService, IPopupEventHub popupEvent)
|
|
||||||
{
|
|
||||||
_popupService = popupService;
|
|
||||||
_popupEvent = popupEvent;
|
|
||||||
LatestPopup.valueGuid = PopupId;
|
|
||||||
}
|
|
||||||
|
|
||||||
[RelayCommand]
|
|
||||||
private async Task Cancel()
|
|
||||||
{
|
|
||||||
_popupEvent.RaiseInfoPopupClose(PopupId);
|
|
||||||
}
|
|
||||||
|
|
||||||
[RelayCommand(CanExecute = nameof(CanSave))]
|
|
||||||
void OnSave()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CanSave() => string.IsNullOrWhiteSpace(Name) is false;
|
|
||||||
|
|
||||||
public void ApplyQueryAttributes(IDictionary<string, object> query)
|
|
||||||
{
|
|
||||||
Title = (string)query[nameof(InfoPopupViewModel.Title)];
|
|
||||||
Message = (string)query[nameof(InfoPopupViewModel.Message)];
|
|
||||||
Name = (string)query[nameof(InfoPopupViewModel.Name)];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -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,11 +1,10 @@
|
|||||||
using Common.Library;
|
using Common.Library;
|
||||||
using CommunityToolkit.Mvvm.ComponentModel;
|
|
||||||
using GreadyPoang.EntityLayer;
|
using GreadyPoang.EntityLayer;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
|
|
||||||
namespace GreadyPoang.ViewModelLayer;
|
namespace GreadyPoang.ViewModelLayer;
|
||||||
|
|
||||||
public class MethodSharingService : ObservableObject, IMethodSharingService<Participant>
|
public class MethodSharingService : ViewModelBase, IMethodSharingService<Participant>
|
||||||
{
|
{
|
||||||
private readonly IRepository<Participant> _repository;
|
private readonly IRepository<Participant> _repository;
|
||||||
|
|
||||||
|
|||||||
@ -1,8 +1,4 @@
|
|||||||
using Common.Library;
|
using Common.Library;
|
||||||
using CommunityToolkit.Maui;
|
|
||||||
using CommunityToolkit.Mvvm.ComponentModel;
|
|
||||||
using CommunityToolkit.Mvvm.Input;
|
|
||||||
using GreadyPoang.Core;
|
|
||||||
using GreadyPoang.EntityLayer;
|
using GreadyPoang.EntityLayer;
|
||||||
using GreadyPoang.Services;
|
using GreadyPoang.Services;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
@ -10,7 +6,7 @@ using System.Collections.ObjectModel;
|
|||||||
|
|
||||||
namespace GreadyPoang.ViewModelLayer;
|
namespace GreadyPoang.ViewModelLayer;
|
||||||
|
|
||||||
public partial class ParticipantViewModel : BaseViewModel
|
public class ParticipantViewModel : ViewModelBase
|
||||||
{
|
{
|
||||||
#region Constructors
|
#region Constructors
|
||||||
public ParticipantViewModel() : base()
|
public ParticipantViewModel() : base()
|
||||||
@ -21,65 +17,58 @@ public partial class ParticipantViewModel : BaseViewModel
|
|||||||
public ParticipantViewModel(
|
public ParticipantViewModel(
|
||||||
IRepository<Participant> repo,
|
IRepository<Participant> repo,
|
||||||
IMethodSharingService<Participant> sharingService,
|
IMethodSharingService<Participant> sharingService,
|
||||||
IPopupService popupService,
|
AppShellViewModel appShell,
|
||||||
IPopupEventHub popupEvent
|
IObjectMessageService objectMessage) : base()
|
||||||
) : base()
|
|
||||||
{
|
{
|
||||||
_Repository = repo;
|
_Repository = repo;
|
||||||
_sharingService = sharingService;
|
_sharingService = sharingService;
|
||||||
_popupService = popupService;
|
_appShell = appShell;
|
||||||
_popupEvent = popupEvent;
|
_objectMessage = objectMessage;
|
||||||
ParticipantObject = new Participant();
|
|
||||||
ParticipantList = new ObservableCollection<Participant>();
|
|
||||||
IsSaveCommandEnabled = true;
|
|
||||||
PopupVisad = false;
|
|
||||||
_popupEvent.InfoPopupCloseRequested += infoPopupViewModel_ClosePopupRequested;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Private Variables
|
#region Private Variables
|
||||||
[ObservableProperty]
|
private Participant? _ParticipantObject = new();
|
||||||
private Participant? participantObject;
|
private ObservableCollection<Participant> _ParticipantList = new();
|
||||||
[ObservableProperty]
|
|
||||||
private ObservableCollection<Participant> participantList;
|
|
||||||
private readonly IRepository<Participant>? _Repository;
|
private readonly IRepository<Participant>? _Repository;
|
||||||
private readonly IMethodSharingService<Participant> _sharingService;
|
private readonly IMethodSharingService<Participant> _sharingService;
|
||||||
private readonly IPopupService _popupService;
|
private readonly AppShellViewModel _appShell;
|
||||||
private readonly IPopupEventHub _popupEvent;
|
private readonly IObjectMessageService _objectMessage;
|
||||||
private readonly InfoPopupViewModel _infoPopupViewModel;
|
|
||||||
private string _activePopupId;
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
public bool PopupVisad { get; set; }
|
#region public Properties
|
||||||
|
|
||||||
[ObservableProperty]
|
public Participant? ParticipantObject
|
||||||
private bool isSaveCommandEnabled;
|
{
|
||||||
|
get { return _ParticipantObject; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_ParticipantObject = value;
|
||||||
|
RaisePropertyChanged(nameof(ParticipantObject));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ObservableCollection<Participant> ParticipantList
|
||||||
|
{
|
||||||
|
get { return _ParticipantList; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_ParticipantList = value;
|
||||||
|
RaisePropertyChanged(nameof(ParticipantList));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region Get Method
|
#region Get Method
|
||||||
public ObservableCollection<Participant> Get()
|
public ObservableCollection<Participant> Get()
|
||||||
{
|
{
|
||||||
ParticipantList = _sharingService.Get();
|
if (_appShell.RoundRunningVisible == false)
|
||||||
|
|
||||||
if (!PopupVisad)
|
|
||||||
{
|
{
|
||||||
var queryAttributes = new Dictionary<string, object>
|
_objectMessage.Delivered = true;
|
||||||
{
|
|
||||||
[nameof(InfoPopupViewModel.Title)] = "Deltagar bildens infopopup",
|
|
||||||
[nameof(InfoPopupViewModel.Message)] = "Deltagare laddade",
|
|
||||||
[nameof(InfoPopupViewModel.Name)] = " ",
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
_popupService.ShowPopup<InfoPopupViewModel>(
|
|
||||||
Shell.Current,
|
|
||||||
options: PopupOptions.Empty,
|
|
||||||
shellParameters: queryAttributes);
|
|
||||||
|
|
||||||
_activePopupId = LatestPopup.valueGuid;
|
|
||||||
}
|
}
|
||||||
|
ParticipantList = _sharingService.Get();
|
||||||
return ParticipantList;
|
return ParticipantList;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -101,62 +90,20 @@ public partial class ParticipantViewModel : BaseViewModel
|
|||||||
|
|
||||||
return ParticipantObject;
|
return ParticipantObject;
|
||||||
}
|
}
|
||||||
|
public virtual bool Save()
|
||||||
#endregion
|
|
||||||
|
|
||||||
[RelayCommand(CanExecute = nameof(IsSaveCommandEnabled))]
|
|
||||||
private async Task Save()
|
|
||||||
{
|
|
||||||
await RunAsyncCommand(async () =>
|
|
||||||
{
|
{
|
||||||
if (_Repository == null || ParticipantObject == null)
|
if (_Repository == null || ParticipantObject == null)
|
||||||
{
|
{
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
await Task.Delay(3600); // Simulerar en fördröjning för att visa laddningsindikatorn
|
|
||||||
var tmpTask = _Repository.Save(ParticipantObject);
|
var tmpTask = _Repository.Save(ParticipantObject);
|
||||||
int tmp = await tmpTask;
|
int tmp = tmpTask.GetAwaiter().GetResult();
|
||||||
if (tmp != -1)
|
if (tmp != -1)
|
||||||
{
|
{
|
||||||
ParticipantObject = new Participant();
|
ParticipantObject = new Participant();
|
||||||
this.Get();
|
this.Get();
|
||||||
await Shell.Current.GoToAsync("..");
|
|
||||||
}
|
}
|
||||||
}, loadingMessage: "Sparar deltagare...", errorMessage: "Fel vid sparande av deltagare");
|
return tmp != -1;
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
[RelayCommand]
|
|
||||||
private void DeleteAsync(Participant pp)
|
|
||||||
{
|
|
||||||
Console.WriteLine($"Valt från ViewModel: {pp.FullName}");
|
|
||||||
if (_Repository == null || pp == null || pp.ParticipantId <= 0)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var tmpTask = _Repository.Delete(pp);
|
|
||||||
this.Get();
|
|
||||||
Shell.Current.GoToAsync("..");
|
|
||||||
}
|
|
||||||
|
|
||||||
[RelayCommand]
|
|
||||||
private async Task LoadDataAsync()
|
|
||||||
{
|
|
||||||
await RunAsyncCommand(async () =>
|
|
||||||
{
|
|
||||||
await Task.Delay(1500); // Simulerar laddning
|
|
||||||
Console.WriteLine("Data laddad!");
|
|
||||||
}, loadingMessage: "Laddar data...");
|
|
||||||
}
|
|
||||||
|
|
||||||
private async void infoPopupViewModel_ClosePopupRequested(object? sender, PopupCloseEventArgs e)
|
|
||||||
{
|
|
||||||
if (e.PopupId != _activePopupId)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
PopupVisad = true;
|
|
||||||
await _popupService.ClosePopupAsync(Shell.Current);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -1,21 +1,17 @@
|
|||||||
using Common.Library;
|
using Common.Library;
|
||||||
using CommunityToolkit.Maui;
|
using GreadyPoang.Core;
|
||||||
using CommunityToolkit.Mvvm.ComponentModel;
|
|
||||||
using CommunityToolkit.Mvvm.Input;
|
|
||||||
using GreadyPoang.DataLayer;
|
using GreadyPoang.DataLayer;
|
||||||
using GreadyPoang.EntityLayer;
|
using GreadyPoang.EntityLayer;
|
||||||
using GreadyPoang.Services;
|
using GreadyPoang.Services;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Windows.Input;
|
|
||||||
|
|
||||||
namespace GreadyPoang.ViewModelLayer;
|
namespace GreadyPoang.ViewModelLayer;
|
||||||
|
|
||||||
public partial class RoundRunningViewModel : ObservableObject
|
public class RoundRunningViewModel : ViewModelBase
|
||||||
{
|
{
|
||||||
|
|
||||||
public event EventHandler RebuildRequested;
|
public event EventHandler RebuildRequested;
|
||||||
public ICommand OnLoadedCommand { get; }
|
|
||||||
|
|
||||||
public RoundRunningViewModel() : base()
|
public RoundRunningViewModel() : base()
|
||||||
{
|
{
|
||||||
@ -28,8 +24,8 @@ public partial class RoundRunningViewModel : ObservableObject
|
|||||||
IMethodSharingService<Participant> sharingService,
|
IMethodSharingService<Participant> sharingService,
|
||||||
ICombinedRepository combined,
|
ICombinedRepository combined,
|
||||||
IObjectMessageService objectMessage,
|
IObjectMessageService objectMessage,
|
||||||
IPopupService popupService,
|
ISplashService splashService,
|
||||||
IPopupEventHub popupEvent
|
AppShellViewModel appShell
|
||||||
) : base()
|
) : base()
|
||||||
{
|
{
|
||||||
_roundsRepo = roundsRepo;
|
_roundsRepo = roundsRepo;
|
||||||
@ -37,48 +33,91 @@ public partial class RoundRunningViewModel : ObservableObject
|
|||||||
_sharingService = sharingService;
|
_sharingService = sharingService;
|
||||||
_combined = combined;
|
_combined = combined;
|
||||||
_objectMessage = objectMessage;
|
_objectMessage = objectMessage;
|
||||||
_popupService = popupService;
|
_splashService = splashService;
|
||||||
_popupEvent = popupEvent;
|
_appShell = appShell;
|
||||||
RoundElements = new ObservableCollection<RoundBuilderElement>();
|
_roundElements = new ObservableCollection<RoundBuilderElement>();
|
||||||
BuilderObject = new();
|
_builderObject = new();
|
||||||
_popupEvent.InfoPopupCloseRequested += infoPopupViewModel_ClosePopupRequested;
|
_SplashShowing = false;
|
||||||
//PopupVisad = false;
|
|
||||||
OnLoadedCommand = new AsyncRelayCommand(OnLoadedAsync, () => true);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool _SplashShowing;
|
||||||
|
|
||||||
private readonly IRepository<GameRound>? _roundsRepo;
|
private readonly IRepository<GameRound>? _roundsRepo;
|
||||||
private readonly IRepository<GamePoint> _pointsRepo;
|
private readonly IRepository<GamePoint> _pointsRepo;
|
||||||
private readonly IMethodSharingService<Participant> _sharingService;
|
private readonly IMethodSharingService<Participant> _sharingService;
|
||||||
private readonly ICombinedRepository _combined;
|
private readonly ICombinedRepository _combined;
|
||||||
private readonly IObjectMessageService _objectMessage;
|
private readonly IObjectMessageService _objectMessage;
|
||||||
private readonly IPopupService _popupService;
|
private readonly ISplashService _splashService;
|
||||||
private readonly IPopupEventHub _popupEvent;
|
private readonly AppShellViewModel _appShell;
|
||||||
|
private ObservableCollection<RoundBuilderGroup> _GameRoundList = new();
|
||||||
|
private ObservableCollection<Participant> _ParticipantList = new();
|
||||||
|
private ObservableCollection<RoundBuilderElement> _roundElements;
|
||||||
|
private Collection<PlayerColumn> _playerColumns;
|
||||||
|
private RoundBuilderElement _builderObject;
|
||||||
|
|
||||||
[ObservableProperty]
|
public void TriggerRebuild()
|
||||||
private ObservableCollection<RoundBuilderElement> roundElements;
|
|
||||||
[ObservableProperty]
|
|
||||||
private Collection<PlayerColumn> playerColumns;
|
|
||||||
[ObservableProperty]
|
|
||||||
private RoundBuilderElement builderObject;
|
|
||||||
public ObservableCollection<ScoreColumn> ScoreColumns { get; } = new ObservableCollection<ScoreColumn>();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private string _activePopupId;
|
|
||||||
|
|
||||||
//public bool PopupVisad { get; set; }
|
|
||||||
|
|
||||||
private async Task OnLoadedAsync()
|
|
||||||
{
|
{
|
||||||
await Get();
|
// Trigga eventet
|
||||||
|
RebuildRequested?.Invoke(this, EventArgs.Empty);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task Get()
|
// Översta raden
|
||||||
|
public ObservableCollection<RoundBuilderElement> RoundElements
|
||||||
{
|
{
|
||||||
|
get { return _roundElements; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_roundElements = value;
|
||||||
|
RaisePropertyChanged(nameof(RoundElements));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Nedersta strukturen
|
||||||
|
public Collection<PlayerColumn> PlayerColumns
|
||||||
|
{
|
||||||
|
get { return _playerColumns; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_playerColumns = value;
|
||||||
|
RaisePropertyChanged(nameof(PlayerColumns));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public RoundBuilderElement BuilderObject
|
||||||
|
{
|
||||||
|
get { return _builderObject; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_builderObject = value;
|
||||||
|
RaisePropertyChanged(nameof(BuilderObject));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool _gobackVisible = true;
|
||||||
|
|
||||||
|
public bool GobackVisible
|
||||||
|
{
|
||||||
|
get { return _gobackVisible; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_gobackVisible = value;
|
||||||
|
RaisePropertyChanged(nameof(GobackVisible));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public ObservableCollection<RoundBuilderElement> Get()
|
||||||
|
{
|
||||||
|
|
||||||
|
//_overlay.ShowSplash("Laddar...", 30);
|
||||||
|
|
||||||
if (_objectMessage.CurrentGroup != null)
|
if (_objectMessage.CurrentGroup != null)
|
||||||
{
|
{
|
||||||
|
GobackVisible = _objectMessage.Delivered;
|
||||||
|
_objectMessage.Delivered = false;
|
||||||
//CurrentGroup är satt från RoundStarting ViewModel
|
//CurrentGroup är satt från RoundStarting ViewModel
|
||||||
Debug.WriteLine($"Chosen round: {_objectMessage.CurrentGroup.GameRoundId}");
|
Debug.WriteLine($"Chosen round: {_objectMessage.CurrentGroup.GameRoundId}");
|
||||||
if (RoundElements.Count > 0)
|
if (RoundElements.Count > 0)
|
||||||
@ -90,17 +129,30 @@ public partial class RoundRunningViewModel : ObservableObject
|
|||||||
RoundElements.Add(item);
|
RoundElements.Add(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Räkna ut vem som är nästa spelare
|
||||||
|
var nxt = nextPlayerElement();
|
||||||
|
|
||||||
|
// Aktuell spelare sätts som BuilderObject
|
||||||
|
BuilderObject.ParticipantName = _objectMessage.CurrentGroup.Elements[nxt].ParticipantName;
|
||||||
|
BuilderObject.GameRoundId = _objectMessage.CurrentGroup.GameRoundId;
|
||||||
|
BuilderObject.ParticipantId = _objectMessage.CurrentGroup.Elements[nxt].ParticipantId;
|
||||||
BuilderObject.Status = _objectMessage.CurrentGroup.Status;
|
BuilderObject.Status = _objectMessage.CurrentGroup.Status;
|
||||||
|
|
||||||
UpdateAndShow();
|
// Alla poängposter från samtliga spelare i rundan samlas ihop och fördelas per deltagare
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void StoreAndHandlePoints()
|
||||||
[RelayCommand]
|
|
||||||
private void StoreAndHandlePointsAsync()
|
|
||||||
{
|
{
|
||||||
var game = _roundsRepo.Get(BuilderObject.GameRoundId).GetAwaiter().GetResult();
|
var game = _roundsRepo.Get(BuilderObject.GameRoundId).GetAwaiter().GetResult();
|
||||||
var regNr = RoundElements.Count > 0 ? RoundElements.Max(e => e.GameRoundRegNr) + 1 : 1;
|
var regNr = RoundElements.Count > 0 ? RoundElements.Max(e => e.GameRoundRegNr) + 1 : 1;
|
||||||
@ -134,10 +186,20 @@ public partial class RoundRunningViewModel : ObservableObject
|
|||||||
RoundElements.Add(item);
|
RoundElements.Add(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Uppdatera spelaren som skall spela nästa
|
||||||
|
var nxt = nextPlayerElement();
|
||||||
BuilderObject.GameRegPoints = 0;
|
BuilderObject.GameRegPoints = 0;
|
||||||
UpdateAndShow();
|
BuilderObject.ParticipantName = RoundElements[nxt].ParticipantName;
|
||||||
Shell.Current.GoToAsync("..").GetAwaiter().GetResult();
|
BuilderObject.ParticipantId = RoundElements[nxt].ParticipantId;
|
||||||
|
BuilderObject.GameRoundId = RoundElements[0].GameRoundId;
|
||||||
|
|
||||||
|
var localElements = _combined.roundBuilderElementsTotalById(BuilderObject.GameRoundId);
|
||||||
|
FillupResultTable(localElements);
|
||||||
|
foreach (var col in _playerColumns)
|
||||||
|
{
|
||||||
|
RoundElements.FirstOrDefault(e => e.ParticipantId == col.PlayerId).GameRegPoints = col.PlayerPoints;
|
||||||
|
}
|
||||||
|
TriggerRebuild();
|
||||||
}
|
}
|
||||||
|
|
||||||
private int nextPlayerElement()
|
private int nextPlayerElement()
|
||||||
@ -152,76 +214,15 @@ public partial class RoundRunningViewModel : ObservableObject
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateAndShow()
|
|
||||||
{
|
|
||||||
// Räkna ut vem som är nästa spelare
|
|
||||||
var nxt = nextPlayerElement();
|
|
||||||
|
|
||||||
// Aktuell spelare sätts som BuilderObject
|
|
||||||
BuilderObject.ParticipantName = _objectMessage.CurrentGroup.Elements[nxt].ParticipantName;
|
|
||||||
BuilderObject.ParticipantId = _objectMessage.CurrentGroup.Elements[nxt].ParticipantId;
|
|
||||||
BuilderObject.GameRoundId = _objectMessage.CurrentGroup.GameRoundId;
|
|
||||||
|
|
||||||
|
|
||||||
// Alla poängposter från samtliga spelare i rundan samlas ihop och fördelas per deltagare
|
|
||||||
var localElements = _combined.roundBuilderElementsTotalById(_objectMessage.CurrentGroup.GameRoundId);
|
|
||||||
|
|
||||||
FillupResultTable(localElements);
|
|
||||||
// Fix for CS8602: Add null check before dereferencing FirstOrDefault result
|
|
||||||
foreach (var col in PlayerColumns)
|
|
||||||
{
|
|
||||||
var roundElement = RoundElements.FirstOrDefault(e => e.ParticipantId == col.PlayerId);
|
|
||||||
if (roundElement != null)
|
|
||||||
{
|
|
||||||
roundElement.GameRegPoints = col.PlayerPoints;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Fix for MVVMTK0034: Use the generated property 'PlayerColumns' instead of the backing field 'playerColumns'
|
|
||||||
BuildScore(PlayerColumns);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Show_a_Popup(string ppName, string ppTitle, string ppMessage)
|
|
||||||
{
|
|
||||||
//if (!PopupVisad)
|
|
||||||
//{
|
|
||||||
var queryAttributes = new Dictionary<string, object>
|
|
||||||
{
|
|
||||||
[nameof(InfoPopupViewModel.Title)] = ppTitle,
|
|
||||||
[nameof(InfoPopupViewModel.Message)] = ppMessage,
|
|
||||||
[nameof(InfoPopupViewModel.Name)] = ppName,
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
_popupService.ShowPopup<InfoPopupViewModel>(
|
|
||||||
Shell.Current,
|
|
||||||
options: PopupOptions.Empty,
|
|
||||||
shellParameters: queryAttributes);
|
|
||||||
|
|
||||||
_activePopupId = LatestPopup.valueGuid;
|
|
||||||
|
|
||||||
//}
|
|
||||||
}
|
|
||||||
|
|
||||||
private async void infoPopupViewModel_ClosePopupRequested(object? sender, PopupCloseEventArgs e)
|
|
||||||
{
|
|
||||||
if (e.PopupId != _activePopupId)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
//PopupVisad = true;
|
|
||||||
await _popupService.ClosePopupAsync(Shell.Current);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void FillupResultTable(IEnumerable<RoundBuilderElement> elements)
|
private void FillupResultTable(IEnumerable<RoundBuilderElement> elements)
|
||||||
{
|
{
|
||||||
if (PlayerColumns != null)
|
if (_playerColumns != null)
|
||||||
{
|
{
|
||||||
PlayerColumns.Clear();
|
_playerColumns.Clear();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
PlayerColumns = new Collection<PlayerColumn>();
|
_playerColumns = new Collection<PlayerColumn>();
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (elements.Any(g => g.GameRegPoints > 0))
|
// if (elements.Any(g => g.GameRegPoints > 0))
|
||||||
@ -229,12 +230,10 @@ public partial class RoundRunningViewModel : ObservableObject
|
|||||||
{
|
{
|
||||||
PlayerColumn player = new PlayerColumn();
|
PlayerColumn player = new PlayerColumn();
|
||||||
|
|
||||||
var regMax = elements.Max(e => e.GameRoundRegNr);
|
|
||||||
var existingWinning = elements.FirstOrDefault(e => e.Status == GamePointStatus.Winning);
|
|
||||||
|
|
||||||
foreach (var element in elements)
|
foreach (var element in elements)
|
||||||
{
|
{
|
||||||
player = PlayerColumns.FirstOrDefault(p => p.PlayerId == element.ParticipantId)!;
|
player = _playerColumns.FirstOrDefault(p => p.PlayerId == element.ParticipantId);
|
||||||
|
|
||||||
if (player == null)
|
if (player == null)
|
||||||
{
|
{
|
||||||
player = new PlayerColumn
|
player = new PlayerColumn
|
||||||
@ -248,17 +247,18 @@ public partial class RoundRunningViewModel : ObservableObject
|
|||||||
if (element.GameRegPoints > 0)
|
if (element.GameRegPoints > 0)
|
||||||
{
|
{
|
||||||
player.Values.Add(element.GameRegPoints.ToString());
|
player.Values.Add(element.GameRegPoints.ToString());
|
||||||
var playerPointsOld = player.PlayerPoints;
|
|
||||||
player.PlayerPoints += element.GameRegPoints;
|
player.PlayerPoints += element.GameRegPoints;
|
||||||
if (player.PlayerPoints > 10000)
|
if (player.PlayerPoints > 10000)
|
||||||
{
|
{
|
||||||
HandlePlayerReachedWinningThreshold(player, regMax, element, playerPointsOld, existingWinning);
|
var winner = RoundElements.FirstOrDefault(e => e.ParticipantId == player.PlayerId);
|
||||||
|
winner.Status = GamePointStatus.Winning;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//oldPart = element.ParticipantId;
|
||||||
|
|
||||||
if (!PlayerColumns.Contains(player))
|
if (!_playerColumns.Contains(player))
|
||||||
{
|
{
|
||||||
PlayerColumns.Add(player);
|
_playerColumns.Add(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -270,9 +270,7 @@ public partial class RoundRunningViewModel : ObservableObject
|
|||||||
{
|
{
|
||||||
var player = new PlayerColumn
|
var player = new PlayerColumn
|
||||||
{
|
{
|
||||||
PlayerName = element.ParticipantName,
|
PlayerName = element.ParticipantName
|
||||||
PlayerId = element.ParticipantId,
|
|
||||||
PlayerPoints = 0
|
|
||||||
};
|
};
|
||||||
|
|
||||||
for (int i = 0; i < slumper.Next(6); i++)
|
for (int i = 0; i < slumper.Next(6); i++)
|
||||||
@ -280,91 +278,32 @@ public partial class RoundRunningViewModel : ObservableObject
|
|||||||
player.Values.Add(slumper.Next(1, 10).ToString());
|
player.Values.Add(slumper.Next(1, 10).ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
PlayerColumns.Add(player);
|
_playerColumns.Add(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void HandlePlayerReachedWinningThreshold(
|
public async void ToggleSplash()
|
||||||
PlayerColumn player,
|
|
||||||
int regMax,
|
|
||||||
RoundBuilderElement element,
|
|
||||||
int playerPointsOld,
|
|
||||||
RoundBuilderElement existingWinning
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
var nextPlayer = RoundElements[AfterNext()].ParticipantName;
|
if (!_SplashShowing)
|
||||||
Debug.WriteLine($"Spelare {nextPlayer} samma som {player.PlayerName} ???.");
|
|
||||||
if (existingWinning != null && existingWinning.ParticipantId != player.PlayerId)
|
|
||||||
{
|
{
|
||||||
// Det finns redan en vinnare, sätt dennes status tillbaka till InProgress
|
//_overlay.ShowSplash("Clcicked!", 5000);
|
||||||
existingWinning.Status = GamePointStatus.InProgress;
|
await _splashService.ShowSplash("Clicked", 0);
|
||||||
|
_SplashShowing = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
await _splashService.HideAsync();
|
||||||
|
_SplashShowing = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Om det redan finns en vinnare, sätt dennes status tillbaka till InProgress, kanske
|
|
||||||
|
|
||||||
var winner = RoundElements.FirstOrDefault(e => e.ParticipantId == player.PlayerId);
|
|
||||||
var oldStatus = winner.Status;
|
|
||||||
winner.Status = GamePointStatus.Winning;
|
|
||||||
if (playerPointsOld < 10000 && oldStatus != winner.Status && regMax == element.GameRoundRegNr)
|
|
||||||
{
|
|
||||||
//PopupVisad = false;
|
|
||||||
Show_a_Popup(
|
|
||||||
player.PlayerName,
|
|
||||||
"Se upp för denne spelare !",
|
|
||||||
$"Du har nått en poängnivå över 10000 ({player.PlayerPoints})\r" +
|
|
||||||
$"Alla övriga får nu en chans att överträffa\r" +
|
|
||||||
$"om någon kommer till samma poäng som\r" +
|
|
||||||
$"{player.PlayerName}\r" +
|
|
||||||
$"får hen försvara sig med nytt kast\r" +
|
|
||||||
$"Om kastet inte blir godkänt (ger poäng)\r" +
|
|
||||||
$"Vinner den upphinnande spelaren"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private int AfterNext()
|
public void GobackAsync()
|
||||||
{
|
{
|
||||||
var comingUp = nextPlayerElement();
|
_appShell.RoundRunningVisible = true;
|
||||||
if (RoundElements.Count - 1 == comingUp)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
return comingUp;
|
|
||||||
}
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
using Common.Library;
|
using Common.Library;
|
||||||
using CommunityToolkit.Mvvm.ComponentModel;
|
using GreadyPoang.Core;
|
||||||
using CommunityToolkit.Mvvm.Input;
|
|
||||||
using GreadyPoang.DataLayer;
|
using GreadyPoang.DataLayer;
|
||||||
using GreadyPoang.EntityLayer;
|
using GreadyPoang.EntityLayer;
|
||||||
using GreadyPoang.Services;
|
using GreadyPoang.Services;
|
||||||
@ -9,12 +8,11 @@ using System.Diagnostics;
|
|||||||
|
|
||||||
namespace GreadyPoang.ViewModelLayer;
|
namespace GreadyPoang.ViewModelLayer;
|
||||||
|
|
||||||
public partial class RoundStartingViewModel : ObservableObject
|
public class RoundStartingViewModel : ViewModelBase
|
||||||
{
|
{
|
||||||
#region Constructors
|
#region Constructors
|
||||||
public RoundStartingViewModel() : base()
|
public RoundStartingViewModel() : base()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public RoundStartingViewModel(
|
public RoundStartingViewModel(
|
||||||
@ -22,51 +20,72 @@ public partial class RoundStartingViewModel : ObservableObject
|
|||||||
IRepository<GamePoint> pointsRepo,
|
IRepository<GamePoint> pointsRepo,
|
||||||
IMethodSharingService<Participant> sharingService,
|
IMethodSharingService<Participant> sharingService,
|
||||||
ICombinedRepository combined,
|
ICombinedRepository combined,
|
||||||
IObjectMessageService objectMessage) : base()
|
IObjectMessageService objectMessage,
|
||||||
|
INavigationService nav,
|
||||||
|
IPageFactory factory,
|
||||||
|
ISplashService splashService,
|
||||||
|
AppShellViewModel appShellView
|
||||||
|
) : base()
|
||||||
{
|
{
|
||||||
_roundsRepo = roundsRepo;
|
_roundsRepo = roundsRepo;
|
||||||
_pointsRepo = pointsRepo;
|
_pointsRepo = pointsRepo;
|
||||||
_sharingService = sharingService;
|
_sharingService = sharingService;
|
||||||
_combined = combined;
|
_combined = combined;
|
||||||
_objectMessage = objectMessage;
|
_objectMessage = objectMessage;
|
||||||
RoundElements = new ObservableCollection<RoundBuilderElement>();
|
_nav = nav;
|
||||||
|
_factory = factory;
|
||||||
|
_splashService = splashService;
|
||||||
|
_appShellView = appShellView;
|
||||||
|
_roundElements = new ObservableCollection<RoundBuilderElement>();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
private GameRound? _GameRoundObject = new();
|
||||||
|
private ObservableCollection<RoundBuilderGroup> _GameRoundList = new();
|
||||||
|
private ObservableCollection<Participant> _ParticipantList = new();
|
||||||
private readonly IRepository<GameRound>? _roundsRepo;
|
private readonly IRepository<GameRound>? _roundsRepo;
|
||||||
private readonly IRepository<GamePoint> _pointsRepo;
|
private readonly IRepository<GamePoint> _pointsRepo;
|
||||||
private readonly IMethodSharingService<Participant> _sharingService;
|
private readonly IMethodSharingService<Participant> _sharingService;
|
||||||
private readonly ICombinedRepository _combined;
|
private readonly ICombinedRepository _combined;
|
||||||
private readonly IObjectMessageService _objectMessage;
|
private readonly IObjectMessageService _objectMessage;
|
||||||
|
private readonly INavigationService _nav;
|
||||||
|
private readonly IPageFactory _factory;
|
||||||
|
private readonly ISplashService _splashService;
|
||||||
|
private readonly AppShellViewModel _appShellView;
|
||||||
|
private Participant _selectedItem;
|
||||||
|
|
||||||
|
private ObservableCollection<RoundBuilderElement> _roundElements;
|
||||||
|
|
||||||
[ObservableProperty]
|
public ObservableCollection<RoundBuilderElement> RoundElements
|
||||||
private Participant selectedItem;
|
|
||||||
partial void OnSelectedItemChanged(Participant value)
|
|
||||||
{
|
{
|
||||||
if (value != null)
|
get { return _roundElements; }
|
||||||
|
set
|
||||||
{
|
{
|
||||||
OnItemSelected(value);
|
_roundElements = value;
|
||||||
|
RaisePropertyChanged(nameof(RoundElements));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[ObservableProperty]
|
|
||||||
private ObservableCollection<RoundBuilderElement> roundElements;
|
|
||||||
|
|
||||||
[ObservableProperty]
|
public Participant SelectedItem
|
||||||
private GameRound? gameRoundObject = new();
|
{
|
||||||
|
get => _selectedItem;
|
||||||
[ObservableProperty]
|
set
|
||||||
private ObservableCollection<RoundBuilderGroup> gameRoundList = new();
|
{
|
||||||
|
if (_selectedItem != value)
|
||||||
[ObservableProperty]
|
{
|
||||||
private ObservableCollection<Participant> participantList = new();
|
|
||||||
|
|
||||||
|
_selectedItem = value;
|
||||||
|
RaisePropertyChanged(nameof(SelectedItem));
|
||||||
|
OnItemSelected(value); // Metod som triggas vid val
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void OnItemSelected(Participant item)
|
private void OnItemSelected(Participant item)
|
||||||
{
|
{
|
||||||
if (RoundElements.Count == 0)
|
if (_roundElements.Count == 0)
|
||||||
{
|
{
|
||||||
var GameRound = new GameRound
|
var GameRound = new GameRound
|
||||||
{
|
{
|
||||||
@ -104,12 +123,41 @@ public partial class RoundStartingViewModel : ObservableObject
|
|||||||
newElement.GameRoundId = GamePointStart.GameRoundId;
|
newElement.GameRoundId = GamePointStart.GameRoundId;
|
||||||
newElement.GamePointId = GamePointStart.GamePointId;
|
newElement.GamePointId = GamePointStart.GamePointId;
|
||||||
|
|
||||||
RoundElements.Add(newElement);
|
_roundElements.Add(newElement);
|
||||||
// Gör något med det valda objektet
|
// Gör något med det valda objektet
|
||||||
Debug.WriteLine($"Du valde: {item.LastNameFirstName}");
|
Debug.WriteLine($"Du valde: {item.LastNameFirstName}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public GameRound? GameRoundObject
|
||||||
|
{
|
||||||
|
get { return _GameRoundObject; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_GameRoundObject = value;
|
||||||
|
RaisePropertyChanged(nameof(GameRoundObject));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ObservableCollection<RoundBuilderGroup> GameRoundList
|
||||||
|
{
|
||||||
|
get { return _GameRoundList; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_GameRoundList = value;
|
||||||
|
RaisePropertyChanged(nameof(GameRoundList));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ObservableCollection<Participant> ParticipantList
|
||||||
|
{
|
||||||
|
get { return _ParticipantList; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_ParticipantList = value;
|
||||||
|
RaisePropertyChanged(nameof(ParticipantList));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#region Get Method
|
#region Get Method
|
||||||
public ObservableCollection<RoundBuilderGroup> Get()
|
public ObservableCollection<RoundBuilderGroup> Get()
|
||||||
@ -170,9 +218,7 @@ public partial class RoundStartingViewModel : ObservableObject
|
|||||||
|
|
||||||
return GameRoundObject;
|
return GameRoundObject;
|
||||||
}
|
}
|
||||||
|
public virtual bool Save()
|
||||||
[RelayCommand]
|
|
||||||
public async Task<bool> SaveAsync()
|
|
||||||
{
|
{
|
||||||
if (_roundsRepo == null || GameRoundObject == null)
|
if (_roundsRepo == null || GameRoundObject == null)
|
||||||
{
|
{
|
||||||
@ -185,13 +231,11 @@ public partial class RoundStartingViewModel : ObservableObject
|
|||||||
GameRoundObject = new GameRound();
|
GameRoundObject = new GameRound();
|
||||||
RoundElements.Clear();
|
RoundElements.Clear();
|
||||||
this.Get();
|
this.Get();
|
||||||
await Shell.Current.GoToAsync("..");
|
|
||||||
}
|
}
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
[RelayCommand]
|
public void Rensa()
|
||||||
private async Task RensaAsync()
|
|
||||||
{
|
{
|
||||||
foreach (var element in RoundElements)
|
foreach (var element in RoundElements)
|
||||||
{
|
{
|
||||||
@ -199,29 +243,30 @@ public partial class RoundStartingViewModel : ObservableObject
|
|||||||
}
|
}
|
||||||
_roundsRepo?.DeleteById(GameRoundObject?.GameRoundId ?? 0);
|
_roundsRepo?.DeleteById(GameRoundObject?.GameRoundId ?? 0);
|
||||||
RoundElements.Clear();
|
RoundElements.Clear();
|
||||||
await Shell.Current.GoToAsync("..");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[RelayCommand]
|
public async void RoundSelected(RoundBuilderElement element)
|
||||||
public async Task RoundSelected(RoundBuilderElement element)
|
|
||||||
{
|
{
|
||||||
var rbGroup = GameRoundList.FirstOrDefault(g => g.GameRoundId == element.GameRoundId);
|
var rbGroup = GameRoundList.FirstOrDefault(g => g.GameRoundId == element.GameRoundId);
|
||||||
Debug.WriteLine($"Du valde raden med Runda {element.GameRoundId} och spelare: {element.ParticipantName}");
|
Debug.WriteLine($"Du valde raden med Runda {element.GameRoundId} och spelare: {element.ParticipantName}");
|
||||||
if (rbGroup != null)
|
if (rbGroup != null)
|
||||||
{
|
{
|
||||||
_objectMessage.CurrentGroup = rbGroup;
|
_objectMessage.CurrentGroup = rbGroup;
|
||||||
//await Shell.Current.GoToAsync("//RoundRunningView");
|
_objectMessage.Delivered = true;
|
||||||
await Shell.Current.GoToAsync("//RoundRunningView");
|
//await _splashService.ShowSplash("Runda vald, gå till\r\r 'Påbörja eller fortsätt Runda'", 3000);
|
||||||
|
await Shell.Current.GoToAsync("RoundRunningPage");
|
||||||
|
|
||||||
|
_appShellView.RoundRunningVisible = false;
|
||||||
|
//_roundRunning.GobackVisible = false;
|
||||||
|
//var page = _factory.CreateRoundPage();
|
||||||
|
//_nav.NavigateToPageAsync(page);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[RelayCommand]
|
|
||||||
public async Task<bool> SelectNewlyAddedParticipant(RoundBuilderElement roundBuilder)
|
public void SelectNewlyAddedParticipant(RoundBuilderElement roundBuilder)
|
||||||
{
|
{
|
||||||
bool goneOk = false;
|
|
||||||
Debug.WriteLine($"Du valde raden med Runda {roundBuilder.GameRoundId} och spelare: {roundBuilder.ParticipantName}");
|
Debug.WriteLine($"Du valde raden med Runda {roundBuilder.GameRoundId} och spelare: {roundBuilder.ParticipantName}");
|
||||||
goneOk = true;
|
|
||||||
return goneOk;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
103
GreadyPoang.ViewModelLayer/ViewModelClasses/SplashViewModel.cs
Normal file
103
GreadyPoang.ViewModelLayer/ViewModelClasses/SplashViewModel.cs
Normal file
@ -0,0 +1,103 @@
|
|||||||
|
using Common.Library;
|
||||||
|
|
||||||
|
namespace GreadyPoang.ViewModelLayer;
|
||||||
|
|
||||||
|
public class SplashViewModel : ViewModelBase
|
||||||
|
{
|
||||||
|
// public event PropertyChangedEventHandler PropertyChanged;
|
||||||
|
|
||||||
|
private Color _splashBackgroundColor = Colors.DarkSlateBlue;
|
||||||
|
public Color SplashBackgroundColor
|
||||||
|
{
|
||||||
|
get => _splashBackgroundColor;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_splashBackgroundColor = value;
|
||||||
|
RaisePropertyChanged(nameof(SplashBackgroundColor));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private bool _isSplashVisible = false;
|
||||||
|
public bool IsSplashVisible
|
||||||
|
{
|
||||||
|
get => _isSplashVisible;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_isSplashVisible = value;
|
||||||
|
RaisePropertyChanged(nameof(IsSplashVisible));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private double _splashOpacity = 1.0;
|
||||||
|
public double SplashOpacity
|
||||||
|
{
|
||||||
|
get => _splashOpacity;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_splashOpacity = value;
|
||||||
|
RaisePropertyChanged(nameof(SplashOpacity));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Color _splashTextColor = Colors.White;
|
||||||
|
|
||||||
|
public Color SplashTextColor
|
||||||
|
{
|
||||||
|
get { return _splashTextColor; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_splashTextColor = value;
|
||||||
|
RaisePropertyChanged(nameof(SplashTextColor));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private double _splashTranslationY = 0;
|
||||||
|
public double SplashTranslationY
|
||||||
|
{
|
||||||
|
get => _splashTranslationY;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_splashTranslationY = value;
|
||||||
|
RaisePropertyChanged(nameof(SplashTranslationY));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task HideSplashAsync()
|
||||||
|
{
|
||||||
|
await Task.Delay(1000); // Simulera laddning
|
||||||
|
await AnimateSplashOut();
|
||||||
|
IsSplashVisible = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private string _splashText = "Välkommen!";
|
||||||
|
public string SplashText
|
||||||
|
{
|
||||||
|
get => _splashText;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_splashText = value;
|
||||||
|
RaisePropertyChanged(nameof(SplashText));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//public Color SplashBackgroundColor { get; set; } = Colors.DarkSlateBlue;
|
||||||
|
//public string SplashImage { get; set; } = "splash_icon.png";
|
||||||
|
|
||||||
|
//protected void OnPropertyChanged(string name) =>
|
||||||
|
// PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private async Task AnimateSplashOut()
|
||||||
|
{
|
||||||
|
for (int i = 0; i < 10; i++)
|
||||||
|
{
|
||||||
|
SplashOpacity -= 0.1;
|
||||||
|
//SplashTranslationY += 5;
|
||||||
|
await Task.Delay(30);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
# Visual Studio Version 17
|
# Visual Studio Version 17
|
||||||
VisualStudioVersion = 17.14.36408.4
|
VisualStudioVersion = 17.14.36518.9 d17.14
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GreadyPoang", "GreadyPoang\GreadyPoang.csproj", "{B237F7D6-3B04-49AE-81B0-FEFE21A94CA7}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GreadyPoang", "GreadyPoang\GreadyPoang.csproj", "{B237F7D6-3B04-49AE-81B0-FEFE21A94CA7}"
|
||||||
EndProject
|
EndProject
|
||||||
|
|||||||
@ -1,18 +1,38 @@
|
|||||||
using GreadyPoang.DataLayer.Database;
|
using GreadyPoang.DataLayer.Database;
|
||||||
|
using System.Diagnostics;
|
||||||
|
|
||||||
namespace GreadyPoang
|
namespace GreadyPoang;
|
||||||
|
|
||||||
|
public partial class App : Application
|
||||||
{
|
{
|
||||||
public partial class App : Application
|
private readonly IServiceProvider _services;
|
||||||
{
|
|
||||||
public App(DataContext dataContext)
|
public App(IServiceProvider services, DataContext dataContext)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
dataContext.Database.EnsureCreated();
|
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)
|
protected override Window CreateWindow(IActivationState? activationState)
|
||||||
{
|
{
|
||||||
return new Window(new AppShell());
|
|
||||||
}
|
//var splashVm = ServiceLocator.Services.GetRequiredService<SplashViewModelCommands>();
|
||||||
|
//var shell = new AppShell(splashVm);
|
||||||
|
|
||||||
|
var shell = _services.GetRequiredService<AppShell>();
|
||||||
|
return new Window(shell);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3,28 +3,28 @@
|
|||||||
x:Class="GreadyPoang.AppShell"
|
x:Class="GreadyPoang.AppShell"
|
||||||
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
|
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||||
|
xmlns:vm ="clr-namespace:GreadyPoang.ViewModelLayer;assembly=GreadyPoang.ViewModelLayer"
|
||||||
xmlns:views="clr-namespace:GreadyPoang.Views"
|
xmlns:views="clr-namespace:GreadyPoang.Views"
|
||||||
|
xmlns:pages="clr-namespace:GreadyPoang.Pages"
|
||||||
xmlns:local="clr-namespace:GreadyPoang"
|
xmlns:local="clr-namespace:GreadyPoang"
|
||||||
Title="GreadyPoang"
|
Title="GreadyPoang"
|
||||||
Shell.TitleColor="LightYellow"
|
Shell.TitleColor="LightYellow"
|
||||||
|
x:DataType="vm:AppShellViewModel"
|
||||||
Shell.BackgroundColor="CadetBlue">
|
Shell.BackgroundColor="CadetBlue">
|
||||||
|
|
||||||
<TabBar>
|
<TabBar>
|
||||||
<ShellContent
|
<ShellContent
|
||||||
Title="Home"
|
Title="Home" ContentTemplate="{DataTemplate local:MainPage}"
|
||||||
ContentTemplate="{DataTemplate local:MainPage}"
|
|
||||||
Route="MainPage" />
|
Route="MainPage" />
|
||||||
<ShellContent
|
<ShellContent
|
||||||
Title="Deltagare"
|
Title="Deltagare" ContentTemplate="{DataTemplate pages:ParticipantListPage}"
|
||||||
ContentTemplate="{DataTemplate views:ParticipantListView}"
|
Route="ParticipantListPage"/>
|
||||||
Route="ParticipantListView" />
|
|
||||||
<ShellContent
|
<ShellContent
|
||||||
Title="Starta Ny Runda"
|
Title="Ny Runda" ContentTemplate="{DataTemplate pages:RoundStartingPage}"
|
||||||
ContentTemplate="{DataTemplate views:RoundStartingView}"
|
Route="RoundStartingPage"/>
|
||||||
Route="RoundStartingView" />
|
|
||||||
<ShellContent
|
<ShellContent
|
||||||
Title="Påbörja eller fortsätt Runda"
|
Title="Påbörja eller fortsätt Runda" ContentTemplate="{DataTemplate pages:RoundRunningPage}"
|
||||||
ContentTemplate="{DataTemplate views:RoundRunningView}"
|
Route="RoundRunningPage" IsVisible="{Binding RoundRunningVisible}"/>
|
||||||
Route="RoundRunningView" />
|
|
||||||
</TabBar>
|
</TabBar>
|
||||||
|
|
||||||
</Shell>
|
</Shell>
|
||||||
|
|||||||
@ -1,10 +1,21 @@
|
|||||||
namespace GreadyPoang
|
using GreadyPoang.Core;
|
||||||
|
using GreadyPoang.ViewModelLayer;
|
||||||
|
|
||||||
|
namespace GreadyPoang
|
||||||
{
|
{
|
||||||
public partial class AppShell : Shell
|
public partial class AppShell : Shell
|
||||||
{
|
{
|
||||||
public AppShell()
|
private readonly IPageFactory _factory;
|
||||||
|
|
||||||
|
public AppShell(IPageFactory factory, AppShellViewModel appShellView)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
|
Routing.RegisterRoute("RoundStartingPage", typeof(Pages.RoundStartingPage));
|
||||||
|
Routing.RegisterRoute("ParticipantListPage", typeof(Pages.ParticipantListPage));
|
||||||
|
Routing.RegisterRoute("RoundRunningPage", typeof(Pages.RoundRunningPage));
|
||||||
|
_factory = factory;
|
||||||
|
BindingContext = appShellView;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
40
GreadyPoang/BasePage.xaml
Normal file
40
GreadyPoang/BasePage.xaml
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||||
|
x:Class="GreadyPoang.BasePage"
|
||||||
|
xmlns:viewsPartial="clr-namespace:GreadyPoang.ViewsPartial"
|
||||||
|
x:Name="Root">
|
||||||
|
<AbsoluteLayout>
|
||||||
|
<!-- Huvudinnehåll -->
|
||||||
|
<ContentView x:Name="MainContent"
|
||||||
|
AbsoluteLayout.LayoutBounds="0,0,1,1"
|
||||||
|
AbsoluteLayout.LayoutFlags="All" />
|
||||||
|
|
||||||
|
<!-- Overlay: Splash -->
|
||||||
|
<viewsPartial:SplashView
|
||||||
|
AbsoluteLayout.LayoutBounds="0,0,1,1"
|
||||||
|
AbsoluteLayout.LayoutFlags="All"
|
||||||
|
x:Name="SplashView"
|
||||||
|
IsVisible="True"
|
||||||
|
Opacity="1"
|
||||||
|
ZIndex="999"
|
||||||
|
TranslationY="{Binding SplashTranslationY}"
|
||||||
|
InputTransparent="True" >
|
||||||
|
</viewsPartial:SplashView>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
WidthRequest="250"
|
||||||
|
HeightRequest="150"
|
||||||
|
IsVisible="{Binding IsSplashVisible}"
|
||||||
|
BackgroundColor="{Binding SplashBackgroundColor}"
|
||||||
|
x:Name="SplashView"
|
||||||
|
BackgroundColor="Black"
|
||||||
|
Opacity="{Binding SplashOpacity}"
|
||||||
|
IsVisible="True"
|
||||||
|
Opacity="0.9"
|
||||||
|
ZIndex="999"
|
||||||
|
BackgroundColor="Black" />-->
|
||||||
|
|
||||||
|
|
||||||
|
</AbsoluteLayout>
|
||||||
|
</ContentPage>
|
||||||
13
GreadyPoang/BasePage.xaml.cs
Normal file
13
GreadyPoang/BasePage.xaml.cs
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
using GreadyPoang.CommandClasses;
|
||||||
|
|
||||||
|
namespace GreadyPoang;
|
||||||
|
|
||||||
|
public partial class BasePage : ContentPage
|
||||||
|
{
|
||||||
|
public BasePage(View content, SplashViewModelCommands splashVm)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
MainContent.Content = content;
|
||||||
|
SplashView.BindingContext = splashVm;
|
||||||
|
}
|
||||||
|
}
|
||||||
11
GreadyPoang/CommandClasses/AppShellViewModelCommands.cs
Normal file
11
GreadyPoang/CommandClasses/AppShellViewModelCommands.cs
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
using GreadyPoang.ViewModelLayer;
|
||||||
|
|
||||||
|
namespace GreadyPoang.CommandClasses;
|
||||||
|
|
||||||
|
public class AppShellViewModelCommands : AppShellViewModel
|
||||||
|
{
|
||||||
|
public AppShellViewModelCommands() : base()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
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)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
72
GreadyPoang/CommandClasses/ParticipantViewModelCommands.cs
Normal file
72
GreadyPoang/CommandClasses/ParticipantViewModelCommands.cs
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
using Common.Library;
|
||||||
|
using GreadyPoang.EntityLayer;
|
||||||
|
using GreadyPoang.Services;
|
||||||
|
using GreadyPoang.ViewModelLayer;
|
||||||
|
using System.Windows.Input;
|
||||||
|
|
||||||
|
|
||||||
|
namespace GreadyPoang.CommandClasses;
|
||||||
|
|
||||||
|
public class ParticipantViewModelCommands : ParticipantViewModel
|
||||||
|
{
|
||||||
|
#region constructors
|
||||||
|
public ParticipantViewModelCommands() : base()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public ParticipantViewModelCommands(
|
||||||
|
IRepository<Participant> repo,
|
||||||
|
IMethodSharingService<Participant> sharingService,
|
||||||
|
AppShellViewModel appShell,
|
||||||
|
IObjectMessageService objectMessage) : base(repo, sharingService, appShell, objectMessage)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Private Variables
|
||||||
|
private bool _IsSaveCommandEnabled = true;
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Public Properties
|
||||||
|
public bool IsSaveCommandEnabled
|
||||||
|
{
|
||||||
|
get { return _IsSaveCommandEnabled; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_IsSaveCommandEnabled = value;
|
||||||
|
RaisePropertyChanged(nameof(IsSaveCommandEnabled));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Commands
|
||||||
|
public ICommand SaveCommand { get; private set; }
|
||||||
|
public ICommand EditCommand { get; private set; }
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Init Method
|
||||||
|
public override void Init()
|
||||||
|
{
|
||||||
|
base.Init();
|
||||||
|
SaveCommand = new Command(async () => SaveAsync(), () => IsSaveCommandEnabled);
|
||||||
|
EditCommand = new Command<int>(async (id) => await EditAsync(id), (id) => id > 0);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
protected async Task EditAsync(int id)
|
||||||
|
{
|
||||||
|
await Shell.Current.GoToAsync($"{nameof(Views.ParticipantListView)}?id={id}");
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<bool> SaveAsync()
|
||||||
|
{
|
||||||
|
var ret = base.Save();
|
||||||
|
if (ret)
|
||||||
|
{
|
||||||
|
await Shell.Current.GoToAsync("..");
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
}
|
||||||
67
GreadyPoang/CommandClasses/RoundRunningViewModelCommands.cs
Normal file
67
GreadyPoang/CommandClasses/RoundRunningViewModelCommands.cs
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
using Common.Library;
|
||||||
|
using GreadyPoang.Core;
|
||||||
|
using GreadyPoang.DataLayer;
|
||||||
|
using GreadyPoang.EntityLayer;
|
||||||
|
using GreadyPoang.Services;
|
||||||
|
using GreadyPoang.ViewModelLayer;
|
||||||
|
using System.Windows.Input;
|
||||||
|
|
||||||
|
namespace GreadyPoang.CommandClasses;
|
||||||
|
|
||||||
|
public class RoundRunningViewModelCommands : RoundRunningViewModel
|
||||||
|
{
|
||||||
|
public RoundRunningViewModelCommands() : base()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public RoundRunningViewModelCommands(
|
||||||
|
IRepository<GameRound> roundsRepo,
|
||||||
|
IRepository<GamePoint> pointsRepo,
|
||||||
|
IMethodSharingService<Participant> sharingService,
|
||||||
|
ICombinedRepository combined,
|
||||||
|
IObjectMessageService objectMessage,
|
||||||
|
ISplashService splashService,
|
||||||
|
AppShellViewModel appShell)
|
||||||
|
: base(roundsRepo,
|
||||||
|
pointsRepo,
|
||||||
|
sharingService,
|
||||||
|
combined,
|
||||||
|
objectMessage,
|
||||||
|
splashService,
|
||||||
|
appShell)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Commands
|
||||||
|
public ICommand GobackCommand { get; private set; }
|
||||||
|
public ICommand StoreAndHandlePointsCommand { get; private set; }
|
||||||
|
public ICommand OnSplashClickedCommand { get; private set; }
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
public override void Init()
|
||||||
|
{
|
||||||
|
base.Init();
|
||||||
|
StoreAndHandlePointsCommand = new Command(async () => StoreAndHandleAsync());
|
||||||
|
OnSplashClickedCommand = new Command(async () => await ToggleSplash());
|
||||||
|
GobackCommand = new Command(async () => GobackAsync());
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void GobackAsync()
|
||||||
|
{
|
||||||
|
base.GobackAsync();
|
||||||
|
await Shell.Current.GoToAsync("..");
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task StoreAndHandleAsync()
|
||||||
|
{
|
||||||
|
base.StoreAndHandlePoints();
|
||||||
|
//await Shell.Current.GoToAsync("..");
|
||||||
|
// await Shell.Current.GoToAsync("RoundRunningPage");
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task ToggleSplash()
|
||||||
|
{
|
||||||
|
base.ToggleSplash();
|
||||||
|
}
|
||||||
|
}
|
||||||
115
GreadyPoang/CommandClasses/RoundStartingViewModelCommands.cs
Normal file
115
GreadyPoang/CommandClasses/RoundStartingViewModelCommands.cs
Normal file
@ -0,0 +1,115 @@
|
|||||||
|
using Common.Library;
|
||||||
|
using GreadyPoang.Core;
|
||||||
|
using GreadyPoang.DataLayer;
|
||||||
|
using GreadyPoang.EntityLayer;
|
||||||
|
using GreadyPoang.Services;
|
||||||
|
using GreadyPoang.ViewModelLayer;
|
||||||
|
using System.Windows.Input;
|
||||||
|
|
||||||
|
namespace GreadyPoang.CommandClasses;
|
||||||
|
|
||||||
|
public class RoundStartingViewModelCommands : RoundStartingViewModel
|
||||||
|
{
|
||||||
|
public RoundStartingViewModelCommands() : base()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
public RoundStartingViewModelCommands(
|
||||||
|
IRepository<GameRound> roundsRepo,
|
||||||
|
IRepository<GamePoint> pointsRepo,
|
||||||
|
IMethodSharingService<Participant> sharingService,
|
||||||
|
ICombinedRepository combined,
|
||||||
|
IObjectMessageService objectMessage,
|
||||||
|
INavigationService nav,
|
||||||
|
IPageFactory factory,
|
||||||
|
ISplashService splashService,
|
||||||
|
AppShellViewModel appShell)
|
||||||
|
: base(roundsRepo,
|
||||||
|
pointsRepo,
|
||||||
|
sharingService,
|
||||||
|
combined,
|
||||||
|
objectMessage,
|
||||||
|
nav,
|
||||||
|
factory,
|
||||||
|
splashService,
|
||||||
|
appShell)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Private Variables
|
||||||
|
private bool _IsSaveCommandEnabled = true;
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Public Properties
|
||||||
|
public bool IsSaveCommandEnabled
|
||||||
|
{
|
||||||
|
get { return _IsSaveCommandEnabled; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_IsSaveCommandEnabled = value;
|
||||||
|
RaisePropertyChanged(nameof(IsSaveCommandEnabled));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Commands
|
||||||
|
public ICommand SaveCommand { get; private set; }
|
||||||
|
public ICommand EditCommand { get; private set; }
|
||||||
|
public ICommand RensaCommand { get; private set; }
|
||||||
|
public ICommand ElementTappedCommand { get; private set; }
|
||||||
|
public ICommand ParticipantTappedCommand { get; private set; }
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Init Method
|
||||||
|
public override void Init()
|
||||||
|
{
|
||||||
|
base.Init();
|
||||||
|
SaveCommand = new Command(async () => SaveAsync(), () => IsSaveCommandEnabled);
|
||||||
|
EditCommand = new Command<int>(async (id) => await EditAsync(id), (id) => id > 0);
|
||||||
|
RensaCommand = new Command(async () => RensaAsync());
|
||||||
|
ParticipantTappedCommand = new Command<RoundBuilderElement>(async (selectedParticipant) => SelectNewlyAddedParticipant(selectedParticipant));
|
||||||
|
ElementTappedCommand = new Command<RoundBuilderElement>((selectedElement) => RoundSelected(selectedElement));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task RensaAsync()
|
||||||
|
{
|
||||||
|
base.Rensa();
|
||||||
|
await Shell.Current.GoToAsync("..");
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
protected async Task EditAsync(int id)
|
||||||
|
{
|
||||||
|
await Shell.Current.GoToAsync($"{nameof(Views.RoundStartingView)}?id={id}");
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<bool> SaveAsync()
|
||||||
|
{
|
||||||
|
var ret = base.Save();
|
||||||
|
if (ret)
|
||||||
|
{
|
||||||
|
await Shell.Current.GoToAsync("..");
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<bool> RoundSelected(RoundBuilderElement element)
|
||||||
|
{
|
||||||
|
bool goneOk = false;
|
||||||
|
base.RoundSelected(element);
|
||||||
|
goneOk = true;
|
||||||
|
return goneOk;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<bool> SelectNewlyAddedParticipant(RoundBuilderElement roundBuilder)
|
||||||
|
{
|
||||||
|
bool goneOk = false;
|
||||||
|
base.SelectNewlyAddedParticipant(roundBuilder);
|
||||||
|
goneOk = true;
|
||||||
|
return goneOk;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
10
GreadyPoang/CommandClasses/SplashViewModelCommands.cs
Normal file
10
GreadyPoang/CommandClasses/SplashViewModelCommands.cs
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
using GreadyPoang.ViewModelLayer;
|
||||||
|
|
||||||
|
namespace GreadyPoang.CommandClasses;
|
||||||
|
|
||||||
|
public class SplashViewModelCommands : SplashViewModel
|
||||||
|
{
|
||||||
|
public SplashViewModelCommands() : base()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
11
GreadyPoang/Core/NavigationService.cs
Normal file
11
GreadyPoang/Core/NavigationService.cs
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
namespace GreadyPoang.Core;
|
||||||
|
|
||||||
|
public class NavigationService : INavigationService
|
||||||
|
{
|
||||||
|
|
||||||
|
public Task NavigateToAsync(string route)
|
||||||
|
=> Shell.Current.GoToAsync(route);
|
||||||
|
|
||||||
|
public Task NavigateToPageAsync(Page page)
|
||||||
|
=> Shell.Current.Navigation.PushAsync(page);
|
||||||
|
}
|
||||||
30
GreadyPoang/Core/PageFactory.cs
Normal file
30
GreadyPoang/Core/PageFactory.cs
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
using GreadyPoang.CommandClasses;
|
||||||
|
using GreadyPoang.Core;
|
||||||
|
using GreadyPoang.Pages;
|
||||||
|
|
||||||
|
namespace GreadyPoang;
|
||||||
|
|
||||||
|
public class PageFactory : IPageFactory
|
||||||
|
{
|
||||||
|
private readonly IServiceProvider _services;
|
||||||
|
|
||||||
|
public PageFactory(IServiceProvider services)
|
||||||
|
{
|
||||||
|
_services = services;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Page CreateRoundPage()
|
||||||
|
{
|
||||||
|
var vm = _services.GetRequiredService<RoundRunningViewModelCommands>();
|
||||||
|
var splashVm = _services.GetRequiredService<SplashViewModelCommands>();
|
||||||
|
return new RoundRunningPage(vm, splashVm);
|
||||||
|
}
|
||||||
|
|
||||||
|
//public Page CreateStatsPage()
|
||||||
|
//{
|
||||||
|
// //var vm = _services.GetRequiredService<StatsViewModel>();
|
||||||
|
// //var splashVm = _services.GetRequiredService<SplashViewModelCommands>();
|
||||||
|
// //var view = new StatsView { BindingContext = vm };
|
||||||
|
// //return new StatsPage(view, splashVm);
|
||||||
|
//}
|
||||||
|
}
|
||||||
10
GreadyPoang/Core/ServiceLocator.cs
Normal file
10
GreadyPoang/Core/ServiceLocator.cs
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
using GreadyPoang.InterFaces;
|
||||||
|
|
||||||
|
namespace GreadyPoang;
|
||||||
|
|
||||||
|
public class ServiceLocator : IServiceLocator
|
||||||
|
{
|
||||||
|
public static IServiceProvider? Services { get; set; } = default;
|
||||||
|
public T Get<T>() => (T)Services!.GetService(typeof(T))!;
|
||||||
|
|
||||||
|
}
|
||||||
@ -60,16 +60,6 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Remove="Views\RoundRunningViewOld.xaml.cs" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<MauiXaml Remove="Views\RoundRunningViewOld.xaml" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="CommunityToolkit.Maui" Version="12.2.0" />
|
|
||||||
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.4.0" />
|
|
||||||
<PackageReference Include="Microsoft.Maui.Controls" Version="9.0.100" />
|
<PackageReference Include="Microsoft.Maui.Controls" Version="9.0.100" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="9.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="9.0.0" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="9.0.8" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="9.0.8" />
|
||||||
@ -80,29 +70,26 @@
|
|||||||
<ProjectReference Include="..\GreadyPoang.Common\GreadyPoang.Common.csproj" />
|
<ProjectReference Include="..\GreadyPoang.Common\GreadyPoang.Common.csproj" />
|
||||||
<ProjectReference Include="..\GreadyPoang.DataLayer\GreadyPoang.DataLayer.csproj" />
|
<ProjectReference Include="..\GreadyPoang.DataLayer\GreadyPoang.DataLayer.csproj" />
|
||||||
<ProjectReference Include="..\GreadyPoang.EntityLayer\GreadyPoang.EntityLayer.csproj" />
|
<ProjectReference Include="..\GreadyPoang.EntityLayer\GreadyPoang.EntityLayer.csproj" />
|
||||||
<ProjectReference Include="..\GreadyPoang.Services\GreadyPoang.Services.csproj" />
|
<!--<ProjectReference Include="..\GreadyPoang.Services\GreadyPoang.Services.csproj" />-->
|
||||||
<ProjectReference Include="..\GreadyPoang.ViewModelLayer\GreadyPoang.ViewModelLayer.csproj" />
|
<ProjectReference Include="..\GreadyPoang.ViewModelLayer\GreadyPoang.ViewModelLayer.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Update="Popups\InfoPopup.xaml.cs">
|
|
||||||
<DependentUpon>InfoPopup.xaml</DependentUpon>
|
|
||||||
</Compile>
|
|
||||||
<Compile Update="Views\ParticipantListView.xaml.cs">
|
<Compile Update="Views\ParticipantListView.xaml.cs">
|
||||||
<DependentUpon>ParticipantListView.xaml</DependentUpon>
|
<DependentUpon>ParticipantListView.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<MauiXaml Update="BasePage.xaml">
|
||||||
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
</MauiXaml>
|
||||||
<MauiXaml Update="Resources\Styles\AppStyles.xaml">
|
<MauiXaml Update="Resources\Styles\AppStyles.xaml">
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
</MauiXaml>
|
</MauiXaml>
|
||||||
<MauiXaml Update="ViewsPartial\HeaderView.xaml">
|
<MauiXaml Update="ViewsPartial\HeaderView.xaml">
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
</MauiXaml>
|
</MauiXaml>
|
||||||
<MauiXaml Update="Popups\InfoPopup.xaml">
|
|
||||||
<Generator>MSBuild:Compile</Generator>
|
|
||||||
</MauiXaml>
|
|
||||||
<MauiXaml Update="Views\ParticipantListView.xaml">
|
<MauiXaml Update="Views\ParticipantListView.xaml">
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
</MauiXaml>
|
</MauiXaml>
|
||||||
@ -112,6 +99,9 @@
|
|||||||
<MauiXaml Update="Views\RoundStartingView.xaml">
|
<MauiXaml Update="Views\RoundStartingView.xaml">
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
</MauiXaml>
|
</MauiXaml>
|
||||||
|
<MauiXaml Update="ViewsPartial\SplashView.xaml">
|
||||||
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
</MauiXaml>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
12
GreadyPoang/InterFaces/IServiceLocator.cs
Normal file
12
GreadyPoang/InterFaces/IServiceLocator.cs
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace GreadyPoang.InterFaces;
|
||||||
|
|
||||||
|
public interface IServiceLocator
|
||||||
|
{
|
||||||
|
T Get<T>();
|
||||||
|
}
|
||||||
34
GreadyPoang/LocalServices/Implements/SplashService.cs
Normal file
34
GreadyPoang/LocalServices/Implements/SplashService.cs
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
using GreadyPoang.CommandClasses;
|
||||||
|
using GreadyPoang.Core;
|
||||||
|
|
||||||
|
namespace GreadyPoang.LocalServices;
|
||||||
|
|
||||||
|
public class SplashService : ISplashService
|
||||||
|
{
|
||||||
|
private readonly SplashViewModelCommands _viewModel;
|
||||||
|
|
||||||
|
public SplashService(SplashViewModelCommands viewModel)
|
||||||
|
{
|
||||||
|
_viewModel = viewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task ShowSplash(string text = "Välkommen!", int durationMs = 3000)
|
||||||
|
{
|
||||||
|
_viewModel.SplashText = text;
|
||||||
|
_viewModel.SplashOpacity = 0.8;
|
||||||
|
_viewModel.SplashBackgroundColor = Colors.DodgerBlue;
|
||||||
|
_viewModel.IsSplashVisible = true;
|
||||||
|
//await Task.Yield(); // ger UI-tråden en chans att uppdatera
|
||||||
|
if (durationMs > 0)
|
||||||
|
{
|
||||||
|
await Task.Delay(durationMs);
|
||||||
|
_viewModel.IsSplashVisible = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task HideAsync()
|
||||||
|
{
|
||||||
|
//_viewModel.IsSplashVisible = false;
|
||||||
|
await _viewModel.HideSplashAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -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();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,9 +1,11 @@
|
|||||||
using Common.Library;
|
using Common.Library;
|
||||||
using CommunityToolkit.Maui;
|
using GreadyPoang.CommandClasses;
|
||||||
|
using GreadyPoang.Core;
|
||||||
using GreadyPoang.DataLayer;
|
using GreadyPoang.DataLayer;
|
||||||
using GreadyPoang.DataLayer.Database;
|
using GreadyPoang.DataLayer.Database;
|
||||||
using GreadyPoang.EntityLayer;
|
using GreadyPoang.EntityLayer;
|
||||||
using GreadyPoang.Popups;
|
using GreadyPoang.InterFaces;
|
||||||
|
using GreadyPoang.LocalServices;
|
||||||
using GreadyPoang.Services;
|
using GreadyPoang.Services;
|
||||||
using GreadyPoang.ViewModelLayer;
|
using GreadyPoang.ViewModelLayer;
|
||||||
using GreadyPoang.Views;
|
using GreadyPoang.Views;
|
||||||
@ -20,8 +22,6 @@ public static class MauiProgram
|
|||||||
|
|
||||||
builder
|
builder
|
||||||
.UseMauiApp<App>()
|
.UseMauiApp<App>()
|
||||||
.UseMauiCommunityToolkit(options =>
|
|
||||||
options.SetShouldEnableSnackbarOnWindows(true))
|
|
||||||
.ConfigureFonts(fonts =>
|
.ConfigureFonts(fonts =>
|
||||||
{
|
{
|
||||||
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
|
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
|
||||||
@ -33,41 +33,49 @@ public static class MauiProgram
|
|||||||
builder.Services.AddDbContext<DataContext>(options =>
|
builder.Services.AddDbContext<DataContext>(options =>
|
||||||
{
|
{
|
||||||
var MauiDataPath = FileSystem.Current.AppDataDirectory;
|
var MauiDataPath = FileSystem.Current.AppDataDirectory;
|
||||||
//if (!File.Exists(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "MauiDataPath_GreadyPoang.txt"))) ;
|
if (!File.Exists(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "MauiDataPath_GreadyPoang.txt"))) ;
|
||||||
//{
|
{
|
||||||
// File.WriteAllText(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "MauiDataPath_GreadyPoang.txt"), MauiDataPath);
|
File.WriteAllText(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "MauiDataPath_GreadyPoang.txt"), MauiDataPath);
|
||||||
//}
|
}
|
||||||
var dbPath = Path.Combine(MauiDataPath, "PoangDB.db");
|
var dbPath = Path.Combine(MauiDataPath, "PoangDB.db");
|
||||||
options.UseSqlite($"Data Source={dbPath}");
|
options.UseSqlite($"Data Source={dbPath}");
|
||||||
});
|
});
|
||||||
|
|
||||||
builder.Services.AddScoped<IRepository<Participant>, ParticipantRepository>();
|
builder.Services.AddScoped<IPageFactory, PageFactory>();
|
||||||
builder.Services.AddScoped<IMethodSharingService<Participant>, MethodSharingService>();
|
builder.Services.AddSingleton<INavigationService, NavigationService>();
|
||||||
|
builder.Services.AddSingleton<IServiceLocator, ServiceLocator>();
|
||||||
|
|
||||||
builder.Services.AddScoped<ParticipantViewModel>();
|
builder.Services.AddScoped<IRepository<Participant>, ParticipantRepository>();
|
||||||
|
builder.Services.AddScoped<ParticipantViewModelCommands>();
|
||||||
builder.Services.AddScoped<ParticipantListView>();
|
builder.Services.AddScoped<ParticipantListView>();
|
||||||
|
|
||||||
builder.Services.AddScoped<IRepository<GameRound>, GameRoundRepository>();
|
builder.Services.AddScoped<IRepository<GameRound>, GameRoundRepository>();
|
||||||
|
builder.Services.AddScoped<RoundStartingViewModelCommands>();
|
||||||
builder.Services.AddScoped<RoundStartingViewModel>();
|
|
||||||
builder.Services.AddScoped<RoundStartingView>();
|
builder.Services.AddScoped<RoundStartingView>();
|
||||||
|
|
||||||
builder.Services.AddScoped<IRepository<GamePoint>, GamePointRepository>();
|
builder.Services.AddScoped<IRepository<GamePoint>, GamePointRepository>();
|
||||||
|
builder.Services.AddScoped<RoundRunningViewModelCommands>();
|
||||||
builder.Services.AddScoped<RoundRunningViewModel>();
|
|
||||||
builder.Services.AddScoped<RoundRunningView>();
|
builder.Services.AddScoped<RoundRunningView>();
|
||||||
|
|
||||||
|
builder.Services.AddScoped<IMethodSharingService<Participant>, MethodSharingService>();
|
||||||
builder.Services.AddScoped<ICombinedRepository, CombinedRepository>();
|
builder.Services.AddScoped<ICombinedRepository, CombinedRepository>();
|
||||||
|
|
||||||
builder.Services.AddSingleton<IObjectMessageService, ObjectMessageService>();
|
builder.Services.AddSingleton<IObjectMessageService, ObjectMessageService>();
|
||||||
|
|
||||||
builder.Services.AddTransientPopup<InfoPopup, InfoPopupViewModel>();
|
builder.Services.AddSingleton<AppShellViewModel>();
|
||||||
builder.Services.AddSingleton<IPopupEventHub, PopupEventHub>();
|
builder.Services.AddSingleton<AppShell>();
|
||||||
|
|
||||||
|
builder.Services.AddSingleton<SplashViewModelCommands>();
|
||||||
|
builder.Services.AddSingleton<ISplashService, SplashService>();
|
||||||
|
|
||||||
|
builder.Services.AddSingleton<MainPageViewModelCommands>();
|
||||||
|
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
builder.Logging.AddDebug();
|
builder.Logging.AddDebug();
|
||||||
#endif
|
#endif
|
||||||
|
var app = builder.Build();
|
||||||
return builder.Build();
|
ServiceLocator.Services = app.Services;
|
||||||
|
return app;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
24
GreadyPoang/Pages/ParticipantListPage.cs
Normal file
24
GreadyPoang/Pages/ParticipantListPage.cs
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
using GreadyPoang.CommandClasses;
|
||||||
|
using GreadyPoang.Views;
|
||||||
|
|
||||||
|
namespace GreadyPoang.Pages;
|
||||||
|
|
||||||
|
public class ParticipantListPage : BasePage
|
||||||
|
{
|
||||||
|
private readonly ParticipantViewModelCommands _vm;
|
||||||
|
|
||||||
|
public ParticipantListPage(ParticipantViewModelCommands vm, SplashViewModelCommands splashVm)
|
||||||
|
: base(new ParticipantListView(vm), splashVm)
|
||||||
|
{
|
||||||
|
Title = "Deltagar Lista";
|
||||||
|
_vm = vm;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnAppearing()
|
||||||
|
{
|
||||||
|
base.OnAppearing();
|
||||||
|
BindingContext = _vm;
|
||||||
|
_vm.Get();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
43
GreadyPoang/Pages/RoundRunningPage.cs
Normal file
43
GreadyPoang/Pages/RoundRunningPage.cs
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
using GreadyPoang.CommandClasses;
|
||||||
|
using GreadyPoang.Core;
|
||||||
|
using GreadyPoang.Views;
|
||||||
|
|
||||||
|
namespace GreadyPoang.Pages;
|
||||||
|
|
||||||
|
public class RoundRunningPage : BasePage
|
||||||
|
{
|
||||||
|
private readonly RoundRunningViewModelCommands _vm;
|
||||||
|
private readonly SplashViewModelCommands _splashVm;
|
||||||
|
public ISplashService Splash { get; set; }
|
||||||
|
|
||||||
|
public RoundRunningPage(RoundRunningViewModelCommands Vm, SplashViewModelCommands splashVm)
|
||||||
|
: base(new RoundRunningView(Vm), splashVm)
|
||||||
|
{
|
||||||
|
Title = "Starta/Fortsätt runda";
|
||||||
|
_vm = Vm;
|
||||||
|
Splash = ServiceLocator.Services?.GetRequiredService<ISplashService>();
|
||||||
|
_splashVm = splashVm;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public SplashViewModelCommands SplashVm { get; }
|
||||||
|
|
||||||
|
protected override async void OnAppearing()
|
||||||
|
{
|
||||||
|
base.OnAppearing();
|
||||||
|
BindingContext = _vm;
|
||||||
|
_vm.Get();
|
||||||
|
//BuildScoreGrid(ViewModel.PlayerColumns); // <-- här bygger du layouten
|
||||||
|
//// _vm.RebuildRequested += ViewModel_RebuildRequested;
|
||||||
|
if (_splashVm != null)
|
||||||
|
{
|
||||||
|
await Splash.ShowSplash("Nu kan du spela vidare", 3000);
|
||||||
|
//await Splash.ShowSplash("Nu kan du spela vidare", 3000).GetAwaiter().GetResult();
|
||||||
|
}
|
||||||
|
//_splashVm.ShowSplash("Nu kan du spela vidare").GetAwaiter().GetResult(); ;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
25
GreadyPoang/Pages/RoundStartingPage.cs
Normal file
25
GreadyPoang/Pages/RoundStartingPage.cs
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
using GreadyPoang.CommandClasses;
|
||||||
|
using GreadyPoang.Views;
|
||||||
|
|
||||||
|
namespace GreadyPoang.Pages;
|
||||||
|
|
||||||
|
public class RoundStartingPage : BasePage
|
||||||
|
{
|
||||||
|
private readonly RoundStartingViewModelCommands _vm;
|
||||||
|
|
||||||
|
public RoundStartingPage(RoundStartingViewModelCommands vm, SplashViewModelCommands splashVm)
|
||||||
|
: base(new RoundStartingView(vm), splashVm)
|
||||||
|
{
|
||||||
|
Title = "Starta ny Runda";
|
||||||
|
_vm = vm;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnAppearing()
|
||||||
|
{
|
||||||
|
base.OnAppearing();
|
||||||
|
BindingContext = _vm;
|
||||||
|
_vm.Get();
|
||||||
|
_vm.GetParticipants();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -1,22 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8" ?>
|
|
||||||
<ContentView
|
|
||||||
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
|
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
|
||||||
xmlns:viewModels="clr-namespace:GreadyPoang.ViewModelLayer;assembly=GreadyPoang.ViewModelLayer"
|
|
||||||
x:Class="GreadyPoang.Popups.InfoPopup"
|
|
||||||
HorizontalOptions="Center"
|
|
||||||
VerticalOptions="Center"
|
|
||||||
Padding="0"
|
|
||||||
x:DataType="viewModels:InfoPopupViewModel"
|
|
||||||
BackgroundColor="Transparent">
|
|
||||||
<VerticalStackLayout BackgroundColor="Aquamarine" Padding="5" Margin="0">
|
|
||||||
<Label HorizontalOptions="Center" TextColor="BlueViolet" Text="{Binding Title}" Style="{StaticResource Headline}" />
|
|
||||||
<Label HorizontalOptions="Center" Text="{Binding Name}" Style="{StaticResource SubHeadline}"/>
|
|
||||||
<Label HorizontalOptions="Center" Text="{Binding Message}" Style="{StaticResource StatusLabelStyle}"/>
|
|
||||||
<!--<Label Text="What is your name?" />
|
|
||||||
<Entry Text="{Binding Name}" />
|
|
||||||
|
|
||||||
<Button Text="Save" Command="{Binding SaveCommand}" />-->
|
|
||||||
<Button Margin="10" Text="Cancel" Command="{Binding CancelCommand}" Style="{StaticResource HoverButtonBlueStyle}" />
|
|
||||||
</VerticalStackLayout>
|
|
||||||
</ContentView>
|
|
||||||
@ -1,13 +0,0 @@
|
|||||||
using GreadyPoang.ViewModelLayer;
|
|
||||||
|
|
||||||
namespace GreadyPoang.Popups;
|
|
||||||
|
|
||||||
public partial class InfoPopup : ContentView
|
|
||||||
{
|
|
||||||
public InfoPopup(InfoPopupViewModel ipViewModel)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
BindingContext = ipViewModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -2,10 +2,7 @@
|
|||||||
<?xaml-comp compile="true" ?>
|
<?xaml-comp compile="true" ?>
|
||||||
<ResourceDictionary
|
<ResourceDictionary
|
||||||
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
|
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml">
|
||||||
xmlns:local="clr-namespace:GreadyPoang.Common;assembly=GreadyPoang.Common" >
|
|
||||||
|
|
||||||
<local:HeaderColorConverter x:Key="HeaderColorConverter" />
|
|
||||||
|
|
||||||
<Style TargetType="StackLayout" x:Key="ResponsiveStackStyle">
|
<Style TargetType="StackLayout" x:Key="ResponsiveStackStyle">
|
||||||
<Setter Property="Orientation" Value="Horizontal"/>
|
<Setter Property="Orientation" Value="Horizontal"/>
|
||||||
|
|||||||
@ -1,20 +1,17 @@
|
|||||||
<?xml version="1.0" encoding="utf-8" ?>
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
|
<ContentView xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||||
xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit"
|
|
||||||
xmlns:partial="clr-namespace:GreadyPoang.ViewsPartial"
|
xmlns:partial="clr-namespace:GreadyPoang.ViewsPartial"
|
||||||
xmlns:vm="clr-namespace:GreadyPoang.ViewModelLayer;assembly=GreadyPoang.ViewModelLayer"
|
xmlns:vm="clr-namespace:GreadyPoang.CommandClasses"
|
||||||
xmlns:model="clr-namespace:GreadyPoang.EntityLayer;assembly=GreadyPoang.EntityLayer"
|
xmlns:model="clr-namespace:GreadyPoang.EntityLayer;assembly=GreadyPoang.EntityLayer"
|
||||||
x:Class="GreadyPoang.Views.ParticipantListView"
|
x:Class="GreadyPoang.Views.ParticipantListView"
|
||||||
x:DataType="vm:ParticipantViewModel"
|
x:DataType="vm:ParticipantViewModelCommands"
|
||||||
x:Name="ParticipantListPage"
|
x:Name="ParticipantListPage">
|
||||||
Title="Deltagar Lista">
|
<!--Title="Deltagar Lista"-->
|
||||||
|
|
||||||
<!--xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit"-->
|
|
||||||
<Border Style="{StaticResource Border.Page}" StrokeThickness="4">
|
<Border Style="{StaticResource Border.Page}" StrokeThickness="4">
|
||||||
<Grid Style="{StaticResource Grid.Page}">
|
<Grid Style="{StaticResource Grid.Page}">
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition Height="Auto" />
|
|
||||||
<RowDefinition Height="Auto" />
|
<RowDefinition Height="Auto" />
|
||||||
<RowDefinition Height="Auto" />
|
<RowDefinition Height="Auto" />
|
||||||
<RowDefinition Height="*" />
|
<RowDefinition Height="*" />
|
||||||
@ -23,16 +20,11 @@
|
|||||||
Grid.ColumnSpan="2"
|
Grid.ColumnSpan="2"
|
||||||
ViewTitle="Deltagare"
|
ViewTitle="Deltagare"
|
||||||
ViewDescription="Lägg till deltagare här" />
|
ViewDescription="Lägg till deltagare här" />
|
||||||
<ActivityIndicator Grid.Row="1" IsRunning="{Binding IsBusy}"
|
<Border Stroke="Gold" StrokeThickness="2" BackgroundColor="LemonChiffon" Grid.Row="1">
|
||||||
IsVisible="{Binding IsBusy}"
|
|
||||||
Color="DarkBlue"
|
|
||||||
HeightRequest="40" />
|
|
||||||
|
|
||||||
<Border Stroke="Gold" StrokeThickness="2" BackgroundColor="LemonChiffon" Grid.Row="2">
|
|
||||||
<VerticalStackLayout Spacing="4" >
|
<VerticalStackLayout Spacing="4" >
|
||||||
<!--<Label Style="{StaticResource SubHeadline}"
|
<Label Style="{StaticResource Label}"
|
||||||
Text="Deltagare "
|
Text="Deltagare "
|
||||||
FontAttributes="Bold" />-->
|
FontAttributes="Bold" FontSize="Large"/>
|
||||||
<Grid ColumnDefinitions="Auto,Auto,*" RowDefinitions="Auto,auto,auto,auto"
|
<Grid ColumnDefinitions="Auto,Auto,*" RowDefinitions="Auto,auto,auto,auto"
|
||||||
Padding="10" RowSpacing="8">
|
Padding="10" RowSpacing="8">
|
||||||
<Label Grid.Row="0" Grid.Column="0" Style="{StaticResource Label}"
|
<Label Grid.Row="0" Grid.Column="0" Style="{StaticResource Label}"
|
||||||
@ -66,7 +58,7 @@
|
|||||||
</Grid>
|
</Grid>
|
||||||
</VerticalStackLayout>
|
</VerticalStackLayout>
|
||||||
</Border>
|
</Border>
|
||||||
<Border Grid.Row="3" Stroke="Gold" BackgroundColor="Ivory" StrokeThickness="2" Padding="5">
|
<Border Grid.Row="2" Stroke="Gold" BackgroundColor="Ivory" StrokeThickness="2" Padding="5">
|
||||||
<CollectionView
|
<CollectionView
|
||||||
x:Name="participants"
|
x:Name="participants"
|
||||||
SelectionMode="Single"
|
SelectionMode="Single"
|
||||||
@ -75,6 +67,7 @@
|
|||||||
ItemsUpdatingScrollMode="KeepLastItemInView">
|
ItemsUpdatingScrollMode="KeepLastItemInView">
|
||||||
<CollectionView.ItemTemplate>
|
<CollectionView.ItemTemplate>
|
||||||
<DataTemplate x:DataType="model:Participant">
|
<DataTemplate x:DataType="model:Participant">
|
||||||
|
<!--Stroke="DarkGray" BackgroundColor="Cornsilk"-->
|
||||||
<Border Margin="8" Padding="12" >
|
<Border Margin="8" Padding="12" >
|
||||||
<VerticalStackLayout Spacing="4">
|
<VerticalStackLayout Spacing="4">
|
||||||
<Label FontAttributes="Bold"
|
<Label FontAttributes="Bold"
|
||||||
@ -83,14 +76,7 @@
|
|||||||
Text="{Binding LastNameFirstName}" />
|
Text="{Binding LastNameFirstName}" />
|
||||||
<HorizontalStackLayout >
|
<HorizontalStackLayout >
|
||||||
<Button Text="Edit" Style="{StaticResource HoverButtonBlueStyle}" CommandParameter="{Binding EditCommand}"/>
|
<Button Text="Edit" Style="{StaticResource HoverButtonBlueStyle}" CommandParameter="{Binding EditCommand}"/>
|
||||||
<Button Text="Delete" Style="{StaticResource HoverButtonRedStyle}"
|
<Button Style="{StaticResource HoverButtonRedStyle}" Text="Delete" />
|
||||||
Command="{Binding Source={RelativeSource AncestorType={x:Type vm:ParticipantViewModel}}, Path=DeleteAsyncCommand}"
|
|
||||||
CommandParameter="{Binding .}" />
|
|
||||||
|
|
||||||
<!--Command="{Binding BindingContext.ParticipantTappedCommand, Source={x:Reference Name=ParticipantList}}"
|
|
||||||
CommandParameter="{Binding .}" />-->
|
|
||||||
|
|
||||||
|
|
||||||
</HorizontalStackLayout>
|
</HorizontalStackLayout>
|
||||||
</VerticalStackLayout>
|
</VerticalStackLayout>
|
||||||
</Border>
|
</Border>
|
||||||
@ -98,7 +84,6 @@
|
|||||||
</CollectionView.ItemTemplate>
|
</CollectionView.ItemTemplate>
|
||||||
</CollectionView>
|
</CollectionView>
|
||||||
</Border>
|
</Border>
|
||||||
|
|
||||||
</Grid>
|
</Grid>
|
||||||
</Border>
|
</Border>
|
||||||
</ContentPage>
|
</ContentView>
|
||||||
@ -1,30 +1,24 @@
|
|||||||
using GreadyPoang.ViewModelLayer;
|
using GreadyPoang.CommandClasses;
|
||||||
|
|
||||||
namespace GreadyPoang.Views;
|
namespace GreadyPoang.Views;
|
||||||
|
|
||||||
public partial class ParticipantListView : ContentPage
|
public partial class ParticipantListView : ContentView
|
||||||
{
|
{
|
||||||
public ParticipantListView(ParticipantViewModel viewModel)
|
public ParticipantListView(ParticipantViewModelCommands viewModel)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
ViewModel = viewModel;
|
ViewModel = viewModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ParticipantViewModel ViewModel { get; set; }
|
public ParticipantViewModelCommands ViewModel { get; set; }
|
||||||
public int ParticipantId { get; set; }
|
public int ParticipantId { get; set; }
|
||||||
|
|
||||||
protected override void OnAppearing()
|
//protected override void OnAppearing()
|
||||||
{
|
//{
|
||||||
base.OnAppearing();
|
// base.OnAppearing();
|
||||||
BindingContext = ViewModel;
|
// BindingContext = ViewModel;
|
||||||
ViewModel.Get();
|
// ViewModel.Get();
|
||||||
}
|
//}
|
||||||
|
|
||||||
protected override void OnDisappearing()
|
|
||||||
{
|
|
||||||
base.OnDisappearing();
|
|
||||||
ViewModel.PopupVisad = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,16 +1,16 @@
|
|||||||
<?xml version="1.0" encoding="utf-8" ?>
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
|
<ContentView xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
|
||||||
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.Views.RoundRunningView"
|
x:Class="GreadyPoang.Views.RoundRunningView"
|
||||||
xmlns:vm ="clr-namespace:GreadyPoang.ViewModelLayer;assembly=GreadyPoang.ViewModelLayer"
|
xmlns:vm ="clr-namespace:GreadyPoang.CommandClasses"
|
||||||
xmlns:behaviors="clr-namespace:GreadyPoang.Common;assembly=GreadyPoang.Common"
|
xmlns:behaviors="clr-namespace:GreadyPoang.Common;assembly=GreadyPoang.Common"
|
||||||
|
xmlns:local="clr-namespace:GreadyPoang.EntityLayer;assembly=GreadyPoang.EntityLayer"
|
||||||
xmlns:model="clr-namespace:GreadyPoang.EntityLayer;assembly=GreadyPoang.EntityLayer"
|
xmlns:model="clr-namespace:GreadyPoang.EntityLayer;assembly=GreadyPoang.EntityLayer"
|
||||||
x:DataType="vm:RoundRunningViewModel"
|
x:DataType="vm:RoundRunningViewModelCommands">
|
||||||
Title="RoundRunningView">
|
<!--Title="RoundRunningView"-->
|
||||||
<Border
|
|
||||||
behaviors:LoadedBehavior.Command="{Binding OnLoadedCommand}"
|
<Border Style="{StaticResource Border.Page}" StrokeThickness="4">
|
||||||
Style="{StaticResource Border.Page}" StrokeThickness="4">
|
|
||||||
<Grid Style="{StaticResource Grid.Page}">
|
<Grid Style="{StaticResource Grid.Page}">
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition Height="Auto" />
|
<RowDefinition Height="Auto" />
|
||||||
@ -27,7 +27,6 @@
|
|||||||
<CollectionView Grid.Row="1"
|
<CollectionView Grid.Row="1"
|
||||||
ItemsSource="{Binding RoundElements}"
|
ItemsSource="{Binding RoundElements}"
|
||||||
ItemsLayout="HorizontalList"
|
ItemsLayout="HorizontalList"
|
||||||
HeightRequest="110"
|
|
||||||
Margin="2">
|
Margin="2">
|
||||||
<CollectionView.ItemTemplate>
|
<CollectionView.ItemTemplate>
|
||||||
<DataTemplate x:DataType="model:RoundBuilderElement">
|
<DataTemplate x:DataType="model:RoundBuilderElement">
|
||||||
@ -35,6 +34,7 @@
|
|||||||
Padding="10"
|
Padding="10"
|
||||||
Margin="5"
|
Margin="5"
|
||||||
StrokeShape="RoundRectangle 10"
|
StrokeShape="RoundRectangle 10"
|
||||||
|
BackgroundColor="{Binding OverrideColor}"
|
||||||
Style="{StaticResource StatusBorderStyle}">
|
Style="{StaticResource StatusBorderStyle}">
|
||||||
<Border.GestureRecognizers>
|
<Border.GestureRecognizers>
|
||||||
<TapGestureRecognizer
|
<TapGestureRecognizer
|
||||||
@ -79,45 +79,37 @@
|
|||||||
<Entry.Behaviors>
|
<Entry.Behaviors>
|
||||||
<behaviors:DigitsOnlyBehavior/>
|
<behaviors:DigitsOnlyBehavior/>
|
||||||
<behaviors:EventToCommandBehavior EventName="Completed"
|
<behaviors:EventToCommandBehavior EventName="Completed"
|
||||||
Command="{Binding StoreAndHandlePointsAsyncCommand}" />
|
Command="{Binding StoreAndHandlePointsCommand}" />
|
||||||
</Entry.Behaviors>
|
</Entry.Behaviors>
|
||||||
</Entry>
|
</Entry>
|
||||||
</Grid>
|
</Grid>
|
||||||
<Button Text="Register Points"
|
<Button Text="Register Points"
|
||||||
|
WidthRequest="100"
|
||||||
Style="{StaticResource HoverButtonRedStyle}"
|
Style="{StaticResource HoverButtonRedStyle}"
|
||||||
Command="{Binding StoreAndHandlePointsAsyncCommand}"/>
|
Command="{Binding StoreAndHandlePointsCommand}"/>
|
||||||
</HorizontalStackLayout>
|
<VerticalStackLayout >
|
||||||
</Border>
|
<Button Text="Visa Splash"
|
||||||
|
WidthRequest="100"
|
||||||
<ScrollView Grid.Row="4" Orientation="Horizontal">
|
Style="{StaticResource HoverButtonBlueStyle}"
|
||||||
<HorizontalStackLayout
|
Command="{Binding OnSplashClickedCommand}"/>
|
||||||
BindableLayout.ItemsSource="{Binding ScoreColumns}"
|
<Button Text="Återgå"
|
||||||
x:Name="ScoreGrid">
|
WidthRequest="100"
|
||||||
<BindableLayout.ItemTemplate>
|
Style="{StaticResource HoverButtonBlueStyle}"
|
||||||
<DataTemplate x:DataType="model:ScoreColumn">
|
Command="{Binding GobackCommand}"
|
||||||
<VerticalStackLayout BindableLayout.ItemsSource="{Binding Cells}">
|
IsVisible="{Binding GobackVisible}" />
|
||||||
<BindableLayout.ItemTemplate>
|
|
||||||
<DataTemplate x:DataType="model:ScoreCell">
|
|
||||||
<Border
|
|
||||||
Stroke="Gray"
|
|
||||||
StrokeThickness="1"
|
|
||||||
BackgroundColor="{Binding IsHeader, Converter={StaticResource HeaderColorConverter}}"
|
|
||||||
Margin="1"
|
|
||||||
Padding="2">
|
|
||||||
<Label
|
|
||||||
Text="{Binding Text}"
|
|
||||||
FontAttributes="{Binding IsHeader, Converter={StaticResource FontWeightConverter}}"
|
|
||||||
TextColor="{Binding IsHeader, Converter={StaticResource TextColorConverter}}"
|
|
||||||
HorizontalOptions="Center"
|
|
||||||
VerticalOptions="Center" />
|
|
||||||
</Border>
|
|
||||||
</DataTemplate>
|
|
||||||
</BindableLayout.ItemTemplate>
|
|
||||||
</VerticalStackLayout>
|
</VerticalStackLayout>
|
||||||
</DataTemplate>
|
|
||||||
</BindableLayout.ItemTemplate>
|
|
||||||
</HorizontalStackLayout>
|
</HorizontalStackLayout>
|
||||||
|
</Border>
|
||||||
|
<ScrollView Grid.Row="4" Orientation="Horizontal">
|
||||||
|
<Grid
|
||||||
|
x:Name="ScoreGrid"
|
||||||
|
ColumnSpacing="5"
|
||||||
|
RowSpacing="5"
|
||||||
|
Padding="3"
|
||||||
|
HorizontalOptions="FillAndExpand"
|
||||||
|
VerticalOptions="FillAndExpand" />
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Border>
|
</Border>
|
||||||
</ContentPage>
|
</ContentView>
|
||||||
@ -1,12 +1,87 @@
|
|||||||
using GreadyPoang.ViewModelLayer;
|
using GreadyPoang.CommandClasses;
|
||||||
|
using GreadyPoang.EntityLayer;
|
||||||
|
|
||||||
namespace GreadyPoang.Views;
|
namespace GreadyPoang.Views;
|
||||||
|
|
||||||
public partial class RoundRunningView : ContentPage
|
public partial class RoundRunningView : ContentView
|
||||||
{
|
{
|
||||||
public RoundRunningView(RoundRunningViewModel viewModel)
|
|
||||||
|
public RoundRunningView(RoundRunningViewModelCommands viewModel)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
BindingContext = viewModel;
|
ViewModel = viewModel;
|
||||||
|
ViewModel.RebuildRequested += ViewModel_RebuildRequested;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void ViewModel_RebuildRequested(object? sender, EventArgs e)
|
||||||
|
{
|
||||||
|
BuildScoreGrid(ViewModel.PlayerColumns); // <-- h<>r bygger du layouten
|
||||||
|
}
|
||||||
|
|
||||||
|
//protected override
|
||||||
|
|
||||||
|
public RoundRunningViewModelCommands ViewModel { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
private void BuildScoreGrid(IEnumerable<PlayerColumn> columns)
|
||||||
|
{
|
||||||
|
ScoreGrid.ColumnDefinitions.Clear();
|
||||||
|
ScoreGrid.RowDefinitions.Clear();
|
||||||
|
ScoreGrid.Children.Clear();
|
||||||
|
|
||||||
|
int maxRows = columns.Max(c => c.Values.Count);
|
||||||
|
|
||||||
|
// Skapa rader
|
||||||
|
for (int row = 0; row < maxRows + 1; row++) // +1 f<>r rubrikraden
|
||||||
|
{
|
||||||
|
ScoreGrid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto });
|
||||||
|
}
|
||||||
|
|
||||||
|
int colIndex = 0;
|
||||||
|
foreach (var column in columns)
|
||||||
|
{
|
||||||
|
ScoreGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Auto });
|
||||||
|
|
||||||
|
var headerCell = CreateCell(column.PlayerName, isHeader: true);
|
||||||
|
ScoreGrid.Children.Add(headerCell);
|
||||||
|
Grid.SetRow(headerCell, 0);
|
||||||
|
Grid.SetColumn(headerCell, colIndex);
|
||||||
|
|
||||||
|
// V<>rdeceller
|
||||||
|
for (int rowIndex = 0; rowIndex < column.Values.Count; rowIndex++)
|
||||||
|
{
|
||||||
|
var value = column.Values[rowIndex];
|
||||||
|
var cell = CreateCell(value);
|
||||||
|
ScoreGrid.Children.Add(cell);
|
||||||
|
Grid.SetRow(cell, rowIndex + 1); // +1 f<>r att hoppa <20>ver rubrikraden
|
||||||
|
Grid.SetColumn(cell, colIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
colIndex++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private View CreateCell(string text, bool isHeader = false)
|
||||||
|
{
|
||||||
|
return new Border
|
||||||
|
{
|
||||||
|
Stroke = Colors.Gray,
|
||||||
|
StrokeThickness = 1,
|
||||||
|
BackgroundColor = isHeader ? Colors.DarkGray : Colors.Yellow,
|
||||||
|
Margin = 1,
|
||||||
|
Padding = 2,
|
||||||
|
Content = new Label
|
||||||
|
{
|
||||||
|
Text = text,
|
||||||
|
FontAttributes = isHeader ? FontAttributes.Bold : FontAttributes.None,
|
||||||
|
TextColor = isHeader ? Colors.White : Colors.Black,
|
||||||
|
HorizontalOptions = LayoutOptions.Center,
|
||||||
|
VerticalOptions = LayoutOptions.Center
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,101 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8" ?>
|
|
||||||
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
|
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
|
||||||
xmlns:partial="clr-namespace:GreadyPoang.ViewsPartial"
|
|
||||||
x:Class="GreadyPoang.Views.RoundRunningView"
|
|
||||||
xmlns:vm ="clr-namespace:GreadyPoang.ViewModelLayer;assembly=GreadyPoang.ViewModelLayer"
|
|
||||||
xmlns:behaviors="clr-namespace:GreadyPoang.Common;assembly=GreadyPoang.Common"
|
|
||||||
xmlns:local="clr-namespace:GreadyPoang.EntityLayer;assembly=GreadyPoang.EntityLayer"
|
|
||||||
xmlns:model="clr-namespace:GreadyPoang.EntityLayer;assembly=GreadyPoang.EntityLayer"
|
|
||||||
x:DataType="vm:RoundRunningViewModel"
|
|
||||||
Title="RoundRunningView">
|
|
||||||
|
|
||||||
<Border Style="{StaticResource Border.Page}" StrokeThickness="4">
|
|
||||||
<Grid Style="{StaticResource Grid.Page}">
|
|
||||||
<Grid.RowDefinitions>
|
|
||||||
<RowDefinition Height="Auto" />
|
|
||||||
<RowDefinition Height="Auto" />
|
|
||||||
<RowDefinition Height="Auto" />
|
|
||||||
<RowDefinition Height="Auto" />
|
|
||||||
<RowDefinition Height="Auto" />
|
|
||||||
<RowDefinition Height="*" />
|
|
||||||
</Grid.RowDefinitions>
|
|
||||||
<partial:HeaderView Grid.Row="0"
|
|
||||||
Grid.ColumnSpan="2"
|
|
||||||
ViewTitle="Starta eller fortsätt en registrerad Runda"
|
|
||||||
ViewDescription="Deltagarna visas först!" />
|
|
||||||
<CollectionView Grid.Row="1"
|
|
||||||
ItemsSource="{Binding RoundElements}"
|
|
||||||
ItemsLayout="HorizontalList"
|
|
||||||
Margin="2">
|
|
||||||
<CollectionView.ItemTemplate>
|
|
||||||
<DataTemplate x:DataType="model:RoundBuilderElement">
|
|
||||||
<Border Stroke="Gray"
|
|
||||||
Padding="10"
|
|
||||||
Margin="5"
|
|
||||||
StrokeShape="RoundRectangle 10"
|
|
||||||
Style="{StaticResource StatusBorderStyle}">
|
|
||||||
<Border.GestureRecognizers>
|
|
||||||
<TapGestureRecognizer
|
|
||||||
Command="{Binding Source={RelativeSource AncestorType={x:Type ContentPage}}, Path=BindingContext.ParticipantTappedCommand}"
|
|
||||||
CommandParameter="{Binding .}" />
|
|
||||||
</Border.GestureRecognizers>
|
|
||||||
<Grid VerticalOptions="Fill" >
|
|
||||||
<Grid.RowDefinitions>
|
|
||||||
<RowDefinition Height="Auto" />
|
|
||||||
<RowDefinition Height="Auto" />
|
|
||||||
<RowDefinition Height="Auto" />
|
|
||||||
<RowDefinition Height="Auto" />
|
|
||||||
<RowDefinition Height="Auto" />
|
|
||||||
</Grid.RowDefinitions>
|
|
||||||
<Label Grid.Row="0" Text="Spelare" />
|
|
||||||
<Label Grid.Row="1" Text="{Binding ParticipantName}" FontAttributes="Bold" Style="{StaticResource StatusLabelStyle}" />
|
|
||||||
<Label Grid.Row="2" Text="{Binding GameRegPoints, StringFormat='Poäng: {0}'}" Style="{StaticResource StatusLabelStyle}" />
|
|
||||||
<Label Grid.Row="3" Text="{Binding Status}" Style="{StaticResource StatusLabelStyle}"/>
|
|
||||||
<Label Grid.Row="4" Text="{Binding GameRoundStartDate, StringFormat='Start: {0:yyyy-MM-dd}'}" Style="{StaticResource StatusLabelStyle}"/>
|
|
||||||
</Grid>
|
|
||||||
</Border>
|
|
||||||
</DataTemplate>
|
|
||||||
</CollectionView.ItemTemplate>
|
|
||||||
</CollectionView>
|
|
||||||
<BoxView
|
|
||||||
Grid.Row="2"
|
|
||||||
Grid.ColumnSpan="2"
|
|
||||||
Margin="0,0,0,5"
|
|
||||||
HeightRequest="1"
|
|
||||||
Color="Black" />
|
|
||||||
<Border Grid.Row="3">
|
|
||||||
<HorizontalStackLayout>
|
|
||||||
<Grid VerticalOptions="Fill">
|
|
||||||
<Grid.RowDefinitions>
|
|
||||||
<RowDefinition Height="Auto" />
|
|
||||||
<RowDefinition Height="Auto" />
|
|
||||||
<RowDefinition Height="Auto" />
|
|
||||||
</Grid.RowDefinitions>
|
|
||||||
<Label Grid.Row="0" Text="{Binding BuilderObject.GameRoundId, StringFormat='Runda: {0}'}"/>
|
|
||||||
<Label Grid.Row="1" Text="{Binding BuilderObject.ParticipantName}" FontAttributes="Bold" FontSize="Subtitle" />
|
|
||||||
<Entry Grid.Row="2" x:Name="Points" Placeholder="Latest Points" Text="{Binding BuilderObject.GameRegPoints}" FontAttributes="Bold" FontSize="20" >
|
|
||||||
<Entry.Behaviors>
|
|
||||||
<behaviors:DigitsOnlyBehavior/>
|
|
||||||
<behaviors:EventToCommandBehavior EventName="Completed"
|
|
||||||
Command="{Binding StoreAndHandlePointsAsyncCommand}" />
|
|
||||||
</Entry.Behaviors>
|
|
||||||
</Entry>
|
|
||||||
</Grid>
|
|
||||||
<Button Text="Register Points"
|
|
||||||
Style="{StaticResource HoverButtonRedStyle}"
|
|
||||||
Command="{Binding StoreAndHandlePointsAsyncCommand}"/>
|
|
||||||
</HorizontalStackLayout>
|
|
||||||
</Border>
|
|
||||||
<ScrollView Grid.Row="4" Orientation="Horizontal">
|
|
||||||
<Grid
|
|
||||||
x:Name="ScoreGrid"
|
|
||||||
ColumnSpacing="5"
|
|
||||||
RowSpacing="5"
|
|
||||||
Padding="3"
|
|
||||||
HorizontalOptions="FillAndExpand"
|
|
||||||
VerticalOptions="FillAndExpand" />
|
|
||||||
</ScrollView>
|
|
||||||
</Grid>
|
|
||||||
</Border>
|
|
||||||
</ContentPage>
|
|
||||||
@ -1,105 +0,0 @@
|
|||||||
using GreadyPoang.EntityLayer;
|
|
||||||
using GreadyPoang.ViewModelLayer;
|
|
||||||
|
|
||||||
namespace GreadyPoang.Views;
|
|
||||||
|
|
||||||
public partial class RoundRunningView : ContentPage
|
|
||||||
{
|
|
||||||
public RoundRunningView(RoundRunningViewModel viewModel)
|
|
||||||
{
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private void ViewModel_RebuildRequested(object? sender, EventArgs e)
|
|
||||||
{
|
|
||||||
BuildScoreGrid(ViewModel.PlayerColumns); // <-- h<>r bygger du layouten
|
|
||||||
}
|
|
||||||
|
|
||||||
//protected override
|
|
||||||
|
|
||||||
public RoundRunningViewModel ViewModel { get; set; }
|
|
||||||
|
|
||||||
|
|
||||||
private void BuildScoreGrid(IEnumerable<PlayerColumn> columns)
|
|
||||||
{
|
|
||||||
ScoreGrid.ColumnDefinitions.Clear();
|
|
||||||
ScoreGrid.RowDefinitions.Clear();
|
|
||||||
ScoreGrid.Children.Clear();
|
|
||||||
|
|
||||||
int maxRows = columns.Max(c => c.Values.Count);
|
|
||||||
|
|
||||||
// Skapa rader
|
|
||||||
for (int row = 0; row < maxRows + 1; row++) // +1 f<>r rubrikraden
|
|
||||||
{
|
|
||||||
ScoreGrid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto });
|
|
||||||
}
|
|
||||||
|
|
||||||
int colIndex = 0;
|
|
||||||
foreach (var column in columns)
|
|
||||||
{
|
|
||||||
ScoreGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Auto });
|
|
||||||
|
|
||||||
var headerCell = CreateCell(column.PlayerName, isHeader: true);
|
|
||||||
ScoreGrid.Children.Add(headerCell);
|
|
||||||
Grid.SetRow(headerCell, 0);
|
|
||||||
Grid.SetColumn(headerCell, colIndex);
|
|
||||||
|
|
||||||
// V<>rdeceller
|
|
||||||
for (int rowIndex = 0; rowIndex < column.Values.Count; rowIndex++)
|
|
||||||
{
|
|
||||||
var value = column.Values[rowIndex];
|
|
||||||
var cell = CreateCell(value);
|
|
||||||
ScoreGrid.Children.Add(cell);
|
|
||||||
Grid.SetRow(cell, column.Values.Count - rowIndex); // +1 f<>r att hoppa <20>ver rubrikraden
|
|
||||||
Grid.SetColumn(cell, colIndex);
|
|
||||||
}
|
|
||||||
|
|
||||||
colIndex++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private View CreateCell(string text, bool isHeader = false)
|
|
||||||
{
|
|
||||||
return new Border
|
|
||||||
{
|
|
||||||
Stroke = Colors.Gray,
|
|
||||||
StrokeThickness = 1,
|
|
||||||
BackgroundColor = isHeader ? Colors.DarkGray : Colors.Yellow,
|
|
||||||
Margin = 1,
|
|
||||||
Padding = 2,
|
|
||||||
Content = new Label
|
|
||||||
{
|
|
||||||
Text = text,
|
|
||||||
FontAttributes = isHeader ? FontAttributes.Bold : FontAttributes.None,
|
|
||||||
TextColor = isHeader ? Colors.White : Colors.Black,
|
|
||||||
HorizontalOptions = LayoutOptions.Center,
|
|
||||||
VerticalOptions = LayoutOptions.Center
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void OnDisappearing()
|
|
||||||
{
|
|
||||||
base.OnDisappearing();
|
|
||||||
ViewModel.PopupVisad = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@ -1,14 +1,14 @@
|
|||||||
<?xml version="1.0" encoding="utf-8" ?>
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
|
<ContentView xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
|
||||||
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.Views.RoundStartingView"
|
x:Class="GreadyPoang.Views.RoundStartingView"
|
||||||
xmlns:vm="clr-namespace:GreadyPoang.ViewModelLayer;assembly=GreadyPoang.ViewModelLayer"
|
xmlns:vm="clr-namespace:GreadyPoang.CommandClasses"
|
||||||
xmlns:local="clr-namespace:GreadyPoang.EntityLayer;assembly=GreadyPoang.EntityLayer"
|
xmlns:local="clr-namespace:GreadyPoang.EntityLayer;assembly=GreadyPoang.EntityLayer"
|
||||||
xmlns:model="clr-namespace:GreadyPoang.EntityLayer;assembly=GreadyPoang.EntityLayer"
|
xmlns:model="clr-namespace:GreadyPoang.EntityLayer;assembly=GreadyPoang.EntityLayer"
|
||||||
x:DataType="vm:RoundStartingViewModel"
|
x:DataType="vm:RoundStartingViewModelCommands"
|
||||||
x:Name="GameRoundStartingPage"
|
x:Name="GameRoundStartingPage">
|
||||||
Title="Starta ny Runda">
|
<!--Title="Starta ny Runda"-->
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -25,7 +25,7 @@
|
|||||||
ViewDescription="Välj deltagare och initiera spel" />
|
ViewDescription="Välj deltagare och initiera spel" />
|
||||||
<Border Grid.Row="1" Stroke="Gold" StrokeThickness="2" BackgroundColor="LemonChiffon" >
|
<Border Grid.Row="1" Stroke="Gold" StrokeThickness="2" BackgroundColor="LemonChiffon" >
|
||||||
<ScrollView Orientation="Horizontal">
|
<ScrollView Orientation="Horizontal">
|
||||||
<StackLayout x:Name="ResponsiveStack" Spacing="5" HeightRequest="125" Style="{StaticResource ResponsiveStackStyle}" >
|
<StackLayout x:Name="ResponsiveStack" Spacing="5" Style="{StaticResource ResponsiveStackStyle}" >
|
||||||
<Border Stroke="Gray"
|
<Border Stroke="Gray"
|
||||||
StrokeThickness="2"
|
StrokeThickness="2"
|
||||||
BackgroundColor="LightGray"
|
BackgroundColor="LightGray"
|
||||||
@ -64,7 +64,7 @@
|
|||||||
>
|
>
|
||||||
<Border.GestureRecognizers>
|
<Border.GestureRecognizers>
|
||||||
<TapGestureRecognizer
|
<TapGestureRecognizer
|
||||||
Command="{Binding BindingContext.SelectNewlyAddedParticipantCommand, Source={x:Reference Name=ParticipantList}}"
|
Command="{Binding BindingContext.ParticipantTappedCommand, Source={x:Reference Name=ParticipantList}}"
|
||||||
CommandParameter="{Binding .}" />
|
CommandParameter="{Binding .}" />
|
||||||
</Border.GestureRecognizers>
|
</Border.GestureRecognizers>
|
||||||
<Border Margin="1" Padding="2" StrokeThickness="3" >
|
<Border Margin="1" Padding="2" StrokeThickness="3" >
|
||||||
@ -119,7 +119,6 @@
|
|||||||
ItemsLayout="HorizontalList"
|
ItemsLayout="HorizontalList"
|
||||||
x:Name="InnerList"
|
x:Name="InnerList"
|
||||||
Margin="0,10,0,10"
|
Margin="0,10,0,10"
|
||||||
HeightRequest="90"
|
|
||||||
ItemSizingStrategy="MeasureAllItems">
|
ItemSizingStrategy="MeasureAllItems">
|
||||||
<CollectionView.ItemTemplate>
|
<CollectionView.ItemTemplate>
|
||||||
<DataTemplate x:DataType="model:RoundBuilderElement">
|
<DataTemplate x:DataType="model:RoundBuilderElement">
|
||||||
@ -130,7 +129,7 @@
|
|||||||
Style="{StaticResource StatusBorderStyle}" >
|
Style="{StaticResource StatusBorderStyle}" >
|
||||||
<Border.GestureRecognizers>
|
<Border.GestureRecognizers>
|
||||||
<TapGestureRecognizer
|
<TapGestureRecognizer
|
||||||
Command="{Binding Path=BindingContext.RoundSelectedCommand ,Source={x:Reference OuterList}}"
|
Command="{Binding Path=BindingContext.ElementTappedCommand,Source={x:Reference OuterList}}"
|
||||||
CommandParameter="{Binding .}" />
|
CommandParameter="{Binding .}" />
|
||||||
</Border.GestureRecognizers>
|
</Border.GestureRecognizers>
|
||||||
|
|
||||||
@ -152,4 +151,4 @@
|
|||||||
</Border>
|
</Border>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Border>
|
</Border>
|
||||||
</ContentPage>
|
</ContentView>
|
||||||
@ -1,42 +1,38 @@
|
|||||||
using GreadyPoang.ViewModelLayer;
|
using GreadyPoang.CommandClasses;
|
||||||
|
|
||||||
namespace GreadyPoang.Views;
|
namespace GreadyPoang.Views;
|
||||||
|
|
||||||
public partial class RoundStartingView : ContentPage
|
public partial class RoundStartingView : ContentView
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
public RoundStartingView(RoundStartingViewModel viewModel)
|
public RoundStartingView(RoundStartingViewModelCommands viewModel)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
ViewModel = viewModel;
|
ViewModel = viewModel;
|
||||||
}
|
}
|
||||||
public RoundStartingViewModel ViewModel { get; set; }
|
public RoundStartingViewModelCommands ViewModel { get; set; }
|
||||||
|
|
||||||
public int GameRoundId { get; set; }
|
public int GameRoundId { get; set; }
|
||||||
|
|
||||||
protected override void OnAppearing()
|
//protected override void OnAppearing()
|
||||||
{
|
//{
|
||||||
base.OnAppearing();
|
// base.OnAppearing();
|
||||||
BindingContext = ViewModel;
|
// BindingContext = ViewModel;
|
||||||
ViewModel.Get();
|
// ViewModel.Get();
|
||||||
ViewModel.GetParticipants();
|
// ViewModel.GetParticipants();
|
||||||
}
|
//}
|
||||||
|
|
||||||
protected override void OnSizeAllocated(double width, double height)
|
protected override void OnSizeAllocated(double width, double height)
|
||||||
{
|
{
|
||||||
base.OnSizeAllocated(width, height);
|
base.OnSizeAllocated(width, height);
|
||||||
|
|
||||||
if (width < 500)
|
if (ResponsiveStack == null || width <= 0)
|
||||||
{
|
return;
|
||||||
VisualStateManager.GoToState(ResponsiveStack, "Narrow");
|
|
||||||
System.Diagnostics.Debug.WriteLine($"width={width} ResponsiveStack=Narrow ");
|
var state = width < 500 ? "Narrow" : "Wide";
|
||||||
}
|
VisualStateManager.GoToState(ResponsiveStack, state);
|
||||||
else
|
System.Diagnostics.Debug.WriteLine($"width={width} ResponsiveStack={state} ");
|
||||||
{
|
|
||||||
VisualStateManager.GoToState(ResponsiveStack, "Wide");
|
|
||||||
System.Diagnostics.Debug.WriteLine($"width={width} ResponsiveStack=Wide ");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
30
GreadyPoang/ViewsPartial/SplashView.xaml
Normal file
30
GreadyPoang/ViewsPartial/SplashView.xaml
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<!-- Views/SplashView.xaml -->
|
||||||
|
<ContentView xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||||
|
x:Class="GreadyPoang.ViewsPartial.SplashView"
|
||||||
|
xmlns:vm="clr-namespace:GreadyPoang.CommandClasses"
|
||||||
|
x:DataType="vm:SplashViewModelCommands">
|
||||||
|
<!--IsVisible="{Binding IsSplashVisible}">-->
|
||||||
|
|
||||||
|
<Border x:Name="SplashBorder"
|
||||||
|
Stroke="Black"
|
||||||
|
BackgroundColor="{Binding SplashBackgroundColor}"
|
||||||
|
WidthRequest="350"
|
||||||
|
HeightRequest="200"
|
||||||
|
StrokeShape="RoundRectangle 20"
|
||||||
|
Padding="20"
|
||||||
|
IsVisible="{Binding IsSplashVisible}"
|
||||||
|
HorizontalOptions="Center"
|
||||||
|
VerticalOptions="Center"
|
||||||
|
Opacity="{Binding SplashOpacity}">
|
||||||
|
<StackLayout>
|
||||||
|
<!--<Image Source="{Binding SplashImage}" HeightRequest="60" />-->
|
||||||
|
<Label Text="{Binding SplashText}"
|
||||||
|
FontSize="18"
|
||||||
|
HorizontalOptions="Center"
|
||||||
|
VerticalOptions="Center"
|
||||||
|
TextColor="{Binding SplashTextColor}"/>
|
||||||
|
</StackLayout>
|
||||||
|
</Border>
|
||||||
|
</ContentView>
|
||||||
18
GreadyPoang/ViewsPartial/SplashView.xaml.cs
Normal file
18
GreadyPoang/ViewsPartial/SplashView.xaml.cs
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
using GreadyPoang.CommandClasses;
|
||||||
|
|
||||||
|
namespace GreadyPoang.ViewsPartial;
|
||||||
|
|
||||||
|
public partial class SplashView : ContentView
|
||||||
|
{
|
||||||
|
public SplashView()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
public SplashViewModelCommands ViewModel
|
||||||
|
{
|
||||||
|
get => (SplashViewModelCommands)BindingContext;
|
||||||
|
set => BindingContext = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
9
TempProj/GreadyPoang.CommandClasses.old.csproj
Normal file
9
TempProj/GreadyPoang.CommandClasses.old.csproj
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net9.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
Reference in New Issue
Block a user