以下のソフトはすべてフリーで配布しておりますが
ここにあるソフトを使用して万一トラブルが発生しても、当方は一切責任を負えませんのでご了承下さい。

C# フロン タス zero3  csf_zero3.zip
プログラム・ソース     下記にあります

■変更履歴
2005/9/03
・公開


 
■解説
c# の 簡易 GUI 開発環境です。

Visual Studio .NETなんて高くて買えないって人のために作りました。(ていうか筆者が買えなかったので)

使い方
・ソースファイルのところにドラッグ&ドロップすると、プロジェクトに追加されます。
 当然メニューから開いても可です。
・プロジェクトから削除するには右クリックメニューからして下さい。

・エディタは各自で用意してください(秀丸、サクラエディタ、メモ帳、etc…)。
 ファイル名ダブルクリックで、開きます。

・コンパイル・ボタンを押すとプロジェクトにあるファイルがまとめてコンパイルされ、1つのexeファイルになります。
 (C# にはc/c++のようなリンカはないです)

・設定ボタンで、コンパイラのディレクトリ指定などができます。

・出力されるファイル名は、
 自動モードなら、ソースファイルリストにある一番上のファイル名+".exe"です。
 指定モードなら、自分でファイル名を指定する必要があります。


c#コンパイラは Microsoft が タダで配ってますのでそちらでダウンロードしてきてください。
.NET Framework SDK っていうのがそれです。
Microsoft .NET Framework Version 1.1 再頒布可能パッケージ
http://www.microsoft.com/downloads/details.aspx?FamilyID=262d25e3-f589-4842-8157-034d1e7cf3a3&displaylang=ja

Microsoft .NET Framework Version 1.1 日本語 Language Pack
http://www.microsoft.com/downloads/details.aspx?FamilyId=04DBAF2E-61ED-43F4-8D2A-CCB2BAB7B8EB&displaylang=ja

.NET Framework SDK Version 1.1
http://www.microsoft.com/downloads/details.aspx?FamilyId=9B3A2CA6-3647-4070-9F41-A333C6B9181D&displaylang=ja



C# フロンタス zero3 ソース


using System.Windows.Forms;
using System.Drawing;
using System.IO;
using System.Collections; // ArrayList
using System;
using System.Diagnostics; // 外部プログラム

// -------------------------------------------
// delegate型 宣言
// -------------------------------------------

// void delegate
delegate void VoidCallback();

// 出力ファイル名更新用
delegate void Filename_Callback(string fullpath);

// -------------------------------------------
// アプリケーション #define
// -------------------------------------------
class APP_DEFINE {
public const string APP_TITLE = "C# フロンタス zero3";
};
// -------------------------------------------
// アプリケーション データ
// -------------------------------------------
class APP_INFO {
// コンパイラ・ディレクトリ
public string m_complier_filename = @"";
};

// -------------------------------------------
// 参照ボタン・コントロール
// -------------------------------------------
class RefButton : Button {

OpenFileDialog m_ofd = new OpenFileDialog(); // ファイルを開くダイアログ
public TextBox m_target_textbox = null; // 反映先エディットボックス
string m_filename; // ファイル名
public event VoidCallback OnPressOK; // OK ボタン 押下時デリゲート
public event VoidCallback OnPressCancel; // キャンセルボタン 押下時デリゲート

// 参照ボタン・コンストラクタ
public RefButton(){
Text = "参照";
OnPressOK += new VoidCallback(OnPressOK_Default);
OnPressCancel += new VoidCallback(OnPressCancel_Default);
MouseUp += new MouseEventHandler(OnMouseUp);
}

// OK ボタン 押下時
void OnPressOK_Default(){
m_filename = m_ofd.FileName;
if (m_target_textbox != null) m_target_textbox.Text = m_filename;
}

// キャンセルボタン 押下時
void OnPressCancel_Default(){
m_filename = "";
}

// 右クリックメニュー
private void OnMouseUp(object sender , MouseEventArgs e) {

// m_ofd.Title = "???" ; // タイトルバーの文字列
// m_ofd.InitialDirectory = "???" ; // 最初に表示されるディレクトリ
m_ofd.Filter = "C#ファイル (*.cs)|*.cs|すべてのファイル (*.*)|*.*" ; //「ファイルの種類」を指定

if (m_ofd.ShowDialog() == DialogResult.OK) {
OnPressOK(); // OK ボタン 押下時
}
else {
OnPressCancel(); // キャンセルボタン 押下時
}
}
};

// -------------------------------------------
// プロジェクト設定データ
// -------------------------------------------
class PROJECT_ESTAB {
// 実行ファイル形式
public enum ID_TARGET_TYPE : int { ID_CON, ID_WIN , ID_DLL , ID_MOD }

public int m_target_type = (int)ID_TARGET_TYPE.ID_WIN; // 実行ファイル形式
public string m_output_filename = @""; // 出力ファイル名
public bool m_output_filename_autoflag=true; // 出力ファイル名・自動設定

// 出力ファイル名 更新・コールバックより呼ばれる
public void UpdateOutputFilename(string fullpath){
// 出力ファイル名自動でないならreturn
if (!m_output_filename_autoflag) return;

// ソースファイル数がゼロになったら出力ファイル名を消す
if (fullpath=="") {
m_output_filename="";
return;
}
// 出力ファイル名がまだ無ければ設定
else if (m_output_filename=="") {
m_output_filename = fullpath;
}

// 拡張子を更新
m_output_filename = Path.GetFullPath(m_output_filename);
switch(m_target_type){
case (int)ID_TARGET_TYPE.ID_CON:
case (int)ID_TARGET_TYPE.ID_WIN:
m_output_filename = Path.ChangeExtension(m_output_filename, ".exe");
break;
case (int)ID_TARGET_TYPE.ID_DLL:
m_output_filename = Path.ChangeExtension(m_output_filename, ".dll");
break;
}
}
};
// -------------------------------------------
// ツリービュー用ファイルデータ
// -------------------------------------------
class PROJECT_SRC_FILEITEM {
public string m_fullpath;
}


// -------------------------------------------
// ソースファイルのリスト表示ツリービュー
// -------------------------------------------
class SRC_FILE_TREEVIEW : TreeView {
// コールバック
public event Filename_Callback UpdateOutputFilename;

// コンストラクタ
public SRC_FILE_TREEVIEW(){
// イベントハンドラを追加
DragEnter += new DragEventHandler(OnDragEnter);
DragDrop += new DragEventHandler(OnDragDrop);
MouseUp += new MouseEventHandler(OnRightMouseUp);
DoubleClick += new System.EventHandler(OnDoubleClick);

// ドロップを受け入れる
AllowDrop = true;
}

// 右クリックメニュー
private void OnRightMouseUp(object sender , MouseEventArgs e) {
if (e.Button == MouseButtons.Right){
MenuItem[] mi = {
new MenuItem("削除", new System.EventHandler(RemoveSrcFile)) ,
new MenuItem("開く", new System.EventHandler(OpenSrcFile)) ,
new MenuItem("ファイル情報", new System.EventHandler(ShowFileInfo)) ,

};
ContextMenu cm = new ContextMenu(mi);
cm.Show(this , new Point(e.X , e.Y));
}
}

// 削除
private void RemoveSrcFile(object obj , System.EventArgs e) {
if (SelectedNode==null) return;
MenuItem mi = (MenuItem)obj;
if (Nodes.Count>0){
Nodes.Remove(SelectedNode);
}

// ソースファイル数がゼロになったら出力ファイル名を消す
if (Nodes.Count==0){
UpdateOutputFilename("");
}
}

// ファイル開く
private void OpenSrcFile(object obj , System.EventArgs e) {
if (SelectedNode==null) return;
PROJECT_SRC_FILEITEM item = (PROJECT_SRC_FILEITEM)SelectedNode.Tag;
System.Diagnostics.Process.Start(item.m_fullpath);
}

// ファイル情報
private void ShowFileInfo(object obj , System.EventArgs e) {
if (SelectedNode==null) return;
PROJECT_SRC_FILEITEM item = (PROJECT_SRC_FILEITEM)SelectedNode.Tag;
MessageBox.Show(item.m_fullpath);
}

// ダブルクリック
private void OnDoubleClick(object sender, System.EventArgs e){
OpenSrcFile(sender, (System.EventArgs)e);
}

// ビュー内にドラッグされた時
private void OnDragEnter(object sender, DragEventArgs e){
e.Effect = DragDropEffects.All;
}

// ソースファイル追加
public void AddSrcFile(string fullpath){
TreeNode tn = new TreeNode();
PROJECT_SRC_FILEITEM item = new PROJECT_SRC_FILEITEM();
tn.Text = Path.GetFileName(fullpath); // ファイル名のみ
item.m_fullpath = fullpath; // フルパス
tn.Tag = item;
Nodes.Add(tn);

UpdateOutputFilename(fullpath);
}


// ビュー内にドロップされたとき
private void OnDragDrop(object sender, DragEventArgs e){
if (e.Data.GetDataPresent(DataFormats.FileDrop)) {
foreach (string filename in (string[])e.Data.GetData(DataFormats.FileDrop)) {
AddSrcFile(filename);
}
}
}

};

// -------------------------------------------
// プロジェクトの設定ダイアログ
// -------------------------------------------
class EstabForm : Form {
// 設定フォーム・メンバ変数 ==========================
GroupBox m_compiler_gbox = new GroupBox(); // コンパイラ名・グループボックス
RefButton m_compiler_ref_button = new RefButton(); // コンパイラ名・参照ボタン
TextBox m_compiler_ref_edit = new TextBox(); // コンパイラ名・エディットボックス

GroupBox m_outfile_labelbox = new GroupBox(); // 出力ファイル名・グループボックス
TextBox m_outfile_edit = new TextBox(); // 出力ファイル名・エディットボックス
RadioButton[] m_outfile_radio = new RadioButton[2]; // 出力ファイル名・ラジオボタン

GroupBox m_target_type_labelbox = new GroupBox(); // 実行ファイル形式・グループボックス
RadioButton[] m_target_type_radio = new RadioButton[4]; // 実行ファイル形式・ラジオボタン

Button m_ok_button = new Button(); // OK ボタン
Button m_cancel_button = new Button(); // キャンセル・ボタン

// 設定フォーム・メンバ関数 ==========================
// 設定フォーム・コンストラクタ
public EstabForm(){
Text = @"コンパイル設定";
int posy = 5, tmp_posy;
FormBorderStyle = FormBorderStyle.FixedToolWindow;

ShowInTaskbar = false; // このフォームをタスクバーに表示しない

// --------------------------------------------

// コンパイラ・グループボックス
m_compiler_gbox.Bounds = new Rectangle(5 , posy, 250 , 55);
m_compiler_gbox.Text = @"コンパイラ (csc.exe)";
Controls.Add(m_compiler_gbox);

tmp_posy = (int)Math.Ceiling(m_compiler_gbox.Font.GetHeight()) +5; // y座標更新

// コンパイラ名エディットボックス
m_compiler_ref_edit.Location = new System.Drawing.Point(10, tmp_posy);
m_compiler_ref_edit.Size = new Size(180 , 15);
m_compiler_gbox.Controls.Add(m_compiler_ref_edit);

m_compiler_ref_button.Bounds = new Rectangle(200, tmp_posy, 40 , 25);
m_compiler_ref_button.m_target_textbox = m_compiler_ref_edit;
m_compiler_gbox.Controls.Add(m_compiler_ref_button);

posy += (int)Math.Ceiling(m_compiler_gbox.Height) ; // y座標更新

// --------------------------------------------
posy += 10;

// 出力ファイル名・グループボックス
m_outfile_labelbox.Bounds = new Rectangle(5 , posy, 250 , 65);
m_outfile_labelbox.Text = @"出力ファイル名";
Controls.Add(m_outfile_labelbox);

posy += (int)Math.Ceiling(m_outfile_labelbox.Font.GetHeight()) ; // y座標更新
tmp_posy = (int)Math.Ceiling(m_outfile_labelbox.Font.GetHeight()) ; // y座標更新

// 出力ファイル名・自動・指定ラジオボタン
int i;
string[] txt2 = { "自動", "指定" };
for(i = 0 ; i < m_outfile_radio.Length ; i++) {
m_outfile_radio[i] = new RadioButton();
m_outfile_radio[i].Bounds = new Rectangle(20 , tmp_posy + 2 + 22 * i , 60 , 25);
m_outfile_radio[i].Text = txt2[i];
m_outfile_radio[i].MouseUp += new MouseEventHandler(OnOutputRadio);
m_outfile_labelbox.Controls.Add(m_outfile_radio[i]);
}

tmp_posy += (int)Math.Ceiling(m_outfile_radio[0].Font.GetHeight())/2 ;

// 出力ファイル名エディットボックス
m_outfile_edit.Location = new System.Drawing.Point(85, tmp_posy + tmp_posy/2);
m_outfile_edit.Size = new Size(150 , 30);
m_outfile_labelbox.Controls.Add(m_outfile_edit);

tmp_posy += (int)Math.Ceiling(m_outfile_radio[0].Font.GetHeight()) ;
tmp_posy += (int)Math.Ceiling(m_outfile_radio[1].Font.GetHeight()) ;
tmp_posy += (int)Math.Ceiling(m_outfile_labelbox.Font.GetHeight()) ; // y座標更新
tmp_posy += 10;

m_outfile_labelbox.Size = new Size(250 , tmp_posy);
// --------------------------------------------
posy += tmp_posy + 5;

// 実行ファイル形式・グループボックス
m_target_type_labelbox.Bounds = new Rectangle(5 , posy, 250 , 25);
m_target_type_labelbox.Text = @"実行ファイル形式";
Controls.Add(m_target_type_labelbox);

tmp_posy = 5+(int)Math.Ceiling(m_target_type_labelbox.Font.GetHeight()) ; // y座標

string[] txt = {
"Windows アプリケーション (.exe)",
"コンソール アプリケーション (.exe)",
"ダイナミック リンク ライブラリ (.dll)",
// "モジュール (.netmodule)" // 暫定で非サポート
};

// 実行ファイル形式・ラジオボタン
for(i = 0 ; i < txt.Length ; i++) {
m_target_type_radio[i] = new RadioButton();
m_target_type_radio[i].Bounds = new Rectangle(20 , tmp_posy, 220 , 25);
m_target_type_radio[i].Text = txt[i];
m_target_type_labelbox.Controls.Add(m_target_type_radio[i]);

tmp_posy += (int)m_target_type_radio[i].Height; // y座標更新
}
tmp_posy += (int)Math.Ceiling(m_target_type_labelbox.Font.GetHeight()) ; // y座標更新
m_target_type_labelbox.Size = new Size(250 , tmp_posy);

posy += 10 + tmp_posy;

// OKボタン/キャンセルボタン
m_ok_button.Bounds = new Rectangle(25 , posy, 90 , 25); // 位置サイズ
m_cancel_button.Bounds = new Rectangle(125 , posy, 90 , 25);
m_ok_button.Text = "OK"; // Text
m_cancel_button.Text = "キャンセル";

AcceptButton = m_ok_button; // Enter キー対応
CancelButton = m_cancel_button; // Esc キー対応

m_ok_button.DialogResult = DialogResult.OK; // ダイアログ終了値「OK」
m_cancel_button.DialogResult = DialogResult.Cancel; // ダイアログ終了値「Cancel」
Controls.Add(m_ok_button); // コントロール登録
Controls.Add(m_cancel_button); // コントロール登録
posy += m_ok_button.Height; // y座標更新

Size = new Size(280, posy +10 +30); // キャプション・サイズも足す
}


// 出力ファイル名ラジオボタン押下時
public void OnOutputRadio(object sender , MouseEventArgs e) {
if (m_outfile_radio[1].Checked){
m_outfile_edit.ReadOnly = false; // ファイル名・指定モード
}
else {
m_outfile_edit.ReadOnly = true; // ファイル名・自動モード
}
}

// 設定を各コントロールに適用
public void set_estab(ref PROJECT_ESTAB ref_prj_est, ref APP_INFO ref_app_info){
if (ref_prj_est.m_output_filename_autoflag){
m_outfile_radio[0].Checked = true;
m_outfile_edit.ReadOnly = true; // ファイル名・自動モード
}
else {
m_outfile_radio[1].Checked = true;
m_outfile_edit.ReadOnly = false; // ファイル名・指定モード
}
// 出力ファイル名設定
m_outfile_edit.Text = ref_prj_est.m_output_filename;

// コンパイラ・ファイル名設定
m_compiler_ref_edit.Text = ref_app_info.m_complier_filename;

// 実行ファイル形式
switch(ref_prj_est.m_target_type){
case (int)PROJECT_ESTAB.ID_TARGET_TYPE.ID_WIN:
m_target_type_radio[0].Checked = true;
break;
case (int)PROJECT_ESTAB.ID_TARGET_TYPE.ID_CON :
m_target_type_radio[1].Checked = true;
break;
case (int)PROJECT_ESTAB.ID_TARGET_TYPE.ID_DLL:
m_target_type_radio[2].Checked = true;
break;
case (int)PROJECT_ESTAB.ID_TARGET_TYPE.ID_MOD :
m_target_type_radio[3].Checked = true;
break;
}
}

// 各コントロールからプロジェクト設定に適用
public void get_estab(ref PROJECT_ESTAB ref_prj_est){
// 出力ファイル名
if (m_outfile_radio[0].Checked){
ref_prj_est.m_output_filename_autoflag = true; // ファイル名・自動モード
}
else {
ref_prj_est.m_output_filename_autoflag = false; // ファイル名・指定モード
}
ref_prj_est.m_output_filename = m_outfile_edit.Text;

// 実行ファイル形式
if (m_target_type_radio[0].Checked){ // Windows アプリケーション
ref_prj_est.m_target_type = (int)PROJECT_ESTAB.ID_TARGET_TYPE.ID_WIN;
}
else if(m_target_type_radio[1].Checked){ // コンソール・アプリケーション
ref_prj_est.m_target_type = (int)PROJECT_ESTAB.ID_TARGET_TYPE.ID_CON;
}
else if(m_target_type_radio[2].Checked){ // DLL
ref_prj_est.m_target_type = (int)PROJECT_ESTAB.ID_TARGET_TYPE.ID_DLL;
}
else if(m_target_type_radio[3].Checked){
ref_prj_est.m_target_type = (int)PROJECT_ESTAB.ID_TARGET_TYPE.ID_MOD;
}
}
}

// *******************************************
// メインウィンドウ・クラス
// *******************************************
class WinMain : Form {
TextBox m_complie_log_edit = new TextBox(); // 出力結果エディットボックス
SRC_FILE_TREEVIEW m_src_file_listwin = new SRC_FILE_TREEVIEW();// ソースファイル・ツリービュー

Label m_prj_file_label = new Label(); // ソースファイル・ラベル
Label m_complie_log_label = new Label(); // 出力結果ラベル

Button m_compile_button = new Button(); // コンパイル・ボタン
Button m_exe_button = new Button(); // 実行ボタン
Button m_estab_button = new Button(); // 設定ボタン

PROJECT_ESTAB m_prj_estab = new PROJECT_ESTAB(); // プロジェクト設定
APP_INFO m_app_info = new APP_INFO(); // アプリケーション情報


// アプリケーション起動
public static void Main(string[] args) {
Application.Run(new WinMain());
}

// サイズ変更時
private void OnAppResize(object sender, System.EventArgs e){
int client_height = Height - SystemInformation.CaptionHeight - SystemInformation.MenuHeight;
int client_width = Width;
//Size = new Size(350 , 315);
// 実行・ボタン作成
m_exe_button.Left = client_width -180;

// 設定・ボタン作成
m_estab_button.Left = client_width -70;

// コンパイル・ボタン作成
m_compile_button.Text = "コンパイル";
m_compile_button.Left = client_width -180;

// プロジェクト・ファイル・リスト
m_src_file_listwin.Width = client_width -195;

// コンパイル結果エディットボックス
m_complie_log_edit.Width = client_width - m_complie_log_edit.Left-20;
m_complie_log_edit.Height = client_height - m_complie_log_edit.Top -20;
}

// コンパイラ情報
private void SetCompiler(){
// コンパイラ名セット済みならreturn
if (m_app_info.m_complier_filename != "") return;

// デフォルト
string csc11_4322 = @"C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\csc.exe";
if (File.Exists(csc11_4322)){
m_app_info.m_complier_filename = csc11_4322;
}
else {
m_app_info.m_complier_filename = "";
}
}

public enum EN_LOAD_MODE : int { ID_NONE, ID_COMPILER };

// アプリケーション設定読込み
private void load_ini_file(){
string file_name = "csf.ini";
if (!File.Exists(file_name)) return; // ファイルの有無をチェック
int load_mode = (int)EN_LOAD_MODE.ID_NONE;
string line;

StreamReader reader = new StreamReader(file_name,
System.Text.Encoding.GetEncoding("Shift_JIS")) ;
while ((line = reader.ReadLine()) != null) {
if (line == "") continue;
if (line == "[compiler]") load_mode = (int)EN_LOAD_MODE.ID_COMPILER;
else {
switch(load_mode){
case (int)EN_LOAD_MODE.ID_COMPILER :
load_mode = (int)EN_LOAD_MODE.ID_NONE;
m_app_info.m_complier_filename = line;
break;
}
}
}
reader.Close() ;
}

// アプリケーション設定保存
private void save_ini_file() {
string file_name = "csf.ini";
StreamWriter writer = new StreamWriter(file_name,
false, // 上書き ( true = 追加 )
System.Text.Encoding.GetEncoding("Shift_JIS")) ;

// WriteLine() は、自動的に、行末コード "\r\n" も書き込む。
writer.WriteLine("[compiler]") ;
writer.WriteLine(m_app_info.m_complier_filename) ;

writer.Close() ;
}

// アプリケーション終了時
private void OnAppClosing(Object sender, EventArgs e){
save_ini_file(); // アプリケーション設定保存
}

// アプリケーション起動(コンストラクタ)
public WinMain() {
// アプリケーション・タイトル
Text = APP_DEFINE.APP_TITLE;

// コンパイラ名初期化
load_ini_file(); // アプリケーション設定読込み
SetCompiler();

Application.ApplicationExit += new EventHandler(OnAppClosing);
Resize += new EventHandler(OnAppResize);

// 出力ファイル名更新コールバック
m_src_file_listwin.UpdateOutputFilename
+= new Filename_Callback(m_prj_estab.UpdateOutputFilename);

Size = new Size(350 , 315);
// メニュー作成
MainMenu mm = new MainMenu();
MenuItem[] mi_file = {
new MenuItem("開く(&O)", new System.EventHandler(FileOpenMenuClick)) ,
new MenuItem("終了(&Q)", new System.EventHandler(ExitMenuClick))
};
mm.MenuItems.Add("ファイル(&F)" , mi_file);
MenuItem[] mi_build = {
new MenuItem("コンパイル(&C)", new System.EventHandler(ComplieMenuClick)) ,
new MenuItem("実行(&E)", new System.EventHandler(ExeMenuClick)) ,
new MenuItem("設定(&S)", new System.EventHandler(EstabMenuClick))
};
mm.MenuItems.Add("ビルド(&B)", mi_build);
Menu = mm;

// コンパイル・ボタン作成
m_compile_button.Text = "コンパイル";
m_compile_button.Bounds = new Rectangle(170 , 10 , 100, 50);
m_compile_button.MouseUp += new MouseEventHandler(OnComplieButton);
Controls.Add(m_compile_button);

// 実行・ボタン作成
m_exe_button.Text = "実行";
m_exe_button.Bounds = new Rectangle(170 , 70 , 100, 30);
m_exe_button.MouseUp += new MouseEventHandler(OnExeButton);
Controls.Add(m_exe_button);

// 設定・ボタン作成
m_estab_button.Text = "設定";
m_estab_button.Bounds = new Rectangle(280 , 20 , 50, 40);
m_estab_button.MouseUp += new MouseEventHandler(OnEstabButton);
Controls.Add(m_estab_button);

// コンパイル結果・出力用テキストボックス
m_complie_log_edit.ReadOnly = true;
m_complie_log_edit.Multiline = true;
m_complie_log_edit.Bounds = new Rectangle(5 , 120 , 320, 120);
m_complie_log_edit.WordWrap = false;
m_complie_log_edit.ScrollBars = ScrollBars.Both;
Controls.Add(m_complie_log_edit);

// プロジェクト・ファイル・リスト
m_src_file_listwin.Location = new System.Drawing.Point(5, 20);
m_src_file_listwin.Size = new Size(150 , 80);
Controls.Add(m_src_file_listwin);

// ソースファイル・ラベル
m_prj_file_label.Location = new System.Drawing.Point(5, 5);
m_prj_file_label.AutoSize =true;
m_prj_file_label.Text = @"ソースファイル";
Controls.Add(m_prj_file_label);

// コンパイル結果・出力・ラベル
m_complie_log_label.Location = new System.Drawing.Point(5, 105);
m_complie_log_label.AutoSize =true;
m_complie_log_label.Text = @"コンパイル結果";
Controls.Add(m_complie_log_label);
}

// ========メニュー選択時===============================

// ファイル開く・メニュー
private void FileOpenMenuClick(object obj , System.EventArgs e) {
OpenFileDialog ofd = new OpenFileDialog();
// ofd.Title = "???" ; // タイトルバーの文字列
// ofd.InitialDirectory = "???" ; // 最初に表示されるディレクトリ
ofd.Filter = "C#ファイル (*.cs)|*.cs|すべてのファイル (*.*)|*.*" ; //「ファイルの種類」を指定

if (ofd.ShowDialog() == DialogResult.OK) {
m_src_file_listwin.AddSrcFile(ofd.FileName) ;
}
}

// 終了メニュー
private void ExitMenuClick(object obj , System.EventArgs e) {
Application.Exit() ;
}

// コンパイル・メニュー
private void ComplieMenuClick(object obj , System.EventArgs e) { DoComplie(); }

// 実行メニュー
private void ExeMenuClick(object obj , System.EventArgs e) { DoExecute(); }

// 設定メニュー
private void EstabMenuClick(object obj , System.EventArgs e) { CallEstabDialog(); }

// =====================================================


// ========ボタン押下時===============================

// 設定ボタン押下時
private void OnEstabButton(object sender, MouseEventArgs e) { CallEstabDialog(); }

// 実行ボタン押下時
private void OnExeButton(object sender, MouseEventArgs e) { DoExecute(); }

// コンパイルボタン押下時
private void OnComplieButton(object sender , MouseEventArgs e) { DoComplie(); }

// ==============================================

// 設定ダイアログ呼び出し
private void CallEstabDialog() {
EstabForm ef = new EstabForm();
ef.Location = new System.Drawing.Point(5, 105);
ef.set_estab(ref m_prj_estab, ref m_app_info);
ef.ShowDialog(this);

if (ef.DialogResult==DialogResult.OK) ef.get_estab(ref m_prj_estab);
}

// 作成ファイル実行
private void DoExecute() {
if (m_prj_estab.m_output_filename==""){
MessageBox.Show("実行ファイルがありません");
return;
}

if (m_prj_estab.m_target_type==(int)PROJECT_ESTAB.ID_TARGET_TYPE.ID_CON){
// 実行
Process p = new Process();
p.StartInfo.FileName = "cmd"; //起動するファイル名
p.StartInfo.Arguments = "/k "+ @""""+ m_prj_estab.m_output_filename + @""""; //起動時の引数
p.Start(); // コンパイル実行

}
else {
System.Diagnostics.Process.Start(m_prj_estab.m_output_filename);
}
}

// コンパイル
private void DoComplie() {
// 出力結果をクリアする
m_complie_log_edit.Text = @"";

// cs ソースファイルがない
if (m_src_file_listwin.GetNodeCount(true)==0){
MessageBox.Show("ファイルがありません");
return;
}

// 開始時間
m_complie_log_edit.Text = "ビルド開始: " + DateTime.Now.ToString() +"\r\n";

// 実行ファイル形式
System.Text.StringBuilder argument = new System.Text.StringBuilder();
switch(m_prj_estab.m_target_type){
case (int)PROJECT_ESTAB.ID_TARGET_TYPE.ID_CON :
break;
case (int)PROJECT_ESTAB.ID_TARGET_TYPE.ID_WIN: // Windows アプリケーション
argument.Append("/t:winexe ");
break;
case (int)PROJECT_ESTAB.ID_TARGET_TYPE.ID_DLL: // ダイナミック・リンク・ライブラリ
argument.Append("/target:library ");
break;
case (int)PROJECT_ESTAB.ID_TARGET_TYPE.ID_MOD :
break;
}

// ソースファイルを引数に入れる
for(int i=0;i<m_src_file_listwin.Nodes.Count;i++){
PROJECT_SRC_FILEITEM sf = (PROJECT_SRC_FILEITEM)m_src_file_listwin.Nodes[i].Tag;
argument.Append(@"""");
argument.Append(sf.m_fullpath);
argument.Append(@""" "); // " は""
}

argument.Append("/optimize "); // 最適化

if (m_app_info.m_complier_filename=="") return;

// 実行
Process p = new Process();
p.StartInfo.FileName = m_app_info.m_complier_filename; //起動するファイル名
p.StartInfo.Arguments = argument.ToString(); //起動時の引数
p.StartInfo.RedirectStandardInput = true; // 入力リダイレクト
p.StartInfo.RedirectStandardOutput = true; // 出力リダイレクト
p.StartInfo.CreateNoWindow = true; // ウィンドウは出さない
p.StartInfo.UseShellExecute = false; // シェルなし
p.Start(); // コンパイル実行

string line;
line = p.StandardOutput.ReadToEnd(); // コンパイル結果の出力取得
m_complie_log_edit.Text += line;

p.WaitForExit(); // 実行終了待ち

m_complie_log_edit.Text += "ビルド終了: " + DateTime.Now.ToString() +"\r\n";
}

}









戻る