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; using GeoScene.Data; namespace Cyberpipe.Forms { public partial class FrmGenTopo : Office2007Form { private GSOGlobe m_globe; private string pipelineName; public FrmGenTopo(GSOGlobe globe,string _pipelineName) { m_globe = globe; pipelineName = _pipelineName; InitializeComponent(); } /// <summary> /// 确定按钮事件处理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnOK_Click(object sender, EventArgs e) { try { if (tboxTopoName.Text == "") { MessageBox.Show("生成数据名称不能为空!"); return; } //GSOLayer layer = m_globe.Layers.GetLayerByID((int)(Utility.LayerLabel_LayerIDs[pipelineName])); GSOLayer layer = m_globe.Layers.GetLayerByCaption(pipelineName); if (layer == null) { MessageBox.Show("处理的图层不能为空!", "提示!", MessageBoxButtons.OK, MessageBoxIcon.Error); } GSODataSource selDS = layer.Dataset.DataSource; GSOFeatureDataset linedataset = 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); this.Close(); MessageBox.Show("拓扑数据创建成功!", "提示!", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { MessageBox.Show(ex.Message); } } /// <summary> /// 窗体初始化事件处理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void FrmGenTopo_Load(object sender, EventArgs e) { //GSOLayer layer = m_globe.Layers.GetLayerByID((int)(Utility.LayerLabel_LayerIDs[pipelineName])); GSOLayer layer = m_globe.Layers.GetLayerByCaption(pipelineName); if (layer != null && layer.Dataset != null) { tboxTopoName.Text = layer.Dataset.Name + "Network"; } tboxTolerance.Text = "0.1"; checkBoxIgnoreZ.Checked = true; } /// <summary> /// 退出按钮事件处理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnQuit_Click(object sender, EventArgs e) { this.Close(); } } }