Esempio n. 1
0
        // Token: 0x0600384A RID: 14410 RVA: 0x000FB61C File Offset: 0x000F981C
        private static void ClipToElement(FrameworkElement element, GeneralTransform transform, ref double horizontalOffset, ref double verticalOffset)
        {
            Geometry clip = VisualTreeHelper.GetClip(element);
            Point    inPoint;
            Point    inPoint2;

            if (clip != null)
            {
                Rect bounds = clip.Bounds;
                inPoint  = new Point(bounds.X, bounds.Y);
                inPoint2 = new Point(bounds.X + bounds.Width, bounds.Y + bounds.Height);
            }
            else
            {
                if (element.ActualWidth == 0.0 && element.ActualHeight == 0.0)
                {
                    return;
                }
                inPoint  = new Point(0.0, 0.0);
                inPoint2 = new Point(element.ActualWidth, element.ActualHeight);
            }
            transform.TryTransform(inPoint, out inPoint);
            transform.TryTransform(inPoint2, out inPoint2);
            horizontalOffset = TextEditorContextMenu.ClipToBounds(inPoint.X, horizontalOffset, inPoint2.X);
            verticalOffset   = TextEditorContextMenu.ClipToBounds(inPoint.Y, verticalOffset, inPoint2.Y);
        }
Esempio n. 2
0
        private static void GetClippedPositionOffsets(TextEditor This, ITextPointer position, LogicalDirection direction, out double horizontalOffset, out double verticalOffset)
        {
            Rect characterRect = position.GetCharacterRect(direction);

            horizontalOffset = characterRect.X;
            verticalOffset   = characterRect.Y + characterRect.Height;
            FrameworkElement frameworkElement = This.TextView.RenderScope as FrameworkElement;

            if (frameworkElement != null)
            {
                GeneralTransform generalTransform = frameworkElement.TransformToAncestor(This.UiScope);
                if (generalTransform != null)
                {
                    TextEditorContextMenu.ClipToElement(frameworkElement, generalTransform, ref horizontalOffset, ref verticalOffset);
                }
            }
            for (Visual visual = This.UiScope; visual != null; visual = (VisualTreeHelper.GetParent(visual) as Visual))
            {
                frameworkElement = (visual as FrameworkElement);
                if (frameworkElement != null)
                {
                    GeneralTransform generalTransform2 = visual.TransformToDescendant(This.UiScope);
                    if (generalTransform2 != null)
                    {
                        TextEditorContextMenu.ClipToElement(frameworkElement, generalTransform2, ref horizontalOffset, ref verticalOffset);
                    }
                }
            }
            PresentationSource presentationSource = PresentationSource.CriticalFromVisual(This.UiScope);
            IWin32Window       win32Window        = presentationSource as IWin32Window;

            if (win32Window != null)
            {
                IntPtr handle = IntPtr.Zero;
                new UIPermission(UIPermissionWindow.AllWindows).Assert();
                try
                {
                    handle = win32Window.Handle;
                }
                finally
                {
                    CodeAccessPermission.RevertAssert();
                }
                NativeMethods.RECT rect = new NativeMethods.RECT(0, 0, 0, 0);
                SafeNativeMethods.GetClientRect(new HandleRef(null, handle), ref rect);
                Point             point             = new Point((double)rect.left, (double)rect.top);
                Point             point2            = new Point((double)rect.right, (double)rect.bottom);
                CompositionTarget compositionTarget = presentationSource.CompositionTarget;
                point  = compositionTarget.TransformFromDevice.Transform(point);
                point2 = compositionTarget.TransformFromDevice.Transform(point2);
                GeneralTransform generalTransform3 = compositionTarget.RootVisual.TransformToDescendant(This.UiScope);
                if (generalTransform3 != null)
                {
                    generalTransform3.TryTransform(point, out point);
                    generalTransform3.TryTransform(point2, out point2);
                    horizontalOffset = TextEditorContextMenu.ClipToBounds(point.X, horizontalOffset, point2.X);
                    verticalOffset   = TextEditorContextMenu.ClipToBounds(point.Y, verticalOffset, point2.Y);
                }
            }
        }