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;
        }
 public bool IsSameWordsCross(CrossPointInfo toCheck)
 {
     return (Word1Number == toCheck.Word1Number && Word2Number == toCheck.Word2Number);
 }
Exemple #3
0
 public static List<CrossPointInfo> GetCrossInfo(Word word1, Word word2)
 {
     var result = new List<CrossPointInfo>();
     for (int i = 0; i < word1.Text.Length; i++)
     {
         var w1 = word1.Text[i];
         for (int index = 0; index < word2.Text.Length; index++)
         {
             char w2 = word2.Text[index];
             if (w1 == w2)
             {
                 var info = new CrossPointInfo()
                 {
                     Letter = w1,
                     W1Pos = i,
                     W2Pos = index,
                     Word1Number = word1.Number,
                     Word2Number = word2.Number,
                 };
                 result.Add(info);
             }
         }
     }
     return result;
 }
        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;
        }