Skip to content

Commit 556ebd3

Browse files
Merge pull request #46 from CodebreakerApp/wpf-v3
Initial WPF client for games API v3
2 parents b926763 + 12c5470 commit 556ebd3

22 files changed

Lines changed: 128 additions & 145 deletions

src/CodeBreaker.WPF.sln

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ VisualStudioVersion = 17.7.33927.210
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Codebreaker.WPF", "Codebreaker.WPF\Codebreaker.WPF.csproj", "{10FD3CBC-D263-49B3-9320-49AA2D522C0E}"
77
EndProject
8+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{0F0847C3-59CA-4C02-87B7-C37A161BC067}"
9+
EndProject
810
Global
911
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1012
Debug|Any CPU = Debug|Any CPU

src/Codebreaker.WPF/App.xaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
<Application x:Class="CodeBreaker.WPF.App"
1+
<Application x:Class="Codebreaker.WPF.App"
22
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
33
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4-
xmlns:local="clr-namespace:CodeBreaker.WPF"
4+
xmlns:local="clr-namespace:Codebreaker.WPF"
55
StartupUri="Views/Pages/GameWindow.xaml">
66
<Application.Resources>
77
<ResourceDictionary>

src/Codebreaker.WPF/App.xaml.cs

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,4 @@
1-
using CodeBreaker.Services;
2-
using CodeBreaker.Services.Authentication;
3-
using CodeBreaker.ViewModels;
4-
using CodeBreaker.ViewModels.Services;
5-
6-
using Microsoft.Extensions.DependencyInjection;
7-
using Microsoft.Extensions.Hosting;
8-
9-
using System.Configuration;
10-
using System.Windows;
11-
12-
namespace CodeBreaker.WPF;
1+
namespace Codebreaker.WPF;
132

143
/// <summary>
154
/// Interaction logic for App.xaml
@@ -34,11 +23,10 @@ public App()
3423
})
3524
.ConfigureServices((context, services) =>
3625
{
37-
services.Configure<GamePageViewModelOptions>(options => options.EnableDialogs = false);
26+
services.Configure<GamePageViewModelOptions>(options => options.EnableDialogs = true);
3827
services.AddTransient<IDialogService, Services.WPFDialogService>();
3928
services.AddScoped<GamePageViewModel>();
40-
services.AddScoped<IAuthService, AuthService>();
41-
services.AddHttpClient<IGameClient, GameClient>(client =>
29+
services.AddHttpClient<IGamesClient, GamesClient>(client =>
4230
{
4331
string uriString = context.Configuration["ApiBase"] ?? throw new ConfigurationErrorsException("ApiBase not configured");
4432
client.BaseAddress = new Uri(uriString);

src/Codebreaker.WPF/Codebreaker.WPF.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
<ImplicitUsings>enable</ImplicitUsings>
88
<UseWPF>true</UseWPF>
99
<Company>CN innovation</Company>
10+
<StartupObject>Codebreaker.WPF.App</StartupObject>
1011
</PropertyGroup>
1112

1213
<ItemGroup>
@@ -28,7 +29,7 @@
2829
</ItemGroup>
2930

3031
<ItemGroup>
31-
<PackageReference Include="CNInnovation.Codebreaker.ViewModels" Version="2.0.0-beta1.12" />
32+
<PackageReference Include="CNInnovation.Codebreaker.ViewModels" Version="3.5.0-beta.22" />
3233
<PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.1" />
3334
<PackageReference Include="Microsoft.Extensions.Http" Version="7.0.0" />
3435
</ItemGroup>

src/Codebreaker.WPF/Converters/BoolToVisibilityConverter.cs

Lines changed: 0 additions & 19 deletions
This file was deleted.

src/Codebreaker.WPF/Converters/ColorNameToBrushConverter.cs

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,17 @@
1-
using System.Globalization;
2-
using System.Windows.Data;
3-
using System.Windows.Media;
4-
5-
using static CodeBreaker.Shared.Models.Data.Colors;
6-
7-
namespace CodeBreaker.WPF.Converters;
1+
namespace Codebreaker.WPF.Converters;
82

93
public class ColorNameToBrushConverter : IValueConverter
104
{
11-
private static readonly Brush s_blackBrush = new SolidColorBrush(Colors.Black);
12-
private static readonly Brush s_whiteBrush = new SolidColorBrush(Colors.White);
5+
private static readonly Brush s_orangeBrush = new SolidColorBrush(Colors.Orange);
6+
private static readonly Brush s_PurpleBrush = new SolidColorBrush(Colors.Purple);
137
private static readonly Brush s_redBrush = new SolidColorBrush(Color.FromRgb(209, 52, 56));
148
private static readonly Brush s_greenBrush = new SolidColorBrush(Color.FromRgb(0, 173, 86));
159
private static readonly Brush s_blueBrush = new SolidColorBrush(Color.FromRgb(79, 107, 237));
1610
private static readonly Brush s_yellowBrush = new SolidColorBrush(Color.FromRgb(252, 225, 0));
1711
private static readonly Brush s_emptyBrush = new SolidColorBrush(Color.FromRgb(160, 174, 178));
1812

19-
public Brush BlackBrush { get; set; } = s_blackBrush;
20-
public Brush WhiteBrush { get; set; } = s_whiteBrush;
13+
public Brush OrangeBrush { get; set; } = s_orangeBrush;
14+
public Brush PurpleBrush { get; set; } = s_PurpleBrush;
2115
public Brush RedBrush { get; set; } = s_redBrush;
2216
public Brush GreenBrush { get; set; } = s_greenBrush;
2317
public Brush BlueBrush { get; set; } = s_blueBrush;
@@ -26,14 +20,15 @@ public class ColorNameToBrushConverter : IValueConverter
2620

2721
public object? Convert(object value, Type targetType, object parameter, CultureInfo culture)
2822
{
23+
2924
return value switch
3025
{
31-
Black => BlackBrush,
32-
White => WhiteBrush,
33-
Red => RedBrush,
34-
Green => GreenBrush,
35-
Blue => BlueBrush,
36-
Yellow => YellowBrush,
26+
"Purple" => OrangeBrush,
27+
"Orange" => PurpleBrush,
28+
"Red" => RedBrush,
29+
"Green" => GreenBrush,
30+
"Blue" => BlueBrush,
31+
"Yellow" => YellowBrush,
3732
_ => EmptyBrush
3833
};
3934
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
namespace Codebreaker.WPF.Converters;
2+
3+
public class FieldValuesToColorsConverter : IValueConverter
4+
{
5+
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
6+
{
7+
if (value is IDictionary<string, string[]> data)
8+
{
9+
return data["colors"];
10+
}
11+
else
12+
{
13+
return value;
14+
}
15+
}
16+
17+
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) => throw new NotImplementedException();
18+
}

src/Codebreaker.WPF/Converters/GameStatusToVisibilityConverter.cs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
1-
using CodeBreaker.ViewModels;
2-
3-
using System.Globalization;
4-
using System.Windows;
5-
using System.Windows.Data;
6-
7-
namespace CodeBreaker.WPF.Converters;
1+
namespace Codebreaker.WPF.Converters;
82

93
internal class GameStatusToVisibilityConverter : IValueConverter
104
{

src/Codebreaker.WPF/Converters/IntToEnumerableConverter.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
using System.Globalization;
2-
using System.Windows.Data;
3-
4-
namespace CodeBreaker.WPF.Converters;
1+
namespace Codebreaker.WPF.Converters;
52

63
internal class IntToEnumerableConverter : IValueConverter
74
{
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
namespace Codebreaker.WPF.Converters;
2+
3+
public class KeyPegColorNameToBrushConverter : IValueConverter
4+
{
5+
public Brush BlackBrush { get; set; } = new SolidColorBrush(Colors.Black);
6+
public Brush WhiteBrush { get; set; } = new SolidColorBrush(Colors.White);
7+
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
8+
{
9+
return value switch
10+
{
11+
"Black" => BlackBrush,
12+
"White" => WhiteBrush,
13+
_ => value
14+
};
15+
}
16+
17+
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) => throw new NotImplementedException();
18+
}

0 commit comments

Comments
 (0)