/
Tile.cs
48 lines (41 loc) · 1.03 KB
/
Tile.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
using System;
using System.Windows.Forms;
using System.ComponentModel;
using System.Collections.Generic;
using System.Drawing;
namespace ImagePuzzle
{
internal class Tile : PictureBox
{
private PuzzleForm parent;
private int row;
private int col;
public Tile(PuzzleForm p)
{
parent = p;
}
public int Row
{
get { return row; }
set { row = value; }
}
public int Col
{
get { return col; }
set { col = value; }
}
protected override void OnClick(EventArgs e)
{
base.OnClick(e);
parent.solver.Abort();
parent.buttonTimer.Stop();
parent.solveButton.Text = "Solve";
parent.MovePiece(this);
int[] positions = parent.GetPositions();
if (parent.IsSolved(positions))
{
MessageBox.Show("Congratulations! Puzzle is solved", "Done");
}
}
}
}