Exemplo n.º 1
0
        private void buttonSaveLanduseConfig_Click(object sender, EventArgs e)
        {
            landUseClassificationInfo.ClearAll();
            for (int i = 0; i < dataGridViewLandUse.Rows.Count; i++)
            {
                StructLanduseInfo strucLanduseInfo = new StructLanduseInfo();
                if (System.Globalization.CultureInfo.CurrentCulture.Parent.Name == "zh-CHS")
                {
                    strucLanduseInfo.LanduseTypeChsName = dataGridViewLandUse.Rows[i].Cells[1].Value.ToString();
                }
                else if (System.Globalization.CultureInfo.CurrentCulture.Parent.Name == "zh-CHT")
                {
                    strucLanduseInfo.LanduseTypeChtName = dataGridViewLandUse.Rows[i].Cells[1].Value.ToString();
                }
                else
                {
                    strucLanduseInfo.LanduseTypeEnName = dataGridViewLandUse.Rows[i].Cells[1].Value.ToString();
                }
                strucLanduseInfo.LanduseTypeValue = Convert.ToSingle(dataGridViewLandUse.Rows[i].Cells[0].Value);
                Bitmap bitmap = (Bitmap)dataGridViewLandUse.Rows[i].Cells[3].Value;
                strucLanduseInfo.LanduseTypeColorIntValue = bitmap.GetPixel(0, 0).ToArgb();

                if (dataGridViewLandUse.Rows[i].Cells[2].Value.ToString() == resourceManager.GetString("String8"))
                {
                    landUseClassificationInfo.AddUrbanLanduseType(strucLanduseInfo);
                }
                else if (dataGridViewLandUse.Rows[i].Cells[2].Value.ToString() == resourceManager.GetString("String6"))
                {
                    landUseClassificationInfo.AddConvertLanduseType(strucLanduseInfo);
                }
                else
                {
                    landUseClassificationInfo.AddNotToConvertLanduseType(strucLanduseInfo);
                }
            }
            landUseClassificationInfo.AddNullValue();
            using (SaveFileDialog sfd = new SaveFileDialog())
            {
                sfd.Filter = resourceManager.GetString("String52");
                sfd.Title  = resourceManager.GetString("String54");
                if (sfd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    System.IO.StreamWriter steamWriter = new System.IO.StreamWriter(sfd.FileName);
                    System.Xml.Serialization.XmlSerializer xmlSerializer = new System.Xml.Serialization.XmlSerializer(typeof(LandUseClassificationInfo));
                    xmlSerializer.Serialize(steamWriter, landUseClassificationInfo);
                    steamWriter.Close();
                    System.Windows.Forms.MessageBox.Show(resourceManager.GetString("String55"), resourceManager.GetString("String2"), MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                }
            }
        }
Exemplo n.º 2
0
 private void buttonLoadLanduseConfig_Click(object sender, EventArgs e)
 {
     dataGridViewLandUse.Rows.Clear();
     using (OpenFileDialog ofd = new OpenFileDialog())
     {
         ofd.Filter = resourceManager.GetString("String52");
         ofd.Title  = resourceManager.GetString("String53");
         if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
         {
             System.IO.StreamReader streamReader = new System.IO.StreamReader(ofd.FileName);
             System.Xml.Serialization.XmlSerializer xmlSerializer = new System.Xml.Serialization.XmlSerializer(typeof(LandUseClassificationInfo));
             landUseClassificationInfo = (LandUseClassificationInfo)xmlSerializer.Deserialize(streamReader);
             streamReader.Close();
             for (int i = 0; i < landUseClassificationInfo.AllTypesCount; i++)
             {
                 StructLanduseInfo strucLanduseInfo = landUseClassificationInfo.AllTypes[i];
                 dataGridViewLandUse.Rows.Add();
                 if (System.Globalization.CultureInfo.CurrentCulture.Parent.Name == "zh-CHS")
                 {
                     dataGridViewLandUse.Rows[i].Cells[1].Value = strucLanduseInfo.LanduseTypeChsName;
                 }
                 else if (System.Globalization.CultureInfo.CurrentCulture.Parent.Name == "zh-CHT")
                 {
                     dataGridViewLandUse.Rows[i].Cells[1].Value = strucLanduseInfo.LanduseTypeChtName;
                 }
                 else
                 {
                     dataGridViewLandUse.Rows[i].Cells[1].Value = strucLanduseInfo.LanduseTypeEnName;
                 }
                 dataGridViewLandUse.Rows[i].Cells[0].Value = strucLanduseInfo.LanduseTypeValue;
                 dataGridViewLandUse.Rows[i].Cells[3].Value =
                     GeneralOpertor.GetBitmap(15, 15, Color.FromArgb(strucLanduseInfo.LanduseTypeColorIntValue));
                 if (landUseClassificationInfo.UrbanValues.Contains(strucLanduseInfo))
                 {
                     dataGridViewLandUse.Rows[i].Cells[2].Value = resourceManager.GetString("String8");
                 }
                 else if (landUseClassificationInfo.ConvertValues.Contains(strucLanduseInfo))
                 {
                     dataGridViewLandUse.Rows[i].Cells[2].Value = resourceManager.GetString("String6");
                 }
                 else
                 {
                     dataGridViewLandUse.Rows[i].Cells[2].Value = resourceManager.GetString("String7");
                 }
             }
         }
     }
 }
Exemplo n.º 3
0
        private void buttonOk_Click(object sender, EventArgs e)
        {
            this.landUse = new LandUseClassificationInfo();

            if (IsDataGridViewCellsNotNull(this.count, 4))
            {
                for (int i = 0; i < this.count; i++)
                {
                    string            landUseType = dataGridViewLandUse.Rows[i].Cells[2].Value.ToString();
                    StructLanduseInfo info        = new StructLanduseInfo();
                    info.LandUseTypeName  = dataGridViewLandUse.Rows[i].Cells[1].Value.ToString();
                    info.LandUseTypeValue = Convert.ToDouble(dataGridViewLandUse.Rows[i].Cells[0].Value);
                    info.LandUseTypeColor = ((Bitmap)dataGridViewLandUse.Rows[i].Cells[3].Value).GetPixel(1, 1).ToArgb();
                    if (landUseType == "城市用地")
                    {
                        this.landUse.UrbanInfos.Add(info);
                        this.landUse.AllTypes.Add(info);
                    }
                    else if (landUseType == "可转换为城市用地")
                    {
                        this.landUse.ConvertableInfos.Add(info);
                        this.landUse.AllTypes.Add(info);
                    }
                    else if (landUseType == "不可转换为城市用地")
                    {
                        this.landUse.UnConvertableInfos.Add(info);
                        this.landUse.AllTypes.Add(info);
                    }
                    else if (landUseType == "数据空值")
                    {
                        this.landUse.NullInfo = info;
                    }
                }
                this.Close();
            }
            else
            {
                MessageBox.Show("数据不完整");
            }
        }