Exemple #1
0
        internal void OnHandleCreated()
        {
            if (_pane == null)
            {
                if (_panel == null)
                {
                    _panel          = new Panel();
                    _panel.Location = new Point(0, 0);
                    _panel.Size     = _form.ClientRectangle.Size;
                    _form.Controls.Add(_panel);
                }

                _pane = new VSFormContainerPane(_form.Context, this, _panel);

                IVsWindowPane p = _pane;

                IntPtr    hwnd;
                Rectangle r = new Rectangle(_form.Location, _form.Size);
                _form.Location = new Point(0, 0);

                if (!VSErr.Succeeded(p.CreatePaneWindow(_form.Handle, 0, 0, r.Width, r.Height, out hwnd)))
                {
                    _pane.Dispose();
                    _pane = null;
                    return;
                }
                _form.Size  = r.Size;
                _panel.Size = _form.ClientSize;

                IButtonControl cancelButton = _form.CancelButton;
                IButtonControl acceptButton = _form.AcceptButton;

                for (int i = 0; i < _form.Controls.Count; i++)
                {
                    Control cc = _form.Controls[i];

                    if (cc != _panel)
                    {
                        _panel.Controls.Add(cc);
                        i--;
                        if (cc == cancelButton)
                        {
                            _form.CancelButton = cancelButton;
                        }

                        if (cc == acceptButton)
                        {
                            _form.AcceptButton = acceptButton;
                        }
                    }
                }
                _form.SizeChanged += new EventHandler(VSForm_SizeChanged);
            }
            if (!_loadRegistered)
            {
                _loadRegistered = true;
                _form.Load     += new EventHandler(OnLoad);
            }
        }
Exemple #2
0
        internal void OnHandleCreated()
        {
            if (_pane == null)
            {
                if (_panel == null)
                {
                    _panel = new Panel();
                    _panel.Location = new Point(0, 0);
                    _panel.Size = _form.ClientRectangle.Size;
                    _form.Controls.Add(_panel);
                }

                _pane = new VSFormContainerPane(_form.Context, this, _panel);

                IVsWindowPane p = _pane;

                IntPtr hwnd;
                Rectangle r = new Rectangle(_form.Location, _form.Size);
                _form.Location = new Point(0, 0);

                if (!ErrorHandler.Succeeded(p.CreatePaneWindow(_form.Handle, 0, 0, r.Width, r.Height, out hwnd)))
                {
                    _pane.Dispose();
                    _pane = null;
                    return;
                }
                _form.Size = r.Size;
                _panel.Size = _form.ClientSize;

                IButtonControl cancelButton = _form.CancelButton;
                IButtonControl acceptButton = _form.AcceptButton;

                for (int i = 0; i < _form.Controls.Count; i++)
                {
                    Control cc = _form.Controls[i];

                    if (cc != _panel)
                    {
                        _panel.Controls.Add(cc);
                        i--;
                        if (cc == cancelButton)
                            _form.CancelButton = cancelButton;

                        if (cc == acceptButton)
                            _form.AcceptButton = acceptButton;

                    }
                }
                _form.SizeChanged += new EventHandler(VSForm_SizeChanged);
            }
            if (!_loadRegistered)
            {
                _loadRegistered = true;
                _form.Load += new EventHandler(OnLoad);
            }
        }
Exemple #3
0
        protected override void Dispose(bool disposing)
        {
            try
            {
                if (_priorityCommandTarget != null)
                {
                    try
                    {
                        _priorityCommandTarget.UnregisterPriorityCommandTarget(_csCookie);
                    }
                    finally
                    {
                        _priorityCommandTarget = null;
                    }
                }

                if (_activeStack != null)
                {
                    try
                    {
                        _activeStack.Dispose();
                    }
                    finally
                    {
                        _activeStack = null;
                    }
                }


                if (_panel != null)
                {
                    RestoreLayout();
                }

                if (_pane != null)
                {
                    _pane.Dispose(); // Unhook
                    _pane = null;
                }

                if (_panel != null)
                {
                    _panel.Dispose();
                    _panel = null;
                }
            }
            finally
            {
                _map.Remove(_form);

                if (_installed)
                {
                    _installed = false;
                    Application.RemoveMessageFilter(this);

                    VSCommandRouting cr = _routers.Pop();
                    Debug.Assert(cr == this, "Pop routing in the right order");

                    if (_routers.Count > 0)
                    {
                        _routers.Peek().Enabled = true;
                    }
                }

                base.Dispose(disposing);
            }
        }
Exemple #4
0
        public void Dispose()
        {
            if (_activeStack != null)
                _activeStack.Dispose();

            if (_csCookie != 0 && _rPct != null)
            {
                _rPct.UnregisterPriorityCommandTarget(_csCookie);
                _csCookie = 0;
            }

            if(_panel != null)
                RestoreLayout();

            if (_pane != null)
            {
                _pane.Dispose(); // Unhook
                _pane = null;
            }

            if (_panel != null)
            {
                _panel.Dispose();
                _panel = null;
            }

            _map.Remove(_form);
            if (_installed)
            {
                VSCommandRouting cr = _routers.Pop();
                Debug.Assert(cr == this, "Pop routing in the right order");
                Application.RemoveMessageFilter(this);

                if (_routers.Count > 0)
                    _routers.Peek().Enabled = true;
            }
        }