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
+55 -6
View File
@@ -31,6 +31,10 @@
this.lsbFiles = new System.Windows.Forms.ListBox();
this.btnImportFiles = new System.Windows.Forms.Button();
this.nonogramme1 = new NonoGramme.Nonogramme();
this.btnShow = new System.Windows.Forms.Button();
this.btnSubmit = new System.Windows.Forms.Button();
this.btnResolve = new System.Windows.Forms.Button();
this.btnSave = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.nonogramme1)).BeginInit();
this.SuspendLayout();
//
@@ -38,17 +42,17 @@
//
this.lsbFiles.FormattingEnabled = true;
this.lsbFiles.ItemHeight = 16;
this.lsbFiles.Location = new System.Drawing.Point(418, 12);
this.lsbFiles.Location = new System.Drawing.Point(568, 12);
this.lsbFiles.Name = "lsbFiles";
this.lsbFiles.Size = new System.Drawing.Size(204, 356);
this.lsbFiles.Size = new System.Drawing.Size(309, 308);
this.lsbFiles.TabIndex = 1;
this.lsbFiles.SelectedIndexChanged += new System.EventHandler(this.lsbFiles_SelectedIndexChanged);
//
// btnImportFiles
//
this.btnImportFiles.Location = new System.Drawing.Point(418, 374);
this.btnImportFiles.Location = new System.Drawing.Point(568, 326);
this.btnImportFiles.Name = "btnImportFiles";
this.btnImportFiles.Size = new System.Drawing.Size(204, 36);
this.btnImportFiles.Size = new System.Drawing.Size(309, 36);
this.btnImportFiles.TabIndex = 2;
this.btnImportFiles.Text = "Import";
this.btnImportFiles.UseVisualStyleBackColor = true;
@@ -59,17 +63,58 @@
this.nonogramme1.GridSize = new System.Drawing.Size(0, 0);
this.nonogramme1.Location = new System.Drawing.Point(12, 12);
this.nonogramme1.Name = "nonogramme1";
this.nonogramme1.Size = new System.Drawing.Size(400, 400);
this.nonogramme1.Size = new System.Drawing.Size(550, 550);
this.nonogramme1.TabIndex = 0;
this.nonogramme1.TabStop = false;
this.nonogramme1.Click += new System.EventHandler(this.nonogramme1_Click);
this.nonogramme1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.nonogramme1_MouseDown);
//
// btnShow
//
this.btnShow.Location = new System.Drawing.Point(568, 368);
this.btnShow.Name = "btnShow";
this.btnShow.Size = new System.Drawing.Size(309, 36);
this.btnShow.TabIndex = 3;
this.btnShow.Text = "Show answer";
this.btnShow.UseVisualStyleBackColor = true;
this.btnShow.Click += new System.EventHandler(this.btnShow_Click);
//
// btnSubmit
//
this.btnSubmit.Location = new System.Drawing.Point(568, 410);
this.btnSubmit.Name = "btnSubmit";
this.btnSubmit.Size = new System.Drawing.Size(309, 36);
this.btnSubmit.TabIndex = 4;
this.btnSubmit.Text = "Submit";
this.btnSubmit.UseVisualStyleBackColor = true;
//
// btnResolve
//
this.btnResolve.Location = new System.Drawing.Point(568, 452);
this.btnResolve.Name = "btnResolve";
this.btnResolve.Size = new System.Drawing.Size(309, 36);
this.btnResolve.TabIndex = 5;
this.btnResolve.Text = "AutoResolve";
this.btnResolve.UseVisualStyleBackColor = true;
//
// btnSave
//
this.btnSave.Location = new System.Drawing.Point(568, 494);
this.btnSave.Name = "btnSave";
this.btnSave.Size = new System.Drawing.Size(309, 36);
this.btnSave.TabIndex = 6;
this.btnSave.Text = "Save as new .non";
this.btnSave.UseVisualStyleBackColor = true;
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(634, 422);
this.ClientSize = new System.Drawing.Size(889, 572);
this.Controls.Add(this.btnSave);
this.Controls.Add(this.btnResolve);
this.Controls.Add(this.btnSubmit);
this.Controls.Add(this.btnShow);
this.Controls.Add(this.btnImportFiles);
this.Controls.Add(this.lsbFiles);
this.Controls.Add(this.nonogramme1);
@@ -87,6 +132,10 @@
private Nonogramme nonogramme1;
private System.Windows.Forms.ListBox lsbFiles;
private System.Windows.Forms.Button btnImportFiles;
private System.Windows.Forms.Button btnShow;
private System.Windows.Forms.Button btnSubmit;
private System.Windows.Forms.Button btnResolve;
private System.Windows.Forms.Button btnSave;
}
}
+8 -1
View File
@@ -20,7 +20,6 @@ namespace NonoGramme
public Form1()
{
InitializeComponent();
NewGame();
}
private void NewGame()
{
@@ -31,6 +30,7 @@ namespace NonoGramme
private void Form1_Load(object sender, EventArgs e)
{
//ScaleUi();
NewGame();
}
private void Form1_Resize(object sender, EventArgs e)
@@ -52,6 +52,7 @@ namespace NonoGramme
private void RefreshUi()
{
nonogramme1.Refresh();
//ScaleUi();
}
private void button1_Click(object sender, EventArgs e)
{
@@ -98,5 +99,11 @@ namespace NonoGramme
nonogramme1.CursorClick(nonogramme1.PointToClient(MousePosition));
RefreshUi();
}
private void btnShow_Click(object sender, EventArgs e)
{
nonogramme1.ToggleSolution();
RefreshUi();
}
}
}
+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));
-1
View File
@@ -32,7 +32,6 @@ namespace NonoGramme
{
Data[i] = new Tile();
}
RecalculateHints();
}
public string GetHorizontalHints()
+4
View File
@@ -38,5 +38,9 @@ namespace NonoGramme
{
GameGrid.Click(position);
}
public void ToggleSolution()
{
GameGrid.ShowSolution = !GameGrid.ShowSolution;
}
}
}