Beispiel #1
0
        //used for normal toolbars, not for satellite toolbars
        void _Show(bool owned, AWnd owner, ITBOwnerObject oo, AScreen screen)
        {
            //if(_c.IsDisposed) throw new ObjectDisposedException("AToolbar");
            if (_loaded)
            {
                throw new InvalidOperationException();
            }

            AWnd c = default;

            if (owned)
            {
                if (owner.Is0)
                {
                    throw new ArgumentException();
                }
                var w = owner.Window; if (w.Is0)
                {
                    return;
                }
                if (w != owner)
                {
                    c = owner; owner = w;
                }
            }

            _CreateControl(owned, owner, screen);
            _Manager.Add(this, owner, c, oo);
        }
Beispiel #2
0
        internal unsafe bool IsFullScreen_(out AScreen.ScreenHandle screen)
        {
            screen = default;
            if (Is0)
            {
                return(false);
            }

            //is client rect equal to window rect (no border)?
            RECT r, rc, rm;

            r = Rect;             //fast
            int cx = r.right - r.left, cy = r.bottom - r.top;

            if (cx < 400 || cy < 300)
            {
                return(false);           //too small
            }
            rc = ClientRect;             //fast
            if (rc.right != cx || rc.bottom != cy)
            {
                if (cx - rc.right > 2 || cy - rc.bottom > 2)
                {
                    return(false);                                                        //some windows have 1-pixel border
                }
            }

            //covers whole monitor rect?
            screen = AScreen.Of(this, SDefault.Zero); if (screen.Is0)
            {
                return(false);
            }
            rm = screen.Bounds;

            if (r.left > rm.left || r.top > rm.top || r.right < rm.right || r.bottom < rm.bottom - 1)
            {
                return(false);                                                                                                 //info: -1 for inactive Chrome
            }
            //is it desktop?
            if (IsOfShellThread_)
            {
                return(false);
            }
            if (this == GetWnd.Root)
            {
                return(false);
            }

            return(true);

            //This is the best way to test for fullscreen (FS) window. Fast.
            //Window and client rect was equal of almost all my tested FS windows. Except Winamp visualization.
            //Most FS windows are same size as screen, but some slightly bigger.
            //Don't look at window styles. For some FS windows they are not as should be.
            //Returns false if the active window is owned by a fullscreen window. This is different than appbar API interprets it. It's OK for our purposes.
        }
Beispiel #3
0
        //used for normal and satellite toolbars
        void _CreateControl(bool owned, AWnd owner, AScreen screen = default)
        {
            _topmost = !owned || owner.IsTopmost;
            if (!owned || _anchor == TBAnchor.None)
            {
                _os = new _OwnerScreen(this, screen);
            }

            GetIconsAsync_(_c);
            _c.ResumeLayout();
            _AutoSize();
            _c.Hwnd(create: true);
            _loaded = true;
        }
Beispiel #4
0
            private void _bClick(object sender, EventArgs e)
            {
                if (!(_lb.SelectedItem is AToolbar tb))
                {
                    return;
                }
                if (tb._c.IsDisposed)
                {
                    ADialog.Show("Closed", owner: this);
                    return;
                }
                var w = tb._c.Hwnd();
                var r = w.Rect;

                if (sender == _bShow)
                {
                    if (AScreen.IsInAnyScreen(r))
                    {
                        r.Inflate(2, 2);
                        var osd = new AOsdRect {
                            Rect = r, Color = 0xff0000
                        };
                        osd.Show();
                        ATimer.After(1000, _ => osd.Dispose());
                    }
                    else
                    {
                        ADialog.Show("Offscreen", "Rectangle: " + r.ToString(), owner: this);
                    }
                }
                else if (sender == _bMove)
                {
                    if (!w.IsVisible && !ADialog.ShowOkCancel("Hidden", "Move this hidden toolbar?", owner: this))
                    {
                        return;
                    }
                    var xy = AMouse.XY;
                    w.MoveLL(xy.x, xy.y);
                    var w2 = this.Hwnd();
                    if (!w.ZorderIsAbove(w2))
                    {
                        w.ZorderAbove(w2);
                    }
                }
            }
Beispiel #5
0
 /// <summary>
 /// Shows the toolbar and attaches to a screen.
 /// </summary>
 /// <param name="screen">Can be used to define the screen. For example a screen index (0 the primary, 1 the first non-primary, and so on). If not specified, the toolbar will be attached to the screen where it is now or where will be moved later.</param>
 /// <exception cref="InvalidOperationException"><b>Show</b> already called.</exception>
 /// <remarks>
 /// The toolbar will be moved when the screen moved or resized.
 /// </remarks>
 public void Show(AScreen screen = default) => _Show(false, default, null, screen);