Uppdelningsläge

This commit is contained in:
2025-10-12 08:39:06 +02:00
parent c00819bec6
commit 02a26871c6
15 changed files with 85 additions and 30 deletions

View File

@ -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>

View File

@ -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;
} }
} }

View File

@ -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>

View File

@ -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;

View File

@ -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)

View File

@ -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,

View File

@ -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>

View File

@ -6,5 +6,6 @@ public enum GamePointStatus
InProgress = 1, InProgress = 1,
Completed = 2, Completed = 2,
Cancelled = 3, Cancelled = 3,
Winning = 4 Winning = 4,
Winner = 5
} }

View File

@ -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>

View File

@ -2,7 +2,12 @@
<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>

View File

@ -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>

View File

@ -4,6 +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; public bool Delivered { get; set; } = false;
} }

View File

@ -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>

View File

@ -12,8 +12,8 @@ public class ParticipantViewModelCommands : ParticipantViewModel
#region constructors #region constructors
public ParticipantViewModelCommands() : base() public ParticipantViewModelCommands() : base()
{ {
} }
public ParticipantViewModelCommands( public ParticipantViewModelCommands(
IRepository<Participant> repo, IRepository<Participant> repo,
IMethodSharingService<Participant> sharingService, IMethodSharingService<Participant> sharingService,

View File

@ -56,6 +56,9 @@
<Setter Property="BackgroundColor" Value="LightCoral" /> <Setter Property="BackgroundColor" Value="LightCoral" />
</DataTrigger> </DataTrigger>
<DataTrigger TargetType="Border" Binding="{Binding Status}" Value="Winning"> <DataTrigger TargetType="Border" Binding="{Binding Status}" Value="Winning">
<Setter Property="BackgroundColor" Value="Yellow" />
</DataTrigger>
<DataTrigger TargetType="Border" Binding="{Binding Status}" Value="Winner">
<Setter Property="BackgroundColor" Value="Red" /> <Setter Property="BackgroundColor" Value="Red" />
</DataTrigger> </DataTrigger>
</Style.Triggers> </Style.Triggers>