コード例 #1
0
        public void SetWorkArea(AppBarScreen screen)
        {
            double dpiScale = 1;
            Rect   rc       = GetWorkArea(ref dpiScale, screen, false, true);

            SystemParametersInfo((int)SPI.SETWORKAREA, 1, ref rc, (uint)(SPIF.UPDATEINIFILE | SPIF.SENDWININICHANGE));
        }
コード例 #2
0
        public double GetAppBarEdgeWindowsHeight(AppBarEdge edge, AppBarScreen screen)
        {
            double edgeHeight   = 0;
            double dpiScale     = 1;
            Rect   workAreaRect = GetWorkArea(ref dpiScale, screen, true, true);

            switch (edge)
            {
            case AppBarEdge.Top:
                edgeHeight += (workAreaRect.Top - screen.Bounds.Top) / dpiScale;
                break;

            case AppBarEdge.Bottom:
                edgeHeight += (screen.Bounds.Bottom - workAreaRect.Bottom) / dpiScale;
                break;

            case AppBarEdge.Left:
                edgeHeight += (workAreaRect.Left - screen.Bounds.Left) / dpiScale;
                break;

            case AppBarEdge.Right:
                edgeHeight += (screen.Bounds.Right - workAreaRect.Right) / dpiScale;
                break;
            }

            return(edgeHeight);
        }
コード例 #3
0
        public Rect GetWorkArea(ref double dpiScale, AppBarScreen screen, bool edgeBarsOnly, bool enabledBarsOnly)
        {
            double topEdgeWindowHeight    = 0;
            double bottomEdgeWindowHeight = 0;
            double leftEdgeWindowWidth    = 0;
            double rightEdgeWindowWidth   = 0;
            Rect   rc;

            // get appropriate windows for this display
            foreach (var window in AppBars)
            {
                if (window.Screen.DeviceName == screen.DeviceName)
                {
                    if ((window.EnableAppBar || !enabledBarsOnly) && (window.RequiresScreenEdge || !edgeBarsOnly))
                    {
                        if (window.AppBarEdge == AppBarEdge.Top)
                        {
                            topEdgeWindowHeight += window.ActualHeight;
                        }
                        else if (window.AppBarEdge == AppBarEdge.Bottom)
                        {
                            bottomEdgeWindowHeight += window.ActualHeight;
                        }
                        else if (window.AppBarEdge == AppBarEdge.Left)
                        {
                            leftEdgeWindowWidth += window.ActualWidth;
                        }
                        else if (window.AppBarEdge == AppBarEdge.Right)
                        {
                            rightEdgeWindowWidth += window.ActualWidth;
                        }
                    }

                    dpiScale = window.DpiScale;
                }
            }

            rc.Top    = screen.Bounds.Top + (int)(topEdgeWindowHeight * dpiScale);
            rc.Bottom = screen.Bounds.Bottom - (int)(bottomEdgeWindowHeight * dpiScale);
            rc.Left   = screen.Bounds.Left + (int)(leftEdgeWindowWidth * dpiScale);
            rc.Right  = screen.Bounds.Right - (int)(rightEdgeWindowWidth * dpiScale);

            return(rc);
        }