<ahref="http://www.codeproject.com/useritems/LineCounterAddin.asp"title="Line Counter - Writing a Visual Studio 2005 Add-In">Line
Counter - Writing a Visual Studio 2005 Add-In</a>
<ahref="http://www.codeproject.com/useritems/LineCounterAddin.asp"target="_blank"title="Line Counter - Writing a Visual Studio 2005 Add-In">[^]</a>,
<ahref="http://www.codeproject.com/useritems/LineCounterAddin.asp"target="_blank"title="Line Counter - Writing a Visual Studio 2005 Add-In">[^]</a>
written by Jon Rista,
I wanted to show you how to write that AddIn for SharpDevelop.<br>
In this article I will show you how to create an AddIn, but I will not discuss
the concepts of the SharpDevelop's AddIn architecture here - you can read more
@ -36,23 +40,24 @@ about that in my article
@@ -36,23 +40,24 @@ about that in my article
Applications with the SharpDevelop Core</a>
<ahref="http://www.codeproject.com/csharp/ICSharpCodeCore.asp"target="_blank"title="Building Applications with the SharpDevelop Core">[^]</a>.
The line counter code is taken from the VS 2005 AddIn written by Jon Rista; the
counting algorithm itself is from Oz Solomon.<br>
counting algorithm itself is from Oz Solomon.<br> I will discuss every of my changes to the code in this article - after all, there aren't so many changes required.
<br>
<h2>
Creating a new AddIn
</h2>
Our AddIn will be a menu entry in the "Tools" menu that opens a document window
displaying the line counter UI. SharpDevelop already comes with a project
template for an AddIn extending the "Tools" menu: "Tools menu entry"<br>
@ -92,7 +97,7 @@ Here is how the content of LineCounter.addin should look like after these steps:
@@ -92,7 +97,7 @@ Here is how the content of LineCounter.addin should look like after these steps:
</AddIn>
</pre>Our menu item uses the "class" attribute. When the menu item is
clicked, SharpDevelop will create an instance of this class and call its Run()
method. This class is defined the file Command.cs. The example code from the
method. This class is defined in the file Command.cs. The example code from the
template accesses the currently opened text editor and reverses the letters in
the currently selected text. We are not interested in accessing the text editor,
so we can delete the content of the Run() method and start writing our own.<br>
@ -105,19 +110,20 @@ about missing references. This is because the template is missing the assembly
@@ -105,19 +110,20 @@ about missing references. This is because the template is missing the assembly
references to the SharpDevelop libraries - these have to hard-coded paths in
most cases, so you should add them manually. Add references to
ICSharpCode.Core.dll and ICSharpCode.SharpDevelop.dll from the bin directory of
your SharpDevelop installation. ICSharpCode.Core contains the AddIn system, we
need the base class of our menu command from it. ICSharpCode.SharpDevelop is the
largest part of SharpDevelop, we'll use the project system from it.<br>
your SharpDevelop installation. ICSharpCode.Core contains the AddIn system,
and also the base class for our menu command.
ICSharpCode.SharpDevelop is the largest part of SharpDevelop, it contains
the project system and many other things.<br>
Make sure you set "Local copy" for the references to
@ -337,7 +343,7 @@ can add SharpDevelop icons to an existing image list.<br>
@@ -337,7 +343,7 @@ can add SharpDevelop icons to an existing image list.<br>
will use two instances of this class to control the two image lists
imgProjectTypes and imgFileTypes.<br>
ScanSolution() is getting the icon index from m_projIconMappings - we will
@ -419,7 +425,7 @@ name "LineCountingAlgorithm". Don't be irritated that it's not defined in the
@@ -419,7 +425,7 @@ name "LineCountingAlgorithm". Don't be irritated that it's not defined in the
XML schema for .addin files - we are creating a new possible codon name here;
the XML schema is just for code completion when editing the .addin file.<br>
Now how can we define this codon type? Constructing objects from the AddInTree
is done by the <spanstyle="FONT-WEIGHT: bold">doozers</span> (the name comes
@ -555,7 +560,7 @@ the zip file to "LineCounter.sdaddin". That really was everything you had to do
@@ -555,7 +560,7 @@ the zip file to "LineCounter.sdaddin". That really was everything you had to do
where you can install the AddIn with just one click. AddIns installed this way
will be extracted to %Application Data%\.ICSharpCode\SharpDevelop2\AddIns.<br>
@ -589,7 +594,7 @@ will be extracted to %Application Data%\.ICSharpCode\SharpDevelop2\AddIns.<br>
@@ -589,7 +594,7 @@ will be extracted to %Application Data%\.ICSharpCode\SharpDevelop2\AddIns.<br>
Summary
</h2>
<p>
This article shows you how to start writing SharpDevelop AddIns. It is a
This articleshows you how to start writing SharpDevelop AddIns. It is a
complete walkthrough from creating a new project to creating the installation
package.
</p>
@ -601,9 +606,7 @@ will be extracted to %Application Data%\.ICSharpCode\SharpDevelop2\AddIns.<br>
@@ -601,9 +606,7 @@ will be extracted to %Application Data%\.ICSharpCode\SharpDevelop2\AddIns.<br>
18<sup>th</sup> July, 2006: Article published (based on SharpDevelop