コード例 #1
0
ファイル: Form1.cs プロジェクト: MateuszChilinski/SN_Project1
        private void RunR()
        {
            var path = System.IO.Path.GetDirectoryName(Application.ExecutablePath);

            var cmd     = ClassificationRadioButton.Checked ? "class.R" : "function.R";
            var args    = path.Replace("\\", "/") + "/";
            var process = new Process
            {
                StartInfo = new ProcessStartInfo
                {
                    FileName               = "Rscript.exe",
                    Arguments              = cmd + " " + args,
                    UseShellExecute        = false,
                    RedirectStandardOutput = true,
                    RedirectStandardError  = true,
                    CreateNoWindow         = true
                },
                EnableRaisingEvents = true
            };

            process.ErrorDataReceived  += ProcessR_OutputDataReceived;
            process.OutputDataReceived += ProcessR_OutputDataReceived;
            Debug.WriteLine(cmd + " " + args);
            process.Start();
            process.BeginOutputReadLine();
            RLabel.Invoke((MethodInvoker)(() =>
            {
                RLabel.Visible = true;
            }
                                          ));
        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: MateuszChilinski/SN_Project1
        private void ProcessR_OutputDataReceived(object sender, DataReceivedEventArgs e)
        {
            Debug.WriteLine(e.Data);
            if (e.Data == null)
            {
                return;
            }
            string data = e.Data.ToString().Replace("\"", "");

            if (data.Contains("[1] "))
            {
                ChartBox.Invoke((MethodInvoker)(() =>
                {
                    ChartBox.Image = Image.FromFile(data.Substring(4, data.Length - 4) + ".png");
                }
                                                ));
                RLabel.Invoke((MethodInvoker)(() =>
                {
                    RLabel.Visible = false;
                }
                                              ));
            }
        }