private void worldCanvas_MouseUp(object sender, MouseButtonEventArgs e)
        {
            int posX = (int)e.GetPosition(worldCanvas).X / ((int)worldCanvas.Width / maze.getWidth());
            int posY = (int)e.GetPosition(worldCanvas).Y / ((int)worldCanvas.Height / maze.getHeight());

            if ((bool)righthandPosRadio.IsChecked)
            {
                if (!maze.isBlock(posX, posY))
                {
                    righthandRunner.setPosition(posX, posY);
                    scene.render();
                }
            }
            else if ((bool)randomPosRadio.IsChecked)
            {
                if (!maze.isBlock(posX, posY))
                {
                    randomRunner.setPosition(posX, posY);
                    scene.render();
                }
            }
            else if ((bool)recursivePosRadio.IsChecked)
            {
                if (!maze.isBlock(posX, posY))
                {
                    recursiveRunner.setPosition(posX, posY);
                    scene.render();
                }
            }
        }
예제 #2
0
        public void drawMaze()
        {
            string[,] blueprint = maze.getBlueprint();
            BitmapImage blockBitmap = new BitmapImage(new Uri("pack://application:,,,/Resources/block.png"));

            for (int i = 0; i < maze.getHeight(); i++)
            {
                for (int j = 0; j < maze.getWidth(); j++)
                {
                    if (blueprint[i, j] == "#")
                    {
                        Image block = new Image();
                        block.Source = blockBitmap;
                        block.Width  = blockBitmap.Width;
                        block.Height = blockBitmap.Height;
                        Canvas.SetLeft(block, 30 * j);
                        Canvas.SetTop(block, 30 * i);
                        worldCanvas.Children.Add(block);
                    }
                }
            }
        }