I get the application mozayka, but here is something the algorithm does not work well. Gives a message about the folding of the picture, even when the picture is not folded
Here is the folding code and a full match check:
void PB_Click(object sender, EventArgs e) { PictureBox pb = (PictureBox)sender; for (int i = 0; i < PB.Length; i++) { // Π‘Π½Π°ΡΠ°Π»Π° ΠΎΠΏΡΠ΅Π΄Π΅Π»ΠΈΠΌ ΠΏΡΡΡΠΎΠ΅ ΠΌΠ΅ΡΡΠΎ Π½Π° ΠΎΠ±Π»Π°ΡΡΠΈ ΡΠΈΡΠΎΠ²Π°Π½ΠΈΡ ΠΊΠ°ΡΡΠΈΠ½ΠΊΠΈ. if (PB[i].Visible == false) { // ΠΠ°ΡΠ΅ΠΌ ΠΏΡΠΎΠ²Π΅ΡΠΈΠΌ ΠΊΠ»ΠΈΠΊΠ½ΡΡΡΠΉ ΠΏΡΡΠΌΠΎΡΠ³ΠΎΠ»ΡΠ½ΠΈΠΊ ΠΈ // Π΅ΡΠ»ΠΈ Ρ Π½Π΅Π³ΠΎ ΡΠΎΠ²ΠΏΠ°Π΄Π°ΡΡ ΠΊΠΎΠΎΡΠ΄ΠΈΠ½Π°ΡΡ ΠΏΠΎ X ΠΈΠ»ΠΈ Y, // (ΠΎΡΠΊΠΈΠ΄ΡΠ²Π°Π΅ΠΌ ΠΈΠ· Π²ΡΡΠΈΡΠ»Π΅Π½ΠΈΡ ΠΏΡΡΠΌΠΎΡΠ³ΠΎΠ»ΡΠ½ΠΈΠΊΠΈ ΡΠ°ΡΠΏΠΎΠ»ΠΎΠΆΠ΅Π½Π½Π½ΡΠ΅ ΠΏΠΎ Π΄ΠΈΠ°Π³ΠΎΠ½Π°Π»ΠΈ) // Π½ΠΎ ΠΏΡΠΈ ΡΡΠΎΠΌ ΠΎΠ½ Π½Π° Π±Π»ΠΈΠΆΠ°ΠΉΡΠ΅ΠΌ ΡΠ°ΡΡΡΠΎΡΠ½ΠΈΠΈ ΠΎΡ ΠΏΡΡΡΠΎΠ³ΠΎ // ΠΏΡΡΠΌΠΎΡΠ³ΠΎΠ»ΡΠ½ΠΈΠΊΠ° // (ΠΎΡΠΊΠΈΠ΄ΡΠ²Π°Π΅ΠΌ ΠΏΡΡΠΌΠΎΡΠ³ΠΎΠ»ΡΠ½ΠΈΠΊΠΈ ΡΠ°ΡΠΏΠΎΠ»ΠΎΠΆΠ΅Π½Π½ΡΠ΅ ΡΠ΅ΡΠ΅Π· ΠΏΡΡΠΌΠΎΡΠ³ΠΎΠ»ΡΠ½ΠΈΠΊ ΠΎΡ ΠΏΡΡΡΠΎΠ³ΠΎ) if ((pb.Location.X == PB[i].Location.X && Math.Abs(pb.Location.Y - PB[i].Location.Y) == PB[i].Height) || (pb.Location.Y == PB[i].Location.Y && Math.Abs(pb.Location.X - PB[i].Location.X) == PB[i].Width)) { // ΠΠΎΡΠ»Π΅ ΡΡΠΏΠ΅ΡΠ½ΠΎΠΉ ΠΏΡΠΎΠ²Π΅ΡΠΊΠΈ // ΠΌΠ΅Π½ΡΠ΅ΠΌ ΠΌΠ΅ΡΡΠ°ΠΌΠΈ ΠΏΡΡΡΠΎΠΉ ΠΈ ΠΊΠ»ΠΈΠΊΠ½ΡΡΡΠΉ ΠΏΡΡΠΌΠΎΡΠ³ΠΎΠ»ΡΠ½ΠΈΠΊΠΈ. Point pt = PB[i].Location; PB[i].Location = pb.Location; pb.Location = pt; // ΠΠΎΡΠ»Π΅ ΠΊΠ°ΠΆΠ΄ΠΎΠ³ΠΎ Ρ
ΠΎΠ΄Π° ΠΏΡΠΎΠ²Π΅ΡΠΊΠ° Π½Π° ΠΏΠΎΠ»Π½ΡΡ ΡΠ±ΠΎΡΠΊΡ ΠΊΠ°ΡΡΠΈΠ½ΠΊΠΈ. //*************** Π±Π»ΠΎΠΊ ΠΏΡΠΎΠ²Π΅ΡΠΊΠΈ *********************** // ΠΡΠ»ΠΈ Ρ
ΠΎΡΡ Ρ ΠΎΠ΄Π½ΠΎΠ³ΠΎ ΠΏΡΡΠΌΠΎΡΠ³ΠΎΠ»ΡΠ½ΠΈΠΊΠ° Π½Π΅ ΡΠΎΠ²ΠΏΠ°Π΄Π°ΡΡ // ΡΠ΅Π°Π»ΡΠ½ΡΠ΅ ΠΊΠΎΠΎΡΠ΄ΠΈΠ½Π°ΡΡ ΠΈ ΠΏΠ΅ΡΠ²ΠΈΡΠ½ΡΠ΅ Π²ΡΡ
ΠΎΠ΄ΠΈΠΌ ΠΈΠ· ΡΡΠ½ΠΊΡΠΈΠΈ. for (int j = 0; j < PB.Length; j++) { Point point = (Point)PB[i].Tag; if (PB[j].Location != point) { //MessageBox.Show(this, point + "x" + PB[j].Location.ToString(), "Data"); Debug.WriteLine(point + "x" + PB[j].Location.ToString()); return; } } // ΠΡΠ»ΠΈ Ρ Π²ΡΠ΅Ρ
ΠΏΡΡΠΌΠΎΡΠ³ΠΎΠ»ΡΠ½ΠΈΠΊΠΎΠ² ΡΠΎΠ²ΠΏΠ°Π»ΠΈ ΡΠ΅Π°Π»ΡΠ½ΡΠ΅ ΠΈ ΠΏΠ΅ΡΠ²ΠΈΡΠ½ΡΠ΅ // ΠΊΠΎΠΎΡΠ΄ΠΈΠ½Π°ΡΡ - ΠΊΠ°ΡΡΠΈΠ½ΠΊΠ° ΡΠΎΠ±ΡΠ°Π½Π°! for (int m = 0; m < PB.Length; m++) { PB[m].Visible = true; PB[m].BorderStyle = BorderStyle.None; // ΡΠ±ΠΈΡΠ°Π΅ΠΌ ΠΎΠ±ΡΠ°ΠΌΠ»Π΅Π½ΠΈΠ΅ ΠΏΡΡΠΌΠΎΡΠ³ΠΎΠ»ΡΠ½ΠΈΠΊΠΎΠ² Properties.Settings.Default.LevelCompleted = true; MessageBox.Show(this, "ΠΠ°ΡΡΠΈΠ½ΠΊΠ° ΡΠΎΠ±ΡΠ°Π½Π°!", "ΠΠΎΠ±Π΅Π΄Π°", MessageBoxButtons.OK, MessageBoxIcon.Information); } //************** ΠΎΠΊΠΎΠ½ΡΠ°Π½ΠΈΠ΅ Π±Π»ΠΎΠΊΠ° ΠΏΡΠΎΠ²Π΅ΡΠΊΠΈ ************* } break; } } } Here is the project: http://www.interestprograms.ru/sources/csharp/files/sourcemosaic.rar It is necessary to display a message when the picture is collected. The message displays even when the picture is not collected. Most likely due to the incorrect verification of coordinates for folding and checking the image composure.
Properties.Settings.Default.LevelCompleted = true; MessageBox.Show(this, "ΠΠ°ΡΡΠΈΠ½ΠΊΠ° ΡΠΎΠ±ΡΠ°Π½Π°!"Properties.Settings.Default.LevelCompleted = true; MessageBox.Show(this, "ΠΠ°ΡΡΠΈΠ½ΠΊΠ° ΡΠΎΠ±ΡΠ°Π½Π°!"Always works - codename0082016