Ejemplo n.º 1
0
        protected override Size ArrangeOverride(Size availableSize)
        {
            Size size = new Size(availableSize.Width, availableSize.Height);

            foreach (UIElement element in _backPanel.Children)
            {
                if (element is TextBlock tb)
                {
                    size.Width = tb.DesiredSize.Width;
                    foreach (Line line in _lineContainer.Children)
                    {
                        line.Stroke = tb.Foreground;
                    }
                    _border.HorizontalAlignment = tb.HorizontalAlignment;
                    break;
                }
            }
            _border.Arrange(new Rect(new Point(0.0, 0.0), availableSize));
            if (_cell.Worksheet.Workbook.CanCellOverflow)
            {
                double            width    = Math.Max(availableSize.Width, size.Width);
                RectangleGeometry geometry = new RectangleGeometry();
                geometry.Rect = new Rect(new Point(0.0, 0.0), new Size(width, availableSize.Height));
                base.Clip     = geometry;
            }
            else
            {
                RectangleGeometry geometry2 = new RectangleGeometry();
                geometry2.Rect = new Rect(new Point(0.0, 0.0), availableSize);
                base.Clip      = geometry2;
            }
            return(base.ArrangeOverride(availableSize));
        }
Ejemplo n.º 2
0
        public void MeasureTest_TransformedChild()
        {
            Border    c = new Border();
            Rectangle r = new Rectangle();

            c.Child = r;

            /* give the child a width and height */
            r.Width  = 20;
            r.Height = 20;

            /* and add a render transform to see if it
             * affects either call.  it shouldn't. */
            ScaleTransform s = new ScaleTransform();

            s.ScaleX = s.ScaleY = 2.0;

            r.RenderTransform = s;

            c.Measure(new Size(250, 250));
            c.Arrange(new Rect(0, 0, 250, 250));

            Assert.AreEqual(new Size(20, 20), r.DesiredSize);
            Assert.AreEqual(new Size(20, 20), r.RenderSize);
        }
Ejemplo n.º 3
0
        protected override Size ArrangeOverride(Size arrangeSize)
        {
            ArrangeHeaderAndFooter();
            double printLeftMargin = PrintLeftMargin;
            double printTopMargin  = PrintTopMargin;
            Size   pageSize        = _pageInfo.GetPageSize();

            if ((_printer.Info.Centering == Centering.Horizontal) || (_printer.Info.Centering == Centering.Both))
            {
                double num3 = (_printer.PrintArea.Width - (pageSize.Width * InnerHorizontalZoomFactor)) / 2.0;
                if (num3 < 0.0)
                {
                    num3 = 0.0;
                }
                printLeftMargin += num3;
            }
            if ((_printer.Info.Centering == Centering.Vertical) || (_printer.Info.Centering == Centering.Both))
            {
                double num4 = (_printer.PrintArea.Height - (pageSize.Height * InnerVerticalZoomFactor)) / 2.0;
                if (num4 < 0.0)
                {
                    num4 = 0.0;
                }
                printTopMargin += num4;
            }
            _excel.Arrange(new Rect(new Point(printLeftMargin, printTopMargin), pageSize));
            if (_border != null)
            {
                _border.Arrange(new Rect(new Point(printLeftMargin - 1.0, printTopMargin - 1.0), new Size(pageSize.Width + 1.0, pageSize.Height + 1.0)));
            }
            return(_printer.PageSize);
        }
Ejemplo n.º 4
0
        public async Task When_ProgressRing_Visible()
        {
            const int expectedSize =
#if __ANDROID__
                48;                 //Natively set as 48 for Android; 20 for other platforms
#else
                20;
#endif

            var panel = new StackPanel();
            var ring  = new ProgressRing()
            {
                IsActive = true
            };
            panel.Children.Add(ring);
            var border = new Border();
            border.Child = panel;

            TestServices.WindowHelper.WindowContent = border;
            await TestServices.WindowHelper.WaitForIdle();

            border.Measure(new Size(1000, 1000));
            border.Arrange(new Rect(0, 0, 1000, 1000));

            Assert.AreEqual(expectedSize, Math.Round(ring.ActualHeight));
        }
Ejemplo n.º 5
0
        public void HitTestRenderTransformTest()
        {
            Border parent = new Border {
                Name = "parent", Background = Brushes.Transparent, Height = 400, Width = 400, IsRootElement = true
            };
            Border child = new Border {
                Name = "child", Background = Brushes.Transparent, Height = 200, Width = 200
            };

            parent.Child = child;

            parent.Measure(Size.Infinity);
            parent.Arrange(new Rect(parent.DesiredSize));

            Assert.AreEqual(parent, parent.HitTest(new Point(350, 50)));
            Assert.AreEqual(child, parent.HitTest(new Point(250, 150)));
            Assert.AreEqual(child, parent.HitTest(new Point(150, 250)));
            Assert.AreEqual(parent, parent.HitTest(new Point(50, 350)));

            child.RenderTransform = new ScaleTransform {
                ScaleX = -0.5, ScaleY = 1.5
            };
            child.RenderTransformOrigin = new Point(0.5, 0);

            // Rect(100, 100, 200, 200) * (RenderTransform, RenderTransformOrigin) = Rect(150, 100, 100, 250)

            Assert.AreEqual(parent, parent.HitTest(new Point(100, 50)));
            Assert.AreEqual(child, parent.HitTest(new Point(200, 150)));
            Assert.AreEqual(child, parent.HitTest(new Point(200, 350)));
            Assert.AreEqual(parent, parent.HitTest(new Point(300, 350)));
        }
Ejemplo n.º 6
0
        public void ArrangeTest_ChildUnsetSize()
        {
            Border    c = new Border();
            Rectangle r = new Rectangle();

            c.Child = r;

            /* don't specify a width/height */

            c.Measure(new Size(25, 25));
            Assert.AreEqual(0, r.ActualWidth);
            Assert.AreEqual(0, r.ActualHeight);
            Assert.AreEqual(0, c.ActualWidth);
            Assert.AreEqual(0, c.ActualHeight);
            Assert.AreEqual(new Size(0, 0), r.DesiredSize, "r desired 0");
            Assert.AreEqual(new Size(0, 0), c.DesiredSize, "c desired 0");

            c.Arrange(new Rect(0, 0, 25, 25));

            Assert.AreEqual(25, r.ActualWidth);
            Assert.AreEqual(25, r.ActualHeight);
            Assert.AreEqual(new Size(0, 0), r.DesiredSize, "r desired 1");
            Assert.AreEqual(new Size(25, 25), r.RenderSize, "r render 1");
            Assert.AreEqual(new Size(0, 0), c.DesiredSize, "c desired 1");
            Assert.AreEqual(new Size(25, 25), c.RenderSize, "c render 1");
        }
Ejemplo n.º 7
0
        public override void Draw(DrawingContext context, System.Collections.Generic.IList <IDrawableObject> drawables)
        {
            if (this.Viewport == BoundingRectangle.Empty) // Should this be set?
            {
                this.Viewport = (BoundingRectangle)context.GraphicsDevice.Viewport.TitleSafeArea;
            }

            windowBorder.Measure(new Vector2(Viewport.Width, Viewport.Height));
            windowBorder.Arrange(Viewport);

            BoundingRectangle titleBounds = new BoundingRectangle
            {
                X      = Viewport.X,
                Y      = Viewport.Y,
                Width  = Viewport.Width,
                Height = windowBorder.BorderThickness.Top,
            };

            title.Measure(new Vector2(titleBounds.Width, windowBorder.BorderThickness.Top));
            title.Arrange(titleBounds);

            if (Renderer == null)
            {
                Renderer = new SpriteBatchRenderer(context.GraphicsDevice);
            }

            Renderer.elapsedTime = context.ElapsedTime;
            Renderer.Begin(context);
            windowBorder.Render(Renderer);
            title.Render(Renderer);
            //DebugDraw();
            Renderer.End(context);
        }
Ejemplo n.º 8
0
        public void When_Child_Is_Stretch_With_MaxSize()
        {
            var parentSize = new Windows.Foundation.Size(500, 500);
            var maxSize    = new Windows.Foundation.Size(100, 100);

            var SUT = new Border()
            {
                Width  = parentSize.Width,
                Height = parentSize.Height
            };

            var child = new View()
            {
                MaxWidth  = maxSize.Width,
                MaxHeight = maxSize.Height
            };

            SUT.AddChild(child);

            SUT.Measure(new Windows.Foundation.Size(500, 500));
            var measuredSize = SUT.DesiredSize;

            SUT.Arrange(new Windows.Foundation.Rect(0, 0, 500, 500));

            Assert.AreEqual(parentSize, measuredSize);
            Assert.AreEqual(new Windows.Foundation.Rect((SUT.Width - maxSize.Width) / 2, (SUT.Height - maxSize.Height) / 2, maxSize.Width, maxSize.Height), child.Arranged);
        }
Ejemplo n.º 9
0
        public void ChildlessArrangeTest5()
        {
            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(9, 9);
            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(10, b.ActualWidth);
            Assert.AreEqual(10, b.ActualHeight);
            Assert.AreEqual(9, c.ActualWidth);
            Assert.AreEqual(9, c.ActualHeight);
        }
Ejemplo n.º 10
0
        public void When_Child_Is_Not_Stretch_With_MinSize()
        {
            var parentSize = new Windows.Foundation.Size(500, 500);
            var minSize    = new Windows.Foundation.Size(100, 100);

            var SUT = new Border()
            {
                Width  = parentSize.Width,
                Height = parentSize.Height
            };

            var child = new View()
            {
                MinWidth            = minSize.Width,
                MinHeight           = minSize.Height,
                HorizontalAlignment = HorizontalAlignment.Left,
                VerticalAlignment   = VerticalAlignment.Top
            };

            SUT.AddChild(child);

            SUT.Measure(new Windows.Foundation.Size(500, 500));
            var measuredSize = SUT.DesiredSize;

            SUT.Arrange(new Windows.Foundation.Rect(0, 0, 500, 500));

            Assert.AreEqual(parentSize, measuredSize);
            Assert.AreEqual(new Windows.Foundation.Rect(0, 0, minSize.Width, minSize.Height), child.Arranged);
        }
        protected override BitmapSource RenderFrame(DataRect dataRect, Rect output)
        {
            Grid grid = new Grid();

            grid.RowDefinitions.Add(new RowDefinition {
                Height = new GridLength(1, GridUnitType.Star)
            });
            grid.RowDefinitions.Add(new RowDefinition {
                Height = new GridLength(1, GridUnitType.Star)
            });
            grid.RowDefinitions.Add(new RowDefinition {
                Height = new GridLength(1, GridUnitType.Star)
            });

            TextBlock lt = new TextBlock
            {
                VerticalAlignment   = VerticalAlignment.Top,
                HorizontalAlignment = HorizontalAlignment.Left,
                Text = String.Format("({0},{1})", dataRect.XMin, dataRect.YMax)
            };

            grid.Children.Add(lt);
            Grid.SetRow(lt, 0);

            TextBlock time = new TextBlock
            {
                VerticalAlignment   = VerticalAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Center,
                Text = String.Format("({0})", DateTime.Now.TimeOfDay)
            };

            grid.Children.Add(time);
            Grid.SetRow(time, 1);


            TextBlock rb = new TextBlock
            {
                VerticalAlignment   = VerticalAlignment.Bottom,
                HorizontalAlignment = HorizontalAlignment.Right,
                Text = String.Format("({0},{1})", dataRect.XMax, dataRect.YMin)
            };

            grid.Children.Add(rb);
            Grid.SetRow(rb, 2);
            Border border = new Border();

            border.BorderThickness = new Thickness(3);
            border.BorderBrush     = Brushes.Blue;
            border.Child           = grid;

            RenderTargetBitmap rtb = new RenderTargetBitmap((int)output.Width, (int)output.Height, 96, 96, PixelFormats.Default);

            border.Measure(new Size(output.Width, output.Height));
            border.Arrange(output);
            rtb.Render(border);

            Thread.Sleep(1000);

            return(rtb);
        }
Ejemplo n.º 12
0
        private static Border CreateFrameworkElementForBalanceDragDrop(Category category)
        {
            double margin          = 5;
            Border categoryBalance = new Border();

            categoryBalance.Padding    = new Thickness(margin);
            categoryBalance.Background = new SolidColorBrush(Color.FromArgb(0x80, 0xc1, 0xc1, 0x60));

            TextBlock amountValue = new TextBlock();

            amountValue.Text                = string.Format("{0:C}", category.Balance);
            amountValue.Foreground          = Brushes.Black;
            amountValue.FontSize            = 12;
            amountValue.HorizontalAlignment = HorizontalAlignment.Center;
            amountValue.VerticalAlignment   = VerticalAlignment.Center;
            amountValue.TextAlignment       = TextAlignment.Center;

            FormattedText ft = new FormattedText(amountValue.Text, System.Globalization.CultureInfo.CurrentCulture,
                                                 FlowDirection.LeftToRight, new Typeface(amountValue.FontFamily, amountValue.FontStyle, amountValue.FontWeight,
                                                                                         amountValue.FontStretch), amountValue.FontSize, amountValue.Foreground);

            Rect bounds = new Rect(0, 0, ft.Width, ft.Height);

            bounds.Inflate(margin, margin);

            categoryBalance.Child = amountValue;

            categoryBalance.Width  = bounds.Width;
            categoryBalance.Height = bounds.Height;
            categoryBalance.Arrange(bounds);

            return(categoryBalance);
        }
Ejemplo n.º 13
0
        public void When_Child_Has_Fixed_Size_Smaller_than_Parent()
        {
            var parentSize = new Windows.Foundation.Size(100, 100);
            var childSize  = new Windows.Foundation.Size(500, 500);

            var SUT = new Border()
            {
                Width  = parentSize.Width,
                Height = parentSize.Height
            };

            var child = new View()
            {
                Width  = childSize.Width,
                Height = childSize.Height
            };

            SUT.Child = child;

            SUT.Measure(new Windows.Foundation.Size(100, 100));
            var measuredSize = SUT.DesiredSize;

            SUT.Arrange(new Windows.Foundation.Rect(0, 0, 100, 100));

            Assert.AreEqual(parentSize, measuredSize, $"(parentSize:{parentSize}) != (measuredSize:{measuredSize})");
            var expectedArrange = new Windows.Foundation.Rect(0, 0, parentSize.Width, parentSize.Height);
            var layoutSlot      = LayoutInformation.GetLayoutSlot(child);

            Assert.AreEqual(expectedArrange, layoutSlot, $"(expectedArrange:{expectedArrange}) != (layoutSlot: {layoutSlot})");
        }
        public FrameworkElement_UnloadedMeasure()
        {
            this.InitializeComponent();

            var content = new Border
            {
                Width      = 200,
                Height     = 200,
                Background = new SolidColorBrush(Colors.Red),
                Child      = new TextBlock {
                    Text = "Some text", TextWrapping = TextWrapping.WrapWholeWords, MaxLines = 10
                },
            };

            var _ = Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => {
                myControl.Content = content;
                content.Measure(new Size(10, 100));

                var __ = Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                {
                    myControl.Content = null;
                    content.Width     = 100;
                    content.Height    = 100;
                    content.Child     = new TextBlock {
                        Text = "This should not be visible !!" + new Guid().ToString(), TextWrapping = TextWrapping.WrapWholeWords, MaxLines = 10
                    };
                    content.InvalidateMeasure();
                    content.Measure(new Size(100, 10));
                    content.Arrange(new Rect(0, 0, 100, 100));
                });
            });
        }
Ejemplo n.º 15
0
        public void ArrangeTest_RenderSize_ChildLargerThanFinalRect()
        {
            Border    c = new Border();
            Rectangle r = new Rectangle();

            Assert.AreEqual(new Size(0, 0), r.RenderSize);

            c.Child = r;

            Assert.AreEqual(new Size(0, 0), r.RenderSize);

            r.Width  = 50;
            r.Height = 50;

            Assert.AreEqual(new Size(0, 0), r.RenderSize);

            // we intentionally give border less room to
            // work with than the configured width/height
            // of the child
            c.Measure(new Size(25, 25));

            Assert.AreEqual(new Size(0, 0), r.RenderSize);

            c.Arrange(new Rect(0, 0, 25, 25));

            Assert.AreEqual(new Size(25, 25), r.DesiredSize);
            Assert.AreEqual(new Size(50, 50), r.RenderSize);
        }
Ejemplo n.º 16
0
        public void AlignmentTest()
        {
            Border      b     = new Border();
            Border      b2    = new Border();
            LayoutPoker poker = new LayoutPoker();

            b.Child  = b2;
            b2.Child = poker;
            b.Width  = 50;

            b2.HorizontalAlignment = HorizontalAlignment.Right;
            b2.VerticalAlignment   = VerticalAlignment.Bottom;

            poker.MeasureResult = new Size(20, 20);
            b.Measure(new Size(100, 100));

            Assert.AreEqual(new Size(50, 100), poker.MeasureArg, "poker m arg");
            Assert.AreEqual(new Size(20, 20), poker.DesiredSize, "poker m result");
            Assert.AreEqual(new Size(0, 0), poker.BaseMeasureResult, "poker base result");

            Assert.AreEqual(new Size(50, 20), b.DesiredSize, "b desiredsize");
            Assert.AreEqual(new Size(20, 20), b2.DesiredSize, "b2 desiredsize");

            poker.ArrangeResult = new Size(20, 20);
            b.Arrange(new Rect(0, 0, b.DesiredSize.Width, b.DesiredSize.Height));

            Assert.AreEqual(new Size(20, 20), poker.ArrangeArg, "poker aa");

            Assert.AreEqual(new Rect(0, 0, 20, 20).ToString(), LayoutInformation.GetLayoutSlot(poker).ToString(), "poker slot");
            Assert.AreEqual(new Rect(0, 0, 50, 20).ToString(), LayoutInformation.GetLayoutSlot(b2).ToString(), "b2 slot");
            Assert.AreEqual(new Rect(0, 0, 50, 20).ToString(), LayoutInformation.GetLayoutSlot(b).ToString(), "b slot");
        }
Ejemplo n.º 17
0
        public void ArrangeTest_ChildLargerThanFinalRect3()
        {
            Border c = new Border();
            Canvas r = new Canvas();

            c.Child = r;

            r.Width  = 50;
            r.Height = 50;

            Assert.AreEqual(new Size(0, 0), new Size(r.ActualWidth, r.ActualHeight), "r actual-1");
            Assert.AreEqual(new Size(0, 0), r.RenderSize, "r render-1");

            // we intentionally give border less room to
            // work with than the configured width/height
            // of the child
            c.Measure(new Size(25, 25));

            Assert.AreEqual(new Size(25, 25), r.DesiredSize, "r desired0");
            Assert.AreEqual(new Size(25, 25), c.DesiredSize, "c desired0");
            Assert.AreEqual(new Size(0, 0), new Size(r.ActualWidth, r.ActualHeight), "r actual0");
            Assert.AreEqual(new Size(0, 0), r.RenderSize, "r render");

            c.Arrange(new Rect(0, 0, 25, 25));

            Assert.AreEqual(new Size(25, 25), r.DesiredSize, "r desired1");
            Assert.AreEqual(new Size(25, 25), c.DesiredSize, "c desired1");
            Assert.AreEqual(new Size(50, 50), new Size(r.ActualWidth, r.ActualHeight), "r actual0");
            Assert.AreEqual(new Size(50, 50), r.RenderSize, "r render");
        }
Ejemplo n.º 18
0
        public void BorderHitTestTest()
        {
            Border border = new Border
            {
                Width           = 200,
                Height          = 100,
                BorderThickness = new Thickness(10, 20, 30, 40),
                IsRootElement   = true,
            };

            border.Measure(Size.Infinity);
            border.Arrange(new Rect(border.DesiredSize));

            BackgroundHitTestTest(border, null);
            BorderHitTestTest(border, null);

            border.Background  = Brushes.Transparent;
            border.BorderBrush = null;

            BackgroundHitTestTest(border, border);
            BorderHitTestTest(border, border);

            border.Background  = null;
            border.BorderBrush = Brushes.Transparent;

            BackgroundHitTestTest(border, null);
            BorderHitTestTest(border, border);

            border.Background  = Brushes.Transparent;
            border.BorderBrush = Brushes.Transparent;

            BackgroundHitTestTest(border, border);
            BorderHitTestTest(border, border);
        }
Ejemplo n.º 19
0
 private static void DetermineTextWidthAndHeightWindows8(out double textWidth, out double textHeight, Border border, TextBlock textblock)
 {
     const int bigEnough = 10000;
     border.Measure(new XamlSize(double.PositiveInfinity, double.PositiveInfinity));
     border.Arrange(new Rect(0, 0, bigEnough, bigEnough));
     textWidth = textblock.ActualWidth;
     textHeight = textblock.ActualHeight;
 }
Ejemplo n.º 20
0
        protected override Size ArrangeOverride(Size finalSize)
        {
            Rect rc = new Rect(new Point(), finalSize);

            _border.Arrange(rc);
            _tb.Arrange(rc);
            return(finalSize);
        }
 protected override Size ArrangeOverride(Size finalSize)
 {
     if (border == null)
     {
         return(finalSize);
     }
     border.Arrange(BorderPositionning);
     return(finalSize);
 }
Ejemplo n.º 22
0
        private static void DetermineTextWidthAndHeightWindows8(out double textWidth, out double textHeight, Border border, TextBlock textblock)
        {
            const int bigEnough = 10000;

            border.Measure(new XamlSize(double.PositiveInfinity, double.PositiveInfinity));
            border.Arrange(new Rect(0, 0, bigEnough, bigEnough));
            textWidth  = textblock.ActualWidth;
            textHeight = textblock.ActualHeight;
        }
Ejemplo n.º 23
0
        protected override Size ArrangeOverride(Size finalSize)
        {
            var location = new Point(_adornedElement.RenderSize.Width - finalSize.Width, 0);
            var rect     = new Rect(location, finalSize);

            _tooltip.Arrange(rect);

            return(finalSize);
        }
Ejemplo n.º 24
0
        protected override Size ArrangeOverride(Size finalSize)
        {
            if (_child == null)
            {
                return(base.ArrangeOverride(finalSize));
            }

            _child.Arrange(new Rect(finalSize));
            return(finalSize);
        }
Ejemplo n.º 25
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");
        }
Ejemplo n.º 26
0
        public void CornerRadiusTest()
        {
            Border b = new Border();

            b.CornerRadius = new CornerRadius(20);

            b.Measure(new Size(Double.PositiveInfinity, Double.PositiveInfinity));
            b.Arrange(new Rect(0, 0, b.DesiredSize.Width, b.DesiredSize.Height));
            Assert.AreEqual(new Size(0, 0), b.DesiredSize, "b desired0");
        }
        /// <inheritdoc/>
        protected override Size ArrangeOverride(Size finalSize)
        {
            double width  = border.Width;
            double height = border.Height;

            double x = GetRelativeXBasedOnTerminalDirection(width);
            double y = GetRelativeYBasedOnTerminalDirection(height);

            border.Arrange(new Rect(x, y, width, height));
            return(finalSize);
        }
Ejemplo n.º 28
0
        protected override Size ArrangeOverride(Size finalSize)
        {
            double width  = border.Width;
            double height = border.Height;

            double x = (AdornedNode.Width / 2.0) - (width / 2.0);
            double y = -height - MarginFromNode;

            border.Arrange(new Rect(x, y, width, height));
            return(finalSize);
        }
Ejemplo n.º 29
0
        protected override Size ArrangeOverride(Size finalSize)
        {
            _displayBorder.Arrange(new Rect(new Point(), _displayBorder.DesiredSize));
            //_displayValue.Arrange(new Rect(new Point(), _displayValue.DesiredSize));
            LayoutDisplayPanel();

            _valueTransform.X = _mole.ActualWidth / 2 - _displayValue.ActualWidth / 2;
            _valueTransform.Y = _mole.ActualHeight / 2 - _displayValue.ActualHeight / 2;
            //SetPosition(_rnd.NextDouble() * _maxTransformX, _rnd.NextDouble() * _maxTransformY);
            return(base.ArrangeOverride(finalSize));
        }
Ejemplo n.º 30
0
        public override DocumentPage GetPage(int pageNumber)
        {
            var page = _pages[pageNumber];

            var container = new Border();

            container.Padding = _margin;
            container.Child   = page;
            container.Measure(PageSize);
            container.Arrange(new Rect(PageSize));

            return(new DocumentPage(container));
        }
Ejemplo n.º 31
0
        /// <summary>
        /// Erstellen eines Cursors für die Darstellung während eines Drag-Vorgangs
        /// </summary>
        /// <param name="dragElement"></param>
        /// <returns></returns>
        public static Cursor CreateCursor(Control dragElement)
        {
            // Zur Demo: Border-Control um Kopie des Inhalts des TreeViewItems
            ContentControl cc = new ContentControl();

            cc.Content = (dragElement.DataContext as TreeItem)?.Data;
            cc.Height  = dragElement.ActualHeight;
            cc.Width   = dragElement.ActualWidth;

            // Einstellungen für Rahmen
            Border border = new Border();

            border.Child           = cc;
            border.BorderBrush     = Brushes.Black;
            border.BorderThickness = new Thickness(1);
            border.Padding         = new Thickness(2);
            border.Background      = new SolidColorBrush(Color.FromArgb(230, 190, 230, 230));

            // Größe anpassen
            border.LayoutTransform = new ScaleTransform(0.8, 0.8);

            border.Visibility = Visibility.Visible;
            border.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
            var offset = new Point(0, 0); // Offset zum Mauszeiger, falls gewünscht

            border.Arrange(new Rect(offset, border.DesiredSize));

            RenderTargetBitmap rtb =
                new RenderTargetBitmap(
                    (int)border.DesiredSize.Width + (int)offset.X,
                    (int)border.DesiredSize.Height + (int)offset.Y,
                    96, 96, PixelFormats.Pbgra32);

            rtb.Render(border);


            var encoder = new PngBitmapEncoder();

            encoder.Frames.Add(BitmapFrame.Create(rtb));

            using (var ms = new MemoryStream())
            {
                encoder.Save(ms);
                using (var bmp = new System.Drawing.Bitmap(ms))
                {
                    return(InternalCreateCursor(bmp));
                }
            }
        }