Пример #1
0
        public Word(Word source)
            : base(source)
        {
            this.beginRotation = source.beginRotation;
            this._hover = source._hover;

            this.wordBottom = new Image();
            this.wordBottom.Margin = source.wordBottom.Margin;
            this.wordBottom.Height = source.wordBottom.Height;
            this.wordBottom.Width = source.wordBottom.Width;

            this.wordTop = new Image();
            this.wordTop.Margin = source.wordTop.Margin;
            this.wordTop.Height = source.wordTop.Height;
            this.wordTop.Width = source.wordTop.Width;

            this.sourceTop = source.sourceTop;
            this.sourceBottom = source.sourceBottom;
            this.wordTop.Source = this.sourceTop;
            this.wordBottom.Source = this.sourceBottom;
            this.Children.Add(this.wordTop);
            this.Children.Add(this.wordBottom);

            long milliseconds = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond;
            this.Name = source.Name + "_dup_" + milliseconds;
        }
Пример #2
0
        private void fusionDetection(Word currentWord, Hand secondHand)
        {
            if (!secondHand.grip)
            {
                foreach (var word in words.ToList())
                {
                    if (word != currentWord)
                    {
                        if ((word.typeWord == "top" && currentWord.typeWord == "bottom") || (currentWord.typeWord == "top" && word.typeWord == "bottom"))
                        {
                            if (ImageTools.getDistance(word, currentWord) < 4000)
                            {
                                //do fusion
                                currentWord.Fusion(word);
                                this.window.canvas.Children.Remove(word);
                                words.Remove(word);
                            }
                        }
                    }

                }
            }
        }
Пример #3
0
 public void Fusion(Word secondWord)
 {
     if(this.typeWord == "top")
     {
         this.wordBottom.Opacity = 1;
         this.sourceBottom = secondWord.sourceBottom;
         this.typeWord = "complete";
     }
     else
         if(this.typeWord == "bottom")
         {
             this.wordTop.Opacity = 1;
             this.sourceTop = secondWord.sourceTop;
             this.typeWord = "complete";
         }
 }
Пример #4
0
        //Return a copy of the word with blank bottom image. Delete top bottom image from current word.
        public Word Duplicate()
        {
            Word top = new Word(this);
            this.wordTop.Opacity = 0;
            this.typeWord = "bottom";
            top.wordBottom.Opacity = 0;
            top.typeWord = "top";

            return top;
        }
Пример #5
0
        // method to manage to zoom detection
        private void zoomDetection(Word word, Hand secondHand)
        {
            //zoom if second hand gripping and without a text attached
            if (secondHand.grip && secondHand.attachedObjectName == "")
            {
                var distance = ImageTools.getDistance(hands.Item1, hands.Item2);
                var difference = distance - Hand.distance;
                var facteur = difference / 1000000 + 1;
                if (difference > 5000 && word.Width * facteur <= Word.MAX_WIDTH)
                {

                    word.Width *= facteur;
                    word.Height *= facteur;
                }
                else
                    if (difference < -5000 && word.Width * facteur >= Word.MIN_WIDTH)
                    {
                        word.Width *= facteur;
                        word.Height *= facteur;
                    }
                Hand.distance = distance;
            }
        }
Пример #6
0
 private void transformationDetection(Word word, Hand secondHand)
 {
     // Detect if both hands are on the word
     if (secondHand.grip && secondHand.attachedObjectName == word.Name)
     {
         if (word.typeWord == "complete")
         {
             Word nouveau = word.Duplicate();
             words.Add(nouveau);
             this.window.canvas.Children.Add(nouveau);
             secondHand.attachedObjectName = nouveau.Name;
         }
     }
 }
Пример #7
0
        // method to manage to rotate detection
        private void rotationDetection(Word word, Hand secondHand)
        {
            //mzoom if second hand open and without a text attached
            if (secondHand.grip && secondHand.attachedObjectName == "")
            {
                double wordRotation = word.beginRotation;

                var newRotation = (wordRotation - ImageTools.getRotation(hands.Item1, hands.Item2)) % 360;
                word.RenderTransform = new RotateTransform(newRotation);
            }
        }
Пример #8
0
        private void moveDetectionWord(Word word, byte which)
        {
            var hand = which == 1 ? hands.Item1 : hands.Item2;
            var secondHand = which == 2 ? hands.Item1 : hands.Item2;

            //if the word is on the bin
            if (ImageTools.isOn(word, bin))
            {
                //if we release the hand on the bin, we delete the word
                if (hand.justReleased)
                {
                    this.window.canvas.Children.Remove(word);
                    words.Remove(word);
                }
                bin.hover = true;
            }

            //if the hand is on the text
            if (ImageTools.isOn(hand, word))
            {
                //detection of grip
                if (hand.justGrip)
                {
                    //we attach the label to the hand until the grip is released
                    hand.attachedObjectName = word.Name;

                    //we savethe current rotation of the word
                    double rotationInDegrees = 0;
                    RotateTransform rotation = word.RenderTransform as RotateTransform;
                    if (rotation != null) // Make sure the transform is actually a RotateTransform
                    {
                        rotationInDegrees = rotation.Angle;
                    }
                    word.beginRotation = rotationInDegrees;
                }
                word.hover = true;
            }

            //moving of the attached text
            if (hand.grip && !hand.pressed && hand.attachedObjectName == word.Name)
            {
                //this is to keep the words inside the canvas
                Point newPos = new Point(hand.x + hand.ActualWidth / 2 - word.ActualWidth / 2, hand.y + hand.ActualHeight / 2 - word.ActualHeight / 2);
                if (newPos.X + word.Width / 2 > 0 && newPos.X - word.Width / 2 < this.window.canvas.Width - word.ActualWidth && newPos.Y > 0 && newPos.Y < this.window.canvas.Height - word.ActualHeight)
                {
                    word.x = newPos.X;
                    word.y = newPos.Y;
                    word.hover = true;
                }
                else
                {
                    hand.attachedObjectName = "";
                }
            }
        }