using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using GeoScene.Globe; using System.IO; using GeoScene.Data; using System.Collections; namespace Cyberpipe { public partial class FrmExportVector :DevComponents.DotNetBar.Office2007Form { GSOGlobeControl globeControl1; List<string> pipeLineNames = new List<string>(); public FrmExportVector(GSOGlobeControl globeControl, List<string> listPipelineNames) { InitializeComponent(); globeControl1 = globeControl; pipeLineNames = listPipelineNames; } /// <summary> /// 窗体初始化事件处理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void FrmExportCADS_Load(object sender, EventArgs e) { if (pipeLineNames.Count > 0) { for (int i = 0; i < pipeLineNames.Count; i++) { GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(pipeLineNames[i]); if (layer != null) { listViewEx1.Items.Add(layer.Caption); } } } } /// <summary> /// 导出按钮事件处理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnExport_Click(object sender, EventArgs e) { string checkItemText = ""; if (listViewEx1.SelectedItems.Count > 0) { checkItemText = listViewEx1.SelectedItems[0].Text.Trim(); try { GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(checkItemText.Trim()); if (layer != null) { if (layer.GetAllFeatures().Length <= 0) { MessageBox.Show("要导出的图层为空", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } layer.Dataset.ImportProjectionRefFromProj4(Utility.projectStr); SaveFileDialog dlg = new SaveFileDialog(); dlg.Filter = "*.kml|*.kml|*.shp|*.shp"; dlg.FileName = layer.Caption; if (dlg.ShowDialog() == DialogResult.OK) { if (layer.GetAllFeatures().Length > 0) { layer.SaveAs(dlg.FileName); MessageBox.Show("导出矢量完成!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); this.Close(); } } } else { MessageBox.Show("请选中要导出的图层!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } catch (Exception ex) { LogError.PublishError(ex); } } else { MessageBox.Show("请选中要导出的图层!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } /// <summary> /// 关闭按钮事件处理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnClose_Click(object sender, EventArgs e) { this.Close(); } } }