示例#1
0
        protected override Size ArrangeOverride(Size finalSize)
        {
            var m = (MatrixTransform)AdornedElement.TransformToVisual(this);

            var p = m.Transform(new Point(0, 0));

            textEditor.Arrange(new Rect(p, AdornedElement.DesiredSize));
            return(finalSize);
        }
示例#2
0
        protected override Size ArrangeOverride(Size finalSize)
        {
            MatrixTransform m = (MatrixTransform)AdornedElement.TransformToVisual(this);

            Rect r = m.TransformBounds(new Rect(new Point(0, 0), AdornedElement.DesiredSize));

            hilightRect.Arrange(r);

            return(finalSize);
        }
        protected override Size ArrangeOverride(Size finalSize)
        {
            //if (Visibility == Visibility.Hidden) return finalSize;
            var ro = new Rect(0, 0, AdornedElement.DesiredSize.Width, AdornedElement.DesiredSize.Height);

            //Rect ro = LayoutInformation.GetLayoutSlot(AdornedElement as FrameworkElement);
            foreach (FrameworkElement control in visualChildren)
            {
                var aligmentRect = new Rect
                {
                    Width  = control.Width,
                    Height = control.Height,
                    Y      = ro.Y, X = ro.X
                };
                switch (control.VerticalAlignment)
                {
                case VerticalAlignment.Top: aligmentRect.Y += 0;
                    break;

                case VerticalAlignment.Bottom: aligmentRect.Y += ro.Height;
                    break;

                case VerticalAlignment.Center: aligmentRect.Y += ro.Height / 2;
                    break;

                case VerticalAlignment.Stretch: aligmentRect.Height = ro.Height;    // *Math.Abs((AdornedElement.RenderTransform as TransformGroup).Children[0].Value.M22);
                    break;

                default:
                    break;
                }
                switch (control.HorizontalAlignment)
                {
                case HorizontalAlignment.Left: aligmentRect.X += 0;
                    break;

                case HorizontalAlignment.Right: aligmentRect.X += ro.Width;
                    break;

                case HorizontalAlignment.Center: aligmentRect.X += ro.Width / 2;
                    break;

                case HorizontalAlignment.Stretch: aligmentRect.Width = ro.Width;    // *Math.Abs((AdornedElement.RenderTransform as TransformGroup).Children[0].Value.M11);
                    break;

                default:
                    break;
                }

                if (control.Cursor == Cursors.SizeAll)
                {
                    control.RenderTransform = AdornedElement.TransformToVisual(this) as System.Windows.Media.MatrixTransform;
                }

                var p = AdornedElement.TranslatePoint(new Point(aligmentRect.X, aligmentRect.Y), this);
                p.X -= control.RenderTransform.Value.OffsetX;
                p.Y -= control.RenderTransform.Value.OffsetY;

                aligmentRect.X = p.X - (double.IsNaN(control.Width) ? 0 : control.Width) / 2;
                aligmentRect.Y = p.Y - (double.IsNaN(control.Height) ? 0 : control.Height) / 2;

                //aligmentRect.X -= (double.IsNaN(control.Width) ? 0 : control.Width) / 2;
                //aligmentRect.Y -= (double.IsNaN(control.Height) ? 0 : control.Height) / 2;
                control.Arrange(aligmentRect);
            }
            return(finalSize);
        }