コード例 #1
0
        private void PositionWindowRelativeToTaskbar(WindowsTaskbar.State taskbar)
        {
            // We're not ready if we don't have a taskbar and monitor. (e.g. RDP transition)
            if (taskbar.ContainingScreen == null)
            {
                return;
            }

            // Force layout so we can be sure lists have created/removed containers.
            UpdateLayout();
            LayoutRoot.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
            double newWidth  = Width * this.DpiX();
            double newHeight = LayoutRoot.DesiredSize.Height * this.DpiY();

            // Distance from corner to offset for each configuration.
            double OffsetX = Addon.Current.Settings.Get("OffsetX", 64);
            double OffsetY = Addon.Current.Settings.Get("OffsetY", 64);

            var resolution = Screen.PrimaryScreen.WorkingArea;

            double x = 0;
            double y = 0;

            switch (Addon.Current.Settings.Get("OverlayPosition", "TopLeft"))
            {
            case "TopLeft":
                x = resolution.Left + OffsetX;
                y = resolution.Top + OffsetY;
                break;

            case "TopRight":
                x = resolution.Right - newWidth - OffsetX;
                y = resolution.Top + OffsetY;
                break;

            case "Center":
                x = ((resolution.Right - resolution.Left - newWidth) / 2) + OffsetX;
                y = ((resolution.Bottom - resolution.Top - newHeight) / 2) + OffsetY;
                break;

            case "BottomLeft":
                x = resolution.Left + OffsetX;
                y = resolution.Bottom - newHeight - OffsetY;
                break;

            case "BottomRight":
                x = resolution.Right - newWidth - OffsetX;
                y = resolution.Bottom - newHeight - OffsetY;
                break;
            }

            this.SetWindowPos(y, x, newHeight, newWidth);
        }
コード例 #2
0
 private void EnableAcrylicIfApplicable(WindowsTaskbar.State taskbar)
 {
     // Note: Enable when in Opening as well as Open in case we get a theme change during a show cycle.
     if (_viewModel.State == FlyoutViewState.Opening || _viewModel.State == FlyoutViewState.Open)
     {
         AccentPolicyLibrary.EnableAcrylic(this, Colors.Transparent, GetAccentFlags(taskbar));
     }
     else
     {
         // Disable to avoid visual issues like showing a pane of acrylic while we're Hidden+cloaked.
         AccentPolicyLibrary.DisableAcrylic(this);
     }
 }
コード例 #3
0
 private void EnableAcrylicIfApplicable(WindowsTaskbar.State taskbar)
 {
     // Note: Enable when in Opening as well as Open in case we get a theme change during a show cycle.
     if (_viewModel.State == FlyoutViewState.Opening || _viewModel.State == FlyoutViewState.Open)
     {
         AccentPolicyLibrary.EnableAcrylic(
             this,
             UI.Themes.Manager.Current.ResolveRef(this, "AcrylicColor_Flyout"),
             User32.AccentFlags.DrawAllBorders);
     }
     else
     {
         // Disable to avoid visual issues like showing a pane of acrylic while we're Hidden+cloaked.
         AccentPolicyLibrary.DisableAcrylic(this);
     }
 }
コード例 #4
0
        private User32.AccentFlags GetAccentFlags(WindowsTaskbar.State taskbar)
        {
            switch (taskbar.Location)
            {
            case WindowsTaskbar.Position.Left:
                return(User32.AccentFlags.DrawRightBorder | User32.AccentFlags.DrawTopBorder);

            case WindowsTaskbar.Position.Right:
                return(User32.AccentFlags.DrawLeftBorder | User32.AccentFlags.DrawTopBorder);

            case WindowsTaskbar.Position.Top:
                return(User32.AccentFlags.DrawLeftBorder | User32.AccentFlags.DrawBottomBorder);

            case WindowsTaskbar.Position.Bottom:
                return(User32.AccentFlags.DrawTopBorder | User32.AccentFlags.DrawLeftBorder);
            }
            return(User32.AccentFlags.None);
        }
コード例 #5
0
        private void PositionWindowRelativeToTaskbar(WindowsTaskbar.State taskbar)
        {
            // We're not ready if we don't have a taskbar and monitor. (e.g. RDP transition)
            if (taskbar.ContainingScreen == null)
            {
                return;
            }

            // Force layout so we can be sure lists have created/removed containers.
            UpdateLayout();
            LayoutRoot.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));

            // WorkArea accounts for normal taskbar and docked windows.
            var maxHeight = taskbar.ContainingScreen.WorkingArea.Height;

            if (taskbar.IsAutoHideEnabled && (taskbar.Location == WindowsTaskbar.Position.Top || taskbar.Location == WindowsTaskbar.Position.Bottom))
            {
                // AutoHide Taskbar won't carve space out for itself, so manually account for the Top or Bottom Taskbar height.
                // Note: Ideally we would open our flyout and 'hold open' the taskbar, but it's not known how to command the Taskbar
                // to stay open for the duration of our window being active.
                maxHeight -= taskbar.Size.Bottom - taskbar.Size.Top;
            }

            double newWidth  = Width * this.DpiX();
            double newHeight = LayoutRoot.DesiredSize.Height * this.DpiY();

            if (newHeight > maxHeight)
            {
                newHeight = maxHeight;
            }

            switch (taskbar.Location)
            {
            case WindowsTaskbar.Position.Left:
                this.SetWindowPos(taskbar.Size.Bottom - newHeight,
                                  taskbar.Size.Right,
                                  newHeight,
                                  newWidth);
                break;

            case WindowsTaskbar.Position.Right:
                this.SetWindowPos(taskbar.Size.Bottom - newHeight,
                                  taskbar.Size.Left - newWidth,
                                  newHeight,
                                  newWidth);
                break;

            case WindowsTaskbar.Position.Top:
                this.SetWindowPos(taskbar.Size.Bottom,
                                  FlowDirection == FlowDirection.RightToLeft ? taskbar.Size.Left : taskbar.Size.Right - newWidth,
                                  newHeight,
                                  newWidth);
                break;

            case WindowsTaskbar.Position.Bottom:
                this.SetWindowPos(taskbar.Size.Top - newHeight,
                                  FlowDirection == FlowDirection.RightToLeft ? taskbar.Size.Left : taskbar.Size.Right - newWidth,
                                  newHeight,
                                  newWidth);
                break;
            }
        }