HTLLeonding.Utility.LeoBoard 3.2.2

Prefix Reserved
dotnet add package HTLLeonding.Utility.LeoBoard --version 3.2.2                
NuGet\Install-Package HTLLeonding.Utility.LeoBoard -Version 3.2.2                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="HTLLeonding.Utility.LeoBoard" Version="3.2.2" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add HTLLeonding.Utility.LeoBoard --version 3.2.2                
#r "nuget: HTLLeonding.Utility.LeoBoard, 3.2.2"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install HTLLeonding.Utility.LeoBoard as a Cake Addin
#addin nuget:?package=HTLLeonding.Utility.LeoBoard&version=3.2.2

// Install HTLLeonding.Utility.LeoBoard as a Cake Tool
#tool nuget:?package=HTLLeonding.Utility.LeoBoard&version=3.2.2                

LeoBoard

A utility library for creating simple, grid-based UI application like Minesweeper, Chess, etc.

Allows drawing a grid with specified size, optional row and column numbers, and content for each cell. Left- and right-click events are captured and can be handled to update the cell content.

sample_run.png

Sample usage

using System.Text;
using Avalonia.Media;
using LeoBoard;

Board.Initialize(Run, "Foo", 10, 20,
                 clickHandler: HandleClick,
                 drawGridNumbers: true);

return;

void Run()
{
    Console.OutputEncoding = Encoding.UTF8;
    
    Board.SetCellContent(0, 0, "X");
    Board.SetCellContent(1, 1, "Y", Brushes.Red);
    Board.SetCellContent(2, 2, "Z", Brushes.Blue);
    
    Console.WriteLine(Board.GetCellContent(2, 2));
    
    Board.ShowMessageBox("Hello World!");
    
    Console.ReadKey();
}

void HandleClick(int row, int col, bool leftClick, bool ctrlKeyPressed)
{
    string ctrlState = ctrlKeyPressed ? " while pressing the Ctrl key" : string.Empty;
    Console.WriteLine($"Clicked cell ({row}, {col}) with {(leftClick ? "left" : "right")} mouse button{ctrlState}");
    if (leftClick)
    {
        Board.SetCellContent(row, col, "A", Brushes.Green);
    }
    else
    {
        Board.SetCellContent(row, col, "B", Brushes.Purple);
    }
}
  • It is necessary to pass a method reference (Run in the above sample) to the initialization method, because to also support macOS we have to use the main thread as UI thread and spin up a second thread for the console interaction and actual 'main' logic. This complexity is hidden from the students as good as possible, but this small requirement remains for technical reasons.
  • The Console.ReadKey() call is required to keep the hosting console application alive
  • Allow for a few seconds for the window to appear (some async initialization is happening)
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
3.2.2 229 5/26/2024
3.2.1 141 5/16/2024
3.2.0 111 5/16/2024
3.1.0 128 5/1/2024
3.0.1 86 5/1/2024
3.0.0 125 5/1/2024
2.0.0 164 4/30/2024
2.0.0-preview1 89 4/29/2024
1.1.0 116 4/26/2024
1.0.1 169 4/3/2024
1.0.0 100 4/3/2024
1.0.0-preview6 83 3/29/2024
1.0.0-preview5 90 3/29/2024
1.0.0-preview4 74 3/29/2024
1.0.0-preview3 81 3/29/2024
1.0.0-preview2 82 3/29/2024
1.0.0-preview1 83 3/29/2024