You can now right click to cross a tile
This commit is contained in:
88
NonoGramme/Form1.Designer.cs
generated
88
NonoGramme/Form1.Designer.cs
generated
@@ -30,11 +30,12 @@
|
||||
{
|
||||
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();
|
||||
this.nonogramme1 = new NonoGramme.Nonogramme();
|
||||
this.button1 = new System.Windows.Forms.Button();
|
||||
((System.ComponentModel.ISupportInitialize)(this.nonogramme1)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
@@ -44,13 +45,13 @@
|
||||
this.lsbFiles.ItemHeight = 16;
|
||||
this.lsbFiles.Location = new System.Drawing.Point(568, 12);
|
||||
this.lsbFiles.Name = "lsbFiles";
|
||||
this.lsbFiles.Size = new System.Drawing.Size(309, 308);
|
||||
this.lsbFiles.Size = new System.Drawing.Size(309, 292);
|
||||
this.lsbFiles.TabIndex = 1;
|
||||
this.lsbFiles.SelectedIndexChanged += new System.EventHandler(this.lsbFiles_SelectedIndexChanged);
|
||||
//
|
||||
// btnImportFiles
|
||||
//
|
||||
this.btnImportFiles.Location = new System.Drawing.Point(568, 326);
|
||||
this.btnImportFiles.Location = new System.Drawing.Point(568, 310);
|
||||
this.btnImportFiles.Name = "btnImportFiles";
|
||||
this.btnImportFiles.Size = new System.Drawing.Size(309, 36);
|
||||
this.btnImportFiles.TabIndex = 2;
|
||||
@@ -58,6 +59,43 @@
|
||||
this.btnImportFiles.UseVisualStyleBackColor = true;
|
||||
this.btnImportFiles.Click += new System.EventHandler(this.button1_Click);
|
||||
//
|
||||
// btnShow
|
||||
//
|
||||
this.btnShow.Location = new System.Drawing.Point(568, 352);
|
||||
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, 394);
|
||||
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, 436);
|
||||
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, 478);
|
||||
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;
|
||||
//
|
||||
// nonogramme1
|
||||
//
|
||||
this.nonogramme1.GridSize = new System.Drawing.Size(0, 0);
|
||||
@@ -69,48 +107,21 @@
|
||||
this.nonogramme1.Click += new System.EventHandler(this.nonogramme1_Click);
|
||||
this.nonogramme1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.nonogramme1_MouseDown);
|
||||
//
|
||||
// btnShow
|
||||
// button1
|
||||
//
|
||||
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;
|
||||
this.button1.Location = new System.Drawing.Point(568, 520);
|
||||
this.button1.Name = "button1";
|
||||
this.button1.Size = new System.Drawing.Size(309, 36);
|
||||
this.button1.TabIndex = 7;
|
||||
this.button1.Text = "Reload";
|
||||
this.button1.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// Form1
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(889, 572);
|
||||
this.Controls.Add(this.button1);
|
||||
this.Controls.Add(this.btnSave);
|
||||
this.Controls.Add(this.btnResolve);
|
||||
this.Controls.Add(this.btnSubmit);
|
||||
@@ -136,6 +147,7 @@
|
||||
private System.Windows.Forms.Button btnSubmit;
|
||||
private System.Windows.Forms.Button btnResolve;
|
||||
private System.Windows.Forms.Button btnSave;
|
||||
private System.Windows.Forms.Button button1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -96,7 +96,15 @@ namespace NonoGramme
|
||||
|
||||
private void nonogramme1_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
nonogramme1.CursorClick(nonogramme1.PointToClient(MousePosition));
|
||||
if (e.Button == MouseButtons.Right)
|
||||
{
|
||||
nonogramme1.CursorClick(nonogramme1.PointToClient(MousePosition),true);
|
||||
}
|
||||
else
|
||||
{
|
||||
nonogramme1.CursorClick(nonogramme1.PointToClient(MousePosition),false);
|
||||
}
|
||||
|
||||
RefreshUi();
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,8 @@ namespace NonoGramme
|
||||
private readonly Color DEFAULT_DISCOVERED_COLOR = Color.Black;
|
||||
private readonly Color DEFAULT_BORDER_COLOR = Color.Pink;
|
||||
private readonly Color DEFAULT_ERROR_COLOR = Color.Purple;
|
||||
private readonly Color DEFAULT_CROSS_COLOR = Color.Red;
|
||||
private readonly Color DEFAULT_FALSE_CROSS_COLOR = Color.PowderBlue;
|
||||
|
||||
private Size _gridSize;
|
||||
private Line[] _horizontalLines;
|
||||
@@ -52,7 +54,7 @@ namespace NonoGramme
|
||||
{
|
||||
ImportFromFile(filePath);
|
||||
}
|
||||
public void Click(Point position)
|
||||
public void Click(Point position,bool rightClick)
|
||||
{
|
||||
//MessageBox.Show(position.ToString());
|
||||
if (GridOffset != new Point(-1, -1))
|
||||
@@ -64,8 +66,8 @@ namespace NonoGramme
|
||||
Point relativePoint = new Point(position.X-GridOffset.X, position.Y-GridOffset.Y);
|
||||
Point reducedIndex = new Point(relativePoint.X / DrawedBlocSize.Width,relativePoint.Y / DrawedBlocSize.Height);
|
||||
//int flatIndex = position.Y * HorizontalLines.Count() + position.X;
|
||||
HorizontalLines[reducedIndex.Y].Click(reducedIndex.X);
|
||||
VerticalLines[reducedIndex.X].Click(reducedIndex.Y);
|
||||
HorizontalLines[reducedIndex.Y].Click(reducedIndex.X,rightClick);
|
||||
VerticalLines[reducedIndex.X].Click(reducedIndex.Y,rightClick);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -322,6 +324,22 @@ namespace NonoGramme
|
||||
g.FillRectangle(new SolidBrush(DEFAULT_EMPTY_COLOR), new Rectangle(position, blocSize));
|
||||
}
|
||||
break;
|
||||
case Tile.State.TrueCrossed:
|
||||
g.DrawLine(new Pen(DEFAULT_CROSS_COLOR),position,new Point(position.X + blocSize.Width,position.Y + blocSize.Height));
|
||||
g.DrawLine(new Pen(DEFAULT_CROSS_COLOR), new Point(position.X + blocSize.Width,position.Y), new Point(position.X, position.Y + blocSize.Height));
|
||||
break;
|
||||
case Tile.State.FalseCrossed:
|
||||
if (ShowSolution)
|
||||
{
|
||||
g.DrawLine(new Pen(DEFAULT_FALSE_CROSS_COLOR), position, new Point(position.X + blocSize.Width, position.Y + blocSize.Height));
|
||||
g.DrawLine(new Pen(DEFAULT_FALSE_CROSS_COLOR), new Point(position.X + blocSize.Width, position.Y), new Point(position.X, position.Y + blocSize.Height));
|
||||
}
|
||||
else
|
||||
{
|
||||
g.DrawLine(new Pen(DEFAULT_CROSS_COLOR), position, new Point(position.X + blocSize.Width, position.Y + blocSize.Height));
|
||||
g.DrawLine(new Pen(DEFAULT_CROSS_COLOR), new Point(position.X + blocSize.Width, position.Y), new Point(position.X, position.Y + blocSize.Height));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
g.FillRectangle(new SolidBrush(DEFAULT_ERROR_COLOR), new Rectangle(position, blocSize));
|
||||
break;
|
||||
|
||||
@@ -66,28 +66,58 @@ namespace NonoGramme
|
||||
Data[index].CurrentState = state;
|
||||
RecalculateHints();
|
||||
}
|
||||
public void Click(int index)
|
||||
public void Click(int index,bool rightClick)
|
||||
{
|
||||
Tile tile = Data[index];
|
||||
//MessageBox.Show("Tile pressed :"+tile.CurrentState);
|
||||
switch (tile.CurrentState)
|
||||
if (rightClick)
|
||||
{
|
||||
case Tile.State.Empty:
|
||||
tile.CurrentState = Tile.State.Full;
|
||||
break;
|
||||
case Tile.State.Undiscovered:
|
||||
tile.CurrentState = Tile.State.Discovered;
|
||||
break;
|
||||
case Tile.State.Full:
|
||||
tile.CurrentState = Tile.State.Empty;
|
||||
break;
|
||||
case Tile.State.Discovered:
|
||||
tile.CurrentState = Tile.State.Undiscovered;
|
||||
break;
|
||||
default:
|
||||
//We dont do anything
|
||||
break;
|
||||
if (tile.CurrentState == Tile.State.Empty || tile.CurrentState == Tile.State.Full)
|
||||
{
|
||||
//This is a correct use of the cross
|
||||
tile.CurrentState = Tile.State.TrueCrossed;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(tile.CurrentState != Tile.State.TrueCrossed && tile.CurrentState != Tile.State.FalseCrossed){
|
||||
//This cross is a mistake
|
||||
tile.CurrentState = Tile.State.FalseCrossed;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (tile.CurrentState == Tile.State.FalseCrossed)
|
||||
{
|
||||
tile.CurrentState = Tile.State.Undiscovered;
|
||||
}
|
||||
else
|
||||
{
|
||||
tile.CurrentState = Tile.State.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (tile.CurrentState)
|
||||
{
|
||||
case Tile.State.Empty:
|
||||
tile.CurrentState = Tile.State.Full;
|
||||
break;
|
||||
case Tile.State.Undiscovered:
|
||||
tile.CurrentState = Tile.State.Discovered;
|
||||
break;
|
||||
case Tile.State.Full:
|
||||
tile.CurrentState = Tile.State.Empty;
|
||||
break;
|
||||
case Tile.State.Discovered:
|
||||
tile.CurrentState = Tile.State.Undiscovered;
|
||||
break;
|
||||
default:
|
||||
//We dont do anything
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
public void RecalculateHints()
|
||||
{
|
||||
|
||||
@@ -34,9 +34,9 @@ namespace NonoGramme
|
||||
Bitmap bmp = new Bitmap(Width, Height);
|
||||
this.Image = GameGrid.Draw(bmp, new Point((Width / 100) * DEFAULT_UI_RATIO, (Height / 100) * DEFAULT_UI_RATIO));
|
||||
}
|
||||
public void CursorClick(Point position)
|
||||
public void CursorClick(Point position,bool rightClick)
|
||||
{
|
||||
GameGrid.Click(position);
|
||||
GameGrid.Click(position,rightClick);
|
||||
}
|
||||
public void ToggleSolution()
|
||||
{
|
||||
|
||||
@@ -20,11 +20,12 @@ namespace NonoGramme
|
||||
Empty,
|
||||
Full,
|
||||
Undiscovered,
|
||||
Discovered
|
||||
Discovered,
|
||||
TrueCrossed,
|
||||
FalseCrossed
|
||||
}
|
||||
|
||||
private State _currentState;
|
||||
|
||||
public State CurrentState { get => _currentState; set => _currentState = value; }
|
||||
|
||||
public Tile(State currentState)
|
||||
|
||||
Reference in New Issue
Block a user