|
C#言語のソースコード整形例 |
|
|
|
|
|
SourceFormatX は優れた構文解析エンジンを元に作られています。ですのであらゆるスタイルで書かれたソースコードを美しく整形することができます。以下の例のようなめちゃくちゃなコードでさえも、整形することが可能です。
|
これは極端な例ですが。SourceFormatXに搭載されている強力な C# / C Sharp 言語のパーサーエンジンの実力を感じて頂けるかと思います。
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();}}}
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();
}
}
}
再び手動でC#言語のソースコードを整形するために時を浪費しないで下さい! SourceFormatX体験版の無料ダウンロード!
|