Esempio n. 1
0
        public void Move(WorkArea workArea)
        {
            AllowMove();

            Left   = workArea.Left;
            Top    = workArea.Top;
            Width  = workArea.Width;
            Height = workArea.Height;

            PreventMove();
        }
Esempio n. 2
0
        public static void GetWorkArea(AppBarWindow window, out int screen, out DockEdge edge, out WorkArea initPos, 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);

            initPos = new WorkArea()
            {
                Top    = _active.WorkArea.Top,
                Left   = _active.WorkArea.Left,
                Bottom = _active.WorkArea.Top + 10,
                Right  = _active.WorkArea.Left + 10
            };

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

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

            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 * _active.ScaleX : 0;

            appbarWA.SetWidth(edge, _appbarWidth);

            appbarWA.Offset(_offsetX, _offsetY);
        }
Esempio n. 3
0
        public void SetAppBar(int screen, DockEdge edge, WorkArea windowWA, WorkArea appbarWA)
        {
            if (edge == DockEdge.None)
            {
                throw new ArgumentException("This parameter cannot be set to 'none'.", "edge");
            }

            if (!IsAppBar)
            {
                IsAppBar = true;

                APPBARDATA _data = NewData();

                _callbackID = _data.uCallbackMessage = NativeMethods.RegisterWindowMessage("AppBarMessage");

                NativeMethods.SHAppBarMessage(APPBARMSG.ABM_NEW, ref _data);
            }

            Screen   = screen;
            DockEdge = edge;

            DockAppBar(edge, windowWA, appbarWA);
        }
Esempio n. 4
0
        private void DockAppBar(DockEdge edge, WorkArea windowWA, WorkArea appbarWA)
        {
            APPBARDATA _data = NewData();

            _data.uEdge = (int)edge;
            _data.rc    = new RECT()
            {
                Left   = (int)Math.Round(appbarWA.Left),
                Top    = (int)Math.Round(appbarWA.Top),
                Right  = (int)Math.Round(appbarWA.Right),
                Bottom = (int)Math.Round(appbarWA.Bottom)
            };

            NativeMethods.SHAppBarMessage(APPBARMSG.ABM_QUERYPOS, ref _data);

            NativeMethods.SHAppBarMessage(APPBARMSG.ABM_SETPOS, ref _data);

            appbarWA.Left   = _data.rc.Left;
            appbarWA.Top    = _data.rc.Top;
            appbarWA.Right  = _data.rc.Right;
            appbarWA.Bottom = _data.rc.Bottom;

            AppBarWidth = appbarWA.Width;

            _source = HwndSource.FromHwnd(_data.hWnd);

            Dispatcher.BeginInvoke(DispatcherPriority.ApplicationIdle, (Action)(() =>
            {
                Top = windowWA.Top;
                Left = windowWA.Left;
                Width = windowWA.Width;
                Height = windowWA.Height;

                _source.AddHook(AppBarHook);
            }));
        }
Esempio n. 5
0
        public void SetAppBar(int screen, DockEdge edge, WorkArea windowWA, WorkArea appbarWA)
        {
            if (edge == DockEdge.None)
            {
                throw new ArgumentException("This parameter cannot be set to 'none'.", "edge");
            }

            if (!IsAppBar)
            {
                IsAppBar = true;

                APPBARDATA _data = NewData();

                _callbackID = _data.uCallbackMessage = NativeMethods.RegisterWindowMessage("AppBarMessage");

                NativeMethods.SHAppBarMessage(APPBARMSG.ABM_NEW, ref _data);
            }

            Screen = screen;
            DockEdge = edge;

            DockAppBar(edge, windowWA, appbarWA);
        }
Esempio n. 6
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;
                }
            }
        }
Esempio n. 7
0
        private void DockAppBar(DockEdge edge, WorkArea windowWA, WorkArea appbarWA)
        {
            APPBARDATA _data = NewData();
            _data.uEdge = (int)edge;
            _data.rc = new RECT()
            {
                Left = (int)Math.Round(appbarWA.Left),
                Top = (int)Math.Round(appbarWA.Top),
                Right = (int)Math.Round(appbarWA.Right),
                Bottom = (int)Math.Round(appbarWA.Bottom)
            };

            NativeMethods.SHAppBarMessage(APPBARMSG.ABM_QUERYPOS, ref _data);

            NativeMethods.SHAppBarMessage(APPBARMSG.ABM_SETPOS, ref _data);

            appbarWA.Left = _data.rc.Left;
            appbarWA.Top = _data.rc.Top;
            appbarWA.Right = _data.rc.Right;
            appbarWA.Bottom = _data.rc.Bottom;

            AppBarWidth = appbarWA.Width;

            _source = HwndSource.FromHwnd(_data.hWnd);

            Dispatcher.BeginInvoke(DispatcherPriority.ApplicationIdle, (Action)(() =>
            {
                Top = windowWA.Top;
                Left = windowWA.Left;
                Width = windowWA.Width;
                Height = windowWA.Height;

                _source.AddHook(AppBarHook);
            }));
        }
        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);
        }
        public void SetAppBar(int screen, DockEdge edge, WorkArea windowWA, WorkArea appbarWA, Action callback)
        {
            if (edge == DockEdge.None)
            {
                throw new ArgumentException("This parameter cannot be set to 'none'.", "edge");
            }

            bool _init = false;

            APPBARDATA _data = NewData();

            if (!IsAppBar)
            {
                IsAppBar = _init = true;

                _callbackID = _data.uCallbackMessage = NativeMethods.RegisterWindowMessage("AppBarMessage");

                NativeMethods.SHAppBarMessage(APPBARMSG.ABM_NEW, ref _data);
            }

            Screen = screen;
            DockEdge = edge;
            
            _data.uEdge = (int)edge;
            _data.rc = new RECT()
            {
                Left = (int)Math.Round(appbarWA.Left),
                Top = (int)Math.Round(appbarWA.Top),
                Right = (int)Math.Round(appbarWA.Right),
                Bottom = (int)Math.Round(appbarWA.Bottom)
            };

            NativeMethods.SHAppBarMessage(APPBARMSG.ABM_QUERYPOS, ref _data);

            NativeMethods.SHAppBarMessage(APPBARMSG.ABM_SETPOS, ref _data);

            appbarWA.Left = _data.rc.Left;
            appbarWA.Top = _data.rc.Top;
            appbarWA.Right = _data.rc.Right;
            appbarWA.Bottom = _data.rc.Bottom;

            AppBarWidth = appbarWA.Width;

            Move(windowWA);

            if (_init)
            {
                Task.Delay(500).ContinueWith(_ =>
                {
                    Dispatcher.BeginInvoke(DispatcherPriority.ApplicationIdle, (Action)(() =>
                    {
                        HwndSource.AddHook(AppBarHook);

                        if (callback != null)
                        {
                            callback();
                        }
                    }));
                });
            }
            else if (callback != null)
            {
                callback();
            }
        }
Esempio n. 10
0
        private void DockAppBar(WorkArea workArea, DockEdge edge)
        {
            APPBARDATA _data = NewData();
            _data.uEdge = (int)edge;
            _data.rc = new RECT()
            {
                Left = (int)Math.Round(workArea.Left),
                Top = (int)Math.Round(workArea.Top),
                Right = (int)Math.Round(workArea.Right),
                Bottom = (int)Math.Round(workArea.Bottom)
            };

            NativeMethods.SHAppBarMessage((int)APPBARMSG.ABM_QUERYPOS, ref _data);

            NativeMethods.SHAppBarMessage((int)APPBARMSG.ABM_SETPOS, ref _data);

            Rect _rect = new Rect(
                _data.rc.Left,
                _data.rc.Top,
                (_data.rc.Right - _data.rc.Left),
                (_data.rc.Bottom - _data.rc.Top)
                );

            _hook = new HwndSourceHook(AppBarCallback);
            _source = HwndSource.FromHwnd(_data.hWnd);

            Dispatcher.BeginInvoke(DispatcherPriority.ApplicationIdle, (Action)(() =>
            {                
                Width = _rect.Width;
                Height = _rect.Height;
                Top = _rect.Top;
                Left = _rect.Left;
                
                LocationChanged += AppBarWindow_LocationChanged;
            }));
        }
Esempio n. 11
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;

            if (OS.SupportDPI)
            {
                window.UpdateScale(_screen.ScaleX, _screen.ScaleY, 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 * _screenX;

            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 _oldWidth = appbarWA.Width;
                double _newWidth = _oldWidth * _screenX;
                double _delta    = _newWidth - _oldWidth;

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

                case DockEdge.Right:
                    appbarWA.Left -= _delta;
                    break;
                }
            }
        }
Esempio n. 12
0
        public static WorkArea GetWorkArea(Window window)
        {
            MonitorInfo _screen = GetMonitorFromIndex(Properties.Settings.Default.ScreenIndex);

            PresentationSource _presentationSource = PresentationSource.FromVisual(window);
            double _scaleX = 1 / _presentationSource.CompositionTarget.TransformToDevice.M11;
            double _scaleY = 1 / _presentationSource.CompositionTarget.TransformToDevice.M22;

            WorkArea _workArea = new WorkArea()
            {
                Left = _screen.WorkArea.Left * _scaleX,
                Top = _screen.WorkArea.Top * _scaleY,
                Right = _screen.WorkArea.Right * _scaleX,
                Bottom = _screen.WorkArea.Bottom * _scaleY
            };

            switch (Properties.Settings.Default.DockEdge)
            {
                case DockEdge.Left:
                    _workArea.Right = _workArea.Left + window.ActualWidth;
                    break;

                case DockEdge.Right:
                    _workArea.Left = _workArea.Right - window.ActualWidth;
                    break;
            }

            return _workArea;
        }
Esempio n. 13
0
        private static RegisterInfo GetRegisterInfo(Window window, WorkArea workArea)
        {
            RegisterInfo _regInfo;

            if (_windowDict.ContainsKey(window))
            {
                _regInfo = _windowDict[window];

                if (workArea != null)
                {
                    _regInfo.WorkArea = workArea;
                }
            }
            else
            {
                _regInfo = new RegisterInfo()
                {
                    CallbackID = 0,
                    IsRegistered = false,
                    Window = window,
                    WorkArea = workArea,
                    Edge = DockEdge.Top
                };

                _windowDict.Add(window, _regInfo);
            }

            return _regInfo;
        }
Esempio n. 14
0
        private static void DockAppBar(Window window, WorkArea workArea, DockEdge edge, RegisterInfo regInfo)
        {
            APPBARDATA _appBarData = new APPBARDATA();
            _appBarData.cbSize = Marshal.SizeOf(_appBarData);
            _appBarData.hWnd = new WindowInteropHelper(window).Handle;
            _appBarData.uEdge = (int)edge;

            _appBarData.rc = new RECT()
            {
                Left = (int)Math.Round(workArea.Left),
                Top = (int)Math.Round(workArea.Top),
                Right = (int)Math.Round(workArea.Right),
                Bottom = (int)Math.Round(workArea.Bottom)
            };

            NativeMethods.SHAppBarMessage((int)AppBarMsg.ABM_QUERYPOS, ref _appBarData);

            NativeMethods.SHAppBarMessage((int)AppBarMsg.ABM_SETPOS, ref _appBarData);

            Rect _rect = new Rect(
                _appBarData.rc.Left,
                _appBarData.rc.Top,
                (_appBarData.rc.Right - _appBarData.rc.Left),
                (_appBarData.rc.Bottom - _appBarData.rc.Top)
                );

            window.Dispatcher.BeginInvoke(DispatcherPriority.ApplicationIdle, (Action)(() =>
            {
                window.Width = _rect.Width;
                window.Height = _rect.Height;
                window.Top = _rect.Top;
                window.Left = _rect.Left;

                window.Dispatcher.BeginInvoke(DispatcherPriority.ApplicationIdle, (Action)(() =>
                {
                    Task.Delay(150).ContinueWith(_ =>
                    {
                        regInfo.Hook = new HwndSourceHook(regInfo.WndProc);
                        regInfo.Source = HwndSource.FromHwnd(_appBarData.hWnd);
                        regInfo.Source.AddHook(regInfo.Hook);
                    });
                }));
            }));
        }
Esempio n. 15
0
        public static void SetAppBar(Window window, WorkArea workArea, DockEdge edge)
        {
            RegisterInfo _regInfo = GetRegisterInfo(window, workArea);

            APPBARDATA _appBarData = new APPBARDATA();
            _appBarData.cbSize = Marshal.SizeOf(_appBarData);
            _appBarData.hWnd = new WindowInteropHelper(window).Handle;

            if (edge == DockEdge.None)
            {
                if (_regInfo.IsRegistered)
                {
                    _regInfo.Source.RemoveHook(_regInfo.Hook);

                    NativeMethods.SHAppBarMessage((int)AppBarMsg.ABM_REMOVE, ref _appBarData);

                    _regInfo.IsRegistered = false;
                }

                return;
            }

            if (!_regInfo.IsRegistered)
            {
                _regInfo.IsRegistered = true;
                _regInfo.CallbackID = NativeMethods.RegisterWindowMessage("AppBarMessage");
                _regInfo.Edge = edge;

                _appBarData.uCallbackMessage = _regInfo.CallbackID;

                NativeMethods.SHAppBarMessage((int)AppBarMsg.ABM_NEW, ref _appBarData);
            }

            window.WindowStyle = WindowStyle.None;
            window.ResizeMode = ResizeMode.NoResize;

            DockAppBar(window, workArea, edge, _regInfo);
        }
Esempio n. 16
0
        public void SetAppBar(int screen, DockEdge edge, WorkArea windowWA, WorkArea appbarWA, Action callback)
        {
            if (edge == DockEdge.None)
            {
                throw new ArgumentException("This parameter cannot be set to 'none'.", "edge");
            }

            bool _init = false;

            APPBARDATA _data = NewData();

            if (!IsAppBar)
            {
                IsAppBar = _init = true;

                _callbackID = _data.uCallbackMessage = NativeMethods.RegisterWindowMessage("AppBarMessage");

                NativeMethods.SHAppBarMessage(APPBARMSG.ABM_NEW, ref _data);
            }

            Screen   = screen;
            DockEdge = edge;

            _data.uEdge = (int)edge;
            _data.rc    = new RECT()
            {
                Left   = (int)Math.Round(appbarWA.Left),
                Top    = (int)Math.Round(appbarWA.Top),
                Right  = (int)Math.Round(appbarWA.Right),
                Bottom = (int)Math.Round(appbarWA.Bottom)
            };

            NativeMethods.SHAppBarMessage(APPBARMSG.ABM_QUERYPOS, ref _data);

            NativeMethods.SHAppBarMessage(APPBARMSG.ABM_SETPOS, ref _data);

            appbarWA.Left   = _data.rc.Left;
            appbarWA.Top    = _data.rc.Top;
            appbarWA.Right  = _data.rc.Right;
            appbarWA.Bottom = _data.rc.Bottom;

            AppBarWidth = appbarWA.Width;

            Move(windowWA);

            if (_init)
            {
                Dispatcher.BeginInvoke(DispatcherPriority.ApplicationIdle, (Action)(() =>
                {
                    HwndSource.AddHook(AppBarHook);

                    if (callback != null)
                    {
                        callback();
                    }
                }));
            }
            else if (callback != null)
            {
                callback();
            }
        }
Esempio n. 17
0
        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;

            Monitor _screen = GetMonitorFromIndex(screen);

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

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

            double _uiScale = Framework.Settings.Instance.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 (Framework.Settings.Instance.HighDPISupport)
            {
                windowWA.Left   *= _inverseX;
                windowWA.Top    *= _inverseY;
                windowWA.Right  *= _inverseX;
                windowWA.Bottom *= _inverseY;
            }

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

            double _modifyX = 0d;

            if (
                window.IsAppBar &&
                window.Screen == screen &&
                window.DockEdge == edge &&
                (_screen.WorkArea.Width + window.AppBarWidth) <= _screen.Size.Width
                )
            {
                _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 = Framework.Settings.Instance.XOffset;
            int _offsetY = Framework.Settings.Instance.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 (Framework.Settings.Instance.UseAppBar)
            {
                if (Framework.Settings.Instance.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;
                    }
                }
            }
            else
            {
                switch (edge)
                {
                case DockEdge.Left:
                    appbarWA.Right = appbarWA.Left;
                    break;

                case DockEdge.Right:
                    appbarWA.Left = appbarWA.Right;
                    break;
                }
            }
        }
Esempio n. 18
0
        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);
        }
Esempio n. 19
0
        public void Move(WorkArea workArea)
        {
            AllowMove();

            Left = workArea.Left;
            Top = workArea.Top;
            Width = workArea.Width;
            Height = workArea.Height;

            PreventMove();
        }
Esempio n. 20
0
        public void SetAppBar(WorkArea workArea, DockEdge edge)
        {
            if (edge == DockEdge.None)
            {
                throw new ArgumentException("This parameter cannot be set to 'none'.", "edge");
            }

            APPBARDATA _data = NewData();

            if (!IsAppBar)
            {
                IsAppBar = true;
                DockEdge = edge;

                _callbackID = _data.uCallbackMessage = NativeMethods.RegisterWindowMessage("AppBarMessage");

                NativeMethods.SHAppBarMessage((int)APPBARMSG.ABM_NEW, ref _data);
            }
            
            DockAppBar(workArea, edge);
        }