コード例 #1
0
        private void Arrange(ILayoutable control)
        {
            if (control.VisualParent is ILayoutable parent)
            {
                Arrange(parent);
            }

            if (!control.IsArrangeValid && control.IsAttachedToVisualTree)
            {
                if (control is IEmbeddedLayoutRoot embeddedRoot)
                {
                    control.Arrange(new Rect(embeddedRoot.AllocatedSize));
                }
                else if (control is ILayoutRoot root)
                {
                    control.Arrange(new Rect(root.DesiredSize));
                }
                else if (control.PreviousArrange != null)
                {
                    // Has been observed that PreviousArrange sometimes is null, probably a bug somewhere else.
                    // Condition observed: control.VisualParent is Scrollbar, control is Border.
                    control.Arrange(control.PreviousArrange.Value);
                }
            }
        }
コード例 #2
0
        private static void ArrangeToFill(ILayoutable layoutable, Size containerSize, Margin margin)
        {
            var containerRect  = new Rect(new Point(0, 0), containerSize);
            var marginsCutout  = margin.AsThickness();
            var withoutMargins = containerRect.Deflate(marginsCutout);

            layoutable.Arrange(withoutMargins);
        }
コード例 #3
0
        private void Arrange(ILayoutable control)
        {
            var root = control as ILayoutRoot;

            if (root != null)
            {
                root.Arrange(new Rect(root.DesiredSize));
            }
            else if (control.PreviousArrange.HasValue)
            {
                control.Arrange(control.PreviousArrange.Value);
            }
        }
コード例 #4
0
        internal void EnsureElementSize(
            Size availableSize,
            VirtualizingLayoutContext context,
            double layoutItemWidth,
            double LayoutItemHeight,
            UniformGridLayoutItemsStretch stretch,
            Orientation orientation,
            double minRowSpacing,
            double minColumnSpacing)
        {
            if (context.ItemCount > 0)
            {
                // If the first element is realized we don't need to cache it or to get it from the context
                var realizedElement = FlowAlgorithm.GetElementIfRealized(0);
                if (realizedElement != null)
                {
                    realizedElement.Measure(availableSize);
                    SetSize(realizedElement, layoutItemWidth, LayoutItemHeight, availableSize, stretch, orientation, minRowSpacing, minColumnSpacing);
                    _cachedFirstElement = null;
                }
                else
                {
                    if (_cachedFirstElement == null)
                    {
                        // we only cache if we aren't realizing it
                        _cachedFirstElement = context.GetOrCreateElementAt(
                            0,
                            ElementRealizationOptions.ForceCreate | ElementRealizationOptions.SuppressAutoRecycle); // expensive
                    }

                    _cachedFirstElement.Measure(availableSize);

                    // This doesn't need to be done in the UWP version and I'm not sure why. If we
                    // don't do this here, and we receive a recycled element then it will be shown
                    // at its previous arrange point, but we don't want it shown at all until its
                    // arranged.
                    _cachedFirstElement.Arrange(new Rect(-10000.0, -10000.0, 0, 0));

                    SetSize(_cachedFirstElement, layoutItemWidth, LayoutItemHeight, availableSize, stretch, orientation, minRowSpacing, minColumnSpacing);

                    // See if we can move ownership to the flow algorithm. If we can, we do not need a local cache.
                    bool added = FlowAlgorithm.TryAddElement0(_cachedFirstElement);
                    if (added)
                    {
                        _cachedFirstElement = null;
                    }
                }
            }
        }
コード例 #5
0
        private void Arrange(ILayoutable control)
        {
            if (control.VisualParent is ILayoutable parent)
            {
                Arrange(parent);
            }

            if (!control.IsArrangeValid && control.IsAttachedToVisualTree)
            {
                if (control is ILayoutRoot root)
                {
                    root.Arrange(new Rect(control.DesiredSize));
                }
                else
                {
                    control.Arrange(control.PreviousArrange.Value);
                }
            }
        }
コード例 #6
0
        private void Arrange(ILayoutable control)
        {
            var root   = control as ILayoutRoot;
            var parent = control.VisualParent as ILayoutable;

            if (root != null)
            {
                root.Arrange(new Rect(root.DesiredSize));
            }
            else if (parent != null)
            {
                Arrange(parent);
            }

            if (control.PreviousArrange.HasValue)
            {
                control.Arrange(control.PreviousArrange.Value);
            }

            _toArrange.Remove(control);
        }
コード例 #7
0
ファイル: LayoutManager.cs プロジェクト: CarlSosaDev/Avalonia
        private void Arrange(ILayoutable control)
        {
            var root = control as ILayoutRoot;
            var parent = control.VisualParent as ILayoutable;

            if (root != null)
            {
                root.Arrange(new Rect(root.DesiredSize));
            }
            else if (parent != null)
            {
                Arrange(parent);
            }

            if (control.PreviousArrange.HasValue)
            {
                control.Arrange(control.PreviousArrange.Value);
            }

            _toArrange.Remove(control);
        }
コード例 #8
0
ファイル: LayoutHelper.cs プロジェクト: soosr/Avalonia
        public static Size ArrangeChild(ILayoutable?child, Size availableSize, Thickness padding)
        {
            child?.Arrange(new Rect(availableSize).Deflate(padding));

            return(availableSize);
        }
コード例 #9
0
ファイル: LayoutManager.cs プロジェクト: alimbada/Perspex
        private void Arrange(ILayoutable control)
        {
            var root = control as ILayoutRoot;

            if (root != null)
            {
                root.Arrange(new Rect(root.DesiredSize));
            }
            else if (control.PreviousArrange.HasValue)
            {
                control.Arrange(control.PreviousArrange.Value);
            }
        }
コード例 #10
0
ファイル: DockPanel.cs プロジェクト: shahid-pk/Perspex
        private static void ArrangeToFill(Size availableSize, Margins margins, ILayoutable layoutable)
        {
            var containerRect = new Rect(new Point(0,0), availableSize);
            var marginsCutout = margins.AsThickness();
            var withoutMargins = containerRect.Deflate(marginsCutout);

            var finalSize = GetConstrainedSize(layoutable, withoutMargins);

            var finalRect = withoutMargins.AlignChild(finalSize, Alignment.Middle, Alignment.Middle);

            layoutable.Arrange(finalRect);
        }