Esempio n. 1
0
        public Point CulcStartPoint(PlacedWord placedWord, CrossPointInfo info, PlaceDirection direction, Word word)
        {
            Point pointToPlace = new Point();

            Point crossPoint = new Point();

            switch (placedWord.PlaceDirection)
            {
                case PlaceDirection.Horisontal:
                    {
                        crossPoint.X = placedWord.StartPoint.X + info.GetThisCross(placedWord.Word.Number);
                        crossPoint.Y = placedWord.StartPoint.Y;
                        break;
                    }
                case PlaceDirection.Vertiacal:
                    {
                        crossPoint.X = placedWord.StartPoint.X;
                        crossPoint.Y = placedWord.StartPoint.Y + info.GetThisCross(placedWord.Word.Number);
                        break;
                    }
            }

            switch (direction)
            {
                case PlaceDirection.Horisontal:
                    {
                        pointToPlace.X = crossPoint.X - info.GetThisCross(word.Number);
                        pointToPlace.Y = crossPoint.Y;
                        break;
                    }
                case PlaceDirection.Vertiacal:
                    {
                        pointToPlace.X = crossPoint.X;
                        pointToPlace.Y = crossPoint.Y - info.GetThisCross(word.Number);
                        break;
                    }
            }
            return pointToPlace;
        }
Esempio n. 2
0
        public void InsertWord(Word word, PlaceDirection direction, Point startPoint)
        {
            var item = new PlacedWord
            {
                Word = word,
                StartPoint = startPoint,
                PlaceDirection = direction
            };

            switch (item.PlaceDirection)
            {

                case PlaceDirection.Horisontal:
                    {
                        InsertWordHorisontal(word, item.StartPoint);
                        break;
                    }
                case PlaceDirection.Vertiacal:
                    {
                        InsertWordVertical(word, item.StartPoint);
                        break;
                    }
            }

            PlacedWords.Push(item);
        }
Esempio n. 3
0
        public bool CanPlaceWord(PlacedWord placedWord, CrossPointInfo info, PlaceDirection direction, Word word)
        {
            var pointToPlace = CulcStartPoint(placedWord, info, direction, word);


            var result = true;
            switch (direction)
            {
                case PlaceDirection.Horisontal:
                    {
                        for (int index = 0; index < word.Text.Length; index++)
                        {
                            var c = word.Text[index];
                            var internalChar = InternalMatrix[pointToPlace.X + index, pointToPlace.Y];

                            if ((internalChar.Symbol == DefSymbol) || (internalChar.Symbol == c))
                            {
                                continue;
                            }
                            else
                            {
                                result = false;
                            }
                        }
                        break;
                    }

                case PlaceDirection.Vertiacal:
                    {
                        for (int index = 0; index < word.Text.Length; index++)
                        {
                            var c = word.Text[index];
                            var internalChar = InternalMatrix[pointToPlace.X, pointToPlace.Y + index];

                            if ((internalChar.Symbol == DefSymbol) || (internalChar.Symbol == c))
                            {
                                continue;
                            }
                            else
                            {
                                result = false;
                            }
                        }
                        break;

                    }
            }

            return result;
        }