using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.IO; using GeoScene.Globe; using GeoScene.Data; using GeoScene.Engine; using System.Runtime.InteropServices; using DevComponents.DotNetBar.Rendering; using DevComponents.DotNetBar; using System.Xml; using System.Collections; using System.Data.SqlClient; using System.Diagnostics; using Microsoft.Win32; using System.Threading; using System.Net.NetworkInformation; using System.Net.Sockets; using MySql.Data.MySqlClient; using System.Data.OracleClient; using Cyberpipe.PATM_Forms; using Cyberpipe.Forms; namespace Cyberpipe { public partial class MainFrm : Office2007Form { TreeNode terrainManagerNode = null; TreeNode layerManagerNode = null; TreeNode myPlaceNode = null; bool m_bFullScreen = false; Rectangle m_rcOld = new Rectangle(0, 0, 0, 0); GeoScene.Globe.GSOGlobeControl globeControl1; GSOGlobeControl globeControl2; private GSOHudButton legend;//定义图例 private GSOHudButton btnToolNone; private GSOHudButton btnToolSelect; System.Windows.Forms.ToolTip tooltip1; GSOBalloon featureTooltip; GSOBalloonEx balloonEx; GSOLayer layerTemp; FrmShResult frmShResult = null; FrmRedlineResult frmredResult = null; FrmMnModify frmModify = null; public bool frmRedlineResult = false; public bool boolfrmShResult = false; public bool boolfrmModify = false; List<string> m_PipelineLayerNames = new List<string>();//线图层名称 List<string> workwellLayerNames = new List<string>();//工井图层名称 List<string> valueLayerNames = new List<string>();//阀门图层名称 List<string> instrumenLayerNames = new List<string>();//附属物图层名称 List<string> pipefittingLayerNames = new List<string>();//管件图层名称 string roadLayerName = ""; public static string m_CurrentQueryLayer;//定义当前查询的图层 //定位和闪烁初始化定义 int count = 0; private string flashflag = "single"; public bool m_AddPipeLine = false;//bool添加管线 bool m_isDrawTunnel = false;//bool创建隧道 bool m_isDrawCitySevenLine = false; private bool m_isDrawRedPology = false; //红线工具 private string trackflag;//定义阀门查询个数 private GSOFeature m_ConnexityAnalysisFirstFeature; private GSOFeature m_ConnexityAnaylsisSecondFeature; private GSOLayer m_ConnexityAnalysisFirstLayer; private GSOLayer m_COnnexityAnalysisSecondLayer; private GSOFeatures m_ConnexityAnalyResFeatures; private GSOFeatures m_TraceUpDownAnalyResFeatures; private GSOFeatures m_AffectedPipeLines; private GSOFeatures m_CloseValvesAnalyResFeatures; private GSOFeatures m_BoosterValvesAnalyResFeatures; //管线间距分析 private GSOFeature disFeature = new GSOFeature(); private GSOFeature featureDis = new GSOFeature(); ArrayList m_CloseValvesList = new ArrayList();//声明集合存储阀门分析的阀门Feature对象 ArrayList m_BoosterValvesList = new ArrayList();//声明集合存储阀门分析的阀门Feature对象 //记录沿线飞行设置 //int m_nFlyMode = 2; double m_dFlyAboveLine = 1; double m_dFlyAlongLineSpeed = 50; double m_dFlyAlongLineRotateSpeed = 50; // 挖坑设置 Double m_dDigPitValue = 3; Double m_dDigPitWidthAlongLine = 6; Boolean m_bDigPitByDepth = true; //选择管线 int selectState = 0; private OracleConnection connBackup = null; //数据集合 public static GeoScene.Engine.GSODataSource ds = null; public static GeoScene.Engine.GSODataSource shds = null; //审核layer string shlayername = ""; string redlinelayername = ""; string newlayername = ""; //导入新layer图层 //一键审核问题layer public ArrayList shresultLists = new ArrayList(); int optiValue = 50; GSOLayer layerRedRegion = null; /// <summary> /// /// </summary> public MainFrm() { InitializeComponent(); PipeSys.Attach(this.panelEx5.Controls); globeControl1 = PipeSys.getGlobeCtrl(); globeControl1.Dock = DockStyle.Fill; this.ribbonControl1.Width = this.Width; this.panelEx4.Controls.Add(splitContainer1); splitContainer1.Dock = DockStyle.Fill; this.panelEx4.Controls.Add(expandableSplitter2); expandableSplitter2.Dock = DockStyle.Bottom; expandableSplitter2.Expanded = false; this.panelEx4.Controls.Add(panelOfTable); panelOfTable.Dock = DockStyle.Bottom; sideBar1.Visible = true; sideBarPanelItem3.Visible = true; controlContainerItem3.Visible = true; controlContainerItem3.Control = layerTree; layerTree.Dock = DockStyle.Fill; sideBar1.ExpandedPanel = sideBarPanelItem3; sideBar1.Refresh(); Refresh(); controlContainerItem5.Control = panel1; panel1.Dock = DockStyle.Fill; panel1.Height = Screen.PrimaryScreen.WorkingArea.Height - 120; sideBarPanelItem4.Visible = false; panel5.Visible = false; panelEx3.Visible = false; panelSpacingAnalysis.Visible = false; panel2.Height = Screen.PrimaryScreen.WorkingArea.Height - 120; featureTooltip = new GSOBalloon(globeControl1.Handle); balloonEx = new GSOBalloonEx(globeControl1.Handle); Utility.SetBallons(featureTooltip, balloonEx); PipeSys.Attach(this.panelEx1.Controls); globeControl2 = PipeSys.getGlobeCtrl(); globeControl2.Dock = DockStyle.Fill; } private void MainFrm_Load(object sender, EventArgs e) { //分辨率问题 int SW = Screen.PrimaryScreen.Bounds.Width; double dsw = (double)SW; if (SW > 1440) { double myScreen = dsw / 1440; this.buttonX1.Width = (int)(this.buttonX1.Width * myScreen); this.buttonX2.Width = (int)(this.buttonX2.Width * myScreen); //this.buttonX3.Width = (int)(this.buttonX3.Width * myScreen); this.buttonX4.Width = (int)(this.buttonX4.Width * myScreen); this.buttonX5.Width = (int)(this.buttonX5.Width * myScreen); this.buttonX6.Width = (int)(this.buttonX6.Width * myScreen); this.buttonX7.Width = (int)(this.buttonX8.Width * myScreen); this.buttonX8.Width = (int)(this.buttonX8.Width * myScreen); this.buttonX9.Width = (int)(this.buttonX9.Width * myScreen); this.buttonX12.Width = (int)(this.buttonX12.Width * myScreen); this.buttonX14.Width = (int)(this.buttonX14.Width * myScreen); this.buttonX15.Width = (int)(this.buttonX15.Width * myScreen); this.buttonX16.Width = (int)(this.buttonX16.Width * myScreen); this.buttonX17.Width = (int)(this.buttonX17.Width * myScreen); this.labelX1.Width = (int)(this.labelX1.Width * myScreen); this.labelX2.Width = (int)(this.labelX2.Width * myScreen); this.labelX3.Width = (int)(this.labelX3.Width * myScreen); //this.labelX4.Width = (int)(this.labelX4.Width * myScreen); this.labelX6.Width = (int)(this.labelX6.Width * myScreen); this.labelX8.Width = (int)(this.labelX8.Width * myScreen); this.labelX9.Width = (int)(this.labelX9.Width * myScreen); this.labelX12.Width = (int)(this.labelX12.Width * myScreen); this.labelX13.Width = (int)(this.labelX13.Width * myScreen); this.labelX14.Width = (int)(this.labelX14.Width * myScreen); this.labelX16.Width = (int)(this.labelX16.Width * myScreen); this.labelX17.Width = (int)(this.labelX17.Width * myScreen); this.labelX11.Width = (int)(this.labelX11.Width * myScreen); this.labelX19.Width = (int)(this.labelX19.Width * myScreen); //this.labelX20.Width = (int)(this.labelX20.Width * myScreen); this.labelX21.Width = (int)(this.labelX21.Width * myScreen); this.labelX22.Width = (int)(this.labelX22.Width * myScreen); this.labelX24.Width = (int)(this.labelX24.Width * myScreen); } btnToolNone = new GSOHudButton(); btnToolNone.SetImage(Application.StartupPath + "\\Resource\\image\\Pan1.png"); btnToolNone.FadeOut = false; btnToolNone.Align = EnumAlign.TopLeft; btnToolNone.SetOffset(20, 15); btnToolNone.Name = "0"; btnToolNone.HeightFixed = true; btnToolNone.WidthFixed = true; globeControl1.Globe.AddHudControl(btnToolNone); globeControl2.Globe.AddHudControl(btnToolNone); btnToolSelect = new GSOHudButton(); btnToolSelect.SetImage(Application.StartupPath + "\\Resource\\image\\select1.png"); btnToolSelect.FadeOut = false; btnToolSelect.Align = EnumAlign.TopLeft; btnToolSelect.SetOffset(20, 50); //btnToolSelect.MinOpaque = 0.05f; btnToolSelect.Name = "1"; //btnToolSelect.MaxOpaque = 1; btnToolSelect.HeightFixed = true; btnToolSelect.WidthFixed = true; globeControl1.Globe.AddHudControl(btnToolSelect); globeControl2.Globe.AddHudControl(btnToolSelect); legend = new GSOHudButton(); legend.SetImage(Application.StartupPath + "/Resource/图例P.jpg"); legend.SetOffset(0, 15); legend.MinOpaque = 1; legend.MaxOpaque = 1; legend.FadeOut = false; legend.Name = "legend"; legend.Align = EnumAlign.BottomRight; globeControl1.Globe.AddHudControl(legend); legend.Visible = false; this.KeyPreview = true; globeControl1.Globe.UnderGroundFloor.Visible = false; globeControl1.Globe.OverviewControl.Visible = false; globeControl1.Globe.ScalerControl.Visible = false; globeControl1.Globe.LatLonGrid.Visible = false; globeControl1.Globe.StatusBar.SetTextVisible(EnumStatusBarText.ProCoord, false); globeControl1.Globe.Antialiasing = true; globeControl1.Globe.FeatureMouseOverEnable = true; globeControl1.Globe.ModelUseLighting = true; globeControl1.Globe.EditSnapObject = false; globeControl1.Globe.MaxUserBackgroundAlt = 20000; globeControl1.Globe.UserBackgroundColorValid = true; globeControl1.Globe.UserBackgroundColor = Color.White; globeControl1.Globe.FlyAlongLineSpeed = m_dFlyAlongLineSpeed; globeControl1.Globe.FlyAlongLineRotateSpeed = m_dFlyAlongLineRotateSpeed; globeControl1.Globe.FlyToPointSpeed = globeControl1.Globe.FlyToPointSpeed * 3; globeControl1.Globe.EditSnapObject = true; globeControl2.Globe.UnderGroundFloor.Visible = false; globeControl2.Globe.LatLonGrid.Visible = false; globeControl2.Globe.StatusBar.SetTextVisible(EnumStatusBarText.ProCoord, false); globeControl2.Globe.Antialiasing = true; globeControl2.Globe.FeatureMouseOverEnable = true; globeControl2.Globe.ModelUseLighting = true; globeControl2.Globe.EditSnapObject = false; globeControl2.Globe.MaxUserBackgroundAlt = 20000; globeControl2.Globe.UserBackgroundColorValid = true; globeControl2.Globe.UserBackgroundColor = Color.White; globeControl2.Globe.FlyAlongLineSpeed = m_dFlyAlongLineSpeed; globeControl2.Globe.FlyAlongLineRotateSpeed = m_dFlyAlongLineRotateSpeed; globeControl2.Globe.FlyToPointSpeed = globeControl2.Globe.FlyToPointSpeed * 3; globeControl2.Globe.EditSnapObject = true; globeControl1.HudControlMouseDownEvent += new HudControlMouseDownEventHandler(globeControl1_HudControlMouseDownEvent); globeControl2.HudControlMouseDownEvent += new HudControlMouseDownEventHandler(globeControl2_HudControlMouseDownEvent); globeControl1.HudControlMouseIntoEvent += new HudControlMouseIntoEventHandler(globeControl1_HudControlMouseIntoEvent); globeControl1.HudControlMouseOutEvent += new HudControlMouseOutEventHandler(globeControl1_HudControlMouseOutEvent); globeControl1.AfterNetLayerAddEvent += new AfterNetLayerAddEventHandler(globeControl1_AfterNetLayerAddEvent); globeControl1.FeatureMouseClickEvent += new FeatureMouseClickEventHandler(globeControl1_FeatureMouseClickEvent); globeControl1.FeatureMouseHoverEvent += new FeatureMouseHoverEventHandler(globeControl1_FeatureMouseHoverEvent); globeControl1.MouseDoubleClick += new MouseEventHandler(globeControl1_MouseDoubleClick); globeControl1.MouseClick += new MouseEventHandler(globeControl1_MouseClick); globeControl1.MouseWheel += new MouseEventHandler(globeControl1_MouseWheel); globeControl2.MouseWheel += new MouseEventHandler(globeControl2_MouseWheel); globeControl1.CameraBeginMoveEvent += new CameraBeginMoveEventHandler(globeControl1_CameraBeginMoveEvent); globeControl1.TrackPolylineEndEvent += new TrackPolylineEndEventHandler(globeControl1_TrackPolylineEndEvent); globeControl1.TrackPolygonEndEvent += new TrackPolygonEndEventHandler(globeControl1_TrackPolygonEndEvent); globeControl1.TrackRectEndEvent += new TrackRectEndEventHandler(globeControl1_TrackRectEndEvent); GSOSimplePolygonStyle3D trackingRectStyle = globeControl1.Globe.TrackRectTool.TrackingPolygonStyle as GSOSimplePolygonStyle3D; trackingRectStyle.FillColor = Color.FromArgb(0, 0, 0, 0); GSOSimplePolygonStyle3D trackRectStyle = globeControl1.Globe.TrackRectTool.PolygonStyle as GSOSimplePolygonStyle3D; trackRectStyle.FillColor = Color.FromArgb(0, 0, 0, 0); GSOSimpleLineStyle3D trackRectLineStyle = globeControl1.Globe.TrackRectTool.PolygonStyle.OutlineStyle as GSOSimpleLineStyle3D; trackRectLineStyle.LineType = EnumLineType.Solid; GSOSimpleLineStyle3D trackRectLineStyle1 = globeControl1.Globe.TrackRectTool.TrackingPolygonStyle.OutlineStyle as GSOSimpleLineStyle3D; trackRectLineStyle1.LineType = EnumLineType.Solid; trackRectLineStyle1.LineColor = Color.FromArgb(0, 174, 255); trackRectLineStyle1.LineWidth = 1; globeControl1.Globe.StatusBar.SetProject(Utility.projectStr); globeControl1.Globe.StatusBar.SetTextVisible(EnumStatusBarText.ProCoord, true); globeControl2.Globe.StatusBar.SetProject(Utility.projectStr); globeControl2.Globe.StatusBar.SetTextVisible(EnumStatusBarText.ProCoord, true); //双屏联动 globeControl1.BeforeSceneRenderEvent += new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); globeControl2.BeforeSceneRenderEvent += new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); //globeControl2.AfterLayerAddEvent += new AfterLayerAddEventHandler(globeControl2_AfterLayerAddEvent); Stopwatch sw = new Stopwatch(); globeControl1.Globe.ConnectServer(Utility.serverip, Utility.serverport, "", ""); //加载locaServer中的数据 //globeControl2.Globe.ConnectServer(Utility.serverip, Utility.serverport, "", ""); //加载locaServer中的数据 //定位 double x = Convert.ToDouble(Utility.Query_Fields["经纬度坐标"].ToString().Split(',')[0]); double y = Convert.ToDouble(Utility.Query_Fields["经纬度坐标"].ToString().Split(',')[1]); double z = Convert.ToDouble(Utility.Query_Fields["经纬度坐标"].ToString().Split(',')[2]); jumpToCameraState(x, y, z); Utility.dataSource = globeControl1.Globe.DataManager.OpenOracleDataSource(Utility.DBServer.Trim() + "/" + Utility.dbdatabase.Trim(), "", "", Utility.userID, Utility.DBPassword); if (Utility.dataSource == null) { MessageBox.Show("数据库连接失败,请确认配置文件参数是否正确!"); } myPlaceNode = new TreeNode(); myPlaceNode.ImageIndex = 0; myPlaceNode.SelectedImageIndex = 0; myPlaceNode.Checked = true; myPlaceNode.Tag = globeControl1.Globe.MemoryLayer; myPlaceNode.Text = "我的地标"; myPlaceNode.NodeFont = new Font(layerTree.Font, FontStyle.Bold); layerTree.Nodes.Add(myPlaceNode); ReadKmlToMemoryLayer(Application.StartupPath + "/MyPlace.kml"); TreeNode node = new TreeNode(); node.ImageIndex = 0; node.SelectedImageIndex = 0; node.Checked = true; node.Text = "标注管理"; layerMarkerTree.Nodes.Add(node); string[] markerStrs = new string[9]; markerStrs[0] = "标高标注"; markerStrs[1] = "管径标注"; markerStrs[2] = "埋深标注"; markerStrs[3] = "坐标标注"; markerStrs[4] = "坡度标注"; markerStrs[5] = "属性标注"; markerStrs[6] = "自定义标注"; markerStrs[7] = "距离标注"; markerStrs[8] = "扯旗标注"; for (int i = 0; i < markerStrs.Length; i++) { if (File.Exists(Application.StartupPath + "\\标注管理\\" + markerStrs[i] + ".lgd")) { GSOLayer markerLayer = globeControl1.Globe.Layers.Add(Application.StartupPath + "\\标注管理\\" + markerStrs[i] + ".lgd"); if (markerLayer != null) { TreeNode node1 = new TreeNode(); node1.Text = markerLayer.Caption; node1.ImageIndex = 0; node1.SelectedImageIndex = 0; node1.Checked = markerLayer.Visible; node1.Tag = markerLayer; layerMarkerTree.Nodes[0].Nodes.Add(node1); } } } //传感器 TreeNode nodeSensor = new TreeNode(); nodeSensor.ImageIndex = 0; nodeSensor.SelectedImageIndex = 0; nodeSensor.Checked = true; nodeSensor.Text = "传感器管理"; layerSensorTree.Nodes.Add(nodeSensor);//传感器 if (Utility.sensorMarkerLayers != null) { for (int i = 0; i < Utility.sensorMarkerLayers.Count; i++) { MarkerLayer mLayer = Utility.sensorMarkerLayers[i]; if (File.Exists(Application.StartupPath + "\\传感器\\" + mLayer.layerName + ".lgd")) { GSOLayer sensorLayer = globeControl1.Globe.Layers.Add(Application.StartupPath + "\\传感器\\" + mLayer.layerName + ".lgd"); if (sensorLayer != null) { sensorLayer.Visible = false; TreeNode node1 = new TreeNode(); node1.Text = sensorLayer.Caption; node1.ImageIndex = 0; node1.SelectedImageIndex = 0; node1.Checked = sensorLayer.Visible; node1.Tag = sensorLayer; layerSensorTree.Nodes[0].Nodes.Add(node1); } } } } layerManagerNode = new TreeNode(); layerManagerNode.ImageIndex = 0; layerManagerNode.SelectedImageIndex = 0; layerManagerNode.Checked = true; layerManagerNode.Text = "临时图层"; layerTree.Nodes.Add(layerManagerNode); loadTreeView(layerTree);//创建节点树,并且添加图层 sideBar1.ExpandedPanel = sideBarPanelItem3; comboBoxEx1.Items.Clear(); comboBoxEx2.Items.Clear(); comboBoxEx3.Items.Clear(); comboBoxEx4.Items.Clear(); comboBoxLayer.Items.Clear(); for (int i = 0; i < m_PipelineLayerNames.Count; i++) { comboBoxEx1.Items.Add(m_PipelineLayerNames[i]); comboBoxEx2.Items.Add(m_PipelineLayerNames[i]); comboBoxEx3.Items.Add(m_PipelineLayerNames[i]); comboBoxEx4.Items.Add(m_PipelineLayerNames[i]); comboBoxLayer.Items.Add(m_PipelineLayerNames[i]); } connBackup = OledbHelper.sqlConnection();//链接数据库中的master,实现数据库文件备份 splitContainer1.Panel2Collapsed = true; layerTemp = globeControl1.Globe.Layers.Add(Application.StartupPath + "\\tempLgdData.lgd"); if (layerTemp != null) { layerTemp.MaxVisibleAltitude = 1000; } globeControl1.Globe.Layers.Add(Application.StartupPath + "/城市七线/城市红线.lgd"); globeControl1.Globe.Layers.Add(Application.StartupPath + "/城市七线/城市橙线.lgd"); globeControl1.Globe.Layers.Add(Application.StartupPath + "/城市七线/城市黄线.lgd"); globeControl1.Globe.Layers.Add(Application.StartupPath + "/城市七线/城市绿线.lgd"); globeControl1.Globe.Layers.Add(Application.StartupPath + "/城市七线/城市蓝线.lgd"); globeControl1.Globe.Layers.Add(Application.StartupPath + "/城市七线/城市紫线.lgd"); globeControl1.Globe.Layers.Add(Application.StartupPath + "/城市七线/城市黑线.lgd"); globeControl1.Globe.Layers.Add(Application.StartupPath + "/隧道.lgd"); buttonItem87.Checked = true;//默认地上模式 configResource2();//配置登录用户的显示 ribbonTabItem1.Select(); //初始化状态为浏览 //显示状态栏信息 //statusLabel.Text = "欢迎您!登陆用户:" + Utility.userName; //初始化隐藏图层管理 sideBarPanelItem3.Visible = false; layerTree.Visible = false; controlContainerItem3.Visible = false; if (sideBarPanelItem4.Visible == true) { sideBar1.Visible = true; controlContainerItem5.Visible = true; } else { sideBar1.Visible = false; } Refresh(); ////////////////////////初始化地面透明度为50////////////////////// sliderGroundTransSet1.Value = optiValue; sliderItem1.Value = optiValue; } /// <summary> /// 每次gis服务加载时都会触发的 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void globeControl2_AfterLayerAddEvent(object sender, AfterLayerAddEventArgs e) { //throw new NotImplementedException(); if (e.Layer != null) { if (e.Layer.Name.Contains("fttp:")) { if(e.Layer.Caption.Contains("180fd")) { MessageBox.Show("afds=="+e.Layer.Caption); } // e.Layer.Caption = dictionaryNetLayerNameAndCaption[e.Layer.Caption]; } } } Dictionary<string, string> dictionaryNetLayerNameAndCaption = new Dictionary<string, string>(); void globeControl1_AfterNetLayerAddEvent(object sender, AfterNetLayerAddEventArgs e) { if (e.Layer != null && dictionaryNetLayerNameAndCaption.ContainsKey(e.Layer.Caption)) { e.Layer.Caption = dictionaryNetLayerNameAndCaption[e.Layer.Caption]; } } void ReadKmlToMemoryLayer(String kmlPath) { GSODataset dataset = globeControl1.Globe.DataManager.AddFileDataset(kmlPath); GSOFeatureDataset fdataset = dataset as GSOFeatureDataset; if (fdataset != null) { GSOFeatures features = fdataset.GetAllFeatures(); AddFeaturesNodeToMyPlace(features); } } void AddFeaturesNodeToMyPlace(GSOFeatures features) { if (features == null || features.Length ==0) { return; } for (Int32 i = 0; i < features.Length; i++) { GSOFeature feature = features[i]; if (feature.Type == EnumFeatureType.FeatureFolder) { GSOFeatureFolder featureFolder = (GSOFeatureFolder)feature; AddFeaturesNodeToMyPlace(featureFolder.Features); } else { TreeNode tempnode = new TreeNode(); tempnode.Text = feature.Name; if (feature.Geometry != null) { switch (feature.Geometry.Type) { case EnumGeometryType.GeoPoint3D: case EnumGeometryType.GeoMarker: tempnode.ImageIndex = 3; tempnode.SelectedImageIndex = 3; break; case EnumGeometryType.GeoPolyline3D: tempnode.ImageIndex = 4; tempnode.SelectedImageIndex = 4; break; case EnumGeometryType.GeoPolygon3D: tempnode.ImageIndex = 5; tempnode.SelectedImageIndex = 5; break; case EnumGeometryType.GeoModel: case EnumGeometryType.GeoEntity: case EnumGeometryType.GeoGroupEntity: case EnumGeometryType.GeoSphereEntity: case EnumGeometryType.GeoBoxEntity: case EnumGeometryType.GeoEllipsoidEntity: case EnumGeometryType.GeoCylinderEntity: case EnumGeometryType.GeoFrustumEntity: case EnumGeometryType.GeoEllipCylinderEntity: case EnumGeometryType.GeoEllipFrustumEntity: case EnumGeometryType.GeoRangeEllipsoidEntity: case EnumGeometryType.GeoRangeEllipCylinderEntity: case EnumGeometryType.GeoRangeEllipFrustumEntity: tempnode.ImageIndex = 6; tempnode.SelectedImageIndex = 6; break; case EnumGeometryType.GeoGroundOverlay: tempnode.ImageIndex = 7; tempnode.SelectedImageIndex = 7; break; } } GSOFeature newFeature = globeControl1.Globe.MemoryLayer.AddFeature(feature); tempnode.Checked = newFeature.Visible; tempnode.Tag = newFeature; myPlaceNode.Nodes.Add(tempnode); } } } private void configResource2() { if (Utility.userName != null && Utility.userName != "") { string userName = Utility.userName; //string sql = "select ur.gid from casic_userroletest as ur,UserInfoTest as ui where ui.rid=ur.role and ui.username='" + userName + "'"; string sql = "select casic_userroletest.\"GID\" from casic_userroletest,casic_userinfotest where casic_userroletest.\"ROLE\" = casic_userinfotest.\"RID\" and casic_userinfotest.\"USERNAME\"='"+userName+"'"; DataTable dt = OledbHelper.QueryTable(sql); string rolename = ""; if (dt != null && dt.Rows.Count > 0) { rolename = dt.Rows[0][0].ToString().Trim(); } setControlVisible(rolename); } } private void setControlVisible(string rolename) { string[] groupname = rolename.Split(','); //有何权限? ArrayList listItem = new ArrayList(); ArrayList subListItem = new ArrayList(); System.Windows.Forms.Control.ControlCollection cc = ribbonControl1.Controls; for (int i = 0; i < cc.Count; i++) { if (cc[i].GetType() == typeof(DevComponents.DotNetBar.RibbonStrip)) { DevComponents.DotNetBar.RibbonStrip ribbonStripResource = cc[i] as DevComponents.DotNetBar.RibbonStrip; for (int j = 0; j < ribbonStripResource.Items.Count; j++) { //MessageBox.Show("i==" + i.ToString() + "==j==" + j.ToString() + "===" + ribbonStripResource.Items.Count.ToString() + "==" + ribbonStripResource.Items[j].Text); if (ribbonStripResource.Items[j].GetType() == typeof(DevComponents.DotNetBar.RibbonTabItem)) { DevComponents.DotNetBar.RibbonTabItem ribbonTabItemResource = ribbonStripResource.Items[j] as DevComponents.DotNetBar.RibbonTabItem; string tabItemResourceName = ribbonTabItemResource.Text; if (rolename == "all") { ribbonTabItemResource.Visible = true; } else { if (!isContainName(groupname, tabItemResourceName)) { //MessageBox.Show(tabItemResourceName); ribbonTabItemResource.Visible = false; } } } } } } } #region 配置用户权限 /// <summary> /// 向数据库插入功能列表 /// </summary> private void insertControlToDatabase() { ArrayList listItem = new ArrayList(); List<Resource> subListItem = new List<Resource>(); System.Windows.Forms.Control.ControlCollection cc = ribbonControl1.Controls; for (int i = 0; i < cc.Count; i++) { if (cc[i].GetType() == typeof(DevComponents.DotNetBar.RibbonStrip)) { DevComponents.DotNetBar.RibbonStrip ribbonStripResource = cc[i] as DevComponents.DotNetBar.RibbonStrip; for (int j = 0; j < ribbonStripResource.Items.Count; j++) { if (ribbonStripResource.Items[j].GetType() == typeof(DevComponents.DotNetBar.RibbonTabItem)) { DevComponents.DotNetBar.RibbonTabItem ribbonTabItemResource = ribbonStripResource.Items[j] as DevComponents.DotNetBar.RibbonTabItem; string tabItemResourceName = ribbonTabItemResource.Text; listItem.Add(tabItemResourceName); subListItem.Add(new Resource(tabItemResourceName, "NULL")); if (ribbonTabItemResource.SubItems.Count > 0) { for (int k = 0; k < ribbonTabItemResource.SubItems.Count; k++) { if (ribbonTabItemResource.SubItems[k].GetType() == typeof(DevComponents.DotNetBar.ButtonItem)) { DevComponents.DotNetBar.ButtonItem buttonItemResource = ribbonTabItemResource.SubItems[k] as DevComponents.DotNetBar.ButtonItem; string buttonItemResourceName = buttonItemResource.Text; subListItem.Add(new Resource(buttonItemResourceName, tabItemResourceName)); } } } } } } else if (cc[i].GetType() == typeof(DevComponents.DotNetBar.RibbonPanel)) { DevComponents.DotNetBar.RibbonPanel ribbonPanelResource = cc[i] as DevComponents.DotNetBar.RibbonPanel; for (int j = 0; j < ribbonPanelResource.Controls.Count; j++) { if (ribbonPanelResource.Controls[j].GetType() == typeof(DevComponents.DotNetBar.RibbonBar)) { DevComponents.DotNetBar.RibbonBar ribbonBarResource = ribbonPanelResource.Controls[j] as DevComponents.DotNetBar.RibbonBar; for (int k = 0; k < ribbonBarResource.Items.Count; k++) { if (ribbonBarResource.Items[k].GetType() == typeof(DevComponents.DotNetBar.ButtonItem)) { DevComponents.DotNetBar.ButtonItem buttonItemResource = ribbonBarResource.Items[k] as DevComponents.DotNetBar.ButtonItem; string buttonItemResourceName = buttonItemResource.Text; subListItem.Add(new Resource(buttonItemResourceName, ribbonBarResource.Name)); if (buttonItemResource.SubItems.Count > 0) { for (int m = 0; m < buttonItemResource.SubItems.Count; m++) { if (buttonItemResource.SubItems[m].GetType() == typeof(DevComponents.DotNetBar.ButtonItem)) { DevComponents.DotNetBar.ButtonItem subButtonItemResource = buttonItemResource.SubItems[m] as DevComponents.DotNetBar.ButtonItem; string SubButtonItemResourceName = subButtonItemResource.Text; subListItem.Add(new Resource(SubButtonItemResourceName, buttonItemResourceName)); } } } } else { if (ribbonBarResource.Items[k].GetType() == typeof(DevComponents.DotNetBar.SliderItem)) { DevComponents.DotNetBar.SliderItem sliderItemResource = ribbonBarResource.Items[k] as DevComponents.DotNetBar.SliderItem; subListItem.Add(new Resource(sliderItemResource.Text.Trim(), ribbonBarResource.Name)); if (sliderItemResource.SubItems.Count > 0) { for (int m = 0; m < sliderItemResource.SubItems.Count; m++) { if (sliderItemResource.SubItems[m].GetType() == typeof(DevComponents.DotNetBar.ButtonItem)) { DevComponents.DotNetBar.ButtonItem subButtonItemResource = sliderItemResource.SubItems[m] as DevComponents.DotNetBar.ButtonItem; string subButtonItemResourceName = subButtonItemResource.Text; subListItem.Add(new Resource(subButtonItemResourceName, sliderItemResource.Text.Trim())); } } } } } } } } } } if (subListItem.Count > 0) { foreach (Resource r in subListItem) { string pname = getRealName(r.resourceParentName); string sql = "insert into casic_resc(\"name\",\"aid\",\"pname\") values('" + r.resourceName + "',1,'" + pname + "')"; int rowCount = OledbHelper.sqlExecuteNonQuery(sql); } MessageBox.Show("插入成功", "提示"); } } private string getRealName(string name) { string realName = ""; switch (name) { case "ribbonBar10": realName = "文件"; break; case "ribbonBar21": realName = "浏览"; break; case "ribbonBar4": realName = "场景"; break; case "ribbonBar2": realName = "查询"; break; case "ribbonBar11": realName = "编辑"; break; case "ribbonBar5": realName = "编辑"; break; case "ribbonBar6": realName = "统计"; break; case "ribbonBar8": realName = "统计"; break; case "ribbonBar14": realName = "量算"; break; case "ribbonBar12": realName = "标注"; break; case "ribbonBar1": realName = "分析"; break; case "ribbonBarJJ": realName = "净距分析"; break; case "ribbonBarTP": realName = "拓扑分析"; break; case "ribbonBarSY": realName = "视域分析"; break; case "ribbonBarKW": realName = "开挖分析"; break; case "ribbonBarQY": realName = "区域分析"; break; case "ribbonBarMN": realName = "模拟分析"; break; case "ribbonBarDM": realName = "断面分析"; break; case "ribbonBar13": realName = "数据管理"; break; case "ribbonBar3": realName = "数据管理"; break; case "ribbonBar9": realName = "数据管理"; break; case "ribbonBar7": realName = "飞行"; break; case "ribbonBar15": realName = "用户管理"; break; case "ribbonBar16": realName = "传感器"; break; default : realName = name; break; } return realName; } private void configResource() { if (Utility.userName != null && Utility.userName != "") { string userName = Utility.userName; string sql = "select casic_resc.\"name\" from casic_userstatus join casic_role on casic_userstatus.\"rid\" = casic_role.\"id\" join casic_perm on casic_role.\"pid\"=casic_perm.\"id\" join casic_permresc on casic_perm.\"id\"=casic_permresc.\"permid\" join casic_resc on casic_permresc.\"rescid\"=casic_resc.\"id\" where casic_userstatus.\"username\"='" + userName + "'"; DataTable dt = OledbHelper.QueryTable(sql); if (dt != null && dt.Rows.Count > 0) { string[] sResourceName = new string[dt.Rows.Count]; for (int i = 0; i < dt.Rows.Count; i++) { sResourceName[i] = dt.Rows[i][0].ToString().Trim(); } setControlVisilbe(sResourceName); } } } private bool isContainName(string[] array, string name) { bool bl = false; for (int i = 0; i < array.Length; i++) { if (array[i] == name) { bl = true; break; } } return bl; } private void setControlVisilbe(string[] resourceNames) { ArrayList listItem = new ArrayList(); ArrayList subListItem = new ArrayList(); System.Windows.Forms.Control.ControlCollection cc = ribbonControl1.Controls; for (int i = 0; i < cc.Count; i++) { if (cc[i].GetType() == typeof(DevComponents.DotNetBar.RibbonStrip)) { DevComponents.DotNetBar.RibbonStrip ribbonStripResource = cc[i] as DevComponents.DotNetBar.RibbonStrip; for (int j = 0; j < ribbonStripResource.Items.Count; j++) { if (ribbonStripResource.Items[j].GetType() == typeof(DevComponents.DotNetBar.RibbonTabItem)) { DevComponents.DotNetBar.RibbonTabItem ribbonTabItemResource = ribbonStripResource.Items[j] as DevComponents.DotNetBar.RibbonTabItem; string tabItemResourceName = ribbonTabItemResource.Text; listItem.Add(tabItemResourceName); subListItem.Add(tabItemResourceName); if (!isContainName(resourceNames, tabItemResourceName)) { ribbonTabItemResource.Visible = false; } if (ribbonTabItemResource.SubItems.Count > 0) { for (int k = 0; k < ribbonTabItemResource.SubItems.Count; k++) { if (ribbonTabItemResource.SubItems[k].GetType() == typeof(DevComponents.DotNetBar.ButtonItem)) { DevComponents.DotNetBar.ButtonItem buttonItemResource = ribbonTabItemResource.SubItems[k] as DevComponents.DotNetBar.ButtonItem; string buttonItemResourceName = buttonItemResource.Text; subListItem.Add(buttonItemResourceName); if (!isContainName(resourceNames, buttonItemResourceName)) { buttonItemResource.Visible = false; } } } } } } } else if (cc[i].GetType() == typeof(DevComponents.DotNetBar.RibbonPanel)) { DevComponents.DotNetBar.RibbonPanel ribbonPanelResource = cc[i] as DevComponents.DotNetBar.RibbonPanel; for (int j = 0; j < ribbonPanelResource.Controls.Count; j++) { if (ribbonPanelResource.Controls[j].GetType() == typeof(DevComponents.DotNetBar.RibbonBar)) { DevComponents.DotNetBar.RibbonBar ribbonBarResource = ribbonPanelResource.Controls[j] as DevComponents.DotNetBar.RibbonBar; for (int k = 0; k < ribbonBarResource.Items.Count; k++) { if (ribbonBarResource.Items[k].GetType() == typeof(DevComponents.DotNetBar.ButtonItem)) { DevComponents.DotNetBar.ButtonItem buttonItemResource = ribbonBarResource.Items[k] as DevComponents.DotNetBar.ButtonItem; string buttonItemResourceName = buttonItemResource.Text; subListItem.Add(buttonItemResourceName); if (!isContainName(resourceNames, buttonItemResourceName)) { buttonItemResource.Visible = false; } if (buttonItemResource.SubItems.Count > 0) { for (int m = 0; m < buttonItemResource.SubItems.Count; m++) { if (buttonItemResource.SubItems[m].GetType() == typeof(DevComponents.DotNetBar.ButtonItem)) { DevComponents.DotNetBar.ButtonItem subButtonItemResource = buttonItemResource.SubItems[m] as DevComponents.DotNetBar.ButtonItem; string SubButtonItemResourceName = subButtonItemResource.Text; subListItem.Add(SubButtonItemResourceName); if (!isContainName(resourceNames, SubButtonItemResourceName)) { subButtonItemResource.Visible = false; } } } } } else { if (ribbonBarResource.Items[k].GetType() == typeof(DevComponents.DotNetBar.SliderItem)) { DevComponents.DotNetBar.SliderItem sliderItemResource = ribbonBarResource.Items[k] as DevComponents.DotNetBar.SliderItem; if (!isContainName(resourceNames, sliderItemResource.Text.Trim())) { sliderItemResource.Visible = false; } if (sliderItemResource.SubItems.Count > 0) { for (int m = 0; m < sliderItemResource.SubItems.Count; m++) { if (sliderItemResource.SubItems[m].GetType() == typeof(DevComponents.DotNetBar.ButtonItem)) { DevComponents.DotNetBar.ButtonItem subButtonItemResource = sliderItemResource.SubItems[m] as DevComponents.DotNetBar.ButtonItem; if (!isContainName(resourceNames, subButtonItemResource.Text.Trim())) { subButtonItemResource.Visible = false; } } } } } } } } } } } } #endregion void globeControl2_HudControlMouseDownEvent(object sender, HudControlMouseDownEventArgs e) { switch (e.HudControl.Name) { case "0": globeControl2.Globe.Action = EnumAction3D.ActionNull; break; case "1": globeControl2.Globe.Action = EnumAction3D.SelectObject; break; } } void globeControl2_BeforeSceneRenderEvent(object sender, BeforeSceneRenderEventArgs e) { if (globeControl2.Focused && btnSpld.Checked && btnSpld.Enabled) { GSOCameraState camera = globeControl2.Globe.CameraState; globeControl1.Globe.JumpToCameraState(camera); } } void globeControl1_BeforeSceneRenderEvent(object sender, BeforeSceneRenderEventArgs e) { if (globeControl1.Focused && btnSpld.Checked && btnSpld.Enabled) { GSOCameraState camera = globeControl1.Globe.CameraState; globeControl2.Globe.JumpToCameraState(camera); } } void globeControl1_AfterLayerAddEvent(object sender, AfterLayerAddEventArgs e) { if (e.Layer.Name != null && e.Layer.Name.Length > 5) { if (e.Layer.Name.Substring(0, 5).Equals("fttp:")) { return; } } if (Path.GetExtension(e.Layer.Name).ToLower().Equals(".kml")) { AddKmlLayer(e.Layer); } else { GSODataset dataset = e.Layer.Dataset; CheckDatasetGeoReference(e.Layer.Dataset, ""); TreeNode node = new TreeNode(); node.Tag = e.Layer; node.Text = e.Layer.Dataset.Caption; node.ImageIndex = 0; node.SelectedImageIndex = 0; node.Checked = e.Layer.Visible; // 注意用insert不要用add,因为后加入的图层在上层 //layerManagerNode.Nodes.Add(node); layerManagerNode.Nodes.Insert(0, node); } layerManagerNode.Expand(); terrainManagerNode.Expand(); } private void AddKmlLayer(GSOLayer layer) { if (layer != null) { TreeNode node = new TreeNode(); node.Tag = layer; node.Text = layer.Caption; node.ImageIndex = 0; node.SelectedImageIndex = 0; node.Checked = layer.Visible; layerManagerNode.Nodes.Insert(0, node); VisitFeature3Ds(layer.GetAllFeatures(), node); } } private void VisitFeature3Ds(GSOFeatures feature3ds, TreeNode node) { for (int i = 0; i < feature3ds.Length; i++) { GSOFeature feature = feature3ds[i]; if (feature.Type == EnumFeatureType.FeatureFolder) { TreeNode tempnode = new TreeNode(); tempnode.Text = feature.Name; tempnode.ImageIndex = 1; tempnode.SelectedImageIndex = 1; tempnode.Checked = node.Checked == true ? feature.Visible : false; tempnode.Tag = feature; node.Nodes.Add(tempnode); GSOFeatureFolder featureFolder = (GSOFeatureFolder)feature; VisitFeature3Ds(featureFolder.Features, tempnode); } else { TreeNode tempnode = new TreeNode(); tempnode.Text = feature.Name; if (feature.Geometry != null) { switch (feature.Geometry.Type) { case EnumGeometryType.GeoPoint3D: case EnumGeometryType.GeoMarker: tempnode.ImageIndex = 3; tempnode.SelectedImageIndex = 3; break; case EnumGeometryType.GeoPolyline3D: tempnode.ImageIndex = 4; tempnode.SelectedImageIndex = 4; break; case EnumGeometryType.GeoPolygon3D: tempnode.ImageIndex = 5; tempnode.SelectedImageIndex = 5; break; case EnumGeometryType.GeoModel: case EnumGeometryType.GeoEntity: case EnumGeometryType.GeoGroupEntity: case EnumGeometryType.GeoSphereEntity: case EnumGeometryType.GeoBoxEntity: case EnumGeometryType.GeoEllipsoidEntity: case EnumGeometryType.GeoCylinderEntity: case EnumGeometryType.GeoFrustumEntity: case EnumGeometryType.GeoEllipCylinderEntity: case EnumGeometryType.GeoEllipFrustumEntity: case EnumGeometryType.GeoRangeEllipsoidEntity: case EnumGeometryType.GeoRangeEllipCylinderEntity: case EnumGeometryType.GeoRangeEllipFrustumEntity: tempnode.ImageIndex = 6; tempnode.SelectedImageIndex = 6; break; case EnumGeometryType.GeoGroundOverlay: tempnode.ImageIndex = 7; tempnode.SelectedImageIndex = 7; break; } } tempnode.Checked = node.Checked == true ? feature.Visible : false; tempnode.Tag = feature; node.Nodes.Add(tempnode); } } } /// <summary> /// 检查数据集是否有坐标系信息 /// </summary> /// <param name="dataset"></param> /// <returns></returns> Boolean CheckDatasetGeoReference(GSODataset dataset, string strDataPath) { Boolean bSuccess = false; if (dataset.GeoReferenceType == EnumGeoReferenceType.Flat) { if (MessageBox.Show("数据没有空间参考信息,请设置空间参考信息!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation) == DialogResult.OK) { String strPath =Application.StartupPath + "\\Coordinate Systems"; OpenFileDialog dlg = new OpenFileDialog(); dlg.InitialDirectory = strPath; dlg.RestoreDirectory = true; dlg.Filter = "投影文件|*.prj||"; if (dlg.ShowDialog() == DialogResult.OK) { string lprjStr = GSODataEngineUtility.ConvertEsriPrjFileToProj4(dlg.FileName); string lprjFileContent = "<Projects><Project><Index>0</Index><Type>prj4</Type><Param>" + lprjStr + "</Param></Project></Projects>"; bSuccess = dataset.LoadProjectionFromESRIFile(dlg.FileName); //bSuccess = dataset.LoadProjectionFromESRIFile(lprjStr); string lprjFileName = strDataPath.Substring(0, strDataPath.LastIndexOf(".")) + ".lprj"; StreamWriter writer = new StreamWriter(lprjFileName, false); writer.Write(lprjFileContent); writer.Close(); } } } else { return true; } return bSuccess; } /// <summary> /// 矩形拉框结束事件处理函数 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void globeControl1_TrackRectEndEvent(object sender, TrackRectEndEventArgs e) { if (e.Polygon != null) { globeControl1.Globe.TrackRectTool.Clear(); globeControl1.ImmediatelyRefresh(); globeControl1.SwapBuffer(); Point pt1 = new Point(Convert.ToInt32(e.StartPos.X), Convert.ToInt32(e.StartPos.Y)); Point pt2 = new Point(Convert.ToInt32(e.EndPos.X), Convert.ToInt32(e.EndPos.Y)); Point pt = getUpperLeftPoint(pt1, pt2); Image myImg = new Bitmap(Convert.ToInt32(e.Rect.Width), Convert.ToInt32(e.Rect.Height)); Graphics g = Graphics.FromImage(myImg); g.CopyFromScreen(pt, new Point(0, 0), new Size(Convert.ToInt32(e.Rect.Width), Convert.ToInt32(e.Rect.Height))); SaveFileDialog dlg = new SaveFileDialog(); dlg.Filter = "输出JPEG(*.jpg)|*.jpg|输出PNG(*.png)|*.png|输出BMP(*.bmp)|*.bmp|输出BMP(*.gif)|*.gif"; if (dlg.ShowDialog() == DialogResult.OK) { string extension = System.IO.Path.GetExtension(dlg.FileName);//扩展名 switch (extension) { case ".jpg": myImg.Save(dlg.FileName, System.Drawing.Imaging.ImageFormat.Jpeg); break; case ".png": myImg.Save(dlg.FileName, System.Drawing.Imaging.ImageFormat.Png); break; case ".bmp": myImg.Save(dlg.FileName, System.Drawing.Imaging.ImageFormat.Bmp); break; case ".gif": myImg.Save(dlg.FileName, System.Drawing.Imaging.ImageFormat.Gif); break; default: break; } } this.globeControl1.Globe.Action = EnumAction3D.ActionNull; this.globeControl1.Globe.MouseRoamingEnable = true; } } /// <summary> /// 定位正北正90度俯视 /// </summary> /// <param name="x"></param> /// <param name="y"></param> /// <param name="z"></param> private void jumpToCameraState(double x, double y, double z) { GSOCameraState camera = new GSOCameraState(); camera.Latitude = y; camera.Longitude = x; camera.Distance = z; camera.Tilt = 0; camera.Heading = 0; globeControl1.Globe.JumpToCameraState(camera); globeControl2.Globe.JumpToCameraState(camera); } void globeControl1_HudControlMouseOutEvent(object sender, HudControlMouseOutEventArgs e) { if (tooltip1 != null) { tooltip1.RemoveAll(); } } void globeControl1_HudControlMouseIntoEvent(object sender, HudControlMouseIntoEventArgs e) { GSOHudButton btn = e.HudControl as GSOHudButton; tooltip1 = new System.Windows.Forms.ToolTip(); switch (e.HudControl.Name) { case "0": tooltip1.SetToolTip(globeControl1, "浏览对象"); break; case "1": tooltip1.SetToolTip(globeControl1, "选择对象"); break; } } void globeControl1_HudControlMouseDownEvent(object sender, HudControlMouseDownEventArgs e) { switch (e.HudControl.Name) { case "0": globeControl1.Globe.Action = EnumAction3D.ActionNull; // 导航功能 break; case "1": globeControl1.Globe.Action = EnumAction3D.SelectObject; // 选中对象功能 break; } } /// <summary> /// layerTree选中后事件处理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void layerTree_AfterCheck(object sender, TreeViewEventArgs e) { if (e.Node.Tag != null) { if (e.Node.Tag.ToString().Contains("|")) { string nodeTag = e.Node.Tag.ToString().Split('|')[1]; GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(nodeTag); if (layer != null) { layer.Visible = e.Node.Checked; globeControl1.Globe.Refresh(); } } if (e.Node.Tag is GSOLayer) { GSOLayer layer = e.Node.Tag as GSOLayer; layer.Visible = e.Node.Checked; globeControl1.Globe.Refresh(); } if (e.Node.Tag is GSOFeature) { if (e.Node.Nodes.Count == 0) { GSOFeature feat = e.Node.Tag as GSOFeature; feat.Visible = e.Node.Checked; globeControl1.Globe.Refresh(); } } } CheckControl(e); } /// <summary> /// 树节点选中方法 /// </summary> /// <param name="e"></param> private void CheckControl(TreeViewEventArgs e) { if (e.Action != TreeViewAction.Unknown) { if (e.Node != null && !Convert.IsDBNull(e.Node)) { CheckParentNode(e.Node); if (e.Node.Nodes.Count > 0) { CheckAllChildNodes(e.Node, e.Node.Checked); } } } } /// <summary> /// 改变所有子节点的状态 /// </summary> /// <param name="pn"></param> /// <param name="IsChecked"></param> private void CheckAllChildNodes(TreeNode pn, bool IsChecked) { foreach (TreeNode tn in pn.Nodes) { tn.Checked = IsChecked; if (tn.Nodes.Count > 0) { CheckAllChildNodes(tn, IsChecked); } } } //改变父节点的选中状态,此处为所有子节点不选中时才取消父节点选中,可以根据需要修改 private void CheckParentNode(TreeNode curNode) { bool bChecked = false; if (curNode.Parent != null) { foreach (TreeNode node in curNode.Parent.Nodes) { if (node.Checked) { bChecked = true; break; } } if (bChecked) { curNode.Parent.Checked = true; CheckParentNode(curNode.Parent); } else { curNode.Parent.Checked = false; CheckParentNode(curNode.Parent); } } } private void layerTree_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e) { if (e.Button == MouseButtons.Right) { layerTree.SelectedNode = e.Node; if (e.Node.Tag != null) { if (e.Button == MouseButtons.Right && e.Node.Tag.ToString().Contains("|")) { if (e.Node.Tag.ToString().Split('|')[0] == "locaserver") { foreach (ToolStripItem item in layerNodeContexMenu.Items) { item.Visible = false; } return; } if (e.Node.Tag.ToString().Split('|')[0] == "new") { LayerEditableMenuItem.Enabled = true; foreach (ToolStripItem item in layerNodeContexMenu.Items) { item.Visible = false; } LayerSelectableMenuItem.Visible = true; LayerEditableMenuItem.Visible = true; RemoveLayer.Visible = true; RefreshLayerFeatureListMenuItem.Visible = true; SaveLayerMenuItem.Visible = true; } LayerEditableMenuItem.Visible = true; LayerEditableMenuItem.Visible = true; SaveLayerMenuItem.Visible = true; layerNodeContexMenu.Show(layerTree, e.X, e.Y); layerNodeContexMenu.Tag = e.Node; GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(e.Node.Tag.ToString().Split('|')[1]); LayerSelectableMenuItem.Checked = layer.Selectable; LayerEditableMenuItem.Checked = layer.Editable; } else { if (e.Node.Tag is GSOLayer && e.Node.Parent != null && e.Node.Parent.Text.Trim() == "临时图层") { contextMenuStripDeleteLayerNode.Show(layerTree, e.X, e.Y); contextMenuStripDeleteLayerNode.Tag = e.Node; } if (e.Node.Tag is GSOFeature && e.Node.Parent != null && e.Node.Parent.Text.Trim() == "我的地标") { contextMenuStripDeleteLayerNode.Show(layerTree, e.X, e.Y); contextMenuStripDeleteLayerNode.Tag = e.Node; } } } } } /// <summary> /// 删除临时添加的本地数据图层 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void 删除ToolStripMenuItem2_Click(object sender, EventArgs e) { TreeNode node = layerTree.SelectedNode; if (node != null && node.Parent != null && node.Parent.Text.Trim() == "临时图层") { if (node.Tag is GSOLayer) { GSOLayer layer = node.Tag as GSOLayer; globeControl1.Globe.Layers.Remove(layer); globeControl1.Globe.Refresh(); node.Remove(); } } if (node != null && node.Parent != null && node.Parent.Text.Trim() == "我的地标") { if (node.Tag is GSOFeature) { GSOFeature f = node.Tag as GSOFeature; f.Delete(); globeControl1.Globe.Refresh(); node.Remove(); } } } private void 可编辑ToolStripMenuItem_Click(object sender, EventArgs e) { TreeNode node = layerTree.SelectedNode; if (node != null && node.Parent != null && node.Parent.Text.Trim() == "临时图层") { if (node.Tag is GSOLayer) { GSOLayer layer = node.Tag as GSOLayer; 可编辑ToolStripMenuItem.Checked = !可编辑ToolStripMenuItem.Checked; layer.Editable = 可编辑ToolStripMenuItem.Checked; } } } private void 保存ToolStripMenuItem_Click(object sender, EventArgs e) { //TreeNode node = layerNodeContexMenu.Tag as TreeNode; TreeNode node = contextMenuStripDeleteLayerNode.Tag as TreeNode; Int32 nIndex = node.Index; string layerCaption = node.Text.ToString();//.Split('|')[1]; GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerCaption); layer.Dataset.Save(); } private void layerTree_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e) { if (e.Node.Tag != null) { if (e.Node.Tag.ToString().Contains("|")) { string nodeTag = e.Node.Tag.ToString().Split('|')[1]; GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(nodeTag); if (layer != null) { double x = layer.LatLonBounds.Center.X; double y = layer.LatLonBounds.Center.Y; globeControl1.Globe.FlyToPosition(new GSOPoint3d(x, y, 0), EnumAltitudeMode.Absolute); } } if (e.Node.Tag is GSOLayer) { GSOLayer layer = e.Node.Tag as GSOLayer; if (layer.GetAllFeatures().Length > 0) { GSOFeature feature = layer.GetAt(0); if (feature != null && feature.Geometry != null) { globeControl1.Globe.FlyToPosition(feature.Geometry.GeoCenterPoint, EnumAltitudeMode.Absolute);//, 0, 0, 1000); } else { globeControl1.Globe.FlyToFeature(feature); } } } if (e.Node.Tag is GSOFeature) { GSOFeature feature = e.Node.Tag as GSOFeature; if (feature.Geometry != null) { globeControl1.Globe.FlyToPosition(feature.Geometry.GeoCenterPoint, EnumAltitudeMode.Absolute, 0, 0, 10); } else { globeControl1.Globe.FlyToFeature(feature); } } } } /// <summary> /// 在三维场景移动时,隐藏气泡 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void globeControl1_CameraBeginMoveEvent(object sender, CameraBeginMoveEventArgs e) { if (featureTooltip.IsVisible()) { featureTooltip.HideBalloon(); } if (balloonEx.IsVisible()) { balloonEx.HideBalloon(); } } void globeControl1_MouseWheel(object sender, MouseEventArgs e) { if (globeControl1.Globe.CameraState.Distance > 20000000) { GSOCameraState cameraState = globeControl1.Globe.CameraState; cameraState.Distance = 20000000; globeControl1.Globe.CameraState = cameraState; globeControl1.Globe.Refresh(); } } void globeControl2_MouseWheel(object sender, MouseEventArgs e) { if (globeControl2.Globe.CameraState.Distance > 20000000) { GSOCameraState cameraState = globeControl2.Globe.CameraState; cameraState.Distance = 20000000; globeControl2.Globe.CameraState = cameraState; globeControl2.Globe.Refresh(); } } /// <summary> /// 横断面分析、基线剖面分析、道路断面分析等 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void globeControl1_TrackPolylineEndEvent(object sender, TrackPolylineEndEventArgs e) { //GSOFeature f2 = new GSOFeature(); //f2.Geometry = e.Polyline; //f2.Geometry.AltitudeMode = EnumAltitudeMode.Absolute; //globeControl1.Globe.MemoryLayer.AddFeature(f2); //f2.Geometry.MoveZ(2); ArrayList arraylistPoint = new ArrayList(); ArrayList arraylistLine = new ArrayList(); // globeControl1.Globe.ClearLastTrackPolyline(); if (e.Polyline != null) { //横断面分析 if (btnItem_HDMAnalysis.Checked || buttonItem9.Checked) { if(m_PipelineLayerNames != null) { GSOGeoPolygon3D polygon = e.Polyline.CreateBuffer(0.1, true, 5, true, false); for (int i = 0; i < m_PipelineLayerNames.Count; i++) { if (m_PipelineLayerNames[i] != null) { GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(m_PipelineLayerNames[i]); if (layer == null) { continue; } if (layer.Visible == false) { continue; } GSOFeatureLayer featurelayer = layer as GSOFeatureLayer; if (featurelayer != null) { GSOFeatures feats = featurelayer.FindFeaturesInPolygon(polygon, false); //featurelayer.GetAllFeatures(); if (feats!=null) { for (int j = 0; j < feats.Length; j++) { GSOFeature feateline = feats[j]; GSOGeoPolyline3D geoline = feateline.Geometry as GSOGeoPolyline3D; if (geoline != null) { if (geoline.Style != null) { if (geoline.Style.GetType() == typeof(GSOPipeLineStyle3D)) { GSOPoint3d pntIntersect1 = new GSOPoint3d(); GSOPoint3d pntIntersect2 = new GSOPoint3d(); double honLen; double verLen; double dDist = globeControl1.Globe.Analysis3D.ComputeTwoGeoPolylineDistance(e.Polyline, geoline, out pntIntersect1, out pntIntersect2, out honLen, out verLen, false, false, 0); globeControl1.Globe.Action = EnumAction3D.ActionNull; if (dDist > -1) { arraylistPoint.Add(pntIntersect2); arraylistLine.Add(feateline); } } } } } } else { MessageBox.Show("请重新绘制断面"); return; } } } } } if (btnItem_HDMAnalysis.Checked) { FrmHDMAnalysis3 frm = FrmHDMAnalysis3.GetForm(arraylistPoint, arraylistLine, e.Polyline, globeControl1); if (!frm.isShowFirst) { frm.Show(this); } frm.LoadChartEvent(); } else { FrmRoadHDM frm = FrmRoadHDM.GetForm(arraylistPoint, arraylistLine, e.Polyline, globeControl1); if (!frm.isShowFirst) { frm.Show(this); } frm.LoadChartEvent(); } globeControl1.Globe.ClearLastTrackPolyline(); } else if (BaselineProfileAnalysisMenuItem.Checked) { FrmBaseLineProfillAnalysis dlg = new FrmBaseLineProfillAnalysis(globeControl1.Globe,e.Polyline); dlg.Show(this); globeControl1.Globe.ClearLastTrackPolyline(); } else if (buttonItem28.Checked) { GSOGeoPolygon3D resPolygon = e.Polyline.CreateBuffer(m_dDigPitWidthAlongLine, false, 0, false, false); GSOGeoPit geoPit = new GSOGeoPit(); geoPit.PitPolygon = resPolygon; if (m_bDigPitByDepth) { geoPit.PitDepth = m_dDigPitValue; geoPit.PitDepthUsing = true; } else { geoPit.PitBottomAlt = m_dDigPitValue; geoPit.PitDepthUsing = false; } globeControl1.Globe.AddPit("", geoPit); GSOLayer layerGround = globeControl1.Globe.Layers.GetLayerByCaption(roadLayerName);// ("180fd"); if (layerGround != null) { layerGround.Visible = false; } // 清除当前TrackPolygonAnalysis的痕迹 globeControl1.Globe.ClearLastTrackPolyline(); } else if (distanceMarker) { setMarkerLayerUnVisible("距离标注"); GSOLayer l = globeControl1.Globe.Layers.GetLayerByCaption("距离标注"); if (l != null) { l.Visible = true; if (getLabelName(l) != -1) { GSOGeoPolyline3D line = e.Polyline; if (line.PartCount > 0) { double length = line.GetSpaceLength(true, 6378137);//线的长度 if (length == 0) { return; } else { GSOGeoPoint3D pt = new GSOGeoPoint3D(); GSOGeoPolyline3D lineLine = line.GetSegment(0, length / 2); GSOPoint3d point3d = lineLine[lineLine.PartCount - 1][lineLine[lineLine.PartCount - 1].Count - 1]; pt.X = point3d.X; pt.Y = point3d.Y; pt.Z = point3d.Z; string Twodecimalplaces = string.Format("{0:F}", length); string radiusLabelName = "" + Twodecimalplaces + "米"; //string radiusLabelName = "" + length + "米";//标注名称 GSOPoint2d point2d = new GSOPoint2d(0, 30);//标注位置 int labelText = getLabelName(l); GSOFeature newFeatureLine = new GSOFeature(); newFeatureLine.Geometry = line; newFeatureLine.Name = (labelText + 1).ToString() + "-line"; l.AddFeature(newFeatureLine); globeControl1.Globe.ClearLastTrackPolyline(); GSOFeature newFeature = new GSOFeature(); newFeature = createLabel(l, newFeature, pt, radiusLabelName, (labelText + 1).ToString(), point2d); l.AddFeature(newFeature); globeControl1.Refresh(); } } } } } } globeControl1.Globe.Action = EnumAction3D.ActionNull; ActionToolMenuChecked(); } /// <summary> /// 根据范围统计阀门、管线、工井等, 开挖分析, 挖方量分析 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void globeControl1_TrackPolygonEndEvent(object sender, TrackPolygonEndEventArgs e) { if (globeControl1.Globe.Action == EnumAction3D.TrackPolygon && e.Polygon != null) { GSOGeoPolygon3D polygon = e.Polygon; //polygon.AltitudeMode = EnumAltitudeMode.RelativeToGround; switch (trackflag) { case "valvequery": workWellLen.Clear(); List<GSOFeatures> list = new List<GSOFeatures>(); //找到所有阀门 if (Utility.LayerNamesList != null) { ArrayList listpt = Utility.LayerNamesList; for (int i = 0; i < listpt.Count; i++) { string pipelineType = (string)Utility.LayerNamesList[i]; if ((pipelineType == "给水") || (pipelineType == "天然气") || (pipelineType == "燃气")) { GSOFeatures fs = Intersect_PointLayerByType(polygon, pipelineType, "阀门"); list.Add(fs); } } } FrmValveStatistics frm = new FrmValveStatistics(workWellLen, list, dataGridViewX1, toolStripNumbers, globeControl1, panelOfTable); frm.Show(this); //panelEx6.Visible = true; toolStripFeatureLength.Text = ""; globeControl1.Globe.Action = EnumAction3D.ActionNull; break; case "PipelineDistanceStatistics": pipeLineDis.Clear(); List<GSOFeatures> list1 = new List<GSOFeatures>(); for (int i = 0; i < m_PipelineLayerNames.Count; i++) { GSOFeatures fs = Intersects_Pipeline(polygon, m_PipelineLayerNames[i]); list1.Add(fs); } FrmAllPipelineStatis frm1 = new FrmAllPipelineStatis(0, pipeLineDis, list1, dataGridViewX1, toolStripNumbers, toolStripFeatureLength, globeControl1, panelOfTable); frm1.Show(this); globeControl1.Globe.Action = EnumAction3D.ActionNull; break; case "PipelineSpatialQuery": pipeLineDis.Clear(); List<GSOFeatures> list2 = new List<GSOFeatures>(); for (int i = 0; i < m_PipelineLayerNames.Count; i++) { GSOFeatures fs = Intersects_Pipeline(polygon, m_PipelineLayerNames[i]); if (fs != null) { for (int j = 0; j < fs.Length; j++) { GSOFeature f = fs[j]; if (f != null) { f.HighLight = true; } } list2.Add(fs); } } FrmAllPipelineStatis.ShowForm(1, pipeLineDis, list2, dataGridViewX1, toolStripNumbers, toolStripFeatureLength, globeControl1, panelOfTable); globeControl1.Globe.ClearAnalysis(); globeControl1.Globe.Action = EnumAction3D.ActionNull; break; case "workwellquery": workWellLen.Clear(); List<GSOFeatures> listWell = new List<GSOFeatures>(); //找到所有井 if (Utility.LayerNamesList != null) { ArrayList listpt = Utility.LayerNamesList; for (int i = 0; i < listpt.Count; i++) { string pipelineType = (string)Utility.LayerNamesList[i]; string sql = "select 附属物名称 from " + pipelineType + "管线附属物 group by 附属物名称"; DataSet dataset = OledbHelper.getDataSet(sql, pipelineType + "管线附属物"); if (dataset != null) { for (int j = 0; j < dataset.Tables[0].Rows.Count; j++) { string accname = dataset.Tables[0].Rows[j][0].ToString(); if ((accname.IndexOf("井") > 0) || (accname.IndexOf("孔") > 0) || (accname.IndexOf("篦") > 0)) { GSOFeatures fs = Intersect_PointLayerByType(polygon, pipelineType, dataset.Tables[0].Rows[j][0].ToString()); listWell.Add(fs); } } } } } FrmAllWorkWellStatis frmWell = new FrmAllWorkWellStatis(workWellLen, listWell, dataGridViewX1, toolStripNumbers, globeControl1, panelOfTable); frmWell.Show(this); globeControl1.Globe.Action = EnumAction3D.ActionNull; break; case "pit": double depth; FrmTackPolygonDlg dlg = new FrmTackPolygonDlg(); if (dlg.ShowDialog() == DialogResult.OK) { depth = dlg.depth; GSOGeoPit geoPit = new GSOGeoPit(); geoPit.PitPolygon = polygon; geoPit.PitDepth = depth; geoPit.PitDepthUsing = true; globeControl1.Globe.AddPit("", geoPit); GSOLayer layerGround = globeControl1.Globe.Layers.GetLayerByCaption(roadLayerName);//("180fd"); if (layerGround != null) { layerGround.Visible = false; } } // 清除当前TrackPolygonAnalysis的痕迹 globeControl1.Globe.ClearLastTrackPolygon(); globeControl1.Globe.Action = EnumAction3D.ActionNull; break; case "digFillAnalysis": DigFillAnalysisDlg dlg1 = new DigFillAnalysisDlg(); dlg1.m_globe = globeControl1.Globe; dlg1.m_polygon3D = polygon; globeControl1.Globe.Action = EnumAction3D.ActionNull; dlg1.Show(this); break; case "FloodAnalysis": FrmFloodAnalysis frmFloodAnalysis = new FrmFloodAnalysis(globeControl1.Globe, polygon); frmFloodAnalysis.Show(this); globeControl1.Globe.Action = EnumAction3D.ActionNull; break; case "": break; default: break; } } } #region 验证端口 /* /// <summary> /// 验证端口 /// </summary> /// <returns></returns> private bool ValiPort() { Ping p = new Ping();//创建Ping对象p PingReply pr = p.Send(Utility.localicenseserverip);//向指定IP或者主机名的计算机发送ICMP协议的ping数据包 if (pr.Status == IPStatus.Success)//如果ping成功 { try { TcpClient tcpc = new TcpClient(Utility.localicenseserverip, Utility.localicenseserverport);//对IP地址为"192.168.0.105"的计算机的1500端口提出连接申请 tcpc.Close(); return true; } catch (Exception ex) { LogError.PublishError(ex); MessageBox.Show("端口连接错误!" + ex.Message); return false; } } else { int times = 0;//重新连接次数; int count = 2;//设置尝试次数 while (times < count) { //Thread.Sleep(1000);//等待时间(方便测试的话,你可以改为1000) pr = p.Send(Utility.localicenseserverip); if (pr.Status == IPStatus.Success) { try { TcpClient tcpc = new TcpClient(Utility.localicenseserverip, Utility.localicenseserverport);//对IP地址为"192.168.0.105"的计算机的1500端口提出连接申请 tcpc.Close(); return true; } catch (Exception ex) { LogError.PublishError(ex); MessageBox.Show("端口连接错误!" + ex.Message); return false; } } else { times++; if (times < count) { continue; } else { MessageBox.Show("重新尝试连接失败"); return false; } } } return false; } } */ #endregion /// <summary> /// 鼠标悬浮提示 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void globeControl1_FeatureMouseHoverEvent(object sender, FeatureMouseHoverEventArgs e) { try { if (e.Feature != null) { if (isFeatureContainsBianhao( e.Feature)) { featureTooltip.ShowBalloon((int)e.MousePos.X, (int)e.MousePos.Y, e.Feature.GetValue(featureIDFieldName).ToString()); } else if (e.Feature.Name != "") { featureTooltip.ShowBalloon((int)e.MousePos.X, (int)e.MousePos.Y, e.Feature.Name); } } } catch (Exception ex) { LogError.PublishError(ex); } } /// <summary> /// 添加管线绘制完成事件, 红线工具绘制完成 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void globeControl1_MouseDoubleClick(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { if (m_AddPipeLine == true && globeControl1.Globe.Action==EnumAction3D.DrawPolyline)//添加管线 { GSOLayer layerDest = globeControl1.Globe.DestLayerFeatureAdd; if (layerDest != null) { GSOFeatures features = layerDest.GetAllFeatures(); GSOFeature f = features[features.Length - 1]; GSOGeoPolyline3D line = f.Geometry as GSOGeoPolyline3D; globeControl1.Globe.Action = EnumAction3D.ActionNull; if (f != null && f.Geometry.Type == EnumGeometryType.GeoPolyline3D) { FrmLineCoordinate lineCoordiante = new FrmLineCoordinate(f, globeControl1, layerDest.Caption); lineCoordiante.Show(this); } globeControl1.Refresh(); } } if (m_isDrawTunnel == true && globeControl1.Globe.Action == EnumAction3D.DrawPolyline)//创建隧道 { GSOLayer tunnel = globeControl1.Globe.Layers.GetLayerByCaption("隧道"); if (tunnel != null && tunnel.GetAllFeatures().Length > 0) { GSOFeature feature = tunnel.GetAt(tunnel.GetAllFeatures().Length - 1); FrmCreateTunnel frm = new FrmCreateTunnel(globeControl1, feature); if (frm.ShowDialog() == DialogResult.OK) { //tunnel.Save(); } } globeControl1.Refresh(); } if (m_isDrawCitySevenLine == true && globeControl1.Globe.Action == EnumAction3D.DrawPolyline)//绘制城市七线 { string lineType = this.citySevenLineType; string lineName = this.cityServerLineName; GSOFeature feature = null; switch (lineType) { case "城市红线": GSOLayer layerRed = globeControl1.Globe.Layers.GetLayerByCaption(lineType); if (layerRed != null && layerRed.GetAllFeatures().Length > 0) { feature = layerRed.GetAt(layerRed.GetAllFeatures().Length - 1); if (feature != null) { feature.Name = lineName; GSOSimpleLineStyle3D style = new GSOSimpleLineStyle3D(); style.LineColor = Color.Red; //改变绘制的线的颜色 style.LineWidth = 1; //改变绘制的线的宽度 feature.Geometry.Style = style; //layerRed.Save(); } } break; case "城市橙线": GSOLayer layerOrange = globeControl1.Globe.Layers.GetLayerByCaption(lineType); if (layerOrange != null && layerOrange.GetAllFeatures().Length > 0) { feature = layerOrange.GetAt(layerOrange.GetAllFeatures().Length - 1); if (feature != null) { feature.Name = lineName; GSOSimpleLineStyle3D style = new GSOSimpleLineStyle3D(); style.LineColor = Color.Orange; feature.Geometry.Style = style; //layerOrange.Save(); } } break; case "城市黄线": GSOLayer layerYellow = globeControl1.Globe.Layers.GetLayerByCaption(lineType); if (layerYellow != null && layerYellow.GetAllFeatures().Length > 0) { feature = layerYellow.GetAt(layerYellow.GetAllFeatures().Length - 1); if (feature != null) { feature.Name = lineName; GSOSimpleLineStyle3D style = new GSOSimpleLineStyle3D(); style.LineColor = Color.Yellow; feature.Geometry.Style = style; //layerYellow.Save(); } } break; case "城市绿线": GSOLayer layerGreen = globeControl1.Globe.Layers.GetLayerByCaption(lineType); if (layerGreen != null && layerGreen.GetAllFeatures().Length > 0) { feature = layerGreen.GetAt(layerGreen.GetAllFeatures().Length - 1); if (feature != null) { feature.Name = lineName; GSOSimpleLineStyle3D style = new GSOSimpleLineStyle3D(); style.LineColor = Color.Green; feature.Geometry.Style = style; //layerGreen.Save(); } } break; case "城市蓝线": GSOLayer layerBlue = globeControl1.Globe.Layers.GetLayerByCaption(lineType); if (layerBlue != null && layerBlue.GetAllFeatures().Length > 0) { feature = layerBlue.GetAt(layerBlue.GetAllFeatures().Length - 1); if (feature != null) { feature.Name = lineName; GSOSimpleLineStyle3D style = new GSOSimpleLineStyle3D(); style.LineColor = Color.Blue; feature.Geometry.Style = style; //layerBlue.Save(); } } break; case "城市紫线": GSOLayer layerPurple = globeControl1.Globe.Layers.GetLayerByCaption(lineType); if (layerPurple != null && layerPurple.GetAllFeatures().Length > 0) { feature = layerPurple.GetAt(layerPurple.GetAllFeatures().Length - 1); if (feature != null) { feature.Name = lineName; GSOSimpleLineStyle3D style = new GSOSimpleLineStyle3D(); style.LineColor = Color.Purple; feature.Geometry.Style = style; //layerPurple.Save(); } } break; case "城市黑线": GSOLayer layerBlack = globeControl1.Globe.Layers.GetLayerByCaption(lineType); if (layerBlack != null && layerBlack.GetAllFeatures().Length > 0) { feature = layerBlack.GetAt(layerBlack.GetAllFeatures().Length - 1); if (feature != null) { feature.Name = lineName; GSOSimpleLineStyle3D style = new GSOSimpleLineStyle3D(); style.LineColor = Color.Black; feature.Geometry.Style = style; //layerBlack.Save(); } } break; } globeControl1.Globe.DestLayerFeatureAdd = null; } m_AddPipeLine = false; m_isDrawTunnel = false; m_isDrawCitySevenLine = false; if (m_isDrawRedPology == true && globeControl1.Globe.Action==EnumAction3D.DrawPolygon)//红线工具 { GSOLayer layerDest = globeControl1.Globe.DestLayerFeatureAdd; if (layerDest != null) { GSOFeatures features = layerDest.GetAllFeatures(); //GSOFeatures features = globeControl1.Globe.MemoryLayer.GetAllFeatures(); GSOFeature f = features[features.Length - 1]; if (f != null) { GSOGeoPolygon3D polygon = f.Geometry as GSOGeoPolygon3D; if (polygon != null) { GSOSimplePolygonStyle3D geoStyle3d = new GSOSimplePolygonStyle3D(); f.Name = (getLabelName(layerDest)+1).ToString(); geoStyle3d.FillColor = Color.Red; polygon.Style = geoStyle3d; GSOLabel label = new GSOLabel(); label.Text = "此区域正在施工中!"; label.Style = new GSOLabelStyle(); label.Style.HasTracktionLine = false; polygon.Label = label; globeControl1.Refresh(); } } } } m_isDrawRedPology = false; globeControl1.Globe.Action = EnumAction3D.ActionNull; } } /// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void globeControl1_MouseClick(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { if (globeControl1.Globe.Action == EnumAction3D.VisibilityAnalysis) { btnSpaceVisibilityAnalysis.Checked = false; return; } if (globeControl1.Globe.Action == EnumAction3D.SelectObject && trackflag == "vertical") // 垂直净距分析 { if (globeControl1.Globe.SelObjectCount > 0) { dataGridViewX2.Rows.Clear(); } for (int i = 0; i < globeControl1.Globe.SelObjectCount; i++) { GSOLayer resLayer = null; GSOFeature feat = null; globeControl1.Globe.GetSelectObject(i, out feat, out resLayer); if (feat != null && feat.Geometry.Type == EnumGeometryType.GeoPolyline3D) { int idx = dataGridViewX2.Rows.Add(); dataGridViewX2.Rows[idx].Tag = feat; dataGridViewX2.Rows[idx].Cells[0].Value = resLayer.Caption; string featureName; if (isFeatureContainsBianhao( feat)) { featureName = feat.GetValue(featureIDFieldName).ToString(); } else { featureName = feat.Name; } dataGridViewX2.Rows[idx].Cells[1].Value = featureName; } } return; } if (globeControl1.Globe.Action == EnumAction3D.SelectObject && trackflag == "spacing") // 间距分析 { if (globeControl1.Globe.SelObjectCount > 0) { dataGridViewLineList.Rows.Clear(); } for (int i = 0; i < globeControl1.Globe.SelObjectCount; i++) { GSOLayer resLayer = null; GSOFeature feat = null; globeControl1.Globe.GetSelectObject(i, out feat, out resLayer); if (feat != null && feat.Geometry.Type == EnumGeometryType.GeoPolyline3D) { int idx = dataGridViewLineList.Rows.Add(); dataGridViewLineList.Rows[idx].Tag = feat; dataGridViewLineList.Rows[idx].Cells[0].Value = resLayer.Caption; string featureName; if (isFeatureContainsBianhao( feat)) { featureName = feat.GetValue(featureIDFieldName).ToString(); } else { featureName = feat.Name; } dataGridViewLineList.Rows[idx].Cells[1].Value = featureName; } } return; } if (globeControl1.Globe.Action == EnumAction3D.SelectObject && trackflag == "horizontal") // 水平净距分析 { if (globeControl1.Globe.SelObjectCount > 0) { dataGridViewX8.Rows.Clear(); } for (int i = 0; i < globeControl1.Globe.SelObjectCount; i++) { GSOLayer resLayer = null; GSOFeature feat = null; globeControl1.Globe.GetSelectObject(i, out feat, out resLayer); if (feat != null && feat.Geometry.Type == EnumGeometryType.GeoPolyline3D) { int idx = dataGridViewX8.Rows.Add(); dataGridViewX8.Rows[idx].Tag = feat; dataGridViewX8.Rows[idx].Cells[0].Value = resLayer.Caption; string featureName; if (isFeatureContainsBianhao( feat)) { featureName = feat.GetValue(featureIDFieldName).ToString(); } else { featureName = feat.Name; } dataGridViewX8.Rows[idx].Cells[1].Value = featureName; } } return; } if (globeControl1.Globe.Action == EnumAction3D.SelectObject && trackflag == "collision") // 管线碰撞分析 { if (globeControl1.Globe.SelObjectCount > 0) { dataGridViewX4.Rows.Clear(); } for (int i = 0; i < globeControl1.Globe.SelObjectCount; i++) { GSOLayer resLayer = null; GSOFeature feat = null; globeControl1.Globe.GetSelectObject(i, out feat, out resLayer); if (feat != null && feat.Geometry.Type == EnumGeometryType.GeoPolyline3D) { int idx = dataGridViewX4.Rows.Add(); dataGridViewX4.Rows[idx].Tag = feat; dataGridViewX4.Rows[idx].Cells[0].Value = resLayer.Caption; string featureName; if (isFeatureContainsBianhao( feat)) { featureName = feat.GetValue(featureIDFieldName).ToString(); } else { featureName = feat.Name; } dataGridViewX4.Rows[idx].Cells[1].Value = featureName; } } return; } if (globeControl1.Globe.Action == EnumAction3D.SelectObject && trackflag == "ftAnalysis") // 覆土分析 { if (globeControl1.Globe.SelObjectCount > 0) { dataGridViewX6.Rows.Clear(); } for (int i = 0; i < globeControl1.Globe.SelObjectCount; i++) { GSOLayer resLayer = null; GSOFeature feat = null; globeControl1.Globe.GetSelectObject(i, out feat, out resLayer); if (feat != null && feat.Geometry.Type == EnumGeometryType.GeoPolyline3D) { int idx = dataGridViewX6.Rows.Add(); dataGridViewX6.Rows[idx].Tag = feat; dataGridViewX6.Rows[idx].Cells[0].Value = resLayer.Caption; string featureName; if (isFeatureContainsBianhao( feat)) { featureName = feat.GetValue(featureIDFieldName).ToString(); } else { featureName = feat.Name; } dataGridViewX6.Rows[idx].Cells[1].Value = featureName; } } return; } GSOPoint3d point; GSOLayer templayer; GSOFeature feature1 = globeControl1.Globe.HitTest(e.X, e.Y, out templayer, out point, false, true, 0); if (point.X == 0 && point.Y == 0 && point.Z == 0) { point = globeControl1.Globe.ScreenToScene(e.X, e.Y); } GSOGeoPoint3D pt = new GSOGeoPoint3D(); pt.X = point.X; pt.Y = point.Y; pt.Z = point.Z; if (btnSpaceMeasureHeight.Checked && globeControl1.Globe.Action == EnumAction3D.SelectObject) // 高度量算菜单 { double z = globeControl1.Globe.GetZ(point.X, point.Y); double modelZ = 0; if (feature1 != null) { modelZ = feature1.Geometry.GeoBottomCenterPoint.Z; } GSOGeoPolyline3D line = new GSOGeoPolyline3D(); GSOPoint3ds pts = new GSOPoint3ds(); GSOPoint3d pt1 = new GSOPoint3d(); pt1.X = point.X; pt1.Y = point.Y; pt1.Z = point.Z - z; pts.Add(pt1); pts.Add(point); line.AddPart(pts); GSOFeature feat = new GSOFeature(); line.AltitudeMode = EnumAltitudeMode.Absolute; feat.Geometry = line; GSOLabel label = new GSOLabel(); GSOLabelStyle style = new GSOLabelStyle(); style.OutlineColor = Color.Transparent; style.HasTracktionLine = false; style.BackBeginColor = Color.Transparent; style.BackEndColor = Color.Transparent; style.BackMidColor = Color.Transparent; label.Style = style; label.Text = "高度:" + (point.Z -z).ToString("0.00") + "米"; feat.Label = label; layerTemp.AddFeature(feat); } } else if(e.Button == MouseButtons.Right) // 右键取消 高度量算 功能 { if (btnSpaceMeasureHeight.Checked) { btnSpaceMeasureHeight.Checked = false; } } globeControl1.Refresh(); } /// <summary> /// 判断网络图片是否存在 /// </summary> /// <param name="fileUrl"></param> /// <returns></returns> public static bool RemoteFileExists(string fileUrl) { bool result = false; System.Net.WebResponse response = null; try { System.Net.WebRequest req = System.Net.WebRequest.Create(fileUrl); response = req.GetResponse(); result = response == null ? false : true; } catch (Exception ex) { result = false; } finally { if (response != null) { response.Close(); } } return result; } string featureIDFieldName = "编号"; private bool isFeatureContainsBianhao(GSOFeature feature) { bool isContains = true; if (feature.GetFieldDefn("编号") == null && feature.GetFieldDefn("标识器编号") == null) { isContains = false; } else if (feature.GetFieldDefn("标识器编号") != null) { featureIDFieldName = "标识器编号"; } else if (feature.GetFieldDefn("编号") != null) { featureIDFieldName = "编号"; } return isContains; } /// <summary> /// 鼠标点击, 弹出气泡功能 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void globeControl1_FeatureMouseClickEvent(object sender, FeatureMouseClickEventArgs e) { GSOFeature feature = e.Feature; string str1 = ""; if (feature != null) { if (feature.GetFieldDefn("图片编码") != null) // { str1 = GetBubbleInfo(feature); if (RemoteFileExists(Utility.PicRootURL + feature.GetValue("图片编码").ToString())) { str1 += "<img width='440' height='350' src='" + Utility.PicRootURL + feature.GetValue("图片编码").ToString() + "' />"; } else if (RemoteFileExists(Utility.PicDefaultURL)) { str1 += "<img width='440' height='350' src='" + Utility.PicDefaultURL + "' />"; } } else if (isFeatureContainsBianhao(feature)) //管线模型图层 { str1 = GetBubbleInfo(feature); } if (str1 != "") { featureTooltip.HideBalloon(); balloonEx.HideBalloon(); balloonEx.SetSize(EnumSizeIndexEx.CONTENT_CX, 480); balloonEx.SetSize(EnumSizeIndexEx.CONTENT_CY, 420); balloonEx.ShowBalloon((int)e.MousePos.X, (int)e.MousePos.Y, str1); return; } } } /// <summary> /// 拼接气泡表格字符串 /// </summary> /// <param name="feature"></param> /// <returns></returns> private string GetBubbleInfo(GSOFeature feature) { if (feature == null) { return ""; } string str = ""; str = "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" style=\"width:100%;background:#FFFFFF none repeat scroll 0 0;border-collapse:collapse;font-family:\"Lucida Sans Unicode\",\"Lucida Grande\",Sans-Serif;font-size:10px;text-align:center;\" >"; string title = ""; if (feature.GetFieldDefn("编码") != null) { string pipelinecode = feature.GetFieldAsString("编码"); if (pipelinecode != null) { if (Utility.listPipelineType != null) { for (int i = 0; i < Utility.listPipelineType.Count; i++) { PipelineType pipelineType = Utility.listPipelineType[i]; if (pipelineType != null && pipelineType.code.Trim() == pipelinecode.Trim()) { title = pipelineType.type + " " + pipelineType.name; if (pipelineType.type == pipelineType.name) { title = pipelineType.type; } break; } } } } } str += "<tr><th colspan=4 style=\"font-size:medium; text-align:center;border-bottom:1px solid #6678B1;color:#003399;font-weight:normal;padding:10px 8px;\">" + title + " " + feature.GetFieldAsString(featureIDFieldName) + "</th></tr>"; int rowCount = feature.GetFieldCount(); string layerName = feature.Dataset.Name; string queryFields = ""; if (Utility.Query_Fields.ContainsKey(layerName) == true) { queryFields = Utility.Query_Fields[layerName].ToString().Trim() ; } else { layerName = feature.Dataset.Caption; queryFields = getpipeLineFields.getFields(layerName, globeControl1); } if (queryFields != null) { string[] param = { ","}; string[] fieldNames = queryFields.Split(param,StringSplitOptions.RemoveEmptyEntries); for (int j = 0; j < fieldNames.Length; j++)//for (int j = 0; j < rowCount; j++) { string fieldName = fieldNames[j].Trim(); GSOFieldDefn field1 = (GSOFieldDefn)feature.GetFieldDefn(fieldName); string name1 = ""; string value1 = ""; if (field1 != null) { if (field1.Name == "图片编码") { j++; } if (j < rowCount) { field1 = (GSOFieldDefn)feature.GetFieldDefn(j); name1 = field1.Name; if (field1.Type == EnumFieldType.Text) { value1 = feature.GetFieldAsString(j); } else if (field1.Type == EnumFieldType.Date) { DateTime dd = Convert.ToDateTime(feature.GetFieldAsDataTime(j)); if (dd.Year <= 1) { value1 = ""; } else { value1 = dd.ToShortDateString(); } } else { if (!feature.IsFieldValueNull(j)) { value1 = feature.GetValue(j).ToString(); } } } } string name2 = ""; string value2 = ""; if (j + 1 < rowCount) { GSOFieldDefn field2 = (GSOFieldDefn)feature.GetFieldDefn(j + 1); if (field2 != null) { if (field2.Name == "图片编码") { j++; } if (j + 1 < rowCount) { field2 = (GSOFieldDefn)feature.GetFieldDefn(j + 1); name2 = field2.Name; if (field2.Type == EnumFieldType.Text) { value2 = feature.GetFieldAsString(j + 1); } else if (field2.Type == EnumFieldType.Date) { DateTime dd = Convert.ToDateTime(feature.GetFieldAsDataTime(j + 1)); if (dd.Year <= 1) { value2 = ""; } else { value2 = dd.ToShortDateString(); } } else { if (!feature.IsFieldValueNull(j + 1)) { value2 = feature.GetValue(j + 1).ToString(); } } } } j++; } str += "<tr><td width=100 style=\"font-size:10pt;border:1px solid #CCCCCC;color:#666699;padding:2px 2px; background-color:#E7F3FB\"><center>" + name1 + "</center></td><td width=100 style=\"font-size:10pt;border:1px solid #CCCCCC;color:#666699;padding:2px 2px;\"><center>" + value1 + "</center></td><td width=100 style=\"font-size:10pt;border:1px solid #CCCCCC;color:#666699;padding:2px 2px;background-color:#E7F3FB\"><center>" + name2 + "</center></td><td width=100 style=\"font-size:10pt;border:1px solid #CCCCCC;color:#666699;padding:2px 2px;\"><center>" + value2 + "</center></td></tr>"; } } str += "</table>"; return str; } string filename = Utility.filename; List<string> g1layername = new List<string>(); /// <summary> /// 构建图层列表目录树 /// </summary> /// <param name="tv"></param> private void loadTreeView(TreeView tv) { try { XmlDocument doc = new XmlDocument(); doc.Load(filename); XmlNodeList Params1 = doc.SelectNodes("/Params/layers"); tv.ShowLines = false; tv.CheckBoxes = true; foreach (XmlNode paramsNode in Params1) //layers { foreach (XmlNode layerNode in paramsNode) //layer { TreeNode nodelayer = new TreeNode(); string layerName = layerNode.Attributes["label"].Value; nodelayer.Text = layerName; if (layerNode.HasChildNodes != false) { tv.Nodes.Add(nodelayer); foreach (XmlNode layerchildNode in layerNode) //layerchild { if (layerchildNode.Name == "layerchild") { TreeNode nodelayerchild = new TreeNode(); string layerType = layerchildNode.Attributes["type"].Value; string layerName1 = layerchildNode.Attributes["layer"].Value; string layerchildName = layerchildNode.Attributes["label"].Value; if (layerType == "locaserver") { if (layerchildNode.Attributes["isRoad"] != null) { roadLayerName = layerchildName; } dictionaryNetLayerNameAndCaption.Add(layerName1, layerchildName); nodelayerchild.Text = layerchildName; nodelayerchild.Tag = layerType + "|" + layerchildName; nodelayerchild.Checked = true; nodelayer.Nodes.Add(nodelayerchild); } else///标识器,交越点,给水,天然气,共通,有线电视,监控,交通,路灯 { if (layerchildNode.Attributes["isPipeLine"] != null) { m_PipelineLayerNames.Add(layerchildName); } if (layerchildNode.Attributes["isWorkWell"] != null) { workwellLayerNames.Add(layerchildName); } if (layerchildNode.Attributes["isValve"] != null) { valueLayerNames.Add(layerchildName); } //if (layerchildNode.Attributes["isInstrument"] != null) if (layerchildNode.Attributes["isAccess"] != null) { instrumenLayerNames.Add(layerchildName); } //if (layerchildNode.Attributes["isPipeFitting"] != null) if (layerchildNode.Attributes["isCharacter"] != null) { pipefittingLayerNames.Add(layerchildName); } bool boollayer = AddLayers(layerName1, layerchildName); nodelayerchild.Text = layerchildName; nodelayerchild.Tag = layerType + "|" + layerchildName; nodelayerchild.Checked = boollayer; if (layerchildName.Contains("特征管点")) { nodelayerchild.Checked = false; setLayerVisible(layerName1); } nodelayer.Nodes.Add(nodelayerchild); g1layername.Add(layerName1); } } else if (layerchildNode.Name == "layertype") { TreeNode nodelayerchild = new TreeNode(); string layerType = layerchildNode.Attributes["label"].Value; nodelayerchild.Text = layerType; nodelayerchild.Tag = layerType; nodelayerchild.Checked = true; nodelayer.Nodes.Add(nodelayerchild); if (layerchildNode.HasChildNodes == true) { foreach (XmlNode childNodeLayer in layerchildNode) { if (childNodeLayer.HasChildNodes == true) { TreeNode nodelayerchild2 = new TreeNode(); string layer = childNodeLayer.Attributes["label"].Value; nodelayerchild2.Text = layer; nodelayerchild2.Tag = layer; nodelayerchild2.Checked = true; nodelayerchild.Nodes.Add(nodelayerchild2); foreach (XmlNode n in childNodeLayer) { TreeNode nodelayerchild1 = new TreeNode(); string layerName1 = n.Attributes["layer"].Value; string layerchildName = n.Attributes["label"].Value; string layerType1 = n.Attributes["type"].Value; if (n.Attributes["isPipeLine"] != null) { m_PipelineLayerNames.Add(layerchildName); } if (n.Attributes["isWorkWell"] != null) { workwellLayerNames.Add(layerchildName); } if (n.Attributes["isValve"] != null) { valueLayerNames.Add(layerchildName); } if (n.Attributes["isAccess"] != null) //if (n.Attributes["isInstrument"] != null) { instrumenLayerNames.Add(layerchildName); } if (n.Attributes["isPipeFitting"] != null) { pipefittingLayerNames.Add(layerchildName); } bool boollayer = AddLayers(layerName1, layerchildName); nodelayerchild1.Text = layerchildName; nodelayerchild1.Tag = layerType1 + "|" + layerchildName; nodelayerchild1.Checked = boollayer; if (layerchildName.Contains("特征管点")) { nodelayerchild1.Checked = false; setLayerVisible(layerName1); } nodelayerchild2.Nodes.Add(nodelayerchild1); g1layername.Add(layerName1); } } else///污水管线,雨水,通讯类,电通,供电, { TreeNode nodelayerchild1 = new TreeNode(); string layerName1 = childNodeLayer.Attributes["layer"].Value; string layerchildName = childNodeLayer.Attributes["label"].Value; string layerType1 = childNodeLayer.Attributes["type"].Value; if (childNodeLayer.Attributes["isPipeLine"] != null) { m_PipelineLayerNames.Add(layerchildName); } if (childNodeLayer.Attributes["isWorkWell"] != null) { workwellLayerNames.Add(layerchildName); } if (childNodeLayer.Attributes["isValve"] != null) { valueLayerNames.Add(layerchildName); } if (childNodeLayer.Attributes["isAccess"] != null) //if (childNodeLayer.Attributes["isInstrument"] != null) { instrumenLayerNames.Add(layerchildName); } if (childNodeLayer.Attributes["isPipeFitting"] != null) { pipefittingLayerNames.Add(layerchildName); } bool boollayer = AddLayers(layerName1, layerchildName); nodelayerchild1.Text = layerchildName; nodelayerchild1.Tag = layerType1 + "|" + layerchildName; nodelayerchild1.Checked = boollayer; if (layerchildName.Contains("特征管点")) { nodelayerchild1.Checked = false; setLayerVisible(layerName1); } nodelayerchild.Nodes.Add(nodelayerchild1); g1layername.Add(layerName1); } } } } } } else { tv.Nodes.Add(nodelayer); } } } foreach (TreeNode tn in tv.Nodes) { if (tn.Nodes.Count > 0) { foreach (TreeNode tnChild in tn.Nodes) { if (tnChild.Checked) tn.Checked = true; } } } } catch (Exception ex) { LogError.PublishError(ex); } } /// <summary> /// 获取目标图层 /// </summary> /// <returns></returns> private GSOLayer TreeNodeFeatureLayer() { TreeNode featureAddPipeFitTreenode = GetDestLayerFeatureAddTreeNode(); GSOLayer featureAddLayer = globeControl1.Globe.Layers.GetLayerByCaption(featureAddPipeFitTreenode.Tag.ToString().Split('|')[1]); if (featureAddLayer != null) { return featureAddLayer; } else { return null; } } private TreeNode GetDestLayerFeatureAddTreeNode() { for (int i = 0; i < layerTree.Nodes.Count; i++) { TreeNode tempNode = layerTree.Nodes[i]; for (int j = 0; j < tempNode.Nodes.Count; j++) { TreeNode tempChildNode = tempNode.Nodes[j]; if (tempChildNode.Tag.ToString().Split('|').Length > 1) // Config配置文件配置的图层 { GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(tempChildNode.Tag.ToString().Split('|')[1]); if (layer == null) { continue; } if (tempChildNode.Tag != null && layer.IsDestLayerFeatureAdd()) { return tempChildNode; } } else //临时添加的本地图层 { for (int m = 0; m < tempChildNode.Nodes.Count; m++) { TreeNode tempChildNode1 = tempChildNode.Nodes[m]; if (tempChildNode1.Tag.ToString().Split('|').Length > 1) { GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(tempChildNode1.Tag.ToString().Split('|')[1]); if (layer == null) { continue; } if (tempChildNode1.Tag != null && layer.IsDestLayerFeatureAdd()) { return tempChildNode1; } } else { for (int n = 0; n < tempChildNode1.Nodes.Count; n++) { TreeNode tempChildNode2 = tempChildNode1.Nodes[n]; if (tempChildNode2.Tag.ToString().Split('|').Length > 1) { GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(tempChildNode2.Tag.ToString().Split('|')[1]); if (layer == null) { continue; } if (tempChildNode2.Tag != null && layer.IsDestLayerFeatureAdd()) { return tempChildNode2; } } } } } } } } return null; } /// <summary> /// 添加图层 /// </summary> /// <param name="layerName"></param> /// <param name="layerCaption"></param> /// <returns></returns> private bool AddLayers(string layerName, string layerCaption) { try { GSODataset dataset1 = Utility.dataSource.GetDatasetByName(layerName); dataset1.Caption = layerCaption; GSOLayer templayer = globeControl1.Globe.Layers.Add(dataset1); templayer.Caption = layerCaption; templayer.MaxVisibleAltitude = 1000; return templayer.Visible; } catch (Exception ex) { LogError.PublishError(ex); return false; } } /// <summary> /// 菜单上的 三维导航 工具按钮 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem86_Click(object sender, EventArgs e) { globeControl1.Globe.Action = EnumAction3D.ActionNull; } /// <summary> /// 地上模式 菜单按钮 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem87_Click(object sender, EventArgs e) { //日志记录 LogManager.saveLog(Utility.userName, this.buttonItem87.Text); if (!buttonItem87.Checked) { buttonItem87.Checked = true; buttonItem88.Checked = false; buttonItem27.Checked = false; switch (globeControl1.Globe.CameraMode) { case EnumCameraMode.UnderGround: globeControl1.Globe.CameraMode = EnumCameraMode.Navigation; GSOCameraState state = new GSOCameraState(); state.AltitudeMode = globeControl1.Globe.CameraState.AltitudeMode; state.Altitude = globeControl1.Globe.CameraState.Altitude; state.Distance = globeControl1.Globe.CameraState.Distance; state.Heading = globeControl1.Globe.CameraState.Heading; state.Latitude = globeControl1.Globe.CameraState.Latitude; state.Longitude = globeControl1.Globe.CameraState.Longitude; if (globeControl1.Globe.CameraState.Tilt < 95 && globeControl1.Globe.CameraState.Tilt > 85) { state.Tilt = 85; } else { state.Tilt = 180 - globeControl1.Globe.CameraState.Tilt; } globeControl1.Globe.JumpToCameraState(state); break; case EnumCameraMode.Walk: globeControl1.Globe.CameraMode = EnumCameraMode.Navigation; break; } globeControl1.Globe.Refresh(); } } /// <summary> /// 地下模式 菜单按钮 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem88_Click(object sender, EventArgs e) { //日志记录 LogManager.saveLog(Utility.userName, this.buttonItem88.Text); if (!buttonItem88.Checked) { buttonItem88.Checked = true; buttonItem27.Checked = false; buttonItem87.Checked = false; switch (globeControl1.Globe.CameraMode) { case EnumCameraMode.Navigation: case EnumCameraMode.Walk: globeControl1.Globe.CameraMode = EnumCameraMode.UnderGround; GSOCameraState state = new GSOCameraState(); state.AltitudeMode = globeControl1.Globe.CameraState.AltitudeMode; state.Altitude = globeControl1.Globe.CameraState.Altitude; state.Distance = globeControl1.Globe.CameraState.Distance; state.Heading = globeControl1.Globe.CameraState.Heading; state.Latitude = globeControl1.Globe.CameraState.Latitude; state.Longitude = globeControl1.Globe.CameraState.Longitude; if (globeControl1.Globe.CameraState.Tilt < 95 && globeControl1.Globe.CameraState.Tilt > 85) { state.Tilt = 95; } else { state.Tilt = 180 - globeControl1.Globe.CameraState.Tilt; } globeControl1.Globe.JumpToCameraState(state); break; } globeControl1.Globe.Refresh(); } } /// <summary> /// 行走模式 菜单按钮 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem27_Click(object sender, EventArgs e) { //日志记录 LogManager.saveLog(Utility.userName, this.buttonItem27.Text); if (!buttonItem27.Checked) { buttonItem27.Checked = true; buttonItem87.Checked = false; buttonItem88.Checked = false; globeControl1.Globe.CameraMode = EnumCameraMode.Walk; } } /// <summary> /// 地面透明度设置 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void sliderGroundTransSet1_ValueChanged(object sender, EventArgs e) { globeControl1.Globe.GroundOpaque = 100 - sliderGroundTransSet1.Value; GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(roadLayerName);//("180fd"); if (layer != null) { layer.Opaque = 100 - sliderGroundTransSet1.Value; } if (btnSpdb.Checked) { layer = globeControl2.Globe.Layers.GetLayerByCaption("180fd"); if (layer != null) { layer.Opaque = 100 - sliderGroundTransSet1.Value; } globeControl2.Globe.GroundOpaque = 100 - sliderGroundTransSet1.Value; } optiValue = sliderGroundTransSet1.Value; sliderItem1.Value = optiValue; } /// <summary> /// 图例 菜单按钮 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnlegendSet_Click(object sender, EventArgs e) { //日志记录 LogManager.saveLog(Utility.userName, this.btnlegendSet.Text); btnlegendSet.Checked = !btnlegendSet.Checked; legend.Visible = !legend.Visible; globeControl1.Refresh(); } /// <summary> /// 快速定位 菜单按钮 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem91_Click(object sender, EventArgs e) // { //日志记录 LogManager.saveLog(Utility.userName, this.buttonItem91.Text); double x = Convert.ToDouble(Utility.Query_Fields["经纬度坐标"].ToString().Split(',')[0]); double y = Convert.ToDouble(Utility.Query_Fields["经纬度坐标"].ToString().Split(',')[1]); double z = Convert.ToDouble(Utility.Query_Fields["经纬度坐标"].ToString().Split(',')[2]); jumpToCameraState(x, y, z); } /// <summary> /// 图层管理 菜单按钮 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem1_Click(object sender, EventArgs e) { //日志记录 LogManager.saveLog(Utility.userName, this.buttonItem1.Text); buttonItem1.Checked = !buttonItem1.Checked; if (buttonItem1.Checked) { sideBarPanelItem3.Visible = true; layerTree.Visible = true; controlContainerItem3.Visible = true; sideBar1.Visible = true; Refresh(); } else { sideBarPanelItem3.Visible = false; layerTree.Visible = false; controlContainerItem3.Visible = false; if (sideBarPanelItem4.Visible == true) { sideBar1.Visible = true; controlContainerItem5.Visible = true; } else { sideBar1.Visible = false; } Refresh(); } } /// <summary> /// 全屏显示 菜单按钮 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem89_Click(object sender, EventArgs e) { //日志记录 LogManager.saveLog(Utility.userName, this.buttonItem89.Text); buttonItem89.Checked = !buttonItem89.Checked; FullScreen(); } //全屏显示调用的windows底层api函数 [DllImport("user32.dll", EntryPoint = "ShowWindow")] private static extern int ShowWindow(int hWnd, int _value); //任务栏 [DllImport("user32.dll", EntryPoint = "FindWindowEx", SetLastError = true)] static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow); int widthOld = 0; int heightOld = 0; int xOld = 0; int yOld = 0; /// <summary> /// 全屏显示功能实现 /// </summary> private void FullScreen() { if (!m_bFullScreen) // 启用全屏 { xOld = this.Location.X; yOld = this.Location.Y; widthOld = this.Width; heightOld = this.Height; this.SuspendLayout();//挂起 this.FormBorderStyle = FormBorderStyle.Sizable; this.WindowState = FormWindowState.Maximized; //////任务栏 IntPtr trayHwnd = FindWindowEx(IntPtr.Zero, IntPtr.Zero, "Shell_TrayWnd", null); if (trayHwnd != IntPtr.Zero) { ShowWindow(trayHwnd.ToInt32(), 0); } int widthFull = Screen.PrimaryScreen.Bounds.Width; int heightFull = Screen.PrimaryScreen.Bounds.Height; this.FormBorderStyle = FormBorderStyle.None; this.WindowState = FormWindowState.Normal; this.Location = new Point(0, 0); SetFullScreen(widthFull, heightFull); ////hudButton btnToolNone.SetImage(Application.StartupPath + "\\Resource\\image\\Pan1.png"); btnToolSelect.SetImage(Application.StartupPath + "\\Resource\\image\\select1.png"); buttonItem89.Checked = true; this.sideBar1.Visible = false; expandableSplitter1.Expanded = false; expandableSplitter1.Visible = false; this.statusStrip1.Visible = false; this.expandableSplitter2.Expanded = false; this.expandableSplitter2.Visible = false; this.ribbonControl1.Visible = false; this.pictureBox1.Visible = false; this.ResumeLayout();//重新开始 m_bFullScreen = true; } else // 取消全屏 { this.SuspendLayout();//挂起 //////任务栏 IntPtr trayHwnd = FindWindowEx(IntPtr.Zero, IntPtr.Zero, "Shell_TrayWnd", null); if (trayHwnd != IntPtr.Zero) { ShowWindow(trayHwnd.ToInt32(), 1); } this.FormBorderStyle = FormBorderStyle.Sizable; this.WindowState = FormWindowState.Normal; this.Location = new Point(xOld, yOld); SetFullScreen(widthOld, heightOld); ////hudButton btnToolNone.SetImage(Application.StartupPath + "\\Resource\\image\\Pan1.png"); btnToolSelect.SetImage(Application.StartupPath + "\\Resource\\image\\select1.png"); buttonItem89.Checked = false; expandableSplitter1.Expanded = true; expandableSplitter1.Visible = true; this.sideBar1.Visible = true; buttonItem1.Checked = true; this.expandableSplitter2.Visible = true; this.statusStrip1.Visible = true; this.ribbonControl1.Visible = true; this.pictureBox1.Visible = true; this.ResumeLayout();//重新开始 m_bFullScreen = false; this.Focus(); //初始化隐藏图层管理 sideBarPanelItem3.Visible = false; layerTree.Visible = false; controlContainerItem3.Visible = false; if (sideBarPanelItem4.Visible == true) { sideBar1.Visible = true; controlContainerItem5.Visible = true; } else { sideBar1.Visible = false; } buttonItem1.Checked = false; Refresh(); } } /// <summary> /// 设置窗体宽、高 /// </summary> /// <param name="width"></param> /// <param name="height"></param> private void SetFullScreen(int width, int height) { this.Width = width; this.Height = height; } /// <summary> /// 全屏功能的快捷键F5 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void MainFrm_KeyDown(object sender, KeyEventArgs e) { switch (e.KeyCode) { case Keys.F5: FullScreen(); break; case Keys.Escape: // esc仅仅取消全屏 if (m_bFullScreen) { FullScreen(); } break; default: break; } if (e.KeyCode == Keys.P && e.Modifiers == Keys.Control) { buttonItem130_Click_1(this, EventArgs.Empty); } } /// <summary> /// 输出地图 /// </summary> /// <param name="p1"></param> /// <param name="p2"></param> /// <returns></returns> private Point getUpperLeftPoint(Point p1, Point p2) // { Rectangle rc = new Rectangle(); p1 = this.globeControl1.PointToScreen(p1); p2 = this.globeControl1.PointToScreen(p2); if (p1.X < p2.X) { rc.X = p1.X; rc.Width = p2.X - p1.X; } else { rc.X = p2.X; rc.Width = p1.X - p2.X; } if (p1.Y < p2.Y) { rc.Y = p1.Y; rc.Height = p2.Y - p1.Y; } else { rc.Y = p2.Y; rc.Height = p1.Y - p2.Y; } Point pt = new Point(rc.Left, rc.Top); return pt; } Image printImage; /// <summary> /// 打印 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem13_Click(object sender, EventArgs e) { Point pt1 = new Point(Convert.ToInt32(0), Convert.ToInt32(0)); Point pt2 = new Point(Convert.ToInt32(panelEx5.Width), Convert.ToInt32(panelEx5.Height)); Point pt = getUpperLeftPoint(pt1, pt2); printImage = new Bitmap(Convert.ToInt32(panelEx5.Width), Convert.ToInt32(panelEx5.Height)); Graphics g = Graphics.FromImage(printImage); g.CopyFromScreen(pt, new Point(0, 0), new Size(Convert.ToInt32(panelEx5.Width), Convert.ToInt32(panelEx5.Height))); PrintDialog pd = new PrintDialog(); try { if (pd.ShowDialog() == DialogResult.OK) //如果确认,将会覆盖所有的打印参数设置 { //打印预览 PrintPreviewDialog ppd = new PrintPreviewDialog(); ppd.Document = printDocument1; if (DialogResult.OK == ppd.ShowDialog()) { printDocument1.Print(); //打印 } } } catch { printDocument1.PrintController.OnEndPrint(printDocument1, new System.Drawing.Printing.PrintEventArgs()); } } private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e) { e.Graphics.DrawImage(printImage, 10, 10); } /// <summary> /// 输出地图 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnOutputJPG_Click(object sender, EventArgs e) { //globeControl1.Globe.Action = EnumAction3D.TrackRect; //绘制矩形模式 //globeControl1.Globe.TrackRectTool.TrackMode = EnumTrackMode.ScreenTrack; //在屏幕上绘制 Point pt1 = new Point(Convert.ToInt32(0), Convert.ToInt32(0)); Point pt2 = new Point(Convert.ToInt32(panelEx5.Width), Convert.ToInt32(panelEx5.Height)); Point pt = getUpperLeftPoint(pt1, pt2); Image myImg = new Bitmap(Convert.ToInt32(panelEx5.Width), Convert.ToInt32(panelEx5.Height)); Graphics g = Graphics.FromImage(myImg); g.CopyFromScreen(pt, new Point(0, 0), new Size(Convert.ToInt32(panelEx5.Width), Convert.ToInt32(panelEx5.Height))); SaveFileDialog dlg = new SaveFileDialog(); dlg.Filter = "输出JPEG(*.jpg)|*.jpg|输出PNG(*.png)|*.png|输出BMP(*.bmp)|*.bmp|输出BMP(*.gif)|*.gif"; if (dlg.ShowDialog() == DialogResult.OK) { string extension = System.IO.Path.GetExtension(dlg.FileName);//扩展名 switch (extension) { case ".jpg": myImg.Save(dlg.FileName, System.Drawing.Imaging.ImageFormat.Jpeg); break; case ".png": myImg.Save(dlg.FileName, System.Drawing.Imaging.ImageFormat.Png); break; case ".bmp": myImg.Save(dlg.FileName, System.Drawing.Imaging.ImageFormat.Bmp); break; case ".gif": myImg.Save(dlg.FileName, System.Drawing.Imaging.ImageFormat.Gif); break; default: break; } } } /// <summary> /// 在窗体的底部状态栏上显示 综合管线条件查询结果 /// </summary> /// <param name="currentLayer"></param> /// <param name="dataCount"></param> private void ToolStripText(string currentLayer, int dataCount) { if (dataCount != 0) { double featurelength = PipeLength(currentLayer, 0);// 统计管线的里程数 toolStripNumbers.Text = " 管线类型:" + currentLayer + " | 共有:" + Convert.ToString(dataCount - 1) + "条记录"; toolStripFeatureLength.Text = " 管线里程:" + featurelength.ToString("0.00") + " 米"; } else { toolStripNumbers.Text = "管线类型: " + currentLayer + "| 共有:" + 0 + " 条记录 | "; } } /// <summary> /// 统计管线的里程数 /// </summary> /// <param name="currentQlayer"></param> /// <param name="totalLength"></param> /// <returns></returns> public Double PipeLength(string currentQlayer, double totalLength) { if (dataGridViewX1.Rows.Count - 1 != 0) { for (int i = 0; i < dataGridViewX1.Rows.Count - 1; i++) { string featureName = ""; if (dataGridViewX1.Columns.Contains("编号")) { featureName = dataGridViewX1.Rows[i].Cells["编号"].Value.ToString().Trim(); } else { featureName = dataGridViewX1.Rows[i].Cells["标识器编号"].Value.ToString().Trim(); } //GSOLayer layer = globeControl1.Globe.Layers.GetLayerByID((int)(Utility.LayerLabel_LayerIDs[currentQlayer])); GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(currentQlayer); GSOFeatures features = layer.GetFeatureByName(featureName, false); for (int j = 0; j < features.Length; j++) { GSOFeature feat = features[j]; GSOGeoPolyline3D line = feat.Geometry as GSOGeoPolyline3D; double lentgh = line.GetSpaceLength(true, 6378137); totalLength += lentgh; } } } return totalLength; } /// <summary> /// 窗体下方属性表格 右键菜单中的 “定位”菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void FlyToMenu_Click(object sender, EventArgs e) { GSOFeature rowFeature = contextMenuStrip1.Tag as GSOFeature; if (rowFeature == null) return; if (rowFeature.Geometry != null && rowFeature.Geometry.Type == EnumGeometryType.GeoPolyline3D) { GSOGeoPolyline3D line = rowFeature.Geometry as GSOGeoPolyline3D; double length = line.GetSpaceLength(true, 6378137); GSOGeoPolyline3D lineLine = line.GetSegment(0, length / 2); GSOPoint3d point3d = lineLine[lineLine.PartCount - 1][lineLine[lineLine.PartCount - 1].Count - 1]; globeControl1.Globe.FlyToPosition(point3d, EnumAltitudeMode.Absolute,0,45,5); } else { globeControl1.Globe.FlyToFeature(rowFeature, 0, 45, 3); } LightMenu_Click(sender, e); } /// <summary> /// 表格中右键 “单个闪烁” 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void LightMenu_Click(object sender, EventArgs e) { flashflag = "single"; timer1.Start(); } /// <summary> /// 表格中右键 “全部闪烁” 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void AllLightMenuItem_Click(object sender, EventArgs e) { flashflag = "all"; timer1.Start(); } /// <summary> /// 使用timer实现管线的闪烁效果 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void timer1_Tick(object sender, EventArgs e) { GSOFeature rowFeature = contextMenuStrip1.Tag as GSOFeature; if (rowFeature == null) return; if (count < 40) { count++; if (flashflag == "single") { if (rowFeature != null) { if (count % 2 != 0) { rowFeature.HighLight = true; globeControl1.Refresh(); } else { rowFeature.HighLight = false; globeControl1.Refresh(); } } } else if (flashflag == "all") { GSOFeatures feats = Utility.Table2Features(dataGridViewX1.DataSource as DataTable, m_CurrentQueryLayer, globeControl1); if (feats.Length > 0) { if (count % 2 != 0) { for (int i = 0; i < feats.Length; i++) { GSOFeature tempfeat = feats[i]; tempfeat.HighLight = true; } globeControl1.Refresh(); } else { for (int i = 0; i < feats.Length; i++) { GSOFeature tempfeat = feats[i]; tempfeat.HighLight = false; } globeControl1.Refresh(); } } } } else { timer1.Stop(); count = 0; } } /// <summary> /// 主窗体下方属性表右键菜单弹出,并且记录点击的行对应的feature /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void dataGridViewX1_MouseClick(object sender, MouseEventArgs e) { GSOFeature rowFeature = contextMenuStrip1.Tag as GSOFeature; if (rowFeature != null && rowFeature.HighLight == true) { rowFeature.HighLight = false; } if (e.Button == MouseButtons.Right) { DataGridView.HitTestInfo hittestinfo = dataGridViewX1.HitTest(e.X, e.Y); if (hittestinfo.RowIndex > -1) { string featureName = ""; if (dataGridViewX1.Columns.Contains("编号")) { featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString(); } else { featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["标识器编号"].Value.ToString(); } contextMenuStrip1.Show(dataGridViewX1, e.X, e.Y); featureName = featureName.Trim(); GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(m_CurrentQueryLayer); if (layer == null) return; GSOFeatures features = layer.GetFeatureByName(featureName, false); for (int j = 0; j < features.Length; j++) { if (features[j].Name == featureName) { contextMenuStrip1.Tag = features[j]; break; } } } } } /// <summary> /// 主窗体下方属性表格 双击定位 功能 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void dataGridViewX1_MouseDoubleClick(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { DataGridView.HitTestInfo hittestinfo = dataGridViewX1.HitTest(e.X, e.Y); if (hittestinfo.RowIndex > -1) { string featureName = ""; if (dataGridViewX1.Columns.Contains("编号")) { featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString(); } else { featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["标识器编号"].Value.ToString(); } featureName = featureName.Trim(); GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(m_CurrentQueryLayer); if (layer != null) { GSOFeatures features = layer.GetFeatureByName(featureName, false); for (int j = 0; j < features.Length; j++) { if (features[j].Name == featureName) { //m_feature = features[j]; GSOFeature rowFeature = features[j]; if (rowFeature == null) continue; if (rowFeature.Geometry != null && rowFeature.Geometry.Type == EnumGeometryType.GeoPolyline3D) { GSOGeoPolyline3D line = rowFeature.Geometry as GSOGeoPolyline3D; double length = line.GetSpaceLength(true, 6378137);//线的长度; GSOGeoPolyline3D lineLine = line.GetSegment(0, length / 2); GSOPoint3d point3d = lineLine[lineLine.PartCount - 1][lineLine[lineLine.PartCount - 1].Count - 1]; globeControl1.Globe.FlyToPosition(point3d, EnumAltitudeMode.Absolute, 0, 45, 5); LightMenu_Click(sender, e); } else { globeControl1.Globe.FlyToFeature(rowFeature, 0, 45, 3); } } } } } } } /// <summary> /// 添加管线 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnAddPipeLine_Click(object sender, EventArgs e) { //日志记录 LogManager.saveLog(Utility.userName, this.btnAddPipelines.Text); frmPipeSetEdit frm = new frmPipeSetEdit(globeControl1,m_PipelineLayerNames); if (frm.ShowDialog() == DialogResult.OK) { m_AddPipeLine = true; m_isDrawTunnel = false; m_isDrawCitySevenLine = false; globeControl1.Globe.Action = EnumAction3D.DrawPolyline; } } /// <summary> /// 添加管件 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnAddPipeFitting_Click(object sender, EventArgs e) { //日志记录 LogManager.saveLog(Utility.userName, this.btnAddTzgd.Text); FrmSetGoalLayer frm = new FrmSetGoalLayer(globeControl1, pipefittingLayerNames); if (frm.ShowDialog() == DialogResult.OK) { GSOLayer featureAddLayer = TreeNodeFeatureLayer(); if (featureAddLayer == null) { return; } FrmAddPipeFitting dlg = new FrmAddPipeFitting(globeControl1, featureAddLayer); dlg.Show(this); } } /// <summary> /// 添加附属物 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem添加附属物_Click(object sender, EventArgs e) { //日志记录 LogManager.saveLog(Utility.userName, this.btnAddWells.Text); FrmSetGoalLayer frm = new FrmSetGoalLayer(globeControl1, instrumenLayerNames); if (frm.ShowDialog() == DialogResult.OK) { GSOLayer featureAddLayer = TreeNodeFeatureLayer(); if (featureAddLayer == null) { return; } FrmAddInstrument dlg = new FrmAddInstrument(globeControl1, featureAddLayer); dlg.Show(this); } } /// <summary> /// 选中对象 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSelObj_Click(object sender, EventArgs e) { //日志记录 LogManager.saveLog(Utility.userName, this.btnSelObjs.Text); globeControl1.Globe.Action = EnumAction3D.SelectObject; } /// <summary> /// 平移对象 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnMoveObj_Click(object sender, EventArgs e) { //日志记录 LogManager.saveLog(Utility.userName, this.btnMoveObjs.Text); globeControl1.Globe.Action = EnumAction3D.MoveObject; } /// <summary> /// 升降对象 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnElevateObj_Click(object sender, EventArgs e) { //日志记录 LogManager.saveLog(Utility.userName, this.btnElevateObjs.Text); globeControl1.Globe.Action = EnumAction3D.ElevateObject; } /// <summary> /// 旋转对象 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnRotateModel_Click(object sender, EventArgs e) { //日志记录 LogManager.saveLog(Utility.userName, this.btnRotateModels.Text); globeControl1.Globe.Action = EnumAction3D.RotateObject; } /// <summary> /// 绘制线 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnAddLine_Click(object sender, EventArgs e) { globeControl1.Globe.DestLayerFeatureAdd = globeControl1.Globe.MemoryLayer; globeControl1.Globe.Action = EnumAction3D.DrawPolyline; } /// <summary> /// 绘制面 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnAddPolygon_Click(object sender, EventArgs e) { globeControl1.Globe.DestLayerFeatureAdd = globeControl1.Globe.MemoryLayer; globeControl1.Globe.Action = EnumAction3D.DrawPolygon; } /// <summary> /// 图层目录树 右键菜单中的 目标图层 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void FeatureAddLayerMenuItem_Click(object sender, EventArgs e) { if (!FeatureAddLayerMenuItem.Checked) { TreeNode node = layerNodeContexMenu.Tag as TreeNode; FeatureAddLayerMenuItem.Checked = true; GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(node.Tag.ToString().Split('|')[1]); //GSOLayer layer = globeControl1.Globe.Layers.GetLayerByID((int)node.Tag); globeControl1.Globe.DestLayerFeatureAdd = layer; } } /// <summary> /// 图层目录树 右键菜单中的 可选择 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void LayerSelectableMenuItem_Click(object sender, EventArgs e) { TreeNode node = layerNodeContexMenu.Tag as TreeNode; Int32 nIndex = node.Index; GSOLayer layer = globeControl1.Globe.Layers[nIndex]; LayerSelectableMenuItem.Checked = !LayerSelectableMenuItem.Checked; layer.Selectable = LayerSelectableMenuItem.Checked; } /// <summary> /// 图层目录树 右键菜单中的 可编辑 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void LayerEditableMenuItem_Click(object sender, EventArgs e) { TreeNode node = layerNodeContexMenu.Tag as TreeNode; GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(node.Tag.ToString().Split('|')[1]); LayerEditableMenuItem.Checked = !LayerEditableMenuItem.Checked; layer.Editable = LayerEditableMenuItem.Checked; } /// <summary> /// 图层目录树 右键菜单中的 保存 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void SaveLayerMenuItem_Click(object sender, EventArgs e) { TreeNode node = layerNodeContexMenu.Tag as TreeNode; Int32 nIndex = node.Index; string layerCaption = node.Tag.ToString().Split('|')[1]; GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerCaption); layer.Dataset.Save(); } /// <summary> /// 根据多边形范围统计管线的里程 /// </summary> /// <param name="polygon"></param> /// <param name="pipelineLayerCaption"></param> /// <returns>返回查询到的管线要素集合</returns> private GSOFeatures Intersects_Pipeline(GSOGeoPolygon3D polygon, string pipelineLayerCaption) { GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(pipelineLayerCaption); if (layer == null) return null; GSOFeatureLayer flayer = layer as GSOFeatureLayer; GSOFeatureDataset fdataset = flayer.Dataset as GSOFeatureDataset; GSOFeatures feats = new GSOFeatures(); if (polygon == null) feats = flayer.GetAllFeatures(); else feats = flayer.FindFeaturesInPolygon(polygon, false); double totallength = 0.01; for (int i = 0; i < feats.Length; i++) { GSOFeature feat = feats[i]; GSOGeoPolyline3D line = feat.Geometry as GSOGeoPolyline3D; if (line == null) continue; double length = line.GetSpaceLength(true, 6378137); totallength += length; if (polygon != null) feat.HighLight = true; } double toLength = Convert.ToDouble(totallength.ToString().Substring(0, totallength.ToString().IndexOf("."))); pipeLineDis.Add(pipelineLayerCaption, toLength); return feats; } Dictionary<string, double> pipeLineDis = new Dictionary<string, double>(); Dictionary<string, int> workWellLen = new Dictionary<string, int>(); /// <summary> /// 管线距离统计 全区域 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem2_Click(object sender, EventArgs e) // { //日志记录 LogManager.saveLog(Utility.userName, "管线长度统计"); pipeLineDis.Clear(); List<GSOFeatures> list = new List<GSOFeatures>(); for (int i = 0; i < m_PipelineLayerNames.Count; i++) { GSOFeatures fs = Intersects_Pipeline(null, m_PipelineLayerNames[i]); list.Add(fs); } FrmAllPipelineStatis frm = new FrmAllPipelineStatis(0, pipeLineDis, list, dataGridViewX1, toolStripNumbers, toolStripFeatureLength, globeControl1, panelOfTable); frm.Show(this); } /// <summary> /// 管线距离统计 绘制区域 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem5_Click(object sender, EventArgs e) { //日志记录 LogManager.saveLog(Utility.userName, "管线长度统计"); trackflag = "PipelineDistanceStatistics"; globeControl1.Globe.Action = EnumAction3D.TrackPolygon; globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; } /// <summary> /// 阀门数量统计 全区域 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem6_Click(object sender, EventArgs e) { //日志记录 LogManager.saveLog(Utility.userName, "阀门数量统计"); workWellLen.Clear(); List<GSOFeatures> list = new List<GSOFeatures>(); //找到所有阀门 if (Utility.LayerNamesList != null) { ArrayList listpt = Utility.LayerNamesList; for (int i = 0; i < listpt.Count; i++) { string pipelineType = (string)Utility.LayerNamesList[i]; if ((pipelineType == "给水") || (pipelineType == "天然气") || (pipelineType == "燃气")) { GSOFeatures fs = Intersect_PointLayerByType(null, pipelineType, "阀门"); list.Add(fs); } } } FrmValveStatistics frm = new FrmValveStatistics(workWellLen, list, dataGridViewX1, toolStripNumbers, globeControl1,panelOfTable); frm.Show(this); globeControl1.Globe.Action = EnumAction3D.ActionNull; } /// <summary> /// 阀门数量统计 绘制区域 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem7_Click(object sender, EventArgs e) { //日志记录 LogManager.saveLog(Utility.userName, "阀门数量统计"); trackflag = "valvequery"; globeControl1.Globe.Action = EnumAction3D.TrackPolygon; globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; } /// <summary> /// 井盖数量统计 全区域 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem59_Click(object sender, EventArgs e) { //日志记录 LogManager.saveLog(Utility.userName, "井盖数量统计"); workWellLen.Clear(); List<GSOFeatures> list = new List<GSOFeatures>(); if (Utility.LayerNamesList != null) { ArrayList listpt = Utility.LayerNamesList; for (int i = 0; i < listpt.Count; i++) { string pipelineType = (string)Utility.LayerNamesList[i]; string sql = "select 附属物名称 from " + pipelineType + "管线附属物 group by 附属物名称"; DataSet dataset = OledbHelper.getDataSet(sql, pipelineType + "管线附属物"); if (dataset != null) { for (int j = 0; j < dataset.Tables[0].Rows.Count; j++) { string accname = dataset.Tables[0].Rows[j][0].ToString(); if ((accname.IndexOf("井") > 0) || (accname.IndexOf("孔") > 0) || (accname.IndexOf("篦") > 0)) { GSOFeatures fs = Intersect_PointLayerByType(null, pipelineType, dataset.Tables[0].Rows[j][0].ToString()); list.Add(fs); } } } } } FrmAllWorkWellStatis frm = new FrmAllWorkWellStatis(workWellLen, list, dataGridViewX1, toolStripNumbers, globeControl1, panelOfTable); frm.Show(this); } /// <summary> /// 井盖数量统计 绘制区域 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem62_Click(object sender, EventArgs e) { //日志记录 LogManager.saveLog(Utility.userName, "井盖数量统计"); trackflag = "workwellquery"; globeControl1.Globe.Action = EnumAction3D.TrackPolygon; globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; } /// <summary> /// 查找指定图层中在 指定范围内的feature对象集合 /// </summary> /// <param name="polygon"></param> /// <param name="layername"></param> /// <returns></returns> private GSOFeatures Polygon_Contain_PointAnalysis(GSOGeoPolygon3D polygon, string layername) { GSOFeatures feats = new GSOFeatures(); GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layername); if (layer == null) { return feats; } GSOFeatureLayer flayer = layer as GSOFeatureLayer; if (flayer != null) { GSOFeatureDataset fdataset = flayer.Dataset as GSOFeatureDataset; } if (polygon == null) { feats = flayer.GetAllFeatures(); } else { feats = flayer.FindFeaturesInPolygon(polygon, false); } return feats; } /// <summary> /// 清除结果 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem47_Click(object sender, EventArgs e) { globeControl1.Globe.ClearAnalysis(); dataGridViewX1.DataSource = null; panelOfTable.Visible = false; clearFeatureHighLight(); } /// <summary> /// 主窗体 下方的工具条中的 导出.xls文件 按钮事件处理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void toolStripDropDownButton3_Click(object sender, EventArgs e) { if (dataGridViewX1.Rows.Count > 0) { int startIdx = toolStripNumbers.Text.IndexOf(":"); int endIdx = toolStripNumbers.Text.IndexOf("|"); if (endIdx == -1) { endIdx = toolStripNumbers.Text.Trim().Length; } string stype = toolStripNumbers.Text.Substring(startIdx + 1, endIdx - startIdx); ExportExcel(stype, dataGridViewX1, null); } else { MessageBox.Show("表格内容为空!","提示"); } } /// <summary> /// 横断面分析 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnItem_HDMAnalysis_Click(object sender, EventArgs e) { //日志记录 LogManager.saveLog(Utility.userName, this.btnItem_HDMAnalysis.Text); if (!btnItem_HDMAnalysis.Checked) { trackflag = "PolylineAnalysis"; globeControl1.Globe.Action = EnumAction3D.TrackPolyline; globeControl1.Globe.TrackPolylineTool.VerticalLineVisible = true; globeControl1.Globe.TrackPolylineTool.TrackMode = EnumTrackMode.SpaceTrack; btnItem_HDMAnalysis.Checked = true; buttonItem9.Checked = false; BaselineProfileAnalysisMenuItem.Checked = false; } else { globeControl1.Globe.Action = EnumAction3D.ActionNull; btnItem_HDMAnalysis.Checked = false; globeControl1.Globe.TrackPolylineTool.VerticalLineVisible = false; } ActionToolMenuChecked(); } /// <summary> /// 道路断面分析 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem9_Click(object sender, EventArgs e) { //日志记录 LogManager.saveLog(Utility.userName, this.buttonItem9.Text); if (!buttonItem9.Checked) { trackflag = "RoadPolylineAnalysis"; globeControl1.Globe.Action = EnumAction3D.TrackPolyline; globeControl1.Globe.TrackPolylineTool.VerticalLineVisible = true; buttonItem9.Checked = true; btnItem_HDMAnalysis.Checked = false; BaselineProfileAnalysisMenuItem.Checked = false; } else { globeControl1.Globe.Action = EnumAction3D.ActionNull; buttonItem9.Checked = false; globeControl1.Globe.TrackPolylineTool.VerticalLineVisible = false; } ActionToolMenuChecked(); } /// <summary> /// 基线剖面分析 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void BaselineProfileAnalysisMenuItem_Click(object sender, EventArgs e) { //日志记录 LogManager.saveLog(Utility.userName, this.BaselineProfileAnalysisMenuItem.Text); if (!BaselineProfileAnalysisMenuItem.Checked) { globeControl1.Globe.Action = EnumAction3D.TrackPolyline; //globeControl1.Globe.TrackPolylineAnalysis.VerticalLineVisible = true; globeControl1.Globe.TrackPolylineTool.VerticalLineVisible = true; BaselineProfileAnalysisMenuItem.Checked = true; buttonItem9.Checked = false; btnItem_HDMAnalysis.Checked = false; } else { globeControl1.Globe.Action = EnumAction3D.ActionNull; BaselineProfileAnalysisMenuItem.Checked = false; //globeControl1.Globe.TrackPolylineAnalysis.VerticalLineVisible = false; globeControl1.Globe.TrackPolylineTool.VerticalLineVisible = false; } ActionToolMenuChecked(); } /// <summary> /// 纵断面分析 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem82_Click(object sender, EventArgs e) { //日志记录 LogManager.saveLog(Utility.userName, this.buttonItem82.Text); if (globeControl1.Globe.SelObjectCount >= 1) { //if (isInterlinked()) GSOFeatures selectFeatures = new GSOFeatures(); for (int i = 0; i < globeControl1.Globe.SelObjectCount; i++) { GSOFeature feature = null; GSOLayer layer = null; globeControl1.Globe.GetSelectObject(i, out feature, out layer); if (feature != null && feature.Geometry != null && feature.Geometry.Type == EnumGeometryType.GeoPolyline3D) { selectFeatures.Add(feature); } } if (selectFeatures.Length < 1) { MessageBox.Show("请选择一条或者多条管线!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } List<GSOFeature> listFeature = new List<GSOFeature>(); if (selectFeatures.Length == 1) { listFeature.Add(selectFeatures[0]); } else { //求多条管线纵断面 1,2,3 //1 判断管线是否相连、且没有分叉 for (int i = 0; i < selectFeatures.Length; i++) { GSOGeoPolyline3D line = selectFeatures[i].Geometry as GSOGeoPolyline3D; bool isConnect = false; int[] valueCount = new int[2]; valueCount[0] = 0; valueCount[1] = 0; if (line != null && line.PartCount > 0) { for (int j = 0; j < selectFeatures.Length; j++) { if (i == j) { continue; } GSOGeoPolyline3D newLine = selectFeatures[j].Geometry as GSOGeoPolyline3D; if (newLine != null && newLine.PartCount > 0) { int minValueIndex = 0; double limitValue = 1.0; double[] value = new double[4]; value[0] = getDistance(line[line.PartCount - 1][line[line.PartCount - 1].Count - 1], newLine[0][0]); value[1] = getDistance(line[line.PartCount - 1][line[line.PartCount - 1].Count - 1], newLine[newLine.PartCount - 1][newLine[newLine.PartCount - 1].Count - 1]); value[2] = getDistance(line[0][0], newLine[0][0]); value[3] = getDistance(line[0][0], newLine[newLine.PartCount - 1][newLine[newLine.PartCount - 1].Count - 1]); double minValue = value[0]; for (int m = 1; m < value.Length; m++) { if (minValue > value[m]) { minValue = value[m]; minValueIndex = m; } } if (minValue < limitValue) { isConnect = true; if (minValueIndex > 1) { valueCount[1]++; } else { valueCount[0]++; } } } } if (!isConnect || valueCount[0] > 1 || valueCount[1] > 1) { MessageBox.Show("请选择相连接的一条线上的管线!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } } } //2 记录每一条相连接的管线的起点和终点,并添加到一条管线中 for (int p = 0; p < selectFeatures.Length; p++) { GSOGeoPolyline3D line = selectFeatures[p].Geometry as GSOGeoPolyline3D; if (line != null && line.PartCount > 0) { for (int n = 0; n < selectFeatures.Length; n++) { if (p == n) { continue; } GSOGeoPolyline3D newLine = selectFeatures[n].Geometry as GSOGeoPolyline3D; if (newLine != null && newLine.PartCount > 0) { int minValueIndex = 0; double limitValue = 1.0; double[] value = new double[4]; value[0] = getDistance(line[line.PartCount - 1][line[line.PartCount - 1].Count - 1], newLine[0][0]); value[1] = getDistance(line[line.PartCount - 1][line[line.PartCount - 1].Count - 1], newLine[newLine.PartCount - 1][newLine[newLine.PartCount - 1].Count - 1]); value[2] = getDistance(line[0][0], newLine[0][0]); value[3] = getDistance(line[0][0], newLine[newLine.PartCount - 1][newLine[newLine.PartCount - 1].Count - 1]); double minValue = value[0]; for (int m = 1; m < value.Length; m++) { if (minValue > value[m]) { minValue = value[m]; minValueIndex = m; } } if (minValue < limitValue) { GSOFeature featureFromAllSelectedObj = new GSOFeature(); GSOGeoPolyline3D lineFromAllSelectedObj = new GSOGeoPolyline3D(); switch (minValueIndex) { case 0: GSOPoint3ds linePart = new GSOPoint3ds(); for (int i = 0; i < line.PartCount; i++) { for (int j = 0; j < line[i].Count; j++) { linePart.Add(line[i][j]); } } for (int i = 0; i < newLine.PartCount; i++) { for (int j = 0; j < newLine[i].Count; j++) { linePart.Add(newLine[i][j]); } } lineFromAllSelectedObj.AddPart(linePart); break; case 1: linePart = new GSOPoint3ds(); for (int i = 0; i < line.PartCount; i++) { for (int j = 0; j < line[i].Count; j++) { linePart.Add(line[i][j]); } } for (int i = newLine.PartCount - 1; i >= 0; i--) { for (int j = newLine[i].Count - 1; j >= 0; j--) { linePart.Add(newLine[i][j]); } } lineFromAllSelectedObj.AddPart(linePart); break; case 2: linePart = new GSOPoint3ds(); for (int i = line.PartCount - 1; i >= 0; i--) { for (int j = line[i].Count - 1; j >= 0; j--) { linePart.Add(line[i][j]); } } for (int i = 0; i < newLine.PartCount; i++) { for (int j = 0; j < newLine[i].Count; j++) { linePart.Add(newLine[i][j]); } } lineFromAllSelectedObj.AddPart(linePart); break; case 3: linePart = new GSOPoint3ds(); for (int i = line.PartCount - 1; i >= 0; i--) { for (int j = line[i].Count - 1; j >= 0; j--) { linePart.Add(line[i][j]); } } for (int i = newLine.PartCount - 1; i >= 0; i--) { for (int j = newLine[i].Count - 1; j >= 0; j--) { linePart.Add(newLine[i][j]); } } lineFromAllSelectedObj.AddPart(linePart); break; } featureFromAllSelectedObj.Geometry = lineFromAllSelectedObj; selectFeatures.Remove(n); selectFeatures.Remove(p); selectFeatures.Add(featureFromAllSelectedObj); p--; break; } } } } } //3 将合并之后的管线添加到集合中 for (int h = 0; h < selectFeatures.Length; h++) { listFeature.Add(selectFeatures[h]); } } //将选中的管线展示在窗体中 if (listFeature.Count > 0) { FrmProfileAnalysis frm = new FrmProfileAnalysis(globeControl1, listFeature); frm.Show(this); } else { MessageBox.Show("请选择相连接的管线!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { MessageBox.Show("请选择一条或者多条管线!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } } /// <summary> /// 设置菜单的选中状态 /// </summary> private void ActionToolMenuChecked() { if (globeControl1.Globe.Action != EnumAction3D.TrackPolyline) { btnItem_HDMAnalysis.Checked = false; BaselineProfileAnalysisMenuItem.Checked = false; buttonItem9.Checked = false; buttonItem28.Checked = false; } if (globeControl1.Globe.Action != EnumAction3D.NormalHit) { btnLTAnalysis.Checked = false; ClearConnexityAnalysis(); btnGFFX.Checked = false; ClearCloseValvesAnalysis(); } if (globeControl1.Globe.Action != EnumAction3D.TrackPolygon) { DigFillAnalysisMenuItem.Checked = false; btnPolygonDigPit.Checked = false; } } /// <summary> /// 连通性分析 功能 /// </summary> private void ConnexityAnalysis() { GSODataset curCAYDataset = m_ConnexityAnalysisFirstLayer.Dataset; string srName = curCAYDataset.Name; GSONetworkDataset curCAYNDataset = curCAYDataset.DataSource.GetDatasetByName(srName + "Network") as GSONetworkDataset; if (curCAYNDataset == null) { MessageBox.Show("该图层没有创建网络拓扑,请先创建网络拓扑信息再进行分析!", "提示"); return; } int[] arryResID; curCAYNDataset.ConnexityAnalysis(m_ConnexityAnalysisFirstFeature.ID, m_ConnexityAnaylsisSecondFeature.ID, out arryResID, false, true); m_ConnexityAnalyResFeatures = m_ConnexityAnalysisFirstLayer.GetFeaturesByIDs(arryResID); if (m_ConnexityAnalyResFeatures == null || m_ConnexityAnalyResFeatures.Length < 1) { String strLine1 = "管线:" + m_ConnexityAnalysisFirstFeature.ID; String strLine2 = "管线:" + m_ConnexityAnaylsisSecondFeature.ID; MessageBox.Show(strLine1 + " 与 " + strLine2 + " 不连通", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { int nCount = m_ConnexityAnalyResFeatures.Length; for (int i = 0; i < nCount; i++) { m_ConnexityAnalyResFeatures[i].HighLight = true; GSOGeoPolyline3D geoline = m_ConnexityAnalyResFeatures[i].Geometry as GSOGeoPolyline3D; if (geoline != null) { GSOLineStyle3D lineStyle = geoline.Style as GSOLineStyle3D; if (lineStyle != null) { if (lineStyle.ArrowStyle == null) { lineStyle.ArrowStyle = new GSOArrowStyle(); } lineStyle.ArrowStyle.BodyLen = 8; lineStyle.ArrowVisible = true; lineStyle.ArrowStyle.Play(); } } } globeControl1.Refresh(); } } /// <summary> /// 清除连通性分析结果 功能 /// </summary> private void ClearConnexityAnalysis() { if (m_ConnexityAnalysisFirstFeature != null) { m_ConnexityAnalysisFirstFeature.HighLight = false; m_ConnexityAnalysisFirstFeature.Label = null; } if (m_ConnexityAnaylsisSecondFeature != null) { m_ConnexityAnaylsisSecondFeature.HighLight = false; m_ConnexityAnaylsisSecondFeature.Label = null; } m_ConnexityAnalysisFirstFeature = null; m_ConnexityAnaylsisSecondFeature = null; m_ConnexityAnalysisFirstLayer = null; m_COnnexityAnalysisSecondLayer = null; if (m_ConnexityAnalyResFeatures != null) { int nCount = m_ConnexityAnalyResFeatures.Length; for (int i = 0; i < nCount; i++) { m_ConnexityAnalyResFeatures[i].HighLight = false; GSOGeoPolyline3D geoline = m_ConnexityAnalyResFeatures[i].Geometry as GSOGeoPolyline3D; if (geoline != null) { GSOLineStyle3D lineStyle = geoline.Style as GSOLineStyle3D; if (lineStyle != null) { lineStyle.ArrowVisible = false; } } } m_ConnexityAnalyResFeatures = null; } } /// <summary> /// 清除阀门分析结果 功能 /// </summary> private void ClearCloseValvesAnalysis() { if (m_CloseValvesAnalyResFeatures != null) { for (int i = 0; i < m_CloseValvesList.Count; i++) { GSOFeature feature = m_CloseValvesList[i] as GSOFeature; feature.Label.Text = ""; } globeControl1.Refresh(); m_CloseValvesAnalyResFeatures = null; m_CloseValvesList = new ArrayList(); } } /// <summary> /// 清除阀门分析结果 功能 /// </summary> private void ClearBoosterValvesAnalysis() { if (m_BoosterValvesAnalyResFeatures != null) { for (int i = 0; i < m_BoosterValvesList.Count; i++) { GSOFeature feature = m_BoosterValvesList[i] as GSOFeature; feature.Label.Text = ""; } globeControl1.Refresh(); m_BoosterValvesAnalyResFeatures = null; m_BoosterValvesList = new ArrayList(); } } /// <summary> /// 水平距离量算 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnMeasureDist_Click(object sender, EventArgs e) { //日志记录 LogManager.saveLog(Utility.userName, this.btnMeasureDist.Text); globeControl1.Globe.Action = EnumAction3D.MeasureDistance; globeControl1.Globe.DistanceRuler.SpaceMeasure = true; btnSpaceMeasureHeight.Checked = false; } /// <summary> /// 垂直距离 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnMeasureHeight_Click(object sender, EventArgs e) { //日志记录 LogManager.saveLog(Utility.userName, this.btnMeasureHeight.Text); btnSpaceMeasureHeight.Checked = false; globeControl1.Globe.Action = EnumAction3D.MeasureHeight; globeControl1.Globe.DistanceRuler.SpaceMeasure = false; } /// <summary> /// 地表面积量算 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnMeasureArea_Click(object sender, EventArgs e) { //日志记录 LogManager.saveLog(Utility.userName, this.btnMeasureArea.Text); btnSpaceMeasureHeight.Checked = false; globeControl1.Globe.Action = EnumAction3D.MeasureArea; globeControl1.Globe.AreaRuler.SpaceMeasure = false; } /// <summary> /// 空间距离量算 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSpaceMeasureDistance_Click(object sender, EventArgs e) { //日志记录 LogManager.saveLog(Utility.userName, this.btnSpaceMeasureDistance.Text); btnSpaceMeasureHeight.Checked = false; globeControl1.Globe.Action = EnumAction3D.MeasureDistance; globeControl1.Globe.DistanceRuler.SpaceMeasure = true; } /// <summary> /// 高度量算 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSpaceMeasureHeight_Click(object sender, EventArgs e) { //日志记录 LogManager.saveLog(Utility.userName, this.btnSpaceMeasureHeight.Text); globeControl1.Globe.Action = EnumAction3D.ActionNull; btnSpaceMeasureHeight.Checked = !btnSpaceMeasureHeight.Checked; if (btnSpaceMeasureHeight.Checked) { globeControl1.Globe.Action = EnumAction3D.SelectObject; } } /// <summary> /// 删除测算结果 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnClearMeasure_Click(object sender, EventArgs e) { globeControl1.Globe.ClearMeasure(); globeControl1.Globe.Action = EnumAction3D.ActionNull; layerTemp.RemoveAllFeature(); btnSpaceMeasureHeight.Checked = false; } /// <summary> /// 通视分析 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSpaceVisibilityAnalysis_Click(object sender, EventArgs e) { //日志记录 LogManager.saveLog(Utility.userName, this.btnSpaceVisibilityAnalysis.Text); if (globeControl1.Globe.Action != EnumAction3D.VisibilityAnalysis) { //btnSpaceVisibilityAnalysis.Checked = true; globeControl1.Globe.Action = EnumAction3D.VisibilityAnalysis; } else { globeControl1.Globe.Action = EnumAction3D.ActionNull; // SetButtonChecked(); } } /// <summary> /// 坐标投影 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> //private void btnProject_Click(object sender, EventArgs e) //{ // //日志记录 // LogManager.saveLog(Utility.userName, this.btnProject.Text); // Cyberpipe.Forms.FrmProject frm = new Cyberpipe.Forms.FrmProject(); // frm.ShowDialog(); //} /// <summary> /// 主窗体关闭事件处理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void MainFrm_FormClosing(object sender, FormClosingEventArgs e) { globeControl1.Globe.MemoryLayer.SaveAs(Application.StartupPath + "/MyPlace.kml"); //注销id号为103的热键设定 // UnregisterHotKey(Handle, 103); } /// <summary> /// 创建拓扑 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem11_Click(object sender, EventArgs e) { //日志记录 LogManager.saveLog(Utility.userName, this.buttonItem11.Text); FrmGenAndFaMenTopu frm = new FrmGenAndFaMenTopu(globeControl1, m_PipelineLayerNames, valueLayerNames); frm.Show(this); } /// <summary> /// 上游追踪 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void TraceUpMenuIte_Click(object sender, EventArgs e) { //日志记录 LogManager.saveLog(Utility.userName, this.TraceUpMenuIte.Text); ClearUpDownTraceAnalysis(); NetworkTraceUpDown(true); } /// <summary> /// 清除追踪结果 功能 /// </summary> private void ClearUpDownTraceAnalysis() { if (m_TraceUpDownAnalyResFeatures != null) { int nCount = m_TraceUpDownAnalyResFeatures.Length; for (int i = 0; i < nCount; i++) { m_TraceUpDownAnalyResFeatures[i].HighLight = false; GSOGeoPolyline3D geoline = m_TraceUpDownAnalyResFeatures[i].Geometry as GSOGeoPolyline3D; if (geoline != null) { GSOLineStyle3D lineStyle = geoline.Style as GSOLineStyle3D; if (lineStyle != null) { lineStyle.ArrowVisible = false; } } } m_TraceUpDownAnalyResFeatures = null; } } /// <summary> /// 取消所有高亮管线的高亮状态 /// </summary> private void ClearAffectedPipeLine() { if (m_AffectedPipeLines != null) { int nCount = m_AffectedPipeLines.Length; for (int i = 0; i < nCount; i++) { m_AffectedPipeLines[i].HighLight = false; } m_AffectedPipeLines = null; } } /// <summary> /// 上下游追踪 功能 /// </summary> /// <param name="bTraceUp"></param> private void NetworkTraceUpDown(Boolean bTraceUp) { if (globeControl1.Globe.SelectedObject == null) { MessageBox.Show("请点击“编辑”—“选中对象”选择一条线!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } GSOFeature selLineFeature = globeControl1.Globe.SelectedObject; if (selLineFeature.Geometry == null || selLineFeature.Geometry.Type != EnumGeometryType.GeoPolyline3D) { MessageBox.Show("请点击“编辑”—“选中对象”选择一条线!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (globeControl1.Globe.SelectedObjectLayer == null) { MessageBox.Show("选中管线所在图层为空!", "提示"); return; } GSODataset curCAYDataset = globeControl1.Globe.SelectedObjectLayer.Dataset; if (curCAYDataset == null || curCAYDataset.DataSource == null) { MessageBox.Show("选中管线所在图层不是数据库图层!","提示"); return; } string srName = curCAYDataset.Name; GSONetworkDataset curCAYNDataset = curCAYDataset.DataSource.GetDatasetByName(srName + "Network") as GSONetworkDataset; if (curCAYNDataset == null) { MessageBox.Show("选中管线所在图层没有创建拓扑!","提示"); return; } int[] arryResID; curCAYNDataset.TraceUpDownAnalysis(selLineFeature.ID, out arryResID, bTraceUp, false, true); m_TraceUpDownAnalyResFeatures = globeControl1.Globe.SelectedObjectLayer.GetFeaturesByIDs(arryResID); if (m_TraceUpDownAnalyResFeatures == null || m_TraceUpDownAnalyResFeatures.Length < 1) { String strLine1 = "没有上游!"; if (!bTraceUp) { strLine1 = "没有下游!"; } MessageBox.Show(strLine1); } else { int nCount = m_TraceUpDownAnalyResFeatures.Length; for (int i = 0; i < nCount; i++) { m_TraceUpDownAnalyResFeatures[i].HighLight = true; GSOGeoPolyline3D geoline = m_TraceUpDownAnalyResFeatures[i].Geometry as GSOGeoPolyline3D; if (geoline != null) { GSOLineStyle3D lineStyle = geoline.Style as GSOLineStyle3D; if (lineStyle != null) { if (lineStyle.ArrowStyle == null) { lineStyle.ArrowStyle = new GSOArrowStyle(); lineStyle.ArrowStyle.BodyWidth = 2; lineStyle.ArrowStyle.BodyLen = 6; lineStyle.ArrowStyle.HeadWidth = 8; lineStyle.ArrowStyle.HeadLen = 10; lineStyle.ArrowStyle.OutlineVisible = true; lineStyle.ArrowStyle.OutlineColor = Color.Red; lineStyle.ArrowStyle.Speed = lineStyle.ArrowStyle.Speed / 2; } lineStyle.ArrowVisible = true; lineStyle.ArrowStyle.Play(); } } } globeControl1.Refresh(); } } /// <summary> /// 上下游追踪 功能 /// </summary> /// <param name="bTraceUp"></param> private void AffectedPipeLine(Boolean bTraceUp) { if (globeControl1.Globe.SelectedObject == null) { MessageBox.Show("请点击“编辑”—“选中对象”选择一条线!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } GSOFeature selLineFeature = globeControl1.Globe.SelectedObject; if (selLineFeature.Geometry == null || selLineFeature.Geometry.Type != EnumGeometryType.GeoPolyline3D) { MessageBox.Show("请点击“编辑”—“选中对象”选择一条线!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (globeControl1.Globe.SelectedObjectLayer == null) { return; } GSODataset curCAYDataset = globeControl1.Globe.SelectedObjectLayer.Dataset; if (curCAYDataset == null || curCAYDataset.DataSource == null) { return; } string srName = curCAYDataset.Name; GSONetworkDataset curCAYNDataset = curCAYDataset.DataSource.GetDatasetByName(srName + "Network") as GSONetworkDataset; if (curCAYNDataset == null) { return; } int[] arryResID; curCAYNDataset.TraceUpDownAnalysis(selLineFeature.ID, out arryResID, bTraceUp, false, true); m_AffectedPipeLines = globeControl1.Globe.SelectedObjectLayer.GetFeaturesByIDs(arryResID); if (m_AffectedPipeLines == null || m_AffectedPipeLines.Length < 1) { } else { int nCount = m_AffectedPipeLines.Length; for (int i = 0; i < nCount; i++) { m_AffectedPipeLines[i].HighLight = true; } globeControl1.Refresh(); } } /// <summary> /// 下游追踪 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void TraceDownMenuItem_Click(object sender, EventArgs e) { //日志记录 LogManager.saveLog(Utility.userName, this.TraceDownMenuItem.Text); ClearUpDownTraceAnalysis(); NetworkTraceUpDown(false); } /// <summary> /// 清除上下游追踪结果 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> //private void buttonItem58_Click(object sender, EventArgs e) //{ // //日志记录 // LogManager.saveLog(Utility.userName, this.buttonItem58.Text); // ClearUpDownTraceAnalysis(); //} /// <summary> /// 显示全球 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem12_Click(object sender, EventArgs e) { //日志记录 LogManager.saveLog(Utility.userName, this.buttonItem12.Text); GSOCameraState camerastate = new GSOCameraState(); camerastate.Longitude = 103.0458; camerastate.Latitude = 37.8900; camerastate.Distance = 13726042.91; camerastate.Heading = -14.7191750305935; camerastate.Tilt = -0.121060930867518; camerastate.Altitude = -454.784417188726; camerastate.AltitudeMode = EnumAltitudeMode.Absolute; globeControl1.Globe.JumpToCameraState(camerastate); } /// <summary> /// 删除模型 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnDelPipeLine_Click(object sender, EventArgs e) { //日志记录 LogManager.saveLog(Utility.userName, this.btnDeletePW.Text); if (globeControl1.Globe.SelObjectCount > 0) { for(int i = 0;i<globeControl1.Globe.SelObjectCount;i++) { GSOFeature f = null; GSOLayer layer = null; globeControl1.Globe.GetSelectObject(i,out f,out layer); if (f != null) { f.Delete(); if (layer != null) { globeControl1.Globe.AddToEditHistroy(layer, f, EnumEditType.Delete); } globeControl1.Refresh(); } } } else { MessageBox.Show("请选中要删除的模型!", "提示"); } } /// <summary> /// 流向分析 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem14_Click(object sender, EventArgs e) { //日志记录 LogManager.saveLog(Utility.userName, this.buttonItem14.Text); FrmFlow frm = new FrmFlow(globeControl1,m_PipelineLayerNames); frm.Show(this); } /// <summary> /// 显示流向 功能 /// </summary> /// <param name="sender"></param> /// <param name="pipelineNameCN"></param> /// <param name="bShow"></param> private void Flow(object sender, string pipelineNameCN,bool bShow) { GSOFeatureLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(pipelineNameCN) as GSOFeatureLayer; GSOFeatures feats = layer.GetAllFeatures(); for (int i = 0; i < feats.Length; i++) { GSOFeature feat = feats[i]; GSOLineStyle3D lineStyle = feat.Geometry.Style as GSOLineStyle3D; if (lineStyle != null) { if (lineStyle.ArrowStyle == null) { lineStyle.ArrowStyle = new GSOArrowStyle(); lineStyle.ArrowStyle.BodyWidth = 2; lineStyle.ArrowStyle.BodyLen = 6; lineStyle.ArrowStyle.HeadWidth = 8; lineStyle.ArrowStyle.HeadLen = 10; lineStyle.ArrowStyle.OutlineVisible = true; lineStyle.ArrowStyle.OutlineColor = Color.Red; lineStyle.ArrowStyle.Speed = lineStyle.ArrowStyle.Speed / 2; lineStyle.ArrowStyle.Play(); } lineStyle.ArrowVisible = bShow; layerTree.SelectedNode = null; } } globeControl1.Globe.Refresh(); } /// <summary> /// 连通性分析 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnLTAnalysis_Click(object sender, EventArgs e) { //日志记录 LogManager.saveLog(Utility.userName, this.btnLTAnalysis.Text); if (globeControl1.Globe.SelObjectCount < 2) { MessageBox.Show("请选中至少两个管线!!"); btnLTAnalysis.Checked = false; return; } ClearConnexityAnalysis(); globeControl1.Globe.GetSelectObject(0, out m_ConnexityAnalysisFirstFeature, out m_ConnexityAnalysisFirstLayer); globeControl1.Globe.GetSelectObject(1, out m_ConnexityAnaylsisSecondFeature, out m_COnnexityAnalysisSecondLayer); GSOGeoPolyline3D line1 = m_ConnexityAnalysisFirstFeature.Geometry as GSOGeoPolyline3D; GSOGeoPolyline3D line2 = m_ConnexityAnaylsisSecondFeature.Geometry as GSOGeoPolyline3D; if (line1 == null || line2 == null) { MessageBox.Show("请选择管线!!"); btnLTAnalysis.Checked = false; return; } GSOPipeLineStyle3D pipeStyle1 = line1.Style as GSOPipeLineStyle3D; GSOPipeLineStyle3D pipeStyle2 = line2.Style as GSOPipeLineStyle3D; if (pipeStyle1 == null || pipeStyle2 == null) { MessageBox.Show("请选择管线!!"); btnLTAnalysis.Checked = false; return; } if (!m_ConnexityAnalysisFirstLayer.IsSameInnerObject(m_COnnexityAnalysisSecondLayer)) { MessageBox.Show("不在同一个图层!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); btnLTAnalysis.Checked = false; ClearConnexityAnalysis(); } else { ConnexityAnalysis(); } } /// <summary> /// 关阀分析 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnGFFX_Click(object sender, EventArgs e) { //日志记录 LogManager.saveLog(Utility.userName, this.btnGFFX.Text); ClearCloseValvesAnalysis(); if (globeControl1.Globe.SelObjectCount < 1) { MessageBox.Show("请选中至少一根管线!!"); btnGFFX.Checked = false; return; } GSOLayer resLayer = null; GSOFeature resFeature = null; globeControl1.Globe.GetSelectObject(0, out resFeature, out resLayer); GSOGeoPolyline3D line1 = resFeature.Geometry as GSOGeoPolyline3D; if (line1 == null) { MessageBox.Show("请选择管线!!"); return; } GSOPipeLineStyle3D pipeStyle1 = line1.Style as GSOPipeLineStyle3D; if (pipeStyle1 == null) { MessageBox.Show("请选择管线!!"); return; } GSOPoint3d resIntersetPoint = new GSOPoint3d(); if (NetworkCloseValvesAnalysis(resFeature, resIntersetPoint, resLayer)) { //btnGFFX.Checked = false; globeControl1.Globe.Action = EnumAction3D.ActionNull; btnGFFX.Checked = false; } } FrmCloseValves frm; /// <summary> /// 关阀分析 功能 /// </summary> /// <param name="lineFeature"></param> /// <param name="pntBreak"></param> /// <param name="lineLayer"></param> /// <returns></returns> private bool NetworkCloseValvesAnalysis(GSOFeature lineFeature, GSOPoint3d pntBreak, GSOLayer lineLayer) { if (lineLayer == null || lineFeature == null || lineFeature.Geometry == null || lineFeature.Geometry.Type != EnumGeometryType.GeoPolyline3D) { return false; } GSODataset curCAYDataset = lineLayer.Dataset; if (curCAYDataset == null || curCAYDataset.DataSource == null) { MessageBox.Show("该图层不是要素图层!", "提示"); return false; } string srName = curCAYDataset.Name; GSONetworkDataset curCAYNDataset = curCAYDataset.DataSource.GetDatasetByName(srName + "Network") as GSONetworkDataset; if (curCAYNDataset == null) { MessageBox.Show("该图层没有创建网络拓扑,请先创建网络拓扑信息再进行分析!", "提示"); return false; } ClearCloseValvesAnalysis(); int[] arryResNodeID = null; int[] arryResValveID = null; try { curCAYNDataset.CloseValveAnalysis(lineFeature.ID, out arryResNodeID, out arryResValveID, false, true); } catch (Exception e) { } string valveName = lineLayer.Caption; valveName = valveName.Substring(0, valveName.IndexOf("管线")); GSOLayer valveLayer = globeControl1.Globe.Layers[valveName + "阀门"]; if (valveLayer == null) { MessageBox.Show("和选中对象所在管线图层相关联的阀门图层不存在!", "提示"); return false; } m_CloseValvesAnalyResFeatures = valveLayer.GetFeaturesByIDs(arryResValveID);// curCAYNDataset.NodeDataset.GetFeaturesByIDs(arryResValveID); if (m_CloseValvesAnalyResFeatures == null || m_CloseValvesAnalyResFeatures.Length < 1) { MessageBox.Show("没有找到要关闭的阀门!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); if (frm != null) { frm.Close(); } } else { int nCount = m_CloseValvesAnalyResFeatures.Length; if (nCount > 0) { frm = FrmCloseValves.getForm(globeControl1, m_CloseValvesAnalyResFeatures, m_CloseValvesList); if (!frm.Visible) { frm.Show(this); } } } return true; } FrmBoosterValvers frmbooster = null; /// <summary> /// 阀门分析 功能 /// </summary> /// <param name="lineFeature"></param> /// <param name="pntBreak"></param> /// <param name="lineLayer"></param> /// <returns></returns> private bool NetworkBoosterValvesAnalysis(GSOFeature lineFeature, GSOPoint3d pntBreak, GSOLayer lineLayer) { if (lineLayer == null || lineFeature == null || lineFeature.Geometry == null || lineFeature.Geometry.Type != EnumGeometryType.GeoPolyline3D) { return false; } GSODataset curCAYDataset = lineLayer.Dataset; if (curCAYDataset == null || curCAYDataset.DataSource == null) { return false; } string srName = curCAYDataset.Name; GSONetworkDataset curCAYNDataset = curCAYDataset.DataSource.GetDatasetByName(srName + "Network") as GSONetworkDataset; if (curCAYNDataset == null) { MessageBox.Show("该图层没有创建网络拓扑,请先创建网络拓扑信息再进行分析!", "提示"); return false; } ClearBoosterValvesAnalysis(); ClearAffectedPipeLine(); int[] arryResNodeID = null; int[] arryResValveID = null; try { curCAYNDataset.CloseValveAnalysis(lineFeature.ID, out arryResNodeID, out arryResValveID, false, true); } catch (Exception e) { } //目前只有燃气管线 有阀门 string valveName = lineLayer.Name; valveName = valveName.Substring(0,valveName.IndexOf("管线")); GSOLayer valveLayer = globeControl1.Globe.Layers[valveName + "阀门"]; if (valveLayer == null) { MessageBox.Show("和选中对象所在管线图层相关联的阀门图层不存在!", "提示"); return false; } m_BoosterValvesAnalyResFeatures = valveLayer.GetFeaturesByIDs(arryResValveID); if (m_BoosterValvesAnalyResFeatures == null || m_BoosterValvesAnalyResFeatures.Length < 1) { MessageBox.Show("没有找到要关闭的阀门!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); if (frmbooster != null) { frmbooster.Close(); } } else { int nCount = m_BoosterValvesAnalyResFeatures.Length; if (nCount > 0) { AffectedPipeLine(false); frmbooster = FrmBoosterValvers.getForm(globeControl1, m_BoosterValvesAnalyResFeatures, m_BoosterValvesList, m_AffectedPipeLines); frmbooster.setLstValvesName(); if (!frmbooster.Visible) { frmbooster.Show(this); } } } return true; } /// <summary> /// 清除分析结果 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem17_Click(object sender, EventArgs e) // { globeControl1.Globe.MemoryLayer.RemoveAllFeature(); globeControl1.Globe.ClearAnalysis(); // 清除净距分析结果 buttonX2_Click(null, null); buttonX8_Click(null, null); buttonX15_Click(null, null); buttonX16_Click(null, null); buttonClearAnalysisResult_Click(null, null); clearFeatureHighLight();//取消管线高亮 ClearConnexityAnalysis();//清除连通性分析 ClearCloseValvesAnalysis();//清除阀门分析 //清除管线间距分析 if (disFeature != null) { if (disFeature.ID != 0) { globeControl1.Globe.MemoryLayer.RemoveFeatureByID(disFeature.ID); } } if (featureDis != null) { if (featureDis.ID != 0) { globeControl1.Globe.MemoryLayer.RemoveFeatureByID(featureDis.ID); } } GSOFeatures feats = globeControl1.Globe.MemoryLayer.GetFeatureByName("粒子要素", true); if (feats.Length > 0) globeControl1.Globe.MemoryLayer.RemoveFeatureByID(feats[0].ID); globeControl1.Globe.UnderGroundFloor.Visible = false;//隐藏地下网格线 ClearUpDownTraceAnalysis(); //清除上下游分析 globeControl1.Globe.RemoveAllPits();//清除所有坑 globeControl1.Globe.Action = EnumAction3D.ActionNull; } /// <summary> /// 垂直净距分析 功能界面中的 选择图层复选框 选中状态改变事件处理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void checkBoxX2_CheckedChanged(object sender, EventArgs e) { clearFeatureHighLight(); comboBoxEx1.Enabled = checkBoxX2.Checked; if (checkBoxX2.Checked) { globeControl1.Globe.Action = EnumAction3D.ActionNull; trackflag = ""; dataGridViewX2.Rows.Clear(); dataGridViewX3.Rows.Clear(); comboBoxEx1.SelectedIndex = -1; } globeControl1.Globe.ClearAnalysis(); layerTemp.RemoveAllFeature(); globeControl1.Refresh(); } /// <summary> /// 水平净距分析 功能界面中的 选择图层复选框 选中状态改变事件处理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void checkBoxX2_CheckedChanged_shuiping(object sender, EventArgs e) { clearFeatureHighLight();//清除高亮 comboBoxEx4.Enabled = checkBoxX8.Checked; if (checkBoxX8.Checked) { globeControl1.Globe.Action = EnumAction3D.ActionNull; trackflag = ""; dataGridViewX8.Rows.Clear(); dataGridViewX9.Rows.Clear(); comboBoxEx4.SelectedIndex = -1; } globeControl1.Globe.ClearAnalysis(); layerTemp.RemoveAllFeature(); globeControl1.Refresh(); } /// <summary> /// 垂直净距分析 功能界面中的 选择管线复选框 选中状态改变事件处理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void checkBoxX1_CheckedChanged(object sender, EventArgs e) { clearFeatureHighLight(); if (checkBoxX1.Checked) { globeControl1.Globe.ClearAnalysis(); layerTemp.RemoveAllFeature(); globeControl1.Refresh(); comboBoxEx1.Enabled = false; dataGridViewX2.Rows.Clear(); dataGridViewX3.Rows.Clear(); trackflag = "vertical"; globeControl1.Globe.Action = EnumAction3D.SelectObject; } else { comboBoxEx1.Enabled = true; } } /// <summary> /// 水平净距分析 功能界面中的 选择管线复选框 选中状态改变事件处理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void checkBoxX1_CheckedChanged_shuiping(object sender, EventArgs e) { clearFeatureHighLight();//清除高亮 if (checkBoxX7.Checked) { globeControl1.Globe.ClearAnalysis(); layerTemp.RemoveAllFeature(); globeControl1.Refresh(); comboBoxEx4.Enabled = false; dataGridViewX8.Rows.Clear(); dataGridViewX9.Rows.Clear(); trackflag = "horizontal"; globeControl1.Globe.Action = EnumAction3D.SelectObject; } else { comboBoxEx4.Enabled = true; } } GSOFeatures feats_vertical = new GSOFeatures(); /// <summary> /// 垂直净距分析 功能界面中的 选择图层下拉框 选中项改变 事件处理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void comboBoxEx1_SelectedIndexChanged(object sender, EventArgs e) { if (comboBoxEx1.SelectedIndex > -1) { dataGridViewX2.Rows.Clear(); dataGridViewX3.Rows.Clear(); listBox1.Items.Clear(); GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(comboBoxEx1.SelectedItem.ToString()); if (layer == null) return; GSOFeatureLayer flayer = layer as GSOFeatureLayer; GSOFeatureDataset fdataset = flayer.Dataset as GSOFeatureDataset; GSOFeatures feats = flayer.GetAllFeatures(); for (int i = 0; i < feats.Length; i++) { int idx = dataGridViewX2.Rows.Add(); dataGridViewX2.Rows[idx].Cells[0].Value = comboBoxEx1.SelectedItem.ToString(); dataGridViewX2.Rows[idx].Cells[1].Value = feats[i].Name; } } } /// <summary> /// 水平净距分析 功能界面中的 选择图层下拉框 选中项改变 事件处理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void comboBoxEx1_SelectedIndexChanged_shuiping(object sender, EventArgs e) { if (comboBoxEx4.SelectedIndex > -1) { dataGridViewX8.Rows.Clear(); dataGridViewX9.Rows.Clear(); listBox3.Items.Clear(); GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(comboBoxEx4.SelectedItem.ToString()); if (layer == null) return; GSOFeatureLayer flayer = layer as GSOFeatureLayer; GSOFeatureDataset fdataset = flayer.Dataset as GSOFeatureDataset; GSOFeatures feats = flayer.GetAllFeatures(); for (int i = 0; i < feats.Length; i++) { int idx = dataGridViewX8.Rows.Add(); dataGridViewX8.Rows[idx].Cells[0].Value = comboBoxEx4.SelectedItem.ToString(); dataGridViewX8.Rows[idx].Cells[1].Value = feats[i].Name; } } } Dictionary<string, int> featCount = new Dictionary<string, int>(); Dictionary<string, double> featLenth = new Dictionary<string, double>(); Dictionary<string, GSOPoint3d> m_FeaturesWithBianhao = new Dictionary<string, GSOPoint3d>();//记录编号和对应的标注点的位置 GSOFeatures polygonJingJuAnalysises = new GSOFeatures(); /// <summary> /// 垂直净距分析 功能界面中的 开始分析按钮 事件处理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonX1_Click(object sender, EventArgs e) { if (!checkBoxX1.Checked && !checkBoxX2.Checked) { MessageBox.Show("请确定是选择管线还是选择图层!", "提示"); return; } if (textBoxX2.Text.Trim() == "") { MessageBox.Show("净距标准不能为空!", "提示"); return; } double dJingJuBiaoZhun = 0.0; if (!double.TryParse(textBoxX2.Text.Trim(), out dJingJuBiaoZhun)) { MessageBox.Show("请输入正确的净距标准!", "提示"); return; } if (dataGridViewX2.Rows.Count > 0) { featCount.Clear(); featLenth.Clear(); listBox1.Items.Clear(); layerTemp.RemoveAllFeature(); polygonJingJuAnalysises.RemoveAll(); clearFeatureHighLight(); dataGridViewX3.Rows.Clear(); m_FeaturesWithBianhao.Clear(); this.Cursor = Cursors.WaitCursor; if (checkBoxX1.Checked) // 选择管线 { for (int i = 0; i < dataGridViewX2.Rows.Count; i++) { GSOFeature selectedFeature = dataGridViewX2.Rows[i].Tag as GSOFeature; if (selectedFeature != null) { selectState = 1; VerticalDistanceAnalysis("垂直净距分析", selectedFeature, m_PipelineLayerNames, dJingJuBiaoZhun, 0.0); } } } else if(checkBoxX2.Checked) // 选择图层 { if (comboBoxEx1.SelectedItem == null) { MessageBox.Show("请选择一个图层!","提示"); return; } GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(comboBoxEx1.SelectedItem.ToString()); if (layer == null) return; GSOFeatureLayer flayer = layer as GSOFeatureLayer; GSOFeatureDataset fdataset = flayer.Dataset as GSOFeatureDataset; GSOFeatures feats = flayer.GetAllFeatures(); for (int i = 0; i < feats.Length; i++) { selectState = 1; VerticalDistanceAnalysis("垂直净距分析", feats[i], m_PipelineLayerNames, dJingJuBiaoZhun, 0.0); } } if (featCount.Count > 0) { for (int i = 0; i < m_PipelineLayerNames.Count; i++) { if (featCount.ContainsKey(m_PipelineLayerNames[i]) && featLenth.ContainsKey(m_PipelineLayerNames[i])) { listBox1.Items.Add(m_PipelineLayerNames[i] + ":" + featCount[m_PipelineLayerNames[i]] + "条,共" + featLenth[m_PipelineLayerNames[i]].ToString("0.00") + "米"); } } } if(dataGridViewX3.Rows.Count == 0&&selectState==1) { MessageBox.Show("没有不符合净距标准的管线!", "提示"); } } else { MessageBox.Show("请选中要进行垂直净距分析的管线!", "提示"); } globeControl1.Refresh(); this.Cursor = Cursors.Default; } /// <summary> /// 在指定的两点组成的线的中间添加一个marker对象,并将marker对象添加到指定的图层中 /// </summary> /// <param name="markerLayer"></param> /// <param name="pntIntersect1"></param> /// <param name="pntIntersect2"></param> /// <param name="distance"></param> /// <returns></returns> private GSOPoint3d LabelVerticalDistance(GSOLayer markerLayer, GSOPoint3d pntIntersect1,GSOPoint3d pntIntersect2,double distance,bool markerVisible) { if (pntIntersect1 == null || pntIntersect2 == null) { return new GSOPoint3d(); } GSOGeoPolyline3D disline = new GSOGeoPolyline3D(); GSOPoint3ds point3ds = new GSOPoint3ds(); point3ds.Add(pntIntersect1); point3ds.Add(pntIntersect2); disline.AddPart(point3ds); GSOSimpleLineStyle3D style = new GSOSimpleLineStyle3D(); //创建线的风格 //设置透明度及颜色,FromArgb()中的四个参数分别为alpha、red、green、blue,取值范围为0到255 style.LineColor = Color.GreenYellow; style.LineWidth = 3; //设置线的宽度为3 style.VertexVisible = true; //显示线的节点 disline.Style = style; //把风格添加到线上 disline.AltitudeMode = EnumAltitudeMode.Absolute; GSOFeature line = new GSOFeature(); line.Geometry = disline; GSOGeoMarker dismarker = new GSOGeoMarker(); dismarker.X = pntIntersect1.X; dismarker.Y = pntIntersect1.Y; dismarker.Z = (pntIntersect1.Z + pntIntersect2.Z) / 2; string disStr = distance.ToString("0.00"); if (disStr != "0.00") { dismarker.Text = distance.ToString("0.00") + "米"; } else { dismarker.Text = "交叉"; } dismarker.AltitudeMode = EnumAltitudeMode.Absolute; GSOMarkerStyle3D styleMarker = new GSOMarkerStyle3D(); GSOTextStyle styleText = new GSOTextStyle(); styleText.IsSizeFixed = true; styleText.ForeColor = Color.White; styleText.FontSize = 20; styleMarker.TextStyle = styleText; dismarker.Style = styleMarker; GSOFeature marker = new GSOFeature(); marker.Geometry = dismarker; line.Visible = marker.Visible = markerVisible; markerLayer.AddFeature(line); markerLayer.AddFeature(marker); return dismarker.Position; } /// <summary> /// 计算指定feature对象与除了该feature所在图层之外的 所有管线图层中的所有feature对象 的垂直距离 并在表格中记录符合要求的管线 /// </summary> /// <param name="type"></param> /// <param name="caption"></param> /// <param name="feat"></param> /// <param name="dis"></param> private void VerticalDistanceAnalysis(string type, GSOFeature selectedFeature,List<string> _pipelineLayerNames, double verticalDistance,double horizontalDistance) { if (selectedFeature == null) { selectState = 0; MessageBox.Show("请选择一条管线!"); return; } GSOGeoPolyline3D line1 = selectedFeature.Geometry as GSOGeoPolyline3D; if (line1 == null) { selectState = 0; MessageBox.Show("请选择一条管线!"); return; } GSOGeoPolygon3D polygon = line1.CreateBuffer(0.1, true, 5, true, false); string caption = selectedFeature.Dataset.Caption; GSOPoint3d pntIntersect1 = new GSOPoint3d(); GSOPoint3d pntIntersect2 = new GSOPoint3d(); GSOPoint3d pntProIntersect1 = new GSOPoint3d(); GSOPoint3d pntProIntersect2 = new GSOPoint3d(); for (int i = 0; i < _pipelineLayerNames.Count; i++) { if (caption == _pipelineLayerNames[i]) { continue; } GSOLayer layer2 = globeControl1.Globe.Layers.GetLayerByCaption(_pipelineLayerNames[i]); if (layer2 != null) { GSOFeatureLayer flayer2 = layer2 as GSOFeatureLayer; GSOFeatureDataset fdataset2 = flayer2.Dataset as GSOFeatureDataset; GSOFeatures feats2 = Polygon_Contain_PointAnalysis(polygon, _pipelineLayerNames[i]); for (int j = 0; j < feats2.Length; j++) { GSOFeature feat2 = feats2[j]; GSOGeoPolyline3D line2 = feats2[j].Geometry as GSOGeoPolyline3D; if (line2 == null) continue; GSOPipeLineStyle3D pipeStyle1 = line1.Style as GSOPipeLineStyle3D; GSOPipeLineStyle3D pipeStyle2 = line2.Style as GSOPipeLineStyle3D; if (pipeStyle1 == null || pipeStyle2 == null) continue; double dDist = -1; dDist = globeControl1.Globe.Analysis3D.ComputeHorizonDistance(line1, line2, out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); //dDist = globeControl1.Globe.Analysis3D.ComputeVerticalDistance(line1, line2, out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); if (dDist > -1) { dDist = Math.Abs(pntIntersect1.Z - pntIntersect2.Z) - pipeStyle1.Radius - pipeStyle2.Radius;//获得净距值 if (dDist < verticalDistance) { int idx = -1; GSOPoint3d markerPosition = new GSOPoint3d(); if (type == "垂直净距分析") { feat2.HighLight = true; markerPosition = LabelVerticalDistance(layerTemp, pntIntersect1, pntIntersect2, dDist,true); idx = dataGridViewX3.Rows.Add(); dataGridViewX3.Rows[idx].Cells[0].Value = caption; dataGridViewX3.Rows[idx].Cells[1].Value = selectedFeature.Name; dataGridViewX3.Rows[idx].Cells[2].Value = layer2.Caption; dataGridViewX3.Rows[idx].Cells[3].Value = feat2.Name; dataGridViewX3.Rows[idx].Cells[4].Value = dDist.ToString("0.00"); } else if (type == "碰撞分析") { feat2.HighLight = true; markerPosition = LabelVerticalDistance(layerTemp, pntIntersect1, pntIntersect2, dDist,false); selectedFeature.HighLight = true; idx = dataGridViewX5.Rows.Add(); dataGridViewX5.Rows[idx].Cells[0].Value = dataGridViewX4.Rows[0].Cells[0].Value.ToString(); dataGridViewX5.Rows[idx].Cells[1].Value = selectedFeature.Name; dataGridViewX5.Rows[idx].Cells[2].Value = layer2.Caption; dataGridViewX5.Rows[idx].Cells[3].Value = feat2.Name; } else if (type == "间距分析") { GSOGeoPolygon3D polygonSpacing = line2.CreateBuffer(horizontalDistance, true, 5, false, false); if (polygonSpacing != null) { GSOFeatures horizontalFeatures = layer2.FindFeaturesInPolygon(polygonSpacing, false); if (horizontalFeatures != null) { for (int m = 0; m < horizontalFeatures.Length; m++) { GSOFeature horizontalFeature = horizontalFeatures[m]; if (horizontalFeature != null && horizontalFeature.ID == feat2.ID) { feat2.HighLight = true; idx = dataGridViewAnalysisResult.Rows.Add(); dataGridViewAnalysisResult.Rows[idx].Tag = feat2; dataGridViewAnalysisResult.Rows[idx].Cells[0].Value = dataGridViewLineList.Rows[0].Cells[0].Value.ToString(); dataGridViewAnalysisResult.Rows[idx].Cells[1].Value = selectedFeature.Name; dataGridViewAnalysisResult.Rows[idx].Cells[2].Value = layer2.Caption; dataGridViewAnalysisResult.Rows[idx].Cells[3].Value = feat2.Name; dataGridViewAnalysisResult.Rows[idx].Cells[4].Value = dDist.ToString("0.00"); dataGridViewAnalysisResult.Rows[idx].Cells[5].Value = horizontalDistance.ToString("0.00"); break; } } } } //double verticalDis = dDist; //dDist = globeControl1.Globe.Analysis3D.ComputeVerticalDistance(line1, line2, out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); //if (dDist > -1) //{ // dDist = Math.Abs(pntIntersect1.Z - pntIntersect2.Z) - pipeStyle1.Radius - pipeStyle2.Radius; // if (dDist < horizontalDistance) // { // feat2.HighLight = true; // idx = dataGridViewAnalysisResult.Rows.Add(); // dataGridViewAnalysisResult.Rows[idx].Tag = feat2; // dataGridViewAnalysisResult.Rows[idx].Cells[0].Value = dataGridViewLineList.Rows[0].Cells[0].Value.ToString(); // dataGridViewAnalysisResult.Rows[idx].Cells[1].Value = selectedFeature.Name; // dataGridViewAnalysisResult.Rows[idx].Cells[2].Value = layer2.Caption; // dataGridViewAnalysisResult.Rows[idx].Cells[3].Value = feat2.Name; // dataGridViewAnalysisResult.Rows[idx].Cells[4].Value = verticalDis.ToString("0.00"); // dataGridViewAnalysisResult.Rows[idx].Cells[5].Value = dDist.ToString("0.00"); // } //} } if (m_FeaturesWithBianhao.ContainsKey(selectedFeature.Name + "-" + feats2[j].Name) == false) { m_FeaturesWithBianhao.Add(selectedFeature.Name + "-" + feats2[j].Name, markerPosition);//添加飞行位置记录 } if (featCount.ContainsKey(layer2.Caption)) { featCount[layer2.Caption] = featCount[layer2.Caption] + 1; } else { featCount.Add(layer2.Caption, 1); } if (featLenth.ContainsKey(layer2.Caption)) { featLenth[layer2.Caption] = featLenth[layer2.Caption] + line2.GetSpaceLength(true, 6378137); } else { featLenth.Add(layer2.Caption, line2.GetSpaceLength(true, 6378137)); } } } line2.ReleaseInnerPointer(); feat2.ReleaseInnerPointer(); } feats2.ReleaseInnerPointer(); } } line1.ReleaseInnerPointer(); selectedFeature.ReleaseInnerPointer(); } /// <summary> /// 垂直净距分析中 表格行的 双击定位 功能。 与覆土分析的实现方法不同,主要原因是需要标注垂距 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void dataGridViewX3_MouseDoubleClick(object sender, MouseEventArgs e) // { if (e.Button == MouseButtons.Left) { DataGridView.HitTestInfo hittestinfo = dataGridViewX3.HitTest(e.X, e.Y); if (hittestinfo.RowIndex > -1) { string key = dataGridViewX3.Rows[hittestinfo.RowIndex].Cells[1].Value.ToString().Trim() + "-" + dataGridViewX3.Rows[hittestinfo.RowIndex].Cells[3].Value.ToString().Trim(); if (m_FeaturesWithBianhao.ContainsKey(key)) { globeControl1.Globe.JumpToPosition(m_FeaturesWithBianhao[key], EnumAltitudeMode.Absolute, 5); } } } } /// <summary> /// 水平净距分析 功能界面中 开始分析按钮 的事件处理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonX1_Click_shuiping(object sender, EventArgs e) // { if (!checkBoxX7.Checked && !checkBoxX8.Checked) { MessageBox.Show("请确定是选择管线还是选择图层!", "提示"); return; } if (textBoxX4.Text.Trim() == "") { MessageBox.Show("净距标准不能为空!", "提示"); return; } double dJingJuBiaoZhun = 0; if (!double.TryParse(textBoxX4.Text.Trim(), out dJingJuBiaoZhun)) { MessageBox.Show("请输入正确的净距标准!", "提示"); return; } if (dataGridViewX8.Rows.Count > 0) { featCount.Clear(); featLenth.Clear(); listBox3.Items.Clear(); layerTemp.RemoveAllFeature(); polygonJingJuAnalysises.RemoveAll(); clearFeatureHighLight(); dataGridViewX9.Rows.Clear(); this.Cursor = Cursors.WaitCursor; if (checkBoxX7.Checked) //选择管线 { for (int i = 0; i < dataGridViewX8.Rows.Count; i++) { GSOFeature selectedFeature = dataGridViewX8.Rows[i].Tag as GSOFeature; if (selectedFeature != null) { selectState = 1; HorizontalDistanceAnalysis(selectedFeature, m_PipelineLayerNames, dJingJuBiaoZhun); } } } else if (checkBoxX8.Checked) //选择图层 { GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(comboBoxEx4.SelectedItem.ToString()); if (layer == null) return; GSOFeatureLayer flayer = layer as GSOFeatureLayer; GSOFeatureDataset fdataset = flayer.Dataset as GSOFeatureDataset; GSOFeatures feats = flayer.GetAllFeatures(); for (int i = 0; i < feats.Length; i++) { HorizontalDistanceAnalysis(feats[i],m_PipelineLayerNames, dJingJuBiaoZhun); } } if (featCount.Count > 0) //统计结果 { for (int i = 0; i < m_PipelineLayerNames.Count; i++) { if (featCount.ContainsKey(m_PipelineLayerNames[i]) && featLenth.ContainsKey(m_PipelineLayerNames[i])) { listBox3.Items.Add(m_PipelineLayerNames[i] + ":" + featCount[m_PipelineLayerNames[i]] + "条,共" + featLenth[m_PipelineLayerNames[i]].ToString("0.00") + "米"); } } } if (dataGridViewX9.Rows.Count == 0 && selectState == 1) { MessageBox.Show("没有不符合净距标准的管线!", "提示"); } } else { MessageBox.Show("请选中要进行水平净距分析的管线!", "提示"); } globeControl1.Refresh(); this.Cursor = Cursors.Default; } /// <summary> /// 计算指定feature对象与除了该feature所在图层之外的 所有管线图层中的所有feature对象 的水平距离 并记录符合要求的管线 功能 /// </summary> /// <param name="type"></param> /// <param name="caption"></param> /// <param name="feat"></param> /// <param name="dis"></param> private void HorizontalDistanceAnalysis( GSOFeature selectedFeature,List<string> _pipelineLayerNames, double dis) { if (selectedFeature == null) { selectState = 0; MessageBox.Show("请选择一条管线!"); return; } GSOGeoPolyline3D line1 = selectedFeature.Geometry as GSOGeoPolyline3D; if (line1 == null) { selectState = 0; MessageBox.Show("请选择一条管线!"); return; } string caption = selectedFeature.Dataset.Caption; GSOGeoPolygon3D polygon = line1.CreateBuffer(dis, true, 5, true, false); GSOFeature new_feat = new GSOFeature(); new_feat.Geometry = polygon; polygonJingJuAnalysises.Add(new_feat); layerTemp.AddFeature(new_feat); for (int i = 0; i < _pipelineLayerNames.Count; i++) { if (caption == _pipelineLayerNames[i]) { continue; } GSOLayer layer2 = globeControl1.Globe.Layers.GetLayerByCaption(_pipelineLayerNames[i]); if (layer2 != null) { GSOFeatureLayer flayer2 = layer2 as GSOFeatureLayer; GSOFeatureDataset fdataset2 = flayer2.Dataset as GSOFeatureDataset; GSOFeatures feats2 = Polygon_Contain_PointAnalysis(polygon, _pipelineLayerNames[i]); for (int j = 0; j < feats2.Length; j++) { GSOFeature feat2 = feats2[j]; GSOGeoPolyline3D line2 = feats2[j].Geometry as GSOGeoPolyline3D; if (line2 == null) { continue; } GSOPipeLineStyle3D pipeStyle1 = line1.Style as GSOPipeLineStyle3D; GSOPipeLineStyle3D pipeStyle2 = line2.Style as GSOPipeLineStyle3D; if (pipeStyle1 == null || pipeStyle2 == null) { continue; } feat2.HighLight = true; int idx = dataGridViewX9.Rows.Add(); dataGridViewX9.Rows[idx].Tag = feat2; dataGridViewX9.Rows[idx].Cells[0].Value = caption; dataGridViewX9.Rows[idx].Cells[1].Value = selectedFeature.Name; dataGridViewX9.Rows[idx].Cells[2].Value = layer2.Caption; dataGridViewX9.Rows[idx].Cells[3].Value = feats2[j].Name; dataGridViewX9.Rows[idx].Cells[4].Value = dis.ToString("0.00"); if (featCount.ContainsKey(layer2.Caption)) { featCount[layer2.Caption] = featCount[layer2.Caption] + 1; } else { featCount.Add(layer2.Caption, 1); } if (featLenth.ContainsKey(layer2.Caption)) { featLenth[layer2.Caption] = featLenth[layer2.Caption] + line2.GetSpaceLength(true, 6378137); } else { featLenth.Add(layer2.Caption, line2.GetSpaceLength(true, 6378137)); } } } } } /// <summary> /// 水平净距分析 功能界面中 表格的 双击定位 功能 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void dataGridViewX9_MouseDoubleClick(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { DataGridView.HitTestInfo hittestinfo = dataGridViewX9.HitTest(e.X, e.Y); if (hittestinfo.RowIndex > -1) { GSOFeature rowFeature = dataGridViewX9.Rows[hittestinfo.RowIndex].Tag as GSOFeature; if (rowFeature != null) { if (rowFeature.Geometry != null && rowFeature.Geometry.Type == EnumGeometryType.GeoPolyline3D) { GSOGeoPolyline3D line = rowFeature.Geometry as GSOGeoPolyline3D; double length = line.GetSpaceLength(true, 6378137); GSOGeoPolyline3D lineLine = line.GetSegment(0, length / 2); GSOPoint3d point3d = lineLine[lineLine.PartCount - 1][lineLine[lineLine.PartCount - 1].Count - 1]; globeControl1.Globe.JumpToPosition(point3d, EnumAltitudeMode.Absolute, 5); } else { globeControl1.Globe.JumpToFeature(rowFeature, 5); } } } } } /// <summary> /// 碰撞分析 功能界面中 开始分析按钮 事件处理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonX5_Click(object sender, EventArgs e) { if (!checkBoxX3.Checked && !checkBoxX4.Checked) { MessageBox.Show("请确定是选择管线还是选择图层!", "提示"); return; } if (dataGridViewX4.Rows.Count > 0) { featLenth.Clear(); featCount.Clear(); listBox2.Items.Clear(); layerTemp.RemoveAllFeature(); polygonJingJuAnalysises.RemoveAll(); dataGridViewX5.Rows.Clear(); clearFeatureHighLight(); m_FeaturesWithBianhao.Clear(); globeControl1.Globe.Action = EnumAction3D.ActionNull; this.Cursor = Cursors.WaitCursor; if (checkBoxX3.Checked) // 选择管线 { for (int i = 0; i < dataGridViewX4.Rows.Count; i++) { GSOFeature selectedFeature = dataGridViewX4.Rows[i].Tag as GSOFeature; if (selectedFeature != null) { selectState = 1; VerticalDistanceAnalysis("碰撞分析", selectedFeature, m_PipelineLayerNames, 0, 0.0); } } } else if (checkBoxX4.Checked) // 选择图层 { GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(comboBoxEx2.SelectedItem.ToString()); if (layer == null) return; GSOFeatureLayer flayer = layer as GSOFeatureLayer; GSOFeatureDataset fdataset = flayer.Dataset as GSOFeatureDataset; GSOFeatures feats = flayer.GetAllFeatures(); for (int i = 0; i < feats.Length; i++) { selectState = 1; VerticalDistanceAnalysis("碰撞分析", feats[i], m_PipelineLayerNames, 0, 0.0); } } if (featCount.Count > 0) { for (int i = 0; i < m_PipelineLayerNames.Count; i++) { if (featCount.ContainsKey(m_PipelineLayerNames[i]) && featLenth.ContainsKey(m_PipelineLayerNames[i])) { listBox2.Items.Add(m_PipelineLayerNames[i] + ":" + featCount[m_PipelineLayerNames[i]] + "条,共" + featLenth[m_PipelineLayerNames[i]].ToString("0.00") + "米"); } } } if (dataGridViewX5.Rows.Count == 0&&selectState==1) { MessageBox.Show("没有发生碰撞的管线!", "提示"); } } else { MessageBox.Show("请选中要进行碰撞分析的管线!", "提示"); //globeControl1.Globe.Action = EnumAction3D.SelectObject; } globeControl1.Refresh(); this.Cursor = Cursors.Default; } /// <summary> /// 碰撞分析功能界面中 表格的 双击定位 功能 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void dataGridViewX5_MouseDoubleClick(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { DataGridView.HitTestInfo hittestinfo = dataGridViewX5.HitTest(e.X, e.Y); if (hittestinfo.RowIndex > -1) { string key =dataGridViewX5.Rows[hittestinfo.RowIndex].Cells[1].Value.ToString().Trim() + "-" + dataGridViewX5.Rows[hittestinfo.RowIndex].Cells[3].Value.ToString().Trim(); if (m_FeaturesWithBianhao.ContainsKey(key)) { globeControl1.Globe.JumpToPosition(m_FeaturesWithBianhao[key], EnumAltitudeMode.Absolute, 5); } } } } /// <summary> /// 水平净距分析 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem83_Click_1(object sender, EventArgs e) { //日志记录 LogManager.saveLog(Utility.userName, this.buttonItem83.Text); this.dataGridViewX8.Size = new System.Drawing.Size(185, 92); this.dataGridViewX9.Size = new System.Drawing.Size(185, 120); layerTemp.RemoveAllFeature(); clearFeatureHighLight(); globeControl1.Refresh(); sideBar1.Visible = true; sideBarPanelItem3.Visible = true; buttonItem1.Checked = true; controlContainerItem3.Visible = true; sideBarPanelItem4.Visible = true; sideBarPanelItem4.Text = "水平净距分析"; trackflag = "horizontal"; controlContainerItem5.Control = panel5; panel5.Dock = DockStyle.Fill; panel5.Visible = true; sideBar1.ExpandedPanel = sideBarPanelItem4; sideBar1.Refresh(); Refresh(); } /// <summary> /// 垂直净距分析 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnPipeDistance_Click(object sender, EventArgs e) { //日志记录 LogManager.saveLog(Utility.userName, this.btnPipeDistance.Text); this.dataGridViewX2.Size = new System.Drawing.Size(185, 92); this.dataGridViewX3.Size = new System.Drawing.Size(185, 120); layerTemp.RemoveAllFeature(); clearFeatureHighLight(); globeControl1.Refresh(); sideBar1.Visible = true; sideBarPanelItem3.Visible = true; buttonItem1.Checked = true; controlContainerItem3.Visible = true; sideBarPanelItem4.Visible = true; sideBarPanelItem4.Text = "垂直净距分析"; trackflag = "vertical"; controlContainerItem5.Control = panel1; panel1.Dock = DockStyle.Fill; panel1.Visible = true; sideBar1.ExpandedPanel = sideBarPanelItem4; sideBar1.Refresh(); Refresh(); } /// <summary> /// 碰撞分析 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem63_Click(object sender, EventArgs e) { //日志记录 LogManager.saveLog(Utility.userName, this.buttonItem63.Text); this.dataGridViewX4.Size = new System.Drawing.Size(195, 92); this.dataGridViewX5.Size = new System.Drawing.Size(195, 120); layerTemp.RemoveAllFeature(); clearFeatureHighLight(); globeControl1.Refresh(); sideBar1.Visible = true; sideBarPanelItem3.Visible = true; buttonItem1.Checked = true; controlContainerItem3.Visible = true; sideBarPanelItem4.Visible = true; sideBarPanelItem4.Text = "碰撞分析"; trackflag = "collision"; controlContainerItem5.Control = panel2; panel2.Dock = DockStyle.Fill; panel2.Visible = true; sideBar1.ExpandedPanel = sideBarPanelItem4; sideBar1.Refresh(); Refresh(); } /// <summary> /// 覆土分析 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem85_Click(object sender, EventArgs e) { //日志记录 LogManager.saveLog(Utility.userName, this.buttonItem85.Text); this.dataGridViewX6.Size = new System.Drawing.Size(195, 92); this.dataGridViewX7.Size = new System.Drawing.Size(195, 120); layerTemp.RemoveAllFeature(); clearFeatureHighLight(); globeControl1.Refresh(); sideBar1.Visible = true; sideBarPanelItem3.Visible = true; buttonItem1.Checked = true; controlContainerItem3.Visible = true; sideBarPanelItem4.Visible = true; sideBarPanelItem4.Text = "覆土分析"; trackflag = "ftAnalysis"; controlContainerItem5.Control = panel4; panel4.Visible = true; panel4.Dock = DockStyle.Fill; sideBar1.ExpandedPanel = sideBarPanelItem4; sideBar1.Refresh(); Refresh(); } /// <summary> /// 覆土分析功能操作界面中的 选择管线 复选框选中状态改变事件处理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void checkBoxX5_CheckedChanged(object sender, EventArgs e) { clearFeatureHighLight(); if (checkBoxX5.Checked) { globeControl1.Globe.ClearAnalysis(); layerTemp.RemoveAllFeature(); globeControl1.Refresh(); comboBoxEx3.Enabled = false; dataGridViewX6.Rows.Clear(); dataGridViewX7.Rows.Clear(); trackflag = "ftAnalysis"; globeControl1.Globe.Action = EnumAction3D.SelectObject; } else { comboBoxEx3.Enabled = true; } } /// <summary> /// 覆土分析功能操作界面中的 选择图层 复选框选中状态改变事件处理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void checkBoxX6_CheckedChanged(object sender, EventArgs e) { clearFeatureHighLight(); comboBoxEx3.Enabled = checkBoxX6.Checked; if (checkBoxX6.Checked) { globeControl1.Globe.Action = EnumAction3D.ActionNull; trackflag = ""; dataGridViewX6.Rows.Clear(); dataGridViewX7.Rows.Clear(); comboBoxEx3.SelectedIndex = -1; } globeControl1.Globe.ClearAnalysis(); layerTemp.RemoveAllFeature(); globeControl1.Refresh(); } /// <summary> /// 覆土分析功能操作界面中的 图层下拉框选中项改变事件处理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void comboBoxEx3_SelectedIndexChanged(object sender, EventArgs e) { if (comboBoxEx3.SelectedIndex > -1) { dataGridViewX6.Rows.Clear(); dataGridViewX7.Rows.Clear(); GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(comboBoxEx3.SelectedItem.ToString()); if (layer == null) return; GSOFeatureLayer flayer = layer as GSOFeatureLayer; GSOFeatureDataset fdataset = flayer.Dataset as GSOFeatureDataset; GSOFeatures feats = flayer.GetAllFeatures(); for (int i = 0; i < feats.Length; i++) { int idx = dataGridViewX6.Rows.Add(); dataGridViewX6.Rows[idx].Cells[0].Value = comboBoxEx3.SelectedItem.ToString(); dataGridViewX6.Rows[idx].Cells[1].Value = feats[i].Name; } } } /// <summary> /// 覆土分析功能操作界面中的 开始分析 按钮事件处理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonX9_Click(object sender, EventArgs e) { if (!checkBoxX5.Checked && !checkBoxX6.Checked) { MessageBox.Show("请确定是选择管线还是选择图层!", "提示"); return; } if (textBoxX3.Text.Trim() == "") { MessageBox.Show("覆土深度不能为空!", "提示"); return; } double dFuTuShenDu = 0; if (!double.TryParse(textBoxX3.Text.Trim(), out dFuTuShenDu)) { MessageBox.Show("请输入正确的覆土深度!", "提示"); return; } if (dataGridViewX6.Rows.Count > 0) { layerTemp.RemoveAllFeature(); dataGridViewX7.Rows.Clear(); clearFeatureHighLight(); this.Cursor = Cursors.WaitCursor; if (checkBoxX5.Checked) // 覆土分析 选择管线 { for (int i = 0; i < dataGridViewX6.Rows.Count; i++) { GSOFeature rowFeature = dataGridViewX6.Rows[i].Tag as GSOFeature; if (rowFeature != null) { string featureName = ""; if (isFeatureContainsBianhao(rowFeature))//判断rowFeature是否包含“编号”字段 { featureName = rowFeature.GetValue(featureIDFieldName).ToString(); } else { featureName = rowFeature.Name; } GSOGeoPolyline3D line = rowFeature.Geometry as GSOGeoPolyline3D; if (line == null) { continue; } GSOPipeLineStyle3D style = line.Style as GSOPipeLineStyle3D; if (style == null) { continue; } if (line.PartCount > 0) { GSOPoint3ds pts = line[0]; for (int m = 0; m < pts.Count; m++) { if (Math.Abs(pts[m].Z + (style.Radius)) < Convert.ToDouble(textBoxX3.Text.Trim())) { rowFeature.HighLight = true; int idx = dataGridViewX7.Rows.Add(); dataGridViewX7.Rows[idx].Tag = rowFeature; dataGridViewX7.Rows[idx].Cells[0].Value = rowFeature.Dataset.Caption; dataGridViewX7.Rows[idx].Cells[1].Value = featureName; dataGridViewX7.Rows[idx].Cells[2].Value = Math.Abs((pts[m].Z + (style.Radius))).ToString("0.00"); break; } } } } } } else if (checkBoxX6.Checked) // 覆土分析 选择图层 { GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(comboBoxEx3.SelectedItem.ToString()); if (layer == null) return; GSOFeatureLayer flayer = layer as GSOFeatureLayer; GSOFeatureDataset fdataset = flayer.Dataset as GSOFeatureDataset; GSOFeatures feats = flayer.GetAllFeatures(); for (int i = 0; i < feats.Length; i++) { GSOFeature f = feats[i]; string featureName = ""; if (isFeatureContainsBianhao(feats[i])) { featureName = feats[i].GetValue(featureIDFieldName).ToString(); } else { featureName = feats[i].Name; } GSOGeoPolyline3D line = f.Geometry as GSOGeoPolyline3D; if (line == null) continue; GSOPipeLineStyle3D style = line.Style as GSOPipeLineStyle3D; if (style == null) continue; if (line.PartCount > 0) { GSOPoint3ds pts = line[0]; for (int m = 0; m < pts.Count; m++) { if (Math.Abs(pts[m].Z + (style.Radius)) < Convert.ToDouble(textBoxX3.Text.Trim())) { f.HighLight = true; int idx = dataGridViewX7.Rows.Add(); dataGridViewX7.Rows[idx].Tag = f; dataGridViewX7.Rows[idx].Cells[0].Value = layer.Caption; dataGridViewX7.Rows[idx].Cells[1].Value = featureName; dataGridViewX7.Rows[idx].Cells[2].Value = Math.Abs((pts[m].Z + (style.Radius))).ToString("0.00"); break; } } } } } globeControl1.Refresh(); if (dataGridViewX7.Rows.Count == 0) { MessageBox.Show("所有管线满足覆土净距标准!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { MessageBox.Show("请选中要进行覆土分析的管线!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); //globeControl1.Globe.Action = EnumAction3D.SelectObject; } this.Cursor = Cursors.Default; } /// <summary> /// 覆土分析中 表格的 双击定位 功能 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void dataGridViewX7_MouseDoubleClick(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { DataGridView.HitTestInfo hittestinfo = dataGridViewX7.HitTest(e.X, e.Y); if (hittestinfo.RowIndex > -1) { GSOFeature rowFeature = dataGridViewX7.Rows[hittestinfo.RowIndex].Tag as GSOFeature; if (rowFeature != null) { if (rowFeature.Geometry != null && rowFeature.Geometry.Type == EnumGeometryType.GeoPolyline3D) { GSOGeoPolyline3D line = rowFeature.Geometry as GSOGeoPolyline3D; double length = line.GetSpaceLength(true, 6378137); GSOGeoPolyline3D lineLine = line.GetSegment(0, length / 2); GSOPoint3d point3d = lineLine[lineLine.PartCount - 1][lineLine[lineLine.PartCount - 1].Count - 1]; globeControl1.Globe.JumpToPosition(point3d, EnumAltitudeMode.Absolute, 5); } else { globeControl1.Globe.JumpToFeature(rowFeature, 5); } } } } } /// <summary> /// 覆土分析功能操作界面中的 导出Excel按钮 事件处理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonX10_Click(object sender, EventArgs e) { if (dataGridViewX7.Rows.Count > 0) { ExportExcel("覆土分析", dataGridViewX7,null); } else { MessageBox.Show("表格内容为空!", "提示"); } } /// <summary> /// 覆土分析功能操作界面底部的 关闭 按钮事件处理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonX11_Click(object sender, EventArgs e) { trackflag = ""; globeControl1.Globe.Action = EnumAction3D.ActionNull; sideBarPanelItem4.Visible = false; panel4.Visible = false; checkBoxX5.Checked = false; checkBoxX6.Checked = false; comboBoxEx3.SelectedIndex = -1; dataGridViewX6.Rows.Clear(); dataGridViewX7.Rows.Clear(); if (buttonItem1.Checked) { sideBar1.ExpandedPanel = sideBarPanelItem3; } else { sideBar1.Visible = false; } Refresh(); } /// <summary> /// 垂直净距分析 功能界面中 清除分析结果按钮 事件处理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonX2_Click(object sender, EventArgs e) { trackflag = ""; globeControl1.Globe.Action = EnumAction3D.ActionNull; checkBoxX1.Checked = false; checkBoxX2.Checked = false; comboBoxEx1.SelectedIndex = -1; comboBoxEx1.Enabled = false; textBoxX2.Text = "1"; dataGridViewX2.Rows.Clear(); dataGridViewX3.Rows.Clear(); listBox1.Items.Clear(); layerTemp.RemoveAllFeature(); globeControl1.Refresh(); } /// <summary> /// 水平净距分析 功能界面中 清除分析结果按钮 事件处理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonX15_Click(object sender, EventArgs e) { trackflag = ""; globeControl1.Globe.Action = EnumAction3D.ActionNull; checkBoxX7.Checked = false; checkBoxX8.Checked = false; comboBoxEx4.SelectedIndex = -1; comboBoxEx4.Enabled = false; textBoxX4.Text = "1"; dataGridViewX8.Rows.Clear(); dataGridViewX9.Rows.Clear(); listBox3.Items.Clear(); layerTemp.RemoveAllFeature(); globeControl1.Refresh(); } /// <summary> /// 键盘按键按下 事件处理, 只允许输入数字。 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> //private void textBoxX1_KeyPress(object sender, KeyPressEventArgs e) //{ // TextBox text = sender as TextBox; // if ((e.KeyChar < 48 || e.KeyChar > 57) && (e.KeyChar != 8) && (int)e.KeyChar != 46) // { // e.Handled = true; // } // if ((int)e.KeyChar == 46) //小数点 // { // if (text.Text.Length <= 0) // e.Handled = true; //小数点不能在第一位 // else //处理不规则的小数点 // { // float f; // float oldf; // bool b1 = false, b2 = false; // b1 = float.TryParse(text.Text, out oldf); // b2 = float.TryParse(text.Text + e.KeyChar.ToString(), out f); // if (b2 == false) // { // if (b1 == true) // e.Handled = true; // else // e.Handled = false; // } // } // } //} /// <summary> /// 垂直净距分析功能界面中 关闭按钮 事件处理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonX3_Click(object sender, EventArgs e) { trackflag = ""; globeControl1.Globe.Action = EnumAction3D.ActionNull; sideBarPanelItem4.Visible = false; panel2.Visible = false; checkBoxX1.Checked = false; checkBoxX2.Checked = false; comboBoxEx1.SelectedIndex = -1; dataGridViewX2.Rows.Clear(); dataGridViewX3.Rows.Clear(); if (layerTemp != null) { layerTemp.RemoveAllFeature(); } if (buttonItem1.Checked) { sideBar1.ExpandedPanel = sideBarPanelItem3; } else { sideBar1.Visible = false; } Refresh(); } /// <summary> /// 水平净距分析功能界面中 删除缓冲区按钮 事件处理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonX14_Click(object sender, EventArgs e) { //for (int i = 0; i < polygonJingJuAnalysises.Length; i++) //{ // polygonJingJuAnalysises[i].Delete(); //} //globeControl1.Globe.Refresh(); trackflag = ""; globeControl1.Globe.Action = EnumAction3D.ActionNull; sideBarPanelItem4.Visible = false; panel5.Visible = false; checkBoxX3.Checked = false; checkBoxX4.Checked = false; comboBoxEx2.SelectedIndex = -1; dataGridViewX8.Rows.Clear(); dataGridViewX9.Rows.Clear(); if (buttonItem1.Checked) { sideBar1.ExpandedPanel = sideBarPanelItem3; } else { sideBar1.Visible = false; } Refresh(); } /// <summary> /// 导出指定DataGridView控件中的内容 /// </summary> /// <param name="type"></param> /// <param name="_dataGridView"></param> private void ExportExcel(string type,DataGridView _dataGridView,ListBox _listBox) { if (_dataGridView.Rows.Count > 0) { SaveFileDialog dlg = new SaveFileDialog(); dlg.Filter = "Excel files (*.xls)|*.xls"; dlg.FilterIndex = 0; dlg.RestoreDirectory = true; //dlg.CreatePrompt = true; dlg.Title = "保存为Excel文件"; dlg.FileName = type + "-" + DateTime.Now.ToString("yyyyMMdd") + ".xls"; if (dlg.ShowDialog() == DialogResult.OK) { Stream myStream; myStream = dlg.OpenFile(); StreamWriter sw = new StreamWriter(myStream, System.Text.Encoding.GetEncoding(-0)); string columnTitle = ""; try { if (_listBox != null) { string strList = ""; for (int i = 0; i < _listBox.Items.Count; i++) { strList += _listBox.Items[i].ToString() + @"/"; } sw.WriteLine("内容:" + type + " 日期:" + DateTime.Now.ToString("yyyy-MM-dd") + " 结果:" + strList); } else { sw.WriteLine("内容:" + type + " 日期:" + DateTime.Now.ToString("yyyy-MM-dd")); } //写入列标题 for (int i = 0; i < _dataGridView.ColumnCount; i++) { if (i > 0) { columnTitle += "\t"; } columnTitle += _dataGridView.Columns[i].HeaderText; } sw.WriteLine(columnTitle); //写入列内容 for (int j = 0; j < _dataGridView.Rows.Count; j++) { string columnValue = ""; for (int k = 0; k < _dataGridView.Columns.Count; k++) { if (k > 0) { columnValue += "\t"; } if (_dataGridView.Rows[j].Cells[k].Value == null) { columnValue += ""; } else { columnValue += _dataGridView.Rows[j].Cells[k].Value.ToString().Trim(); } } sw.WriteLine(columnValue); } sw.Close(); myStream.Close(); if (MessageBox.Show("导出Excel文件成功!是否打开?", "提示", MessageBoxButtons.YesNo) == DialogResult.Yes) { System.Diagnostics.Process.Start(dlg.FileName); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { sw.Close(); myStream.Close(); } } } } /// <summary> /// 垂直净距分析功能界面中 导出Excel按钮 事件处理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonX4_Click(object sender, EventArgs e) { if (dataGridViewX3.Rows.Count > 0) { ExportExcel("垂直净距分析", dataGridViewX3,listBox1); } else { MessageBox.Show("表格内容为空!", "提示"); } } /// <summary> /// 水平净距分析功能界面中 导出Excel按钮 事件处理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonX4_Click_shuiping(object sender, EventArgs e) { if (dataGridViewX9.Rows.Count > 0) { ExportExcel("水平净距分析", dataGridViewX9,listBox3); } else { MessageBox.Show("表格内容为空!", "提示"); } } /// <summary> /// 多边形挖坑 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnPolygonDigPit_Click(object sender, EventArgs e) { //日志记录 LogManager.saveLog(Utility.userName, this.btnPolygonDigPit.Text); trackflag = "pit"; globeControl1.Globe.Action = EnumAction3D.TrackPolygon; globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; //是这个么?是的,在模型上 } /// <summary> /// 清除所有坑 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem3_Click(object sender, EventArgs e) { //日志记录 LogManager.saveLog(Utility.userName, this.buttonItem3.Text); globeControl1.Globe.RemoveAllPits(); } /// <summary> /// 挖方量分析 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void DigFillAnalysisMenuItem_Click(object sender, EventArgs e) { //日志记录 LogManager.saveLog(Utility.userName, this.DigFillAnalysisMenuItem.Text); trackflag = "digFillAnalysis"; globeControl1.Globe.Action = EnumAction3D.TrackPolygon; globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; ActionToolMenuChecked(); } //private void command1_Executed(object sender, EventArgs e) //{ // ICommandSource source = sender as ICommandSource; // if (source.CommandParameter is string) // { // eOffice2007ColorScheme colorScheme = (eOffice2007ColorScheme)Enum.Parse(typeof(eOffice2007ColorScheme), source.CommandParameter.ToString()); // ribbonControl1.Office2007ColorTable = colorScheme; // } //} /// <summary> /// 坐标查询 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem102_Click(object sender, EventArgs e) { //日志记录 LogManager.saveLog(Utility.userName, this.buttonItem102.Text); FrmSetLatLonPos.ShowForm(globeControl1); } /// <summary> /// 沿线挖坑 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem28_Click(object sender, EventArgs e) { //日志记录 LogManager.saveLog(Utility.userName, this.buttonItem28.Text); if (!buttonItem28.Checked) { FrmDigPitSetting dlg = new FrmDigPitSetting(m_dDigPitValue, m_bDigPitByDepth, m_dDigPitWidthAlongLine); if (dlg.ShowDialog() == DialogResult.OK) { m_dDigPitValue = dlg.m_dDigPitValue; m_bDigPitByDepth = dlg.m_bDigPitByDepth; m_dDigPitWidthAlongLine = dlg.m_dDigPitWidthAlongLine; trackflag = "LineDigPit"; globeControl1.Globe.Action = EnumAction3D.TrackPolyline; globeControl1.Globe.TrackPolylineTool.VerticalLineVisible = true; globeControl1.Globe.TrackPolylineTool.TrackMode = EnumTrackMode.SpaceTrack; buttonItem28.Checked = true; } } else { globeControl1.Globe.Action = EnumAction3D.ActionNull; buttonItem28.Checked = false; globeControl1.Globe.TrackPolylineTool.VerticalLineVisible = false; } ActionToolMenuChecked(); } /// <summary> /// 可视域分析 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem29_Click(object sender, EventArgs e) { //日志记录 LogManager.saveLog(Utility.userName, this.buttonItem29.Text); globeControl1.Globe.Action = EnumAction3D.ViewshedAnalysis; } /// <summary> /// 可视包络分析 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem30_Click(object sender, EventArgs e) { //日志记录 LogManager.saveLog(Utility.userName, this.buttonItem30.Text); globeControl1.Globe.Action = EnumAction3D.ViewEnvelopeAnalysis; } /// <summary> /// 净距分析 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem32_Click(object sender, EventArgs e) { //日志记录 LogManager.saveLog(Utility.userName, this.buttonItem32.Text); buttonItem32.Checked = !buttonItem32.Checked; ribbonBarJJ.Visible = buttonItem32.Checked; ribbonBarJJ.Location = new Point(0, 0); } /// <summary> /// 视域分析 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem49_Click(object sender, EventArgs e) { buttonItem49.Checked = !buttonItem49.Checked; ribbonBarSY.Visible = buttonItem49.Checked; ribbonBarSY.Location = new Point(0, 0); } /// <summary> /// 拓扑分析 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem34_Click(object sender, EventArgs e) { buttonItem34.Checked = !buttonItem34.Checked; ribbonBarTP.Visible = buttonItem34.Checked; ribbonBarTP.Location = new Point(0, 0); } /// <summary> /// 大气层 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem17_Click_1(object sender, EventArgs e) { globeControl1.Globe.Atmosphere.Visible = !globeControl1.Globe.Atmosphere.Visible; pzscBtn.Checked = globeControl1.Globe.Atmosphere.Visible; globeControl1.Refresh(); } /// <summary> /// 经纬网 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem20_Click(object sender, EventArgs e) { globeControl1.Globe.LatLonGrid.Visible = !globeControl1.Globe.LatLonGrid.Visible; spjjscBtn.Checked = globeControl1.Globe.LatLonGrid.Visible; globeControl1.Globe.Refresh(); } /// <summary> /// 状态条 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem21_Click_1(object sender, EventArgs e) { globeControl1.Globe.StatusBar.Visible = !globeControl1.Globe.StatusBar.Visible; czjjscBtn.Checked = globeControl1.Globe.StatusBar.Visible; //btnToolNone.Visible = true; //btnToolSelect.Visible = true; globeControl1.Globe.Refresh(); } /// <summary> /// 飞行到目标点 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem92_Click(object sender, EventArgs e) { //日志记录 LogManager.saveLog(Utility.userName, this.buttonItem92.Text); FrmSetFlytoPos.ShowForm(globeControl1); } /// <summary> /// 绕中心点飞行 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem56_Click(object sender, EventArgs e) { //日志记录 LogManager.saveLog(Utility.userName, this.buttonItem56.Text); globeControl1.Globe.FlyAroundCenter(10000, EnumFlyRepeatValueType.MiliSeconds); globeControl1.Globe.CurFlyID = 1; } /// <summary> /// 绕眼睛飞行 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem57_Click(object sender, EventArgs e) { //日志记录 LogManager.saveLog(Utility.userName, this.buttonItem57.Text); globeControl1.Globe.FlyAroundEye(720, EnumFlyRepeatValueType.Degrees); globeControl1.Globe.CurFlyID = 2; } /// <summary> /// 自定义飞行 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem15_Click(object sender, EventArgs e) { //日志记录 LogManager.saveLog(Utility.userName, this.buttonItem15.Text); GSOGeoPolyline3D line = null; GSOFeature f = globeControl1.Globe.SelectedObject; if (f != null) { line = f.Geometry as GSOGeoPolyline3D; } if (line == null) { MessageBox.Show("请先选中一条线!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information); globeControl1.Globe.Action = EnumAction3D.SelectObject; return; } FrmFlySetDlg dlg = new FrmFlySetDlg(); dlg.dFlyAboveLine = m_dFlyAboveLine; dlg.dFlyAloneLineSpeed = m_dFlyAlongLineSpeed; dlg.dFlyAloneLineRotateSpeed = m_dFlyAlongLineRotateSpeed; if (dlg.ShowDialog() == DialogResult.OK) { m_dFlyAboveLine = dlg.dFlyAboveLine; m_dFlyAlongLineSpeed = dlg.dFlyAloneLineSpeed; m_dFlyAlongLineRotateSpeed = dlg.dFlyAloneLineRotateSpeed; globeControl1.Globe.FlyAlongLineSpeed = m_dFlyAlongLineSpeed; globeControl1.Globe.FlyAlongLineRotateSpeed = m_dFlyAlongLineRotateSpeed; globeControl1.Globe.FlyEyeAlongWithLine(line, m_dFlyAboveLine, 85, true, 0, false); } } /// <summary> /// 添加数据 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnAddData_Click(object sender, EventArgs e) { //日志记录 LogManager.saveLog(Utility.userName, this.btnImport.Text); OpenFileDialog dlg = new OpenFileDialog(); dlg.Filter = "矢量数据(*.shp)|*.shp|栅格数据(*.lrp)|*.lrp|栅格缓存(*.lrc)|*.lrc|KML数据(*.kml)|*.kml|矢量数据(*.lgd)|*.lgd|矢量缓存(*.gft)|*.gft|CAD文件(*.dxf)|*.dxf|全部支持格式(*.lrp,*.tif,*.img,*.lrc,*.kml,*.lgd,*.shp,*.gft,*.dxf)|*.lrp;*.tif;*.img;*.lrc;*.kml;*.lgd;*.shp;*.gft;*.dxf"; //dlg.Filter = "支持格式(*.lrp,*.tif,*.img,*.lrc,*.kml,*.lgd,*.shp,*.gft)|*.lrp;*.tif;*.img;*.lrc;*.kml;*.lgd;*.shp;*.gft|栅格数据(*.lrp)|*.lrp|栅格缓存(*.lrc)|*.lrc|KML数据(*.kml)|*.kml|矢量数据(*.lgd)|*.lgd|矢量缓存(*.gft)|*.gft|其它格式(*.*)|*.*||"; dlg.Multiselect = true; if (dlg.ShowDialog() == DialogResult.OK) { //自定义lprj文件名,从程序中复制一lprj文件。 int bindex = dlg.FileName.Split('\\').Length; string lastname = dlg.FileName.Split('\\')[bindex - 1]; if (lastname.IndexOf(".dxf") != -1) { string firstname = dlg.FileName.Substring(0, dlg.FileName.Length - lastname.Length); string filename = lastname.Substring(0, lastname.Length - 4) + ".lprj"; //复制lprj string lprjfilepath = firstname + filename; FileInfo OFInfo = new FileInfo(lprjfilepath);//获取目标文件所在的路径 FileInfo SFInfo = new FileInfo(Application.StartupPath + "\\lprj\\sz.lprj"); if (!OFInfo.Exists) { SFInfo.CopyTo(lprjfilepath, true);//将文件复制到指定的路径中 } } else if (lastname.IndexOf(".shp") != -1)//只能对苏州本地坐标系进行纠正 { string firstname = dlg.FileName.Substring(0, dlg.FileName.Length - lastname.Length); string filename = lastname.Substring(0, lastname.Length - 4) + ".prj"; //复制lprj string lprjfilepath = firstname + filename; FileInfo OFInfo = new FileInfo(lprjfilepath);//获取目标文件所在的路径 FileInfo SFInfo = new FileInfo(Application.StartupPath + "\\lprj\\sz.prj"); SFInfo.CopyTo(lprjfilepath, true);//将文件复制到指定的路径中 } for (int i = 0; i < dlg.FileNames.Length; i++) { AddLayerData(dlg.FileNames[i]); } layerManagerNode.Expand(); //放大到新导入的图层 GSOLayer lyr = globeControl1.Globe.Layers.GetLayerByCaption(newlayername); if (newlayername != "") { GSOFeatures features = lyr.GetAllFeatures(); GSORect2d rd = lyr.LatLonBounds; GSOPoint2d rdcenter = rd.Center; globeControl1.Globe.JumpToPosition(new GSOPoint3d(rdcenter.X, rdcenter.Y, 0), EnumAltitudeMode.Absolute, 1000); globeControl1.Refresh(); } } } /// <summary> /// 导入其他坐标系数据 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem141_Click_1(object sender, EventArgs e) { //Form1 f1 = new Form1(globeControl1, ds); //f1.Show(); //日志记录 LogManager.saveLog(Utility.userName, this.btnImport.Text); OpenFileDialog dlg = new OpenFileDialog(); dlg.Filter = "矢量数据(*.shp)|*.shp|栅格数据(*.lrp)|*.lrp|栅格缓存(*.lrc)|*.lrc|KML数据(*.kml)|*.kml|矢量数据(*.lgd)|*.lgd|矢量缓存(*.gft)|*.gft|CAD文件(*.dxf)|*.dxf|全部支持格式(*.lrp,*.tif,*.img,*.lrc,*.kml,*.lgd,*.shp,*.gft,*.dxf)|*.lrp;*.tif;*.img;*.lrc;*.kml;*.lgd;*.shp;*.gft;*.dxf"; //dlg.Filter = "支持格式(*.lrp,*.tif,*.img,*.lrc,*.kml,*.lgd,*.shp,*.gft)|*.lrp;*.tif;*.img;*.lrc;*.kml;*.lgd;*.shp;*.gft|栅格数据(*.lrp)|*.lrp|栅格缓存(*.lrc)|*.lrc|KML数据(*.kml)|*.kml|矢量数据(*.lgd)|*.lgd|矢量缓存(*.gft)|*.gft|其它格式(*.*)|*.*||"; dlg.Multiselect = true; if (dlg.ShowDialog() == DialogResult.OK) { //自定义lprj文件名,从程序中复制一lprj文件。 int bindex = dlg.FileName.Split('\\').Length; string lastname = dlg.FileName.Split('\\')[bindex - 1]; if (lastname.IndexOf(".dxf") != -1) { string firstname = dlg.FileName.Substring(0, dlg.FileName.Length - lastname.Length); string filename = lastname.Substring(0, lastname.Length - 4) + ".lprj"; //复制lprj string lprjfilepath = firstname + filename; FileInfo OFInfo = new FileInfo(lprjfilepath);//获取目标文件所在的路径 FileInfo SFInfo = new FileInfo(Application.StartupPath + "\\lprj\\sz.lprj"); if (!OFInfo.Exists) { SFInfo.CopyTo(lprjfilepath, true);//将文件复制到指定的路径中 } } else if (lastname.IndexOf(".shp") != -1)//只能对苏州本地坐标系进行纠正 { string firstname = dlg.FileName.Substring(0, dlg.FileName.Length - lastname.Length); string filename = lastname.Substring(0, lastname.Length - 4) + ".prj"; //复制lprj string lprjfilepath = firstname + filename; FileInfo OFInfo = new FileInfo(lprjfilepath);//获取目标文件所在的路径 FileInfo SFInfo = new FileInfo(Application.StartupPath + "\\lprj\\xian80.prj"); SFInfo.CopyTo(lprjfilepath, true);//将文件复制到指定的路径中 } for (int i = 0; i < dlg.FileNames.Length; i++) { AddLayerData(dlg.FileNames[i]); } layerManagerNode.Expand(); //放大到新导入的图层 GSOLayer lyr = globeControl1.Globe.Layers.GetLayerByCaption(newlayername); if (newlayername != "") { GSOFeatures features = lyr.GetAllFeatures(); GSORect2d rd = lyr.LatLonBounds; GSOPoint2d rdcenter = rd.Center; globeControl1.Globe.JumpToPosition(new GSOPoint3d(rdcenter.X, rdcenter.Y, 0), EnumAltitudeMode.Absolute, 1000); globeControl1.Refresh(); } } } /// <summary> /// 添加指定路径下的数据 功能 /// </summary> /// <param name="strDataPath"></param> /// <returns></returns> private object AddLayerData(string strDataPath) { object objRes = null; if (Path.GetExtension(strDataPath).ToLower().Equals(".kml")) { GSOLayer layer = globeControl1.Globe.Layers.Add(strDataPath); objRes = layer; if (layer != null) { GSODataset dataset = layer.Dataset; CheckDatasetGeoReference(layer.Dataset,""); TreeNode node = new TreeNode(); node.Tag = layer; node.Text = layer.Dataset.Caption; node.ImageIndex = 0; node.SelectedImageIndex = 0; node.Checked = layer.Visible; // 注意用insert不要用add,因为后加入的图层在上层 //layerManagerNode.Nodes.Add(node); layerManagerNode.Nodes.Insert(0, node); } newlayername = layer.Caption; } else if (GSOUtility.IsDatasetSupportTerrain(strDataPath)) { GSOTerrain terrain = globeControl1.Globe.Terrains.Add(strDataPath); objRes = terrain; if (terrain != null) { TreeNode node = new TreeNode(); node.Tag = terrain; node.Text = terrain.Caption; node.ImageIndex = 0; node.SelectedImageIndex = 0; node.Checked = terrain.Visible; // 注意用insert不要用add,因为后加入的图层在上层 // terrainManagerNode.Nodes.Add(node); layerManagerNode.Nodes.Insert(0, node); } newlayername = terrain.Caption; } else if (Path.GetExtension(strDataPath).ToLower().Equals(".dxf")) { GSOLayer layer = globeControl1.Globe.Layers.Add(strDataPath); objRes = layer; if (layer != null) { GSODataset dataset = layer.Dataset; CheckDatasetGeoReference(layer.Dataset, strDataPath); CheckDatasetGeoReference(layer.Dataset, strDataPath); TreeNode node = new TreeNode(); node.Tag = layer; node.Text = layer.Dataset.Caption; node.ImageIndex = 0; node.SelectedImageIndex = 0; node.Checked = layer.Visible; // 注意用insert不要用add,因为后加入的图层在上层 //layerManagerNode.Nodes.Add(node); layerManagerNode.Nodes.Insert(0, node); } newlayername = layer.Caption; } else { GSOLayer layer = globeControl1.Globe.Layers.Add(strDataPath); objRes = layer; if (layer != null) { GSODataset dataset = layer.Dataset; CheckDatasetGeoReference(layer.Dataset, strDataPath); CheckDatasetGeoReference(layer.Dataset, strDataPath); TreeNode node = new TreeNode(); node.Tag = layer; node.Text = layer.Dataset.Caption; node.ImageIndex = 0; node.SelectedImageIndex = 0; node.Checked = layer.Visible; // 注意用insert不要用add,因为后加入的图层在上层 //layerManagerNode.Nodes.Add(node); layerManagerNode.Nodes.Insert(0, node); } newlayername = layer.Caption; } return objRes; } /// <summary> /// 刷新目录树 功能 /// </summary> private void RefreshDataTree() { layerTree.Nodes[0].Nodes.Clear(); Int32 nCount = globeControl1.Globe.DataManager.DataSourceCount; Int32 i = 0; for (i = 0; i < nCount; i++) { GSODataSource dataSpace = globeControl1.Globe.DataManager[i]; TreeNode node = new TreeNode(); node.Text = dataSpace.Name; node.ImageIndex = 0; node.SelectedImageIndex = 0; node.Checked = true; node.Tag = dataSpace; Int32 nDatasetCount = dataSpace.DatasetCount; for (Int32 j = 0; j < nDatasetCount; j++) { GSODataset dataset = dataSpace[j]; TreeNode subNode = new TreeNode(); subNode.Text = dataset.Name; subNode.ImageIndex = 0; subNode.SelectedImageIndex = 0; subNode.Checked = true; subNode.Tag = dataset; node.Nodes.Add(subNode); } layerTree.Nodes[0].Nodes.Add(node); } } /// <summary> /// 关键字查询 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem90_Click(object sender, EventArgs e) { //日志记录 LogManager.saveLog(Utility.userName, this.buttonItem90.Text); FrmKeywordQuery.ShowForm(globeControl1, m_PipelineLayerNames, dataGridViewX1, panelOfTable, toolStripNumbers, toolStripFeatureLength); } /// <summary> /// 空间查询 菜单, 针对多个类型的管线图层进行空间查询,与 管线距离统计 - 绘制区域 功能一样 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem101_Click(object sender, EventArgs e) { //日志记录 LogManager.saveLog(Utility.userName, this.buttonItem101.Text); trackflag = "PipelineSpatialQuery"; globeControl1.Globe.Action = EnumAction3D.TrackPolygon; globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; } /// <summary> /// 管径查询 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem104_Click(object sender, EventArgs e) { //日志记录 LogManager.saveLog(Utility.userName, this.buttonItem104.Text); FrmDiameterQuery.ShowForm(globeControl1, m_PipelineLayerNames, dataGridViewX1, panelOfTable, toolStripNumbers, toolStripFeatureLength); } /// <summary> /// 材质查询 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem105_Click(object sender, EventArgs e) { //日志记录 LogManager.saveLog(Utility.userName, this.buttonItem105.Text); FrmMaterialSel.ShowForm(globeControl1, m_PipelineLayerNames, dataGridViewX1, panelOfTable, toolStripNumbers, toolStripFeatureLength); } /// <summary> /// 附属物查询 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem103_Click(object sender, EventArgs e) { //日志记录 LogManager.saveLog(Utility.userName, this.buttonItem103.Text); FrmFittingQuery.ShowForm(globeControl1, instrumenLayerNames, dataGridViewX1, panelOfTable, toolStripNumbers, toolStripFeatureLength); } /// <summary> /// 基本查询 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem106_Click(object sender, EventArgs e) { //日志记录 LogManager.saveLog(Utility.userName, this.buttonItem106.Text); FrmBasicQuery.ShowForm(globeControl1,dataGridViewX1,panelOfTable, toolStripNumbers, toolStripFeatureLength); } /// <summary> /// 复合查询 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem107_Click(object sender, EventArgs e) { //日志记录 LogManager.saveLog(Utility.userName, this.buttonItem107.Text); if (dataGridViewX1.DataSource != null) { dataGridViewX1.DataSource = null; toolStripNumbers.Text = " 管线类型: " + m_CurrentQueryLayer + "|| 共有:" + 0 + " 条记录 || "; } List<string> newLayer = new List<string>(); foreach (TreeNode node in layerTree.Nodes) { if (node.Text == "新添加图层") { foreach (TreeNode nodeChild in node.Nodes) { if (nodeChild.Tag.ToString().Split('|')[1].ToString().Contains("管线")) { if (HasFields(nodeChild.Tag.ToString().Split('|')[1].ToString())) { newLayer.Add(nodeChild.Tag.ToString().Split('|')[1].ToString()); } } } } } FrmQuerySQL.ShowForm(globeControl1, dataGridViewX1,"admin", newLayer); } /// <summary> /// 判断图层是否包含字段列表 /// </summary> /// <param name="layerName"></param> /// <returns></returns> private bool HasFields(string layerName) { GSOLayer m_layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName);//获取当前选择的layer图层 if (m_layer == null) return false; GSOFeatureLayer flayer = m_layer as GSOFeatureLayer; GSOFeatureDataset _featureDataSet = m_layer.Dataset as GSOFeatureDataset; if (_featureDataSet == null) return false; _featureDataSet.Open(); if (_featureDataSet.FieldCount > 0) return true; else return false; } /// <summary> /// 统计指定图层在指定范围内的所有feature对象 /// </summary> /// <param name="polygon"></param> /// <param name="pipelinetype"></param> /// <returns></returns> private GSOFeatures Intersect_PointLayer(GSOGeoPolygon3D polygon, string pointLayerName) { GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(pointLayerName); if (layer == null) return null; GSOFeatureLayer flayer = layer as GSOFeatureLayer; GSOFeatureDataset fdataset = flayer.Dataset as GSOFeatureDataset; GSOFeatures feats; if (polygon == null) { feats = flayer.GetAllFeatures(); } else { feats = flayer.FindFeaturesInPolygon(polygon, false); } workWellLen.Add(pointLayerName, feats.Length); return feats; } /// <summary> /// 碰撞分析功能界面中 选择管线复选框 选中状态改变事件处理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void checkBoxX3_CheckedChanged(object sender, EventArgs e) { clearFeatureHighLight(); if (checkBoxX3.Checked) { globeControl1.Globe.ClearAnalysis(); layerTemp.RemoveAllFeature(); globeControl1.Refresh(); comboBoxEx2.Enabled = false; dataGridViewX4.Rows.Clear(); dataGridViewX5.Rows.Clear(); trackflag = "collision"; globeControl1.Globe.Action = EnumAction3D.SelectObject; } else { comboBoxEx2.Enabled = true; } } /// <summary> /// 碰撞分析功能界面中 选择图层复选框 选中状态改变事件处理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void checkBoxX4_CheckedChanged(object sender, EventArgs e) { clearFeatureHighLight(); comboBoxEx2.Enabled = checkBoxX4.Checked; if (checkBoxX4.Checked) { globeControl1.Globe.Action = EnumAction3D.ActionNull; trackflag = ""; dataGridViewX4.Rows.Clear(); dataGridViewX5.Rows.Clear(); comboBoxEx2.SelectedIndex = -1; } globeControl1.Globe.ClearAnalysis(); layerTemp.RemoveAllFeature(); globeControl1.Refresh(); } /// <summary> /// 碰撞分析功能界面中 选择图层下拉框 选中项改变事件处理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void comboBoxEx2_SelectedIndexChanged(object sender, EventArgs e) { if (comboBoxEx2.SelectedIndex > -1) { listBox2.Items.Clear(); dataGridViewX4.Rows.Clear(); dataGridViewX5.Rows.Clear(); GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(comboBoxEx2.SelectedItem.ToString()); if (layer == null) return; GSOFeatureLayer flayer = layer as GSOFeatureLayer; GSOFeatureDataset fdataset = flayer.Dataset as GSOFeatureDataset; GSOFeatures feats = flayer.GetAllFeatures(); for (int i = 0; i < feats.Length; i++) { int idx = dataGridViewX4.Rows.Add(); dataGridViewX4.Rows[idx].Cells[0].Value = comboBoxEx2.SelectedItem.ToString(); dataGridViewX4.Rows[idx].Cells[1].Value = feats[i].Name; } } } /// <summary> /// 清除所有图层中的所有feature对象的高亮状态 功能 /// </summary> private void clearFeatureHighLight() { for (int i = 0; i < globeControl1.Globe.Layers.Count; i++) { GSOLayer layer = globeControl1.Globe.Layers[i]; if (layer is GSOFeatureLayer) { GSOFeatures feats = layer.GetAllFeatures(); for (int j = 0; j < feats.Length; j++) { GSOFeature feat = feats[j]; feat.HighLight = false; GSOLineStyle3D lineStyle = feat.Geometry.Style as GSOLineStyle3D; if (lineStyle != null) { lineStyle.ArrowVisible = false; feat.Geometry.SetModified(true); } } } } if (globeControl1.Globe.Action == EnumAction3D.SelectObject) { globeControl1.Globe.Action = EnumAction3D.ActionNull; globeControl1.Globe.Action = EnumAction3D.SelectObject; } } /// <summary> /// 碰撞分析功能界面中 清除分析结果按钮 事件处理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonX8_Click(object sender, EventArgs e) { trackflag = ""; globeControl1.Globe.Action = EnumAction3D.ActionNull; checkBoxX3.Checked = false; checkBoxX4.Checked = false; comboBoxEx2.SelectedIndex = -1; comboBoxEx2.Enabled = false; dataGridViewX4.Rows.Clear(); dataGridViewX5.Rows.Clear(); listBox2.Items.Clear(); layerTemp.RemoveAllFeature(); globeControl1.Refresh(); } /// <summary> /// 碰撞分析功能界面中 导出Excel按钮 事件处理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonX6_Click(object sender, EventArgs e) { if (dataGridViewX5.Rows.Count > 0) { ExportExcel("碰撞分析", dataGridViewX5,listBox2); } else { MessageBox.Show("表格内容为空!", "提示"); } } /// <summary> /// 导出CAD 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnExportCAD_Click(object sender, EventArgs e) { FrmExportCADS frm = new FrmExportCADS(globeControl1,m_PipelineLayerNames); frm.ShowDialog(); } /// <summary> /// 区域分析 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem50_Click(object sender, EventArgs e) { buttonItem50.Checked = !buttonItem50.Checked; ribbonBarQY.Visible = buttonItem50.Checked; ribbonBarQY.Location = new Point(0, 0); } /// <summary> /// 连接数据库 菜单事件处理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ConnectDB(object sender, EventArgs e) { FrmDatabaseParaSetting frm = new FrmDatabaseParaSetting(globeControl1); if (frm.ShowDialog() == DialogResult.OK) { ds = FrmDatabaseParaSetting.ds; if (ds != null) { ds.IsCloseSaved = false; } } } /// <summary> /// 数据验证 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem80_Click(object sender, EventArgs e) { FrmValiData frm = new FrmValiData(globeControl1); frm.ShowDialog(); } /// <summary> /// 根据指定图层创建图层节点并将节点添加到图层管理节点的子节点集合中 /// </summary> /// <param name="layer"></param> private void addNodeToLayerManagerNode(GSOLayer layer) { if (layer != null) { GSODataset dataset = layer.Dataset; CheckDatasetGeoReference(layer.Dataset,""); TreeNode node = new TreeNode(); node.Tag = layer; node.Text = layer.Dataset.Caption; node.ImageIndex = 0; node.SelectedImageIndex = 0; node.Checked = layer.Visible; layerManagerNode.Nodes.Insert(0, node); layerManagerNode.Expand(); } } /// <summary> /// 数据库备份 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnBackDatabase_Click(object sender, EventArgs e) { if (MessageBox.Show("是否确定要备份数据库文件", "信息", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { try { DateTime currentTime = DateTime.Now; //string Dtime = currentTime.ToShortDateString().ToString("yyyy-MM-dd"); string Dtime = currentTime.GetDateTimeFormats('D')[0].ToString(); string Htime = DateTime.Now.ToString("HH时mm分ss秒").Trim(); string fileName = Dtime + "(" + Htime + ")"; string pathName = ""; string sql = "select filename from master..sysdatabases where name='" + Utility.dbdatabase + "'"; DataTable dt = OledbHelper.ExecuteDataTable(sql); if (dt != null && dt.Rows.Count > 0) { pathName = dt.Rows[0][0].ToString().Trim(); int count = pathName.LastIndexOf("\\") == -1 ? pathName.LastIndexOf("/") : pathName.LastIndexOf("\\"); pathName = pathName.Substring(0, count); } pathName += "\\管网数据库" + fileName + ".bak"; OracleCommand cmdBK = new OracleCommand(); cmdBK.CommandType = CommandType.Text; cmdBK.Connection = connBackup; cmdBK.CommandText = @"backup database " + Utility.dbdatabase + " to disk='" + pathName + "' with init"; connBackup.Open(); cmdBK.ExecuteNonQuery(); MessageBox.Show("数据库文件备份成功", "提示"); } catch (Exception ex) { MessageBox.Show(ex.Message); LogError.PublishError(ex); } finally { connBackup.Close(); } } } /// <summary> /// 缓冲分析 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem68_Click(object sender, EventArgs e) { //日志记录 LogManager.saveLog(Utility.userName, this.buttonItem68.Text); GSOFeature feat = globeControl1.Globe.SelectedObject; if (feat == null) { MessageBox.Show("请选择一条管线!"); buttonItem97.Checked = false; return; } GSOGeoPolyline3D line1 = feat.Geometry as GSOGeoPolyline3D; if (line1 == null) { MessageBox.Show("请选择一条管线!"); buttonItem97.Checked = false; return; } FrmBufferAnalysis frm = new FrmBufferAnalysis(globeControl1, line1,layerTemp); frm.ShowDialog(); } /// <summary> /// 附属物分析 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem69_Click(object sender, EventArgs e) { //日志记录 LogManager.saveLog(Utility.userName, this.buttonItem69.Text); globeControl1.Globe.Action = EnumAction3D.ActionNull; FrmAccessoryAnalysis dlg = new FrmAccessoryAnalysis(globeControl1, layerTemp); dlg.Show(this); } /// <summary> /// 爆管分析 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem70_Click(object sender, EventArgs e) { ClearCloseValvesAnalysis(); if (globeControl1.Globe.SelObjectCount < 1) { MessageBox.Show("请选中至少一个管线!!"); return; } GSOLayer resLayer = null; GSOFeature resFeature = null; globeControl1.Globe.GetSelectObject(0, out resFeature, out resLayer); GSOGeoPolyline3D line1 = resFeature.Geometry as GSOGeoPolyline3D; if (line1 == null) { MessageBox.Show("请选择管线!!"); return; } GSOPipeLineStyle3D pipeStyle1 = line1.Style as GSOPipeLineStyle3D; if (pipeStyle1 == null) { MessageBox.Show("请选择管线!!"); return; } GSOFeatures feats = globeControl1.Globe.MemoryLayer.GetFeatureByName("粒子要素", true); if (feats.Length > 0) globeControl1.Globe.MemoryLayer.RemoveFeatureByID(feats[0].ID); //if (emitterFeature != null) //{ // globeControl1.Globe.MemoryLayer.RemoveFeatureByID(emitterFeature.ID); //} GSOPoint3d pt = new GSOPoint3d(); double length = line1.GetSpaceLength(true, 6378137);//线的长度 GSOGeoPolyline3D lineLine = line1.GetSegment(0, length / 2); GSOPoint3d point3d = lineLine[lineLine.PartCount - 1][lineLine[lineLine.PartCount - 1].Count - 1]; pt.X = point3d.X; pt.Y = point3d.Y; pt.Z = point3d.Z ; pt.Z += pipeStyle1.Radius * 2; if (resLayer.Caption.Contains("气")) { globeControl1.Globe.UnderGroundFloor.Visible = true; AddFire(pt.X, pt.Y, pt.Z); } else if (resLayer.Caption.Contains("给水")) { globeControl1.Globe.UnderGroundFloor.Visible = true; AddFountain(pt.X, pt.Y, pt.Z); } else if (resLayer.Caption.Contains("热力")) { globeControl1.Globe.UnderGroundFloor.Visible = true; AddFountain(pt.X, pt.Y, pt.Z); } GSOPoint3d resIntersetPoint = new GSOPoint3d(); if (NetworkBoosterValvesAnalysis(resFeature, resIntersetPoint, resLayer)) { globeControl1.Globe.Action = EnumAction3D.ActionNull; } } //GSOFeature emitterFeature; // 粒子要素 /// <summary> /// 添加火苗 功能 /// </summary> /// <param name="x"></param> /// <param name="y"></param> /// <param name="z"></param> private void AddFire(double x, double y, double z) { GSOFeatures feats = globeControl1.Globe.MemoryLayer.GetFeatureByName("粒子要素", true); if (feats.Length > 0) globeControl1.Globe.MemoryLayer.RemoveFeatureByID(feats[0].ID); string strResPath = Application.StartupPath + "/Resource"; // 烟火粒子示例,由三个发射器构成 GSOGeoParticle geoParticle = new GSOGeoParticle(); geoParticle.SetPosition(x, y, z); // 添加到这个经纬度位置 geoParticle.AltitudeMode = EnumAltitudeMode.RelativeToGround; GSORingParticleEmitter emitter = new GSORingParticleEmitter(); emitter.TexturePath = strResPath + "/ParticleImage/flare1.png";//烟1111111111111 emitter.SetSizeFix(1, 1); emitter.VelFix = 1; emitter.VelRnd = 5; emitter.AngleXYFix = 0; emitter.AngleXYRnd = 180; emitter.AngleXZFix = 90; emitter.AngleXZRnd = 0; emitter.LifeFix = 0.5f; emitter.LifeRnd = 0.0f; emitter.RotFix = 0; emitter.RotRnd = 0; emitter.RotVelFix = 0; emitter.RotVelRnd = 0; emitter.EmitPerSec = 100; emitter.IsLumAdded = true; // 采用线性插值生成粒子的初始颜色 emitter.ColorRndStart = Color.White; emitter.ColorRndEnd = Color.Red; GSOColorParticleEffector effector2 = new GSOColorParticleEffector(); effector2.SetColorChanged(0, -1, -1, 0); effector2.StartTime = 0.0f; effector2.EndTime = -1.0f; emitter.AddEffector(effector2); // 将三个发射器添加到粒子对象中 geoParticle.AddEmitter(emitter); geoParticle.Play(); GSOFeature emitterFeature = new GSOFeature(); emitterFeature.Geometry = geoParticle; emitterFeature.Name = "粒子要素"; // globeControl1.Globe.MemoryLayer.AddFeature(emitterFeature); } /// <summary> /// 添加喷泉 功能 /// </summary> /// <param name="x"></param> /// <param name="y"></param> /// <param name="z"></param> private void AddFountain(double x, double y, double z) { GSOFeatures feats = globeControl1.Globe.MemoryLayer.GetFeatureByName("粒子要素", true); if (feats.Length > 0) globeControl1.Globe.MemoryLayer.RemoveFeatureByID(feats[0].ID); string strResPath = Application.StartupPath + "/Resource"; GSOGeoParticle geoParticle = new GSOGeoParticle(); geoParticle.SetPosition( x, y, z); // 添加到这个经纬度位置 geoParticle.AltitudeMode = EnumAltitudeMode.RelativeToGround; GSOPointParticleEmitter emitter = new GSOPointParticleEmitter(); emitter.TexturePath = strResPath + "/ParticleImage/test.png"; emitter.SetSizeFix(0.5f, 2); emitter.VelFix = 10; emitter.VelRnd = 2; emitter.GravityAcc = 9.8f; emitter.AngleXYFix = 0; emitter.AngleXYRnd = 180; emitter.AngleXZFix = 88; emitter.AngleXZRnd = 2; emitter.LifeFix = 5.0f; emitter.LifeRnd = 1.0f; emitter.RotFix = 0; emitter.RotRnd = 0; emitter.RotVelFix = 0; emitter.RotVelRnd = 0; emitter.EmitPerSec = 1000; emitter.ColorRndStart = Color.FromArgb(33, 255, 255, 255); emitter.ColorRndEnd = Color.FromArgb(11, 255, 255, 255); emitter.IsLumAdded = false; // 将三个发射器添加到粒子对象中 geoParticle.AddEmitter(emitter); geoParticle.Play(); GSOFeature emitterFeature = new GSOFeature(); emitterFeature.Geometry = geoParticle; emitterFeature.Name = "粒子要素"; // globeControl1.Globe.MemoryLayer.AddFeature(emitterFeature); //globeControl1.Globe.FlyToFeature(emitterFeature); } /// <summary> /// 标高标注 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem72_Click(object sender, EventArgs e) { //日志记录 LogManager.saveLog(Utility.userName, this.buttonItem72.Text); GSOFeature startFeature; GSOFeature endFeature; GSOFeature resFeature = IsPipeLineOfSelectedObj(); if (resFeature !=null) { GSOGeoPolyline3D selLine = resFeature.Geometry as GSOGeoPolyline3D; if (selLine[0].Count > 1) { setMarkerLayerUnVisible("标高标注"); GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption("标高标注"); layer.Visible = true; GSOGeoPoint3D startPoint = new GSOGeoPoint3D(); startPoint.X = selLine[0][0].X; startPoint.Y = selLine[0][0].Y; startPoint.Z = selLine[0][0].Z; string startLabelName = "起点标高:" + resFeature.GetFieldAsString("起始地面高程") + "米"; startFeature = new GSOFeature(); GSOPoint2d point2d = new GSOPoint2d(0, 80); if (getLabelName(layer) != -1) { startFeature = createLabel(layer,startFeature, startPoint, startLabelName, (getLabelName(layer)+1).ToString(), point2d); layer.AddFeature(startFeature); } GSOGeoPoint3D endPoint = new GSOGeoPoint3D(); endPoint.X = selLine[0][selLine[0].Count - 1].X; endPoint.Y = selLine[0][selLine[0].Count - 1].Y; endPoint.Z = selLine[0][selLine[0].Count - 1].Z; string endLabelName = "终点标高:" + resFeature.GetFieldAsString("终止地面高程") + "米"; endFeature = new GSOFeature(); if (getLabelName(layer) != -1) { endFeature = createLabel(layer,endFeature, endPoint, endLabelName, (getLabelName(layer) + 1).ToString(), point2d); layer.AddFeature(endFeature); } globeControl1.Refresh(); } } else { MessageBox.Show("请选中一根管线","提示",MessageBoxButtons.OK,MessageBoxIcon.Warning); } } /// <summary> /// 获取指定图层中最后一个feature对象的名称对应的整数 /// </summary> /// <param name="layer"></param> /// <returns></returns> public int getLabelName(GSOLayer layer) { int nid = -1; if (layer.GetAllFeatures().Length > 0) { string id = layer.GetAllFeatures()[layer.GetAllFeatures().Length - 1].Name; int.TryParse(id, out nid); } else { nid = 0; } return nid; } /// <summary> /// 设置除指定标注图层之外的所有标注图层不可见 /// </summary> /// <param name="layerName"></param> public void setMarkerLayerUnVisible(string layerName) { string[] markerStrs = new string[10]; markerStrs[0] = "标高标注"; markerStrs[1] = "管径标注"; markerStrs[2] = "埋深标注"; markerStrs[3] = "坐标标注"; markerStrs[4] = "坡度标注"; markerStrs[5] = "属性标注"; markerStrs[6] = "自定义标注"; markerStrs[7] = "距离标注"; markerStrs[8] = "红线工具"; markerStrs[9] = "扯旗标注"; for (int i = 0; i < markerStrs.Length; i++) { GSOLayer markerLayer = globeControl1.Globe.Layers.GetLayerByCaption(markerStrs[i]); if (markerLayer != null) { if (markerStrs[i] != layerName) { markerLayer.Visible = false; if (layerMarkerTree.Nodes[0].Nodes.Count > i) { layerMarkerTree.Nodes[0].Nodes[i].Checked = false; } } else { markerLayer.Visible = true; for (int j = 0; j < markerLayer.GetAllFeatures().Length; j++) { GSOFeature markerFeature = markerLayer.GetAt(j); if (markerFeature != null) { markerFeature.Visible = false; } } if (layerMarkerTree.Nodes[0].Nodes.Count > i) { layerMarkerTree.Nodes[0].Nodes[i].Checked = true; } } } } } /// <summary> /// 判断选中的对象是否为管线 /// </summary> /// <param name="resFeature">被选中管线</param> /// <returns>返回一根线</returns> private GSOFeature IsPipeLineOfSelectedObj() { GSOFeature resFeature = null; if (globeControl1.Globe.SelObjectCount < 1) { return null; } GSOLayer resLayer = null; globeControl1.Globe.GetSelectObject(0, out resFeature, out resLayer); if (resFeature == null) return null; GSOGeoPolyline3D line1 = resFeature.Geometry as GSOGeoPolyline3D; if (line1 == null) { return null; } GSOPipeLineStyle3D pipeStyle1 = line1.Style as GSOPipeLineStyle3D; if (pipeStyle1 == null) { return null; } return resFeature; } /// <summary> /// 创建label要素 功能 /// </summary> /// <param name="feature">添加label要素的feature</param> /// <param name="point">feature的位置</param> /// <param name="labelName">label要素名字</param> /// <param name="featureName">feature名字</param> /// <param name="point2d">label要素距离点的位置</param> /// <returns></returns> private GSOFeature createLabel(GSOLayer layer,GSOFeature feature, GSOGeoPoint3D point, string labelName, string featureName, GSOPoint2d point2d) { for (int i = layer.GetAllFeatures().Length - 1; i >= 0; i--) { GSOFeature gfeat = layer.GetAt(i); if (gfeat != null && gfeat.Geometry != null && gfeat.Geometry.Type == EnumGeometryType.GeoPoint3D) { GSOGeoPoint3D pointItem = gfeat.Geometry as GSOGeoPoint3D; if (pointItem.X == point.X && pointItem.Y == point.Y && pointItem.Z == point.Z) { layer.RemoveAt(i); break; } } } point.AltitudeMode = EnumAltitudeMode.RelativeToGround; feature.Geometry = point; feature.Name = featureName; GSOLabel newLabel = new GSOLabel(); newLabel.Text = labelName; newLabel.Style = new GSOLabelStyle(); newLabel.Style.Opaque = 0.8; newLabel.Style.OutlineColor = Color.Gray; newLabel.Style.TractionLineEndPos = point2d; newLabel.Style.OutlineWidth = 1; newLabel.Style.TracktionLineWidth = 1; newLabel.Style.TractionLineColor = Color.Green; Color color1 = Color.FromArgb(60, 187, 206, 230); Color color2 = Color.FromArgb(150, 187, 200, 250); newLabel.Style.BackBeginColor = color1; newLabel.Style.BackEndColor = color2; feature.Label = newLabel; return feature; } GSOFeature radiusMarkerFeature; /// <summary> /// 管径标注 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem73_Click(object sender, EventArgs e) { //日志记录 LogManager.saveLog(Utility.userName, this.buttonItem73.Text); GSOFeature resFeature = IsPipeLineOfSelectedObj(); if (resFeature != null) { GSOGeoPolyline3D selLine = resFeature.Geometry as GSOGeoPolyline3D; if (selLine[0].Count > 1) { setMarkerLayerUnVisible("管径标注"); GSOLayer radiusMarkerLayer = globeControl1.Globe.Layers.GetLayerByCaption("管径标注"); if (radiusMarkerLayer == null) { radiusMarkerLayer = globeControl1.Globe.MemoryLayer; } //radiusMarkerLayer.Visible = true; GSOGeoPoint3D pt = new GSOGeoPoint3D(); GSOPoint3d point3d = selLine.GeoCenterPoint; pt.X = point3d.X; pt.Y = point3d.Y; pt.Z = point3d.Z; string radiusLabelName = "管径:" + resFeature.GetFieldAsFloat("管径_毫米") + "毫米"; radiusMarkerFeature = new GSOFeature(); GSOPoint2d point2d = new GSOPoint2d(0, 50); if (radiusMarkerLayer != null) { if (getLabelName(radiusMarkerLayer) != -1) { radiusMarkerFeature = createLabel(radiusMarkerLayer,radiusMarkerFeature, pt, radiusLabelName, (getLabelName(radiusMarkerLayer)+1).ToString(), point2d); radiusMarkerFeature.Visible = true; radiusMarkerLayer.AddFeature(radiusMarkerFeature); } } globeControl1.Refresh(); } } else { MessageBox.Show("请选中一根管线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } /// <summary> /// 埋深标注 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem74_Click(object sender, EventArgs e) { //日志记录 LogManager.saveLog(Utility.userName, this.buttonItem74.Text); GSOFeature startDeepFeature; GSOFeature endDeepFeature; GSOFeature resFeature = IsPipeLineOfSelectedObj(); if (resFeature != null) { GSOGeoPolyline3D selLine = resFeature.Geometry as GSOGeoPolyline3D; if (selLine[0].Count > 1) { setMarkerLayerUnVisible("埋深标注"); GSOLayer l = globeControl1.Globe.Layers.GetLayerByCaption("埋深标注"); l.Visible = true; GSOGeoPoint3D startPoint = new GSOGeoPoint3D(); startPoint.X = selLine[0][0].X; startPoint.Y = selLine[0][0].Y; startPoint.Z = selLine[0][0].Z; string startLabelName = "起点埋深:" + resFeature.GetFieldAsString("起始埋深") + "米"; GSOPoint2d point2d = new GSOPoint2d(0, 60); if (l != null) { if (getLabelName(l) != -1) { startDeepFeature = new GSOFeature(); startDeepFeature = createLabel(l,startDeepFeature, startPoint, startLabelName, (getLabelName(l)+1).ToString(), point2d); l.AddFeature(startDeepFeature); } } GSOGeoPoint3D endPoint = new GSOGeoPoint3D(); endPoint.X = selLine[0][selLine[0].Count - 1].X; endPoint.Y = selLine[0][selLine[0].Count - 1].Y; endPoint.Z = selLine[0][selLine[0].Count - 1].Z; string endLabelName = "终点埋深:" + resFeature.GetFieldAsString("终止埋深") + "米"; if (l != null) { if (getLabelName(l) != -1) { endDeepFeature = new GSOFeature(); endDeepFeature = createLabel(l,endDeepFeature, endPoint, endLabelName, (getLabelName(l) + 1).ToString(), point2d); l.AddFeature(endDeepFeature); } } globeControl1.Refresh(); } } else { MessageBox.Show("请选中一根管线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } bool distanceMarker = false; /// <summary> /// 距离标注 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem75_Click(object sender, EventArgs e) { //日志记录 LogManager.saveLog(Utility.userName, this.buttonItem75.Text); globeControl1.Globe.Action = EnumAction3D.TrackPolyline; //globeControl1.Globe.DistanceRuler.MeasureMode = EnumDistanceMeasureMode.HVSLineMeasure; distanceMarker = true; } /// <summary> /// 坐标标注 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem76_Click(object sender, EventArgs e) { //日志记录 LogManager.saveLog(Utility.userName, this.buttonItem76.Text); GSOFeature startXYFeature; GSOFeature endXYFeature; GSOFeature resFeature = IsPipeLineOfSelectedObj(); if (resFeature != null) { GSOGeoPolyline3D selLine = resFeature.Geometry as GSOGeoPolyline3D; if (selLine[0].Count > 1) { setMarkerLayerUnVisible("坐标标注"); GSOLayer l = globeControl1.Globe.Layers.GetLayerByCaption("坐标标注"); l.Visible = true; GSOGeoPoint3D startPoint = new GSOGeoPoint3D(); startPoint.X = selLine[0][0].X; startPoint.Y = selLine[0][0].Y; startPoint.Z = selLine[0][0].Z; string startLabelName = "起点坐标:(" + selLine[0][0].X.ToString("0.00") + "," + selLine[0][0].Y.ToString("0.00") + "," + selLine[0][0].Z.ToString("0.00") + ")"; GSOPoint2d point2d = new GSOPoint2d(0, 100); if (l != null) { if (getLabelName(l) != -1) { startXYFeature = new GSOFeature(); startXYFeature = createLabel(l,startXYFeature, startPoint, startLabelName, (getLabelName(l) + 1).ToString(), point2d); l.AddFeature(startXYFeature); } } GSOGeoPoint3D endPoint = new GSOGeoPoint3D(); endPoint.X = selLine[0][selLine[0].Count - 1].X; endPoint.Y = selLine[0][selLine[0].Count - 1].Y; endPoint.Z = selLine[0][selLine[0].Count - 1].Z; string endLabelName = "终点坐标:(" + selLine[0][selLine[0].Count - 1].X.ToString("0.00") + "," + selLine[0][selLine[0].Count - 1].Y.ToString("0.00") + "," + selLine[0][selLine[0].Count - 1].Z.ToString("0.00") + ")"; if (l != null) { if (getLabelName(l) != -1) { endXYFeature = new GSOFeature(); endXYFeature = createLabel(l,endXYFeature, endPoint, endLabelName, (getLabelName(l) + 1).ToString(), point2d); l.AddFeature(endXYFeature); } } globeControl1.Refresh(); } } else { MessageBox.Show("请选中一根管线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } /// <summary> /// 标注管理 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem77_Click(object sender, EventArgs e) { buttonItem77.Checked = !buttonItem77.Checked; //buttonItem139.Checked = false; string[] markerStrs = new string[10]; markerStrs[0] = "标高标注"; markerStrs[1] = "管径标注"; markerStrs[2] = "埋深标注"; markerStrs[3] = "坐标标注"; markerStrs[4] = "坡度标注"; markerStrs[5] = "属性标注"; markerStrs[6] = "自定义标注"; markerStrs[7] = "距离标注"; markerStrs[8] = "红线工具"; markerStrs[9] = "扯旗标注"; if (buttonItem77.Checked) { sideBar1.Visible = true; sideBarPanelItem3.Visible = true; buttonItem1.Checked = true; controlContainerItem3.Visible = true; sideBarPanelItem4.Visible = true; sideBarPanelItem4.Text = "标注管理"; panel2.Visible = false; panel1.Visible = false; panel4.Visible = false; panel5.Visible = false; controlContainerItem5.Control = panel3; panel3.Dock = DockStyle.Fill; panel3.Visible = true; sideBar1.ExpandedPanel = sideBarPanelItem4; sideBar1.Refresh(); Refresh(); } else { globeControl1.Globe.Action = EnumAction3D.ActionNull; sideBarPanelItem4.Visible = false; panel3.Visible = false; if (buttonItem1.Checked) { sideBar1.ExpandedPanel = sideBarPanelItem3; } else { sideBar1.Visible = false; } Refresh(); } } /// <summary> /// 红线工具 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem36_Click(object sender, EventArgs e) { setMarkerLayerUnVisible("红线工具"); GSOLayer l = globeControl1.Globe.Layers.GetLayerByCaption("红线工具"); if (l != null) { l.Visible = true; globeControl1.Globe.DestLayerFeatureAdd = l; l.Editable = true; globeControl1.Globe.Action = EnumAction3D.DrawPolygon; m_isDrawRedPology = true; } } /// <summary> /// 地表距离 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem64_Click_1(object sender, EventArgs e) { //日志记录 LogManager.saveLog(Utility.userName, this.buttonItem64.Text); btnSpaceMeasureHeight.Checked = false; globeControl1.Globe.Action = EnumAction3D.MeasureDistance; globeControl1.Globe.DistanceRuler.SpaceMeasure = false; } /// <summary> /// 水平面积量算 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem78_Click(object sender, EventArgs e) { //日志记录 LogManager.saveLog(Utility.userName, this.buttonItem78.Text); btnSpaceMeasureHeight.Checked = false; globeControl1.Globe.Action = EnumAction3D.MeasureArea; globeControl1.Globe.AreaRuler.SpaceMeasure = true; } /// <summary> /// 获取指定两点组成的线的长度 功能 /// </summary> /// <param name="point1"></param> /// <param name="point2"></param> /// <returns></returns> private double getDistance(GSOPoint3d point1, GSOPoint3d point2) { GSOGeoPolyline3D lineline = new GSOGeoPolyline3D(); GSOPoint3ds point3ds = new GSOPoint3ds(); point3ds.Add(point1); point3ds.Add(point2); lineline.AddPart(point3ds); double distance = lineline.GetSpaceLength(true, 6378137.0); return distance; } /// <summary> /// 判断管线是否相通 功能 /// </summary> /// <returns></returns> public bool isInterlinked() { if (globeControl1.Globe.SelObjectCount < 2) { MessageBox.Show("请选中至少两个管线!!"); btnLTAnalysis.Checked = false; return false; } ClearConnexityAnalysis(); globeControl1.Globe.GetSelectObject(0, out m_ConnexityAnalysisFirstFeature, out m_ConnexityAnalysisFirstLayer); globeControl1.Globe.GetSelectObject(1, out m_ConnexityAnaylsisSecondFeature, out m_COnnexityAnalysisSecondLayer); GSOGeoPolyline3D line1 = m_ConnexityAnalysisFirstFeature.Geometry as GSOGeoPolyline3D; GSOGeoPolyline3D line2 = m_ConnexityAnaylsisSecondFeature.Geometry as GSOGeoPolyline3D; if (line1 == null || line2 == null) { MessageBox.Show("请选择管线!!"); return false; } GSOPipeLineStyle3D pipeStyle1 = line1.Style as GSOPipeLineStyle3D; GSOPipeLineStyle3D pipeStyle2 = line2.Style as GSOPipeLineStyle3D; if (pipeStyle1 == null || pipeStyle2 == null) { MessageBox.Show("请选择管线!!"); return false; } if (!m_ConnexityAnalysisFirstLayer.IsSameInnerObject(m_COnnexityAnalysisSecondLayer)) { MessageBox.Show("不在同一个图层!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); ClearConnexityAnalysis(); return false; } else { GSODataset curCAYDataset = m_ConnexityAnalysisFirstLayer.Dataset; string srName = curCAYDataset.Name; GSONetworkDataset curCAYNDataset = curCAYDataset.DataSource.GetDatasetByName(srName + "Network") as GSONetworkDataset; if (curCAYNDataset == null) { MessageBox.Show("该图层没有创建网络拓扑,请先创建网络拓扑信息再进行分析!", "提示"); return false; } int[] arryResID; curCAYNDataset.ConnexityAnalysis(m_ConnexityAnalysisFirstFeature.ID, m_ConnexityAnaylsisSecondFeature.ID, out arryResID, false, true); m_ConnexityAnalyResFeatures = m_ConnexityAnalysisFirstLayer.GetFeaturesByIDs(arryResID); if (m_ConnexityAnalyResFeatures == null || m_ConnexityAnalyResFeatures.Length < 1) { String strLine1 = "管线:" + m_ConnexityAnalysisFirstFeature.ID; String strLine2 = "管线:" + m_ConnexityAnaylsisSecondFeature.ID; MessageBox.Show("请选择两条相通的管线!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return false; } else { return true; } } } /// <summary> /// 坡度标注 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem81_Click(object sender, EventArgs e) { //日志记录 LogManager.saveLog(Utility.userName, this.buttonItem81.Text); GSOFeature resFeature = IsPipeLineOfSelectedObj(); if (resFeature != null) { GSOGeoPolyline3D selLine = resFeature.Geometry as GSOGeoPolyline3D; if (selLine[0].Count > 1) { setMarkerLayerUnVisible("坡度标注"); GSOLayer l = globeControl1.Globe.Layers.GetLayerByCaption("坡度标注"); if (l != null) { l.Visible = true; GSOGeoPoint3D pt = new GSOGeoPoint3D(); GSOPoint3d point3d = selLine.GeoCenterPoint; pt.X = point3d.X; pt.Y = point3d.Y; pt.Z = point3d.Z; if (getLabelName(l) != -1) { GSOPoint3ds pts = new GSOPoint3ds(); pts.Add(selLine[0][0]); pts.Add(selLine[0][1]); GSOGeoPolyline3D newLine = new GSOGeoPolyline3D(); newLine.AddPart(pts); double newFeatLen = newLine.GetSpaceLength(true, 6378137.0); double z = selLine[0][1].Z - selLine[0][0].Z; double i = Convert.ToDouble(z / newFeatLen); double a = Math.Atan(i) * 180 / Math.PI; string radiusLabelName = "坡度:" + resFeature.GetFieldAsFloat("管径_毫米"); radiusMarkerFeature = new GSOFeature(); GSOPoint2d point2d = new GSOPoint2d(0, 70); radiusMarkerFeature = createLabel(l, radiusMarkerFeature, pt, "坡度:" + i.ToString("0.0000") + "度 坡角:" + a.ToString("0.0000") + "度", (getLabelName(l) + 1).ToString(), point2d); l.AddFeature(radiusMarkerFeature); globeControl1.Refresh(); } } } } else { MessageBox.Show("请选中一根管线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } /// <summary> /// 属性标注 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem83_Click(object sender, EventArgs e) { //日志记录 LogManager.saveLog(Utility.userName, this.buttonItem83.Text); if (globeControl1.Globe.SelectedObject != null) { GSOFeature f = globeControl1.Globe.SelectedObject; if (f.Geometry.Type != EnumGeometryType.GeoPolyline3D) { MessageBox.Show("请选择一条管线!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } GSOLayer l = globeControl1.Globe.SelectedObjectLayer; if (l.Type == EnumLayerType.FeatureLayer) { GSOFeatureDataset fDataset = l.Dataset as GSOFeatureDataset; if (fDataset != null) { FrmPropertiesMarker frm = new FrmPropertiesMarker(globeControl1, l, f); if (frm.ShowDialog() == DialogResult.OK) { setMarkerLayerUnVisible("属性标注"); l = globeControl1.Globe.Layers.GetLayerByCaption("属性标注"); if (l != null) { l.Visible = true; if (getLabelName(l) != -1) { GSOGeoPolyline3D line = f.Geometry as GSOGeoPolyline3D; if (line.PartCount > 0) { GSOGeoPoint3D pt = new GSOGeoPoint3D(); GSOPoint3d point3d = line.GeoCenterPoint; pt.X = point3d.X; pt.Y = point3d.Y; pt.Z = point3d.Z; string radiusLabelName = frm.labelText; GSOFeature newF = new GSOFeature(); GSOPoint2d point2d = new GSOPoint2d(0, 110); newF = createLabel(l,newF, pt, radiusLabelName, (getLabelName(l) + 1).ToString(), point2d); l.AddFeature(newF); globeControl1.Refresh(); } } } } } } } else { MessageBox.Show("请选择一条管线!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } } /// <summary> /// 自定义标注 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem84_Click(object sender, EventArgs e) { //日志记录 LogManager.saveLog(Utility.userName, this.buttonItem84.Text); if (globeControl1.Globe.SelObjectCount == 1 && globeControl1.Globe.SelectedObject.Geometry != null && globeControl1.Globe.SelectedObject.Geometry.Type == EnumGeometryType.GeoPolyline3D) { GSOFeature f = globeControl1.Globe.SelectedObject; FrmCustomLabel frm = new FrmCustomLabel(globeControl1, globeControl1.Globe.SelectedObjectLayer, f); if (frm.ShowDialog() == DialogResult.OK) { setMarkerLayerUnVisible("自定义标注"); GSOLayer l = globeControl1.Globe.Layers.GetLayerByCaption("自定义标注"); if (l != null) { l.Visible = true; if (getLabelName(l) != -1) { GSOGeoPolyline3D line = f.Geometry as GSOGeoPolyline3D; if (line.PartCount > 0) { GSOGeoPoint3D pt = new GSOGeoPoint3D(); GSOPoint3d point3d = line.GeoCenterPoint; pt.X = point3d.X; pt.Y = point3d.Y; pt.Z = point3d.Z; string radiusLabelName = frm.labelText; GSOFeature newF = new GSOFeature(); GSOPoint2d point2d = new GSOPoint2d(0, 90); newF = createLabel(l,newF, pt, radiusLabelName, (getLabelName(l) + 1).ToString(), point2d); l.AddFeature(newF); globeControl1.Refresh(); } } } } } else { MessageBox.Show("请选择一条管线!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information); } } /// <summary> /// 图层节点树中 节点 右键单击事件处理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void layerMarkerTree_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e) { if (e.Button == MouseButtons.Right) { if (e.Node.Text == "标注管理" || e.Node.Text == "传感器管理") { return; } else if (e.Node.Parent.Text == "标注管理") { layerMarkerTree.SelectedNode = e.Node; contextMenuStrip2.Show(layerMarkerTree, e.X, e.Y); contextMenuStrip2.Tag = e.Node; } else if (e.Node.Parent.Text == "传感器管理") { layerSensorTree.SelectedNode = e.Node; contextMenuStrip2.Show(layerSensorTree, e.X, e.Y); contextMenuStrip2.Tag = e.Node; } else { if (e.Node.Tag is GSOFeature) { if (e.Node.Parent.Parent.Text == "标注管理") { layerMarkerTree.SelectedNode = e.Node; contextMenuStrip3.Show(layerMarkerTree, e.X, e.Y); contextMenuStrip3.Tag = e.Node; } else if (e.Node.Parent.Parent.Text == "传感器管理") { layerSensorTree.SelectedNode = e.Node; contextMenuStrip3.Show(layerSensorTree, e.X, e.Y); contextMenuStrip3.Tag = e.Node; } } } } } /// <summary> /// 标注管理、传感器管理 图层目录树的右键菜单中的 刷新列表 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void toolStripMenuItem1_Click(object sender, EventArgs e) { TreeNode node = contextMenuStrip2.Tag as TreeNode; TreeNode parentNode = node.Parent; Int32 nIndex = node.Index; if (parentNode.Text == "标注管理" || parentNode.Text == "传感器管理") { RefreshTreeNodeLayerFeatureList(node); } } /// <summary> /// 给指定的图层节点添加代表feature对象的子节点 /// </summary> /// <param name="layerTreeNode"></param> private void RefreshTreeNodeLayerFeatureList(TreeNode layerTreeNode) { layerTreeNode.Nodes.Clear(); GSOLayer layer = (GSOLayer)layerTreeNode.Tag; // 只将类型为内存数据集的图层列出,如果是其它类型的数据集可能数据量太大,没发显示在树控件中 if (layer.Dataset is GSOFeatureDataset) { VisitFeature3Ds(layer.GetAllFeatures(), layerTreeNode); } } /// <summary> /// 标注管理、传感器管理 图层目录树的右键菜单中的 移除所有 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void toolStripMenuItem2_Click(object sender, EventArgs e) { TreeNode node = contextMenuStrip3.Tag as TreeNode; GSOFeature feature3d = node.Tag as GSOFeature; if (node == null) { return; } if (feature3d != null) { feature3d.Delete(); globeControl1.Globe.Refresh(); node.Remove(); } } /// <summary> /// 图层目录树的 节点对应的复选框选中状态改变事件处理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void layerMarkerTree_AfterCheck(object sender, TreeViewEventArgs e) { if (e.Action != TreeViewAction.Unknown) { CheckTreeNode(e.Node, e.Node.Checked); } } /// <summary> /// 改变指定节点对应的复选框的选中状态 /// </summary> /// <param name="node"></param> /// <param name="bChecked"></param> private void CheckTreeNode(TreeNode node, Boolean bChecked) { CheckChildTreeNode(node, bChecked); globeControl1.Globe.Refresh(); } /// <summary> /// 改变指定节点的子节点对应的复选框的选中状态 /// </summary> /// <param name="node"></param> /// <param name="bChecked"></param> private void CheckChildTreeNode(TreeNode node, Boolean bChecked) { if (node == null) { return; } if (node.Tag != null) { if (node.Tag.GetType() == typeof(GSOFeatureFolder) || node.Tag.GetType() == typeof(GSOFeature)) { ((GSOFeature)node.Tag).SetVisibleDirectly(bChecked); } else { GSOLayer curLayer = node.Tag as GSOLayer; GSOTerrain curTerrain = node.Tag as GSOTerrain; if (curLayer != null) { curLayer.Visible = bChecked; } else if (curTerrain != null) { curTerrain.Visible = bChecked; } } } // 递归处理子节点 for (int i = 0; i < node.Nodes.Count; i++) { node.Nodes[i].Checked = bChecked; CheckChildTreeNode(node.Nodes[i], bChecked); } } /// <summary> /// 标注管理、传感器管理 目录树中的feature节点的右键菜单中的 删除 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void 删除ToolStripMenuItem1_Click(object sender, EventArgs e) { TreeNode node = contextMenuStrip2.Tag as TreeNode; GSOLayer l = globeControl1.Globe.Layers.GetLayerByCaption(node.Text); if (l != null) { l.RemoveAllFeature(); node.Nodes.Clear(); globeControl1.Refresh(); } } /// <summary> /// 双屏对比 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> //private void buttonItem94_Click(object sender, EventArgs e) //{ // buttonItem94.Checked = !buttonItem94.Checked; // splitContainer1.Panel2Collapsed = !buttonItem94.Checked; // if (buttonItem94.Checked) // { // buttonItem95.Enabled = true; // buttonItem96.Enabled = true; // sideBar1.Visible = false; // buttonItem1.Checked = false; // for (int i = globeControl2.Globe.Layers.Count - 1; i >= 0 ; i--) // { // GSOLayer layer = globeControl2.Globe.Layers[i]; // if (!layer.Name.Contains("fttp:")) // { // globeControl2.Globe.Layers.Remove(layer); // } // } // globeControl2.Globe.GroundOpaque = globeControl1.Globe.GroundOpaque; // FrmDataBaseOpt frm = new FrmDataBaseOpt(globeControl2); // frm.Show(this); // globeControl2.Globe.Refresh(); // } // else // { // buttonItem95.Enabled = false; // buttonItem96.Enabled = false; // sideBar1.Visible = true; // buttonItem1.Checked = true; // sideBarPanelItem3.Visible = true; // layerTree.Visible = true; // controlContainerItem3.Visible = true; // Refresh(); // } //} /// <summary> /// 模拟分析 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> //private void buttonItem51_Click(object sender, EventArgs e) //{ // buttonItem51.Checked = !buttonItem51.Checked; // ribbonBarMN.Visible = buttonItem51.Checked; // ribbonBarMN.Location = new Point(0, 0); //} /// <summary> /// 双屏设置 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> //private void buttonItem96_Click(object sender, EventArgs e) //{ // FrmLayerControl frm = new FrmLayerControl(layerTree,globeControl1,globeControl2); // frm.Show(this); //} /// <summary> /// 双屏联动 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> //private void buttonItem95_Click(object sender, EventArgs e) //{ // buttonItem95.Checked = !buttonItem95.Checked; //} ///// <summary> /// 添加用户仓库 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem108_Click(object sender, EventArgs e) { FrmUserRepo frm = new FrmUserRepo(-1); frm.ShowDialog(); } /// <summary> /// 用户仓库管理 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem111_Click(object sender, EventArgs e) { FrmUserRepoMgr frm = new FrmUserRepoMgr(); frm.ShowDialog(); } /// <summary> /// 添加分系统 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem112_Click(object sender, EventArgs e) { //FrmAPP frm = new FrmAPP(-1); //frm.ShowDialog(); } /// <summary> /// 分系统管理 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem113_Click(object sender, EventArgs e) { //FrmAPPMgr frm = new FrmAPPMgr(); //frm.ShowDialog(); } /// <summary> /// 添加操作 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem114_Click(object sender, EventArgs e) { FrmOper frm = new FrmOper(-1); frm.ShowDialog(); } /// <summary> /// 操作管理 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem115_Click(object sender, EventArgs e) { FrmOperMgr frm = new FrmOperMgr(); frm.ShowDialog(); } /// <summary> /// 添加资源 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem116_Click(object sender, EventArgs e) { FrmRESC frm = new FrmRESC(-1); frm.ShowDialog(); } /// <summary> /// 资源管理 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem117_Click(object sender, EventArgs e) { FrmRESCMgr frm = new FrmRESCMgr(); frm.ShowDialog(); } /// <summary> /// 添加权限 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem118_Click(object sender, EventArgs e) { FrmPerm frm = new FrmPerm(-1); frm.ShowDialog(); } /// <summary> /// 权限管理 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem119_Click(object sender, EventArgs e) { FrmPermMgr frm = new FrmPermMgr(); frm.ShowDialog(); } /// <summary> /// 添加访问控制 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem120_Click(object sender, EventArgs e) { FrmAccess frm = new FrmAccess(-1); frm.ShowDialog(); } /// <summary> /// 访问控制管理 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem121_Click(object sender, EventArgs e) { FrmAccessMgr frm = new FrmAccessMgr(); frm.ShowDialog(); } /// <summary> /// 部门类型管理 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem122_Click(object sender, EventArgs e) { FrmRegionTypeMgr frm = new FrmRegionTypeMgr(); frm.ShowDialog(); } /// <summary> /// 添加用户 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem127_Click(object sender, EventArgs e) { FrmUserAdd frm = new FrmUserAdd(-1); frm.ShowDialog(); } /// <summary> /// 用户信息管理 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem128_Click_1(object sender, EventArgs e) { FrmUserManager frm = new FrmUserManager(); frm.ShowDialog(); } /// <summary> /// 添加角色 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void 添加角色_Click(object sender, EventArgs e) { FrmRole frm = new FrmRole(-1); frm.ShowDialog(); } /// <summary> /// 所有角色管理 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void 角色管理_Click(object sender, EventArgs e) { FrmRoleMgr frm = new FrmRoleMgr(); frm.ShowDialog(); } /// <summary> /// 用户角色管理 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem136_Click(object sender, EventArgs e) { FrmUserRoleMgr frm = new FrmUserRoleMgr(); frm.ShowDialog(); } /// <summary> /// 部门角色管理 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem133_Click(object sender, EventArgs e) { FrmRegionRoleMgr frm = new FrmRegionRoleMgr(); frm.ShowDialog(); } /// <summary> /// 部门管理 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem130_Click(object sender, EventArgs e) { FrmRegionMgr frm = new FrmRegionMgr(); frm.ShowDialog(); } /// <summary> /// 日志管理 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem135_Click(object sender, EventArgs e) { FrmLogManager frm = new FrmLogManager(); frm.ShowDialog(); } /// <summary> /// 传感器信息查询 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem131_Click_1(object sender, EventArgs e) { GSOFeature selectedFeature = globeControl1.Globe.SelectedObject; if (selectedFeature == null) { MessageBox.Show("请选择一个传感器对象!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { if (selectedFeature.Geometry != null && selectedFeature.Geometry.Type == EnumGeometryType.GeoModel) { GSOLayer layer = globeControl1.Globe.SelectedObjectLayer; string tabelName = getTableName(layer.Caption); string eqtID = selectedFeature.Description.Trim(); if (tabelName != "" && eqtID != "") { string fields = getFields(tabelName); if (fields != "") { string sql = "select " + fields + " from " + Utility.sensorDatabase + "." + tabelName + " where EqtID=" + eqtID + " order by RecordDate desc limit 1;"; DataTable dt = MySqlHelper.queryDataTable(sql); if (dt != null && dt.Rows.Count > 0) { FrmQueryMessage.ShowForm(this, dt, layer.Caption); //queryMessage.Show(this); } else { MessageBox.Show("没有查询到相关信息!", "提示"); } } else { MessageBox.Show("配置文件 \"sensorConfig.xml\" 有误!", "提示"); } } else { MessageBox.Show("请选择一个传感器对象!", "提示"); } } else { MessageBox.Show("请选择一个传感器对象!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } /// <summary> /// 根据指定的图层的caption属性的值在配置文件中查找对应的数据库中的表的名称 /// </summary> /// <param name="name">图层的caption属性的值</param> /// <returns>对应的数据库中的表的名称</returns> private string getTableName(string name) { string tabelName = ""; if (Utility.sensorMarkerLayers != null) { for (int i = 0; i < Utility.sensorMarkerLayers.Count; i++) { MarkerLayer mLayer = Utility.sensorMarkerLayers[i]; if (mLayer.layerName == name) { tabelName = mLayer.tableName; break; } } } return tabelName; } /// <summary> /// 根据数据库中的表的名称 查找对应的表中的字段名称的集合 /// </summary> /// <param name="tabelName">数据库中的表的名称</param> /// <returns>对应的表中的字段名称的集合</returns> private string getFields(string tabelName) { string fields = ""; if (Utility.sensorMarkerLayers != null) { for (int i = 0; i < Utility.sensorMarkerLayers.Count; i++) { MarkerLayer mLayer = Utility.sensorMarkerLayers[i]; if (mLayer.tableName.Trim() == tabelName.Trim()) { if (mLayer.fields != null) { foreach (string key in mLayer.fields.Keys) { string value = mLayer.fields[key]; fields += tabelName.Trim() + "." + key + " as " + value + ","; } fields = fields.Remove(fields.Length - 1); } break; } } } return fields; } /// <summary> /// 历史曲线查询 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem132_Click(object sender, EventArgs e) { GSOFeature selectedFeature = globeControl1.Globe.SelectedObject; if (selectedFeature == null) { MessageBox.Show("请选择一个对象!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { if (selectedFeature.Geometry != null && selectedFeature.Geometry.Type == EnumGeometryType.GeoModel) { GSOLayer layer = globeControl1.Globe.SelectedObjectLayer; string tabelName = getTableName(layer.Caption); string eqtID = selectedFeature.Description; if (tabelName != "" && eqtID != "") { FrmQueryHistory.ShowForm(this, tabelName, eqtID); } else { MessageBox.Show("请选择一个传感器对象!", "提示"); } } else { MessageBox.Show("请选择一个传感器对象!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } //定时检查传感器的状态 public System.Windows.Forms.Timer timerOfSensor = null; public int alarmValueLiuLiang = 0; public int alarmValueYaLi = 0; public int alarmValueYeTi = 0; public int alarmValueZaoSheng = 0; /// <summary> /// 传感器在线报警 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem134_Click(object sender, EventArgs e) { if (timerOfSensor == null) { timerOfSensor = new System.Windows.Forms.Timer(); timerOfSensor.Interval = 30000; timerOfSensor.Tick += new EventHandler(timerOfSensor_Tick); } FrmQuerySensorAlarm.ShowForm(this); } /// <summary> /// 传感器报警 功能中的 定时器 的触发事件处理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void timerOfSensor_Tick(Object sender, EventArgs e) { checkSensor(); } private void checkSensor() { if (Utility.sensorMarkerLayers != null) { for (int i = 0; i < Utility.sensorMarkerLayers.Count; i++) { MarkerLayer mLayer = Utility.sensorMarkerLayers[i]; if (mLayer.alarmValue > 0) { string sql = "select *,max(CollectTime) from " + Utility.sensorDatabase + "." + mLayer.tableName + " group by EqtID;";// "select * from " + Utility.sensorDatabase + "." + mLayer.tableName + " order by CollectTime desc limit 1;"; DataTable dt = MySqlHelper.queryDataTable(sql); if (dt != null && dt.Rows.Count > 0) { for (int j = 0; j < dt.Rows.Count; j++) { try { string EqtID = dt.Rows[j]["EqtID"].ToString().Trim(); string RecordDateDATE = dt.Rows[j]["RecordDate"].ToString().Trim(); string RecordTimeTIME = dt.Rows[j]["RecordTime"].ToString().Trim(); string CollectTime = dt.Rows[j]["CollectTime"].ToString().Trim(); string CollectValue = ""; if (mLayer.tableName == "Data_3a") { CollectValue = dt.Rows[j]["InstantValue"].ToString().Trim(); } else { CollectValue = dt.Rows[j]["CollectValue"].ToString().Trim(); } int value = 0; if (int.TryParse(CollectValue, out value)) { if (value > mLayer.alarmValue) { GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(mLayer.layerName); if (layer != null) { for (int m = 0; m < layer.GetAllFeatures().Length; m++) { GSOFeature f = layer.GetAt(m); if (f != null && f.Description.Trim() == EqtID) { f.HighLight = true; globeControl1.Globe.Refresh(); LogError.PublishAlarmMessage(f.Name, EqtID, CollectValue, CollectTime); break; } } } } } } catch (Exception ex) { continue; } } } } } } } /// <summary> /// 清除标注 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem137_Click(object sender, EventArgs e) { globeControl1.Globe.ClearAnalysis(); string[] markerStrs = new string[9]; markerStrs[0] = "标高标注"; markerStrs[1] = "管径标注"; markerStrs[2] = "埋深标注"; markerStrs[3] = "坐标标注"; markerStrs[4] = "坡度标注"; markerStrs[5] = "属性标注"; markerStrs[6] = "自定义标注"; markerStrs[7] = "距离标注"; markerStrs[8] = "扯旗标注"; for (int i = 0; i < markerStrs.Length; i++) { GSOLayer markerLayer = globeControl1.Globe.Layers.GetLayerByCaption(markerStrs[i]); markerLayer.RemoveAllFeature(); } if (layerMarkerTree != null && layerMarkerTree.Nodes.Count > 0) { for (int i = 0; i < layerMarkerTree.Nodes[0].Nodes.Count; i++) { layerMarkerTree.Nodes[0].Nodes[i].Nodes.Clear(); } } globeControl1.Refresh(); } /// <summary> /// 沿线运动 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem138_Click(object sender, EventArgs e) { } /// <summary> /// 回退 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem99_Click(object sender, EventArgs e) { globeControl1.Globe.UnDoEdit(); } /// <summary> /// 前进 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem100_Click(object sender, EventArgs e) { globeControl1.Globe.ReDoEdit(); } /// <summary> /// 水平净距 功能界面中的 标签内容改变事件处理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void textBoxX4_TextChanged(object sender, EventArgs e) { string valueJingJu = textBoxX4.Text.Trim(); if(valueJingJu != "") { double value = 0; bool bl = double.TryParse(valueJingJu,out value); if(bl) { labelX24.Text = "水平净距小于" + value.ToString() +"米的管线有:"; } } } /// <summary> /// 垂直净距 功能界面中的 标签内容改变事件处理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void textBoxX2_TextChanged(object sender, EventArgs e) { string valueJingJu = textBoxX2.Text.Trim(); if (valueJingJu != "") { double value = 0; bool bl = double.TryParse(valueJingJu, out value); if (bl) { labelX23.Text = "垂直净距小于" + value.ToString() + "米的管线有:"; } } } /// <summary> /// 覆土分析 功能界面中的 标签内容改变事件处理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void textBoxX3_TextChanged(object sender, EventArgs e) { string valueJingJu = textBoxX3.Text.Trim(); if (valueJingJu != "") { double value = 0; bool bl = double.TryParse(valueJingJu, out value); if (bl) { labelX17.Text = "覆土深度小于" + value.ToString() + "米的管线有:"; } } } /// <summary> /// 管径分段统计 全区域 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem全区域_Click(object sender, EventArgs e) { //日志记录 LogManager.saveLog(Utility.userName, "管径分段统计"); Frmpipediameterstatis.ShowForm(globeControl1, m_PipelineLayerNames,0); } /// <summary> /// 管径分段统计 绘制区域 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem绘制区域_Click(object sender, EventArgs e) { //日志记录 LogManager.saveLog(Utility.userName, "管径分段统计"); trackflag = null; Frmpipediameterstatis.ShowForm(globeControl1, m_PipelineLayerNames,1); } /// <summary> /// 埋深分段统计 全区域 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem埋深全区域_Click(object sender, EventArgs e) { //日志记录 LogManager.saveLog(Utility.userName, "埋深分段统计"); FrmpipeDeepstatis.ShowForm(globeControl1, m_PipelineLayerNames,0); } /// <summary> /// 埋深分段统计 绘制区域 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem埋深绘制区域_Click(object sender, EventArgs e) { //日志记录 LogManager.saveLog(Utility.userName, "埋深分段统计"); trackflag = null; FrmpipeDeepstatis.ShowForm(globeControl1, m_PipelineLayerNames,1); } /// <summary> /// 管径分类汇总 全区域 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem管径分类全区域_Click(object sender, EventArgs e) { //日志记录 LogManager.saveLog(Utility.userName, "管径分类汇总"); FrmpipeDiametergather.ShowForm(globeControl1, m_PipelineLayerNames, 0); } /// <summary> /// 管径分类汇总 绘制区域 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem管径分类绘制区域_Click(object sender, EventArgs e) { //日志记录 LogManager.saveLog(Utility.userName, "管径分类汇总"); trackflag = null; FrmpipeDiametergather.ShowForm(globeControl1, m_PipelineLayerNames, 1); } /// <summary> /// 附属物分类汇总 全区域 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem附属物全区域_Click(object sender, EventArgs e) { //日志记录 LogManager.saveLog(Utility.userName, "附属物分类汇总"); FrmAccessoriesgather.ShowForm(globeControl1, instrumenLayerNames,0); } /// <summary> /// 附属物分类汇总 绘制区域 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem附属物绘制区域_Click(object sender, EventArgs e) { //日志记录 LogManager.saveLog(Utility.userName, "附属物分类汇总"); trackflag = null; FrmAccessoriesgather.ShowForm(globeControl1, instrumenLayerNames,1); } /// <summary> /// 材质分类汇总 全区域 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem材质全区域_Click(object sender, EventArgs e) { //日志记录 LogManager.saveLog(Utility.userName, "材质分类汇总"); FrmpipeMaterialGather.ShowForm(globeControl1, m_PipelineLayerNames,0); } /// <summary> /// 材质分类汇总 绘制区域 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem材质绘制区域_Click(object sender, EventArgs e) { //日志记录 LogManager.saveLog(Utility.userName, "材质分类汇总"); trackflag = null; FrmpipeMaterialGather.ShowForm(globeControl1, m_PipelineLayerNames,1); } /// <summary> /// 传感器分类查询 全区域 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItemSensor全区域查询_Click(object sender, EventArgs e) { FrmAccessoriesSensor.ShowForm(globeControl1, instrumenLayerNames, 0); } /// <summary> /// 传感器分类查询 绘制区域 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItemSensor绘制区域查询_Click(object sender, EventArgs e) { FrmAccessoriesSensor.ShowForm(globeControl1, instrumenLayerNames, 1); } /// <summary> /// 传感器管理 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> //private void buttonItem139_Click(object sender, EventArgs e) //{ // buttonItem139.Checked = !buttonItem139.Checked; // buttonItem77.Checked = false; // if (buttonItem139.Checked) // { // sideBar1.Visible = true; // sideBarPanelItem3.Visible = true; // buttonItem1.Checked = true; // controlContainerItem3.Visible = true; // sideBarPanelItem4.Visible = true; // sideBarPanelItem4.Text = "传感器管理"; // panel2.Visible = false; // panel1.Visible = false; // panel4.Visible = false; // panel5.Visible = false; // panel3.Visible = false; // controlContainerItem5.Control = panelEx3; // panelEx3.Dock = DockStyle.Fill; // panelEx3.Visible = true; // sideBar1.ExpandedPanel = sideBarPanelItem4; // sideBar1.Refresh(); // Refresh(); //} //else //{ // globeControl1.Globe.Action = EnumAction3D.ActionNull; // sideBarPanelItem4.Visible = false; // panelEx3.Visible = false; // if (buttonItem1.Checked) // { // sideBar1.ExpandedPanel = sideBarPanelItem3; // } // else // { // sideBar1.Visible = false; // } // Refresh(); // } //} /// <summary> /// 碰撞分析 功能界面中 关闭按钮 事件处理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonX7_Click_1(object sender, EventArgs e) { trackflag = ""; globeControl1.Globe.Action = EnumAction3D.ActionNull; sideBarPanelItem4.Visible = false; panel2.Visible = false; checkBoxX3.Checked = false; checkBoxX4.Checked = false; comboBoxEx2.SelectedIndex = -1; dataGridViewX4.Rows.Clear(); dataGridViewX5.Rows.Clear(); if (buttonItem1.Checked) { sideBar1.ExpandedPanel = sideBarPanelItem3; } else { sideBar1.Visible = false; } Refresh(); } /// <summary> /// 覆土分析 功能界面中的 清除分析结果 按钮事件处理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonX16_Click(object sender, EventArgs e) { trackflag = ""; globeControl1.Globe.Action = EnumAction3D.ActionNull; checkBoxX5.Checked = false; checkBoxX6.Checked = false; comboBoxEx3.SelectedIndex = -1; comboBoxEx3.Enabled = false; textBoxX3.Text = "1"; dataGridViewX6.Rows.Clear(); dataGridViewX7.Rows.Clear(); layerTemp.RemoveAllFeature(); globeControl1.Refresh(); } /// <summary> /// 数字预处理 功能 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void 数字预处理buttonItem140_Click(object sender, EventArgs e) { FrmEditShapeFile frm = new FrmEditShapeFile(globeControl1); frm.ShowDialog(this); } /// <summary> /// 创建隧道 功能 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void 创建隧道buttonItem140_Click(object sender, EventArgs e) { globeControl1.Globe.Action = EnumAction3D.DrawPolyline; GSOLayer tunnel = globeControl1.Globe.Layers.GetLayerByCaption("隧道"); if (tunnel != null) { globeControl1.Globe.DestLayerFeatureAdd = tunnel; tunnel.Editable = true; m_isDrawTunnel = true; m_AddPipeLine = false; m_isDrawCitySevenLine = false; } else { MessageBox.Show("场景中未加载隧道图层!","提示"); } } /// <summary> /// 隐藏隧道 功能 隐藏隧道图层 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void 隐藏隧道buttonItem141_Click(object sender, EventArgs e) { GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption("隧道"); if (layer != null) { layer.Visible = !layer.Visible; } } /// <summary> /// 删除隧道 功能 删除选中的隧道对象 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void 删除隧道buttonItem142_Click(object sender, EventArgs e) { if (globeControl1.Globe.SelObjectCount > 0) { int tunnelCount = 0; for (int i = 0; i < globeControl1.Globe.SelObjectCount; i++) { GSOFeature f = null; GSOLayer layer = null; globeControl1.Globe.GetSelectObject(i, out f, out layer); if (f != null && f.Dataset.Caption == "隧道") { tunnelCount++; f.Delete(); if (layer != null) { globeControl1.Globe.AddToEditHistroy(layer, f, EnumEditType.Delete); } globeControl1.Refresh(); } } if (tunnelCount == 0) { MessageBox.Show("请选中要删除的隧道!", "提示"); } } else { MessageBox.Show("请选中要删除的隧道!", "提示"); } } /// <summary> /// 无源淹没分析 功能 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void 无源淹没分析buttonItem140_Click(object sender, EventArgs e) { //日志记录 LogManager.saveLog(Utility.userName, this.无源淹没分析buttonItem140.Text); globeControl1.Globe.Action = EnumAction3D.TrackPolygon; trackflag = "FloodAnalysis"; } /// <summary> /// 导出矢量 功能 将图层导出为kml和shp格式数据 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void 导出矢量buttonItem140_Click(object sender, EventArgs e) { /* List<string> m_PipelineLayerNames = new List<string>();//线图层名称 List<string> workwellLayerNames = new List<string>();//工井图层名称 List<string> valueLayerNames = new List<string>();//阀门图层名称 List<string> instrumenLayerNames = new List<string>();//附属物图层名称 List<string> pipefittingLayerNames = new List<string>();//管件图层名称 */ List<string> listVectorNames = new List<string>(); for (int i = 0; i < m_PipelineLayerNames.Count; i++) { if (m_PipelineLayerNames[i] == "移动" || m_PipelineLayerNames[i] == "联通" || m_PipelineLayerNames[i] == "电信" || m_PipelineLayerNames[i] == "共通" || m_PipelineLayerNames[i] == "有限电视" || m_PipelineLayerNames[i] == "交通信号" || m_PipelineLayerNames[i] == "供电") { continue; } if (listVectorNames.Contains(m_PipelineLayerNames[i]) == false) { listVectorNames.Add(m_PipelineLayerNames[i]); } } for (int i = 0; i < valueLayerNames.Count; i++) { if (listVectorNames.Contains(valueLayerNames[i]) == false) { listVectorNames.Add(valueLayerNames[i]); } } for (int i = 0; i < workwellLayerNames.Count; i++) { if (listVectorNames.Contains(workwellLayerNames[i]) == false) { listVectorNames.Add(workwellLayerNames[i]); } } for (int i = 0; i < instrumenLayerNames.Count; i++) { if (listVectorNames.Contains(instrumenLayerNames[i]) == false) { listVectorNames.Add(instrumenLayerNames[i]); } } for (int i = 0; i < pipefittingLayerNames.Count; i++) { if (listVectorNames.Contains(pipefittingLayerNames[i]) == false) { listVectorNames.Add(pipefittingLayerNames[i]); } } FrmExportVector frm = new FrmExportVector(globeControl1, listVectorNames); frm.ShowDialog(); } string citySevenLineType = ""; string cityServerLineName = ""; /// <summary> /// 绘制城市七线 功能按钮 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void 绘制城市七线buttonItem140_Click(object sender, EventArgs e) { FrmCitySevenLineType frm = new FrmCitySevenLineType(); if (frm.ShowDialog() == DialogResult.OK) { globeControl1.Globe.Action = EnumAction3D.DrawPolyline; m_isDrawCitySevenLine = true; m_isDrawTunnel = false; m_AddPipeLine = false; this.citySevenLineType = frm.citySevenLineType; this.cityServerLineName = frm.citySevenLineName; switch (frm.citySevenLineType) { case "城市红线": GSOLayer layerRed = globeControl1.Globe.Layers.GetLayerByCaption(frm.citySevenLineType); if (layerRed != null) { globeControl1.Globe.DestLayerFeatureAdd = layerRed; layerRed.Editable = true; } break; case "城市橙线": GSOLayer layerOrange = globeControl1.Globe.Layers.GetLayerByCaption(frm.citySevenLineType); if (layerOrange != null) { globeControl1.Globe.DestLayerFeatureAdd = layerOrange; layerOrange.Editable = true; } break; case "城市黄线": GSOLayer layerYellow = globeControl1.Globe.Layers.GetLayerByCaption(frm.citySevenLineType); if (layerYellow != null) { globeControl1.Globe.DestLayerFeatureAdd = layerYellow; layerYellow.Editable = true; } break; case "城市绿线": GSOLayer layerGreen = globeControl1.Globe.Layers.GetLayerByCaption(frm.citySevenLineType); if (layerGreen != null) { globeControl1.Globe.DestLayerFeatureAdd = layerGreen; layerGreen.Editable = true; } break; case "城市蓝线": GSOLayer layerBlue = globeControl1.Globe.Layers.GetLayerByCaption(frm.citySevenLineType); if (layerBlue != null) { globeControl1.Globe.DestLayerFeatureAdd = layerBlue; layerBlue.Editable = true; } break; case "城市紫线": GSOLayer layerPurple = globeControl1.Globe.Layers.GetLayerByCaption(frm.citySevenLineType); if (layerPurple != null) { globeControl1.Globe.DestLayerFeatureAdd = layerPurple; layerPurple.Editable = true; } break; case "城市黑线": GSOLayer layerBlack = globeControl1.Globe.Layers.GetLayerByCaption(frm.citySevenLineType); if (layerBlack != null) { globeControl1.Globe.DestLayerFeatureAdd = layerBlack; layerBlack.Editable = true; } break; } } } /// <summary> /// 七线审核 功能按钮 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void 七线审核buttonItem141_Click(object sender, EventArgs e) { FrmCityServerLineAnalysis frm = new FrmCityServerLineAnalysis(globeControl1,m_PipelineLayerNames); frm.ShowDialog(this); } /// <summary> /// 间距分析 功能按钮 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void 间距分析buttonItem140_Click(object sender, EventArgs e) { //日志记录 LogManager.saveLog(Utility.userName, this.间距分析buttonItem140.Text); this.dataGridViewLineList.Size = new System.Drawing.Size(185, 92); this.dataGridViewAnalysisResult.Size = new System.Drawing.Size(185, 120); layerTemp.RemoveAllFeature(); clearFeatureHighLight(); globeControl1.Refresh(); sideBar1.Visible = true; sideBarPanelItem3.Visible = true; buttonItem1.Checked = true; controlContainerItem3.Visible = true; sideBarPanelItem4.Visible = true; sideBarPanelItem4.Text = "间距分析"; trackflag = "spacing"; controlContainerItem5.Control = panelSpacingAnalysis; panelSpacingAnalysis.Dock = DockStyle.Fill; panelSpacingAnalysis.Visible = true; sideBar1.ExpandedPanel = sideBarPanelItem4; sideBar1.Refresh(); Refresh(); } /// <summary> /// 间距分析 开始分析按钮 分析绘制的七线和管线的距离是否符合标准 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonStartAnalysis_Click(object sender, EventArgs e) { if (!checkBoxSelectPipeline.Checked && !checkBoxSelectLayer.Checked) { MessageBox.Show("请确定是选择管线还是选择图层!", "提示"); return; } if (textBoxVerticalDistance.Text.Trim() == "") { MessageBox.Show("垂直净距标准不能为空!", "提示"); return; } if (textBoxHorizontalDistance.Text.Trim() == "") { MessageBox.Show("水平净距标准不能为空!", "提示"); return; } double dVerticalJingJuBiaoZhun = 0.0; if (!double.TryParse(textBoxVerticalDistance.Text.Trim(), out dVerticalJingJuBiaoZhun)) { MessageBox.Show("请输入正确的垂直净距标准!", "提示"); return; } double dHorizontalJingJuBiaoZhun = 0.0; if (!double.TryParse(textBoxHorizontalDistance.Text.Trim(), out dHorizontalJingJuBiaoZhun)) { MessageBox.Show("请输入正确的水平净距标准!", "提示"); return; } if (dataGridViewLineList.Rows.Count > 0) { featCount.Clear(); featLenth.Clear(); listBoxStasticsResult.Items.Clear(); layerTemp.RemoveAllFeature(); polygonJingJuAnalysises.RemoveAll(); clearFeatureHighLight(); dataGridViewAnalysisResult.Rows.Clear(); m_FeaturesWithBianhao.Clear(); this.Cursor = Cursors.WaitCursor; if (checkBoxSelectPipeline.Checked) // 选择管线 { for (int i = 0; i < dataGridViewLineList.Rows.Count; i++) { GSOFeature selectedFeature = dataGridViewLineList.Rows[i].Tag as GSOFeature; if (selectedFeature != null) { selectState = 1; VerticalDistanceAnalysis("间距分析", selectedFeature, m_PipelineLayerNames, dVerticalJingJuBiaoZhun, dHorizontalJingJuBiaoZhun);//分析 } } } else if (checkBoxSelectLayer.Checked) // 选择图层 { if (comboBoxLayer.SelectedItem == null) { MessageBox.Show("请选择一个图层!", "提示"); return; } GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(comboBoxLayer.SelectedItem.ToString()); if (layer == null) { return; } GSOFeatureLayer flayer = layer as GSOFeatureLayer; if (flayer == null) { return; } GSOFeatures feats = flayer.GetAllFeatures(); if (feats == null) { return; } for (int i = 0; i < feats.Length; i++) { selectState = 1; VerticalDistanceAnalysis("间距分析", feats[i], m_PipelineLayerNames, dVerticalJingJuBiaoZhun, dHorizontalJingJuBiaoZhun);//分析 } } if (featCount.Count > 0) { for (int i = 0; i < m_PipelineLayerNames.Count; i++) { if (featCount.ContainsKey(m_PipelineLayerNames[i]) && featLenth.ContainsKey(m_PipelineLayerNames[i])) { listBoxStasticsResult.Items.Add(m_PipelineLayerNames[i] + ":" + featCount[m_PipelineLayerNames[i]] + "条,共" + featLenth[m_PipelineLayerNames[i]].ToString("0.00") + "米"); } } } if (dataGridViewAnalysisResult.Rows.Count == 0&&selectState==1) { MessageBox.Show("没有不符合间距分析标准的管线!", "提示"); } } else { MessageBox.Show("请选中要进行间距分析的管线!", "提示"); } globeControl1.Refresh(); this.Cursor = Cursors.Default; } /// <summary> /// 间距分析 清除分析结果 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonClearAnalysisResult_Click(object sender, EventArgs e) { trackflag = ""; globeControl1.Globe.Action = EnumAction3D.ActionNull; checkBoxSelectLayer.Checked = false; checkBoxSelectPipeline.Checked = false; comboBoxLayer.SelectedIndex = -1; comboBoxLayer.Enabled = false; dataGridViewLineList.Rows.Clear(); dataGridViewAnalysisResult.Rows.Clear(); listBoxStasticsResult.Items.Clear(); layerTemp.RemoveAllFeature(); globeControl1.Refresh(); } /// <summary> /// 间距分析 导出Excel按钮 将间距分析的结果以Excel表格的形式导出 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonExportExcel_Click(object sender, EventArgs e) { if (dataGridViewAnalysisResult.Rows.Count > 0) { ExportExcel("间距分析", dataGridViewAnalysisResult, listBoxStasticsResult); } else { MessageBox.Show("表格内容为空!", "提示"); } } /// <summary> /// 间距分析 关闭按钮 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonClosePanel_Click(object sender, EventArgs e) { trackflag = ""; globeControl1.Globe.Action = EnumAction3D.ActionNull; sideBarPanelItem4.Visible = false; panelSpacingAnalysis.Visible = false; checkBoxSelectPipeline.Checked = false; checkBoxSelectLayer.Checked = false; comboBoxLayer.SelectedIndex = -1; dataGridViewLineList.Rows.Clear(); dataGridViewAnalysisResult.Rows.Clear(); if (buttonItem1.Checked) { sideBar1.ExpandedPanel = sideBarPanelItem3; } else { sideBar1.Visible = false; } Refresh(); } /// <summary> /// 间距分析 分析结果表格双击定位 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void dataGridViewAnalysisResult_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e) { if (e.Button == MouseButtons.Left && e.RowIndex > -1) { GSOFeature rowFeature = dataGridViewAnalysisResult.Rows[e.RowIndex].Tag as GSOFeature; if (rowFeature != null) { if (rowFeature.Geometry != null && rowFeature.Geometry.Type == EnumGeometryType.GeoPolyline3D) { GSOGeoPolyline3D line = rowFeature.Geometry as GSOGeoPolyline3D; double length = line.GetSpaceLength(true, 6378137); GSOGeoPolyline3D lineLine = line.GetSegment(0, length / 2); GSOPoint3d point3d = lineLine[lineLine.PartCount - 1][lineLine[lineLine.PartCount - 1].Count - 1]; globeControl1.Globe.JumpToPosition(point3d, EnumAltitudeMode.Absolute, 5); } else { globeControl1.Globe.JumpToFeature(rowFeature, 5); } } } } /// <summary> /// 间距分析 选择管线复选框 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void checkBoxSelectPipeline_CheckedChanged(object sender, EventArgs e) { clearFeatureHighLight();//清除高亮 if (checkBoxSelectPipeline.Checked) { globeControl1.Globe.ClearAnalysis(); layerTemp.RemoveAllFeature(); globeControl1.Refresh(); comboBoxLayer.Enabled = false; dataGridViewLineList.Rows.Clear(); dataGridViewAnalysisResult.Rows.Clear(); trackflag = "spacing"; globeControl1.Globe.Action = EnumAction3D.SelectObject; } else { comboBoxLayer.Enabled = true; } } /// <summary> /// 间距分析 选择图层复选框 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void checkBoxSelectLayer_CheckedChanged(object sender, EventArgs e) { clearFeatureHighLight();//清除高亮 comboBoxLayer.Enabled = checkBoxSelectLayer.Checked; if (checkBoxSelectLayer.Checked) { globeControl1.Globe.Action = EnumAction3D.ActionNull; trackflag = ""; dataGridViewLineList.Rows.Clear(); dataGridViewAnalysisResult.Rows.Clear(); comboBoxLayer.SelectedIndex = -1; } globeControl1.Globe.ClearAnalysis(); layerTemp.RemoveAllFeature(); globeControl1.Refresh(); } /// <summary> /// 间距分析 选择图层下拉框 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void comboBoxLayer_SelectedIndexChanged(object sender, EventArgs e) { if (comboBoxLayer.SelectedIndex > -1) { dataGridViewLineList.Rows.Clear(); dataGridViewAnalysisResult.Rows.Clear(); listBoxStasticsResult.Items.Clear(); GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(comboBoxLayer.SelectedItem.ToString()); if (layer == null) return; GSOFeatureLayer flayer = layer as GSOFeatureLayer; if (flayer == null) return; GSOFeatures feats = flayer.GetAllFeatures(); if (feats == null) return; for (int i = 0; i < feats.Length; i++) { int idx = dataGridViewLineList.Rows.Add(); dataGridViewLineList.Rows[idx].Cells[0].Value = comboBoxLayer.SelectedItem.ToString(); dataGridViewLineList.Rows[idx].Cells[1].Value = feats[i].Name; } } } /// <summary> /// 关联查询 功能 查询与选中对象相关联的对象 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void 关联查询buttonItem140_Click(object sender, EventArgs e) { //日志记录 LogManager.saveLog(Utility.userName, this.关联查询buttonItem140.Text); if (globeControl1.Globe.SelObjectCount != 1) { MessageBox.Show("请选中一个对象!","提示"); return; } GSOFeatures featuresAllResult = new GSOFeatures(); double valueAllowance = 1.0; for (int j = 0; j < globeControl1.Globe.SelObjectCount; j++) { GSOFeature feature = null; GSOLayer layer = null; globeControl1.Globe.GetSelectObject(j, out feature, out layer); if (feature != null && feature.Geometry != null) { if (feature.Geometry.Type == EnumGeometryType.GeoPolyline3D) { GSOGeoPolyline3D line = feature.Geometry as GSOGeoPolyline3D; double lineLenght = line.GetSpaceLength(false, 6378137.0); //头 List<string> pointLayerNames = new List<string>(); for (int i = 0; i < valueLayerNames.Count; i++) { if (pointLayerNames.Contains(valueLayerNames[i]) == false) { pointLayerNames.Add(valueLayerNames[i]); } } for (int i = 0; i < workwellLayerNames.Count; i++) { if (pointLayerNames.Contains(workwellLayerNames[i]) == false) { pointLayerNames.Add(workwellLayerNames[i]); } } for (int i = 0; i < instrumenLayerNames.Count; i++) { if (pointLayerNames.Contains(instrumenLayerNames[i]) == false) { pointLayerNames.Add(instrumenLayerNames[i]); } } for (int i = 0; i < pipefittingLayerNames.Count; i++) { if (pointLayerNames.Contains(pipefittingLayerNames[i]) == false) { pointLayerNames.Add(pipefittingLayerNames[i]); } } GSOPoint3d headPoint = line[0][0]; GSOGeoPolyline3D newline = new GSOGeoPolyline3D(); GSOPoint3ds part = new GSOPoint3ds(); part.Add(headPoint); headPoint.X = headPoint.X - 0.0000000005; part.Add(headPoint); newline.AddPart(part); GSOGeoPolygon3D buffer = newline.CreateBuffer(valueAllowance, true, 5, true, false); for (int i = 0; i < pointLayerNames.Count; i++) { GSOLayer pointLayer = globeControl1.Globe.Layers.GetLayerByCaption(pointLayerNames[i]); if (pointLayer == null) { continue; } GSOFeatures features = pointLayer.FindFeaturesInPolygon(buffer, false); if (features != null && features.Length > 0) { for (int m = 0; m < features.Length; m++) { featuresAllResult.Add(features[m]); } } } //尾缩进 GSOPoint3d tailPoint = line[line.PartCount - 1][line[line.PartCount - 1].Count - 1]; newline = new GSOGeoPolyline3D(); part = new GSOPoint3ds(); part.Add(tailPoint); tailPoint.X = tailPoint.X - 0.0000000005; part.Add(tailPoint); newline.AddPart(part); buffer = newline.CreateBuffer(valueAllowance, true, 5, true, false); for (int i = 0; i < pointLayerNames.Count; i++) { GSOLayer pointLayer = globeControl1.Globe.Layers.GetLayerByCaption(pointLayerNames[i]); if (pointLayer == null) { continue; } GSOFeatures features = pointLayer.FindFeaturesInPolygon(buffer, false); if (features != null && features.Length > 0) { for (int m = 0; m < features.Length; m++) { featuresAllResult.Add(features[m]); } } } //FrmFittingQuery.ShowForm(globeControl1, instrumenLayerNames, dataGridViewX1, panelOfTable, toolStripNumbers, toolStripFeatureLength); for (int i = 0; i < featuresAllResult.Length; i++) { GSOFeature featureResult = featuresAllResult[i]; if (featureResult != null) { featureResult.HighLight = true; } } } else if (feature.Geometry.Type == EnumGeometryType.GeoPolygon3D || feature.Geometry.Type == EnumGeometryType.GeoWater) { } else { GSOPoint3d point = feature.Geometry.GeoCenterPoint; if (point != null) { GSOGeoPolyline3D line = new GSOGeoPolyline3D(); GSOPoint3ds part = new GSOPoint3ds(); part.Add(point); point.X = point.X - 0.0000000005; part.Add(point); line.AddPart(part); GSOGeoPolygon3D buffer = line.CreateBuffer(valueAllowance, true, 5, true, false); //pipeLineDis.Clear(); //List<GSOFeatures> list = new List<GSOFeatures>(); for (int i = 0; i < m_PipelineLayerNames.Count; i++) { GSOLayer lineLayer = globeControl1.Globe.Layers.GetLayerByCaption(m_PipelineLayerNames[i]); if (lineLayer == null) { continue; } GSOFeatures features = lineLayer.FindFeaturesInPolygon(buffer, false); if (features != null && features.Length > 0) { for (int m = 0;m < features.Length; m++) { GSOFeature featureResult = features[m]; if (featureResult != null) { featureResult.HighLight = true; } } //list.Add(features); } } } } } } } /// <summary> /// 扯旗标注 多个对象同时指向一个标注 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void 扯旗标注buttonItem140_Click(object sender, EventArgs e) { //日志记录 LogManager.saveLog(Utility.userName, this.扯旗标注buttonItem140.Text); if (globeControl1.Globe.SelObjectCount < 1) { MessageBox.Show("请选中要标注的管线!", "提示"); return; } FrmMarker frm = new FrmMarker(); if (frm.ShowDialog() == DialogResult.OK) { string label = frm.markerContent; setMarkerLayerUnVisible("扯旗标注"); GSOLayer labelLayer = globeControl1.Globe.Layers.GetLayerByCaption("扯旗标注"); labelLayer.Visible = true; GSOPoint3ds points = new GSOPoint3ds(); double minLongitude = double.MaxValue; double maxLongitude = double.MinValue; double minLatitude = double.MaxValue; double maxLatitude = double.MinValue; double maxZ = double.MinValue; for (int j = 0; j < globeControl1.Globe.SelObjectCount; j++) { GSOFeature feature = null; GSOLayer selectLayer = null; globeControl1.Globe.GetSelectObject(j, out feature, out selectLayer); if (feature != null && feature.Geometry != null && feature.Geometry.Type == EnumGeometryType.GeoPolyline3D) { GSOGeoPolyline3D line = feature.Geometry as GSOGeoPolyline3D; GSOPoint3d startPoint = line[0][0]; GSOPoint3d endPoint = line[line.PartCount - 1][line[line.PartCount - 1].Count - 1]; double minX = startPoint.X > endPoint.X ? endPoint.X : startPoint.X; double maxX = startPoint.X > endPoint.X ? startPoint.X : endPoint.X; double minY = startPoint.Y > endPoint.Y ? endPoint.Y : startPoint.Y; double maxY = startPoint.Y > endPoint.Y ? startPoint.Y : endPoint.Y; minLongitude = minLongitude > minX ? minX : minLongitude; maxLongitude = maxLongitude > maxX ? maxLongitude : maxX; minLatitude = minLatitude > minY ? minY : minLatitude; maxLatitude = maxLatitude > maxY ? maxLatitude : maxY; maxZ = startPoint.Z > maxZ ? startPoint.Z : maxZ; maxZ = endPoint.Z > maxZ ? endPoint.Z : maxZ; double lineLenght = line.GetSpaceLength(false, 6378137.0); GSOGeoPolyline3D newline = line.GetSegment(lineLenght / 2, lineLenght); if (newline != null) { GSOPoint3d middlePoint = newline[0][0]; points.Add(middlePoint); } } } GSOGeoPoint3D labelPosition = new GSOGeoPoint3D(); labelPosition.X = (maxLongitude + minLongitude) / 2; labelPosition.Y = (maxLatitude + minLatitude) / 2; labelPosition.Z = maxZ + 5; GSOFeature labelFeature = new GSOFeature(); GSOPoint2d point2d = new GSOPoint2d(0, 80); if (getLabelName(labelLayer) != -1) { string featureName = "扯旗标注" + labelLayer.GetAllFeatures().Length; labelFeature = createLabel(labelLayer, labelFeature, labelPosition, label, featureName, point2d); labelLayer.AddFeature(labelFeature); for (int i = 0; i < points.Count; i++) { GSOFeature lineFeature = new GSOFeature(); lineFeature.Name = featureName; GSOGeoPolyline3D line = new GSOGeoPolyline3D(); line.AltitudeMode = EnumAltitudeMode.RelativeToGround; GSOPoint3ds pts = new GSOPoint3ds(); pts.Add(points[i]); pts.Add(new GSOPoint3d(labelPosition.X, labelPosition.Y, labelPosition.Z)); line.AddPart(pts); lineFeature.Geometry = line; labelLayer.AddFeature(lineFeature); } } } } /// <summary> /// 管线自动缩进 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void 管线自动缩进buttonItem140_Click(object sender, EventArgs e) { FrmPipelineIndented frm = new FrmPipelineIndented(globeControl1, m_PipelineLayerNames, workwellLayerNames); frm.ShowDialog(this); } /// <summary> /// 编号查询 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem149_Click(object sender, EventArgs e) { //日志记录 LogManager.saveLog(Utility.userName, this.buttonItem149.Text); FrmCodingQuery.ShowForm(globeControl1, m_PipelineLayerNames, dataGridViewX1, panelOfTable, toolStripNumbers, toolStripFeatureLength); } // //数据预处理 // private void buttonItem141_Click(object sender, EventArgs e) { //保存日志 LogManager.saveLog(Utility.userName, this.btnSjycl.Text); FrmEditShapeFile frm = new FrmEditShapeFile(globeControl1); frm.ShowDialog(this); } private void btnExportCADs_Click(object sender, EventArgs e) { } // //导出路由专题图 // private void btnOutputR_Click(object sender, EventArgs e) { //日志记录 LogManager.saveLog(Utility.userName, this.btnOutputR.Text); Point pt1 = new Point(Convert.ToInt32(0), Convert.ToInt32(0)); Point pt2 = new Point(Convert.ToInt32(panelEx5.Width), Convert.ToInt32(panelEx5.Height)); Point pt = getUpperLeftPoint(pt1, pt2); Image myImg = new Bitmap(Convert.ToInt32(panelEx5.Width), Convert.ToInt32(panelEx5.Height)); Graphics g = Graphics.FromImage(myImg); g.CopyFromScreen(pt, new Point(0, 0), new Size(Convert.ToInt32(panelEx5.Width), Convert.ToInt32(panelEx5.Height))); F_PATMTitle frm = new F_PATMTitle("R", myImg); frm.ShowDialog(); } // //导出配件专题图 // private void btnOutputF_Click(object sender, EventArgs e) { //日志记录 LogManager.saveLog(Utility.userName, this.btnOutputF.Text); Point pt1 = new Point(Convert.ToInt32(0), Convert.ToInt32(0)); Point pt2 = new Point(Convert.ToInt32(panelEx5.Width), Convert.ToInt32(panelEx5.Height)); Point pt = getUpperLeftPoint(pt1, pt2); Image myImg = new Bitmap(Convert.ToInt32(panelEx5.Width), Convert.ToInt32(panelEx5.Height)); Graphics g = Graphics.FromImage(myImg); g.CopyFromScreen(pt, new Point(0, 0), new Size(Convert.ToInt32(panelEx5.Width), Convert.ToInt32(panelEx5.Height))); F_PATMTitle frm = new F_PATMTitle("F", myImg); frm.ShowDialog(); } //数据质量检查 private void btnDataValid_Click(object sender, EventArgs e) { //日志记录 LogManager.saveLog(Utility.userName, this.btnDataValid.Text); FrmValiData frm = new FrmValiData(globeControl1); frm.ShowDialog(); } // //连接数据库 // private void btnConnectDBS_Click(object sender, EventArgs e) { //保存日志 LogManager.saveLog(Utility.userName, this.buttonItem21.Text); FrmDatabaseParaSetting frm = new FrmDatabaseParaSetting(globeControl1); if (frm.ShowDialog() == DialogResult.OK) { ds = FrmDatabaseParaSetting.ds; if (ds != null) { ds.IsCloseSaved = false; } } } // //管线入库 // private void gxrk_Click(object sender, EventArgs e) { //保存日志 LogManager.saveLog(Utility.userName, this.buttonItem22.Text); if (ds == null) { MessageBox.Show("请先连接数据库", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); ConnectDB(null, null); } if (ds == null) return; Cyberpipe.Forms.FrmPipelineModelDB frm = new Cyberpipe.Forms.FrmPipelineModelDB(globeControl1, ds); if (frm.ShowDialog() == DialogResult.OK) { addNodeToLayerManagerNode(frm.rukuLayer); } } //附属物入库 private void gjrk_Click(object sender, EventArgs e) { //保存日志 LogManager.saveLog(Utility.userName, this.buttonItem23.Text); if (ds == null) { MessageBox.Show("请先连接数据库!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); ConnectDB(null, null); } if (ds == null) return; FrmAddWellShp frm = new FrmAddWellShp(globeControl1, ds); if (frm.ShowDialog() == DialogResult.OK) { addNodeToLayerManagerNode(frm.rukuLayer); } } //特征管点入库 private void ysybrk_Click(object sender, EventArgs e) { //保存日志 LogManager.saveLog(Utility.userName, this.buttonItem25.Text); if (ds == null) { MessageBox.Show("请先连接数据库", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); ConnectDB(null, null); } if (ds == null) return; FrmAddYuBiZiShp frm = new FrmAddYuBiZiShp(globeControl1, ds); if (frm.ShowDialog() == DialogResult.OK) { addNodeToLayerManagerNode(frm.rukuLayer); } } ////交越点入库 //private void fmrk_Click(object sender, EventArgs e) //{ // //保存日志 // LogManager.saveLog(Utility.userName, this.fmrk.Text); // if (ds == null) // { // MessageBox.Show("请先连接数据库", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); // ConnectDB(null, null); // } // if (ds == null) // return; // FrmAddValve frm = new FrmAddValve(globeControl1, ds); // if (frm.ShowDialog() == DialogResult.OK) // { // addNodeToLayerManagerNode(frm.rukuLayer); // } //} //坐标转换 private void btnCovertC_Click(object sender, EventArgs e) { //保存日志 LogManager.saveLog(Utility.userName, this.btnCovertC.Text); Cyberpipe.Forms.FrmProject frm = new Cyberpipe.Forms.FrmProject(); frm.ShowDialog(); } /// <summary> /// 统计指定图层在指定范围内的所有feature对象 /// </summary> /// <param name="polygon"></param> /// <param name="pipelinetype"></param> /// <returns></returns> private GSOFeatures Intersect_PointLayerByType(GSOGeoPolygon3D polygon, string pointLayerName, string type) { GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(pointLayerName + "管线附属物"); if (layer == null) return null; GSOFeatureLayer flayer = layer as GSOFeatureLayer; GSOFeatureDataset fdataset = flayer.Dataset as GSOFeatureDataset; GSOFeatures feats; GSOFeatures newfeats; string typeg = ""; if (polygon == null) { //feats = flayer.GetAllFeatures(); if (type == "阀门") { typeg = "阀门井"; } else if (type == "井") { typeg = type; } else { typeg = type; } feats = flayer.GetFeatureByFieldValue("附属物名称", typeg, true); newfeats = feats; } else { feats = flayer.FindFeaturesInPolygon(polygon, false); newfeats = flayer.FindFeaturesInPolygon(polygon, false); newfeats.RemoveAll(); if (type == "阀门") { typeg = "阀门井"; } else if (type == "井") { typeg = type; } else { typeg = type; } //过滤 for (int j = 0; j < feats.Length; j++) { GSOFeature feat = feats[j]; if (feat.GetFieldAsString("附属物名称").EndsWith(typeg)) { newfeats.Add(feat); } } } workWellLen.Add(pointLayerName + type, newfeats.Length); return newfeats; } //元数据管理 private void btnMetaData_Click(object sender, EventArgs e) { //日志记录 LogManager.saveLog(Utility.userName, this.buttonItem53.Text); FrmMetadata frmmd = new FrmMetadata(); frmmd.ShowDialog(); } private void btnMetaDataSearch_Click(object sender, EventArgs e) { //日志记录 LogManager.saveLog(Utility.userName, this.buttonItem54.Text); FrmMetadataStat frmmds = new FrmMetadataStat(); //frmmds.Show(); frmmds.ShowDialog(); } //操作日志管理 private void btnLogManage_Click(object sender, EventArgs e) { //日志记录 LogManager.saveLog(Utility.userName, this.btnLogManage.Text); FrmLogOper frmlo = new FrmLogOper(); frmlo.ShowDialog(); } //数据元字典管理 private void btnMetaDataDicManage_Click(object sender, EventArgs e) { //日志记录 LogManager.saveLog(Utility.userName, this.btnMetaDataDicManage.Text); FrmMDDictory frmmdd = new FrmMDDictory(); frmmdd.ShowDialog(); } //数据备份 //private void btnBackup_Click(object sender, EventArgs e) //{ // 日志记录 // LogManager.saveLog(Utility.userName, this.btnBackup.Text); // if (MessageBox.Show("是否确定要备份数据库文件", "信息", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) // { // try // { // DateTime currentTime = DateTime.Now; // string Dtime = currentTime.ToShortDateString().ToString("yyyy-MM-dd"); // string Dtime = currentTime.GetDateTimeFormats('D')[0].ToString(); // string Htime = DateTime.Now.ToString("HH时mm分ss秒").Trim(); // string fileName = Dtime+"("+Htime+")"+".dmp";//要备份到的文件名称string fileName = Dtime + "(" + Htime + ")"; // string command = "exp "+Utility.userID+"/"+Utility.DBPassword+"@"+Utility.dbdatabase+" "+ // "file=" + Application.StartupPath + "\\oracleBackup\\" + fileName+" log="+ // Application.StartupPath+"\\log\\log.log";//备份 // Process p = new Process(); // p.StartInfo.FileName = "cmd.exe"; // p.StartInfo.UseShellExecute = false; // p.StartInfo.RedirectStandardInput = true; // p.StartInfo.RedirectStandardOutput = true; // p.StartInfo.CreateNoWindow = true; // p.Start(); // p.StandardInput.WriteLine(command); // string responed = p.StandardOutput.ReadToEnd(); // MessageBox.Show(responed,"提示"); // p.WaitForExit(); // p.Close(); // string pathName = ""; // string sql = "select filename from master..sysdatabases where name='" + Utility.dbdatabase + "'"; // DataTable dt = OledbHelper.ExecuteDataTable(sql); // if (dt != null && dt.Rows.Count > 0) // { // pathName = dt.Rows[0][0].ToString().Trim(); // int count = pathName.LastIndexOf("\\") == -1 ? pathName.LastIndexOf("/") : pathName.LastIndexOf("\\"); // pathName = pathName.Substring(0, count); // } // pathName += "\\管网数据库" + fileName + ".bak"; // OracleCommand cmdBK = new OracleCommand(); // cmdBK.CommandType = CommandType.Text; // cmdBK.Connection = connBackup; // cmdBK.CommandText = @"backup database " + Utility.dbdatabase + " to disk='" + pathName + "' with init"; // connBackup.Open(); // cmdBK.ExecuteNonQuery(); // MessageBox.Show("数据库文件备份成功", "提示"); // } // catch (Exception ex) // { // MessageBox.Show(ex.Message); // LogError.PublishError(ex); // } // finally // { // connBackup.Close(); // } // } //} //public string UpAndDown_Dir(string dir) //{ // string Change_dir = ""; // Change_dir = Directory.GetParent(dir).FullName; // return Change_dir; //} private void btnBackup_Click(object sender, EventArgs e) { //旧 #region // 日志记录 //LogManager.saveLog(Utility.userName, this.btnBackup.Text); //if (MessageBox.Show("是否确定要备份数据库文件", "信息", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) //{ // try // { // DateTime currentTime = DateTime.Now; // string Dtime = currentTime.GetDateTimeFormats('D')[0].ToString(); // string Htime = DateTime.Now.ToString("HH时mm分ss秒").Trim(); // string fileName = Dtime + "(" + Htime + ")" + ".dmp"; //要备份到的文件的名称 // string command = "exp " + Utility.userID + "/" + Utility.DBPassword + "@" // + Utility.dbdatabase + " file="+Application.StartupPath+"\\OracleBackup\\" + fileName // + " log="+Application.StartupPath+"\\OracleBackup\\log.log"; //备份Oracle数据库使用的命令 // //创建一下新的线程调用cmd命令行工具,执行备份命令command // Process p = new Process(); // p.StartInfo.FileName = "cmd.exe"; // p.StartInfo.UseShellExecute = false; // p.StartInfo.RedirectStandardInput = true; // p.StartInfo.RedirectStandardOutput = true; // p.StartInfo.CreateNoWindow = true; // p.Start(); // p.StandardInput.WriteLine(command); // string responed = p.StandardOutput.ReadToEnd(); // MessageBox.Show(responed, "提示"); // p.WaitForExit(); // p.Close(); // } // catch (Exception ex) // { // MessageBox.Show(ex.Message); // LogError.PublishError(ex); // } // finally // { // connBackup.Close(); // } //} #endregion //新 #region FrmBACKORACLE backOracle = new FrmBACKORACLE(); backOracle.Show(); //Process p = new Process(); //p.StartInfo.FileName = UpAndDown_Dir(Application.StartupPath) // + "\\Debug\\数据库备份\\WindowsFormsApplication1.exe"; //p.StartInfo.UseShellExecute = false; //p.StartInfo.RedirectStandardInput = true; //p.StartInfo.RedirectStandardOutput = true; //p.StartInfo.CreateNoWindow = true; //p.Start(); //p.WaitForExit(); //p.Close(); //btnBackup.Checked = false; #endregion } //碰撞审查 private void pzscBtn_Click(object sender, EventArgs e) { //日志记录 LogManager.saveLog(Utility.userName, this.pzscBtn.Text); this.dataGridViewX4.Size = new System.Drawing.Size(185, 92); this.dataGridViewX5.Size = new System.Drawing.Size(185, 120); layerTemp.RemoveAllFeature(); clearFeatureHighLight(); globeControl1.Refresh(); sideBar1.Visible = true; sideBarPanelItem3.Visible = true; buttonItem1.Checked = true; controlContainerItem3.Visible = true; sideBarPanelItem4.Visible = true; sideBarPanelItem4.Text = "碰撞审查"; trackflag = "collision"; controlContainerItem5.Control = panel2; panel2.Dock = DockStyle.Fill; panel2.Visible = true; sideBar1.ExpandedPanel = sideBarPanelItem4; sideBar1.Refresh(); Refresh(); } //水平净距审查 private void spjjscBtn_Click(object sender, EventArgs e) { //日志记录 LogManager.saveLog(Utility.userName, this.spjjscBtn.Text); this.dataGridViewX8.Size = new System.Drawing.Size(190, 92); this.dataGridViewX9.Size = new System.Drawing.Size(190, 120); layerTemp.RemoveAllFeature(); clearFeatureHighLight(); globeControl1.Refresh(); sideBar1.Visible = true; sideBarPanelItem3.Visible = true; buttonItem1.Checked = true; controlContainerItem3.Visible = true; sideBarPanelItem4.Visible = true; sideBarPanelItem4.Text = "水平净距审查"; trackflag = "horizontal"; controlContainerItem5.Control = panel5; panel5.Dock = DockStyle.Fill; panel5.Visible = true; sideBar1.ExpandedPanel = sideBarPanelItem4; sideBar1.Refresh(); Refresh(); } //垂直净距审查 private void czjjscBtn_Click(object sender, EventArgs e) { //日志记录 LogManager.saveLog(Utility.userName, this.czjjscBtn.Text); this.dataGridViewX2.Visible = true; this.dataGridViewX3.Visible = true; this.dataGridViewX2.Size = new System.Drawing.Size(185, 92); this.dataGridViewX3.Size = new System.Drawing.Size(185, 120); layerTemp.RemoveAllFeature(); clearFeatureHighLight(); globeControl1.Refresh(); sideBar1.Visible = true; sideBarPanelItem3.Visible = true; buttonItem1.Checked = true; controlContainerItem3.Visible = true; sideBarPanelItem4.Visible = true; sideBarPanelItem4.Text = "垂直净距审查"; trackflag = "vertical"; //globeControl1.Globe.Action = EnumAction3D.SelectObject; panel2.Visible = false; panel3.Visible = false; panel5.Visible = false; panel4.Visible = false; controlContainerItem5.Control = panel1; panel1.Dock = DockStyle.Fill; panel1.Visible = true; sideBar1.ExpandedPanel = sideBarPanelItem4; sideBar1.Refresh(); Refresh(); } //覆土审查 private void ftscBtn_Click(object sender, EventArgs e) { //日志记录 LogManager.saveLog(Utility.userName, this.ftscBtn.Text); this.dataGridViewX6.Size = new System.Drawing.Size(185, 92); this.dataGridViewX7.Size = new System.Drawing.Size(185, 120); layerTemp.RemoveAllFeature(); clearFeatureHighLight(); globeControl1.Refresh(); sideBar1.Visible = true; sideBarPanelItem3.Visible = true; buttonItem1.Checked = true; controlContainerItem3.Visible = true; sideBarPanelItem4.Visible = true; sideBarPanelItem4.Text = "覆土审查"; trackflag = "ftAnalysis"; controlContainerItem5.Control = panel4; panel4.Visible = true; panel4.Dock = DockStyle.Fill; sideBar1.ExpandedPanel = sideBarPanelItem4; sideBar1.Refresh(); Refresh(); } //综合区域审查 private void buttonItem24_Click(object sender, EventArgs e) { //日志记录 LogManager.saveLog(Utility.userName, this.buttonItem24.Text); FrmCityServerLineAnalysis frm = new FrmCityServerLineAnalysis(globeControl1, m_PipelineLayerNames); frm.Show(this); } private int connectServerCount = 0; //双屏显示 public void btnSpdb_Click(object sender, EventArgs e) { //日志记录 LogManager.saveLog(Utility.userName, this.btnSpdb.Text); btnSpdb.Checked = !btnSpdb.Checked; splitContainer1.Panel2Collapsed = !btnSpdb.Checked; if (btnSpdb.Checked) { btnSpld.Enabled = true; btnSpsz.Enabled = true; btnSpfx.Enabled = true; sideBar1.Visible = false; buttonItem1.Checked = false; for (int i = globeControl2.Globe.Layers.Count - 1; i >= 0; i--) { GSOLayer layer = globeControl2.Globe.Layers[i]; if (!layer.Name.Contains("fttp:")) { layer.Dataset.Close();//清除内存 globeControl2.Globe.Layers.Remove(layer); } } if (connectServerCount == 0) { globeControl2.Globe.ConnectServer(Utility.serverip, Utility.serverport, "", ""); connectServerCount = 1; } //globeControl2.Refresh(); globeControl2.Globe.GroundOpaque = globeControl1.Globe.GroundOpaque; FrmDataBaseOpt frm = new FrmDataBaseOpt(globeControl1,globeControl2); frm.ShowDialog(this); globeControl2.Globe.Refresh(); } else { btnSpld.Enabled = false; btnSpsz.Enabled = false; btnSpfx.Enabled = false; sideBar1.Visible = true; buttonItem1.Checked = true; sideBarPanelItem3.Visible = true; layerTree.Visible = true; controlContainerItem3.Visible = true; //初始化隐藏图层管理 sideBarPanelItem3.Visible = false; layerTree.Visible = false; controlContainerItem3.Visible = false; if (sideBarPanelItem4.Visible == true) { sideBar1.Visible = true; controlContainerItem5.Visible = true; } else { sideBar1.Visible = false; } ////还原实测库 refreshGlobe1(); Refresh(); } } /// <summary> /// 还原球到实测库 /// </summary> private void refreshGlobe1() { //添加实测库图层已有图层 int servernum = 0; //1.清除global1上 for (int i = globeControl1.Globe.Layers.Count - 1; i >= 0; i--) { GSOLayer layer = globeControl1.Globe.Layers[i]; if (!layer.Name.Contains("fttp:")) { layer.Dataset.Close();//清除内存 globeControl1.Globe.Layers.Remove(layer); } else { servernum++; } } //globeControl1.Globe.ConnectServer(Utility.serverip, Utility.serverport, "", ""); //加载locaServer中的数据 //2.添加实测库图层 string[] markerStrs = new string[9]; markerStrs[0] = "标高标注"; markerStrs[1] = "管径标注"; markerStrs[2] = "埋深标注"; markerStrs[3] = "坐标标注"; markerStrs[4] = "坡度标注"; markerStrs[5] = "属性标注"; markerStrs[6] = "自定义标注"; markerStrs[7] = "距离标注"; markerStrs[8] = "扯旗标注"; for (int i = 0; i < markerStrs.Length; i++) { if (File.Exists(Application.StartupPath + "\\标注管理\\" + markerStrs[i] + ".lgd")) { GSOLayer markerLayer = globeControl1.Globe.Layers.Add(Application.StartupPath + "\\标注管理\\" + markerStrs[i] + ".lgd"); } } for (int i = 0; i < g1layername.Count; i++) { string g1name = g1layername[i]; GSODataset datasetg1 = Utility.dataSource.GetDatasetByName(g1name); GSOLayer templayer = globeControl1.Globe.Layers.Add(datasetg1); templayer.MaxVisibleAltitude = 1000; } layerTemp = globeControl1.Globe.Layers.Add(Application.StartupPath + "\\tempLgdData.lgd"); globeControl1.Globe.Layers.Add(Application.StartupPath + "/城市七线/城市红线.lgd"); globeControl1.Globe.Layers.Add(Application.StartupPath + "/城市七线/城市橙线.lgd"); globeControl1.Globe.Layers.Add(Application.StartupPath + "/城市七线/城市黄线.lgd"); globeControl1.Globe.Layers.Add(Application.StartupPath + "/城市七线/城市绿线.lgd"); globeControl1.Globe.Layers.Add(Application.StartupPath + "/城市七线/城市蓝线.lgd"); globeControl1.Globe.Layers.Add(Application.StartupPath + "/城市七线/城市紫线.lgd"); globeControl1.Globe.Layers.Add(Application.StartupPath + "/城市七线/城市黑线.lgd"); globeControl1.Globe.Layers.Add(Application.StartupPath + "/隧道.lgd"); //移动server的数据图层 for (int i = 0; i < servernum; i++) { globeControl1.Globe.Layers.MoveTo(globeControl1.Globe.Layers.Count - 1, 0); } globeControl1.Refresh(); } //双屏联动 private void btnSpld_Click(object sender, EventArgs e) { //日志记录 LogManager.saveLog(Utility.userName, this.btnSpld.Text); btnSpld.Checked = !btnSpld.Checked; } //双屏设置 private void btnSpsz_Click(object sender, EventArgs e) { //日志记录 LogManager.saveLog(Utility.userName, this.btnSpsz.Text); FrmLayerControl frm = new FrmLayerControl(layerTree, globeControl1, globeControl2); frm.ShowDialog(this); } //绘制城市七线 private void btnAddCsqx_Click(object sender, EventArgs e) { //日志记录 LogManager.saveLog(Utility.userName, this.btnAddCsqx.Text); FrmCitySevenLineType frm = new FrmCitySevenLineType(); if (frm.ShowDialog() == DialogResult.OK) { globeControl1.Globe.Action = EnumAction3D.DrawPolyline; m_isDrawCitySevenLine = true; m_isDrawTunnel = false; m_AddPipeLine = false; this.citySevenLineType = frm.citySevenLineType; this.cityServerLineName = frm.citySevenLineName; switch (frm.citySevenLineType) { case "城市红线": GSOLayer layerRed = globeControl1.Globe.Layers.GetLayerByCaption(frm.citySevenLineType); if (layerRed != null) { globeControl1.Globe.DestLayerFeatureAdd = layerRed; layerRed.Editable = true; } break; case "城市橙线": GSOLayer layerOrange = globeControl1.Globe.Layers.GetLayerByCaption(frm.citySevenLineType); if (layerOrange != null) { globeControl1.Globe.DestLayerFeatureAdd = layerOrange; layerOrange.Editable = true; } break; case "城市黄线": GSOLayer layerYellow = globeControl1.Globe.Layers.GetLayerByCaption(frm.citySevenLineType); if (layerYellow != null) { globeControl1.Globe.DestLayerFeatureAdd = layerYellow; layerYellow.Editable = true; } break; case "城市绿线": GSOLayer layerGreen = globeControl1.Globe.Layers.GetLayerByCaption(frm.citySevenLineType); if (layerGreen != null) { globeControl1.Globe.DestLayerFeatureAdd = layerGreen; layerGreen.Editable = true; } break; case "城市蓝线": GSOLayer layerBlue = globeControl1.Globe.Layers.GetLayerByCaption(frm.citySevenLineType); if (layerBlue != null) { globeControl1.Globe.DestLayerFeatureAdd = layerBlue; layerBlue.Editable = true; } break; case "城市紫线": GSOLayer layerPurple = globeControl1.Globe.Layers.GetLayerByCaption(frm.citySevenLineType); if (layerPurple != null) { globeControl1.Globe.DestLayerFeatureAdd = layerPurple; layerPurple.Editable = true; } break; case "城市黑线": GSOLayer layerBlack = globeControl1.Globe.Layers.GetLayerByCaption(frm.citySevenLineType); if (layerBlack != null) { globeControl1.Globe.DestLayerFeatureAdd = layerBlack; layerBlack.Editable = true; } break; } } } /// <summary> /// 生成连接管 菜单 将选中的多跟不相连管线通过连接管连接到一起 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnjoinModels_Click(object sender, EventArgs e) { //日志记录 LogManager.saveLog(Utility.userName, this.btnjoinModels.Text); if (globeControl1.Globe.SelObjectCount < 2) { MessageBox.Show("对不起,请至少选中2个对象!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } globeControl1.Globe.InsertJointPipeline(false); } /// <summary> /// 回退 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnBack_Click(object sender, EventArgs e) { globeControl1.Globe.UnDoEdit(); } /// <summary> /// 前进 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem55_Click(object sender, EventArgs e) { globeControl1.Globe.ReDoEdit(); } /// <summary> /// 导出CAD 菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnExport_Click(object sender, EventArgs e) { //日志记录 LogManager.saveLog(Utility.userName, this.btnExport.Text); List<string> listVectorNames = new List<string>(); for (int i = 0; i < m_PipelineLayerNames.Count; i++) { if (m_PipelineLayerNames[i] == "移动" || m_PipelineLayerNames[i] == "联通" || m_PipelineLayerNames[i] == "电信" || m_PipelineLayerNames[i] == "共通" || m_PipelineLayerNames[i] == "有线电视" || m_PipelineLayerNames[i] == "交通信号" || m_PipelineLayerNames[i] == "供电") { continue; } if (listVectorNames.Contains(m_PipelineLayerNames[i]) == false) { listVectorNames.Add(m_PipelineLayerNames[i]); } } for (int i = 0; i < valueLayerNames.Count; i++) { if (listVectorNames.Contains(valueLayerNames[i]) == false) { listVectorNames.Add(valueLayerNames[i]); } } for (int i = 0; i < workwellLayerNames.Count; i++) { if (listVectorNames.Contains(workwellLayerNames[i]) == false) { listVectorNames.Add(workwellLayerNames[i]); } } for (int i = 0; i < instrumenLayerNames.Count; i++) { if (listVectorNames.Contains(instrumenLayerNames[i]) == false) { listVectorNames.Add(instrumenLayerNames[i]); } } for (int i = 0; i < pipefittingLayerNames.Count; i++) { if (listVectorNames.Contains(pipefittingLayerNames[i]) == false) { listVectorNames.Add(pipefittingLayerNames[i]); } } FrmExportCADS frm = new FrmExportCADS(globeControl1, listVectorNames);//m_PipelineLayerNames); frm.ShowDialog(); } /// <summary> /// 导出矢量 功能 将图层导出为kml和shp格式数据 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnExportSL_Click(object sender, EventArgs e) { //日志记录 LogManager.saveLog(Utility.userName, this.btnExportSL.Text); List<string> listVectorNames = new List<string>(); for (int i = 0; i < m_PipelineLayerNames.Count; i++) { if (m_PipelineLayerNames[i] == "移动" || m_PipelineLayerNames[i] == "联通" || m_PipelineLayerNames[i] == "电信" || m_PipelineLayerNames[i] == "共通" || m_PipelineLayerNames[i] == "有线电视" || m_PipelineLayerNames[i] == "交通信号" || m_PipelineLayerNames[i] == "供电") { continue; } if (listVectorNames.Contains(m_PipelineLayerNames[i]) == false) { listVectorNames.Add(m_PipelineLayerNames[i]); } } for (int i = 0; i < valueLayerNames.Count; i++) { if (listVectorNames.Contains(valueLayerNames[i]) == false) { listVectorNames.Add(valueLayerNames[i]); } } for (int i = 0; i < workwellLayerNames.Count; i++) { if (listVectorNames.Contains(workwellLayerNames[i]) == false) { listVectorNames.Add(workwellLayerNames[i]); } } for (int i = 0; i < instrumenLayerNames.Count; i++) { if (listVectorNames.Contains(instrumenLayerNames[i]) == false) { listVectorNames.Add(instrumenLayerNames[i]); } } for (int i = 0; i < pipefittingLayerNames.Count; i++) { if (listVectorNames.Contains(pipefittingLayerNames[i]) == false) { listVectorNames.Add(pipefittingLayerNames[i]); } } FrmExportVector frm = new FrmExportVector(globeControl1, listVectorNames); frm.ShowDialog(); } //热点功能统计 private void btnHotFunc_Click(object sender, EventArgs e) { //日志记录 LogManager.saveLog(Utility.userName, this.btnHotFunc.Text); FrmHotFuncStat frmhfs = new FrmHotFuncStat(); frmhfs.ShowDialog(); } //管线路由分布 private void btnPTRoute_Click(object sender, EventArgs e) { //日志记录 LogManager.saveLog(Utility.userName, this.btnPTRoute.Text); PATM patm = new PATM(); patm.operation = "Route"; patm.Text = "路由专题图管理"; patm.ShowDialog(); } //管线配件专题图管理 private void btnPTFittings_Click(object sender, EventArgs e) { //日志记录 LogManager.saveLog(Utility.userName, this.btnPTFittings.Text); PATM patm = new PATM(); patm.operation = "Fittings"; patm.Text = "配件专题图管理"; patm.ShowDialog(); } //统计数据专题图管理 private void btnPTStatistic_Click(object sender, EventArgs e) { //日志记录 LogManager.saveLog(Utility.userName, this.btnPTStatistic.Text); PATM patm = new PATM(); patm.operation = "Statistic"; patm.Text = "统计专题图管理"; patm.ShowDialog(); } //规划设计审核稳定管理 private void btnPED_Click(object sender, EventArgs e) { //日志记录 LogManager.saveLog(Utility.userName, this.btnPED.Text); PED frmPED = new PED(); frmPED.ShowDialog(); } //标准规范库管理 private void btnPSL_Click(object sender, EventArgs e) { //日志记录 LogManager.saveLog(Utility.userName, this.btnPSL.Text); PAS pas = new PAS(); pas.operation = "PDF"; pas.Text = "标准规范管理"; pas.ShowDialog(); } //规划设计文档管理 private void btnPDD_Click(object sender, EventArgs e) { //日志记录 LogManager.saveLog(Utility.userName, this.btnPDD.Text); PAS pas = new PAS(); pas.operation = "DOC"; pas.Text = "设计文档管理"; pas.ShowDialog(); } //规划设计图管理 private void btnPDG_Click(object sender, EventArgs e) { //日志记录 LogManager.saveLog(Utility.userName, this.btnPDG.Text); PAS pas = new PAS(); pas.operation = "CAD"; pas.Text = "设计图纸管理"; pas.ShowDialog(); } private void buttonItem33_Click(object sender, EventArgs e) { //日志记录 LogManager.saveLog(Utility.userName, this.buttonItem33.Text); buttonItem33.Checked = !buttonItem33.Checked; ribbonBarDM.Visible = buttonItem33.Checked; ribbonBarDM.Location = new Point(0, 0); } private void buttonItem35_Click(object sender, EventArgs e) { //日志记录 LogManager.saveLog(Utility.userName, this.buttonItem35.Text); buttonItem35.Checked = !buttonItem35.Checked; ribbonBarKW.Visible = buttonItem35.Checked; ribbonBarKW.Location = new Point(0, 0); } private void buttonItem13_Click_1(object sender, EventArgs e) { FrmUserManager frm = new FrmUserManager(); frm.ShowDialog(); } private void buttonItem17_Click_2(object sender, EventArgs e) { FrmUserAdd frm = new FrmUserAdd(-1); frm.ShowDialog(); } /// <summary> /// APP端人云修改 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem96_Click(object sender, EventArgs e) { FrmAppUSER appUSER = new FrmAppUSER(); appUSER.ShowDialog(); } /// <summary> /// APP端人员增加 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem99_Click_1(object sender, EventArgs e) { FrmAppUSERRESET appUSERRESET = new FrmAppUSERRESET(); appUSERRESET.ShowDialog(); } /// <summary> /// 专题图审核 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem108_Click_1(object sender, EventArgs e) { FrmAPPFORASK appForask = new FrmAPPFORASK("专题图审核"); appForask.ShowDialog(); } /// <summary> /// 专题图审核记录 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem111_Click_1(object sender, EventArgs e) { FrmAPPregion appregion = new FrmAPPregion("专题图审核"); appregion.ShowDialog(); } /// <summary> /// 打印审核 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem113_Click_1(object sender, EventArgs e) { FrmAPPFORASK appForask = new FrmAPPFORASK("打印审核"); appForask.ShowDialog(); } /// <summary> /// 打印审核记录 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem114_Click_1(object sender, EventArgs e) { FrmAPPregion appregion = new FrmAPPregion("打印审核"); appregion.ShowDialog(); } /// <summary> /// 拷贝审核 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem116_Click_1(object sender, EventArgs e) { FrmAPPFORASK appForask = new FrmAPPFORASK("拷贝审核"); appForask.ShowDialog(); } /// <summary> /// 拷贝审核记录 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem117_Click_1(object sender, EventArgs e) { FrmAPPregion appregion = new FrmAPPregion("拷贝审核"); appregion.Show(); } /// <summary> /// 规控图入库 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem118_Click_1(object sender, EventArgs e) { //日志记录 LogManager.saveLog(Utility.userName, this.buttonItem118.Text); GKT gkt = new GKT(); gkt.Show(); } /// <summary> /// 单证文档入库 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem119_Click_1(object sender, EventArgs e) { GKT1 gkt = new GKT1(); gkt.Show(); } //设置图层为隐藏 private void setLayerVisible(string layerName) { GSOLayer templayer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); templayer.Visible = false; globeControl1.Globe.Refresh(); } private void 双屏分析_Click(object sender, EventArgs e) { FrmCompareLayers frm = new FrmCompareLayers(globeControl1,globeControl2); //frm.ShowDialog(this); frm.Show(); } private void buttonItem123_Click(object sender, EventArgs e) { FrmAPP appfrm = new FrmAPP("专题图申请"); appfrm.ShowDialog(); } private void buttonItem125_Click(object sender, EventArgs e) { FrmAPP appfrm = new FrmAPP("拷贝申请"); appfrm.ShowDialog(); } private void buttonItem124_Click(object sender, EventArgs e) { FrmAPP appfrm = new FrmAPP("打印申请"); appfrm.ShowDialog(); } //数据库配置 private void buttonItem127_Click_1(object sender, EventArgs e) { } private void buttonItem126_Click(object sender, EventArgs e) { //查看数据库列表 FrmDbManager frm = new FrmDbManager(); frm.ShowDialog(); } private void ribbonBar10_ItemClick(object sender, EventArgs e) { } /// <summary> /// 连接数据库 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem129_Click(object sender, EventArgs e) { //保存日志 LogManager.saveLog(Utility.userName, this.buttonItem21.Text); FrmDatabaseParaSetting2 frm = new FrmDatabaseParaSetting2(globeControl1); if (frm.ShowDialog() == DialogResult.OK) { ds = FrmDatabaseParaSetting2.ds; if (ds != null) { ds.IsCloseSaved = false; } } } /// <summary> /// 一键审核---导入数据 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem127_Click_2(object sender, EventArgs e) { //保存日志 if (shds == null) { //没连的话,直接连接审核库; //审核库配置读配置文件 string dbIp = Utility.shdbip; string database = Utility.shdbname; string user = Utility.shdbuser; string pass = Utility.shdbpwd; if (!Utility.isNetworkConnectionSuccess(dbIp.Trim())) { MessageBox.Show("网络连接失败!", "提示"); return; } shds = globeControl1.Globe.DataManager.OpenOracleDataSource(dbIp + "/" + database, "", "", user, pass); if (shds == null) { MessageBox.Show("数据库连接失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } Cyberpipe.Forms.FrmPipelineModelDataOneStep frm = new Cyberpipe.Forms.FrmPipelineModelDataOneStep(globeControl1, shds, layerTree); if (frm.ShowDialog() == DialogResult.OK) { addNodeToLayerManagerNode(frm.rukuLayer); } if (frm.rukuLayer != null) { shlayername = frm.rukuLayer.Name; } } /// <summary> ///自动导出图片 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem130_Click_1(object sender, EventArgs e) { //Form1 f1 = new Form1(globeControl1); //f1.Show(); Point pt1 = new Point(Convert.ToInt32(0), Convert.ToInt32(0)); Point pt2 = new Point(Convert.ToInt32(panelEx5.Width), Convert.ToInt32(panelEx5.Height)); Point pt = getUpperLeftPoint(pt1, pt2); Image myImg = new Bitmap(Convert.ToInt32(panelEx5.Width), Convert.ToInt32(panelEx5.Height)); Graphics g = Graphics.FromImage(myImg); g.CopyFromScreen(pt, new Point(0, 0), new Size(Convert.ToInt32(panelEx5.Width), Convert.ToInt32(panelEx5.Height))); SaveFileDialog dlg = new SaveFileDialog(); dlg.Filter = "输出JPEG(*.jpg)|*.jpg|输出PNG(*.png)|*.png|输出BMP(*.bmp)|*.bmp|输出BMP(*.gif)|*.gif"; if (dlg.ShowDialog() == DialogResult.OK) { string extension = System.IO.Path.GetExtension(dlg.FileName);//扩展名 switch (extension) { case ".jpg": myImg.Save(dlg.FileName, System.Drawing.Imaging.ImageFormat.Jpeg); break; case ".png": myImg.Save(dlg.FileName, System.Drawing.Imaging.ImageFormat.Png); break; case ".bmp": myImg.Save(dlg.FileName, System.Drawing.Imaging.ImageFormat.Bmp); break; case ".gif": myImg.Save(dlg.FileName, System.Drawing.Imaging.ImageFormat.Gif); break; default: break; } } } /// <smary> /// 一键审核功能 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem128_Click(object sender, EventArgs e) { //垂直净距标准 double dVerticalJingJuBiaoZhun=1, dHorizontalJingJuBiaoZhun=1; frmShResult = new FrmShResult(dVerticalJingJuBiaoZhun, dHorizontalJingJuBiaoZhun, shlayername, globeControl1,m_PipelineLayerNames); if (boolfrmShResult == false) { frmShResult.Location = new Point(this.Width - frmShResult.Width - 10, this.Height - frmShResult.Height - 50); frmShResult.Owner = this; frmShResult.Show(); boolfrmShResult = true; } else { } } /// <summary> /// 清除分析结果 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem131_Click(object sender, EventArgs e) { clearFeatureHighLight(); if (boolfrmShResult == true) { frmShResult.ClearAnalyseResult(); } else { } ClearRedlineAnalyseResult(); } /// <summary> /// 清除渲染结果 /// </summary> public void ClearRedlineAnalyseResult() { for (int i = 0; i < globeControl1.Globe.Layers.Count; i++) { GSOLayer layer = globeControl1.Globe.Layers[i]; if (layer.Caption == "tempLgdData") { layer.RemoveAllFeature(); } } layerTemp.RemoveAllFeature(); globeControl1.Refresh(); } /// <summary> /// 已审核的图层 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem132_Click_1(object sender, EventArgs e) { //保存日志 LogManager.saveLog(Utility.userName, this.buttonItem127.Text); if (shds == null) { //没连的话,直接连接审核库; //审核库配置读配置文件 string dbIp = Utility.shdbip; string database = Utility.shdbname; string user = Utility.shdbuser; string pass = Utility.shdbpwd; if (!Utility.isNetworkConnectionSuccess(dbIp.Trim())) { MessageBox.Show("网络连接失败!", "提示"); return; } shds = globeControl1.Globe.DataManager.OpenOracleDataSource(dbIp + "/" + database, "", "", user, pass); if (shds == null) { MessageBox.Show("数据库连接失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } Cyberpipe.Forms.FrmShLayers frm = new Cyberpipe.Forms.FrmShLayers(globeControl1, shds); frm.Show(); //if (frm.ShowDialog() == DialogResult.OK) //{ // addNodeToLayerManagerNode(frm.rukuLayer); //} //if (frm.rukuLayer != null) //{ // shlayername = frm.rukuLayer.Name; //} } /// <summary> /// 审核入库 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem133_Click_1(object sender, EventArgs e) { FrmShRK frmShrk = new FrmShRK(globeControl1); frmShrk.Show(); } /// <summary> /// 模拟设计修改 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem134_Click_1(object sender, EventArgs e) { frmModify = new FrmMnModify(globeControl1, shlayername,shresultLists); if (boolfrmModify == false) { frmModify.Owner = this; frmModify.Location = new Point(this.Width - frmModify.Width - 10, this.Height - frmModify.Height - 50); frmModify.Show(); boolfrmModify = true; } else { } } /// <summary> /// 导入红线 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem135_Click_1(object sender, EventArgs e) { string filepath = ""; //日志记录 OpenFileDialog dlg = new OpenFileDialog(); dlg.Filter = "矢量数据(*.shp)|*.shp|矢量数据(*.lgd)|*.lgd|CAD数据(*.dxf)|*.dxf|全部支持格式(*.lgd,*.shp,*.dxf)|*.lgd;*.shp;*.dxf;"; //dlg.Filter = "支持格式(*.lrp,*.tif,*.img,*.lrc,*.kml,*.lgd,*.shp,*.gft)|*.lrp;*.tif;*.img;*.lrc;*.kml;*.lgd;*.shp;*.gft|栅格数据(*.lrp)|*.lrp|栅格缓存(*.lrc)|*.lrc|KML数据(*.kml)|*.kml|矢量数据(*.lgd)|*.lgd|矢量缓存(*.gft)|*.gft|其它格式(*.*)|*.*||"; dlg.Multiselect = true; if (dlg.ShowDialog() == DialogResult.OK) { //自定义lprj文件名,从程序中复制一lprj文件。 int bindex = dlg.FileName.Split('\\').Length; string lastname = dlg.FileName.Split('\\')[bindex - 1]; if (lastname.IndexOf(".dxf") != -1) { string firstname = dlg.FileName.Substring(0, dlg.FileName.Length - lastname.Length); string filename = lastname.Substring(0, lastname.Length - 4) + ".lprj"; //复制lprj string lprjfilepath = firstname + filename; FileInfo OFInfo = new FileInfo(lprjfilepath);//获取目标文件所在的路径 FileInfo SFInfo = new FileInfo(Application.StartupPath + "\\lprj\\sz.lprj"); if (!OFInfo.Exists) { SFInfo.CopyTo(lprjfilepath, true);//将文件复制到指定的路径中 } } else if (lastname.IndexOf(".shp") != -1) { string firstname = dlg.FileName.Substring(0, dlg.FileName.Length - lastname.Length); string filename = lastname.Substring(0, lastname.Length - 4) + ".prj"; //复制lprj string lprjfilepath = firstname + filename; FileInfo OFInfo = new FileInfo(lprjfilepath);//获取目标文件所在的路径 FileInfo SFInfo = new FileInfo(Application.StartupPath + "\\lprj\\sz.prj"); SFInfo.CopyTo(lprjfilepath, true);//将文件复制到指定的路径中 } for (int i = 0; i < dlg.FileNames.Length; i++) { string strDataPath = dlg.FileNames[i]; filepath = strDataPath; GSOLayer layer = globeControl1.Globe.Layers.Add(strDataPath); redlinelayername = layer.Caption; //objRes = layer; if (layer != null) { layerRedRegion = layer; GSODataset dataset = layer.Dataset; CheckDatasetGeoReference(layer.Dataset, strDataPath); CheckDatasetGeoReference(layer.Dataset, strDataPath); TreeNode node = new TreeNode(); node.Tag = layer; node.Text = layer.Dataset.Caption; node.ImageIndex = 0; node.SelectedImageIndex = 0; node.Checked = layer.Visible; // 注意用insert不要用add,因为后加入的图层在上层 //layerManagerNode.Nodes.Add(node); layerManagerNode.Nodes.Insert(0, node); for (int j = 0; j < layer.GetAllFeatures().Length; j++) { GSOFeature f = layer.GetAt(j); if (f != null) { f.Geometry.AltitudeMode = EnumAltitudeMode.RelativeToGround; } } } layerManagerNode.Expand(); //放大到红线 GSOLayer lyr = globeControl1.Globe.Layers.GetLayerByCaption(redlinelayername); GSOSimpleLineStyle3D redlinestyle = new GSOSimpleLineStyle3D(); redlinestyle.LineColor = Color.Red; redlinestyle.LineWidth = 5; lyr.Style = redlinestyle; if (redlinelayername != "") { GSOFeatures features = lyr.GetAllFeatures(); GSORect2d rd = lyr.LatLonBounds; GSOPoint2d rdcenter = rd.Center; globeControl1.Globe.JumpToPosition(new GSOPoint3d(rdcenter.X, rdcenter.Y, 0), EnumAltitudeMode.Absolute, 500); ////////////////////////初始化地面透明度为50////////////////////// sliderGroundTransSet1.Value = 50; sliderItem1.Value = 50; globeControl1.Globe.GroundOpaque = 100 - sliderGroundTransSet1.Value; layer = globeControl1.Globe.Layers.GetLayerByCaption(roadLayerName);//("180fd"); if (layer != null) { layer.Opaque = 100 - sliderGroundTransSet1.Value; } /////////////////////////////////////////////////////////////////////////////////////////// //layer.Visible = false; globeControl1.Globe.Layers.MoveTo(0, globeControl1.Globe.Layers.Count - 1); globeControl1.Refresh(); } } } } /// <summary> /// 一键审核-导入其他坐标系数据 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem145_Click(object sender, EventArgs e) { string filepath = ""; //日志记录 OpenFileDialog dlg = new OpenFileDialog(); dlg.Filter = "矢量数据(*.shp)|*.shp|矢量数据(*.lgd)|*.lgd|CAD数据(*.dxf)|*.dxf|全部支持格式(*.lgd,*.shp,*.dxf)|*.lgd;*.shp;*.dxf;"; //dlg.Filter = "支持格式(*.lrp,*.tif,*.img,*.lrc,*.kml,*.lgd,*.shp,*.gft)|*.lrp;*.tif;*.img;*.lrc;*.kml;*.lgd;*.shp;*.gft|栅格数据(*.lrp)|*.lrp|栅格缓存(*.lrc)|*.lrc|KML数据(*.kml)|*.kml|矢量数据(*.lgd)|*.lgd|矢量缓存(*.gft)|*.gft|其它格式(*.*)|*.*||"; dlg.Multiselect = true; if (dlg.ShowDialog() == DialogResult.OK) { //自定义lprj文件名,从程序中复制一lprj文件。 int bindex = dlg.FileName.Split('\\').Length; string lastname = dlg.FileName.Split('\\')[bindex - 1]; if (lastname.IndexOf(".dxf") != -1) { string firstname = dlg.FileName.Substring(0, dlg.FileName.Length - lastname.Length); string filename = lastname.Substring(0, lastname.Length - 4) + ".lprj"; //复制lprj string lprjfilepath = firstname + filename; FileInfo OFInfo = new FileInfo(lprjfilepath);//获取目标文件所在的路径 FileInfo SFInfo = new FileInfo(Application.StartupPath + "\\lprj\\sz.lprj"); if (!OFInfo.Exists) { SFInfo.CopyTo(lprjfilepath, true);//将文件复制到指定的路径中 } } for (int i = 0; i < dlg.FileNames.Length; i++) { string strDataPath = dlg.FileNames[i]; filepath = strDataPath; GSOLayer layer = globeControl1.Globe.Layers.Add(strDataPath); redlinelayername = layer.Caption; //objRes = layer; if (layer != null) { GSODataset dataset = layer.Dataset; CheckDatasetGeoReference(layer.Dataset, strDataPath); CheckDatasetGeoReference(layer.Dataset, strDataPath); TreeNode node = new TreeNode(); node.Tag = layer; node.Text = layer.Dataset.Caption; node.ImageIndex = 0; node.SelectedImageIndex = 0; node.Checked = layer.Visible; // 注意用insert不要用add,因为后加入的图层在上层 //layerManagerNode.Nodes.Add(node); layerManagerNode.Nodes.Insert(0, node); for (int j = 0; j < layer.GetAllFeatures().Length; j++) { GSOFeature f = layer.GetAt(j); if (f != null) { f.Geometry.AltitudeMode = EnumAltitudeMode.RelativeToGround; } } } layerManagerNode.Expand(); //放大到红线 GSOLayer lyr = globeControl1.Globe.Layers.GetLayerByCaption(redlinelayername); GSOSimpleLineStyle3D redlinestyle = new GSOSimpleLineStyle3D(); redlinestyle.LineColor = Color.Red; redlinestyle.LineWidth = 5; lyr.Style = redlinestyle; if (redlinelayername != "") { GSOFeatures features = lyr.GetAllFeatures(); GSORect2d rd = lyr.LatLonBounds; GSOPoint2d rdcenter = rd.Center; globeControl1.Globe.JumpToPosition(new GSOPoint3d(rdcenter.X, rdcenter.Y, 0), EnumAltitudeMode.Absolute, 500); ////////////////////////初始化地面透明度为50////////////////////// sliderGroundTransSet1.Value = 50; sliderItem1.Value = 50; globeControl1.Globe.GroundOpaque = 100 - sliderGroundTransSet1.Value; layer = globeControl1.Globe.Layers.GetLayerByCaption(roadLayerName);//("180fd"); if (layer != null) { layer.Opaque = 100 - sliderGroundTransSet1.Value; } /////////////////////////////////////////////////////////////////////////////////////////// //layer.Visible = false; globeControl1.Globe.Layers.MoveTo(0, globeControl1.Globe.Layers.Count - 1); globeControl1.Refresh(); } } } } /// <summary> /// 红线审核 /// </summary> private void buttonItem138_Click_red(object sender, EventArgs e) { // if (layerRedRegion == null) { MessageBox.Show("请先导入红线!"); return; } List<GSOLayer> listPipelineLayers = new List<GSOLayer>(); #region 获取管线列表 GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption("电信管线"); if (layer != null) { listPipelineLayers.Add(layer); } layer = globeControl1.Globe.Layers.GetLayerByCaption("给水管线"); if (layer != null) { listPipelineLayers.Add(layer); } layer = globeControl1.Globe.Layers.GetLayerByCaption("路灯管线"); if (layer != null) { listPipelineLayers.Add(layer); } layer = globeControl1.Globe.Layers.GetLayerByCaption("天然气管线"); if (layer != null) { listPipelineLayers.Add(layer); } layer = globeControl1.Globe.Layers.GetLayerByCaption("网通管线"); if (layer != null) { listPipelineLayers.Add(layer); } layer = globeControl1.Globe.Layers.GetLayerByCaption("污水管线"); if (layer != null) { listPipelineLayers.Add(layer); } layer = globeControl1.Globe.Layers.GetLayerByCaption("移动管线"); if (layer != null) { listPipelineLayers.Add(layer); } layer = globeControl1.Globe.Layers.GetLayerByCaption("有线电视管线"); if (layer != null) { listPipelineLayers.Add(layer); } layer = globeControl1.Globe.Layers.GetLayerByCaption("雨水管线"); if (layer != null) { listPipelineLayers.Add(layer); } #endregion DataTable dt = new DataTable(); dt.Columns.Add("红线编号"); dt.Columns.Add("管线类型"); dt.Columns.Add("侵占面积"); dt.Columns.Add("管线进入地块长度"); for (int i = 0; i < layerRedRegion.GetAllFeatures().Length; i++) { //获取红线区域面 GSOFeature featureSelected = layerRedRegion.GetAt(i); GSOGeoPolyline3D polyline = featureSelected.Geometry as GSOGeoPolyline3D; GSOGeoPolygon3D polygon = new GSOGeoPolygon3D(); polygon.AddPart(polyline[0]); GSOFeature featurePolygon = new GSOFeature(); featurePolygon.Geometry = polygon; //globeControl1.Globe.MemoryLayer.AddFeature(featurePolygon); //面和每一类管线进行规划分析 for (int j = 0; j < listPipelineLayers.Count; j++) { DataRow row = dt.NewRow(); layer = listPipelineLayers[j]; if (layer != null) { //获取不完全包含在面中的所有线 GSOFeatures features = layer.FindFeaturesInPolygon(polygon, false); //获取完全包含在面中的所有线 GSOFeatures featuresTrue = layer.FindFeaturesInPolygon(polygon, true); //获取面中所有对象组成的切割面的长线 GSOFeature feature = getLineFromGSOFeatures(features, featuresTrue); if (feature != null && feature.Geometry != null) { //面积结果 GSOFeatures fs = new GSOFeatures(); int result = 0; //长度结果 GSOFeatures lfs = new GSOFeatures(); int lresult = 0; // ///计算侵占面积 GSODataEngineUtility.GSLineClipPolygon(feature, featurePolygon, out fs, out result); ///计算进入长度 GSODataEngineUtility.GSPolygonClipLine(feature, featurePolygon, out lfs, out lresult); ///////////////////////判断面积问题/////////////////////// if (result == 0) { //MessageBox.Show("表示用来切割的线不合法!"); } else if (result == 1) { //MessageBox.Show("表示要被切割的面不合法!"); } else if (result == 2) { //MessageBox.Show("表示线、面无交集!"); } else if (result == 3) { double areaMin = double.MaxValue; for (int m = 0; m < fs.Length; m++) { GSOFeature featurePolgyon = fs[m]; if (featurePolgyon.Geometry.Type == EnumGeometryType.GeoPolygon3D) { GSOGeoPolygon3D polygonAnalysis = featurePolgyon.Geometry as GSOGeoPolygon3D; double areaPolygon = polygonAnalysis.Area; if (areaPolygon < areaMin) { areaMin = areaPolygon; } } //globeControl1.Globe.MemoryLayer.AddFeature(fs[i]); } row[0] = (i + 1).ToString(); row[1] = layer.Caption; row[2] = areaMin.ToString("0.000000"); dt.Rows.Add(row); } ///////////////////////判断面积问题结束/////////////////////// ///////////////////////判断长度问题/////////////////////// if (lresult == 0) { //MessageBox.Show("表示用来切割的线、面不合法!"); } else if (lresult == 2) { //MessageBox.Show("表示线、面无交点!"); } else if (lresult == 1) { double lengthTotal = 0.0; for (int m = 0; m < lfs.Length; m++) { GSOFeature featureline = lfs[m]; if (featureline.Geometry.Type == EnumGeometryType.GeoPolyline3D) { GSOGeoPolyline3D lineAnalysis = featureline.Geometry as GSOGeoPolyline3D; double length = lineAnalysis.GetSpaceLength(false, 6378137); ; lengthTotal += length; } //globeControl1.Globe.MemoryLayer.AddFeature(featureline); } row[3] = lengthTotal.ToString("0.000") + "米"; } ///////////////////////判断长度问题结束/////////////////////// //feature.HighLight = true; //globeControl1.Globe.MemoryLayer.AddFeature(feature); } else { //MessageBox.Show("没有找到切割面的线对象!"); } } } } FrmAnalysisGuiHuaResult frm = new FrmAnalysisGuiHuaResult(dt); frm.Location = new Point(this.Width - frm.Width - 10, this.Height - frm.Height - 50); frm.Show(this); } /// <summary> /// 红线审核 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem138_Click_1(object sender, EventArgs e) { int blog = 0; //标注位置 GSOPoint3d pntIntersect1 = new GSOPoint3d(); GSOPoint3d pntIntersect2 = new GSOPoint3d(); GSOPoint3d pntProIntersect1 = new GSOPoint3d(); GSOPoint3d pntProIntersect2 = new GSOPoint3d(); //计算所有点集合到垂线垂距 double tmpmax = 0.0; double tmpmin = 0.0; GSOPoint3d tmpMaxpt = new GSOPoint3d(); GSOPoint3d tmpMinpt = new GSOPoint3d(); GSOPoint3d tmpbMaxpt = new GSOPoint3d(); GSOPoint3d tmpbMinpt = new GSOPoint3d(); //计算进入长度与进入面积 double distance = 0.0; double area = 0.0; //找到所有管线 string pipelinetype = Utility.pipelinetype; string[] pipelinetypes = pipelinetype.Split(','); //获得红线polygon GSOLayer layerSevenLine = globeControl1.Globe.Layers.GetLayerByCaption(redlinelayername); //获得红线结果列表 ArrayList rrLists = new ArrayList(); if (redlinelayername != "") { GSOFeatures fs = layerSevenLine.GetAllFeatures(); int len = fs.Length; for (int k = 0; k < len; k++) {//多根红线 ///////生成红线区域/////// GSOFeature featSevenLine = layerSevenLine.GetAt(k); GSOGeoPolyline3D sevenLine = featSevenLine.Geometry as GSOGeoPolyline3D; List<GSOPoint3ds> sevenParts = new List<GSOPoint3ds>(); for (int i = 0; i < sevenLine.PartCount; i++) { sevenParts.Add(sevenLine[i]); } GSOGeoPolygon3D sevenPolygon = new GSOGeoPolygon3D(); for (int i = 0; i < sevenParts.Count; i++) { sevenPolygon.AddPart((GSOPoint3ds)sevenParts[i]); } /////拼出红线多边形over////// ////把红线切成一段段的线段,获得切前的红线点集 List<GSOPoint3d> redpts = new List<GSOPoint3d>();//切前的红线点集合 for (int i = 0; i < sevenPolygon.PartCount; i++) { GSOPoint3ds partP = sevenPolygon[i]; for (int j = 0; j < partP.Count; j++) { redpts.Add(partP[j]); } } //每个管线与红线区域对比 for (int i = 0; i < pipelinetypes.Length; i++) { GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(pipelinetypes[i] + "管线"); //线切割面定义,输出用 GSOFeatures resFeats = new GSOFeatures(); int resultstyle = 0; //管线切割红线区域后,面积较小的区域 GSOGeoPolygon3D restPoly = new GSOGeoPolygon3D(); List<GSOPoint3d> inpts = new List<GSOPoint3d>(); if (layer != null) { //红线区域 GSOFeature sevenfeature = new GSOFeature(); sevenfeature.Geometry = sevenPolygon; //获取不完全包含在面中的所有线 GSOFeatures feats = layer.FindFeaturesInPolygon(sevenPolygon, false); //获取完全包含在面中的所有线 GSOFeatures featsTrue = layer.FindFeaturesInPolygon(sevenPolygon, true); //获取面中所有对象组成的切割面的长线 GSOFeature feature = new GSOFeature(); //判断管线与面积的关系 int pd = feats.Length - featsTrue.Length; // MessageBox.Show(pd.ToString()+"==="+layer.Caption); if (pd == 2) { //2=有两个交点(针对非多孔管线,有进有出的情况) tmpmax = 0.0; tmpmin = 0.0; distance = 0.0; area = 0.0; feature = getLineFromGSOFeatures(feats, featsTrue);//管线多个feature拼成一个feature //globeControl1.Globe.MemoryLayer.AddFeature(feature); //globeControl1.Globe.MemoryLayer.AddFeature(sevenfeature); if (feature != null) { //线切割面,输出 //feature.HighLight = true; GSODataEngineUtility.GSLineClipPolygon(feature, sevenfeature, out resFeats, out resultstyle); } else { MessageBox.Show("没有找到切割面的线对象!"); } ////////////////绘制分割后的多边形/////////////// //for (int a = 0; a < resFeats.Length; a++) //{ // GSOFeature gf = resFeats[a]; // globeControl1.Globe.MemoryLayer.AddFeature(gf); //} ////////////////////结束绘制//////////////////////// //判断切割后的两个区域面积大小,得到切割后的面积 if (resultstyle != 3) { //线面无交集 continue; } else if (resultstyle == 3) { if (resFeats != null) { double rArea1 = 0, rArea2 = 0; GSOGeoPolygon3D respoly1 = null, respoly2 = null; for (int j = 0; j < resFeats.Length; j++) { GSOFeature resfeat = resFeats[j]; if (j == 0) { respoly1 = resfeat.Geometry as GSOGeoPolygon3D; rArea1 = respoly1.Area; } else { respoly2 = resfeat.Geometry as GSOGeoPolygon3D; rArea2 = respoly2.Area; } } //判断哪个是最小区域 if (rArea1 > rArea2) { restPoly = respoly2; } else { restPoly = respoly1; } area = restPoly.Area; //放大到该区域 globeControl1.Globe.JumpToGeometry(restPoly,50); ////////////////得到面积较小的区域为restpoly over////////////////// List<GSOPoint3d> gxPtnew = new List<GSOPoint3d>();//管线点集 GSOGeoPolyline3D linenew = new GSOGeoPolyline3D();//新管线 GSOGeoPolyline3D redlinenew = new GSOGeoPolyline3D();//新红线 //////////得到在红线区域内的管线的点集合////////// List<GSOPoint3d> lptse = new List<GSOPoint3d>(); for (int b = 0; b < featsTrue.Length; b++) { GSOFeature featTrue = featsTrue[b]; GSOGeoPolyline3D l = featTrue.Geometry as GSOGeoPolyline3D; for (int a = 0; a < l.PartCount; a++) { GSOPoint3ds lparts = l[a]; for (int c = 0; c < lparts.Count; c++) { lptse.Add(lparts[c]); } } } gxPtnew = lptse; /////////////////得到切割后的区域的全部点//////////////////////// List<GSOPoint3d> redptse = new List<GSOPoint3d>(); List<GSOPoint3d> redptsebk = new List<GSOPoint3d>(); List<GSOPoint3d> redptsebk2 = new List<GSOPoint3d>(); for (int b = 0; b < restPoly.PartCount; b++) { GSOPoint3ds partPs = restPoly[b]; for (int j = 0; j < partPs.Count; j++) { redptse.Add(partPs[j]); } } redptsebk = redptse;//用于生成新红线 redptsebk2 = redptse;//用于生成新管线 /////////////////将切割后的区域的点集去掉管线的点//////////////// for (int a = 0; a < redptse.Count; a++) { GSOPoint3d redpt = redptse[a]; for (int b = 0; b < lptse.Count; b++) { GSOPoint3d lpt = lptse[b]; if (comparePoint(redpt, lpt)) {//如果两个点相同 redptse.RemoveAt(a); a--; } } } ////////////获得交点==切割后的点-红线的点////////// for (int a = 0; a < redptse.Count; a++) { GSOPoint3d redpt = redptse[a]; for (int b = 0; b < redpts.Count; b++) { GSOPoint3d redallpt = redpts[b]; if (comparePoint(redpt, redallpt)) { redptse.RemoveAt(a); a--; } } } ////////////////////当前redptse为交点集//////////////// //////////////得到新管线=切后的红线-原有红线/////////// for (int a = 0; a < redptsebk2.Count; a++) { GSOPoint3d redpt = redptsebk2[a]; for (int b = 0; b < redpts.Count; b++) { GSOPoint3d redp = redpts[b]; if (comparePoint(redpt, redp)) { redptsebk2.RemoveAt(a); a--; } } } ////当前redptsebk2 为新管线包含交点 GSOPoint3ds lps = new GSOPoint3ds(); for (int a = 0; a < redptsebk2.Count; a++) { GSOPoint3d lp = redptsebk2[a]; lps.Add(lp); } linenew.AddPart(lps); /////////计算管线进入长度//////////// distance = linenew.GetSpaceLength(false, 6378137.0); //////////////////得到新红线/////////////////// for (int a = 0; a < redptsebk.Count; a++) { GSOPoint3d redpt = redptsebk[a]; for (int b = 0; b < gxPtnew.Count; b++) { GSOPoint3d gxpt = gxPtnew[b]; if (comparePoint(redpt, gxpt)) { redptsebk.RemoveAt(a); a--; } } } GSOPoint3ds redlinepts = new GSOPoint3ds(); for (int a = 0; a < redptsebk.Count; a++) { GSOPoint3d p = redptsebk[a]; redlinepts.Add(p); } redlinenew = new GSOGeoPolyline3D(redlinepts); blog = 1; ///////////////计算垂距==对每一段红线最垂线,找到离该垂线最近的点与最远的点///////////// //for (int g = 0; g < redptsebk.Count - 1; g++) //{ // //计算垂距垂点 // double clength = 0.0; // GSOPoint3d cpoint = new GSOPoint3d(); // //构建红线线段 // GSOPoint3ds rpts = new GSOPoint3ds(); // rpts.Add(redptsebk[g]); // rpts.Add(redptsebk[g + 1]); // GSOGeoPolyline3D rline = new GSOGeoPolyline3D(rpts); // for (int h = 0; h < gxPtnew.Count; h++) // { // GSOPoint3d gxpt = gxPtnew[h]; // comparePointLine(gxpt, rline, out clength, out cpoint); // if (clength != 0) //向新红线上做垂线 // { // } // else // { // } // // // } //} //for (int g = 0; g < gxPtnew.Count; g++) //{ // //计算垂距垂点 // double clength = 0.0; // GSOPoint3d cpoint = new GSOPoint3d(); // GSOPoint3d gxpt = gxPtnew[g]; // for (int h = 0; h < redptsebk.Count-1; h++) // { // GSOPoint3ds rpts = new GSOPoint3ds(); // rpts.Add(redptsebk[h]); // rpts.Add(redptsebk[h + 1]); // GSOGeoPolyline3D rline = new GSOGeoPolyline3D(rpts); // comparePointLine(gxpt, rline, out clength, out cpoint); // if (clength != 0) //向新红线上最垂线 // { // } // else { // } // } // if (g == 0) // { // tmpmax = clength; // tmpmin = clength; // tmpMaxpt = cpoint; // tmpMinpt = cpoint; // tmpbMaxpt = gxpt; // tmpbMinpt = gxpt; // } // if (tmpmax > clength) // { // continue; // } // else // { // tmpmax = clength; // tmpMaxpt = cpoint; // tmpbMaxpt = gxpt; // } // if (tmpmin < clength) // { // continue; // } // else // { // tmpmin = clength; // tmpMinpt = cpoint; // tmpbMinpt = gxpt; // } //} ////////////////创建对象////////////////////////// RedlineResult lrr = new RedlineResult(pipelinetypes[i], string.Format("{0:F}", tmpmax), string.Format("{0:F}", tmpmin), tmpbMaxpt, tmpMaxpt, tmpbMinpt, tmpMinpt, string.Format("{0:F}", distance), string.Format("{0:F}", area)); rrLists.Add(lrr); } } } else if (pd == 1) //1=有一个交点(针对单孔管线,有进无出或有出无进,只计算进入长度) { tmpmax = 0.0; tmpmin = 0.0; distance = 0.0; area = 0.0; //////////得到在红线区域内的管线的点集合////////// List<GSOPoint3d> lptse = new List<GSOPoint3d>(); for (int b = 0; b < featsTrue.Length; b++) { GSOFeature featTrue = featsTrue[b]; GSOGeoPolyline3D l = featTrue.Geometry as GSOGeoPolyline3D; for (int a = 0; a < l.PartCount; a++) { GSOPoint3ds lparts = l[a]; for (int c = 0; c < lparts.Count; c++) { lptse.Add(lparts[c]); } } } ////////////////得到在红线区域内的管线的点集合,与红线区域相切的///////////////////////// List<GSOPoint3d> lptse2 = new List<GSOPoint3d>(); for (int b = 0; b < feats.Length; b++) { GSOFeature feat = feats[b]; GSOGeoPolyline3D l = feat.Geometry as GSOGeoPolyline3D; for (int a = 0; a < l.PartCount; a++) { GSOPoint3ds lparts = l[a]; for (int c = 0; c < lparts.Count; c++) { lptse2.Add(lparts[c]); } } } //////////////给所有点做垂线,得到所有垂点集合,使用垂线加管线切割红线得到最小区域////////////// GSOPoint3d cpt = new GSOPoint3d(); List<RedlineResult> rrList = new List<RedlineResult>(); double clength = 0; for (int a = 0; a < lptse.Count; a++) { GSOPoint3d lpt = lptse[a]; comparePointLine(lpt, sevenLine, out clength, out cpt); lptse2.Add(cpt); //构建新的穿入管线 GSOPoint3ds lpts = new GSOPoint3ds(); for (int b = 0; b < lptse2.Count; b++) { lpts.Add(lptse2[b]); } GSOGeoPolyline3D newgxline = new GSOGeoPolyline3D(lpts); GSOFeature newgxlinefeat = new GSOFeature(); newgxlinefeat.Geometry = newgxline; //globeControl1.Globe.MemoryLayer.AddFeature(newgxlinefeat); ////新穿入的管线切割红线区域,输出两个面 //GSODataEngineUtility.GSLineClipPolygon(newgxlinefeat, sevenfeature, out resFeats, out resultstyle); //double area1 = 0; double area2 = 0; //GSOGeoPolygon3D crespoly = null; //GSOGeoPolygon3D respoly1 = null, respoly2 = null; //for (int j = 0; j < resFeats.Length; j++) //{ // GSOFeature resfeat = resFeats[j]; // if (j == 0) // { // respoly1 = resfeat.Geometry as GSOGeoPolygon3D; // area1 = respoly1.Area; // } // else // { // respoly2 = resfeat.Geometry as GSOGeoPolygon3D; // area2 = respoly2.Area; // } //} ////判断哪个面是最小区域 //if (area1 > area2) //{ // crespoly = respoly2; //} //else //{ // crespoly = respoly1; //} //double pdArea = crespoly.Area;//用来判断面积大小 //RedlineResult rr = new RedlineResult(crespoly, cpt, lptse, string.Format("{0:F}", pdArea)); //rrList.Add(rr); } //////////////////遍历得到的结果,找到最大面积区域,通过最大区域得到交点////////////////////////// //RedlineResult maxrr = null; //double tmp = 0; //for (int c = 0; c < rrList.Count; c++) { // RedlineResult rr = rrList[c]; // double rrarea = double.Parse(rr.area); // if (tmp < rrarea) { // tmp = rrarea; // maxrr = rr; // } //} ////////////////////通过找到的最大面积区域的值,找到交点//////////////////// //GSOGeoPolygon3D maxpoly = maxrr.poly; //GSOPoint3d maxcpt = maxrr.cpt; //List<GSOPoint3d> maxlptse = maxrr.inpts; //////////////得到切后区域的点集合///////////// //List<GSOPoint3d> maxppt = new List<GSOPoint3d>();//切后的点集合 //for (int c = 0; c < maxpoly.PartCount; c++) //{ // GSOPoint3ds partP = maxpoly[c]; // for (int d = 0; d < partP.Count; d++) // { // maxppt.Add(partP[d]); // } //} ///////////////得到切后的点集合-垂点/////////////// //for (int a = 0; a < maxppt.Count; a++) //{ // GSOPoint3d redpt = maxppt[a]; // if (comparePoint(redpt, maxcpt)) // { // maxppt.RemoveAt(a); // a--; // } //} //////////////-垂点后再-区域内的点集合///////////////// //for (int a = 0; a < maxppt.Count; a++) //{ // GSOPoint3d redpt = maxppt[a]; // for (int b = 0; b < maxlptse.Count; b++) // { // GSOPoint3d gxpt = maxlptse[b]; // if (comparePoint(redpt, gxpt)) // { // maxppt.RemoveAt(a); // a--; // } // } //} //////////////-垂点后再-区域内点-原红线点/////////////// //for (int a = 0; a < maxppt.Count; a++) //{ // GSOPoint3d redpt = maxppt[a]; // for (int b = 0; b < redpts.Count; b++) // { // GSOPoint3d gxpt = redpts[b]; // if (comparePoint(redpt, gxpt)) // { // maxppt.RemoveAt(a); // a--; // } // } //} /////////////得到的是交点/////////////////// //GSOPoint3d jdpt = maxppt[0]; } else if (pd == 0) { //pd===无交叉 tmpmax = 0.0; tmpmin = 0.0; distance = 0.0; area = 0.0; RedlineResult lrr = new RedlineResult(pipelinetypes[i], string.Format("{0:F}", tmpmax), string.Format("{0:F}", tmpmin), tmpbMaxpt, tmpMaxpt, tmpbMinpt, tmpMinpt, string.Format("{0:F}", distance), string.Format("{0:F}", area)); rrLists.Add(lrr); } else if ((pipelinetypes[i] == "移动") || (pipelinetypes[i] == "联通") || (pipelinetypes[i] == "电信") || (pipelinetypes[i] == "有线电视") || (pipelinetypes[i] == "网通") || (pipelinetypes[i] == "交通信号") || (pipelinetypes[i] == "监控") || (pipelinetypes[i] == "电通")) {//如果是多孔 tmpmax = 0.0; tmpmin = 0.0; distance = 0.0; area = 0.0; if (pd > 2) { } RedlineResult lrr = new RedlineResult(pipelinetypes[i], string.Format("{0:F}", tmpmax), string.Format("{0:F}", tmpmin), tmpbMaxpt, tmpMaxpt, tmpbMinpt, tmpMinpt, string.Format("{0:F}", distance), string.Format("{0:F}", area)); rrLists.Add(lrr); } } } } if (blog == 0) { MessageBox.Show("请导入红线"); return; } frmredResult = new FrmRedlineResult(rrLists, globeControl1); if (frmRedlineResult == false) { frmredResult.Owner = this; frmredResult.Show(); frmredResult.Location = new Point(this.Width - frmredResult.Width - 10, this.Height - frmredResult.Height - 50); frmRedlineResult = true; } else { } } else { MessageBox.Show("请导入红线"); } } /// <summary> /// 求管线进入地块的长度 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void 求管线进入地块的长度ToolStripMenuItem_Click(object sender, EventArgs e) { List<GSOLayer> listPipelineLayers = new List<GSOLayer>(); #region 获取管线列表 GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption("电信管线"); if (layer != null) { listPipelineLayers.Add(layer); } layer = globeControl1.Globe.Layers.GetLayerByCaption("给水管线"); if (layer != null) { listPipelineLayers.Add(layer); } layer = globeControl1.Globe.Layers.GetLayerByCaption("路灯管线"); if (layer != null) { listPipelineLayers.Add(layer); } layer = globeControl1.Globe.Layers.GetLayerByCaption("天然气管线"); if (layer != null) { listPipelineLayers.Add(layer); } layer = globeControl1.Globe.Layers.GetLayerByCaption("网通管线"); if (layer != null) { listPipelineLayers.Add(layer); } layer = globeControl1.Globe.Layers.GetLayerByCaption("污水管线"); if (layer != null) { listPipelineLayers.Add(layer); } layer = globeControl1.Globe.Layers.GetLayerByCaption("移动管线"); if (layer != null) { listPipelineLayers.Add(layer); } layer = globeControl1.Globe.Layers.GetLayerByCaption("有线电视管线"); if (layer != null) { listPipelineLayers.Add(layer); } layer = globeControl1.Globe.Layers.GetLayerByCaption("雨水管线"); if (layer != null) { listPipelineLayers.Add(layer); } #endregion DataTable dt = new DataTable(); dt.Columns.Add("红线编号"); dt.Columns.Add("管线类型"); dt.Columns.Add("管线进入地块长度"); dt.Columns.Add("管线进入地块面积"); for (int i = 0; i < layerRedRegion.GetAllFeatures().Length; i++) { //获取红线区域面 GSOFeature featureSelected = layerRedRegion.GetAt(i); GSOGeoPolyline3D polyline = featureSelected.Geometry as GSOGeoPolyline3D; GSOGeoPolygon3D polygon = new GSOGeoPolygon3D(); polygon.AddPart(polyline[0]); GSOFeature featurePolygon = new GSOFeature(); featurePolygon.Geometry = polygon; //globeControl1.Globe.MemoryLayer.AddFeature(featurePolygon); //面和每一类管线进行规划分析 for (int j = 0; j < listPipelineLayers.Count; j++) { layer = listPipelineLayers[j]; if (layer != null) { //获取不完全包含在面中的所有线 GSOFeatures features = layer.FindFeaturesInPolygon(polygon, false); //获取完全包含在面中的所有线 GSOFeatures featuresTrue = layer.FindFeaturesInPolygon(polygon, true); //获取面中所有对象组成的切割面的长线 GSOFeature feature = getLineFromGSOFeatures(features, featuresTrue); if (feature != null && feature.Geometry != null) { GSOFeatures fs = new GSOFeatures(); int result = 0; GSODataEngineUtility.GSPolygonClipLine(feature, featurePolygon, out fs, out result); if (result == 0) { //MessageBox.Show("表示用来切割的线、面不合法!"); } else if (result == 2) { //MessageBox.Show("表示线、面无交点!"); } else if (result == 1) { double lengthTotal = 0.0; for (int m = 0; m < fs.Length; m++) { GSOFeature featureline = fs[m]; if (featureline.Geometry.Type == EnumGeometryType.GeoPolyline3D) { GSOGeoPolyline3D lineAnalysis = featureline.Geometry as GSOGeoPolyline3D; double length = lineAnalysis.GetSpaceLength(false, 6378137); ; lengthTotal += length; } globeControl1.Globe.MemoryLayer.AddFeature(featureline); } DataRow row = dt.NewRow(); row[0] = (i + 1).ToString(); row[1] = layer.Caption; row[2] = lengthTotal.ToString("0.000") + "米"; dt.Rows.Add(row); } //feature.HighLight = true; //globeControl1.Globe.MemoryLayer.AddFeature(feature); } else { //MessageBox.Show("没有找到切割面的线对象!"); } } } } FrmAnalysisGuiHuaResult frm = new FrmAnalysisGuiHuaResult(dt); frm.Show(this); } /// <summary> /// 绘制垂线 /// </summary> /// <param name="fpt"></param> /// <param name="tpt"></param> private void drawCLine(GSOPoint3d fpt,GSOPoint3d tpt) { GSOGeoPolyline3D pline = new GSOGeoPolyline3D(); GSOPoint3ds pts = new GSOPoint3ds(); pts.Add(fpt); pts.Add(tpt); pline.AddPart(pts); GSOGeoPoint3D fptg = new GSOGeoPoint3D(); GSOGeoPoint3D tptg = new GSOGeoPoint3D(); fptg.X = fpt.X; fptg.Y = fpt.Y; fptg.Z = 0; tptg.X = tpt.X; tptg.Y = tpt.Y; tptg.Z = 0; GSOFeature gf = new GSOFeature(); gf.Geometry = pline; globeControl1.Globe.MemoryLayer.AddFeature(gf); } /// <summary> /// 红线审核 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem138_Click_2(object sender, EventArgs e) { } /// <summary> /// 比较两个点是否是同一个点 /// </summary> /// <param name="pt1"></param> /// <param name="pt2"></param> /// <returns></returns> private bool comparePoint(GSOPoint3d pt1, GSOPoint3d pt2) { double x1 = 0; double y1 = 0; double x2 = 0; double y2 = 0; x1 = pt1.X; y1 = pt1.Y; x2 = pt2.X; y2 = pt2.Y; if ((x1 == x2) && (y1 == y2)) { return true; } return false; } /// <summary> /// 获得点到线的垂线距离及垂点 /// </summary> /// <param name="point"></param> /// <param name="line"></param> /// <param name="length"></param> /// <param name="pointChuiDian"></param> private void comparePointLine(GSOPoint3d point, GSOGeoPolyline3D line, out double length, out GSOPoint3d pointChuiDian) { GSOPoint3d lineStartPoint = line[0][0]; GSOPoint3d lineEndPoint = line[0][1]; GSOGeoPolyline3D lineAB = new GSOGeoPolyline3D(); GSOPoint3ds pointsAB = new GSOPoint3ds(); pointsAB.Add(point); pointsAB.Add(lineStartPoint); lineAB.AddPart(pointsAB); double lengthAB = lineAB.GetSpaceLength(false, 6378137.0); double xieLvAB = getXieLu("", point.X, point.Y, lineStartPoint.X, lineStartPoint.Y); double xieLvBC = getXieLu("", lineStartPoint.X, lineStartPoint.Y, lineEndPoint.X, lineEndPoint.Y); double tanABC = Math.Abs(xieLvAB - xieLvBC) / (1 + xieLvAB * xieLvBC); double angle = Math.Atan(tanABC); //if (angle > Math.PI / 2) //落在外边 //{ // length = 0; //} double lengthAD = lengthAB * Math.Sin(angle); length = Math.Abs(lengthAD); double lengthBD = lengthAB * Math.Cos(angle); GSOPoint2d point2dStart = Latlon_2_XYZ(lineStartPoint.X, lineStartPoint.Y); double bBC = point2dStart.Y - xieLvBC * point2dStart.X; GSOPoint2d point2dEnd = new GSOPoint2d(); point2dEnd.X = point2dStart.X + 100; point2dEnd.Y = point2dEnd.X * xieLvBC + bBC; point2dEnd = XYZ_2_Latlon(point2dEnd.X, point2dEnd.Y); GSOPoint3d pointEnd = new GSOPoint3d(); pointEnd.X = point2dEnd.X; pointEnd.Y = point2dEnd.Y; GSOGeoPolyline3D lineYanShen = new GSOGeoPolyline3D(); GSOPoint3ds pointsYanShen = new GSOPoint3ds(); pointsYanShen.Add(lineStartPoint); pointsYanShen.Add(pointEnd); lineYanShen.AddPart(pointsYanShen); GSOGeoPolyline3D lineSegment = lineYanShen.GetSegment(0, lengthBD); pointChuiDian = lineSegment[0][1]; } /// <summary> /// 获得斜率 /// </summary> /// <param name="projectName"></param> /// <param name="lon1"></param> /// <param name="lat1"></param> /// <param name="lon2"></param> /// <param name="lat2"></param> /// <returns></returns> public static double getXieLu(string projectName, double lon1, double lat1, double lon2, double lat2) { if (lon1 == lon2) { return 0; } else { GSOPoint2d pointStart = Latlon_2_XYZ(projectName, lon1, lat1); GSOPoint2d pointEnd = Latlon_2_XYZ(projectName, lon2, lat2); return (pointEnd.Y - pointStart.Y) / (pointEnd.X - pointStart.X); } } /// <summary> /// 根据默认投影参数,经纬度转xyz /// </summary> /// <param name="lon"></param> /// <param name="lat"></param> /// <returns></returns> public static GeoScene.Data.GSOPoint2d Latlon_2_XYZ(double lon, double lat) { int id = GeoScene.Data.GSOProjectManager.AddProject(null);//Utility.GetProjectName()); GeoScene.Data.GSOPoint2d pt2d = new GeoScene.Data.GSOPoint2d(lon, lat); GeoScene.Data.GSOPoint2d result = GeoScene.Data.GSOProjectManager.Forward(pt2d, id); return result; } /// <summary> /// 根据投影参数,经纬度转xyz /// </summary> /// <param name="projectName"></param> /// <param name="lon"></param> /// <param name="lat"></param> /// <returns></returns> public static GeoScene.Data.GSOPoint2d Latlon_2_XYZ(string projectName, double lon, double lat) { int id = GeoScene.Data.GSOProjectManager.AddProject(projectName); GeoScene.Data.GSOPoint2d pt2d = new GeoScene.Data.GSOPoint2d(lon, lat); GeoScene.Data.GSOPoint2d result = GeoScene.Data.GSOProjectManager.Forward(pt2d, id); return result; } /// <summary> /// 根据默认投影参数,xyz转经纬度 /// </summary> /// <param name="x"></param> /// <param name="y"></param> /// <returns></returns> public static GeoScene.Data.GSOPoint2d XYZ_2_Latlon(double x, double y) { int id = GeoScene.Data.GSOProjectManager.AddProject(null);//Utility.GetProjectName()); GeoScene.Data.GSOPoint2d pt2d = new GeoScene.Data.GSOPoint2d(x, y); GeoScene.Data.GSOPoint2d result = GeoScene.Data.GSOProjectManager.Inverse(pt2d, id); return result; } /// <summary> /// 根据投影参数,Xyz转经纬度 /// </summary> /// <param name="projectName"></param> /// <param name="x"></param> /// <param name="y"></param> /// <returns></returns> public static GeoScene.Data.GSOPoint2d XYZ_2_Latlon(string projectName, double x, double y) { int id = GeoScene.Data.GSOProjectManager.AddProject(projectName); GeoScene.Data.GSOPoint2d pt2d = new GeoScene.Data.GSOPoint2d(x, y); GeoScene.Data.GSOPoint2d result = GeoScene.Data.GSOProjectManager.Inverse(pt2d, id); return result; } /// <summary> /// 获得inpolygon的管线长度 /// </summary> /// <returns></returns> public double getInDistance(GSOPoint3d markerPosition, GSOGeoPolyline3D linep, GSOGeoPolygon3D sevenPolygon) { GSOGeoPolyline3D newline = new GSOGeoPolyline3D(); GSOPoint3ds newpts = new GSOPoint3ds(); newpts.Add(markerPosition); GSOPoint3d inpt = new GSOPoint3d(); int lineptcount = linep.PartCount; if(lineptcount==1) { GSOPoint3ds linept = linep[0]; GSOPoint3d fpt = linept[0]; GSOPoint3d tpt = linept[1]; GSOGeoPoint3D fpt2 = new GSOGeoPoint3D(); fpt2.X=fpt.X; fpt2.Y=fpt.Y; fpt2.Z=fpt.Z; GSOFeature ffeat = new GSOFeature(); ffeat.Geometry =fpt2; GSOGeoPoint3D tpt2 = new GSOGeoPoint3D(); tpt2.X=tpt.X; tpt2.Y=tpt.Y; tpt2.Z=tpt.Z; GSOFeature tfeat = new GSOFeature(); tfeat.Geometry =tpt2; //判断那个点在polygon里 GSOLayer layer = globeControl1.Globe.MemoryLayer; layer.RemoveAllFeature(); layer.AddFeature(ffeat); GSOFeatures inorout = layer.FindFeaturesInPolygon(sevenPolygon,true); layer.RemoveAllFeature(); layer.AddFeature(tfeat); GSOFeatures inorout2 = layer.FindFeaturesInPolygon(sevenPolygon,true); if (inorout.Length != 0) { inpt = fpt; } else { inpt = tpt; } } newpts.Add(inpt); newline.AddPart(newpts); double indis = 0; indis = newline.GetSpaceLength(true, 6378137); return indis; } /// <summary> /// 获取与点相连的所有线以及线的点的集合 /// </summary> /// <param name="featureSelect">选定的点所在的线</param> /// <param name="lineStart">选定的点</param> /// <param name="selectFeatures">面中不完全包含的除起点线之外所有的线</param> /// <param name="ps">选定的点所在的点的集合</param> /// <param name="listPS">所有以选定线为起点的点的集合</param> /// <returns></returns> private List<GSOPoint3ds> getFeaturesPoints(GSOFeature featureSelect, GSOPoint3d lineStart, GSOFeatures selectFeatures, GSOPoint3ds ps, List<GSOPoint3ds> listPS) { GSOFeatures fsStart = new GSOFeatures(); for (int n = 0; n < selectFeatures.Length; n++) { if (featureSelect.ID == selectFeatures[n].ID) { continue; } GSOGeoPolyline3D newLine = selectFeatures[n].Geometry as GSOGeoPolyline3D; if (newLine != null && newLine.PartCount > 0) { GSOPoint3d newLineStart = newLine[0][0]; GSOPoint3d newLineEnd = newLine[0][newLine[0].Count - 1]; if (lineStart.X == newLineEnd.X && lineStart.Y == newLineEnd.Y) { GSOPoint3ds psAdd = new GSOPoint3ds(); for (int k = newLine[0].Count - 1; k >= 0; k--) { psAdd.Add(newLine[0][k]); } newLine[0] = psAdd; fsStart.Add(selectFeatures[n]); } else if (lineStart.X == newLineStart.X && lineStart.Y == newLineStart.Y) { fsStart.Add(selectFeatures[n]); } } } if (fsStart.Length > 0) { for (int m = 0; m < fsStart.Length; m++) { GSOGeoPolyline3D lineFsStart = fsStart[m].Geometry as GSOGeoPolyline3D; if (lineFsStart != null && lineFsStart.PartCount > 0) { GSOPoint3ds psAdd = ps.Clone(); for (int k = 0; k < lineFsStart[0].Count; k++) { psAdd.Add(lineFsStart[0][k]); } listPS = getFeaturesPoints(fsStart[m], lineFsStart[0][lineFsStart[0].Count - 1], selectFeatures, psAdd, listPS); } } } else { listPS.Add(ps); } return listPS; } /// <summary> /// 获取切割面的线 /// </summary> /// <param name="features">不完全包含在面中的所有线</param> /// <param name="featuresTrue">完全包含在面中的所有线</param> /// <returns>线</returns> private GSOFeature getLineFromGSOFeatures(GSOFeatures features, GSOFeatures featuresTrue) { //1. 当线对象数组的长度为0时,返回空 if (features.Length == 0) { return null; } //2. 当线对象数组的长度为1时,返回这条线 if (features.Length == 1) { return features[0]; } //3. 当线对象数组的长度大于1时,计算所有线组成的最长线 //3.1 获取所有不完全包含在面中的对象selectFeatures GSOFeatures selectFeatures = new GSOFeatures(); for (int a = 0; a < features.Length; a++) { selectFeatures.Add(features[a].Clone()); } //3.2 删除features中完全包含在面中的线,获取和面的边界相交的线对象 for (int a = 0; a < featuresTrue.Length; a++) { for (int b = 0; b < features.Length; b++) { if (featuresTrue[a].ID == features[b].ID) { features.Remove(b); break; } } } //3.3 如果和面的边界相交的线的数量为0,返回空 if (features.Length == 0) { return null; } //3.4 获取第一条和面的边界相交的线featureInOutPolygon GSOFeature featureInOutPolygon = features[0]; //3.5 从所有的线中删除featureInOutPolygon for (int a = 0; a < selectFeatures.Length; a++) { if (selectFeatures[a].ID == featureInOutPolygon.ID) { selectFeatures.Remove(a); break; } } //listPS存储所有从featureInOutPolygon出发的点的集合 List<GSOPoint3ds> listPS = new List<GSOPoint3ds>(); //3.5 获取与featureInOutPolygon相连的线的集合 GSOGeoPolyline3D line = featureInOutPolygon.Geometry as GSOGeoPolyline3D; if (line != null && line.PartCount > 0) { GSOPoint3d lineStart = line[0][0]; GSOPoint3d lineEnd = line[0][line[0].Count - 1]; #region//获取和featureInOutPolygon的起点相连的线 GSOFeatures fsStart = new GSOFeatures(); for (int n = 0; n < selectFeatures.Length; n++) { GSOGeoPolyline3D newLine = selectFeatures[n].Geometry as GSOGeoPolyline3D; if (newLine != null && newLine.PartCount > 0) { GSOPoint3d newLineStart = newLine[0][0]; GSOPoint3d newLineEnd = newLine[0][newLine[0].Count - 1]; if (lineStart.X == newLineEnd.X && lineStart.Y == newLineEnd.Y) { GSOPoint3ds psAdd = new GSOPoint3ds(); for (int k = newLine[0].Count - 1; k >= 0; k--) { psAdd.Add(newLine[0][k]); } newLine[0] = psAdd; fsStart.Add(selectFeatures[n]); } else if (lineStart.X == newLineStart.X && lineStart.Y == newLineStart.Y) { fsStart.Add(selectFeatures[n]); } } } #endregion #region//获取和featureInOutPolygon的终点相连的线 GSOFeatures fsEnd = new GSOFeatures(); for (int n = 0; n < selectFeatures.Length; n++) { GSOGeoPolyline3D newLine = selectFeatures[n].Geometry as GSOGeoPolyline3D; if (newLine != null && newLine.PartCount > 0) { GSOPoint3d newLineStart = newLine[0][0]; GSOPoint3d newLineEnd = newLine[0][newLine[0].Count - 1]; if (lineEnd.X == newLineStart.X && lineEnd.Y == newLineStart.Y) { fsEnd.Add(selectFeatures[n]); } else if (lineEnd.X == newLineEnd.X && lineEnd.Y == newLineEnd.Y) { GSOPoint3ds psAdd = new GSOPoint3ds(); for (int k = newLine[0].Count - 1; k >= 0; k--) { psAdd.Add(newLine[0][k]); } newLine[0] = psAdd; fsEnd.Add(selectFeatures[n]); } } } #endregion //3.6 将featureInOutPolygon的所有点和与之起点相连的线的所有点组成一个点的集合并添加到listPS中 if (fsStart.Length > 0 && fsEnd.Length == 0) { for (int m = 0; m < fsStart.Length; m++) { GSOGeoPolyline3D lineFsStart = fsStart[m].Geometry as GSOGeoPolyline3D; if (lineFsStart != null && lineFsStart.PartCount > 0) { GSOPoint3ds psAdd = new GSOPoint3ds(); for (int k = line[0].Count - 1; k >= 0; k--) { psAdd.Add(line[0][k]); } for (int k = 0; k < lineFsStart[0].Count; k++) { psAdd.Add(lineFsStart[0][k]); } listPS = getFeaturesPoints(fsStart[m], lineFsStart[0][lineFsStart[0].Count - 1], selectFeatures, psAdd, listPS); } } } //3.6 将featureInOutPolygon的所有点和与之终点相连的线的所有点组成一个点的集合并添加到listPS中 else if (fsStart.Length == 0 && fsEnd.Length > 0) { for (int n = 0; n < fsEnd.Length; n++) { GSOGeoPolyline3D lineFsEnd = fsEnd[n].Geometry as GSOGeoPolyline3D; if (lineFsEnd != null && lineFsEnd.PartCount > 0) { GSOPoint3ds psAdd = new GSOPoint3ds(); for (int k = 0; k < line[0].Count - 1; k++) { psAdd.Add(line[0][k]); } for (int k = 0; k < lineFsEnd[0].Count; k++) { psAdd.Add(lineFsEnd[0][k]); } //获取线fsEnd[n]的另一个端点相连的线并记录该线的点的集合 listPS = getFeaturesPoints(fsEnd[n], lineFsEnd[0][lineFsEnd[0].Count - 1], selectFeatures, psAdd, listPS); } } } } //3.7 获取所有以featureInOutPolygon为起点的点的集合组成的线中的最长的线 double maxLength = 0; GSOFeature featureNew = new GSOFeature(); for (int h = 0; h < listPS.Count; h++) { GSOGeoPolyline3D lineNew = new GSOGeoPolyline3D(); lineNew.AddPart(listPS[h]); GSOLabel label = new GSOLabel(); label.Text = h.ToString(); featureNew.Label = label; double length = lineNew.GetSpaceLength(true, 6378137); if (length > maxLength) { featureNew.Geometry = lineNew; } } return featureNew; } /// <summary> /// 更新最大最小状态 /// </summary> /// <param name="rrlist"></param> /// <returns></returns> public ArrayList getRedlineState(ArrayList rrlist) { ArrayList mmlist = new ArrayList(); double[] jj = new double[rrlist.Count]; for (int i = 0; i < rrlist.Count; i++) { RedlineResult rr = (RedlineResult)rrlist[i]; jj[i]=double.Parse(rr.distance); } ArrayList list = new ArrayList(jj); list.Sort(); double minvalue = Convert.ToDouble(list[0]); double maxvalue = Convert.ToDouble(list[list.Count-1]); //找到是哪根管子 for (int i = 0; i < rrlist.Count; i++) { RedlineResult rr = (RedlineResult)rrlist[i]; jj[i] = double.Parse(rr.distance); if (jj[i] == minvalue) { rr.state = "min"; mmlist.Add(rr); } else if (jj[i] == maxvalue) { rr.state = "max"; mmlist.Add(rr); } else { mmlist.Add(rr); continue; } } return mmlist; } /// <summary> /// 一键审核中调节透明度 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void sliderItem1_ValueChanged(object sender, EventArgs e) { globeControl1.Globe.GroundOpaque = 100 - sliderItem1.Value; GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(roadLayerName);//("180fd"); if (layer != null) { layer.Opaque = 100 - sliderItem1.Value; } if (btnSpdb.Checked) { layer = globeControl2.Globe.Layers.GetLayerByCaption(roadLayerName);//("180fd"); if (layer != null) { layer.Opaque = 100 - sliderItem1.Value; } globeControl2.Globe.GroundOpaque = 100 - sliderItem1.Value; } optiValue = sliderItem1.Value; sliderGroundTransSet1.Value = optiValue; } private void buttonItem139_Click(object sender, EventArgs e) { string filepath = ""; //日志记录 OpenFileDialog dlg = new OpenFileDialog(); dlg.Filter = "矢量数据(*.shp)|*.shp|矢量数据(*.lgd)|*.lgd|全部支持格式(*.lgd,*.shp)|*.lgd;*.shp;"; //dlg.Filter = "支持格式(*.lrp,*.tif,*.img,*.lrc,*.kml,*.lgd,*.shp,*.gft)|*.lrp;*.tif;*.img;*.lrc;*.kml;*.lgd;*.shp;*.gft|栅格数据(*.lrp)|*.lrp|栅格缓存(*.lrc)|*.lrc|KML数据(*.kml)|*.kml|矢量数据(*.lgd)|*.lgd|矢量缓存(*.gft)|*.gft|其它格式(*.*)|*.*||"; dlg.Multiselect = true; if (dlg.ShowDialog() == DialogResult.OK) { //自定义lprj文件名,从程序中复制一lprj文件。 int bindex = dlg.FileName.Split('\\').Length; string lastname = dlg.FileName.Split('\\')[bindex - 1]; for (int i = 0; i < dlg.FileNames.Length; i++) { string strDataPath = dlg.FileNames[i]; filepath = strDataPath; GSOLayer layer = globeControl1.Globe.Layers.Add(strDataPath); } } globeControl1.Refresh(); } /// <summary> /// 系统文件管理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonItem146_Click(object sender, EventArgs e) { SystemFile frmSFiles = new SystemFile(); frmSFiles.ShowDialog(); } } }