C# Code Formatting Demo 2


FormatCode Code Formatter is based on serveral powerful syntax parser engines so you can exactly control the appearance of your source code. Here is the code formatting demo of FormatCode C# Code Formatter to prove the ability of code formatting functions of FormatCode:

   /* Before Code Formatting */

   using System;using System.Drawing;using System.Collections;using
   System.ComponentModel;using System.Windows.Forms;using System.Data;using
   VSNET.Menu;namespace MyDrawMenu{/// <summary>
   /// Summary description for Form1.
   /// </summary>
   public class Form1:System.Windows.Forms.Form{private const String BMPPATHSTR=
   "C:\\DotNetApp\\VSNETMenu\\Pictures\\";private System.Windows.Forms.Button
   button1;private System.ComponentModel.Container components=null;private
   System.Windows.Forms.MainMenu MainMenu1;private System.Windows.Forms.MenuItem
   mItems1;private System.Windows.Forms.MenuItem mItems2;private
   System.Windows.Forms.MenuItem mItemsFile;private System.Windows.Forms.MenuItem
   mItemsHelp;protected override void Dispose(bool disposing){if(disposing){if(
   components!=null){components.Dispose();}}base.Dispose(disposing);}
   /// <summary>
   /// Required method for Designer support - do not modify
   /// the contents of this method with the code editor.
   /// </summary>
   private void InitializeComponent(){this.button1=new System.Windows.Forms.Button
   ();this.SuspendLayout();this.button1.Location=new System.Drawing.Point(104,168)
   ;this.button1.Name="button1";this.button1.Size=new System.Drawing.Size(80,24);
   this.button1.TabIndex=0;this.button1.Text="Exit";this.button1.Click+=new
   System.EventHandler(this.button1_Click);VSNET.Menu.IconMenuStyle MenuStyle=
   VSNET.Menu.IconMenuStyle.VSNet;MainMenu1=new MainMenu();mItemsFile=new MenuItem
   ("&File");mItemsFile.Index=0;mItemsHelp=new MenuItem("&Help");mItemsHelp.Index=
   1;IconMenuItem iMenuItem=new IconMenuItem();System.Drawing.Bitmap Bitmap1=new
   Bitmap(BMPPATHSTR+"Open.bmp");mItems1=iMenuItem.MenuItemCreator(MenuStyle,
   "&Open",Bitmap1,null);Bitmap Bitmap2=new Bitmap(BMPPATHSTR+"Save.bmp");mItems2=
   iMenuItem.MenuItemCreator(MenuStyle,"&Exit",Bitmap2,null);
   this.mItemsFile.MenuItems.AddRange(new System.Windows.Forms.MenuItem[]{
   this.mItems1,this.mItems2});this.MainMenu1.MenuItems.AddRange(new
   System.Windows.Forms.MenuItem[]{this.mItemsFile,this.mItemsHelp});this.Menu=
   this.MainMenu1;this.AutoScaleBaseSize=new System.Drawing.Size(6,14);
   this.ClientSize=new System.Drawing.Size(292,273);this.Controls.AddRange(new
   System.Windows.Forms.Control[]{this.button1});this.Name="Form1";this.Text=
   "Form1";this.ResumeLayout(false);}[STAThread]static void Main(){Application.Run
   (new Form1());}private void button1_Click(object sender,System.EventArgs e){
   this.Close();}}}


   /* After Code Formatting */

   using System;
   using System.Drawing;
   using System.Collections;
   using System.ComponentModel;
   using System.Windows.Forms;
   using System.Data;
   using VSNET.Menu;
   namespace MyDrawMenu
   {

     /// <summary>
     /// Summary description for Form1.
     /// </summary>

     public class Form1: System.Windows.Forms.Form
     {
       private const String BMPPATHSTR = "C:\\DotNetApp\\VSNETMenu\\Pictures\\";
       private System.Windows.Forms.Button button1;
       private System.ComponentModel.Container components = null;
       private System.Windows.Forms.MainMenu MainMenu1;
       private System.Windows.Forms.MenuItem mItems1;
       private System.Windows.Forms.MenuItem mItems2;
       private System.Windows.Forms.MenuItem mItemsFile;
       private System.Windows.Forms.MenuItem mItemsHelp;
       protected override void Dispose(bool disposing)
       {
         if (disposing)
         {
           if (components != null)
           {
             components.Dispose();
           }
         }
         base.Dispose(disposing);
       }

       /// <summary>
       /// Required method for Designer support - do not modify
       /// the contents of this method with the code editor.
       /// </summary>

       private void InitializeComponent()
       {
         this.button1 = new System.Windows.Forms.Button();
         this.SuspendLayout();
         this.button1.Location = new System.Drawing.Point(104, 168);
         this.button1.Name = "button1";
         this.button1.Size = new System.Drawing.Size(80, 24);
         this.button1.TabIndex = 0;
         this.button1.Text = "Exit";
         this.button1.Click += new System.EventHandler(this.button1_Click);
         VSNET.Menu.IconMenuStyle MenuStyle = VSNET.Menu.IconMenuStyle.VSNet;
         MainMenu1 = new MainMenu();
         mItemsFile = new MenuItem("&File");
         mItemsFile.Index = 0;
         mItemsHelp = new MenuItem("&Help");
         mItemsHelp.Index = 1;
         IconMenuItem iMenuItem = new IconMenuItem();
         System.Drawing.Bitmap Bitmap1 = new Bitmap(BMPPATHSTR + "Open.bmp");
         mItems1 = iMenuItem.MenuItemCreator(MenuStyle, "&Open", Bitmap1, null);
         Bitmap Bitmap2 = new Bitmap(BMPPATHSTR + "Save.bmp");
         mItems2 = iMenuItem.MenuItemCreator(MenuStyle, "&Exit", Bitmap2, null);
         this.mItemsFile.MenuItems.AddRange(new System.Windows.Forms.MenuItem[]
         {
           this.mItems1, this.mItems2
         }
         );
         this.MainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[]
         {
           this.mItemsFile, this.mItemsHelp
         }
         );
         this.Menu = this.MainMenu1;
         this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
         this.ClientSize = new System.Drawing.Size(292, 273);
         this.Controls.AddRange(new System.Windows.Forms.Control[]
         {
           this.button1
         }
         );
         this.Name = "Form1";
         this.Text = "Form1";
         this.ResumeLayout(false);
       }
       [STAThread] static void Main()
       {
         Application.Run(new Form1());
       }
       private void button1_Click(object sender, System.EventArgs e)
       {
         this.Close();
       }
     }
   }


Click here to preview the C# Code Formatting Demo 1.

With FormatCode C# Code Formatters, you can format and transform any foreign C# source code to meet your preferred coding style or any common code convention in several seconds!