GetWorkArea() public static method

public static GetWorkArea ( AppBarWindow window, int &screen, DockEdge &edge, WorkArea &windowWA, WorkArea &appbarWA ) : void
window AppBarWindow
screen int
edge DockEdge
windowWA WorkArea
appbarWA WorkArea
return void
Exemplo n.º 1
0
        private IntPtr AppBarHook(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
        {
            if (msg == _callbackID)
            {
                switch (wParam.ToInt32())
                {
                case APPBARNOTIFY.ABN_POSCHANGED:
                    if (_cancelReposition != null)
                    {
                        _cancelReposition.Cancel();
                    }

                    _cancelReposition = new CancellationTokenSource();

                    Task.Delay(TimeSpan.FromMilliseconds(100), _cancelReposition.Token).ContinueWith(_ =>
                    {
                        if (_.IsCanceled)
                        {
                            return;
                        }

                        Dispatcher.BeginInvoke(DispatcherPriority.Normal, (Action)(() =>
                        {
                            int _screen;
                            DockEdge _edge;
                            WorkArea _windowWA;
                            WorkArea _appbarWA;

                            Monitor.GetWorkArea(this, out _screen, out _edge, out _windowWA, out _appbarWA);

                            SetAppBar(_screen, _edge, _windowWA, _appbarWA, null);
                        }));

                        _cancelReposition = null;
                    });
                    break;

                case APPBARNOTIFY.ABN_FULLSCREENAPP:
                    if (lParam.ToInt32() == 1)
                    {
                        _wasTopMost = IsTopMost;

                        if (IsTopMost)
                        {
                            SetBottom(false);
                        }
                    }
                    else if (_wasTopMost)
                    {
                        SetTopMost(false);
                    }
                    break;
                }

                handled = true;
            }

            return(IntPtr.Zero);
        }
Exemplo n.º 2
0
        private async Task BindAppBar()
        {
            Monitor.GetWorkArea(this, out int screen, out DockEdge edge, out WorkArea initPos, out WorkArea windowWA, out WorkArea appbarWA);

            Move(initPos);

            APPBARDATA _data = NewData();

            _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);

            IsAppBar = true;

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

            AppBarWidth = appbarWA.Width;

            await Dispatcher.BeginInvoke(DispatcherPriority.ApplicationIdle, (Action)(() =>
            {
                Move(windowWA);
            }));

            await Task.Delay(500).ContinueWith(async(_) =>
            {
                await Dispatcher.BeginInvoke(DispatcherPriority.ApplicationIdle, (Action)(() =>
                {
                    HwndSource.AddHook(AppBarHook);
                }));
            });
        }
Exemplo n.º 3
0
        public virtual void AppBarShow()
        {
            if (Framework.Settings.Instance.UseAppBar)
            {
                int      _screen;
                DockEdge _edge;
                WorkArea _windowWA;
                WorkArea _appbarWA;

                Monitor.GetWorkArea(this, out _screen, out _edge, out _windowWA, out _appbarWA);

                SetAppBar(_screen, _edge, _windowWA, _appbarWA, null);
            }

            Show();
        }
Exemplo n.º 4
0
        public void AppBarShow()
        {
            if (Properties.Settings.Default.UseAppBar)
            {
                int      _screen;
                DockEdge _edge;
                WorkArea _windowWA;
                WorkArea _appbarWA;

                Monitor.GetWorkArea(this, out _screen, out _edge, out _windowWA, out _appbarWA);

                SetAppBar(_screen, _edge, _windowWA, _appbarWA);
            }

            Show();
            Activate();
        }