public static TaskBarLocation GetTaskBarLocation() { TaskBarLocation taskBarLocation = TaskBarLocation.Bottom; bool taskBarOnTopOrBottom = (Screen.PrimaryScreen.WorkingArea.Width == Screen.PrimaryScreen.Bounds.Width); if (taskBarOnTopOrBottom) { if (Screen.PrimaryScreen.WorkingArea.Top > 0) { taskBarLocation = TaskBarLocation.Top; } } else { if (Screen.PrimaryScreen.WorkingArea.Left > 0) { taskBarLocation = TaskBarLocation.Left; } else { taskBarLocation = TaskBarLocation.Right; } } return(taskBarLocation); }
private TaskBarLocation GetTaskBarLocation() { TaskBarLocation taskBarLocation = TaskBarLocation.BOTTOM; bool taskBarOnTopOrBottom = (Screen.PrimaryScreen.WorkingArea.Width == Screen.PrimaryScreen.Bounds.Width); if (taskBarOnTopOrBottom) { if (Screen.PrimaryScreen.WorkingArea.Top > 0) { taskBarLocation = TaskBarLocation.TOP; } } else { if (Screen.PrimaryScreen.WorkingArea.Left > 0) { taskBarLocation = TaskBarLocation.LEFT; } else { taskBarLocation = TaskBarLocation.RIGHT; } } return(taskBarLocation); }
public Point GetProgressFormStartingLocation() { TaskBarLocation tbLocation = Utility.GetTaskBarLocation(); Rectangle taskbarRect = Win32.GetTaskbarPosition(); Point position; switch (tbLocation) { case TaskBarLocation.TOP: case TaskBarLocation.LEFT: position = new Point(taskbarRect.Width - this.Width, Screen.PrimaryScreen.Bounds.Height - this.Height); break; case TaskBarLocation.BOTTOM: position = new Point(taskbarRect.Width - this.Width, taskbarRect.Y - this.Height); break; case TaskBarLocation.RIGHT: position = new Point(Screen.PrimaryScreen.Bounds.Width - taskbarRect.Width - this.Width, Screen.PrimaryScreen.Bounds.Height - this.Height); break; default: position = Point.Empty; break; } return(position); }
public static TaskBarLocation GetTaskBarLocation() { TaskBarLocation taskBarLocation = TaskBarLocation.BOTTOM; bool taskBarOnTopOrBottom = (SystemParameters.WorkArea.Width == SystemParameters.PrimaryScreenWidth); if (taskBarOnTopOrBottom) { if (SystemParameters.WorkArea.Top > 0) { taskBarLocation = TaskBarLocation.TOP; } } else { if (SystemParameters.WorkArea.Left > 0) { taskBarLocation = TaskBarLocation.LEFT; } else { taskBarLocation = TaskBarLocation.RIGHT; } } return(taskBarLocation); }
internal static double GetTaskbarHeight(TaskBarLocation location) { switch (location) { case TaskBarLocation.TOP: return(Screen.PrimaryScreen.Bounds.Top - Screen.PrimaryScreen.WorkingArea.Top); case TaskBarLocation.BOTTOM: return(Screen.PrimaryScreen.Bounds.Bottom - Screen.PrimaryScreen.WorkingArea.Bottom); case TaskBarLocation.LEFT: return(Screen.PrimaryScreen.Bounds.Left - Screen.PrimaryScreen.WorkingArea.Left); case TaskBarLocation.RIGHT: return(Screen.PrimaryScreen.Bounds.Right - Screen.PrimaryScreen.WorkingArea.Right); } return(0); }
/// <summary> /// Move window to the right corner depending on the taskbar location /// </summary> private void SetWindowPosition() { TaskBarLocation taskBarLocation = GetTaskBarLocation(); double topPos; switch (taskBarLocation) { case TaskBarLocation.TOP: this.Left = SystemParameters.WorkArea.Right - this.ActualWidth - BorderIndent; topPos = SystemParameters.WorkArea.Top + BorderIndent; this.Top = topPos < 0 ? 0 : topPos; break; case TaskBarLocation.BOTTOM: this.Left = SystemParameters.WorkArea.Right - this.ActualWidth - BorderIndent; topPos = SystemParameters.WorkArea.Bottom - this.ActualHeight - BorderIndent; this.Top = topPos < 0 ? 0 : topPos; break; case TaskBarLocation.LEFT: this.Left = SystemParameters.WorkArea.Left + BorderIndent; topPos = SystemParameters.WorkArea.Bottom - this.ActualHeight - BorderIndent; this.Top = topPos < 0 ? 0 : topPos; break; case TaskBarLocation.RIGHT: this.Left = SystemParameters.WorkArea.Right - this.ActualWidth - BorderIndent; topPos = SystemParameters.WorkArea.Bottom - this.ActualHeight - BorderIndent; this.Top = topPos < 0 ? 0 : topPos; break; } }
public void SetPosition(NotificationPosition n_position) { TaskBarLocation t_position = this.GetTaskBarLocation(); this.StartPosition = FormStartPosition.Manual; if (n_position == NotificationPosition.TOP_LEFT) { if (t_position == TaskBarLocation.LEFT) { this.Left = (Screen.PrimaryScreen.Bounds.Width - Screen.PrimaryScreen.WorkingArea.Width) + 3; } else { this.Left = 3; } if (t_position == TaskBarLocation.TOP) { this.Top = (Screen.PrimaryScreen.Bounds.Height - Screen.PrimaryScreen.WorkingArea.Height) + 3; } else { this.Top = 3; } } else if (n_position == NotificationPosition.BOTTOM_LEFT) { if (t_position == TaskBarLocation.LEFT) { this.Left = (Screen.PrimaryScreen.Bounds.Width - Screen.PrimaryScreen.WorkingArea.Width) + 3; } else { this.Left = 3; } if (t_position == TaskBarLocation.TOP) { this.Top = Screen.PrimaryScreen.Bounds.Height - this.Height - 3; } else { this.Top = Screen.PrimaryScreen.Bounds.Height - (Screen.PrimaryScreen.Bounds.Height - Screen.PrimaryScreen.WorkingArea.Height) - this.Height - 3; } } else if (n_position == NotificationPosition.TOP_RIGHT) { if (t_position == TaskBarLocation.LEFT) { this.Left = Screen.PrimaryScreen.Bounds.Width - this.Width - 3; } else { this.Left = Screen.PrimaryScreen.Bounds.Width - (Screen.PrimaryScreen.Bounds.Width - Screen.PrimaryScreen.WorkingArea.Width) - this.Width - 3; } if (t_position == TaskBarLocation.TOP) { this.Top = (Screen.PrimaryScreen.Bounds.Height - Screen.PrimaryScreen.WorkingArea.Height) + 3; } else { this.Top = 3; } } else { if (t_position == TaskBarLocation.LEFT) { this.Left = Screen.PrimaryScreen.Bounds.Width - this.Width - 3; } else { this.Left = Screen.PrimaryScreen.Bounds.Width - (Screen.PrimaryScreen.Bounds.Width - Screen.PrimaryScreen.WorkingArea.Width) - this.Width - 3; } if (t_position == TaskBarLocation.TOP) { this.Top = Screen.PrimaryScreen.Bounds.Height - this.Height - 3; } else { this.Top = Screen.PrimaryScreen.Bounds.Height - (Screen.PrimaryScreen.Bounds.Height - Screen.PrimaryScreen.WorkingArea.Height) - this.Height - 3; } } }