Пример #1
0
        private void PositionWindowRelativeToTaskbar()
        {
            WindowsTaskbar taskbar = new WindowsTaskbar();

            switch (taskbar.GetTaskBarLocation())
            {
            case WindowsTaskbar.TaskBarLocation.LEFT:
                Left = -WindowsTaskbar.GetTaskbarHeight(taskbar.GetTaskBarLocation());
                Top  = SystemParameters.PrimaryScreenHeight - Height;
                break;

            case WindowsTaskbar.TaskBarLocation.RIGHT:
                Left = SystemParameters.PrimaryScreenWidth - (Width + WindowsTaskbar.GetTaskbarHeight(taskbar.GetTaskBarLocation()));
                Top  = SystemParameters.PrimaryScreenHeight - Height;
                break;

            case WindowsTaskbar.TaskBarLocation.TOP:
                Left = SystemParameters.PrimaryScreenWidth - Width;
                Top  = -WindowsTaskbar.GetTaskbarHeight(taskbar.GetTaskBarLocation());
                break;

            case WindowsTaskbar.TaskBarLocation.BOTTOM:
                Left = SystemParameters.PrimaryScreenWidth - Width;
                Top  = SystemParameters.PrimaryScreenHeight - (Height + WindowsTaskbar.GetTaskbarHeight(taskbar.GetTaskBarLocation()));
                break;
            }
        }
Пример #2
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            WindowsTaskbar taskbar = new WindowsTaskbar();

            PrimaryScreenHeightValue.Content = SystemParameters.PrimaryScreenHeight.ToString();
            PrimaryScreenWidthValue.Content  = SystemParameters.PrimaryScreenWidth.ToString();
            WorkAreaHeightValue.Content      = SystemParameters.WorkArea.Top.ToString();
            WorkAreaWidthValue.Content       = SystemParameters.WorkArea.Left.ToString();
            TopValue.Content        = Top.ToString();
            LeftValue.Content       = Left.ToString();
            TaskbarHeight.Content   = WindowsTaskbar.GetTaskbarHeight(taskbar.GetTaskBarLocation()).ToString();
            TaskbarPosition.Content = taskbar.GetTaskBarLocation().ToString();
        }