Skip to content

Commit 39a57ca

Browse files
Merge pull request #205 from CodebreakerApp/copilot/create-codebreaker-winforms-project
Create initial Codebreaker.WinForms project as alternative game client using CNinnovation.Codebreaker.ViewModels
2 parents c13cd84 + ea7b627 commit 39a57ca

File tree

13 files changed

+709
-0
lines changed

13 files changed

+709
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
* Blazor app to play games and show game results using [MudBlazor](https://www.mudblazor.com/), [FastBlazor](https://github.com/microsoft/fast-blazor), and native, pure Blazor with only CSS
5353
* WinUI app to play games calling the API, and show live services
5454
* WPF app to play games calling the API
55+
* WinForms app to play games calling the API (classic Windows desktop experience)
5556
* .NET MAUI App to play games calling the API (Android, iOS, Windows)
5657

5758
* [Blazor Pure CSS](https://codebreaker-pure.azurewebsites.net/)

src/CodeBreaker.WinForms.sln

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.7.33927.210
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Codebreaker.WinForms", "Codebreaker.WinForms\Codebreaker.WinForms.csproj", "{8F5B6A3E-9C4D-4A3B-8E1F-2D3C4B5A6789}"
7+
EndProject
8+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{7D8E9F1A-2B3C-4D5E-6F7A-8B9C0D1E2F34}"
9+
EndProject
10+
Global
11+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
12+
Debug|Any CPU = Debug|Any CPU
13+
Release|Any CPU = Release|Any CPU
14+
EndGlobalSection
15+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
16+
{8F5B6A3E-9C4D-4A3B-8E1F-2D3C4B5A6789}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
17+
{8F5B6A3E-9C4D-4A3B-8E1F-2D3C4B5A6789}.Debug|Any CPU.Build.0 = Debug|Any CPU
18+
{8F5B6A3E-9C4D-4A3B-8E1F-2D3C4B5A6789}.Release|Any CPU.ActiveCfg = Release|Any CPU
19+
{8F5B6A3E-9C4D-4A3B-8E1F-2D3C4B5A6789}.Release|Any CPU.Build.0 = Release|Any CPU
20+
EndGlobalSection
21+
GlobalSection(SolutionProperties) = preSolution
22+
HideSolutionNode = FALSE
23+
EndGlobalSection
24+
GlobalSection(ExtensibilityGlobals) = postSolution
25+
SolutionGuid = {A1B2C3D4-E5F6-7890-ABCD-EF1234567890}
26+
EndGlobalSection
27+
EndGlobal
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>WinExe</OutputType>
5+
<TargetFramework>net9.0-windows</TargetFramework>
6+
<Nullable>enable</Nullable>
7+
<ImplicitUsings>enable</ImplicitUsings>
8+
<UseWindowsForms>true</UseWindowsForms>
9+
<Company>CN innovation</Company>
10+
<StartupObject>Codebreaker.WinForms.Program</StartupObject>
11+
</PropertyGroup>
12+
13+
<ItemGroup>
14+
<None Remove="appsettings.Development.json" />
15+
<None Remove="appsettings.json" />
16+
<None Remove="appsettings.Production.json" />
17+
</ItemGroup>
18+
19+
<ItemGroup>
20+
<Content Include="appsettings.Production.json">
21+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
22+
</Content>
23+
<Content Include="appsettings.Development.json">
24+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
25+
</Content>
26+
<Content Include="appsettings.json">
27+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
28+
</Content>
29+
</ItemGroup>
30+
31+
<ItemGroup>
32+
<PackageReference Include="CNInnovation.Codebreaker.ViewModels" Version="3.6.0-beta.34" />
33+
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.0" />
34+
<PackageReference Include="Microsoft.Extensions.Http" Version="9.0.0" />
35+
</ItemGroup>
36+
37+
</Project>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
namespace Microsoft.Extensions.Configuration;
2+
3+
internal static class ConfigurationExtensions
4+
{
5+
public static void SetDotnetEnvironmentVariable(this IHostApplicationBuilder builder)
6+
{
7+
#if DEBUG
8+
Environment.SetEnvironmentVariable("DOTNET_ENVIRONMENT", "Development");
9+
#else
10+
Environment.SetEnvironmentVariable("DOTNET_ENVIRONMENT", "Production");
11+
#endif
12+
}
13+
14+
public static string GetRequired(this IConfiguration configuration, string key) =>
15+
configuration[key] ?? throw new InvalidOperationException($"Configuration \"{key}\" was not found.");
16+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
global using Codebreaker.GameAPIs.Client;
2+
global using Codebreaker.ViewModels;
3+
global using Codebreaker.ViewModels.Services;
4+
5+
global using Microsoft.Extensions.Configuration;
6+
global using Microsoft.Extensions.DependencyInjection;
7+
global using Microsoft.Extensions.Hosting;
8+
9+
global using System.ComponentModel;
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
namespace Codebreaker.WinForms.Helpers;
2+
3+
/// <summary>
4+
/// Helper class to convert color names to Color objects for WinForms.
5+
/// </summary>
6+
public static class ColorHelper
7+
{
8+
public static Color GetColorFromName(string colorName)
9+
{
10+
return colorName.ToLowerInvariant() switch
11+
{
12+
"red" => Color.Red,
13+
"green" => Color.Green,
14+
"blue" => Color.Blue,
15+
"yellow" => Color.Yellow,
16+
"orange" => Color.Orange,
17+
"purple" => Color.Purple,
18+
"white" => Color.White,
19+
"black" => Color.Black,
20+
_ => Color.Gray
21+
};
22+
}
23+
}

0 commit comments

Comments
 (0)