Example #1
0
        /// <summary>
        /// 选择区域按钮
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnChooseAOI_Click(object sender, EventArgs e)
        {
            int fieldIndex = -1; string fieldName; string shapeFilename; string regionName = "";

            if (aoiContainer != null)
            {
                aoiContainer.Dispose();
            }
            if (fieldValues != null)
            {
                fieldValues.Clear();
            }
            using (frmStatSubRegionTemplatesMWS frm = new frmStatSubRegionTemplatesMWS())
            {
                frm.listView1.MultiSelect = true;
                if (frm.ShowDialog() == DialogResult.OK)
                {
                    Feature[] fets = frm.GetSelectedFeatures();
                    fets = frm.GetStatFeatures(out fieldName, out shapeFilename, out fieldIndex);
                    if (fets == null)
                    {
                        MessageBox.Show("未选定目标区域,请选择区域");
                    }
                    else
                    {
                        string chinafieldValue = fets[0].GetFieldValue(fieldIndex);
                        if (chinafieldValue == "中国")
                        {
                            aoiContainer.AddAOI(fets[0]);
                            regionName = "全国";
                            fieldValues.Add("全国");
                            IsAllContry = "YES";
                        }
                        else
                        {
                            foreach (Feature fet in fets)
                            {
                                fieldValues.Add(fet.GetFieldValue(fieldIndex)); //获得选择区域名称
                                aoiContainer.AddAOI(fet);
                            }
                            regionName = "";
                            foreach (string region in fieldValues)
                            {
                                regionName += region;
                            }
                        }
                    }
                    txtRegionName.Text = regionName;
                }
                else
                {
                    MessageBox.Show("请选择区域");
                }
            }
        }
Example #2
0
        private void btnChooseAOI_Click(object sender, EventArgs e)
        {
            int fieldIndex = -1; string fieldName; string shapeFilename; string regionName = "";

            if (aoiContainer != null)
            {
                aoiContainer.Dispose();
            }
            if (fieldValues != null)
            {
                fieldValues.Clear();
            }
            using (frmStatSubRegionTemplatesMWS frm = new frmStatSubRegionTemplatesMWS())
            {
                frm.listView1.MultiSelect = true;
                if (frm.ShowDialog() == DialogResult.OK)
                {
                    Feature[] fets = frm.GetSelectedFeatures();
                    fets = frm.GetStatFeatures(out fieldName, out shapeFilename, out fieldIndex);
                    if (fets == null)
                    {
                        MessageBox.Show("未选定目标区域,请选择区域");
                    }
                    else
                    {
                        string chinafieldValue = fets[0].GetFieldValue(fieldIndex);
                        if (chinafieldValue == "中国")
                        {
                            aoiContainer.AddAOI(fets[0]);
                            regionName = "全国";
                            fieldValues.Add("全国");
                            IsAllContry = "YES";
                        }
                        else
                        {
                            foreach (Feature fet in fets)
                            {
                                fieldValues.Add(fet.GetFieldValue(fieldIndex)); //获得选择区域名称
                                aoiContainer.AddAOI(fet);
                            }
                            regionName = "";
                            foreach (string region in fieldValues)
                            {
                                regionName += region;
                            }
                        }
                    }
                    txtRegionName.Text = regionName;
                    if (aoiContainer != null)
                    {
                        if (aoiContainer.AOIs.Count() > 1)
                        {
                            if ((radibtnPeriod.Checked) && (combxTimeMonthStart.SelectedItem.ToString() != combxTimeMonthEnd.SelectedItem.ToString() ||
                                                            combxTimeTenStart.SelectedItem.ToString() != combxTimeTenEnd.SelectedItem.ToString() ||
                                                            combxTimePentadStart.SelectedItem.ToString() != combxTimePentadEnd.SelectedItem.ToString()))
                            {
                                cbxAOIMerge.Checked = true; cbxAOIMerge.Enabled = false;
                                //MessageBox.Show("选择为多周期段和多区域时,所选区域将自动合成,请输入简称");
                            }
                            else
                            {
                                cbxAOIMerge.Checked = false; cbxAOIMerge.Enabled = true;
                            }
                        }
                    }
                }
                else
                {
                    MessageBox.Show("请选择区域");
                }
            }
        }