Beispiel #1
0
        public static void CreateToolWindow(IVsUIShell vsUiShell, ToolWindowPane toolWindow, int instanceId)
        {
            var            clsId            = toolWindow.ToolClsid;
            var            typeId           = toolWindow.GetType().GUID;
            var            guidAutoActivate = Guid.Empty;
            var            caption          = toolWindow.Caption;
            IVsWindowFrame frame;

            toolWindow.Package = RPackage.Current;

            ErrorHandler.ThrowOnFailure(
                vsUiShell.CreateToolWindow(
                    (uint)(__VSCREATETOOLWIN.CTW_fInitNew | __VSCREATETOOLWIN.CTW_fToolbarHost | __VSCREATETOOLWIN.CTW_fForceCreate),
                    (uint)instanceId,
                    toolWindow,
                    ref clsId,
                    ref typeId,
                    ref guidAutoActivate,
                    null,
                    caption,
                    null,
                    out frame
                    )
                );

            toolWindow.Frame = frame;
            SetToolbarToHost(frame, toolWindow);
        }
Beispiel #2
0
        private void OpenToolWindow(ToolWindowPane pane, BrowserViewModel vm, Package vsPackage, int toolId = 0)
        {
            try
            {
                if (vsPackage == null)
                {
                    vsPackage = _vsPackage;
                }
                var window = vsPackage.FindToolWindow(pane.GetType(), toolId, true);

                if ((null == window) || (null == window.Frame))
                {
                    throw new NotSupportedException("oops!");
                }

                ((BrowserView)window.Content).Dispatcher.BeginInvoke(
                    (Action) delegate
                {
                    ((BrowserView)window.Content).ViewModel = vm;
                }
                    );

                //for some reason the above code does not properly update URL if it's been updated in the vm we pass in...
                ((BrowserView)window.Content).ViewModel.Url = vm.Url;

                var windowFrame = (IVsWindowFrame)window.Frame;

                ErrorHandler.ThrowOnFailure(windowFrame.Show());
            }
            catch (Exception e)
            {
                _logger.WriteToLog(string.Format("OpenToolWindow catch-all: method: {0}: error: {1}", "OpenToolWindowGeneric", e.Message), LogPriority.HighPriority);
            }
        }
Beispiel #3
0
        private void CloseToolWindow(ToolWindowPane pane, Package vsPackage, int toolID = 0)
        {
            if (vsPackage == null)
            {
                vsPackage = _vsPackage;
            }
            var window = vsPackage.FindToolWindow(pane.GetType(), toolID, true);

            if ((null == window) || (null == window.Frame))
            {
                // window already closed
                return;
            }

            var windowFrame = (IVsWindowFrame)window.Frame;

            windowFrame.CloseFrame((uint)__FRAMECLOSE.FRAMECLOSE_NoSave);
        }
Beispiel #4
0
        private void OpenToolWindow(ToolWindowPane pane, BrowserViewModel vm, Package vsPackage, int toolId = 0)
        {
            if (vsPackage == null)
            {
                vsPackage = _vsPackage;
            }
            ToolWindowPane window = vsPackage.FindToolWindow(pane.GetType(), toolId, true);

            if ((null == window) || (null == window.Frame))
            {
                throw new NotSupportedException("oops!");
            }
            (window.Content as BrowserView).Dispatcher.BeginInvoke(
                (Action) delegate
            {
                (window.Content as BrowserView).ViewModel = vm;
            }
                );
            IVsWindowFrame windowFrame = (IVsWindowFrame)window.Frame;

            Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(windowFrame.Show());
        }
Beispiel #5
0
 public static void ReportScreenView(ToolWindowPane pane)
 {
     Debug.WriteLine($"Opening tool pane {pane.Caption}");
     s_reporter.Value?.ReportScreen(pane.GetType().Name);
 }