Example #1
0
		public void InvalidateArrangeTest ()
		{
			Border b = new Border ();
			LayoutPoker c = new LayoutPoker ();
			Size s = new Size (10,10);
			
			b.Padding = new Thickness (1,1,0,0);
			b.Child = c;
			b.Measure (s);

			Assert.AreEqual (new Size (0,0), c.DesiredSize, "c DesiredSize");
			Assert.AreEqual (new Size (9,9), c.MeasureArg, "c measure args");
			Assert.AreEqual (new Size (1,1), b.DesiredSize, "b DesiredSize");
			Assert.AreEqual (0,b.ActualWidth);
			Assert.AreEqual (0,b.ActualHeight);
			Assert.AreEqual (0,c.ActualWidth);
			Assert.AreEqual (0,c.ActualHeight);
			
			c.ArrangeResult = new Size (20,20);
			b.Arrange (new Rect (0,0,10,10));

			Assert.AreEqual (new Size (0,0), c.DesiredSize, "c DesiredSize");
			Assert.AreEqual (new Size (20,20), c.RenderSize, "c render size");
			Assert.AreEqual (new Size (9,9), c.ArrangeArg, "c measure args");
			Assert.AreEqual (new Size (1,1), b.DesiredSize, "b DesiredSize");
			Assert.AreEqual (new Size (10,10), b.RenderSize, "b render size");
			Assert.AreEqual (new Size (10,10), new Size (b.ActualWidth, b.ActualHeight),"b actual");
			Assert.AreEqual (new Size (20,20), new Size (c.ActualWidth, c.ActualHeight), "c actual");

			c.ArrangeResult = new Size (9,9);
			b.Arrange (new Rect (0,0,10,10));

			// Does not invalidate child
			b.InvalidateArrange ();

			Assert.AreEqual (new Size (0,0), c.DesiredSize, "c DesiredSize");
			Assert.AreEqual (new Size (20,20), c.RenderSize, "c render size");
			Assert.AreEqual (new Size (9,9), c.ArrangeArg, "c measure args");
			Assert.AreEqual (new Size (1,1), b.DesiredSize, "b DesiredSize");
			Assert.AreEqual (new Size (10,10), b.RenderSize, "b render size");
			Assert.AreEqual (new Size (10,10), new Size (b.ActualWidth, b.ActualHeight),"b actual1");
			Assert.AreEqual (new Size (20,20), new Size (c.ActualWidth, c.ActualHeight), "c actual1");

			c.InvalidateArrange ();
			b.Arrange (new Rect (0,0,10,10));

			Assert.AreEqual (new Size (0,0), c.DesiredSize, "c DesiredSize");
			Assert.AreEqual (new Size (9,9), c.RenderSize, "c render size");
			Assert.AreEqual (new Size (9,9), c.ArrangeArg, "c measure args");
			Assert.AreEqual (new Size (1,1), b.DesiredSize, "b DesiredSize");
			Assert.AreEqual (new Size (10,10), b.RenderSize, "b render size");
			Assert.AreEqual (new Size (10,10), new Size (b.ActualWidth, b.ActualHeight),"b actual2");
			Assert.AreEqual (new Size (9,9), new Size (c.ActualWidth, c.ActualHeight), "c actual2");
		}
Example #2
0
        public CustomDropDown(Canvas anchor, Canvas drop, double _dropHeight)
        {
            wAnchor = new WeakReference<Canvas>(anchor);
            nativePopup = new System.Windows.Controls.Primitives.Popup();
            dropHeight = _dropHeight;

            nativePopup.VerticalOffset = 0;
            nativePopup.HorizontalOffset = 0;

            drop.HorizontalAlignment = HorizontalAlignment.Left;
            drop.VerticalAlignment = VerticalAlignment.Top;

            nativeBorder = new Border();
            nativeBorder.BorderThickness = new System.Windows.Thickness(1);
            nativeBorder.Padding = new System.Windows.Thickness(5);
            nativeBorder.CornerRadius = new CornerRadius(3);
            nativeBorder.BorderBrush = new SolidColorBrush(System.Windows.Media.Color.FromArgb(255, 50, 50, 50));
            nativeBorder.Background = new SolidColorBrush(System.Windows.Media.Color.FromArgb(255, 255, 255, 255));
            nativeBorder.VerticalAlignment = VerticalAlignment.Center;
            nativeBorder.HorizontalAlignment = HorizontalAlignment.Center;

            nativeBorder.Child = drop;
            nativeBorder.InvalidateArrange();

            Canvas canvas = new Canvas();
            canvas.Width = XFPopupConst.SCREEN_WIDTH;
            canvas.Height = XFPopupConst.SCREEN_HEIGHT;
            canvas.Background = new SolidColorBrush(System.Windows.Media.Color.FromArgb(0, 255, 255, 255));

            canvas.Tap += (c, a) => {
                Hide();
            };

            canvas.Children.Add(nativeBorder);

            nativePopup.Child = canvas;
        }
Example #3
0
		public void BorderCallsLayoutTest ()
		{
			var parent = new Border ();
			LayoutPoker c = new LayoutPoker ();
			parent.Child = c;

			c.Width = 50;
			c.Height = 50;
			
			int measure_called = 0;
			int arrange_called = 0;
			c.Measured += (Size real) => { 
				c.MeasureResult = real; 
				measure_called++;
			};
			c.Arranged += (Size real) => {
				c.ArrangeResult = real;
				arrange_called++;
			};

			parent.Measure (new Size (100, 100));
			Assert.AreEqual (0, arrange_called, "arrange called 0");
			Assert.AreEqual (1, measure_called, "measure called 0");

			Assert.AreEqual (new Size (50,50), c.DesiredSize, "c desired");
			Assert.AreEqual (new Size (50,50), parent.DesiredSize, "parent desired");

			parent.Arrange (new Rect (0, 0, 100, 100));

			Assert.AreEqual (1, arrange_called, "arrange called 1");
			Assert.AreEqual (1, measure_called, "measure called 1");

			c.InvalidateMeasure ();
			c.InvalidateArrange ();
			parent.InvalidateArrange ();
			parent.InvalidateMeasure ();
			parent.Arrange (new Rect (0, 0, 100, 100));

			Assert.AreEqual (2, arrange_called, "arrange called 2");
			Assert.AreEqual (2, measure_called, "measure called 2");
		}