예제 #1
0
        private IWindow CreateToolWindow(IDockableUserControl control)
        {
            IWindow toolWindow;

            try
            {
                using (var windows = _vbe.Windows)
                {
                    var info = windows.CreateToolWindow(_addin, RubberduckProgId.DockableWindowHostProgId, control.Caption, control.ClassId);
                    _userControlObject = info.UserControl;
                    toolWindow         = info.ToolWindow;
                }
            }
            catch (COMException exception)
            {
                Logger.Error(exception);
                throw;
            }
            catch (NullReferenceException exception)
            {
                Logger.Error(exception);
                throw;
            }

            toolWindow.IsVisible = true; //window resizing doesn't work without this
            EnsureMinimumWindowSize(toolWindow);
            toolWindow.IsVisible = _settings != null && _settings.IsWindowVisible(this);

            // currently we always inject _DockableToolWindowHost from Rubberduck.Main.
            // that method is not exposed in any of the interfaces we know, though, so we need to invoke it blindly
            ((dynamic)_userControlObject).AddUserControl(control as UserControl, new IntPtr(_vbe.MainWindow.HWnd));

            return(toolWindow);
        }
예제 #2
0
        private IWindow CreateToolWindow(IDockableUserControl control)
        {
            IWindow toolWindow;

            try
            {
                var info = _vbe.Windows.CreateToolWindow(_addin, _DockableWindowHost.RegisteredProgId, control.Caption, control.ClassId);
                _userControlObject = info.UserControl;
                toolWindow         = info.ToolWindow;
            }
            catch (COMException exception)
            {
                Logger.Error(exception);
                throw;
            }
            catch (NullReferenceException exception)
            {
                Logger.Error(exception);
                throw;
            }

            var userControlHost = (_DockableWindowHost)_userControlObject;

            toolWindow.IsVisible = true; //window resizing doesn't work without this

            EnsureMinimumWindowSize(toolWindow);

            toolWindow.IsVisible = _settings != null && _settings.IsWindowVisible(this);

            userControlHost.AddUserControl(control as UserControl, new IntPtr(_vbe.MainWindow.HWnd));
            return(toolWindow);
        }