Example #1
0
        private void btnGenerate_Click(object sender, EventArgs e)
        {
            if (txtPassword.Text.Length < 3)
            {
                MessageBox.Show("Password has to contains at least 3 characters.", "Invalid password", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            var type = GetCrosswordType();

            crosswordInformation = new CrosswordInformation(txtPassword.Text, CrosswordType.Simple);

            DialogResult = DialogResult.OK;
        }
Example #2
0
        private void GenerateSimpleCrossword(CrosswordInformation crosswordInformation)
        {
            var elements = GetElementsForCrossword(crosswordInformation);

            MoveElementsOffsetForSimpleCrossword(ref elements);

            var rows    = crosswordInformation.Password.Length;
            var columns = GetNumberOfColumns(elements);

            if (columns > rows)
            {
                rows = columns;
            }

            if (rows > columns)
            {
                columns = rows;
            }

            _board = new Board(rows, columns, elements);
        }
Example #3
0
        private void btnGenerateCrossword_Click(object sender, System.EventArgs e)
        {
            var dialog = new GenerateCrossword();

            if (dialog.ShowDialog() == DialogResult.Cancel)
            {
                return;
            }

            _crosswordInformation = dialog.crosswordInformation;

            try
            {
                _board = _crosswordManager.GenerateCrossword(_crosswordInformation);

                DrawBoard();
                PrepareCellStyles();

                if (_cluesBoard != null)
                {
                    _cluesBoard.Close();
                    _cluesBoard = null;
                }

                CreateClueBoard();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Problem with generating crossword", MessageBoxButtons.OK, MessageBoxIcon.Error);
                btnCheck.Enabled   = false;
                btnCheck.BackColor = DefaultBackColor;

                return;
            }

            btnCheck.Enabled   = true;
            btnCheck.BackColor = Color.LightGreen;
        }
Example #4
0
        public Board GenerateCrossword(CrosswordInformation crosswordInformation)
        {
            _board = null;

            switch (crosswordInformation.Type)
            {
            case CrosswordType.Simple:
                GenerateSimpleCrossword(crosswordInformation);
                break;

            case CrosswordType.Medium:
                GenerateSecondTypeCrossword(crosswordInformation);
                break;

            case CrosswordType.Panoramic:
                GenerateThirdTypeCrossword(crosswordInformation);
                break;

            default:
                throw new Exception("Given crossword type to generate is invalid.");
            }

            return(_board);
        }
Example #5
0
        private CrosswordElement[] GetElementsForCrossword(CrosswordInformation crosswordInformation)
        {
            var elements = new List <CrosswordElement>();

            switch (crosswordInformation.Type)
            {
            case CrosswordType.Simple:
                GetElementsForSimpleCrossword(crosswordInformation.Password, ref elements);
                break;

            case CrosswordType.Medium:
                GetElementsForSecondTypeCrossword(crosswordInformation.Password, ref elements);
                break;

            case CrosswordType.Panoramic:
                GetElementsForThirdTypeCrossword(crosswordInformation.Password, ref elements);
                break;

            default:
                throw new Exception("Given crossword type to generate is invalid.");
            }

            return(elements.ToArray());
        }
Example #6
0
 private void GenerateThirdTypeCrossword(CrosswordInformation crosswordInformation)
 {
     //TODO: Generate panoramic crossword based on a given CrosswordInformation
 }
Example #7
0
 private void GenerateSecondTypeCrossword(CrosswordInformation crosswordInformation)
 {
     //TODO: Generate medium crossword based on a given CrosswordInformation
 }