Example #1
0
        /// <summary>
        /// Construct a maze that fits into the drawing area.
        /// </summary>
        private void CreateMaze()
        {
            this.imageLocations.Clear();
            this.controlLocations.Clear();

            if (this.MazeForm == null)
            {
                painter.CreateMaze(null);
            }
            else
            {
                painter.CreateMaze(this.MazeForm.MakeReservedAreas);

                // Note: In the designer, the MazeForm property is not valid.
                if (allowUpdates)
                {
                    this.MazeForm.UpdateStatusLine();
                    this.MazeForm.UpdateCaption();
                }
            }
        }
        /// <summary>
        /// Creates a new maze.
        /// </summary>
        public void OnNew(object sender, EventArgs e)
        {
            #region Set up the painter.

            painter.Setup();

            int squareWidth;
            int pathWidth;
            int wallWidth;
            MazePainter.SuggestWidths(painter.GridWidth, painter.VisibleWalls, out squareWidth, out pathWidth, out wallWidth);

            painter.Setup(squareWidth, wallWidth, pathWidth);

            #endregion

            painter.Reset();
            painter.BlinkingCounter = 0;

            // Create and display a maze.
            painter.CreateMaze(null);
            painter.PaintMaze(null);
        }