using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using DevComponents.DotNetBar; using GeoScene.Globe; using GeoScene.Engine; namespace Cyberpipe.Forms { public partial class FrmGenAndFaMenTopu : DevComponents.DotNetBar.Office2007Form { private GSOGlobe m_globe; private string pipelineName; private GSOLayer m_layer; List<string> valueLayerNames; public FrmGenAndFaMenTopu(GSOGlobe globe, string _pipelineName, List<string> _valueLayerNames) { InitializeComponent(); m_globe = globe; valueLayerNames = _valueLayerNames; pipelineName = _pipelineName; } /// <summary> /// 窗体初始化事件处理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void FrmGenAndFaMenTopu_Load(object sender, EventArgs e) { //设置线拓扑参数 //m_layer = globeControl.Globe.Layers.GetLayerByID((int)(Utility.LayerLabel_LayerIDs[pipelineName])); m_layer = m_globe.Layers.GetLayerByCaption(pipelineName); if (m_layer != null && m_layer.Dataset != null) { tboxTopoName.Text = m_layer.Dataset.Name + "Network"; } tboxTolerance.Text = "0.1"; //checkBoxIgnoreZ.Checked = true; //阀门图层参数设置 for (int i = 0; i < valueLayerNames.Count; i++)//获取树节点后中所有的layer图层 { // GSOLayer layer = valueLayerNames[i]; cbbPointLayers.Items.Add(valueLayerNames[i]); } if (cbbPointLayers .Items .Count >0) { cbbPointLayers.SelectedIndex = 0; } tboxFMTolerance.Text = "0.1"; //checkBoxFMIgnoreZ.Checked = true; tbNearestDistLimit.Text = "0.2"; tbNearestDistLimit.Enabled = false; //默认为不开启阀门信息 cbbPointLayers.Enabled = false; tboxFMTolerance.Enabled = false; checkBoxFMIgnoreZ.Enabled = false; checkBoxMatchNearest.Enabled = false; checkBoxClearValves.Enabled = false; } /// <summary> /// 确定按钮单击事件处理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btn_OK_Click(object sender, EventArgs e) { try { //创建线拓扑 if (tboxTopoName.Text == "") { MessageBox.Show("生成数据名称不能为空!"); return; } if (m_layer == null) { MessageBox.Show("处理的图层不能为空!", "提示!", MessageBoxButtons.OK, MessageBoxIcon.Error); } GSODataSource selDS = m_layer.Dataset.DataSource; GSOFeatureDataset linedataset = m_layer.Dataset as GSOFeatureDataset; if (selDS == null) { MessageBox.Show("数据源不能为空!"); return; } GSODataset testDataset = selDS.GetDatasetByName(tboxTopoName.Text); if (testDataset != null) { DialogResult dres = MessageBox.Show("拓扑数据已经存在,是否重建?", "警告", MessageBoxButtons.OKCancel); if (dres == DialogResult.OK) { selDS.DeleteDatasetByName(tboxTopoName.Text); } else { return; } } double dTolerance = 0; Double.TryParse(tboxTolerance.Text, out dTolerance); GSODataEngineUtility.GeneratePipelineNetwork(selDS, linedataset, tboxTopoName.Text, true, dTolerance, "", "", checkBoxIgnoreZ.Checked, false); if (checkUnionFamen.Checked) { //添加阀门信息 GSONetworkDataset selNWDataset = selDS.GetDatasetByName(tboxTopoName.Text.ToString().Trim()) as GSONetworkDataset; if (selNWDataset == null) { MessageBox.Show("处理的拓扑数据集不能为空!"); return; } GSOLayer selLayer = m_globe.Layers.GetLayerByCaption(cbbPointLayers.SelectedItem.ToString()); GSOFeatureDataset pointDataset = selLayer.Dataset as GSOFeatureDataset; if (pointDataset == null) { MessageBox.Show("必须有用于匹配的矢量图层!"); return; } if (checkBoxClearValves.Checked)//清除掉以前关联的阀门信息 { selNWDataset.ClearValves(); } double dFMTolerance = 0; Double.TryParse(tboxFMTolerance.Text, out dFMTolerance); Boolean bMatchNearest = checkBoxMatchNearest.Checked; double dNearstDisLimit = 0; Double.TryParse(tbNearestDistLimit.Text, out dNearstDisLimit); Int32 nMatchNum = selNWDataset.GenerateValves(pointDataset, dFMTolerance, checkBoxFMIgnoreZ.Checked, bMatchNearest, dNearstDisLimit); //MessageBox.Show("阀门匹配完成!共匹配了" + nMatchNum + "个阀门!"); MessageBox.Show("拓扑数据创建成功,阀门匹配完成!共匹配了 " + nMatchNum + " 个阀门!", "提示!", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("拓扑数据创建成功!", "提示!", MessageBoxButtons.OK, MessageBoxIcon.Information); } this.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); LogError.PublishError(ex); } } private void checkBoxMatchNearest_CheckedChanged(object sender, EventArgs e) { if (checkBoxMatchNearest.Checked) { tbNearestDistLimit.Enabled = true; } else { tbNearestDistLimit.Enabled = false; } } /// <summary> /// 关联阀门信息 复选框的事件处理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void checkUnionFamen_CheckedChanged(object sender, EventArgs e) { if (checkUnionFamen.Checked) { //默认为不开启阀门信息 cbbPointLayers.Enabled = true; tboxFMTolerance.Enabled = true; checkBoxFMIgnoreZ.Enabled = true; checkBoxMatchNearest.Enabled = true; checkBoxClearValves.Enabled = true; } else { cbbPointLayers.Enabled = false; tboxFMTolerance.Enabled = false; checkBoxFMIgnoreZ.Enabled = false; checkBoxMatchNearest.Enabled = false; checkBoxClearValves.Enabled = false; } } /// <summary> /// 关闭按钮事件处理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonX1_Click(object sender, EventArgs e) { this.Close(); } } }