Hot File

Adding your items to Visual Studio default files

View: 515    Dowload: 0   Comment: 0   Post by: hanhga  
Author: OriginalGriff   Category: Visual studio & .NET   Fields: Computers - Technology

0 point/2 review File has been tested

My code includes Regions: A Fields region, Properties region, Constructor region, and so forth, which I have to create manually when I create a new Form, UserControl, or project. Or, at least, I did, until I remembered how to change the existing VS templates.

Introduction

My code includes Regions: A Fields region, Properties region, Constructor region, and so forth, which I have to create manually when I create a new Form, UserControl, or project. Or, at least, I did, until I remembered how to change the existing VS templates.
 
I am assuming here that you have WinZip installed - if you don't, either get a free demo, or handle ZIP extract / insert yourself.
 
VS Templates are stored as text files with ZIPs in one of two directory structures, depending on your OS (assuming you installed VS in the default location)
 
For 32 bit:

   C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\

For 64 bit:

   C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\

In either case, the Class template is stored under:

   \ItemTemplates\CSharp\Code\1033\

In a file called "Class.Zip".
Important edit for Vista / Windows 7:
Before you go any further, you need to apply security attributes to allow you to modify the content of the zip files.
Right click the ItemTemplates folder, and select "Properties". In the resulting dialog, select the "Security" tab, and use the "Edit..." button to change priorities so that you can write and modify folder contents. If you do not, you will get "disk full" messages from WinZip when you try to save the files back.
End Vista / Windows 7 edit
 
Firstly: Open an explorer window in the template directory, and create a new folder called "Original". Copy all the zip files to this folder. That way, you can restore them to the original if you completely mess things up...
 
Double click the "Class.Zip" file, and open "Class.cs" for editing.
Replace the content with either your prefered items, or this:


using System;
using System.Collections.Generic;
$if$ ($targetframeworkversion$ == 3.5)using System.Linq;
$endif$using System.Text;
 
namespace $rootnamespace$
    {
    /// 

/// TODO: Class description ///

public class $safeitemrootname$ { #region Constants #endregion #region Fields #region Internal #endregion #region Property bases #endregion #endregion #region Properties #endregion #region Regular Expressions #endregion #region Enums #endregion #region Constructors ///

/// Default constructor ///

public $safeitemrootname$() { /// TODO: Default constructor } #endregion #region Events #region Event Constructors #endregion #region Event Handlers #endregion #endregion #region Public Methods #endregion #region Overrides #endregion #region Private Methods #endregion } }

Save the file, and update "class.zip" with the new version.
 
Ensure VS is not running (this may not be essential, but it can't hurt!)
 
Now open a new command prompt as Adminstrator.
Important edit for Vista / Windows 7:
If you do not use Administrator mode when you run this, you will get a "The operation could not be completed" dialog.
The easiest way to do this is to right click on the "Visual Studio Command Prompt" in the Visual Studio Tools menu of the "Start button...Programs" list and select "Run as Administrator"
End Vista / Windows 7 edit
 
Change to the appropriate directory:
64 bit

 

   cd "C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\"

 

32 bit

 

   cd "C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\"

 

Run this:

 

   devenv.exe /installvstemplates

 

Do note that this runs in the background, and may not be quick (depending on your computer).
 
Now each time you add a new class, it will contain your items.
 
You will probably want to repeat this for the
\ItemTemplates\CSharp\Windows Forms\1033\ files:

 

  CustomControl
  UserControl
  Form

 

 
And also the files under ProjectTemplates rather than ItemTemplates in order to include them with a new job!
 
IN EACH CASE, DO NOT FORGET TO COPY THE ORIGINAL FILES!

 

Adding your items to Visual Studio default files

Adding your items to Visual Studio default files Posted on 21-03-2014  My code includes Regions: A Fields region, Properties region, Constructor region, and so forth, which I have to create manually when I create a new Form, UserControl, or project. Or, at least, I did, until I remembered how to change the existing VS templates. 5/10 515

Comment:

To comment you must be logged in members.

Files with category

 
Newsletter Email

File suggestion for you

File top downloads

logo codetitle
Codetitle.com - library source code to share, download the file to the community
Copyright © 2015. All rights reserved. codetitle.com Develope by Vinagon .Ltd