Tutorials to .com

Tutorials to .com » Dotnet » Control-and-components » Visual Studio.NET in the use of custom plug-ins to maximize your productivity (c)

Visual Studio.NET in the use of custom plug-ins to maximize your productivity (c)

Print View , by: iSee ,Total views: 14 ,Word Count: 900 ,Date: Thu, 21 May 2009 Time: 1:05 PM

How the plug-ins work?

In the previous chapter demonstrated to you InsertDate code is relatively simple, and auto-complete feature incredible feel.

I started from the object browser (Object Browser) to start, because he is very easy to let us learn from the object so he is a very good assistant. You can view the object you want to right-click and select Go to definition (Go To Definition) to satisfaction of class members to view. See Figure 4 the final results, you can view the list of members of a member of any of the prototype, or a member of the select first visit by the F1 help.




Figure 4 Object Browser

applicationObject object describes the plug-versus-host (host) applications, in this case the host (host) applications for Visual Studio. NET IDE. applicationObject methods in the realization of OnConnection. Found in the online help "DTE", or even in the wizard automatically generates the code for the statement "_DTE" type of variable applicationObject. In the application-level you will see her again a member of a number of interesting.

One of the members of ActiveDocument attribute (property), it describes the focus of the current document (document). This document is the operation you want to InsertDate documents. In the window has the focus and the focus of the relationship between the document under different circumstances, however, a very useful rule is that, regardless of whether the form has the focus will be the focus of the document are to be preserved.

ActiveDocument.Selection property returns a description of the current selection in the document object. c # because it is an ordinary object, so I forced him type it into TextSelectioni. ActiveDocument is a common category, because the document (the translator: similar to vc + + in the document type) is not necessary based on the text, like the design of a form document (the translator: to learn VC + + may be more familiar with the document type of inheritance, are not familiar with can take a look at the books in this regard). Selection as the end result is a general property of the class, I put it into the mandatory category type in the code we have the actual operation TextSelection type.

TextSelection paper describes a view (view), and the document actions and tools | options settings are used to state. He provided a lot of you may think of to modify the document properties and methods, as well as he can view the impact of the use of the (view), the currently selected content, insert location. If you have been recorded macro, you can see the use of TextSelection to capture the contents of the object.

InsertDate simple set up of the Text property value is the current date. Text similar to the same, all the action can be set up with the type of value. This means that all must be content to be replaced, if the contents of it will have no choice in the location of the cursor on the replacement, but you should pay attention to the current state of the insert or cover model.

Another method is to use the Insert function, this method allows you to control the placement of the text description of the location and can not redo an action. Use this method to replace the Text property to insert the contents of the code specified as follows:

((TextSelection) applicationObject.ActiveDocument.Selection). Insert (

DateTime.Now.ToString ( "yyyy-MM-dd"),

(int) EnvDTE.vsInsertFlags.vsInsertFlagsCollapseToEnd);

VsInsertFlags pointed out that in what way the text has been inserted where. Online help groups ignored vsInsertFlags documents, so I included in Figure 5 that part.

Now you understand by the plug-in is how to work, let us for the order to make a simple keyboard and the addition of a bonding menu.

Figure 5 vsInsertFlags value

vsInsertFlagsCollapseToEnd
The selection's current

contents are deleted before

performing the insertion, and

the TextSelection is left empty

at the end of the newly

inserted text.




vsInsertFlagsCollapseToStart


The selection's current

contents are deleted before

performing the insertion, and

the TextSelection is left empty

at the beginning of the newly

inserted text.




vsInsertFlagsContainNewText


The selection's current

contents are replaced with the

inserted text, and the

TextSelection is left containing

the new text.




vsInsertFlagsInsertAtStart
The inserted text is placed at

the beginning of the

TextSelection, and the

resulting TextSelection

contains both the new and

previous text.




vsInsertFlagsInsertAtEnd


The inserted text is placed at

the end of the TextSelection,

and the resulting

TextSelection contains both

the new and previous text.





.Net Control and components Articles


Can't Find What You're Looking For?


Rating: Not yet rated

Comments

No comments posted.