Beispiel #1
0
        private void MainWindow_MouseUp(object sender, MouseButtonEventArgs e)
        {
            Point pos = Mouse.GetPosition(desk);

            if (link != null)
            {
                if ((pos.X < img.Width) && (pos.Y < img.Height))
                {
                    int x = ((int)pos.X / W) * W;
                    int y = ((int)pos.Y / H) * H;


                    int cX = (int)(x / W);
                    int cY = (int)(y / H);

                    int ind = l.get(cX, cY);


                    shapes[ind].RenderTransform = new TranslateTransform(oldX * W, oldY * H);

                    l.move(oldX, oldY, ind);

                    g           = g + 1;
                    hod.Content = g;

                    link.RenderTransform = new TranslateTransform(x, y);



                    if (l.move(cX, cY, int.Parse(link.Tag.ToString())))
                    {
                        // MessageBox.Show("win win");
                        winner winner = new winner();
                        winner.w1.Content = timer.Content;
                        winner.w2.Content = hod.Content;
                        winner.Show();
                        this.Close();
                    }
                }
                else
                {
                    link.RenderTransform = new TranslateTransform(oldX * W, oldY * H);
                }
            }

            link = null;
            // ll.Content = "null";
        }
Beispiel #2
0
            public void move()
            {
                logic l = new logic(C, R);
                bool  p = false;

                //int ii = 1;
                //int jj = 1;
                //int num = 1;
                for (int i = 0; i < C; i++)
                {
                    for (int j = 0; j < R; j++)
                    {
                        int t1 = l.img[i, j];
                        int t2 = l.get(i, j);

                        l.move(i, j, i + j * C);

                        if (l.img[i, j] == t2 && l.get(i, j) == t1)
                        {
                            p = true;
                        }
                    }
                }


                Assert.IsTrue(p);
            }