private void BT_Ok_Click(object sender, EventArgs e) { try { if (!Directory.Exists(m_MakeContoursFolder)) { Directory.CreateDirectory(m_MakeContoursFolder); } panel1.Enabled = false; panel2.Enabled = false; panel4.Enabled = false; lbshengc.Visible = true; Application.DoEvents(); ArrayList TheValueList = new ArrayList(); if (radioBtndata.Checked) { if (m_layerAliasName.Equals("瓦斯压力等值线")) { var gasPressures = GasPressure.FindAll(); foreach (var i in gasPressures) { XYValueStruct temp; temp.X = i.coordinate_x; temp.Y = i.coordinate_y; temp.TheValue = i.gas_pressure_value; TheValueList.Add(temp); } } if (m_layerAliasName.Equals("瓦斯含量等值线")) { var gasContent = GasContent.FindAll(); foreach (var i in gasContent) { XYValueStruct temp; temp.X = i.coordinate_x; temp.Y = i.coordinate_y; temp.TheValue = i.gas_content_value; TheValueList.Add(temp); } } if (m_layerAliasName.Equals("瓦斯涌出量等值线")) { var gasGushQuantity = GasGushQuantity.FindAll(); foreach (var i in gasGushQuantity) { XYValueStruct temp; temp.X = i.coordinate_x; temp.Y = i.coordinate_y; temp.TheValue = i.absolute_gas_gush_quantity; TheValueList.Add(temp); } } if (TheValueList.Count < 3) { MessageBox.Show("离散点数据为空或小于三个,无法生成等值线!"); return; } string[] strlsd = new string[TheValueList.Count]; for (int i = 0; i < TheValueList.Count; i++) { XYValueStruct tempxy = (XYValueStruct)TheValueList[i]; string temstr = tempxy.X + "," + tempxy.Y + "," + tempxy.TheValue; strlsd[i] = temstr; } m_strDataFilePath = Application.StartupPath + "\\tempdata.txt"; File.WriteAllLines(m_strDataFilePath, strlsd); } else { m_strDataFilePath = TB_DocumentPath.Text.Trim(); if (m_strDataFilePath.Equals("")) { MessageBox.Show("请选择一个离散点文件!"); return; } } bool bIsSuccess = false; string failInfo = ""; DrawSpecialCommon drawspecial = new DrawSpecialCommon(); string sLayerAliasName = m_layerAliasName; //MapControl中图层名称 string nameOftargetFeatureClass = SDELayerName; //m_layerName + "_NO" + sCoalseamNO;//数据库中图层名称 string extent = ""; if (radioBtnKJ.Checked) { ILayer pLayer = DataEditCommon.GetLayerByName(DataEditCommon.g_pMap, LayerNames.LAYER_ALIAS_MINE_BOUNDARY); IFeatureLayer pFeatureLayer = (IFeatureLayer)pLayer; IEnvelope pEnvelope = pFeatureLayer.AreaOfInterest; //右上左下 xmax ymax xmin ymin extent = pEnvelope.XMax.ToString() + " " + pEnvelope.YMax.ToString() + " " + pEnvelope.XMin.ToString() + " " + pEnvelope.YMin.ToString(); } IWorkspace targetworkspace = DataEditCommon.g_pCurrentWorkSpace; //最后重新生成图层并添加到数据库及MapControl中 bIsSuccess = CreateContours(targetworkspace, nameOftargetFeatureClass, sLayerAliasName, extent, ref failInfo); if (bIsSuccess) { string layername = ""; if (m_layerAliasName.Equals("瓦斯压力等值线")) { layername = LayerNames.LAYER_ALIAS_MR_YLDZX; } if (m_layerAliasName.Equals("瓦斯含量等值线")) { layername = LayerNames.LAYER_ALIAS_MR_HLDZX; } if (m_layerAliasName.Equals("瓦斯涌出量等值线")) { layername = LayerNames.LAYER_ALIAS_MR_YCLDZX; } if (m_layerAliasName.Equals("地面标高等值线")) { layername = LayerNames.GROUND_LEVLE_CONTOUR; } if (m_layerAliasName.Equals("煤层底板等值线")) { layername = LayerNames.FLOOR_ELEVATION_CONTOUR; } if (m_layerAliasName.Equals("埋深等值线")) { layername = LayerNames.EMBEDDED_DEPTH_CONTOUR; } DataEditCommon.SetLayerVisibleByName(DataEditCommon.g_pMap, layername, true); MessageBox.Show("等值线和渲染图生成完成。"); this.Close(); } else { MessageBox.Show(failInfo + "生成过程有误,请检查。"); } //this.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { panel1.Enabled = true; panel2.Enabled = true; panel4.Enabled = true; lbshengc.Visible = false; Application.DoEvents(); progressBarControl1.Position = 0; } }
private void BT_Ok_Click(object sender, EventArgs e) { try { if (!Directory.Exists(m_MakeContoursFolder)) { Directory.CreateDirectory(m_MakeContoursFolder); } panel1.Enabled = false; panel2.Enabled = false; panel4.Enabled = false; lbshengc.Visible = true; Application.DoEvents(); ArrayList TheValueList = new ArrayList(); DataSet theDS = new DataSet(); string TheCoalSeamNum = ""; theDS = TheManage.ReturnDS("select * from T_COAL_SEAMS_INFO where COAL_SEAMS_NAME='" + cbCoalSeam.SelectedItem.ToString() + "#'"); if (theDS.Tables[0].Rows.Count > 0) { TheCoalSeamNum = theDS.Tables[0].Rows[0]["COAL_SEAMS_ID"].ToString(); if (radioBtndata.Checked) { if (m_layerAliasName.Equals("瓦斯压力等值线")) { theDS = TheManage.ReturnDS("select * from T_GAS_PRESSURE where COAL_SEAMS_ID='" + TheCoalSeamNum + "'"); if (theDS.Tables[0].Rows.Count > 0) { for (int i = 0; i < theDS.Tables[0].Rows.Count; i++) { XYValueStruct temp; temp.X = Convert.ToDouble(theDS.Tables[0].Rows[i]["COORDINATE_X"].ToString()); temp.Y = Convert.ToDouble(theDS.Tables[0].Rows[i]["COORDINATE_Y"].ToString()); temp.TheValue = Convert.ToDouble(theDS.Tables[0].Rows[i]["GAS_PRESSURE_VALUE"].ToString()); TheValueList.Add(temp); } } } if (m_layerAliasName.Equals("瓦斯含量等值线")) { theDS = TheManage.ReturnDS("select * from T_GAS_CONTENT where COAL_SEAMS_ID='" + TheCoalSeamNum + "'"); if (theDS.Tables[0].Rows.Count > 0) { for (int i = 0; i < theDS.Tables[0].Rows.Count; i++) { XYValueStruct temp; temp.X = Convert.ToDouble(theDS.Tables[0].Rows[i]["COORDINATE_X"].ToString()); temp.Y = Convert.ToDouble(theDS.Tables[0].Rows[i]["COORDINATE_Y"].ToString()); temp.TheValue = Convert.ToDouble(theDS.Tables[0].Rows[i]["GAS_CONTENT_VALUE"].ToString()); TheValueList.Add(temp); } } } if (m_layerAliasName.Equals("瓦斯涌出量等值线")) { theDS = TheManage.ReturnDS("select * from T_GAS_GUSH_QUANTITY where COAL_SEAMS_ID='" + TheCoalSeamNum + "'"); if (theDS.Tables[0].Rows.Count > 0) { for (int i = 0; i < theDS.Tables[0].Rows.Count; i++) { XYValueStruct temp; temp.X = Convert.ToDouble(theDS.Tables[0].Rows[i]["COORDINATE_X"].ToString()); temp.Y = Convert.ToDouble(theDS.Tables[0].Rows[i]["COORDINATE_Y"].ToString()); temp.TheValue = Convert.ToDouble(theDS.Tables[0].Rows[i]["ABSOLUTE_GAS_GUSH_QUANTITY"].ToString()); TheValueList.Add(temp); } } } //FileStream fs = new FileStream(fileName,FileMode.CreateNew,FileAccess.Write,FileShare.None); //m_strDataFilePath if (TheValueList.Count < 3) { MessageBox.Show("离散点数据为空或小于三个,无法生成等值线!"); return; } string[] strlsd = new string[TheValueList.Count]; for (int i = 0; i < TheValueList.Count; i++) { XYValueStruct tempxy = (XYValueStruct)TheValueList[i]; string temstr = tempxy.X.ToString() + "," + tempxy.Y.ToString() + "," + tempxy.TheValue.ToString(); strlsd[i] = temstr; } m_strDataFilePath = System.Windows.Forms.Application.StartupPath + "\\tempdata.txt"; System.IO.File.WriteAllLines(m_strDataFilePath, strlsd); } else { m_strDataFilePath = TB_DocumentPath.Text.Trim(); if (m_strDataFilePath.Equals("")) { MessageBox.Show("请选择一个离散点文件!"); return; } } bool bIsSuccess = false; string failInfo = ""; DrawSpecialCommon drawspecial = new DrawSpecialCommon(); string sCoalseamNO = this.cbCoalSeam.Text; //煤层号 string sLayerAliasName = sCoalseamNO + "号煤层-" + m_layerAliasName; //MapControl中图层名称 string nameOftargetFeatureClass = SDELayerName; //m_layerName + "_NO" + sCoalseamNO;//数据库中图层名称 string extent = ""; if (radioBtnKJ.Checked) { ILayer pLayer = DataEditCommon.GetLayerByName(DataEditCommon.g_pMap, LayerNames.LAYER_ALIAS_MINE_BOUNDARY); IFeatureLayer pFeatureLayer = (IFeatureLayer)pLayer; IEnvelope pEnvelope = pFeatureLayer.AreaOfInterest; //右上左下 xmax ymax xmin ymin extent = pEnvelope.XMax.ToString() + " " + pEnvelope.YMax.ToString() + " " + pEnvelope.XMin.ToString() + " " + pEnvelope.YMin.ToString(); } IWorkspace targetworkspace = DataEditCommon.g_pCurrentWorkSpace; //最后重新生成图层并添加到数据库及MapControl中 bIsSuccess = CreateContours(targetworkspace, nameOftargetFeatureClass, sLayerAliasName, extent, ref failInfo); if (bIsSuccess) { string layername = ""; if (m_layerAliasName.Equals("瓦斯压力等值线")) { layername = LayerNames.LAYER_ALIAS_MR_YLDZX; } if (m_layerAliasName.Equals("瓦斯含量等值线")) { layername = LayerNames.LAYER_ALIAS_MR_HLDZX; } if (m_layerAliasName.Equals("瓦斯涌出量等值线")) { layername = LayerNames.LAYER_ALIAS_MR_YCLDZX; } DataEditCommon.SetLayerVisibleByName(DataEditCommon.g_pMap, layername, true); MessageBox.Show("等值线和渲染图生成完成。"); this.Close(); } else { MessageBox.Show(failInfo + "生成过程有误,请检查。"); } } //this.Close(); } catch (System.Exception ex) { MessageBox.Show(ex.Message); } finally { panel1.Enabled = true; panel2.Enabled = true; panel4.Enabled = true; lbshengc.Visible = false; Application.DoEvents(); progressBarControl1.Position = 0; } }