예제 #1
0
        public static Point GetDpiScaledCursorPosition()
        {
            var p = Cursor.Position;

            p.X = DpiManager.ConvertPixelsToWpfUnits(p.X);
            p.Y = DpiManager.ConvertPixelsToWpfUnits(p.Y);
            return(p);
        }
예제 #2
0
        public static Point GetDpiScaledGlobalControlPosition(UIElement uiElement)
        {
            var uiPoint = uiElement.PointToScreen(new System.Windows.Point(0, 0));

            var uiDrawPoint = new Point(DpiManager.ConvertPixelsToWpfUnits(uiPoint.X),
                                        DpiManager.ConvertPixelsToWpfUnits(uiPoint.Y));

            return(uiDrawPoint);
        }
예제 #3
0
 public static System.Windows.Media.ImageSource GetIconFromFilePath(string path, int width, int height, uint flags)
 {
     WinApi.ShFileInfo shInfo = new WinApi.ShFileInfo();
     WinApi.SHGetFileInfo(path, 0, ref shInfo, (uint)Marshal.SizeOf(shInfo), flags);
     System.Drawing.Icon entryIcon = System.Drawing.Icon.FromHandle(shInfo.hIcon);
     System.Windows.Media.ImageSource entryIconImageSource = Imaging.CreateBitmapSourceFromHIcon(
         entryIcon.Handle,
         Int32Rect.Empty,
         BitmapSizeOptions.FromWidthAndHeight(Convert.ToInt32(DpiManager.ConvertPixelsToWpfUnits(width)), Convert.ToInt32(DpiManager.ConvertPixelsToWpfUnits(height)))
         );
     return(entryIconImageSource);
 }