Exemplo n.º 1
0
        public void TestNormalMeasure2()
        {
            TestContentControl contentControl = new TestContentControl();
            TestFinalControl   finalControl   = new TestFinalControl {
                Width  = 100,
                Height = 20,
                Margin = new Thickness(10, 0, 20, 0),
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment   = VerticalAlignment.Top
            };

            contentControl.Content = finalControl;
            // do not set contentControl.Width and Height explicitly
            contentControl.Measure(new Size(80, 80));
            contentControl.Arrange(new Rect(0, 0, 80, 80));
            //
            Assert.AreEqual(new Rect(0, 0, 80, 20), finalControl.RenderSlotRect);
            Assert.AreEqual(new Vector(-15, 0), finalControl.ActualOffset);
            Assert.AreEqual(new Size(100, 20), finalControl.RenderSize);
            Assert.AreEqual(new Size(80, 20), finalControl.DesiredSize);
            Assert.AreEqual(new Rect(25, 0, 50, 20), finalControl.LayoutClip);
            Assert.AreEqual(new Size(80, 80), finalControl.MeasureArgument);
            Assert.AreEqual(new Size(100, 20), finalControl.LastMeasureOverrideArgument); // because Width/Height
            Assert.AreEqual(new Size(0, 0), finalControl.LastMeasureOverrideResult);
            Assert.AreEqual(new Size(100, 20), finalControl.LastArrangeOverrideArgument);
            Assert.AreEqual(new Size(100, 20), finalControl.LastArrangeOverrideResult);
        }
Exemplo n.º 2
0
        public void TestNormalMeasure3()
        {
            TestContentControl contentControl = new TestContentControl();
            TestFinalControl   finalControl   = new TestFinalControl {
                Width  = 100,
                Height = 20,
                Margin = new Thickness(10, -10, 20, 7),
                HorizontalAlignment = HorizontalAlignment.Right,
                VerticalAlignment   = VerticalAlignment.Center
            };

            contentControl.Content = finalControl;
            contentControl.Width   = 70;
            contentControl.Height  = 80;
            contentControl.Measure(new Size(1000, 1000));
            contentControl.Arrange(new Rect(0, 0, 1000, 1000));
            //
            Assert.AreEqual(new Rect(0, 0, 70, 80), finalControl.RenderSlotRect);
            Assert.AreEqual(new Vector(-50, 21), finalControl.ActualOffset);
            Assert.AreEqual(new Size(100, 20), finalControl.RenderSize);
            Assert.AreEqual(new Size(70, 17), finalControl.DesiredSize);
            Assert.AreEqual(new Rect(60, -31, 40, 83), finalControl.LayoutClip);
            Assert.AreEqual(new Size(70, 80), finalControl.MeasureArgument);
            Assert.AreEqual(new Size(100, 20), finalControl.LastMeasureOverrideArgument); // because Width/Height
            Assert.AreEqual(new Size(0, 0), finalControl.LastMeasureOverrideResult);
            Assert.AreEqual(new Size(100, 20), finalControl.LastArrangeOverrideArgument);
            Assert.AreEqual(new Size(100, 20), finalControl.LastArrangeOverrideResult);
        }
Exemplo n.º 3
0
 public void TestNormalMeasure() {
     TestContentControl contentControl = new TestContentControl();
     TestFinalControl finalControl = new TestFinalControl {
         Width = 100,
         Height = 100,
         Margin = new Thickness(10, 0, 20, 0),
         HorizontalAlignment = HorizontalAlignment.Center,
         VerticalAlignment = VerticalAlignment.Top
     };
     contentControl.Content = finalControl;
     contentControl.Width = 80;
     contentControl.Height = 80;
     contentControl.Measure(new Size(80, 80));
     contentControl.Arrange(new Rect(0, 0, 80, 80));
     //
     Assert.AreEqual(new Rect(0, 0, 80, 80), finalControl.RenderSlotRect);
     Assert.AreEqual(new Vector(-15, 0), finalControl.ActualOffset);
     Assert.AreEqual(new Size(100, 100), finalControl.RenderSize);
     Assert.AreEqual(new Size(80, 80), finalControl.DesiredSize);
     Assert.AreEqual(new Rect(25, 0, 50, 80), finalControl.LayoutClip);
     Assert.AreEqual(new Size(80, 80), finalControl.MeasureArgument);
     Assert.AreEqual(new Size(100, 100), finalControl.LastMeasureOverrideArgument); // because Width/Height
     Assert.AreEqual(new Size(0, 0), finalControl.LastMeasureOverrideResult);
     Assert.AreEqual(new Size(100, 100), finalControl.LastArrangeOverrideArgument);
     Assert.AreEqual(new Size(100, 100), finalControl.LastArrangeOverrideResult);
 }