Example #1
0
        private void Form1_Load(object sender, EventArgs e)
        {
            //显示颜色和类名
            if (classDet.ReadRuleSet())
            {
                classname = classDet.LoadClassInfo();
                var classColor = classDet.ObtainClassColor();
                for (int i = 0; i < classname.Count; i++)
                {
                    DataGridViewRow row = new DataGridViewRow();
                    //DataGridViewColumn column = new DataGridViewColumn();
                    //int[] color = generateColor();

                    //int rowIndex = dgvClassDetail.Columns.Add(column);
                    int index = this.dgvClassDetail.Rows.Add(row);
                    this.dgvClassDetail.Rows[index].Cells[1].Style.BackColor =
                        Color.FromArgb(classColor[i].Item1, classColor[i].Item2, classColor[i].Item3);
                    this.dgvClassDetail.Rows[index].Cells[0].Value           = classname[i];
                    this.dgvClassDetail.Rows[index].Cells[0].Style.Alignment = DataGridViewContentAlignment.MiddleCenter;

                    color = null;
                }
                //RuleSetMessage.OutClassResultsPath = tb_outputPath.Text;
                string outPath = classDet.SearchAlgoParams2();
                tb_outputPath.Text = ParseOutPathRe(outPath);
                //string changedOutPath = ChangeOutPath(ref outPath, RuleSetMessage.OutClassResultsPath);
                //classDet.ChangeoutPath2(changedOutPath);
            }
            else
            {
                return;
            }
        }
        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;
            }
        }