Esempio n. 1
0
        // (Mouse Move) Assigner un point final lors du mouvement de la souris sur une case.
        private void SetEndingLetter(object sender, MouseEventArgs e)
        {
            Label endLetter = sender as Label;

            // Sauvegarde le endpos au cas que celui qu'on prend est invalide (un encerclement qui n'est pas exactement 90 degres)
            StrikethroughDrawing.CellPosition prevEndpos = new StrikethroughDrawing.CellPosition()
            {
                Row = StrikethroughDrawing.CellLastLetter.Row, Col = StrikethroughDrawing.CellLastLetter.Col
            };

            StrikethroughDrawing.CellLastLetter = new StrikethroughDrawing.CellPosition()
            {
                Row = Grid.GetRow(endLetter), Col = Grid.GetColumn(endLetter)
            };

            // Verifie qu'on a peser sur une case
            if (isCellFirstLetterSelected)
            {
                if (StrikethroughDrawing.ValidatePoints()) // Verifie l'angle de l'entourage
                {
                    AssignPolygonToPoints();               // Si c'est bon, dessine le polygone
                }
                else
                {
                    StrikethroughDrawing.CellLastLetter = prevEndpos;
                }
            }
        }
Esempio n. 2
0
        // Former le mot qui est encerclé
        private string AssembleWord()
        {
            listLettersFormingWord.Clear();

            int wordLength = StrikethroughDrawing.GetWordLength();

            //Determiner le saut requis en Y (soit 1 ou 0)
            int jumpY = (StrikethroughDrawing.CellFirstLetter.Row == StrikethroughDrawing.CellLastLetter.Row ? 0 : 1);

            if (StrikethroughDrawing.CellFirstLetter.Row > StrikethroughDrawing.CellLastLetter.Row)
            {
                jumpY *= -1; // Voir si le saut est à l'envers
            }
            //Determiner le saut requis en X (soit 1 ou 0)
            int jumpX = (StrikethroughDrawing.CellFirstLetter.Col == StrikethroughDrawing.CellLastLetter.Col ? 0 : 1);

            if (StrikethroughDrawing.CellFirstLetter.Col > StrikethroughDrawing.CellLastLetter.Col)
            {
                jumpX *= -1; // Voir si le saut est à l'envers
            }
            string mot = "";

            // Forme le mot
            for (int indexLettre = 0; indexLettre <= wordLength; ++indexLettre)
            {
                // Contruit le nom avec le row et col
                string nom = string.Format("{0}{1:00}{2:00}",
                                           gridLetterNamePrefix, StrikethroughDrawing.CellFirstLetter.Row + indexLettre * jumpY,
                                           StrikethroughDrawing.CellFirstLetter.Col + indexLettre * jumpX);

                // Trouve le nom dans notre grille
                Label letter = (Label)(LogicalTreeHelper.FindLogicalNode(grdLettres, nom));

                //  Retourne rien si on cherche quelquechose d'invalide
                if (letter == null)
                {
                    listLettersFormingWord.Clear(); // Empty la liste.
                    return("");                     // Retounrne du vide.
                }

                // Rajoute la lettre dans notre mot
                mot += letter.Content;

                // Rajoute le dans notre liste
                listLettersFormingWord.Add(letter);
            }
            return(mot);
        }
Esempio n. 3
0
        // Calcul chaque point du polygone.
        private void AssignPolygonToPoints()
        {
            PointCollection points = StrikethroughDrawing.GetPolygonPoints();

            currentPolygon.Points = points;
        }