private LogicalPixelsToDevice ( |
||
logicalPoint | ||
리턴 |
public static Rect LogicalRectToDevice(Rect logicalRectangle) { Point point = DpiHelper.LogicalPixelsToDevice(new Point(logicalRectangle.Left, logicalRectangle.Top)); Point point2 = DpiHelper.LogicalPixelsToDevice(new Point(logicalRectangle.Right, logicalRectangle.Bottom)); return(new Rect(point, point2)); }
// Token: 0x0600002D RID: 45 RVA: 0x00002544 File Offset: 0x00000744 public static Thickness LogicalThicknessToDevice(Thickness logicalThickness, double dpiScaleX, double dpiScaleY) { Point point = DpiHelper.LogicalPixelsToDevice(new Point(logicalThickness.Left, logicalThickness.Top), dpiScaleX, dpiScaleY); Point point2 = DpiHelper.LogicalPixelsToDevice(new Point(logicalThickness.Right, logicalThickness.Bottom), dpiScaleX, dpiScaleY); return(new Thickness(point.X, point.Y, point2.X, point2.Y)); }
public static Size LogicalSizeToDevice(Size logicalSize) { Point point = DpiHelper.LogicalPixelsToDevice(new Point(logicalSize.Width, logicalSize.Height)); return(new Size { Width = point.X, Height = point.Y }); }
public static Size LogicalSizeToDevice(Size logicalSize) { Point device = DpiHelper.LogicalPixelsToDevice(new Point(logicalSize.Width, logicalSize.Height)); Size size = new Size() { Width = device.X, Height = device.Y }; return size; }
public static Thickness LogicalThicknessToDevice(Thickness logicalThickness) { Point device = DpiHelper.LogicalPixelsToDevice(new Point(logicalThickness.Left, logicalThickness.Top)); Point point = DpiHelper.LogicalPixelsToDevice(new Point(logicalThickness.Right, logicalThickness.Bottom)); return new Thickness(device.X, device.Y, point.X, point.Y); }
private static bool _ExtendGlassFrameInternal(Window window, Thickness margin) { Assert.IsNotNull(window); Assert.IsTrue(window.CheckAccess()); // Expect that this might be called on OSes other than Vista. if (!Utility.IsOSVistaOrNewer) { // Not an error. Just not on Vista so we're not going to get glass. return(false); } IntPtr hwnd = new WindowInteropHelper(window).Handle; if (IntPtr.Zero == hwnd) { throw new InvalidOperationException("Window must be shown before extending glass."); } HwndSource hwndSource = HwndSource.FromHwnd(hwnd); bool isGlassEnabled = NativeMethods.DwmIsCompositionEnabled(); if (!isGlassEnabled) { window.Background = SystemColors.WindowBrush; hwndSource.CompositionTarget.BackgroundColor = SystemColors.WindowColor; } else { // Apply the transparent background to both the Window and the HWND window.Background = Brushes.Transparent; hwndSource.CompositionTarget.BackgroundColor = Colors.Transparent; // Thickness is going to be DIPs, need to convert to system coordinates. Point deviceTopLeft = DpiHelper.LogicalPixelsToDevice(new Point(margin.Left, margin.Top)); Point deviceBottomRight = DpiHelper.LogicalPixelsToDevice(new Point(margin.Right, margin.Bottom)); var dwmMargin = new MARGINS { // err on the side of pushing in glass an extra pixel. cxLeftWidth = (int)Math.Ceiling(deviceTopLeft.X), cxRightWidth = (int)Math.Ceiling(deviceBottomRight.X), cyTopHeight = (int)Math.Ceiling(deviceTopLeft.Y), cyBottomHeight = (int)Math.Ceiling(deviceBottomRight.Y), }; NativeMethods.DwmExtendFrameIntoClientArea(hwnd, ref dwmMargin); } // Even if glass isn't currently enabled, add the hook so we can appropriately respond // if that changes. bool addHook = !_extendedWindows.ContainsKey(hwnd); if (addHook) { HwndSourceHook hook = delegate(IntPtr innerHwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled) { if (WM.DWMCOMPOSITIONCHANGED == (WM)msg) { _ExtendGlassFrameInternal(window, margin); handled = false; } return(IntPtr.Zero); }; _extendedWindows.Add(hwnd, hook); hwndSource.AddHook(hook); window.Closing += _OnExtendedWindowClosing; } return(isGlassEnabled); }