Beispiel #1
0
        // Incriment cell focus to next available cell or defocus
        private void LetterCell_TextChanged(CustomEntry entry, TextChangedEventArgs e)
        {
            // Check if the character is not empty
            if (!IsCellEmpty(e))
            {
                return;
            }

            // Check if word is complete and correct - if so, defocus and dehighlight
            if (_wordChecker.IsWordCorrect())
            {
                // Update Score
                UpdateScoring();

                if (_focusedLetterCell != null)
                {
                    DeFocusCell();
                    _isPlacedWordSelected = false;
                }
            }
            else
            {
                // Exit if _focusedLetterCell is null
                if (!IsFocusedLetterCellNull())
                {
                    return;
                }

                // Exit if placed word is not selected
                if (!IsFocusedLetterCellNull())
                {
                    return;
                }

                // Change Entry focus to next cell in word
                // Return next cell position
                var nextCellPos = _currentPlacedWord.IncrimentCellPos(_focusedLetterCell.Pos);

                if (nextCellPos != null)
                {
                    // Clear character when selected
                    var letterCell = CrosswordViewModel.Instance().DisplayBoard[nextCellPos.Item2][nextCellPos.Item1];
                    if (letterCell.LetterIn != Char.MinValue)
                    {
                        letterCell.LetterIn = Char.MinValue;
                    }
                    _focusedLetterCell = letterCell;
                }
                else
                {
                    DeFocusCell();
                    _isPlacedWordSelected = false;
                }

                if (nextCellPos != null)
                {
                    CrosswordViewModel.Instance().DisplayBoard[nextCellPos.Item2][nextCellPos.Item1].CellEntry.Focus();
                }
            }
        }
Beispiel #2
0
 public static void ResetDisplayBoard()
 {
     CrosswordBoardMain.Instance().ResetBoard();
     CrosswordBoardPlacedWord.Instance().ResetBoard();
     CrosswordViewModel.Instance().AssignCrosswordDisplayBoard(CrosswordBoardMain.Instance().Board, CrosswordBoardPlacedWord.Instance().Board);
     CrosswordViewModel.Instance().Definitions.Clear();
 }
Beispiel #3
0
        private void ButtonRegenBoard_Clicked(object sender, EventArgs e)
        {
            ResetVariables();
            _wordChecker.FoundWords.Clear();
            CrosswordBoardMain.Instance().ResetBoard();
            CrosswordBoardPlacedWord.Instance().ResetBoard();

            MainController.SetupCrosswordPuzzle(CrosswordViewModel.Instance(), CrosswordBoardMain.Instance(), PlacementManager.Instance());
        }
Beispiel #4
0
        public static void SetupCrosswordPuzzle(CrosswordViewModel crosswordViewModel, CrosswordBoardMain crosswordBoardMain, PlacementManager placementManager)
        {
            placementManager.PlaceAllWords();

            crosswordBoardMain.DebugWriteLineBoard(crosswordBoardMain.Board);

            crosswordViewModel.AssignCrosswordDisplayBoard(crosswordBoardMain.Board, CrosswordBoardPlacedWord.Instance().Board);

            crosswordViewModel.AssignDefinitionList(placementManager.Definitions);

            placementManager.ApplyDefinitionNumbersToDisplayBoard(placementManager.GroupedWords, crosswordViewModel.DisplayBoard);
        }
Beispiel #5
0
        public MainController()
        {
            // Grid size 10, MinWordsPlaced = 12
            // Grid size 12, MinWordsPlaced = 15
            // Grid size 14, MinWordsPlaced = 21
            // Grid size 16, MinWordsPlaced = 24

            GridSize       = 12;
            MinWordsPlaced = 15;


            CrosswordBoardMain.Instance().InitializeBoard(GridSize, GridSize, Char.MinValue);
            CrosswordBoardPlacedWord.Instance().InitializeBoard(GridSize, GridSize);
            CrosswordViewModel.Instance().InitializeDisplayBoard(GridSize, GridSize);
        }
Beispiel #6
0
 // Colours word cells
 public void ColourizeSelectedWordCells(Xamarin.Forms.Color color)
 {
     if (Word != null)
     {
         for (var i = 0; i < Word.Length; i++)
         {
             if (Direction == WordDirection.Horizontal)
             {
                 CrosswordViewModel.Instance().DisplayBoard[StartPos.Item2][StartPos.Item1 + i].BackgroundCellColour = color;
             }
             else
             {
                 CrosswordViewModel.Instance().DisplayBoard[StartPos.Item2 + i][StartPos.Item1].BackgroundCellColour = color;
             }
         }
     }
 }
Beispiel #7
0
        public CrosswordView()
        {
            InitializeComponent();

            ResetVariables();

            NavigationPage.SetHasNavigationBar(this, false);

            // Grid Crossword
            mainGrid.Children.Add(GenerateCrosswordGrid(CrosswordViewModel.Instance().DisplayBoard), 1, 1);

            // Definition List
            _defList = GenerateDefinitionList(CrosswordViewModel.Instance().Definitions);
            definitionGrid.Children.Add(_defList, 0, 1);

            ScoreLabel.BindingContext = _score;
            ScoreLabel.SetBinding(Label.TextProperty, new Binding("Value", BindingMode.OneWay, new StringToIntConverter()));
            SizeChanged += OnSizeChanged;
        }
Beispiel #8
0
 private void PrintPlacedWord_Clicked(object sender, EventArgs e)
 {
     CrosswordViewModel.Instance().PrintPlacedWordBoard();
 }
Beispiel #9
0
 private void ButtonSolve_Clicked(object sender, EventArgs e)
 {
     SolveBoard(CrosswordViewModel.Instance().DisplayBoard);
 }
Beispiel #10
0
 private void ButtonPrintList_Clicked(object sender, EventArgs e)
 {
     Debug.WriteLine("Print Board");
     CrosswordViewModel.Instance().PrintBoard();
 }