You can now choose not to see the answers and try to play

This commit is contained in:
2022-10-17 17:23:35 +02:00
parent 24af23a3a2
commit 40a234b8f1
5 changed files with 88 additions and 11 deletions
+21 -3
View File
@@ -23,6 +23,7 @@ namespace NonoGramme
private Line[] _horizontalLines;
private Line[] _verticalLines;
private bool _showSolution;
private Point _gridOffset;
private Size _drawedBlocSize;
@@ -36,6 +37,7 @@ namespace NonoGramme
}
public Size DrawedBlocSize { get => _drawedBlocSize; set => _drawedBlocSize = value; }
public bool ShowSolution { get => _showSolution; set => _showSolution = value; }
public Grid(Size size)
{
@@ -43,6 +45,7 @@ namespace NonoGramme
HorizontalLines = new Line[size.Height];
VerticalLines = new Line[size.Width];
GridOffset = new Point(-1,-1);
ShowSolution = false;
Populate();
}
public Grid(string filePath)
@@ -252,7 +255,8 @@ namespace NonoGramme
}
public Bitmap Draw(Bitmap UI,Point offset)
{
RefreshGrid();
//We dont want the hints to update dynamically
//RefreshGrid();
Size actualSize = new Size(UI.Width - offset.X, UI.Height - offset.Y);
Size blocSize = new Size(actualSize.Width/GridSize.Width,actualSize.Height/GridSize.Height);
@@ -293,7 +297,14 @@ namespace NonoGramme
switch (tile.CurrentState)
{
case Tile.State.Full:
g.FillRectangle(new SolidBrush(DEFAULT_FULL_COLOR),new Rectangle(position,blocSize));
if (ShowSolution)
{
g.FillRectangle(new SolidBrush(DEFAULT_FULL_COLOR), new Rectangle(position, blocSize));
}
else
{
g.FillRectangle(new SolidBrush(DEFAULT_DISCOVERED_COLOR), new Rectangle(position, blocSize));
}
break;
case Tile.State.Empty:
g.FillRectangle(new SolidBrush(DEFAULT_EMPTY_COLOR), new Rectangle(position, blocSize));
@@ -302,7 +313,14 @@ namespace NonoGramme
g.FillRectangle(new SolidBrush(DEFAULT_DISCOVERED_COLOR), new Rectangle(position, blocSize));
break;
case Tile.State.Undiscovered:
g.FillRectangle(new SolidBrush(DEFAULT_UNDISCOVERED_COLOR), new Rectangle(position, blocSize));
if (ShowSolution)
{
g.FillRectangle(new SolidBrush(DEFAULT_UNDISCOVERED_COLOR), new Rectangle(position, blocSize));
}
else
{
g.FillRectangle(new SolidBrush(DEFAULT_EMPTY_COLOR), new Rectangle(position, blocSize));
}
break;
default:
g.FillRectangle(new SolidBrush(DEFAULT_ERROR_COLOR), new Rectangle(position, blocSize));