/// <summary> /// Gets the position of the system tray. /// </summary> /// <returns>Tray coordinates.</returns> public static Point GetTrayLocation() { var info = new AppBarInfo(); info.GetSystemTaskBarPosition(); Rectangle rcWorkArea = info.WorkArea; int x = 0, y = 0; if (info.Edge == AppBarInfo.ScreenEdge.Left) { x = rcWorkArea.Left + 2; y = rcWorkArea.Bottom; } else if (info.Edge == AppBarInfo.ScreenEdge.Bottom) { x = rcWorkArea.Right; y = rcWorkArea.Bottom; } else if (info.Edge == AppBarInfo.ScreenEdge.Top) { x = rcWorkArea.Right; y = rcWorkArea.Top; } else if (info.Edge == AppBarInfo.ScreenEdge.Right) { x = rcWorkArea.Right; y = rcWorkArea.Bottom; } return new Point {X = x, Y = y}; }
/// <summary> /// Gets the position of the system tray. /// </summary> /// <returns>Tray coordinates.</returns> public static Point GetTrayLocation() { var info = new AppBarInfo(); info.GetSystemTaskBarPosition(); Rectangle rcWorkArea = info.WorkArea; int x = 0, y = 0; if (info.Edge == AppBarInfo.ScreenEdge.Left) { x = rcWorkArea.Left + 2; y = rcWorkArea.Bottom; } else if (info.Edge == AppBarInfo.ScreenEdge.Bottom) { x = rcWorkArea.Right; y = rcWorkArea.Bottom; } else if (info.Edge == AppBarInfo.ScreenEdge.Top) { x = rcWorkArea.Right; y = rcWorkArea.Top; } else if (info.Edge == AppBarInfo.ScreenEdge.Right) { x = rcWorkArea.Right; y = rcWorkArea.Bottom; } return(new Point { X = x, Y = y }); }
/// <summary> /// Gets the position of the system tray. /// </summary> /// <returns>Tray coordinates.</returns> public static System.Windows.Point GetTrayLocation() { var info = new AppBarInfo(); //此处的try-catch语句由K.F.Storm添加。当explorer.exe没有启动时,原作者的版本会报错,但豆瓣电台不允许崩溃。 try { info.GetSystemTaskBarPosition(); } catch { } Rectangle rcWorkArea = info.WorkArea; int x = 0, y = 0; if (info.Edge == AppBarInfo.ScreenEdge.Left) { x = rcWorkArea.Left + 2; y = rcWorkArea.Bottom; } else if (info.Edge == AppBarInfo.ScreenEdge.Bottom) { x = rcWorkArea.Right; y = rcWorkArea.Bottom; } else if (info.Edge == AppBarInfo.ScreenEdge.Top) { x = rcWorkArea.Right; y = rcWorkArea.Top; } else if (info.Edge == AppBarInfo.ScreenEdge.Right) { x = rcWorkArea.Right; y = rcWorkArea.Bottom; } return(new Point { X = x, Y = y }.ToWpfPoint()); }
/// <summary> /// Gets the position of the system tray. /// </summary> /// <returns>Tray coordinates.</returns> 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 })); }
/// <summary> /// Gets the position of the system tray. /// </summary> /// <returns>Tray coordinates.</returns> public static Point GetTrayLocation() { var info = new AppBarInfo(); info.GetSystemTaskBarPosition(); Rectangle rcWorkArea = info.WorkArea; int x = 0, y = 0; switch (info.Edge) { case AppBarInfo.ScreenEdge.Left: x = rcWorkArea.Left + 2; y = rcWorkArea.Bottom; break; case AppBarInfo.ScreenEdge.Bottom: x = rcWorkArea.Right; y = rcWorkArea.Bottom; break; case AppBarInfo.ScreenEdge.Top: x = rcWorkArea.Right; y = rcWorkArea.Top; break; case AppBarInfo.ScreenEdge.Right: x = rcWorkArea.Right; y = rcWorkArea.Bottom; break; } return(new Point { X = x, Y = y }); }
/// <summary> /// Gets the position of the system tray. /// </summary> /// <returns>Tray coordinates.</returns> public static Point GetTrayLocation() { var info = new AppBarInfo(); //此处的try-catch语句由K.F.Storm添加。当explorer.exe没有启动时,原作者的版本会报错,但豆瓣电台不允许崩溃。 try { info.GetSystemTaskBarPosition(); } catch { } Rectangle rcWorkArea = info.WorkArea; int x = 0, y = 0; if (info.Edge == AppBarInfo.ScreenEdge.Left) { x = rcWorkArea.Left + 2; y = rcWorkArea.Bottom; } else if (info.Edge == AppBarInfo.ScreenEdge.Bottom) { x = rcWorkArea.Right; y = rcWorkArea.Bottom; } else if (info.Edge == AppBarInfo.ScreenEdge.Top) { x = rcWorkArea.Right; y = rcWorkArea.Top; } else if (info.Edge == AppBarInfo.ScreenEdge.Right) { x = rcWorkArea.Right; y = rcWorkArea.Bottom; } return new Point { X = x, Y = y}; }
/// <summary> /// Gets the position of the system tray. /// </summary> /// <returns>Tray coordinates.</returns> public static Point GetTrayLocation() { int space = 2; AppBarInfo info = new AppBarInfo(); info.GetSystemTaskBarPosition(); Rectangle rcWorkArea = info.WorkArea; int x = 0, y = 0; if (info.Edge == AppBarInfo.ScreenEdge.Left) { x = rcWorkArea.Right + space; y = rcWorkArea.Bottom; } else if (info.Edge == AppBarInfo.ScreenEdge.Bottom) { x = rcWorkArea.Right; y = rcWorkArea.Bottom - rcWorkArea.Height - space; } else if (info.Edge == AppBarInfo.ScreenEdge.Top) { x = rcWorkArea.Right; y = rcWorkArea.Top + rcWorkArea.Height + space; } else if (info.Edge == AppBarInfo.ScreenEdge.Right) { x = rcWorkArea.Right - rcWorkArea.Width - space; y = rcWorkArea.Bottom; } return(GetDeviceCoordinates(new Point { X = x, Y = y })); }