Exemplo n.º 1
0
 /// <summary>
 /// Take all modifyable parameters from the given data object.
 /// </summary>
 /// <param name="data"></param>
 public void TakeParametersFrom(AriadneSettingsData data)
 {
     data.IsArena = true;
     TemplateMazeUserControl.TakeParametersFrom(data);
     DistributeTemplateParameters();
     UpdateCaption();
 }
Exemplo n.º 2
0
        private void DistributeTemplateParameters()
        {
            AriadneSettingsData data = new AriadneSettingsData();

            TemplateMazeUserControl.FillParametersInto(data);

            data.AutoSeed       = false;
            data.AutoGridWidth  = data.AutoPathWidth = false;
            data.AutoMazeHeight = data.AutoMazeWidth = true;
            data.AutoColors     = false;

            // The other MazePainters should not have a local ImageLoader.
            data.LeaveCurrentBackgroundImageLoader = true;
            data.IsArena = true;

            for (int i = 0; i < Items.Count; i++)
            {
                // The last item may use the shared list of recently used images.
                if (i == Items.Count - 1)
                {
                    data.IsArena = false;
                }

                ArenaItem item = Items[i];
                if (item != TemplateItem)
                {
                    item.MazeUserControl.MazePainter.BackgroundImageLoader = TemplateItem.MazeUserControl.MazePainter;
                    item.MazeUserControl.TakeParametersFrom(data);
                    item.Setup(false);
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Take all modifyable parameters from the given data object.
        /// </summary>
        /// <param name="data"></param>
        public void TakeParametersFrom(AriadneSettingsData data)
        {
            // The Auto... flags for Width and Height have already been checked by the MazeUserControl.
            this.xSize = Math.Max(dimensionsObj.MinSize, Math.Min(dimensionsObj.MaxXSize, data.MazeWidth));
            this.ySize = Math.Max(dimensionsObj.MinSize, Math.Min(dimensionsObj.MaxYSize, data.MazeHeight));

            if (!data.AutoSeed)
            {
                this.seed = Math.Max(0, Math.Min(codeObj.SeedLimit - 1, data.Seed));
            }
            else
            {
                Random r = RandomFactory.CreateRandom();
                this.seed = r.Next(codeObj.SeedLimit);
            }
            this.random = RandomFactory.CreateRandom(seed);

            this.reservedAreas.Clear();
            this.reservedAreaShapes.Clear();
            this.outlineShape = null;
            this.embeddedMazeShapes.Clear();
            this.embeddedMazes.Clear();

            this.Irregular    = data.IrregularMaze;
            this.Irregularity = data.Irregularity;

            // Decode(data.Code);
        }
Exemplo n.º 4
0
 /// <summary>
 /// Fill all modifyable parameters into the given data object.
 /// </summary>
 /// <param name="data"></param>
 public void FillParametersInto(AriadneSettingsData data)
 {
     data.MazeWidth     = this.xSize;
     data.MazeHeight    = this.ySize;
     data.Seed          = this.seed;
     data.Code          = this.Code;
     data.IrregularMaze = this.Irregular;
     data.Irregularity  = this.Irregularity;
 }
Exemplo n.º 5
0
        /// <summary>
        /// Reserves areas for the number of images given in the AriadneSettingsData.
        /// </summary>
        /// <param name="data"></param>
        private void ReserveAreasForImages(AriadneSettingsData data)
        {
            int    count       = data.ImageNumber;
            int    displaySize = Math.Min(DisplayRectangle.Width, DisplayRectangle.Height);
            int    minSize     = data.ImageMinSizePct * displaySize / 100;
            int    maxSize     = data.ImageMaxSizePct * displaySize / 100;
            string imageFolder = data.ImageFolder;

            ReserveAreaForImages(count, minSize, maxSize, imageFolder, data.IsArena);
        }
Exemplo n.º 6
0
        private void BuildNewMaze()
        {
            AriadneSettingsData data = new AriadneSettingsData();

            mazeControl.FillParametersInto(data);

            data.AutoSeed        = true;
            data.AutoMazeWidth   = data.AutoMazeHeight = true;
            data.AutoSquareWidth = data.AutoWallWidth = data.AutoPathWidth = true;

            data.GridWidth     = (int)this.gridWidthNumericUpDown.Value;
            data.AutoGridWidth = false;

            data.WallVisibility = (this.visibleCheckBox.Checked ? AriadneSettingsData.WallVisibilityEnum.Always : AriadneSettingsData.WallVisibilityEnum.Never);

            data.VisibleOutlines = true;
            data.AsEmbeddedMaze  = false;

            mazeControl.TakeParametersFrom(data);
            //mazeControl.Setup();
        }
Exemplo n.º 7
0
        /// <summary>
        /// Take all modifyable parameters from the given data object.
        /// </summary>
        /// <param name="data"></param>
        public void TakeParametersFrom(AriadneSettingsData data)
        {
            this.settingsData = data;

            painter.TakeParametersFrom(data);

            // Destroy the current image loader (in case the parameters have changed).
            this.imageLoader = null;

            #region Do the equivalent of Setup() with the modified parameters.

            // CreateMaze()
            MazeForm.MakeReservedAreas(Maze);
            this.ReserveAreasForImages(data);
            this.AddOutlineShape(data);
            Maze.CreateMaze();
            Reset();

            #endregion

            mazeForm.UpdateStatusLine();
            mazeForm.UpdateCaption();
        }
Exemplo n.º 8
0
        private void AddOutlineShape(AriadneSettingsData data)
        {
            Random r = Maze.Random;

            double offCenter = data.OutlineOffCenter / 100.0;
            double size      = data.OutlineSize / 100.0;

            OutlineShape.OutlineShapeBuilder shapeBuilderDelegate = null;

            switch (data.OutlineKind)
            {
            case AriadneSettingsData.OutlineKindEnum.Random:
                shapeBuilderDelegate = OutlineShape.RandomOutlineShapeBuilder(r);
                break;

            case AriadneSettingsData.OutlineKindEnum.Circle:
                shapeBuilderDelegate = OutlineShape.Circle;
                break;

            case AriadneSettingsData.OutlineKindEnum.Diamond:
                shapeBuilderDelegate = OutlineShape.Diamond;
                break;

            case AriadneSettingsData.OutlineKindEnum.Character:
                shapeBuilderDelegate = OutlineShape.Character;
                break;

            case AriadneSettingsData.OutlineKindEnum.Symbol:
                shapeBuilderDelegate = OutlineShape.Symbol;
                break;

            case AriadneSettingsData.OutlineKindEnum.Polygon:
                shapeBuilderDelegate = OutlineShape.Polygon;
                break;

            case AriadneSettingsData.OutlineKindEnum.Function:
                shapeBuilderDelegate = OutlineShape.Function;
                break;

            case AriadneSettingsData.OutlineKindEnum.Bitmap:
                shapeBuilderDelegate = OutlineShape.Bitmap;
                break;

            case AriadneSettingsData.OutlineKindEnum.Tiles:
                shapeBuilderDelegate = OutlineShape.Tiles;
                break;

            case AriadneSettingsData.OutlineKindEnum.Rectangles:
                shapeBuilderDelegate = OutlineShape.Rectangles;
                break;

            case AriadneSettingsData.OutlineKindEnum.Grid:
                shapeBuilderDelegate = OutlineShape.Grid;
                break;

            case AriadneSettingsData.OutlineKindEnum.GridElement:
                shapeBuilderDelegate = OutlineShape.GridElement;
                break;

            case AriadneSettingsData.OutlineKindEnum.Maze:
                shapeBuilderDelegate = OutlineShape.Maze;
                break;

            case AriadneSettingsData.OutlineKindEnum.Lines:
                shapeBuilderDelegate = OutlineShape.Lines;
                break;

            case AriadneSettingsData.OutlineKindEnum.Circles:
                shapeBuilderDelegate = OutlineShape.Circles;
                break;
            }
            if (shapeBuilderDelegate != null)
            {
                OutlineShape shape = OutlineShape.RandomInstance(r, shapeBuilderDelegate, XSize, YSize, offCenter, size);

                if (data.DistortedOutlines)
                {
                    shape = shape.DistortedCopy(r);
                }

                if (data.AsEmbeddedMaze)
                {
                    Maze.AddEmbeddedMaze(shape);
                }
                else
                {
                    Maze.OutlineShape = shape;
                }
            }
        }
Exemplo n.º 9
0
 /// <summary>
 /// Fill all modifyable parameters into the given data object.
 /// </summary>
 /// <param name="data"></param>
 public void FillParametersInto(AriadneSettingsData data)
 {
     painter.FillParametersInto(data);
 }
Exemplo n.º 10
0
        public DetailsDialog(IAriadneSettingsSource target)
            : this()
        {
            this.target = target;

            #region Set the minimum and maximum values of NumericUpDownControls.

            this.squareWidthNumericUpDown.Minimum = MazePainter.MinSquareWidth;
            this.squareWidthNumericUpDown.Maximum = MazePainter.MaxSquareWidth;
            this.pathWidthNumericUpDown.Minimum   = MazePainter.MinPathWidth;
            this.pathWidthNumericUpDown.Maximum   = MazePainter.MaxPathWidth;
            this.wallWidthNumericUpDown.Minimum   = MazePainter.MinWallWidth;
            this.wallWidthNumericUpDown.Maximum   = MazePainter.MaxWallWidth;
            this.gridWidthNumericUpDown.Minimum   = MazePainter.MinGridWidth;
            this.gridWidthNumericUpDown.Maximum   = MazePainter.MaxGridWidth;

            #endregion

            #region Create a data object, fill its contents from the target and add it to the BindingSource.

            this.data = new AriadneSettingsData();

            #region Put the designer's panel settings into the data object.

            data.IrregularMaze = this.irregularMazeCheckBox.Checked;
            data.Irregularity  = (int)this.irregularityNumericUpDown.Value;

            data.WallVisibility = AriadneSettingsData.WallVisibilityEnum.Always;

            data.AutoColors = true;

            // The following settings are already initialized in AriadneSettingsData
            //data.ImageNumber = (int) this.imageNumberNumericUpDown.Value;
            //data.ImageMinSizePct = (int) this.imageMinSizeNumericUpDown.Value;
            //data.ImageMaxSizePct = (int) this.imageMaxSizeNumericUpDown.Value;
            //data.ImageFolder = RegisteredOptions.GetStringSetting(RegisteredOptions.OPT_IMAGE_FOLDER);
            data.ShowBackgroundImage = this.backgroundImageCheckBox.Checked;

            data.OutlineKind       = AriadneSettingsData.OutlineKindEnum.None;
            data.OutlineOffCenter  = (int)this.offCenterNumericUpDown.Value;
            data.OutlineSize       = (int)this.sizeNumericUpDown.Value;
            data.AsEmbeddedMaze    = this.asEmbeddedMazeCheckBox.Checked;
            data.VisibleOutlines   = this.visibleOutlinesCheckBox.Checked;
            data.DistortedOutlines = this.distortedOutlinesCheckBox.Checked;

            #endregion

            target.FillParametersInto(data);

            // When no walls are drawn, the wall width is zero, which would be
            // an invalid setting.
            data.WallWidth = Math.Max(data.WallWidth, MazePainter.MinWallWidth);

            // Select the current OutlineKind radio button.
            foreach (Control control in this.outlineKindPanel.Controls)
            {
                if (typeof(RadioButton).IsAssignableFrom(control.GetType()))
                {
                    RadioButton button = (RadioButton)control;
                    button.Checked = ((AriadneSettingsData.OutlineKindEnum)button.Tag == data.OutlineKind);
                }
            }

            // Select the current WallVisibility radio button.
            foreach (Control control in this.wallVisibilityGroupBox.Controls)
            {
                if (typeof(RadioButton).IsAssignableFrom(control.GetType()))
                {
                    RadioButton button = (RadioButton)control;
                    button.Checked = ((AriadneSettingsData.WallVisibilityEnum)button.Tag == data.WallVisibility);
                }
            }

            CalculateResultingArea();

            data.AutoSquareWidth = data.AutoPathWidth = data.AutoWallWidth = data.AutoGridWidth = true;
            data.AutoMazeWidth   = data.AutoMazeHeight = data.AutoSeed = true;
            data.ClearModifedFlags();

            dataBindingSource.DataSource = data;

            #endregion
        }
Exemplo n.º 11
0
 /// <summary>
 /// Fill all modifyable parameters into the given data object.
 /// </summary>
 /// <param name="data"></param>
 public void FillParametersInto(AriadneSettingsData data)
 {
     TemplateMazeUserControl.FillParametersInto(data);
 }