Add guide lines to Visual Studio [translation]

Source: Internet
Author: User

This is a compilation that we can see today at http://www.codeproject.com/useritems/guidelines.as ..ArticleIs a good tool. You can also take a look at how to operate the registry. As follows:

 

 

Introduction

Introduction

When I logged on to codeproject this morning, their weekly poll asked the question, "How wide is your sourcecode? ". This led to a discussion in the forums, where Vikram posted a link to this article by Sara Ford:

When I browsed the codeproject this morning, I asked yourCodeHow long is the segment ?". This caused a discussion in the forum. Vikram provided a link to an article written by Sara Ford:

Http://blogs.msdn.com/saraford/archive/2004/11/15/257953.aspx

The article details a little hack that you can make to the registry so that one or more "Guidelines" can be dispalyed in Visual Studio. so the bottom line is, this end result of this article isn't really due to my own bright idea-the only original part of this is in creating a tool to perform the Registry hack for you with minimal effort on your part.

This article describes a tip: by modifying the registry, you can display one or more guide lines in Visual Studio. What I want to talk about is that I have come up with a better idea: to use a tool to complete the registry, you only need to use it.

I won't bother to rehash the content of the article here, as you can read it freely Sara's blog. I will simply address the tool, and what went into it.

I won't repeat the content of that article here-you can read Sara's blog (in fact, it is in the Registry's HKEY_CURRENT_USER/software/Microsoft/visualstudio/[vertion (such as 8.0)] /Add a key value such as ("Guides", RGB (, 0),) to text editor ). I only provide download of the tool and discuss its principles.

The tool

Tools

The tool is so simple it's almost silly to review it. it took me about 10 minutes to hack together from start to finish. basically, it allows you select a color to set the guidelines to, and to enter a list of column addresses to place the guidelines. click "Apply" and the changes are made. click "Remove" and the changes are removed. it's a no brainer.

This tool is too simple to review it. It took me 10 minutes to press it. Simply put, it allows you to set the color of the guide line and the position of the guide line. Click Apply to submit the changes and click remove to delete the changes.

The changes are made through some simple callto the registry.

You can modify the registry only.

Private void btnapply_click (Object sender, eventargs e) {If (txtpreview. Text! = "" & Txtlocations. Text! = "") {// Create a new keyregistrykey = registry. currentuser. opensubkey ("SOFTWARE \ Microsoft \" + "visualstudio \ 8.0 \ Text Editor", true); // set value of sub key. setvalue ("Guides", txtpreview. text); key. close ();}}
 
Private void btnremove_click (Object sender, eventargs e) {registrykey delkey = registry. currentuser. opensubkey ("SOFTWARE \ Microsoft \" + "visualstudio \ 8.0 \ Text Editor", true); delkey. deletevalue ("Guides"); dekkey. close ();}
The isnumeric Problem

Is it a number?

C # is a wonderful language, but every now and then you wander into a situation that leaves you scratching your head in disbelief. one of the things I wanted to do was to make sure that the list of guideline locations was a comma seperated list of integers. my first thought (being an old VB programmer at heart) was to simply split () the string and check to see if each value was a number by asking "I Snumeric ()"? But lo and behold, C # has no such function! The char type has a similar function, but not string.

C # is a wonderful language, but sometimes it will make you scratching your ears for suspicion and linger in the solution. For example, when I want to determine whether the position parameter of the guide line is a comma-separated number, my first thought is (I am an old VBProgramMember), Use spit () to extract and separate each vertex, and then use isnumeric () to determine whether it is a number. But you see, this function is not available in C! Char type has a similar function, but string does not.

My first attempt (and you might have downloaded this copy, see the update below) was to split () the string, and then "borrow" the function by stealing from VB, like this:

My first attempt was to split the () string first, and then borrow isnumeric () from VB ():

 
Private bool isnumeric (string value) {return Microsoft. VisualBasic. Information. isnumeric (value );}

That worked just fine for the most part, then I realized that you cocould still enter a value such a-9, or 9.5, And it wocould pass muster. while those values probably wouldn't hurt anything, they weren't helping it any either, so I came up with a new plan, and the one I shoshould have gone with in the first place, using a regular expression to validate the input. not only did this minimize a lot of code in my program, but it works better in the end.

In most cases it works well, but then I realized that you can still enter the numbers-9 and 9.5, or you can upload them to the heap. These values won't let the program report errors, but they are useless, so I have another plan-for the first part, I should use regular expressions to verify the input, it not only reduces the code of my program, but also works well.

 
Private bool verifylocations (string locations) {RegEx = new RegEx ("^ (\ d |,) * \ D * $"); Return RegEx. ismatch (locations. replace ("",""));}
  Source Code  download 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.