0

My program consists of a grid with 8 images (one free space). It's like those unscramble the picture games. How can I detect that the user has completed the game, meaning they've placed all the right images in the right grids?

These are my images and so how can I specify that once they're at for example row 2 and column 3 that that is the correct position it needs to be in?

GridPic1.Source = new BitmapImage(new Uri("pack://application:,,,/Pic1/Pic1.jpg"));
GridPic2.Source = new BitmapImage(new Uri("pack://application:,,,/Pic1/Pic2.jpg"));
// [...]
GridPic9.Source = new BitmapImage(new Uri("pack://application:,,,/Pic1/Pic9.jpg"));
  • Are you asking how to detect that the picture is in the correct place, or how to show a message box? Those are two separate tasks – ADyson Jun 22 '21 at 11:43
  • How to detect that the images are in the correct place –  Jun 22 '21 at 11:50
  • Thanks. I clarified the question for you. Be aware you can also edit it yourself. – ADyson Jun 22 '21 at 11:57
  • Maybe you need to replace the `WinForms` tag with the right one. – dr.null Jun 22 '21 at 13:34
  • that wasn't done by me so I can't be sure –  Jun 22 '21 at 13:40
  • Are you also sure that this is a WinForms app? It doesn't look like. That code applies to a WPF app. Anyway, you can build a class object that contains, e.g., an `Index` Property, an `Image` Property and a references to a Cell of a grid (are you using an Image Control?). Scramble the `List` when you start and after each move (your *space* has `Index = 0`), check whether the sequence of the indexes in the list is the same as the original (`0-7`? Or `1-7`, not counting the Index at `0`). – Jimi Jun 22 '21 at 13:41
  • yes I'm using an Image control. How can I check the sequence of the indexes in the list? My images start at different positions every time as well –  Jun 22 '21 at 13:51
  • Nope, your Images start at the same position each time, then you [shuffle the List](https://stackoverflow.com/q/273313/7444103) and show the Images in this random order. Or do you mean you have no idea what is the initial layout of the images? It'd be weird... – Jimi Jun 22 '21 at 13:58
  • Oh yes the images are always in the same position. Thankyou! –  Jun 22 '21 at 14:09

0 Answers0