Skip to content

Commit 7bdfac0

Browse files
Add detailed documentation for WinForms project
Co-authored-by: christiannagel <1908285+christiannagel@users.noreply.github.com>
1 parent 23000e6 commit 7bdfac0

1 file changed

Lines changed: 134 additions & 0 deletions

File tree

src/Codebreaker.WinForms/README.md

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
# Codebreaker.WinForms
2+
3+
A Windows Forms implementation of the Codebreaker game, providing a classic Windows desktop experience.
4+
5+
## Overview
6+
7+
This project is a Windows Forms client application that allows users to play the Codebreaker game. It integrates with the existing CNinnovation.Codebreaker.ViewModels library for MVVM logic and communicates with the Codebreaker API service.
8+
9+
## Features
10+
11+
- **Classic Windows UI**: Traditional Windows Forms interface with familiar controls
12+
- **Full Gameplay**: Complete implementation of the Codebreaker game mechanics
13+
- **MVVM Integration**: Uses the CNinnovation.Codebreaker.ViewModels library for consistent game logic
14+
- **Real-time Updates**: UI updates in response to game state changes
15+
- **Visual Feedback**: Color-coded pegs and move history display
16+
- **Info Bar**: Displays messages and notifications during gameplay
17+
18+
## Requirements
19+
20+
- .NET 9.0 or later
21+
- Windows operating system
22+
- Visual Studio 2022 (or later) for development
23+
24+
## Getting Started
25+
26+
### Building the Project
27+
28+
1. Open the solution file: `src/CodeBreaker.WinForms.sln`
29+
2. Restore NuGet packages
30+
3. Build the solution (Ctrl+Shift+B)
31+
32+
### Running the Application
33+
34+
1. Press F5 in Visual Studio to run with debugging, or Ctrl+F5 to run without debugging
35+
2. Alternatively, run the built executable from `bin/Debug/net9.0-windows/` or `bin/Release/net9.0-windows/`
36+
37+
### Playing the Game
38+
39+
1. **Start**: Enter your username and click "Start Game"
40+
2. **Select Colors**: Choose colors for each peg position using the dropdown menus
41+
3. **Make Move**: Click "Set Move" to submit your guess
42+
4. **Review Feedback**: Check the key pegs to see how many colors are correct and in the right position
43+
5. **Win/Lose**: Continue until you guess correctly or run out of moves
44+
45+
## Project Structure
46+
47+
```
48+
Codebreaker.WinForms/
49+
├── Extensions/
50+
│ └── ConfigurationExtensions.cs # Configuration helper methods
51+
├── Helpers/
52+
│ └── ColorHelper.cs # Color conversion utilities
53+
├── Services/
54+
│ └── WinFormsDialogService.cs # Dialog service implementation
55+
├── MainForm.cs # Main game form
56+
├── Program.cs # Application entry point
57+
├── GlobalUsings.cs # Global using directives
58+
├── appsettings.json # Application configuration
59+
└── Codebreaker.WinForms.csproj # Project file
60+
```
61+
62+
## Configuration
63+
64+
The application uses `appsettings.json` for configuration. Key settings include:
65+
66+
- **ApiBase**: The base URL for the Codebreaker API service
67+
68+
```json
69+
{
70+
"ApiBase": "https://gameapis.kindbeach-def2191a.westeurope.azurecontainerapps.io"
71+
}
72+
```
73+
74+
You can override settings for different environments using:
75+
- `appsettings.Development.json` - Development environment
76+
- `appsettings.Production.json` - Production environment
77+
78+
## Architecture
79+
80+
### Dependency Injection
81+
82+
The application uses Microsoft.Extensions.Hosting for dependency injection:
83+
84+
```csharp
85+
builder.Services.AddSingleton<IInfoBarService, InfoBarService>();
86+
builder.Services.AddSingleton<IDialogService, WinFormsDialogService>();
87+
builder.Services.AddScoped<GamePageViewModel>();
88+
builder.Services.AddHttpClient<IGamesClient, GamesClient>();
89+
```
90+
91+
### MVVM Pattern
92+
93+
The UI binds to the `GamePageViewModel` from the CNinnovation.Codebreaker.ViewModels library:
94+
- **GamePageViewModel**: Manages game state and provides commands
95+
- **IInfoBarService**: Displays messages to the user
96+
- **IDialogService**: Shows dialog boxes
97+
- **IGamesClient**: Communicates with the game API
98+
99+
## Key Components
100+
101+
### MainForm
102+
103+
The main form contains:
104+
- **Start Game Panel**: Username input and start button
105+
- **Peg Selection Panel**: Dropdown menus for color selection
106+
- **Moves List**: History of all moves with visual feedback
107+
- **Status Bar**: Current game status and progress indicator
108+
- **Info Bar**: Messages and notifications
109+
110+
### Custom Drawing
111+
112+
The application uses custom drawing for:
113+
- **Color Pegs**: Rendered as colored circles in combo boxes
114+
- **Move History**: Each move displays guess pegs and key peg feedback
115+
116+
## Dependencies
117+
118+
- **CNInnovation.Codebreaker.ViewModels**: MVVM view models and game logic
119+
- **Microsoft.Extensions.Hosting**: Dependency injection and configuration
120+
- **Microsoft.Extensions.Http**: HTTP client factory
121+
122+
## Related Projects
123+
124+
- **Codebreaker.WPF**: WPF implementation
125+
- **Codebreaker.WinUI**: WinUI implementation
126+
- **Codebreaker.MAUI**: Cross-platform MAUI implementation
127+
128+
## Contributing
129+
130+
Follow the repository guidelines for contributions. See [guidelines.md](../../guidelines.md) for more information.
131+
132+
## License
133+
134+
MIT License - See the LICENSE file in the repository root.

0 commit comments

Comments
 (0)