123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
-
- using System.Drawing;
- namespace Hardcodet.Wpf.TaskbarNotification.Interop
- {
-
-
-
- public static class TrayInfo
- {
-
-
-
-
- public static Point GetTrayLocation()
- {
- int space = 2;
- var info = new AppBarInfo();
- info.GetSystemTaskBarPosition();
- Rectangle rcWorkArea = info.WorkArea;
- int x = 0, y = 0;
- switch (info.Edge)
- {
- case AppBarInfo.ScreenEdge.Left:
- x = rcWorkArea.Right + space;
- y = rcWorkArea.Bottom;
- break;
- case AppBarInfo.ScreenEdge.Bottom:
- x = rcWorkArea.Right;
- y = rcWorkArea.Bottom - rcWorkArea.Height - space;
- break;
- case AppBarInfo.ScreenEdge.Top:
- x = rcWorkArea.Right;
- y = rcWorkArea.Top + rcWorkArea.Height + space;
- break;
- case AppBarInfo.ScreenEdge.Right:
- x = rcWorkArea.Right - rcWorkArea.Width - space;
- y = rcWorkArea.Bottom;
- break;
- }
- return GetDeviceCoordinates(new Point {X = x, Y = y});
- }
-
-
-
-
-
-
- public static Point GetDeviceCoordinates(Point point)
- {
- return new Point
- {
- X = (int)(point.X / SystemInfo.DpiFactorX),
- Y = (int)(point.Y / SystemInfo.DpiFactorY)
- };
- }
- }
- }
|