コード例 #1
0
 private void processDataReceived(object sender, DataReceivedEventArgs r)
 {
     if (!String.IsNullOrEmpty(r.Data))
     {
         OutputWindow.Invoke(new MethodInvoker(() =>
         {
             OutputWindow.AppendText(r.Data + "\r\n");
             OutputWindow.DeselectAll();
         }));
     }
 }
コード例 #2
0
 private void processExited(object sender, EventArgs e)
 {
     unpacker.WaitForExit();
     OutputWindow.Invoke(new MethodInvoker(() =>
     {
         extractToolStripMenuItem.Enabled = true;
         cancelToolStripMenuItem.Enabled  = false;
         OutputWindow.AppendText("Completed.\r\n");
         OutputWindow.DeselectAll();
         converterExited = true;
     }));
 }
コード例 #3
0
        private void extractToolStripMenuItem_Click(object sender, EventArgs e)
        {
            extractForm.ShowDialog(this);
            if (extractForm.DialogResult != DialogResult.OK)
            {
                return;
            }

            unpacker = new Process();
            unpacker.StartInfo.FileName               = "m2033unp.exe";
            unpacker.StartInfo.CreateNoWindow         = true;
            unpacker.StartInfo.UseShellExecute        = false;
            unpacker.StartInfo.RedirectStandardOutput = true;
            unpacker.StartInfo.RedirectStandardError  = true;
            unpacker.Exited += new EventHandler(processExited);
            unpacker.EnableRaisingEvents = true;
            unpacker.OutputDataReceived += new DataReceivedEventHandler(processDataReceived);
            unpacker.ErrorDataReceived  += new DataReceivedEventHandler(processDataReceived);

            unpacker.StartInfo.Arguments = parseDialogData();

            extractToolStripMenuItem.Enabled = false;
            cancelToolStripMenuItem.Enabled  = true;
            OutputWindow.Text = "Started...\r\n";
            OutputWindow.DeselectAll();

            converterExited = false;

            try
            {
                unpacker.Start();
            }
            catch (Win32Exception ex)
            {
                OutputWindow.Text = ex.ToString();
                converterExited   = true;
                extractToolStripMenuItem.Enabled = true;
                cancelToolStripMenuItem.Enabled  = false;
                return;
            }

            unpacker.BeginOutputReadLine();
            unpacker.BeginErrorReadLine();
        }