Ejemplo n.º 1
0
        private void btn_execute_Click(object sender, EventArgs e)
        {
            XmlInfo xml_doc = new XmlInfo(RuleSetMessage.RuleSetPath, "vrblValScale", "vrblHCShape", "vrblHCArea");

            xml_doc.ReadRuleSet();
            string scale = this.txt_scale.Text;
            string shape = this.txt_shape.Text;
            string comp = this.txt_compactness.Text;
            string outpath = tb_outpath.Text;
            float  scalevalue, shapevalue, compvalue;
            bool   validate1 = float.TryParse(scale, out scalevalue);
            bool   validate2 = float.TryParse(shape, out shapevalue);
            bool   validate3 = float.TryParse(comp, out compvalue);

            if (xml_doc.ReadRuleSet())
            {
                if (validate1 && validate2 && validate3 && (shapevalue >= 0.0 && shapevalue <= 0.9) && (compvalue >= 0 && compvalue <= 1.0))
                {
                    xml_doc.ChangeNdVal(scale, shape, comp);
                }
                else
                {
                    MessageBox.Show("请输入合法的参数值,Shape的范围在0-0.9之间,Compactness的范围在0-1之间");
                }
                string OutPathInfo = xml_doc.SearchAlgoParams();
                if (OutPathInfo != "")
                {
                    string changedOutPath = ChangeOutPath(ref OutPathInfo, outpath);
                    xml_doc.ChangeoutPath(changedOutPath);
                }
                else
                {
                    MessageBox.Show("此规则集无效,或不能用于分割,\n请更改规则集并重试!");
                }
                RuleSetMessage.AlgoOptions = 1;
                RuleSetMessage.OutShpPath  = tb_outpath.Text;
            }
            else
            {
                MessageBox.Show("输入信息不完全,请重新设置!");
                return;
            }
            this.Close();
        }
Ejemplo n.º 2
0
 private void MainForm_Load(object sender, EventArgs e)
 {
     if (RuleSetMessage.RuleSetPath != null)
     {
         XmlInfo xml_doc = new XmlInfo(RuleSetMessage.RuleSetPath, "vrblValScale", "vrblHCShape", "vrblHCArea");
         xml_doc.ReadRuleSet();
         string[] searchedItems = xml_doc.SearchNdVal();
         txt_scale.Text       = searchedItems[0];
         txt_shape.Text       = searchedItems[1];
         txt_compactness.Text = searchedItems[2];
         //tb_outpath.Text = xml_doc.SearchAlgoParams();
         //txt_scale.Text = xml_doc.DisplayedParams[0];
         string OutPathInfo = xml_doc.SearchAlgoParams();
         tb_outpath.Text           = ParseOutPathRe(OutPathInfo);
         RuleSetMessage.OutShpPath = tb_outpath.Text;
         //ParseOutXML(tb_outpath.Text);
     }
     else
     {
         return;
     }
 }
Ejemplo n.º 3
0
        private async void bn_Execute_Click(object sender, EventArgs e)
        {
            string imagepath = tb_image.Text;

            if (imagepath == "")
            {
                MessageBox.Show("请加载要处理的影像!");
                return;
            }
            string rulepath = tb_ruleset.Text;

            if (rulepath == "")
            {
                MessageBox.Show("请加载规则集!");
                return;
            }
            XmlInfo classDet = new XmlInfo(rulepath);

            classDet.ReadRuleSet();
            string OutShpPath        = classDet.SearchAlgoParams();
            string ClassficationPath = classDet.SearchAlgoParams2();

            if (OutShpPath == "" && ClassficationPath == "")
            {
                MessageBox.Show("此规则集有误,或本系统暂不支持该规则集,\n请修改规则集并重试!");
                return;
            }
            if (RuleSetMessage.AlgoOptions != 1 && RuleSetMessage.AlgoOptions != 2)
            {
                if (ClassficationPath != "")
                {
                    MessageBox.Show("此规则集用于分类,请先在分类参数窗口中\n" +
                                    "进行相关设置,并点击确定按钮!");
                    return;
                }
                else if (OutShpPath != "")
                {
                    MessageBox.Show("此规则集用于分割,请先在多尺度分割参数窗口中\n" +
                                    "进行相关设置,并点击确定按钮!");
                    return;
                }
            }
            string project     = tb_projectPath.Text;
            string projectName = tb_projetName.Text;

            Lb_result.Text = "开始执行";
            Task       t2 = ProgressbarStatus();
            Task <int> t1 = AnalyseImageAsync2(imagepath, rulepath, project, projectName);
            await Task.WhenAny(t1, t2);

            if (t1.Result == 0)
            {
                Lb_result.Text             = "执行成功";
                RuleSetMessage.AlgoOptions = 0;
                NotcancelFlag = false;
                Console.Beep(1000, 1000);
                MessageBox.Show("完成");
                Close();
            }
            else
            {
                Lb_result.Text             = "执行失败,错误码为:" + t1.Result.ToString();
                RuleSetMessage.AlgoOptions = 0;
                NotcancelFlag        = false;
                progressBar1.Visible = false;
            }
        }