Example #1
0
        void CreateMazeButtonClick(object sender, EventArgs e)
        {
            try
            {
                int generationAlgoComboboxIndex = mazeGenerationAlgoCombobox.SelectedIndex;
                if (generationAlgoComboboxIndex >= 0)
                {
                    IMazeGenerator selectedGenerator =
                        MazeGeneratorsFactory.Instance.Create(
                            generatorsComboboxValues.ValueByIndex(generationAlgoComboboxIndex));

                    ClearClusters();

                    Stopwatch methodTime = Stopwatch.StartNew();

                    maze = selectedGenerator.Generate(
                        mazeRowsTrackbar.Value,
                        mazeColumnsTrackbar.Value);

                    ShowMaze();

                    methodTime.Stop();
                    DebugConsole.Instance.Info(
                        string.Format("Лабиринт ({0} x {1}) создан и нарисован за {2} мс",
                                      maze.RowCount, maze.ColCount, methodTime.ElapsedMilliseconds));
                }
                else
                {
                    MessageBox.Show("Не выбран алгоритм генерации лабиринта");
                }
            }
            catch (MazeException ex)
            {
                DebugConsole.Instance.Error(
                    string.Format("При создании лабиринта произошла ошибка: {0}",
                                  ex.ToString()));
            }
        }
        private void OKButtonClick(Object sender, EventArgs e)
        {
            int drawerIndex = drawingAlgoCombobox.SelectedIndex;

            if (drawerIndex >= 0)
            {
                drawer = drawersComboboxValues.ValueByIndex(drawerIndex);
            }

            int clustererIndex = clustererCombobox.SelectedIndex;

            if (clustererIndex >= 0)
            {
                clusterer = clustererComboboxValues.ValueByIndex(clustererIndex);
            }

            int rotationIndex = rotationCombobox.SelectedIndex;

            if (rotationIndex >= 0)
            {
                rotation = rotationComboboxValues.ValueByIndex(rotationIndex);
            }

            drawingSettings.CellHeight = (int)cellHeightNumericUpDown.Value;
            drawingSettings.CellWidth  = (int)cellWidthNumericUpDown.Value;

            drawingSettings.BackgroundColor = backgroundColor;
            drawingSettings.BorderColor     = borderColor;
            drawingSettings.SideColor       = sideColor;

            debugLogging = debugLoggingCheckbox.Checked;

            DialogResult = DialogResult.OK;

            Close();
        }