コード例 #1
0
ファイル: CodeGen.cs プロジェクト: PaulNichols/Old-Projects
 private void GetOutputWindow()
 {
     if (newOutputWindow == null)
     {
         object serviceObject = GetService(typeof(ProjectItem));
         Debug.Assert(serviceObject != null, "Unable to get Project Item.");
         if (serviceObject == null)
         {
             string errorMessage = "Unable to add DLL to project references.";
             GeneratorErrorCallback(false, 1, errorMessage, 0, 0);
             //				return null;
         }
         else
         {
             // get the output window
             EnvDTE.Window win = ((ProjectItem)serviceObject).DTE.Windows.Item(EnvDTE.Constants.vsWindowKindOutput);
             win.Activate();
             //and the internal object (.nets window)
             EnvDTE.OutputWindow outputWindow = (EnvDTE.OutputWindow)win.Object;
             try
             {
                 // have we a curent pane?
                 newOutputWindow = outputWindow.OutputWindowPanes.Item("Proxy Builder");
             }
             catch
             {
                 // no, so create...strangely it errors, so it must be handled this way
                 newOutputWindow = outputWindow.OutputWindowPanes.Add("Proxy Builder");
             }
         }
     }
 }
コード例 #2
0
        /// <summary>
        /// Called when the analyze thread has completed.
        /// </summary>
        /// <param name="sender">The event sender.</param>
        /// <param name="e">The event arguments.</param>
        private void AnalyzeCompleteMain(object sender, EventArgs e)
        {
            Param.AssertNotNull(sender, "sender");
            Param.Ignore(e);

            EnvDTE.OutputWindowPane pane = VSWindows.GetInstance(this.serviceProvider).OutputPane;
            if (pane != null)
            {
                if (this.core.Cancel)
                {
                    pane.OutputString(string.Format(
                                          CultureInfo.InvariantCulture, Strings.LogBreak, Strings.Cancelled));
                }
                else
                {
                    pane.OutputString(string.Format(
                                          CultureInfo.InvariantCulture, Strings.LogBreak, Strings.Done));

                    pane.OutputString(string.Format(CultureInfo.InvariantCulture, Strings.ViolationCount, this.violationCount) + "\n\n\n");
                }
            }

            if (this.violationCount > 0)
            {
                this.ProvideEndAnalysisResult(this.violations);
                this.violations = null;
            }
        }
コード例 #3
0
        private EnvDTE.OutputWindowPane LoadOutputWindowPane(DTE dte)
        {
            const string windowName = "pMixins Code Generator";

            EnvDTE.OutputWindowPane pane   = null;
            EnvDTE.Window           window = dte.Windows.Item(EnvDTE.Constants.vsWindowKindOutput);
            if (window != null)
            {
                EnvDTE.OutputWindow output = window.Object as EnvDTE.OutputWindow;
                if (output != null)
                {
                    pane = output.ActivePane;
                    if (pane == null || pane.Name != windowName)
                    {
                        for (int ix = output.OutputWindowPanes.Count; ix > 0; ix--)
                        {
                            pane = output.OutputWindowPanes.Item(ix);
                            if (pane.Name == windowName)
                            {
                                break;
                            }
                        }
                        if (pane == null || pane.Name != windowName)
                        {
                            pane = output.OutputWindowPanes.Add(windowName);
                        }
                        if (pane != null)
                        {
                            pane.Activate();
                        }
                    }
                }
            }
            return(pane);
        }
コード例 #4
0
ファイル: OutputPane.cs プロジェクト: DreamSworK/rudebuild
        private bool Initialize()
        {
            if (null != _outputPane)                    // already initialized?
            {
                return(true);
            }

            if (0 == _application.Windows.Count)
            {
                return(false);
            }
            _window = _application.Windows.Item(EnvDTE.Constants.vsWindowKindOutput);
            if (null == _window)
            {
                return(false);
            }

            _outputWindow = _window.Object as EnvDTE.OutputWindow;
            if (null == _outputWindow)
            {
                return(false);
            }

            var outputWindowPane = from EnvDTE.OutputWindowPane pane in _outputWindow.OutputWindowPanes
                                   where pane.Name == _outputPaneName
                                   select pane;

            _outputPane = outputWindowPane.SingleOrDefault();
            if (_outputPane == null)
            {
                _outputPane = _outputWindow.OutputWindowPanes.Add(_outputPaneName);
            }

            return(_outputPane != null);
        }
コード例 #5
0
 /// <summary>
 /// Signals the helper to output that no files were avaliable for analysis.
 /// </summary>
 protected override void NoFilesToAnalyze()
 {
     EnvDTE.OutputWindowPane pane = VSWindows.GetInstance(this.ServiceProvider).OutputPane;
     if (pane != null)
     {
         pane.OutputString(string.Format(
                               CultureInfo.InvariantCulture, Strings.MiniLogBreak, Strings.NoFilesToAnalyze));
     }
 }
コード例 #6
0
        /// <summary>
        /// Signals the helper to output that analysis has begun.
        /// </summary>
        protected override void SignalAnalysisStarted()
        {
            // Write out our header to the output window.
            EnvDTE.OutputWindowPane pane = VSWindows.GetInstance(this.ServiceProvider).OutputPane;
            if (pane != null)
            {
                pane.Clear();
                pane.Activate();

                VSWindows.GetInstance(this.ServiceProvider).OutputWindow.Activate();

                pane.OutputString(string.Format(
                                      CultureInfo.InvariantCulture, Strings.MiniLogBreak, Strings.StyleCopStarted));
            }
        }
コード例 #7
0
        public VisualStudioWriter(DTE dte, System.IServiceProvider serviceProvider)
        {
            if (dte == null)
            {
                Debug.Write("Visual Studio Writer was passed a null DTE");

                if(System.Diagnostics.Debugger.IsAttached)
                    System.Diagnostics.Debugger.Break();

                return;
            }

            _outputWindowPane = LoadOutputWindowPane(dte);
            _errorListProvider = LoadErrorListPane(serviceProvider);
            _statusbar = serviceProvider.GetService(typeof (SVsStatusbar)) as IVsStatusbar;
        }
コード例 #8
0
        public static string GetAllTextFromPane(EnvDTE.OutputWindowPane Pane)
        {
            if (Pane == null)
            {
                return(null);
            }

            TextDocument  doc = Pane.TextDocument;
            TextSelection sel = doc.Selection;

            sel.StartOfDocument(false);
            sel.EndOfDocument(true);

            string content = sel.Text;

            return(content);
        }
コード例 #9
0
        protected EnvDTE.OutputWindowPane GetOutputPane(DTE dte)
        {
            try
            {
                if (dte == null)
                {
                    return(null);
                }

                string windowName              = GetType().Name;
                EnvDTE.OutputWindowPane pane   = null;
                EnvDTE.Window           window = dte.Windows.Item(EnvDTE.Constants.vsWindowKindOutput);
                if (window != null)
                {
                    EnvDTE.OutputWindow output = window.Object as EnvDTE.OutputWindow;
                    if (output != null)
                    {
                        pane = output.ActivePane;
                        if (pane == null || pane.Name != windowName)
                        {
                            for (int ix = output.OutputWindowPanes.Count; ix > 0; ix--)
                            {
                                pane = output.OutputWindowPanes.Item(ix);
                                if (pane.Name == windowName)
                                {
                                    break;
                                }
                            }
                            if (pane == null || pane.Name != windowName)
                            {
                                pane = output.OutputWindowPanes.Add(windowName);
                            }
                            if (pane != null)
                            {
                                pane.Activate();
                            }
                        }
                    }
                }
                return(pane);
            }
            catch
            {
                return(null);
            }
        }
コード例 #10
0
        public VisualStudioWriter(DTE dte, System.IServiceProvider serviceProvider)
        {
            if (dte == null)
            {
                Debug.Write("Visual Studio Writer was passed a null DTE");

                if (System.Diagnostics.Debugger.IsAttached)
                {
                    System.Diagnostics.Debugger.Break();
                }

                return;
            }

            _outputWindowPane  = LoadOutputWindowPane(dte);
            _errorListProvider = LoadErrorListPane(serviceProvider);
            _statusbar         = serviceProvider.GetService(typeof(SVsStatusbar)) as IVsStatusbar;
        }
コード例 #11
0
        /// <summary>
        /// Called when output should be added to the Ouput pane.
        /// </summary>
        /// <param name="sender">The event sender.</param>
        /// <param name="e">Contains the output string.</param>
        private void CoreOutputGenerated(object sender, OutputEventArgs e)
        {
            Param.Ignore(sender, e);

            // Make sure this is running on the main thread.
            if (InvisibleForm.Instance.InvokeRequired)
            {
                EventHandler <OutputEventArgs> outputDelegate = new EventHandler <OutputEventArgs>(
                    this.CoreOutputGenerated);

                InvisibleForm.Instance.Invoke(outputDelegate, sender, e);
            }
            else
            {
                EnvDTE.OutputWindowPane pane = VSWindows.GetInstance(this.serviceProvider).OutputPane;
                if (pane != null)
                {
                    pane.OutputString(e.Output);
                }
            }
        }
コード例 #12
0
        protected virtual void Dispose(bool disposing)
        {
            if (_disposed)
            {
                return;
            }

            if (disposing)
            {
                if (null != _errorListProvider)
                {
                    _errorListProvider.Dispose();
                }
            }

            _outputWindowPane  = null;
            _errorListProvider = null;
            _statusbar         = null;

            _disposed = true;
        }
コード例 #13
0
        public static void OutPut(this DTE dte, string message, bool isnewline, string panename = "")
        {
            var outputwindow = ((DTE2)dte).ToolWindows.OutputWindow;

            EnvDTE.OutputWindowPane pane = outputwindow.ActivePane;
            if (!string.IsNullOrWhiteSpace(panename))
            {
                pane = null;
                foreach (OutputWindowPane item in outputwindow.OutputWindowPanes)
                {
                    if (item.Name.Equals(panename))
                    {
                        pane = item;
                        break;
                    }
                }
                if (pane == null)
                {
                    pane = outputwindow.OutputWindowPanes.Add(panename);
                }
            }
            pane.OutputString(message + (isnewline ? Environment.NewLine : ""));
        }
コード例 #14
0
 public static EnvDTE.OutputWindowPane writeLine(this EnvDTE.OutputWindowPane outputWindow, string text)
 {
     outputWindow.OutputString(text.line());
     return(outputWindow);
 }
コード例 #15
0
 public void PaneClearing(EnvDTE.OutputWindowPane pane)
 {
     _outputWindowPane.OutputString("OutputWindowEvents, PaneClearing\n");
     _outputWindowPane.OutputString("\tPane: " + pane.Name + "\n");
 }
コード例 #16
0
 public void PaneUpdated(EnvDTE.OutputWindowPane pane)
 {
     //Dont want to do this one, or we will end up in a recursive call:
     //outputWindowPane.OutputString("OutputWindowEvents, PaneUpdated\n");
     //outputWindowPane.OutputString("\tPane: " + pane.Name + "\n");
 }
コード例 #17
0
        protected virtual void Dispose(bool disposing)
        {
            if (_disposed)
                return;

            if (disposing)
            {
                if (null != _errorListProvider)
                    _errorListProvider.Dispose();
            }

            _outputWindowPane = null;
            _errorListProvider = null;
            _statusbar = null;

            _disposed = true;
        }