NEUTRINO_GUIs

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

Form1.cs (3365B)


      1 using System.Diagnostics;
      2 
      3 namespace NEUTRINO_GUIs
      4 {
      5     public partial class Form1 : Form
      6     {
      7         string whereRun;
      8         public void Command(string command)
      9         {
     10             //引数を代入
     11             ProcessStartInfo processStartInfo = new ProcessStartInfo(command);
     12 
     13             //新しいタブができないように設定。
     14             processStartInfo.CreateNoWindow = true;
     15 
     16             //標準出力を取得。
     17             processStartInfo.RedirectStandardOutput = true;
     18 
     19             //実行
     20             Process process = Process.Start(processStartInfo);
     21 
     22             //終了を待って閉じる。
     23             process.WaitForExit();
     24             process.Close();
     25 
     26 
     27         }
     28         public Form1()
     29         {
     30             InitializeComponent();
     31         }
     32 
     33         private void Form1_Load(object sender, EventArgs e)
     34         {
     35 
     36         }
     37 
     38         private void RUN_Click(object sender, EventArgs e)
     39         {
     40             string fileNameR = whereRunfile.Text;
     41             //選択されたRunファイルを実行
     42             MessageBox.Show("実行が開始されました。");
     43             Command(fileNameR);
     44             MessageBox.Show("Done");
     45 
     46         }
     47 
     48         private void 楽譜ファイル選択_Click(object sender, EventArgs e)
     49         {
     50             var openFileDialog = new OpenFileDialog();
     51             openFileDialog.Filter = "musicxml (*.musicxml)|*.musicxml|All files (*.*)|*.*";
     52             openFileDialog.FilterIndex = 1;
     53             openFileDialog.Title = "楽譜ファイル選択";
     54             openFileDialog.RestoreDirectory = true;
     55             openFileDialog.FileName = "sample1.musicxml";
     56             if (openFileDialog.ShowDialog() == DialogResult.OK)
     57             {
     58                 Console.WriteLine(openFileDialog.FileName);
     59             }
     60 
     61             //配列に代入
     62             string[] lines = File.ReadAllLines(whereRun);
     63             //Runファイルを書き換える
     64             bool streamWriterOption = false;
     65             string scoreFileName = Path.GetFileNameWithoutExtension(openFileDialog.FileName);
     66             //StreamWriterを起動
     67             StreamWriter sw = new StreamWriter(whereRun, streamWriterOption);
     68 
     69 
     70             for (int a = 0; a < 5; a++)
     71             {
     72                 sw.WriteLine(lines[a]);
     73             }
     74             //BASENAMEの行を書き換え
     75             sw.WriteLine("set BASENAME=" + scoreFileName);
     76 
     77             //残りの行を書き換え
     78             for (int b = 6; b < lines.Length; b++)
     79             {
     80                 sw.WriteLine(lines[b]);
     81             }
     82             sw.Close();
     83 
     84             scorefile.Text = openFileDialog.FileName;
     85             MessageBox.Show("ファイル選択が完了しました。");
     86         }
     87 
     88         private void runFileSellect_Click(object sender, EventArgs e)
     89         {
     90             var openFileDialog1 = new OpenFileDialog();
     91             openFileDialog1.Filter = "バッチファイル(*.bat)|*.bat|All files (*.*)|*.*";
     92             openFileDialog1.FilterIndex = 1;
     93             openFileDialog1.Title = "Runファイル選択";
     94             openFileDialog1.RestoreDirectory = true;
     95             openFileDialog1.FileName = "Run.bat";
     96             if (openFileDialog1.ShowDialog() == DialogResult.OK)
     97             {
     98                 Console.WriteLine(openFileDialog1.FileName);
     99             }
    100 
    101             whereRun = openFileDialog1.FileName;
    102             whereRunfile.Text = openFileDialog1.FileName;
    103             MessageBox.Show("ファイル選択が完了しました。");
    104         }
    105 
    106     }
    107 }