/// <summary> /// This function is the callback used to execute the command when the menu item is clicked. /// See the constructor to see how the menu item is associated with this function using /// OleMenuCommandService service and MenuCommand class. /// </summary> /// <param name="sender">Event sender.</param> /// <param name="e">Event args.</param> private void MenuItemCallback(object sender, EventArgs e) { var dte = ServiceProvider.GetService(typeof(SDTE)) as EnvDTE.DTE; var guid = PackageConstants.OutputWindowGuid; IVsOutputWindow output = (IVsOutputWindow)ServiceProvider.GetService(typeof(SVsOutputWindow)); output.CreatePane(ref guid, PackageConstants.OutputWindowTitle, Convert.ToInt32(true), Convert.ToInt32(true)); output.GetPane(ref guid, out IVsOutputWindowPane pane); var startstring = @" _ _ _ _ __ ___ _ _____ _ _ _ ______ _ _ | | | | | | | \ \ / (_) | | / ____| | | (_) | ____| | | (_) | |__| | ___| | | ___ \ \ / / _ ___ _ _ __ _| | | (___ | |_ _ _ __| |_ ___ | |__ __ _| |_ ___ _ __ ___ _ ___ _ __ | __ |/ _ \ | |/ _ \ \ \/ / | / __| | | |/ _` | | \___ \| __| | | |/ _` | |/ _ \ | __| \ \/ / __/ _ \ '_ \/ __| |/ _ \| '_ \ | | | | __/ | | (_) | \ / | \__ \ |_| | (_| | | ____) | |_| |_| | (_| | | (_) | | |____ > <| || __/ | | \__ \ | (_) | | | | |_| |_|\___|_|_|\___/ \/ |_|___/\__,_|\__,_|_| |_____/ \__|\__,_|\__,_|_|\___/ |______/_/\_\\__\___|_| |_|___/_|\___/|_| |_| "; pane.OutputString(startstring); OutputWindowPanes panes = ((DTE2)dte).ToolWindows.OutputWindow.OutputWindowPanes; OutputWindowPane outputPane = null; try { outputPane = panes.Item(PackageConstants.OutputWindowTitle); } catch (ArgumentException) { panes.Add(PackageConstants.OutputWindowTitle); outputPane = panes.Item(PackageConstants.OutputWindowTitle); } var envdtestring = @" _ _ _ _ _ ______ _____ _______ ______ | | | | | | | | | ____| | __ \__ __| ____| | |__| | ___| | | | ___ | |__ _ ____ __ | | | | | | | |__ | __ |/ _ \ | | |/ _ \ | __| | '_ \ \ / / | | | | | | | __| | | | | __/ | | | (_) | | |____| | | \ V / | |__| | | | | |____ |_| |_|\___|_|_|_|\___/ |______|_| |_|\_/ |_____/ |_| |______| "; outputPane.OutputString(envdtestring); Solution solution = dte.Solution; Projects projects = solution.Projects; foreach (Project project in projects) { outputPane.OutputString(project.Name); } }
private OutputWindowPane GetOutputWindow(OutputWindowPanes outputWindowPanes) { for (uint i = 1; i <= outputWindowPanes.Count; i++) { if (outputWindowPanes.Item(i).Name.Equals("Lumiere", StringComparison.CurrentCultureIgnoreCase)) { return(outputWindowPanes.Item(i)); } } return(outputWindowPanes.Add("Lumiere")); }
/// <summary> /// Get item of the output window by name. /// </summary> /// <param name="name">Name of item</param> /// <param name="createIfNotExist">If this value as true: Creates new pane if this item does not exist, otherwise exception.</param> /// <returns></returns> /// <exception cref="Exception"></exception> public OutputWindowPane getByName(string name, bool createIfNotExist) { OutputWindowPanes panes = dte2.ToolWindows.OutputWindow.OutputWindowPanes; if (createIfNotExist) { try { return(panes.Item(name)); } catch (ArgumentException) { return(panes.Add(name)); } } return(panes.Item(name)); }
public static void WriteMessageToOutputPane(string message, string title = "GIT Source Control") { DTE2 dte = GetActiveIDE(); OutputWindowPanes panes = dte.ToolWindows.OutputWindow.OutputWindowPanes; try { // If the pane exists already, write to it. panes.Item(title); } catch (ArgumentException) { // Create a new pane and write to it. panes.Add(title); } foreach (EnvDTE.OutputWindowPane pane in panes) { if (pane.Name.Contains(title)) { pane.OutputString(message + "\n"); pane.Activate(); return; } } }
private OutputWindowPane MakeOutputWindow() { // _applicationObject is from the main class try { Window win = dte2.Windows.Item(EnvDTE.Constants.vsWindowKindOutput); OutputWindow outputWindow = (OutputWindow)win.Object; OutputWindowPane outputPane = null; OutputWindowPanes panes = outputWindow.OutputWindowPanes; // Reuse the existing pane (if it exists) for (int i = 1; i <= panes.Count; i++) { outputPane = panes.Item(i); if (outputPane.Name == "NPanday Execution Output:") { return(outputPane); } } OutputWindowPane output = outputWindow.OutputWindowPanes.Add("NPanday Execution Output:"); return(output); } catch (Exception e) { throw new Exception("Error In Generation Output Window: " + e.Message); } }
public VSOutputLogger(EnvDTE80.DTE2 dte) { ThreadHelper.ThrowIfNotOnUIThread(); OutputWindowPanes panes = dte.ToolWindows.OutputWindow.OutputWindowPanes; outputPane = null; try { outputPane = panes.Item("VSslnToCMake"); } catch (ArgumentException) { panes.Add("VSslnToCMake"); outputPane = panes.Item("VSslnToCMake"); } }
private OutputWindowPane GetPane(string title) { DTE2 dte = (DTE2)Package.GetGlobalService(typeof(DTE)); OutputWindowPanes panes = dte.ToolWindows.OutputWindow.OutputWindowPanes; try { return(panes.Item(title)); } catch (ArgumentException) { return(panes.Add(title)); } }
private OutputWindowPane GetOutputPane(string title) { OutputWindowPanes panes = dte.ToolWindows.OutputWindow.OutputWindowPanes; try { // If the pane exists already, return it. return(panes.Item(title)); } catch (ArgumentException) { // Create a new pane. return(panes.Add(title)); } }
private OutputWindowPane CreateOrGetOutputPane(string title) { DTE2 dte = (DTE2)GetService(typeof(DTE)); OutputWindowPanes panes = dte.ToolWindows.OutputWindow.OutputWindowPanes; try { // If the pane exists already, write to it. return(panes.Item(title)); } catch (ArgumentException) { // Create a new pane and write to it. return(panes.Add(title)); } }
void TraceMessage(string msg) { OutputWindowPanes panes = dte.ToolWindows.OutputWindow.OutputWindowPanes; OutputWindowPane pane; String cppScript = "C++ Script"; try { pane = panes.Item(cppScript); } catch (ArgumentException) { pane = panes.Add(cppScript); } pane.OutputString(msg + "\n"); pane.Activate(); dte.ToolWindows.OutputWindow.Parent.Activate(); return; //foreach (OutputWindowPane pane in panes) //{ // if (pane.Name.Contains("Build")) // { // pane.OutputString(msg + "\n"); // pane.Activate(); // //dte.ToolWindows.OutputWindow.Parent.Activate(); // return; // } //} _errorListProvider.Tasks.Clear(); var task = new ErrorTask { Document = @"d:\PrototypingQuick\VSSyncProj\OpenSyncProjectFile.cs", Line = 105, Column = 17, ErrorCategory = TaskErrorCategory.Error, Category = TaskCategory.BuildCompile, Text = "Hello error panel" }; task.Navigate += Task_Navigate; _errorListProvider.Tasks.Add(task); _errorListProvider.Show(); _errorListProvider.BringToFront(); }
OutputWindowPane GetOutputPanel() { OutputWindowPanes panes = GetDTE().ToolWindows.OutputWindow.OutputWindowPanes; OutputWindowPane pane; String cppScript = "Script Engine"; try { pane = panes.Item(cppScript); } catch (ArgumentException) { pane = panes.Add(cppScript); } return(pane); }
/// <summary> /// Creates (or returns, if exists) Output Pane /// </summary> /// <param name="title">Pane title</param> private OutputWindowPane CreatePane(string title) { DTE2 dte = (DTE2)ServiceProvider.GetService(typeof(DTE)); dte.ExecuteCommand("View.Output"); OutputWindowPanes panes = dte.ToolWindows.OutputWindow.OutputWindowPanes; try { // If the pane exists already, write to it. return(panes.Item(title)); } catch (ArgumentException) { // Create a new pane and write to it. return(panes.Add(title)); } }
OutputWindowPane CreatePane(string title) { EnvDTE80.DTE2 dte = (EnvDTE80.DTE2)ServiceProvider.GetService(typeof(DTE)); OutputWindowPanes panes = dte.ToolWindows.OutputWindow.OutputWindowPanes; OutputWindowPane pane; try { // If the pane exists already, write to it. pane = panes.Item(title); } catch (ArgumentException) { // Create a new pane and write to it. return(panes.Add(title)); } return(pane); }
private void WriteToOutputWindow(string message) { string paneName = "Sourcetrail Log"; if (_dte.Windows.Count > 0) { Window window = _dte.Windows.Item(EnvDTE.Constants.vsWindowKindOutput); OutputWindow outputWindow = (OutputWindow)window.Object; OutputWindowPanes panes = outputWindow.OutputWindowPanes; if (_pane == null) { try { for (int i = 0; i < panes.Count; i++) { OutputWindowPane pane = panes.Item(i); if (pane.Name.Equals(paneName, StringComparison.CurrentCultureIgnoreCase)) { _pane = outputWindow.OutputWindowPanes.Item(i); break; } } } catch (Exception) { // don't log here, otherwise we create an infinite loop ;) } } if (_pane == null) { _pane = outputWindow.OutputWindowPanes.Add(paneName); } _pane.OutputString(message + '\n'); } }
private static OutputWindowPane GetLogPane() { string title = _packageName; OutputWindowPanes panes = _application.ToolWindows.OutputWindow.OutputWindowPanes; OutputWindowPane logPane; try { logPane = panes.Item(title); // If the pane exists already, return it. } catch (ArgumentException) { // Create a new pane. logPane = panes.Add(title); logPane.WriteLine("Activity log for " + _packageName); logPane.WriteLine(System.Reflection.Assembly.GetExecutingAssembly().FullName); logPane.WriteLine("----------------------------------------------------"); } return(logPane); }
/// <summary> /// Sets up the DTE and other code which depends on /// visual studios initalization being complete /// </summary> /// <returns>true id initialization was completed successfully</returns> private bool AttemptInit() { // zombie state dependent code this._dte = (DTE2)GetService(typeof(DTE)); if (this._dte == null) { return(false); } //setup all our windows and panes here OutputWindowPanes panes = _dte.ToolWindows.OutputWindow.OutputWindowPanes; // Create a new pane. try { _debugOut = panes.Item(DebugTestOutputWindow); } catch { _debugOut = panes.Add(DebugTestOutputWindow); } //events we're intrested in. _buildEvents = _dte.Events.BuildEvents; _solutionEvents = _dte.Events.SolutionEvents; _documentEvents = _dte.Events.get_DocumentEvents(null); _solutionEvents.Opened += SolutionEvents_Opened; _solutionEvents.AfterClosing += SolutionEvents_AfterClosing; _buildEvents.OnBuildProjConfigDone += BuildEvents_OnBuildProjConfigDone; _documentEvents.DocumentOpened += DocumentEvents_DocumentOpened; TestMarkerProvider.InitializeMarkerIds(GetTextManager()); return(true); }
/// <summary> /// This function is the callback used to execute the command when the menu item is clicked. /// See the constructor to see how the menu item is associated with this function using /// OleMenuCommandService service and MenuCommand class. /// </summary> /// <param name="sender">Event sender.</param> /// <param name="e">Event args.</param> private void Execute(object sender, EventArgs e) { ThreadHelper.ThrowIfNotOnUIThread(); MSBuildWorkspace workspace = MSBuildWorkspace.Create(); var targetProject = GetSelectedProject(); string projectPath = null; string projectName = null; for (var i = 1; i <= targetProject.Properties.Count; i++) { if (targetProject.Properties.Item(i).Name == "FullPath") { projectPath = targetProject.Properties.Item(i).Value.ToString(); } if (targetProject.Properties.Item(i).Name == "FileName") { projectName = targetProject.Properties.Item(i).Value.ToString(); } } Microsoft.CodeAnalysis.Project currentProject = workspace.OpenProjectAsync(projectPath + projectName).Result; var projectCompilation = currentProject.GetCompilationAsync().Result; var assemblyTypes = projectCompilation.Assembly.TypeNames; var namedSymbols = assemblyTypes.Select(type => (INamedTypeSymbol)projectCompilation.GetSymbolsWithName(symbolName => symbolName == type).Where(symbol => symbol.Kind == SymbolKind.NamedType).First()); var controllerSymbols = namedSymbols.Where(symbol => CheckTypeIsOrInheritedFromController(symbol)).ToList(); var controllerMethodsCollection = new Dictionary <INamedTypeSymbol, IEnumerable <IMethodSymbol> >(); foreach (var controller in controllerSymbols) { var isAuthorized = CheckControllerIsOrInheritedFromAuthorizedController(controller); var controllerActionMethods = controller.GetMembers() .Where(member => member.DeclaredAccessibility == Accessibility.Public && member.Kind == SymbolKind.Method && ((IMethodSymbol)member).MethodKind == MethodKind.Ordinary) .Select(item => (IMethodSymbol)item).ToList(); var anonymousMethods = isAuthorized ? controllerActionMethods.Where(action => action.GetAttributes().Any(attribute => attribute.AttributeClass.Name == "AllowAnonymousAttribute")) : controllerActionMethods.Where(action => action.GetAttributes().All(attribute => attribute.AttributeClass.Name != "AuthorizeAttribute")); if (anonymousMethods.Count() > 0) { controllerMethodsCollection.Add(controller, anonymousMethods); } } DTE2 dte = (DTE2)ServiceProvider.GetServiceAsync(typeof(DTE)).Result; OutputWindowPanes panes = dte.ToolWindows.OutputWindow.OutputWindowPanes; OutputWindowPane outputPane; try { outputPane = panes.Item("N-Tools"); } catch (ArgumentException) { outputPane = panes.Add("N-Tools"); } outputPane.Activate(); foreach (var record in controllerMethodsCollection) { outputPane.OutputString("Controller: " + record.Key.Name); foreach (var method in record.Value) { outputPane.OutputString(Environment.NewLine); outputPane.OutputString("\t"); outputPane.OutputString("Action: "); outputPane.OutputString(method.Name); outputPane.OutputString(Environment.NewLine); } outputPane.OutputString(Environment.NewLine); } }