public void EqualityTest()
        {
            BoundingRectangle boundingRectangle = new BoundingRectangle(1, 2, 3, 4);
            BoundingRectangle sameBoundingRectangle = new BoundingRectangle(1, 2, 3, 4);
            BoundingRectangle diffBoundingRectangle = new BoundingRectangle(2, 3, 4, 5);

            Assert.IsTrue(boundingRectangle.Equals(sameBoundingRectangle));
            Assert.IsFalse(boundingRectangle.Equals(diffBoundingRectangle));
            Assert.IsTrue(boundingRectangle == sameBoundingRectangle);
            Assert.IsTrue(boundingRectangle != diffBoundingRectangle);

            object nonBoundingRectangleObject = new object();
            Assert.IsFalse(boundingRectangle.Equals(nonBoundingRectangleObject));

            object boundingRectangleObject = boundingRectangle;
            Assert.IsTrue(boundingRectangle.Equals(boundingRectangleObject));
        }
Esempio n. 2
0
        public void EqualityTest()
        {
            BoundingRectangle boundingRectangle     = new BoundingRectangle(1, 2, 3, 4);
            BoundingRectangle sameBoundingRectangle = new BoundingRectangle(1, 2, 3, 4);
            BoundingRectangle diffBoundingRectangle = new BoundingRectangle(2, 3, 4, 5);

            Assert.IsTrue(boundingRectangle.Equals(sameBoundingRectangle));
            Assert.IsFalse(boundingRectangle.Equals(diffBoundingRectangle));
            Assert.IsTrue(boundingRectangle == sameBoundingRectangle);
            Assert.IsTrue(boundingRectangle != diffBoundingRectangle);

            object nonBoundingRectangleObject = new object();

            Assert.IsFalse(boundingRectangle.Equals(nonBoundingRectangleObject));

            object boundingRectangleObject = boundingRectangle;

            Assert.IsTrue(boundingRectangle.Equals(boundingRectangleObject));
        }
Esempio n. 3
0
        public void Equality(BoundingRectangle boundingRectangle1, BoundingRectangle boundingRectangle2, bool expectedToBeEqual)
        {
            Assert.IsTrue(Equals(boundingRectangle1, boundingRectangle2) == expectedToBeEqual);
            Assert.IsTrue(boundingRectangle1 == boundingRectangle2 == expectedToBeEqual);
            Assert.IsFalse(boundingRectangle1 == boundingRectangle2 != expectedToBeEqual);
            Assert.IsTrue(boundingRectangle1.Equals(boundingRectangle2) == expectedToBeEqual);

            if (expectedToBeEqual)
            {
                Assert.AreEqual(boundingRectangle1.GetHashCode(), boundingRectangle2.GetHashCode());
            }
        }
Esempio n. 4
0
        public void Arrange(BoundingRectangle finalRect)
        {
            if (float.IsNaN(finalRect.Width) || float.IsNaN(finalRect.Height))
            {
                throw new InvalidOperationException("X and Y must be numbers");
            }

            if (float.IsPositiveInfinity(finalRect.Width) || float.IsPositiveInfinity(finalRect.Height))
            {
                throw new InvalidOperationException("X and Y must be less than infinity");
            }

            if (!this.isArrangeValid || !finalRect.Equals(this.previousFinalRect))
            {
                this.ArrangeCore(finalRect);
                this.clip = this.GetClippingRect(finalRect.Size);

                this.previousFinalRect = finalRect;
                this.isArrangeValid    = true;
            }
        }
Esempio n. 5
0
 public void Inequality(BoundingRectangle boundingRectangle, object obj, bool expectedToBeEqual)
 {
     Assert.IsTrue(boundingRectangle.Equals(obj) == expectedToBeEqual);
 }
Esempio n. 6
0
        internal void MoveWordAndCanvasList(IList <WordAndCanvas> wordAndCanvasList)
        {
            if (wordAndCanvasList == null)
            {
                throw new ArgumentNullException(nameof(wordAndCanvasList));
            }
            if (wordAndCanvasList.Count == 0)
            {
                throw new ArgumentException("Zero words in list", nameof(wordAndCanvasList));
            }

            // If bounding rectangle is updated, need to redraw background grid
            BoundingRectangle r = viewModel.Layout.Bounds;

            if (!r.Equals(gridBounding))
            {
                UpdateBackgroundGrid();
            }

            // Compute distance moved on 1st element to choose animation speed (duration)
            WordPosition wp1      = wordAndCanvasList.First().WordPosition;
            WordCanvas   wc1      = wordAndCanvasList.First().WordCanvas;
            double       deltaX   = (double)wc1.GetValue(Canvas.LeftProperty) - wp1.StartColumn * UnitSize;
            double       deltaY   = (double)wc1.GetValue(Canvas.TopProperty) - wp1.StartRow * UnitSize;
            double       distance = Math.Sqrt(deltaX * deltaX + deltaY * deltaY);

            // If distance is null, for instance after a selection click, we're done
            if (distance <= 0.0001)
            {
                return;
            }

            // Group animations in a storyboard to simplify premature ending
            var sb       = new Storyboard();
            var duration = new Duration(TimeSpan.FromSeconds(distance >= UnitSize ? 0.35 : 0.1));

            finalMoveWordAnimationData = new List <(Canvas, DependencyProperty, double)>();
            foreach (WordAndCanvas wac in wordAndCanvasList)
            {
                WordCanvas wc = wac.WordCanvas;

                double          finalLeftValue = wac.WordPosition.StartColumn * UnitSize;
                DoubleAnimation daLeft         = new DoubleAnimation
                {
                    Duration = duration,
                    From     = (double)wc.GetValue(Canvas.LeftProperty),
                    To       = finalLeftValue
                };
                Storyboard.SetTarget(daLeft, wc);
                Storyboard.SetTargetProperty(daLeft, new PropertyPath("Left"));
                sb.Children.Add(daLeft);
                finalMoveWordAnimationData.Add((wc, Canvas.LeftProperty, finalLeftValue));

                double          finalTopValue = wac.WordPosition.StartRow * UnitSize;
                DoubleAnimation daTop         = new DoubleAnimation
                {
                    Duration = duration,
                    From     = (double)wc.GetValue(Canvas.TopProperty),
                    To       = finalTopValue
                };
                Storyboard.SetTarget(daTop, wc);
                Storyboard.SetTargetProperty(daTop, new PropertyPath("Top"));
                sb.Children.Add(daTop);
                finalMoveWordAnimationData.Add((wc, Canvas.TopProperty, finalTopValue));
            }
            IsMoveWordAnimationInProgress = true;
            sb.Completed += Sb_Completed;
            sb.Begin();
        }
        public void AssertThat_Equals_IsFalseForNull()
        {
            var a = new BoundingRectangle(new Vector2(0, 0), new Vector2(10, 10));

            Assert.IsFalse(a.Equals(null));
        }