March 5, 2021
Hot Topics:

Prime Programming Proficiency, Part 3: Lines-of-code Counter

  • By Paul Kimmel
  • Send Email »
  • More Articles »

Implementing the Output Window

The last piece is the Output class. The extensibility object model has an OutputWindowPane. Again, I wrapped the existing OutputWinowPane to add some convenience methods for my specific purposes. Listing 9 shows the code.

Listing 9: A Wrapper for the OutputWindowPane.

Imports EnvDTE
Imports System.Diagnostics

Public Class Output
   Private Shared FOutputWindow As OutputWindowPane

   Shared Sub New()
      FOutputWindow = GetOutputWindowPane("Project Utility")
   End Sub

   Public Shared ReadOnly Property Output() As OutputWindowPane
         Return FOutputWindow
      End Get
   End Property

   Public Shared Sub Clear()
   End Sub

   Public Shared Sub Write(ByVal Text As String)
   End Sub

   Public Shared Sub WriteLine(ByVal Text As String)
      FOutputWindow.OutputString(Text & vbCrLf)
   End Sub

   Shared Function GetOutputWindowPane(ByVal Name As String, _
      Optional ByVal show As Boolean = True) As OutputWindowPane
         Dim win As Window = _
         If show Then win.Visible = True
         Dim ow As OutputWindow = win.Object
         Dim owpane As OutputWindowPane
            owpane = ow.OutputWindowPanes.Item(Name)
         Catch e As System.Exception
            owpane = ow.OutputWindowPanes.Add(Name)
         End Try
         Return owpane
   End Function

End Class

I borrowed GetOutputWindowPane from the Samples.Utilities module that ships with VS.NET. This window is the Output window in VS.NET, and you can supply your own pane with a suitable title. In the example, we name it Project Utility. The rest of the wrapper methods orchestrate clearing or sending text to the window pane.

Build Your Skills Base

Programming requires a huge amount of knowledge. We learn about object models, grammars, libraries and third-party tools, patterns, refactoring, algorithms, threading, database design, testing tools, delegates, events, XML, stylesheets, source control tools, and much more. It is easy to forget how much the average programmer has to know to create even a "Hello World" application.

I hope this three-part series helps you see how many of these skills are tied together to create a whole. Still, all of these skills may only make one a competent programmer. The kind of talent that creates a thing of beauty and artistry is rare indeed and very difficult to attain.

(Eventually, I will get the source for this example posted on my Web site at http://www.softconcepts.com.)


Paul Kimmel is the VB Today columnist, has written several books on .NET programming, and is a software architect. You may contact him at pkimmel@softconcepts.com if you need assistance or are interested in joining the Lansing Area .NET Users Group (glugnet.org).

Copyright © 2004 by Paul Kimmel. All Rights Reserved.

Page 6 of 6

This article was originally published on August 12, 2004

Enterprise Development Update

Don't miss an article. Subscribe to our newsletter below.

Thanks for your registration, follow us on our social networks to keep up-to-date