Show / Hide Table of Contents

Class Chessboard

Blazor Component for adding an interactive chessboard to a Blazor application. It was build as a Blazor version of chessboard.js and allows to use this functionality without the need to interop with javascript.

There are however quite some differences:

  • No animations
  • It has chess knowledge and therefore provides legal move check out of the box
Inheritance
System.Object
Chessboard
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: PonzianiComponents
Assembly: PonzianiComponents.dll
Syntax
public class Chessboard

Properties

| Improve this Doc View Source

ColorDarkSquares

Color of dark squares

Declaration
[Parameter]
public string ColorDarkSquares { get; set; }
Property Value
Type Description
System.String
| Improve this Doc View Source

ColorHighlight

Color used for highlighting squares

Declaration
[Parameter]
public string ColorHighlight { get; set; }
Property Value
Type Description
System.String
| Improve this Doc View Source

ColorLightSquares

Color of light squares

Declaration
[Parameter]
public string ColorLightSquares { get; set; }
Property Value
Type Description
System.String
| Improve this Doc View Source

Fen

Position displayed on the board in Forsyth-Edwards-Notation

Declaration
[Parameter]
public string Fen { get; set; }
Property Value
Type Description
System.String
| Improve this Doc View Source

HighlightLastAppliedMove

If true, the squares of the last applied Move get highlighted

Declaration
[Parameter]
public bool HighlightLastAppliedMove { get; set; }
Property Value
Type Description
System.Boolean
| Improve this Doc View Source

Id

Id of the rendered HTML element

Declaration
[Parameter]
public string Id { get; set; }
Property Value
Type Description
System.String
| Improve this Doc View Source

OnMovePlayed

Is called whenever the user played a move on the board. Only active if SetupMode is false.

Declaration
[Parameter]
public EventCallback<MovePlayedInfo> OnMovePlayed { get; set; }
Property Value
Type Description
Microsoft.AspNetCore.Components.EventCallback<MovePlayedInfo>
| Improve this Doc View Source

OnSetupChanged

Is called whenever the user changed the board's setup be moving, adding or removing a piece in SetupMode

Declaration
[Parameter]
public EventCallback<SetupChangedInfo> OnSetupChanged { get; set; }
Property Value
Type Description
Microsoft.AspNetCore.Components.EventCallback<SetupChangedInfo>
| Improve this Doc View Source

OtherAttributes

Other HTML Attributes, which are applied to the root element of the rendered scoresheet.

Declaration
[Parameter(CaptureUnmatchedValues = true)]
public Dictionary<string, object> OtherAttributes { get; set; }
Property Value
Type Description
System.Collections.Generic.Dictionary<System.String, System.Object>
| Improve this Doc View Source

PathPieceImages

Allowing to replace the current piece images with a different set. The piece images must follow the naming convention {color}{piecetype}.png, so wB.png for white Bishop, bP.png for black Pawn

Declaration
[Parameter]
public string PathPieceImages { get; set; }
Property Value
Type Description
System.String
| Improve this Doc View Source

Rotate

If true the board's orientation is reversed

Declaration
[Parameter]
public bool Rotate { get; set; }
Property Value
Type Description
System.Boolean
| Improve this Doc View Source

SetupMode

SetupMode can be used to allow the user to set up a new position. If SetupMode is active pieces can be freely moved, added and removed. There are spare pieces shown outside the board. If SetupMode isn't active only legal moves can be played. Default is false.

Declaration
[Parameter]
public bool SetupMode { get; set; }
Property Value
Type Description
System.Boolean
| Improve this Doc View Source

ShowCoordinates

If true, the file and rank labels are displayed

Declaration
[Parameter]
public bool ShowCoordinates { get; set; }
Property Value
Type Description
System.Boolean
| Improve this Doc View Source

Size

Size (in pixels) of Chessboard

Declaration
[Parameter]
public int Size { get; set; }
Property Value
Type Description
System.Int32

Methods

| Improve this Doc View Source

ApplyMove(Move)

Applies a move to the current board

Declaration
public bool ApplyMove(Move move)
Parameters
Type Name Description
Move move

The move which shall be applied

Returns
Type Description
System.Boolean

true, if move could be applied

| Improve this Doc View Source

ClearHighlighting()

Removes all square highlights which have been sett by SetHighlightSquare(Square, Boolean)

Declaration
public void ClearHighlighting()
| Improve this Doc View Source

ExitSetupMode()

Leave setup mode (API-call to set parameter SetupMode to false)

Declaration
public void ExitSetupMode()
| Improve this Doc View Source

IsHighlighted(Square)

Checks if a square is highlighted (marked) or not

Declaration
public bool IsHighlighted(Square s)
Parameters
Type Name Description
Square s

Square

Returns
Type Description
System.Boolean

true if highlighted

| Improve this Doc View Source

OnAfterRenderAsync(Boolean)

Declaration
protected override async Task OnAfterRenderAsync(bool firstRender)
Parameters
Type Name Description
System.Boolean firstRender
Returns
Type Description
System.Threading.Tasks.Task
| Improve this Doc View Source

SetFen(String)

API call to set the position

Declaration
public void SetFen(string fen)
Parameters
Type Name Description
System.String fen

The new position in FEN-Notation

| Improve this Doc View Source

SetHighlightSquare(Square, Boolean)

Method to mark/highlight a square

Declaration
public void SetHighlightSquare(Square s, bool highlight = true)
Parameters
Type Name Description
Square s

The square, which shall be highlighted

System.Boolean highlight

if true, square will be highlighted, if false highlight is switched off

| Improve this Doc View Source

SwitchToSetupMode()

Enter setup mode (API-call to set parameter SetupMode to true)

Declaration
public void SwitchToSetupMode()
  • Improve this Doc
  • View Source
In This Article
Back to top Generated by DocFX