Exemplo n.º 1
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);
            }
Exemplo n.º 2
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";
        }
Exemplo n.º 3
0
            public void get()
            {
                logic l = new logic(C, R);
                bool  p = true;

                for (int i = 0; i < C; i++)
                {
                    for (int j = 0; j < R; j++)
                    {
                        if (l.get(i, j) != i + j * C)
                        {
                            p = false;
                        }
                    }
                }
                Assert.IsTrue(p);
            }
Exemplo n.º 4
0
        private void name_Click(object sender, RoutedEventArgs e)
        {
            DispatcherTimer dtClockTime = new DispatcherTimer();

            dtClockTime.Tick    += dispatcherTimer_Tick;
            dtClockTime.Interval = new TimeSpan(0, 0, 1);
            dtClockTime.Start();

            shapes = new Rectangle[N];

            l = new logic(C, R);
            l.scramble(100);

            desk.Children.Clear();
            desk.Children.Add(raz);

            for (int i = 0; i < C; i++)
            {
                for (int j = 0; j < R; j++)
                {
                    int ind = l.get(i, j);

                    shapes[ind]     = new Rectangle();
                    shapes[ind].Tag = ind;

                    ImageBrush ib = new ImageBrush();
                    //позиция изображения будет указана как координаты левого верхнего угла
                    //изображение будет выведено без растяжения/сжатия
                    ib.AlignmentX = AlignmentX.Left;
                    ib.AlignmentY = AlignmentY.Top;
                    ib.Stretch    = Stretch.None;
                    //участок изображения который будет нарисован
                    //в данном случае, второй кадр первой строки

                    int py = ind / C;
                    int px = ind - (py * C);

                    ib.Viewbox = new Rect(px * W, py * H, px * W + W, py * H + H);

                    ib.ViewboxUnits = BrushMappingMode.Absolute;

                    //загрузка изображения и назначение кисти
                    ib.ImageSource   = img;
                    shapes[ind].Fill = ib;
                    //толщина и цвет обводки
                    shapes[ind].StrokeThickness = 2;
                    shapes[ind].Stroke          = Brushes.Black;
                    //размеры овала
                    shapes[ind].Width  = W;
                    shapes[ind].Height = H;
                    //позиция овала
                    //shapes[i].Margin = new Thickness(0, 0, 0, 0);


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

                    //добавление овала в сцену
                    desk.Children.Add(shapes[ind]);

                    shapes[ind].MouseDown += MainWindow_MouseDown;
                    shapes[ind].MouseUp   += MainWindow_MouseUp;
                }
            }
        }