Inheritance: DPIAwareWindow
Example #1
0
 internal static extern UIntPtr SHAppBarMessage(int dwMessage, ref AppBarWindow.APPBARDATA pData);
        public static void GetWorkArea(AppBarWindow window, out int screen, out DockEdge edge, out WorkArea windowWA, out WorkArea appbarWA)
        {
            screen = Framework.Settings.Instance.ScreenIndex;
            edge = Framework.Settings.Instance.DockEdge;

            double _uiScale = Framework.Settings.Instance.UIScale;

            if (OS.SupportDPI)
            {
                window.UpdateScale(_uiScale, _uiScale, false);
            }

            Monitor[] _monitors = GetMonitors();

            Monitor _primary = _monitors.GetPrimary();            
            Monitor _active = GetMonitorFromIndex(screen, _monitors);

            windowWA = Windows.WorkArea.FromRECT(_active.WorkArea);
            windowWA.Scale(_primary.InverseScaleX, _primary.InverseScaleY);

            double _modifyX = 0d;
            double _modifyY = 0d;

            if (
                window.IsAppBar &&
                window.Screen == screen &&
                window.DockEdge == edge &&
                (_active.WorkArea.Width + window.ActualWidth) <= _active.Size.Width
                )
            {
                _modifyX = window.ActualWidth;

                if (edge == DockEdge.Left)
                {
                    _modifyX *= -1;
                }
            }

            windowWA.Offset(_modifyX, _modifyY);

            double _windowWidth = Framework.Settings.Instance.SidebarWidth * _uiScale;

            windowWA.SetWidth(edge, _windowWidth);
            
            int _offsetX = Framework.Settings.Instance.XOffset;
            int _offsetY = Framework.Settings.Instance.YOffset;

            windowWA.Offset(_offsetX, _offsetY);

            appbarWA = Windows.WorkArea.FromRECT(_active.WorkArea);

            appbarWA.Offset(_modifyX, _modifyY);

            double _appbarWidth = Framework.Settings.Instance.UseAppBar ? windowWA.Width * _primary.ScaleX : 0;

            appbarWA.SetWidth(edge, _appbarWidth);

            appbarWA.Offset(_offsetX, _offsetY);
        }
Example #3
0
        public static void GetWorkArea(AppBarWindow window, out int screen, out DockEdge edge, out WorkArea windowWA, out WorkArea appbarWA)
        {
            screen = Properties.Settings.Default.ScreenIndex;
            edge = Properties.Settings.Default.DockEdge;

            Monitor _screen = GetMonitorFromIndex(screen);

            double _screenX = _screen.ScaleX;
            double _screenY = _screen.ScaleY;

            double _inverseX = _screen.InverseScaleX;
            double _inverseY = _screen.InverseScaleY;

            double _uiScale = Properties.Settings.Default.UIScale;

            double _abScaleX = _screenX * _uiScale;
            double _abScaleY = _screenY * _uiScale;
            
            if (OS.SupportDPI)
            {
                window.UpdateScale(_uiScale, _uiScale, false);
            }

            windowWA = new WorkArea()
            {
                Left = _screen.WorkArea.Left,
                Top = _screen.WorkArea.Top,
                Right = _screen.WorkArea.Right,
                Bottom = _screen.WorkArea.Bottom
            };

            if (Properties.Settings.Default.HighDPISupport)
            {
                windowWA.Left *= _inverseX;
                windowWA.Top *= _inverseY;
                windowWA.Right *= _inverseX;
                windowWA.Bottom *= _inverseY;
            }

            double _windowWidth = Properties.Settings.Default.SidebarWidth * _uiScale;

            double _modifyX = 0d;

            if (window.IsAppBar && window.Screen == screen && window.DockEdge == edge)
            {
                _modifyX = window.AppBarWidth;
            }

            switch (edge)
            {
                case DockEdge.Left:
                    windowWA.Right = windowWA.Left + _windowWidth - _modifyX;
                    windowWA.Left -= _modifyX;
                    break;

                case DockEdge.Right:
                    windowWA.Left = windowWA.Right - _windowWidth + _modifyX;
                    windowWA.Right += _modifyX;
                    break;
            }

            int _offsetX = Properties.Settings.Default.XOffset;
            int _offsetY = Properties.Settings.Default.YOffset;

            windowWA.Left += _offsetX;
            windowWA.Top += _offsetY;
            windowWA.Right += _offsetX;
            windowWA.Bottom += _offsetY;

            appbarWA = new WorkArea()
            {
                Left = windowWA.Left,
                Top = windowWA.Top,
                Right = windowWA.Right,
                Bottom = windowWA.Bottom
            };

            if (Properties.Settings.Default.HighDPISupport)
            {
                double _abWidth = appbarWA.Width * _abScaleX;

                switch (edge)
                {
                    case DockEdge.Left:
                        appbarWA.Right = appbarWA.Left + _abWidth;
                        break;

                    case DockEdge.Right:
                        appbarWA.Left = appbarWA.Right - _abWidth;
                        break;
                }
            }
        }
 internal static extern int DwmSetWindowAttribute(IntPtr hwnd, AppBarWindow.DWMWINDOWATTRIBUTE dwmAttribute, IntPtr pvAttribute, uint cbAttribute);