コード例 #1
0
        private void okbt_Click(object sender, EventArgs e)
        {
            List <string> filelist = new List <string>();//筛选文件列表

            foreach (string item in listBox1.Items)
            {
                if (item.IndexOf("\\") == -1)
                {
                    filelist.Add(filepathtextBox.Text.Trim() + "\\" + item);
                }
                else
                {
                    filelist.Add(item);
                }
            }
            filelist.Add(ignoretextBox.Text.Trim());
            filelist.Add(invaildtextBox.Text.Trim());
            filelist.Add(resulttext.Text.Trim());
            string          taskname = AddToTaskList(filelist, "第一次筛选");
            RunPythonScript rps      = new RunPythonScript(mainform, taskname);

            //QAClass inputqa = new QAClass();
            rps.pythonscript = "firstndvimean.py";
            rps.temp         = "";
            rps.index        = filelist;
            Thread t = new Thread(new ThreadStart(rps.RunPythonScriptFunction));

            t.Start();
            this.Close();
            this.Dispose();
        }
コード例 #2
0
        private void okbt_Click(object sender, EventArgs e)
        {
            List <string> str = new List <string>();
            //string[] str=new string[4];
            string inputpath1 = datacomboBox.Text.Trim();
            string inputpath2 = selectcomboBox.Text.Trim();

            if (inputpath1 == "")
            {
                MessageBox.Show("数据文件不能为空");
                return;
            }
            if (inputpath2 == "")
            {
                MessageBox.Show("筛选文件不能为空");
                return;
            }
            int invalidint;

            try
            {
                invalidint = Convert.ToInt32(invaliddata.Text.Trim());
            }
            catch (Exception)
            {
                MessageBox.Show("无效值应为数字");
                return;
            }
            int ignoreint;

            try
            {
                ignoreint = Convert.ToInt32(ignoredata.Text.Trim());
            }
            catch (Exception)
            {
                MessageBox.Show("无效值应为数字");
                return;
            }
            string outpath = resulttext.Text.Trim();

            str.Add(inputpath1);
            str.Add(inputpath2);
            str.Add(ignoreint.ToString());
            str.Add(invalidint.ToString());
            str.Add(outpath);
            string          taskname = AddToTaskList(str, "阈值比值法");
            RunPythonScript rps      = new RunPythonScript(mainfrm, taskname);

            //QAClass inputqa = new QAClass();
            rps.pythonscript = "threshold_ratio.py";
            rps.temp         = "";
            rps.index        = str;
            Thread t = new Thread(new ThreadStart(rps.RunPythonScriptFunction));

            t.Start();
            this.Close();
            this.Dispose();
        }
コード例 #3
0
ファイル: NDVIYZ.cs プロジェクト: zyhgis/firstwork
        private void okbt_Click(object sender, EventArgs e)
        {
            //ndvi_threshold.py
            List <string> str = new List <string>();
            //string[] str=new string[4];
            string inputpath1 = datacomboBox.Text.Trim();
            string inputpath2 = selectcomboBox.Text.Trim();

            if (inputpath1 == "")
            {
                MessageBox.Show("NDVI植被参考值文件不能为空");
                return;
            }
            if (inputpath2 == "")
            {
                MessageBox.Show("灾后植被数据不能为空");
                return;
            }
            int invalidint;

            try
            {
                invalidint = Convert.ToInt32(invalidata.Text.Trim());
            }
            catch (Exception)
            {
                MessageBox.Show("无效值应为数字");
                return;
            }
            int ignoredataint;

            try
            {
                ignoredataint = Convert.ToInt32(ignoredata.Text.Trim());
            }
            catch (Exception)
            {
                MessageBox.Show("忽略值应为数字");
                return;
            }
            int diseasterint;

            try
            {
                diseasterint = Convert.ToInt32(diseasterdata.Text.Trim());
            }
            catch (Exception)
            {
                MessageBox.Show("无效值应为数字");
                return;
            }
            int nodiseasterint;

            try
            {
                nodiseasterint = Convert.ToInt32(nodiseasterdata.Text.Trim());
            }
            catch (Exception)
            {
                MessageBox.Show("无效值应为数字");
                return;
            }
            string outpath = resulttext.Text.Trim();

            str.Add(inputpath1);
            str.Add(inputpath2);
            str.Add(ignoredataint.ToString());
            str.Add(invalidint.ToString());
            str.Add(diseasterint.ToString());
            str.Add(nodiseasterint.ToString());
            str.Add(outpath);

            string          taskname = AddToTaskList(str, "灾后波动值");
            RunPythonScript rps      = new RunPythonScript(mainfrm, taskname);

            rps.pythonscript = "ndvi_threshold.py";
            rps.temp         = "";
            rps.index        = str;
            Thread t = new Thread(new ThreadStart(rps.RunPythonScriptFunction));

            t.Start();
            this.Close();
            this.Dispose();
        }
コード例 #4
0
        private void okbt_Click(object sender, EventArgs e)
        {
            List <string> str = new List <string>();
            //string[] str=new string[4];
            string inputpath1 = datacomboBox.Text.Trim();
            string inputpath2 = selectcomboBox.Text.Trim();

            if (inputpath1 == "")
            {
                MessageBox.Show("数据文件不能为空");
                return;
            }
            if (inputpath2 == "")
            {
                MessageBox.Show("筛选文件不能为空");
                return;
            }
            int invalidint = -3000;

            try
            {
                invalidint = Convert.ToInt32(invaliddata.Text.Trim());
            }
            catch (Exception)
            {
                MessageBox.Show("无效值应为数字");
                return;
            }

            string outpath = resulttext.Text.Trim();

            str[0] = inputpath1;
            str[1] = inputpath2;
            str[2] = invalidint.ToString();
            str[3] = outpath;

            //str[0] = "e:\\work\\共享杯\\wangxc20160912\\cqa_data\\tqa2008.tif";
            //str[1] = "e:\\work\\共享杯\\wangxc20160912\\cndvi_data\\tndvi2008.tif";
            //str[2] = "-3000";
            //str[3] = "e:\\work\\共享杯\\wangxc20160912\\fcndvidata\\f.tif";


            //str[0] = "e:\\wangxc20160912\\cqa_data\\tqa2008.tif";
            //str[1] = "e:\\wangxc20160912\\cndvi_data\\tndvi2008.tif";
            //str[2] = "-3000";
            //str[3] = "e:\\wangxc20160912\\fcndvidata\\ftndvi2008.tif";


            //Form1 frm = new Form1();
            //frm.listBox1.Items.Add("ewew");
            //TaskList frm = new TaskList(str);
            //frm.FormBorderStyle = FormBorderStyle.None;
            //frm.Dock = DockStyle.Fill;
            //frm.TopLevel = false;
            //frm.AllowDrop = true;
            //this.panel1.Controls.Clear();
            //this.Controls.Add(sAllPage);


            //frm.Show();
            string          taskname = AddToTaskList(str, "QA文件");
            RunPythonScript rps      = new RunPythonScript(mainform, taskname);

            //QAClass inputqa = new QAClass();
            rps.pythonscript = "qa_choice.py";
            rps.temp         = "";
            rps.index        = str;
            Thread t = new Thread(new ThreadStart(rps.RunPythonScriptFunction));

            t.Start();
            this.Close();
            this.Dispose();
            //rps.RunPythonScriptFunction("qa_choice.py", "", str);
            //this.Close();
            //this.Close();
            //this.Dispose();
            //RunPythonScript("qa_choice.py","",str);
            //string inputpath1 = datacomboBox.Text.Trim();
            //string inputpath2 = selectcomboBox.Text.Trim();
            //int invalidint = -3000;
            //try
            //{
            //    invalidint = Convert.ToInt32(invaliddata.Text.Trim());
            //}
            //catch (Exception)
            //{

            //    MessageBox.Show("无效值应为数字");
            //}
            //string outpath = resulttext.Text.Trim();

            //ScriptRuntime pyRuntime = Python.CreateRuntime();
            //dynamic obj = pyRuntime.UseFile(Application.StartupPath + @"\python\qa_choice.py");
            //obj.qa_choice2(inputpath1, inputpath2, invalidint, outpath);

            //var engine = IronPython.Hosting.Python.CreateEngine();
            //var scope = engine.CreateScope();
            //var source = engine.CreateScriptSourceFromFile(Application.StartupPath + @"\python\qa_choice.py");
            //source.Execute(scope);

            ////var say_hello = scope.GetVariable<Func<object>>("qa_choice2");
            ////say_hello();

            ////var get_text = scope.GetVariable<Func<object>>("get_text");
            ////var text = get_text().ToString();
            ////Console.WriteLine(text);

            //var add = scope.GetVariable<Func<object, object, object, object, object>>("qa_choice2");
            //add(inputpath1, inputpath2, invalidint, outpath);


            ////var result2 = add("hello ", "world");
            ////Console.WriteLine(result2);
        }