Exemplo n.º 1
0
        /// <summary>
        /// Writes text directly to the VS Output window.
        /// </summary>
        public static void Write(string message, string pane = DefaultOutputPane)
        {
            ThreadHelper.JoinableTaskFactory.RunAsync(async delegate
            {
                await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();
                try
                {
                    // Get the Output window
                    IVsOutputWindow outputWindow = outputWindowLazy.Value;
                    if (outputWindow == null)
                    {
                        return;
                    }

                    // Get the pane guid
                    PaneInfo paneInfo;
                    if (!panes.TryGetValue(pane, out paneInfo))
                    {
                        // Pane didn't exist, create it
                        paneInfo = new PaneInfo(Guid.NewGuid());
                        panes.Add(pane, paneInfo);
                    }

                    // Get the pane
                    IVsOutputWindowPane outputPane;
                    if (outputWindow.GetPane(ref paneInfo.paneId, out outputPane) != VSConstants.S_OK)
                    {
                        // Failed to get the pane - might need to create it first
                        outputWindow.CreatePane(ref paneInfo.paneId, pane, fInitVisible: 1, fClearWithSolution: 1);
                        outputWindow.GetPane(ref paneInfo.paneId, out outputPane);
                    }

                    // The first time we output text to a pane, ensure it's visible
                    if (!paneInfo.Shown)
                    {
                        paneInfo.Shown = true;

                        // Switch to the pane of the Output window
                        outputPane.Activate();

                        // Show the output window
                        IVsUIShell shell = shellLazy.Value;
                        if (shell != null)
                        {
                            object inputVariant = null;
                            shell.PostExecCommand(VSConstants.GUID_VSStandardCommandSet97, (uint)VSConstants.VSStd97CmdID.OutputWindow, 0, ref inputVariant);
                        }
                    }

                    // Output the text
                    outputPane.OutputString(message);
                }
                catch (Exception)
                {
                    Debug.Fail("Failed to write to output pane.");
                }
            }).FileAndForget("VS/Diagnostics/Debugger/SSHDebugPS/VsOutputWindowWrapper/Write");
        }
Exemplo n.º 2
0
        }//end method SubmitData

        public void SwitchPanel(PaneInfo panel)
        {
            switch (panel)
            {
            case PaneInfo.CustomerPanel:
                LoadPanelCustomer();
                break;

            case PaneInfo.RoomPanel:
                LoadPanelRoom();
                break;
            } //end switch
        }     //end method SwitchPanel
        private void EnsurePaneVisible()
        {
            TreeNode treeNode = preferencePaneTree.SelectedNode;

            if (treeNode != null)
            {
                bool found = false;
                foreach (PreferencePaneContainer preferencePaneContainer in preferencePaneSplitContainer.Panel2.Controls)
                {
                    if (preferencePaneContainer.Tag == treeNode)
                    {
                        preferencePaneContainer.Visible = true;
                        found = true;
                    }
                    else
                    {
                        preferencePaneContainer.Visible = false;
                    }
                }

                if (!found)
                {
                    PaneInfo paneInfo = (PaneInfo)treeNode.Tag;

                    PreferencePane preferencePane = paneInfo.Factory();
                    preferencePane.Dock         = DockStyle.Fill;
                    preferencePane.Margin       = new Padding(0, 0, 0, 0);
                    preferencePane.AutoSize     = true;
                    preferencePane.AutoSizeMode = AutoSizeMode.GrowAndShrink;
                    preferencePane.PendingSettingsChangesChanged += preferencePane_PendingSettingsChangesChanged;
                    preferencePane.RequiresElevationChanged      += preferencePane_ElevationRequiredChanged;

                    PreferencePaneContainer preferencePaneContainer = new PreferencePaneContainer();
                    preferencePaneContainer.Dock           = DockStyle.Fill;
                    preferencePaneContainer.Margin         = new Padding(0, 0, 0, 0);
                    preferencePaneContainer.AutoSize       = true;
                    preferencePaneContainer.AutoSizeMode   = AutoSizeMode.GrowAndShrink;
                    preferencePaneContainer.Tag            = treeNode;
                    preferencePaneContainer.PreferencePane = preferencePane;
                    preferencePaneContainer.Title          = paneInfo.Title;

                    preferencePaneSplitContainer.Panel2.Controls.Add(preferencePaneContainer);

                    RefreshPendingSettingsChangesState();
                    RefreshElevationRequiredState();
                }
            }
        }