Пример #1
0
        /// <summary>
        /// Arrange Children based on their set relative position and size.
        /// </summary>
        protected override Size ArrangeOverride(Size finalSize)
        {
            if (Children == null || Children.Count == 0)
            {
                return(finalSize);
            }

            foreach (FrameworkElement child in Children)
            {
                double size = ScatterCanvas.GetSize(child);

                double tempHeight = finalSize.Height * size, tempWidth = finalSize.Width * size;

                if (tempHeight < 0 || tempWidth < 0)
                {
                    continue;
                }

                if ((Stretch)child.GetValue(ScatterViewItem.StretchProperty) == Stretch.None)
                {
                    tempHeight = child.DesiredSize.Height;
                    tempWidth  = child.DesiredSize.Width;
                }

                Point center = ScatterCanvas.GetCenter(child);

                Point pinPoint = ScatterCanvas.GetPinPoint(child);

                Point actualPinPoint = new Point(center.X * finalSize.Width - tempWidth * pinPoint.X, center.Y * finalSize.Height - tempHeight * pinPoint.Y);

                child.Arrange(new Rect(actualPinPoint, new Size(tempWidth, tempHeight)));
            }

            return(finalSize);
        }