예제 #1
0
        private void cmbASCDL_TextChanged(object sender, EventArgs e)
        {
            string   filePath = cmbASCDL.Text.TrimEnd();
            FileInfo file     = new FileInfo(filePath);
            string   fileHdr  = filePath.Replace(file.Extension, ".hdr");

            try
            {
                if (File.Exists(fileHdr))
                {
                    SampleData.classNames = SampleFrame.GetClassFromHdr(fileHdr);
                    this.cmbDestination.Properties.Items.Clear();
                    this.cmbDestination.Properties.Items.AddRange(SampleData.classNames);
                }
                else
                {
                    SampleData.classNames = SampleFrame.GetClassFromRaster(filePath);
                    this.cmbDestination.Properties.Items.Clear();
                    this.cmbDestination.Properties.Items.AddRange(SampleData.classNames);
                }
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show(ex.Message, "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Log.WriteLog(typeof(frmSampleFrame), ex);
            }
        }
예제 #2
0
        private void InitialData()
        {
            cmbFirstUnit.Text = SampleData.firstSample;
            if (!string.IsNullOrEmpty(cmbFirstUnit.Text))
            {
                getFields();
                cmbVillage.Text = SampleData.villageField;
                cmbLayer.Text   = SampleData.layerField;
            }

            cmbCultivation.Text = SampleData.farmLand;
            cmbASCDL.Text       = SampleData.ASCDL;
            if (!string.IsNullOrEmpty(cmbASCDL.Text))
            {
                cmbCrop.Properties.Items.Clear();
                if (SampleData.classNames.Count > 0)
                {
                    cmbCrop.Properties.Items.AddRange(SampleData.classNames);
                }
                else
                {
                    try
                    {
                        string   filePath = cmbASCDL.Text.TrimEnd();
                        FileInfo file     = new FileInfo(filePath);
                        string   fileHdr  = filePath.Replace(file.Extension, ".hdr");
                        if (File.Exists(fileHdr))
                        {
                            SampleData.classNames = SampleFrame.GetClassFromHdr(fileHdr);
                            this.cmbCrop.Properties.Items.AddRange(SampleData.classNames);
                        }
                        else
                        {
                            SampleData.classNames = SampleFrame.GetClassFromRaster(filePath);
                            this.cmbCrop.Properties.Items.AddRange(SampleData.classNames);
                        }
                    }
                    catch (Exception ex)
                    {
                        XtraMessageBox.Show(ex.Message, "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        Log.WriteLog(typeof(frmSampleFrame), ex);
                    }
                }

                if (SampleData.targetCrop >= 0)
                {
                    cmbCrop.Text = SampleData.classNames[SampleData.targetCrop];
                }
            }
        }