Ejemplo n.º 1
0
        private NativeMethods.RECT CalculateAssignedRC(PresentationSource source)
        {
            Rect   rectElement = new Rect(base.RenderSize);
            Rect   rectRoot    = PointUtil.ElementToRoot(rectElement, this, source);
            Rect   rect        = PointUtil.RootToClient(rectRoot, source);
            IntPtr parent      = UnsafeNativeMethods.GetParent(this._hwnd);

            NativeMethods.RECT rc    = PointUtil.FromRect(rect);
            NativeMethods.RECT rect2 = PointUtil.AdjustForRightToLeft(rc, new HandleRef(null, parent));
            if (!CoreAppContextSwitches.DoNotUsePresentationDpiCapabilityTier2OrGreater)
            {
                rect2 = this.AdjustRectForDpi(rect2);
            }
            return(rect2);
        }
Ejemplo n.º 2
0
        // Translate the layout information assigned to us from the co-ordinate
        // space of this element, through the root visual, to the Win32 client
        // co-ordinate space
        private NativeMethods.RECT CalculateAssignedRC(PresentationSource source)
        {
            Rect rectElement = new Rect(RenderSize);
            Rect rectRoot    = PointUtil.ElementToRoot(rectElement, this, source);
            Rect rectClient  = PointUtil.RootToClient(rectRoot, source);

            // Adjust for Right-To-Left oriented windows
            IntPtr hwndParent = UnsafeNativeMethods.GetParent(_hwnd);

            NativeMethods.RECT rcClient            = PointUtil.FromRect(rectClient);
            NativeMethods.RECT rcClientRTLAdjusted = PointUtil.AdjustForRightToLeft(rcClient, new HandleRef(null, hwndParent));

            if (!CoreAppContextSwitches.DoNotUsePresentationDpiCapabilityTier2OrGreater)
            {
                //Adjust for differences in DPI between _hwnd and hwndParent
                rcClientRTLAdjusted = AdjustRectForDpi(rcClientRTLAdjusted);
            }

            return(rcClientRTLAdjusted);
        }