diff --git a/Cyberpipe.csproj b/Cyberpipe.csproj index 3a45ad8..d22f590 100644 --- a/Cyberpipe.csproj +++ b/Cyberpipe.csproj @@ -402,12 +402,6 @@ FrmBACKORACLE.cs - - Form - - - FrmBSQDuoBianXingStatis.cs - Form @@ -1271,9 +1265,6 @@ FrmBACKORACLE.cs - - FrmBSQDuoBianXingStatis.cs - FrmBSQStatis.cs diff --git a/Cyberpipe.csproj b/Cyberpipe.csproj index 3a45ad8..d22f590 100644 --- a/Cyberpipe.csproj +++ b/Cyberpipe.csproj @@ -402,12 +402,6 @@ FrmBACKORACLE.cs - - Form - - - FrmBSQDuoBianXingStatis.cs - Form @@ -1271,9 +1265,6 @@ FrmBACKORACLE.cs - - FrmBSQDuoBianXingStatis.cs - FrmBSQStatis.cs diff --git a/FeatureStatisticsService.cs b/FeatureStatisticsService.cs index e833e5f..c7de210 100644 --- a/FeatureStatisticsService.cs +++ b/FeatureStatisticsService.cs @@ -273,19 +273,15 @@ /// 获取特定区域图层的管线列表,并将其总长度统计出来 /// TODOLIST:将Intersects_Pipeline在MainFrm中去除 /// - /// + /// + /// 要统计的长度 /// public static GSOFeatures getLayerPipes(GSOGeoPolygon3D polygon, GSOLayer layer, out double length) { length = 0; if (layer == null) return null; - GSOFeatureLayer flayer = layer as GSOFeatureLayer; - GSOFeatureDataset fdataset = flayer.Dataset as GSOFeatureDataset; - GSOFeatures feats = null; - - feats = polygon == null?flayer.GetAllFeatures():flayer.FindFeaturesInPolygon(polygon, false); - + GSOFeatures feats = getLayerFeatures(polygon, layer); double totallength = 0.00; for (int i = 0; i < feats.Length; i++) { @@ -301,5 +297,17 @@ return feats; } + /// + /// 获取区域图层内的feature列表,MainFrm.PolygonIntersectAnalysis和此方法重复,需要整理删除 + /// + /// + /// + /// + public static GSOFeatures getLayerFeatures(GSOGeoPolygon3D polygon, GSOLayer layer) + { + if (layer == null) return null; + GSOFeatureLayer flayer = layer as GSOFeatureLayer; + return polygon == null ? flayer.GetAllFeatures() : flayer.FindFeaturesInPolygon(polygon, false); + } } } diff --git a/Cyberpipe.csproj b/Cyberpipe.csproj index 3a45ad8..d22f590 100644 --- a/Cyberpipe.csproj +++ b/Cyberpipe.csproj @@ -402,12 +402,6 @@ FrmBACKORACLE.cs - - Form - - - FrmBSQDuoBianXingStatis.cs - Form @@ -1271,9 +1265,6 @@ FrmBACKORACLE.cs - - FrmBSQDuoBianXingStatis.cs - FrmBSQStatis.cs diff --git a/FeatureStatisticsService.cs b/FeatureStatisticsService.cs index e833e5f..c7de210 100644 --- a/FeatureStatisticsService.cs +++ b/FeatureStatisticsService.cs @@ -273,19 +273,15 @@ /// 获取特定区域图层的管线列表,并将其总长度统计出来 /// TODOLIST:将Intersects_Pipeline在MainFrm中去除 /// - /// + /// + /// 要统计的长度 /// public static GSOFeatures getLayerPipes(GSOGeoPolygon3D polygon, GSOLayer layer, out double length) { length = 0; if (layer == null) return null; - GSOFeatureLayer flayer = layer as GSOFeatureLayer; - GSOFeatureDataset fdataset = flayer.Dataset as GSOFeatureDataset; - GSOFeatures feats = null; - - feats = polygon == null?flayer.GetAllFeatures():flayer.FindFeaturesInPolygon(polygon, false); - + GSOFeatures feats = getLayerFeatures(polygon, layer); double totallength = 0.00; for (int i = 0; i < feats.Length; i++) { @@ -301,5 +297,17 @@ return feats; } + /// + /// 获取区域图层内的feature列表,MainFrm.PolygonIntersectAnalysis和此方法重复,需要整理删除 + /// + /// + /// + /// + public static GSOFeatures getLayerFeatures(GSOGeoPolygon3D polygon, GSOLayer layer) + { + if (layer == null) return null; + GSOFeatureLayer flayer = layer as GSOFeatureLayer; + return polygon == null ? flayer.GetAllFeatures() : flayer.FindFeaturesInPolygon(polygon, false); + } } } diff --git a/FrmAllWorkWellStatis.cs b/FrmAllWorkWellStatis.cs index 7bf65dc..bd0f81b 100644 --- a/FrmAllWorkWellStatis.cs +++ b/FrmAllWorkWellStatis.cs @@ -19,17 +19,7 @@ private Dictionary map = null; private GSOGlobeControl globeControl1; private GSOGeoPolygon3D polygon; - //TODOLIST:用晓伟的代理进行操作,功能拆分细化 - //public FrmAllWorkWellStatis(GSOGeoPolygon3D polygon, DataGridView dataGridViewX11, ToolStripStatusLabel toolStripNumbers1, GSOGlobeControl ctl, PanelEx p) - //{ - // InitializeComponent(); - // panel = p; - // dataGridViewX1 = dataGridViewX11; - // toolStripNumbers = toolStripNumbers1; - // globeControl1 = ctl; - // map = getAccsMap(polygon); - //} public FrmAllWorkWellStatis(GSOGlobeControl ctl,GSOGeoPolygon3D polygon, MainFrm.DataGridViewDelegate InitDataGridViewX1) { InitializeComponent(); @@ -117,8 +107,9 @@ sql = "select " + getpipeLineFields.getFields(layername, globeControl1) + " from " + layer.Name; sql += " where 1>2 "; - for (int i = 0; i < fs.Length && fs[i].GetFieldDefn("编号") != null; i++) + for (int i = 0; i < fs.Length; i++) { + if (fs[i].GetFieldDefn("编号") == null) continue; sql += " or 编号 = '" + fs[i].GetValue("编号").ToString() + "'"; } diff --git a/Cyberpipe.csproj b/Cyberpipe.csproj index 3a45ad8..d22f590 100644 --- a/Cyberpipe.csproj +++ b/Cyberpipe.csproj @@ -402,12 +402,6 @@ FrmBACKORACLE.cs - - Form - - - FrmBSQDuoBianXingStatis.cs - Form @@ -1271,9 +1265,6 @@ FrmBACKORACLE.cs - - FrmBSQDuoBianXingStatis.cs - FrmBSQStatis.cs diff --git a/FeatureStatisticsService.cs b/FeatureStatisticsService.cs index e833e5f..c7de210 100644 --- a/FeatureStatisticsService.cs +++ b/FeatureStatisticsService.cs @@ -273,19 +273,15 @@ /// 获取特定区域图层的管线列表,并将其总长度统计出来 /// TODOLIST:将Intersects_Pipeline在MainFrm中去除 /// - /// + /// + /// 要统计的长度 /// public static GSOFeatures getLayerPipes(GSOGeoPolygon3D polygon, GSOLayer layer, out double length) { length = 0; if (layer == null) return null; - GSOFeatureLayer flayer = layer as GSOFeatureLayer; - GSOFeatureDataset fdataset = flayer.Dataset as GSOFeatureDataset; - GSOFeatures feats = null; - - feats = polygon == null?flayer.GetAllFeatures():flayer.FindFeaturesInPolygon(polygon, false); - + GSOFeatures feats = getLayerFeatures(polygon, layer); double totallength = 0.00; for (int i = 0; i < feats.Length; i++) { @@ -301,5 +297,17 @@ return feats; } + /// + /// 获取区域图层内的feature列表,MainFrm.PolygonIntersectAnalysis和此方法重复,需要整理删除 + /// + /// + /// + /// + public static GSOFeatures getLayerFeatures(GSOGeoPolygon3D polygon, GSOLayer layer) + { + if (layer == null) return null; + GSOFeatureLayer flayer = layer as GSOFeatureLayer; + return polygon == null ? flayer.GetAllFeatures() : flayer.FindFeaturesInPolygon(polygon, false); + } } } diff --git a/FrmAllWorkWellStatis.cs b/FrmAllWorkWellStatis.cs index 7bf65dc..bd0f81b 100644 --- a/FrmAllWorkWellStatis.cs +++ b/FrmAllWorkWellStatis.cs @@ -19,17 +19,7 @@ private Dictionary map = null; private GSOGlobeControl globeControl1; private GSOGeoPolygon3D polygon; - //TODOLIST:用晓伟的代理进行操作,功能拆分细化 - //public FrmAllWorkWellStatis(GSOGeoPolygon3D polygon, DataGridView dataGridViewX11, ToolStripStatusLabel toolStripNumbers1, GSOGlobeControl ctl, PanelEx p) - //{ - // InitializeComponent(); - // panel = p; - // dataGridViewX1 = dataGridViewX11; - // toolStripNumbers = toolStripNumbers1; - // globeControl1 = ctl; - // map = getAccsMap(polygon); - //} public FrmAllWorkWellStatis(GSOGlobeControl ctl,GSOGeoPolygon3D polygon, MainFrm.DataGridViewDelegate InitDataGridViewX1) { InitializeComponent(); @@ -117,8 +107,9 @@ sql = "select " + getpipeLineFields.getFields(layername, globeControl1) + " from " + layer.Name; sql += " where 1>2 "; - for (int i = 0; i < fs.Length && fs[i].GetFieldDefn("编号") != null; i++) + for (int i = 0; i < fs.Length; i++) { + if (fs[i].GetFieldDefn("编号") == null) continue; sql += " or 编号 = '" + fs[i].GetValue("编号").ToString() + "'"; } diff --git a/FrmBSQDuoBianXingStatis.Designer.cs b/FrmBSQDuoBianXingStatis.Designer.cs deleted file mode 100644 index bda6842..0000000 --- a/FrmBSQDuoBianXingStatis.Designer.cs +++ /dev/null @@ -1,87 +0,0 @@ -namespace Cyberpipe -{ - partial class FrmBSQDuoBianXingStatis - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea1 = new System.Windows.Forms.DataVisualization.Charting.ChartArea(); - this.groupBox1 = new System.Windows.Forms.GroupBox(); - this.chart1 = new System.Windows.Forms.DataVisualization.Charting.Chart(); - this.groupBox1.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.chart1)).BeginInit(); - this.SuspendLayout(); - // - // groupBox1 - // - this.groupBox1.Controls.Add(this.chart1); - this.groupBox1.Dock = System.Windows.Forms.DockStyle.Fill; - this.groupBox1.Location = new System.Drawing.Point(0, 0); - this.groupBox1.Name = "groupBox1"; - this.groupBox1.Size = new System.Drawing.Size(592, 384); - this.groupBox1.TabIndex = 0; - this.groupBox1.TabStop = false; - this.groupBox1.Text = "统计结果信息"; - // - // chart1 - // - chartArea1.AxisX.MajorGrid.Enabled = false; - chartArea1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(191)))), ((int)(((byte)(219)))), ((int)(((byte)(255))))); - chartArea1.BackGradientStyle = System.Windows.Forms.DataVisualization.Charting.GradientStyle.TopBottom; - chartArea1.Name = "ChartArea1"; - this.chart1.ChartAreas.Add(chartArea1); - this.chart1.Dock = System.Windows.Forms.DockStyle.Fill; - this.chart1.Location = new System.Drawing.Point(3, 17); - this.chart1.Name = "chart1"; - this.chart1.Size = new System.Drawing.Size(586, 364); - this.chart1.TabIndex = 0; - this.chart1.Text = "chart1"; - // - // FrmBSQDuoBianXingStatis - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(592, 384); - this.Controls.Add(this.groupBox1); - this.DoubleBuffered = true; - this.Name = "FrmBSQDuoBianXingStatis"; - this.ShowIcon = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; - this.Text = "多边形区域统计"; - this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FrmBSQDuoBianXingStatis_FormClosing); - this.Load += new System.EventHandler(this.FrmBSQDuoBianXingStatis_Load); - this.groupBox1.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)(this.chart1)).EndInit(); - this.ResumeLayout(false); - - } - - #endregion - - private System.Windows.Forms.GroupBox groupBox1; - private System.Windows.Forms.DataVisualization.Charting.Chart chart1; - } -} \ No newline at end of file diff --git a/Cyberpipe.csproj b/Cyberpipe.csproj index 3a45ad8..d22f590 100644 --- a/Cyberpipe.csproj +++ b/Cyberpipe.csproj @@ -402,12 +402,6 @@ FrmBACKORACLE.cs - - Form - - - FrmBSQDuoBianXingStatis.cs - Form @@ -1271,9 +1265,6 @@ FrmBACKORACLE.cs - - FrmBSQDuoBianXingStatis.cs - FrmBSQStatis.cs diff --git a/FeatureStatisticsService.cs b/FeatureStatisticsService.cs index e833e5f..c7de210 100644 --- a/FeatureStatisticsService.cs +++ b/FeatureStatisticsService.cs @@ -273,19 +273,15 @@ /// 获取特定区域图层的管线列表,并将其总长度统计出来 /// TODOLIST:将Intersects_Pipeline在MainFrm中去除 /// - /// + /// + /// 要统计的长度 /// public static GSOFeatures getLayerPipes(GSOGeoPolygon3D polygon, GSOLayer layer, out double length) { length = 0; if (layer == null) return null; - GSOFeatureLayer flayer = layer as GSOFeatureLayer; - GSOFeatureDataset fdataset = flayer.Dataset as GSOFeatureDataset; - GSOFeatures feats = null; - - feats = polygon == null?flayer.GetAllFeatures():flayer.FindFeaturesInPolygon(polygon, false); - + GSOFeatures feats = getLayerFeatures(polygon, layer); double totallength = 0.00; for (int i = 0; i < feats.Length; i++) { @@ -301,5 +297,17 @@ return feats; } + /// + /// 获取区域图层内的feature列表,MainFrm.PolygonIntersectAnalysis和此方法重复,需要整理删除 + /// + /// + /// + /// + public static GSOFeatures getLayerFeatures(GSOGeoPolygon3D polygon, GSOLayer layer) + { + if (layer == null) return null; + GSOFeatureLayer flayer = layer as GSOFeatureLayer; + return polygon == null ? flayer.GetAllFeatures() : flayer.FindFeaturesInPolygon(polygon, false); + } } } diff --git a/FrmAllWorkWellStatis.cs b/FrmAllWorkWellStatis.cs index 7bf65dc..bd0f81b 100644 --- a/FrmAllWorkWellStatis.cs +++ b/FrmAllWorkWellStatis.cs @@ -19,17 +19,7 @@ private Dictionary map = null; private GSOGlobeControl globeControl1; private GSOGeoPolygon3D polygon; - //TODOLIST:用晓伟的代理进行操作,功能拆分细化 - //public FrmAllWorkWellStatis(GSOGeoPolygon3D polygon, DataGridView dataGridViewX11, ToolStripStatusLabel toolStripNumbers1, GSOGlobeControl ctl, PanelEx p) - //{ - // InitializeComponent(); - // panel = p; - // dataGridViewX1 = dataGridViewX11; - // toolStripNumbers = toolStripNumbers1; - // globeControl1 = ctl; - // map = getAccsMap(polygon); - //} public FrmAllWorkWellStatis(GSOGlobeControl ctl,GSOGeoPolygon3D polygon, MainFrm.DataGridViewDelegate InitDataGridViewX1) { InitializeComponent(); @@ -117,8 +107,9 @@ sql = "select " + getpipeLineFields.getFields(layername, globeControl1) + " from " + layer.Name; sql += " where 1>2 "; - for (int i = 0; i < fs.Length && fs[i].GetFieldDefn("编号") != null; i++) + for (int i = 0; i < fs.Length; i++) { + if (fs[i].GetFieldDefn("编号") == null) continue; sql += " or 编号 = '" + fs[i].GetValue("编号").ToString() + "'"; } diff --git a/FrmBSQDuoBianXingStatis.Designer.cs b/FrmBSQDuoBianXingStatis.Designer.cs deleted file mode 100644 index bda6842..0000000 --- a/FrmBSQDuoBianXingStatis.Designer.cs +++ /dev/null @@ -1,87 +0,0 @@ -namespace Cyberpipe -{ - partial class FrmBSQDuoBianXingStatis - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea1 = new System.Windows.Forms.DataVisualization.Charting.ChartArea(); - this.groupBox1 = new System.Windows.Forms.GroupBox(); - this.chart1 = new System.Windows.Forms.DataVisualization.Charting.Chart(); - this.groupBox1.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.chart1)).BeginInit(); - this.SuspendLayout(); - // - // groupBox1 - // - this.groupBox1.Controls.Add(this.chart1); - this.groupBox1.Dock = System.Windows.Forms.DockStyle.Fill; - this.groupBox1.Location = new System.Drawing.Point(0, 0); - this.groupBox1.Name = "groupBox1"; - this.groupBox1.Size = new System.Drawing.Size(592, 384); - this.groupBox1.TabIndex = 0; - this.groupBox1.TabStop = false; - this.groupBox1.Text = "统计结果信息"; - // - // chart1 - // - chartArea1.AxisX.MajorGrid.Enabled = false; - chartArea1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(191)))), ((int)(((byte)(219)))), ((int)(((byte)(255))))); - chartArea1.BackGradientStyle = System.Windows.Forms.DataVisualization.Charting.GradientStyle.TopBottom; - chartArea1.Name = "ChartArea1"; - this.chart1.ChartAreas.Add(chartArea1); - this.chart1.Dock = System.Windows.Forms.DockStyle.Fill; - this.chart1.Location = new System.Drawing.Point(3, 17); - this.chart1.Name = "chart1"; - this.chart1.Size = new System.Drawing.Size(586, 364); - this.chart1.TabIndex = 0; - this.chart1.Text = "chart1"; - // - // FrmBSQDuoBianXingStatis - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(592, 384); - this.Controls.Add(this.groupBox1); - this.DoubleBuffered = true; - this.Name = "FrmBSQDuoBianXingStatis"; - this.ShowIcon = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; - this.Text = "多边形区域统计"; - this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FrmBSQDuoBianXingStatis_FormClosing); - this.Load += new System.EventHandler(this.FrmBSQDuoBianXingStatis_Load); - this.groupBox1.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)(this.chart1)).EndInit(); - this.ResumeLayout(false); - - } - - #endregion - - private System.Windows.Forms.GroupBox groupBox1; - private System.Windows.Forms.DataVisualization.Charting.Chart chart1; - } -} \ No newline at end of file diff --git a/FrmBSQDuoBianXingStatis.cs b/FrmBSQDuoBianXingStatis.cs deleted file mode 100644 index 80b567e..0000000 --- a/FrmBSQDuoBianXingStatis.cs +++ /dev/null @@ -1,179 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Windows.Forms; -using DevComponents.DotNetBar; -using System.Data.SqlClient; -using System.Windows.Forms.DataVisualization.Charting; -using GeoScene.Data; -using GeoScene.Engine; -using GeoScene.Globe; -using System.Data.OracleClient; - -namespace Cyberpipe -{ - public partial class FrmBSQDuoBianXingStatis : Office2007Form - { - Dictionary bsq = new Dictionary(); - Dictionary bsq1 = new Dictionary(); - static FrmBSQDuoBianXingStatis frm; - GSOGlobeControl globeControl1; - List list = new List(); - public static List pipeLists = new List(); - - string[] codeStr = new string[50]; - string[] nameStr = new string[30]; - public static List typeLists; - - public FrmBSQDuoBianXingStatis(Dictionary workWellLen, GSOGlobeControl glb,List _list) - { - InitializeComponent(); - bsq = workWellLen; - globeControl1 = glb; - list = _list; - } - - private void FrmBSQDuoBianXingStatis_Load(object sender, EventArgs e) - { - FrmBSQDuoBianXingStatisFenLei(); - try - { - chart1.Series.Add("标识器"); - chart1.ChartAreas["ChartArea1"].AxisX.Title = "标识器类型"; - chart1.ChartAreas["ChartArea1"].AxisY.Title = "标识器数量"; - chart1.ChartAreas["ChartArea1"].AxisX.Interval = 1; - chart1.Series["标识器"].ChartType = SeriesChartType.Column; - chart1.Series["标识器"]["DrawingStyle"] = "Cylinder"; - - chart1.Series["标识器"].Points.DataBindXY(bsq1.Keys, bsq1.Values); - if (bsq1.Values.Count == 0) - { - MessageBox.Show("该区域没有标识器信息", "提示"); - this.Close(); - return; - } - else - { - for (int m = 0; m < bsq1.Values.Count; m++) - { - if (chart1.Series["标识器"].Points[m].YValues[0].ToString() != "0") - { - chart1.Series["标识器"].Points[m].Label = chart1.Series[0].Points[m].YValues[0].ToString(); - } - } - } - } - catch (Exception ex) - { - //ErrorLog.PublishError(ex); - } - } - - private void FrmBSQDuoBianXingStatis_FormClosing(object sender, FormClosingEventArgs e) - { - frm = null; - globeControl1.Globe.ClearAnalysis(); - globeControl1.Globe.MemoryLayer.RemoveAllFeature(); - } - - - private void FrmBSQDuoBianXingStatisFenLei() - { - try - { - bool flag2 = false; - for (int i = 0; i < Utility.listPipelineType.Count; i++) - { - - for (int j = 0; j < pipeLists.Count; j++) - { - if (pipeLists[j] == Utility.listPipelineType[i].type) - { - flag2 = true; - break; - } - } - if (!flag2 && Utility.listPipelineType[i].type != "标识器") - { - pipeLists.Add(Utility.listPipelineType[i].type); - } - flag2 = false; - } - - typeLists = new List(); - for (int num = 0; num < pipeLists.Count; num++) - { - typeList ls = new typeList(0, pipeLists[num]); - typeLists.Add(ls); - } - - GSOFeatures fs = list[0]; - string pipetype = "标识器"; - foreach (string key in bsq.Keys) - { - if (key.StartsWith(pipetype)) - { - pipetype = key; - break; - } - } - if (fs.Length > 0) - { - for (int i = 0; i < fs.Length; i++) - { - string str = fs[i].GetValue("对象名称").ToString(); - codeStr = str.Split(','); - for (int n = 0; n < codeStr.Length; n++) - { - for (int ii = 0; ii < Utility.listPipelineType.Count; ii++) - { - if (Utility.listPipelineType[ii].code == codeStr[n]) - { - for (int m = 0; m < typeLists.Count; m++) - { - if (Utility.listPipelineType[ii].type == typeLists[m].type) - { - typeLists[m].num++; - break; - } - } - break; - } - } - } - } - } - - for (int i = 0; i < typeLists.Count; i++) - { - if (typeLists[i].num > 0) - bsq1.Add(typeLists[i].type, typeLists[i].num); - } - - } - catch (Exception ex) - { - //ErrorLog.PublishError(ex); - //MessageBox.Show(ex.Message); - } - - } - public class typeList - { - public int num; - public string type; - - public typeList(int _num, string _type) - { - num = _num; - type = _type; - } - } - - - } -} diff --git a/Cyberpipe.csproj b/Cyberpipe.csproj index 3a45ad8..d22f590 100644 --- a/Cyberpipe.csproj +++ b/Cyberpipe.csproj @@ -402,12 +402,6 @@ FrmBACKORACLE.cs - - Form - - - FrmBSQDuoBianXingStatis.cs - Form @@ -1271,9 +1265,6 @@ FrmBACKORACLE.cs - - FrmBSQDuoBianXingStatis.cs - FrmBSQStatis.cs diff --git a/FeatureStatisticsService.cs b/FeatureStatisticsService.cs index e833e5f..c7de210 100644 --- a/FeatureStatisticsService.cs +++ b/FeatureStatisticsService.cs @@ -273,19 +273,15 @@ /// 获取特定区域图层的管线列表,并将其总长度统计出来 /// TODOLIST:将Intersects_Pipeline在MainFrm中去除 /// - /// + /// + /// 要统计的长度 /// public static GSOFeatures getLayerPipes(GSOGeoPolygon3D polygon, GSOLayer layer, out double length) { length = 0; if (layer == null) return null; - GSOFeatureLayer flayer = layer as GSOFeatureLayer; - GSOFeatureDataset fdataset = flayer.Dataset as GSOFeatureDataset; - GSOFeatures feats = null; - - feats = polygon == null?flayer.GetAllFeatures():flayer.FindFeaturesInPolygon(polygon, false); - + GSOFeatures feats = getLayerFeatures(polygon, layer); double totallength = 0.00; for (int i = 0; i < feats.Length; i++) { @@ -301,5 +297,17 @@ return feats; } + /// + /// 获取区域图层内的feature列表,MainFrm.PolygonIntersectAnalysis和此方法重复,需要整理删除 + /// + /// + /// + /// + public static GSOFeatures getLayerFeatures(GSOGeoPolygon3D polygon, GSOLayer layer) + { + if (layer == null) return null; + GSOFeatureLayer flayer = layer as GSOFeatureLayer; + return polygon == null ? flayer.GetAllFeatures() : flayer.FindFeaturesInPolygon(polygon, false); + } } } diff --git a/FrmAllWorkWellStatis.cs b/FrmAllWorkWellStatis.cs index 7bf65dc..bd0f81b 100644 --- a/FrmAllWorkWellStatis.cs +++ b/FrmAllWorkWellStatis.cs @@ -19,17 +19,7 @@ private Dictionary map = null; private GSOGlobeControl globeControl1; private GSOGeoPolygon3D polygon; - //TODOLIST:用晓伟的代理进行操作,功能拆分细化 - //public FrmAllWorkWellStatis(GSOGeoPolygon3D polygon, DataGridView dataGridViewX11, ToolStripStatusLabel toolStripNumbers1, GSOGlobeControl ctl, PanelEx p) - //{ - // InitializeComponent(); - // panel = p; - // dataGridViewX1 = dataGridViewX11; - // toolStripNumbers = toolStripNumbers1; - // globeControl1 = ctl; - // map = getAccsMap(polygon); - //} public FrmAllWorkWellStatis(GSOGlobeControl ctl,GSOGeoPolygon3D polygon, MainFrm.DataGridViewDelegate InitDataGridViewX1) { InitializeComponent(); @@ -117,8 +107,9 @@ sql = "select " + getpipeLineFields.getFields(layername, globeControl1) + " from " + layer.Name; sql += " where 1>2 "; - for (int i = 0; i < fs.Length && fs[i].GetFieldDefn("编号") != null; i++) + for (int i = 0; i < fs.Length; i++) { + if (fs[i].GetFieldDefn("编号") == null) continue; sql += " or 编号 = '" + fs[i].GetValue("编号").ToString() + "'"; } diff --git a/FrmBSQDuoBianXingStatis.Designer.cs b/FrmBSQDuoBianXingStatis.Designer.cs deleted file mode 100644 index bda6842..0000000 --- a/FrmBSQDuoBianXingStatis.Designer.cs +++ /dev/null @@ -1,87 +0,0 @@ -namespace Cyberpipe -{ - partial class FrmBSQDuoBianXingStatis - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea1 = new System.Windows.Forms.DataVisualization.Charting.ChartArea(); - this.groupBox1 = new System.Windows.Forms.GroupBox(); - this.chart1 = new System.Windows.Forms.DataVisualization.Charting.Chart(); - this.groupBox1.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.chart1)).BeginInit(); - this.SuspendLayout(); - // - // groupBox1 - // - this.groupBox1.Controls.Add(this.chart1); - this.groupBox1.Dock = System.Windows.Forms.DockStyle.Fill; - this.groupBox1.Location = new System.Drawing.Point(0, 0); - this.groupBox1.Name = "groupBox1"; - this.groupBox1.Size = new System.Drawing.Size(592, 384); - this.groupBox1.TabIndex = 0; - this.groupBox1.TabStop = false; - this.groupBox1.Text = "统计结果信息"; - // - // chart1 - // - chartArea1.AxisX.MajorGrid.Enabled = false; - chartArea1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(191)))), ((int)(((byte)(219)))), ((int)(((byte)(255))))); - chartArea1.BackGradientStyle = System.Windows.Forms.DataVisualization.Charting.GradientStyle.TopBottom; - chartArea1.Name = "ChartArea1"; - this.chart1.ChartAreas.Add(chartArea1); - this.chart1.Dock = System.Windows.Forms.DockStyle.Fill; - this.chart1.Location = new System.Drawing.Point(3, 17); - this.chart1.Name = "chart1"; - this.chart1.Size = new System.Drawing.Size(586, 364); - this.chart1.TabIndex = 0; - this.chart1.Text = "chart1"; - // - // FrmBSQDuoBianXingStatis - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(592, 384); - this.Controls.Add(this.groupBox1); - this.DoubleBuffered = true; - this.Name = "FrmBSQDuoBianXingStatis"; - this.ShowIcon = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; - this.Text = "多边形区域统计"; - this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FrmBSQDuoBianXingStatis_FormClosing); - this.Load += new System.EventHandler(this.FrmBSQDuoBianXingStatis_Load); - this.groupBox1.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)(this.chart1)).EndInit(); - this.ResumeLayout(false); - - } - - #endregion - - private System.Windows.Forms.GroupBox groupBox1; - private System.Windows.Forms.DataVisualization.Charting.Chart chart1; - } -} \ No newline at end of file diff --git a/FrmBSQDuoBianXingStatis.cs b/FrmBSQDuoBianXingStatis.cs deleted file mode 100644 index 80b567e..0000000 --- a/FrmBSQDuoBianXingStatis.cs +++ /dev/null @@ -1,179 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Windows.Forms; -using DevComponents.DotNetBar; -using System.Data.SqlClient; -using System.Windows.Forms.DataVisualization.Charting; -using GeoScene.Data; -using GeoScene.Engine; -using GeoScene.Globe; -using System.Data.OracleClient; - -namespace Cyberpipe -{ - public partial class FrmBSQDuoBianXingStatis : Office2007Form - { - Dictionary bsq = new Dictionary(); - Dictionary bsq1 = new Dictionary(); - static FrmBSQDuoBianXingStatis frm; - GSOGlobeControl globeControl1; - List list = new List(); - public static List pipeLists = new List(); - - string[] codeStr = new string[50]; - string[] nameStr = new string[30]; - public static List typeLists; - - public FrmBSQDuoBianXingStatis(Dictionary workWellLen, GSOGlobeControl glb,List _list) - { - InitializeComponent(); - bsq = workWellLen; - globeControl1 = glb; - list = _list; - } - - private void FrmBSQDuoBianXingStatis_Load(object sender, EventArgs e) - { - FrmBSQDuoBianXingStatisFenLei(); - try - { - chart1.Series.Add("标识器"); - chart1.ChartAreas["ChartArea1"].AxisX.Title = "标识器类型"; - chart1.ChartAreas["ChartArea1"].AxisY.Title = "标识器数量"; - chart1.ChartAreas["ChartArea1"].AxisX.Interval = 1; - chart1.Series["标识器"].ChartType = SeriesChartType.Column; - chart1.Series["标识器"]["DrawingStyle"] = "Cylinder"; - - chart1.Series["标识器"].Points.DataBindXY(bsq1.Keys, bsq1.Values); - if (bsq1.Values.Count == 0) - { - MessageBox.Show("该区域没有标识器信息", "提示"); - this.Close(); - return; - } - else - { - for (int m = 0; m < bsq1.Values.Count; m++) - { - if (chart1.Series["标识器"].Points[m].YValues[0].ToString() != "0") - { - chart1.Series["标识器"].Points[m].Label = chart1.Series[0].Points[m].YValues[0].ToString(); - } - } - } - } - catch (Exception ex) - { - //ErrorLog.PublishError(ex); - } - } - - private void FrmBSQDuoBianXingStatis_FormClosing(object sender, FormClosingEventArgs e) - { - frm = null; - globeControl1.Globe.ClearAnalysis(); - globeControl1.Globe.MemoryLayer.RemoveAllFeature(); - } - - - private void FrmBSQDuoBianXingStatisFenLei() - { - try - { - bool flag2 = false; - for (int i = 0; i < Utility.listPipelineType.Count; i++) - { - - for (int j = 0; j < pipeLists.Count; j++) - { - if (pipeLists[j] == Utility.listPipelineType[i].type) - { - flag2 = true; - break; - } - } - if (!flag2 && Utility.listPipelineType[i].type != "标识器") - { - pipeLists.Add(Utility.listPipelineType[i].type); - } - flag2 = false; - } - - typeLists = new List(); - for (int num = 0; num < pipeLists.Count; num++) - { - typeList ls = new typeList(0, pipeLists[num]); - typeLists.Add(ls); - } - - GSOFeatures fs = list[0]; - string pipetype = "标识器"; - foreach (string key in bsq.Keys) - { - if (key.StartsWith(pipetype)) - { - pipetype = key; - break; - } - } - if (fs.Length > 0) - { - for (int i = 0; i < fs.Length; i++) - { - string str = fs[i].GetValue("对象名称").ToString(); - codeStr = str.Split(','); - for (int n = 0; n < codeStr.Length; n++) - { - for (int ii = 0; ii < Utility.listPipelineType.Count; ii++) - { - if (Utility.listPipelineType[ii].code == codeStr[n]) - { - for (int m = 0; m < typeLists.Count; m++) - { - if (Utility.listPipelineType[ii].type == typeLists[m].type) - { - typeLists[m].num++; - break; - } - } - break; - } - } - } - } - } - - for (int i = 0; i < typeLists.Count; i++) - { - if (typeLists[i].num > 0) - bsq1.Add(typeLists[i].type, typeLists[i].num); - } - - } - catch (Exception ex) - { - //ErrorLog.PublishError(ex); - //MessageBox.Show(ex.Message); - } - - } - public class typeList - { - public int num; - public string type; - - public typeList(int _num, string _type) - { - num = _num; - type = _type; - } - } - - - } -} diff --git a/FrmBSQDuoBianXingStatis.resx b/FrmBSQDuoBianXingStatis.resx deleted file mode 100644 index 1af7de1..0000000 --- a/FrmBSQDuoBianXingStatis.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/Cyberpipe.csproj b/Cyberpipe.csproj index 3a45ad8..d22f590 100644 --- a/Cyberpipe.csproj +++ b/Cyberpipe.csproj @@ -402,12 +402,6 @@ FrmBACKORACLE.cs - - Form - - - FrmBSQDuoBianXingStatis.cs - Form @@ -1271,9 +1265,6 @@ FrmBACKORACLE.cs - - FrmBSQDuoBianXingStatis.cs - FrmBSQStatis.cs diff --git a/FeatureStatisticsService.cs b/FeatureStatisticsService.cs index e833e5f..c7de210 100644 --- a/FeatureStatisticsService.cs +++ b/FeatureStatisticsService.cs @@ -273,19 +273,15 @@ /// 获取特定区域图层的管线列表,并将其总长度统计出来 /// TODOLIST:将Intersects_Pipeline在MainFrm中去除 /// - /// + /// + /// 要统计的长度 /// public static GSOFeatures getLayerPipes(GSOGeoPolygon3D polygon, GSOLayer layer, out double length) { length = 0; if (layer == null) return null; - GSOFeatureLayer flayer = layer as GSOFeatureLayer; - GSOFeatureDataset fdataset = flayer.Dataset as GSOFeatureDataset; - GSOFeatures feats = null; - - feats = polygon == null?flayer.GetAllFeatures():flayer.FindFeaturesInPolygon(polygon, false); - + GSOFeatures feats = getLayerFeatures(polygon, layer); double totallength = 0.00; for (int i = 0; i < feats.Length; i++) { @@ -301,5 +297,17 @@ return feats; } + /// + /// 获取区域图层内的feature列表,MainFrm.PolygonIntersectAnalysis和此方法重复,需要整理删除 + /// + /// + /// + /// + public static GSOFeatures getLayerFeatures(GSOGeoPolygon3D polygon, GSOLayer layer) + { + if (layer == null) return null; + GSOFeatureLayer flayer = layer as GSOFeatureLayer; + return polygon == null ? flayer.GetAllFeatures() : flayer.FindFeaturesInPolygon(polygon, false); + } } } diff --git a/FrmAllWorkWellStatis.cs b/FrmAllWorkWellStatis.cs index 7bf65dc..bd0f81b 100644 --- a/FrmAllWorkWellStatis.cs +++ b/FrmAllWorkWellStatis.cs @@ -19,17 +19,7 @@ private Dictionary map = null; private GSOGlobeControl globeControl1; private GSOGeoPolygon3D polygon; - //TODOLIST:用晓伟的代理进行操作,功能拆分细化 - //public FrmAllWorkWellStatis(GSOGeoPolygon3D polygon, DataGridView dataGridViewX11, ToolStripStatusLabel toolStripNumbers1, GSOGlobeControl ctl, PanelEx p) - //{ - // InitializeComponent(); - // panel = p; - // dataGridViewX1 = dataGridViewX11; - // toolStripNumbers = toolStripNumbers1; - // globeControl1 = ctl; - // map = getAccsMap(polygon); - //} public FrmAllWorkWellStatis(GSOGlobeControl ctl,GSOGeoPolygon3D polygon, MainFrm.DataGridViewDelegate InitDataGridViewX1) { InitializeComponent(); @@ -117,8 +107,9 @@ sql = "select " + getpipeLineFields.getFields(layername, globeControl1) + " from " + layer.Name; sql += " where 1>2 "; - for (int i = 0; i < fs.Length && fs[i].GetFieldDefn("编号") != null; i++) + for (int i = 0; i < fs.Length; i++) { + if (fs[i].GetFieldDefn("编号") == null) continue; sql += " or 编号 = '" + fs[i].GetValue("编号").ToString() + "'"; } diff --git a/FrmBSQDuoBianXingStatis.Designer.cs b/FrmBSQDuoBianXingStatis.Designer.cs deleted file mode 100644 index bda6842..0000000 --- a/FrmBSQDuoBianXingStatis.Designer.cs +++ /dev/null @@ -1,87 +0,0 @@ -namespace Cyberpipe -{ - partial class FrmBSQDuoBianXingStatis - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea1 = new System.Windows.Forms.DataVisualization.Charting.ChartArea(); - this.groupBox1 = new System.Windows.Forms.GroupBox(); - this.chart1 = new System.Windows.Forms.DataVisualization.Charting.Chart(); - this.groupBox1.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.chart1)).BeginInit(); - this.SuspendLayout(); - // - // groupBox1 - // - this.groupBox1.Controls.Add(this.chart1); - this.groupBox1.Dock = System.Windows.Forms.DockStyle.Fill; - this.groupBox1.Location = new System.Drawing.Point(0, 0); - this.groupBox1.Name = "groupBox1"; - this.groupBox1.Size = new System.Drawing.Size(592, 384); - this.groupBox1.TabIndex = 0; - this.groupBox1.TabStop = false; - this.groupBox1.Text = "统计结果信息"; - // - // chart1 - // - chartArea1.AxisX.MajorGrid.Enabled = false; - chartArea1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(191)))), ((int)(((byte)(219)))), ((int)(((byte)(255))))); - chartArea1.BackGradientStyle = System.Windows.Forms.DataVisualization.Charting.GradientStyle.TopBottom; - chartArea1.Name = "ChartArea1"; - this.chart1.ChartAreas.Add(chartArea1); - this.chart1.Dock = System.Windows.Forms.DockStyle.Fill; - this.chart1.Location = new System.Drawing.Point(3, 17); - this.chart1.Name = "chart1"; - this.chart1.Size = new System.Drawing.Size(586, 364); - this.chart1.TabIndex = 0; - this.chart1.Text = "chart1"; - // - // FrmBSQDuoBianXingStatis - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(592, 384); - this.Controls.Add(this.groupBox1); - this.DoubleBuffered = true; - this.Name = "FrmBSQDuoBianXingStatis"; - this.ShowIcon = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; - this.Text = "多边形区域统计"; - this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FrmBSQDuoBianXingStatis_FormClosing); - this.Load += new System.EventHandler(this.FrmBSQDuoBianXingStatis_Load); - this.groupBox1.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)(this.chart1)).EndInit(); - this.ResumeLayout(false); - - } - - #endregion - - private System.Windows.Forms.GroupBox groupBox1; - private System.Windows.Forms.DataVisualization.Charting.Chart chart1; - } -} \ No newline at end of file diff --git a/FrmBSQDuoBianXingStatis.cs b/FrmBSQDuoBianXingStatis.cs deleted file mode 100644 index 80b567e..0000000 --- a/FrmBSQDuoBianXingStatis.cs +++ /dev/null @@ -1,179 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Windows.Forms; -using DevComponents.DotNetBar; -using System.Data.SqlClient; -using System.Windows.Forms.DataVisualization.Charting; -using GeoScene.Data; -using GeoScene.Engine; -using GeoScene.Globe; -using System.Data.OracleClient; - -namespace Cyberpipe -{ - public partial class FrmBSQDuoBianXingStatis : Office2007Form - { - Dictionary bsq = new Dictionary(); - Dictionary bsq1 = new Dictionary(); - static FrmBSQDuoBianXingStatis frm; - GSOGlobeControl globeControl1; - List list = new List(); - public static List pipeLists = new List(); - - string[] codeStr = new string[50]; - string[] nameStr = new string[30]; - public static List typeLists; - - public FrmBSQDuoBianXingStatis(Dictionary workWellLen, GSOGlobeControl glb,List _list) - { - InitializeComponent(); - bsq = workWellLen; - globeControl1 = glb; - list = _list; - } - - private void FrmBSQDuoBianXingStatis_Load(object sender, EventArgs e) - { - FrmBSQDuoBianXingStatisFenLei(); - try - { - chart1.Series.Add("标识器"); - chart1.ChartAreas["ChartArea1"].AxisX.Title = "标识器类型"; - chart1.ChartAreas["ChartArea1"].AxisY.Title = "标识器数量"; - chart1.ChartAreas["ChartArea1"].AxisX.Interval = 1; - chart1.Series["标识器"].ChartType = SeriesChartType.Column; - chart1.Series["标识器"]["DrawingStyle"] = "Cylinder"; - - chart1.Series["标识器"].Points.DataBindXY(bsq1.Keys, bsq1.Values); - if (bsq1.Values.Count == 0) - { - MessageBox.Show("该区域没有标识器信息", "提示"); - this.Close(); - return; - } - else - { - for (int m = 0; m < bsq1.Values.Count; m++) - { - if (chart1.Series["标识器"].Points[m].YValues[0].ToString() != "0") - { - chart1.Series["标识器"].Points[m].Label = chart1.Series[0].Points[m].YValues[0].ToString(); - } - } - } - } - catch (Exception ex) - { - //ErrorLog.PublishError(ex); - } - } - - private void FrmBSQDuoBianXingStatis_FormClosing(object sender, FormClosingEventArgs e) - { - frm = null; - globeControl1.Globe.ClearAnalysis(); - globeControl1.Globe.MemoryLayer.RemoveAllFeature(); - } - - - private void FrmBSQDuoBianXingStatisFenLei() - { - try - { - bool flag2 = false; - for (int i = 0; i < Utility.listPipelineType.Count; i++) - { - - for (int j = 0; j < pipeLists.Count; j++) - { - if (pipeLists[j] == Utility.listPipelineType[i].type) - { - flag2 = true; - break; - } - } - if (!flag2 && Utility.listPipelineType[i].type != "标识器") - { - pipeLists.Add(Utility.listPipelineType[i].type); - } - flag2 = false; - } - - typeLists = new List(); - for (int num = 0; num < pipeLists.Count; num++) - { - typeList ls = new typeList(0, pipeLists[num]); - typeLists.Add(ls); - } - - GSOFeatures fs = list[0]; - string pipetype = "标识器"; - foreach (string key in bsq.Keys) - { - if (key.StartsWith(pipetype)) - { - pipetype = key; - break; - } - } - if (fs.Length > 0) - { - for (int i = 0; i < fs.Length; i++) - { - string str = fs[i].GetValue("对象名称").ToString(); - codeStr = str.Split(','); - for (int n = 0; n < codeStr.Length; n++) - { - for (int ii = 0; ii < Utility.listPipelineType.Count; ii++) - { - if (Utility.listPipelineType[ii].code == codeStr[n]) - { - for (int m = 0; m < typeLists.Count; m++) - { - if (Utility.listPipelineType[ii].type == typeLists[m].type) - { - typeLists[m].num++; - break; - } - } - break; - } - } - } - } - } - - for (int i = 0; i < typeLists.Count; i++) - { - if (typeLists[i].num > 0) - bsq1.Add(typeLists[i].type, typeLists[i].num); - } - - } - catch (Exception ex) - { - //ErrorLog.PublishError(ex); - //MessageBox.Show(ex.Message); - } - - } - public class typeList - { - public int num; - public string type; - - public typeList(int _num, string _type) - { - num = _num; - type = _type; - } - } - - - } -} diff --git a/FrmBSQDuoBianXingStatis.resx b/FrmBSQDuoBianXingStatis.resx deleted file mode 100644 index 1af7de1..0000000 --- a/FrmBSQDuoBianXingStatis.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/FrmBSQStatis.Designer.cs b/FrmBSQStatis.Designer.cs index 2509c7d..ee9b1e7 100644 --- a/FrmBSQStatis.Designer.cs +++ b/FrmBSQStatis.Designer.cs @@ -57,6 +57,7 @@ this.ShowIcon = false; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "标识器全区域统计"; + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FrmBSQStatis_FormClosing); this.Load += new System.EventHandler(this.FrmBSQStatis_Load); ((System.ComponentModel.ISupportInitialize)(this.chartStatis)).EndInit(); this.ResumeLayout(false); diff --git a/Cyberpipe.csproj b/Cyberpipe.csproj index 3a45ad8..d22f590 100644 --- a/Cyberpipe.csproj +++ b/Cyberpipe.csproj @@ -402,12 +402,6 @@ FrmBACKORACLE.cs - - Form - - - FrmBSQDuoBianXingStatis.cs - Form @@ -1271,9 +1265,6 @@ FrmBACKORACLE.cs - - FrmBSQDuoBianXingStatis.cs - FrmBSQStatis.cs diff --git a/FeatureStatisticsService.cs b/FeatureStatisticsService.cs index e833e5f..c7de210 100644 --- a/FeatureStatisticsService.cs +++ b/FeatureStatisticsService.cs @@ -273,19 +273,15 @@ /// 获取特定区域图层的管线列表,并将其总长度统计出来 /// TODOLIST:将Intersects_Pipeline在MainFrm中去除 /// - /// + /// + /// 要统计的长度 /// public static GSOFeatures getLayerPipes(GSOGeoPolygon3D polygon, GSOLayer layer, out double length) { length = 0; if (layer == null) return null; - GSOFeatureLayer flayer = layer as GSOFeatureLayer; - GSOFeatureDataset fdataset = flayer.Dataset as GSOFeatureDataset; - GSOFeatures feats = null; - - feats = polygon == null?flayer.GetAllFeatures():flayer.FindFeaturesInPolygon(polygon, false); - + GSOFeatures feats = getLayerFeatures(polygon, layer); double totallength = 0.00; for (int i = 0; i < feats.Length; i++) { @@ -301,5 +297,17 @@ return feats; } + /// + /// 获取区域图层内的feature列表,MainFrm.PolygonIntersectAnalysis和此方法重复,需要整理删除 + /// + /// + /// + /// + public static GSOFeatures getLayerFeatures(GSOGeoPolygon3D polygon, GSOLayer layer) + { + if (layer == null) return null; + GSOFeatureLayer flayer = layer as GSOFeatureLayer; + return polygon == null ? flayer.GetAllFeatures() : flayer.FindFeaturesInPolygon(polygon, false); + } } } diff --git a/FrmAllWorkWellStatis.cs b/FrmAllWorkWellStatis.cs index 7bf65dc..bd0f81b 100644 --- a/FrmAllWorkWellStatis.cs +++ b/FrmAllWorkWellStatis.cs @@ -19,17 +19,7 @@ private Dictionary map = null; private GSOGlobeControl globeControl1; private GSOGeoPolygon3D polygon; - //TODOLIST:用晓伟的代理进行操作,功能拆分细化 - //public FrmAllWorkWellStatis(GSOGeoPolygon3D polygon, DataGridView dataGridViewX11, ToolStripStatusLabel toolStripNumbers1, GSOGlobeControl ctl, PanelEx p) - //{ - // InitializeComponent(); - // panel = p; - // dataGridViewX1 = dataGridViewX11; - // toolStripNumbers = toolStripNumbers1; - // globeControl1 = ctl; - // map = getAccsMap(polygon); - //} public FrmAllWorkWellStatis(GSOGlobeControl ctl,GSOGeoPolygon3D polygon, MainFrm.DataGridViewDelegate InitDataGridViewX1) { InitializeComponent(); @@ -117,8 +107,9 @@ sql = "select " + getpipeLineFields.getFields(layername, globeControl1) + " from " + layer.Name; sql += " where 1>2 "; - for (int i = 0; i < fs.Length && fs[i].GetFieldDefn("编号") != null; i++) + for (int i = 0; i < fs.Length; i++) { + if (fs[i].GetFieldDefn("编号") == null) continue; sql += " or 编号 = '" + fs[i].GetValue("编号").ToString() + "'"; } diff --git a/FrmBSQDuoBianXingStatis.Designer.cs b/FrmBSQDuoBianXingStatis.Designer.cs deleted file mode 100644 index bda6842..0000000 --- a/FrmBSQDuoBianXingStatis.Designer.cs +++ /dev/null @@ -1,87 +0,0 @@ -namespace Cyberpipe -{ - partial class FrmBSQDuoBianXingStatis - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea1 = new System.Windows.Forms.DataVisualization.Charting.ChartArea(); - this.groupBox1 = new System.Windows.Forms.GroupBox(); - this.chart1 = new System.Windows.Forms.DataVisualization.Charting.Chart(); - this.groupBox1.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.chart1)).BeginInit(); - this.SuspendLayout(); - // - // groupBox1 - // - this.groupBox1.Controls.Add(this.chart1); - this.groupBox1.Dock = System.Windows.Forms.DockStyle.Fill; - this.groupBox1.Location = new System.Drawing.Point(0, 0); - this.groupBox1.Name = "groupBox1"; - this.groupBox1.Size = new System.Drawing.Size(592, 384); - this.groupBox1.TabIndex = 0; - this.groupBox1.TabStop = false; - this.groupBox1.Text = "统计结果信息"; - // - // chart1 - // - chartArea1.AxisX.MajorGrid.Enabled = false; - chartArea1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(191)))), ((int)(((byte)(219)))), ((int)(((byte)(255))))); - chartArea1.BackGradientStyle = System.Windows.Forms.DataVisualization.Charting.GradientStyle.TopBottom; - chartArea1.Name = "ChartArea1"; - this.chart1.ChartAreas.Add(chartArea1); - this.chart1.Dock = System.Windows.Forms.DockStyle.Fill; - this.chart1.Location = new System.Drawing.Point(3, 17); - this.chart1.Name = "chart1"; - this.chart1.Size = new System.Drawing.Size(586, 364); - this.chart1.TabIndex = 0; - this.chart1.Text = "chart1"; - // - // FrmBSQDuoBianXingStatis - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(592, 384); - this.Controls.Add(this.groupBox1); - this.DoubleBuffered = true; - this.Name = "FrmBSQDuoBianXingStatis"; - this.ShowIcon = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; - this.Text = "多边形区域统计"; - this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FrmBSQDuoBianXingStatis_FormClosing); - this.Load += new System.EventHandler(this.FrmBSQDuoBianXingStatis_Load); - this.groupBox1.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)(this.chart1)).EndInit(); - this.ResumeLayout(false); - - } - - #endregion - - private System.Windows.Forms.GroupBox groupBox1; - private System.Windows.Forms.DataVisualization.Charting.Chart chart1; - } -} \ No newline at end of file diff --git a/FrmBSQDuoBianXingStatis.cs b/FrmBSQDuoBianXingStatis.cs deleted file mode 100644 index 80b567e..0000000 --- a/FrmBSQDuoBianXingStatis.cs +++ /dev/null @@ -1,179 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Windows.Forms; -using DevComponents.DotNetBar; -using System.Data.SqlClient; -using System.Windows.Forms.DataVisualization.Charting; -using GeoScene.Data; -using GeoScene.Engine; -using GeoScene.Globe; -using System.Data.OracleClient; - -namespace Cyberpipe -{ - public partial class FrmBSQDuoBianXingStatis : Office2007Form - { - Dictionary bsq = new Dictionary(); - Dictionary bsq1 = new Dictionary(); - static FrmBSQDuoBianXingStatis frm; - GSOGlobeControl globeControl1; - List list = new List(); - public static List pipeLists = new List(); - - string[] codeStr = new string[50]; - string[] nameStr = new string[30]; - public static List typeLists; - - public FrmBSQDuoBianXingStatis(Dictionary workWellLen, GSOGlobeControl glb,List _list) - { - InitializeComponent(); - bsq = workWellLen; - globeControl1 = glb; - list = _list; - } - - private void FrmBSQDuoBianXingStatis_Load(object sender, EventArgs e) - { - FrmBSQDuoBianXingStatisFenLei(); - try - { - chart1.Series.Add("标识器"); - chart1.ChartAreas["ChartArea1"].AxisX.Title = "标识器类型"; - chart1.ChartAreas["ChartArea1"].AxisY.Title = "标识器数量"; - chart1.ChartAreas["ChartArea1"].AxisX.Interval = 1; - chart1.Series["标识器"].ChartType = SeriesChartType.Column; - chart1.Series["标识器"]["DrawingStyle"] = "Cylinder"; - - chart1.Series["标识器"].Points.DataBindXY(bsq1.Keys, bsq1.Values); - if (bsq1.Values.Count == 0) - { - MessageBox.Show("该区域没有标识器信息", "提示"); - this.Close(); - return; - } - else - { - for (int m = 0; m < bsq1.Values.Count; m++) - { - if (chart1.Series["标识器"].Points[m].YValues[0].ToString() != "0") - { - chart1.Series["标识器"].Points[m].Label = chart1.Series[0].Points[m].YValues[0].ToString(); - } - } - } - } - catch (Exception ex) - { - //ErrorLog.PublishError(ex); - } - } - - private void FrmBSQDuoBianXingStatis_FormClosing(object sender, FormClosingEventArgs e) - { - frm = null; - globeControl1.Globe.ClearAnalysis(); - globeControl1.Globe.MemoryLayer.RemoveAllFeature(); - } - - - private void FrmBSQDuoBianXingStatisFenLei() - { - try - { - bool flag2 = false; - for (int i = 0; i < Utility.listPipelineType.Count; i++) - { - - for (int j = 0; j < pipeLists.Count; j++) - { - if (pipeLists[j] == Utility.listPipelineType[i].type) - { - flag2 = true; - break; - } - } - if (!flag2 && Utility.listPipelineType[i].type != "标识器") - { - pipeLists.Add(Utility.listPipelineType[i].type); - } - flag2 = false; - } - - typeLists = new List(); - for (int num = 0; num < pipeLists.Count; num++) - { - typeList ls = new typeList(0, pipeLists[num]); - typeLists.Add(ls); - } - - GSOFeatures fs = list[0]; - string pipetype = "标识器"; - foreach (string key in bsq.Keys) - { - if (key.StartsWith(pipetype)) - { - pipetype = key; - break; - } - } - if (fs.Length > 0) - { - for (int i = 0; i < fs.Length; i++) - { - string str = fs[i].GetValue("对象名称").ToString(); - codeStr = str.Split(','); - for (int n = 0; n < codeStr.Length; n++) - { - for (int ii = 0; ii < Utility.listPipelineType.Count; ii++) - { - if (Utility.listPipelineType[ii].code == codeStr[n]) - { - for (int m = 0; m < typeLists.Count; m++) - { - if (Utility.listPipelineType[ii].type == typeLists[m].type) - { - typeLists[m].num++; - break; - } - } - break; - } - } - } - } - } - - for (int i = 0; i < typeLists.Count; i++) - { - if (typeLists[i].num > 0) - bsq1.Add(typeLists[i].type, typeLists[i].num); - } - - } - catch (Exception ex) - { - //ErrorLog.PublishError(ex); - //MessageBox.Show(ex.Message); - } - - } - public class typeList - { - public int num; - public string type; - - public typeList(int _num, string _type) - { - num = _num; - type = _type; - } - } - - - } -} diff --git a/FrmBSQDuoBianXingStatis.resx b/FrmBSQDuoBianXingStatis.resx deleted file mode 100644 index 1af7de1..0000000 --- a/FrmBSQDuoBianXingStatis.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/FrmBSQStatis.Designer.cs b/FrmBSQStatis.Designer.cs index 2509c7d..ee9b1e7 100644 --- a/FrmBSQStatis.Designer.cs +++ b/FrmBSQStatis.Designer.cs @@ -57,6 +57,7 @@ this.ShowIcon = false; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "标识器全区域统计"; + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FrmBSQStatis_FormClosing); this.Load += new System.EventHandler(this.FrmBSQStatis_Load); ((System.ComponentModel.ISupportInitialize)(this.chartStatis)).EndInit(); this.ResumeLayout(false); diff --git a/FrmBSQStatis.cs b/FrmBSQStatis.cs index 4b25eda..e7c4926 100644 --- a/FrmBSQStatis.cs +++ b/FrmBSQStatis.cs @@ -18,94 +18,18 @@ { public partial class FrmBSQStatis : Office2007Form { - public Dictionary bsq = new Dictionary(); - //SqlConnection conn; - public static List typeLists; - OracleConnection conn; - string connectString; + private Dictionary bsq = new Dictionary(); + private GSOGlobeControl globeControl1; + private GSOGeoPolygon3D polygon; - public FrmBSQStatis() + public FrmBSQStatis(GSOGlobeControl globeControl1,GSOGeoPolygon3D polygon) { + this.globeControl1 = globeControl1; + this.polygon = polygon; InitializeComponent(); - BSQNumStatis(); + bsq = getBSQNameAndNumMap(polygon); } - string[] codeStr = new string[50]; - string[] nameStr = new string[30]; - public static List pipeLists = new List(); - - private void BSQNumStatis() - { - bool flag2 = false; - for (int i = 0; i < Utility.listPipelineType.Count; i++) - { - for (int j = 0; j < pipeLists.Count; j++) - { - if (pipeLists[j] == Utility.listPipelineType[i].type) - { - flag2 = true; - break; - } - } - if (!flag2 && Utility.listPipelineType[i].type != "标识器") - { - pipeLists.Add(Utility.listPipelineType[i].type); - } - flag2 = false; - } - - typeLists = new List(); - for (int num = 0; num 0) - bsq.Add(typeLists[i].type, typeLists[i].num); - } - - } - catch (Exception ex) - { - - } - } private void FrmBSQStatis_Load(object sender, EventArgs e) { @@ -136,17 +60,88 @@ } } - public class typeList + private Dictionary getBSQNameAndNumMap(GSOGeoPolygon3D polygon) { - public int num; - public string type; - public typeList(int _num, string _type) + Dictionary result = new Dictionary(); + Dictionary codeAndType = new Dictionary(); + //得到type的种类 + for (int i = 0; i < Utility.listPipelineType.Count; i++) { - num = _num; - type = _type; + if (!result.ContainsKey(Utility.listPipelineType[i].type) && Utility.listPipelineType[i].type != "标识器") + { + result.Add(Utility.listPipelineType[i].type, 0); + codeAndType.Add(Utility.listPipelineType[i].code, Utility.listPipelineType[i].type); + } + } + + return polygon == null ? getAllAreaMap(result, codeAndType) : getBSQMapByPolygon(polygon, result, codeAndType); + } + public Dictionary getAllAreaMap(Dictionary typeAndCount,Dictionary codeAndType) + { + try + { + OracleConnection conn = OledbHelper.sqlConnection(); + conn.Open(); + OracleCommand cmd; + cmd = new OracleCommand("select 对象类型 from 标识器", conn); + OracleDataReader dr = cmd.ExecuteReader(); + + while (dr.Read()) + { + string str = Convert.ToString(dr["对象类型"]); + if (str == null) continue; + foreach (string key in codeAndType.Keys) + { + if (str.Contains(key)) + { + typeAndCount[codeAndType[key]] += 1; + } + } + } + conn.Close(); + } + catch (Exception ex) + { + LogHelper.WriteLog(typeof(FrmBSQStatis),ex.Message.ToString()); + } + return typeAndCount; + } + + + public Dictionary getBSQMapByPolygon(GSOGeoPolygon3D polygon,Dictionary typeAndCount, Dictionary codeAndType) + { + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption("标识器"); + GSOFeatures bsqFs = FeatureStatisticsService.getLayerFeatures(polygon, layer); + if (bsqFs == null || bsqFs.Length <= 0) { + LogHelper.WriteLog(typeof(FrmBSQStatis),"标识器图层下的Feature为空"); + return null; + } + + for (int i = 0; i < bsqFs.Length; i++) + { + string str = bsqFs[i].GetValue("对象类型").ToString(); + + foreach (string key in codeAndType.Keys) + { + if (str.Contains(key)) + { + typeAndCount[codeAndType[key]] += 1; + } + } + } + + return typeAndCount; + } + + private void FrmBSQStatis_FormClosing(object sender, FormClosingEventArgs e) + { + globeControl1.Globe.ClearAnalysis(); + } + + } } diff --git a/Cyberpipe.csproj b/Cyberpipe.csproj index 3a45ad8..d22f590 100644 --- a/Cyberpipe.csproj +++ b/Cyberpipe.csproj @@ -402,12 +402,6 @@ FrmBACKORACLE.cs - - Form - - - FrmBSQDuoBianXingStatis.cs - Form @@ -1271,9 +1265,6 @@ FrmBACKORACLE.cs - - FrmBSQDuoBianXingStatis.cs - FrmBSQStatis.cs diff --git a/FeatureStatisticsService.cs b/FeatureStatisticsService.cs index e833e5f..c7de210 100644 --- a/FeatureStatisticsService.cs +++ b/FeatureStatisticsService.cs @@ -273,19 +273,15 @@ /// 获取特定区域图层的管线列表,并将其总长度统计出来 /// TODOLIST:将Intersects_Pipeline在MainFrm中去除 /// - /// + /// + /// 要统计的长度 /// public static GSOFeatures getLayerPipes(GSOGeoPolygon3D polygon, GSOLayer layer, out double length) { length = 0; if (layer == null) return null; - GSOFeatureLayer flayer = layer as GSOFeatureLayer; - GSOFeatureDataset fdataset = flayer.Dataset as GSOFeatureDataset; - GSOFeatures feats = null; - - feats = polygon == null?flayer.GetAllFeatures():flayer.FindFeaturesInPolygon(polygon, false); - + GSOFeatures feats = getLayerFeatures(polygon, layer); double totallength = 0.00; for (int i = 0; i < feats.Length; i++) { @@ -301,5 +297,17 @@ return feats; } + /// + /// 获取区域图层内的feature列表,MainFrm.PolygonIntersectAnalysis和此方法重复,需要整理删除 + /// + /// + /// + /// + public static GSOFeatures getLayerFeatures(GSOGeoPolygon3D polygon, GSOLayer layer) + { + if (layer == null) return null; + GSOFeatureLayer flayer = layer as GSOFeatureLayer; + return polygon == null ? flayer.GetAllFeatures() : flayer.FindFeaturesInPolygon(polygon, false); + } } } diff --git a/FrmAllWorkWellStatis.cs b/FrmAllWorkWellStatis.cs index 7bf65dc..bd0f81b 100644 --- a/FrmAllWorkWellStatis.cs +++ b/FrmAllWorkWellStatis.cs @@ -19,17 +19,7 @@ private Dictionary map = null; private GSOGlobeControl globeControl1; private GSOGeoPolygon3D polygon; - //TODOLIST:用晓伟的代理进行操作,功能拆分细化 - //public FrmAllWorkWellStatis(GSOGeoPolygon3D polygon, DataGridView dataGridViewX11, ToolStripStatusLabel toolStripNumbers1, GSOGlobeControl ctl, PanelEx p) - //{ - // InitializeComponent(); - // panel = p; - // dataGridViewX1 = dataGridViewX11; - // toolStripNumbers = toolStripNumbers1; - // globeControl1 = ctl; - // map = getAccsMap(polygon); - //} public FrmAllWorkWellStatis(GSOGlobeControl ctl,GSOGeoPolygon3D polygon, MainFrm.DataGridViewDelegate InitDataGridViewX1) { InitializeComponent(); @@ -117,8 +107,9 @@ sql = "select " + getpipeLineFields.getFields(layername, globeControl1) + " from " + layer.Name; sql += " where 1>2 "; - for (int i = 0; i < fs.Length && fs[i].GetFieldDefn("编号") != null; i++) + for (int i = 0; i < fs.Length; i++) { + if (fs[i].GetFieldDefn("编号") == null) continue; sql += " or 编号 = '" + fs[i].GetValue("编号").ToString() + "'"; } diff --git a/FrmBSQDuoBianXingStatis.Designer.cs b/FrmBSQDuoBianXingStatis.Designer.cs deleted file mode 100644 index bda6842..0000000 --- a/FrmBSQDuoBianXingStatis.Designer.cs +++ /dev/null @@ -1,87 +0,0 @@ -namespace Cyberpipe -{ - partial class FrmBSQDuoBianXingStatis - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea1 = new System.Windows.Forms.DataVisualization.Charting.ChartArea(); - this.groupBox1 = new System.Windows.Forms.GroupBox(); - this.chart1 = new System.Windows.Forms.DataVisualization.Charting.Chart(); - this.groupBox1.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.chart1)).BeginInit(); - this.SuspendLayout(); - // - // groupBox1 - // - this.groupBox1.Controls.Add(this.chart1); - this.groupBox1.Dock = System.Windows.Forms.DockStyle.Fill; - this.groupBox1.Location = new System.Drawing.Point(0, 0); - this.groupBox1.Name = "groupBox1"; - this.groupBox1.Size = new System.Drawing.Size(592, 384); - this.groupBox1.TabIndex = 0; - this.groupBox1.TabStop = false; - this.groupBox1.Text = "统计结果信息"; - // - // chart1 - // - chartArea1.AxisX.MajorGrid.Enabled = false; - chartArea1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(191)))), ((int)(((byte)(219)))), ((int)(((byte)(255))))); - chartArea1.BackGradientStyle = System.Windows.Forms.DataVisualization.Charting.GradientStyle.TopBottom; - chartArea1.Name = "ChartArea1"; - this.chart1.ChartAreas.Add(chartArea1); - this.chart1.Dock = System.Windows.Forms.DockStyle.Fill; - this.chart1.Location = new System.Drawing.Point(3, 17); - this.chart1.Name = "chart1"; - this.chart1.Size = new System.Drawing.Size(586, 364); - this.chart1.TabIndex = 0; - this.chart1.Text = "chart1"; - // - // FrmBSQDuoBianXingStatis - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(592, 384); - this.Controls.Add(this.groupBox1); - this.DoubleBuffered = true; - this.Name = "FrmBSQDuoBianXingStatis"; - this.ShowIcon = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; - this.Text = "多边形区域统计"; - this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FrmBSQDuoBianXingStatis_FormClosing); - this.Load += new System.EventHandler(this.FrmBSQDuoBianXingStatis_Load); - this.groupBox1.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)(this.chart1)).EndInit(); - this.ResumeLayout(false); - - } - - #endregion - - private System.Windows.Forms.GroupBox groupBox1; - private System.Windows.Forms.DataVisualization.Charting.Chart chart1; - } -} \ No newline at end of file diff --git a/FrmBSQDuoBianXingStatis.cs b/FrmBSQDuoBianXingStatis.cs deleted file mode 100644 index 80b567e..0000000 --- a/FrmBSQDuoBianXingStatis.cs +++ /dev/null @@ -1,179 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Windows.Forms; -using DevComponents.DotNetBar; -using System.Data.SqlClient; -using System.Windows.Forms.DataVisualization.Charting; -using GeoScene.Data; -using GeoScene.Engine; -using GeoScene.Globe; -using System.Data.OracleClient; - -namespace Cyberpipe -{ - public partial class FrmBSQDuoBianXingStatis : Office2007Form - { - Dictionary bsq = new Dictionary(); - Dictionary bsq1 = new Dictionary(); - static FrmBSQDuoBianXingStatis frm; - GSOGlobeControl globeControl1; - List list = new List(); - public static List pipeLists = new List(); - - string[] codeStr = new string[50]; - string[] nameStr = new string[30]; - public static List typeLists; - - public FrmBSQDuoBianXingStatis(Dictionary workWellLen, GSOGlobeControl glb,List _list) - { - InitializeComponent(); - bsq = workWellLen; - globeControl1 = glb; - list = _list; - } - - private void FrmBSQDuoBianXingStatis_Load(object sender, EventArgs e) - { - FrmBSQDuoBianXingStatisFenLei(); - try - { - chart1.Series.Add("标识器"); - chart1.ChartAreas["ChartArea1"].AxisX.Title = "标识器类型"; - chart1.ChartAreas["ChartArea1"].AxisY.Title = "标识器数量"; - chart1.ChartAreas["ChartArea1"].AxisX.Interval = 1; - chart1.Series["标识器"].ChartType = SeriesChartType.Column; - chart1.Series["标识器"]["DrawingStyle"] = "Cylinder"; - - chart1.Series["标识器"].Points.DataBindXY(bsq1.Keys, bsq1.Values); - if (bsq1.Values.Count == 0) - { - MessageBox.Show("该区域没有标识器信息", "提示"); - this.Close(); - return; - } - else - { - for (int m = 0; m < bsq1.Values.Count; m++) - { - if (chart1.Series["标识器"].Points[m].YValues[0].ToString() != "0") - { - chart1.Series["标识器"].Points[m].Label = chart1.Series[0].Points[m].YValues[0].ToString(); - } - } - } - } - catch (Exception ex) - { - //ErrorLog.PublishError(ex); - } - } - - private void FrmBSQDuoBianXingStatis_FormClosing(object sender, FormClosingEventArgs e) - { - frm = null; - globeControl1.Globe.ClearAnalysis(); - globeControl1.Globe.MemoryLayer.RemoveAllFeature(); - } - - - private void FrmBSQDuoBianXingStatisFenLei() - { - try - { - bool flag2 = false; - for (int i = 0; i < Utility.listPipelineType.Count; i++) - { - - for (int j = 0; j < pipeLists.Count; j++) - { - if (pipeLists[j] == Utility.listPipelineType[i].type) - { - flag2 = true; - break; - } - } - if (!flag2 && Utility.listPipelineType[i].type != "标识器") - { - pipeLists.Add(Utility.listPipelineType[i].type); - } - flag2 = false; - } - - typeLists = new List(); - for (int num = 0; num < pipeLists.Count; num++) - { - typeList ls = new typeList(0, pipeLists[num]); - typeLists.Add(ls); - } - - GSOFeatures fs = list[0]; - string pipetype = "标识器"; - foreach (string key in bsq.Keys) - { - if (key.StartsWith(pipetype)) - { - pipetype = key; - break; - } - } - if (fs.Length > 0) - { - for (int i = 0; i < fs.Length; i++) - { - string str = fs[i].GetValue("对象名称").ToString(); - codeStr = str.Split(','); - for (int n = 0; n < codeStr.Length; n++) - { - for (int ii = 0; ii < Utility.listPipelineType.Count; ii++) - { - if (Utility.listPipelineType[ii].code == codeStr[n]) - { - for (int m = 0; m < typeLists.Count; m++) - { - if (Utility.listPipelineType[ii].type == typeLists[m].type) - { - typeLists[m].num++; - break; - } - } - break; - } - } - } - } - } - - for (int i = 0; i < typeLists.Count; i++) - { - if (typeLists[i].num > 0) - bsq1.Add(typeLists[i].type, typeLists[i].num); - } - - } - catch (Exception ex) - { - //ErrorLog.PublishError(ex); - //MessageBox.Show(ex.Message); - } - - } - public class typeList - { - public int num; - public string type; - - public typeList(int _num, string _type) - { - num = _num; - type = _type; - } - } - - - } -} diff --git a/FrmBSQDuoBianXingStatis.resx b/FrmBSQDuoBianXingStatis.resx deleted file mode 100644 index 1af7de1..0000000 --- a/FrmBSQDuoBianXingStatis.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/FrmBSQStatis.Designer.cs b/FrmBSQStatis.Designer.cs index 2509c7d..ee9b1e7 100644 --- a/FrmBSQStatis.Designer.cs +++ b/FrmBSQStatis.Designer.cs @@ -57,6 +57,7 @@ this.ShowIcon = false; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "标识器全区域统计"; + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FrmBSQStatis_FormClosing); this.Load += new System.EventHandler(this.FrmBSQStatis_Load); ((System.ComponentModel.ISupportInitialize)(this.chartStatis)).EndInit(); this.ResumeLayout(false); diff --git a/FrmBSQStatis.cs b/FrmBSQStatis.cs index 4b25eda..e7c4926 100644 --- a/FrmBSQStatis.cs +++ b/FrmBSQStatis.cs @@ -18,94 +18,18 @@ { public partial class FrmBSQStatis : Office2007Form { - public Dictionary bsq = new Dictionary(); - //SqlConnection conn; - public static List typeLists; - OracleConnection conn; - string connectString; + private Dictionary bsq = new Dictionary(); + private GSOGlobeControl globeControl1; + private GSOGeoPolygon3D polygon; - public FrmBSQStatis() + public FrmBSQStatis(GSOGlobeControl globeControl1,GSOGeoPolygon3D polygon) { + this.globeControl1 = globeControl1; + this.polygon = polygon; InitializeComponent(); - BSQNumStatis(); + bsq = getBSQNameAndNumMap(polygon); } - string[] codeStr = new string[50]; - string[] nameStr = new string[30]; - public static List pipeLists = new List(); - - private void BSQNumStatis() - { - bool flag2 = false; - for (int i = 0; i < Utility.listPipelineType.Count; i++) - { - for (int j = 0; j < pipeLists.Count; j++) - { - if (pipeLists[j] == Utility.listPipelineType[i].type) - { - flag2 = true; - break; - } - } - if (!flag2 && Utility.listPipelineType[i].type != "标识器") - { - pipeLists.Add(Utility.listPipelineType[i].type); - } - flag2 = false; - } - - typeLists = new List(); - for (int num = 0; num 0) - bsq.Add(typeLists[i].type, typeLists[i].num); - } - - } - catch (Exception ex) - { - - } - } private void FrmBSQStatis_Load(object sender, EventArgs e) { @@ -136,17 +60,88 @@ } } - public class typeList + private Dictionary getBSQNameAndNumMap(GSOGeoPolygon3D polygon) { - public int num; - public string type; - public typeList(int _num, string _type) + Dictionary result = new Dictionary(); + Dictionary codeAndType = new Dictionary(); + //得到type的种类 + for (int i = 0; i < Utility.listPipelineType.Count; i++) { - num = _num; - type = _type; + if (!result.ContainsKey(Utility.listPipelineType[i].type) && Utility.listPipelineType[i].type != "标识器") + { + result.Add(Utility.listPipelineType[i].type, 0); + codeAndType.Add(Utility.listPipelineType[i].code, Utility.listPipelineType[i].type); + } + } + + return polygon == null ? getAllAreaMap(result, codeAndType) : getBSQMapByPolygon(polygon, result, codeAndType); + } + public Dictionary getAllAreaMap(Dictionary typeAndCount,Dictionary codeAndType) + { + try + { + OracleConnection conn = OledbHelper.sqlConnection(); + conn.Open(); + OracleCommand cmd; + cmd = new OracleCommand("select 对象类型 from 标识器", conn); + OracleDataReader dr = cmd.ExecuteReader(); + + while (dr.Read()) + { + string str = Convert.ToString(dr["对象类型"]); + if (str == null) continue; + foreach (string key in codeAndType.Keys) + { + if (str.Contains(key)) + { + typeAndCount[codeAndType[key]] += 1; + } + } + } + conn.Close(); + } + catch (Exception ex) + { + LogHelper.WriteLog(typeof(FrmBSQStatis),ex.Message.ToString()); + } + return typeAndCount; + } + + + public Dictionary getBSQMapByPolygon(GSOGeoPolygon3D polygon,Dictionary typeAndCount, Dictionary codeAndType) + { + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption("标识器"); + GSOFeatures bsqFs = FeatureStatisticsService.getLayerFeatures(polygon, layer); + if (bsqFs == null || bsqFs.Length <= 0) { + LogHelper.WriteLog(typeof(FrmBSQStatis),"标识器图层下的Feature为空"); + return null; + } + + for (int i = 0; i < bsqFs.Length; i++) + { + string str = bsqFs[i].GetValue("对象类型").ToString(); + + foreach (string key in codeAndType.Keys) + { + if (str.Contains(key)) + { + typeAndCount[codeAndType[key]] += 1; + } + } + } + + return typeAndCount; + } + + private void FrmBSQStatis_FormClosing(object sender, FormClosingEventArgs e) + { + globeControl1.Globe.ClearAnalysis(); + } + + } } diff --git a/FrmValveStatistics.cs b/FrmValveStatistics.cs index 672f97a..17dad6c 100644 --- a/FrmValveStatistics.cs +++ b/FrmValveStatistics.cs @@ -120,6 +120,7 @@ sql += " where 1>2 "; for (int i = 0; i < fs.Length; i++) { + if (fs[i].GetValue("编号") == null) continue; sql += " or 编号 = '" + fs[i].GetValue("编号").ToString() + "'"; } diff --git a/Cyberpipe.csproj b/Cyberpipe.csproj index 3a45ad8..d22f590 100644 --- a/Cyberpipe.csproj +++ b/Cyberpipe.csproj @@ -402,12 +402,6 @@ FrmBACKORACLE.cs - - Form - - - FrmBSQDuoBianXingStatis.cs - Form @@ -1271,9 +1265,6 @@ FrmBACKORACLE.cs - - FrmBSQDuoBianXingStatis.cs - FrmBSQStatis.cs diff --git a/FeatureStatisticsService.cs b/FeatureStatisticsService.cs index e833e5f..c7de210 100644 --- a/FeatureStatisticsService.cs +++ b/FeatureStatisticsService.cs @@ -273,19 +273,15 @@ /// 获取特定区域图层的管线列表,并将其总长度统计出来 /// TODOLIST:将Intersects_Pipeline在MainFrm中去除 /// - /// + /// + /// 要统计的长度 /// public static GSOFeatures getLayerPipes(GSOGeoPolygon3D polygon, GSOLayer layer, out double length) { length = 0; if (layer == null) return null; - GSOFeatureLayer flayer = layer as GSOFeatureLayer; - GSOFeatureDataset fdataset = flayer.Dataset as GSOFeatureDataset; - GSOFeatures feats = null; - - feats = polygon == null?flayer.GetAllFeatures():flayer.FindFeaturesInPolygon(polygon, false); - + GSOFeatures feats = getLayerFeatures(polygon, layer); double totallength = 0.00; for (int i = 0; i < feats.Length; i++) { @@ -301,5 +297,17 @@ return feats; } + /// + /// 获取区域图层内的feature列表,MainFrm.PolygonIntersectAnalysis和此方法重复,需要整理删除 + /// + /// + /// + /// + public static GSOFeatures getLayerFeatures(GSOGeoPolygon3D polygon, GSOLayer layer) + { + if (layer == null) return null; + GSOFeatureLayer flayer = layer as GSOFeatureLayer; + return polygon == null ? flayer.GetAllFeatures() : flayer.FindFeaturesInPolygon(polygon, false); + } } } diff --git a/FrmAllWorkWellStatis.cs b/FrmAllWorkWellStatis.cs index 7bf65dc..bd0f81b 100644 --- a/FrmAllWorkWellStatis.cs +++ b/FrmAllWorkWellStatis.cs @@ -19,17 +19,7 @@ private Dictionary map = null; private GSOGlobeControl globeControl1; private GSOGeoPolygon3D polygon; - //TODOLIST:用晓伟的代理进行操作,功能拆分细化 - //public FrmAllWorkWellStatis(GSOGeoPolygon3D polygon, DataGridView dataGridViewX11, ToolStripStatusLabel toolStripNumbers1, GSOGlobeControl ctl, PanelEx p) - //{ - // InitializeComponent(); - // panel = p; - // dataGridViewX1 = dataGridViewX11; - // toolStripNumbers = toolStripNumbers1; - // globeControl1 = ctl; - // map = getAccsMap(polygon); - //} public FrmAllWorkWellStatis(GSOGlobeControl ctl,GSOGeoPolygon3D polygon, MainFrm.DataGridViewDelegate InitDataGridViewX1) { InitializeComponent(); @@ -117,8 +107,9 @@ sql = "select " + getpipeLineFields.getFields(layername, globeControl1) + " from " + layer.Name; sql += " where 1>2 "; - for (int i = 0; i < fs.Length && fs[i].GetFieldDefn("编号") != null; i++) + for (int i = 0; i < fs.Length; i++) { + if (fs[i].GetFieldDefn("编号") == null) continue; sql += " or 编号 = '" + fs[i].GetValue("编号").ToString() + "'"; } diff --git a/FrmBSQDuoBianXingStatis.Designer.cs b/FrmBSQDuoBianXingStatis.Designer.cs deleted file mode 100644 index bda6842..0000000 --- a/FrmBSQDuoBianXingStatis.Designer.cs +++ /dev/null @@ -1,87 +0,0 @@ -namespace Cyberpipe -{ - partial class FrmBSQDuoBianXingStatis - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea1 = new System.Windows.Forms.DataVisualization.Charting.ChartArea(); - this.groupBox1 = new System.Windows.Forms.GroupBox(); - this.chart1 = new System.Windows.Forms.DataVisualization.Charting.Chart(); - this.groupBox1.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.chart1)).BeginInit(); - this.SuspendLayout(); - // - // groupBox1 - // - this.groupBox1.Controls.Add(this.chart1); - this.groupBox1.Dock = System.Windows.Forms.DockStyle.Fill; - this.groupBox1.Location = new System.Drawing.Point(0, 0); - this.groupBox1.Name = "groupBox1"; - this.groupBox1.Size = new System.Drawing.Size(592, 384); - this.groupBox1.TabIndex = 0; - this.groupBox1.TabStop = false; - this.groupBox1.Text = "统计结果信息"; - // - // chart1 - // - chartArea1.AxisX.MajorGrid.Enabled = false; - chartArea1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(191)))), ((int)(((byte)(219)))), ((int)(((byte)(255))))); - chartArea1.BackGradientStyle = System.Windows.Forms.DataVisualization.Charting.GradientStyle.TopBottom; - chartArea1.Name = "ChartArea1"; - this.chart1.ChartAreas.Add(chartArea1); - this.chart1.Dock = System.Windows.Forms.DockStyle.Fill; - this.chart1.Location = new System.Drawing.Point(3, 17); - this.chart1.Name = "chart1"; - this.chart1.Size = new System.Drawing.Size(586, 364); - this.chart1.TabIndex = 0; - this.chart1.Text = "chart1"; - // - // FrmBSQDuoBianXingStatis - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(592, 384); - this.Controls.Add(this.groupBox1); - this.DoubleBuffered = true; - this.Name = "FrmBSQDuoBianXingStatis"; - this.ShowIcon = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; - this.Text = "多边形区域统计"; - this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FrmBSQDuoBianXingStatis_FormClosing); - this.Load += new System.EventHandler(this.FrmBSQDuoBianXingStatis_Load); - this.groupBox1.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)(this.chart1)).EndInit(); - this.ResumeLayout(false); - - } - - #endregion - - private System.Windows.Forms.GroupBox groupBox1; - private System.Windows.Forms.DataVisualization.Charting.Chart chart1; - } -} \ No newline at end of file diff --git a/FrmBSQDuoBianXingStatis.cs b/FrmBSQDuoBianXingStatis.cs deleted file mode 100644 index 80b567e..0000000 --- a/FrmBSQDuoBianXingStatis.cs +++ /dev/null @@ -1,179 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Windows.Forms; -using DevComponents.DotNetBar; -using System.Data.SqlClient; -using System.Windows.Forms.DataVisualization.Charting; -using GeoScene.Data; -using GeoScene.Engine; -using GeoScene.Globe; -using System.Data.OracleClient; - -namespace Cyberpipe -{ - public partial class FrmBSQDuoBianXingStatis : Office2007Form - { - Dictionary bsq = new Dictionary(); - Dictionary bsq1 = new Dictionary(); - static FrmBSQDuoBianXingStatis frm; - GSOGlobeControl globeControl1; - List list = new List(); - public static List pipeLists = new List(); - - string[] codeStr = new string[50]; - string[] nameStr = new string[30]; - public static List typeLists; - - public FrmBSQDuoBianXingStatis(Dictionary workWellLen, GSOGlobeControl glb,List _list) - { - InitializeComponent(); - bsq = workWellLen; - globeControl1 = glb; - list = _list; - } - - private void FrmBSQDuoBianXingStatis_Load(object sender, EventArgs e) - { - FrmBSQDuoBianXingStatisFenLei(); - try - { - chart1.Series.Add("标识器"); - chart1.ChartAreas["ChartArea1"].AxisX.Title = "标识器类型"; - chart1.ChartAreas["ChartArea1"].AxisY.Title = "标识器数量"; - chart1.ChartAreas["ChartArea1"].AxisX.Interval = 1; - chart1.Series["标识器"].ChartType = SeriesChartType.Column; - chart1.Series["标识器"]["DrawingStyle"] = "Cylinder"; - - chart1.Series["标识器"].Points.DataBindXY(bsq1.Keys, bsq1.Values); - if (bsq1.Values.Count == 0) - { - MessageBox.Show("该区域没有标识器信息", "提示"); - this.Close(); - return; - } - else - { - for (int m = 0; m < bsq1.Values.Count; m++) - { - if (chart1.Series["标识器"].Points[m].YValues[0].ToString() != "0") - { - chart1.Series["标识器"].Points[m].Label = chart1.Series[0].Points[m].YValues[0].ToString(); - } - } - } - } - catch (Exception ex) - { - //ErrorLog.PublishError(ex); - } - } - - private void FrmBSQDuoBianXingStatis_FormClosing(object sender, FormClosingEventArgs e) - { - frm = null; - globeControl1.Globe.ClearAnalysis(); - globeControl1.Globe.MemoryLayer.RemoveAllFeature(); - } - - - private void FrmBSQDuoBianXingStatisFenLei() - { - try - { - bool flag2 = false; - for (int i = 0; i < Utility.listPipelineType.Count; i++) - { - - for (int j = 0; j < pipeLists.Count; j++) - { - if (pipeLists[j] == Utility.listPipelineType[i].type) - { - flag2 = true; - break; - } - } - if (!flag2 && Utility.listPipelineType[i].type != "标识器") - { - pipeLists.Add(Utility.listPipelineType[i].type); - } - flag2 = false; - } - - typeLists = new List(); - for (int num = 0; num < pipeLists.Count; num++) - { - typeList ls = new typeList(0, pipeLists[num]); - typeLists.Add(ls); - } - - GSOFeatures fs = list[0]; - string pipetype = "标识器"; - foreach (string key in bsq.Keys) - { - if (key.StartsWith(pipetype)) - { - pipetype = key; - break; - } - } - if (fs.Length > 0) - { - for (int i = 0; i < fs.Length; i++) - { - string str = fs[i].GetValue("对象名称").ToString(); - codeStr = str.Split(','); - for (int n = 0; n < codeStr.Length; n++) - { - for (int ii = 0; ii < Utility.listPipelineType.Count; ii++) - { - if (Utility.listPipelineType[ii].code == codeStr[n]) - { - for (int m = 0; m < typeLists.Count; m++) - { - if (Utility.listPipelineType[ii].type == typeLists[m].type) - { - typeLists[m].num++; - break; - } - } - break; - } - } - } - } - } - - for (int i = 0; i < typeLists.Count; i++) - { - if (typeLists[i].num > 0) - bsq1.Add(typeLists[i].type, typeLists[i].num); - } - - } - catch (Exception ex) - { - //ErrorLog.PublishError(ex); - //MessageBox.Show(ex.Message); - } - - } - public class typeList - { - public int num; - public string type; - - public typeList(int _num, string _type) - { - num = _num; - type = _type; - } - } - - - } -} diff --git a/FrmBSQDuoBianXingStatis.resx b/FrmBSQDuoBianXingStatis.resx deleted file mode 100644 index 1af7de1..0000000 --- a/FrmBSQDuoBianXingStatis.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/FrmBSQStatis.Designer.cs b/FrmBSQStatis.Designer.cs index 2509c7d..ee9b1e7 100644 --- a/FrmBSQStatis.Designer.cs +++ b/FrmBSQStatis.Designer.cs @@ -57,6 +57,7 @@ this.ShowIcon = false; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "标识器全区域统计"; + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FrmBSQStatis_FormClosing); this.Load += new System.EventHandler(this.FrmBSQStatis_Load); ((System.ComponentModel.ISupportInitialize)(this.chartStatis)).EndInit(); this.ResumeLayout(false); diff --git a/FrmBSQStatis.cs b/FrmBSQStatis.cs index 4b25eda..e7c4926 100644 --- a/FrmBSQStatis.cs +++ b/FrmBSQStatis.cs @@ -18,94 +18,18 @@ { public partial class FrmBSQStatis : Office2007Form { - public Dictionary bsq = new Dictionary(); - //SqlConnection conn; - public static List typeLists; - OracleConnection conn; - string connectString; + private Dictionary bsq = new Dictionary(); + private GSOGlobeControl globeControl1; + private GSOGeoPolygon3D polygon; - public FrmBSQStatis() + public FrmBSQStatis(GSOGlobeControl globeControl1,GSOGeoPolygon3D polygon) { + this.globeControl1 = globeControl1; + this.polygon = polygon; InitializeComponent(); - BSQNumStatis(); + bsq = getBSQNameAndNumMap(polygon); } - string[] codeStr = new string[50]; - string[] nameStr = new string[30]; - public static List pipeLists = new List(); - - private void BSQNumStatis() - { - bool flag2 = false; - for (int i = 0; i < Utility.listPipelineType.Count; i++) - { - for (int j = 0; j < pipeLists.Count; j++) - { - if (pipeLists[j] == Utility.listPipelineType[i].type) - { - flag2 = true; - break; - } - } - if (!flag2 && Utility.listPipelineType[i].type != "标识器") - { - pipeLists.Add(Utility.listPipelineType[i].type); - } - flag2 = false; - } - - typeLists = new List(); - for (int num = 0; num 0) - bsq.Add(typeLists[i].type, typeLists[i].num); - } - - } - catch (Exception ex) - { - - } - } private void FrmBSQStatis_Load(object sender, EventArgs e) { @@ -136,17 +60,88 @@ } } - public class typeList + private Dictionary getBSQNameAndNumMap(GSOGeoPolygon3D polygon) { - public int num; - public string type; - public typeList(int _num, string _type) + Dictionary result = new Dictionary(); + Dictionary codeAndType = new Dictionary(); + //得到type的种类 + for (int i = 0; i < Utility.listPipelineType.Count; i++) { - num = _num; - type = _type; + if (!result.ContainsKey(Utility.listPipelineType[i].type) && Utility.listPipelineType[i].type != "标识器") + { + result.Add(Utility.listPipelineType[i].type, 0); + codeAndType.Add(Utility.listPipelineType[i].code, Utility.listPipelineType[i].type); + } + } + + return polygon == null ? getAllAreaMap(result, codeAndType) : getBSQMapByPolygon(polygon, result, codeAndType); + } + public Dictionary getAllAreaMap(Dictionary typeAndCount,Dictionary codeAndType) + { + try + { + OracleConnection conn = OledbHelper.sqlConnection(); + conn.Open(); + OracleCommand cmd; + cmd = new OracleCommand("select 对象类型 from 标识器", conn); + OracleDataReader dr = cmd.ExecuteReader(); + + while (dr.Read()) + { + string str = Convert.ToString(dr["对象类型"]); + if (str == null) continue; + foreach (string key in codeAndType.Keys) + { + if (str.Contains(key)) + { + typeAndCount[codeAndType[key]] += 1; + } + } + } + conn.Close(); + } + catch (Exception ex) + { + LogHelper.WriteLog(typeof(FrmBSQStatis),ex.Message.ToString()); + } + return typeAndCount; + } + + + public Dictionary getBSQMapByPolygon(GSOGeoPolygon3D polygon,Dictionary typeAndCount, Dictionary codeAndType) + { + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption("标识器"); + GSOFeatures bsqFs = FeatureStatisticsService.getLayerFeatures(polygon, layer); + if (bsqFs == null || bsqFs.Length <= 0) { + LogHelper.WriteLog(typeof(FrmBSQStatis),"标识器图层下的Feature为空"); + return null; + } + + for (int i = 0; i < bsqFs.Length; i++) + { + string str = bsqFs[i].GetValue("对象类型").ToString(); + + foreach (string key in codeAndType.Keys) + { + if (str.Contains(key)) + { + typeAndCount[codeAndType[key]] += 1; + } + } + } + + return typeAndCount; + } + + private void FrmBSQStatis_FormClosing(object sender, FormClosingEventArgs e) + { + globeControl1.Globe.ClearAnalysis(); + } + + } } diff --git a/FrmValveStatistics.cs b/FrmValveStatistics.cs index 672f97a..17dad6c 100644 --- a/FrmValveStatistics.cs +++ b/FrmValveStatistics.cs @@ -120,6 +120,7 @@ sql += " where 1>2 "; for (int i = 0; i < fs.Length; i++) { + if (fs[i].GetValue("编号") == null) continue; sql += " or 编号 = '" + fs[i].GetValue("编号").ToString() + "'"; } diff --git a/FrmpipeDeepstatis.cs b/FrmpipeDeepstatis.cs index 879801a..c7edbc3 100644 --- a/FrmpipeDeepstatis.cs +++ b/FrmpipeDeepstatis.cs @@ -164,88 +164,6 @@ } } - //if (clbPipeLine.CheckedItems.Count > 0) - //{ - // if (dataGridViewX2.Rows.Count > 0) - // { - // for (int i = 0; i < clbPipeLine.CheckedItems.Count; i++) - // { - // GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(clbPipeLine.CheckedItems[i].ToString()); - // GSOFeatureLayer flayer = layer as GSOFeatureLayer; - // GSOFeatures feats = new GSOFeatures(); - // if (polygon == null) - // feats = flayer.GetAllFeatures(); - // else - // feats = flayer.FindFeaturesInPolygon(polygon, false); - // for (int j = 0; j < dataGridViewX2.Rows.Count; j++) - // { - // double totalLength = 0.00; - // int ncount = 0; - // for (int m = 0; m < feats.Length; m++) - // { - // GSOFeature feat = feats[m]; - // float radius = feat.GetFieldAsFloat("起始埋深"); - // bool upCompare = true; - // bool downCompare = true; - // if (dataGridViewX2.Rows[j].Cells["下限"].Value != null || dataGridViewX2.Rows[j].Cells["上限"].Value != null) - // { - // if (dataGridViewX2.Rows[j].Cells["下限"].Value != null) - // { - // if (dataGridViewX2.Rows[j].Cells["下限"].Value.ToString() != "") - // { - // if (radius >= Convert.ToDouble(dataGridViewX2.Rows[j].Cells["下限"].Value)) - // { - // downCompare = true; - // } - // else - // downCompare = false; - // } - // } - // if (dataGridViewX2.Rows[j].Cells["上限"].Value != null) - // { - // if (dataGridViewX2.Rows[j].Cells["上限"].Value.ToString() != "") - // { - // if (radius <= Convert.ToDouble(dataGridViewX2.Rows[j].Cells["上限"].Value)) - // { - // upCompare = true; - // } - // else - // upCompare = false; - // } - // } - // if (upCompare && downCompare) - // { - // GSOGeoPolyline3D line = feat.Geometry as GSOGeoPolyline3D; - // double length = line.GetSpaceLength(true, 6378137); - // totalLength += length; - // ncount += 1; - // } - // } - // } - // if (dataGridViewX2.Rows[j].Cells["下限"].Value != null || dataGridViewX2.Rows[j].Cells["上限"].Value != null) - // { - // DataGridViewRow row = new DataGridViewRow(); - // int index = dataGridViewX1.Rows.Add(row); - // row = dataGridViewX1.Rows[index]; - // row.Cells["图层名称"].Value = layer.Caption; - // row.Cells["埋深范围"].Value = dataGridViewX2.Rows[j].Cells["下限"].Value + "-" + dataGridViewX2.Rows[j].Cells["上限"].Value; - // row.Cells["条数"].Value = ncount; - // row.Cells["总长度"].Value =Math.Round(totalLength,2); - - // dic.Add(layer.Caption + "," + row.Cells["埋深范围"].Value.ToString()+","+row.Cells["总长度"].Value.ToString(), ncount); - // } - // } - // } - // } - // else - // { - // MessageBox.Show("请添加分段!"); - // } - //} - //else - //{ - // MessageBox.Show("请选择图层!"); - //} showPipeWidget(); } catch (Exception ex) diff --git a/Cyberpipe.csproj b/Cyberpipe.csproj index 3a45ad8..d22f590 100644 --- a/Cyberpipe.csproj +++ b/Cyberpipe.csproj @@ -402,12 +402,6 @@ FrmBACKORACLE.cs - - Form - - - FrmBSQDuoBianXingStatis.cs - Form @@ -1271,9 +1265,6 @@ FrmBACKORACLE.cs - - FrmBSQDuoBianXingStatis.cs - FrmBSQStatis.cs diff --git a/FeatureStatisticsService.cs b/FeatureStatisticsService.cs index e833e5f..c7de210 100644 --- a/FeatureStatisticsService.cs +++ b/FeatureStatisticsService.cs @@ -273,19 +273,15 @@ /// 获取特定区域图层的管线列表,并将其总长度统计出来 /// TODOLIST:将Intersects_Pipeline在MainFrm中去除 /// - /// + /// + /// 要统计的长度 /// public static GSOFeatures getLayerPipes(GSOGeoPolygon3D polygon, GSOLayer layer, out double length) { length = 0; if (layer == null) return null; - GSOFeatureLayer flayer = layer as GSOFeatureLayer; - GSOFeatureDataset fdataset = flayer.Dataset as GSOFeatureDataset; - GSOFeatures feats = null; - - feats = polygon == null?flayer.GetAllFeatures():flayer.FindFeaturesInPolygon(polygon, false); - + GSOFeatures feats = getLayerFeatures(polygon, layer); double totallength = 0.00; for (int i = 0; i < feats.Length; i++) { @@ -301,5 +297,17 @@ return feats; } + /// + /// 获取区域图层内的feature列表,MainFrm.PolygonIntersectAnalysis和此方法重复,需要整理删除 + /// + /// + /// + /// + public static GSOFeatures getLayerFeatures(GSOGeoPolygon3D polygon, GSOLayer layer) + { + if (layer == null) return null; + GSOFeatureLayer flayer = layer as GSOFeatureLayer; + return polygon == null ? flayer.GetAllFeatures() : flayer.FindFeaturesInPolygon(polygon, false); + } } } diff --git a/FrmAllWorkWellStatis.cs b/FrmAllWorkWellStatis.cs index 7bf65dc..bd0f81b 100644 --- a/FrmAllWorkWellStatis.cs +++ b/FrmAllWorkWellStatis.cs @@ -19,17 +19,7 @@ private Dictionary map = null; private GSOGlobeControl globeControl1; private GSOGeoPolygon3D polygon; - //TODOLIST:用晓伟的代理进行操作,功能拆分细化 - //public FrmAllWorkWellStatis(GSOGeoPolygon3D polygon, DataGridView dataGridViewX11, ToolStripStatusLabel toolStripNumbers1, GSOGlobeControl ctl, PanelEx p) - //{ - // InitializeComponent(); - // panel = p; - // dataGridViewX1 = dataGridViewX11; - // toolStripNumbers = toolStripNumbers1; - // globeControl1 = ctl; - // map = getAccsMap(polygon); - //} public FrmAllWorkWellStatis(GSOGlobeControl ctl,GSOGeoPolygon3D polygon, MainFrm.DataGridViewDelegate InitDataGridViewX1) { InitializeComponent(); @@ -117,8 +107,9 @@ sql = "select " + getpipeLineFields.getFields(layername, globeControl1) + " from " + layer.Name; sql += " where 1>2 "; - for (int i = 0; i < fs.Length && fs[i].GetFieldDefn("编号") != null; i++) + for (int i = 0; i < fs.Length; i++) { + if (fs[i].GetFieldDefn("编号") == null) continue; sql += " or 编号 = '" + fs[i].GetValue("编号").ToString() + "'"; } diff --git a/FrmBSQDuoBianXingStatis.Designer.cs b/FrmBSQDuoBianXingStatis.Designer.cs deleted file mode 100644 index bda6842..0000000 --- a/FrmBSQDuoBianXingStatis.Designer.cs +++ /dev/null @@ -1,87 +0,0 @@ -namespace Cyberpipe -{ - partial class FrmBSQDuoBianXingStatis - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea1 = new System.Windows.Forms.DataVisualization.Charting.ChartArea(); - this.groupBox1 = new System.Windows.Forms.GroupBox(); - this.chart1 = new System.Windows.Forms.DataVisualization.Charting.Chart(); - this.groupBox1.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.chart1)).BeginInit(); - this.SuspendLayout(); - // - // groupBox1 - // - this.groupBox1.Controls.Add(this.chart1); - this.groupBox1.Dock = System.Windows.Forms.DockStyle.Fill; - this.groupBox1.Location = new System.Drawing.Point(0, 0); - this.groupBox1.Name = "groupBox1"; - this.groupBox1.Size = new System.Drawing.Size(592, 384); - this.groupBox1.TabIndex = 0; - this.groupBox1.TabStop = false; - this.groupBox1.Text = "统计结果信息"; - // - // chart1 - // - chartArea1.AxisX.MajorGrid.Enabled = false; - chartArea1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(191)))), ((int)(((byte)(219)))), ((int)(((byte)(255))))); - chartArea1.BackGradientStyle = System.Windows.Forms.DataVisualization.Charting.GradientStyle.TopBottom; - chartArea1.Name = "ChartArea1"; - this.chart1.ChartAreas.Add(chartArea1); - this.chart1.Dock = System.Windows.Forms.DockStyle.Fill; - this.chart1.Location = new System.Drawing.Point(3, 17); - this.chart1.Name = "chart1"; - this.chart1.Size = new System.Drawing.Size(586, 364); - this.chart1.TabIndex = 0; - this.chart1.Text = "chart1"; - // - // FrmBSQDuoBianXingStatis - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(592, 384); - this.Controls.Add(this.groupBox1); - this.DoubleBuffered = true; - this.Name = "FrmBSQDuoBianXingStatis"; - this.ShowIcon = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; - this.Text = "多边形区域统计"; - this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FrmBSQDuoBianXingStatis_FormClosing); - this.Load += new System.EventHandler(this.FrmBSQDuoBianXingStatis_Load); - this.groupBox1.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)(this.chart1)).EndInit(); - this.ResumeLayout(false); - - } - - #endregion - - private System.Windows.Forms.GroupBox groupBox1; - private System.Windows.Forms.DataVisualization.Charting.Chart chart1; - } -} \ No newline at end of file diff --git a/FrmBSQDuoBianXingStatis.cs b/FrmBSQDuoBianXingStatis.cs deleted file mode 100644 index 80b567e..0000000 --- a/FrmBSQDuoBianXingStatis.cs +++ /dev/null @@ -1,179 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Windows.Forms; -using DevComponents.DotNetBar; -using System.Data.SqlClient; -using System.Windows.Forms.DataVisualization.Charting; -using GeoScene.Data; -using GeoScene.Engine; -using GeoScene.Globe; -using System.Data.OracleClient; - -namespace Cyberpipe -{ - public partial class FrmBSQDuoBianXingStatis : Office2007Form - { - Dictionary bsq = new Dictionary(); - Dictionary bsq1 = new Dictionary(); - static FrmBSQDuoBianXingStatis frm; - GSOGlobeControl globeControl1; - List list = new List(); - public static List pipeLists = new List(); - - string[] codeStr = new string[50]; - string[] nameStr = new string[30]; - public static List typeLists; - - public FrmBSQDuoBianXingStatis(Dictionary workWellLen, GSOGlobeControl glb,List _list) - { - InitializeComponent(); - bsq = workWellLen; - globeControl1 = glb; - list = _list; - } - - private void FrmBSQDuoBianXingStatis_Load(object sender, EventArgs e) - { - FrmBSQDuoBianXingStatisFenLei(); - try - { - chart1.Series.Add("标识器"); - chart1.ChartAreas["ChartArea1"].AxisX.Title = "标识器类型"; - chart1.ChartAreas["ChartArea1"].AxisY.Title = "标识器数量"; - chart1.ChartAreas["ChartArea1"].AxisX.Interval = 1; - chart1.Series["标识器"].ChartType = SeriesChartType.Column; - chart1.Series["标识器"]["DrawingStyle"] = "Cylinder"; - - chart1.Series["标识器"].Points.DataBindXY(bsq1.Keys, bsq1.Values); - if (bsq1.Values.Count == 0) - { - MessageBox.Show("该区域没有标识器信息", "提示"); - this.Close(); - return; - } - else - { - for (int m = 0; m < bsq1.Values.Count; m++) - { - if (chart1.Series["标识器"].Points[m].YValues[0].ToString() != "0") - { - chart1.Series["标识器"].Points[m].Label = chart1.Series[0].Points[m].YValues[0].ToString(); - } - } - } - } - catch (Exception ex) - { - //ErrorLog.PublishError(ex); - } - } - - private void FrmBSQDuoBianXingStatis_FormClosing(object sender, FormClosingEventArgs e) - { - frm = null; - globeControl1.Globe.ClearAnalysis(); - globeControl1.Globe.MemoryLayer.RemoveAllFeature(); - } - - - private void FrmBSQDuoBianXingStatisFenLei() - { - try - { - bool flag2 = false; - for (int i = 0; i < Utility.listPipelineType.Count; i++) - { - - for (int j = 0; j < pipeLists.Count; j++) - { - if (pipeLists[j] == Utility.listPipelineType[i].type) - { - flag2 = true; - break; - } - } - if (!flag2 && Utility.listPipelineType[i].type != "标识器") - { - pipeLists.Add(Utility.listPipelineType[i].type); - } - flag2 = false; - } - - typeLists = new List(); - for (int num = 0; num < pipeLists.Count; num++) - { - typeList ls = new typeList(0, pipeLists[num]); - typeLists.Add(ls); - } - - GSOFeatures fs = list[0]; - string pipetype = "标识器"; - foreach (string key in bsq.Keys) - { - if (key.StartsWith(pipetype)) - { - pipetype = key; - break; - } - } - if (fs.Length > 0) - { - for (int i = 0; i < fs.Length; i++) - { - string str = fs[i].GetValue("对象名称").ToString(); - codeStr = str.Split(','); - for (int n = 0; n < codeStr.Length; n++) - { - for (int ii = 0; ii < Utility.listPipelineType.Count; ii++) - { - if (Utility.listPipelineType[ii].code == codeStr[n]) - { - for (int m = 0; m < typeLists.Count; m++) - { - if (Utility.listPipelineType[ii].type == typeLists[m].type) - { - typeLists[m].num++; - break; - } - } - break; - } - } - } - } - } - - for (int i = 0; i < typeLists.Count; i++) - { - if (typeLists[i].num > 0) - bsq1.Add(typeLists[i].type, typeLists[i].num); - } - - } - catch (Exception ex) - { - //ErrorLog.PublishError(ex); - //MessageBox.Show(ex.Message); - } - - } - public class typeList - { - public int num; - public string type; - - public typeList(int _num, string _type) - { - num = _num; - type = _type; - } - } - - - } -} diff --git a/FrmBSQDuoBianXingStatis.resx b/FrmBSQDuoBianXingStatis.resx deleted file mode 100644 index 1af7de1..0000000 --- a/FrmBSQDuoBianXingStatis.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/FrmBSQStatis.Designer.cs b/FrmBSQStatis.Designer.cs index 2509c7d..ee9b1e7 100644 --- a/FrmBSQStatis.Designer.cs +++ b/FrmBSQStatis.Designer.cs @@ -57,6 +57,7 @@ this.ShowIcon = false; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "标识器全区域统计"; + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FrmBSQStatis_FormClosing); this.Load += new System.EventHandler(this.FrmBSQStatis_Load); ((System.ComponentModel.ISupportInitialize)(this.chartStatis)).EndInit(); this.ResumeLayout(false); diff --git a/FrmBSQStatis.cs b/FrmBSQStatis.cs index 4b25eda..e7c4926 100644 --- a/FrmBSQStatis.cs +++ b/FrmBSQStatis.cs @@ -18,94 +18,18 @@ { public partial class FrmBSQStatis : Office2007Form { - public Dictionary bsq = new Dictionary(); - //SqlConnection conn; - public static List typeLists; - OracleConnection conn; - string connectString; + private Dictionary bsq = new Dictionary(); + private GSOGlobeControl globeControl1; + private GSOGeoPolygon3D polygon; - public FrmBSQStatis() + public FrmBSQStatis(GSOGlobeControl globeControl1,GSOGeoPolygon3D polygon) { + this.globeControl1 = globeControl1; + this.polygon = polygon; InitializeComponent(); - BSQNumStatis(); + bsq = getBSQNameAndNumMap(polygon); } - string[] codeStr = new string[50]; - string[] nameStr = new string[30]; - public static List pipeLists = new List(); - - private void BSQNumStatis() - { - bool flag2 = false; - for (int i = 0; i < Utility.listPipelineType.Count; i++) - { - for (int j = 0; j < pipeLists.Count; j++) - { - if (pipeLists[j] == Utility.listPipelineType[i].type) - { - flag2 = true; - break; - } - } - if (!flag2 && Utility.listPipelineType[i].type != "标识器") - { - pipeLists.Add(Utility.listPipelineType[i].type); - } - flag2 = false; - } - - typeLists = new List(); - for (int num = 0; num 0) - bsq.Add(typeLists[i].type, typeLists[i].num); - } - - } - catch (Exception ex) - { - - } - } private void FrmBSQStatis_Load(object sender, EventArgs e) { @@ -136,17 +60,88 @@ } } - public class typeList + private Dictionary getBSQNameAndNumMap(GSOGeoPolygon3D polygon) { - public int num; - public string type; - public typeList(int _num, string _type) + Dictionary result = new Dictionary(); + Dictionary codeAndType = new Dictionary(); + //得到type的种类 + for (int i = 0; i < Utility.listPipelineType.Count; i++) { - num = _num; - type = _type; + if (!result.ContainsKey(Utility.listPipelineType[i].type) && Utility.listPipelineType[i].type != "标识器") + { + result.Add(Utility.listPipelineType[i].type, 0); + codeAndType.Add(Utility.listPipelineType[i].code, Utility.listPipelineType[i].type); + } + } + + return polygon == null ? getAllAreaMap(result, codeAndType) : getBSQMapByPolygon(polygon, result, codeAndType); + } + public Dictionary getAllAreaMap(Dictionary typeAndCount,Dictionary codeAndType) + { + try + { + OracleConnection conn = OledbHelper.sqlConnection(); + conn.Open(); + OracleCommand cmd; + cmd = new OracleCommand("select 对象类型 from 标识器", conn); + OracleDataReader dr = cmd.ExecuteReader(); + + while (dr.Read()) + { + string str = Convert.ToString(dr["对象类型"]); + if (str == null) continue; + foreach (string key in codeAndType.Keys) + { + if (str.Contains(key)) + { + typeAndCount[codeAndType[key]] += 1; + } + } + } + conn.Close(); + } + catch (Exception ex) + { + LogHelper.WriteLog(typeof(FrmBSQStatis),ex.Message.ToString()); + } + return typeAndCount; + } + + + public Dictionary getBSQMapByPolygon(GSOGeoPolygon3D polygon,Dictionary typeAndCount, Dictionary codeAndType) + { + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption("标识器"); + GSOFeatures bsqFs = FeatureStatisticsService.getLayerFeatures(polygon, layer); + if (bsqFs == null || bsqFs.Length <= 0) { + LogHelper.WriteLog(typeof(FrmBSQStatis),"标识器图层下的Feature为空"); + return null; + } + + for (int i = 0; i < bsqFs.Length; i++) + { + string str = bsqFs[i].GetValue("对象类型").ToString(); + + foreach (string key in codeAndType.Keys) + { + if (str.Contains(key)) + { + typeAndCount[codeAndType[key]] += 1; + } + } + } + + return typeAndCount; + } + + private void FrmBSQStatis_FormClosing(object sender, FormClosingEventArgs e) + { + globeControl1.Globe.ClearAnalysis(); + } + + } } diff --git a/FrmValveStatistics.cs b/FrmValveStatistics.cs index 672f97a..17dad6c 100644 --- a/FrmValveStatistics.cs +++ b/FrmValveStatistics.cs @@ -120,6 +120,7 @@ sql += " where 1>2 "; for (int i = 0; i < fs.Length; i++) { + if (fs[i].GetValue("编号") == null) continue; sql += " or 编号 = '" + fs[i].GetValue("编号").ToString() + "'"; } diff --git a/FrmpipeDeepstatis.cs b/FrmpipeDeepstatis.cs index 879801a..c7edbc3 100644 --- a/FrmpipeDeepstatis.cs +++ b/FrmpipeDeepstatis.cs @@ -164,88 +164,6 @@ } } - //if (clbPipeLine.CheckedItems.Count > 0) - //{ - // if (dataGridViewX2.Rows.Count > 0) - // { - // for (int i = 0; i < clbPipeLine.CheckedItems.Count; i++) - // { - // GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(clbPipeLine.CheckedItems[i].ToString()); - // GSOFeatureLayer flayer = layer as GSOFeatureLayer; - // GSOFeatures feats = new GSOFeatures(); - // if (polygon == null) - // feats = flayer.GetAllFeatures(); - // else - // feats = flayer.FindFeaturesInPolygon(polygon, false); - // for (int j = 0; j < dataGridViewX2.Rows.Count; j++) - // { - // double totalLength = 0.00; - // int ncount = 0; - // for (int m = 0; m < feats.Length; m++) - // { - // GSOFeature feat = feats[m]; - // float radius = feat.GetFieldAsFloat("起始埋深"); - // bool upCompare = true; - // bool downCompare = true; - // if (dataGridViewX2.Rows[j].Cells["下限"].Value != null || dataGridViewX2.Rows[j].Cells["上限"].Value != null) - // { - // if (dataGridViewX2.Rows[j].Cells["下限"].Value != null) - // { - // if (dataGridViewX2.Rows[j].Cells["下限"].Value.ToString() != "") - // { - // if (radius >= Convert.ToDouble(dataGridViewX2.Rows[j].Cells["下限"].Value)) - // { - // downCompare = true; - // } - // else - // downCompare = false; - // } - // } - // if (dataGridViewX2.Rows[j].Cells["上限"].Value != null) - // { - // if (dataGridViewX2.Rows[j].Cells["上限"].Value.ToString() != "") - // { - // if (radius <= Convert.ToDouble(dataGridViewX2.Rows[j].Cells["上限"].Value)) - // { - // upCompare = true; - // } - // else - // upCompare = false; - // } - // } - // if (upCompare && downCompare) - // { - // GSOGeoPolyline3D line = feat.Geometry as GSOGeoPolyline3D; - // double length = line.GetSpaceLength(true, 6378137); - // totalLength += length; - // ncount += 1; - // } - // } - // } - // if (dataGridViewX2.Rows[j].Cells["下限"].Value != null || dataGridViewX2.Rows[j].Cells["上限"].Value != null) - // { - // DataGridViewRow row = new DataGridViewRow(); - // int index = dataGridViewX1.Rows.Add(row); - // row = dataGridViewX1.Rows[index]; - // row.Cells["图层名称"].Value = layer.Caption; - // row.Cells["埋深范围"].Value = dataGridViewX2.Rows[j].Cells["下限"].Value + "-" + dataGridViewX2.Rows[j].Cells["上限"].Value; - // row.Cells["条数"].Value = ncount; - // row.Cells["总长度"].Value =Math.Round(totalLength,2); - - // dic.Add(layer.Caption + "," + row.Cells["埋深范围"].Value.ToString()+","+row.Cells["总长度"].Value.ToString(), ncount); - // } - // } - // } - // } - // else - // { - // MessageBox.Show("请添加分段!"); - // } - //} - //else - //{ - // MessageBox.Show("请选择图层!"); - //} showPipeWidget(); } catch (Exception ex) diff --git a/FrmpipeMaterialGather.cs b/FrmpipeMaterialGather.cs index b7ab1d2..3e9f45d 100644 --- a/FrmpipeMaterialGather.cs +++ b/FrmpipeMaterialGather.cs @@ -180,79 +180,6 @@ } - //if (clbPipeLine.CheckedItems.Count > 0) - //{ - // for (int i = 0; i < clbPipeLine.CheckedItems.Count; i++) - // { - // GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(clbPipeLine.CheckedItems[i].ToString()); - // GSOFeatureLayer flayer = layer as GSOFeatureLayer; - // GSOFeatures feats = new GSOFeatures(); - // if (polygon == null) - // feats = flayer.GetAllFeatures(); - // else - // feats = flayer.FindFeaturesInPolygon(polygon, false); - // List lstDiameter = new List(); - - // for (int j = 0; j < clbmaterials.CheckedItems.Count; j++) - // { - // if (!lstDiameter.Contains(clbmaterials.CheckedItems[j].ToString())) - // { - // lstDiameter.Add(clbmaterials.CheckedItems[j].ToString()); - // } - // } - // //lstDiameter.Sort(); - // if (lstDiameter.Count > 0) - // { - // for (int m = 0; m < lstDiameter.Count; m++) - // { - // double totalLength = 0.00; - // int ncount = 0; - // for (int j = 0; j < feats.Length; j++) - // { - // if (lstDiameter[m] != "无") - // { - // if (feats[j].GetFieldAsString("材质") == lstDiameter[m]) - // { - // GSOGeoPolyline3D line = feats[j].Geometry as GSOGeoPolyline3D; - // if (line != null) - // { - // double length = line.GetSpaceLength(true, 6378137); - // totalLength += length; - // ncount += 1; - // } - // } - // } - // else - // { - // if (feats[j].GetFieldAsString("材质") == "") - // { - // GSOGeoPolyline3D line = feats[j].Geometry as GSOGeoPolyline3D; - // if (line != null) - // { - // double length = line.GetSpaceLength(true, 6378137); - // totalLength += length; - // ncount += 1; - // } - // } - // } - // } - // DataGridViewRow row = new DataGridViewRow(); - // int index = dataGridViewX1.Rows.Add(row); - // row = dataGridViewX1.Rows[index]; - // row.Cells["图层名称"].Value = layer.Caption; - // row.Cells["材质"].Value = lstDiameter[m]; - // row.Cells["条数"].Value = ncount; - // row.Cells["总长度"].Value = Math.Round(totalLength); - - // dic.Add(layer.Caption + "," + row.Cells["材质"].Value.ToString(), ncount); - // } - // } - // } - //} - //else - //{ - // MessageBox.Show("请选择图层!"); - //} showPipeWidget(); } catch (Exception ex) diff --git a/Cyberpipe.csproj b/Cyberpipe.csproj index 3a45ad8..d22f590 100644 --- a/Cyberpipe.csproj +++ b/Cyberpipe.csproj @@ -402,12 +402,6 @@ FrmBACKORACLE.cs - - Form - - - FrmBSQDuoBianXingStatis.cs - Form @@ -1271,9 +1265,6 @@ FrmBACKORACLE.cs - - FrmBSQDuoBianXingStatis.cs - FrmBSQStatis.cs diff --git a/FeatureStatisticsService.cs b/FeatureStatisticsService.cs index e833e5f..c7de210 100644 --- a/FeatureStatisticsService.cs +++ b/FeatureStatisticsService.cs @@ -273,19 +273,15 @@ /// 获取特定区域图层的管线列表,并将其总长度统计出来 /// TODOLIST:将Intersects_Pipeline在MainFrm中去除 /// - /// + /// + /// 要统计的长度 /// public static GSOFeatures getLayerPipes(GSOGeoPolygon3D polygon, GSOLayer layer, out double length) { length = 0; if (layer == null) return null; - GSOFeatureLayer flayer = layer as GSOFeatureLayer; - GSOFeatureDataset fdataset = flayer.Dataset as GSOFeatureDataset; - GSOFeatures feats = null; - - feats = polygon == null?flayer.GetAllFeatures():flayer.FindFeaturesInPolygon(polygon, false); - + GSOFeatures feats = getLayerFeatures(polygon, layer); double totallength = 0.00; for (int i = 0; i < feats.Length; i++) { @@ -301,5 +297,17 @@ return feats; } + /// + /// 获取区域图层内的feature列表,MainFrm.PolygonIntersectAnalysis和此方法重复,需要整理删除 + /// + /// + /// + /// + public static GSOFeatures getLayerFeatures(GSOGeoPolygon3D polygon, GSOLayer layer) + { + if (layer == null) return null; + GSOFeatureLayer flayer = layer as GSOFeatureLayer; + return polygon == null ? flayer.GetAllFeatures() : flayer.FindFeaturesInPolygon(polygon, false); + } } } diff --git a/FrmAllWorkWellStatis.cs b/FrmAllWorkWellStatis.cs index 7bf65dc..bd0f81b 100644 --- a/FrmAllWorkWellStatis.cs +++ b/FrmAllWorkWellStatis.cs @@ -19,17 +19,7 @@ private Dictionary map = null; private GSOGlobeControl globeControl1; private GSOGeoPolygon3D polygon; - //TODOLIST:用晓伟的代理进行操作,功能拆分细化 - //public FrmAllWorkWellStatis(GSOGeoPolygon3D polygon, DataGridView dataGridViewX11, ToolStripStatusLabel toolStripNumbers1, GSOGlobeControl ctl, PanelEx p) - //{ - // InitializeComponent(); - // panel = p; - // dataGridViewX1 = dataGridViewX11; - // toolStripNumbers = toolStripNumbers1; - // globeControl1 = ctl; - // map = getAccsMap(polygon); - //} public FrmAllWorkWellStatis(GSOGlobeControl ctl,GSOGeoPolygon3D polygon, MainFrm.DataGridViewDelegate InitDataGridViewX1) { InitializeComponent(); @@ -117,8 +107,9 @@ sql = "select " + getpipeLineFields.getFields(layername, globeControl1) + " from " + layer.Name; sql += " where 1>2 "; - for (int i = 0; i < fs.Length && fs[i].GetFieldDefn("编号") != null; i++) + for (int i = 0; i < fs.Length; i++) { + if (fs[i].GetFieldDefn("编号") == null) continue; sql += " or 编号 = '" + fs[i].GetValue("编号").ToString() + "'"; } diff --git a/FrmBSQDuoBianXingStatis.Designer.cs b/FrmBSQDuoBianXingStatis.Designer.cs deleted file mode 100644 index bda6842..0000000 --- a/FrmBSQDuoBianXingStatis.Designer.cs +++ /dev/null @@ -1,87 +0,0 @@ -namespace Cyberpipe -{ - partial class FrmBSQDuoBianXingStatis - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea1 = new System.Windows.Forms.DataVisualization.Charting.ChartArea(); - this.groupBox1 = new System.Windows.Forms.GroupBox(); - this.chart1 = new System.Windows.Forms.DataVisualization.Charting.Chart(); - this.groupBox1.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.chart1)).BeginInit(); - this.SuspendLayout(); - // - // groupBox1 - // - this.groupBox1.Controls.Add(this.chart1); - this.groupBox1.Dock = System.Windows.Forms.DockStyle.Fill; - this.groupBox1.Location = new System.Drawing.Point(0, 0); - this.groupBox1.Name = "groupBox1"; - this.groupBox1.Size = new System.Drawing.Size(592, 384); - this.groupBox1.TabIndex = 0; - this.groupBox1.TabStop = false; - this.groupBox1.Text = "统计结果信息"; - // - // chart1 - // - chartArea1.AxisX.MajorGrid.Enabled = false; - chartArea1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(191)))), ((int)(((byte)(219)))), ((int)(((byte)(255))))); - chartArea1.BackGradientStyle = System.Windows.Forms.DataVisualization.Charting.GradientStyle.TopBottom; - chartArea1.Name = "ChartArea1"; - this.chart1.ChartAreas.Add(chartArea1); - this.chart1.Dock = System.Windows.Forms.DockStyle.Fill; - this.chart1.Location = new System.Drawing.Point(3, 17); - this.chart1.Name = "chart1"; - this.chart1.Size = new System.Drawing.Size(586, 364); - this.chart1.TabIndex = 0; - this.chart1.Text = "chart1"; - // - // FrmBSQDuoBianXingStatis - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(592, 384); - this.Controls.Add(this.groupBox1); - this.DoubleBuffered = true; - this.Name = "FrmBSQDuoBianXingStatis"; - this.ShowIcon = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; - this.Text = "多边形区域统计"; - this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FrmBSQDuoBianXingStatis_FormClosing); - this.Load += new System.EventHandler(this.FrmBSQDuoBianXingStatis_Load); - this.groupBox1.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)(this.chart1)).EndInit(); - this.ResumeLayout(false); - - } - - #endregion - - private System.Windows.Forms.GroupBox groupBox1; - private System.Windows.Forms.DataVisualization.Charting.Chart chart1; - } -} \ No newline at end of file diff --git a/FrmBSQDuoBianXingStatis.cs b/FrmBSQDuoBianXingStatis.cs deleted file mode 100644 index 80b567e..0000000 --- a/FrmBSQDuoBianXingStatis.cs +++ /dev/null @@ -1,179 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Windows.Forms; -using DevComponents.DotNetBar; -using System.Data.SqlClient; -using System.Windows.Forms.DataVisualization.Charting; -using GeoScene.Data; -using GeoScene.Engine; -using GeoScene.Globe; -using System.Data.OracleClient; - -namespace Cyberpipe -{ - public partial class FrmBSQDuoBianXingStatis : Office2007Form - { - Dictionary bsq = new Dictionary(); - Dictionary bsq1 = new Dictionary(); - static FrmBSQDuoBianXingStatis frm; - GSOGlobeControl globeControl1; - List list = new List(); - public static List pipeLists = new List(); - - string[] codeStr = new string[50]; - string[] nameStr = new string[30]; - public static List typeLists; - - public FrmBSQDuoBianXingStatis(Dictionary workWellLen, GSOGlobeControl glb,List _list) - { - InitializeComponent(); - bsq = workWellLen; - globeControl1 = glb; - list = _list; - } - - private void FrmBSQDuoBianXingStatis_Load(object sender, EventArgs e) - { - FrmBSQDuoBianXingStatisFenLei(); - try - { - chart1.Series.Add("标识器"); - chart1.ChartAreas["ChartArea1"].AxisX.Title = "标识器类型"; - chart1.ChartAreas["ChartArea1"].AxisY.Title = "标识器数量"; - chart1.ChartAreas["ChartArea1"].AxisX.Interval = 1; - chart1.Series["标识器"].ChartType = SeriesChartType.Column; - chart1.Series["标识器"]["DrawingStyle"] = "Cylinder"; - - chart1.Series["标识器"].Points.DataBindXY(bsq1.Keys, bsq1.Values); - if (bsq1.Values.Count == 0) - { - MessageBox.Show("该区域没有标识器信息", "提示"); - this.Close(); - return; - } - else - { - for (int m = 0; m < bsq1.Values.Count; m++) - { - if (chart1.Series["标识器"].Points[m].YValues[0].ToString() != "0") - { - chart1.Series["标识器"].Points[m].Label = chart1.Series[0].Points[m].YValues[0].ToString(); - } - } - } - } - catch (Exception ex) - { - //ErrorLog.PublishError(ex); - } - } - - private void FrmBSQDuoBianXingStatis_FormClosing(object sender, FormClosingEventArgs e) - { - frm = null; - globeControl1.Globe.ClearAnalysis(); - globeControl1.Globe.MemoryLayer.RemoveAllFeature(); - } - - - private void FrmBSQDuoBianXingStatisFenLei() - { - try - { - bool flag2 = false; - for (int i = 0; i < Utility.listPipelineType.Count; i++) - { - - for (int j = 0; j < pipeLists.Count; j++) - { - if (pipeLists[j] == Utility.listPipelineType[i].type) - { - flag2 = true; - break; - } - } - if (!flag2 && Utility.listPipelineType[i].type != "标识器") - { - pipeLists.Add(Utility.listPipelineType[i].type); - } - flag2 = false; - } - - typeLists = new List(); - for (int num = 0; num < pipeLists.Count; num++) - { - typeList ls = new typeList(0, pipeLists[num]); - typeLists.Add(ls); - } - - GSOFeatures fs = list[0]; - string pipetype = "标识器"; - foreach (string key in bsq.Keys) - { - if (key.StartsWith(pipetype)) - { - pipetype = key; - break; - } - } - if (fs.Length > 0) - { - for (int i = 0; i < fs.Length; i++) - { - string str = fs[i].GetValue("对象名称").ToString(); - codeStr = str.Split(','); - for (int n = 0; n < codeStr.Length; n++) - { - for (int ii = 0; ii < Utility.listPipelineType.Count; ii++) - { - if (Utility.listPipelineType[ii].code == codeStr[n]) - { - for (int m = 0; m < typeLists.Count; m++) - { - if (Utility.listPipelineType[ii].type == typeLists[m].type) - { - typeLists[m].num++; - break; - } - } - break; - } - } - } - } - } - - for (int i = 0; i < typeLists.Count; i++) - { - if (typeLists[i].num > 0) - bsq1.Add(typeLists[i].type, typeLists[i].num); - } - - } - catch (Exception ex) - { - //ErrorLog.PublishError(ex); - //MessageBox.Show(ex.Message); - } - - } - public class typeList - { - public int num; - public string type; - - public typeList(int _num, string _type) - { - num = _num; - type = _type; - } - } - - - } -} diff --git a/FrmBSQDuoBianXingStatis.resx b/FrmBSQDuoBianXingStatis.resx deleted file mode 100644 index 1af7de1..0000000 --- a/FrmBSQDuoBianXingStatis.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/FrmBSQStatis.Designer.cs b/FrmBSQStatis.Designer.cs index 2509c7d..ee9b1e7 100644 --- a/FrmBSQStatis.Designer.cs +++ b/FrmBSQStatis.Designer.cs @@ -57,6 +57,7 @@ this.ShowIcon = false; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "标识器全区域统计"; + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FrmBSQStatis_FormClosing); this.Load += new System.EventHandler(this.FrmBSQStatis_Load); ((System.ComponentModel.ISupportInitialize)(this.chartStatis)).EndInit(); this.ResumeLayout(false); diff --git a/FrmBSQStatis.cs b/FrmBSQStatis.cs index 4b25eda..e7c4926 100644 --- a/FrmBSQStatis.cs +++ b/FrmBSQStatis.cs @@ -18,94 +18,18 @@ { public partial class FrmBSQStatis : Office2007Form { - public Dictionary bsq = new Dictionary(); - //SqlConnection conn; - public static List typeLists; - OracleConnection conn; - string connectString; + private Dictionary bsq = new Dictionary(); + private GSOGlobeControl globeControl1; + private GSOGeoPolygon3D polygon; - public FrmBSQStatis() + public FrmBSQStatis(GSOGlobeControl globeControl1,GSOGeoPolygon3D polygon) { + this.globeControl1 = globeControl1; + this.polygon = polygon; InitializeComponent(); - BSQNumStatis(); + bsq = getBSQNameAndNumMap(polygon); } - string[] codeStr = new string[50]; - string[] nameStr = new string[30]; - public static List pipeLists = new List(); - - private void BSQNumStatis() - { - bool flag2 = false; - for (int i = 0; i < Utility.listPipelineType.Count; i++) - { - for (int j = 0; j < pipeLists.Count; j++) - { - if (pipeLists[j] == Utility.listPipelineType[i].type) - { - flag2 = true; - break; - } - } - if (!flag2 && Utility.listPipelineType[i].type != "标识器") - { - pipeLists.Add(Utility.listPipelineType[i].type); - } - flag2 = false; - } - - typeLists = new List(); - for (int num = 0; num 0) - bsq.Add(typeLists[i].type, typeLists[i].num); - } - - } - catch (Exception ex) - { - - } - } private void FrmBSQStatis_Load(object sender, EventArgs e) { @@ -136,17 +60,88 @@ } } - public class typeList + private Dictionary getBSQNameAndNumMap(GSOGeoPolygon3D polygon) { - public int num; - public string type; - public typeList(int _num, string _type) + Dictionary result = new Dictionary(); + Dictionary codeAndType = new Dictionary(); + //得到type的种类 + for (int i = 0; i < Utility.listPipelineType.Count; i++) { - num = _num; - type = _type; + if (!result.ContainsKey(Utility.listPipelineType[i].type) && Utility.listPipelineType[i].type != "标识器") + { + result.Add(Utility.listPipelineType[i].type, 0); + codeAndType.Add(Utility.listPipelineType[i].code, Utility.listPipelineType[i].type); + } + } + + return polygon == null ? getAllAreaMap(result, codeAndType) : getBSQMapByPolygon(polygon, result, codeAndType); + } + public Dictionary getAllAreaMap(Dictionary typeAndCount,Dictionary codeAndType) + { + try + { + OracleConnection conn = OledbHelper.sqlConnection(); + conn.Open(); + OracleCommand cmd; + cmd = new OracleCommand("select 对象类型 from 标识器", conn); + OracleDataReader dr = cmd.ExecuteReader(); + + while (dr.Read()) + { + string str = Convert.ToString(dr["对象类型"]); + if (str == null) continue; + foreach (string key in codeAndType.Keys) + { + if (str.Contains(key)) + { + typeAndCount[codeAndType[key]] += 1; + } + } + } + conn.Close(); + } + catch (Exception ex) + { + LogHelper.WriteLog(typeof(FrmBSQStatis),ex.Message.ToString()); + } + return typeAndCount; + } + + + public Dictionary getBSQMapByPolygon(GSOGeoPolygon3D polygon,Dictionary typeAndCount, Dictionary codeAndType) + { + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption("标识器"); + GSOFeatures bsqFs = FeatureStatisticsService.getLayerFeatures(polygon, layer); + if (bsqFs == null || bsqFs.Length <= 0) { + LogHelper.WriteLog(typeof(FrmBSQStatis),"标识器图层下的Feature为空"); + return null; + } + + for (int i = 0; i < bsqFs.Length; i++) + { + string str = bsqFs[i].GetValue("对象类型").ToString(); + + foreach (string key in codeAndType.Keys) + { + if (str.Contains(key)) + { + typeAndCount[codeAndType[key]] += 1; + } + } + } + + return typeAndCount; + } + + private void FrmBSQStatis_FormClosing(object sender, FormClosingEventArgs e) + { + globeControl1.Globe.ClearAnalysis(); + } + + } } diff --git a/FrmValveStatistics.cs b/FrmValveStatistics.cs index 672f97a..17dad6c 100644 --- a/FrmValveStatistics.cs +++ b/FrmValveStatistics.cs @@ -120,6 +120,7 @@ sql += " where 1>2 "; for (int i = 0; i < fs.Length; i++) { + if (fs[i].GetValue("编号") == null) continue; sql += " or 编号 = '" + fs[i].GetValue("编号").ToString() + "'"; } diff --git a/FrmpipeDeepstatis.cs b/FrmpipeDeepstatis.cs index 879801a..c7edbc3 100644 --- a/FrmpipeDeepstatis.cs +++ b/FrmpipeDeepstatis.cs @@ -164,88 +164,6 @@ } } - //if (clbPipeLine.CheckedItems.Count > 0) - //{ - // if (dataGridViewX2.Rows.Count > 0) - // { - // for (int i = 0; i < clbPipeLine.CheckedItems.Count; i++) - // { - // GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(clbPipeLine.CheckedItems[i].ToString()); - // GSOFeatureLayer flayer = layer as GSOFeatureLayer; - // GSOFeatures feats = new GSOFeatures(); - // if (polygon == null) - // feats = flayer.GetAllFeatures(); - // else - // feats = flayer.FindFeaturesInPolygon(polygon, false); - // for (int j = 0; j < dataGridViewX2.Rows.Count; j++) - // { - // double totalLength = 0.00; - // int ncount = 0; - // for (int m = 0; m < feats.Length; m++) - // { - // GSOFeature feat = feats[m]; - // float radius = feat.GetFieldAsFloat("起始埋深"); - // bool upCompare = true; - // bool downCompare = true; - // if (dataGridViewX2.Rows[j].Cells["下限"].Value != null || dataGridViewX2.Rows[j].Cells["上限"].Value != null) - // { - // if (dataGridViewX2.Rows[j].Cells["下限"].Value != null) - // { - // if (dataGridViewX2.Rows[j].Cells["下限"].Value.ToString() != "") - // { - // if (radius >= Convert.ToDouble(dataGridViewX2.Rows[j].Cells["下限"].Value)) - // { - // downCompare = true; - // } - // else - // downCompare = false; - // } - // } - // if (dataGridViewX2.Rows[j].Cells["上限"].Value != null) - // { - // if (dataGridViewX2.Rows[j].Cells["上限"].Value.ToString() != "") - // { - // if (radius <= Convert.ToDouble(dataGridViewX2.Rows[j].Cells["上限"].Value)) - // { - // upCompare = true; - // } - // else - // upCompare = false; - // } - // } - // if (upCompare && downCompare) - // { - // GSOGeoPolyline3D line = feat.Geometry as GSOGeoPolyline3D; - // double length = line.GetSpaceLength(true, 6378137); - // totalLength += length; - // ncount += 1; - // } - // } - // } - // if (dataGridViewX2.Rows[j].Cells["下限"].Value != null || dataGridViewX2.Rows[j].Cells["上限"].Value != null) - // { - // DataGridViewRow row = new DataGridViewRow(); - // int index = dataGridViewX1.Rows.Add(row); - // row = dataGridViewX1.Rows[index]; - // row.Cells["图层名称"].Value = layer.Caption; - // row.Cells["埋深范围"].Value = dataGridViewX2.Rows[j].Cells["下限"].Value + "-" + dataGridViewX2.Rows[j].Cells["上限"].Value; - // row.Cells["条数"].Value = ncount; - // row.Cells["总长度"].Value =Math.Round(totalLength,2); - - // dic.Add(layer.Caption + "," + row.Cells["埋深范围"].Value.ToString()+","+row.Cells["总长度"].Value.ToString(), ncount); - // } - // } - // } - // } - // else - // { - // MessageBox.Show("请添加分段!"); - // } - //} - //else - //{ - // MessageBox.Show("请选择图层!"); - //} showPipeWidget(); } catch (Exception ex) diff --git a/FrmpipeMaterialGather.cs b/FrmpipeMaterialGather.cs index b7ab1d2..3e9f45d 100644 --- a/FrmpipeMaterialGather.cs +++ b/FrmpipeMaterialGather.cs @@ -180,79 +180,6 @@ } - //if (clbPipeLine.CheckedItems.Count > 0) - //{ - // for (int i = 0; i < clbPipeLine.CheckedItems.Count; i++) - // { - // GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(clbPipeLine.CheckedItems[i].ToString()); - // GSOFeatureLayer flayer = layer as GSOFeatureLayer; - // GSOFeatures feats = new GSOFeatures(); - // if (polygon == null) - // feats = flayer.GetAllFeatures(); - // else - // feats = flayer.FindFeaturesInPolygon(polygon, false); - // List lstDiameter = new List(); - - // for (int j = 0; j < clbmaterials.CheckedItems.Count; j++) - // { - // if (!lstDiameter.Contains(clbmaterials.CheckedItems[j].ToString())) - // { - // lstDiameter.Add(clbmaterials.CheckedItems[j].ToString()); - // } - // } - // //lstDiameter.Sort(); - // if (lstDiameter.Count > 0) - // { - // for (int m = 0; m < lstDiameter.Count; m++) - // { - // double totalLength = 0.00; - // int ncount = 0; - // for (int j = 0; j < feats.Length; j++) - // { - // if (lstDiameter[m] != "无") - // { - // if (feats[j].GetFieldAsString("材质") == lstDiameter[m]) - // { - // GSOGeoPolyline3D line = feats[j].Geometry as GSOGeoPolyline3D; - // if (line != null) - // { - // double length = line.GetSpaceLength(true, 6378137); - // totalLength += length; - // ncount += 1; - // } - // } - // } - // else - // { - // if (feats[j].GetFieldAsString("材质") == "") - // { - // GSOGeoPolyline3D line = feats[j].Geometry as GSOGeoPolyline3D; - // if (line != null) - // { - // double length = line.GetSpaceLength(true, 6378137); - // totalLength += length; - // ncount += 1; - // } - // } - // } - // } - // DataGridViewRow row = new DataGridViewRow(); - // int index = dataGridViewX1.Rows.Add(row); - // row = dataGridViewX1.Rows[index]; - // row.Cells["图层名称"].Value = layer.Caption; - // row.Cells["材质"].Value = lstDiameter[m]; - // row.Cells["条数"].Value = ncount; - // row.Cells["总长度"].Value = Math.Round(totalLength); - - // dic.Add(layer.Caption + "," + row.Cells["材质"].Value.ToString(), ncount); - // } - // } - // } - //} - //else - //{ - // MessageBox.Show("请选择图层!"); - //} showPipeWidget(); } catch (Exception ex) diff --git a/Frmpipediameterstatis.cs b/Frmpipediameterstatis.cs index 9953ac0..aa482d8 100644 --- a/Frmpipediameterstatis.cs +++ b/Frmpipediameterstatis.cs @@ -27,12 +27,9 @@ frm = new Frmpipediameterstatis(_globeControl1, pipeLayers, visibleId); frm.Show(_globeControl1.Parent); } - else + else if (frm.WindowState == FormWindowState.Minimized) { - if (frm.WindowState == FormWindowState.Minimized) - { - frm.WindowState = FormWindowState.Normal; - } + frm.WindowState = FormWindowState.Normal; } } @@ -208,7 +205,8 @@ } catch (Exception ex) { - MessageBox.Show(ex.Message); + LogHelper.WriteLog(typeof(Frmpipediameterstatis), ex.Message); + //MessageBox.Show(ex.Message); LogError.PublishError(ex); } } @@ -290,76 +288,77 @@ /// private void btnExport_Click(object sender, EventArgs e) { - if (dataGridViewX1.Rows.Count > 0) + if (dataGridViewX1.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 = DateTime.Now.ToString("yyyyMMdd") + ".xls"; - if (dlg.ShowDialog() == DialogResult.OK) + MessageBox.Show("统计结果为空,请重新统计之后再导出Excel!", "提示"); + return; + } + + SaveFileDialog dlg = new SaveFileDialog(); + dlg.Filter = "Excel files (*.xls)|*.xls"; + dlg.FilterIndex = 0; + dlg.RestoreDirectory = true; + //dlg.CreatePrompt = true; + dlg.Title = "保存为Excel文件"; + dlg.FileName = 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 { - Stream myStream; - myStream = dlg.OpenFile(); - StreamWriter sw = new StreamWriter(myStream, System.Text.Encoding.GetEncoding(-0)); - string columnTitle = ""; - try + sw.WriteLine("日期:" + DateTime.Now.ToString("yyyy-MM-dd")); + + //写入列标题 + for (int i = 0; i < dataGridViewX1.ColumnCount; i++) { - sw.WriteLine("日期:" + DateTime.Now.ToString("yyyy-MM-dd")); - - //写入列标题 - for (int i = 0; i < dataGridViewX1.ColumnCount; i++) + if (i > 0) { - if (i > 0) - { - columnTitle += "\t"; - } - columnTitle += dataGridViewX1.Columns[i].HeaderText; + columnTitle += "\t"; } - sw.WriteLine(columnTitle); - - //写入列内容 - for (int j = 0; j < dataGridViewX1.Rows.Count; j++) - { - string columnValue = ""; - for (int k = 0; k < dataGridViewX1.Columns.Count; k++) - { - if (k > 0) - { - columnValue += "\t"; - } - if (dataGridViewX1.Rows[j].Cells[k].Value == null) - columnValue += ""; - else - columnValue += dataGridViewX1.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); - } + columnTitle += dataGridViewX1.Columns[i].HeaderText; } - catch (Exception ex) + sw.WriteLine(columnTitle); + + //写入列内容 + for (int j = 0; j < dataGridViewX1.Rows.Count; j++) { - MessageBox.Show(ex.ToString()); + string columnValue = ""; + for (int k = 0; k < dataGridViewX1.Columns.Count; k++) + { + if (k > 0) + { + columnValue += "\t"; + } + if (dataGridViewX1.Rows[j].Cells[k].Value == null) + columnValue += ""; + else + columnValue += dataGridViewX1.Rows[j].Cells[k].Value.ToString().Trim(); + } + + sw.WriteLine(columnValue); } - finally + sw.Close(); + myStream.Close(); + if (MessageBox.Show("导出Excel文件成功!是否打开?", "提示", MessageBoxButtons.YesNo) == DialogResult.Yes) { - sw.Close(); - myStream.Close(); + System.Diagnostics.Process.Start(dlg.FileName); } } + catch (Exception ex) + { + MessageBox.Show(ex.ToString()); + } + finally + { + sw.Close(); + myStream.Close(); + } } - else - { - MessageBox.Show("统计结果为空,请重新统计之后再导出Excel!","提示"); - } + + } /// /// 绘制区域分段统计 diff --git a/Cyberpipe.csproj b/Cyberpipe.csproj index 3a45ad8..d22f590 100644 --- a/Cyberpipe.csproj +++ b/Cyberpipe.csproj @@ -402,12 +402,6 @@ FrmBACKORACLE.cs - - Form - - - FrmBSQDuoBianXingStatis.cs - Form @@ -1271,9 +1265,6 @@ FrmBACKORACLE.cs - - FrmBSQDuoBianXingStatis.cs - FrmBSQStatis.cs diff --git a/FeatureStatisticsService.cs b/FeatureStatisticsService.cs index e833e5f..c7de210 100644 --- a/FeatureStatisticsService.cs +++ b/FeatureStatisticsService.cs @@ -273,19 +273,15 @@ /// 获取特定区域图层的管线列表,并将其总长度统计出来 /// TODOLIST:将Intersects_Pipeline在MainFrm中去除 /// - /// + /// + /// 要统计的长度 /// public static GSOFeatures getLayerPipes(GSOGeoPolygon3D polygon, GSOLayer layer, out double length) { length = 0; if (layer == null) return null; - GSOFeatureLayer flayer = layer as GSOFeatureLayer; - GSOFeatureDataset fdataset = flayer.Dataset as GSOFeatureDataset; - GSOFeatures feats = null; - - feats = polygon == null?flayer.GetAllFeatures():flayer.FindFeaturesInPolygon(polygon, false); - + GSOFeatures feats = getLayerFeatures(polygon, layer); double totallength = 0.00; for (int i = 0; i < feats.Length; i++) { @@ -301,5 +297,17 @@ return feats; } + /// + /// 获取区域图层内的feature列表,MainFrm.PolygonIntersectAnalysis和此方法重复,需要整理删除 + /// + /// + /// + /// + public static GSOFeatures getLayerFeatures(GSOGeoPolygon3D polygon, GSOLayer layer) + { + if (layer == null) return null; + GSOFeatureLayer flayer = layer as GSOFeatureLayer; + return polygon == null ? flayer.GetAllFeatures() : flayer.FindFeaturesInPolygon(polygon, false); + } } } diff --git a/FrmAllWorkWellStatis.cs b/FrmAllWorkWellStatis.cs index 7bf65dc..bd0f81b 100644 --- a/FrmAllWorkWellStatis.cs +++ b/FrmAllWorkWellStatis.cs @@ -19,17 +19,7 @@ private Dictionary map = null; private GSOGlobeControl globeControl1; private GSOGeoPolygon3D polygon; - //TODOLIST:用晓伟的代理进行操作,功能拆分细化 - //public FrmAllWorkWellStatis(GSOGeoPolygon3D polygon, DataGridView dataGridViewX11, ToolStripStatusLabel toolStripNumbers1, GSOGlobeControl ctl, PanelEx p) - //{ - // InitializeComponent(); - // panel = p; - // dataGridViewX1 = dataGridViewX11; - // toolStripNumbers = toolStripNumbers1; - // globeControl1 = ctl; - // map = getAccsMap(polygon); - //} public FrmAllWorkWellStatis(GSOGlobeControl ctl,GSOGeoPolygon3D polygon, MainFrm.DataGridViewDelegate InitDataGridViewX1) { InitializeComponent(); @@ -117,8 +107,9 @@ sql = "select " + getpipeLineFields.getFields(layername, globeControl1) + " from " + layer.Name; sql += " where 1>2 "; - for (int i = 0; i < fs.Length && fs[i].GetFieldDefn("编号") != null; i++) + for (int i = 0; i < fs.Length; i++) { + if (fs[i].GetFieldDefn("编号") == null) continue; sql += " or 编号 = '" + fs[i].GetValue("编号").ToString() + "'"; } diff --git a/FrmBSQDuoBianXingStatis.Designer.cs b/FrmBSQDuoBianXingStatis.Designer.cs deleted file mode 100644 index bda6842..0000000 --- a/FrmBSQDuoBianXingStatis.Designer.cs +++ /dev/null @@ -1,87 +0,0 @@ -namespace Cyberpipe -{ - partial class FrmBSQDuoBianXingStatis - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea1 = new System.Windows.Forms.DataVisualization.Charting.ChartArea(); - this.groupBox1 = new System.Windows.Forms.GroupBox(); - this.chart1 = new System.Windows.Forms.DataVisualization.Charting.Chart(); - this.groupBox1.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.chart1)).BeginInit(); - this.SuspendLayout(); - // - // groupBox1 - // - this.groupBox1.Controls.Add(this.chart1); - this.groupBox1.Dock = System.Windows.Forms.DockStyle.Fill; - this.groupBox1.Location = new System.Drawing.Point(0, 0); - this.groupBox1.Name = "groupBox1"; - this.groupBox1.Size = new System.Drawing.Size(592, 384); - this.groupBox1.TabIndex = 0; - this.groupBox1.TabStop = false; - this.groupBox1.Text = "统计结果信息"; - // - // chart1 - // - chartArea1.AxisX.MajorGrid.Enabled = false; - chartArea1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(191)))), ((int)(((byte)(219)))), ((int)(((byte)(255))))); - chartArea1.BackGradientStyle = System.Windows.Forms.DataVisualization.Charting.GradientStyle.TopBottom; - chartArea1.Name = "ChartArea1"; - this.chart1.ChartAreas.Add(chartArea1); - this.chart1.Dock = System.Windows.Forms.DockStyle.Fill; - this.chart1.Location = new System.Drawing.Point(3, 17); - this.chart1.Name = "chart1"; - this.chart1.Size = new System.Drawing.Size(586, 364); - this.chart1.TabIndex = 0; - this.chart1.Text = "chart1"; - // - // FrmBSQDuoBianXingStatis - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(592, 384); - this.Controls.Add(this.groupBox1); - this.DoubleBuffered = true; - this.Name = "FrmBSQDuoBianXingStatis"; - this.ShowIcon = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; - this.Text = "多边形区域统计"; - this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FrmBSQDuoBianXingStatis_FormClosing); - this.Load += new System.EventHandler(this.FrmBSQDuoBianXingStatis_Load); - this.groupBox1.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)(this.chart1)).EndInit(); - this.ResumeLayout(false); - - } - - #endregion - - private System.Windows.Forms.GroupBox groupBox1; - private System.Windows.Forms.DataVisualization.Charting.Chart chart1; - } -} \ No newline at end of file diff --git a/FrmBSQDuoBianXingStatis.cs b/FrmBSQDuoBianXingStatis.cs deleted file mode 100644 index 80b567e..0000000 --- a/FrmBSQDuoBianXingStatis.cs +++ /dev/null @@ -1,179 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Windows.Forms; -using DevComponents.DotNetBar; -using System.Data.SqlClient; -using System.Windows.Forms.DataVisualization.Charting; -using GeoScene.Data; -using GeoScene.Engine; -using GeoScene.Globe; -using System.Data.OracleClient; - -namespace Cyberpipe -{ - public partial class FrmBSQDuoBianXingStatis : Office2007Form - { - Dictionary bsq = new Dictionary(); - Dictionary bsq1 = new Dictionary(); - static FrmBSQDuoBianXingStatis frm; - GSOGlobeControl globeControl1; - List list = new List(); - public static List pipeLists = new List(); - - string[] codeStr = new string[50]; - string[] nameStr = new string[30]; - public static List typeLists; - - public FrmBSQDuoBianXingStatis(Dictionary workWellLen, GSOGlobeControl glb,List _list) - { - InitializeComponent(); - bsq = workWellLen; - globeControl1 = glb; - list = _list; - } - - private void FrmBSQDuoBianXingStatis_Load(object sender, EventArgs e) - { - FrmBSQDuoBianXingStatisFenLei(); - try - { - chart1.Series.Add("标识器"); - chart1.ChartAreas["ChartArea1"].AxisX.Title = "标识器类型"; - chart1.ChartAreas["ChartArea1"].AxisY.Title = "标识器数量"; - chart1.ChartAreas["ChartArea1"].AxisX.Interval = 1; - chart1.Series["标识器"].ChartType = SeriesChartType.Column; - chart1.Series["标识器"]["DrawingStyle"] = "Cylinder"; - - chart1.Series["标识器"].Points.DataBindXY(bsq1.Keys, bsq1.Values); - if (bsq1.Values.Count == 0) - { - MessageBox.Show("该区域没有标识器信息", "提示"); - this.Close(); - return; - } - else - { - for (int m = 0; m < bsq1.Values.Count; m++) - { - if (chart1.Series["标识器"].Points[m].YValues[0].ToString() != "0") - { - chart1.Series["标识器"].Points[m].Label = chart1.Series[0].Points[m].YValues[0].ToString(); - } - } - } - } - catch (Exception ex) - { - //ErrorLog.PublishError(ex); - } - } - - private void FrmBSQDuoBianXingStatis_FormClosing(object sender, FormClosingEventArgs e) - { - frm = null; - globeControl1.Globe.ClearAnalysis(); - globeControl1.Globe.MemoryLayer.RemoveAllFeature(); - } - - - private void FrmBSQDuoBianXingStatisFenLei() - { - try - { - bool flag2 = false; - for (int i = 0; i < Utility.listPipelineType.Count; i++) - { - - for (int j = 0; j < pipeLists.Count; j++) - { - if (pipeLists[j] == Utility.listPipelineType[i].type) - { - flag2 = true; - break; - } - } - if (!flag2 && Utility.listPipelineType[i].type != "标识器") - { - pipeLists.Add(Utility.listPipelineType[i].type); - } - flag2 = false; - } - - typeLists = new List(); - for (int num = 0; num < pipeLists.Count; num++) - { - typeList ls = new typeList(0, pipeLists[num]); - typeLists.Add(ls); - } - - GSOFeatures fs = list[0]; - string pipetype = "标识器"; - foreach (string key in bsq.Keys) - { - if (key.StartsWith(pipetype)) - { - pipetype = key; - break; - } - } - if (fs.Length > 0) - { - for (int i = 0; i < fs.Length; i++) - { - string str = fs[i].GetValue("对象名称").ToString(); - codeStr = str.Split(','); - for (int n = 0; n < codeStr.Length; n++) - { - for (int ii = 0; ii < Utility.listPipelineType.Count; ii++) - { - if (Utility.listPipelineType[ii].code == codeStr[n]) - { - for (int m = 0; m < typeLists.Count; m++) - { - if (Utility.listPipelineType[ii].type == typeLists[m].type) - { - typeLists[m].num++; - break; - } - } - break; - } - } - } - } - } - - for (int i = 0; i < typeLists.Count; i++) - { - if (typeLists[i].num > 0) - bsq1.Add(typeLists[i].type, typeLists[i].num); - } - - } - catch (Exception ex) - { - //ErrorLog.PublishError(ex); - //MessageBox.Show(ex.Message); - } - - } - public class typeList - { - public int num; - public string type; - - public typeList(int _num, string _type) - { - num = _num; - type = _type; - } - } - - - } -} diff --git a/FrmBSQDuoBianXingStatis.resx b/FrmBSQDuoBianXingStatis.resx deleted file mode 100644 index 1af7de1..0000000 --- a/FrmBSQDuoBianXingStatis.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/FrmBSQStatis.Designer.cs b/FrmBSQStatis.Designer.cs index 2509c7d..ee9b1e7 100644 --- a/FrmBSQStatis.Designer.cs +++ b/FrmBSQStatis.Designer.cs @@ -57,6 +57,7 @@ this.ShowIcon = false; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "标识器全区域统计"; + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FrmBSQStatis_FormClosing); this.Load += new System.EventHandler(this.FrmBSQStatis_Load); ((System.ComponentModel.ISupportInitialize)(this.chartStatis)).EndInit(); this.ResumeLayout(false); diff --git a/FrmBSQStatis.cs b/FrmBSQStatis.cs index 4b25eda..e7c4926 100644 --- a/FrmBSQStatis.cs +++ b/FrmBSQStatis.cs @@ -18,94 +18,18 @@ { public partial class FrmBSQStatis : Office2007Form { - public Dictionary bsq = new Dictionary(); - //SqlConnection conn; - public static List typeLists; - OracleConnection conn; - string connectString; + private Dictionary bsq = new Dictionary(); + private GSOGlobeControl globeControl1; + private GSOGeoPolygon3D polygon; - public FrmBSQStatis() + public FrmBSQStatis(GSOGlobeControl globeControl1,GSOGeoPolygon3D polygon) { + this.globeControl1 = globeControl1; + this.polygon = polygon; InitializeComponent(); - BSQNumStatis(); + bsq = getBSQNameAndNumMap(polygon); } - string[] codeStr = new string[50]; - string[] nameStr = new string[30]; - public static List pipeLists = new List(); - - private void BSQNumStatis() - { - bool flag2 = false; - for (int i = 0; i < Utility.listPipelineType.Count; i++) - { - for (int j = 0; j < pipeLists.Count; j++) - { - if (pipeLists[j] == Utility.listPipelineType[i].type) - { - flag2 = true; - break; - } - } - if (!flag2 && Utility.listPipelineType[i].type != "标识器") - { - pipeLists.Add(Utility.listPipelineType[i].type); - } - flag2 = false; - } - - typeLists = new List(); - for (int num = 0; num 0) - bsq.Add(typeLists[i].type, typeLists[i].num); - } - - } - catch (Exception ex) - { - - } - } private void FrmBSQStatis_Load(object sender, EventArgs e) { @@ -136,17 +60,88 @@ } } - public class typeList + private Dictionary getBSQNameAndNumMap(GSOGeoPolygon3D polygon) { - public int num; - public string type; - public typeList(int _num, string _type) + Dictionary result = new Dictionary(); + Dictionary codeAndType = new Dictionary(); + //得到type的种类 + for (int i = 0; i < Utility.listPipelineType.Count; i++) { - num = _num; - type = _type; + if (!result.ContainsKey(Utility.listPipelineType[i].type) && Utility.listPipelineType[i].type != "标识器") + { + result.Add(Utility.listPipelineType[i].type, 0); + codeAndType.Add(Utility.listPipelineType[i].code, Utility.listPipelineType[i].type); + } + } + + return polygon == null ? getAllAreaMap(result, codeAndType) : getBSQMapByPolygon(polygon, result, codeAndType); + } + public Dictionary getAllAreaMap(Dictionary typeAndCount,Dictionary codeAndType) + { + try + { + OracleConnection conn = OledbHelper.sqlConnection(); + conn.Open(); + OracleCommand cmd; + cmd = new OracleCommand("select 对象类型 from 标识器", conn); + OracleDataReader dr = cmd.ExecuteReader(); + + while (dr.Read()) + { + string str = Convert.ToString(dr["对象类型"]); + if (str == null) continue; + foreach (string key in codeAndType.Keys) + { + if (str.Contains(key)) + { + typeAndCount[codeAndType[key]] += 1; + } + } + } + conn.Close(); + } + catch (Exception ex) + { + LogHelper.WriteLog(typeof(FrmBSQStatis),ex.Message.ToString()); + } + return typeAndCount; + } + + + public Dictionary getBSQMapByPolygon(GSOGeoPolygon3D polygon,Dictionary typeAndCount, Dictionary codeAndType) + { + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption("标识器"); + GSOFeatures bsqFs = FeatureStatisticsService.getLayerFeatures(polygon, layer); + if (bsqFs == null || bsqFs.Length <= 0) { + LogHelper.WriteLog(typeof(FrmBSQStatis),"标识器图层下的Feature为空"); + return null; + } + + for (int i = 0; i < bsqFs.Length; i++) + { + string str = bsqFs[i].GetValue("对象类型").ToString(); + + foreach (string key in codeAndType.Keys) + { + if (str.Contains(key)) + { + typeAndCount[codeAndType[key]] += 1; + } + } + } + + return typeAndCount; + } + + private void FrmBSQStatis_FormClosing(object sender, FormClosingEventArgs e) + { + globeControl1.Globe.ClearAnalysis(); + } + + } } diff --git a/FrmValveStatistics.cs b/FrmValveStatistics.cs index 672f97a..17dad6c 100644 --- a/FrmValveStatistics.cs +++ b/FrmValveStatistics.cs @@ -120,6 +120,7 @@ sql += " where 1>2 "; for (int i = 0; i < fs.Length; i++) { + if (fs[i].GetValue("编号") == null) continue; sql += " or 编号 = '" + fs[i].GetValue("编号").ToString() + "'"; } diff --git a/FrmpipeDeepstatis.cs b/FrmpipeDeepstatis.cs index 879801a..c7edbc3 100644 --- a/FrmpipeDeepstatis.cs +++ b/FrmpipeDeepstatis.cs @@ -164,88 +164,6 @@ } } - //if (clbPipeLine.CheckedItems.Count > 0) - //{ - // if (dataGridViewX2.Rows.Count > 0) - // { - // for (int i = 0; i < clbPipeLine.CheckedItems.Count; i++) - // { - // GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(clbPipeLine.CheckedItems[i].ToString()); - // GSOFeatureLayer flayer = layer as GSOFeatureLayer; - // GSOFeatures feats = new GSOFeatures(); - // if (polygon == null) - // feats = flayer.GetAllFeatures(); - // else - // feats = flayer.FindFeaturesInPolygon(polygon, false); - // for (int j = 0; j < dataGridViewX2.Rows.Count; j++) - // { - // double totalLength = 0.00; - // int ncount = 0; - // for (int m = 0; m < feats.Length; m++) - // { - // GSOFeature feat = feats[m]; - // float radius = feat.GetFieldAsFloat("起始埋深"); - // bool upCompare = true; - // bool downCompare = true; - // if (dataGridViewX2.Rows[j].Cells["下限"].Value != null || dataGridViewX2.Rows[j].Cells["上限"].Value != null) - // { - // if (dataGridViewX2.Rows[j].Cells["下限"].Value != null) - // { - // if (dataGridViewX2.Rows[j].Cells["下限"].Value.ToString() != "") - // { - // if (radius >= Convert.ToDouble(dataGridViewX2.Rows[j].Cells["下限"].Value)) - // { - // downCompare = true; - // } - // else - // downCompare = false; - // } - // } - // if (dataGridViewX2.Rows[j].Cells["上限"].Value != null) - // { - // if (dataGridViewX2.Rows[j].Cells["上限"].Value.ToString() != "") - // { - // if (radius <= Convert.ToDouble(dataGridViewX2.Rows[j].Cells["上限"].Value)) - // { - // upCompare = true; - // } - // else - // upCompare = false; - // } - // } - // if (upCompare && downCompare) - // { - // GSOGeoPolyline3D line = feat.Geometry as GSOGeoPolyline3D; - // double length = line.GetSpaceLength(true, 6378137); - // totalLength += length; - // ncount += 1; - // } - // } - // } - // if (dataGridViewX2.Rows[j].Cells["下限"].Value != null || dataGridViewX2.Rows[j].Cells["上限"].Value != null) - // { - // DataGridViewRow row = new DataGridViewRow(); - // int index = dataGridViewX1.Rows.Add(row); - // row = dataGridViewX1.Rows[index]; - // row.Cells["图层名称"].Value = layer.Caption; - // row.Cells["埋深范围"].Value = dataGridViewX2.Rows[j].Cells["下限"].Value + "-" + dataGridViewX2.Rows[j].Cells["上限"].Value; - // row.Cells["条数"].Value = ncount; - // row.Cells["总长度"].Value =Math.Round(totalLength,2); - - // dic.Add(layer.Caption + "," + row.Cells["埋深范围"].Value.ToString()+","+row.Cells["总长度"].Value.ToString(), ncount); - // } - // } - // } - // } - // else - // { - // MessageBox.Show("请添加分段!"); - // } - //} - //else - //{ - // MessageBox.Show("请选择图层!"); - //} showPipeWidget(); } catch (Exception ex) diff --git a/FrmpipeMaterialGather.cs b/FrmpipeMaterialGather.cs index b7ab1d2..3e9f45d 100644 --- a/FrmpipeMaterialGather.cs +++ b/FrmpipeMaterialGather.cs @@ -180,79 +180,6 @@ } - //if (clbPipeLine.CheckedItems.Count > 0) - //{ - // for (int i = 0; i < clbPipeLine.CheckedItems.Count; i++) - // { - // GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(clbPipeLine.CheckedItems[i].ToString()); - // GSOFeatureLayer flayer = layer as GSOFeatureLayer; - // GSOFeatures feats = new GSOFeatures(); - // if (polygon == null) - // feats = flayer.GetAllFeatures(); - // else - // feats = flayer.FindFeaturesInPolygon(polygon, false); - // List lstDiameter = new List(); - - // for (int j = 0; j < clbmaterials.CheckedItems.Count; j++) - // { - // if (!lstDiameter.Contains(clbmaterials.CheckedItems[j].ToString())) - // { - // lstDiameter.Add(clbmaterials.CheckedItems[j].ToString()); - // } - // } - // //lstDiameter.Sort(); - // if (lstDiameter.Count > 0) - // { - // for (int m = 0; m < lstDiameter.Count; m++) - // { - // double totalLength = 0.00; - // int ncount = 0; - // for (int j = 0; j < feats.Length; j++) - // { - // if (lstDiameter[m] != "无") - // { - // if (feats[j].GetFieldAsString("材质") == lstDiameter[m]) - // { - // GSOGeoPolyline3D line = feats[j].Geometry as GSOGeoPolyline3D; - // if (line != null) - // { - // double length = line.GetSpaceLength(true, 6378137); - // totalLength += length; - // ncount += 1; - // } - // } - // } - // else - // { - // if (feats[j].GetFieldAsString("材质") == "") - // { - // GSOGeoPolyline3D line = feats[j].Geometry as GSOGeoPolyline3D; - // if (line != null) - // { - // double length = line.GetSpaceLength(true, 6378137); - // totalLength += length; - // ncount += 1; - // } - // } - // } - // } - // DataGridViewRow row = new DataGridViewRow(); - // int index = dataGridViewX1.Rows.Add(row); - // row = dataGridViewX1.Rows[index]; - // row.Cells["图层名称"].Value = layer.Caption; - // row.Cells["材质"].Value = lstDiameter[m]; - // row.Cells["条数"].Value = ncount; - // row.Cells["总长度"].Value = Math.Round(totalLength); - - // dic.Add(layer.Caption + "," + row.Cells["材质"].Value.ToString(), ncount); - // } - // } - // } - //} - //else - //{ - // MessageBox.Show("请选择图层!"); - //} showPipeWidget(); } catch (Exception ex) diff --git a/Frmpipediameterstatis.cs b/Frmpipediameterstatis.cs index 9953ac0..aa482d8 100644 --- a/Frmpipediameterstatis.cs +++ b/Frmpipediameterstatis.cs @@ -27,12 +27,9 @@ frm = new Frmpipediameterstatis(_globeControl1, pipeLayers, visibleId); frm.Show(_globeControl1.Parent); } - else + else if (frm.WindowState == FormWindowState.Minimized) { - if (frm.WindowState == FormWindowState.Minimized) - { - frm.WindowState = FormWindowState.Normal; - } + frm.WindowState = FormWindowState.Normal; } } @@ -208,7 +205,8 @@ } catch (Exception ex) { - MessageBox.Show(ex.Message); + LogHelper.WriteLog(typeof(Frmpipediameterstatis), ex.Message); + //MessageBox.Show(ex.Message); LogError.PublishError(ex); } } @@ -290,76 +288,77 @@ /// private void btnExport_Click(object sender, EventArgs e) { - if (dataGridViewX1.Rows.Count > 0) + if (dataGridViewX1.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 = DateTime.Now.ToString("yyyyMMdd") + ".xls"; - if (dlg.ShowDialog() == DialogResult.OK) + MessageBox.Show("统计结果为空,请重新统计之后再导出Excel!", "提示"); + return; + } + + SaveFileDialog dlg = new SaveFileDialog(); + dlg.Filter = "Excel files (*.xls)|*.xls"; + dlg.FilterIndex = 0; + dlg.RestoreDirectory = true; + //dlg.CreatePrompt = true; + dlg.Title = "保存为Excel文件"; + dlg.FileName = 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 { - Stream myStream; - myStream = dlg.OpenFile(); - StreamWriter sw = new StreamWriter(myStream, System.Text.Encoding.GetEncoding(-0)); - string columnTitle = ""; - try + sw.WriteLine("日期:" + DateTime.Now.ToString("yyyy-MM-dd")); + + //写入列标题 + for (int i = 0; i < dataGridViewX1.ColumnCount; i++) { - sw.WriteLine("日期:" + DateTime.Now.ToString("yyyy-MM-dd")); - - //写入列标题 - for (int i = 0; i < dataGridViewX1.ColumnCount; i++) + if (i > 0) { - if (i > 0) - { - columnTitle += "\t"; - } - columnTitle += dataGridViewX1.Columns[i].HeaderText; + columnTitle += "\t"; } - sw.WriteLine(columnTitle); - - //写入列内容 - for (int j = 0; j < dataGridViewX1.Rows.Count; j++) - { - string columnValue = ""; - for (int k = 0; k < dataGridViewX1.Columns.Count; k++) - { - if (k > 0) - { - columnValue += "\t"; - } - if (dataGridViewX1.Rows[j].Cells[k].Value == null) - columnValue += ""; - else - columnValue += dataGridViewX1.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); - } + columnTitle += dataGridViewX1.Columns[i].HeaderText; } - catch (Exception ex) + sw.WriteLine(columnTitle); + + //写入列内容 + for (int j = 0; j < dataGridViewX1.Rows.Count; j++) { - MessageBox.Show(ex.ToString()); + string columnValue = ""; + for (int k = 0; k < dataGridViewX1.Columns.Count; k++) + { + if (k > 0) + { + columnValue += "\t"; + } + if (dataGridViewX1.Rows[j].Cells[k].Value == null) + columnValue += ""; + else + columnValue += dataGridViewX1.Rows[j].Cells[k].Value.ToString().Trim(); + } + + sw.WriteLine(columnValue); } - finally + sw.Close(); + myStream.Close(); + if (MessageBox.Show("导出Excel文件成功!是否打开?", "提示", MessageBoxButtons.YesNo) == DialogResult.Yes) { - sw.Close(); - myStream.Close(); + System.Diagnostics.Process.Start(dlg.FileName); } } + catch (Exception ex) + { + MessageBox.Show(ex.ToString()); + } + finally + { + sw.Close(); + myStream.Close(); + } } - else - { - MessageBox.Show("统计结果为空,请重新统计之后再导出Excel!","提示"); - } + + } /// /// 绘制区域分段统计 diff --git a/MainFrm.cs b/MainFrm.cs index 0b7e393..9bfb70e 100644 --- a/MainFrm.cs +++ b/MainFrm.cs @@ -2667,12 +2667,195 @@ FrmBaseLineProfillAnalysis dlg = new FrmBaseLineProfillAnalysis(globeControl1.Globe, e.Polyline); dlg.Show(this); globeControl1.Globe.ClearLastTrackPolyline(); + /* + FrmRoadHDM f = new FrmRoadHDM(); + f.Show() + * **/ } else { } trackPolylineEndMode = EnumTrackPolylineEndMode.Default_Analysis; + /* + ArrayList arraylistPoint = new ArrayList(); + ArrayList arraylistLine = new ArrayList(); + + // globeControl1.Globe.ClearLastTrackPolyline(); + + if (e.Polyline != null) + { + //横断面分析 + if (buttonItemFX2_1.Checked || buttonItemFX2_3.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 (buttonItemFX2_1.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 (buttonItemFX2_4.Checked) + { + FrmBaseLineProfillAnalysis dlg = new FrmBaseLineProfillAnalysis(globeControl1.Globe, e.Polyline); + dlg.Show(this); + globeControl1.Globe.ClearLastTrackPolyline(); + } + else if (buttonItemFX4_3.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(); + * **/ } #endregion @@ -2713,16 +2896,20 @@ case "valvequery": FrmValveStatistics frm = new FrmValveStatistics(globeControl1,polygon, new DataGridViewDelegate(InitDataGridViewX1)); frm.Show(this); + //panelEx6.Visible = true; + toolStripFeatureLength.Text = ""; globeControl1.Globe.Action = EnumAction3D.ActionNull; break; case "PipelineDistanceStatistics": + FrmAllPipelineStatis frm1 = new FrmAllPipelineStatis(globeControl1, polygon, new DataGridViewDelegate(InitDataGridViewX1), m_PipelineLayerNames); frm1.Show(this); globeControl1.Globe.Action = EnumAction3D.ActionNull; break; case "PipelineSpatialQuery": + FrmAllPipelineStatis.ShowForm(globeControl1,polygon,new DataGridViewDelegate(InitDataGridViewX1),m_PipelineLayerNames); globeControl1.Globe.ClearAnalysis(); globeControl1.Globe.Action = EnumAction3D.ActionNull; @@ -2771,18 +2958,19 @@ break; case "BSQDuoBianXiangStatis": - GSOFeature f2 = new GSOFeature(); - f2.Geometry = e.Polygon; - f2.Geometry.AltitudeMode = EnumAltitudeMode.Absolute; - globeControl1.Globe.MemoryLayer.AddFeature(f2); - f2.Geometry.MoveZ(3); - workWellLen.Clear(); - List listBSQ = new List(); + //GSOFeature f2 = new GSOFeature(); + //f2.Geometry = e.Polygon; + //f2.Geometry.AltitudeMode = EnumAltitudeMode.Absolute; + //globeControl1.Globe.MemoryLayer.AddFeature(f2); + //f2.Geometry.MoveZ(3); + //workWellLen.Clear(); + //List listBSQ = new List(); - GSOFeatures bsqFeatures = PolygonIntersectAnalysis(e.Polygon, "标识器"); - listBSQ.Add(bsqFeatures); + //GSOFeatures bsqFeatures = PolygonIntersectAnalysis(e.Polygon, "标识器"); + //listBSQ.Add(bsqFeatures); - FrmBSQDuoBianXingStatis bsqFrm = new FrmBSQDuoBianXingStatis(workWellLen, globeControl1, listBSQ); + //FrmBSQDuoBianXingStatis bsqFrm = new FrmBSQDuoBianXingStatis(workWellLen, globeControl1, listBSQ); + FrmBSQStatis bsqFrm = new FrmBSQStatis(globeControl1,e.Polygon); bsqFrm.Show(this); globeControl1.Globe.Action = EnumAction3D.ActionNull; break; @@ -4351,6 +4539,26 @@ } /// + /// 在窗体的底部状态栏上显示 综合管线条件查询结果 + /// + /// + /// + 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 + " 条记录 | "; + } + } + + /// /// 统计管线的里程数 /// /// @@ -6824,6 +7032,54 @@ } /// + /// 创建label要素 功能 + /// + /// 添加label要素的feature + /// feature的位置 + /// label要素名字 + /// feature名字 + /// label要素距离点的位置 + /// + 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; + } + + + + /// /// 获取指定两点组成的线的长度 功能 /// /// @@ -9266,8 +9522,19 @@ //日志记录 LogManager.saveLog(Utility.userName, "管线长度统计"); + //pipeLineDis.Clear(); + //List list = new List(); + //for (int i = 0; i < m_PipelineLayerNames.Count; i++) + //{ + // GSOFeatures fs = Intersects_Pipeline(null, m_PipelineLayerNames[i]); + // if (fs!=null) + // list.Add(fs); + //} + + //FrmAllPipelineStatis frm = new FrmAllPipelineStatis(0, pipeLineDis, list, globeControl1, new DataGridViewDelegate(InitDataGridViewX1)); FrmAllPipelineStatis frm = new FrmAllPipelineStatis(globeControl1,null, new DataGridViewDelegate(InitDataGridViewX1), m_PipelineLayerNames); frm.Show(this); + } /// /// 管线长度绘制区域统计 @@ -9293,6 +9560,25 @@ //日志记录 LogManager.saveLog(Utility.userName, "阀门数量统计"); + //workWellLen.Clear(); + //List list = new List(); + ////找到所有阀门 + //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, globeControl1, new DataGridViewDelegate(InitDataGridViewX1)); FrmValveStatistics frm = new FrmValveStatistics(globeControl1, null, new DataGridViewDelegate(InitDataGridViewX1)); frm.Show(this); @@ -9318,9 +9604,7 @@ /// /// private void buttonItemTJ3_ALL_Click(object sender, EventArgs e) - { - //日志记录 - LogManager.saveLog(Utility.userName, "井盖数量统计"); + { FrmAllWorkWellStatis frm = new FrmAllWorkWellStatis(globeControl1, null, new DataGridViewDelegate(InitDataGridViewX1)); frm.Show(this); } @@ -9333,7 +9617,7 @@ { //日志记录 LogManager.saveLog(Utility.userName, "井盖数量统计"); - + trackflag = "workwellquery"; globeControl1.Globe.Action = EnumAction3D.TrackPolygon; globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; @@ -11142,7 +11426,7 @@ Cyberpipe.Forms.FrmPipelineModelDB frm = new Cyberpipe.Forms.FrmPipelineModelDB(globeControl1, ds); if (frm.ShowDialog() == DialogResult.OK) { - //addNodeToLayerManagerNode(frm.rukuLayer); + addNodeToLayerManagerNode(frm.rukuLayer); } } /// @@ -12377,7 +12661,8 @@ private void 标识器分类统计ToolStripMenuItem_Click(object sender, EventArgs e) { globeControl1.Globe.Action = EnumAction3D.ActionNull; - FrmBSQStatis bsqStatis = new FrmBSQStatis(); + FrmBSQStatis bsqStatis = new FrmBSQStatis(globeControl1,null); + //FrmBSQStatis bsqStatis = new FrmBSQStatis(); bsqStatis.Show(this); } /// diff --git a/Cyberpipe.csproj b/Cyberpipe.csproj index 3a45ad8..d22f590 100644 --- a/Cyberpipe.csproj +++ b/Cyberpipe.csproj @@ -402,12 +402,6 @@ FrmBACKORACLE.cs - - Form - - - FrmBSQDuoBianXingStatis.cs - Form @@ -1271,9 +1265,6 @@ FrmBACKORACLE.cs - - FrmBSQDuoBianXingStatis.cs - FrmBSQStatis.cs diff --git a/FeatureStatisticsService.cs b/FeatureStatisticsService.cs index e833e5f..c7de210 100644 --- a/FeatureStatisticsService.cs +++ b/FeatureStatisticsService.cs @@ -273,19 +273,15 @@ /// 获取特定区域图层的管线列表,并将其总长度统计出来 /// TODOLIST:将Intersects_Pipeline在MainFrm中去除 /// - /// + /// + /// 要统计的长度 /// public static GSOFeatures getLayerPipes(GSOGeoPolygon3D polygon, GSOLayer layer, out double length) { length = 0; if (layer == null) return null; - GSOFeatureLayer flayer = layer as GSOFeatureLayer; - GSOFeatureDataset fdataset = flayer.Dataset as GSOFeatureDataset; - GSOFeatures feats = null; - - feats = polygon == null?flayer.GetAllFeatures():flayer.FindFeaturesInPolygon(polygon, false); - + GSOFeatures feats = getLayerFeatures(polygon, layer); double totallength = 0.00; for (int i = 0; i < feats.Length; i++) { @@ -301,5 +297,17 @@ return feats; } + /// + /// 获取区域图层内的feature列表,MainFrm.PolygonIntersectAnalysis和此方法重复,需要整理删除 + /// + /// + /// + /// + public static GSOFeatures getLayerFeatures(GSOGeoPolygon3D polygon, GSOLayer layer) + { + if (layer == null) return null; + GSOFeatureLayer flayer = layer as GSOFeatureLayer; + return polygon == null ? flayer.GetAllFeatures() : flayer.FindFeaturesInPolygon(polygon, false); + } } } diff --git a/FrmAllWorkWellStatis.cs b/FrmAllWorkWellStatis.cs index 7bf65dc..bd0f81b 100644 --- a/FrmAllWorkWellStatis.cs +++ b/FrmAllWorkWellStatis.cs @@ -19,17 +19,7 @@ private Dictionary map = null; private GSOGlobeControl globeControl1; private GSOGeoPolygon3D polygon; - //TODOLIST:用晓伟的代理进行操作,功能拆分细化 - //public FrmAllWorkWellStatis(GSOGeoPolygon3D polygon, DataGridView dataGridViewX11, ToolStripStatusLabel toolStripNumbers1, GSOGlobeControl ctl, PanelEx p) - //{ - // InitializeComponent(); - // panel = p; - // dataGridViewX1 = dataGridViewX11; - // toolStripNumbers = toolStripNumbers1; - // globeControl1 = ctl; - // map = getAccsMap(polygon); - //} public FrmAllWorkWellStatis(GSOGlobeControl ctl,GSOGeoPolygon3D polygon, MainFrm.DataGridViewDelegate InitDataGridViewX1) { InitializeComponent(); @@ -117,8 +107,9 @@ sql = "select " + getpipeLineFields.getFields(layername, globeControl1) + " from " + layer.Name; sql += " where 1>2 "; - for (int i = 0; i < fs.Length && fs[i].GetFieldDefn("编号") != null; i++) + for (int i = 0; i < fs.Length; i++) { + if (fs[i].GetFieldDefn("编号") == null) continue; sql += " or 编号 = '" + fs[i].GetValue("编号").ToString() + "'"; } diff --git a/FrmBSQDuoBianXingStatis.Designer.cs b/FrmBSQDuoBianXingStatis.Designer.cs deleted file mode 100644 index bda6842..0000000 --- a/FrmBSQDuoBianXingStatis.Designer.cs +++ /dev/null @@ -1,87 +0,0 @@ -namespace Cyberpipe -{ - partial class FrmBSQDuoBianXingStatis - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea1 = new System.Windows.Forms.DataVisualization.Charting.ChartArea(); - this.groupBox1 = new System.Windows.Forms.GroupBox(); - this.chart1 = new System.Windows.Forms.DataVisualization.Charting.Chart(); - this.groupBox1.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.chart1)).BeginInit(); - this.SuspendLayout(); - // - // groupBox1 - // - this.groupBox1.Controls.Add(this.chart1); - this.groupBox1.Dock = System.Windows.Forms.DockStyle.Fill; - this.groupBox1.Location = new System.Drawing.Point(0, 0); - this.groupBox1.Name = "groupBox1"; - this.groupBox1.Size = new System.Drawing.Size(592, 384); - this.groupBox1.TabIndex = 0; - this.groupBox1.TabStop = false; - this.groupBox1.Text = "统计结果信息"; - // - // chart1 - // - chartArea1.AxisX.MajorGrid.Enabled = false; - chartArea1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(191)))), ((int)(((byte)(219)))), ((int)(((byte)(255))))); - chartArea1.BackGradientStyle = System.Windows.Forms.DataVisualization.Charting.GradientStyle.TopBottom; - chartArea1.Name = "ChartArea1"; - this.chart1.ChartAreas.Add(chartArea1); - this.chart1.Dock = System.Windows.Forms.DockStyle.Fill; - this.chart1.Location = new System.Drawing.Point(3, 17); - this.chart1.Name = "chart1"; - this.chart1.Size = new System.Drawing.Size(586, 364); - this.chart1.TabIndex = 0; - this.chart1.Text = "chart1"; - // - // FrmBSQDuoBianXingStatis - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(592, 384); - this.Controls.Add(this.groupBox1); - this.DoubleBuffered = true; - this.Name = "FrmBSQDuoBianXingStatis"; - this.ShowIcon = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; - this.Text = "多边形区域统计"; - this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FrmBSQDuoBianXingStatis_FormClosing); - this.Load += new System.EventHandler(this.FrmBSQDuoBianXingStatis_Load); - this.groupBox1.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)(this.chart1)).EndInit(); - this.ResumeLayout(false); - - } - - #endregion - - private System.Windows.Forms.GroupBox groupBox1; - private System.Windows.Forms.DataVisualization.Charting.Chart chart1; - } -} \ No newline at end of file diff --git a/FrmBSQDuoBianXingStatis.cs b/FrmBSQDuoBianXingStatis.cs deleted file mode 100644 index 80b567e..0000000 --- a/FrmBSQDuoBianXingStatis.cs +++ /dev/null @@ -1,179 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Windows.Forms; -using DevComponents.DotNetBar; -using System.Data.SqlClient; -using System.Windows.Forms.DataVisualization.Charting; -using GeoScene.Data; -using GeoScene.Engine; -using GeoScene.Globe; -using System.Data.OracleClient; - -namespace Cyberpipe -{ - public partial class FrmBSQDuoBianXingStatis : Office2007Form - { - Dictionary bsq = new Dictionary(); - Dictionary bsq1 = new Dictionary(); - static FrmBSQDuoBianXingStatis frm; - GSOGlobeControl globeControl1; - List list = new List(); - public static List pipeLists = new List(); - - string[] codeStr = new string[50]; - string[] nameStr = new string[30]; - public static List typeLists; - - public FrmBSQDuoBianXingStatis(Dictionary workWellLen, GSOGlobeControl glb,List _list) - { - InitializeComponent(); - bsq = workWellLen; - globeControl1 = glb; - list = _list; - } - - private void FrmBSQDuoBianXingStatis_Load(object sender, EventArgs e) - { - FrmBSQDuoBianXingStatisFenLei(); - try - { - chart1.Series.Add("标识器"); - chart1.ChartAreas["ChartArea1"].AxisX.Title = "标识器类型"; - chart1.ChartAreas["ChartArea1"].AxisY.Title = "标识器数量"; - chart1.ChartAreas["ChartArea1"].AxisX.Interval = 1; - chart1.Series["标识器"].ChartType = SeriesChartType.Column; - chart1.Series["标识器"]["DrawingStyle"] = "Cylinder"; - - chart1.Series["标识器"].Points.DataBindXY(bsq1.Keys, bsq1.Values); - if (bsq1.Values.Count == 0) - { - MessageBox.Show("该区域没有标识器信息", "提示"); - this.Close(); - return; - } - else - { - for (int m = 0; m < bsq1.Values.Count; m++) - { - if (chart1.Series["标识器"].Points[m].YValues[0].ToString() != "0") - { - chart1.Series["标识器"].Points[m].Label = chart1.Series[0].Points[m].YValues[0].ToString(); - } - } - } - } - catch (Exception ex) - { - //ErrorLog.PublishError(ex); - } - } - - private void FrmBSQDuoBianXingStatis_FormClosing(object sender, FormClosingEventArgs e) - { - frm = null; - globeControl1.Globe.ClearAnalysis(); - globeControl1.Globe.MemoryLayer.RemoveAllFeature(); - } - - - private void FrmBSQDuoBianXingStatisFenLei() - { - try - { - bool flag2 = false; - for (int i = 0; i < Utility.listPipelineType.Count; i++) - { - - for (int j = 0; j < pipeLists.Count; j++) - { - if (pipeLists[j] == Utility.listPipelineType[i].type) - { - flag2 = true; - break; - } - } - if (!flag2 && Utility.listPipelineType[i].type != "标识器") - { - pipeLists.Add(Utility.listPipelineType[i].type); - } - flag2 = false; - } - - typeLists = new List(); - for (int num = 0; num < pipeLists.Count; num++) - { - typeList ls = new typeList(0, pipeLists[num]); - typeLists.Add(ls); - } - - GSOFeatures fs = list[0]; - string pipetype = "标识器"; - foreach (string key in bsq.Keys) - { - if (key.StartsWith(pipetype)) - { - pipetype = key; - break; - } - } - if (fs.Length > 0) - { - for (int i = 0; i < fs.Length; i++) - { - string str = fs[i].GetValue("对象名称").ToString(); - codeStr = str.Split(','); - for (int n = 0; n < codeStr.Length; n++) - { - for (int ii = 0; ii < Utility.listPipelineType.Count; ii++) - { - if (Utility.listPipelineType[ii].code == codeStr[n]) - { - for (int m = 0; m < typeLists.Count; m++) - { - if (Utility.listPipelineType[ii].type == typeLists[m].type) - { - typeLists[m].num++; - break; - } - } - break; - } - } - } - } - } - - for (int i = 0; i < typeLists.Count; i++) - { - if (typeLists[i].num > 0) - bsq1.Add(typeLists[i].type, typeLists[i].num); - } - - } - catch (Exception ex) - { - //ErrorLog.PublishError(ex); - //MessageBox.Show(ex.Message); - } - - } - public class typeList - { - public int num; - public string type; - - public typeList(int _num, string _type) - { - num = _num; - type = _type; - } - } - - - } -} diff --git a/FrmBSQDuoBianXingStatis.resx b/FrmBSQDuoBianXingStatis.resx deleted file mode 100644 index 1af7de1..0000000 --- a/FrmBSQDuoBianXingStatis.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/FrmBSQStatis.Designer.cs b/FrmBSQStatis.Designer.cs index 2509c7d..ee9b1e7 100644 --- a/FrmBSQStatis.Designer.cs +++ b/FrmBSQStatis.Designer.cs @@ -57,6 +57,7 @@ this.ShowIcon = false; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "标识器全区域统计"; + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FrmBSQStatis_FormClosing); this.Load += new System.EventHandler(this.FrmBSQStatis_Load); ((System.ComponentModel.ISupportInitialize)(this.chartStatis)).EndInit(); this.ResumeLayout(false); diff --git a/FrmBSQStatis.cs b/FrmBSQStatis.cs index 4b25eda..e7c4926 100644 --- a/FrmBSQStatis.cs +++ b/FrmBSQStatis.cs @@ -18,94 +18,18 @@ { public partial class FrmBSQStatis : Office2007Form { - public Dictionary bsq = new Dictionary(); - //SqlConnection conn; - public static List typeLists; - OracleConnection conn; - string connectString; + private Dictionary bsq = new Dictionary(); + private GSOGlobeControl globeControl1; + private GSOGeoPolygon3D polygon; - public FrmBSQStatis() + public FrmBSQStatis(GSOGlobeControl globeControl1,GSOGeoPolygon3D polygon) { + this.globeControl1 = globeControl1; + this.polygon = polygon; InitializeComponent(); - BSQNumStatis(); + bsq = getBSQNameAndNumMap(polygon); } - string[] codeStr = new string[50]; - string[] nameStr = new string[30]; - public static List pipeLists = new List(); - - private void BSQNumStatis() - { - bool flag2 = false; - for (int i = 0; i < Utility.listPipelineType.Count; i++) - { - for (int j = 0; j < pipeLists.Count; j++) - { - if (pipeLists[j] == Utility.listPipelineType[i].type) - { - flag2 = true; - break; - } - } - if (!flag2 && Utility.listPipelineType[i].type != "标识器") - { - pipeLists.Add(Utility.listPipelineType[i].type); - } - flag2 = false; - } - - typeLists = new List(); - for (int num = 0; num 0) - bsq.Add(typeLists[i].type, typeLists[i].num); - } - - } - catch (Exception ex) - { - - } - } private void FrmBSQStatis_Load(object sender, EventArgs e) { @@ -136,17 +60,88 @@ } } - public class typeList + private Dictionary getBSQNameAndNumMap(GSOGeoPolygon3D polygon) { - public int num; - public string type; - public typeList(int _num, string _type) + Dictionary result = new Dictionary(); + Dictionary codeAndType = new Dictionary(); + //得到type的种类 + for (int i = 0; i < Utility.listPipelineType.Count; i++) { - num = _num; - type = _type; + if (!result.ContainsKey(Utility.listPipelineType[i].type) && Utility.listPipelineType[i].type != "标识器") + { + result.Add(Utility.listPipelineType[i].type, 0); + codeAndType.Add(Utility.listPipelineType[i].code, Utility.listPipelineType[i].type); + } + } + + return polygon == null ? getAllAreaMap(result, codeAndType) : getBSQMapByPolygon(polygon, result, codeAndType); + } + public Dictionary getAllAreaMap(Dictionary typeAndCount,Dictionary codeAndType) + { + try + { + OracleConnection conn = OledbHelper.sqlConnection(); + conn.Open(); + OracleCommand cmd; + cmd = new OracleCommand("select 对象类型 from 标识器", conn); + OracleDataReader dr = cmd.ExecuteReader(); + + while (dr.Read()) + { + string str = Convert.ToString(dr["对象类型"]); + if (str == null) continue; + foreach (string key in codeAndType.Keys) + { + if (str.Contains(key)) + { + typeAndCount[codeAndType[key]] += 1; + } + } + } + conn.Close(); + } + catch (Exception ex) + { + LogHelper.WriteLog(typeof(FrmBSQStatis),ex.Message.ToString()); + } + return typeAndCount; + } + + + public Dictionary getBSQMapByPolygon(GSOGeoPolygon3D polygon,Dictionary typeAndCount, Dictionary codeAndType) + { + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption("标识器"); + GSOFeatures bsqFs = FeatureStatisticsService.getLayerFeatures(polygon, layer); + if (bsqFs == null || bsqFs.Length <= 0) { + LogHelper.WriteLog(typeof(FrmBSQStatis),"标识器图层下的Feature为空"); + return null; + } + + for (int i = 0; i < bsqFs.Length; i++) + { + string str = bsqFs[i].GetValue("对象类型").ToString(); + + foreach (string key in codeAndType.Keys) + { + if (str.Contains(key)) + { + typeAndCount[codeAndType[key]] += 1; + } + } + } + + return typeAndCount; + } + + private void FrmBSQStatis_FormClosing(object sender, FormClosingEventArgs e) + { + globeControl1.Globe.ClearAnalysis(); + } + + } } diff --git a/FrmValveStatistics.cs b/FrmValveStatistics.cs index 672f97a..17dad6c 100644 --- a/FrmValveStatistics.cs +++ b/FrmValveStatistics.cs @@ -120,6 +120,7 @@ sql += " where 1>2 "; for (int i = 0; i < fs.Length; i++) { + if (fs[i].GetValue("编号") == null) continue; sql += " or 编号 = '" + fs[i].GetValue("编号").ToString() + "'"; } diff --git a/FrmpipeDeepstatis.cs b/FrmpipeDeepstatis.cs index 879801a..c7edbc3 100644 --- a/FrmpipeDeepstatis.cs +++ b/FrmpipeDeepstatis.cs @@ -164,88 +164,6 @@ } } - //if (clbPipeLine.CheckedItems.Count > 0) - //{ - // if (dataGridViewX2.Rows.Count > 0) - // { - // for (int i = 0; i < clbPipeLine.CheckedItems.Count; i++) - // { - // GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(clbPipeLine.CheckedItems[i].ToString()); - // GSOFeatureLayer flayer = layer as GSOFeatureLayer; - // GSOFeatures feats = new GSOFeatures(); - // if (polygon == null) - // feats = flayer.GetAllFeatures(); - // else - // feats = flayer.FindFeaturesInPolygon(polygon, false); - // for (int j = 0; j < dataGridViewX2.Rows.Count; j++) - // { - // double totalLength = 0.00; - // int ncount = 0; - // for (int m = 0; m < feats.Length; m++) - // { - // GSOFeature feat = feats[m]; - // float radius = feat.GetFieldAsFloat("起始埋深"); - // bool upCompare = true; - // bool downCompare = true; - // if (dataGridViewX2.Rows[j].Cells["下限"].Value != null || dataGridViewX2.Rows[j].Cells["上限"].Value != null) - // { - // if (dataGridViewX2.Rows[j].Cells["下限"].Value != null) - // { - // if (dataGridViewX2.Rows[j].Cells["下限"].Value.ToString() != "") - // { - // if (radius >= Convert.ToDouble(dataGridViewX2.Rows[j].Cells["下限"].Value)) - // { - // downCompare = true; - // } - // else - // downCompare = false; - // } - // } - // if (dataGridViewX2.Rows[j].Cells["上限"].Value != null) - // { - // if (dataGridViewX2.Rows[j].Cells["上限"].Value.ToString() != "") - // { - // if (radius <= Convert.ToDouble(dataGridViewX2.Rows[j].Cells["上限"].Value)) - // { - // upCompare = true; - // } - // else - // upCompare = false; - // } - // } - // if (upCompare && downCompare) - // { - // GSOGeoPolyline3D line = feat.Geometry as GSOGeoPolyline3D; - // double length = line.GetSpaceLength(true, 6378137); - // totalLength += length; - // ncount += 1; - // } - // } - // } - // if (dataGridViewX2.Rows[j].Cells["下限"].Value != null || dataGridViewX2.Rows[j].Cells["上限"].Value != null) - // { - // DataGridViewRow row = new DataGridViewRow(); - // int index = dataGridViewX1.Rows.Add(row); - // row = dataGridViewX1.Rows[index]; - // row.Cells["图层名称"].Value = layer.Caption; - // row.Cells["埋深范围"].Value = dataGridViewX2.Rows[j].Cells["下限"].Value + "-" + dataGridViewX2.Rows[j].Cells["上限"].Value; - // row.Cells["条数"].Value = ncount; - // row.Cells["总长度"].Value =Math.Round(totalLength,2); - - // dic.Add(layer.Caption + "," + row.Cells["埋深范围"].Value.ToString()+","+row.Cells["总长度"].Value.ToString(), ncount); - // } - // } - // } - // } - // else - // { - // MessageBox.Show("请添加分段!"); - // } - //} - //else - //{ - // MessageBox.Show("请选择图层!"); - //} showPipeWidget(); } catch (Exception ex) diff --git a/FrmpipeMaterialGather.cs b/FrmpipeMaterialGather.cs index b7ab1d2..3e9f45d 100644 --- a/FrmpipeMaterialGather.cs +++ b/FrmpipeMaterialGather.cs @@ -180,79 +180,6 @@ } - //if (clbPipeLine.CheckedItems.Count > 0) - //{ - // for (int i = 0; i < clbPipeLine.CheckedItems.Count; i++) - // { - // GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(clbPipeLine.CheckedItems[i].ToString()); - // GSOFeatureLayer flayer = layer as GSOFeatureLayer; - // GSOFeatures feats = new GSOFeatures(); - // if (polygon == null) - // feats = flayer.GetAllFeatures(); - // else - // feats = flayer.FindFeaturesInPolygon(polygon, false); - // List lstDiameter = new List(); - - // for (int j = 0; j < clbmaterials.CheckedItems.Count; j++) - // { - // if (!lstDiameter.Contains(clbmaterials.CheckedItems[j].ToString())) - // { - // lstDiameter.Add(clbmaterials.CheckedItems[j].ToString()); - // } - // } - // //lstDiameter.Sort(); - // if (lstDiameter.Count > 0) - // { - // for (int m = 0; m < lstDiameter.Count; m++) - // { - // double totalLength = 0.00; - // int ncount = 0; - // for (int j = 0; j < feats.Length; j++) - // { - // if (lstDiameter[m] != "无") - // { - // if (feats[j].GetFieldAsString("材质") == lstDiameter[m]) - // { - // GSOGeoPolyline3D line = feats[j].Geometry as GSOGeoPolyline3D; - // if (line != null) - // { - // double length = line.GetSpaceLength(true, 6378137); - // totalLength += length; - // ncount += 1; - // } - // } - // } - // else - // { - // if (feats[j].GetFieldAsString("材质") == "") - // { - // GSOGeoPolyline3D line = feats[j].Geometry as GSOGeoPolyline3D; - // if (line != null) - // { - // double length = line.GetSpaceLength(true, 6378137); - // totalLength += length; - // ncount += 1; - // } - // } - // } - // } - // DataGridViewRow row = new DataGridViewRow(); - // int index = dataGridViewX1.Rows.Add(row); - // row = dataGridViewX1.Rows[index]; - // row.Cells["图层名称"].Value = layer.Caption; - // row.Cells["材质"].Value = lstDiameter[m]; - // row.Cells["条数"].Value = ncount; - // row.Cells["总长度"].Value = Math.Round(totalLength); - - // dic.Add(layer.Caption + "," + row.Cells["材质"].Value.ToString(), ncount); - // } - // } - // } - //} - //else - //{ - // MessageBox.Show("请选择图层!"); - //} showPipeWidget(); } catch (Exception ex) diff --git a/Frmpipediameterstatis.cs b/Frmpipediameterstatis.cs index 9953ac0..aa482d8 100644 --- a/Frmpipediameterstatis.cs +++ b/Frmpipediameterstatis.cs @@ -27,12 +27,9 @@ frm = new Frmpipediameterstatis(_globeControl1, pipeLayers, visibleId); frm.Show(_globeControl1.Parent); } - else + else if (frm.WindowState == FormWindowState.Minimized) { - if (frm.WindowState == FormWindowState.Minimized) - { - frm.WindowState = FormWindowState.Normal; - } + frm.WindowState = FormWindowState.Normal; } } @@ -208,7 +205,8 @@ } catch (Exception ex) { - MessageBox.Show(ex.Message); + LogHelper.WriteLog(typeof(Frmpipediameterstatis), ex.Message); + //MessageBox.Show(ex.Message); LogError.PublishError(ex); } } @@ -290,76 +288,77 @@ /// private void btnExport_Click(object sender, EventArgs e) { - if (dataGridViewX1.Rows.Count > 0) + if (dataGridViewX1.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 = DateTime.Now.ToString("yyyyMMdd") + ".xls"; - if (dlg.ShowDialog() == DialogResult.OK) + MessageBox.Show("统计结果为空,请重新统计之后再导出Excel!", "提示"); + return; + } + + SaveFileDialog dlg = new SaveFileDialog(); + dlg.Filter = "Excel files (*.xls)|*.xls"; + dlg.FilterIndex = 0; + dlg.RestoreDirectory = true; + //dlg.CreatePrompt = true; + dlg.Title = "保存为Excel文件"; + dlg.FileName = 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 { - Stream myStream; - myStream = dlg.OpenFile(); - StreamWriter sw = new StreamWriter(myStream, System.Text.Encoding.GetEncoding(-0)); - string columnTitle = ""; - try + sw.WriteLine("日期:" + DateTime.Now.ToString("yyyy-MM-dd")); + + //写入列标题 + for (int i = 0; i < dataGridViewX1.ColumnCount; i++) { - sw.WriteLine("日期:" + DateTime.Now.ToString("yyyy-MM-dd")); - - //写入列标题 - for (int i = 0; i < dataGridViewX1.ColumnCount; i++) + if (i > 0) { - if (i > 0) - { - columnTitle += "\t"; - } - columnTitle += dataGridViewX1.Columns[i].HeaderText; + columnTitle += "\t"; } - sw.WriteLine(columnTitle); - - //写入列内容 - for (int j = 0; j < dataGridViewX1.Rows.Count; j++) - { - string columnValue = ""; - for (int k = 0; k < dataGridViewX1.Columns.Count; k++) - { - if (k > 0) - { - columnValue += "\t"; - } - if (dataGridViewX1.Rows[j].Cells[k].Value == null) - columnValue += ""; - else - columnValue += dataGridViewX1.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); - } + columnTitle += dataGridViewX1.Columns[i].HeaderText; } - catch (Exception ex) + sw.WriteLine(columnTitle); + + //写入列内容 + for (int j = 0; j < dataGridViewX1.Rows.Count; j++) { - MessageBox.Show(ex.ToString()); + string columnValue = ""; + for (int k = 0; k < dataGridViewX1.Columns.Count; k++) + { + if (k > 0) + { + columnValue += "\t"; + } + if (dataGridViewX1.Rows[j].Cells[k].Value == null) + columnValue += ""; + else + columnValue += dataGridViewX1.Rows[j].Cells[k].Value.ToString().Trim(); + } + + sw.WriteLine(columnValue); } - finally + sw.Close(); + myStream.Close(); + if (MessageBox.Show("导出Excel文件成功!是否打开?", "提示", MessageBoxButtons.YesNo) == DialogResult.Yes) { - sw.Close(); - myStream.Close(); + System.Diagnostics.Process.Start(dlg.FileName); } } + catch (Exception ex) + { + MessageBox.Show(ex.ToString()); + } + finally + { + sw.Close(); + myStream.Close(); + } } - else - { - MessageBox.Show("统计结果为空,请重新统计之后再导出Excel!","提示"); - } + + } /// /// 绘制区域分段统计 diff --git a/MainFrm.cs b/MainFrm.cs index 0b7e393..9bfb70e 100644 --- a/MainFrm.cs +++ b/MainFrm.cs @@ -2667,12 +2667,195 @@ FrmBaseLineProfillAnalysis dlg = new FrmBaseLineProfillAnalysis(globeControl1.Globe, e.Polyline); dlg.Show(this); globeControl1.Globe.ClearLastTrackPolyline(); + /* + FrmRoadHDM f = new FrmRoadHDM(); + f.Show() + * **/ } else { } trackPolylineEndMode = EnumTrackPolylineEndMode.Default_Analysis; + /* + ArrayList arraylistPoint = new ArrayList(); + ArrayList arraylistLine = new ArrayList(); + + // globeControl1.Globe.ClearLastTrackPolyline(); + + if (e.Polyline != null) + { + //横断面分析 + if (buttonItemFX2_1.Checked || buttonItemFX2_3.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 (buttonItemFX2_1.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 (buttonItemFX2_4.Checked) + { + FrmBaseLineProfillAnalysis dlg = new FrmBaseLineProfillAnalysis(globeControl1.Globe, e.Polyline); + dlg.Show(this); + globeControl1.Globe.ClearLastTrackPolyline(); + } + else if (buttonItemFX4_3.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(); + * **/ } #endregion @@ -2713,16 +2896,20 @@ case "valvequery": FrmValveStatistics frm = new FrmValveStatistics(globeControl1,polygon, new DataGridViewDelegate(InitDataGridViewX1)); frm.Show(this); + //panelEx6.Visible = true; + toolStripFeatureLength.Text = ""; globeControl1.Globe.Action = EnumAction3D.ActionNull; break; case "PipelineDistanceStatistics": + FrmAllPipelineStatis frm1 = new FrmAllPipelineStatis(globeControl1, polygon, new DataGridViewDelegate(InitDataGridViewX1), m_PipelineLayerNames); frm1.Show(this); globeControl1.Globe.Action = EnumAction3D.ActionNull; break; case "PipelineSpatialQuery": + FrmAllPipelineStatis.ShowForm(globeControl1,polygon,new DataGridViewDelegate(InitDataGridViewX1),m_PipelineLayerNames); globeControl1.Globe.ClearAnalysis(); globeControl1.Globe.Action = EnumAction3D.ActionNull; @@ -2771,18 +2958,19 @@ break; case "BSQDuoBianXiangStatis": - GSOFeature f2 = new GSOFeature(); - f2.Geometry = e.Polygon; - f2.Geometry.AltitudeMode = EnumAltitudeMode.Absolute; - globeControl1.Globe.MemoryLayer.AddFeature(f2); - f2.Geometry.MoveZ(3); - workWellLen.Clear(); - List listBSQ = new List(); + //GSOFeature f2 = new GSOFeature(); + //f2.Geometry = e.Polygon; + //f2.Geometry.AltitudeMode = EnumAltitudeMode.Absolute; + //globeControl1.Globe.MemoryLayer.AddFeature(f2); + //f2.Geometry.MoveZ(3); + //workWellLen.Clear(); + //List listBSQ = new List(); - GSOFeatures bsqFeatures = PolygonIntersectAnalysis(e.Polygon, "标识器"); - listBSQ.Add(bsqFeatures); + //GSOFeatures bsqFeatures = PolygonIntersectAnalysis(e.Polygon, "标识器"); + //listBSQ.Add(bsqFeatures); - FrmBSQDuoBianXingStatis bsqFrm = new FrmBSQDuoBianXingStatis(workWellLen, globeControl1, listBSQ); + //FrmBSQDuoBianXingStatis bsqFrm = new FrmBSQDuoBianXingStatis(workWellLen, globeControl1, listBSQ); + FrmBSQStatis bsqFrm = new FrmBSQStatis(globeControl1,e.Polygon); bsqFrm.Show(this); globeControl1.Globe.Action = EnumAction3D.ActionNull; break; @@ -4351,6 +4539,26 @@ } /// + /// 在窗体的底部状态栏上显示 综合管线条件查询结果 + /// + /// + /// + 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 + " 条记录 | "; + } + } + + /// /// 统计管线的里程数 /// /// @@ -6824,6 +7032,54 @@ } /// + /// 创建label要素 功能 + /// + /// 添加label要素的feature + /// feature的位置 + /// label要素名字 + /// feature名字 + /// label要素距离点的位置 + /// + 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; + } + + + + /// /// 获取指定两点组成的线的长度 功能 /// /// @@ -9266,8 +9522,19 @@ //日志记录 LogManager.saveLog(Utility.userName, "管线长度统计"); + //pipeLineDis.Clear(); + //List list = new List(); + //for (int i = 0; i < m_PipelineLayerNames.Count; i++) + //{ + // GSOFeatures fs = Intersects_Pipeline(null, m_PipelineLayerNames[i]); + // if (fs!=null) + // list.Add(fs); + //} + + //FrmAllPipelineStatis frm = new FrmAllPipelineStatis(0, pipeLineDis, list, globeControl1, new DataGridViewDelegate(InitDataGridViewX1)); FrmAllPipelineStatis frm = new FrmAllPipelineStatis(globeControl1,null, new DataGridViewDelegate(InitDataGridViewX1), m_PipelineLayerNames); frm.Show(this); + } /// /// 管线长度绘制区域统计 @@ -9293,6 +9560,25 @@ //日志记录 LogManager.saveLog(Utility.userName, "阀门数量统计"); + //workWellLen.Clear(); + //List list = new List(); + ////找到所有阀门 + //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, globeControl1, new DataGridViewDelegate(InitDataGridViewX1)); FrmValveStatistics frm = new FrmValveStatistics(globeControl1, null, new DataGridViewDelegate(InitDataGridViewX1)); frm.Show(this); @@ -9318,9 +9604,7 @@ /// /// private void buttonItemTJ3_ALL_Click(object sender, EventArgs e) - { - //日志记录 - LogManager.saveLog(Utility.userName, "井盖数量统计"); + { FrmAllWorkWellStatis frm = new FrmAllWorkWellStatis(globeControl1, null, new DataGridViewDelegate(InitDataGridViewX1)); frm.Show(this); } @@ -9333,7 +9617,7 @@ { //日志记录 LogManager.saveLog(Utility.userName, "井盖数量统计"); - + trackflag = "workwellquery"; globeControl1.Globe.Action = EnumAction3D.TrackPolygon; globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; @@ -11142,7 +11426,7 @@ Cyberpipe.Forms.FrmPipelineModelDB frm = new Cyberpipe.Forms.FrmPipelineModelDB(globeControl1, ds); if (frm.ShowDialog() == DialogResult.OK) { - //addNodeToLayerManagerNode(frm.rukuLayer); + addNodeToLayerManagerNode(frm.rukuLayer); } } /// @@ -12377,7 +12661,8 @@ private void 标识器分类统计ToolStripMenuItem_Click(object sender, EventArgs e) { globeControl1.Globe.Action = EnumAction3D.ActionNull; - FrmBSQStatis bsqStatis = new FrmBSQStatis(); + FrmBSQStatis bsqStatis = new FrmBSQStatis(globeControl1,null); + //FrmBSQStatis bsqStatis = new FrmBSQStatis(); bsqStatis.Show(this); } /// diff --git a/MainFrm.cs.BACKUP.9016.cs b/MainFrm.cs.BACKUP.9016.cs new file mode 100644 index 0000000..28cb7fa --- /dev/null +++ b/MainFrm.cs.BACKUP.9016.cs @@ -0,0 +1,13074 @@ +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; + + GSOBalloon featureTooltip2; + GSOBalloonEx balloonEx2; + + GSOLayer layerTemp; + GSOLayer layerTemp2; + FrmShResult frmShResult = null; + FrmRedlineResult frmredResult = null; + FrmMnModify frmModify = null; + public bool frmRedlineResult = false; + public bool boolfrmShResult = false; + public bool boolfrmModify = false; + + List m_PipelineLayerNames = new List();//线图层名称 + List workwellLayerNames = new List();//工井图层名称 + List valueLayerNames = new List();//阀门图层名称 + List instrumenLayerNames = new List();//附属物图层名称 + List pipefittingLayerNames = new List();//管件图层名称 + List sgPipeLayersNames = new List();//施工管线图层名称 + 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 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; + public string redLayer = null; + //GSOLayer redLayer1 = null; + bool redSH = false; + string redDt = "红线"; + //双屏对比 + //bool zhanshi=false; + Thread t = null; + private GSOHudButton legendSC;//定义图例 + private GSOHudButton legendSG;//定义图例 + //管纵图 + private GSOHudButton lendendGZ50; + private GSOHudButton lendendGZ36; + private GSOHudButton lendendGZ42; + private GSOHudButton lendendGZ24_1; + private GSOHudButton lendendGZ24_2; + private GSOHudButton lendendGZ24_3; + private GSOHudButton lendendGZ26; + + GSOGeoPoint3D bsqPT; + + FrmYJSHTC frmSh = null;//一键审核窗口全局变量wxl + FrmWait frmWait = null;//一键审核等待窗口 + //FrmWait frmWait2 = null;//文档操作等待窗口 + + float mouseDownX1,mouseDownY1; + float mouseDownX2,mouseDownY2; + /// + /// + /// + 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; + + featureTooltip2 = new GSOBalloon(globeControl2.Handle); + balloonEx2 = new GSOBalloonEx(globeControl2.Handle); + Utility.SetBallons(featureTooltip, balloonEx); + + panelOfTable.Height = 200; + + RigthMenuSet(); + + MenuSet(); + + } + /// + /// 右屏中添加管纵图片 + /// + private void AddGZ() + { + + lendendGZ50 = new GSOHudButton(); + lendendGZ50.SetImage(Application.StartupPath + "/Resource/管纵/50.png"); + lendendGZ50.SetOffset(0, 0); + lendendGZ50.MinOpaque = 1; + lendendGZ50.MaxOpaque = 1; + lendendGZ50.FadeOut = false; + lendendGZ50.Name = "lendendGZ50"; + lendendGZ50.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ50); + lendendGZ50.Visible = false; + + lendendGZ36 = new GSOHudButton(); + lendendGZ36.SetImage(Application.StartupPath + "/Resource/管纵/36.png"); + lendendGZ36.SetOffset(0, 0); + lendendGZ36.MinOpaque = 1; + lendendGZ36.MaxOpaque = 1; + lendendGZ36.FadeOut = false; + lendendGZ36.Name = "lendendGZ36"; + lendendGZ36.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ36); + lendendGZ36.Visible = false; + + lendendGZ42 = new GSOHudButton(); + lendendGZ42.SetImage(Application.StartupPath + "/Resource/管纵/42.png"); + lendendGZ42.SetOffset(0, 0); + lendendGZ42.MinOpaque = 1; + lendendGZ42.MaxOpaque = 1; + lendendGZ42.FadeOut = false; + lendendGZ42.Name = "lendendGZ42"; + lendendGZ42.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ42); + lendendGZ42.Visible = false; + + lendendGZ24_1 = new GSOHudButton(); + lendendGZ24_1.SetImage(Application.StartupPath + "/Resource/管纵/24_1.png"); + lendendGZ24_1.SetOffset(0, 0); + lendendGZ24_1.MinOpaque = 1; + lendendGZ24_1.MaxOpaque = 1; + lendendGZ24_1.FadeOut = false; + lendendGZ24_1.Name = "lendendGZ24_1"; + lendendGZ24_1.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ24_1); + lendendGZ24_1.Visible = false; + + lendendGZ24_2 = new GSOHudButton(); + lendendGZ24_2.SetImage(Application.StartupPath + "/Resource/管纵/24_2.png"); + lendendGZ24_2.SetOffset(0, 0); + lendendGZ24_2.MinOpaque = 1; + lendendGZ24_2.MaxOpaque = 1; + lendendGZ24_2.FadeOut = false; + lendendGZ24_2.Name = "lendendGZ24_2"; + lendendGZ24_2.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ24_2); + lendendGZ24_2.Visible = false; + + lendendGZ24_3 = new GSOHudButton(); + lendendGZ24_3.SetImage(Application.StartupPath + "/Resource/管纵/24_3.png"); + lendendGZ24_3.SetOffset(0, 0); + lendendGZ24_3.MinOpaque = 1; + lendendGZ24_3.MaxOpaque = 1; + lendendGZ24_3.FadeOut = false; + lendendGZ24_3.Name = "lendendGZ24_3"; + lendendGZ24_3.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ24_3); + lendendGZ24_3.Visible = false; + + lendendGZ26 = new GSOHudButton(); + lendendGZ26.SetImage(Application.StartupPath + "/Resource/管纵/26.png"); + lendendGZ26.SetOffset(0, 0); + lendendGZ26.MinOpaque = 1; + lendendGZ26.MaxOpaque = 1; + lendendGZ26.FadeOut = false; + lendendGZ26.Name = "lendendGZ26"; + lendendGZ26.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ26); + lendendGZ26.Visible = false; + + } + + public void RigthMenuSet() + { + if (Utility.userRole.IndexOf("清除分析") < 0) + { + toolRightMenu.Items.Remove(清除分析ToolStripMenuItem); + } + + #region 区域分析 + if (Utility.userRole.IndexOf("区域分析") < 0) + { + toolRightMenu.Items.Remove(区域分析ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("缓冲区分析") < 0) + { + 区域分析ToolStripMenuItem.DropDownItems.Remove(缓冲区分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("附属物分析") < 0) + { + 区域分析ToolStripMenuItem.DropDownItems.Remove(附属物分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("无源淹没分析") < 0) + { + 区域分析ToolStripMenuItem.DropDownItems.Remove(无源淹没分析ToolStripMenuItem); + } + } + #endregion + + #region 视域分析 + if (Utility.userRole.IndexOf("视域分析") < 0) + { + toolRightMenu.Items.Remove(视域分析ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("通视分析") < 0) + { + 视域分析ToolStripMenuItem.DropDownItems.Remove(通视分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("可视域分析") < 0) + { + 视域分析ToolStripMenuItem.DropDownItems.Remove(可视域分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("可视包络分析") < 0) + { + 视域分析ToolStripMenuItem.DropDownItems.Remove(可视包络分析ToolStripMenuItem); + } + } + #endregion + + #region 开发分析 + if (Utility.userRole.IndexOf("开挖分析") < 0) + { + toolRightMenu.Items.Remove(开挖分析ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("多边形开挖") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(多边形开挖ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("挖方量分析") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(挖方量分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("沿线开挖") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(沿线开挖ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("创建隧道") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(创建隧道ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("隐藏隧道") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(隐藏隧道ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("删除隧道") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(删除隧道ToolStripMenuItem); + } + } + #endregion + + #region 拓扑分析 + if (Utility.userRole.IndexOf("拓扑分析") < 0) + { + toolRightMenu.Items.Remove(拓扑分析ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("创建拓扑") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(创建拓扑ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("上游分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(上游分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("下游分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(下游分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("流向分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(流向分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("关阀分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(关阀分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("连通分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(连通分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("爆管分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(爆管分析ToolStripMenuItem); + } + } + #endregion + + #region 断面分析 + if (Utility.userRole.IndexOf("断面分析") < 0) + { + toolRightMenu.Items.Remove(断面分析ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("横断面分析") < 0) + { + 断面分析ToolStripMenuItem.DropDownItems.Remove(横断面分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("纵断面分析") < 0) + { + 断面分析ToolStripMenuItem.DropDownItems.Remove(纵断面分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("道路断面分析") < 0) + { + 断面分析ToolStripMenuItem.DropDownItems.Remove(道路断面分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("基线剖面分析") < 0) + { + 断面分析ToolStripMenuItem.DropDownItems.Remove(基线剖面分析ToolStripMenuItem); + } + } + #endregion + + #region 绘制区域统计 + if (Utility.userRole.IndexOf("绘制区域统计") < 0) + { + toolRightMenu.Items.Remove(绘制区域统计ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("绘制区域管线长度统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管线长度统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域阀门数量统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(阀门数量统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域井盖数量统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(井盖数量统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域管径分段统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管径分段统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域埋深分段统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(埋深分段统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域管径分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管径分类统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域材质分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(材质分类统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域附属物分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(附属物分类统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域标识器分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(标识器分类统计ToolStripMenuItem1); + } + + } + #endregion + + #region 全区域统计 + if (Utility.userRole.IndexOf("全区域统计") < 0) + { + toolRightMenu.Items.Remove(全区域统计ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("全区域管线长度统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管线长度统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域阀门数量统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(阀门数量统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域井盖数量统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(井盖数量统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域管径分段统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管径分段统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域埋深分段统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(埋深分段统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域管径分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管径分类统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域材质分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(材质分类统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域附属物分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(附属物分类统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域标识器分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(标识器分类统计ToolStripMenuItem); + } + + } + #endregion + + #region 查询 + if (Utility.userRole.IndexOf("查询") < 0) + { + toolRightMenu.Items.Remove(查询ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("空间查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(空间查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("编号查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(编号查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("坐标查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(坐标查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("管径查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(管径查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("材质查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(材质查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("基本查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(基本查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("复合查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(复合查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("关联查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(关联查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("关键字查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(关键字查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("附属物查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(附属物查询ToolStripMenuItem); + } + } + #endregion + + #region 标注 + if (Utility.userRole.IndexOf("标注") < 0) + { + toolRightMenu.Items.Remove(标注ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("标高标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(标高标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("管径标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(管径标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("埋深标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(埋深标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("坐标标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(坐标标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("距离标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(距离标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("自定义标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(自定义标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("扯旗标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(扯旗标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("坡度标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(坡度标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("属性标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(属性标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("标注管理") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(标注管理ToolStripMenuItem); + } + } + #endregion + + #region 飞行 + if (Utility.userRole.IndexOf("飞行") < 0) + { + toolRightMenu.Items.Remove(飞行ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("自定义飞行") < 0) + { + 飞行ToolStripMenuItem.DropDownItems.Remove(自定义飞行ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("飞行到目标点") < 0) + { + 飞行ToolStripMenuItem.DropDownItems.Remove(飞行到目标点ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("绕中心点飞行") < 0) + { + 飞行ToolStripMenuItem.DropDownItems.Remove(绕中心点飞行ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("绕眼睛飞行") < 0) + { + 飞行ToolStripMenuItem.DropDownItems.Remove(绕眼睛飞行ToolStripMenuItem); + } + } + #endregion + + #region 编辑 + if (Utility.userRole.IndexOf("编辑") < 0) + { + toolRightMenu.Items.Remove(编辑ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("平移对象") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(平移对象ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("升降对象") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(升降对象ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("旋转对象") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(旋转对象ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("连接管段") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(连接管段ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("导出文件") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(导出文件ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("前进") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(前进ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("后退") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(删除模型ToolStripMenuItem); + } + } + #endregion + + #region 量算 + if (Utility.userRole.IndexOf("量算") < 0) + { + toolRightMenu.Items.Remove(量算ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("水平距离") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(水平距离ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("垂直距离") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(垂直距离ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("空间距离") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(空间距离ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("地表距离") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(地表距离ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("高度量算") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(高度量算ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("水平面积") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(水平面积ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("地表面积") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(地表面积ToolStripMenuItem1); + } + } + #endregion + } + + public void MenuSet() + { + + #region 权限管理 + if (Utility.userRole.IndexOf("权限管理") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem2); + } + else + { + + if (Utility.userRole.IndexOf("用户管理") < 0) + { + btn_user_info.Visible = false; + } + if (Utility.userRole.IndexOf("角色管理") < 0) + { + btn_role_info.Visible = false; + } + if (Utility.userRole.IndexOf("资源管理") < 0) + { + btn_resc_info.Visible = false; + } + if (Utility.userRole.IndexOf("角色授权") < 0) + { + btn_role_resc.Visible = false; + } + if (Utility.userRole.IndexOf("用户授权") < 0) + { + btn_user_role.Visible = false; + } + if (Utility.userRole.IndexOf("密码修改") < 0) + { + btn_password_edit.Visible = false; + } + + } + #endregion + + #region 基础工具 + if (Utility.userRole.IndexOf("基础工具") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem1); + } + else + { + if (Utility.userRole.IndexOf("地上模式") < 0) + { + buttonItem87.Visible = false; + } + if (Utility.userRole.IndexOf("地下模式") < 0) + { + buttonItem88.Visible = false; + } + if (Utility.userRole.IndexOf("行走模式") < 0) + { + buttonItem27.Visible = false; + } + if (Utility.userRole.IndexOf("透明度设置") < 0) + { + sliderGroundTransSet1.Visible = false; + } + if (Utility.userRole.IndexOf("快速定位") < 0) + { + buttonItem91.Visible = false; + } + if (Utility.userRole.IndexOf("图层管理") < 0) + { + buttonItem1.Visible = false; + } + if (Utility.userRole.IndexOf("图例管理") < 0) + { + btnlegendSet.Visible = false; + } + if (Utility.userRole.IndexOf("全屏显示") < 0) + { + buttonItem89.Visible = false; + } + if (Utility.userRole.IndexOf("导出图片") < 0) + { + btnOutputJPG.Visible = false; + } + + } + #endregion + + #region 一键审核 + if (Utility.userRole.IndexOf("一键审核") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem11); + } + #endregion + + #region 红线审核 + if (Utility.userRole.IndexOf("红线审核") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem6); + } + #endregion + + #region 双屏对比 + if (Utility.userRole.IndexOf("双屏对比") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem9); + } + #endregion + + #region 文档管理 + if (Utility.userRole.IndexOf("文档管理") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem4); + } + #endregion + + #region 基础管理 + if (Utility.userRole.IndexOf("基础管理") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem14); + } + else + { + if (Utility.userRole.IndexOf("专题图审批") < 0) + { + buttonItemZTT3_2.Visible = false; + } + if (Utility.userRole.IndexOf("打印审批") < 0) + { + buttonItemZTT4_2.Visible = false; + } + if (Utility.userRole.IndexOf("拷贝审批") < 0) + { + buttonItemZTT5_2.Visible = false; + } + } + + #endregion + + if (ribbonControl1.Items.Count <= 0) + { + ribbonControl1.Visible = false; + } + } + + #region Fan Zhang 重构现有代码 + //初始化控件布局 + private void initLayout() + { + 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.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.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.labelX21.Width = (int)(this.labelX21.Width * myScreen); + this.labelX22.Width = (int)(this.labelX22.Width * myScreen); + this.labelX24.Width = (int)(this.labelX24.Width * myScreen); + } + sideBar1.Visible = false; + 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]); + } + + splitContainer1.Panel2Collapsed = true; + + buttonItem87.Checked = true;//默认地上模式 + ribbonTabItem1.Select(); //初始化状态为浏览 + + sideBarPanelItem3.Visible = false; + layerTree.Visible = false; + controlContainerItem3.Visible = false; + if (sideBarPanelItem4.Visible == true) + { + sideBar1.Visible = true; + controlContainerItem5.Visible = true; + } + else + { + sideBar1.Visible = false; + } + Refresh(); + sliderGroundTransSet1.Value = optiValue; + sliderItem1.Value = optiValue; + sliderItem2.Value = optiValue; + sliderItem3.Value = optiValue; + + } + + //初始化地球控件 + private void initGlobalControl() + { + //选择 + btnToolSelect = new GSOHudButton(); + btnToolSelect.SetImage(Application.StartupPath + "\\Resource\\image\\select1.png"); + btnToolSelect.FadeOut = false; + btnToolSelect.Align = EnumAlign.TopLeft; + btnToolSelect.SetOffset(20, 50); + btnToolSelect.Name = "1"; + btnToolSelect.HeightFixed = true; + btnToolSelect.WidthFixed = true; + globeControl1.Globe.AddHudControl(btnToolSelect); + globeControl2.Globe.AddHudControl(btnToolSelect); + + //浏览 + 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); + + //图例 + legend = new GSOHudButton(); + legend.SetImage(Application.StartupPath + "/Resource/图例P.jpg");//图例P + legend.SetOffset(0, 15); + legend.MinOpaque = 1; + legend.MaxOpaque = 1; + legend.FadeOut = false; + legend.Name = "legend"; + legend.Align = EnumAlign.BottomRight; + legend.Visible = false; + globeControl1.Globe.AddHudControl(legend); + + //实测 + legendSC = new GSOHudButton(); + legendSC.SetImage(Application.StartupPath + "/Resource/sc.jpg"); + legendSC.SetOffset(0, 15); + legendSC.MinOpaque = 1; + legendSC.MaxOpaque = 1; + legendSC.FadeOut = false; + legendSC.Name = "legendSC"; + legendSC.Align = EnumAlign.BottomRight; + globeControl1.Globe.AddHudControl(legendSC); + legendSC.Visible = false; + + //施工 + legendSG = new GSOHudButton(); + legendSG.SetImage(Application.StartupPath + "/Resource/sg.jpg"); + legendSG.SetOffset(0, 15); + legendSG.MinOpaque = 1; + legendSG.MaxOpaque = 1; + legendSG.FadeOut = false; + legendSG.Name = "legendSG"; + legendSG.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(legendSG); + legendSG.Visible = false; + + //管纵 + AddGZ(); + + 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; + globeControl1.Globe.IsReleaseMemOutOfView = true; + globeControl1.Globe.ControlPanel.Visible = true; + + globeControl2.Globe.UnderGroundFloor.Visible = false; + globeControl2.Globe.OverviewControl.Visible = false; + globeControl2.Globe.ScalerControl.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; + globeControl2.Globe.IsReleaseMemOutOfView = true; + globeControl2.Globe.ControlPanel.Visible = false; + + 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); + + //添加临时图层 + layerTemp = globeControl1.Globe.Layers.Add(Application.StartupPath + "\\tempLgdData.lgd"); + layerTemp2 = globeControl2.Globe.Layers.Add(Application.StartupPath + "\\tempLgdData2.lgd"); + if (layerTemp != null) + { + layerTemp.MaxVisibleAltitude = 1000; + } + + //添加城市7线图层 + 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"); + + //注册对应事件 + this.registerEvent(); + } + + //注册地球事件 + private bool registerEvent() + { + if (globeControl1 == null || globeControl2 == null) + { + return false; + } + 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); + + globeControl2.FeatureMouseClickEvent += new FeatureMouseClickEventHandler(globeControl2_FeatureMouseClickEvent); + globeControl2.CameraBeginMoveEvent += new CameraBeginMoveEventHandler(globeControl2_CameraBeginMoveEvent); + + globeControl1.MouseDoubleClick += new MouseEventHandler(globeControl1_MouseDoubleClick); + globeControl1.MouseClick += new MouseEventHandler(globeControl1_MouseClick); + globeControl1.MouseDown += new MouseEventHandler(globeControl1_MouseDown); + + globeControl2.MouseClick += new MouseEventHandler(globeControl2_MouseClick); + globeControl2.MouseDown += new MouseEventHandler(globeControl2_MouseDown); + + 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); + + return true; + } + + //加载两个地球数据 + private void loadData() + { + Thread t1 = new Thread(new ThreadStart(doLoadDataForGlobalControl1)); + t1.IsBackground = true; + t1.Start(); + + + } + + delegate void LoadDataForGlobalControl(); + + private void connectServer() + { + globeControl1.Globe.ConnectServer(Utility.serverip, Utility.serverport, "", ""); //加载locaServer中的数据 + globeControl2.Globe.ConnectServer(Utility.serverip, Utility.serverport, "", ""); //加载locaServer中的数据 + //初始化TreeView + // 勾选实测图层 + foreach (TreeNode tn in layerTree.Nodes) + { + if (tn.Nodes.Count > 0) + { + if (tn.Text == "实测数据") + { + tn.Checked = true; + foreach (TreeNode tnChild in tn.Nodes) + { + tnChild.Checked = true; + foreach (TreeNode tnGrandChild in tnChild.Nodes) + { + tnGrandChild.Checked = true; + } + } + } + } + } + } + + private void doLoadDataForGlobalControl1() + { + try + { + + globeControl1.Globe.Layers.MoveDown(10000); + //加载实测管线数据 + Utility.dataSource = globeControl1.Globe.DataManager.OpenOracleDataSource(Utility.DBServer.Trim() + "/" + Utility.dbdatabase.Trim(), "", "", Utility.userID, Utility.DBPassword); + + if (Utility.dataSource != null) + { + for (int j = 0; j < Utility.dataSource.DatasetCount; j++) + { + GSODataset dataset = Utility.dataSource.GetDatasetAt(j); + if (dataset != null && dictionaryNetLayerNameAndCaption.ContainsKey(dataset.Caption)) + { + dataset.Caption = dataset.Name; + globeControl1.Globe.Layers.Add(dataset); + } + } + } + //隐藏红线图层 + globeControl1.Globe.Layers.GetLayerByCaption("红线").Visible = false; + + //globleControl1中加载规划数据 + GSODataSource ghDS = globeControl1.Globe.DataManager.OpenOracleDataSource(Utility.ghdbip + "/" + Utility.ghdbname, "", "", Utility.ghdbuser, Utility.ghdbpwd); + if (ghDS != null) + { + for (int j = 0; j < ghDS.DatasetCount; j++) + { + GSODataset dataset = ghDS.GetDatasetAt(j); + if (dataset != null && dictionaryNetLayerNameAndCaption.ContainsKey(dataset.Caption)) + { + dataset.Caption = dataset.Name; + globeControl1.Globe.Layers.Add(dataset); + globeControl1.Globe.Layers[0].Visible = false; + } + } + } + + //globeControl1,globeControl2中加载施工数据 + GSODataSource sgDS = globeControl1.Globe.DataManager.OpenOracleDataSource(Utility.sgdbip + "/" + Utility.sgdbname, "", "", Utility.sgdbuser, Utility.sgdbpwd); + if (sgDS != null) + { + for (int m = 0; m < sgDS.DatasetCount; m++) + { + GSODataset dataset = sgDS.GetDatasetAt(m); + if (dataset != null && !dataset.Caption.Contains("SH") && dictionaryNetLayerNameAndCaption.ContainsKey(dataset.Caption)) + { + dataset.Caption = dataset.Name; + globeControl1.Globe.Layers.Add(dataset); + globeControl1.Globe.Layers[0].Visible = false; + + globeControl2.Globe.Layers.Add(dataset); + globeControl2.Globe.Layers[0].Visible = true; + } + } + } + + LoadDataForGlobalControl ss = new LoadDataForGlobalControl(connectServer); + ss(); + + } + catch (Exception ex) + { + MessageBox.Show(ex.Message); + } + } + + private void initLayerTree() + { + //加载临时图层节点 + layerManagerNode = new TreeNode(); + layerManagerNode.ImageIndex = 0; + layerManagerNode.SelectedImageIndex = 0; + layerManagerNode.Checked = true; + layerManagerNode.Text = "临时图层"; + layerTree.Nodes.Add(layerManagerNode); + + XmlDocument doc = new XmlDocument(); + doc.Load(filename); + XmlNodeList xmlLayerNodes = doc.SelectNodes("//layer"); + + foreach (XmlNode xmlLayerNode in xmlLayerNodes) + { + + //TODO LIST:创建一级TreeNode(实测、规划、施工) + TreeNode nodelayer = new TreeNode(); + string layerName = xmlLayerNode.Attributes["label"].Value; + nodelayer.Text = layerName; + nodelayer.Checked = false; + layerTree.Nodes.Add(nodelayer); + + XmlNodeList xmlChildLayerNodes = xmlLayerNode.ChildNodes; + foreach (XmlNode xmlChildLayerNode in xmlChildLayerNodes) + { + //TODO LIST:创建二级TreeNode节点 + TreeNode secondLevelNode = new TreeNode(); + string layerType = xmlChildLayerNode.Attributes["label"].Value; + secondLevelNode.Text = layerType; + + if (xmlChildLayerNode.Attributes["type"] != null) + { //道路图层特殊处理 + string type = xmlChildLayerNode.Attributes["type"].Value; + secondLevelNode.Tag = type + "|" + layerType; + } + else + { + secondLevelNode.Tag = layerType; + } + secondLevelNode.Checked = false; + nodelayer.Nodes.Add(secondLevelNode); + + XmlNodeList xmlActitualLayerNodes = xmlChildLayerNode.ChildNodes; + + foreach (XmlNode xmlActitualLayerNode in xmlActitualLayerNodes) + { + //TODO LIST:创建三级图层节点 + TreeNode layerNode = new TreeNode(); + string actutallylayerType = xmlActitualLayerNode.Attributes["type"].Value; + string actutallylayerName = xmlActitualLayerNode.Attributes["layer"].Value; + string actutallyLabelName = xmlActitualLayerNode.Attributes["label"].Value; + + layerNode.Text = actutallyLabelName; + layerNode.Tag = layerType + "|" + actutallyLabelName; + layerNode.Checked = false; + secondLevelNode.Nodes.Add(layerNode); + } + + } + + } + + } + + /** + * 读取Config.xml文件,初始化以下全局Map + * m_PipelineLayerNames:管线 + * workwellLayerNames:工井 + * valueLayerNames:阀门 + * instrumenLayerNames:附属物 + * pipefittingLayerNames:特征管点 + * sgPipeLayersNames:施工管线 + **/ + private void initGlobalMap() + { + XmlDocument doc = new XmlDocument(); + doc.Load(filename); + XmlNodeList xmlLayerNodes = doc.SelectNodes("//layerchild"); + + foreach (XmlNode xmlLayerNode in xmlLayerNodes) + { + string layerType = xmlLayerNode.Attributes["type"].Value; + string layerName1 = xmlLayerNode.Attributes["layer"].Value; + string layerchildName = xmlLayerNode.Attributes["label"].Value; + + dictionaryNetLayerNameAndCaption.Add(layerName1, layerchildName); + + if (layerType != "db") + { + if (xmlLayerNode.Attributes["isRoad"] != null) + { + roadLayerName = layerchildName; + } + } + else if (xmlLayerNode.Attributes["isPipeLine"] != null) + { + m_PipelineLayerNames.Add(layerchildName); + g1layername.Add(layerName1); + } + else if (xmlLayerNode.Attributes["isWorkWell"] != null) + { + workwellLayerNames.Add(layerchildName); + g1layername.Add(layerName1); + } + else if (xmlLayerNode.Attributes["isValve"] != null) + { + valueLayerNames.Add(layerchildName); + g1layername.Add(layerName1); + } + else if (xmlLayerNode.Attributes["isAccess"] != null) + { + instrumenLayerNames.Add(layerchildName); + g1layername.Add(layerName1); + } + else if (xmlLayerNode.Attributes["isCharacter"] != null) + { + pipefittingLayerNames.Add(layerchildName); + g1layername.Add(layerName1); + } + else if (xmlLayerNode.Attributes["isSgData"] != null) + { + sgPipeLayersNames.Add(layerchildName); + g1layername.Add(layerName1); + } + + } + } + + private void initMarkerTree() + { + 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); + } + } + } + } + + private void MainFrm_Load(object sender, EventArgs e) + { + + this.initGlobalControl(); + this.initGlobalMap(); + this.initLayerTree(); + this.initMarkerTree(); + this.initLayout(); + this.loadData(); + + + double x = Convert.ToDouble(Utility.Query_Roads["绿岛"].ToString().Split(',')[0]); + double y = Convert.ToDouble(Utility.Query_Roads["绿岛"].ToString().Split(',')[1]); + double z = Convert.ToDouble(Utility.Query_Roads["绿岛"].ToString().Split(',')[2]); + jumpToCameraState(x, y, z); + + + } + + #endregion + + /// + /// 每次gis服务加载时都会触发的 + /// + /// + /// + 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 dictionaryNetLayerNameAndCaption = new Dictionary(); + 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 配置用户权限 + /// + /// 向数据库插入功能列表 + /// + private void insertControlToDatabase() + { + ArrayList listItem = new ArrayList(); + List subListItem = new List(); + 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) + { + GSOCameraState camera = globeControl2.Globe.CameraState; + globeControl1.Globe.JumpToCameraState(camera); + } + } + + void globeControl1_BeforeSceneRenderEvent(object sender, BeforeSceneRenderEventArgs e) + { + if (globeControl1.Focused) + { + 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); + } + } + } + + /// + /// 检查数据集是否有坐标系信息 + /// + /// + /// + 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 = "0prj4" + lprjStr + ""; + + bSuccess = dataset.LoadProjectionFromESRIFile(dlg.FileName); + + string lprjFileName = strDataPath.Substring(0, strDataPath.LastIndexOf(".")) + ".lprj"; + StreamWriter writer = new StreamWriter(lprjFileName, false); + writer.Write(lprjFileContent); + writer.Close(); + + } + } + } + else + { + return true; + } + return bSuccess; + } + + /// + /// 矩形拉框结束事件处理函数 + /// + /// + /// + 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))); + */ + + int mapWidth = 0; + int mapHeight = 0; + Point pt = getUpperLeftPoint(pt1, pt2, out mapWidth, out mapHeight); + int rightBottomX = pt.X + mapWidth; + int rightBottomY = pt.Y + mapHeight; + Image myImg = new Bitmap(mapWidth, mapHeight); + Graphics g = Graphics.FromImage(myImg); + g.CopyFromScreen(pt, new Point(0, 0), new Size(rightBottomX, rightBottomY)); + + 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; + } + } + /// + /// 定位正北正90度俯视 + /// + /// + /// + /// + 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; + } + } + /// + /// layerTree选中后事件处理 + /// + /// + /// + 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); + } + /// + /// 树节点选中方法 + /// + /// + 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); + } + } + } + + } + /// + /// 改变所有子节点的状态 + /// + /// + /// + 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; + LayerFlyMenuItem.Visible = true; + } + + LayerSelectableMenuItem.Visible = true; + LayerEditableMenuItem.Visible = true; + SaveLayerMenuItem.Visible = true; + LayerFlyMenuItem.Visible = true; + 导出CADToolStripMenuItem1.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]); + if (layer != null) + { + LayerSelectableMenuItem.Checked = layer.Selectable; + LayerEditableMenuItem.Checked = layer.Editable; + } + else + { + return; + } + } + 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; + } + } + } + } + } + + /// + /// 删除临时添加的本地数据图层 + /// + /// + /// + 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); + for (int i = globeControl1.Globe.Layers.Count-1; i >=0; i--) + { + if (globeControl1.Globe.Layers[i].Caption == layer.Caption) + { + globeControl1.Globe.Layers.Remove(globeControl1.Globe.Layers[i]); + } + } + + 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 定位ToolStripMenuItem_Click(object sender, EventArgs e) + { + TreeNode node = layerTree.SelectedNode; + + if (node != null) + { + if (node.Parent.Text.Trim() == "临时图层") + { + GSOLayer lsLayer = globeControl1.Globe.Layers.GetLayerByCaption(node.Text.ToString()); + double x = lsLayer.LatLonBounds.Center.X; + double y = lsLayer.LatLonBounds.Center.Y; + if (x == 0 && y == 0) + { + x = lsLayer.Bounds.Center.X; + y = lsLayer.Bounds.Center.Y; + } + + globeControl1.Globe.FlyToPosition(new GSOPoint3d(x, y, 10), EnumAltitudeMode.Absolute); + } + else + { + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(node.Tag.ToString().Split('|')[1]); + + if (layer != null) + { + if (layer.Caption == "红线") + { + globeControl1.Globe.FlyToPosition(new GSOPoint3d(120.610963, 31.188121, 50), EnumAltitudeMode.Absolute, -4, 50, 1000); + globeControl1.Globe.FlyToPointSpeed = 10000000; + globeControl1.Globe.Action = EnumAction3D.SelectObject; + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = true; + } + globeControl1.Refresh(); + } + else + { + double x = layer.LatLonBounds.Center.X; + double y = layer.LatLonBounds.Center.Y; + globeControl1.Globe.FlyToPosition(new GSOPoint3d(x, y, 100), EnumAltitudeMode.Absolute); + } + } + } + } + else + { + return; + } + + } + + private void layerTree_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e) + { + if(this.layerTree.SelectedNode!=null) + { + if (this.layerTree.SelectedNode.Tag.ToString().Contains("|")) + { + string nodeTag = this.layerTree.SelectedNode.Tag.ToString().Split('|')[1]; + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(nodeTag); + if (layer != null) + { + if (layer.Caption == "红线") + { + globeControl1.Globe.FlyToPosition(new GSOPoint3d(120.610963, 31.188121, 50), EnumAltitudeMode.Absolute, -4, 50, 1000); + globeControl1.Globe.FlyToPointSpeed = 10000000; + globeControl1.Globe.Action = EnumAction3D.SelectObject; + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = true; + } + globeControl1.Refresh(); + } + else { + double x = layer.LatLonBounds.Center.X; + double y = layer.LatLonBounds.Center.Y; + globeControl1.Globe.FlyToPosition(new GSOPoint3d(x, y, 0), EnumAltitudeMode.Absolute); + } + } + } + if (this.layerTree.SelectedNode.Tag is GSOLayer) + { + GSOLayer layer = this.layerTree.SelectedNode.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 (this.layerTree.SelectedNode.Tag is GSOFeature) + { + GSOFeature feature = this.layerTree.SelectedNode.Tag as GSOFeature; + if (feature.Geometry != null) + { + globeControl1.Globe.FlyToPosition(feature.Geometry.GeoCenterPoint, EnumAltitudeMode.Absolute, 0, 0, 10); + } + else + { + globeControl1.Globe.FlyToFeature(feature); + } + } + } + } + + /// + /// 在三维场景移动时,隐藏气泡globeControl1 + /// + /// + /// + void globeControl1_CameraBeginMoveEvent(object sender, CameraBeginMoveEventArgs e) + { + if (featureTooltip.IsVisible()) + { + featureTooltip.HideBalloon(); + } + if (balloonEx.IsVisible()) + { + balloonEx.HideBalloon(); + } + } + + /// + /// 在三维场景移动时,隐藏气泡globeControl2 + /// + /// + /// + void globeControl2_CameraBeginMoveEvent(object sender, CameraBeginMoveEventArgs e) + { + if (featureTooltip2.IsVisible()) + { + featureTooltip2.HideBalloon(); + } + if (balloonEx2.IsVisible()) + { + balloonEx2.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(); + } + } + + #region Fan 横断面 + /// + /// 横断面分析、基线剖面分析、道路断面分析等 + /// + /// + /// + private static EnumTrackPolylineEndMode trackPolylineEndMode; + + void globeControl1_TrackPolylineEndEvent(object sender, TrackPolylineEndEventArgs e) + { + //横断面分析、道路横断面分析 + if (trackPolylineEndMode == EnumTrackPolylineEndMode.HDM_Analysis|| + trackPolylineEndMode == EnumTrackPolylineEndMode.DLDM_Analysis) + { + Dictionary hdmDic = SectionAnalysisTool.HDMAnalysis(this.globeControl1, + e.Polyline, this.m_PipelineLayerNames); + FrmHDMAnalysis3 frm = new FrmHDMAnalysis3(hdmDic, this.globeControl1, + trackPolylineEndMode); + frm.Show(this); + } + //基线剖面分析 + else if (trackPolylineEndMode == EnumTrackPolylineEndMode.JXPM_Analysis) + { + FrmBaseLineProfillAnalysis dlg = new FrmBaseLineProfillAnalysis(globeControl1.Globe, e.Polyline); + dlg.Show(this); + globeControl1.Globe.ClearLastTrackPolyline(); + } + else + { + + } + trackPolylineEndMode = EnumTrackPolylineEndMode.Default_Analysis; + } + #endregion + + private GSOFeatures PolygonIntersectAnalysis(GSOGeoPolygon3D polygon, string pipelinetype) + { + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(pipelinetype); + 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(pipelinetype, feats.Length); + return feats; + } + /// + /// 根据范围统计阀门、管线、工井等, 开挖分析, 挖方量分析 + /// + /// + /// + void globeControl1_TrackPolygonEndEvent(object sender, TrackPolygonEndEventArgs e) + { + if (globeControl1.Globe.Action == EnumAction3D.TrackPolygon && e.Polygon != null) + { + GSOGeoPolygon3D polygon = e.Polygon; + + switch (trackflag) + { + case "valvequery": + FrmValveStatistics frm = new FrmValveStatistics(globeControl1,polygon, new DataGridViewDelegate(InitDataGridViewX1)); + frm.Show(this); + globeControl1.Globe.Action = EnumAction3D.ActionNull; + break; + + case "PipelineDistanceStatistics": +<<<<<<< HEAD +======= + +>>>>>>> d2d0088a6b3c53c1a96b7f1997f4d3443c0ee8c0 + FrmAllPipelineStatis frm1 = new FrmAllPipelineStatis(globeControl1, polygon, new DataGridViewDelegate(InitDataGridViewX1), m_PipelineLayerNames); + frm1.Show(this); + globeControl1.Globe.Action = EnumAction3D.ActionNull; + + break; + case "PipelineSpatialQuery": +<<<<<<< HEAD +======= + +>>>>>>> d2d0088a6b3c53c1a96b7f1997f4d3443c0ee8c0 + FrmAllPipelineStatis.ShowForm(globeControl1,polygon,new DataGridViewDelegate(InitDataGridViewX1),m_PipelineLayerNames); + globeControl1.Globe.ClearAnalysis(); + globeControl1.Globe.Action = EnumAction3D.ActionNull; + + break; + case "workwellquery": + FrmAllWorkWellStatis frmWell = new FrmAllWorkWellStatis(globeControl1, polygon, new DataGridViewDelegate(InitDataGridViewX1)); + 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 "BSQDuoBianXiangStatis": + + //GSOFeature f2 = new GSOFeature(); + //f2.Geometry = e.Polygon; + //f2.Geometry.AltitudeMode = EnumAltitudeMode.Absolute; + //globeControl1.Globe.MemoryLayer.AddFeature(f2); + //f2.Geometry.MoveZ(3); + //workWellLen.Clear(); + //List listBSQ = new List(); + + //GSOFeatures bsqFeatures = PolygonIntersectAnalysis(e.Polygon, "标识器"); + //listBSQ.Add(bsqFeatures); + + //FrmBSQDuoBianXingStatis bsqFrm = new FrmBSQDuoBianXingStatis(workWellLen, globeControl1, listBSQ); + FrmBSQStatis bsqFrm = new FrmBSQStatis(globeControl1,e.Polygon); + bsqFrm.Show(this); + globeControl1.Globe.Action = EnumAction3D.ActionNull; + break; + + case "": + break; + default: + break; + } + } + } + + #region 验证端口 + /* + /// + /// 验证端口 + /// + /// + 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 + + /// + /// 鼠标悬浮提示 + /// + /// + /// + 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); + } + } + + /// + /// 添加管线绘制完成事件, 红线工具绘制完成 + /// + /// + /// + 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; + + + } + } + + /// + /// 获取globeControl1中鼠标按下的坐标供区别鼠标右键和滚轮按下事件 + /// + /// + /// + void globeControl1_MouseDown(object sender, MouseEventArgs e) + { + mouseDownX1 = e.X; + mouseDownY1 = e.Y; + } + /// + /// 获取globeControl2中鼠标按下的坐标供区别鼠标右键和滚轮按下事件 + /// + /// + /// + void globeControl2_MouseDown(object sender, MouseEventArgs e) + { + mouseDownX2 = e.X; + mouseDownY2 = e.Y; + } + /// + /// + /// + /// + /// + void globeControl2_MouseClick(object sender, MouseEventArgs e) + { + if (e.Button == MouseButtons.Right) + { + if (e.X == mouseDownX2 && e.Y == mouseDownY2) + { + RightScreenToolMenu.Show(globeControl2, e.X, e.Y); + } + else + { + return; + } + } + } + /// + /// + /// + /// + /// + void globeControl1_MouseClick(object sender, MouseEventArgs e) + { + if (e.Button == MouseButtons.Left) + { + if (globeControl1.Globe.Action == EnumAction3D.VisibilityAnalysis) + { + buttonItemFX5_1.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; + + bsqPT = pt; + + if (buttonItemLS5.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 (e.X == mouseDownX1 && e.Y == mouseDownY1) + { + toolRightMenu.Show(globeControl1, e.X, e.Y); + if (buttonItemLS5.Checked) + { + buttonItemLS5.Checked = false; + } + } + else + { + return; + } + } + globeControl1.Refresh(); + } + + /// + /// 判断网络图片是否存在 + /// + /// + /// + 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; + } + + /// + /// 鼠标点击, 弹出气泡功能globeControl1 + /// + /// + /// + void globeControl1_FeatureMouseClickEvent(object sender, FeatureMouseClickEventArgs e) + { + GSOFeature feature = e.Feature; + + string str1 = ""; + if (feature != null) + { + if (feature.GetFieldDefn("图片编码") != null)// + { + str1 = GetBubbleInfo(feature, globeControl1); + if (RemoteFileExists(Utility.PicRootURL + feature.GetValue("图片编码").ToString())) + { + str1 += ""; + } + else if (RemoteFileExists(Utility.PicDefaultURL)) + { + str1 += ""; + } + } + else if (isFeatureContainsBianhao(feature)) //管线模型图层 + { + str1 = GetBubbleInfo(feature, globeControl1); + } + + 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; + } + } + } + + /// + /// 鼠标点击, 弹出气泡功能globeControl2 + /// + /// + /// + void globeControl2_FeatureMouseClickEvent(object sender, FeatureMouseClickEventArgs e) + { + GSOFeature feature = e.Feature; + + string str1 = ""; + if (feature != null) + { + if (feature.GetFieldDefn("图片编码") != null) // + { + str1 = GetBubbleInfo(feature, globeControl2); + if (RemoteFileExists(Utility.PicRootURL + feature.GetValue("图片编码").ToString())) + { + str1 += ""; + } + else if (RemoteFileExists(Utility.PicDefaultURL)) + { + str1 += ""; + } + } + else if (isFeatureContainsBianhao(feature)) //管线模型图层 + { + str1 = GetBubbleInfo(feature, globeControl2); + } + + if (str1 != "") + { + + featureTooltip2.HideBalloon(); + balloonEx2.HideBalloon(); + balloonEx2.SetSize(EnumSizeIndexEx.CONTENT_CX, 480); + balloonEx2.SetSize(EnumSizeIndexEx.CONTENT_CY, 420); + balloonEx2.ShowBalloon((int)e.MousePos.X, (int)e.MousePos.Y, str1); + + return; + } + } + } + + /// + /// 拼接气泡表格字符串 + /// + /// + /// + private string GetBubbleInfo(GSOFeature feature,GSOGlobeControl globeControl) + { + if (feature == null) + { + return ""; + } + string str = ""; + str = ""; + 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 += ""; + + 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.get_Fields(layerName, globeControl); + } + if (queryFields != null) + { + string[] param = { "," }; + string[] fieldNames = queryFields.Split(param, StringSplitOptions.RemoveEmptyEntries); + for (int j = 0; j < fieldNames.Length; 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 (name1 == "模型路径") + { + continue; + } + 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 (field1.Type == EnumFieldType.Double) + { + double dl1 = feature.GetFieldAsDouble(j); + if (!name1.Contains("管径") && !name1.Contains("电压") && !name1.Contains("角度")) + { + name1 += "_米"; + } + value1 = dl1.ToString("0.00"); + } + 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 (name2 == "模型路径") + { + continue; + } + + 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 (field2.Type == EnumFieldType.Double) + { + double dl2 = feature.GetFieldAsDouble(j + 1); + if (!name2.Contains("管径") && !name2.Contains("电压") && !name2.Contains("角度")) + { + name2 += "_米"; + } + value2 = dl2.ToString("0.00"); + } + else + { + if (!feature.IsFieldValueNull(j + 1)) + { + value2 = feature.GetValue(j + 1).ToString(); + } + } + } + } + + j++; + } + str += ""; + } + } + str += "
" + title + " " + feature.GetFieldAsString(featureIDFieldName) + "
" + + name1 + + "
" + + value1 + + "
" + + name2 + + "
" + + value2 + "
"; + return str; + } + + string filename = Utility.filename; + List g1layername = new List(); + + /// + /// 获取目标图层 + /// + /// + 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; + } + /// + /// 添加图层 + /// + /// + /// + /// + 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 = 5000; + return templayer.Visible; + } + catch (Exception ex) + { + return false; + } + } + /// + /// 菜单上的 三维导航 工具按钮 + /// + /// + /// + private void buttonItem86_Click(object sender, EventArgs e) + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + } + + /// + /// 地上模式 菜单按钮 + /// + /// + /// + 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(); + + } + } + /// + /// 地下模式 菜单按钮 + /// + /// + /// + 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(); + } + } + /// + /// 行走模式 菜单按钮 + /// + /// + /// + 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; + } + } + /// + /// 地面透明度设置 菜单 + /// + /// + /// + private void sliderGroundTransSet1_ValueChanged(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.sliderGroundTransSet1.Text); + + globeControl1.Globe.GroundOpaque = 100 - sliderGroundTransSet1.Value; + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(roadLayerName);//("180fd"); + if (layer != null) + { + layer.Opaque = 100 - sliderGroundTransSet1.Value; + } + //if (buttonItemSPDB.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; + } + /// + /// 图例 菜单按钮 + /// + /// + /// + 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(); + } + /// + /// 快速定位 菜单按钮 + /// + /// + /// + private void buttonItem91_Click(object sender, EventArgs e) // + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItem91.Text); + FrmFlyToPosition fly = new FrmFlyToPosition(globeControl1); + fly.Show(this); + } + /// + /// 图层管理 菜单按钮 + /// + /// + /// + 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; + + //修改图层管理与标注管理、覆土审查、水平净距分析、垂直净距分析和碰撞分析控件之间的逻辑关系 + controlContainerItem5.Visible = false; + sideBar1.Visible = false; + sideBarPanelItem4.Visible = false; + panel3.Visible = false; + sideBar1.ExpandedPanel = sideBarPanelItem3; + buttonItemBZ11.Checked = false; + + //20160624 + /* + if (sideBarPanelItem4.Visible == true) + { + sideBar1.Visible = true; + controlContainerItem5.Visible = true; + } + else + { + sideBar1.Visible = false; + } + */ + Refresh(); + + } + } + /// + /// 全屏显示 菜单按钮 + /// + /// + /// + 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; + /// + /// 全屏显示功能实现 + /// + 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(); + } + } + + /// + /// 设置窗体宽、高 + /// + /// + /// + private void SetFullScreen(int width, int height) + { + this.Width = width; + this.Height = height; + } + + /// + /// 全屏功能的快捷键F5 + /// + /// + /// + 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); + } + } + /* + /// + /// 输出地图 + /// + /// + /// + /// + 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; + } + * */ + + private Point getUpperLeftPoint(Point p1, Point p2, out int mapWidth, out int mapHeight) // + { + Rectangle rc = new Rectangle(); + + p1 = this.globeControl1.PointToScreen(p1); + p2 = this.globeControl1.PointToScreen(p2); + + int x = Screen.PrimaryScreen.Bounds.X; + int y = Screen.PrimaryScreen.Bounds.Y; + int screenWidth = SystemInformation.WorkingArea.Width; + int screenHeight = SystemInformation.WorkingArea.Height; + + if (p1.X < x) + rc.X = x; + else + rc.X = p1.X; + + if (p1.Y < y) + rc.Y = y; + else + rc.Y = p1.Y; + + p1.X = rc.Left; + p1.Y = rc.Top; + + if (p2.X > screenWidth) + p2.X = screenWidth; + else + p2.X = p2.X; + + if (p2.Y > screenHeight) + p2.Y = screenHeight; + else + p2.Y = p2.Y; + + rc.Width = p2.X - rc.X; + rc.Height = p2.Y - rc.Y; + + mapWidth = rc.Width; + mapHeight = rc.Height; + Point pt = new Point(rc.Left, rc.Top); + return pt; + } + + Image printImage; + /// + /// 打印 菜单 + /// + /// + /// + 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))); + */ + int mapWidth = 0; + int mapHeight = 0; + Point pt = getUpperLeftPoint(pt1, pt2, out mapWidth, out mapHeight); + int rightBottomX = pt.X + mapWidth; + int rightBottomY = pt.Y + mapHeight; + Image myImg = new Bitmap(mapWidth, mapHeight); + Graphics g = Graphics.FromImage(myImg); + g.CopyFromScreen(pt, new Point(0, 0), new Size(rightBottomX, rightBottomY)); + + + 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); + } + /// + /// 输出地图 菜单 + /// + /// + /// + private void btnOutputJPG_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btnOutputJPG.Text); + + //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))); + */ + int mapWidth = 0; + int mapHeight = 0; + Point pt = getUpperLeftPoint(pt1, pt2, out mapWidth, out mapHeight); + int rightBottomX = pt.X + mapWidth; + int rightBottomY = pt.Y + mapHeight; + Image myImg = new Bitmap(mapWidth, mapHeight); + Graphics g = Graphics.FromImage(myImg); + g.CopyFromScreen(pt, new Point(0, 0), new Size(rightBottomX, rightBottomY)); + + 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; + } + } + } + + /// + /// 统计管线的里程数 + /// + /// + /// + /// + 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; + } + + /// + /// 窗体下方属性表格 右键菜单中的 “定位”菜单 + /// + /// + /// + 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); + + } + + /// + /// 表格中右键 “单个闪烁” 菜单 + /// + /// + /// + private void LightMenu_Click(object sender, EventArgs e) + { + flashflag = "single"; + timer1.Start(); + } + /// + /// 表格中右键 “全部闪烁” 菜单 + /// + /// + /// + private void AllLightMenuItem_Click(object sender, EventArgs e) + { + flashflag = "all"; + timer1.Start(); + } + + /// + /// 使用timer实现管线的闪烁效果 + /// + /// + /// + 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; + } + } + + /// + /// 绘制线 菜单 + /// + /// + /// + private void btnAddLine_Click(object sender, EventArgs e) + { + globeControl1.Globe.DestLayerFeatureAdd = globeControl1.Globe.MemoryLayer; + globeControl1.Globe.Action = EnumAction3D.DrawPolyline; + } + /// + /// 绘制面 菜单 + /// + /// + /// + private void btnAddPolygon_Click(object sender, EventArgs e) + { + globeControl1.Globe.DestLayerFeatureAdd = globeControl1.Globe.MemoryLayer; + globeControl1.Globe.Action = EnumAction3D.DrawPolygon; + } + /// + /// 图层目录树 右键菜单中的 目标图层 菜单 + /// + /// + /// + 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; + } + } + /// + /// 图层目录树 右键菜单中的 可选择 菜单 + /// + /// + /// + 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; + } + /// + /// 图层目录树 右键菜单中的 可编辑 菜单 + /// + /// + /// + 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; + } + /// + /// 图层目录树 右键菜单中的 保存 菜单 + /// + /// + /// + 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(); + } + + /// + /// 根据多边形范围统计管线的里程 + /// + /// + /// + /// 返回查询到的管线要素集合 + 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 pipeLineDis = new Dictionary(); + Dictionary workWellLen = new Dictionary(); + + + + + /// + /// 查找指定图层中在 指定范围内的feature对象集合 + /// + /// + /// + /// + 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; + } + /// + /// 清除结果 菜单 + /// + /// + /// + private void buttonItem47_Click(object sender, EventArgs e) + { + globeControl1.Globe.ClearAnalysis(); + dataGridViewX1.DataSource = null; + panelOfTable.Visible = false; + clearFeatureHighLight(); + } + /// + /// 设置菜单的选中状态 + /// + private void ActionToolMenuChecked() + { + if (globeControl1.Globe.Action != EnumAction3D.TrackPolyline) + { + buttonItemFX2_1.Checked = false; + buttonItemFX2_4.Checked = false; + buttonItemFX2_3.Checked = false; + buttonItemFX4_3.Checked = false; + } + if (globeControl1.Globe.Action != EnumAction3D.NormalHit) + { + buttonItemFX3_6.Checked = false; + // ClearConnexityAnalysis(); + + buttonItemFX3_5.Checked = false; + // ClearCloseValvesAnalysis(); + } + if (globeControl1.Globe.Action != EnumAction3D.TrackPolygon) + { + buttonItemFX4_2.Checked = false; + buttonItemFX4_1.Checked = false; + } + } + + /// + /// 主窗体关闭事件处理 + /// + /// + /// + private void MainFrm_FormClosing(object sender, FormClosingEventArgs e) + { + + if (MessageBox.Show("是否退出系统?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) + { + e.Cancel = true; + } + else { + globeControl1.Globe.MemoryLayer.SaveAs(Application.StartupPath + "/MyPlace.kml"); + } + + //saveLayerList(layerManagerNode.Nodes); + //注销id号为103的热键设定 + // UnregisterHotKey(Handle, 103); + } + + /// + /// 显示流向 功能 + /// + /// + /// + /// + 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(); + } + + FrmCloseValves frm; + + FrmBoosterValvers frmbooster = null; + + /// + /// 垂直净距分析 功能界面中的 选择图层复选框 选中状态改变事件处理 + /// + /// + /// + 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(); + } + /// + /// 水平净距分析 功能界面中的 选择图层复选框 选中状态改变事件处理 + /// + /// + /// + 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(); + } + /// + /// 垂直净距分析 功能界面中的 选择管线复选框 选中状态改变事件处理 + /// + /// + /// + private void checkBoxX1_CheckedChanged(object sender, EventArgs e) + { + clearFeatureHighLight(); + if (checkBoxX1.Checked) + { + comboBoxEx1.SelectedItem = null; + 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; + } + } + /// + /// 水平净距分析 功能界面中的 选择管线复选框 选中状态改变事件处理 + /// + /// + /// + private void checkBoxX1_CheckedChanged_shuiping(object sender, EventArgs e) + { + clearFeatureHighLight();//清除高亮 + if (checkBoxX7.Checked) + { + comboBoxEx4.SelectedItem = null; + 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(); + /// + /// 垂直净距分析 功能界面中的 选择图层下拉框 选中项改变 事件处理 + /// + /// + /// + 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; + } + } + } + /// + /// 水平净距分析 功能界面中的 选择图层下拉框 选中项改变 事件处理 + /// + /// + /// + 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 featCount = new Dictionary(); + Dictionary featLenth = new Dictionary(); + Dictionary m_FeaturesWithBianhao = new Dictionary();//记录编号和对应的标注点的位置 + GSOFeatures polygonJingJuAnalysises = new GSOFeatures(); + + /// + /// 垂直净距分析 功能界面中的 开始分析按钮 事件处理 + /// + /// + /// + 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; + } + + /// + /// 在指定的两点组成的线的中间添加一个marker对象,并将marker对象添加到指定的图层中 + /// + /// + /// + /// + /// + /// + 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; + } + + /// + /// 计算指定feature对象与除了该feature所在图层之外的 所有管线图层中的所有feature对象 的垂直距离 并在表格中记录符合要求的管线 + /// + /// + /// + /// + /// + private void VerticalDistanceAnalysis(string type, GSOFeature selectedFeature, List _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(); + } + /// + /// 垂直净距分析中 表格行的 双击定位 功能。 与覆土分析的实现方法不同,主要原因是需要标注垂距 + /// + /// + /// + 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); + } + } + } + } + + /// + /// 水平净距分析 功能界面中 开始分析按钮 的事件处理 + /// + /// + /// + 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; + } + + + /// + /// 计算指定feature对象与除了该feature所在图层之外的 所有管线图层中的所有feature对象 的水平距离 并记录符合要求的管线 功能 + /// + /// + /// + /// + /// + private void HorizontalDistanceAnalysis(GSOFeature selectedFeature, List _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)); + } + } + } + } + } + /// + /// 水平净距分析 功能界面中 表格的 双击定位 功能 + /// + /// + /// + 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); + } + } + } + } + } + /// + /// 碰撞分析 功能界面中 开始分析按钮 事件处理 + /// + /// + /// + 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; + } + /// + /// 碰撞分析功能界面中 表格的 双击定位 功能 + /// + /// + /// + 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); + } + } + } + } + + + + /// + /// 覆土分析功能操作界面中的 选择管线 复选框选中状态改变事件处理 + /// + /// + /// + private void checkBoxX5_CheckedChanged(object sender, EventArgs e) + { + clearFeatureHighLight(); + if (checkBoxX5.Checked) + { + comboBoxEx3.SelectedItem = null; + 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; + } + } + /// + /// 覆土分析功能操作界面中的 选择图层 复选框选中状态改变事件处理 + /// + /// + /// + 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(); + } + /// + /// 覆土分析功能操作界面中的 图层下拉框选中项改变事件处理 + /// + /// + /// + 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; + } + } + } + /// + /// 覆土分析功能操作界面中的 开始分析 按钮事件处理 + /// + /// + /// + 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; + + + GSOPoint3d markerPosition = new GSOPoint3d(); + 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]; + GSOPoint3d pt = new GSOPoint3d(); + + 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"); + + pt.X = pts[m].X; + pt.Y = pts[m].Y; + pt.Z = 0; + markerPosition = LabelVerticalDistance(layerTemp, pts[m], pt, Convert.ToDouble(dataGridViewX7.Rows[idx].Cells[2].Value), true); + 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]; + GSOPoint3d pt = new GSOPoint3d(); + 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"); + + pt.X = pts[m].X; + pt.Y = pts[m].Y; + pt.Z = 0; + markerPosition = LabelVerticalDistance(layerTemp, pts[m], pt, Convert.ToDouble(dataGridViewX7.Rows[idx].Cells[2].Value), true); + + 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; + } + + /// + /// 覆土分析中 表格的 双击定位 功能 + /// + /// + /// + 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); + } + } + } + } + } + /// + /// 覆土分析功能操作界面中的 导出Excel按钮 事件处理 + /// + /// + /// + private void buttonX10_Click(object sender, EventArgs e) + { + if (dataGridViewX7.Rows.Count > 0) + { + ExportExcel("覆土分析", dataGridViewX7, null); + } + else + { + MessageBox.Show("表格内容为空!", "提示"); + } + } + /// + /// 覆土分析功能操作界面底部的 关闭 按钮事件处理 + /// + /// + /// + 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(); + layerTemp.RemoveAllFeature(); + + if (buttonItem1.Checked) + { + sideBar1.ExpandedPanel = sideBarPanelItem3; + } + else + { + sideBar1.Visible = false; + } + globeControl1.Refresh(); + + //Refresh(); + } + + + /// + /// 垂直净距分析 功能界面中 清除分析结果按钮 事件处理 + /// + /// + /// + 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(); + } + /// + /// 水平净距分析 功能界面中 清除分析结果按钮 事件处理 + /// + /// + /// + 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(); + } + + /// + /// 垂直净距分析功能界面中 关闭按钮 事件处理 + /// + /// + /// + 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(); + } + /// + /// 水平净距分析功能界面中 删除缓冲区按钮 事件处理 + /// + /// + /// + private void buttonX14_Click(object sender, EventArgs e) + { + 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(); + } + + /// + /// 导出指定DataGridView控件中的内容 + /// + /// + /// + 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(); + } + } + } + } + + /// + /// 垂直净距分析功能界面中 导出Excel按钮 事件处理 + /// + /// + /// + private void buttonX4_Click(object sender, EventArgs e) + { + if (dataGridViewX3.Rows.Count > 0) + { + ExportExcel("垂直净距分析", dataGridViewX3, listBox1); + } + else + { + MessageBox.Show("表格内容为空!", "提示"); + } + } + /// + /// 水平净距分析功能界面中 导出Excel按钮 事件处理 + /// + /// + /// + private void buttonX4_Click_shuiping(object sender, EventArgs e) + { + if (dataGridViewX9.Rows.Count > 0) + { + ExportExcel("水平净距分析", dataGridViewX9, listBox3); + } + else + { + MessageBox.Show("表格内容为空!", "提示"); + } + } + + + /// + /// 清除所有坑 菜单 + /// + /// + /// + private void buttonItem3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItem3.Text); + + globeControl1.Globe.RemoveAllPits(); + } + + //} + /// + /// 大气层 菜单 + /// + /// + /// + private void buttonItem17_Click_1(object sender, EventArgs e) + { + globeControl1.Globe.Atmosphere.Visible = !globeControl1.Globe.Atmosphere.Visible; + buttonItemSH1.Checked = globeControl1.Globe.Atmosphere.Visible; + globeControl1.Refresh(); + } + /// + /// 经纬网 菜单 + /// + /// + /// + private void buttonItem20_Click(object sender, EventArgs e) + { + globeControl1.Globe.LatLonGrid.Visible = !globeControl1.Globe.LatLonGrid.Visible; + buttonItemSH3.Checked = globeControl1.Globe.LatLonGrid.Visible; + globeControl1.Globe.Refresh(); + } + /// + /// 状态条 菜单 + /// + /// + /// + private void buttonItem21_Click_1(object sender, EventArgs e) + { + globeControl1.Globe.StatusBar.Visible = !globeControl1.Globe.StatusBar.Visible; + buttonItemSH4.Checked = globeControl1.Globe.StatusBar.Visible; + globeControl1.Globe.Refresh(); + } + + + + /// + /// 添加指定路径下的数据 功能 + /// + /// + /// + 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); + //CheckDatasetGeoReference(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; + } + return objRes; + } + /// + /// 刷新目录树 功能 + /// + 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); + } + } + /// + /// 判断图层是否包含字段列表 + /// + /// + /// + 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; + } + + /// + /// 统计指定图层在指定范围内的所有feature对象 + /// + /// + /// + /// + 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; + } + /// + /// 碰撞分析功能界面中 选择管线复选框 选中状态改变事件处理 + /// + /// + /// + private void checkBoxX3_CheckedChanged(object sender, EventArgs e) + { + clearFeatureHighLight(); + if (checkBoxX3.Checked) + { + comboBoxEx2.SelectedItem = null; + 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; + } + } + /// + /// 碰撞分析功能界面中 选择图层复选框 选中状态改变事件处理 + /// + /// + /// + 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(); + } + /// + /// 碰撞分析功能界面中 选择图层下拉框 选中项改变事件处理 + /// + /// + /// + 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; + } + } + } + /// + /// 清除所有图层中的所有feature对象的高亮状态 功能 + /// + 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); + } + } + } + } + for (int i = 0; i < globeControl2.Globe.Layers.Count; i++) + { + GSOLayer layer = globeControl2.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; + } + } + } + + if (globeControl1.Globe.Action == EnumAction3D.SelectObject) + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + //globeControl1.Globe.Action = EnumAction3D.SelectObject; + } + } + + /// + /// 碰撞分析功能界面中 清除分析结果按钮 事件处理 + /// + /// + /// + 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(); + } + /// + /// 碰撞分析功能界面中 导出Excel按钮 事件处理 + /// + /// + /// + private void buttonX6_Click(object sender, EventArgs e) + { + if (dataGridViewX5.Rows.Count > 0) + { + ExportExcel("碰撞分析", dataGridViewX5, listBox2); + } + else + { + MessageBox.Show("表格内容为空!", "提示"); + } + } + /// + /// 导出CAD 菜单 + /// + /// + /// + private void btnExportCAD_Click(object sender, EventArgs e) + { + FrmExportCADS frm = new FrmExportCADS(globeControl1, m_PipelineLayerNames); + frm.ShowDialog(); + } + + ///// + ///// 区域分析 菜单 + ///// + ///// + ///// + //private void buttonItem50_Click(object sender, EventArgs e) + //{ + // buttonItem50.Checked = !buttonItem50.Checked; + // ribbonBarQY.Visible = buttonItem50.Checked; + // ribbonBarQY.Location = new Point(0, 0); + //} + + + /// + /// 连接数据库 菜单事件处理 + /// + /// + /// + 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; + } + } + } + /// + /// 数据验证 菜单 + /// + /// + /// + private void buttonItem80_Click(object sender, EventArgs e) + { + FrmValiData frm = new FrmValiData(globeControl1); + frm.ShowDialog(); + } + /// + /// 根据指定图层创建图层节点并将节点添加到图层管理节点的子节点集合中 + /// + /// + 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; + + if (!layerManagerNode.Nodes.Contains(node)) + { + layerManagerNode.Nodes.Insert(0, node); + layerManagerNode.Expand(); + } + } + } + /// + /// 数据库备份 菜单 + /// + /// + /// + 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(); + } + } + } + + + + #region Fan 去掉 + //GSOFeature emitterFeature; // 粒子要素 + /// + /// 添加火苗 功能 + /// + /// + /// + /// + 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); + + } + /// + /// 添加喷泉 功能 + /// + /// + /// + /// + 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); + } + #endregion + + /// + /// 获取指定图层中最后一个feature对象的名称对应的整数 + /// + /// + /// + 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; + } + /// + /// 设置除指定标注图层之外的所有标注图层不可见 + /// + /// + 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; + } + } + } + } + } + + /// + /// 判断选中的对象是否为管线 + /// + /// 被选中管线 + /// 返回一根线 + 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; + } + + /// + /// 获取指定两点组成的线的长度 功能 + /// + /// + /// + /// + 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; + } + + /// + /// 图层节点树中 节点 右键单击事件处理 + /// + /// + /// + 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; + } + } + } + } + } + + /// + /// 标注管理、传感器管理 图层目录树的右键菜单中的 刷新列表 菜单 + /// + /// + /// + 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); + } + } + /// + /// 给指定的图层节点添加代表feature对象的子节点 + /// + /// + private void RefreshTreeNodeLayerFeatureList(TreeNode layerTreeNode) + { + layerTreeNode.Nodes.Clear(); + GSOLayer layer = (GSOLayer)layerTreeNode.Tag; + // 只将类型为内存数据集的图层列出,如果是其它类型的数据集可能数据量太大,没发显示在树控件中 + if (layer.Dataset is GSOFeatureDataset) + { + VisitFeature3Ds(layer.GetAllFeatures(), layerTreeNode); + } + } + + /// + /// 标注管理、传感器管理 图层目录树的右键菜单中的 移除所有 菜单 + /// + /// + /// + 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(); + } + } + + /// + /// 图层目录树的 节点对应的复选框选中状态改变事件处理 + /// + /// + /// + private void layerMarkerTree_AfterCheck(object sender, TreeViewEventArgs e) + { + if (e.Action != TreeViewAction.Unknown) + { + CheckTreeNode(e.Node, e.Node.Checked); + } + } + /// + /// 改变指定节点对应的复选框的选中状态 + /// + /// + /// + private void CheckTreeNode(TreeNode node, Boolean bChecked) + { + CheckChildTreeNode(node, bChecked); + globeControl1.Globe.Refresh(); + } + /// + /// 改变指定节点的子节点对应的复选框的选中状态 + /// + /// + /// + 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); + } + } + /// + /// 标注管理、传感器管理 目录树中的feature节点的右键菜单中的 删除 菜单 + /// + /// + /// + 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(); + } + } + + /// + /// 双屏对比 菜单 + /// + /// + /// + //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(); + // } + //} + /// + /// 模拟分析 菜单 + /// + /// + /// + //private void buttonItem51_Click(object sender, EventArgs e) + //{ + // buttonItem51.Checked = !buttonItem51.Checked; + // ribbonBarMN.Visible = buttonItem51.Checked; + // ribbonBarMN.Location = new Point(0, 0); + //} + + /// + /// 双屏设置 菜单 + /// + /// + /// + //private void buttonItem96_Click(object sender, EventArgs e) + //{ + // FrmLayerControl frm = new FrmLayerControl(layerTree,globeControl1,globeControl2); + // frm.Show(this); + //} + /// + /// 双屏联动 菜单 + /// + /// + /// + //private void buttonItem95_Click(object sender, EventArgs e) + //{ + // buttonItem95.Checked = !buttonItem95.Checked; + //} + ///// + /// 添加用户仓库 菜单 + /// + /// + /// + private void buttonItem108_Click(object sender, EventArgs e) + { + FrmUserRepo frm = new FrmUserRepo(-1); + frm.ShowDialog(); + } + /// + /// 用户仓库管理 菜单 + /// + /// + /// + private void buttonItem111_Click(object sender, EventArgs e) + { + FrmUserRepoMgr frm = new FrmUserRepoMgr(); + frm.ShowDialog(); + } + /// + /// 添加分系统 菜单 + /// + /// + /// + private void buttonItem112_Click(object sender, EventArgs e) + { + //FrmAPP frm = new FrmAPP(-1); + //frm.ShowDialog(); + } + /// + /// 分系统管理 菜单 + /// + /// + /// + private void buttonItem113_Click(object sender, EventArgs e) + { + //FrmAPPMgr frm = new FrmAPPMgr(); + //frm.ShowDialog(); + } + /// + /// 添加操作 菜单 + /// + /// + /// + private void buttonItem114_Click(object sender, EventArgs e) + { + FrmOper frm = new FrmOper(-1); + frm.ShowDialog(); + } + /// + /// 操作管理 菜单 + /// + /// + /// + private void buttonItem115_Click(object sender, EventArgs e) + { + FrmOperMgr frm = new FrmOperMgr(); + frm.ShowDialog(); + } + /// + /// 添加资源 菜单 + /// + /// + /// + private void buttonItem116_Click(object sender, EventArgs e) + { + FrmRESC frm = new FrmRESC(-1); + frm.ShowDialog(); + } + /// + /// 资源管理 菜单 + /// + /// + /// + private void buttonItem117_Click(object sender, EventArgs e) + { + FrmRESCMgr frm = new FrmRESCMgr(); + frm.ShowDialog(); + } + /// + /// 添加权限 菜单 + /// + /// + /// + private void buttonItem118_Click(object sender, EventArgs e) + { + FrmPerm frm = new FrmPerm(-1); + frm.ShowDialog(); + } + /// + /// 权限管理 菜单 + /// + /// + /// + private void buttonItem119_Click(object sender, EventArgs e) + { + FrmPermMgr frm = new FrmPermMgr(); + frm.ShowDialog(); + } + /// + /// 添加访问控制 菜单 + /// + /// + /// + private void buttonItem120_Click(object sender, EventArgs e) + { + FrmAccess frm = new FrmAccess(-1); + frm.ShowDialog(); + } + /// + /// 访问控制管理 菜单 + /// + /// + /// + private void buttonItem121_Click(object sender, EventArgs e) + { + FrmAccessMgr frm = new FrmAccessMgr(); + frm.ShowDialog(); + } + /// + /// 部门类型管理 菜单 + /// + /// + /// + private void buttonItem122_Click(object sender, EventArgs e) + { + FrmRegionTypeMgr frm = new FrmRegionTypeMgr(); + frm.ShowDialog(); + } + /// + /// 添加用户 菜单 + /// + /// + /// + private void buttonItem127_Click(object sender, EventArgs e) + { + FrmUserAdd frm = new FrmUserAdd(-1); + frm.ShowDialog(); + } + /// + /// 用户信息管理 菜单 + /// + /// + /// + private void buttonItem128_Click_1(object sender, EventArgs e) + { + FrmUserManager frm = new FrmUserManager(); + frm.ShowDialog(); + } + /// + /// 添加角色 菜单 + /// + /// + /// + private void 添加角色_Click(object sender, EventArgs e) + { + FrmRole frm = new FrmRole(-1); + frm.ShowDialog(); + } + /// + /// 所有角色管理 菜单 + /// + /// + /// + private void 角色管理_Click(object sender, EventArgs e) + { + FrmRoleMgr frm = new FrmRoleMgr(); + frm.ShowDialog(); + } + + /// + /// 部门角色管理 菜单 + /// + /// + /// + private void buttonItem133_Click(object sender, EventArgs e) + { + FrmRegionRoleMgr frm = new FrmRegionRoleMgr(); + frm.ShowDialog(); + } + /// + /// 部门管理 菜单 + /// + /// + /// + private void buttonItem130_Click(object sender, EventArgs e) + { + FrmRegionMgr frm = new FrmRegionMgr(); + frm.ShowDialog(); + } + + /// + /// 日志管理 菜单 + /// + /// + /// + private void buttonItem135_Click(object sender, EventArgs e) + { + FrmLogManager frm = new FrmLogManager(); + frm.ShowDialog(); + } + /// + /// 传感器信息查询 菜单 + /// + /// + /// + 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); + } + } + } + /// + /// 根据指定的图层的caption属性的值在配置文件中查找对应的数据库中的表的名称 + /// + /// 图层的caption属性的值 + /// 对应的数据库中的表的名称 + 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; + } + /// + /// 根据数据库中的表的名称 查找对应的表中的字段名称的集合 + /// + /// 数据库中的表的名称 + /// 对应的表中的字段名称的集合 + 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; + } + + /// + /// 历史曲线查询 菜单 + /// + /// + /// + 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; + /// + /// 传感器在线报警 菜单 + /// + /// + /// + 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); + } + /// + /// 传感器报警 功能中的 定时器 的触发事件处理 + /// + /// + /// + 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; + } + } + } + } + } + } + } + + + /// + /// 沿线运动 菜单 + /// + /// + /// + private void buttonItem138_Click(object sender, EventArgs e) + { + if (globeControl1.Globe.SelectedObject == null) + { + MessageBox.Show("请先选择一条线!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + return; + } + + GSOFeature lineFeature = globeControl1.Globe.SelectedObject; + if (lineFeature.Geometry == null || lineFeature.Geometry.Type != EnumGeometryType.GeoPolyline3D) + { + MessageBox.Show("请先选择一条线!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + return; + } + + OpenFileDialog dlg = new OpenFileDialog(); + dlg.Filter = "*.gcm;*.3ds|*.gcm;*.3ds|*.3ds|*.3ds|*.gcm|*.gcm"; + if (dlg.ShowDialog() == DialogResult.OK) + { + GSOGeoModel model = new GSOGeoModel(); + model.FilePath = dlg.FileName; + + GSOGeoDynamicRoute dynamicRoute = new GSOGeoDynamicRoute(); + dynamicRoute.ActorGeometry = model; + + GSORoute route = new GSORoute(); + GSOGeoPolyline3D geoline = (GSOGeoPolyline3D)lineFeature.Geometry; + for (int i = 0; i < geoline[0].Count; i++) + { + route.Add(geoline[0][i]); + } + route.CircleRoute = false; + route.Speed = 30; + route.RotateSpeed = 50; + route.AltitudeMode = geoline.AltitudeMode; + dynamicRoute.Route = route; + + GSOFeature feature = new GSOFeature(); + + dynamicRoute.Play(); + feature.Geometry = dynamicRoute; + + //GSOLabel gsoLabel = new GSOLabel(); + //gsoLabel.Text = "模型测试"; + //feature.Label = gsoLabel; + globeControl1.Globe.MinModelVisibleSize = 0; + + globeControl1.Globe.MemoryLayer.AddFeature(feature); + globeControl1.Globe.Refresh(); + } + } + /// + /// 回退 菜单 + /// + /// + /// + private void buttonItem99_Click(object sender, EventArgs e) + { + globeControl1.Globe.UnDoEdit(); + } + /// + /// 前进 菜单 + /// + /// + /// + private void buttonItem100_Click(object sender, EventArgs e) + { + globeControl1.Globe.ReDoEdit(); + } + /// + /// 水平净距 功能界面中的 标签内容改变事件处理 + /// + /// + /// + 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() + "米的管线有:"; + } + } + } + /// + /// 垂直净距 功能界面中的 标签内容改变事件处理 + /// + /// + /// + 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() + "米的管线有:"; + } + } + } + /// + /// 覆土分析 功能界面中的 标签内容改变事件处理 + /// + /// + /// + 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() + "米的管线有:"; + } + } + } + + /// + /// 传感器分类查询 全区域 菜单 + /// + /// + /// + private void buttonItemSensor全区域查询_Click(object sender, EventArgs e) + { + FrmAccessoriesSensor.ShowForm(globeControl1, instrumenLayerNames, 0); + } + /// + /// 传感器分类查询 绘制区域 菜单 + /// + /// + /// + private void buttonItemSensor绘制区域查询_Click(object sender, EventArgs e) + { + FrmAccessoriesSensor.ShowForm(globeControl1, instrumenLayerNames, 1); + } + + + /// + /// 碰撞分析 功能界面中 关闭按钮 事件处理 + /// + /// + /// + 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(); + } + /// + /// 覆土分析 功能界面中的 清除分析结果 按钮事件处理 + /// + /// + /// + 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(); + } + /// + /// 数字预处理 功能 + /// + /// + /// + private void 数字预处理buttonItem140_Click(object sender, EventArgs e) + { + FrmEditShapeFile frm = new FrmEditShapeFile(globeControl1); + frm.ShowDialog(this); + } + + + /// + /// 导出矢量 功能 将图层导出为kml和shp格式数据 + /// + /// + /// + private void 导出矢量buttonItem140_Click(object sender, EventArgs e) + { + List listVectorNames = new List(); + for (int i = 0; i < m_PipelineLayerNames.Count; i++) + { + 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 = ""; + /// + /// 绘制城市七线 功能按钮 + /// + /// + /// + 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; + } + } + } + /// + /// 七线审核 功能按钮 + /// + /// + /// + private void 七线审核buttonItem141_Click(object sender, EventArgs e) + { + FrmCityServerLineAnalysis frm = new FrmCityServerLineAnalysis(globeControl1, m_PipelineLayerNames); + frm.ShowDialog(this); + } + + /// + /// 间距分析 开始分析按钮 分析绘制的七线和管线的距离是否符合标准 + /// + /// + /// + 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; + } + /// + /// 间距分析 清除分析结果 + /// + /// + /// + 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(); + } + /// + /// 间距分析 导出Excel按钮 将间距分析的结果以Excel表格的形式导出 + /// + /// + /// + private void buttonExportExcel_Click(object sender, EventArgs e) + { + if (dataGridViewAnalysisResult.Rows.Count > 0) + { + ExportExcel("间距分析", dataGridViewAnalysisResult, listBoxStasticsResult); + } + else + { + MessageBox.Show("表格内容为空!", "提示"); + } + } + /// + /// 间距分析 关闭按钮 + /// + /// + /// + 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(); + } + /// + /// 间距分析 分析结果表格双击定位 + /// + /// + /// + 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); + } + } + } + } + /// + /// 间距分析 选择管线复选框 + /// + /// + /// + private void checkBoxSelectPipeline_CheckedChanged(object sender, EventArgs e) + { + clearFeatureHighLight();//清除高亮 + if (checkBoxSelectPipeline.Checked) + { + comboBoxLayer.SelectedItem = null; + 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; + } + } + /// + /// 间距分析 选择图层复选框 + /// + /// + /// + 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(); + } + /// + /// 间距分析 选择图层下拉框 + /// + /// + /// + 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; + } + } + } + + + + /// + /// 管线自动缩进 菜单 + /// + /// + /// + private void 管线自动缩进buttonItem140_Click(object sender, EventArgs e) + { + FrmPipelineIndented frm = new FrmPipelineIndented(globeControl1, m_PipelineLayerNames, workwellLayerNames); + 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 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); + // } + //} + + /// + /// 统计指定图层在指定范围内的所有feature对象 + /// + /// + /// + /// + 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) + { + 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 setLayerVisible(string layerName) + { + GSOLayer templayer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + if (templayer != null) + { + templayer.Visible = false; + } + globeControl1.Globe.Refresh(); + } + + /// + /// 连接数据库 + /// + /// + /// + private void buttonItem129_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL4_1.Text); + + FrmDatabaseParaSetting2 frm = new FrmDatabaseParaSetting2(globeControl1); + if (frm.ShowDialog() == DialogResult.OK) + { + ds = FrmDatabaseParaSetting2.ds; + if (ds != null) + { + ds.IsCloseSaved = false; + } + } + } + + /// + /// 一键审核---导入数据 + /// + /// + /// + private void buttonItem127_Click_2(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, "打开数据"); + + try + { + //if (shds == null) + //{ + //没连的话,直接连接审核库; //审核库配置读配置文件 + string dbIp = Utility.sgdbip; + string database = Utility.sgdbname; + string user = Utility.sgdbuser; + string pass = Utility.sgdbpwd; + /* + 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; + //} + } + catch (Exception ex) + { + LogError.PublishError(ex); + MessageBox.Show("内存过载请清理内存,并重新启动规划分析!", "提示"); + return; + } + + } + + /// + ///自动导出图片 + /// + /// + /// + private void buttonItem130_Click_1(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, "导出审核图"); + + 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))); + */ + + int mapWidth = 0; + int mapHeight = 0; + Point pt = getUpperLeftPoint(pt1, pt2, out mapWidth, out mapHeight); + int rightBottomX = pt.X + mapWidth; + int rightBottomY = pt.Y + mapHeight; + Image myImg = new Bitmap(mapWidth, mapHeight); + Graphics g = Graphics.FromImage(myImg); + g.CopyFromScreen(pt, new Point(0, 0), new Size(rightBottomX, rightBottomY)); + + 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; + } + } + } + /// + /// 一键审核功能 + ///
+ /// + /// + private void buttonItem128_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItem128.Text); + //垂直净距标准 + + frmSh = new FrmYJSHTC(globeControl1, globeControl2,layerTree); + + if (frmSh.ShowDialog() == DialogResult.OK) + { + frmWait = new FrmWait("一键审核……"); + frmWait.Location = new Point(this.Width - frmWait.Width - 10, this.Height - frmWait.Height - 50); + frmWait.Owner = this; + frmWait.Show(); + Thread thread = new Thread(new ThreadStart(doWork)); + thread.IsBackground = true; + thread.Start(); + } + } + + void doWork() + { + FrmShResult frmShResult = null; + + double dVerticalJingJuBiaoZhun = 1, dHorizontalJingJuBiaoZhun = 1; + if (frmSh.rukuLayer != null) + { + #region + this.Invoke((EventHandler)delegate + { + try + { + List managerLayerList = new List(); + for (int i = 0; i < layerManagerNode.Nodes.Count; i++) + { + managerLayerList.Add(layerManagerNode.Nodes[i].Text); + } + if (!managerLayerList.Contains(frmSh.rukuLayer.Caption)) + { + TreeNode node = new TreeNode(); + node.Tag = frmSh.rukuLayer; + node.Text = frmSh.rukuLayer.Dataset.Caption; + node.ImageIndex = 0; + node.SelectedImageIndex = 0; + node.Checked = frmSh.rukuLayer.Visible; + layerManagerNode.Nodes.Insert(0, node); + layerManagerNode.Expand(); + } + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "提示"); + } + }); + #endregion + + shlayername = frmSh.rukuLayer.Name; + globeControl1.Refresh(); + } + + if (frmShResult != null && !frmShResult.IsDisposed) + { + try + { + clearFeatureHighLight(); + ClearRedlineAnalyseResult(); + frmShResult.Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message); + } + } + + 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.analysis(); + + //MainFrm窗体显示控制,回到一键审核Tab + this.Invoke((EventHandler)delegate + { + frmShResult.Show(); + frmWait.Close(); + //将tab页恢复到一键审核 + ribbonTabItem11.Checked = true; + try + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + //zhanshi = false; + splitContainer1.Panel2Collapsed = true; + + panelOfTable.Visible = false; + legendSC.Visible = false; + legendSG.Visible = false; + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + } + catch (Exception ex) + { + MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + + }); + + boolfrmShResult = true; + } + else + { + + } + } + + + /// + /// 清除渲染结果 + /// + 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(); + } + /// + /// 已审核的图层 + /// + /// + /// + private void buttonItem132_Click_1(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItem132.Text); + + if (shds == null) + { + //没连的话,直接连接审核库; //审核库配置读配置文件 + string dbIp = Utility.sgdbip; + string database = Utility.sgdbname; + string user = Utility.sgdbuser; + string pass = Utility.sgdbpwd; + + /* + 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; + //} + + } + /// + /// 审核入库 + /// + /// + /// + private void buttonItem133_Click_1(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, "审核入库"); + FrmShRK frmShrk = new FrmShRK(globeControl1); + frmShrk.Show(); + } + /// + /// 模拟设计修改 + /// + /// + /// + private void buttonItem134_Click_1(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, "模拟设计修改"); + + 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 + { + + } + + } + + + /// + /// 绘制垂线 + /// + /// + /// + 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); + } + /// + /// 比较两个点是否是同一个点 + /// + /// + /// + /// + 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; + } + /// + /// 获得点到线的垂线距离及垂点 + /// + /// + /// + /// + /// + 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); + 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]; + } + /// + /// 获得斜率 + /// + /// + /// + /// + /// + /// + /// + 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); + } + } + /// + /// 根据默认投影参数,经纬度转xyz + /// + /// + /// + /// + 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; + } + /// + /// 根据投影参数,经纬度转xyz + /// + /// + /// + /// + /// + 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; + } + /// + /// 根据默认投影参数,xyz转经纬度 + /// + /// + /// + /// + 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; + } + /// + /// 根据投影参数,Xyz转经纬度 + /// + /// + /// + /// + /// + 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; + } + /// + /// 获得inpolygon的管线长度 + /// + /// + 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; + } + + + /// + /// 一键审核中调节透明度 + /// + /// + /// + private void sliderItem1_ValueChanged(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.sliderItem1.Text); + + globeControl1.Globe.GroundOpaque = 100 - sliderItem1.Value; + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(roadLayerName);//("180fd"); + if (layer != null) + { + layer.Opaque = 100 - sliderItem1.Value; + } + + optiValue = sliderItem1.Value; + } + /// + /// 红线审核中的透明度分析 + /// + /// + /// + private void sliderItem3_ValueChanged(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.sliderItem3.Text); + + globeControl1.Globe.GroundOpaque = 100 - sliderItem3.Value; + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(roadLayerName);//("180fd"); + if (layer != null) + { + layer.Opaque = 100 - sliderItem3.Value; + } + optiValue = sliderItem3.Value; + } + + #region yanxiaowei + //初始化DataGridViewX1控件 + public delegate void DataGridViewDelegate(DataTable dt, string strLable, string strLayer, bool initDataGrid); + /// + /// 代理函数,操作DatgridViewX1 + /// + /// + /// + public void InitDataGridViewX1(DataTable dt, string strLable, string strLayer, bool initDataGrid) + { + if (initDataGrid == true) + { + dataGridViewX1.DataSource = dt; + panelOfTable.Visible = true; + toolStripNumbers.Text = strLable; + dataGridViewX1.Tag = strLayer; + } + else + { + dataGridViewX1.DataSource = null; + dataGridViewX1.Refresh(); + panelOfTable.Visible = false; + toolStripNumbers.Text = ""; + dataGridViewX1.Tag = ""; + globeControl1.Globe.MemoryLayer.RemoveAllFeature();//清除双击产生的标注 + } + } + FrmAnalysisGuiHuaResult from; + /// + /// 主窗体下方属性表格 双击定位 功能 + /// + /// + /// + private void dataGridViewX1_MouseDoubleClick(object sender, MouseEventArgs e) + { + if (redSH == false) + { + 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 if (dataGridViewX1.Columns.Contains("标识器编号")) + { + featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["标识器编号"].Value.ToString(); + } + featureName = featureName.Trim(); + + GSOLayer layer = null; + layer = globeControl1.Globe.Layers.GetLayerByCaption(dataGridViewX1.Tag.ToString()); + + if (layer == null) return; + + GSOFeatures features = layer.GetFeatureByName(featureName, false); + if (features.Length == 0) return; + GSOFeature rowFeature = features[0]; + + ClassSearchAnalysis.AddMakerToLineFeature(globeControl1, rowFeature); + + } + } + } + else + { + if (e.Button == MouseButtons.Left) + { + if (from != null && !from.IsDisposed) + { + try + { + from.Close(); + } + catch (Exception ex) + { + LogError.PublishError(ex); + } + } + try + { + DataGridView.HitTestInfo hittestinfo = dataGridViewX1.HitTest(e.X, e.Y); + if (hittestinfo.RowIndex >= 0) + { + string layer = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["管线类型"].Value.ToString(); + string hxName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["红线编号"].Value.ToString(); + FrmAnalysisGuiHuaResult frm = new FrmAnalysisGuiHuaResult(globeControl1, lineStruct, featsList, + panelOfTable, dataGridViewX1, layer, hxName); + frm.Location = new Point(this.Width - frm.Width - 10, this.Height - frm.Height - 20); + frm.Show(this); + + from = frm; + } + } + catch (Exception ex) + { + LogError.PublishError(ex); + } + } + } + } + + /// + /// 空间查询 + /// + /// + /// + private void buttonItemSearch1_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemSearch1.Text); + + trackflag = "PipelineSpatialQuery"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; + + } + /// + /// 关键字查询 + /// + /// + /// + private void buttonItemSearch9_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch9.Text); + + FrmKeywordQuery.ShowForm(globeControl1, m_PipelineLayerNames, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 编号查询 + /// + /// + /// + private void buttonItemSearch2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch2.Text); + + FrmCodingQuery.ShowForm(globeControl1, m_PipelineLayerNames, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 坐标查询 + /// + /// + /// + private void buttonItemSearch3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch3.Text); + + FrmSetLatLonPos.ShowForm(globeControl1); + } + /// + /// 附属物查询 + /// + /// + /// + private void buttonItemSearch10_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch10.Text); + + FrmFittingQuery.ShowForm(globeControl1, instrumenLayerNames, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 管径查询 + /// + /// + /// + private void buttonItemSearch4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch4.Text); + + FrmDiameterQuery.ShowForm(globeControl1, m_PipelineLayerNames, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 材质查询 + /// + /// + /// + private void buttonItemSearch5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch5.Text); + + FrmMaterialSel.ShowForm(globeControl1, m_PipelineLayerNames, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 基本查询 + /// + /// + /// + private void buttonItemSearch6_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch6.Text); + + FrmBasicQuery.ShowForm(globeControl1, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 复合查询 + /// + /// + /// + private void buttonItemSearch7_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch7.Text); + + FrmQuerySQL.ShowForm(globeControl1, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 关联查询 + /// + /// + /// + private void buttonItemSearch8_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch8.Text); + + if (globeControl1.Globe.SelObjectCount != 1) + { + MessageBox.Show("请选中一个对象!", "提示"); + return; + } + + 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 || (feature.Geometry.Type == EnumGeometryType.GeoPolygon3D + || feature.Geometry.Type == EnumGeometryType.GeoWater)) + return; + else + { + ClassSearchAnalysis.ResultRelationAnalysis(globeControl1, feature, valueLayerNames, workwellLayerNames, + instrumenLayerNames, pipefittingLayerNames, m_PipelineLayerNames, valueAllowance); + } + } + } + #endregion + /// + /// 清除分析 + /// + /// + /// + private void buttonItemClear_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemClear.Text); + + globeControl1.Globe.ClearMeasure(); + layerTemp.RemoveAllFeature(); + layerTemp2.RemoveAllFeature(); + buttonItemLS5.Checked = false; + + dataGridViewX1.DataSource = null; + panelOfTable.Visible = false; + + 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); + + NetworkAnalysisTool.ClearAllTopAnalysis(this.globeControl1); + // 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();//清除所有坑 + + 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(); + } + } + + clearFeatureHighLight();//取消管线高亮 + + GSOLayer layerGround = globeControl1.Globe.Layers.GetLayerByCaption(roadLayerName);//("180fd"); + if (layerGround != null) + { + layerGround.Visible = true; + } + globeControl1.Refresh(); + globeControl2.Refresh(); + ClearRedlineAnalyseResult(); + globeControl1.Globe.Action = EnumAction3D.ActionNull; + } + /// + /// 管线长度全区域统计 + /// + /// + /// + private void buttonItemTJ1_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管线长度统计"); + + FrmAllPipelineStatis frm = new FrmAllPipelineStatis(globeControl1,null, new DataGridViewDelegate(InitDataGridViewX1), m_PipelineLayerNames); + frm.Show(this); + } + /// + /// 管线长度绘制区域统计 + /// + /// + /// + private void buttonItemTJ1_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管线长度统计"); + + trackflag = "PipelineDistanceStatistics"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; + } + /// + /// 阀门数量全区域统计 + /// + /// + /// + private void buttonItemTJ2_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "阀门数量统计"); + + FrmValveStatistics frm = new FrmValveStatistics(globeControl1, null, new DataGridViewDelegate(InitDataGridViewX1)); + frm.Show(this); + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + } + /// + /// 阀门数量绘制区域统计 + /// + /// + /// + private void buttonItemTJ2_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "阀门数量统计"); + + trackflag = "valvequery"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; + } + /// + /// 井盖数量全区域统计 + /// + /// + /// + private void buttonItemTJ3_ALL_Click(object sender, EventArgs e) +<<<<<<< HEAD + { + //日志记录 + LogManager.saveLog(Utility.userName, "井盖数量统计"); +======= + { +>>>>>>> d2d0088a6b3c53c1a96b7f1997f4d3443c0ee8c0 + FrmAllWorkWellStatis frm = new FrmAllWorkWellStatis(globeControl1, null, new DataGridViewDelegate(InitDataGridViewX1)); + frm.Show(this); + } + /// + /// 井盖数量绘制区域统计 + /// + /// + /// + private void buttonItemTJ3_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "井盖数量统计"); + + trackflag = "workwellquery"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; + } + /// + /// 管径分段统计全区域统计 + /// + /// + /// + private void buttonItemTJ4_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管径分段统计"); + + Frmpipediameterstatis.ShowForm(globeControl1, m_PipelineLayerNames, 0); + } + /// + /// 管径分段统计绘制区域统计 + /// + /// + /// + private void buttonItemTJ4_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管径分段统计"); + + trackflag = null; + Frmpipediameterstatis.ShowForm(globeControl1, m_PipelineLayerNames, 1); + } + /// + /// 埋深分段统计全区域统计 + /// + /// + /// + private void buttonItemTJ5_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "埋深分段统计"); + FrmpipeDeepstatis.ShowForm(globeControl1, m_PipelineLayerNames, 0); + } + /// + /// 埋深分段统计绘制区域统计 + /// + /// + /// + private void buttonItemTJ5_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "埋深分段统计"); + trackflag = null; + FrmpipeDeepstatis.ShowForm(globeControl1, m_PipelineLayerNames, 1); + } + /// + /// 管径分类统计全区域统计 + /// + /// + /// + private void buttonItemTJ6_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管径分类汇总"); + + FrmpipeDiametergather.ShowForm(globeControl1, m_PipelineLayerNames, 0); + } + /// + /// 管径分类统计绘制区域统计 + /// + /// + /// + private void buttonItemTJ6_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管径分类汇总"); + + trackflag = null; + FrmpipeDiametergather.ShowForm(globeControl1, m_PipelineLayerNames, 1); + } + /// + /// 材质分类统计全区域统计 + /// + /// + /// + private void buttonItemTJ7_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "材质分类汇总"); + + FrmpipeMaterialGather.ShowForm(globeControl1, m_PipelineLayerNames, 0); + } + /// + /// 材质分类统计绘制区域统计 + /// + /// + /// + private void buttonItemTJ7_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "材质分类汇总"); + + trackflag = null; + FrmpipeMaterialGather.ShowForm(globeControl1, m_PipelineLayerNames, 1); + } + /// + /// 附属物分类统计全区域统计 + /// + /// + /// + private void buttonItemTJ8_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "附属物分类汇总"); + + FrmAccessoriesgather.ShowForm(globeControl1, instrumenLayerNames, 0); + } + /// + /// 附属物分类统计绘制区域统计 + /// + /// + /// + private void buttonItemTJ8_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "附属物分类汇总"); + + trackflag = null; + FrmAccessoriesgather.ShowForm(globeControl1, instrumenLayerNames, 1); + } + /// + /// 碰撞分析 + /// + /// + /// + private void buttonItemFX1_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_4.Text); + + this.dataGridViewX4.Size = new System.Drawing.Size(195, 120); + 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(); + } + /// + /// 覆土分析 + /// + /// + /// + private void buttonItemFX1_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX5_1.Text); + this.dataGridViewX6.Size = new System.Drawing.Size(195, 120); + 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(); + } + /// + /// 间距分析 + /// + /// + /// + private void buttonItemFX1_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX1_3.Text); + + this.dataGridViewLineList.Size = new System.Drawing.Size(185, 120); + 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(); + } + /// + /// 垂直净距分析 + /// + /// + /// + private void buttonItemFX1_4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX1_4.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(); + } + /// + /// 水平净距分析 + /// + /// + /// + private void buttonItemFX1_5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_6.Text); + this.dataGridViewX8.Size = new System.Drawing.Size(185, 120); + 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(); + } + + #region Predaotr,断面分析 + /// + /// 横断面分析 + /// + /// + /// + private void buttonItemFX2_1_Click(object sender, EventArgs e) + { + globeControl1.Globe.Action = EnumAction3D.TrackPolyline; + globeControl1.Globe.TrackPolylineTool.VerticalLineVisible = true; + globeControl1.Globe.TrackPolylineTool.TrackMode = EnumTrackMode.SpaceTrack; + trackPolylineEndMode = EnumTrackPolylineEndMode.HDM_Analysis; + + } + /// + /// 纵断面分析 + /// + /// + /// + private void buttonItemFX2_2_Click(object sender, EventArgs e) + { + if (globeControl1.Globe.SelObjectCount<1) + { + MessageBox.Show("请选择一条或者多条管线!", "提示", MessageBoxButtons.OK, + MessageBoxIcon.Information); + return; + } + 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); + } + } + List feats = SectionAnalysisTool.ZDMAnalysis(selectFeatures); + if (feats != null && feats.Count >= 1) + { + FrmProfileAnalysis frm = new FrmProfileAnalysis(globeControl1, feats); + frm.Show(this); + } + } + /// + /// 道路断面分析 + /// + /// + /// + private void buttonItemFX2_3_Click(object sender, EventArgs e) + { + globeControl1.Globe.Action = EnumAction3D.TrackPolyline; + globeControl1.Globe.TrackPolylineTool.VerticalLineVisible = true; + globeControl1.Globe.TrackPolylineTool.TrackMode = EnumTrackMode.SpaceTrack; + trackPolylineEndMode = EnumTrackPolylineEndMode.DLDM_Analysis; + + } + /// + /// 基线剖面分析 + /// + /// + /// + private void buttonItemFX2_4_Click(object sender, EventArgs e) + { + globeControl1.Globe.Action = EnumAction3D.TrackPolyline; + globeControl1.Globe.TrackPolylineTool.VerticalLineVisible = true; + globeControl1.Globe.TrackPolylineTool.TrackMode = EnumTrackMode.SpaceTrack; + trackPolylineEndMode = EnumTrackPolylineEndMode.JXPM_Analysis; + + } + + #endregion + /// + /// 创建拓扑 + /// + /// + /// + private void buttonItemFX3_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX3_1.Text); + + FrmGenAndFaMenTopu frm = new FrmGenAndFaMenTopu(globeControl1, m_PipelineLayerNames, valueLayerNames); + frm.Show(this); + } + #region Predator :拓扑分析 + /// + /// 上游分析 + /// + /// + /// + private void buttonItemFX3_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX3_2.Text); + NetworkTraceUpDown(true); + } + /// + /// 下游分析 + /// + /// + /// + private void buttonItemFX3_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX3_3.Text); + NetworkTraceUpDown(false); + } + + /// + /// 上下游追踪 功能 + /// + /// + private void NetworkTraceUpDown(Boolean bTraceUp) + { + GSOFeature selLineFeature = globeControl1.Globe.SelectedObject; + if (selLineFeature == null || selLineFeature.Geometry == null || selLineFeature.Geometry.Type != EnumGeometryType.GeoPolyline3D) + { + MessageBox.Show("请点击“编辑”—“选中对象”选择一条线!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); + return; + } + GSOLayer selLayer = globeControl1.Globe.SelectedObjectLayer; + + NetworkAnalysisTool.TraceUpDownAnalysis(bTraceUp, + selLineFeature, selLayer); + } + + /// + /// 流向分析 + /// + /// + /// + private void buttonItemFX3_4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX3_4.Text); + + FrmFlow frm = new FrmFlow(globeControl1, m_PipelineLayerNames); + frm.Show(this); + } + /// + /// 关阀分析 + /// + /// + /// + private void buttonItemFX3_5_Click(object sender, EventArgs e) + { + if (globeControl1.Globe.SelObjectCount < 1) + { + MessageBox.Show("请选中至少一根管线!!"); + buttonItemFX3_5.Checked = false; + return; + } + GSOLayer resLayer = null; + GSOFeature resFeature = null; + globeControl1.Globe.GetSelectObject(0, out resFeature, out resLayer); + + String pipeLayerName = resLayer.Caption; + String pipeLayerNamePrefix = pipeLayerName.Substring(0, pipeLayerName.IndexOf("管线")); + GSOLayer valveLayer = globeControl1.Globe.Layers[pipeLayerNamePrefix + "阀门"]; + if (valveLayer == null) + { + MessageBox.Show("无" + pipeLayerNamePrefix+"阀门图层", "提示"); + return; + } + + GSOFeatures valveFeats = NetworkAnalysisTool.CloseValvesAnalysis(resFeature, + resLayer, valveLayer); + + if (valveFeats != null) + { + FrmCloseValves frm = new FrmCloseValves(this.globeControl1, valveFeats); + frm.Show(this); + } + else + { + MessageBox.Show("未找到关闭阀门"); + } + } + + /// + /// 连通分析 + /// + /// + /// + private void buttonItemFX3_6_Click(object sender, EventArgs e) + { + if (globeControl1.Globe.SelObjectCount < 2) + { + MessageBox.Show("请选中至少两个管线!!"); + buttonItemFX3_6.Checked = false; + return; + } + GSOFeature selFeat0, selFeat1; + GSOLayer layer0,layer1; + globeControl1.Globe.GetSelectObject(0, out selFeat0, out layer0); + globeControl1.Globe.GetSelectObject(1, out selFeat1, out layer1); + + if (!layer0.IsSameInnerObject(layer1)) + { + MessageBox.Show("不在同一个图层!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); + buttonItemFX3_6.Checked = false; + return; + } + NetworkAnalysisTool.ConnexityAnalysis(selFeat0, selFeat1, layer0); + } + /// + /// 爆管分析 + /// + /// + /// + private void buttonItemFX3_7_Click(object sender, EventArgs e) + { + NetworkTraceUpDown(true); //上游追踪: + + GSOFeature selLineFeature = globeControl1.Globe.SelectedObject; + if (selLineFeature == null || selLineFeature.Geometry == null || selLineFeature.Geometry.Type != EnumGeometryType.GeoPolyline3D) + { + MessageBox.Show("请点击“编辑”—“选中对象”选择一条线!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); + return; + } + GSOLayer selLayer = globeControl1.Globe.SelectedObjectLayer; + + NetworkAnalysisTool.ExplodeAnalysis(this.globeControl1,selLineFeature,selLayer); + + this.buttonItemFX3_5_Click(sender, e); //关阀分析: + + } + + #endregion + /// + /// 多边形开挖 + /// + /// + /// + private void buttonItemFX4_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_1.Text); + + trackflag = "pit"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; //是这个么?是的,在模型上 + } + /// + /// 挖方量分析 + /// + /// + /// + private void buttonItemFX4_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_2.Text); + + trackflag = "digFillAnalysis"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; + ActionToolMenuChecked(); + } + /// + /// 沿线开挖 + /// + /// + /// + private void buttonItemFX4_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_3.Text); + + if (!buttonItemFX4_3.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; + buttonItemFX4_3.Checked = true; + } + } + else + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + buttonItemFX4_3.Checked = false; + globeControl1.Globe.TrackPolylineTool.VerticalLineVisible = false; + } + ActionToolMenuChecked(); + } + /// + /// 创建隧道 + /// + /// + /// + private void buttonItemFX4_4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_4.Text); + + 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("场景中未加载隧道图层!", "提示"); + } + } + /// + /// 隐藏隧道 + /// + /// + /// + private void buttonItemFX4_5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_5.Text); + + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption("隧道"); + if (layer != null) + { + layer.Visible = !layer.Visible; + } + } + /// + /// 删除隧道 + /// + /// + /// + private void buttonItemFX4_6_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_6.Text); + + 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("请选中要删除的隧道!", "提示"); + } + } + /// + /// 通视分析 + /// + /// + /// + private void buttonItemFX5_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX5_1.Text); + + if (globeControl1.Globe.Action != EnumAction3D.VisibilityAnalysis) + { + //btnSpaceVisibilityAnalysis.Checked = true; + globeControl1.Globe.Action = EnumAction3D.VisibilityAnalysis; + } + else + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + // SetButtonChecked(); + } + } + /// + /// 可视域分析 + /// + /// + /// + private void buttonItemFX5_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX5_2.Text); + + globeControl1.Globe.Action = EnumAction3D.ViewshedAnalysis; + } + /// + /// 可视包络分析 + /// + /// + /// + private void buttonItemFX5_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX5_3.Text); + + globeControl1.Globe.Action = EnumAction3D.ViewEnvelopeAnalysis; + } + /// + /// 缓冲区分析 + /// + /// + /// + private void buttonItemFX6_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX6_1.Text); + + GSOFeature feat = globeControl1.Globe.SelectedObject; + if (feat == null) + { + MessageBox.Show("请选择要分析的要素!"); + return; + } + if (feat.Geometry.Type == EnumGeometryType.GeoPolyline3D) + { + GSOGeoPolyline3D line1 = feat.Geometry as GSOGeoPolyline3D; + if (line1 == null) + { + MessageBox.Show("请选择一条管线!"); + return; + } + + FrmBufferAnalysis frm = new FrmBufferAnalysis(globeControl1, line1, layerTemp); + frm.Show(this); + } + else + { + FrmBufferAnalysisBSQ frm = new FrmBufferAnalysisBSQ(globeControl1, layerTemp, bsqPT); + frm.Show(this); + } + + } + /// + /// 附属物分析 + /// + /// + /// + private void buttonItemFX6_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX6_2.Text); + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + FrmAccessoryAnalysis dlg = new FrmAccessoryAnalysis(globeControl1, layerTemp); + dlg.Show(this); + } + /// + /// 无源淹没分析 + /// + /// + /// + private void buttonItemFX6_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX6_3.Text); + + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + trackflag = "FloodAnalysis"; + } + /// + /// 水平距离 + /// + /// + /// + private void buttonItemLS1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS1.Text); + + globeControl1.Globe.Action = EnumAction3D.MeasureDistance; + globeControl1.Globe.DistanceRuler.SpaceMeasure = false; + buttonItemLS5.Checked = false; + } + /// + /// 垂直距离 + /// + /// + /// + private void buttonItemLS2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS2.Text); + + buttonItemLS5.Checked = false; + globeControl1.Globe.Action = EnumAction3D.MeasureHeight; + globeControl1.Globe.DistanceRuler.SpaceMeasure = false; + } + /// + /// 空间距离 + /// + /// + /// + private void buttonItemLS3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS3.Text); + + buttonItemLS5.Checked = false; + globeControl1.Globe.Action = EnumAction3D.MeasureDistance; + globeControl1.Globe.DistanceRuler.SpaceMeasure = true; + } + /// + /// 地表距离 + /// + /// + /// + private void buttonItemLS4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS4.Text); + + buttonItemLS5.Checked = false; + globeControl1.Globe.Action = EnumAction3D.MeasureDistance; + globeControl1.Globe.DistanceRuler.SpaceMeasure = false; + } + /// + /// 高度量算 + /// + /// + /// + private void buttonItemLS5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS5.Text); + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + buttonItemLS5.Checked = !buttonItemLS5.Checked; + if (buttonItemLS5.Checked) + { + globeControl1.Globe.Action = EnumAction3D.SelectObject; + } + } + /// + /// 水平面积 + /// + /// + /// + private void buttonItemLS6_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS6.Text); + + buttonItemLS5.Checked = false; + globeControl1.Globe.Action = EnumAction3D.MeasureArea; + globeControl1.Globe.AreaRuler.SpaceMeasure = true; + } + /// + /// 地表面积 + /// + /// + /// + private void buttonItemLS7_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS7.Text); + + buttonItemLS5.Checked = false; + globeControl1.Globe.Action = EnumAction3D.MeasureArea; + globeControl1.Globe.AreaRuler.SpaceMeasure = false; + + } + + # region Fan 重构标注代码 + /// + /// 标高标注 + /// + /// + /// + private void buttonItemSZ1_Click(object sender, EventArgs e) + { + GSOFeature resFeature = IsPipeLineOfSelectedObj(); + if (resFeature == null) + { + MessageBox.Show("请选中一根管线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + GSOGeoPolyline3D selLine = resFeature.Geometry as GSOGeoPolyline3D; + if (selLine[0].Count <= 1) + { + return; + } + + MarkTools.getInstance().showMarker(resFeature, + globeControl1, EnumMarkLayer.Mark_Altitude, ""); + } + /// + /// 管径标注 + /// + GSOFeature radiusMarkerFeature; + private void buttonItemBZ2_Click(object sender, EventArgs e) + { + GSOFeature resFeature = IsPipeLineOfSelectedObj(); + if (resFeature == null) + { + MessageBox.Show("请选中一根管线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + GSOGeoPolyline3D selLine = resFeature.Geometry as GSOGeoPolyline3D; + if (selLine[0].Count <= 1) + { + return; + } + + MarkTools.getInstance().showMarker(resFeature, + globeControl1, EnumMarkLayer.Mark_Diameter, ""); + } + /// + /// 埋深标注 + /// + /// + /// + private void buttonItemBZ3_Click(object sender, EventArgs e) + { + GSOFeature resFeature = IsPipeLineOfSelectedObj(); + if (resFeature == null) + { + MessageBox.Show("请选中一根管线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + GSOGeoPolyline3D selLine = resFeature.Geometry as GSOGeoPolyline3D; + if (selLine[0].Count <=1) + { + return; + } + + MarkTools.getInstance().showMarker(resFeature, + globeControl1, EnumMarkLayer.Mark_Depth, ""); + + } + /// + /// 坐标标注 + /// + /// + /// + private void buttonItemBZ4_Click(object sender, EventArgs e) + { + GSOFeature resFeature = IsPipeLineOfSelectedObj(); + if (resFeature == null) + { + MessageBox.Show("请选中一根管线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + GSOGeoPolyline3D selLine = resFeature.Geometry as GSOGeoPolyline3D; + if (selLine[0].Count <= 1) + { + return; + } + MarkTools.getInstance().showMarker(resFeature, + globeControl1, EnumMarkLayer.Mark_Location, ""); + } + /// + /// 距离标注 + /// + bool distanceMarker = false; + private void buttonItemBZ5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBZ5.Text); + + globeControl1.Globe.Action = EnumAction3D.TrackPolyline; + //globeControl1.Globe.DistanceRuler.MeasureMode = EnumDistanceMeasureMode.HVSLineMeasure; + distanceMarker = true; + } + /// + /// 自定义标注 + /// + /// + /// + private void buttonItemBZ6_Click(object sender, EventArgs e) + { + GSOFeature f = globeControl1.Globe.SelectedObject; + GSOLayer l = globeControl1.Globe.SelectedObjectLayer; + FrmCustomLabel frm = new FrmCustomLabel(globeControl1, l, f); + if (frm.ShowDialog() == DialogResult.OK) + { + MarkTools.getInstance().showMarker(f, globeControl1, EnumMarkLayer.Mark_Custom, frm.labelText); + } + } + /// + /// 扯旗标注 + /// + /// + /// + private void buttonItemBZ7_Click(object sender, EventArgs e) + { + GSOFeature f = globeControl1.Globe.SelectedObject; + GSOLayer l = globeControl1.Globe.SelectedObjectLayer; + FrmMarker frm = new FrmMarker(); + if (frm.ShowDialog() == DialogResult.OK) + { + MarkTools.getInstance().showMarker(f, globeControl1, EnumMarkLayer.Mark_Custom, frm.markerContent); + } + } + /// + /// 坡度标注 + /// + /// + /// + private void buttonItemBZ8_Click(object sender, EventArgs e) + { + GSOFeature resFeature = IsPipeLineOfSelectedObj(); + if (resFeature == null) + { + MessageBox.Show("请选中一根管线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + GSOGeoPolyline3D selLine = resFeature.Geometry as GSOGeoPolyline3D; + if (selLine[0].Count <= 1) + { + return; + } + + MarkTools.getInstance().showMarker(resFeature, + globeControl1, EnumMarkLayer.Mark_Slope, ""); + } + /// + /// 属性标注 + /// + /// + /// + private void buttonItemBZ9_Click(object sender, EventArgs e) + { + GSOFeature f = globeControl1.Globe.SelectedObject; + GSOLayer l = globeControl1.Globe.SelectedObjectLayer; + FrmPropertiesMarker frm = new FrmPropertiesMarker(globeControl1, l, f); + if (frm.ShowDialog() == DialogResult.OK) + { + MarkTools.getInstance().showMarker(f, globeControl1, EnumMarkLayer.Mark_Property, frm.labelText); + } + } + /// + /// 红线工具 + /// + /// + /// + private void buttonItemBZ10_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBZ10.Text); + 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; + } + } + /// + /// 标注管理 + /// + /// + /// + private void buttonItemBZ11_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBZ11.Text); + + buttonItemBZ11.Checked = !buttonItemBZ11.Checked; + 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 (buttonItemBZ11.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(); + } + } + + #endregion + /// + /// 飞行到目标点 + /// + /// + /// + private void buttonItemFXGJ1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFXGJ1.Text); + + FrmSetFlytoPos.ShowForm(globeControl1); + + } + /// + /// 自定义飞行 + /// + /// + /// + private void buttonItemFXGJ2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFXGJ2.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); + } + } + /// + /// 绕中心点飞行 + /// + /// + /// + private void buttonItemFXGJ3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFXGJ3.Text); + + globeControl1.Globe.FlyAroundCenter(10000, EnumFlyRepeatValueType.MiliSeconds); + globeControl1.Globe.CurFlyID = 1; + } + /// + /// 绕眼睛飞行 + /// + /// + /// + private void buttonItemFXGJ4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFXGJ4.Text); + + globeControl1.Globe.FlyAroundEye(720, EnumFlyRepeatValueType.Degrees); + globeControl1.Globe.CurFlyID = 2; + } + + /// + /// 权限管理 + /// + /// + /// + private void buttonItemXT1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT1.Text); + + FrmUserRoleMgr frm = new FrmUserRoleMgr(); + frm.ShowDialog(); + } + /// + /// 数据库管理 + /// + /// + /// + private void buttonItemXT2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT2.Text); + + //查看数据库列表 + FrmDbManager frm = new FrmDbManager(); + frm.ShowDialog(); + } + /// + /// 用户列表 + /// + /// + /// + private void buttonItemXT3_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT3_1.Text); + + FrmUserManager frm = new FrmUserManager(); + frm.ShowDialog(); + } + /// + /// 创建新用户 + /// + /// + /// + private void buttonItemXT3_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT3_2.Text); + + FrmUserAdd frm = new FrmUserAdd(-1); + frm.ShowDialog(); + } + /// + /// 人员修改 + /// + /// + /// + private void buttonItemXT4_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT4_2.Text); + + FrmAppUSER appUSER = new FrmAppUSER(); + appUSER.ShowDialog(); + } + /// + /// 增加人员 + /// + /// + /// + private void buttonItemXT4_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT4_1.Text); + + FrmAppUSERRESET appUSERRESET = new FrmAppUSERRESET(); + appUSERRESET.ShowDialog(); + } + /// + /// 统计数据 + /// + /// + /// + private void buttonItemZTT1_Click(object sender, EventArgs e) + { + ////日志记录 + //LogManager.saveLog(Utility.userName, this.buttonItemZTT1.Text); + + //PATM patm = new PATM(); + //patm.operation = "Statistic"; + //patm.Text = "统计专题图管理"; + //patm.ShowDialog(); + } + /// + /// 热点功能统计 + /// + /// + /// + private void buttonItemZTT2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT2.Text); + + FrmHotFuncStat frmhfs = new FrmHotFuncStat(); + frmhfs.ShowDialog(); + } + + private void buttonItemZTT3_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT3_1.Text); + + FrmAPP appfrm = new FrmAPP("专题图申请"); + appfrm.ShowDialog(); + } + + private void buttonItemZTT3_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT3_2.Text); + + FrmAPPFORASK appForask = new FrmAPPFORASK("专题图审核"); + appForask.ShowDialog(); + } + + private void buttonItemZTT3_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT3_3.Text); + + FrmAPPregion appregion = new FrmAPPregion("专题图审核"); + appregion.ShowDialog(); + } + + private void buttonItemZTT4_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT4_1.Text); + + FrmAPP appfrm = new FrmAPP("打印申请"); + appfrm.ShowDialog(); + } + + private void buttonItemZTT4_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT4_2.Text); + + FrmAPPFORASK appForask = new FrmAPPFORASK("打印审核"); + appForask.ShowDialog(); + } + + private void buttonItemZTT4_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT4_3.Text); + + FrmAPPregion appregion = new FrmAPPregion("打印审核"); + appregion.ShowDialog(); + } + + private void buttonItemZTT5_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT5_1.Text); + + FrmAPP appfrm = new FrmAPP("拷贝申请"); + appfrm.ShowDialog(); + } + + private void buttonItemZTT5_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT5_2.Text); + + FrmAPPFORASK appForask = new FrmAPPFORASK("拷贝审核"); + appForask.ShowDialog(); + } + + private void buttonItemZTT5_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT5_3.Text); + + FrmAPPregion appregion = new FrmAPPregion("拷贝审核"); + appregion.Show(); + } + + private int connectServerCount = 0; + + /// + /// 还原球到实测库 + /// + 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); + } + + if (layerManagerNode.Nodes.Count > 0) + { + for (int i = layerManagerNode.Nodes.Count - 1; i >= 0; i--) + { + layerManagerNode.Nodes[i].Remove(); + + } + } + + globeControl1.Refresh(); + + } + + private void buttonItemSPSZ_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSPSZ.Text); + + FrmLayerControl frm = new FrmLayerControl(layerTree, globeControl1, globeControl2); + frm.Show(this); + } + + /// + /// 碰撞审查 + /// + /// + /// + private void buttonItemSH1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSH1.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 buttonItemSH2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSH2.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 buttonItemSH3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSH3.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 buttonItemSH4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSH4.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 buttonItemSH5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSH5.Text); + FrmCityServerLineAnalysis frm = new FrmCityServerLineAnalysis(globeControl1, m_PipelineLayerNames); + frm.Show(this); + } + #region 数据管理-导入文件 + ///// + ///// 数据管理-导入本地坐标系文件 + ///// + ///// + ///// + //private void buttonItemSJGL1_1_Click(object sender, EventArgs e) + //{ + // //日志记录 + // LogManager.saveLog(Utility.userName, this.buttonItemSJGL1_1.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(); + // } + // } + //} + + ///// + ///// 数据管理-导入其他坐标系文件 + ///// + ///// + ///// + //private void buttonItemSJGL1_2_Click(object sender, EventArgs e) + //{ + // //日志记录 + // LogManager.saveLog(Utility.userName, this.buttonItemSJGL1_2.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(); + // } + // } + //} + #endregion + /// + /// 数据质量检查 + /// + /// + /// + private void buttonItemSJGL2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL2.Text); + FrmValiData frm = new FrmValiData(globeControl1); + frm.ShowDialog(); + } + /// + /// 数据预处理 + /// + /// + /// + private void buttonItemSJGL3_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL3.Text); + + FrmEditShapeFile frm = new FrmEditShapeFile(globeControl1); + frm.ShowDialog(this); + } + /// + /// 连接数据库 + /// + /// + /// + private void buttonItemSJGL4_1_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL4_1.Text); + + FrmDatabaseParaSetting frm = new FrmDatabaseParaSetting(globeControl1); + if (frm.ShowDialog() == DialogResult.OK) + { + ds = FrmDatabaseParaSetting.ds; + if (ds != null) + { + ds.IsCloseSaved = false; + } + } + } + /// + /// 管线入库 + /// + /// + /// + private void buttonItemSJGL4_2_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL4_2.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 buttonItemSJGL4_3_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL4_3.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 buttonItemSJGL5_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL5.Text); + + Cyberpipe.Forms.FrmProject frm = new Cyberpipe.Forms.FrmProject(); + frm.ShowDialog(); + } + /// + /// 元数据基本管理 + /// + /// + /// + private void buttonItemSJGL6_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL6_1.Text); + + FrmMetadata frmmd = new FrmMetadata(); + frmmd.ShowDialog(); + } + /// + /// 元数据查询管理 + /// + /// + /// + private void buttonItemSJGL6_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL6_2.Text); + + FrmMetadataStat frmmds = new FrmMetadataStat(); + //frmmds.Show(); + frmmds.ShowDialog(); + } + /// + /// 操作日志管理 + /// + /// + /// + private void buttonItemSJGL7_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL7.Text); + + FrmLogOper frmlo = new FrmLogOper(); + frmlo.ShowDialog(); + } + /// + /// 数据字典管理 + /// + /// + /// + private void buttonItemSJGL8_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL8.Text); + + FrmMDDictory frmmdd = new FrmMDDictory(); + frmmdd.ShowDialog(); + } + /// + /// 数据库备份 + /// + /// + /// + private void buttonItemSJGL9_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL9.Text); + + //新 + FrmBACKORACLE backOracle = new FrmBACKORACLE(); + backOracle.Show(); + } + /// + /// 创建管段 + /// + /// + /// + private void buttonItemBJ1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ1.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; + } + } + /// + /// 创建附属物 + /// + /// + /// + private void buttonItemBJ2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ2.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); + } + } + /// + /// 创建特征管点 + /// + /// + /// + private void buttonItemBJ3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ3.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); + } + } + /// + /// 绘制城市七线 + /// + /// + /// + private void buttonItemBJ4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ4.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; + } + } + } + /// + /// 选中对象 + /// + /// + /// + private void buttonItemBJ5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ5.Text); + + globeControl1.Globe.Action = EnumAction3D.SelectObject; + } + /// + /// 平移对象 + /// + /// + /// + private void buttonItemBJ6_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ6.Text); + + globeControl1.Globe.Action = EnumAction3D.MoveObject; + } + /// + /// 升降对象 + /// + /// + /// + private void buttonItemBJ7_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ7.Text); + + globeControl1.Globe.Action = EnumAction3D.ElevateObject; + } + /// + /// 旋转对象 + /// + /// + /// + private void buttonItemBJ8_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ8.Text); + + globeControl1.Globe.Action = EnumAction3D.RotateObject; + } + /// + /// 连接管段 + /// + /// + /// + private void buttonItemBJ9_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ9.Text); + + if (globeControl1.Globe.SelObjectCount < 2) + { + MessageBox.Show("对不起,请至少选中2个对象!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + return; + } + globeControl1.Globe.InsertJointPipeline(false); + } + /// + /// 后退 + /// + /// + /// + private void buttonItemBJ11_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemBJ11.Text); + globeControl1.Globe.UnDoEdit(); + } + /// + /// 前进 + /// + /// + /// + private void buttonItemBJ12_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemBJ12.Text); + + globeControl1.Globe.ReDoEdit(); + } + /// + /// 导出CAD + /// + /// + /// + private void buttonItemBJ10_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ10_1.Text); + + #region 导出成dxf格式 + List listVectorNames = new List(); + 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(); + #endregion + } + /// + /// 导出矢量 + /// + /// + /// + private void buttonItemBJ10_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ10_2.Text); + + List listVectorNames = new List(); + 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 buttonItemBJ13_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemBJ13.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(); + } + } + MessageBox.Show("删除成功!", "提示"); + } + else + { + MessageBox.Show("请选中要删除的模型!", "提示"); + } + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + } + + private void buttonItemHX1_1_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]; + string filePath = dlg.FileName; + string lastname = Path.GetFileName(filePath); + + 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(); + } + + } + } + } + + public struct LineStruct + { + public string layerName; + public string layerCode; + public string lineLength; + public string hxName; + } + + List lineStruct = new List(); + List featsList = new List(); + + /// + /// 红线审核 + /// + /// + /// + private void buttonItemHX2_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemHX2.Text); + redSH = true; + featsList.Clear(); + lineStruct.Clear(); + List listPipelineLayers = new List(); + + GSOLayer layer = null; + for (int i = 0; i < m_PipelineLayerNames.Count; i++) + { + layer = globeControl1.Globe.Layers.GetLayerByCaption(m_PipelineLayerNames[i]); + if (layer != null) + { + listPipelineLayers.Add(layer); + } + } + //yanxiaowei 重构 + GSOFeatures selectFeatures=new GSOFeatures(); + for (int i = 0; i < globeControl1.Globe.SelObjectCount; i++) + { + GSOFeature feature = null; + globeControl1.Globe.GetSelectObject(i, out feature, out layer); + selectFeatures.Add(feature); + } + DataTable table=new DataTable(); + + ClassGSOTool.CalculateRedLineResult(out table, redSH, selectFeatures, globeControl1, + listPipelineLayers,out lineStruct, out featsList); + + if (table.Rows.Count != 0) + AddDatagridView(table); + else + { + MessageBox.Show("没有侵入地块红线的管线数据!", "提示"); + dataGridViewX1.DataSource = null; + panelOfTable.Visible = false; + return; + } + } + + private void AddDatagridView(DataTable table) + { + dataGridViewX1.DataSource = table; + panelOfTable.Visible = true; + panelOfTable.Height = 200; + toolStripNumbers.Text = "红线审核 |共有:" + table.Rows.Count + "条"; + toolStripDropDownButton3.Visible = true; + } + /// + /// 主窗体 下方的工具条中的 导出.xls文件 按钮事件处理 + /// + /// + /// + private void toolStripDropDownButton3_Click(object sender, EventArgs e) + { + if (dataGridViewX1.Rows.Count == 0) + { + MessageBox.Show("表格内容为空!", "提示"); + return; + } + + string strSaveFile = string.Empty; + SaveFileDialog savefiledialog = new SaveFileDialog(); + savefiledialog.Filter = "Excel文件|*.xls,*.xlsx"; + savefiledialog.AddExtension = true; + savefiledialog.FileName = "红线审核"; + if (savefiledialog.ShowDialog() == DialogResult.OK) + strSaveFile = savefiledialog.FileName; + else return; + + ExpEXCEL.ExpToExcel(dataGridViewX1, strSaveFile, "红线审核", lineStruct, featsList); + MessageBox.Show("导出成功!"); + } + /// + /// 去除集合中重复的管线 + /// + /// + /// + /// + private GSOFeatures getFeaturesByFilter(GSOFeatures features, string fieldName) + { + if (features == null) + { + return null; + } + GSOFeatures featuresGet = new GSOFeatures(); + for (int i = 0; i < features.Length; i++) + { + GSOFeature featureFromFS = features[i]; + string fieldValueFromFS = featureFromFS.GetValue(fieldName).ToString().Trim(); + bool isHas = false; + for (int j = featuresGet.Length - 1; j >= 0; j--) + { + GSOFeature featureFromFSGet = featuresGet[j]; + string fieldValueFromFSGet = featureFromFSGet.GetValue(fieldName).ToString().Trim(); + if (fieldValueFromFS.Equals(fieldValueFromFSGet)) + { + isHas = true; + break; + } + } + if (isHas == false) + { + featuresGet.Add(featureFromFS.Clone()); + } + } + return featuresGet; + } + + private void sliderItem2_ValueChanged(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.sliderItem2.Text); + + globeControl1.Globe.GroundOpaque = 100 - sliderItem2.Value; + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(roadLayerName);//("180fd"); + if (layer != null) + { + layer.Opaque = 100 - sliderItem2.Value; + } + layer = globeControl2.Globe.Layers.GetLayerByCaption("180fd");//("180fd"); + if (layer != null) + { + layer.Opaque = 100 - sliderItem2.Value; + } + globeControl2.Globe.GroundOpaque = 100 - sliderItem2.Value; + + optiValue = sliderItem2.Value; + } + /// + /// 数据管理导入文件 + /// + /// + /// + private void buttonItemSJGL1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL1.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.Multiselect = true; + if (dlg.ShowDialog() == DialogResult.OK) + { + //自定义lprj文件名,从程序中复制一lprj文件。 + string filePath = dlg.FileName; + string lastname = Path.GetFileName(filePath); + + 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, 100); + + globeControl1.Refresh(); + } + } + } + + private void buttonItemHX1_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemHX1.Text); + + GSODataSource dataSpace = globeControl1.Globe.DataManager.OpenOracleDataSource(Utility.DBServer.Trim() + "/" + Utility.dbdatabase.Trim(), "", "", Utility.userID, Utility.DBPassword); + string filepath = ""; + //日志记录 + OpenFileDialog dlg = new OpenFileDialog(); + dlg.Filter = "矢量数据(*.shp)|*.shp|矢量数据(*.lgd)|*.lgd|CAD数据(*.dxf)|*.dxf|全部支持格式(*.lgd,*.shp,*.dxf)|*.lgd;*.shp;*.dxf;"; + dlg.Multiselect = true; + + #region 临时图层显示 + if (dlg.ShowDialog() == DialogResult.OK) + { + string filePath = dlg.FileName; + string lastname = Path.GetFileName(filePath); + + #region + for (int i = 0; i < dlg.FileNames.Length; i++) + { + string strDataPath = dlg.FileNames[i]; + filepath = strDataPath; + + GSOLayer layer = globeControl1.Globe.Layers.Add(strDataPath); + GSOFeatures RedFeatures = layer.GetAllFeatures(); + + 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(); + RedFeatures = features; + 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; + } + + /////////////////////////////////////////////////////////////////////////////////////////// + globeControl1.Globe.Layers.MoveTo(0, globeControl1.Globe.Layers.Count - 1); + globeControl1.Refresh(); + } + + IModelBuilder modelBuilder = new RedLineBuilder(); + + modelBuilder.batchInsert(dataSpace, redDt, RedFeatures); + + } + #endregion + + } + #endregion + } + /// + /// 定位 + /// + /// + /// + private void buttonItemLocation_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemLocation.Text); + + FrmFlyToPosition fly = new FrmFlyToPosition(globeControl1,globeControl2); + fly.Show(this); + } + /// + /// 2015-10-17演示代码 红线审核 + /// + /// + /// + private void ribbonTabItem6_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.FlyToPosition(new GSOPoint3d(120.610963, 31.188121, 50), EnumAltitudeMode.Absolute, -4, 50, 800); + globeControl1.Globe.FlyToPointSpeed = 10000000; + globeControl1.Globe.Action = EnumAction3D.SelectObject; + globeControl1.Refresh(); + + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + + //zhanshi = false; + redSH = true; + splitContainer1.Panel2Collapsed = true; + legendSG.Visible = false; + legendSC.Visible = false; + ClearGZData(); + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = true; + } + + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 基础工具 + /// + /// + /// + private void ribbonTabItem1_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + //zhanshi = false; + redSH = false; + splitContainer1.Panel2Collapsed = true; + panelOfTable.Visible = false; + legendSC.Visible = false; + legendSG.Visible = false; + ClearGZData(); + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + + + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 一键审核 + /// + /// + /// + private void ribbonTabItem11_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + //zhanshi = false; + redSH = false; + splitContainer1.Panel2Collapsed = true; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + panelOfTable.Visible = false; + legendSC.Visible = false; + legendSG.Visible = false; + ClearGZData(); + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + + + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 右屏添加冰箱数据 + /// + void AddDataToGlobeControl2() + { + + bool modelDataBool = false; + for (int i = globeControl2.Globe.Layers.Count - 1; i >= 0; i--) + { + GSOLayer layer = globeControl2.Globe.Layers[i]; + if (layer.Name.Contains("fttp:")) + { + modelDataBool = true; + break; + } + } + + if (modelDataBool == false) + { + GSOLayer ly = globeControl1.Globe.Layers.GetLayerByCaption("天地图地图"); + globeControl2.Globe.Layers.Add(ly); + } + else + { + return; + } + } + /// + /// 双屏对比 + /// + /// + /// + private void ribbonTabItem9_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent += new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent += new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + panelOfTable.Visible = false; + + splitContainer1.Panel2Collapsed = false; + //zhanshi = true; + redSH = false; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + sliderItem2.Value = 100 - globeControl1.Globe.GroundOpaque; + globeControl2.Globe.GroundOpaque = globeControl1.Globe.GroundOpaque; + legendSC.Visible = true; + legendSG.Visible = true; + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + AddDataToGlobeControl2(); + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 文档管理 + /// + /// + /// + private void ribbonTabItem4_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + panelOfTable.Visible = false; + //zhanshi = false; + redSH = false; + splitContainer1.Panel2Collapsed = true; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + legendSC.Visible = false; + legendSG.Visible = false; + ClearGZData(); + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 基础管理 + /// + /// + /// + private void ribbonTabItem14_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + panelOfTable.Visible = false; + //zhanshi = false; + redSH = false; + splitContainer1.Panel2Collapsed = true; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + legendSC.Visible = false; + legendSG.Visible = false; + ClearGZData(); + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 权限管理 + /// + /// + /// + private void ribbonTabItem2_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + panelOfTable.Visible = false; + //zhanshi = false; + redSH = false; + splitContainer1.Panel2Collapsed = true; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + legendSC.Visible = false; + legendSG.Visible = false; + ClearGZData(); + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + GSOFeature dpFeatuer = null; + /// + /// 双屏分析,点击管段分析 + /// + /// + /// + private void buttonItem8_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItem8.Text); + + //FrmCompareFeature frmCompareFeature = new FrmCompareFeature(globeControl1, globeControl2, layerTemp, layerTemp2,m_PipelineLayerNames,sgPipeLayersNames); + int width = this.Width; + FrmCompareFeature.ShowForm(globeControl1, globeControl2, layerTemp, layerTemp2, m_PipelineLayerNames, sgPipeLayersNames,width); + //frmCompareFeature.Location = new Point((this.Width - frmCompareFeature.Width)/2,50); + //frmCompareFeature.Show(this); + + } + /// + /// 红线审核导出图片 + /// + /// + /// + private void buttonItemDCTP_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemDCTP.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))); + */ + int mapWidth = 0; + int mapHeight = 0; + Point pt = getUpperLeftPoint(pt1, pt2, out mapWidth, out mapHeight); + int rightBottomX = pt.X + mapWidth; + int rightBottomY = pt.Y + mapHeight; + Image myImg = new Bitmap(mapWidth, mapHeight); + Graphics g = Graphics.FromImage(myImg); + g.CopyFromScreen(pt, new Point(0, 0), new Size(rightBottomX, rightBottomY)); + + 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; + } + } + } + /// + /// 标识器全区域统计 + /// + /// + /// + private void 标识器分类统计ToolStripMenuItem_Click(object sender, EventArgs e) + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + FrmBSQStatis bsqStatis = new FrmBSQStatis(globeControl1,null); + //FrmBSQStatis bsqStatis = new FrmBSQStatis(); + bsqStatis.Show(this); + } + /// + /// 标识器绘制区域统计 + /// + /// + /// + private void 标识器分类统计ToolStripMenuItem1_Click(object sender, EventArgs e) + { + trackflag = "BSQDuoBianXiangStatis"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + } + + #region 保存和加载审核库加载的图层 + /* + private void saveLayerList(TreeNodeCollection treeNodeList) + { + string configPath = Application.StartupPath + "\\configLayerList.xml"; + try + { + XmlDocument doc = new XmlDocument(); + doc.Load(configPath); + XmlNode dbParams = doc.SelectSingleNode("Params/dbparams"); + XmlNode dbLayers = doc.SelectSingleNode("Params/dblayers"); + XmlNode layers = doc.SelectSingleNode("Params/layers"); + dbParams.RemoveAll(); + dbLayers.RemoveAll(); + layers.RemoveAll(); + + List listDS = new List(); + String shDatasourceName = Utility.sgdbip + "/" + Utility.sgdbname + "_" + Utility.sgdbuser; + bool flag = false; + + for (int i = 0; i < globeControl1.Globe.DataManager.DataSourceCount; i++) + { + GSODataSource ds = globeControl1.Globe.DataManager.GetDataSourceAt(i); + if (ds != null && ds.Type == EnumDataSourceType.SqlServer || ds.Type == EnumDataSourceType.Oracle) + { + if (ds.Name == shDatasourceName) + { + //防止因为多次连接同一个数据库 + if (flag == true) + { + break; + } + flag = true; + listDS.Add(ds); + GSODataSourceCnn conn = ds.GetConnectionInfo(); + + XmlElement dbparam = doc.CreateElement("shdbparam"); + XmlElement ip = doc.CreateElement("ship"); + ip.InnerText = conn.Server; + + XmlElement dbname = doc.CreateElement("shdbname"); + dbname.InnerText = conn.Database; + + XmlElement username = doc.CreateElement("shusername"); + username.InnerText = conn.User; + + XmlElement password = doc.CreateElement("shpassword"); + password.InnerText = conn.Password; + + XmlElement type = doc.CreateElement("shtype"); + if (ds.Type == EnumDataSourceType.SqlServer) + { + type.InnerText = "sqlserver"; + } + else + { + type.InnerText = "oracle"; + } + + dbparam.AppendChild(ip); + dbparam.AppendChild(dbname); + dbparam.AppendChild(username); + dbparam.AppendChild(password); + dbparam.AppendChild(type); + dbParams.AppendChild(dbparam); + } + + } + } + + for (int i = 0; i < treeNodeList.Count; i++) + { + GSOLayer layer = treeNodeList[i].Tag as GSOLayer; + if (Path.GetExtension(layer.Name) == "") + { + XmlElement dbLayer = doc.CreateElement("dblayer"); + XmlAttribute attri = doc.CreateAttribute("dbindex"); + for (int j = 0; j < listDS.Count; j++) + { + if (layer.Dataset.DataSource.Name == listDS[j].Name) + { + attri.Value = j.ToString(); + break; + } + } + dbLayer.Attributes.Append(attri); + dbLayer.InnerText = layer.Name; + + dbLayers.AppendChild(dbLayer); + } + else + { + XmlElement dbLayer = doc.CreateElement("layer"); + dbLayer.InnerText = layer.Name; + layers.AppendChild(dbLayer); + } + } + + doc.Save(configPath); + } + catch (Exception e) + { + + } + } + + private void openLayerList() + { + layerManagerNode.Nodes.Clear(); + + string configPath = Application.StartupPath + "\\configLayerList.xml"; + try + { + XmlDocument doc = new XmlDocument(); + doc.Load(configPath); + XmlNode dbParams = doc.SelectSingleNode("Params/dbparams"); + XmlNode dbLayers = doc.SelectSingleNode("Params/dblayers"); + XmlNode layers = doc.SelectSingleNode("Params/layers"); + + List listDS = new List(); + for (int i = 0; i < dbParams.ChildNodes.Count; i++) + { + string ip = ""; + string dbname = ""; + string username = ""; + string password = ""; + string type = ""; + XmlNode node = dbParams.ChildNodes.Item(i); + for (int j = 0; j < node.ChildNodes.Count; j++) + { + XmlNode nodeChild = node.ChildNodes.Item(j); + + if (nodeChild != null && nodeChild.Name == "ship") + { + ip = nodeChild.InnerText; + } + else if (nodeChild != null && nodeChild.Name == "shdbname") + { + dbname = nodeChild.InnerText; + } + else if (nodeChild != null && nodeChild.Name == "shusername") + { + username = nodeChild.InnerText; + } + else if (nodeChild != null && nodeChild.Name == "shpassword") + { + password = nodeChild.InnerText; + } + else if (nodeChild != null && nodeChild.Name == "shtype") + { + type = nodeChild.InnerText; + } + } + + if (type == "sqlserver") + { + GSODataSource ds = globeControl1.Globe.DataManager.OpenSqlServerDataSource(ip, "", dbname, username, password); + listDS.Add(ds); + } + else if (type == "oracle") + { + GSODataSource ds = globeControl1.Globe.DataManager.OpenOracleDataSource(ip + "/" + dbname, "", "", username, password); + listDS.Add(ds); + } + } + + for (int i = 0; i < dbLayers.ChildNodes.Count; i++) + { + XmlNode node = dbLayers.ChildNodes.Item(i); + if (node != null) + { + string layerName = node.InnerText; + XmlAttribute attri = node.Attributes["dbindex"]; + if (attri != null) + { + int dbIndex = -1; + if (int.TryParse(attri.Value, out dbIndex)) + { + GSODataset dataset = listDS[dbIndex].GetDatasetByName(layerName); + globeControl1.Globe.Layers.Add(dataset); + //更新树节点 + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + TreeNode layerNode = new TreeNode(); + layerNode.Tag = layer; + layerNode.Text = layer.Dataset.Caption; + layerNode.ImageIndex = 0; + layerNode.SelectedImageIndex = 0; + layerNode.Checked = layer.Visible; + layerManagerNode.Nodes.Insert(0, layerNode); + // layerManagerNode.Expand(); + + + } + } + } + } + for (int i = 0; i < layers.ChildNodes.Count; i++) + { + XmlNode node = layers.ChildNodes.Item(i); + if (node != null) + { + string layerName = node.InnerText; + globeControl1.Globe.Layers.Add(layerName); + + //更新树节点 + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + TreeNode layerNode = new TreeNode(); + layerNode.Tag = layer; + layerNode.Text = layer.Dataset.Caption; + layerNode.ImageIndex = 0; + layerNode.SelectedImageIndex = 0; + layerNode.Checked = layer.Visible; + layerManagerNode.Nodes.Insert(0, layerNode); + } + } + layerManagerNode.Expand(); + } + catch (Exception e) + { + + } + } + * */ + #endregion + + private void btn_check_history_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_check_history.Text); + + if (FrmCheckHistory.isOpen == true) + { + return; + } + FrmCheckHistory frm = new FrmCheckHistory(globeControl1, globeControl2); + frm.addNode += new AddNodeToLayerManagerNode(addNodeToLayerManagerNode); + frm.Show(); + + } + + private void buttonItem查看数据_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItem查看数据.Text); + + FrmThreeOracle tr = new FrmThreeOracle(globeControl1); + + if (tr.ShowDialog() == DialogResult.OK) + { + addNodeToLayerManagerNode(tr.rukuLayer); + globeControl1.Refresh(); + } + } + /// + /// 规划数据入库 + /// + /// + /// + private void buttonItemGHRK_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemGHRK.Text); + + FrmGHRK ghrk = new FrmGHRK(globeControl1, layerManagerNode); + ghrk.Show(this); + } + + private void btn_user_info_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_user_info.Text); + + if (!FrmSysUserInfoManger.IS_OPEN) + { + FrmSysUserInfoManger frm = new FrmSysUserInfoManger(); + frm.ShowDialog(); + } + } + + private void btn_role_info_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_role_info.Text); + + if (FrmRoleInfoManager.IS_OPEN) + { + return; + } + FrmRoleInfoManager frm = new FrmRoleInfoManager(); + frm.ShowDialog(); + } + + private void btn_resc_info_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_resc_info.Text); + + if (!SysRescInfoManager.IS_OPEN) + { + SysRescInfoManager frm = new SysRescInfoManager(); + frm.ShowDialog(); + } + } + + private void btn_role_resc_Click(object sender, EventArgs e) + { + + LogManager.saveLog(Utility.userName, this.btn_role_resc.Text); + + if (!FrmRoleRescManager.IS_OPEN) + { + FrmRoleRescManager frm = new FrmRoleRescManager(); + frm.ShowDialog(); + } + } + + private void btn_user_role_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_user_role.Text); + + if (FrmUserRole.IS_OPEN) + { + return; + } + FrmUserRole frm = new FrmUserRole(); + frm.ShowDialog(); + } + + private void btn_document_info_Click(object sender, EventArgs e) + { + + LogManager.saveLog(Utility.userName, this.btn_document_info.Text); + + //if (FormDocumentManager.IS_OPEN) + //{ + // return; + //} + //FormDocumentManager frm = new FormDocumentManager(); + //frm.ShowDialog(); + + //if (FormDocumentManager.IS_OPEN) + //{ + // return; + //} + //new FormDocumentManager().ShowDialog(); + if (FormDocumentManager.IS_OPEN) + { + return; + } + this.Cursor = Cursors.WaitCursor; + FormDocumentManager frm = new FormDocumentManager(); + frm.changeCursor += new ChangeCursor(changeCursorToDefault); + frm.ShowDialog(); + + } + + private void changeCursorToDefault() + { + this.Cursor = Cursors.Default; + } + + /// + /// 判断CAD文件是否有投影信息 + /// + /// + /// + Boolean CheckDatasetGeoReference(GSODataset dataset) + { + Boolean bSuccess = false; + if (dataset.GeoReferenceType == EnumGeoReferenceType.Flat) + { + if (MessageBox.Show("数据没有空间参考信息,请设置空间参考信息!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation) == DialogResult.OK) + { + String strPath = Path.GetDirectoryName(Application.ExecutablePath) + "\\Coordinate Systems"; + OpenFileDialog dlg = new OpenFileDialog(); + + dlg.InitialDirectory = strPath; + dlg.RestoreDirectory = true; + + dlg.Filter = "投影文件|*.prj||"; + if (dlg.ShowDialog() == DialogResult.OK) + { + bSuccess = dataset.LoadProjectionFromESRIFile(dlg.FileName); + } + } + } + else + { + return true; + } + return bSuccess; + } + + private void buttonItemexp_CAD_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemexp_CAD.Text); + + OpenFileDialog dlg = new OpenFileDialog(); + dlg.Filter = "支持格式(*.dwg)|*.dwg"; + dlg.Multiselect = true; + if (dlg.ShowDialog() == DialogResult.OK) + { + for (int i = 0; i < dlg.FileNames.Length; i++) + { + //this.Cursor = Cursors.WaitCursor; + string strDataPath = dlg.FileNames[i]; + + #region + //string strDataPathPrj = strDataPath.ToLower().Replace(".dwg", ".lprj"); + + //if (File.Exists(strDataPathPrj) == false) + //{ + // if (MessageBox.Show("数据没有空间参考信息,请设置空间参考信息!", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation) == DialogResult.OK) + // { + // String strPath = Application.StartupPath + "\\Coordinate Systems"; + // OpenFileDialog dlgPrj = new OpenFileDialog(); + // dlgPrj.InitialDirectory = strPath; + // dlgPrj.RestoreDirectory = true; + // dlgPrj.Multiselect = false; + // dlg.Filter = "投影文件|*.prj"; + // if (dlg.ShowDialog() == DialogResult.OK) + // { + // this.Cursor = Cursors.WaitCursor; + // string proj4 = GSODataEngineUtility.ConvertEsriPrjFileToProj4(dlg.FileName); + // using (StreamWriter stream = new StreamWriter(strDataPathPrj, false)) + // { + // stream.WriteLine("0prj4" + proj4 + ""); + // } + // AddLayerData(strDataPath); + // //globeControl1.Globe.Layers.Add(strDataPath); + + // this.Cursor = Cursors.Default; + // } + // else + // { + // AddLayerData(strDataPath); + // //globeControl1.Globe.Layers.Add(strDataPath); + // } + // } + // else + // { + // AddLayerData(strDataPath); + // //globeControl1.Globe.Layers.Add(strDataPath); + // } + + //} + //else + //{ + // //globeControl1.Globe.Layers.Add(strDataPath); + // AddLayerData(strDataPath); + //} + #endregion + AddLayerData(strDataPath); + //this.Cursor = Cursors.Default; + } + } + + 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, 100); + + globeControl1.Refresh(); + } + } + + private void btn_password_edit_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_password_edit.Text); + + if (FrmChangePassword.IS_OPEN) + { + return; + } + FrmChangePassword frm = new FrmChangePassword(); + frm.ShowDialog(); + } + /// + /// 多孔管线入库 + /// + /// + /// + private void buttonItem9_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL4_2.Text); + + if (ds == null) + { + MessageBox.Show("请先连接数据库", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + ConnectDB(null, null); + } + if (ds == null) + return; + + FrmMultiPipelineModelDB frm = new FrmMultiPipelineModelDB(globeControl1, ds); + if (frm.ShowDialog() == DialogResult.OK) + { + addNodeToLayerManagerNode(frm.rukuLayer); + } + //frm.Show(); + } + private void 导出CADToolStripMenuItem1_Click(object sender, EventArgs e) + { + TreeNode node = layerNodeContexMenu.Tag as TreeNode; + if (node == null) + { + MessageBox.Show("请在左侧节点集中选择要导出的图层", "提示"); + return; + } + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(node.Text.Trim()); + if (layer == null || layer.GetAllFeatures().Length <= 0) + { + MessageBox.Show("要导出的图层为空", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + return; + } + string strProjectName = Utility.projectStr; + if (strProjectName != "") + { + SaveFileDialog dlg = new SaveFileDialog(); + dlg.Filter = "*.dwg|*.dwg|*.dxf|*.dxf"; + dlg.FileName = layer.Caption; + if (dlg.ShowDialog(this) == DialogResult.OK) + { + globeControl1.Globe.MemoryLayer.SaveAs(dlg.FileName); + GSOLayer newlayer = globeControl1.Globe.Layers.Add(dlg.FileName); + newlayer.RemoveAllFeature(); + int featureCount = layer.GetAllFeatures().Length; + for (int i = 0; i < featureCount; i++) + { + GSOFeature feature = layer.GetAt(i); + if (feature != null && feature.Geometry != null) + { + if (feature.Geometry.Type == EnumGeometryType.GeoPolyline3D) + { + feature.Geometry.Style = new GSOSimpleLineStyle3D(); + } + else if (feature.Geometry.Type == EnumGeometryType.GeoPolygon3D) + { + feature.Geometry.Style = new GSOSimplePolygonStyle3D(); + } + newlayer.AddFeature(feature); + } + } + newlayer.Save(); + newlayer.Dataset.DataSource.RemoveDataset(newlayer.Dataset); + globeControl1.Globe.Layers.Remove(newlayer); + MessageBox.Show("导出CAD完成!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + } + } + } + + private void buttonItemGBJC_Click(object sender, EventArgs e) + { + FrmGBJC gb = new FrmGBJC(globeControl1, globeControl2, layerTemp, layerTemp2); + gb.Show(this); + } + + #region 右屏管纵数据控制 + private void 五十米主干道ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = true; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + + private void 三十六米次干道ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = true; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + + private void 四十二米次干道ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = true; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + + private void 二十四米一块板ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = true; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + + private void 二十四米三块板ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = true; + } + + private void 二十四米停车带ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = true; + lendendGZ24_3.Visible = false; + } + + private void 二十六米大堤路ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = true; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + + private void 清除管纵数据ToolStripMenuItem_Click(object sender, EventArgs e) + { + ClearGZData(); + } + + private void ClearGZData() + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + #endregion + + private void buttonItemPasswordReset_Click(object sender, EventArgs e) + { + Frm_password_reset reset = new Frm_password_reset(); + reset.Show(); + } + + private void pictureBox1_Paint(object sender, PaintEventArgs e) + { + int Width = this.Width; + string welcomeUser = "欢迎您:" + Utility.userName; + Graphics g = e.Graphics; + g.DrawString(welcomeUser, new Font("宋体", 12), new SolidBrush(Color.Black), Width - 180, 50); + } + + } +} \ No newline at end of file diff --git a/Cyberpipe.csproj b/Cyberpipe.csproj index 3a45ad8..d22f590 100644 --- a/Cyberpipe.csproj +++ b/Cyberpipe.csproj @@ -402,12 +402,6 @@ FrmBACKORACLE.cs - - Form - - - FrmBSQDuoBianXingStatis.cs - Form @@ -1271,9 +1265,6 @@ FrmBACKORACLE.cs - - FrmBSQDuoBianXingStatis.cs - FrmBSQStatis.cs diff --git a/FeatureStatisticsService.cs b/FeatureStatisticsService.cs index e833e5f..c7de210 100644 --- a/FeatureStatisticsService.cs +++ b/FeatureStatisticsService.cs @@ -273,19 +273,15 @@ /// 获取特定区域图层的管线列表,并将其总长度统计出来 ///
TODOLIST:将Intersects_Pipeline在MainFrm中去除 /// - /// + /// + /// 要统计的长度 /// public static GSOFeatures getLayerPipes(GSOGeoPolygon3D polygon, GSOLayer layer, out double length) { length = 0; if (layer == null) return null; - GSOFeatureLayer flayer = layer as GSOFeatureLayer; - GSOFeatureDataset fdataset = flayer.Dataset as GSOFeatureDataset; - GSOFeatures feats = null; - - feats = polygon == null?flayer.GetAllFeatures():flayer.FindFeaturesInPolygon(polygon, false); - + GSOFeatures feats = getLayerFeatures(polygon, layer); double totallength = 0.00; for (int i = 0; i < feats.Length; i++) { @@ -301,5 +297,17 @@ return feats; } + /// + /// 获取区域图层内的feature列表,MainFrm.PolygonIntersectAnalysis和此方法重复,需要整理删除 + /// + /// + /// + /// + public static GSOFeatures getLayerFeatures(GSOGeoPolygon3D polygon, GSOLayer layer) + { + if (layer == null) return null; + GSOFeatureLayer flayer = layer as GSOFeatureLayer; + return polygon == null ? flayer.GetAllFeatures() : flayer.FindFeaturesInPolygon(polygon, false); + } } } diff --git a/FrmAllWorkWellStatis.cs b/FrmAllWorkWellStatis.cs index 7bf65dc..bd0f81b 100644 --- a/FrmAllWorkWellStatis.cs +++ b/FrmAllWorkWellStatis.cs @@ -19,17 +19,7 @@ private Dictionary map = null; private GSOGlobeControl globeControl1; private GSOGeoPolygon3D polygon; - //TODOLIST:用晓伟的代理进行操作,功能拆分细化 - //public FrmAllWorkWellStatis(GSOGeoPolygon3D polygon, DataGridView dataGridViewX11, ToolStripStatusLabel toolStripNumbers1, GSOGlobeControl ctl, PanelEx p) - //{ - // InitializeComponent(); - // panel = p; - // dataGridViewX1 = dataGridViewX11; - // toolStripNumbers = toolStripNumbers1; - // globeControl1 = ctl; - // map = getAccsMap(polygon); - //} public FrmAllWorkWellStatis(GSOGlobeControl ctl,GSOGeoPolygon3D polygon, MainFrm.DataGridViewDelegate InitDataGridViewX1) { InitializeComponent(); @@ -117,8 +107,9 @@ sql = "select " + getpipeLineFields.getFields(layername, globeControl1) + " from " + layer.Name; sql += " where 1>2 "; - for (int i = 0; i < fs.Length && fs[i].GetFieldDefn("编号") != null; i++) + for (int i = 0; i < fs.Length; i++) { + if (fs[i].GetFieldDefn("编号") == null) continue; sql += " or 编号 = '" + fs[i].GetValue("编号").ToString() + "'"; } diff --git a/FrmBSQDuoBianXingStatis.Designer.cs b/FrmBSQDuoBianXingStatis.Designer.cs deleted file mode 100644 index bda6842..0000000 --- a/FrmBSQDuoBianXingStatis.Designer.cs +++ /dev/null @@ -1,87 +0,0 @@ -namespace Cyberpipe -{ - partial class FrmBSQDuoBianXingStatis - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea1 = new System.Windows.Forms.DataVisualization.Charting.ChartArea(); - this.groupBox1 = new System.Windows.Forms.GroupBox(); - this.chart1 = new System.Windows.Forms.DataVisualization.Charting.Chart(); - this.groupBox1.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.chart1)).BeginInit(); - this.SuspendLayout(); - // - // groupBox1 - // - this.groupBox1.Controls.Add(this.chart1); - this.groupBox1.Dock = System.Windows.Forms.DockStyle.Fill; - this.groupBox1.Location = new System.Drawing.Point(0, 0); - this.groupBox1.Name = "groupBox1"; - this.groupBox1.Size = new System.Drawing.Size(592, 384); - this.groupBox1.TabIndex = 0; - this.groupBox1.TabStop = false; - this.groupBox1.Text = "统计结果信息"; - // - // chart1 - // - chartArea1.AxisX.MajorGrid.Enabled = false; - chartArea1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(191)))), ((int)(((byte)(219)))), ((int)(((byte)(255))))); - chartArea1.BackGradientStyle = System.Windows.Forms.DataVisualization.Charting.GradientStyle.TopBottom; - chartArea1.Name = "ChartArea1"; - this.chart1.ChartAreas.Add(chartArea1); - this.chart1.Dock = System.Windows.Forms.DockStyle.Fill; - this.chart1.Location = new System.Drawing.Point(3, 17); - this.chart1.Name = "chart1"; - this.chart1.Size = new System.Drawing.Size(586, 364); - this.chart1.TabIndex = 0; - this.chart1.Text = "chart1"; - // - // FrmBSQDuoBianXingStatis - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(592, 384); - this.Controls.Add(this.groupBox1); - this.DoubleBuffered = true; - this.Name = "FrmBSQDuoBianXingStatis"; - this.ShowIcon = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; - this.Text = "多边形区域统计"; - this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FrmBSQDuoBianXingStatis_FormClosing); - this.Load += new System.EventHandler(this.FrmBSQDuoBianXingStatis_Load); - this.groupBox1.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)(this.chart1)).EndInit(); - this.ResumeLayout(false); - - } - - #endregion - - private System.Windows.Forms.GroupBox groupBox1; - private System.Windows.Forms.DataVisualization.Charting.Chart chart1; - } -} \ No newline at end of file diff --git a/FrmBSQDuoBianXingStatis.cs b/FrmBSQDuoBianXingStatis.cs deleted file mode 100644 index 80b567e..0000000 --- a/FrmBSQDuoBianXingStatis.cs +++ /dev/null @@ -1,179 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Windows.Forms; -using DevComponents.DotNetBar; -using System.Data.SqlClient; -using System.Windows.Forms.DataVisualization.Charting; -using GeoScene.Data; -using GeoScene.Engine; -using GeoScene.Globe; -using System.Data.OracleClient; - -namespace Cyberpipe -{ - public partial class FrmBSQDuoBianXingStatis : Office2007Form - { - Dictionary bsq = new Dictionary(); - Dictionary bsq1 = new Dictionary(); - static FrmBSQDuoBianXingStatis frm; - GSOGlobeControl globeControl1; - List list = new List(); - public static List pipeLists = new List(); - - string[] codeStr = new string[50]; - string[] nameStr = new string[30]; - public static List typeLists; - - public FrmBSQDuoBianXingStatis(Dictionary workWellLen, GSOGlobeControl glb,List _list) - { - InitializeComponent(); - bsq = workWellLen; - globeControl1 = glb; - list = _list; - } - - private void FrmBSQDuoBianXingStatis_Load(object sender, EventArgs e) - { - FrmBSQDuoBianXingStatisFenLei(); - try - { - chart1.Series.Add("标识器"); - chart1.ChartAreas["ChartArea1"].AxisX.Title = "标识器类型"; - chart1.ChartAreas["ChartArea1"].AxisY.Title = "标识器数量"; - chart1.ChartAreas["ChartArea1"].AxisX.Interval = 1; - chart1.Series["标识器"].ChartType = SeriesChartType.Column; - chart1.Series["标识器"]["DrawingStyle"] = "Cylinder"; - - chart1.Series["标识器"].Points.DataBindXY(bsq1.Keys, bsq1.Values); - if (bsq1.Values.Count == 0) - { - MessageBox.Show("该区域没有标识器信息", "提示"); - this.Close(); - return; - } - else - { - for (int m = 0; m < bsq1.Values.Count; m++) - { - if (chart1.Series["标识器"].Points[m].YValues[0].ToString() != "0") - { - chart1.Series["标识器"].Points[m].Label = chart1.Series[0].Points[m].YValues[0].ToString(); - } - } - } - } - catch (Exception ex) - { - //ErrorLog.PublishError(ex); - } - } - - private void FrmBSQDuoBianXingStatis_FormClosing(object sender, FormClosingEventArgs e) - { - frm = null; - globeControl1.Globe.ClearAnalysis(); - globeControl1.Globe.MemoryLayer.RemoveAllFeature(); - } - - - private void FrmBSQDuoBianXingStatisFenLei() - { - try - { - bool flag2 = false; - for (int i = 0; i < Utility.listPipelineType.Count; i++) - { - - for (int j = 0; j < pipeLists.Count; j++) - { - if (pipeLists[j] == Utility.listPipelineType[i].type) - { - flag2 = true; - break; - } - } - if (!flag2 && Utility.listPipelineType[i].type != "标识器") - { - pipeLists.Add(Utility.listPipelineType[i].type); - } - flag2 = false; - } - - typeLists = new List(); - for (int num = 0; num < pipeLists.Count; num++) - { - typeList ls = new typeList(0, pipeLists[num]); - typeLists.Add(ls); - } - - GSOFeatures fs = list[0]; - string pipetype = "标识器"; - foreach (string key in bsq.Keys) - { - if (key.StartsWith(pipetype)) - { - pipetype = key; - break; - } - } - if (fs.Length > 0) - { - for (int i = 0; i < fs.Length; i++) - { - string str = fs[i].GetValue("对象名称").ToString(); - codeStr = str.Split(','); - for (int n = 0; n < codeStr.Length; n++) - { - for (int ii = 0; ii < Utility.listPipelineType.Count; ii++) - { - if (Utility.listPipelineType[ii].code == codeStr[n]) - { - for (int m = 0; m < typeLists.Count; m++) - { - if (Utility.listPipelineType[ii].type == typeLists[m].type) - { - typeLists[m].num++; - break; - } - } - break; - } - } - } - } - } - - for (int i = 0; i < typeLists.Count; i++) - { - if (typeLists[i].num > 0) - bsq1.Add(typeLists[i].type, typeLists[i].num); - } - - } - catch (Exception ex) - { - //ErrorLog.PublishError(ex); - //MessageBox.Show(ex.Message); - } - - } - public class typeList - { - public int num; - public string type; - - public typeList(int _num, string _type) - { - num = _num; - type = _type; - } - } - - - } -} diff --git a/FrmBSQDuoBianXingStatis.resx b/FrmBSQDuoBianXingStatis.resx deleted file mode 100644 index 1af7de1..0000000 --- a/FrmBSQDuoBianXingStatis.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/FrmBSQStatis.Designer.cs b/FrmBSQStatis.Designer.cs index 2509c7d..ee9b1e7 100644 --- a/FrmBSQStatis.Designer.cs +++ b/FrmBSQStatis.Designer.cs @@ -57,6 +57,7 @@ this.ShowIcon = false; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "标识器全区域统计"; + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FrmBSQStatis_FormClosing); this.Load += new System.EventHandler(this.FrmBSQStatis_Load); ((System.ComponentModel.ISupportInitialize)(this.chartStatis)).EndInit(); this.ResumeLayout(false); diff --git a/FrmBSQStatis.cs b/FrmBSQStatis.cs index 4b25eda..e7c4926 100644 --- a/FrmBSQStatis.cs +++ b/FrmBSQStatis.cs @@ -18,94 +18,18 @@ { public partial class FrmBSQStatis : Office2007Form { - public Dictionary bsq = new Dictionary(); - //SqlConnection conn; - public static List typeLists; - OracleConnection conn; - string connectString; + private Dictionary bsq = new Dictionary(); + private GSOGlobeControl globeControl1; + private GSOGeoPolygon3D polygon; - public FrmBSQStatis() + public FrmBSQStatis(GSOGlobeControl globeControl1,GSOGeoPolygon3D polygon) { + this.globeControl1 = globeControl1; + this.polygon = polygon; InitializeComponent(); - BSQNumStatis(); + bsq = getBSQNameAndNumMap(polygon); } - string[] codeStr = new string[50]; - string[] nameStr = new string[30]; - public static List pipeLists = new List(); - - private void BSQNumStatis() - { - bool flag2 = false; - for (int i = 0; i < Utility.listPipelineType.Count; i++) - { - for (int j = 0; j < pipeLists.Count; j++) - { - if (pipeLists[j] == Utility.listPipelineType[i].type) - { - flag2 = true; - break; - } - } - if (!flag2 && Utility.listPipelineType[i].type != "标识器") - { - pipeLists.Add(Utility.listPipelineType[i].type); - } - flag2 = false; - } - - typeLists = new List(); - for (int num = 0; num 0) - bsq.Add(typeLists[i].type, typeLists[i].num); - } - - } - catch (Exception ex) - { - - } - } private void FrmBSQStatis_Load(object sender, EventArgs e) { @@ -136,17 +60,88 @@ } } - public class typeList + private Dictionary getBSQNameAndNumMap(GSOGeoPolygon3D polygon) { - public int num; - public string type; - public typeList(int _num, string _type) + Dictionary result = new Dictionary(); + Dictionary codeAndType = new Dictionary(); + //得到type的种类 + for (int i = 0; i < Utility.listPipelineType.Count; i++) { - num = _num; - type = _type; + if (!result.ContainsKey(Utility.listPipelineType[i].type) && Utility.listPipelineType[i].type != "标识器") + { + result.Add(Utility.listPipelineType[i].type, 0); + codeAndType.Add(Utility.listPipelineType[i].code, Utility.listPipelineType[i].type); + } + } + + return polygon == null ? getAllAreaMap(result, codeAndType) : getBSQMapByPolygon(polygon, result, codeAndType); + } + public Dictionary getAllAreaMap(Dictionary typeAndCount,Dictionary codeAndType) + { + try + { + OracleConnection conn = OledbHelper.sqlConnection(); + conn.Open(); + OracleCommand cmd; + cmd = new OracleCommand("select 对象类型 from 标识器", conn); + OracleDataReader dr = cmd.ExecuteReader(); + + while (dr.Read()) + { + string str = Convert.ToString(dr["对象类型"]); + if (str == null) continue; + foreach (string key in codeAndType.Keys) + { + if (str.Contains(key)) + { + typeAndCount[codeAndType[key]] += 1; + } + } + } + conn.Close(); + } + catch (Exception ex) + { + LogHelper.WriteLog(typeof(FrmBSQStatis),ex.Message.ToString()); + } + return typeAndCount; + } + + + public Dictionary getBSQMapByPolygon(GSOGeoPolygon3D polygon,Dictionary typeAndCount, Dictionary codeAndType) + { + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption("标识器"); + GSOFeatures bsqFs = FeatureStatisticsService.getLayerFeatures(polygon, layer); + if (bsqFs == null || bsqFs.Length <= 0) { + LogHelper.WriteLog(typeof(FrmBSQStatis),"标识器图层下的Feature为空"); + return null; + } + + for (int i = 0; i < bsqFs.Length; i++) + { + string str = bsqFs[i].GetValue("对象类型").ToString(); + + foreach (string key in codeAndType.Keys) + { + if (str.Contains(key)) + { + typeAndCount[codeAndType[key]] += 1; + } + } + } + + return typeAndCount; + } + + private void FrmBSQStatis_FormClosing(object sender, FormClosingEventArgs e) + { + globeControl1.Globe.ClearAnalysis(); + } + + } } diff --git a/FrmValveStatistics.cs b/FrmValveStatistics.cs index 672f97a..17dad6c 100644 --- a/FrmValveStatistics.cs +++ b/FrmValveStatistics.cs @@ -120,6 +120,7 @@ sql += " where 1>2 "; for (int i = 0; i < fs.Length; i++) { + if (fs[i].GetValue("编号") == null) continue; sql += " or 编号 = '" + fs[i].GetValue("编号").ToString() + "'"; } diff --git a/FrmpipeDeepstatis.cs b/FrmpipeDeepstatis.cs index 879801a..c7edbc3 100644 --- a/FrmpipeDeepstatis.cs +++ b/FrmpipeDeepstatis.cs @@ -164,88 +164,6 @@ } } - //if (clbPipeLine.CheckedItems.Count > 0) - //{ - // if (dataGridViewX2.Rows.Count > 0) - // { - // for (int i = 0; i < clbPipeLine.CheckedItems.Count; i++) - // { - // GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(clbPipeLine.CheckedItems[i].ToString()); - // GSOFeatureLayer flayer = layer as GSOFeatureLayer; - // GSOFeatures feats = new GSOFeatures(); - // if (polygon == null) - // feats = flayer.GetAllFeatures(); - // else - // feats = flayer.FindFeaturesInPolygon(polygon, false); - // for (int j = 0; j < dataGridViewX2.Rows.Count; j++) - // { - // double totalLength = 0.00; - // int ncount = 0; - // for (int m = 0; m < feats.Length; m++) - // { - // GSOFeature feat = feats[m]; - // float radius = feat.GetFieldAsFloat("起始埋深"); - // bool upCompare = true; - // bool downCompare = true; - // if (dataGridViewX2.Rows[j].Cells["下限"].Value != null || dataGridViewX2.Rows[j].Cells["上限"].Value != null) - // { - // if (dataGridViewX2.Rows[j].Cells["下限"].Value != null) - // { - // if (dataGridViewX2.Rows[j].Cells["下限"].Value.ToString() != "") - // { - // if (radius >= Convert.ToDouble(dataGridViewX2.Rows[j].Cells["下限"].Value)) - // { - // downCompare = true; - // } - // else - // downCompare = false; - // } - // } - // if (dataGridViewX2.Rows[j].Cells["上限"].Value != null) - // { - // if (dataGridViewX2.Rows[j].Cells["上限"].Value.ToString() != "") - // { - // if (radius <= Convert.ToDouble(dataGridViewX2.Rows[j].Cells["上限"].Value)) - // { - // upCompare = true; - // } - // else - // upCompare = false; - // } - // } - // if (upCompare && downCompare) - // { - // GSOGeoPolyline3D line = feat.Geometry as GSOGeoPolyline3D; - // double length = line.GetSpaceLength(true, 6378137); - // totalLength += length; - // ncount += 1; - // } - // } - // } - // if (dataGridViewX2.Rows[j].Cells["下限"].Value != null || dataGridViewX2.Rows[j].Cells["上限"].Value != null) - // { - // DataGridViewRow row = new DataGridViewRow(); - // int index = dataGridViewX1.Rows.Add(row); - // row = dataGridViewX1.Rows[index]; - // row.Cells["图层名称"].Value = layer.Caption; - // row.Cells["埋深范围"].Value = dataGridViewX2.Rows[j].Cells["下限"].Value + "-" + dataGridViewX2.Rows[j].Cells["上限"].Value; - // row.Cells["条数"].Value = ncount; - // row.Cells["总长度"].Value =Math.Round(totalLength,2); - - // dic.Add(layer.Caption + "," + row.Cells["埋深范围"].Value.ToString()+","+row.Cells["总长度"].Value.ToString(), ncount); - // } - // } - // } - // } - // else - // { - // MessageBox.Show("请添加分段!"); - // } - //} - //else - //{ - // MessageBox.Show("请选择图层!"); - //} showPipeWidget(); } catch (Exception ex) diff --git a/FrmpipeMaterialGather.cs b/FrmpipeMaterialGather.cs index b7ab1d2..3e9f45d 100644 --- a/FrmpipeMaterialGather.cs +++ b/FrmpipeMaterialGather.cs @@ -180,79 +180,6 @@ } - //if (clbPipeLine.CheckedItems.Count > 0) - //{ - // for (int i = 0; i < clbPipeLine.CheckedItems.Count; i++) - // { - // GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(clbPipeLine.CheckedItems[i].ToString()); - // GSOFeatureLayer flayer = layer as GSOFeatureLayer; - // GSOFeatures feats = new GSOFeatures(); - // if (polygon == null) - // feats = flayer.GetAllFeatures(); - // else - // feats = flayer.FindFeaturesInPolygon(polygon, false); - // List lstDiameter = new List(); - - // for (int j = 0; j < clbmaterials.CheckedItems.Count; j++) - // { - // if (!lstDiameter.Contains(clbmaterials.CheckedItems[j].ToString())) - // { - // lstDiameter.Add(clbmaterials.CheckedItems[j].ToString()); - // } - // } - // //lstDiameter.Sort(); - // if (lstDiameter.Count > 0) - // { - // for (int m = 0; m < lstDiameter.Count; m++) - // { - // double totalLength = 0.00; - // int ncount = 0; - // for (int j = 0; j < feats.Length; j++) - // { - // if (lstDiameter[m] != "无") - // { - // if (feats[j].GetFieldAsString("材质") == lstDiameter[m]) - // { - // GSOGeoPolyline3D line = feats[j].Geometry as GSOGeoPolyline3D; - // if (line != null) - // { - // double length = line.GetSpaceLength(true, 6378137); - // totalLength += length; - // ncount += 1; - // } - // } - // } - // else - // { - // if (feats[j].GetFieldAsString("材质") == "") - // { - // GSOGeoPolyline3D line = feats[j].Geometry as GSOGeoPolyline3D; - // if (line != null) - // { - // double length = line.GetSpaceLength(true, 6378137); - // totalLength += length; - // ncount += 1; - // } - // } - // } - // } - // DataGridViewRow row = new DataGridViewRow(); - // int index = dataGridViewX1.Rows.Add(row); - // row = dataGridViewX1.Rows[index]; - // row.Cells["图层名称"].Value = layer.Caption; - // row.Cells["材质"].Value = lstDiameter[m]; - // row.Cells["条数"].Value = ncount; - // row.Cells["总长度"].Value = Math.Round(totalLength); - - // dic.Add(layer.Caption + "," + row.Cells["材质"].Value.ToString(), ncount); - // } - // } - // } - //} - //else - //{ - // MessageBox.Show("请选择图层!"); - //} showPipeWidget(); } catch (Exception ex) diff --git a/Frmpipediameterstatis.cs b/Frmpipediameterstatis.cs index 9953ac0..aa482d8 100644 --- a/Frmpipediameterstatis.cs +++ b/Frmpipediameterstatis.cs @@ -27,12 +27,9 @@ frm = new Frmpipediameterstatis(_globeControl1, pipeLayers, visibleId); frm.Show(_globeControl1.Parent); } - else + else if (frm.WindowState == FormWindowState.Minimized) { - if (frm.WindowState == FormWindowState.Minimized) - { - frm.WindowState = FormWindowState.Normal; - } + frm.WindowState = FormWindowState.Normal; } } @@ -208,7 +205,8 @@ } catch (Exception ex) { - MessageBox.Show(ex.Message); + LogHelper.WriteLog(typeof(Frmpipediameterstatis), ex.Message); + //MessageBox.Show(ex.Message); LogError.PublishError(ex); } } @@ -290,76 +288,77 @@ /// private void btnExport_Click(object sender, EventArgs e) { - if (dataGridViewX1.Rows.Count > 0) + if (dataGridViewX1.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 = DateTime.Now.ToString("yyyyMMdd") + ".xls"; - if (dlg.ShowDialog() == DialogResult.OK) + MessageBox.Show("统计结果为空,请重新统计之后再导出Excel!", "提示"); + return; + } + + SaveFileDialog dlg = new SaveFileDialog(); + dlg.Filter = "Excel files (*.xls)|*.xls"; + dlg.FilterIndex = 0; + dlg.RestoreDirectory = true; + //dlg.CreatePrompt = true; + dlg.Title = "保存为Excel文件"; + dlg.FileName = 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 { - Stream myStream; - myStream = dlg.OpenFile(); - StreamWriter sw = new StreamWriter(myStream, System.Text.Encoding.GetEncoding(-0)); - string columnTitle = ""; - try + sw.WriteLine("日期:" + DateTime.Now.ToString("yyyy-MM-dd")); + + //写入列标题 + for (int i = 0; i < dataGridViewX1.ColumnCount; i++) { - sw.WriteLine("日期:" + DateTime.Now.ToString("yyyy-MM-dd")); - - //写入列标题 - for (int i = 0; i < dataGridViewX1.ColumnCount; i++) + if (i > 0) { - if (i > 0) - { - columnTitle += "\t"; - } - columnTitle += dataGridViewX1.Columns[i].HeaderText; + columnTitle += "\t"; } - sw.WriteLine(columnTitle); - - //写入列内容 - for (int j = 0; j < dataGridViewX1.Rows.Count; j++) - { - string columnValue = ""; - for (int k = 0; k < dataGridViewX1.Columns.Count; k++) - { - if (k > 0) - { - columnValue += "\t"; - } - if (dataGridViewX1.Rows[j].Cells[k].Value == null) - columnValue += ""; - else - columnValue += dataGridViewX1.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); - } + columnTitle += dataGridViewX1.Columns[i].HeaderText; } - catch (Exception ex) + sw.WriteLine(columnTitle); + + //写入列内容 + for (int j = 0; j < dataGridViewX1.Rows.Count; j++) { - MessageBox.Show(ex.ToString()); + string columnValue = ""; + for (int k = 0; k < dataGridViewX1.Columns.Count; k++) + { + if (k > 0) + { + columnValue += "\t"; + } + if (dataGridViewX1.Rows[j].Cells[k].Value == null) + columnValue += ""; + else + columnValue += dataGridViewX1.Rows[j].Cells[k].Value.ToString().Trim(); + } + + sw.WriteLine(columnValue); } - finally + sw.Close(); + myStream.Close(); + if (MessageBox.Show("导出Excel文件成功!是否打开?", "提示", MessageBoxButtons.YesNo) == DialogResult.Yes) { - sw.Close(); - myStream.Close(); + System.Diagnostics.Process.Start(dlg.FileName); } } + catch (Exception ex) + { + MessageBox.Show(ex.ToString()); + } + finally + { + sw.Close(); + myStream.Close(); + } } - else - { - MessageBox.Show("统计结果为空,请重新统计之后再导出Excel!","提示"); - } + + } /// /// 绘制区域分段统计 diff --git a/MainFrm.cs b/MainFrm.cs index 0b7e393..9bfb70e 100644 --- a/MainFrm.cs +++ b/MainFrm.cs @@ -2667,12 +2667,195 @@ FrmBaseLineProfillAnalysis dlg = new FrmBaseLineProfillAnalysis(globeControl1.Globe, e.Polyline); dlg.Show(this); globeControl1.Globe.ClearLastTrackPolyline(); + /* + FrmRoadHDM f = new FrmRoadHDM(); + f.Show() + * **/ } else { } trackPolylineEndMode = EnumTrackPolylineEndMode.Default_Analysis; + /* + ArrayList arraylistPoint = new ArrayList(); + ArrayList arraylistLine = new ArrayList(); + + // globeControl1.Globe.ClearLastTrackPolyline(); + + if (e.Polyline != null) + { + //横断面分析 + if (buttonItemFX2_1.Checked || buttonItemFX2_3.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 (buttonItemFX2_1.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 (buttonItemFX2_4.Checked) + { + FrmBaseLineProfillAnalysis dlg = new FrmBaseLineProfillAnalysis(globeControl1.Globe, e.Polyline); + dlg.Show(this); + globeControl1.Globe.ClearLastTrackPolyline(); + } + else if (buttonItemFX4_3.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(); + * **/ } #endregion @@ -2713,16 +2896,20 @@ case "valvequery": FrmValveStatistics frm = new FrmValveStatistics(globeControl1,polygon, new DataGridViewDelegate(InitDataGridViewX1)); frm.Show(this); + //panelEx6.Visible = true; + toolStripFeatureLength.Text = ""; globeControl1.Globe.Action = EnumAction3D.ActionNull; break; case "PipelineDistanceStatistics": + FrmAllPipelineStatis frm1 = new FrmAllPipelineStatis(globeControl1, polygon, new DataGridViewDelegate(InitDataGridViewX1), m_PipelineLayerNames); frm1.Show(this); globeControl1.Globe.Action = EnumAction3D.ActionNull; break; case "PipelineSpatialQuery": + FrmAllPipelineStatis.ShowForm(globeControl1,polygon,new DataGridViewDelegate(InitDataGridViewX1),m_PipelineLayerNames); globeControl1.Globe.ClearAnalysis(); globeControl1.Globe.Action = EnumAction3D.ActionNull; @@ -2771,18 +2958,19 @@ break; case "BSQDuoBianXiangStatis": - GSOFeature f2 = new GSOFeature(); - f2.Geometry = e.Polygon; - f2.Geometry.AltitudeMode = EnumAltitudeMode.Absolute; - globeControl1.Globe.MemoryLayer.AddFeature(f2); - f2.Geometry.MoveZ(3); - workWellLen.Clear(); - List listBSQ = new List(); + //GSOFeature f2 = new GSOFeature(); + //f2.Geometry = e.Polygon; + //f2.Geometry.AltitudeMode = EnumAltitudeMode.Absolute; + //globeControl1.Globe.MemoryLayer.AddFeature(f2); + //f2.Geometry.MoveZ(3); + //workWellLen.Clear(); + //List listBSQ = new List(); - GSOFeatures bsqFeatures = PolygonIntersectAnalysis(e.Polygon, "标识器"); - listBSQ.Add(bsqFeatures); + //GSOFeatures bsqFeatures = PolygonIntersectAnalysis(e.Polygon, "标识器"); + //listBSQ.Add(bsqFeatures); - FrmBSQDuoBianXingStatis bsqFrm = new FrmBSQDuoBianXingStatis(workWellLen, globeControl1, listBSQ); + //FrmBSQDuoBianXingStatis bsqFrm = new FrmBSQDuoBianXingStatis(workWellLen, globeControl1, listBSQ); + FrmBSQStatis bsqFrm = new FrmBSQStatis(globeControl1,e.Polygon); bsqFrm.Show(this); globeControl1.Globe.Action = EnumAction3D.ActionNull; break; @@ -4351,6 +4539,26 @@ } /// + /// 在窗体的底部状态栏上显示 综合管线条件查询结果 + /// + /// + /// + 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 + " 条记录 | "; + } + } + + /// /// 统计管线的里程数 /// /// @@ -6824,6 +7032,54 @@ } /// + /// 创建label要素 功能 + /// + /// 添加label要素的feature + /// feature的位置 + /// label要素名字 + /// feature名字 + /// label要素距离点的位置 + /// + 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; + } + + + + /// /// 获取指定两点组成的线的长度 功能 /// /// @@ -9266,8 +9522,19 @@ //日志记录 LogManager.saveLog(Utility.userName, "管线长度统计"); + //pipeLineDis.Clear(); + //List list = new List(); + //for (int i = 0; i < m_PipelineLayerNames.Count; i++) + //{ + // GSOFeatures fs = Intersects_Pipeline(null, m_PipelineLayerNames[i]); + // if (fs!=null) + // list.Add(fs); + //} + + //FrmAllPipelineStatis frm = new FrmAllPipelineStatis(0, pipeLineDis, list, globeControl1, new DataGridViewDelegate(InitDataGridViewX1)); FrmAllPipelineStatis frm = new FrmAllPipelineStatis(globeControl1,null, new DataGridViewDelegate(InitDataGridViewX1), m_PipelineLayerNames); frm.Show(this); + } /// /// 管线长度绘制区域统计 @@ -9293,6 +9560,25 @@ //日志记录 LogManager.saveLog(Utility.userName, "阀门数量统计"); + //workWellLen.Clear(); + //List list = new List(); + ////找到所有阀门 + //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, globeControl1, new DataGridViewDelegate(InitDataGridViewX1)); FrmValveStatistics frm = new FrmValveStatistics(globeControl1, null, new DataGridViewDelegate(InitDataGridViewX1)); frm.Show(this); @@ -9318,9 +9604,7 @@ /// /// private void buttonItemTJ3_ALL_Click(object sender, EventArgs e) - { - //日志记录 - LogManager.saveLog(Utility.userName, "井盖数量统计"); + { FrmAllWorkWellStatis frm = new FrmAllWorkWellStatis(globeControl1, null, new DataGridViewDelegate(InitDataGridViewX1)); frm.Show(this); } @@ -9333,7 +9617,7 @@ { //日志记录 LogManager.saveLog(Utility.userName, "井盖数量统计"); - + trackflag = "workwellquery"; globeControl1.Globe.Action = EnumAction3D.TrackPolygon; globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; @@ -11142,7 +11426,7 @@ Cyberpipe.Forms.FrmPipelineModelDB frm = new Cyberpipe.Forms.FrmPipelineModelDB(globeControl1, ds); if (frm.ShowDialog() == DialogResult.OK) { - //addNodeToLayerManagerNode(frm.rukuLayer); + addNodeToLayerManagerNode(frm.rukuLayer); } } /// @@ -12377,7 +12661,8 @@ private void 标识器分类统计ToolStripMenuItem_Click(object sender, EventArgs e) { globeControl1.Globe.Action = EnumAction3D.ActionNull; - FrmBSQStatis bsqStatis = new FrmBSQStatis(); + FrmBSQStatis bsqStatis = new FrmBSQStatis(globeControl1,null); + //FrmBSQStatis bsqStatis = new FrmBSQStatis(); bsqStatis.Show(this); } /// diff --git a/MainFrm.cs.BACKUP.9016.cs b/MainFrm.cs.BACKUP.9016.cs new file mode 100644 index 0000000..28cb7fa --- /dev/null +++ b/MainFrm.cs.BACKUP.9016.cs @@ -0,0 +1,13074 @@ +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; + + GSOBalloon featureTooltip2; + GSOBalloonEx balloonEx2; + + GSOLayer layerTemp; + GSOLayer layerTemp2; + FrmShResult frmShResult = null; + FrmRedlineResult frmredResult = null; + FrmMnModify frmModify = null; + public bool frmRedlineResult = false; + public bool boolfrmShResult = false; + public bool boolfrmModify = false; + + List m_PipelineLayerNames = new List();//线图层名称 + List workwellLayerNames = new List();//工井图层名称 + List valueLayerNames = new List();//阀门图层名称 + List instrumenLayerNames = new List();//附属物图层名称 + List pipefittingLayerNames = new List();//管件图层名称 + List sgPipeLayersNames = new List();//施工管线图层名称 + 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 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; + public string redLayer = null; + //GSOLayer redLayer1 = null; + bool redSH = false; + string redDt = "红线"; + //双屏对比 + //bool zhanshi=false; + Thread t = null; + private GSOHudButton legendSC;//定义图例 + private GSOHudButton legendSG;//定义图例 + //管纵图 + private GSOHudButton lendendGZ50; + private GSOHudButton lendendGZ36; + private GSOHudButton lendendGZ42; + private GSOHudButton lendendGZ24_1; + private GSOHudButton lendendGZ24_2; + private GSOHudButton lendendGZ24_3; + private GSOHudButton lendendGZ26; + + GSOGeoPoint3D bsqPT; + + FrmYJSHTC frmSh = null;//一键审核窗口全局变量wxl + FrmWait frmWait = null;//一键审核等待窗口 + //FrmWait frmWait2 = null;//文档操作等待窗口 + + float mouseDownX1,mouseDownY1; + float mouseDownX2,mouseDownY2; + /// + /// + /// + 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; + + featureTooltip2 = new GSOBalloon(globeControl2.Handle); + balloonEx2 = new GSOBalloonEx(globeControl2.Handle); + Utility.SetBallons(featureTooltip, balloonEx); + + panelOfTable.Height = 200; + + RigthMenuSet(); + + MenuSet(); + + } + /// + /// 右屏中添加管纵图片 + /// + private void AddGZ() + { + + lendendGZ50 = new GSOHudButton(); + lendendGZ50.SetImage(Application.StartupPath + "/Resource/管纵/50.png"); + lendendGZ50.SetOffset(0, 0); + lendendGZ50.MinOpaque = 1; + lendendGZ50.MaxOpaque = 1; + lendendGZ50.FadeOut = false; + lendendGZ50.Name = "lendendGZ50"; + lendendGZ50.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ50); + lendendGZ50.Visible = false; + + lendendGZ36 = new GSOHudButton(); + lendendGZ36.SetImage(Application.StartupPath + "/Resource/管纵/36.png"); + lendendGZ36.SetOffset(0, 0); + lendendGZ36.MinOpaque = 1; + lendendGZ36.MaxOpaque = 1; + lendendGZ36.FadeOut = false; + lendendGZ36.Name = "lendendGZ36"; + lendendGZ36.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ36); + lendendGZ36.Visible = false; + + lendendGZ42 = new GSOHudButton(); + lendendGZ42.SetImage(Application.StartupPath + "/Resource/管纵/42.png"); + lendendGZ42.SetOffset(0, 0); + lendendGZ42.MinOpaque = 1; + lendendGZ42.MaxOpaque = 1; + lendendGZ42.FadeOut = false; + lendendGZ42.Name = "lendendGZ42"; + lendendGZ42.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ42); + lendendGZ42.Visible = false; + + lendendGZ24_1 = new GSOHudButton(); + lendendGZ24_1.SetImage(Application.StartupPath + "/Resource/管纵/24_1.png"); + lendendGZ24_1.SetOffset(0, 0); + lendendGZ24_1.MinOpaque = 1; + lendendGZ24_1.MaxOpaque = 1; + lendendGZ24_1.FadeOut = false; + lendendGZ24_1.Name = "lendendGZ24_1"; + lendendGZ24_1.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ24_1); + lendendGZ24_1.Visible = false; + + lendendGZ24_2 = new GSOHudButton(); + lendendGZ24_2.SetImage(Application.StartupPath + "/Resource/管纵/24_2.png"); + lendendGZ24_2.SetOffset(0, 0); + lendendGZ24_2.MinOpaque = 1; + lendendGZ24_2.MaxOpaque = 1; + lendendGZ24_2.FadeOut = false; + lendendGZ24_2.Name = "lendendGZ24_2"; + lendendGZ24_2.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ24_2); + lendendGZ24_2.Visible = false; + + lendendGZ24_3 = new GSOHudButton(); + lendendGZ24_3.SetImage(Application.StartupPath + "/Resource/管纵/24_3.png"); + lendendGZ24_3.SetOffset(0, 0); + lendendGZ24_3.MinOpaque = 1; + lendendGZ24_3.MaxOpaque = 1; + lendendGZ24_3.FadeOut = false; + lendendGZ24_3.Name = "lendendGZ24_3"; + lendendGZ24_3.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ24_3); + lendendGZ24_3.Visible = false; + + lendendGZ26 = new GSOHudButton(); + lendendGZ26.SetImage(Application.StartupPath + "/Resource/管纵/26.png"); + lendendGZ26.SetOffset(0, 0); + lendendGZ26.MinOpaque = 1; + lendendGZ26.MaxOpaque = 1; + lendendGZ26.FadeOut = false; + lendendGZ26.Name = "lendendGZ26"; + lendendGZ26.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ26); + lendendGZ26.Visible = false; + + } + + public void RigthMenuSet() + { + if (Utility.userRole.IndexOf("清除分析") < 0) + { + toolRightMenu.Items.Remove(清除分析ToolStripMenuItem); + } + + #region 区域分析 + if (Utility.userRole.IndexOf("区域分析") < 0) + { + toolRightMenu.Items.Remove(区域分析ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("缓冲区分析") < 0) + { + 区域分析ToolStripMenuItem.DropDownItems.Remove(缓冲区分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("附属物分析") < 0) + { + 区域分析ToolStripMenuItem.DropDownItems.Remove(附属物分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("无源淹没分析") < 0) + { + 区域分析ToolStripMenuItem.DropDownItems.Remove(无源淹没分析ToolStripMenuItem); + } + } + #endregion + + #region 视域分析 + if (Utility.userRole.IndexOf("视域分析") < 0) + { + toolRightMenu.Items.Remove(视域分析ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("通视分析") < 0) + { + 视域分析ToolStripMenuItem.DropDownItems.Remove(通视分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("可视域分析") < 0) + { + 视域分析ToolStripMenuItem.DropDownItems.Remove(可视域分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("可视包络分析") < 0) + { + 视域分析ToolStripMenuItem.DropDownItems.Remove(可视包络分析ToolStripMenuItem); + } + } + #endregion + + #region 开发分析 + if (Utility.userRole.IndexOf("开挖分析") < 0) + { + toolRightMenu.Items.Remove(开挖分析ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("多边形开挖") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(多边形开挖ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("挖方量分析") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(挖方量分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("沿线开挖") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(沿线开挖ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("创建隧道") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(创建隧道ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("隐藏隧道") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(隐藏隧道ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("删除隧道") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(删除隧道ToolStripMenuItem); + } + } + #endregion + + #region 拓扑分析 + if (Utility.userRole.IndexOf("拓扑分析") < 0) + { + toolRightMenu.Items.Remove(拓扑分析ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("创建拓扑") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(创建拓扑ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("上游分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(上游分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("下游分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(下游分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("流向分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(流向分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("关阀分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(关阀分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("连通分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(连通分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("爆管分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(爆管分析ToolStripMenuItem); + } + } + #endregion + + #region 断面分析 + if (Utility.userRole.IndexOf("断面分析") < 0) + { + toolRightMenu.Items.Remove(断面分析ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("横断面分析") < 0) + { + 断面分析ToolStripMenuItem.DropDownItems.Remove(横断面分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("纵断面分析") < 0) + { + 断面分析ToolStripMenuItem.DropDownItems.Remove(纵断面分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("道路断面分析") < 0) + { + 断面分析ToolStripMenuItem.DropDownItems.Remove(道路断面分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("基线剖面分析") < 0) + { + 断面分析ToolStripMenuItem.DropDownItems.Remove(基线剖面分析ToolStripMenuItem); + } + } + #endregion + + #region 绘制区域统计 + if (Utility.userRole.IndexOf("绘制区域统计") < 0) + { + toolRightMenu.Items.Remove(绘制区域统计ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("绘制区域管线长度统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管线长度统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域阀门数量统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(阀门数量统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域井盖数量统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(井盖数量统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域管径分段统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管径分段统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域埋深分段统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(埋深分段统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域管径分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管径分类统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域材质分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(材质分类统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域附属物分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(附属物分类统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域标识器分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(标识器分类统计ToolStripMenuItem1); + } + + } + #endregion + + #region 全区域统计 + if (Utility.userRole.IndexOf("全区域统计") < 0) + { + toolRightMenu.Items.Remove(全区域统计ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("全区域管线长度统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管线长度统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域阀门数量统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(阀门数量统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域井盖数量统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(井盖数量统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域管径分段统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管径分段统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域埋深分段统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(埋深分段统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域管径分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管径分类统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域材质分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(材质分类统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域附属物分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(附属物分类统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域标识器分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(标识器分类统计ToolStripMenuItem); + } + + } + #endregion + + #region 查询 + if (Utility.userRole.IndexOf("查询") < 0) + { + toolRightMenu.Items.Remove(查询ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("空间查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(空间查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("编号查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(编号查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("坐标查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(坐标查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("管径查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(管径查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("材质查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(材质查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("基本查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(基本查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("复合查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(复合查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("关联查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(关联查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("关键字查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(关键字查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("附属物查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(附属物查询ToolStripMenuItem); + } + } + #endregion + + #region 标注 + if (Utility.userRole.IndexOf("标注") < 0) + { + toolRightMenu.Items.Remove(标注ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("标高标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(标高标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("管径标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(管径标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("埋深标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(埋深标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("坐标标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(坐标标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("距离标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(距离标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("自定义标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(自定义标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("扯旗标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(扯旗标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("坡度标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(坡度标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("属性标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(属性标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("标注管理") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(标注管理ToolStripMenuItem); + } + } + #endregion + + #region 飞行 + if (Utility.userRole.IndexOf("飞行") < 0) + { + toolRightMenu.Items.Remove(飞行ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("自定义飞行") < 0) + { + 飞行ToolStripMenuItem.DropDownItems.Remove(自定义飞行ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("飞行到目标点") < 0) + { + 飞行ToolStripMenuItem.DropDownItems.Remove(飞行到目标点ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("绕中心点飞行") < 0) + { + 飞行ToolStripMenuItem.DropDownItems.Remove(绕中心点飞行ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("绕眼睛飞行") < 0) + { + 飞行ToolStripMenuItem.DropDownItems.Remove(绕眼睛飞行ToolStripMenuItem); + } + } + #endregion + + #region 编辑 + if (Utility.userRole.IndexOf("编辑") < 0) + { + toolRightMenu.Items.Remove(编辑ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("平移对象") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(平移对象ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("升降对象") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(升降对象ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("旋转对象") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(旋转对象ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("连接管段") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(连接管段ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("导出文件") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(导出文件ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("前进") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(前进ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("后退") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(删除模型ToolStripMenuItem); + } + } + #endregion + + #region 量算 + if (Utility.userRole.IndexOf("量算") < 0) + { + toolRightMenu.Items.Remove(量算ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("水平距离") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(水平距离ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("垂直距离") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(垂直距离ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("空间距离") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(空间距离ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("地表距离") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(地表距离ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("高度量算") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(高度量算ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("水平面积") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(水平面积ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("地表面积") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(地表面积ToolStripMenuItem1); + } + } + #endregion + } + + public void MenuSet() + { + + #region 权限管理 + if (Utility.userRole.IndexOf("权限管理") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem2); + } + else + { + + if (Utility.userRole.IndexOf("用户管理") < 0) + { + btn_user_info.Visible = false; + } + if (Utility.userRole.IndexOf("角色管理") < 0) + { + btn_role_info.Visible = false; + } + if (Utility.userRole.IndexOf("资源管理") < 0) + { + btn_resc_info.Visible = false; + } + if (Utility.userRole.IndexOf("角色授权") < 0) + { + btn_role_resc.Visible = false; + } + if (Utility.userRole.IndexOf("用户授权") < 0) + { + btn_user_role.Visible = false; + } + if (Utility.userRole.IndexOf("密码修改") < 0) + { + btn_password_edit.Visible = false; + } + + } + #endregion + + #region 基础工具 + if (Utility.userRole.IndexOf("基础工具") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem1); + } + else + { + if (Utility.userRole.IndexOf("地上模式") < 0) + { + buttonItem87.Visible = false; + } + if (Utility.userRole.IndexOf("地下模式") < 0) + { + buttonItem88.Visible = false; + } + if (Utility.userRole.IndexOf("行走模式") < 0) + { + buttonItem27.Visible = false; + } + if (Utility.userRole.IndexOf("透明度设置") < 0) + { + sliderGroundTransSet1.Visible = false; + } + if (Utility.userRole.IndexOf("快速定位") < 0) + { + buttonItem91.Visible = false; + } + if (Utility.userRole.IndexOf("图层管理") < 0) + { + buttonItem1.Visible = false; + } + if (Utility.userRole.IndexOf("图例管理") < 0) + { + btnlegendSet.Visible = false; + } + if (Utility.userRole.IndexOf("全屏显示") < 0) + { + buttonItem89.Visible = false; + } + if (Utility.userRole.IndexOf("导出图片") < 0) + { + btnOutputJPG.Visible = false; + } + + } + #endregion + + #region 一键审核 + if (Utility.userRole.IndexOf("一键审核") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem11); + } + #endregion + + #region 红线审核 + if (Utility.userRole.IndexOf("红线审核") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem6); + } + #endregion + + #region 双屏对比 + if (Utility.userRole.IndexOf("双屏对比") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem9); + } + #endregion + + #region 文档管理 + if (Utility.userRole.IndexOf("文档管理") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem4); + } + #endregion + + #region 基础管理 + if (Utility.userRole.IndexOf("基础管理") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem14); + } + else + { + if (Utility.userRole.IndexOf("专题图审批") < 0) + { + buttonItemZTT3_2.Visible = false; + } + if (Utility.userRole.IndexOf("打印审批") < 0) + { + buttonItemZTT4_2.Visible = false; + } + if (Utility.userRole.IndexOf("拷贝审批") < 0) + { + buttonItemZTT5_2.Visible = false; + } + } + + #endregion + + if (ribbonControl1.Items.Count <= 0) + { + ribbonControl1.Visible = false; + } + } + + #region Fan Zhang 重构现有代码 + //初始化控件布局 + private void initLayout() + { + 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.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.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.labelX21.Width = (int)(this.labelX21.Width * myScreen); + this.labelX22.Width = (int)(this.labelX22.Width * myScreen); + this.labelX24.Width = (int)(this.labelX24.Width * myScreen); + } + sideBar1.Visible = false; + 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]); + } + + splitContainer1.Panel2Collapsed = true; + + buttonItem87.Checked = true;//默认地上模式 + ribbonTabItem1.Select(); //初始化状态为浏览 + + sideBarPanelItem3.Visible = false; + layerTree.Visible = false; + controlContainerItem3.Visible = false; + if (sideBarPanelItem4.Visible == true) + { + sideBar1.Visible = true; + controlContainerItem5.Visible = true; + } + else + { + sideBar1.Visible = false; + } + Refresh(); + sliderGroundTransSet1.Value = optiValue; + sliderItem1.Value = optiValue; + sliderItem2.Value = optiValue; + sliderItem3.Value = optiValue; + + } + + //初始化地球控件 + private void initGlobalControl() + { + //选择 + btnToolSelect = new GSOHudButton(); + btnToolSelect.SetImage(Application.StartupPath + "\\Resource\\image\\select1.png"); + btnToolSelect.FadeOut = false; + btnToolSelect.Align = EnumAlign.TopLeft; + btnToolSelect.SetOffset(20, 50); + btnToolSelect.Name = "1"; + btnToolSelect.HeightFixed = true; + btnToolSelect.WidthFixed = true; + globeControl1.Globe.AddHudControl(btnToolSelect); + globeControl2.Globe.AddHudControl(btnToolSelect); + + //浏览 + 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); + + //图例 + legend = new GSOHudButton(); + legend.SetImage(Application.StartupPath + "/Resource/图例P.jpg");//图例P + legend.SetOffset(0, 15); + legend.MinOpaque = 1; + legend.MaxOpaque = 1; + legend.FadeOut = false; + legend.Name = "legend"; + legend.Align = EnumAlign.BottomRight; + legend.Visible = false; + globeControl1.Globe.AddHudControl(legend); + + //实测 + legendSC = new GSOHudButton(); + legendSC.SetImage(Application.StartupPath + "/Resource/sc.jpg"); + legendSC.SetOffset(0, 15); + legendSC.MinOpaque = 1; + legendSC.MaxOpaque = 1; + legendSC.FadeOut = false; + legendSC.Name = "legendSC"; + legendSC.Align = EnumAlign.BottomRight; + globeControl1.Globe.AddHudControl(legendSC); + legendSC.Visible = false; + + //施工 + legendSG = new GSOHudButton(); + legendSG.SetImage(Application.StartupPath + "/Resource/sg.jpg"); + legendSG.SetOffset(0, 15); + legendSG.MinOpaque = 1; + legendSG.MaxOpaque = 1; + legendSG.FadeOut = false; + legendSG.Name = "legendSG"; + legendSG.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(legendSG); + legendSG.Visible = false; + + //管纵 + AddGZ(); + + 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; + globeControl1.Globe.IsReleaseMemOutOfView = true; + globeControl1.Globe.ControlPanel.Visible = true; + + globeControl2.Globe.UnderGroundFloor.Visible = false; + globeControl2.Globe.OverviewControl.Visible = false; + globeControl2.Globe.ScalerControl.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; + globeControl2.Globe.IsReleaseMemOutOfView = true; + globeControl2.Globe.ControlPanel.Visible = false; + + 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); + + //添加临时图层 + layerTemp = globeControl1.Globe.Layers.Add(Application.StartupPath + "\\tempLgdData.lgd"); + layerTemp2 = globeControl2.Globe.Layers.Add(Application.StartupPath + "\\tempLgdData2.lgd"); + if (layerTemp != null) + { + layerTemp.MaxVisibleAltitude = 1000; + } + + //添加城市7线图层 + 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"); + + //注册对应事件 + this.registerEvent(); + } + + //注册地球事件 + private bool registerEvent() + { + if (globeControl1 == null || globeControl2 == null) + { + return false; + } + 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); + + globeControl2.FeatureMouseClickEvent += new FeatureMouseClickEventHandler(globeControl2_FeatureMouseClickEvent); + globeControl2.CameraBeginMoveEvent += new CameraBeginMoveEventHandler(globeControl2_CameraBeginMoveEvent); + + globeControl1.MouseDoubleClick += new MouseEventHandler(globeControl1_MouseDoubleClick); + globeControl1.MouseClick += new MouseEventHandler(globeControl1_MouseClick); + globeControl1.MouseDown += new MouseEventHandler(globeControl1_MouseDown); + + globeControl2.MouseClick += new MouseEventHandler(globeControl2_MouseClick); + globeControl2.MouseDown += new MouseEventHandler(globeControl2_MouseDown); + + 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); + + return true; + } + + //加载两个地球数据 + private void loadData() + { + Thread t1 = new Thread(new ThreadStart(doLoadDataForGlobalControl1)); + t1.IsBackground = true; + t1.Start(); + + + } + + delegate void LoadDataForGlobalControl(); + + private void connectServer() + { + globeControl1.Globe.ConnectServer(Utility.serverip, Utility.serverport, "", ""); //加载locaServer中的数据 + globeControl2.Globe.ConnectServer(Utility.serverip, Utility.serverport, "", ""); //加载locaServer中的数据 + //初始化TreeView + // 勾选实测图层 + foreach (TreeNode tn in layerTree.Nodes) + { + if (tn.Nodes.Count > 0) + { + if (tn.Text == "实测数据") + { + tn.Checked = true; + foreach (TreeNode tnChild in tn.Nodes) + { + tnChild.Checked = true; + foreach (TreeNode tnGrandChild in tnChild.Nodes) + { + tnGrandChild.Checked = true; + } + } + } + } + } + } + + private void doLoadDataForGlobalControl1() + { + try + { + + globeControl1.Globe.Layers.MoveDown(10000); + //加载实测管线数据 + Utility.dataSource = globeControl1.Globe.DataManager.OpenOracleDataSource(Utility.DBServer.Trim() + "/" + Utility.dbdatabase.Trim(), "", "", Utility.userID, Utility.DBPassword); + + if (Utility.dataSource != null) + { + for (int j = 0; j < Utility.dataSource.DatasetCount; j++) + { + GSODataset dataset = Utility.dataSource.GetDatasetAt(j); + if (dataset != null && dictionaryNetLayerNameAndCaption.ContainsKey(dataset.Caption)) + { + dataset.Caption = dataset.Name; + globeControl1.Globe.Layers.Add(dataset); + } + } + } + //隐藏红线图层 + globeControl1.Globe.Layers.GetLayerByCaption("红线").Visible = false; + + //globleControl1中加载规划数据 + GSODataSource ghDS = globeControl1.Globe.DataManager.OpenOracleDataSource(Utility.ghdbip + "/" + Utility.ghdbname, "", "", Utility.ghdbuser, Utility.ghdbpwd); + if (ghDS != null) + { + for (int j = 0; j < ghDS.DatasetCount; j++) + { + GSODataset dataset = ghDS.GetDatasetAt(j); + if (dataset != null && dictionaryNetLayerNameAndCaption.ContainsKey(dataset.Caption)) + { + dataset.Caption = dataset.Name; + globeControl1.Globe.Layers.Add(dataset); + globeControl1.Globe.Layers[0].Visible = false; + } + } + } + + //globeControl1,globeControl2中加载施工数据 + GSODataSource sgDS = globeControl1.Globe.DataManager.OpenOracleDataSource(Utility.sgdbip + "/" + Utility.sgdbname, "", "", Utility.sgdbuser, Utility.sgdbpwd); + if (sgDS != null) + { + for (int m = 0; m < sgDS.DatasetCount; m++) + { + GSODataset dataset = sgDS.GetDatasetAt(m); + if (dataset != null && !dataset.Caption.Contains("SH") && dictionaryNetLayerNameAndCaption.ContainsKey(dataset.Caption)) + { + dataset.Caption = dataset.Name; + globeControl1.Globe.Layers.Add(dataset); + globeControl1.Globe.Layers[0].Visible = false; + + globeControl2.Globe.Layers.Add(dataset); + globeControl2.Globe.Layers[0].Visible = true; + } + } + } + + LoadDataForGlobalControl ss = new LoadDataForGlobalControl(connectServer); + ss(); + + } + catch (Exception ex) + { + MessageBox.Show(ex.Message); + } + } + + private void initLayerTree() + { + //加载临时图层节点 + layerManagerNode = new TreeNode(); + layerManagerNode.ImageIndex = 0; + layerManagerNode.SelectedImageIndex = 0; + layerManagerNode.Checked = true; + layerManagerNode.Text = "临时图层"; + layerTree.Nodes.Add(layerManagerNode); + + XmlDocument doc = new XmlDocument(); + doc.Load(filename); + XmlNodeList xmlLayerNodes = doc.SelectNodes("//layer"); + + foreach (XmlNode xmlLayerNode in xmlLayerNodes) + { + + //TODO LIST:创建一级TreeNode(实测、规划、施工) + TreeNode nodelayer = new TreeNode(); + string layerName = xmlLayerNode.Attributes["label"].Value; + nodelayer.Text = layerName; + nodelayer.Checked = false; + layerTree.Nodes.Add(nodelayer); + + XmlNodeList xmlChildLayerNodes = xmlLayerNode.ChildNodes; + foreach (XmlNode xmlChildLayerNode in xmlChildLayerNodes) + { + //TODO LIST:创建二级TreeNode节点 + TreeNode secondLevelNode = new TreeNode(); + string layerType = xmlChildLayerNode.Attributes["label"].Value; + secondLevelNode.Text = layerType; + + if (xmlChildLayerNode.Attributes["type"] != null) + { //道路图层特殊处理 + string type = xmlChildLayerNode.Attributes["type"].Value; + secondLevelNode.Tag = type + "|" + layerType; + } + else + { + secondLevelNode.Tag = layerType; + } + secondLevelNode.Checked = false; + nodelayer.Nodes.Add(secondLevelNode); + + XmlNodeList xmlActitualLayerNodes = xmlChildLayerNode.ChildNodes; + + foreach (XmlNode xmlActitualLayerNode in xmlActitualLayerNodes) + { + //TODO LIST:创建三级图层节点 + TreeNode layerNode = new TreeNode(); + string actutallylayerType = xmlActitualLayerNode.Attributes["type"].Value; + string actutallylayerName = xmlActitualLayerNode.Attributes["layer"].Value; + string actutallyLabelName = xmlActitualLayerNode.Attributes["label"].Value; + + layerNode.Text = actutallyLabelName; + layerNode.Tag = layerType + "|" + actutallyLabelName; + layerNode.Checked = false; + secondLevelNode.Nodes.Add(layerNode); + } + + } + + } + + } + + /** + * 读取Config.xml文件,初始化以下全局Map + * m_PipelineLayerNames:管线 + * workwellLayerNames:工井 + * valueLayerNames:阀门 + * instrumenLayerNames:附属物 + * pipefittingLayerNames:特征管点 + * sgPipeLayersNames:施工管线 + **/ + private void initGlobalMap() + { + XmlDocument doc = new XmlDocument(); + doc.Load(filename); + XmlNodeList xmlLayerNodes = doc.SelectNodes("//layerchild"); + + foreach (XmlNode xmlLayerNode in xmlLayerNodes) + { + string layerType = xmlLayerNode.Attributes["type"].Value; + string layerName1 = xmlLayerNode.Attributes["layer"].Value; + string layerchildName = xmlLayerNode.Attributes["label"].Value; + + dictionaryNetLayerNameAndCaption.Add(layerName1, layerchildName); + + if (layerType != "db") + { + if (xmlLayerNode.Attributes["isRoad"] != null) + { + roadLayerName = layerchildName; + } + } + else if (xmlLayerNode.Attributes["isPipeLine"] != null) + { + m_PipelineLayerNames.Add(layerchildName); + g1layername.Add(layerName1); + } + else if (xmlLayerNode.Attributes["isWorkWell"] != null) + { + workwellLayerNames.Add(layerchildName); + g1layername.Add(layerName1); + } + else if (xmlLayerNode.Attributes["isValve"] != null) + { + valueLayerNames.Add(layerchildName); + g1layername.Add(layerName1); + } + else if (xmlLayerNode.Attributes["isAccess"] != null) + { + instrumenLayerNames.Add(layerchildName); + g1layername.Add(layerName1); + } + else if (xmlLayerNode.Attributes["isCharacter"] != null) + { + pipefittingLayerNames.Add(layerchildName); + g1layername.Add(layerName1); + } + else if (xmlLayerNode.Attributes["isSgData"] != null) + { + sgPipeLayersNames.Add(layerchildName); + g1layername.Add(layerName1); + } + + } + } + + private void initMarkerTree() + { + 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); + } + } + } + } + + private void MainFrm_Load(object sender, EventArgs e) + { + + this.initGlobalControl(); + this.initGlobalMap(); + this.initLayerTree(); + this.initMarkerTree(); + this.initLayout(); + this.loadData(); + + + double x = Convert.ToDouble(Utility.Query_Roads["绿岛"].ToString().Split(',')[0]); + double y = Convert.ToDouble(Utility.Query_Roads["绿岛"].ToString().Split(',')[1]); + double z = Convert.ToDouble(Utility.Query_Roads["绿岛"].ToString().Split(',')[2]); + jumpToCameraState(x, y, z); + + + } + + #endregion + + /// + /// 每次gis服务加载时都会触发的 + /// + /// + /// + 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 dictionaryNetLayerNameAndCaption = new Dictionary(); + 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 配置用户权限 + /// + /// 向数据库插入功能列表 + /// + private void insertControlToDatabase() + { + ArrayList listItem = new ArrayList(); + List subListItem = new List(); + 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) + { + GSOCameraState camera = globeControl2.Globe.CameraState; + globeControl1.Globe.JumpToCameraState(camera); + } + } + + void globeControl1_BeforeSceneRenderEvent(object sender, BeforeSceneRenderEventArgs e) + { + if (globeControl1.Focused) + { + 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); + } + } + } + + /// + /// 检查数据集是否有坐标系信息 + /// + /// + /// + 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 = "0prj4" + lprjStr + ""; + + bSuccess = dataset.LoadProjectionFromESRIFile(dlg.FileName); + + string lprjFileName = strDataPath.Substring(0, strDataPath.LastIndexOf(".")) + ".lprj"; + StreamWriter writer = new StreamWriter(lprjFileName, false); + writer.Write(lprjFileContent); + writer.Close(); + + } + } + } + else + { + return true; + } + return bSuccess; + } + + /// + /// 矩形拉框结束事件处理函数 + /// + /// + /// + 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))); + */ + + int mapWidth = 0; + int mapHeight = 0; + Point pt = getUpperLeftPoint(pt1, pt2, out mapWidth, out mapHeight); + int rightBottomX = pt.X + mapWidth; + int rightBottomY = pt.Y + mapHeight; + Image myImg = new Bitmap(mapWidth, mapHeight); + Graphics g = Graphics.FromImage(myImg); + g.CopyFromScreen(pt, new Point(0, 0), new Size(rightBottomX, rightBottomY)); + + 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; + } + } + /// + /// 定位正北正90度俯视 + /// + /// + /// + /// + 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; + } + } + /// + /// layerTree选中后事件处理 + /// + /// + /// + 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); + } + /// + /// 树节点选中方法 + /// + /// + 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); + } + } + } + + } + /// + /// 改变所有子节点的状态 + /// + /// + /// + 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; + LayerFlyMenuItem.Visible = true; + } + + LayerSelectableMenuItem.Visible = true; + LayerEditableMenuItem.Visible = true; + SaveLayerMenuItem.Visible = true; + LayerFlyMenuItem.Visible = true; + 导出CADToolStripMenuItem1.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]); + if (layer != null) + { + LayerSelectableMenuItem.Checked = layer.Selectable; + LayerEditableMenuItem.Checked = layer.Editable; + } + else + { + return; + } + } + 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; + } + } + } + } + } + + /// + /// 删除临时添加的本地数据图层 + /// + /// + /// + 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); + for (int i = globeControl1.Globe.Layers.Count-1; i >=0; i--) + { + if (globeControl1.Globe.Layers[i].Caption == layer.Caption) + { + globeControl1.Globe.Layers.Remove(globeControl1.Globe.Layers[i]); + } + } + + 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 定位ToolStripMenuItem_Click(object sender, EventArgs e) + { + TreeNode node = layerTree.SelectedNode; + + if (node != null) + { + if (node.Parent.Text.Trim() == "临时图层") + { + GSOLayer lsLayer = globeControl1.Globe.Layers.GetLayerByCaption(node.Text.ToString()); + double x = lsLayer.LatLonBounds.Center.X; + double y = lsLayer.LatLonBounds.Center.Y; + if (x == 0 && y == 0) + { + x = lsLayer.Bounds.Center.X; + y = lsLayer.Bounds.Center.Y; + } + + globeControl1.Globe.FlyToPosition(new GSOPoint3d(x, y, 10), EnumAltitudeMode.Absolute); + } + else + { + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(node.Tag.ToString().Split('|')[1]); + + if (layer != null) + { + if (layer.Caption == "红线") + { + globeControl1.Globe.FlyToPosition(new GSOPoint3d(120.610963, 31.188121, 50), EnumAltitudeMode.Absolute, -4, 50, 1000); + globeControl1.Globe.FlyToPointSpeed = 10000000; + globeControl1.Globe.Action = EnumAction3D.SelectObject; + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = true; + } + globeControl1.Refresh(); + } + else + { + double x = layer.LatLonBounds.Center.X; + double y = layer.LatLonBounds.Center.Y; + globeControl1.Globe.FlyToPosition(new GSOPoint3d(x, y, 100), EnumAltitudeMode.Absolute); + } + } + } + } + else + { + return; + } + + } + + private void layerTree_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e) + { + if(this.layerTree.SelectedNode!=null) + { + if (this.layerTree.SelectedNode.Tag.ToString().Contains("|")) + { + string nodeTag = this.layerTree.SelectedNode.Tag.ToString().Split('|')[1]; + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(nodeTag); + if (layer != null) + { + if (layer.Caption == "红线") + { + globeControl1.Globe.FlyToPosition(new GSOPoint3d(120.610963, 31.188121, 50), EnumAltitudeMode.Absolute, -4, 50, 1000); + globeControl1.Globe.FlyToPointSpeed = 10000000; + globeControl1.Globe.Action = EnumAction3D.SelectObject; + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = true; + } + globeControl1.Refresh(); + } + else { + double x = layer.LatLonBounds.Center.X; + double y = layer.LatLonBounds.Center.Y; + globeControl1.Globe.FlyToPosition(new GSOPoint3d(x, y, 0), EnumAltitudeMode.Absolute); + } + } + } + if (this.layerTree.SelectedNode.Tag is GSOLayer) + { + GSOLayer layer = this.layerTree.SelectedNode.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 (this.layerTree.SelectedNode.Tag is GSOFeature) + { + GSOFeature feature = this.layerTree.SelectedNode.Tag as GSOFeature; + if (feature.Geometry != null) + { + globeControl1.Globe.FlyToPosition(feature.Geometry.GeoCenterPoint, EnumAltitudeMode.Absolute, 0, 0, 10); + } + else + { + globeControl1.Globe.FlyToFeature(feature); + } + } + } + } + + /// + /// 在三维场景移动时,隐藏气泡globeControl1 + /// + /// + /// + void globeControl1_CameraBeginMoveEvent(object sender, CameraBeginMoveEventArgs e) + { + if (featureTooltip.IsVisible()) + { + featureTooltip.HideBalloon(); + } + if (balloonEx.IsVisible()) + { + balloonEx.HideBalloon(); + } + } + + /// + /// 在三维场景移动时,隐藏气泡globeControl2 + /// + /// + /// + void globeControl2_CameraBeginMoveEvent(object sender, CameraBeginMoveEventArgs e) + { + if (featureTooltip2.IsVisible()) + { + featureTooltip2.HideBalloon(); + } + if (balloonEx2.IsVisible()) + { + balloonEx2.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(); + } + } + + #region Fan 横断面 + /// + /// 横断面分析、基线剖面分析、道路断面分析等 + /// + /// + /// + private static EnumTrackPolylineEndMode trackPolylineEndMode; + + void globeControl1_TrackPolylineEndEvent(object sender, TrackPolylineEndEventArgs e) + { + //横断面分析、道路横断面分析 + if (trackPolylineEndMode == EnumTrackPolylineEndMode.HDM_Analysis|| + trackPolylineEndMode == EnumTrackPolylineEndMode.DLDM_Analysis) + { + Dictionary hdmDic = SectionAnalysisTool.HDMAnalysis(this.globeControl1, + e.Polyline, this.m_PipelineLayerNames); + FrmHDMAnalysis3 frm = new FrmHDMAnalysis3(hdmDic, this.globeControl1, + trackPolylineEndMode); + frm.Show(this); + } + //基线剖面分析 + else if (trackPolylineEndMode == EnumTrackPolylineEndMode.JXPM_Analysis) + { + FrmBaseLineProfillAnalysis dlg = new FrmBaseLineProfillAnalysis(globeControl1.Globe, e.Polyline); + dlg.Show(this); + globeControl1.Globe.ClearLastTrackPolyline(); + } + else + { + + } + trackPolylineEndMode = EnumTrackPolylineEndMode.Default_Analysis; + } + #endregion + + private GSOFeatures PolygonIntersectAnalysis(GSOGeoPolygon3D polygon, string pipelinetype) + { + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(pipelinetype); + 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(pipelinetype, feats.Length); + return feats; + } + /// + /// 根据范围统计阀门、管线、工井等, 开挖分析, 挖方量分析 + /// + /// + /// + void globeControl1_TrackPolygonEndEvent(object sender, TrackPolygonEndEventArgs e) + { + if (globeControl1.Globe.Action == EnumAction3D.TrackPolygon && e.Polygon != null) + { + GSOGeoPolygon3D polygon = e.Polygon; + + switch (trackflag) + { + case "valvequery": + FrmValveStatistics frm = new FrmValveStatistics(globeControl1,polygon, new DataGridViewDelegate(InitDataGridViewX1)); + frm.Show(this); + globeControl1.Globe.Action = EnumAction3D.ActionNull; + break; + + case "PipelineDistanceStatistics": +<<<<<<< HEAD +======= + +>>>>>>> d2d0088a6b3c53c1a96b7f1997f4d3443c0ee8c0 + FrmAllPipelineStatis frm1 = new FrmAllPipelineStatis(globeControl1, polygon, new DataGridViewDelegate(InitDataGridViewX1), m_PipelineLayerNames); + frm1.Show(this); + globeControl1.Globe.Action = EnumAction3D.ActionNull; + + break; + case "PipelineSpatialQuery": +<<<<<<< HEAD +======= + +>>>>>>> d2d0088a6b3c53c1a96b7f1997f4d3443c0ee8c0 + FrmAllPipelineStatis.ShowForm(globeControl1,polygon,new DataGridViewDelegate(InitDataGridViewX1),m_PipelineLayerNames); + globeControl1.Globe.ClearAnalysis(); + globeControl1.Globe.Action = EnumAction3D.ActionNull; + + break; + case "workwellquery": + FrmAllWorkWellStatis frmWell = new FrmAllWorkWellStatis(globeControl1, polygon, new DataGridViewDelegate(InitDataGridViewX1)); + 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 "BSQDuoBianXiangStatis": + + //GSOFeature f2 = new GSOFeature(); + //f2.Geometry = e.Polygon; + //f2.Geometry.AltitudeMode = EnumAltitudeMode.Absolute; + //globeControl1.Globe.MemoryLayer.AddFeature(f2); + //f2.Geometry.MoveZ(3); + //workWellLen.Clear(); + //List listBSQ = new List(); + + //GSOFeatures bsqFeatures = PolygonIntersectAnalysis(e.Polygon, "标识器"); + //listBSQ.Add(bsqFeatures); + + //FrmBSQDuoBianXingStatis bsqFrm = new FrmBSQDuoBianXingStatis(workWellLen, globeControl1, listBSQ); + FrmBSQStatis bsqFrm = new FrmBSQStatis(globeControl1,e.Polygon); + bsqFrm.Show(this); + globeControl1.Globe.Action = EnumAction3D.ActionNull; + break; + + case "": + break; + default: + break; + } + } + } + + #region 验证端口 + /* + /// + /// 验证端口 + /// + /// + 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 + + /// + /// 鼠标悬浮提示 + /// + /// + /// + 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); + } + } + + /// + /// 添加管线绘制完成事件, 红线工具绘制完成 + /// + /// + /// + 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; + + + } + } + + /// + /// 获取globeControl1中鼠标按下的坐标供区别鼠标右键和滚轮按下事件 + /// + /// + /// + void globeControl1_MouseDown(object sender, MouseEventArgs e) + { + mouseDownX1 = e.X; + mouseDownY1 = e.Y; + } + /// + /// 获取globeControl2中鼠标按下的坐标供区别鼠标右键和滚轮按下事件 + /// + /// + /// + void globeControl2_MouseDown(object sender, MouseEventArgs e) + { + mouseDownX2 = e.X; + mouseDownY2 = e.Y; + } + /// + /// + /// + /// + /// + void globeControl2_MouseClick(object sender, MouseEventArgs e) + { + if (e.Button == MouseButtons.Right) + { + if (e.X == mouseDownX2 && e.Y == mouseDownY2) + { + RightScreenToolMenu.Show(globeControl2, e.X, e.Y); + } + else + { + return; + } + } + } + /// + /// + /// + /// + /// + void globeControl1_MouseClick(object sender, MouseEventArgs e) + { + if (e.Button == MouseButtons.Left) + { + if (globeControl1.Globe.Action == EnumAction3D.VisibilityAnalysis) + { + buttonItemFX5_1.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; + + bsqPT = pt; + + if (buttonItemLS5.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 (e.X == mouseDownX1 && e.Y == mouseDownY1) + { + toolRightMenu.Show(globeControl1, e.X, e.Y); + if (buttonItemLS5.Checked) + { + buttonItemLS5.Checked = false; + } + } + else + { + return; + } + } + globeControl1.Refresh(); + } + + /// + /// 判断网络图片是否存在 + /// + /// + /// + 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; + } + + /// + /// 鼠标点击, 弹出气泡功能globeControl1 + /// + /// + /// + void globeControl1_FeatureMouseClickEvent(object sender, FeatureMouseClickEventArgs e) + { + GSOFeature feature = e.Feature; + + string str1 = ""; + if (feature != null) + { + if (feature.GetFieldDefn("图片编码") != null)// + { + str1 = GetBubbleInfo(feature, globeControl1); + if (RemoteFileExists(Utility.PicRootURL + feature.GetValue("图片编码").ToString())) + { + str1 += ""; + } + else if (RemoteFileExists(Utility.PicDefaultURL)) + { + str1 += ""; + } + } + else if (isFeatureContainsBianhao(feature)) //管线模型图层 + { + str1 = GetBubbleInfo(feature, globeControl1); + } + + 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; + } + } + } + + /// + /// 鼠标点击, 弹出气泡功能globeControl2 + /// + /// + /// + void globeControl2_FeatureMouseClickEvent(object sender, FeatureMouseClickEventArgs e) + { + GSOFeature feature = e.Feature; + + string str1 = ""; + if (feature != null) + { + if (feature.GetFieldDefn("图片编码") != null) // + { + str1 = GetBubbleInfo(feature, globeControl2); + if (RemoteFileExists(Utility.PicRootURL + feature.GetValue("图片编码").ToString())) + { + str1 += ""; + } + else if (RemoteFileExists(Utility.PicDefaultURL)) + { + str1 += ""; + } + } + else if (isFeatureContainsBianhao(feature)) //管线模型图层 + { + str1 = GetBubbleInfo(feature, globeControl2); + } + + if (str1 != "") + { + + featureTooltip2.HideBalloon(); + balloonEx2.HideBalloon(); + balloonEx2.SetSize(EnumSizeIndexEx.CONTENT_CX, 480); + balloonEx2.SetSize(EnumSizeIndexEx.CONTENT_CY, 420); + balloonEx2.ShowBalloon((int)e.MousePos.X, (int)e.MousePos.Y, str1); + + return; + } + } + } + + /// + /// 拼接气泡表格字符串 + /// + /// + /// + private string GetBubbleInfo(GSOFeature feature,GSOGlobeControl globeControl) + { + if (feature == null) + { + return ""; + } + string str = ""; + str = ""; + 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 += ""; + + 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.get_Fields(layerName, globeControl); + } + if (queryFields != null) + { + string[] param = { "," }; + string[] fieldNames = queryFields.Split(param, StringSplitOptions.RemoveEmptyEntries); + for (int j = 0; j < fieldNames.Length; 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 (name1 == "模型路径") + { + continue; + } + 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 (field1.Type == EnumFieldType.Double) + { + double dl1 = feature.GetFieldAsDouble(j); + if (!name1.Contains("管径") && !name1.Contains("电压") && !name1.Contains("角度")) + { + name1 += "_米"; + } + value1 = dl1.ToString("0.00"); + } + 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 (name2 == "模型路径") + { + continue; + } + + 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 (field2.Type == EnumFieldType.Double) + { + double dl2 = feature.GetFieldAsDouble(j + 1); + if (!name2.Contains("管径") && !name2.Contains("电压") && !name2.Contains("角度")) + { + name2 += "_米"; + } + value2 = dl2.ToString("0.00"); + } + else + { + if (!feature.IsFieldValueNull(j + 1)) + { + value2 = feature.GetValue(j + 1).ToString(); + } + } + } + } + + j++; + } + str += ""; + } + } + str += "
" + title + " " + feature.GetFieldAsString(featureIDFieldName) + "
" + + name1 + + "
" + + value1 + + "
" + + name2 + + "
" + + value2 + "
"; + return str; + } + + string filename = Utility.filename; + List g1layername = new List(); + + /// + /// 获取目标图层 + /// + /// + 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; + } + /// + /// 添加图层 + /// + /// + /// + /// + 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 = 5000; + return templayer.Visible; + } + catch (Exception ex) + { + return false; + } + } + /// + /// 菜单上的 三维导航 工具按钮 + /// + /// + /// + private void buttonItem86_Click(object sender, EventArgs e) + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + } + + /// + /// 地上模式 菜单按钮 + /// + /// + /// + 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(); + + } + } + /// + /// 地下模式 菜单按钮 + /// + /// + /// + 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(); + } + } + /// + /// 行走模式 菜单按钮 + /// + /// + /// + 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; + } + } + /// + /// 地面透明度设置 菜单 + /// + /// + /// + private void sliderGroundTransSet1_ValueChanged(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.sliderGroundTransSet1.Text); + + globeControl1.Globe.GroundOpaque = 100 - sliderGroundTransSet1.Value; + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(roadLayerName);//("180fd"); + if (layer != null) + { + layer.Opaque = 100 - sliderGroundTransSet1.Value; + } + //if (buttonItemSPDB.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; + } + /// + /// 图例 菜单按钮 + /// + /// + /// + 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(); + } + /// + /// 快速定位 菜单按钮 + /// + /// + /// + private void buttonItem91_Click(object sender, EventArgs e) // + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItem91.Text); + FrmFlyToPosition fly = new FrmFlyToPosition(globeControl1); + fly.Show(this); + } + /// + /// 图层管理 菜单按钮 + /// + /// + /// + 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; + + //修改图层管理与标注管理、覆土审查、水平净距分析、垂直净距分析和碰撞分析控件之间的逻辑关系 + controlContainerItem5.Visible = false; + sideBar1.Visible = false; + sideBarPanelItem4.Visible = false; + panel3.Visible = false; + sideBar1.ExpandedPanel = sideBarPanelItem3; + buttonItemBZ11.Checked = false; + + //20160624 + /* + if (sideBarPanelItem4.Visible == true) + { + sideBar1.Visible = true; + controlContainerItem5.Visible = true; + } + else + { + sideBar1.Visible = false; + } + */ + Refresh(); + + } + } + /// + /// 全屏显示 菜单按钮 + /// + /// + /// + 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; + /// + /// 全屏显示功能实现 + /// + 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(); + } + } + + /// + /// 设置窗体宽、高 + /// + /// + /// + private void SetFullScreen(int width, int height) + { + this.Width = width; + this.Height = height; + } + + /// + /// 全屏功能的快捷键F5 + /// + /// + /// + 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); + } + } + /* + /// + /// 输出地图 + /// + /// + /// + /// + 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; + } + * */ + + private Point getUpperLeftPoint(Point p1, Point p2, out int mapWidth, out int mapHeight) // + { + Rectangle rc = new Rectangle(); + + p1 = this.globeControl1.PointToScreen(p1); + p2 = this.globeControl1.PointToScreen(p2); + + int x = Screen.PrimaryScreen.Bounds.X; + int y = Screen.PrimaryScreen.Bounds.Y; + int screenWidth = SystemInformation.WorkingArea.Width; + int screenHeight = SystemInformation.WorkingArea.Height; + + if (p1.X < x) + rc.X = x; + else + rc.X = p1.X; + + if (p1.Y < y) + rc.Y = y; + else + rc.Y = p1.Y; + + p1.X = rc.Left; + p1.Y = rc.Top; + + if (p2.X > screenWidth) + p2.X = screenWidth; + else + p2.X = p2.X; + + if (p2.Y > screenHeight) + p2.Y = screenHeight; + else + p2.Y = p2.Y; + + rc.Width = p2.X - rc.X; + rc.Height = p2.Y - rc.Y; + + mapWidth = rc.Width; + mapHeight = rc.Height; + Point pt = new Point(rc.Left, rc.Top); + return pt; + } + + Image printImage; + /// + /// 打印 菜单 + /// + /// + /// + 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))); + */ + int mapWidth = 0; + int mapHeight = 0; + Point pt = getUpperLeftPoint(pt1, pt2, out mapWidth, out mapHeight); + int rightBottomX = pt.X + mapWidth; + int rightBottomY = pt.Y + mapHeight; + Image myImg = new Bitmap(mapWidth, mapHeight); + Graphics g = Graphics.FromImage(myImg); + g.CopyFromScreen(pt, new Point(0, 0), new Size(rightBottomX, rightBottomY)); + + + 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); + } + /// + /// 输出地图 菜单 + /// + /// + /// + private void btnOutputJPG_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btnOutputJPG.Text); + + //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))); + */ + int mapWidth = 0; + int mapHeight = 0; + Point pt = getUpperLeftPoint(pt1, pt2, out mapWidth, out mapHeight); + int rightBottomX = pt.X + mapWidth; + int rightBottomY = pt.Y + mapHeight; + Image myImg = new Bitmap(mapWidth, mapHeight); + Graphics g = Graphics.FromImage(myImg); + g.CopyFromScreen(pt, new Point(0, 0), new Size(rightBottomX, rightBottomY)); + + 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; + } + } + } + + /// + /// 统计管线的里程数 + /// + /// + /// + /// + 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; + } + + /// + /// 窗体下方属性表格 右键菜单中的 “定位”菜单 + /// + /// + /// + 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); + + } + + /// + /// 表格中右键 “单个闪烁” 菜单 + /// + /// + /// + private void LightMenu_Click(object sender, EventArgs e) + { + flashflag = "single"; + timer1.Start(); + } + /// + /// 表格中右键 “全部闪烁” 菜单 + /// + /// + /// + private void AllLightMenuItem_Click(object sender, EventArgs e) + { + flashflag = "all"; + timer1.Start(); + } + + /// + /// 使用timer实现管线的闪烁效果 + /// + /// + /// + 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; + } + } + + /// + /// 绘制线 菜单 + /// + /// + /// + private void btnAddLine_Click(object sender, EventArgs e) + { + globeControl1.Globe.DestLayerFeatureAdd = globeControl1.Globe.MemoryLayer; + globeControl1.Globe.Action = EnumAction3D.DrawPolyline; + } + /// + /// 绘制面 菜单 + /// + /// + /// + private void btnAddPolygon_Click(object sender, EventArgs e) + { + globeControl1.Globe.DestLayerFeatureAdd = globeControl1.Globe.MemoryLayer; + globeControl1.Globe.Action = EnumAction3D.DrawPolygon; + } + /// + /// 图层目录树 右键菜单中的 目标图层 菜单 + /// + /// + /// + 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; + } + } + /// + /// 图层目录树 右键菜单中的 可选择 菜单 + /// + /// + /// + 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; + } + /// + /// 图层目录树 右键菜单中的 可编辑 菜单 + /// + /// + /// + 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; + } + /// + /// 图层目录树 右键菜单中的 保存 菜单 + /// + /// + /// + 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(); + } + + /// + /// 根据多边形范围统计管线的里程 + /// + /// + /// + /// 返回查询到的管线要素集合 + 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 pipeLineDis = new Dictionary(); + Dictionary workWellLen = new Dictionary(); + + + + + /// + /// 查找指定图层中在 指定范围内的feature对象集合 + /// + /// + /// + /// + 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; + } + /// + /// 清除结果 菜单 + /// + /// + /// + private void buttonItem47_Click(object sender, EventArgs e) + { + globeControl1.Globe.ClearAnalysis(); + dataGridViewX1.DataSource = null; + panelOfTable.Visible = false; + clearFeatureHighLight(); + } + /// + /// 设置菜单的选中状态 + /// + private void ActionToolMenuChecked() + { + if (globeControl1.Globe.Action != EnumAction3D.TrackPolyline) + { + buttonItemFX2_1.Checked = false; + buttonItemFX2_4.Checked = false; + buttonItemFX2_3.Checked = false; + buttonItemFX4_3.Checked = false; + } + if (globeControl1.Globe.Action != EnumAction3D.NormalHit) + { + buttonItemFX3_6.Checked = false; + // ClearConnexityAnalysis(); + + buttonItemFX3_5.Checked = false; + // ClearCloseValvesAnalysis(); + } + if (globeControl1.Globe.Action != EnumAction3D.TrackPolygon) + { + buttonItemFX4_2.Checked = false; + buttonItemFX4_1.Checked = false; + } + } + + /// + /// 主窗体关闭事件处理 + /// + /// + /// + private void MainFrm_FormClosing(object sender, FormClosingEventArgs e) + { + + if (MessageBox.Show("是否退出系统?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) + { + e.Cancel = true; + } + else { + globeControl1.Globe.MemoryLayer.SaveAs(Application.StartupPath + "/MyPlace.kml"); + } + + //saveLayerList(layerManagerNode.Nodes); + //注销id号为103的热键设定 + // UnregisterHotKey(Handle, 103); + } + + /// + /// 显示流向 功能 + /// + /// + /// + /// + 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(); + } + + FrmCloseValves frm; + + FrmBoosterValvers frmbooster = null; + + /// + /// 垂直净距分析 功能界面中的 选择图层复选框 选中状态改变事件处理 + /// + /// + /// + 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(); + } + /// + /// 水平净距分析 功能界面中的 选择图层复选框 选中状态改变事件处理 + /// + /// + /// + 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(); + } + /// + /// 垂直净距分析 功能界面中的 选择管线复选框 选中状态改变事件处理 + /// + /// + /// + private void checkBoxX1_CheckedChanged(object sender, EventArgs e) + { + clearFeatureHighLight(); + if (checkBoxX1.Checked) + { + comboBoxEx1.SelectedItem = null; + 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; + } + } + /// + /// 水平净距分析 功能界面中的 选择管线复选框 选中状态改变事件处理 + /// + /// + /// + private void checkBoxX1_CheckedChanged_shuiping(object sender, EventArgs e) + { + clearFeatureHighLight();//清除高亮 + if (checkBoxX7.Checked) + { + comboBoxEx4.SelectedItem = null; + 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(); + /// + /// 垂直净距分析 功能界面中的 选择图层下拉框 选中项改变 事件处理 + /// + /// + /// + 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; + } + } + } + /// + /// 水平净距分析 功能界面中的 选择图层下拉框 选中项改变 事件处理 + /// + /// + /// + 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 featCount = new Dictionary(); + Dictionary featLenth = new Dictionary(); + Dictionary m_FeaturesWithBianhao = new Dictionary();//记录编号和对应的标注点的位置 + GSOFeatures polygonJingJuAnalysises = new GSOFeatures(); + + /// + /// 垂直净距分析 功能界面中的 开始分析按钮 事件处理 + /// + /// + /// + 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; + } + + /// + /// 在指定的两点组成的线的中间添加一个marker对象,并将marker对象添加到指定的图层中 + /// + /// + /// + /// + /// + /// + 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; + } + + /// + /// 计算指定feature对象与除了该feature所在图层之外的 所有管线图层中的所有feature对象 的垂直距离 并在表格中记录符合要求的管线 + /// + /// + /// + /// + /// + private void VerticalDistanceAnalysis(string type, GSOFeature selectedFeature, List _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(); + } + /// + /// 垂直净距分析中 表格行的 双击定位 功能。 与覆土分析的实现方法不同,主要原因是需要标注垂距 + /// + /// + /// + 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); + } + } + } + } + + /// + /// 水平净距分析 功能界面中 开始分析按钮 的事件处理 + /// + /// + /// + 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; + } + + + /// + /// 计算指定feature对象与除了该feature所在图层之外的 所有管线图层中的所有feature对象 的水平距离 并记录符合要求的管线 功能 + /// + /// + /// + /// + /// + private void HorizontalDistanceAnalysis(GSOFeature selectedFeature, List _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)); + } + } + } + } + } + /// + /// 水平净距分析 功能界面中 表格的 双击定位 功能 + /// + /// + /// + 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); + } + } + } + } + } + /// + /// 碰撞分析 功能界面中 开始分析按钮 事件处理 + /// + /// + /// + 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; + } + /// + /// 碰撞分析功能界面中 表格的 双击定位 功能 + /// + /// + /// + 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); + } + } + } + } + + + + /// + /// 覆土分析功能操作界面中的 选择管线 复选框选中状态改变事件处理 + /// + /// + /// + private void checkBoxX5_CheckedChanged(object sender, EventArgs e) + { + clearFeatureHighLight(); + if (checkBoxX5.Checked) + { + comboBoxEx3.SelectedItem = null; + 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; + } + } + /// + /// 覆土分析功能操作界面中的 选择图层 复选框选中状态改变事件处理 + /// + /// + /// + 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(); + } + /// + /// 覆土分析功能操作界面中的 图层下拉框选中项改变事件处理 + /// + /// + /// + 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; + } + } + } + /// + /// 覆土分析功能操作界面中的 开始分析 按钮事件处理 + /// + /// + /// + 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; + + + GSOPoint3d markerPosition = new GSOPoint3d(); + 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]; + GSOPoint3d pt = new GSOPoint3d(); + + 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"); + + pt.X = pts[m].X; + pt.Y = pts[m].Y; + pt.Z = 0; + markerPosition = LabelVerticalDistance(layerTemp, pts[m], pt, Convert.ToDouble(dataGridViewX7.Rows[idx].Cells[2].Value), true); + 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]; + GSOPoint3d pt = new GSOPoint3d(); + 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"); + + pt.X = pts[m].X; + pt.Y = pts[m].Y; + pt.Z = 0; + markerPosition = LabelVerticalDistance(layerTemp, pts[m], pt, Convert.ToDouble(dataGridViewX7.Rows[idx].Cells[2].Value), true); + + 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; + } + + /// + /// 覆土分析中 表格的 双击定位 功能 + /// + /// + /// + 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); + } + } + } + } + } + /// + /// 覆土分析功能操作界面中的 导出Excel按钮 事件处理 + /// + /// + /// + private void buttonX10_Click(object sender, EventArgs e) + { + if (dataGridViewX7.Rows.Count > 0) + { + ExportExcel("覆土分析", dataGridViewX7, null); + } + else + { + MessageBox.Show("表格内容为空!", "提示"); + } + } + /// + /// 覆土分析功能操作界面底部的 关闭 按钮事件处理 + /// + /// + /// + 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(); + layerTemp.RemoveAllFeature(); + + if (buttonItem1.Checked) + { + sideBar1.ExpandedPanel = sideBarPanelItem3; + } + else + { + sideBar1.Visible = false; + } + globeControl1.Refresh(); + + //Refresh(); + } + + + /// + /// 垂直净距分析 功能界面中 清除分析结果按钮 事件处理 + /// + /// + /// + 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(); + } + /// + /// 水平净距分析 功能界面中 清除分析结果按钮 事件处理 + /// + /// + /// + 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(); + } + + /// + /// 垂直净距分析功能界面中 关闭按钮 事件处理 + /// + /// + /// + 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(); + } + /// + /// 水平净距分析功能界面中 删除缓冲区按钮 事件处理 + /// + /// + /// + private void buttonX14_Click(object sender, EventArgs e) + { + 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(); + } + + /// + /// 导出指定DataGridView控件中的内容 + /// + /// + /// + 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(); + } + } + } + } + + /// + /// 垂直净距分析功能界面中 导出Excel按钮 事件处理 + /// + /// + /// + private void buttonX4_Click(object sender, EventArgs e) + { + if (dataGridViewX3.Rows.Count > 0) + { + ExportExcel("垂直净距分析", dataGridViewX3, listBox1); + } + else + { + MessageBox.Show("表格内容为空!", "提示"); + } + } + /// + /// 水平净距分析功能界面中 导出Excel按钮 事件处理 + /// + /// + /// + private void buttonX4_Click_shuiping(object sender, EventArgs e) + { + if (dataGridViewX9.Rows.Count > 0) + { + ExportExcel("水平净距分析", dataGridViewX9, listBox3); + } + else + { + MessageBox.Show("表格内容为空!", "提示"); + } + } + + + /// + /// 清除所有坑 菜单 + /// + /// + /// + private void buttonItem3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItem3.Text); + + globeControl1.Globe.RemoveAllPits(); + } + + //} + /// + /// 大气层 菜单 + /// + /// + /// + private void buttonItem17_Click_1(object sender, EventArgs e) + { + globeControl1.Globe.Atmosphere.Visible = !globeControl1.Globe.Atmosphere.Visible; + buttonItemSH1.Checked = globeControl1.Globe.Atmosphere.Visible; + globeControl1.Refresh(); + } + /// + /// 经纬网 菜单 + /// + /// + /// + private void buttonItem20_Click(object sender, EventArgs e) + { + globeControl1.Globe.LatLonGrid.Visible = !globeControl1.Globe.LatLonGrid.Visible; + buttonItemSH3.Checked = globeControl1.Globe.LatLonGrid.Visible; + globeControl1.Globe.Refresh(); + } + /// + /// 状态条 菜单 + /// + /// + /// + private void buttonItem21_Click_1(object sender, EventArgs e) + { + globeControl1.Globe.StatusBar.Visible = !globeControl1.Globe.StatusBar.Visible; + buttonItemSH4.Checked = globeControl1.Globe.StatusBar.Visible; + globeControl1.Globe.Refresh(); + } + + + + /// + /// 添加指定路径下的数据 功能 + /// + /// + /// + 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); + //CheckDatasetGeoReference(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; + } + return objRes; + } + /// + /// 刷新目录树 功能 + /// + 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); + } + } + /// + /// 判断图层是否包含字段列表 + /// + /// + /// + 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; + } + + /// + /// 统计指定图层在指定范围内的所有feature对象 + /// + /// + /// + /// + 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; + } + /// + /// 碰撞分析功能界面中 选择管线复选框 选中状态改变事件处理 + /// + /// + /// + private void checkBoxX3_CheckedChanged(object sender, EventArgs e) + { + clearFeatureHighLight(); + if (checkBoxX3.Checked) + { + comboBoxEx2.SelectedItem = null; + 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; + } + } + /// + /// 碰撞分析功能界面中 选择图层复选框 选中状态改变事件处理 + /// + /// + /// + 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(); + } + /// + /// 碰撞分析功能界面中 选择图层下拉框 选中项改变事件处理 + /// + /// + /// + 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; + } + } + } + /// + /// 清除所有图层中的所有feature对象的高亮状态 功能 + /// + 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); + } + } + } + } + for (int i = 0; i < globeControl2.Globe.Layers.Count; i++) + { + GSOLayer layer = globeControl2.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; + } + } + } + + if (globeControl1.Globe.Action == EnumAction3D.SelectObject) + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + //globeControl1.Globe.Action = EnumAction3D.SelectObject; + } + } + + /// + /// 碰撞分析功能界面中 清除分析结果按钮 事件处理 + /// + /// + /// + 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(); + } + /// + /// 碰撞分析功能界面中 导出Excel按钮 事件处理 + /// + /// + /// + private void buttonX6_Click(object sender, EventArgs e) + { + if (dataGridViewX5.Rows.Count > 0) + { + ExportExcel("碰撞分析", dataGridViewX5, listBox2); + } + else + { + MessageBox.Show("表格内容为空!", "提示"); + } + } + /// + /// 导出CAD 菜单 + /// + /// + /// + private void btnExportCAD_Click(object sender, EventArgs e) + { + FrmExportCADS frm = new FrmExportCADS(globeControl1, m_PipelineLayerNames); + frm.ShowDialog(); + } + + ///// + ///// 区域分析 菜单 + ///// + ///// + ///// + //private void buttonItem50_Click(object sender, EventArgs e) + //{ + // buttonItem50.Checked = !buttonItem50.Checked; + // ribbonBarQY.Visible = buttonItem50.Checked; + // ribbonBarQY.Location = new Point(0, 0); + //} + + + /// + /// 连接数据库 菜单事件处理 + /// + /// + /// + 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; + } + } + } + /// + /// 数据验证 菜单 + /// + /// + /// + private void buttonItem80_Click(object sender, EventArgs e) + { + FrmValiData frm = new FrmValiData(globeControl1); + frm.ShowDialog(); + } + /// + /// 根据指定图层创建图层节点并将节点添加到图层管理节点的子节点集合中 + /// + /// + 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; + + if (!layerManagerNode.Nodes.Contains(node)) + { + layerManagerNode.Nodes.Insert(0, node); + layerManagerNode.Expand(); + } + } + } + /// + /// 数据库备份 菜单 + /// + /// + /// + 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(); + } + } + } + + + + #region Fan 去掉 + //GSOFeature emitterFeature; // 粒子要素 + /// + /// 添加火苗 功能 + /// + /// + /// + /// + 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); + + } + /// + /// 添加喷泉 功能 + /// + /// + /// + /// + 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); + } + #endregion + + /// + /// 获取指定图层中最后一个feature对象的名称对应的整数 + /// + /// + /// + 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; + } + /// + /// 设置除指定标注图层之外的所有标注图层不可见 + /// + /// + 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; + } + } + } + } + } + + /// + /// 判断选中的对象是否为管线 + /// + /// 被选中管线 + /// 返回一根线 + 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; + } + + /// + /// 获取指定两点组成的线的长度 功能 + /// + /// + /// + /// + 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; + } + + /// + /// 图层节点树中 节点 右键单击事件处理 + /// + /// + /// + 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; + } + } + } + } + } + + /// + /// 标注管理、传感器管理 图层目录树的右键菜单中的 刷新列表 菜单 + /// + /// + /// + 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); + } + } + /// + /// 给指定的图层节点添加代表feature对象的子节点 + /// + /// + private void RefreshTreeNodeLayerFeatureList(TreeNode layerTreeNode) + { + layerTreeNode.Nodes.Clear(); + GSOLayer layer = (GSOLayer)layerTreeNode.Tag; + // 只将类型为内存数据集的图层列出,如果是其它类型的数据集可能数据量太大,没发显示在树控件中 + if (layer.Dataset is GSOFeatureDataset) + { + VisitFeature3Ds(layer.GetAllFeatures(), layerTreeNode); + } + } + + /// + /// 标注管理、传感器管理 图层目录树的右键菜单中的 移除所有 菜单 + /// + /// + /// + 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(); + } + } + + /// + /// 图层目录树的 节点对应的复选框选中状态改变事件处理 + /// + /// + /// + private void layerMarkerTree_AfterCheck(object sender, TreeViewEventArgs e) + { + if (e.Action != TreeViewAction.Unknown) + { + CheckTreeNode(e.Node, e.Node.Checked); + } + } + /// + /// 改变指定节点对应的复选框的选中状态 + /// + /// + /// + private void CheckTreeNode(TreeNode node, Boolean bChecked) + { + CheckChildTreeNode(node, bChecked); + globeControl1.Globe.Refresh(); + } + /// + /// 改变指定节点的子节点对应的复选框的选中状态 + /// + /// + /// + 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); + } + } + /// + /// 标注管理、传感器管理 目录树中的feature节点的右键菜单中的 删除 菜单 + /// + /// + /// + 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(); + } + } + + /// + /// 双屏对比 菜单 + /// + /// + /// + //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(); + // } + //} + /// + /// 模拟分析 菜单 + /// + /// + /// + //private void buttonItem51_Click(object sender, EventArgs e) + //{ + // buttonItem51.Checked = !buttonItem51.Checked; + // ribbonBarMN.Visible = buttonItem51.Checked; + // ribbonBarMN.Location = new Point(0, 0); + //} + + /// + /// 双屏设置 菜单 + /// + /// + /// + //private void buttonItem96_Click(object sender, EventArgs e) + //{ + // FrmLayerControl frm = new FrmLayerControl(layerTree,globeControl1,globeControl2); + // frm.Show(this); + //} + /// + /// 双屏联动 菜单 + /// + /// + /// + //private void buttonItem95_Click(object sender, EventArgs e) + //{ + // buttonItem95.Checked = !buttonItem95.Checked; + //} + ///// + /// 添加用户仓库 菜单 + /// + /// + /// + private void buttonItem108_Click(object sender, EventArgs e) + { + FrmUserRepo frm = new FrmUserRepo(-1); + frm.ShowDialog(); + } + /// + /// 用户仓库管理 菜单 + /// + /// + /// + private void buttonItem111_Click(object sender, EventArgs e) + { + FrmUserRepoMgr frm = new FrmUserRepoMgr(); + frm.ShowDialog(); + } + /// + /// 添加分系统 菜单 + /// + /// + /// + private void buttonItem112_Click(object sender, EventArgs e) + { + //FrmAPP frm = new FrmAPP(-1); + //frm.ShowDialog(); + } + /// + /// 分系统管理 菜单 + /// + /// + /// + private void buttonItem113_Click(object sender, EventArgs e) + { + //FrmAPPMgr frm = new FrmAPPMgr(); + //frm.ShowDialog(); + } + /// + /// 添加操作 菜单 + /// + /// + /// + private void buttonItem114_Click(object sender, EventArgs e) + { + FrmOper frm = new FrmOper(-1); + frm.ShowDialog(); + } + /// + /// 操作管理 菜单 + /// + /// + /// + private void buttonItem115_Click(object sender, EventArgs e) + { + FrmOperMgr frm = new FrmOperMgr(); + frm.ShowDialog(); + } + /// + /// 添加资源 菜单 + /// + /// + /// + private void buttonItem116_Click(object sender, EventArgs e) + { + FrmRESC frm = new FrmRESC(-1); + frm.ShowDialog(); + } + /// + /// 资源管理 菜单 + /// + /// + /// + private void buttonItem117_Click(object sender, EventArgs e) + { + FrmRESCMgr frm = new FrmRESCMgr(); + frm.ShowDialog(); + } + /// + /// 添加权限 菜单 + /// + /// + /// + private void buttonItem118_Click(object sender, EventArgs e) + { + FrmPerm frm = new FrmPerm(-1); + frm.ShowDialog(); + } + /// + /// 权限管理 菜单 + /// + /// + /// + private void buttonItem119_Click(object sender, EventArgs e) + { + FrmPermMgr frm = new FrmPermMgr(); + frm.ShowDialog(); + } + /// + /// 添加访问控制 菜单 + /// + /// + /// + private void buttonItem120_Click(object sender, EventArgs e) + { + FrmAccess frm = new FrmAccess(-1); + frm.ShowDialog(); + } + /// + /// 访问控制管理 菜单 + /// + /// + /// + private void buttonItem121_Click(object sender, EventArgs e) + { + FrmAccessMgr frm = new FrmAccessMgr(); + frm.ShowDialog(); + } + /// + /// 部门类型管理 菜单 + /// + /// + /// + private void buttonItem122_Click(object sender, EventArgs e) + { + FrmRegionTypeMgr frm = new FrmRegionTypeMgr(); + frm.ShowDialog(); + } + /// + /// 添加用户 菜单 + /// + /// + /// + private void buttonItem127_Click(object sender, EventArgs e) + { + FrmUserAdd frm = new FrmUserAdd(-1); + frm.ShowDialog(); + } + /// + /// 用户信息管理 菜单 + /// + /// + /// + private void buttonItem128_Click_1(object sender, EventArgs e) + { + FrmUserManager frm = new FrmUserManager(); + frm.ShowDialog(); + } + /// + /// 添加角色 菜单 + /// + /// + /// + private void 添加角色_Click(object sender, EventArgs e) + { + FrmRole frm = new FrmRole(-1); + frm.ShowDialog(); + } + /// + /// 所有角色管理 菜单 + /// + /// + /// + private void 角色管理_Click(object sender, EventArgs e) + { + FrmRoleMgr frm = new FrmRoleMgr(); + frm.ShowDialog(); + } + + /// + /// 部门角色管理 菜单 + /// + /// + /// + private void buttonItem133_Click(object sender, EventArgs e) + { + FrmRegionRoleMgr frm = new FrmRegionRoleMgr(); + frm.ShowDialog(); + } + /// + /// 部门管理 菜单 + /// + /// + /// + private void buttonItem130_Click(object sender, EventArgs e) + { + FrmRegionMgr frm = new FrmRegionMgr(); + frm.ShowDialog(); + } + + /// + /// 日志管理 菜单 + /// + /// + /// + private void buttonItem135_Click(object sender, EventArgs e) + { + FrmLogManager frm = new FrmLogManager(); + frm.ShowDialog(); + } + /// + /// 传感器信息查询 菜单 + /// + /// + /// + 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); + } + } + } + /// + /// 根据指定的图层的caption属性的值在配置文件中查找对应的数据库中的表的名称 + /// + /// 图层的caption属性的值 + /// 对应的数据库中的表的名称 + 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; + } + /// + /// 根据数据库中的表的名称 查找对应的表中的字段名称的集合 + /// + /// 数据库中的表的名称 + /// 对应的表中的字段名称的集合 + 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; + } + + /// + /// 历史曲线查询 菜单 + /// + /// + /// + 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; + /// + /// 传感器在线报警 菜单 + /// + /// + /// + 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); + } + /// + /// 传感器报警 功能中的 定时器 的触发事件处理 + /// + /// + /// + 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; + } + } + } + } + } + } + } + + + /// + /// 沿线运动 菜单 + /// + /// + /// + private void buttonItem138_Click(object sender, EventArgs e) + { + if (globeControl1.Globe.SelectedObject == null) + { + MessageBox.Show("请先选择一条线!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + return; + } + + GSOFeature lineFeature = globeControl1.Globe.SelectedObject; + if (lineFeature.Geometry == null || lineFeature.Geometry.Type != EnumGeometryType.GeoPolyline3D) + { + MessageBox.Show("请先选择一条线!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + return; + } + + OpenFileDialog dlg = new OpenFileDialog(); + dlg.Filter = "*.gcm;*.3ds|*.gcm;*.3ds|*.3ds|*.3ds|*.gcm|*.gcm"; + if (dlg.ShowDialog() == DialogResult.OK) + { + GSOGeoModel model = new GSOGeoModel(); + model.FilePath = dlg.FileName; + + GSOGeoDynamicRoute dynamicRoute = new GSOGeoDynamicRoute(); + dynamicRoute.ActorGeometry = model; + + GSORoute route = new GSORoute(); + GSOGeoPolyline3D geoline = (GSOGeoPolyline3D)lineFeature.Geometry; + for (int i = 0; i < geoline[0].Count; i++) + { + route.Add(geoline[0][i]); + } + route.CircleRoute = false; + route.Speed = 30; + route.RotateSpeed = 50; + route.AltitudeMode = geoline.AltitudeMode; + dynamicRoute.Route = route; + + GSOFeature feature = new GSOFeature(); + + dynamicRoute.Play(); + feature.Geometry = dynamicRoute; + + //GSOLabel gsoLabel = new GSOLabel(); + //gsoLabel.Text = "模型测试"; + //feature.Label = gsoLabel; + globeControl1.Globe.MinModelVisibleSize = 0; + + globeControl1.Globe.MemoryLayer.AddFeature(feature); + globeControl1.Globe.Refresh(); + } + } + /// + /// 回退 菜单 + /// + /// + /// + private void buttonItem99_Click(object sender, EventArgs e) + { + globeControl1.Globe.UnDoEdit(); + } + /// + /// 前进 菜单 + /// + /// + /// + private void buttonItem100_Click(object sender, EventArgs e) + { + globeControl1.Globe.ReDoEdit(); + } + /// + /// 水平净距 功能界面中的 标签内容改变事件处理 + /// + /// + /// + 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() + "米的管线有:"; + } + } + } + /// + /// 垂直净距 功能界面中的 标签内容改变事件处理 + /// + /// + /// + 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() + "米的管线有:"; + } + } + } + /// + /// 覆土分析 功能界面中的 标签内容改变事件处理 + /// + /// + /// + 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() + "米的管线有:"; + } + } + } + + /// + /// 传感器分类查询 全区域 菜单 + /// + /// + /// + private void buttonItemSensor全区域查询_Click(object sender, EventArgs e) + { + FrmAccessoriesSensor.ShowForm(globeControl1, instrumenLayerNames, 0); + } + /// + /// 传感器分类查询 绘制区域 菜单 + /// + /// + /// + private void buttonItemSensor绘制区域查询_Click(object sender, EventArgs e) + { + FrmAccessoriesSensor.ShowForm(globeControl1, instrumenLayerNames, 1); + } + + + /// + /// 碰撞分析 功能界面中 关闭按钮 事件处理 + /// + /// + /// + 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(); + } + /// + /// 覆土分析 功能界面中的 清除分析结果 按钮事件处理 + /// + /// + /// + 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(); + } + /// + /// 数字预处理 功能 + /// + /// + /// + private void 数字预处理buttonItem140_Click(object sender, EventArgs e) + { + FrmEditShapeFile frm = new FrmEditShapeFile(globeControl1); + frm.ShowDialog(this); + } + + + /// + /// 导出矢量 功能 将图层导出为kml和shp格式数据 + /// + /// + /// + private void 导出矢量buttonItem140_Click(object sender, EventArgs e) + { + List listVectorNames = new List(); + for (int i = 0; i < m_PipelineLayerNames.Count; i++) + { + 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 = ""; + /// + /// 绘制城市七线 功能按钮 + /// + /// + /// + 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; + } + } + } + /// + /// 七线审核 功能按钮 + /// + /// + /// + private void 七线审核buttonItem141_Click(object sender, EventArgs e) + { + FrmCityServerLineAnalysis frm = new FrmCityServerLineAnalysis(globeControl1, m_PipelineLayerNames); + frm.ShowDialog(this); + } + + /// + /// 间距分析 开始分析按钮 分析绘制的七线和管线的距离是否符合标准 + /// + /// + /// + 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; + } + /// + /// 间距分析 清除分析结果 + /// + /// + /// + 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(); + } + /// + /// 间距分析 导出Excel按钮 将间距分析的结果以Excel表格的形式导出 + /// + /// + /// + private void buttonExportExcel_Click(object sender, EventArgs e) + { + if (dataGridViewAnalysisResult.Rows.Count > 0) + { + ExportExcel("间距分析", dataGridViewAnalysisResult, listBoxStasticsResult); + } + else + { + MessageBox.Show("表格内容为空!", "提示"); + } + } + /// + /// 间距分析 关闭按钮 + /// + /// + /// + 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(); + } + /// + /// 间距分析 分析结果表格双击定位 + /// + /// + /// + 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); + } + } + } + } + /// + /// 间距分析 选择管线复选框 + /// + /// + /// + private void checkBoxSelectPipeline_CheckedChanged(object sender, EventArgs e) + { + clearFeatureHighLight();//清除高亮 + if (checkBoxSelectPipeline.Checked) + { + comboBoxLayer.SelectedItem = null; + 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; + } + } + /// + /// 间距分析 选择图层复选框 + /// + /// + /// + 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(); + } + /// + /// 间距分析 选择图层下拉框 + /// + /// + /// + 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; + } + } + } + + + + /// + /// 管线自动缩进 菜单 + /// + /// + /// + private void 管线自动缩进buttonItem140_Click(object sender, EventArgs e) + { + FrmPipelineIndented frm = new FrmPipelineIndented(globeControl1, m_PipelineLayerNames, workwellLayerNames); + 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 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); + // } + //} + + /// + /// 统计指定图层在指定范围内的所有feature对象 + /// + /// + /// + /// + 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) + { + 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 setLayerVisible(string layerName) + { + GSOLayer templayer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + if (templayer != null) + { + templayer.Visible = false; + } + globeControl1.Globe.Refresh(); + } + + /// + /// 连接数据库 + /// + /// + /// + private void buttonItem129_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL4_1.Text); + + FrmDatabaseParaSetting2 frm = new FrmDatabaseParaSetting2(globeControl1); + if (frm.ShowDialog() == DialogResult.OK) + { + ds = FrmDatabaseParaSetting2.ds; + if (ds != null) + { + ds.IsCloseSaved = false; + } + } + } + + /// + /// 一键审核---导入数据 + /// + /// + /// + private void buttonItem127_Click_2(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, "打开数据"); + + try + { + //if (shds == null) + //{ + //没连的话,直接连接审核库; //审核库配置读配置文件 + string dbIp = Utility.sgdbip; + string database = Utility.sgdbname; + string user = Utility.sgdbuser; + string pass = Utility.sgdbpwd; + /* + 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; + //} + } + catch (Exception ex) + { + LogError.PublishError(ex); + MessageBox.Show("内存过载请清理内存,并重新启动规划分析!", "提示"); + return; + } + + } + + /// + ///自动导出图片 + /// + /// + /// + private void buttonItem130_Click_1(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, "导出审核图"); + + 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))); + */ + + int mapWidth = 0; + int mapHeight = 0; + Point pt = getUpperLeftPoint(pt1, pt2, out mapWidth, out mapHeight); + int rightBottomX = pt.X + mapWidth; + int rightBottomY = pt.Y + mapHeight; + Image myImg = new Bitmap(mapWidth, mapHeight); + Graphics g = Graphics.FromImage(myImg); + g.CopyFromScreen(pt, new Point(0, 0), new Size(rightBottomX, rightBottomY)); + + 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; + } + } + } + /// + /// 一键审核功能 + ///
+ /// + /// + private void buttonItem128_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItem128.Text); + //垂直净距标准 + + frmSh = new FrmYJSHTC(globeControl1, globeControl2,layerTree); + + if (frmSh.ShowDialog() == DialogResult.OK) + { + frmWait = new FrmWait("一键审核……"); + frmWait.Location = new Point(this.Width - frmWait.Width - 10, this.Height - frmWait.Height - 50); + frmWait.Owner = this; + frmWait.Show(); + Thread thread = new Thread(new ThreadStart(doWork)); + thread.IsBackground = true; + thread.Start(); + } + } + + void doWork() + { + FrmShResult frmShResult = null; + + double dVerticalJingJuBiaoZhun = 1, dHorizontalJingJuBiaoZhun = 1; + if (frmSh.rukuLayer != null) + { + #region + this.Invoke((EventHandler)delegate + { + try + { + List managerLayerList = new List(); + for (int i = 0; i < layerManagerNode.Nodes.Count; i++) + { + managerLayerList.Add(layerManagerNode.Nodes[i].Text); + } + if (!managerLayerList.Contains(frmSh.rukuLayer.Caption)) + { + TreeNode node = new TreeNode(); + node.Tag = frmSh.rukuLayer; + node.Text = frmSh.rukuLayer.Dataset.Caption; + node.ImageIndex = 0; + node.SelectedImageIndex = 0; + node.Checked = frmSh.rukuLayer.Visible; + layerManagerNode.Nodes.Insert(0, node); + layerManagerNode.Expand(); + } + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "提示"); + } + }); + #endregion + + shlayername = frmSh.rukuLayer.Name; + globeControl1.Refresh(); + } + + if (frmShResult != null && !frmShResult.IsDisposed) + { + try + { + clearFeatureHighLight(); + ClearRedlineAnalyseResult(); + frmShResult.Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message); + } + } + + 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.analysis(); + + //MainFrm窗体显示控制,回到一键审核Tab + this.Invoke((EventHandler)delegate + { + frmShResult.Show(); + frmWait.Close(); + //将tab页恢复到一键审核 + ribbonTabItem11.Checked = true; + try + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + //zhanshi = false; + splitContainer1.Panel2Collapsed = true; + + panelOfTable.Visible = false; + legendSC.Visible = false; + legendSG.Visible = false; + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + } + catch (Exception ex) + { + MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + + }); + + boolfrmShResult = true; + } + else + { + + } + } + + + /// + /// 清除渲染结果 + /// + 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(); + } + /// + /// 已审核的图层 + /// + /// + /// + private void buttonItem132_Click_1(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItem132.Text); + + if (shds == null) + { + //没连的话,直接连接审核库; //审核库配置读配置文件 + string dbIp = Utility.sgdbip; + string database = Utility.sgdbname; + string user = Utility.sgdbuser; + string pass = Utility.sgdbpwd; + + /* + 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; + //} + + } + /// + /// 审核入库 + /// + /// + /// + private void buttonItem133_Click_1(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, "审核入库"); + FrmShRK frmShrk = new FrmShRK(globeControl1); + frmShrk.Show(); + } + /// + /// 模拟设计修改 + /// + /// + /// + private void buttonItem134_Click_1(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, "模拟设计修改"); + + 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 + { + + } + + } + + + /// + /// 绘制垂线 + /// + /// + /// + 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); + } + /// + /// 比较两个点是否是同一个点 + /// + /// + /// + /// + 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; + } + /// + /// 获得点到线的垂线距离及垂点 + /// + /// + /// + /// + /// + 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); + 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]; + } + /// + /// 获得斜率 + /// + /// + /// + /// + /// + /// + /// + 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); + } + } + /// + /// 根据默认投影参数,经纬度转xyz + /// + /// + /// + /// + 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; + } + /// + /// 根据投影参数,经纬度转xyz + /// + /// + /// + /// + /// + 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; + } + /// + /// 根据默认投影参数,xyz转经纬度 + /// + /// + /// + /// + 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; + } + /// + /// 根据投影参数,Xyz转经纬度 + /// + /// + /// + /// + /// + 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; + } + /// + /// 获得inpolygon的管线长度 + /// + /// + 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; + } + + + /// + /// 一键审核中调节透明度 + /// + /// + /// + private void sliderItem1_ValueChanged(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.sliderItem1.Text); + + globeControl1.Globe.GroundOpaque = 100 - sliderItem1.Value; + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(roadLayerName);//("180fd"); + if (layer != null) + { + layer.Opaque = 100 - sliderItem1.Value; + } + + optiValue = sliderItem1.Value; + } + /// + /// 红线审核中的透明度分析 + /// + /// + /// + private void sliderItem3_ValueChanged(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.sliderItem3.Text); + + globeControl1.Globe.GroundOpaque = 100 - sliderItem3.Value; + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(roadLayerName);//("180fd"); + if (layer != null) + { + layer.Opaque = 100 - sliderItem3.Value; + } + optiValue = sliderItem3.Value; + } + + #region yanxiaowei + //初始化DataGridViewX1控件 + public delegate void DataGridViewDelegate(DataTable dt, string strLable, string strLayer, bool initDataGrid); + /// + /// 代理函数,操作DatgridViewX1 + /// + /// + /// + public void InitDataGridViewX1(DataTable dt, string strLable, string strLayer, bool initDataGrid) + { + if (initDataGrid == true) + { + dataGridViewX1.DataSource = dt; + panelOfTable.Visible = true; + toolStripNumbers.Text = strLable; + dataGridViewX1.Tag = strLayer; + } + else + { + dataGridViewX1.DataSource = null; + dataGridViewX1.Refresh(); + panelOfTable.Visible = false; + toolStripNumbers.Text = ""; + dataGridViewX1.Tag = ""; + globeControl1.Globe.MemoryLayer.RemoveAllFeature();//清除双击产生的标注 + } + } + FrmAnalysisGuiHuaResult from; + /// + /// 主窗体下方属性表格 双击定位 功能 + /// + /// + /// + private void dataGridViewX1_MouseDoubleClick(object sender, MouseEventArgs e) + { + if (redSH == false) + { + 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 if (dataGridViewX1.Columns.Contains("标识器编号")) + { + featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["标识器编号"].Value.ToString(); + } + featureName = featureName.Trim(); + + GSOLayer layer = null; + layer = globeControl1.Globe.Layers.GetLayerByCaption(dataGridViewX1.Tag.ToString()); + + if (layer == null) return; + + GSOFeatures features = layer.GetFeatureByName(featureName, false); + if (features.Length == 0) return; + GSOFeature rowFeature = features[0]; + + ClassSearchAnalysis.AddMakerToLineFeature(globeControl1, rowFeature); + + } + } + } + else + { + if (e.Button == MouseButtons.Left) + { + if (from != null && !from.IsDisposed) + { + try + { + from.Close(); + } + catch (Exception ex) + { + LogError.PublishError(ex); + } + } + try + { + DataGridView.HitTestInfo hittestinfo = dataGridViewX1.HitTest(e.X, e.Y); + if (hittestinfo.RowIndex >= 0) + { + string layer = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["管线类型"].Value.ToString(); + string hxName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["红线编号"].Value.ToString(); + FrmAnalysisGuiHuaResult frm = new FrmAnalysisGuiHuaResult(globeControl1, lineStruct, featsList, + panelOfTable, dataGridViewX1, layer, hxName); + frm.Location = new Point(this.Width - frm.Width - 10, this.Height - frm.Height - 20); + frm.Show(this); + + from = frm; + } + } + catch (Exception ex) + { + LogError.PublishError(ex); + } + } + } + } + + /// + /// 空间查询 + /// + /// + /// + private void buttonItemSearch1_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemSearch1.Text); + + trackflag = "PipelineSpatialQuery"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; + + } + /// + /// 关键字查询 + /// + /// + /// + private void buttonItemSearch9_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch9.Text); + + FrmKeywordQuery.ShowForm(globeControl1, m_PipelineLayerNames, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 编号查询 + /// + /// + /// + private void buttonItemSearch2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch2.Text); + + FrmCodingQuery.ShowForm(globeControl1, m_PipelineLayerNames, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 坐标查询 + /// + /// + /// + private void buttonItemSearch3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch3.Text); + + FrmSetLatLonPos.ShowForm(globeControl1); + } + /// + /// 附属物查询 + /// + /// + /// + private void buttonItemSearch10_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch10.Text); + + FrmFittingQuery.ShowForm(globeControl1, instrumenLayerNames, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 管径查询 + /// + /// + /// + private void buttonItemSearch4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch4.Text); + + FrmDiameterQuery.ShowForm(globeControl1, m_PipelineLayerNames, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 材质查询 + /// + /// + /// + private void buttonItemSearch5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch5.Text); + + FrmMaterialSel.ShowForm(globeControl1, m_PipelineLayerNames, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 基本查询 + /// + /// + /// + private void buttonItemSearch6_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch6.Text); + + FrmBasicQuery.ShowForm(globeControl1, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 复合查询 + /// + /// + /// + private void buttonItemSearch7_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch7.Text); + + FrmQuerySQL.ShowForm(globeControl1, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 关联查询 + /// + /// + /// + private void buttonItemSearch8_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch8.Text); + + if (globeControl1.Globe.SelObjectCount != 1) + { + MessageBox.Show("请选中一个对象!", "提示"); + return; + } + + 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 || (feature.Geometry.Type == EnumGeometryType.GeoPolygon3D + || feature.Geometry.Type == EnumGeometryType.GeoWater)) + return; + else + { + ClassSearchAnalysis.ResultRelationAnalysis(globeControl1, feature, valueLayerNames, workwellLayerNames, + instrumenLayerNames, pipefittingLayerNames, m_PipelineLayerNames, valueAllowance); + } + } + } + #endregion + /// + /// 清除分析 + /// + /// + /// + private void buttonItemClear_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemClear.Text); + + globeControl1.Globe.ClearMeasure(); + layerTemp.RemoveAllFeature(); + layerTemp2.RemoveAllFeature(); + buttonItemLS5.Checked = false; + + dataGridViewX1.DataSource = null; + panelOfTable.Visible = false; + + 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); + + NetworkAnalysisTool.ClearAllTopAnalysis(this.globeControl1); + // 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();//清除所有坑 + + 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(); + } + } + + clearFeatureHighLight();//取消管线高亮 + + GSOLayer layerGround = globeControl1.Globe.Layers.GetLayerByCaption(roadLayerName);//("180fd"); + if (layerGround != null) + { + layerGround.Visible = true; + } + globeControl1.Refresh(); + globeControl2.Refresh(); + ClearRedlineAnalyseResult(); + globeControl1.Globe.Action = EnumAction3D.ActionNull; + } + /// + /// 管线长度全区域统计 + /// + /// + /// + private void buttonItemTJ1_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管线长度统计"); + + FrmAllPipelineStatis frm = new FrmAllPipelineStatis(globeControl1,null, new DataGridViewDelegate(InitDataGridViewX1), m_PipelineLayerNames); + frm.Show(this); + } + /// + /// 管线长度绘制区域统计 + /// + /// + /// + private void buttonItemTJ1_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管线长度统计"); + + trackflag = "PipelineDistanceStatistics"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; + } + /// + /// 阀门数量全区域统计 + /// + /// + /// + private void buttonItemTJ2_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "阀门数量统计"); + + FrmValveStatistics frm = new FrmValveStatistics(globeControl1, null, new DataGridViewDelegate(InitDataGridViewX1)); + frm.Show(this); + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + } + /// + /// 阀门数量绘制区域统计 + /// + /// + /// + private void buttonItemTJ2_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "阀门数量统计"); + + trackflag = "valvequery"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; + } + /// + /// 井盖数量全区域统计 + /// + /// + /// + private void buttonItemTJ3_ALL_Click(object sender, EventArgs e) +<<<<<<< HEAD + { + //日志记录 + LogManager.saveLog(Utility.userName, "井盖数量统计"); +======= + { +>>>>>>> d2d0088a6b3c53c1a96b7f1997f4d3443c0ee8c0 + FrmAllWorkWellStatis frm = new FrmAllWorkWellStatis(globeControl1, null, new DataGridViewDelegate(InitDataGridViewX1)); + frm.Show(this); + } + /// + /// 井盖数量绘制区域统计 + /// + /// + /// + private void buttonItemTJ3_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "井盖数量统计"); + + trackflag = "workwellquery"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; + } + /// + /// 管径分段统计全区域统计 + /// + /// + /// + private void buttonItemTJ4_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管径分段统计"); + + Frmpipediameterstatis.ShowForm(globeControl1, m_PipelineLayerNames, 0); + } + /// + /// 管径分段统计绘制区域统计 + /// + /// + /// + private void buttonItemTJ4_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管径分段统计"); + + trackflag = null; + Frmpipediameterstatis.ShowForm(globeControl1, m_PipelineLayerNames, 1); + } + /// + /// 埋深分段统计全区域统计 + /// + /// + /// + private void buttonItemTJ5_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "埋深分段统计"); + FrmpipeDeepstatis.ShowForm(globeControl1, m_PipelineLayerNames, 0); + } + /// + /// 埋深分段统计绘制区域统计 + /// + /// + /// + private void buttonItemTJ5_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "埋深分段统计"); + trackflag = null; + FrmpipeDeepstatis.ShowForm(globeControl1, m_PipelineLayerNames, 1); + } + /// + /// 管径分类统计全区域统计 + /// + /// + /// + private void buttonItemTJ6_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管径分类汇总"); + + FrmpipeDiametergather.ShowForm(globeControl1, m_PipelineLayerNames, 0); + } + /// + /// 管径分类统计绘制区域统计 + /// + /// + /// + private void buttonItemTJ6_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管径分类汇总"); + + trackflag = null; + FrmpipeDiametergather.ShowForm(globeControl1, m_PipelineLayerNames, 1); + } + /// + /// 材质分类统计全区域统计 + /// + /// + /// + private void buttonItemTJ7_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "材质分类汇总"); + + FrmpipeMaterialGather.ShowForm(globeControl1, m_PipelineLayerNames, 0); + } + /// + /// 材质分类统计绘制区域统计 + /// + /// + /// + private void buttonItemTJ7_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "材质分类汇总"); + + trackflag = null; + FrmpipeMaterialGather.ShowForm(globeControl1, m_PipelineLayerNames, 1); + } + /// + /// 附属物分类统计全区域统计 + /// + /// + /// + private void buttonItemTJ8_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "附属物分类汇总"); + + FrmAccessoriesgather.ShowForm(globeControl1, instrumenLayerNames, 0); + } + /// + /// 附属物分类统计绘制区域统计 + /// + /// + /// + private void buttonItemTJ8_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "附属物分类汇总"); + + trackflag = null; + FrmAccessoriesgather.ShowForm(globeControl1, instrumenLayerNames, 1); + } + /// + /// 碰撞分析 + /// + /// + /// + private void buttonItemFX1_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_4.Text); + + this.dataGridViewX4.Size = new System.Drawing.Size(195, 120); + 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(); + } + /// + /// 覆土分析 + /// + /// + /// + private void buttonItemFX1_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX5_1.Text); + this.dataGridViewX6.Size = new System.Drawing.Size(195, 120); + 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(); + } + /// + /// 间距分析 + /// + /// + /// + private void buttonItemFX1_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX1_3.Text); + + this.dataGridViewLineList.Size = new System.Drawing.Size(185, 120); + 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(); + } + /// + /// 垂直净距分析 + /// + /// + /// + private void buttonItemFX1_4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX1_4.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(); + } + /// + /// 水平净距分析 + /// + /// + /// + private void buttonItemFX1_5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_6.Text); + this.dataGridViewX8.Size = new System.Drawing.Size(185, 120); + 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(); + } + + #region Predaotr,断面分析 + /// + /// 横断面分析 + /// + /// + /// + private void buttonItemFX2_1_Click(object sender, EventArgs e) + { + globeControl1.Globe.Action = EnumAction3D.TrackPolyline; + globeControl1.Globe.TrackPolylineTool.VerticalLineVisible = true; + globeControl1.Globe.TrackPolylineTool.TrackMode = EnumTrackMode.SpaceTrack; + trackPolylineEndMode = EnumTrackPolylineEndMode.HDM_Analysis; + + } + /// + /// 纵断面分析 + /// + /// + /// + private void buttonItemFX2_2_Click(object sender, EventArgs e) + { + if (globeControl1.Globe.SelObjectCount<1) + { + MessageBox.Show("请选择一条或者多条管线!", "提示", MessageBoxButtons.OK, + MessageBoxIcon.Information); + return; + } + 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); + } + } + List feats = SectionAnalysisTool.ZDMAnalysis(selectFeatures); + if (feats != null && feats.Count >= 1) + { + FrmProfileAnalysis frm = new FrmProfileAnalysis(globeControl1, feats); + frm.Show(this); + } + } + /// + /// 道路断面分析 + /// + /// + /// + private void buttonItemFX2_3_Click(object sender, EventArgs e) + { + globeControl1.Globe.Action = EnumAction3D.TrackPolyline; + globeControl1.Globe.TrackPolylineTool.VerticalLineVisible = true; + globeControl1.Globe.TrackPolylineTool.TrackMode = EnumTrackMode.SpaceTrack; + trackPolylineEndMode = EnumTrackPolylineEndMode.DLDM_Analysis; + + } + /// + /// 基线剖面分析 + /// + /// + /// + private void buttonItemFX2_4_Click(object sender, EventArgs e) + { + globeControl1.Globe.Action = EnumAction3D.TrackPolyline; + globeControl1.Globe.TrackPolylineTool.VerticalLineVisible = true; + globeControl1.Globe.TrackPolylineTool.TrackMode = EnumTrackMode.SpaceTrack; + trackPolylineEndMode = EnumTrackPolylineEndMode.JXPM_Analysis; + + } + + #endregion + /// + /// 创建拓扑 + /// + /// + /// + private void buttonItemFX3_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX3_1.Text); + + FrmGenAndFaMenTopu frm = new FrmGenAndFaMenTopu(globeControl1, m_PipelineLayerNames, valueLayerNames); + frm.Show(this); + } + #region Predator :拓扑分析 + /// + /// 上游分析 + /// + /// + /// + private void buttonItemFX3_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX3_2.Text); + NetworkTraceUpDown(true); + } + /// + /// 下游分析 + /// + /// + /// + private void buttonItemFX3_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX3_3.Text); + NetworkTraceUpDown(false); + } + + /// + /// 上下游追踪 功能 + /// + /// + private void NetworkTraceUpDown(Boolean bTraceUp) + { + GSOFeature selLineFeature = globeControl1.Globe.SelectedObject; + if (selLineFeature == null || selLineFeature.Geometry == null || selLineFeature.Geometry.Type != EnumGeometryType.GeoPolyline3D) + { + MessageBox.Show("请点击“编辑”—“选中对象”选择一条线!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); + return; + } + GSOLayer selLayer = globeControl1.Globe.SelectedObjectLayer; + + NetworkAnalysisTool.TraceUpDownAnalysis(bTraceUp, + selLineFeature, selLayer); + } + + /// + /// 流向分析 + /// + /// + /// + private void buttonItemFX3_4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX3_4.Text); + + FrmFlow frm = new FrmFlow(globeControl1, m_PipelineLayerNames); + frm.Show(this); + } + /// + /// 关阀分析 + /// + /// + /// + private void buttonItemFX3_5_Click(object sender, EventArgs e) + { + if (globeControl1.Globe.SelObjectCount < 1) + { + MessageBox.Show("请选中至少一根管线!!"); + buttonItemFX3_5.Checked = false; + return; + } + GSOLayer resLayer = null; + GSOFeature resFeature = null; + globeControl1.Globe.GetSelectObject(0, out resFeature, out resLayer); + + String pipeLayerName = resLayer.Caption; + String pipeLayerNamePrefix = pipeLayerName.Substring(0, pipeLayerName.IndexOf("管线")); + GSOLayer valveLayer = globeControl1.Globe.Layers[pipeLayerNamePrefix + "阀门"]; + if (valveLayer == null) + { + MessageBox.Show("无" + pipeLayerNamePrefix+"阀门图层", "提示"); + return; + } + + GSOFeatures valveFeats = NetworkAnalysisTool.CloseValvesAnalysis(resFeature, + resLayer, valveLayer); + + if (valveFeats != null) + { + FrmCloseValves frm = new FrmCloseValves(this.globeControl1, valveFeats); + frm.Show(this); + } + else + { + MessageBox.Show("未找到关闭阀门"); + } + } + + /// + /// 连通分析 + /// + /// + /// + private void buttonItemFX3_6_Click(object sender, EventArgs e) + { + if (globeControl1.Globe.SelObjectCount < 2) + { + MessageBox.Show("请选中至少两个管线!!"); + buttonItemFX3_6.Checked = false; + return; + } + GSOFeature selFeat0, selFeat1; + GSOLayer layer0,layer1; + globeControl1.Globe.GetSelectObject(0, out selFeat0, out layer0); + globeControl1.Globe.GetSelectObject(1, out selFeat1, out layer1); + + if (!layer0.IsSameInnerObject(layer1)) + { + MessageBox.Show("不在同一个图层!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); + buttonItemFX3_6.Checked = false; + return; + } + NetworkAnalysisTool.ConnexityAnalysis(selFeat0, selFeat1, layer0); + } + /// + /// 爆管分析 + /// + /// + /// + private void buttonItemFX3_7_Click(object sender, EventArgs e) + { + NetworkTraceUpDown(true); //上游追踪: + + GSOFeature selLineFeature = globeControl1.Globe.SelectedObject; + if (selLineFeature == null || selLineFeature.Geometry == null || selLineFeature.Geometry.Type != EnumGeometryType.GeoPolyline3D) + { + MessageBox.Show("请点击“编辑”—“选中对象”选择一条线!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); + return; + } + GSOLayer selLayer = globeControl1.Globe.SelectedObjectLayer; + + NetworkAnalysisTool.ExplodeAnalysis(this.globeControl1,selLineFeature,selLayer); + + this.buttonItemFX3_5_Click(sender, e); //关阀分析: + + } + + #endregion + /// + /// 多边形开挖 + /// + /// + /// + private void buttonItemFX4_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_1.Text); + + trackflag = "pit"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; //是这个么?是的,在模型上 + } + /// + /// 挖方量分析 + /// + /// + /// + private void buttonItemFX4_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_2.Text); + + trackflag = "digFillAnalysis"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; + ActionToolMenuChecked(); + } + /// + /// 沿线开挖 + /// + /// + /// + private void buttonItemFX4_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_3.Text); + + if (!buttonItemFX4_3.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; + buttonItemFX4_3.Checked = true; + } + } + else + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + buttonItemFX4_3.Checked = false; + globeControl1.Globe.TrackPolylineTool.VerticalLineVisible = false; + } + ActionToolMenuChecked(); + } + /// + /// 创建隧道 + /// + /// + /// + private void buttonItemFX4_4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_4.Text); + + 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("场景中未加载隧道图层!", "提示"); + } + } + /// + /// 隐藏隧道 + /// + /// + /// + private void buttonItemFX4_5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_5.Text); + + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption("隧道"); + if (layer != null) + { + layer.Visible = !layer.Visible; + } + } + /// + /// 删除隧道 + /// + /// + /// + private void buttonItemFX4_6_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_6.Text); + + 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("请选中要删除的隧道!", "提示"); + } + } + /// + /// 通视分析 + /// + /// + /// + private void buttonItemFX5_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX5_1.Text); + + if (globeControl1.Globe.Action != EnumAction3D.VisibilityAnalysis) + { + //btnSpaceVisibilityAnalysis.Checked = true; + globeControl1.Globe.Action = EnumAction3D.VisibilityAnalysis; + } + else + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + // SetButtonChecked(); + } + } + /// + /// 可视域分析 + /// + /// + /// + private void buttonItemFX5_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX5_2.Text); + + globeControl1.Globe.Action = EnumAction3D.ViewshedAnalysis; + } + /// + /// 可视包络分析 + /// + /// + /// + private void buttonItemFX5_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX5_3.Text); + + globeControl1.Globe.Action = EnumAction3D.ViewEnvelopeAnalysis; + } + /// + /// 缓冲区分析 + /// + /// + /// + private void buttonItemFX6_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX6_1.Text); + + GSOFeature feat = globeControl1.Globe.SelectedObject; + if (feat == null) + { + MessageBox.Show("请选择要分析的要素!"); + return; + } + if (feat.Geometry.Type == EnumGeometryType.GeoPolyline3D) + { + GSOGeoPolyline3D line1 = feat.Geometry as GSOGeoPolyline3D; + if (line1 == null) + { + MessageBox.Show("请选择一条管线!"); + return; + } + + FrmBufferAnalysis frm = new FrmBufferAnalysis(globeControl1, line1, layerTemp); + frm.Show(this); + } + else + { + FrmBufferAnalysisBSQ frm = new FrmBufferAnalysisBSQ(globeControl1, layerTemp, bsqPT); + frm.Show(this); + } + + } + /// + /// 附属物分析 + /// + /// + /// + private void buttonItemFX6_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX6_2.Text); + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + FrmAccessoryAnalysis dlg = new FrmAccessoryAnalysis(globeControl1, layerTemp); + dlg.Show(this); + } + /// + /// 无源淹没分析 + /// + /// + /// + private void buttonItemFX6_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX6_3.Text); + + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + trackflag = "FloodAnalysis"; + } + /// + /// 水平距离 + /// + /// + /// + private void buttonItemLS1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS1.Text); + + globeControl1.Globe.Action = EnumAction3D.MeasureDistance; + globeControl1.Globe.DistanceRuler.SpaceMeasure = false; + buttonItemLS5.Checked = false; + } + /// + /// 垂直距离 + /// + /// + /// + private void buttonItemLS2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS2.Text); + + buttonItemLS5.Checked = false; + globeControl1.Globe.Action = EnumAction3D.MeasureHeight; + globeControl1.Globe.DistanceRuler.SpaceMeasure = false; + } + /// + /// 空间距离 + /// + /// + /// + private void buttonItemLS3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS3.Text); + + buttonItemLS5.Checked = false; + globeControl1.Globe.Action = EnumAction3D.MeasureDistance; + globeControl1.Globe.DistanceRuler.SpaceMeasure = true; + } + /// + /// 地表距离 + /// + /// + /// + private void buttonItemLS4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS4.Text); + + buttonItemLS5.Checked = false; + globeControl1.Globe.Action = EnumAction3D.MeasureDistance; + globeControl1.Globe.DistanceRuler.SpaceMeasure = false; + } + /// + /// 高度量算 + /// + /// + /// + private void buttonItemLS5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS5.Text); + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + buttonItemLS5.Checked = !buttonItemLS5.Checked; + if (buttonItemLS5.Checked) + { + globeControl1.Globe.Action = EnumAction3D.SelectObject; + } + } + /// + /// 水平面积 + /// + /// + /// + private void buttonItemLS6_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS6.Text); + + buttonItemLS5.Checked = false; + globeControl1.Globe.Action = EnumAction3D.MeasureArea; + globeControl1.Globe.AreaRuler.SpaceMeasure = true; + } + /// + /// 地表面积 + /// + /// + /// + private void buttonItemLS7_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS7.Text); + + buttonItemLS5.Checked = false; + globeControl1.Globe.Action = EnumAction3D.MeasureArea; + globeControl1.Globe.AreaRuler.SpaceMeasure = false; + + } + + # region Fan 重构标注代码 + /// + /// 标高标注 + /// + /// + /// + private void buttonItemSZ1_Click(object sender, EventArgs e) + { + GSOFeature resFeature = IsPipeLineOfSelectedObj(); + if (resFeature == null) + { + MessageBox.Show("请选中一根管线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + GSOGeoPolyline3D selLine = resFeature.Geometry as GSOGeoPolyline3D; + if (selLine[0].Count <= 1) + { + return; + } + + MarkTools.getInstance().showMarker(resFeature, + globeControl1, EnumMarkLayer.Mark_Altitude, ""); + } + /// + /// 管径标注 + /// + GSOFeature radiusMarkerFeature; + private void buttonItemBZ2_Click(object sender, EventArgs e) + { + GSOFeature resFeature = IsPipeLineOfSelectedObj(); + if (resFeature == null) + { + MessageBox.Show("请选中一根管线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + GSOGeoPolyline3D selLine = resFeature.Geometry as GSOGeoPolyline3D; + if (selLine[0].Count <= 1) + { + return; + } + + MarkTools.getInstance().showMarker(resFeature, + globeControl1, EnumMarkLayer.Mark_Diameter, ""); + } + /// + /// 埋深标注 + /// + /// + /// + private void buttonItemBZ3_Click(object sender, EventArgs e) + { + GSOFeature resFeature = IsPipeLineOfSelectedObj(); + if (resFeature == null) + { + MessageBox.Show("请选中一根管线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + GSOGeoPolyline3D selLine = resFeature.Geometry as GSOGeoPolyline3D; + if (selLine[0].Count <=1) + { + return; + } + + MarkTools.getInstance().showMarker(resFeature, + globeControl1, EnumMarkLayer.Mark_Depth, ""); + + } + /// + /// 坐标标注 + /// + /// + /// + private void buttonItemBZ4_Click(object sender, EventArgs e) + { + GSOFeature resFeature = IsPipeLineOfSelectedObj(); + if (resFeature == null) + { + MessageBox.Show("请选中一根管线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + GSOGeoPolyline3D selLine = resFeature.Geometry as GSOGeoPolyline3D; + if (selLine[0].Count <= 1) + { + return; + } + MarkTools.getInstance().showMarker(resFeature, + globeControl1, EnumMarkLayer.Mark_Location, ""); + } + /// + /// 距离标注 + /// + bool distanceMarker = false; + private void buttonItemBZ5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBZ5.Text); + + globeControl1.Globe.Action = EnumAction3D.TrackPolyline; + //globeControl1.Globe.DistanceRuler.MeasureMode = EnumDistanceMeasureMode.HVSLineMeasure; + distanceMarker = true; + } + /// + /// 自定义标注 + /// + /// + /// + private void buttonItemBZ6_Click(object sender, EventArgs e) + { + GSOFeature f = globeControl1.Globe.SelectedObject; + GSOLayer l = globeControl1.Globe.SelectedObjectLayer; + FrmCustomLabel frm = new FrmCustomLabel(globeControl1, l, f); + if (frm.ShowDialog() == DialogResult.OK) + { + MarkTools.getInstance().showMarker(f, globeControl1, EnumMarkLayer.Mark_Custom, frm.labelText); + } + } + /// + /// 扯旗标注 + /// + /// + /// + private void buttonItemBZ7_Click(object sender, EventArgs e) + { + GSOFeature f = globeControl1.Globe.SelectedObject; + GSOLayer l = globeControl1.Globe.SelectedObjectLayer; + FrmMarker frm = new FrmMarker(); + if (frm.ShowDialog() == DialogResult.OK) + { + MarkTools.getInstance().showMarker(f, globeControl1, EnumMarkLayer.Mark_Custom, frm.markerContent); + } + } + /// + /// 坡度标注 + /// + /// + /// + private void buttonItemBZ8_Click(object sender, EventArgs e) + { + GSOFeature resFeature = IsPipeLineOfSelectedObj(); + if (resFeature == null) + { + MessageBox.Show("请选中一根管线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + GSOGeoPolyline3D selLine = resFeature.Geometry as GSOGeoPolyline3D; + if (selLine[0].Count <= 1) + { + return; + } + + MarkTools.getInstance().showMarker(resFeature, + globeControl1, EnumMarkLayer.Mark_Slope, ""); + } + /// + /// 属性标注 + /// + /// + /// + private void buttonItemBZ9_Click(object sender, EventArgs e) + { + GSOFeature f = globeControl1.Globe.SelectedObject; + GSOLayer l = globeControl1.Globe.SelectedObjectLayer; + FrmPropertiesMarker frm = new FrmPropertiesMarker(globeControl1, l, f); + if (frm.ShowDialog() == DialogResult.OK) + { + MarkTools.getInstance().showMarker(f, globeControl1, EnumMarkLayer.Mark_Property, frm.labelText); + } + } + /// + /// 红线工具 + /// + /// + /// + private void buttonItemBZ10_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBZ10.Text); + 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; + } + } + /// + /// 标注管理 + /// + /// + /// + private void buttonItemBZ11_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBZ11.Text); + + buttonItemBZ11.Checked = !buttonItemBZ11.Checked; + 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 (buttonItemBZ11.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(); + } + } + + #endregion + /// + /// 飞行到目标点 + /// + /// + /// + private void buttonItemFXGJ1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFXGJ1.Text); + + FrmSetFlytoPos.ShowForm(globeControl1); + + } + /// + /// 自定义飞行 + /// + /// + /// + private void buttonItemFXGJ2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFXGJ2.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); + } + } + /// + /// 绕中心点飞行 + /// + /// + /// + private void buttonItemFXGJ3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFXGJ3.Text); + + globeControl1.Globe.FlyAroundCenter(10000, EnumFlyRepeatValueType.MiliSeconds); + globeControl1.Globe.CurFlyID = 1; + } + /// + /// 绕眼睛飞行 + /// + /// + /// + private void buttonItemFXGJ4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFXGJ4.Text); + + globeControl1.Globe.FlyAroundEye(720, EnumFlyRepeatValueType.Degrees); + globeControl1.Globe.CurFlyID = 2; + } + + /// + /// 权限管理 + /// + /// + /// + private void buttonItemXT1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT1.Text); + + FrmUserRoleMgr frm = new FrmUserRoleMgr(); + frm.ShowDialog(); + } + /// + /// 数据库管理 + /// + /// + /// + private void buttonItemXT2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT2.Text); + + //查看数据库列表 + FrmDbManager frm = new FrmDbManager(); + frm.ShowDialog(); + } + /// + /// 用户列表 + /// + /// + /// + private void buttonItemXT3_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT3_1.Text); + + FrmUserManager frm = new FrmUserManager(); + frm.ShowDialog(); + } + /// + /// 创建新用户 + /// + /// + /// + private void buttonItemXT3_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT3_2.Text); + + FrmUserAdd frm = new FrmUserAdd(-1); + frm.ShowDialog(); + } + /// + /// 人员修改 + /// + /// + /// + private void buttonItemXT4_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT4_2.Text); + + FrmAppUSER appUSER = new FrmAppUSER(); + appUSER.ShowDialog(); + } + /// + /// 增加人员 + /// + /// + /// + private void buttonItemXT4_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT4_1.Text); + + FrmAppUSERRESET appUSERRESET = new FrmAppUSERRESET(); + appUSERRESET.ShowDialog(); + } + /// + /// 统计数据 + /// + /// + /// + private void buttonItemZTT1_Click(object sender, EventArgs e) + { + ////日志记录 + //LogManager.saveLog(Utility.userName, this.buttonItemZTT1.Text); + + //PATM patm = new PATM(); + //patm.operation = "Statistic"; + //patm.Text = "统计专题图管理"; + //patm.ShowDialog(); + } + /// + /// 热点功能统计 + /// + /// + /// + private void buttonItemZTT2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT2.Text); + + FrmHotFuncStat frmhfs = new FrmHotFuncStat(); + frmhfs.ShowDialog(); + } + + private void buttonItemZTT3_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT3_1.Text); + + FrmAPP appfrm = new FrmAPP("专题图申请"); + appfrm.ShowDialog(); + } + + private void buttonItemZTT3_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT3_2.Text); + + FrmAPPFORASK appForask = new FrmAPPFORASK("专题图审核"); + appForask.ShowDialog(); + } + + private void buttonItemZTT3_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT3_3.Text); + + FrmAPPregion appregion = new FrmAPPregion("专题图审核"); + appregion.ShowDialog(); + } + + private void buttonItemZTT4_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT4_1.Text); + + FrmAPP appfrm = new FrmAPP("打印申请"); + appfrm.ShowDialog(); + } + + private void buttonItemZTT4_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT4_2.Text); + + FrmAPPFORASK appForask = new FrmAPPFORASK("打印审核"); + appForask.ShowDialog(); + } + + private void buttonItemZTT4_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT4_3.Text); + + FrmAPPregion appregion = new FrmAPPregion("打印审核"); + appregion.ShowDialog(); + } + + private void buttonItemZTT5_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT5_1.Text); + + FrmAPP appfrm = new FrmAPP("拷贝申请"); + appfrm.ShowDialog(); + } + + private void buttonItemZTT5_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT5_2.Text); + + FrmAPPFORASK appForask = new FrmAPPFORASK("拷贝审核"); + appForask.ShowDialog(); + } + + private void buttonItemZTT5_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT5_3.Text); + + FrmAPPregion appregion = new FrmAPPregion("拷贝审核"); + appregion.Show(); + } + + private int connectServerCount = 0; + + /// + /// 还原球到实测库 + /// + 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); + } + + if (layerManagerNode.Nodes.Count > 0) + { + for (int i = layerManagerNode.Nodes.Count - 1; i >= 0; i--) + { + layerManagerNode.Nodes[i].Remove(); + + } + } + + globeControl1.Refresh(); + + } + + private void buttonItemSPSZ_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSPSZ.Text); + + FrmLayerControl frm = new FrmLayerControl(layerTree, globeControl1, globeControl2); + frm.Show(this); + } + + /// + /// 碰撞审查 + /// + /// + /// + private void buttonItemSH1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSH1.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 buttonItemSH2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSH2.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 buttonItemSH3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSH3.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 buttonItemSH4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSH4.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 buttonItemSH5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSH5.Text); + FrmCityServerLineAnalysis frm = new FrmCityServerLineAnalysis(globeControl1, m_PipelineLayerNames); + frm.Show(this); + } + #region 数据管理-导入文件 + ///// + ///// 数据管理-导入本地坐标系文件 + ///// + ///// + ///// + //private void buttonItemSJGL1_1_Click(object sender, EventArgs e) + //{ + // //日志记录 + // LogManager.saveLog(Utility.userName, this.buttonItemSJGL1_1.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(); + // } + // } + //} + + ///// + ///// 数据管理-导入其他坐标系文件 + ///// + ///// + ///// + //private void buttonItemSJGL1_2_Click(object sender, EventArgs e) + //{ + // //日志记录 + // LogManager.saveLog(Utility.userName, this.buttonItemSJGL1_2.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(); + // } + // } + //} + #endregion + /// + /// 数据质量检查 + /// + /// + /// + private void buttonItemSJGL2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL2.Text); + FrmValiData frm = new FrmValiData(globeControl1); + frm.ShowDialog(); + } + /// + /// 数据预处理 + /// + /// + /// + private void buttonItemSJGL3_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL3.Text); + + FrmEditShapeFile frm = new FrmEditShapeFile(globeControl1); + frm.ShowDialog(this); + } + /// + /// 连接数据库 + /// + /// + /// + private void buttonItemSJGL4_1_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL4_1.Text); + + FrmDatabaseParaSetting frm = new FrmDatabaseParaSetting(globeControl1); + if (frm.ShowDialog() == DialogResult.OK) + { + ds = FrmDatabaseParaSetting.ds; + if (ds != null) + { + ds.IsCloseSaved = false; + } + } + } + /// + /// 管线入库 + /// + /// + /// + private void buttonItemSJGL4_2_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL4_2.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 buttonItemSJGL4_3_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL4_3.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 buttonItemSJGL5_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL5.Text); + + Cyberpipe.Forms.FrmProject frm = new Cyberpipe.Forms.FrmProject(); + frm.ShowDialog(); + } + /// + /// 元数据基本管理 + /// + /// + /// + private void buttonItemSJGL6_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL6_1.Text); + + FrmMetadata frmmd = new FrmMetadata(); + frmmd.ShowDialog(); + } + /// + /// 元数据查询管理 + /// + /// + /// + private void buttonItemSJGL6_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL6_2.Text); + + FrmMetadataStat frmmds = new FrmMetadataStat(); + //frmmds.Show(); + frmmds.ShowDialog(); + } + /// + /// 操作日志管理 + /// + /// + /// + private void buttonItemSJGL7_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL7.Text); + + FrmLogOper frmlo = new FrmLogOper(); + frmlo.ShowDialog(); + } + /// + /// 数据字典管理 + /// + /// + /// + private void buttonItemSJGL8_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL8.Text); + + FrmMDDictory frmmdd = new FrmMDDictory(); + frmmdd.ShowDialog(); + } + /// + /// 数据库备份 + /// + /// + /// + private void buttonItemSJGL9_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL9.Text); + + //新 + FrmBACKORACLE backOracle = new FrmBACKORACLE(); + backOracle.Show(); + } + /// + /// 创建管段 + /// + /// + /// + private void buttonItemBJ1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ1.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; + } + } + /// + /// 创建附属物 + /// + /// + /// + private void buttonItemBJ2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ2.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); + } + } + /// + /// 创建特征管点 + /// + /// + /// + private void buttonItemBJ3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ3.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); + } + } + /// + /// 绘制城市七线 + /// + /// + /// + private void buttonItemBJ4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ4.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; + } + } + } + /// + /// 选中对象 + /// + /// + /// + private void buttonItemBJ5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ5.Text); + + globeControl1.Globe.Action = EnumAction3D.SelectObject; + } + /// + /// 平移对象 + /// + /// + /// + private void buttonItemBJ6_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ6.Text); + + globeControl1.Globe.Action = EnumAction3D.MoveObject; + } + /// + /// 升降对象 + /// + /// + /// + private void buttonItemBJ7_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ7.Text); + + globeControl1.Globe.Action = EnumAction3D.ElevateObject; + } + /// + /// 旋转对象 + /// + /// + /// + private void buttonItemBJ8_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ8.Text); + + globeControl1.Globe.Action = EnumAction3D.RotateObject; + } + /// + /// 连接管段 + /// + /// + /// + private void buttonItemBJ9_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ9.Text); + + if (globeControl1.Globe.SelObjectCount < 2) + { + MessageBox.Show("对不起,请至少选中2个对象!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + return; + } + globeControl1.Globe.InsertJointPipeline(false); + } + /// + /// 后退 + /// + /// + /// + private void buttonItemBJ11_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemBJ11.Text); + globeControl1.Globe.UnDoEdit(); + } + /// + /// 前进 + /// + /// + /// + private void buttonItemBJ12_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemBJ12.Text); + + globeControl1.Globe.ReDoEdit(); + } + /// + /// 导出CAD + /// + /// + /// + private void buttonItemBJ10_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ10_1.Text); + + #region 导出成dxf格式 + List listVectorNames = new List(); + 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(); + #endregion + } + /// + /// 导出矢量 + /// + /// + /// + private void buttonItemBJ10_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ10_2.Text); + + List listVectorNames = new List(); + 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 buttonItemBJ13_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemBJ13.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(); + } + } + MessageBox.Show("删除成功!", "提示"); + } + else + { + MessageBox.Show("请选中要删除的模型!", "提示"); + } + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + } + + private void buttonItemHX1_1_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]; + string filePath = dlg.FileName; + string lastname = Path.GetFileName(filePath); + + 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(); + } + + } + } + } + + public struct LineStruct + { + public string layerName; + public string layerCode; + public string lineLength; + public string hxName; + } + + List lineStruct = new List(); + List featsList = new List(); + + /// + /// 红线审核 + /// + /// + /// + private void buttonItemHX2_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemHX2.Text); + redSH = true; + featsList.Clear(); + lineStruct.Clear(); + List listPipelineLayers = new List(); + + GSOLayer layer = null; + for (int i = 0; i < m_PipelineLayerNames.Count; i++) + { + layer = globeControl1.Globe.Layers.GetLayerByCaption(m_PipelineLayerNames[i]); + if (layer != null) + { + listPipelineLayers.Add(layer); + } + } + //yanxiaowei 重构 + GSOFeatures selectFeatures=new GSOFeatures(); + for (int i = 0; i < globeControl1.Globe.SelObjectCount; i++) + { + GSOFeature feature = null; + globeControl1.Globe.GetSelectObject(i, out feature, out layer); + selectFeatures.Add(feature); + } + DataTable table=new DataTable(); + + ClassGSOTool.CalculateRedLineResult(out table, redSH, selectFeatures, globeControl1, + listPipelineLayers,out lineStruct, out featsList); + + if (table.Rows.Count != 0) + AddDatagridView(table); + else + { + MessageBox.Show("没有侵入地块红线的管线数据!", "提示"); + dataGridViewX1.DataSource = null; + panelOfTable.Visible = false; + return; + } + } + + private void AddDatagridView(DataTable table) + { + dataGridViewX1.DataSource = table; + panelOfTable.Visible = true; + panelOfTable.Height = 200; + toolStripNumbers.Text = "红线审核 |共有:" + table.Rows.Count + "条"; + toolStripDropDownButton3.Visible = true; + } + /// + /// 主窗体 下方的工具条中的 导出.xls文件 按钮事件处理 + /// + /// + /// + private void toolStripDropDownButton3_Click(object sender, EventArgs e) + { + if (dataGridViewX1.Rows.Count == 0) + { + MessageBox.Show("表格内容为空!", "提示"); + return; + } + + string strSaveFile = string.Empty; + SaveFileDialog savefiledialog = new SaveFileDialog(); + savefiledialog.Filter = "Excel文件|*.xls,*.xlsx"; + savefiledialog.AddExtension = true; + savefiledialog.FileName = "红线审核"; + if (savefiledialog.ShowDialog() == DialogResult.OK) + strSaveFile = savefiledialog.FileName; + else return; + + ExpEXCEL.ExpToExcel(dataGridViewX1, strSaveFile, "红线审核", lineStruct, featsList); + MessageBox.Show("导出成功!"); + } + /// + /// 去除集合中重复的管线 + /// + /// + /// + /// + private GSOFeatures getFeaturesByFilter(GSOFeatures features, string fieldName) + { + if (features == null) + { + return null; + } + GSOFeatures featuresGet = new GSOFeatures(); + for (int i = 0; i < features.Length; i++) + { + GSOFeature featureFromFS = features[i]; + string fieldValueFromFS = featureFromFS.GetValue(fieldName).ToString().Trim(); + bool isHas = false; + for (int j = featuresGet.Length - 1; j >= 0; j--) + { + GSOFeature featureFromFSGet = featuresGet[j]; + string fieldValueFromFSGet = featureFromFSGet.GetValue(fieldName).ToString().Trim(); + if (fieldValueFromFS.Equals(fieldValueFromFSGet)) + { + isHas = true; + break; + } + } + if (isHas == false) + { + featuresGet.Add(featureFromFS.Clone()); + } + } + return featuresGet; + } + + private void sliderItem2_ValueChanged(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.sliderItem2.Text); + + globeControl1.Globe.GroundOpaque = 100 - sliderItem2.Value; + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(roadLayerName);//("180fd"); + if (layer != null) + { + layer.Opaque = 100 - sliderItem2.Value; + } + layer = globeControl2.Globe.Layers.GetLayerByCaption("180fd");//("180fd"); + if (layer != null) + { + layer.Opaque = 100 - sliderItem2.Value; + } + globeControl2.Globe.GroundOpaque = 100 - sliderItem2.Value; + + optiValue = sliderItem2.Value; + } + /// + /// 数据管理导入文件 + /// + /// + /// + private void buttonItemSJGL1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL1.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.Multiselect = true; + if (dlg.ShowDialog() == DialogResult.OK) + { + //自定义lprj文件名,从程序中复制一lprj文件。 + string filePath = dlg.FileName; + string lastname = Path.GetFileName(filePath); + + 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, 100); + + globeControl1.Refresh(); + } + } + } + + private void buttonItemHX1_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemHX1.Text); + + GSODataSource dataSpace = globeControl1.Globe.DataManager.OpenOracleDataSource(Utility.DBServer.Trim() + "/" + Utility.dbdatabase.Trim(), "", "", Utility.userID, Utility.DBPassword); + string filepath = ""; + //日志记录 + OpenFileDialog dlg = new OpenFileDialog(); + dlg.Filter = "矢量数据(*.shp)|*.shp|矢量数据(*.lgd)|*.lgd|CAD数据(*.dxf)|*.dxf|全部支持格式(*.lgd,*.shp,*.dxf)|*.lgd;*.shp;*.dxf;"; + dlg.Multiselect = true; + + #region 临时图层显示 + if (dlg.ShowDialog() == DialogResult.OK) + { + string filePath = dlg.FileName; + string lastname = Path.GetFileName(filePath); + + #region + for (int i = 0; i < dlg.FileNames.Length; i++) + { + string strDataPath = dlg.FileNames[i]; + filepath = strDataPath; + + GSOLayer layer = globeControl1.Globe.Layers.Add(strDataPath); + GSOFeatures RedFeatures = layer.GetAllFeatures(); + + 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(); + RedFeatures = features; + 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; + } + + /////////////////////////////////////////////////////////////////////////////////////////// + globeControl1.Globe.Layers.MoveTo(0, globeControl1.Globe.Layers.Count - 1); + globeControl1.Refresh(); + } + + IModelBuilder modelBuilder = new RedLineBuilder(); + + modelBuilder.batchInsert(dataSpace, redDt, RedFeatures); + + } + #endregion + + } + #endregion + } + /// + /// 定位 + /// + /// + /// + private void buttonItemLocation_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemLocation.Text); + + FrmFlyToPosition fly = new FrmFlyToPosition(globeControl1,globeControl2); + fly.Show(this); + } + /// + /// 2015-10-17演示代码 红线审核 + /// + /// + /// + private void ribbonTabItem6_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.FlyToPosition(new GSOPoint3d(120.610963, 31.188121, 50), EnumAltitudeMode.Absolute, -4, 50, 800); + globeControl1.Globe.FlyToPointSpeed = 10000000; + globeControl1.Globe.Action = EnumAction3D.SelectObject; + globeControl1.Refresh(); + + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + + //zhanshi = false; + redSH = true; + splitContainer1.Panel2Collapsed = true; + legendSG.Visible = false; + legendSC.Visible = false; + ClearGZData(); + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = true; + } + + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 基础工具 + /// + /// + /// + private void ribbonTabItem1_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + //zhanshi = false; + redSH = false; + splitContainer1.Panel2Collapsed = true; + panelOfTable.Visible = false; + legendSC.Visible = false; + legendSG.Visible = false; + ClearGZData(); + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + + + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 一键审核 + /// + /// + /// + private void ribbonTabItem11_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + //zhanshi = false; + redSH = false; + splitContainer1.Panel2Collapsed = true; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + panelOfTable.Visible = false; + legendSC.Visible = false; + legendSG.Visible = false; + ClearGZData(); + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + + + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 右屏添加冰箱数据 + /// + void AddDataToGlobeControl2() + { + + bool modelDataBool = false; + for (int i = globeControl2.Globe.Layers.Count - 1; i >= 0; i--) + { + GSOLayer layer = globeControl2.Globe.Layers[i]; + if (layer.Name.Contains("fttp:")) + { + modelDataBool = true; + break; + } + } + + if (modelDataBool == false) + { + GSOLayer ly = globeControl1.Globe.Layers.GetLayerByCaption("天地图地图"); + globeControl2.Globe.Layers.Add(ly); + } + else + { + return; + } + } + /// + /// 双屏对比 + /// + /// + /// + private void ribbonTabItem9_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent += new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent += new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + panelOfTable.Visible = false; + + splitContainer1.Panel2Collapsed = false; + //zhanshi = true; + redSH = false; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + sliderItem2.Value = 100 - globeControl1.Globe.GroundOpaque; + globeControl2.Globe.GroundOpaque = globeControl1.Globe.GroundOpaque; + legendSC.Visible = true; + legendSG.Visible = true; + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + AddDataToGlobeControl2(); + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 文档管理 + /// + /// + /// + private void ribbonTabItem4_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + panelOfTable.Visible = false; + //zhanshi = false; + redSH = false; + splitContainer1.Panel2Collapsed = true; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + legendSC.Visible = false; + legendSG.Visible = false; + ClearGZData(); + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 基础管理 + /// + /// + /// + private void ribbonTabItem14_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + panelOfTable.Visible = false; + //zhanshi = false; + redSH = false; + splitContainer1.Panel2Collapsed = true; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + legendSC.Visible = false; + legendSG.Visible = false; + ClearGZData(); + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 权限管理 + /// + /// + /// + private void ribbonTabItem2_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + panelOfTable.Visible = false; + //zhanshi = false; + redSH = false; + splitContainer1.Panel2Collapsed = true; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + legendSC.Visible = false; + legendSG.Visible = false; + ClearGZData(); + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + GSOFeature dpFeatuer = null; + /// + /// 双屏分析,点击管段分析 + /// + /// + /// + private void buttonItem8_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItem8.Text); + + //FrmCompareFeature frmCompareFeature = new FrmCompareFeature(globeControl1, globeControl2, layerTemp, layerTemp2,m_PipelineLayerNames,sgPipeLayersNames); + int width = this.Width; + FrmCompareFeature.ShowForm(globeControl1, globeControl2, layerTemp, layerTemp2, m_PipelineLayerNames, sgPipeLayersNames,width); + //frmCompareFeature.Location = new Point((this.Width - frmCompareFeature.Width)/2,50); + //frmCompareFeature.Show(this); + + } + /// + /// 红线审核导出图片 + /// + /// + /// + private void buttonItemDCTP_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemDCTP.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))); + */ + int mapWidth = 0; + int mapHeight = 0; + Point pt = getUpperLeftPoint(pt1, pt2, out mapWidth, out mapHeight); + int rightBottomX = pt.X + mapWidth; + int rightBottomY = pt.Y + mapHeight; + Image myImg = new Bitmap(mapWidth, mapHeight); + Graphics g = Graphics.FromImage(myImg); + g.CopyFromScreen(pt, new Point(0, 0), new Size(rightBottomX, rightBottomY)); + + 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; + } + } + } + /// + /// 标识器全区域统计 + /// + /// + /// + private void 标识器分类统计ToolStripMenuItem_Click(object sender, EventArgs e) + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + FrmBSQStatis bsqStatis = new FrmBSQStatis(globeControl1,null); + //FrmBSQStatis bsqStatis = new FrmBSQStatis(); + bsqStatis.Show(this); + } + /// + /// 标识器绘制区域统计 + /// + /// + /// + private void 标识器分类统计ToolStripMenuItem1_Click(object sender, EventArgs e) + { + trackflag = "BSQDuoBianXiangStatis"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + } + + #region 保存和加载审核库加载的图层 + /* + private void saveLayerList(TreeNodeCollection treeNodeList) + { + string configPath = Application.StartupPath + "\\configLayerList.xml"; + try + { + XmlDocument doc = new XmlDocument(); + doc.Load(configPath); + XmlNode dbParams = doc.SelectSingleNode("Params/dbparams"); + XmlNode dbLayers = doc.SelectSingleNode("Params/dblayers"); + XmlNode layers = doc.SelectSingleNode("Params/layers"); + dbParams.RemoveAll(); + dbLayers.RemoveAll(); + layers.RemoveAll(); + + List listDS = new List(); + String shDatasourceName = Utility.sgdbip + "/" + Utility.sgdbname + "_" + Utility.sgdbuser; + bool flag = false; + + for (int i = 0; i < globeControl1.Globe.DataManager.DataSourceCount; i++) + { + GSODataSource ds = globeControl1.Globe.DataManager.GetDataSourceAt(i); + if (ds != null && ds.Type == EnumDataSourceType.SqlServer || ds.Type == EnumDataSourceType.Oracle) + { + if (ds.Name == shDatasourceName) + { + //防止因为多次连接同一个数据库 + if (flag == true) + { + break; + } + flag = true; + listDS.Add(ds); + GSODataSourceCnn conn = ds.GetConnectionInfo(); + + XmlElement dbparam = doc.CreateElement("shdbparam"); + XmlElement ip = doc.CreateElement("ship"); + ip.InnerText = conn.Server; + + XmlElement dbname = doc.CreateElement("shdbname"); + dbname.InnerText = conn.Database; + + XmlElement username = doc.CreateElement("shusername"); + username.InnerText = conn.User; + + XmlElement password = doc.CreateElement("shpassword"); + password.InnerText = conn.Password; + + XmlElement type = doc.CreateElement("shtype"); + if (ds.Type == EnumDataSourceType.SqlServer) + { + type.InnerText = "sqlserver"; + } + else + { + type.InnerText = "oracle"; + } + + dbparam.AppendChild(ip); + dbparam.AppendChild(dbname); + dbparam.AppendChild(username); + dbparam.AppendChild(password); + dbparam.AppendChild(type); + dbParams.AppendChild(dbparam); + } + + } + } + + for (int i = 0; i < treeNodeList.Count; i++) + { + GSOLayer layer = treeNodeList[i].Tag as GSOLayer; + if (Path.GetExtension(layer.Name) == "") + { + XmlElement dbLayer = doc.CreateElement("dblayer"); + XmlAttribute attri = doc.CreateAttribute("dbindex"); + for (int j = 0; j < listDS.Count; j++) + { + if (layer.Dataset.DataSource.Name == listDS[j].Name) + { + attri.Value = j.ToString(); + break; + } + } + dbLayer.Attributes.Append(attri); + dbLayer.InnerText = layer.Name; + + dbLayers.AppendChild(dbLayer); + } + else + { + XmlElement dbLayer = doc.CreateElement("layer"); + dbLayer.InnerText = layer.Name; + layers.AppendChild(dbLayer); + } + } + + doc.Save(configPath); + } + catch (Exception e) + { + + } + } + + private void openLayerList() + { + layerManagerNode.Nodes.Clear(); + + string configPath = Application.StartupPath + "\\configLayerList.xml"; + try + { + XmlDocument doc = new XmlDocument(); + doc.Load(configPath); + XmlNode dbParams = doc.SelectSingleNode("Params/dbparams"); + XmlNode dbLayers = doc.SelectSingleNode("Params/dblayers"); + XmlNode layers = doc.SelectSingleNode("Params/layers"); + + List listDS = new List(); + for (int i = 0; i < dbParams.ChildNodes.Count; i++) + { + string ip = ""; + string dbname = ""; + string username = ""; + string password = ""; + string type = ""; + XmlNode node = dbParams.ChildNodes.Item(i); + for (int j = 0; j < node.ChildNodes.Count; j++) + { + XmlNode nodeChild = node.ChildNodes.Item(j); + + if (nodeChild != null && nodeChild.Name == "ship") + { + ip = nodeChild.InnerText; + } + else if (nodeChild != null && nodeChild.Name == "shdbname") + { + dbname = nodeChild.InnerText; + } + else if (nodeChild != null && nodeChild.Name == "shusername") + { + username = nodeChild.InnerText; + } + else if (nodeChild != null && nodeChild.Name == "shpassword") + { + password = nodeChild.InnerText; + } + else if (nodeChild != null && nodeChild.Name == "shtype") + { + type = nodeChild.InnerText; + } + } + + if (type == "sqlserver") + { + GSODataSource ds = globeControl1.Globe.DataManager.OpenSqlServerDataSource(ip, "", dbname, username, password); + listDS.Add(ds); + } + else if (type == "oracle") + { + GSODataSource ds = globeControl1.Globe.DataManager.OpenOracleDataSource(ip + "/" + dbname, "", "", username, password); + listDS.Add(ds); + } + } + + for (int i = 0; i < dbLayers.ChildNodes.Count; i++) + { + XmlNode node = dbLayers.ChildNodes.Item(i); + if (node != null) + { + string layerName = node.InnerText; + XmlAttribute attri = node.Attributes["dbindex"]; + if (attri != null) + { + int dbIndex = -1; + if (int.TryParse(attri.Value, out dbIndex)) + { + GSODataset dataset = listDS[dbIndex].GetDatasetByName(layerName); + globeControl1.Globe.Layers.Add(dataset); + //更新树节点 + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + TreeNode layerNode = new TreeNode(); + layerNode.Tag = layer; + layerNode.Text = layer.Dataset.Caption; + layerNode.ImageIndex = 0; + layerNode.SelectedImageIndex = 0; + layerNode.Checked = layer.Visible; + layerManagerNode.Nodes.Insert(0, layerNode); + // layerManagerNode.Expand(); + + + } + } + } + } + for (int i = 0; i < layers.ChildNodes.Count; i++) + { + XmlNode node = layers.ChildNodes.Item(i); + if (node != null) + { + string layerName = node.InnerText; + globeControl1.Globe.Layers.Add(layerName); + + //更新树节点 + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + TreeNode layerNode = new TreeNode(); + layerNode.Tag = layer; + layerNode.Text = layer.Dataset.Caption; + layerNode.ImageIndex = 0; + layerNode.SelectedImageIndex = 0; + layerNode.Checked = layer.Visible; + layerManagerNode.Nodes.Insert(0, layerNode); + } + } + layerManagerNode.Expand(); + } + catch (Exception e) + { + + } + } + * */ + #endregion + + private void btn_check_history_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_check_history.Text); + + if (FrmCheckHistory.isOpen == true) + { + return; + } + FrmCheckHistory frm = new FrmCheckHistory(globeControl1, globeControl2); + frm.addNode += new AddNodeToLayerManagerNode(addNodeToLayerManagerNode); + frm.Show(); + + } + + private void buttonItem查看数据_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItem查看数据.Text); + + FrmThreeOracle tr = new FrmThreeOracle(globeControl1); + + if (tr.ShowDialog() == DialogResult.OK) + { + addNodeToLayerManagerNode(tr.rukuLayer); + globeControl1.Refresh(); + } + } + /// + /// 规划数据入库 + /// + /// + /// + private void buttonItemGHRK_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemGHRK.Text); + + FrmGHRK ghrk = new FrmGHRK(globeControl1, layerManagerNode); + ghrk.Show(this); + } + + private void btn_user_info_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_user_info.Text); + + if (!FrmSysUserInfoManger.IS_OPEN) + { + FrmSysUserInfoManger frm = new FrmSysUserInfoManger(); + frm.ShowDialog(); + } + } + + private void btn_role_info_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_role_info.Text); + + if (FrmRoleInfoManager.IS_OPEN) + { + return; + } + FrmRoleInfoManager frm = new FrmRoleInfoManager(); + frm.ShowDialog(); + } + + private void btn_resc_info_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_resc_info.Text); + + if (!SysRescInfoManager.IS_OPEN) + { + SysRescInfoManager frm = new SysRescInfoManager(); + frm.ShowDialog(); + } + } + + private void btn_role_resc_Click(object sender, EventArgs e) + { + + LogManager.saveLog(Utility.userName, this.btn_role_resc.Text); + + if (!FrmRoleRescManager.IS_OPEN) + { + FrmRoleRescManager frm = new FrmRoleRescManager(); + frm.ShowDialog(); + } + } + + private void btn_user_role_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_user_role.Text); + + if (FrmUserRole.IS_OPEN) + { + return; + } + FrmUserRole frm = new FrmUserRole(); + frm.ShowDialog(); + } + + private void btn_document_info_Click(object sender, EventArgs e) + { + + LogManager.saveLog(Utility.userName, this.btn_document_info.Text); + + //if (FormDocumentManager.IS_OPEN) + //{ + // return; + //} + //FormDocumentManager frm = new FormDocumentManager(); + //frm.ShowDialog(); + + //if (FormDocumentManager.IS_OPEN) + //{ + // return; + //} + //new FormDocumentManager().ShowDialog(); + if (FormDocumentManager.IS_OPEN) + { + return; + } + this.Cursor = Cursors.WaitCursor; + FormDocumentManager frm = new FormDocumentManager(); + frm.changeCursor += new ChangeCursor(changeCursorToDefault); + frm.ShowDialog(); + + } + + private void changeCursorToDefault() + { + this.Cursor = Cursors.Default; + } + + /// + /// 判断CAD文件是否有投影信息 + /// + /// + /// + Boolean CheckDatasetGeoReference(GSODataset dataset) + { + Boolean bSuccess = false; + if (dataset.GeoReferenceType == EnumGeoReferenceType.Flat) + { + if (MessageBox.Show("数据没有空间参考信息,请设置空间参考信息!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation) == DialogResult.OK) + { + String strPath = Path.GetDirectoryName(Application.ExecutablePath) + "\\Coordinate Systems"; + OpenFileDialog dlg = new OpenFileDialog(); + + dlg.InitialDirectory = strPath; + dlg.RestoreDirectory = true; + + dlg.Filter = "投影文件|*.prj||"; + if (dlg.ShowDialog() == DialogResult.OK) + { + bSuccess = dataset.LoadProjectionFromESRIFile(dlg.FileName); + } + } + } + else + { + return true; + } + return bSuccess; + } + + private void buttonItemexp_CAD_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemexp_CAD.Text); + + OpenFileDialog dlg = new OpenFileDialog(); + dlg.Filter = "支持格式(*.dwg)|*.dwg"; + dlg.Multiselect = true; + if (dlg.ShowDialog() == DialogResult.OK) + { + for (int i = 0; i < dlg.FileNames.Length; i++) + { + //this.Cursor = Cursors.WaitCursor; + string strDataPath = dlg.FileNames[i]; + + #region + //string strDataPathPrj = strDataPath.ToLower().Replace(".dwg", ".lprj"); + + //if (File.Exists(strDataPathPrj) == false) + //{ + // if (MessageBox.Show("数据没有空间参考信息,请设置空间参考信息!", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation) == DialogResult.OK) + // { + // String strPath = Application.StartupPath + "\\Coordinate Systems"; + // OpenFileDialog dlgPrj = new OpenFileDialog(); + // dlgPrj.InitialDirectory = strPath; + // dlgPrj.RestoreDirectory = true; + // dlgPrj.Multiselect = false; + // dlg.Filter = "投影文件|*.prj"; + // if (dlg.ShowDialog() == DialogResult.OK) + // { + // this.Cursor = Cursors.WaitCursor; + // string proj4 = GSODataEngineUtility.ConvertEsriPrjFileToProj4(dlg.FileName); + // using (StreamWriter stream = new StreamWriter(strDataPathPrj, false)) + // { + // stream.WriteLine("0prj4" + proj4 + ""); + // } + // AddLayerData(strDataPath); + // //globeControl1.Globe.Layers.Add(strDataPath); + + // this.Cursor = Cursors.Default; + // } + // else + // { + // AddLayerData(strDataPath); + // //globeControl1.Globe.Layers.Add(strDataPath); + // } + // } + // else + // { + // AddLayerData(strDataPath); + // //globeControl1.Globe.Layers.Add(strDataPath); + // } + + //} + //else + //{ + // //globeControl1.Globe.Layers.Add(strDataPath); + // AddLayerData(strDataPath); + //} + #endregion + AddLayerData(strDataPath); + //this.Cursor = Cursors.Default; + } + } + + 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, 100); + + globeControl1.Refresh(); + } + } + + private void btn_password_edit_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_password_edit.Text); + + if (FrmChangePassword.IS_OPEN) + { + return; + } + FrmChangePassword frm = new FrmChangePassword(); + frm.ShowDialog(); + } + /// + /// 多孔管线入库 + /// + /// + /// + private void buttonItem9_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL4_2.Text); + + if (ds == null) + { + MessageBox.Show("请先连接数据库", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + ConnectDB(null, null); + } + if (ds == null) + return; + + FrmMultiPipelineModelDB frm = new FrmMultiPipelineModelDB(globeControl1, ds); + if (frm.ShowDialog() == DialogResult.OK) + { + addNodeToLayerManagerNode(frm.rukuLayer); + } + //frm.Show(); + } + private void 导出CADToolStripMenuItem1_Click(object sender, EventArgs e) + { + TreeNode node = layerNodeContexMenu.Tag as TreeNode; + if (node == null) + { + MessageBox.Show("请在左侧节点集中选择要导出的图层", "提示"); + return; + } + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(node.Text.Trim()); + if (layer == null || layer.GetAllFeatures().Length <= 0) + { + MessageBox.Show("要导出的图层为空", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + return; + } + string strProjectName = Utility.projectStr; + if (strProjectName != "") + { + SaveFileDialog dlg = new SaveFileDialog(); + dlg.Filter = "*.dwg|*.dwg|*.dxf|*.dxf"; + dlg.FileName = layer.Caption; + if (dlg.ShowDialog(this) == DialogResult.OK) + { + globeControl1.Globe.MemoryLayer.SaveAs(dlg.FileName); + GSOLayer newlayer = globeControl1.Globe.Layers.Add(dlg.FileName); + newlayer.RemoveAllFeature(); + int featureCount = layer.GetAllFeatures().Length; + for (int i = 0; i < featureCount; i++) + { + GSOFeature feature = layer.GetAt(i); + if (feature != null && feature.Geometry != null) + { + if (feature.Geometry.Type == EnumGeometryType.GeoPolyline3D) + { + feature.Geometry.Style = new GSOSimpleLineStyle3D(); + } + else if (feature.Geometry.Type == EnumGeometryType.GeoPolygon3D) + { + feature.Geometry.Style = new GSOSimplePolygonStyle3D(); + } + newlayer.AddFeature(feature); + } + } + newlayer.Save(); + newlayer.Dataset.DataSource.RemoveDataset(newlayer.Dataset); + globeControl1.Globe.Layers.Remove(newlayer); + MessageBox.Show("导出CAD完成!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + } + } + } + + private void buttonItemGBJC_Click(object sender, EventArgs e) + { + FrmGBJC gb = new FrmGBJC(globeControl1, globeControl2, layerTemp, layerTemp2); + gb.Show(this); + } + + #region 右屏管纵数据控制 + private void 五十米主干道ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = true; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + + private void 三十六米次干道ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = true; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + + private void 四十二米次干道ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = true; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + + private void 二十四米一块板ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = true; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + + private void 二十四米三块板ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = true; + } + + private void 二十四米停车带ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = true; + lendendGZ24_3.Visible = false; + } + + private void 二十六米大堤路ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = true; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + + private void 清除管纵数据ToolStripMenuItem_Click(object sender, EventArgs e) + { + ClearGZData(); + } + + private void ClearGZData() + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + #endregion + + private void buttonItemPasswordReset_Click(object sender, EventArgs e) + { + Frm_password_reset reset = new Frm_password_reset(); + reset.Show(); + } + + private void pictureBox1_Paint(object sender, PaintEventArgs e) + { + int Width = this.Width; + string welcomeUser = "欢迎您:" + Utility.userName; + Graphics g = e.Graphics; + g.DrawString(welcomeUser, new Font("宋体", 12), new SolidBrush(Color.Black), Width - 180, 50); + } + + } +} \ No newline at end of file diff --git a/MainFrm.cs.BASE.9016.cs b/MainFrm.cs.BASE.9016.cs new file mode 100644 index 0000000..e530fbd --- /dev/null +++ b/MainFrm.cs.BASE.9016.cs @@ -0,0 +1,13442 @@ +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; + + GSOBalloon featureTooltip2; + GSOBalloonEx balloonEx2; + + GSOLayer layerTemp; + GSOLayer layerTemp2; + FrmShResult frmShResult = null; + FrmRedlineResult frmredResult = null; + FrmMnModify frmModify = null; + public bool frmRedlineResult = false; + public bool boolfrmShResult = false; + public bool boolfrmModify = false; + + List m_PipelineLayerNames = new List();//线图层名称 + List workwellLayerNames = new List();//工井图层名称 + List valueLayerNames = new List();//阀门图层名称 + List instrumenLayerNames = new List();//附属物图层名称 + List pipefittingLayerNames = new List();//管件图层名称 + List sgPipeLayersNames = new List();//施工管线图层名称 + 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 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; + public string redLayer = null; + //GSOLayer redLayer1 = null; + bool redSH = false; + string redDt = "红线"; + //双屏对比 + //bool zhanshi=false; + Thread t = null; + private GSOHudButton legendSC;//定义图例 + private GSOHudButton legendSG;//定义图例 + //管纵图 + private GSOHudButton lendendGZ50; + private GSOHudButton lendendGZ36; + private GSOHudButton lendendGZ42; + private GSOHudButton lendendGZ24_1; + private GSOHudButton lendendGZ24_2; + private GSOHudButton lendendGZ24_3; + private GSOHudButton lendendGZ26; + + GSOGeoPoint3D bsqPT; + + FrmYJSHTC frmSh = null;//一键审核窗口全局变量wxl + FrmWait frmWait = null;//一键审核等待窗口 + //FrmWait frmWait2 = null;//文档操作等待窗口 + + float mouseDownX1,mouseDownY1; + float mouseDownX2,mouseDownY2; + /// + /// + /// + 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; + + featureTooltip2 = new GSOBalloon(globeControl2.Handle); + balloonEx2 = new GSOBalloonEx(globeControl2.Handle); + Utility.SetBallons(featureTooltip, balloonEx); + + panelOfTable.Height = 200; + + RigthMenuSet(); + + MenuSet(); + + } + /// + /// 右屏中添加管纵图片 + /// + private void AddGZ() + { + + lendendGZ50 = new GSOHudButton(); + lendendGZ50.SetImage(Application.StartupPath + "/Resource/管纵/50.png"); + lendendGZ50.SetOffset(0, 0); + lendendGZ50.MinOpaque = 1; + lendendGZ50.MaxOpaque = 1; + lendendGZ50.FadeOut = false; + lendendGZ50.Name = "lendendGZ50"; + lendendGZ50.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ50); + lendendGZ50.Visible = false; + + lendendGZ36 = new GSOHudButton(); + lendendGZ36.SetImage(Application.StartupPath + "/Resource/管纵/36.png"); + lendendGZ36.SetOffset(0, 0); + lendendGZ36.MinOpaque = 1; + lendendGZ36.MaxOpaque = 1; + lendendGZ36.FadeOut = false; + lendendGZ36.Name = "lendendGZ36"; + lendendGZ36.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ36); + lendendGZ36.Visible = false; + + lendendGZ42 = new GSOHudButton(); + lendendGZ42.SetImage(Application.StartupPath + "/Resource/管纵/42.png"); + lendendGZ42.SetOffset(0, 0); + lendendGZ42.MinOpaque = 1; + lendendGZ42.MaxOpaque = 1; + lendendGZ42.FadeOut = false; + lendendGZ42.Name = "lendendGZ42"; + lendendGZ42.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ42); + lendendGZ42.Visible = false; + + lendendGZ24_1 = new GSOHudButton(); + lendendGZ24_1.SetImage(Application.StartupPath + "/Resource/管纵/24_1.png"); + lendendGZ24_1.SetOffset(0, 0); + lendendGZ24_1.MinOpaque = 1; + lendendGZ24_1.MaxOpaque = 1; + lendendGZ24_1.FadeOut = false; + lendendGZ24_1.Name = "lendendGZ24_1"; + lendendGZ24_1.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ24_1); + lendendGZ24_1.Visible = false; + + lendendGZ24_2 = new GSOHudButton(); + lendendGZ24_2.SetImage(Application.StartupPath + "/Resource/管纵/24_2.png"); + lendendGZ24_2.SetOffset(0, 0); + lendendGZ24_2.MinOpaque = 1; + lendendGZ24_2.MaxOpaque = 1; + lendendGZ24_2.FadeOut = false; + lendendGZ24_2.Name = "lendendGZ24_2"; + lendendGZ24_2.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ24_2); + lendendGZ24_2.Visible = false; + + lendendGZ24_3 = new GSOHudButton(); + lendendGZ24_3.SetImage(Application.StartupPath + "/Resource/管纵/24_3.png"); + lendendGZ24_3.SetOffset(0, 0); + lendendGZ24_3.MinOpaque = 1; + lendendGZ24_3.MaxOpaque = 1; + lendendGZ24_3.FadeOut = false; + lendendGZ24_3.Name = "lendendGZ24_3"; + lendendGZ24_3.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ24_3); + lendendGZ24_3.Visible = false; + + lendendGZ26 = new GSOHudButton(); + lendendGZ26.SetImage(Application.StartupPath + "/Resource/管纵/26.png"); + lendendGZ26.SetOffset(0, 0); + lendendGZ26.MinOpaque = 1; + lendendGZ26.MaxOpaque = 1; + lendendGZ26.FadeOut = false; + lendendGZ26.Name = "lendendGZ26"; + lendendGZ26.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ26); + lendendGZ26.Visible = false; + + } + + public void RigthMenuSet() + { + if (Utility.userRole.IndexOf("清除分析") < 0) + { + toolRightMenu.Items.Remove(清除分析ToolStripMenuItem); + } + + #region 区域分析 + if (Utility.userRole.IndexOf("区域分析") < 0) + { + toolRightMenu.Items.Remove(区域分析ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("缓冲区分析") < 0) + { + 区域分析ToolStripMenuItem.DropDownItems.Remove(缓冲区分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("附属物分析") < 0) + { + 区域分析ToolStripMenuItem.DropDownItems.Remove(附属物分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("无源淹没分析") < 0) + { + 区域分析ToolStripMenuItem.DropDownItems.Remove(无源淹没分析ToolStripMenuItem); + } + } + #endregion + + #region 视域分析 + if (Utility.userRole.IndexOf("视域分析") < 0) + { + toolRightMenu.Items.Remove(视域分析ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("通视分析") < 0) + { + 视域分析ToolStripMenuItem.DropDownItems.Remove(通视分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("可视域分析") < 0) + { + 视域分析ToolStripMenuItem.DropDownItems.Remove(可视域分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("可视包络分析") < 0) + { + 视域分析ToolStripMenuItem.DropDownItems.Remove(可视包络分析ToolStripMenuItem); + } + } + #endregion + + #region 开发分析 + if (Utility.userRole.IndexOf("开挖分析") < 0) + { + toolRightMenu.Items.Remove(开挖分析ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("多边形开挖") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(多边形开挖ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("挖方量分析") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(挖方量分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("沿线开挖") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(沿线开挖ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("创建隧道") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(创建隧道ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("隐藏隧道") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(隐藏隧道ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("删除隧道") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(删除隧道ToolStripMenuItem); + } + } + #endregion + + #region 拓扑分析 + if (Utility.userRole.IndexOf("拓扑分析") < 0) + { + toolRightMenu.Items.Remove(拓扑分析ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("创建拓扑") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(创建拓扑ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("上游分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(上游分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("下游分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(下游分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("流向分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(流向分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("关阀分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(关阀分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("连通分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(连通分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("爆管分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(爆管分析ToolStripMenuItem); + } + } + #endregion + + #region 断面分析 + if (Utility.userRole.IndexOf("断面分析") < 0) + { + toolRightMenu.Items.Remove(断面分析ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("横断面分析") < 0) + { + 断面分析ToolStripMenuItem.DropDownItems.Remove(横断面分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("纵断面分析") < 0) + { + 断面分析ToolStripMenuItem.DropDownItems.Remove(纵断面分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("道路断面分析") < 0) + { + 断面分析ToolStripMenuItem.DropDownItems.Remove(道路断面分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("基线剖面分析") < 0) + { + 断面分析ToolStripMenuItem.DropDownItems.Remove(基线剖面分析ToolStripMenuItem); + } + } + #endregion + + #region 绘制区域统计 + if (Utility.userRole.IndexOf("绘制区域统计") < 0) + { + toolRightMenu.Items.Remove(绘制区域统计ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("绘制区域管线长度统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管线长度统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域阀门数量统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(阀门数量统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域井盖数量统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(井盖数量统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域管径分段统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管径分段统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域埋深分段统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(埋深分段统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域管径分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管径分类统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域材质分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(材质分类统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域附属物分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(附属物分类统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域标识器分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(标识器分类统计ToolStripMenuItem1); + } + + } + #endregion + + #region 全区域统计 + if (Utility.userRole.IndexOf("全区域统计") < 0) + { + toolRightMenu.Items.Remove(全区域统计ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("全区域管线长度统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管线长度统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域阀门数量统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(阀门数量统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域井盖数量统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(井盖数量统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域管径分段统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管径分段统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域埋深分段统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(埋深分段统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域管径分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管径分类统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域材质分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(材质分类统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域附属物分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(附属物分类统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域标识器分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(标识器分类统计ToolStripMenuItem); + } + + } + #endregion + + #region 查询 + if (Utility.userRole.IndexOf("查询") < 0) + { + toolRightMenu.Items.Remove(查询ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("空间查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(空间查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("编号查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(编号查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("坐标查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(坐标查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("管径查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(管径查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("材质查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(材质查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("基本查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(基本查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("复合查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(复合查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("关联查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(关联查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("关键字查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(关键字查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("附属物查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(附属物查询ToolStripMenuItem); + } + } + #endregion + + #region 标注 + if (Utility.userRole.IndexOf("标注") < 0) + { + toolRightMenu.Items.Remove(标注ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("标高标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(标高标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("管径标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(管径标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("埋深标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(埋深标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("坐标标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(坐标标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("距离标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(距离标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("自定义标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(自定义标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("扯旗标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(扯旗标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("坡度标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(坡度标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("属性标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(属性标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("标注管理") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(标注管理ToolStripMenuItem); + } + } + #endregion + + #region 飞行 + if (Utility.userRole.IndexOf("飞行") < 0) + { + toolRightMenu.Items.Remove(飞行ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("自定义飞行") < 0) + { + 飞行ToolStripMenuItem.DropDownItems.Remove(自定义飞行ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("飞行到目标点") < 0) + { + 飞行ToolStripMenuItem.DropDownItems.Remove(飞行到目标点ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("绕中心点飞行") < 0) + { + 飞行ToolStripMenuItem.DropDownItems.Remove(绕中心点飞行ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("绕眼睛飞行") < 0) + { + 飞行ToolStripMenuItem.DropDownItems.Remove(绕眼睛飞行ToolStripMenuItem); + } + } + #endregion + + #region 编辑 + if (Utility.userRole.IndexOf("编辑") < 0) + { + toolRightMenu.Items.Remove(编辑ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("平移对象") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(平移对象ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("升降对象") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(升降对象ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("旋转对象") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(旋转对象ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("连接管段") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(连接管段ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("导出文件") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(导出文件ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("前进") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(前进ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("后退") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(删除模型ToolStripMenuItem); + } + } + #endregion + + #region 量算 + if (Utility.userRole.IndexOf("量算") < 0) + { + toolRightMenu.Items.Remove(量算ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("水平距离") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(水平距离ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("垂直距离") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(垂直距离ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("空间距离") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(空间距离ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("地表距离") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(地表距离ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("高度量算") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(高度量算ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("水平面积") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(水平面积ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("地表面积") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(地表面积ToolStripMenuItem1); + } + } + #endregion + } + + public void MenuSet() + { + + #region 权限管理 + if (Utility.userRole.IndexOf("权限管理") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem2); + } + else + { + + if (Utility.userRole.IndexOf("用户管理") < 0) + { + btn_user_info.Visible = false; + } + if (Utility.userRole.IndexOf("角色管理") < 0) + { + btn_role_info.Visible = false; + } + if (Utility.userRole.IndexOf("资源管理") < 0) + { + btn_resc_info.Visible = false; + } + if (Utility.userRole.IndexOf("角色授权") < 0) + { + btn_role_resc.Visible = false; + } + if (Utility.userRole.IndexOf("用户授权") < 0) + { + btn_user_role.Visible = false; + } + if (Utility.userRole.IndexOf("密码修改") < 0) + { + btn_password_edit.Visible = false; + } + + } + #endregion + + #region 基础工具 + if (Utility.userRole.IndexOf("基础工具") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem1); + } + else + { + if (Utility.userRole.IndexOf("地上模式") < 0) + { + buttonItem87.Visible = false; + } + if (Utility.userRole.IndexOf("地下模式") < 0) + { + buttonItem88.Visible = false; + } + if (Utility.userRole.IndexOf("行走模式") < 0) + { + buttonItem27.Visible = false; + } + if (Utility.userRole.IndexOf("透明度设置") < 0) + { + sliderGroundTransSet1.Visible = false; + } + if (Utility.userRole.IndexOf("快速定位") < 0) + { + buttonItem91.Visible = false; + } + if (Utility.userRole.IndexOf("图层管理") < 0) + { + buttonItem1.Visible = false; + } + if (Utility.userRole.IndexOf("图例管理") < 0) + { + btnlegendSet.Visible = false; + } + if (Utility.userRole.IndexOf("全屏显示") < 0) + { + buttonItem89.Visible = false; + } + if (Utility.userRole.IndexOf("导出图片") < 0) + { + btnOutputJPG.Visible = false; + } + + } + #endregion + + #region 一键审核 + if (Utility.userRole.IndexOf("一键审核") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem11); + } + #endregion + + #region 红线审核 + if (Utility.userRole.IndexOf("红线审核") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem6); + } + #endregion + + #region 双屏对比 + if (Utility.userRole.IndexOf("双屏对比") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem9); + } + #endregion + + #region 文档管理 + if (Utility.userRole.IndexOf("文档管理") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem4); + } + #endregion + + #region 基础管理 + if (Utility.userRole.IndexOf("基础管理") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem14); + } + else + { + if (Utility.userRole.IndexOf("专题图审批") < 0) + { + buttonItemZTT3_2.Visible = false; + } + if (Utility.userRole.IndexOf("打印审批") < 0) + { + buttonItemZTT4_2.Visible = false; + } + if (Utility.userRole.IndexOf("拷贝审批") < 0) + { + buttonItemZTT5_2.Visible = false; + } + } + + #endregion + + if (ribbonControl1.Items.Count <= 0) + { + ribbonControl1.Visible = false; + } + } + + #region Fan Zhang 重构现有代码 + //初始化控件布局 + private void initLayout() + { + 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.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.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.labelX21.Width = (int)(this.labelX21.Width * myScreen); + this.labelX22.Width = (int)(this.labelX22.Width * myScreen); + this.labelX24.Width = (int)(this.labelX24.Width * myScreen); + } + sideBar1.Visible = false; + 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]); + } + + splitContainer1.Panel2Collapsed = true; + + buttonItem87.Checked = true;//默认地上模式 + ribbonTabItem1.Select(); //初始化状态为浏览 + + sideBarPanelItem3.Visible = false; + layerTree.Visible = false; + controlContainerItem3.Visible = false; + if (sideBarPanelItem4.Visible == true) + { + sideBar1.Visible = true; + controlContainerItem5.Visible = true; + } + else + { + sideBar1.Visible = false; + } + Refresh(); + sliderGroundTransSet1.Value = optiValue; + sliderItem1.Value = optiValue; + sliderItem2.Value = optiValue; + sliderItem3.Value = optiValue; + + } + + //初始化地球控件 + private void initGlobalControl() + { + //选择 + btnToolSelect = new GSOHudButton(); + btnToolSelect.SetImage(Application.StartupPath + "\\Resource\\image\\select1.png"); + btnToolSelect.FadeOut = false; + btnToolSelect.Align = EnumAlign.TopLeft; + btnToolSelect.SetOffset(20, 50); + btnToolSelect.Name = "1"; + btnToolSelect.HeightFixed = true; + btnToolSelect.WidthFixed = true; + globeControl1.Globe.AddHudControl(btnToolSelect); + globeControl2.Globe.AddHudControl(btnToolSelect); + + //浏览 + 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); + + //图例 + legend = new GSOHudButton(); + legend.SetImage(Application.StartupPath + "/Resource/图例P.jpg");//图例P + legend.SetOffset(0, 15); + legend.MinOpaque = 1; + legend.MaxOpaque = 1; + legend.FadeOut = false; + legend.Name = "legend"; + legend.Align = EnumAlign.BottomRight; + legend.Visible = false; + globeControl1.Globe.AddHudControl(legend); + + //实测 + legendSC = new GSOHudButton(); + legendSC.SetImage(Application.StartupPath + "/Resource/sc.jpg"); + legendSC.SetOffset(0, 15); + legendSC.MinOpaque = 1; + legendSC.MaxOpaque = 1; + legendSC.FadeOut = false; + legendSC.Name = "legendSC"; + legendSC.Align = EnumAlign.BottomRight; + globeControl1.Globe.AddHudControl(legendSC); + legendSC.Visible = false; + + //施工 + legendSG = new GSOHudButton(); + legendSG.SetImage(Application.StartupPath + "/Resource/sg.jpg"); + legendSG.SetOffset(0, 15); + legendSG.MinOpaque = 1; + legendSG.MaxOpaque = 1; + legendSG.FadeOut = false; + legendSG.Name = "legendSG"; + legendSG.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(legendSG); + legendSG.Visible = false; + + //管纵 + AddGZ(); + + 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; + globeControl1.Globe.IsReleaseMemOutOfView = true; + globeControl1.Globe.ControlPanel.Visible = true; + + globeControl2.Globe.UnderGroundFloor.Visible = false; + globeControl2.Globe.OverviewControl.Visible = false; + globeControl2.Globe.ScalerControl.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; + globeControl2.Globe.IsReleaseMemOutOfView = true; + globeControl2.Globe.ControlPanel.Visible = false; + + 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); + + //添加临时图层 + layerTemp = globeControl1.Globe.Layers.Add(Application.StartupPath + "\\tempLgdData.lgd"); + layerTemp2 = globeControl2.Globe.Layers.Add(Application.StartupPath + "\\tempLgdData2.lgd"); + if (layerTemp != null) + { + layerTemp.MaxVisibleAltitude = 1000; + } + + //添加城市7线图层 + 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"); + + //注册对应事件 + this.registerEvent(); + } + + //注册地球事件 + private bool registerEvent() + { + if (globeControl1 == null || globeControl2 == null) + { + return false; + } + 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); + + globeControl2.FeatureMouseClickEvent += new FeatureMouseClickEventHandler(globeControl2_FeatureMouseClickEvent); + globeControl2.CameraBeginMoveEvent += new CameraBeginMoveEventHandler(globeControl2_CameraBeginMoveEvent); + + globeControl1.MouseDoubleClick += new MouseEventHandler(globeControl1_MouseDoubleClick); + globeControl1.MouseClick += new MouseEventHandler(globeControl1_MouseClick); + globeControl1.MouseDown += new MouseEventHandler(globeControl1_MouseDown); + + globeControl2.MouseClick += new MouseEventHandler(globeControl2_MouseClick); + globeControl2.MouseDown += new MouseEventHandler(globeControl2_MouseDown); + + 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); + + return true; + } + + //加载两个地球数据 + private void loadData() + { + Thread t1 = new Thread(new ThreadStart(doLoadDataForGlobalControl1)); + t1.IsBackground = true; + t1.Start(); + + + } + + delegate void LoadDataForGlobalControl(); + + private void connectServer() + { + globeControl1.Globe.ConnectServer(Utility.serverip, Utility.serverport, "", ""); //加载locaServer中的数据 + globeControl2.Globe.ConnectServer(Utility.serverip, Utility.serverport, "", ""); //加载locaServer中的数据 + //初始化TreeView + // 勾选实测图层 + foreach (TreeNode tn in layerTree.Nodes) + { + if (tn.Nodes.Count > 0) + { + if (tn.Text == "实测数据") + { + tn.Checked = true; + foreach (TreeNode tnChild in tn.Nodes) + { + tnChild.Checked = true; + foreach (TreeNode tnGrandChild in tnChild.Nodes) + { + tnGrandChild.Checked = true; + } + } + } + } + } + } + + private void doLoadDataForGlobalControl1() + { + try + { + + globeControl1.Globe.Layers.MoveDown(10000); + //加载实测管线数据 + Utility.dataSource = globeControl1.Globe.DataManager.OpenOracleDataSource(Utility.DBServer.Trim() + "/" + Utility.dbdatabase.Trim(), "", "", Utility.userID, Utility.DBPassword); + + if (Utility.dataSource != null) + { + for (int j = 0; j < Utility.dataSource.DatasetCount; j++) + { + GSODataset dataset = Utility.dataSource.GetDatasetAt(j); + if (dataset != null && dictionaryNetLayerNameAndCaption.ContainsKey(dataset.Caption)) + { + dataset.Caption = dataset.Name; + globeControl1.Globe.Layers.Add(dataset); + } + } + } + //隐藏红线图层 + globeControl1.Globe.Layers.GetLayerByCaption("红线").Visible = false; + + //globleControl1中加载规划数据 + GSODataSource ghDS = globeControl1.Globe.DataManager.OpenOracleDataSource(Utility.ghdbip + "/" + Utility.ghdbname, "", "", Utility.ghdbuser, Utility.ghdbpwd); + if (ghDS != null) + { + for (int j = 0; j < ghDS.DatasetCount; j++) + { + GSODataset dataset = ghDS.GetDatasetAt(j); + if (dataset != null && dictionaryNetLayerNameAndCaption.ContainsKey(dataset.Caption)) + { + dataset.Caption = dataset.Name; + globeControl1.Globe.Layers.Add(dataset); + globeControl1.Globe.Layers[0].Visible = false; + } + } + } + + //globeControl1,globeControl2中加载施工数据 + GSODataSource sgDS = globeControl1.Globe.DataManager.OpenOracleDataSource(Utility.sgdbip + "/" + Utility.sgdbname, "", "", Utility.sgdbuser, Utility.sgdbpwd); + if (sgDS != null) + { + for (int m = 0; m < sgDS.DatasetCount; m++) + { + GSODataset dataset = sgDS.GetDatasetAt(m); + if (dataset != null && !dataset.Caption.Contains("SH") && dictionaryNetLayerNameAndCaption.ContainsKey(dataset.Caption)) + { + dataset.Caption = dataset.Name; + globeControl1.Globe.Layers.Add(dataset); + globeControl1.Globe.Layers[0].Visible = false; + + globeControl2.Globe.Layers.Add(dataset); + globeControl2.Globe.Layers[0].Visible = true; + } + } + } + + LoadDataForGlobalControl ss = new LoadDataForGlobalControl(connectServer); + ss(); + + } + catch (Exception ex) + { + MessageBox.Show(ex.Message); + } + } + + private void initLayerTree() + { + //加载临时图层节点 + layerManagerNode = new TreeNode(); + layerManagerNode.ImageIndex = 0; + layerManagerNode.SelectedImageIndex = 0; + layerManagerNode.Checked = true; + layerManagerNode.Text = "临时图层"; + layerTree.Nodes.Add(layerManagerNode); + + XmlDocument doc = new XmlDocument(); + doc.Load(filename); + XmlNodeList xmlLayerNodes = doc.SelectNodes("//layer"); + + foreach (XmlNode xmlLayerNode in xmlLayerNodes) + { + + //TODO LIST:创建一级TreeNode(实测、规划、施工) + TreeNode nodelayer = new TreeNode(); + string layerName = xmlLayerNode.Attributes["label"].Value; + nodelayer.Text = layerName; + nodelayer.Checked = false; + layerTree.Nodes.Add(nodelayer); + + XmlNodeList xmlChildLayerNodes = xmlLayerNode.ChildNodes; + foreach (XmlNode xmlChildLayerNode in xmlChildLayerNodes) + { + //TODO LIST:创建二级TreeNode节点 + TreeNode secondLevelNode = new TreeNode(); + string layerType = xmlChildLayerNode.Attributes["label"].Value; + secondLevelNode.Text = layerType; + + if (xmlChildLayerNode.Attributes["type"] != null) + { //道路图层特殊处理 + string type = xmlChildLayerNode.Attributes["type"].Value; + secondLevelNode.Tag = type + "|" + layerType; + } + else + { + secondLevelNode.Tag = layerType; + } + secondLevelNode.Checked = false; + nodelayer.Nodes.Add(secondLevelNode); + + XmlNodeList xmlActitualLayerNodes = xmlChildLayerNode.ChildNodes; + + foreach (XmlNode xmlActitualLayerNode in xmlActitualLayerNodes) + { + //TODO LIST:创建三级图层节点 + TreeNode layerNode = new TreeNode(); + string actutallylayerType = xmlActitualLayerNode.Attributes["type"].Value; + string actutallylayerName = xmlActitualLayerNode.Attributes["layer"].Value; + string actutallyLabelName = xmlActitualLayerNode.Attributes["label"].Value; + + layerNode.Text = actutallyLabelName; + layerNode.Tag = layerType + "|" + actutallyLabelName; + layerNode.Checked = false; + secondLevelNode.Nodes.Add(layerNode); + } + + } + + } + + } + + /** + * 读取Config.xml文件,初始化以下全局Map + * m_PipelineLayerNames:管线 + * workwellLayerNames:工井 + * valueLayerNames:阀门 + * instrumenLayerNames:附属物 + * pipefittingLayerNames:特征管点 + * sgPipeLayersNames:施工管线 + **/ + private void initGlobalMap() + { + XmlDocument doc = new XmlDocument(); + doc.Load(filename); + XmlNodeList xmlLayerNodes = doc.SelectNodes("//layerchild"); + + foreach (XmlNode xmlLayerNode in xmlLayerNodes) + { + string layerType = xmlLayerNode.Attributes["type"].Value; + string layerName1 = xmlLayerNode.Attributes["layer"].Value; + string layerchildName = xmlLayerNode.Attributes["label"].Value; + + dictionaryNetLayerNameAndCaption.Add(layerName1, layerchildName); + + if (layerType != "db") + { + if (xmlLayerNode.Attributes["isRoad"] != null) + { + roadLayerName = layerchildName; + } + } + else if (xmlLayerNode.Attributes["isPipeLine"] != null) + { + m_PipelineLayerNames.Add(layerchildName); + g1layername.Add(layerName1); + } + else if (xmlLayerNode.Attributes["isWorkWell"] != null) + { + workwellLayerNames.Add(layerchildName); + g1layername.Add(layerName1); + } + else if (xmlLayerNode.Attributes["isValve"] != null) + { + valueLayerNames.Add(layerchildName); + g1layername.Add(layerName1); + } + else if (xmlLayerNode.Attributes["isAccess"] != null) + { + instrumenLayerNames.Add(layerchildName); + g1layername.Add(layerName1); + } + else if (xmlLayerNode.Attributes["isCharacter"] != null) + { + pipefittingLayerNames.Add(layerchildName); + g1layername.Add(layerName1); + } + else if (xmlLayerNode.Attributes["isSgData"] != null) + { + sgPipeLayersNames.Add(layerchildName); + g1layername.Add(layerName1); + } + + } + } + + private void initMarkerTree() + { + 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); + } + } + } + } + + private void MainFrm_Load(object sender, EventArgs e) + { + + this.initGlobalControl(); + this.initGlobalMap(); + this.initLayerTree(); + this.initMarkerTree(); + this.initLayout(); + this.loadData(); + + + double x = Convert.ToDouble(Utility.Query_Roads["绿岛"].ToString().Split(',')[0]); + double y = Convert.ToDouble(Utility.Query_Roads["绿岛"].ToString().Split(',')[1]); + double z = Convert.ToDouble(Utility.Query_Roads["绿岛"].ToString().Split(',')[2]); + jumpToCameraState(x, y, z); + + + } + + #endregion + + /// + /// 每次gis服务加载时都会触发的 + /// + /// + /// + 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 dictionaryNetLayerNameAndCaption = new Dictionary(); + 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 配置用户权限 + /// + /// 向数据库插入功能列表 + /// + private void insertControlToDatabase() + { + ArrayList listItem = new ArrayList(); + List subListItem = new List(); + 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) + { + GSOCameraState camera = globeControl2.Globe.CameraState; + globeControl1.Globe.JumpToCameraState(camera); + } + } + + void globeControl1_BeforeSceneRenderEvent(object sender, BeforeSceneRenderEventArgs e) + { + if (globeControl1.Focused) + { + 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); + } + } + } + + /// + /// 检查数据集是否有坐标系信息 + /// + /// + /// + 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 = "0prj4" + lprjStr + ""; + + bSuccess = dataset.LoadProjectionFromESRIFile(dlg.FileName); + + string lprjFileName = strDataPath.Substring(0, strDataPath.LastIndexOf(".")) + ".lprj"; + StreamWriter writer = new StreamWriter(lprjFileName, false); + writer.Write(lprjFileContent); + writer.Close(); + + } + } + } + else + { + return true; + } + return bSuccess; + } + + /// + /// 矩形拉框结束事件处理函数 + /// + /// + /// + 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))); + */ + + int mapWidth = 0; + int mapHeight = 0; + Point pt = getUpperLeftPoint(pt1, pt2, out mapWidth, out mapHeight); + int rightBottomX = pt.X + mapWidth; + int rightBottomY = pt.Y + mapHeight; + Image myImg = new Bitmap(mapWidth, mapHeight); + Graphics g = Graphics.FromImage(myImg); + g.CopyFromScreen(pt, new Point(0, 0), new Size(rightBottomX, rightBottomY)); + + 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; + } + } + /// + /// 定位正北正90度俯视 + /// + /// + /// + /// + 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; + } + } + /// + /// layerTree选中后事件处理 + /// + /// + /// + 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); + } + /// + /// 树节点选中方法 + /// + /// + 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); + } + } + } + + } + /// + /// 改变所有子节点的状态 + /// + /// + /// + 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; + LayerFlyMenuItem.Visible = true; + } + + LayerSelectableMenuItem.Visible = true; + LayerEditableMenuItem.Visible = true; + SaveLayerMenuItem.Visible = true; + LayerFlyMenuItem.Visible = true; + 导出CADToolStripMenuItem1.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]); + if (layer != null) + { + LayerSelectableMenuItem.Checked = layer.Selectable; + LayerEditableMenuItem.Checked = layer.Editable; + } + else + { + return; + } + } + 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; + } + } + } + } + } + + /// + /// 删除临时添加的本地数据图层 + /// + /// + /// + 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); + for (int i = globeControl1.Globe.Layers.Count-1; i >=0; i--) + { + if (globeControl1.Globe.Layers[i].Caption == layer.Caption) + { + globeControl1.Globe.Layers.Remove(globeControl1.Globe.Layers[i]); + } + } + + 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 定位ToolStripMenuItem_Click(object sender, EventArgs e) + { + TreeNode node = layerTree.SelectedNode; + + if (node != null) + { + if (node.Parent.Text.Trim() == "临时图层") + { + GSOLayer lsLayer = globeControl1.Globe.Layers.GetLayerByCaption(node.Text.ToString()); + double x = lsLayer.LatLonBounds.Center.X; + double y = lsLayer.LatLonBounds.Center.Y; + if (x == 0 && y == 0) + { + x = lsLayer.Bounds.Center.X; + y = lsLayer.Bounds.Center.Y; + } + + globeControl1.Globe.FlyToPosition(new GSOPoint3d(x, y, 10), EnumAltitudeMode.Absolute); + } + else + { + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(node.Tag.ToString().Split('|')[1]); + + if (layer != null) + { + if (layer.Caption == "红线") + { + globeControl1.Globe.FlyToPosition(new GSOPoint3d(120.610963, 31.188121, 50), EnumAltitudeMode.Absolute, -4, 50, 1000); + globeControl1.Globe.FlyToPointSpeed = 10000000; + globeControl1.Globe.Action = EnumAction3D.SelectObject; + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = true; + } + globeControl1.Refresh(); + } + else + { + double x = layer.LatLonBounds.Center.X; + double y = layer.LatLonBounds.Center.Y; + globeControl1.Globe.FlyToPosition(new GSOPoint3d(x, y, 100), EnumAltitudeMode.Absolute); + } + } + } + } + else + { + return; + } + + } + + private void layerTree_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e) + { + if(this.layerTree.SelectedNode!=null) + { + if (this.layerTree.SelectedNode.Tag.ToString().Contains("|")) + { + string nodeTag = this.layerTree.SelectedNode.Tag.ToString().Split('|')[1]; + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(nodeTag); + if (layer != null) + { + if (layer.Caption == "红线") + { + globeControl1.Globe.FlyToPosition(new GSOPoint3d(120.610963, 31.188121, 50), EnumAltitudeMode.Absolute, -4, 50, 1000); + globeControl1.Globe.FlyToPointSpeed = 10000000; + globeControl1.Globe.Action = EnumAction3D.SelectObject; + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = true; + } + globeControl1.Refresh(); + } + else { + double x = layer.LatLonBounds.Center.X; + double y = layer.LatLonBounds.Center.Y; + globeControl1.Globe.FlyToPosition(new GSOPoint3d(x, y, 0), EnumAltitudeMode.Absolute); + } + } + } + if (this.layerTree.SelectedNode.Tag is GSOLayer) + { + GSOLayer layer = this.layerTree.SelectedNode.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 (this.layerTree.SelectedNode.Tag is GSOFeature) + { + GSOFeature feature = this.layerTree.SelectedNode.Tag as GSOFeature; + if (feature.Geometry != null) + { + globeControl1.Globe.FlyToPosition(feature.Geometry.GeoCenterPoint, EnumAltitudeMode.Absolute, 0, 0, 10); + } + else + { + globeControl1.Globe.FlyToFeature(feature); + } + } + } + } + + /// + /// 在三维场景移动时,隐藏气泡globeControl1 + /// + /// + /// + void globeControl1_CameraBeginMoveEvent(object sender, CameraBeginMoveEventArgs e) + { + if (featureTooltip.IsVisible()) + { + featureTooltip.HideBalloon(); + } + if (balloonEx.IsVisible()) + { + balloonEx.HideBalloon(); + } + } + + /// + /// 在三维场景移动时,隐藏气泡globeControl2 + /// + /// + /// + void globeControl2_CameraBeginMoveEvent(object sender, CameraBeginMoveEventArgs e) + { + if (featureTooltip2.IsVisible()) + { + featureTooltip2.HideBalloon(); + } + if (balloonEx2.IsVisible()) + { + balloonEx2.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(); + } + } + + #region Fan 横断面 + /// + /// 横断面分析、基线剖面分析、道路断面分析等 + /// + /// + /// + private static EnumTrackPolylineEndMode trackPolylineEndMode; + + void globeControl1_TrackPolylineEndEvent(object sender, TrackPolylineEndEventArgs e) + { + //横断面分析、道路横断面分析 + if (trackPolylineEndMode == EnumTrackPolylineEndMode.HDM_Analysis|| + trackPolylineEndMode == EnumTrackPolylineEndMode.DLDM_Analysis) + { + Dictionary hdmDic = SectionAnalysisTool.HDMAnalysis(this.globeControl1, + e.Polyline, this.m_PipelineLayerNames); + FrmHDMAnalysis3 frm = new FrmHDMAnalysis3(hdmDic, this.globeControl1, + trackPolylineEndMode); + frm.Show(this); + } + //基线剖面分析 + else if (trackPolylineEndMode == EnumTrackPolylineEndMode.JXPM_Analysis) + { + FrmBaseLineProfillAnalysis dlg = new FrmBaseLineProfillAnalysis(globeControl1.Globe, e.Polyline); + dlg.Show(this); + globeControl1.Globe.ClearLastTrackPolyline(); + /* + FrmRoadHDM f = new FrmRoadHDM(); + f.Show() + * **/ + } + else + { + + } + trackPolylineEndMode = EnumTrackPolylineEndMode.Default_Analysis; + /* + ArrayList arraylistPoint = new ArrayList(); + ArrayList arraylistLine = new ArrayList(); + + // globeControl1.Globe.ClearLastTrackPolyline(); + + if (e.Polyline != null) + { + //横断面分析 + if (buttonItemFX2_1.Checked || buttonItemFX2_3.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 (buttonItemFX2_1.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 (buttonItemFX2_4.Checked) + { + FrmBaseLineProfillAnalysis dlg = new FrmBaseLineProfillAnalysis(globeControl1.Globe, e.Polyline); + dlg.Show(this); + globeControl1.Globe.ClearLastTrackPolyline(); + } + else if (buttonItemFX4_3.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(); + * **/ + } + #endregion + + private GSOFeatures PolygonIntersectAnalysis(GSOGeoPolygon3D polygon, string pipelinetype) + { + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(pipelinetype); + 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(pipelinetype, feats.Length); + return feats; + } + /// + /// 根据范围统计阀门、管线、工井等, 开挖分析, 挖方量分析 + /// + /// + /// + void globeControl1_TrackPolygonEndEvent(object sender, TrackPolygonEndEventArgs e) + { + if (globeControl1.Globe.Action == EnumAction3D.TrackPolygon && e.Polygon != null) + { + GSOGeoPolygon3D polygon = e.Polygon; + + switch (trackflag) + { + case "valvequery": + //workWellLen.Clear(); + //List list = new List(); + ////找到所有阀门 + //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, globeControl1, new DataGridViewDelegate(InitDataGridViewX1)); + FrmValveStatistics frm = new FrmValveStatistics(globeControl1,polygon, new DataGridViewDelegate(InitDataGridViewX1)); + frm.Show(this); + //panelEx6.Visible = true; + toolStripFeatureLength.Text = ""; + globeControl1.Globe.Action = EnumAction3D.ActionNull; + break; + + case "PipelineDistanceStatistics": + //pipeLineDis.Clear(); + //List list1 = new List(); + //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, globeControl1, new DataGridViewDelegate(InitDataGridViewX1)); + FrmAllPipelineStatis frm1 = new FrmAllPipelineStatis(globeControl1, polygon, new DataGridViewDelegate(InitDataGridViewX1), m_PipelineLayerNames); + frm1.Show(this); + globeControl1.Globe.Action = EnumAction3D.ActionNull; + + break; + case "PipelineSpatialQuery": + //pipeLineDis.Clear(); + //List list2 = new List(); + //for (int i = 0; i < m_PipelineLayerNames.Count; i++) + //{ + // GSOFeatures fs = Intersects_Pipeline(polygon, m_PipelineLayerNames[i]); + // if (fs != null) + // { + // list2.Add(fs); + // } + //} + + //FrmAllPipelineStatis.ShowForm(1, pipeLineDis, list2, globeControl1, new DataGridViewDelegate(InitDataGridViewX1)); + FrmAllPipelineStatis.ShowForm(globeControl1,polygon,new DataGridViewDelegate(InitDataGridViewX1),m_PipelineLayerNames); + globeControl1.Globe.ClearAnalysis(); + globeControl1.Globe.Action = EnumAction3D.ActionNull; + + break; + case "workwellquery": + //workWellLen.Clear(); + //List listWell = new List(); + ////找到所有井 + //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(polygon, dataGridViewX1, toolStripNumbers, globeControl1, panelOfTable); + FrmAllWorkWellStatis frmWell = new FrmAllWorkWellStatis(globeControl1, polygon, new DataGridViewDelegate(InitDataGridViewX1)); + 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 "BSQDuoBianXiangStatis": + + GSOFeature f2 = new GSOFeature(); + f2.Geometry = e.Polygon; + f2.Geometry.AltitudeMode = EnumAltitudeMode.Absolute; + globeControl1.Globe.MemoryLayer.AddFeature(f2); + f2.Geometry.MoveZ(3); + workWellLen.Clear(); + List listBSQ = new List(); + + GSOFeatures bsqFeatures = PolygonIntersectAnalysis(e.Polygon, "标识器"); + listBSQ.Add(bsqFeatures); + + FrmBSQDuoBianXingStatis bsqFrm = new FrmBSQDuoBianXingStatis(workWellLen, globeControl1, listBSQ); + bsqFrm.Show(this); + globeControl1.Globe.Action = EnumAction3D.ActionNull; + break; + + case "": + break; + default: + break; + } + } + } + + #region 验证端口 + /* + /// + /// 验证端口 + /// + /// + 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 + + /// + /// 鼠标悬浮提示 + /// + /// + /// + 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); + } + } + + /// + /// 添加管线绘制完成事件, 红线工具绘制完成 + /// + /// + /// + 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; + + + } + } + + /// + /// 获取globeControl1中鼠标按下的坐标供区别鼠标右键和滚轮按下事件 + /// + /// + /// + void globeControl1_MouseDown(object sender, MouseEventArgs e) + { + mouseDownX1 = e.X; + mouseDownY1 = e.Y; + } + /// + /// 获取globeControl2中鼠标按下的坐标供区别鼠标右键和滚轮按下事件 + /// + /// + /// + void globeControl2_MouseDown(object sender, MouseEventArgs e) + { + mouseDownX2 = e.X; + mouseDownY2 = e.Y; + } + /// + /// + /// + /// + /// + void globeControl2_MouseClick(object sender, MouseEventArgs e) + { + if (e.Button == MouseButtons.Right) + { + if (e.X == mouseDownX2 && e.Y == mouseDownY2) + { + RightScreenToolMenu.Show(globeControl2, e.X, e.Y); + } + else + { + return; + } + } + } + /// + /// + /// + /// + /// + void globeControl1_MouseClick(object sender, MouseEventArgs e) + { + if (e.Button == MouseButtons.Left) + { + if (globeControl1.Globe.Action == EnumAction3D.VisibilityAnalysis) + { + buttonItemFX5_1.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; + + bsqPT = pt; + + if (buttonItemLS5.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 (e.X == mouseDownX1 && e.Y == mouseDownY1) + { + toolRightMenu.Show(globeControl1, e.X, e.Y); + if (buttonItemLS5.Checked) + { + buttonItemLS5.Checked = false; + } + } + else + { + return; + } + } + globeControl1.Refresh(); + } + + /// + /// 判断网络图片是否存在 + /// + /// + /// + 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; + } + + /// + /// 鼠标点击, 弹出气泡功能globeControl1 + /// + /// + /// + void globeControl1_FeatureMouseClickEvent(object sender, FeatureMouseClickEventArgs e) + { + GSOFeature feature = e.Feature; + + string str1 = ""; + if (feature != null) + { + if (feature.GetFieldDefn("图片编码") != null)// + { + str1 = GetBubbleInfo(feature, globeControl1); + if (RemoteFileExists(Utility.PicRootURL + feature.GetValue("图片编码").ToString())) + { + str1 += ""; + } + else if (RemoteFileExists(Utility.PicDefaultURL)) + { + str1 += ""; + } + } + else if (isFeatureContainsBianhao(feature)) //管线模型图层 + { + str1 = GetBubbleInfo(feature, globeControl1); + } + + 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; + } + } + } + + /// + /// 鼠标点击, 弹出气泡功能globeControl2 + /// + /// + /// + void globeControl2_FeatureMouseClickEvent(object sender, FeatureMouseClickEventArgs e) + { + GSOFeature feature = e.Feature; + + string str1 = ""; + if (feature != null) + { + if (feature.GetFieldDefn("图片编码") != null) // + { + str1 = GetBubbleInfo(feature, globeControl2); + if (RemoteFileExists(Utility.PicRootURL + feature.GetValue("图片编码").ToString())) + { + str1 += ""; + } + else if (RemoteFileExists(Utility.PicDefaultURL)) + { + str1 += ""; + } + } + else if (isFeatureContainsBianhao(feature)) //管线模型图层 + { + str1 = GetBubbleInfo(feature, globeControl2); + } + + if (str1 != "") + { + + featureTooltip2.HideBalloon(); + balloonEx2.HideBalloon(); + balloonEx2.SetSize(EnumSizeIndexEx.CONTENT_CX, 480); + balloonEx2.SetSize(EnumSizeIndexEx.CONTENT_CY, 420); + balloonEx2.ShowBalloon((int)e.MousePos.X, (int)e.MousePos.Y, str1); + + return; + } + } + } + + /// + /// 拼接气泡表格字符串 + /// + /// + /// + private string GetBubbleInfo(GSOFeature feature,GSOGlobeControl globeControl) + { + if (feature == null) + { + return ""; + } + string str = ""; + str = ""; + 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 += ""; + + 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.get_Fields(layerName, globeControl); + } + if (queryFields != null) + { + string[] param = { "," }; + string[] fieldNames = queryFields.Split(param, StringSplitOptions.RemoveEmptyEntries); + for (int j = 0; j < fieldNames.Length; 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 (name1 == "模型路径") + { + continue; + } + 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 (field1.Type == EnumFieldType.Double) + { + double dl1 = feature.GetFieldAsDouble(j); + if (!name1.Contains("管径") && !name1.Contains("电压") && !name1.Contains("角度")) + { + name1 += "_米"; + } + value1 = dl1.ToString("0.00"); + } + 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 (name2 == "模型路径") + { + continue; + } + + 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 (field2.Type == EnumFieldType.Double) + { + double dl2 = feature.GetFieldAsDouble(j + 1); + if (!name2.Contains("管径") && !name2.Contains("电压") && !name2.Contains("角度")) + { + name2 += "_米"; + } + value2 = dl2.ToString("0.00"); + } + else + { + if (!feature.IsFieldValueNull(j + 1)) + { + value2 = feature.GetValue(j + 1).ToString(); + } + } + } + } + + j++; + } + str += ""; + } + } + str += "
" + title + " " + feature.GetFieldAsString(featureIDFieldName) + "
" + + name1 + + "
" + + value1 + + "
" + + name2 + + "
" + + value2 + "
"; + return str; + } + + string filename = Utility.filename; + List g1layername = new List(); + + /// + /// 获取目标图层 + /// + /// + 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; + } + /// + /// 添加图层 + /// + /// + /// + /// + 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 = 5000; + return templayer.Visible; + } + catch (Exception ex) + { + return false; + } + } + /// + /// 菜单上的 三维导航 工具按钮 + /// + /// + /// + private void buttonItem86_Click(object sender, EventArgs e) + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + } + + /// + /// 地上模式 菜单按钮 + /// + /// + /// + 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(); + + } + } + /// + /// 地下模式 菜单按钮 + /// + /// + /// + 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(); + } + } + /// + /// 行走模式 菜单按钮 + /// + /// + /// + 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; + } + } + /// + /// 地面透明度设置 菜单 + /// + /// + /// + private void sliderGroundTransSet1_ValueChanged(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.sliderGroundTransSet1.Text); + + globeControl1.Globe.GroundOpaque = 100 - sliderGroundTransSet1.Value; + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(roadLayerName);//("180fd"); + if (layer != null) + { + layer.Opaque = 100 - sliderGroundTransSet1.Value; + } + //if (buttonItemSPDB.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; + } + /// + /// 图例 菜单按钮 + /// + /// + /// + 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(); + } + /// + /// 快速定位 菜单按钮 + /// + /// + /// + private void buttonItem91_Click(object sender, EventArgs e) // + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItem91.Text); + FrmFlyToPosition fly = new FrmFlyToPosition(globeControl1); + fly.Show(this); + } + /// + /// 图层管理 菜单按钮 + /// + /// + /// + 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; + + //修改图层管理与标注管理、覆土审查、水平净距分析、垂直净距分析和碰撞分析控件之间的逻辑关系 + controlContainerItem5.Visible = false; + sideBar1.Visible = false; + sideBarPanelItem4.Visible = false; + panel3.Visible = false; + sideBar1.ExpandedPanel = sideBarPanelItem3; + buttonItemBZ11.Checked = false; + + //20160624 + /* + if (sideBarPanelItem4.Visible == true) + { + sideBar1.Visible = true; + controlContainerItem5.Visible = true; + } + else + { + sideBar1.Visible = false; + } + */ + Refresh(); + + } + } + /// + /// 全屏显示 菜单按钮 + /// + /// + /// + 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; + /// + /// 全屏显示功能实现 + /// + 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(); + } + } + + /// + /// 设置窗体宽、高 + /// + /// + /// + private void SetFullScreen(int width, int height) + { + this.Width = width; + this.Height = height; + } + + /// + /// 全屏功能的快捷键F5 + /// + /// + /// + 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); + } + } + /* + /// + /// 输出地图 + /// + /// + /// + /// + 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; + } + * */ + + private Point getUpperLeftPoint(Point p1, Point p2, out int mapWidth, out int mapHeight) // + { + Rectangle rc = new Rectangle(); + + p1 = this.globeControl1.PointToScreen(p1); + p2 = this.globeControl1.PointToScreen(p2); + + int x = Screen.PrimaryScreen.Bounds.X; + int y = Screen.PrimaryScreen.Bounds.Y; + int screenWidth = SystemInformation.WorkingArea.Width; + int screenHeight = SystemInformation.WorkingArea.Height; + + if (p1.X < x) + rc.X = x; + else + rc.X = p1.X; + + if (p1.Y < y) + rc.Y = y; + else + rc.Y = p1.Y; + + p1.X = rc.Left; + p1.Y = rc.Top; + + if (p2.X > screenWidth) + p2.X = screenWidth; + else + p2.X = p2.X; + + if (p2.Y > screenHeight) + p2.Y = screenHeight; + else + p2.Y = p2.Y; + + rc.Width = p2.X - rc.X; + rc.Height = p2.Y - rc.Y; + + mapWidth = rc.Width; + mapHeight = rc.Height; + Point pt = new Point(rc.Left, rc.Top); + return pt; + } + + Image printImage; + /// + /// 打印 菜单 + /// + /// + /// + 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))); + */ + int mapWidth = 0; + int mapHeight = 0; + Point pt = getUpperLeftPoint(pt1, pt2, out mapWidth, out mapHeight); + int rightBottomX = pt.X + mapWidth; + int rightBottomY = pt.Y + mapHeight; + Image myImg = new Bitmap(mapWidth, mapHeight); + Graphics g = Graphics.FromImage(myImg); + g.CopyFromScreen(pt, new Point(0, 0), new Size(rightBottomX, rightBottomY)); + + + 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); + } + /// + /// 输出地图 菜单 + /// + /// + /// + private void btnOutputJPG_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btnOutputJPG.Text); + + //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))); + */ + int mapWidth = 0; + int mapHeight = 0; + Point pt = getUpperLeftPoint(pt1, pt2, out mapWidth, out mapHeight); + int rightBottomX = pt.X + mapWidth; + int rightBottomY = pt.Y + mapHeight; + Image myImg = new Bitmap(mapWidth, mapHeight); + Graphics g = Graphics.FromImage(myImg); + g.CopyFromScreen(pt, new Point(0, 0), new Size(rightBottomX, rightBottomY)); + + 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; + } + } + } + + /// + /// 在窗体的底部状态栏上显示 综合管线条件查询结果 + /// + /// + /// + 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 + " 条记录 | "; + } + } + + /// + /// 统计管线的里程数 + /// + /// + /// + /// + 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; + } + + /// + /// 窗体下方属性表格 右键菜单中的 “定位”菜单 + /// + /// + /// + 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); + + } + + /// + /// 表格中右键 “单个闪烁” 菜单 + /// + /// + /// + private void LightMenu_Click(object sender, EventArgs e) + { + flashflag = "single"; + timer1.Start(); + } + /// + /// 表格中右键 “全部闪烁” 菜单 + /// + /// + /// + private void AllLightMenuItem_Click(object sender, EventArgs e) + { + flashflag = "all"; + timer1.Start(); + } + + /// + /// 使用timer实现管线的闪烁效果 + /// + /// + /// + 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; + } + } + + /// + /// 绘制线 菜单 + /// + /// + /// + private void btnAddLine_Click(object sender, EventArgs e) + { + globeControl1.Globe.DestLayerFeatureAdd = globeControl1.Globe.MemoryLayer; + globeControl1.Globe.Action = EnumAction3D.DrawPolyline; + } + /// + /// 绘制面 菜单 + /// + /// + /// + private void btnAddPolygon_Click(object sender, EventArgs e) + { + globeControl1.Globe.DestLayerFeatureAdd = globeControl1.Globe.MemoryLayer; + globeControl1.Globe.Action = EnumAction3D.DrawPolygon; + } + /// + /// 图层目录树 右键菜单中的 目标图层 菜单 + /// + /// + /// + 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; + } + } + /// + /// 图层目录树 右键菜单中的 可选择 菜单 + /// + /// + /// + 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; + } + /// + /// 图层目录树 右键菜单中的 可编辑 菜单 + /// + /// + /// + 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; + } + /// + /// 图层目录树 右键菜单中的 保存 菜单 + /// + /// + /// + 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(); + } + + /// + /// 根据多边形范围统计管线的里程 + /// + /// + /// + /// 返回查询到的管线要素集合 + 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 pipeLineDis = new Dictionary(); + Dictionary workWellLen = new Dictionary(); + + + + + /// + /// 查找指定图层中在 指定范围内的feature对象集合 + /// + /// + /// + /// + 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; + } + /// + /// 清除结果 菜单 + /// + /// + /// + private void buttonItem47_Click(object sender, EventArgs e) + { + globeControl1.Globe.ClearAnalysis(); + dataGridViewX1.DataSource = null; + panelOfTable.Visible = false; + clearFeatureHighLight(); + } + /// + /// 设置菜单的选中状态 + /// + private void ActionToolMenuChecked() + { + if (globeControl1.Globe.Action != EnumAction3D.TrackPolyline) + { + buttonItemFX2_1.Checked = false; + buttonItemFX2_4.Checked = false; + buttonItemFX2_3.Checked = false; + buttonItemFX4_3.Checked = false; + } + if (globeControl1.Globe.Action != EnumAction3D.NormalHit) + { + buttonItemFX3_6.Checked = false; + // ClearConnexityAnalysis(); + + buttonItemFX3_5.Checked = false; + // ClearCloseValvesAnalysis(); + } + if (globeControl1.Globe.Action != EnumAction3D.TrackPolygon) + { + buttonItemFX4_2.Checked = false; + buttonItemFX4_1.Checked = false; + } + } + + /// + /// 主窗体关闭事件处理 + /// + /// + /// + private void MainFrm_FormClosing(object sender, FormClosingEventArgs e) + { + + if (MessageBox.Show("是否退出系统?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) + { + e.Cancel = true; + } + else { + globeControl1.Globe.MemoryLayer.SaveAs(Application.StartupPath + "/MyPlace.kml"); + } + + //saveLayerList(layerManagerNode.Nodes); + //注销id号为103的热键设定 + // UnregisterHotKey(Handle, 103); + } + + /// + /// 显示流向 功能 + /// + /// + /// + /// + 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(); + } + + FrmCloseValves frm; + + FrmBoosterValvers frmbooster = null; + + /// + /// 垂直净距分析 功能界面中的 选择图层复选框 选中状态改变事件处理 + /// + /// + /// + 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(); + } + /// + /// 水平净距分析 功能界面中的 选择图层复选框 选中状态改变事件处理 + /// + /// + /// + 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(); + } + /// + /// 垂直净距分析 功能界面中的 选择管线复选框 选中状态改变事件处理 + /// + /// + /// + private void checkBoxX1_CheckedChanged(object sender, EventArgs e) + { + clearFeatureHighLight(); + if (checkBoxX1.Checked) + { + comboBoxEx1.SelectedItem = null; + 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; + } + } + /// + /// 水平净距分析 功能界面中的 选择管线复选框 选中状态改变事件处理 + /// + /// + /// + private void checkBoxX1_CheckedChanged_shuiping(object sender, EventArgs e) + { + clearFeatureHighLight();//清除高亮 + if (checkBoxX7.Checked) + { + comboBoxEx4.SelectedItem = null; + 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(); + /// + /// 垂直净距分析 功能界面中的 选择图层下拉框 选中项改变 事件处理 + /// + /// + /// + 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; + } + } + } + /// + /// 水平净距分析 功能界面中的 选择图层下拉框 选中项改变 事件处理 + /// + /// + /// + 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 featCount = new Dictionary(); + Dictionary featLenth = new Dictionary(); + Dictionary m_FeaturesWithBianhao = new Dictionary();//记录编号和对应的标注点的位置 + GSOFeatures polygonJingJuAnalysises = new GSOFeatures(); + + /// + /// 垂直净距分析 功能界面中的 开始分析按钮 事件处理 + /// + /// + /// + 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; + } + + /// + /// 在指定的两点组成的线的中间添加一个marker对象,并将marker对象添加到指定的图层中 + /// + /// + /// + /// + /// + /// + 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; + } + + /// + /// 计算指定feature对象与除了该feature所在图层之外的 所有管线图层中的所有feature对象 的垂直距离 并在表格中记录符合要求的管线 + /// + /// + /// + /// + /// + private void VerticalDistanceAnalysis(string type, GSOFeature selectedFeature, List _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(); + } + /// + /// 垂直净距分析中 表格行的 双击定位 功能。 与覆土分析的实现方法不同,主要原因是需要标注垂距 + /// + /// + /// + 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); + } + } + } + } + + /// + /// 水平净距分析 功能界面中 开始分析按钮 的事件处理 + /// + /// + /// + 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; + } + + + /// + /// 计算指定feature对象与除了该feature所在图层之外的 所有管线图层中的所有feature对象 的水平距离 并记录符合要求的管线 功能 + /// + /// + /// + /// + /// + private void HorizontalDistanceAnalysis(GSOFeature selectedFeature, List _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)); + } + } + } + } + } + /// + /// 水平净距分析 功能界面中 表格的 双击定位 功能 + /// + /// + /// + 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); + } + } + } + } + } + /// + /// 碰撞分析 功能界面中 开始分析按钮 事件处理 + /// + /// + /// + 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; + } + /// + /// 碰撞分析功能界面中 表格的 双击定位 功能 + /// + /// + /// + 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); + } + } + } + } + + + + /// + /// 覆土分析功能操作界面中的 选择管线 复选框选中状态改变事件处理 + /// + /// + /// + private void checkBoxX5_CheckedChanged(object sender, EventArgs e) + { + clearFeatureHighLight(); + if (checkBoxX5.Checked) + { + comboBoxEx3.SelectedItem = null; + 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; + } + } + /// + /// 覆土分析功能操作界面中的 选择图层 复选框选中状态改变事件处理 + /// + /// + /// + 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(); + } + /// + /// 覆土分析功能操作界面中的 图层下拉框选中项改变事件处理 + /// + /// + /// + 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; + } + } + } + /// + /// 覆土分析功能操作界面中的 开始分析 按钮事件处理 + /// + /// + /// + 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; + + + GSOPoint3d markerPosition = new GSOPoint3d(); + 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]; + GSOPoint3d pt = new GSOPoint3d(); + + 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"); + + pt.X = pts[m].X; + pt.Y = pts[m].Y; + pt.Z = 0; + markerPosition = LabelVerticalDistance(layerTemp, pts[m], pt, Convert.ToDouble(dataGridViewX7.Rows[idx].Cells[2].Value), true); + 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]; + GSOPoint3d pt = new GSOPoint3d(); + 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"); + + pt.X = pts[m].X; + pt.Y = pts[m].Y; + pt.Z = 0; + markerPosition = LabelVerticalDistance(layerTemp, pts[m], pt, Convert.ToDouble(dataGridViewX7.Rows[idx].Cells[2].Value), true); + + 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; + } + + /// + /// 覆土分析中 表格的 双击定位 功能 + /// + /// + /// + 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); + } + } + } + } + } + /// + /// 覆土分析功能操作界面中的 导出Excel按钮 事件处理 + /// + /// + /// + private void buttonX10_Click(object sender, EventArgs e) + { + if (dataGridViewX7.Rows.Count > 0) + { + ExportExcel("覆土分析", dataGridViewX7, null); + } + else + { + MessageBox.Show("表格内容为空!", "提示"); + } + } + /// + /// 覆土分析功能操作界面底部的 关闭 按钮事件处理 + /// + /// + /// + 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(); + layerTemp.RemoveAllFeature(); + + if (buttonItem1.Checked) + { + sideBar1.ExpandedPanel = sideBarPanelItem3; + } + else + { + sideBar1.Visible = false; + } + globeControl1.Refresh(); + + //Refresh(); + } + + + /// + /// 垂直净距分析 功能界面中 清除分析结果按钮 事件处理 + /// + /// + /// + 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(); + } + /// + /// 水平净距分析 功能界面中 清除分析结果按钮 事件处理 + /// + /// + /// + 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(); + } + + /// + /// 垂直净距分析功能界面中 关闭按钮 事件处理 + /// + /// + /// + 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(); + } + /// + /// 水平净距分析功能界面中 删除缓冲区按钮 事件处理 + /// + /// + /// + private void buttonX14_Click(object sender, EventArgs e) + { + 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(); + } + + /// + /// 导出指定DataGridView控件中的内容 + /// + /// + /// + 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(); + } + } + } + } + + /// + /// 垂直净距分析功能界面中 导出Excel按钮 事件处理 + /// + /// + /// + private void buttonX4_Click(object sender, EventArgs e) + { + if (dataGridViewX3.Rows.Count > 0) + { + ExportExcel("垂直净距分析", dataGridViewX3, listBox1); + } + else + { + MessageBox.Show("表格内容为空!", "提示"); + } + } + /// + /// 水平净距分析功能界面中 导出Excel按钮 事件处理 + /// + /// + /// + private void buttonX4_Click_shuiping(object sender, EventArgs e) + { + if (dataGridViewX9.Rows.Count > 0) + { + ExportExcel("水平净距分析", dataGridViewX9, listBox3); + } + else + { + MessageBox.Show("表格内容为空!", "提示"); + } + } + + + /// + /// 清除所有坑 菜单 + /// + /// + /// + private void buttonItem3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItem3.Text); + + globeControl1.Globe.RemoveAllPits(); + } + + //} + /// + /// 大气层 菜单 + /// + /// + /// + private void buttonItem17_Click_1(object sender, EventArgs e) + { + globeControl1.Globe.Atmosphere.Visible = !globeControl1.Globe.Atmosphere.Visible; + buttonItemSH1.Checked = globeControl1.Globe.Atmosphere.Visible; + globeControl1.Refresh(); + } + /// + /// 经纬网 菜单 + /// + /// + /// + private void buttonItem20_Click(object sender, EventArgs e) + { + globeControl1.Globe.LatLonGrid.Visible = !globeControl1.Globe.LatLonGrid.Visible; + buttonItemSH3.Checked = globeControl1.Globe.LatLonGrid.Visible; + globeControl1.Globe.Refresh(); + } + /// + /// 状态条 菜单 + /// + /// + /// + private void buttonItem21_Click_1(object sender, EventArgs e) + { + globeControl1.Globe.StatusBar.Visible = !globeControl1.Globe.StatusBar.Visible; + buttonItemSH4.Checked = globeControl1.Globe.StatusBar.Visible; + globeControl1.Globe.Refresh(); + } + + + + /// + /// 添加指定路径下的数据 功能 + /// + /// + /// + 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); + //CheckDatasetGeoReference(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; + } + return objRes; + } + /// + /// 刷新目录树 功能 + /// + 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); + } + } + /// + /// 判断图层是否包含字段列表 + /// + /// + /// + 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; + } + + /// + /// 统计指定图层在指定范围内的所有feature对象 + /// + /// + /// + /// + 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; + } + /// + /// 碰撞分析功能界面中 选择管线复选框 选中状态改变事件处理 + /// + /// + /// + private void checkBoxX3_CheckedChanged(object sender, EventArgs e) + { + clearFeatureHighLight(); + if (checkBoxX3.Checked) + { + comboBoxEx2.SelectedItem = null; + 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; + } + } + /// + /// 碰撞分析功能界面中 选择图层复选框 选中状态改变事件处理 + /// + /// + /// + 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(); + } + /// + /// 碰撞分析功能界面中 选择图层下拉框 选中项改变事件处理 + /// + /// + /// + 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; + } + } + } + /// + /// 清除所有图层中的所有feature对象的高亮状态 功能 + /// + 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); + } + } + } + } + for (int i = 0; i < globeControl2.Globe.Layers.Count; i++) + { + GSOLayer layer = globeControl2.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; + } + } + } + + if (globeControl1.Globe.Action == EnumAction3D.SelectObject) + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + //globeControl1.Globe.Action = EnumAction3D.SelectObject; + } + } + + /// + /// 碰撞分析功能界面中 清除分析结果按钮 事件处理 + /// + /// + /// + 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(); + } + /// + /// 碰撞分析功能界面中 导出Excel按钮 事件处理 + /// + /// + /// + private void buttonX6_Click(object sender, EventArgs e) + { + if (dataGridViewX5.Rows.Count > 0) + { + ExportExcel("碰撞分析", dataGridViewX5, listBox2); + } + else + { + MessageBox.Show("表格内容为空!", "提示"); + } + } + /// + /// 导出CAD 菜单 + /// + /// + /// + private void btnExportCAD_Click(object sender, EventArgs e) + { + FrmExportCADS frm = new FrmExportCADS(globeControl1, m_PipelineLayerNames); + frm.ShowDialog(); + } + + ///// + ///// 区域分析 菜单 + ///// + ///// + ///// + //private void buttonItem50_Click(object sender, EventArgs e) + //{ + // buttonItem50.Checked = !buttonItem50.Checked; + // ribbonBarQY.Visible = buttonItem50.Checked; + // ribbonBarQY.Location = new Point(0, 0); + //} + + + /// + /// 连接数据库 菜单事件处理 + /// + /// + /// + 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; + } + } + } + /// + /// 数据验证 菜单 + /// + /// + /// + private void buttonItem80_Click(object sender, EventArgs e) + { + FrmValiData frm = new FrmValiData(globeControl1); + frm.ShowDialog(); + } + /// + /// 根据指定图层创建图层节点并将节点添加到图层管理节点的子节点集合中 + /// + /// + 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; + + if (!layerManagerNode.Nodes.Contains(node)) + { + layerManagerNode.Nodes.Insert(0, node); + layerManagerNode.Expand(); + } + } + } + /// + /// 数据库备份 菜单 + /// + /// + /// + 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(); + } + } + } + + + + #region Fan 去掉 + //GSOFeature emitterFeature; // 粒子要素 + /// + /// 添加火苗 功能 + /// + /// + /// + /// + 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); + + } + /// + /// 添加喷泉 功能 + /// + /// + /// + /// + 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); + } + #endregion + + /// + /// 获取指定图层中最后一个feature对象的名称对应的整数 + /// + /// + /// + 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; + } + /// + /// 设置除指定标注图层之外的所有标注图层不可见 + /// + /// + 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; + } + } + } + } + } + + /// + /// 判断选中的对象是否为管线 + /// + /// 被选中管线 + /// 返回一根线 + 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; + } + + /// + /// 创建label要素 功能 + /// + /// 添加label要素的feature + /// feature的位置 + /// label要素名字 + /// feature名字 + /// label要素距离点的位置 + /// + 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; + } + + + + /// + /// 获取指定两点组成的线的长度 功能 + /// + /// + /// + /// + 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; + } + + /// + /// 图层节点树中 节点 右键单击事件处理 + /// + /// + /// + 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; + } + } + } + } + } + + /// + /// 标注管理、传感器管理 图层目录树的右键菜单中的 刷新列表 菜单 + /// + /// + /// + 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); + } + } + /// + /// 给指定的图层节点添加代表feature对象的子节点 + /// + /// + private void RefreshTreeNodeLayerFeatureList(TreeNode layerTreeNode) + { + layerTreeNode.Nodes.Clear(); + GSOLayer layer = (GSOLayer)layerTreeNode.Tag; + // 只将类型为内存数据集的图层列出,如果是其它类型的数据集可能数据量太大,没发显示在树控件中 + if (layer.Dataset is GSOFeatureDataset) + { + VisitFeature3Ds(layer.GetAllFeatures(), layerTreeNode); + } + } + + /// + /// 标注管理、传感器管理 图层目录树的右键菜单中的 移除所有 菜单 + /// + /// + /// + 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(); + } + } + + /// + /// 图层目录树的 节点对应的复选框选中状态改变事件处理 + /// + /// + /// + private void layerMarkerTree_AfterCheck(object sender, TreeViewEventArgs e) + { + if (e.Action != TreeViewAction.Unknown) + { + CheckTreeNode(e.Node, e.Node.Checked); + } + } + /// + /// 改变指定节点对应的复选框的选中状态 + /// + /// + /// + private void CheckTreeNode(TreeNode node, Boolean bChecked) + { + CheckChildTreeNode(node, bChecked); + globeControl1.Globe.Refresh(); + } + /// + /// 改变指定节点的子节点对应的复选框的选中状态 + /// + /// + /// + 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); + } + } + /// + /// 标注管理、传感器管理 目录树中的feature节点的右键菜单中的 删除 菜单 + /// + /// + /// + 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(); + } + } + + /// + /// 双屏对比 菜单 + /// + /// + /// + //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(); + // } + //} + /// + /// 模拟分析 菜单 + /// + /// + /// + //private void buttonItem51_Click(object sender, EventArgs e) + //{ + // buttonItem51.Checked = !buttonItem51.Checked; + // ribbonBarMN.Visible = buttonItem51.Checked; + // ribbonBarMN.Location = new Point(0, 0); + //} + + /// + /// 双屏设置 菜单 + /// + /// + /// + //private void buttonItem96_Click(object sender, EventArgs e) + //{ + // FrmLayerControl frm = new FrmLayerControl(layerTree,globeControl1,globeControl2); + // frm.Show(this); + //} + /// + /// 双屏联动 菜单 + /// + /// + /// + //private void buttonItem95_Click(object sender, EventArgs e) + //{ + // buttonItem95.Checked = !buttonItem95.Checked; + //} + ///// + /// 添加用户仓库 菜单 + /// + /// + /// + private void buttonItem108_Click(object sender, EventArgs e) + { + FrmUserRepo frm = new FrmUserRepo(-1); + frm.ShowDialog(); + } + /// + /// 用户仓库管理 菜单 + /// + /// + /// + private void buttonItem111_Click(object sender, EventArgs e) + { + FrmUserRepoMgr frm = new FrmUserRepoMgr(); + frm.ShowDialog(); + } + /// + /// 添加分系统 菜单 + /// + /// + /// + private void buttonItem112_Click(object sender, EventArgs e) + { + //FrmAPP frm = new FrmAPP(-1); + //frm.ShowDialog(); + } + /// + /// 分系统管理 菜单 + /// + /// + /// + private void buttonItem113_Click(object sender, EventArgs e) + { + //FrmAPPMgr frm = new FrmAPPMgr(); + //frm.ShowDialog(); + } + /// + /// 添加操作 菜单 + /// + /// + /// + private void buttonItem114_Click(object sender, EventArgs e) + { + FrmOper frm = new FrmOper(-1); + frm.ShowDialog(); + } + /// + /// 操作管理 菜单 + /// + /// + /// + private void buttonItem115_Click(object sender, EventArgs e) + { + FrmOperMgr frm = new FrmOperMgr(); + frm.ShowDialog(); + } + /// + /// 添加资源 菜单 + /// + /// + /// + private void buttonItem116_Click(object sender, EventArgs e) + { + FrmRESC frm = new FrmRESC(-1); + frm.ShowDialog(); + } + /// + /// 资源管理 菜单 + /// + /// + /// + private void buttonItem117_Click(object sender, EventArgs e) + { + FrmRESCMgr frm = new FrmRESCMgr(); + frm.ShowDialog(); + } + /// + /// 添加权限 菜单 + /// + /// + /// + private void buttonItem118_Click(object sender, EventArgs e) + { + FrmPerm frm = new FrmPerm(-1); + frm.ShowDialog(); + } + /// + /// 权限管理 菜单 + /// + /// + /// + private void buttonItem119_Click(object sender, EventArgs e) + { + FrmPermMgr frm = new FrmPermMgr(); + frm.ShowDialog(); + } + /// + /// 添加访问控制 菜单 + /// + /// + /// + private void buttonItem120_Click(object sender, EventArgs e) + { + FrmAccess frm = new FrmAccess(-1); + frm.ShowDialog(); + } + /// + /// 访问控制管理 菜单 + /// + /// + /// + private void buttonItem121_Click(object sender, EventArgs e) + { + FrmAccessMgr frm = new FrmAccessMgr(); + frm.ShowDialog(); + } + /// + /// 部门类型管理 菜单 + /// + /// + /// + private void buttonItem122_Click(object sender, EventArgs e) + { + FrmRegionTypeMgr frm = new FrmRegionTypeMgr(); + frm.ShowDialog(); + } + /// + /// 添加用户 菜单 + /// + /// + /// + private void buttonItem127_Click(object sender, EventArgs e) + { + FrmUserAdd frm = new FrmUserAdd(-1); + frm.ShowDialog(); + } + /// + /// 用户信息管理 菜单 + /// + /// + /// + private void buttonItem128_Click_1(object sender, EventArgs e) + { + FrmUserManager frm = new FrmUserManager(); + frm.ShowDialog(); + } + /// + /// 添加角色 菜单 + /// + /// + /// + private void 添加角色_Click(object sender, EventArgs e) + { + FrmRole frm = new FrmRole(-1); + frm.ShowDialog(); + } + /// + /// 所有角色管理 菜单 + /// + /// + /// + private void 角色管理_Click(object sender, EventArgs e) + { + FrmRoleMgr frm = new FrmRoleMgr(); + frm.ShowDialog(); + } + + /// + /// 部门角色管理 菜单 + /// + /// + /// + private void buttonItem133_Click(object sender, EventArgs e) + { + FrmRegionRoleMgr frm = new FrmRegionRoleMgr(); + frm.ShowDialog(); + } + /// + /// 部门管理 菜单 + /// + /// + /// + private void buttonItem130_Click(object sender, EventArgs e) + { + FrmRegionMgr frm = new FrmRegionMgr(); + frm.ShowDialog(); + } + + /// + /// 日志管理 菜单 + /// + /// + /// + private void buttonItem135_Click(object sender, EventArgs e) + { + FrmLogManager frm = new FrmLogManager(); + frm.ShowDialog(); + } + /// + /// 传感器信息查询 菜单 + /// + /// + /// + 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); + } + } + } + /// + /// 根据指定的图层的caption属性的值在配置文件中查找对应的数据库中的表的名称 + /// + /// 图层的caption属性的值 + /// 对应的数据库中的表的名称 + 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; + } + /// + /// 根据数据库中的表的名称 查找对应的表中的字段名称的集合 + /// + /// 数据库中的表的名称 + /// 对应的表中的字段名称的集合 + 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; + } + + /// + /// 历史曲线查询 菜单 + /// + /// + /// + 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; + /// + /// 传感器在线报警 菜单 + /// + /// + /// + 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); + } + /// + /// 传感器报警 功能中的 定时器 的触发事件处理 + /// + /// + /// + 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; + } + } + } + } + } + } + } + + + /// + /// 沿线运动 菜单 + /// + /// + /// + private void buttonItem138_Click(object sender, EventArgs e) + { + if (globeControl1.Globe.SelectedObject == null) + { + MessageBox.Show("请先选择一条线!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + return; + } + + GSOFeature lineFeature = globeControl1.Globe.SelectedObject; + if (lineFeature.Geometry == null || lineFeature.Geometry.Type != EnumGeometryType.GeoPolyline3D) + { + MessageBox.Show("请先选择一条线!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + return; + } + + OpenFileDialog dlg = new OpenFileDialog(); + dlg.Filter = "*.gcm;*.3ds|*.gcm;*.3ds|*.3ds|*.3ds|*.gcm|*.gcm"; + if (dlg.ShowDialog() == DialogResult.OK) + { + GSOGeoModel model = new GSOGeoModel(); + model.FilePath = dlg.FileName; + + GSOGeoDynamicRoute dynamicRoute = new GSOGeoDynamicRoute(); + dynamicRoute.ActorGeometry = model; + + GSORoute route = new GSORoute(); + GSOGeoPolyline3D geoline = (GSOGeoPolyline3D)lineFeature.Geometry; + for (int i = 0; i < geoline[0].Count; i++) + { + route.Add(geoline[0][i]); + } + route.CircleRoute = false; + route.Speed = 30; + route.RotateSpeed = 50; + route.AltitudeMode = geoline.AltitudeMode; + dynamicRoute.Route = route; + + GSOFeature feature = new GSOFeature(); + + dynamicRoute.Play(); + feature.Geometry = dynamicRoute; + + //GSOLabel gsoLabel = new GSOLabel(); + //gsoLabel.Text = "模型测试"; + //feature.Label = gsoLabel; + globeControl1.Globe.MinModelVisibleSize = 0; + + globeControl1.Globe.MemoryLayer.AddFeature(feature); + globeControl1.Globe.Refresh(); + } + } + /// + /// 回退 菜单 + /// + /// + /// + private void buttonItem99_Click(object sender, EventArgs e) + { + globeControl1.Globe.UnDoEdit(); + } + /// + /// 前进 菜单 + /// + /// + /// + private void buttonItem100_Click(object sender, EventArgs e) + { + globeControl1.Globe.ReDoEdit(); + } + /// + /// 水平净距 功能界面中的 标签内容改变事件处理 + /// + /// + /// + 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() + "米的管线有:"; + } + } + } + /// + /// 垂直净距 功能界面中的 标签内容改变事件处理 + /// + /// + /// + 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() + "米的管线有:"; + } + } + } + /// + /// 覆土分析 功能界面中的 标签内容改变事件处理 + /// + /// + /// + 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() + "米的管线有:"; + } + } + } + + /// + /// 传感器分类查询 全区域 菜单 + /// + /// + /// + private void buttonItemSensor全区域查询_Click(object sender, EventArgs e) + { + FrmAccessoriesSensor.ShowForm(globeControl1, instrumenLayerNames, 0); + } + /// + /// 传感器分类查询 绘制区域 菜单 + /// + /// + /// + private void buttonItemSensor绘制区域查询_Click(object sender, EventArgs e) + { + FrmAccessoriesSensor.ShowForm(globeControl1, instrumenLayerNames, 1); + } + + + /// + /// 碰撞分析 功能界面中 关闭按钮 事件处理 + /// + /// + /// + 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(); + } + /// + /// 覆土分析 功能界面中的 清除分析结果 按钮事件处理 + /// + /// + /// + 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(); + } + /// + /// 数字预处理 功能 + /// + /// + /// + private void 数字预处理buttonItem140_Click(object sender, EventArgs e) + { + FrmEditShapeFile frm = new FrmEditShapeFile(globeControl1); + frm.ShowDialog(this); + } + + + /// + /// 导出矢量 功能 将图层导出为kml和shp格式数据 + /// + /// + /// + private void 导出矢量buttonItem140_Click(object sender, EventArgs e) + { + List listVectorNames = new List(); + for (int i = 0; i < m_PipelineLayerNames.Count; i++) + { + 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 = ""; + /// + /// 绘制城市七线 功能按钮 + /// + /// + /// + 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; + } + } + } + /// + /// 七线审核 功能按钮 + /// + /// + /// + private void 七线审核buttonItem141_Click(object sender, EventArgs e) + { + FrmCityServerLineAnalysis frm = new FrmCityServerLineAnalysis(globeControl1, m_PipelineLayerNames); + frm.ShowDialog(this); + } + + /// + /// 间距分析 开始分析按钮 分析绘制的七线和管线的距离是否符合标准 + /// + /// + /// + 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; + } + /// + /// 间距分析 清除分析结果 + /// + /// + /// + 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(); + } + /// + /// 间距分析 导出Excel按钮 将间距分析的结果以Excel表格的形式导出 + /// + /// + /// + private void buttonExportExcel_Click(object sender, EventArgs e) + { + if (dataGridViewAnalysisResult.Rows.Count > 0) + { + ExportExcel("间距分析", dataGridViewAnalysisResult, listBoxStasticsResult); + } + else + { + MessageBox.Show("表格内容为空!", "提示"); + } + } + /// + /// 间距分析 关闭按钮 + /// + /// + /// + 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(); + } + /// + /// 间距分析 分析结果表格双击定位 + /// + /// + /// + 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); + } + } + } + } + /// + /// 间距分析 选择管线复选框 + /// + /// + /// + private void checkBoxSelectPipeline_CheckedChanged(object sender, EventArgs e) + { + clearFeatureHighLight();//清除高亮 + if (checkBoxSelectPipeline.Checked) + { + comboBoxLayer.SelectedItem = null; + 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; + } + } + /// + /// 间距分析 选择图层复选框 + /// + /// + /// + 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(); + } + /// + /// 间距分析 选择图层下拉框 + /// + /// + /// + 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; + } + } + } + + + + /// + /// 管线自动缩进 菜单 + /// + /// + /// + private void 管线自动缩进buttonItem140_Click(object sender, EventArgs e) + { + FrmPipelineIndented frm = new FrmPipelineIndented(globeControl1, m_PipelineLayerNames, workwellLayerNames); + 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 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); + // } + //} + + /// + /// 统计指定图层在指定范围内的所有feature对象 + /// + /// + /// + /// + 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) + { + 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 setLayerVisible(string layerName) + { + GSOLayer templayer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + if (templayer != null) + { + templayer.Visible = false; + } + globeControl1.Globe.Refresh(); + } + + /// + /// 连接数据库 + /// + /// + /// + private void buttonItem129_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL4_1.Text); + + FrmDatabaseParaSetting2 frm = new FrmDatabaseParaSetting2(globeControl1); + if (frm.ShowDialog() == DialogResult.OK) + { + ds = FrmDatabaseParaSetting2.ds; + if (ds != null) + { + ds.IsCloseSaved = false; + } + } + } + + /// + /// 一键审核---导入数据 + /// + /// + /// + private void buttonItem127_Click_2(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, "打开数据"); + + try + { + //if (shds == null) + //{ + //没连的话,直接连接审核库; //审核库配置读配置文件 + string dbIp = Utility.sgdbip; + string database = Utility.sgdbname; + string user = Utility.sgdbuser; + string pass = Utility.sgdbpwd; + /* + 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; + //} + } + catch (Exception ex) + { + LogError.PublishError(ex); + MessageBox.Show("内存过载请清理内存,并重新启动规划分析!", "提示"); + return; + } + + } + + /// + ///自动导出图片 + /// + /// + /// + private void buttonItem130_Click_1(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, "导出审核图"); + + 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))); + */ + + int mapWidth = 0; + int mapHeight = 0; + Point pt = getUpperLeftPoint(pt1, pt2, out mapWidth, out mapHeight); + int rightBottomX = pt.X + mapWidth; + int rightBottomY = pt.Y + mapHeight; + Image myImg = new Bitmap(mapWidth, mapHeight); + Graphics g = Graphics.FromImage(myImg); + g.CopyFromScreen(pt, new Point(0, 0), new Size(rightBottomX, rightBottomY)); + + 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; + } + } + } + /// + /// 一键审核功能 + ///
+ /// + /// + private void buttonItem128_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItem128.Text); + //垂直净距标准 + + frmSh = new FrmYJSHTC(globeControl1, globeControl2,layerTree); + + if (frmSh.ShowDialog() == DialogResult.OK) + { + frmWait = new FrmWait("一键审核……"); + frmWait.Location = new Point(this.Width - frmWait.Width - 10, this.Height - frmWait.Height - 50); + frmWait.Owner = this; + frmWait.Show(); + Thread thread = new Thread(new ThreadStart(doWork)); + thread.IsBackground = true; + thread.Start(); + } + } + + void doWork() + { + FrmShResult frmShResult = null; + + double dVerticalJingJuBiaoZhun = 1, dHorizontalJingJuBiaoZhun = 1; + if (frmSh.rukuLayer != null) + { + #region + this.Invoke((EventHandler)delegate + { + try + { + List managerLayerList = new List(); + for (int i = 0; i < layerManagerNode.Nodes.Count; i++) + { + managerLayerList.Add(layerManagerNode.Nodes[i].Text); + } + if (!managerLayerList.Contains(frmSh.rukuLayer.Caption)) + { + TreeNode node = new TreeNode(); + node.Tag = frmSh.rukuLayer; + node.Text = frmSh.rukuLayer.Dataset.Caption; + node.ImageIndex = 0; + node.SelectedImageIndex = 0; + node.Checked = frmSh.rukuLayer.Visible; + layerManagerNode.Nodes.Insert(0, node); + layerManagerNode.Expand(); + } + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "提示"); + } + }); + #endregion + + shlayername = frmSh.rukuLayer.Name; + globeControl1.Refresh(); + } + + if (frmShResult != null && !frmShResult.IsDisposed) + { + try + { + clearFeatureHighLight(); + ClearRedlineAnalyseResult(); + frmShResult.Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message); + } + } + + 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.analysis(); + + //MainFrm窗体显示控制,回到一键审核Tab + this.Invoke((EventHandler)delegate + { + frmShResult.Show(); + frmWait.Close(); + //将tab页恢复到一键审核 + ribbonTabItem11.Checked = true; + try + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + //zhanshi = false; + splitContainer1.Panel2Collapsed = true; + + panelOfTable.Visible = false; + legendSC.Visible = false; + legendSG.Visible = false; + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + } + catch (Exception ex) + { + MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + + }); + + boolfrmShResult = true; + } + else + { + + } + } + + + /// + /// 清除渲染结果 + /// + 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(); + } + /// + /// 已审核的图层 + /// + /// + /// + private void buttonItem132_Click_1(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItem132.Text); + + if (shds == null) + { + //没连的话,直接连接审核库; //审核库配置读配置文件 + string dbIp = Utility.sgdbip; + string database = Utility.sgdbname; + string user = Utility.sgdbuser; + string pass = Utility.sgdbpwd; + + /* + 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; + //} + + } + /// + /// 审核入库 + /// + /// + /// + private void buttonItem133_Click_1(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, "审核入库"); + FrmShRK frmShrk = new FrmShRK(globeControl1); + frmShrk.Show(); + } + /// + /// 模拟设计修改 + /// + /// + /// + private void buttonItem134_Click_1(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, "模拟设计修改"); + + 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 + { + + } + + } + + + /// + /// 绘制垂线 + /// + /// + /// + 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); + } + /// + /// 比较两个点是否是同一个点 + /// + /// + /// + /// + 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; + } + /// + /// 获得点到线的垂线距离及垂点 + /// + /// + /// + /// + /// + 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); + 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]; + } + /// + /// 获得斜率 + /// + /// + /// + /// + /// + /// + /// + 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); + } + } + /// + /// 根据默认投影参数,经纬度转xyz + /// + /// + /// + /// + 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; + } + /// + /// 根据投影参数,经纬度转xyz + /// + /// + /// + /// + /// + 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; + } + /// + /// 根据默认投影参数,xyz转经纬度 + /// + /// + /// + /// + 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; + } + /// + /// 根据投影参数,Xyz转经纬度 + /// + /// + /// + /// + /// + 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; + } + /// + /// 获得inpolygon的管线长度 + /// + /// + 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; + } + + + /// + /// 一键审核中调节透明度 + /// + /// + /// + private void sliderItem1_ValueChanged(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.sliderItem1.Text); + + globeControl1.Globe.GroundOpaque = 100 - sliderItem1.Value; + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(roadLayerName);//("180fd"); + if (layer != null) + { + layer.Opaque = 100 - sliderItem1.Value; + } + + optiValue = sliderItem1.Value; + } + /// + /// 红线审核中的透明度分析 + /// + /// + /// + private void sliderItem3_ValueChanged(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.sliderItem3.Text); + + globeControl1.Globe.GroundOpaque = 100 - sliderItem3.Value; + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(roadLayerName);//("180fd"); + if (layer != null) + { + layer.Opaque = 100 - sliderItem3.Value; + } + optiValue = sliderItem3.Value; + } + + #region yanxiaowei + //初始化DataGridViewX1控件 + public delegate void DataGridViewDelegate(DataTable dt, string strLable, string strLayer, bool initDataGrid); + /// + /// 代理函数,操作DatgridViewX1 + /// + /// + /// + public void InitDataGridViewX1(DataTable dt, string strLable, string strLayer, bool initDataGrid) + { + if (initDataGrid == true) + { + dataGridViewX1.DataSource = dt; + panelOfTable.Visible = true; + toolStripNumbers.Text = strLable; + dataGridViewX1.Tag = strLayer; + } + else + { + dataGridViewX1.DataSource = null; + dataGridViewX1.Refresh(); + panelOfTable.Visible = false; + toolStripNumbers.Text = ""; + dataGridViewX1.Tag = ""; + globeControl1.Globe.MemoryLayer.RemoveAllFeature();//清除双击产生的标注 + } + } + FrmAnalysisGuiHuaResult from; + /// + /// 主窗体下方属性表格 双击定位 功能 + /// + /// + /// + private void dataGridViewX1_MouseDoubleClick(object sender, MouseEventArgs e) + { + if (redSH == false) + { + 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 if (dataGridViewX1.Columns.Contains("标识器编号")) + { + featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["标识器编号"].Value.ToString(); + } + featureName = featureName.Trim(); + + GSOLayer layer = null; + layer = globeControl1.Globe.Layers.GetLayerByCaption(dataGridViewX1.Tag.ToString()); + + if (layer == null) return; + + GSOFeatures features = layer.GetFeatureByName(featureName, false); + if (features.Length == 0) return; + GSOFeature rowFeature = features[0]; + + ClassSearchAnalysis.AddMakerToLineFeature(globeControl1, rowFeature); + + } + } + } + else + { + if (e.Button == MouseButtons.Left) + { + if (from != null && !from.IsDisposed) + { + try + { + from.Close(); + } + catch (Exception ex) + { + LogError.PublishError(ex); + } + } + try + { + DataGridView.HitTestInfo hittestinfo = dataGridViewX1.HitTest(e.X, e.Y); + if (hittestinfo.RowIndex >= 0) + { + string layer = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["管线类型"].Value.ToString(); + string hxName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["红线编号"].Value.ToString(); + FrmAnalysisGuiHuaResult frm = new FrmAnalysisGuiHuaResult(globeControl1, lineStruct, featsList, + panelOfTable, dataGridViewX1, layer, hxName); + frm.Location = new Point(this.Width - frm.Width - 10, this.Height - frm.Height - 20); + frm.Show(this); + + from = frm; + } + } + catch (Exception ex) + { + LogError.PublishError(ex); + } + } + } + } + + /// + /// 空间查询 + /// + /// + /// + private void buttonItemSearch1_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemSearch1.Text); + + trackflag = "PipelineSpatialQuery"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; + + } + /// + /// 关键字查询 + /// + /// + /// + private void buttonItemSearch9_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch9.Text); + + FrmKeywordQuery.ShowForm(globeControl1, m_PipelineLayerNames, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 编号查询 + /// + /// + /// + private void buttonItemSearch2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch2.Text); + + FrmCodingQuery.ShowForm(globeControl1, m_PipelineLayerNames, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 坐标查询 + /// + /// + /// + private void buttonItemSearch3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch3.Text); + + FrmSetLatLonPos.ShowForm(globeControl1); + } + /// + /// 附属物查询 + /// + /// + /// + private void buttonItemSearch10_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch10.Text); + + FrmFittingQuery.ShowForm(globeControl1, instrumenLayerNames, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 管径查询 + /// + /// + /// + private void buttonItemSearch4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch4.Text); + + FrmDiameterQuery.ShowForm(globeControl1, m_PipelineLayerNames, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 材质查询 + /// + /// + /// + private void buttonItemSearch5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch5.Text); + + FrmMaterialSel.ShowForm(globeControl1, m_PipelineLayerNames, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 基本查询 + /// + /// + /// + private void buttonItemSearch6_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch6.Text); + + FrmBasicQuery.ShowForm(globeControl1, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 复合查询 + /// + /// + /// + private void buttonItemSearch7_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch7.Text); + + FrmQuerySQL.ShowForm(globeControl1, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 关联查询 + /// + /// + /// + private void buttonItemSearch8_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch8.Text); + + if (globeControl1.Globe.SelObjectCount != 1) + { + MessageBox.Show("请选中一个对象!", "提示"); + return; + } + + 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 || (feature.Geometry.Type == EnumGeometryType.GeoPolygon3D + || feature.Geometry.Type == EnumGeometryType.GeoWater)) + return; + else + { + ClassSearchAnalysis.ResultRelationAnalysis(globeControl1, feature, valueLayerNames, workwellLayerNames, + instrumenLayerNames, pipefittingLayerNames, m_PipelineLayerNames, valueAllowance); + } + } + } + #endregion + /// + /// 清除分析 + /// + /// + /// + private void buttonItemClear_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemClear.Text); + + globeControl1.Globe.ClearMeasure(); + layerTemp.RemoveAllFeature(); + layerTemp2.RemoveAllFeature(); + buttonItemLS5.Checked = false; + + dataGridViewX1.DataSource = null; + panelOfTable.Visible = false; + + 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); + + NetworkAnalysisTool.ClearAllTopAnalysis(this.globeControl1); + // 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();//清除所有坑 + + 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(); + } + } + + clearFeatureHighLight();//取消管线高亮 + + GSOLayer layerGround = globeControl1.Globe.Layers.GetLayerByCaption(roadLayerName);//("180fd"); + if (layerGround != null) + { + layerGround.Visible = true; + } + globeControl1.Refresh(); + globeControl2.Refresh(); + ClearRedlineAnalyseResult(); + globeControl1.Globe.Action = EnumAction3D.ActionNull; + } + /// + /// 管线长度全区域统计 + /// + /// + /// + private void buttonItemTJ1_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管线长度统计"); + + //pipeLineDis.Clear(); + //List list = new List(); + //for (int i = 0; i < m_PipelineLayerNames.Count; i++) + //{ + // GSOFeatures fs = Intersects_Pipeline(null, m_PipelineLayerNames[i]); + // if (fs!=null) + // list.Add(fs); + //} + + //FrmAllPipelineStatis frm = new FrmAllPipelineStatis(0, pipeLineDis, list, globeControl1, new DataGridViewDelegate(InitDataGridViewX1)); + FrmAllPipelineStatis frm = new FrmAllPipelineStatis(globeControl1,null, new DataGridViewDelegate(InitDataGridViewX1), m_PipelineLayerNames); + frm.Show(this); + + } + /// + /// 管线长度绘制区域统计 + /// + /// + /// + private void buttonItemTJ1_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管线长度统计"); + + trackflag = "PipelineDistanceStatistics"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; + } + /// + /// 阀门数量全区域统计 + /// + /// + /// + private void buttonItemTJ2_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "阀门数量统计"); + + //workWellLen.Clear(); + //List list = new List(); + ////找到所有阀门 + //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, globeControl1, new DataGridViewDelegate(InitDataGridViewX1)); + FrmValveStatistics frm = new FrmValveStatistics(globeControl1, null, new DataGridViewDelegate(InitDataGridViewX1)); + frm.Show(this); + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + } + /// + /// 阀门数量绘制区域统计 + /// + /// + /// + private void buttonItemTJ2_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "阀门数量统计"); + + trackflag = "valvequery"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; + } + /// + /// 井盖数量全区域统计 + /// + /// + /// + private void buttonItemTJ3_ALL_Click(object sender, EventArgs e) + { + //日志记录 + //LogManager.saveLog(Utility.userName, "井盖数量统计"); + + //workWellLen.Clear(); + //List list = new List(); + + //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(null, dataGridViewX1, toolStripNumbers, globeControl1, panelOfTable); + FrmAllWorkWellStatis frm = new FrmAllWorkWellStatis(globeControl1, null, new DataGridViewDelegate(InitDataGridViewX1)); + frm.Show(this); + } + /// + /// 井盖数量绘制区域统计 + /// + /// + /// + private void buttonItemTJ3_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "井盖数量统计"); + + trackflag = "workwellquery"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; + } + /// + /// 管径分段统计全区域统计 + /// + /// + /// + private void buttonItemTJ4_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管径分段统计"); + + Frmpipediameterstatis.ShowForm(globeControl1, m_PipelineLayerNames, 0); + } + /// + /// 管径分段统计绘制区域统计 + /// + /// + /// + private void buttonItemTJ4_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管径分段统计"); + + trackflag = null; + Frmpipediameterstatis.ShowForm(globeControl1, m_PipelineLayerNames, 1); + } + /// + /// 埋深分段统计全区域统计 + /// + /// + /// + private void buttonItemTJ5_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "埋深分段统计"); + FrmpipeDeepstatis.ShowForm(globeControl1, m_PipelineLayerNames, 0); + } + /// + /// 埋深分段统计绘制区域统计 + /// + /// + /// + private void buttonItemTJ5_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "埋深分段统计"); + trackflag = null; + FrmpipeDeepstatis.ShowForm(globeControl1, m_PipelineLayerNames, 1); + } + /// + /// 管径分类统计全区域统计 + /// + /// + /// + private void buttonItemTJ6_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管径分类汇总"); + + FrmpipeDiametergather.ShowForm(globeControl1, m_PipelineLayerNames, 0); + } + /// + /// 管径分类统计绘制区域统计 + /// + /// + /// + private void buttonItemTJ6_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管径分类汇总"); + + trackflag = null; + FrmpipeDiametergather.ShowForm(globeControl1, m_PipelineLayerNames, 1); + } + /// + /// 材质分类统计全区域统计 + /// + /// + /// + private void buttonItemTJ7_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "材质分类汇总"); + + FrmpipeMaterialGather.ShowForm(globeControl1, m_PipelineLayerNames, 0); + } + /// + /// 材质分类统计绘制区域统计 + /// + /// + /// + private void buttonItemTJ7_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "材质分类汇总"); + + trackflag = null; + FrmpipeMaterialGather.ShowForm(globeControl1, m_PipelineLayerNames, 1); + } + /// + /// 附属物分类统计全区域统计 + /// + /// + /// + private void buttonItemTJ8_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "附属物分类汇总"); + + FrmAccessoriesgather.ShowForm(globeControl1, instrumenLayerNames, 0); + } + /// + /// 附属物分类统计绘制区域统计 + /// + /// + /// + private void buttonItemTJ8_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "附属物分类汇总"); + + trackflag = null; + FrmAccessoriesgather.ShowForm(globeControl1, instrumenLayerNames, 1); + } + /// + /// 碰撞分析 + /// + /// + /// + private void buttonItemFX1_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_4.Text); + + this.dataGridViewX4.Size = new System.Drawing.Size(195, 120); + 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(); + } + /// + /// 覆土分析 + /// + /// + /// + private void buttonItemFX1_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX5_1.Text); + this.dataGridViewX6.Size = new System.Drawing.Size(195, 120); + 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(); + } + /// + /// 间距分析 + /// + /// + /// + private void buttonItemFX1_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX1_3.Text); + + this.dataGridViewLineList.Size = new System.Drawing.Size(185, 120); + 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(); + } + /// + /// 垂直净距分析 + /// + /// + /// + private void buttonItemFX1_4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX1_4.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(); + } + /// + /// 水平净距分析 + /// + /// + /// + private void buttonItemFX1_5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_6.Text); + this.dataGridViewX8.Size = new System.Drawing.Size(185, 120); + 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(); + } + + #region Predaotr,断面分析 + /// + /// 横断面分析 + /// + /// + /// + private void buttonItemFX2_1_Click(object sender, EventArgs e) + { + globeControl1.Globe.Action = EnumAction3D.TrackPolyline; + globeControl1.Globe.TrackPolylineTool.VerticalLineVisible = true; + globeControl1.Globe.TrackPolylineTool.TrackMode = EnumTrackMode.SpaceTrack; + trackPolylineEndMode = EnumTrackPolylineEndMode.HDM_Analysis; + + } + /// + /// 纵断面分析 + /// + /// + /// + private void buttonItemFX2_2_Click(object sender, EventArgs e) + { + if (globeControl1.Globe.SelObjectCount<1) + { + MessageBox.Show("请选择一条或者多条管线!", "提示", MessageBoxButtons.OK, + MessageBoxIcon.Information); + return; + } + 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); + } + } + List feats = SectionAnalysisTool.ZDMAnalysis(selectFeatures); + if (feats != null && feats.Count >= 1) + { + FrmProfileAnalysis frm = new FrmProfileAnalysis(globeControl1, feats); + frm.Show(this); + } + } + /// + /// 道路断面分析 + /// + /// + /// + private void buttonItemFX2_3_Click(object sender, EventArgs e) + { + globeControl1.Globe.Action = EnumAction3D.TrackPolyline; + globeControl1.Globe.TrackPolylineTool.VerticalLineVisible = true; + globeControl1.Globe.TrackPolylineTool.TrackMode = EnumTrackMode.SpaceTrack; + trackPolylineEndMode = EnumTrackPolylineEndMode.DLDM_Analysis; + + } + /// + /// 基线剖面分析 + /// + /// + /// + private void buttonItemFX2_4_Click(object sender, EventArgs e) + { + globeControl1.Globe.Action = EnumAction3D.TrackPolyline; + globeControl1.Globe.TrackPolylineTool.VerticalLineVisible = true; + globeControl1.Globe.TrackPolylineTool.TrackMode = EnumTrackMode.SpaceTrack; + trackPolylineEndMode = EnumTrackPolylineEndMode.JXPM_Analysis; + + } + + #endregion + /// + /// 创建拓扑 + /// + /// + /// + private void buttonItemFX3_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX3_1.Text); + + FrmGenAndFaMenTopu frm = new FrmGenAndFaMenTopu(globeControl1, m_PipelineLayerNames, valueLayerNames); + frm.Show(this); + } + #region Predator :拓扑分析 + /// + /// 上游分析 + /// + /// + /// + private void buttonItemFX3_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX3_2.Text); + NetworkTraceUpDown(true); + } + /// + /// 下游分析 + /// + /// + /// + private void buttonItemFX3_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX3_3.Text); + NetworkTraceUpDown(false); + } + + /// + /// 上下游追踪 功能 + /// + /// + private void NetworkTraceUpDown(Boolean bTraceUp) + { + GSOFeature selLineFeature = globeControl1.Globe.SelectedObject; + if (selLineFeature == null || selLineFeature.Geometry == null || selLineFeature.Geometry.Type != EnumGeometryType.GeoPolyline3D) + { + MessageBox.Show("请点击“编辑”—“选中对象”选择一条线!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); + return; + } + GSOLayer selLayer = globeControl1.Globe.SelectedObjectLayer; + + NetworkAnalysisTool.TraceUpDownAnalysis(bTraceUp, + selLineFeature, selLayer); + } + + /// + /// 流向分析 + /// + /// + /// + private void buttonItemFX3_4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX3_4.Text); + + FrmFlow frm = new FrmFlow(globeControl1, m_PipelineLayerNames); + frm.Show(this); + } + /// + /// 关阀分析 + /// + /// + /// + private void buttonItemFX3_5_Click(object sender, EventArgs e) + { + if (globeControl1.Globe.SelObjectCount < 1) + { + MessageBox.Show("请选中至少一根管线!!"); + buttonItemFX3_5.Checked = false; + return; + } + GSOLayer resLayer = null; + GSOFeature resFeature = null; + globeControl1.Globe.GetSelectObject(0, out resFeature, out resLayer); + + String pipeLayerName = resLayer.Caption; + String pipeLayerNamePrefix = pipeLayerName.Substring(0, pipeLayerName.IndexOf("管线")); + GSOLayer valveLayer = globeControl1.Globe.Layers[pipeLayerNamePrefix + "阀门"]; + if (valveLayer == null) + { + MessageBox.Show("无" + pipeLayerNamePrefix+"阀门图层", "提示"); + return; + } + + GSOFeatures valveFeats = NetworkAnalysisTool.CloseValvesAnalysis(resFeature, + resLayer, valveLayer); + + if (valveFeats != null) + { + FrmCloseValves frm = new FrmCloseValves(this.globeControl1, valveFeats); + frm.Show(this); + } + else + { + MessageBox.Show("未找到关闭阀门"); + } + } + + /// + /// 连通分析 + /// + /// + /// + private void buttonItemFX3_6_Click(object sender, EventArgs e) + { + if (globeControl1.Globe.SelObjectCount < 2) + { + MessageBox.Show("请选中至少两个管线!!"); + buttonItemFX3_6.Checked = false; + return; + } + GSOFeature selFeat0, selFeat1; + GSOLayer layer0,layer1; + globeControl1.Globe.GetSelectObject(0, out selFeat0, out layer0); + globeControl1.Globe.GetSelectObject(1, out selFeat1, out layer1); + + if (!layer0.IsSameInnerObject(layer1)) + { + MessageBox.Show("不在同一个图层!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); + buttonItemFX3_6.Checked = false; + return; + } + NetworkAnalysisTool.ConnexityAnalysis(selFeat0, selFeat1, layer0); + } + /// + /// 爆管分析 + /// + /// + /// + private void buttonItemFX3_7_Click(object sender, EventArgs e) + { + NetworkTraceUpDown(true); //上游追踪: + + GSOFeature selLineFeature = globeControl1.Globe.SelectedObject; + if (selLineFeature == null || selLineFeature.Geometry == null || selLineFeature.Geometry.Type != EnumGeometryType.GeoPolyline3D) + { + MessageBox.Show("请点击“编辑”—“选中对象”选择一条线!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); + return; + } + GSOLayer selLayer = globeControl1.Globe.SelectedObjectLayer; + + NetworkAnalysisTool.ExplodeAnalysis(this.globeControl1,selLineFeature,selLayer); + + this.buttonItemFX3_5_Click(sender, e); //关阀分析: + + } + + #endregion + /// + /// 多边形开挖 + /// + /// + /// + private void buttonItemFX4_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_1.Text); + + trackflag = "pit"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; //是这个么?是的,在模型上 + } + /// + /// 挖方量分析 + /// + /// + /// + private void buttonItemFX4_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_2.Text); + + trackflag = "digFillAnalysis"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; + ActionToolMenuChecked(); + } + /// + /// 沿线开挖 + /// + /// + /// + private void buttonItemFX4_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_3.Text); + + if (!buttonItemFX4_3.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; + buttonItemFX4_3.Checked = true; + } + } + else + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + buttonItemFX4_3.Checked = false; + globeControl1.Globe.TrackPolylineTool.VerticalLineVisible = false; + } + ActionToolMenuChecked(); + } + /// + /// 创建隧道 + /// + /// + /// + private void buttonItemFX4_4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_4.Text); + + 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("场景中未加载隧道图层!", "提示"); + } + } + /// + /// 隐藏隧道 + /// + /// + /// + private void buttonItemFX4_5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_5.Text); + + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption("隧道"); + if (layer != null) + { + layer.Visible = !layer.Visible; + } + } + /// + /// 删除隧道 + /// + /// + /// + private void buttonItemFX4_6_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_6.Text); + + 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("请选中要删除的隧道!", "提示"); + } + } + /// + /// 通视分析 + /// + /// + /// + private void buttonItemFX5_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX5_1.Text); + + if (globeControl1.Globe.Action != EnumAction3D.VisibilityAnalysis) + { + //btnSpaceVisibilityAnalysis.Checked = true; + globeControl1.Globe.Action = EnumAction3D.VisibilityAnalysis; + } + else + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + // SetButtonChecked(); + } + } + /// + /// 可视域分析 + /// + /// + /// + private void buttonItemFX5_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX5_2.Text); + + globeControl1.Globe.Action = EnumAction3D.ViewshedAnalysis; + } + /// + /// 可视包络分析 + /// + /// + /// + private void buttonItemFX5_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX5_3.Text); + + globeControl1.Globe.Action = EnumAction3D.ViewEnvelopeAnalysis; + } + /// + /// 缓冲区分析 + /// + /// + /// + private void buttonItemFX6_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX6_1.Text); + + GSOFeature feat = globeControl1.Globe.SelectedObject; + if (feat == null) + { + MessageBox.Show("请选择要分析的要素!"); + return; + } + if (feat.Geometry.Type == EnumGeometryType.GeoPolyline3D) + { + GSOGeoPolyline3D line1 = feat.Geometry as GSOGeoPolyline3D; + if (line1 == null) + { + MessageBox.Show("请选择一条管线!"); + return; + } + + FrmBufferAnalysis frm = new FrmBufferAnalysis(globeControl1, line1, layerTemp); + frm.Show(this); + } + else + { + FrmBufferAnalysisBSQ frm = new FrmBufferAnalysisBSQ(globeControl1, layerTemp, bsqPT); + frm.Show(this); + } + + } + /// + /// 附属物分析 + /// + /// + /// + private void buttonItemFX6_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX6_2.Text); + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + FrmAccessoryAnalysis dlg = new FrmAccessoryAnalysis(globeControl1, layerTemp); + dlg.Show(this); + } + /// + /// 无源淹没分析 + /// + /// + /// + private void buttonItemFX6_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX6_3.Text); + + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + trackflag = "FloodAnalysis"; + } + /// + /// 水平距离 + /// + /// + /// + private void buttonItemLS1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS1.Text); + + globeControl1.Globe.Action = EnumAction3D.MeasureDistance; + globeControl1.Globe.DistanceRuler.SpaceMeasure = false; + buttonItemLS5.Checked = false; + } + /// + /// 垂直距离 + /// + /// + /// + private void buttonItemLS2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS2.Text); + + buttonItemLS5.Checked = false; + globeControl1.Globe.Action = EnumAction3D.MeasureHeight; + globeControl1.Globe.DistanceRuler.SpaceMeasure = false; + } + /// + /// 空间距离 + /// + /// + /// + private void buttonItemLS3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS3.Text); + + buttonItemLS5.Checked = false; + globeControl1.Globe.Action = EnumAction3D.MeasureDistance; + globeControl1.Globe.DistanceRuler.SpaceMeasure = true; + } + /// + /// 地表距离 + /// + /// + /// + private void buttonItemLS4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS4.Text); + + buttonItemLS5.Checked = false; + globeControl1.Globe.Action = EnumAction3D.MeasureDistance; + globeControl1.Globe.DistanceRuler.SpaceMeasure = false; + } + /// + /// 高度量算 + /// + /// + /// + private void buttonItemLS5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS5.Text); + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + buttonItemLS5.Checked = !buttonItemLS5.Checked; + if (buttonItemLS5.Checked) + { + globeControl1.Globe.Action = EnumAction3D.SelectObject; + } + } + /// + /// 水平面积 + /// + /// + /// + private void buttonItemLS6_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS6.Text); + + buttonItemLS5.Checked = false; + globeControl1.Globe.Action = EnumAction3D.MeasureArea; + globeControl1.Globe.AreaRuler.SpaceMeasure = true; + } + /// + /// 地表面积 + /// + /// + /// + private void buttonItemLS7_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS7.Text); + + buttonItemLS5.Checked = false; + globeControl1.Globe.Action = EnumAction3D.MeasureArea; + globeControl1.Globe.AreaRuler.SpaceMeasure = false; + + } + + # region Fan 重构标注代码 + /// + /// 标高标注 + /// + /// + /// + private void buttonItemSZ1_Click(object sender, EventArgs e) + { + GSOFeature resFeature = IsPipeLineOfSelectedObj(); + if (resFeature == null) + { + MessageBox.Show("请选中一根管线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + GSOGeoPolyline3D selLine = resFeature.Geometry as GSOGeoPolyline3D; + if (selLine[0].Count <= 1) + { + return; + } + + MarkTools.getInstance().showMarker(resFeature, + globeControl1, EnumMarkLayer.Mark_Altitude, ""); + } + /// + /// 管径标注 + /// + GSOFeature radiusMarkerFeature; + private void buttonItemBZ2_Click(object sender, EventArgs e) + { + GSOFeature resFeature = IsPipeLineOfSelectedObj(); + if (resFeature == null) + { + MessageBox.Show("请选中一根管线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + GSOGeoPolyline3D selLine = resFeature.Geometry as GSOGeoPolyline3D; + if (selLine[0].Count <= 1) + { + return; + } + + MarkTools.getInstance().showMarker(resFeature, + globeControl1, EnumMarkLayer.Mark_Diameter, ""); + } + /// + /// 埋深标注 + /// + /// + /// + private void buttonItemBZ3_Click(object sender, EventArgs e) + { + GSOFeature resFeature = IsPipeLineOfSelectedObj(); + if (resFeature == null) + { + MessageBox.Show("请选中一根管线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + GSOGeoPolyline3D selLine = resFeature.Geometry as GSOGeoPolyline3D; + if (selLine[0].Count <=1) + { + return; + } + + MarkTools.getInstance().showMarker(resFeature, + globeControl1, EnumMarkLayer.Mark_Depth, ""); + + } + /// + /// 坐标标注 + /// + /// + /// + private void buttonItemBZ4_Click(object sender, EventArgs e) + { + GSOFeature resFeature = IsPipeLineOfSelectedObj(); + if (resFeature == null) + { + MessageBox.Show("请选中一根管线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + GSOGeoPolyline3D selLine = resFeature.Geometry as GSOGeoPolyline3D; + if (selLine[0].Count <= 1) + { + return; + } + MarkTools.getInstance().showMarker(resFeature, + globeControl1, EnumMarkLayer.Mark_Location, ""); + } + /// + /// 距离标注 + /// + bool distanceMarker = false; + private void buttonItemBZ5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBZ5.Text); + + globeControl1.Globe.Action = EnumAction3D.TrackPolyline; + //globeControl1.Globe.DistanceRuler.MeasureMode = EnumDistanceMeasureMode.HVSLineMeasure; + distanceMarker = true; + } + /// + /// 自定义标注 + /// + /// + /// + private void buttonItemBZ6_Click(object sender, EventArgs e) + { + GSOFeature f = globeControl1.Globe.SelectedObject; + GSOLayer l = globeControl1.Globe.SelectedObjectLayer; + FrmCustomLabel frm = new FrmCustomLabel(globeControl1, l, f); + if (frm.ShowDialog() == DialogResult.OK) + { + MarkTools.getInstance().showMarker(f, globeControl1, EnumMarkLayer.Mark_Custom, frm.labelText); + } + } + /// + /// 扯旗标注 + /// + /// + /// + private void buttonItemBZ7_Click(object sender, EventArgs e) + { + GSOFeature f = globeControl1.Globe.SelectedObject; + GSOLayer l = globeControl1.Globe.SelectedObjectLayer; + FrmMarker frm = new FrmMarker(); + if (frm.ShowDialog() == DialogResult.OK) + { + MarkTools.getInstance().showMarker(f, globeControl1, EnumMarkLayer.Mark_Custom, frm.markerContent); + } + } + /// + /// 坡度标注 + /// + /// + /// + private void buttonItemBZ8_Click(object sender, EventArgs e) + { + GSOFeature resFeature = IsPipeLineOfSelectedObj(); + if (resFeature == null) + { + MessageBox.Show("请选中一根管线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + GSOGeoPolyline3D selLine = resFeature.Geometry as GSOGeoPolyline3D; + if (selLine[0].Count <= 1) + { + return; + } + + MarkTools.getInstance().showMarker(resFeature, + globeControl1, EnumMarkLayer.Mark_Slope, ""); + } + /// + /// 属性标注 + /// + /// + /// + private void buttonItemBZ9_Click(object sender, EventArgs e) + { + GSOFeature f = globeControl1.Globe.SelectedObject; + GSOLayer l = globeControl1.Globe.SelectedObjectLayer; + FrmPropertiesMarker frm = new FrmPropertiesMarker(globeControl1, l, f); + if (frm.ShowDialog() == DialogResult.OK) + { + MarkTools.getInstance().showMarker(f, globeControl1, EnumMarkLayer.Mark_Property, frm.labelText); + } + } + /// + /// 红线工具 + /// + /// + /// + private void buttonItemBZ10_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBZ10.Text); + 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; + } + } + /// + /// 标注管理 + /// + /// + /// + private void buttonItemBZ11_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBZ11.Text); + + buttonItemBZ11.Checked = !buttonItemBZ11.Checked; + 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 (buttonItemBZ11.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(); + } + } + + #endregion + /// + /// 飞行到目标点 + /// + /// + /// + private void buttonItemFXGJ1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFXGJ1.Text); + + FrmSetFlytoPos.ShowForm(globeControl1); + + } + /// + /// 自定义飞行 + /// + /// + /// + private void buttonItemFXGJ2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFXGJ2.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); + } + } + /// + /// 绕中心点飞行 + /// + /// + /// + private void buttonItemFXGJ3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFXGJ3.Text); + + globeControl1.Globe.FlyAroundCenter(10000, EnumFlyRepeatValueType.MiliSeconds); + globeControl1.Globe.CurFlyID = 1; + } + /// + /// 绕眼睛飞行 + /// + /// + /// + private void buttonItemFXGJ4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFXGJ4.Text); + + globeControl1.Globe.FlyAroundEye(720, EnumFlyRepeatValueType.Degrees); + globeControl1.Globe.CurFlyID = 2; + } + + /// + /// 权限管理 + /// + /// + /// + private void buttonItemXT1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT1.Text); + + FrmUserRoleMgr frm = new FrmUserRoleMgr(); + frm.ShowDialog(); + } + /// + /// 数据库管理 + /// + /// + /// + private void buttonItemXT2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT2.Text); + + //查看数据库列表 + FrmDbManager frm = new FrmDbManager(); + frm.ShowDialog(); + } + /// + /// 用户列表 + /// + /// + /// + private void buttonItemXT3_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT3_1.Text); + + FrmUserManager frm = new FrmUserManager(); + frm.ShowDialog(); + } + /// + /// 创建新用户 + /// + /// + /// + private void buttonItemXT3_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT3_2.Text); + + FrmUserAdd frm = new FrmUserAdd(-1); + frm.ShowDialog(); + } + /// + /// 人员修改 + /// + /// + /// + private void buttonItemXT4_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT4_2.Text); + + FrmAppUSER appUSER = new FrmAppUSER(); + appUSER.ShowDialog(); + } + /// + /// 增加人员 + /// + /// + /// + private void buttonItemXT4_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT4_1.Text); + + FrmAppUSERRESET appUSERRESET = new FrmAppUSERRESET(); + appUSERRESET.ShowDialog(); + } + /// + /// 统计数据 + /// + /// + /// + private void buttonItemZTT1_Click(object sender, EventArgs e) + { + ////日志记录 + //LogManager.saveLog(Utility.userName, this.buttonItemZTT1.Text); + + //PATM patm = new PATM(); + //patm.operation = "Statistic"; + //patm.Text = "统计专题图管理"; + //patm.ShowDialog(); + } + /// + /// 热点功能统计 + /// + /// + /// + private void buttonItemZTT2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT2.Text); + + FrmHotFuncStat frmhfs = new FrmHotFuncStat(); + frmhfs.ShowDialog(); + } + + private void buttonItemZTT3_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT3_1.Text); + + FrmAPP appfrm = new FrmAPP("专题图申请"); + appfrm.ShowDialog(); + } + + private void buttonItemZTT3_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT3_2.Text); + + FrmAPPFORASK appForask = new FrmAPPFORASK("专题图审核"); + appForask.ShowDialog(); + } + + private void buttonItemZTT3_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT3_3.Text); + + FrmAPPregion appregion = new FrmAPPregion("专题图审核"); + appregion.ShowDialog(); + } + + private void buttonItemZTT4_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT4_1.Text); + + FrmAPP appfrm = new FrmAPP("打印申请"); + appfrm.ShowDialog(); + } + + private void buttonItemZTT4_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT4_2.Text); + + FrmAPPFORASK appForask = new FrmAPPFORASK("打印审核"); + appForask.ShowDialog(); + } + + private void buttonItemZTT4_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT4_3.Text); + + FrmAPPregion appregion = new FrmAPPregion("打印审核"); + appregion.ShowDialog(); + } + + private void buttonItemZTT5_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT5_1.Text); + + FrmAPP appfrm = new FrmAPP("拷贝申请"); + appfrm.ShowDialog(); + } + + private void buttonItemZTT5_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT5_2.Text); + + FrmAPPFORASK appForask = new FrmAPPFORASK("拷贝审核"); + appForask.ShowDialog(); + } + + private void buttonItemZTT5_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT5_3.Text); + + FrmAPPregion appregion = new FrmAPPregion("拷贝审核"); + appregion.Show(); + } + + private int connectServerCount = 0; + + /// + /// 还原球到实测库 + /// + 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); + } + + if (layerManagerNode.Nodes.Count > 0) + { + for (int i = layerManagerNode.Nodes.Count - 1; i >= 0; i--) + { + layerManagerNode.Nodes[i].Remove(); + + } + } + + globeControl1.Refresh(); + + } + + private void buttonItemSPSZ_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSPSZ.Text); + + FrmLayerControl frm = new FrmLayerControl(layerTree, globeControl1, globeControl2); + frm.Show(this); + } + + /// + /// 碰撞审查 + /// + /// + /// + private void buttonItemSH1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSH1.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 buttonItemSH2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSH2.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 buttonItemSH3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSH3.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 buttonItemSH4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSH4.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 buttonItemSH5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSH5.Text); + FrmCityServerLineAnalysis frm = new FrmCityServerLineAnalysis(globeControl1, m_PipelineLayerNames); + frm.Show(this); + } + #region 数据管理-导入文件 + ///// + ///// 数据管理-导入本地坐标系文件 + ///// + ///// + ///// + //private void buttonItemSJGL1_1_Click(object sender, EventArgs e) + //{ + // //日志记录 + // LogManager.saveLog(Utility.userName, this.buttonItemSJGL1_1.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(); + // } + // } + //} + + ///// + ///// 数据管理-导入其他坐标系文件 + ///// + ///// + ///// + //private void buttonItemSJGL1_2_Click(object sender, EventArgs e) + //{ + // //日志记录 + // LogManager.saveLog(Utility.userName, this.buttonItemSJGL1_2.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(); + // } + // } + //} + #endregion + /// + /// 数据质量检查 + /// + /// + /// + private void buttonItemSJGL2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL2.Text); + FrmValiData frm = new FrmValiData(globeControl1); + frm.ShowDialog(); + } + /// + /// 数据预处理 + /// + /// + /// + private void buttonItemSJGL3_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL3.Text); + + FrmEditShapeFile frm = new FrmEditShapeFile(globeControl1); + frm.ShowDialog(this); + } + /// + /// 连接数据库 + /// + /// + /// + private void buttonItemSJGL4_1_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL4_1.Text); + + FrmDatabaseParaSetting frm = new FrmDatabaseParaSetting(globeControl1); + if (frm.ShowDialog() == DialogResult.OK) + { + ds = FrmDatabaseParaSetting.ds; + if (ds != null) + { + ds.IsCloseSaved = false; + } + } + } + /// + /// 管线入库 + /// + /// + /// + private void buttonItemSJGL4_2_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL4_2.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 buttonItemSJGL4_3_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL4_3.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 buttonItemSJGL5_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL5.Text); + + Cyberpipe.Forms.FrmProject frm = new Cyberpipe.Forms.FrmProject(); + frm.ShowDialog(); + } + /// + /// 元数据基本管理 + /// + /// + /// + private void buttonItemSJGL6_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL6_1.Text); + + FrmMetadata frmmd = new FrmMetadata(); + frmmd.ShowDialog(); + } + /// + /// 元数据查询管理 + /// + /// + /// + private void buttonItemSJGL6_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL6_2.Text); + + FrmMetadataStat frmmds = new FrmMetadataStat(); + //frmmds.Show(); + frmmds.ShowDialog(); + } + /// + /// 操作日志管理 + /// + /// + /// + private void buttonItemSJGL7_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL7.Text); + + FrmLogOper frmlo = new FrmLogOper(); + frmlo.ShowDialog(); + } + /// + /// 数据字典管理 + /// + /// + /// + private void buttonItemSJGL8_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL8.Text); + + FrmMDDictory frmmdd = new FrmMDDictory(); + frmmdd.ShowDialog(); + } + /// + /// 数据库备份 + /// + /// + /// + private void buttonItemSJGL9_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL9.Text); + + //新 + FrmBACKORACLE backOracle = new FrmBACKORACLE(); + backOracle.Show(); + } + /// + /// 创建管段 + /// + /// + /// + private void buttonItemBJ1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ1.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; + } + } + /// + /// 创建附属物 + /// + /// + /// + private void buttonItemBJ2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ2.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); + } + } + /// + /// 创建特征管点 + /// + /// + /// + private void buttonItemBJ3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ3.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); + } + } + /// + /// 绘制城市七线 + /// + /// + /// + private void buttonItemBJ4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ4.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; + } + } + } + /// + /// 选中对象 + /// + /// + /// + private void buttonItemBJ5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ5.Text); + + globeControl1.Globe.Action = EnumAction3D.SelectObject; + } + /// + /// 平移对象 + /// + /// + /// + private void buttonItemBJ6_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ6.Text); + + globeControl1.Globe.Action = EnumAction3D.MoveObject; + } + /// + /// 升降对象 + /// + /// + /// + private void buttonItemBJ7_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ7.Text); + + globeControl1.Globe.Action = EnumAction3D.ElevateObject; + } + /// + /// 旋转对象 + /// + /// + /// + private void buttonItemBJ8_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ8.Text); + + globeControl1.Globe.Action = EnumAction3D.RotateObject; + } + /// + /// 连接管段 + /// + /// + /// + private void buttonItemBJ9_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ9.Text); + + if (globeControl1.Globe.SelObjectCount < 2) + { + MessageBox.Show("对不起,请至少选中2个对象!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + return; + } + globeControl1.Globe.InsertJointPipeline(false); + } + /// + /// 后退 + /// + /// + /// + private void buttonItemBJ11_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemBJ11.Text); + globeControl1.Globe.UnDoEdit(); + } + /// + /// 前进 + /// + /// + /// + private void buttonItemBJ12_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemBJ12.Text); + + globeControl1.Globe.ReDoEdit(); + } + /// + /// 导出CAD + /// + /// + /// + private void buttonItemBJ10_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ10_1.Text); + + #region 导出成dxf格式 + List listVectorNames = new List(); + 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(); + #endregion + } + /// + /// 导出矢量 + /// + /// + /// + private void buttonItemBJ10_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ10_2.Text); + + List listVectorNames = new List(); + 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 buttonItemBJ13_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemBJ13.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(); + } + } + MessageBox.Show("删除成功!", "提示"); + } + else + { + MessageBox.Show("请选中要删除的模型!", "提示"); + } + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + } + + private void buttonItemHX1_1_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]; + string filePath = dlg.FileName; + string lastname = Path.GetFileName(filePath); + + 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(); + } + + } + } + } + + public struct LineStruct + { + public string layerName; + public string layerCode; + public string lineLength; + public string hxName; + } + + List lineStruct = new List(); + List featsList = new List(); + + /// + /// 红线审核 + /// + /// + /// + private void buttonItemHX2_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemHX2.Text); + redSH = true; + featsList.Clear(); + lineStruct.Clear(); + List listPipelineLayers = new List(); + + GSOLayer layer = null; + for (int i = 0; i < m_PipelineLayerNames.Count; i++) + { + layer = globeControl1.Globe.Layers.GetLayerByCaption(m_PipelineLayerNames[i]); + if (layer != null) + { + listPipelineLayers.Add(layer); + } + } + //yanxiaowei 重构 + GSOFeatures selectFeatures=new GSOFeatures(); + for (int i = 0; i < globeControl1.Globe.SelObjectCount; i++) + { + GSOFeature feature = null; + globeControl1.Globe.GetSelectObject(i, out feature, out layer); + selectFeatures.Add(feature); + } + DataTable table=new DataTable(); + + ClassGSOTool.CalculateRedLineResult(out table, redSH, selectFeatures, globeControl1, + listPipelineLayers,out lineStruct, out featsList); + + if (table.Rows.Count != 0) + AddDatagridView(table); + else + { + MessageBox.Show("没有侵入地块红线的管线数据!", "提示"); + dataGridViewX1.DataSource = null; + panelOfTable.Visible = false; + return; + } + } + + private void AddDatagridView(DataTable table) + { + dataGridViewX1.DataSource = table; + panelOfTable.Visible = true; + panelOfTable.Height = 200; + toolStripNumbers.Text = "红线审核 |共有:" + table.Rows.Count + "条"; + toolStripDropDownButton3.Visible = true; + } + /// + /// 主窗体 下方的工具条中的 导出.xls文件 按钮事件处理 + /// + /// + /// + private void toolStripDropDownButton3_Click(object sender, EventArgs e) + { + if (dataGridViewX1.Rows.Count == 0) + { + MessageBox.Show("表格内容为空!", "提示"); + return; + } + + string strSaveFile = string.Empty; + SaveFileDialog savefiledialog = new SaveFileDialog(); + savefiledialog.Filter = "Excel文件|*.xls,*.xlsx"; + savefiledialog.AddExtension = true; + savefiledialog.FileName = "红线审核"; + if (savefiledialog.ShowDialog() == DialogResult.OK) + strSaveFile = savefiledialog.FileName; + else return; + + ExpEXCEL.ExpToExcel(dataGridViewX1, strSaveFile, "红线审核", lineStruct, featsList); + MessageBox.Show("导出成功!"); + } + /// + /// 去除集合中重复的管线 + /// + /// + /// + /// + private GSOFeatures getFeaturesByFilter(GSOFeatures features, string fieldName) + { + if (features == null) + { + return null; + } + GSOFeatures featuresGet = new GSOFeatures(); + for (int i = 0; i < features.Length; i++) + { + GSOFeature featureFromFS = features[i]; + string fieldValueFromFS = featureFromFS.GetValue(fieldName).ToString().Trim(); + bool isHas = false; + for (int j = featuresGet.Length - 1; j >= 0; j--) + { + GSOFeature featureFromFSGet = featuresGet[j]; + string fieldValueFromFSGet = featureFromFSGet.GetValue(fieldName).ToString().Trim(); + if (fieldValueFromFS.Equals(fieldValueFromFSGet)) + { + isHas = true; + break; + } + } + if (isHas == false) + { + featuresGet.Add(featureFromFS.Clone()); + } + } + return featuresGet; + } + + private void sliderItem2_ValueChanged(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.sliderItem2.Text); + + globeControl1.Globe.GroundOpaque = 100 - sliderItem2.Value; + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(roadLayerName);//("180fd"); + if (layer != null) + { + layer.Opaque = 100 - sliderItem2.Value; + } + layer = globeControl2.Globe.Layers.GetLayerByCaption("180fd");//("180fd"); + if (layer != null) + { + layer.Opaque = 100 - sliderItem2.Value; + } + globeControl2.Globe.GroundOpaque = 100 - sliderItem2.Value; + + optiValue = sliderItem2.Value; + } + /// + /// 数据管理导入文件 + /// + /// + /// + private void buttonItemSJGL1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL1.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.Multiselect = true; + if (dlg.ShowDialog() == DialogResult.OK) + { + //自定义lprj文件名,从程序中复制一lprj文件。 + string filePath = dlg.FileName; + string lastname = Path.GetFileName(filePath); + + 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, 100); + + globeControl1.Refresh(); + } + } + } + + private void buttonItemHX1_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemHX1.Text); + + GSODataSource dataSpace = globeControl1.Globe.DataManager.OpenOracleDataSource(Utility.DBServer.Trim() + "/" + Utility.dbdatabase.Trim(), "", "", Utility.userID, Utility.DBPassword); + string filepath = ""; + //日志记录 + OpenFileDialog dlg = new OpenFileDialog(); + dlg.Filter = "矢量数据(*.shp)|*.shp|矢量数据(*.lgd)|*.lgd|CAD数据(*.dxf)|*.dxf|全部支持格式(*.lgd,*.shp,*.dxf)|*.lgd;*.shp;*.dxf;"; + dlg.Multiselect = true; + + #region 临时图层显示 + if (dlg.ShowDialog() == DialogResult.OK) + { + string filePath = dlg.FileName; + string lastname = Path.GetFileName(filePath); + + #region + for (int i = 0; i < dlg.FileNames.Length; i++) + { + string strDataPath = dlg.FileNames[i]; + filepath = strDataPath; + + GSOLayer layer = globeControl1.Globe.Layers.Add(strDataPath); + GSOFeatures RedFeatures = layer.GetAllFeatures(); + + 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(); + RedFeatures = features; + 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; + } + + /////////////////////////////////////////////////////////////////////////////////////////// + globeControl1.Globe.Layers.MoveTo(0, globeControl1.Globe.Layers.Count - 1); + globeControl1.Refresh(); + } + + IModelBuilder modelBuilder = new RedLineBuilder(); + + modelBuilder.batchInsert(dataSpace, redDt, RedFeatures); + + } + #endregion + + } + #endregion + } + /// + /// 定位 + /// + /// + /// + private void buttonItemLocation_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemLocation.Text); + + FrmFlyToPosition fly = new FrmFlyToPosition(globeControl1,globeControl2); + fly.Show(this); + } + /// + /// 2015-10-17演示代码 红线审核 + /// + /// + /// + private void ribbonTabItem6_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.FlyToPosition(new GSOPoint3d(120.610963, 31.188121, 50), EnumAltitudeMode.Absolute, -4, 50, 800); + globeControl1.Globe.FlyToPointSpeed = 10000000; + globeControl1.Globe.Action = EnumAction3D.SelectObject; + globeControl1.Refresh(); + + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + + //zhanshi = false; + redSH = true; + splitContainer1.Panel2Collapsed = true; + legendSG.Visible = false; + legendSC.Visible = false; + ClearGZData(); + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = true; + } + + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 基础工具 + /// + /// + /// + private void ribbonTabItem1_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + //zhanshi = false; + redSH = false; + splitContainer1.Panel2Collapsed = true; + panelOfTable.Visible = false; + legendSC.Visible = false; + legendSG.Visible = false; + ClearGZData(); + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + + + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 一键审核 + /// + /// + /// + private void ribbonTabItem11_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + //zhanshi = false; + redSH = false; + splitContainer1.Panel2Collapsed = true; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + panelOfTable.Visible = false; + legendSC.Visible = false; + legendSG.Visible = false; + ClearGZData(); + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + + + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 右屏添加冰箱数据 + /// + void AddDataToGlobeControl2() + { + + bool modelDataBool = false; + for (int i = globeControl2.Globe.Layers.Count - 1; i >= 0; i--) + { + GSOLayer layer = globeControl2.Globe.Layers[i]; + if (layer.Name.Contains("fttp:")) + { + modelDataBool = true; + break; + } + } + + if (modelDataBool == false) + { + GSOLayer ly = globeControl1.Globe.Layers.GetLayerByCaption("天地图地图"); + globeControl2.Globe.Layers.Add(ly); + } + else + { + return; + } + } + /// + /// 双屏对比 + /// + /// + /// + private void ribbonTabItem9_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent += new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent += new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + panelOfTable.Visible = false; + + splitContainer1.Panel2Collapsed = false; + //zhanshi = true; + redSH = false; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + sliderItem2.Value = 100 - globeControl1.Globe.GroundOpaque; + globeControl2.Globe.GroundOpaque = globeControl1.Globe.GroundOpaque; + legendSC.Visible = true; + legendSG.Visible = true; + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + AddDataToGlobeControl2(); + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 文档管理 + /// + /// + /// + private void ribbonTabItem4_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + panelOfTable.Visible = false; + //zhanshi = false; + redSH = false; + splitContainer1.Panel2Collapsed = true; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + legendSC.Visible = false; + legendSG.Visible = false; + ClearGZData(); + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 基础管理 + /// + /// + /// + private void ribbonTabItem14_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + panelOfTable.Visible = false; + //zhanshi = false; + redSH = false; + splitContainer1.Panel2Collapsed = true; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + legendSC.Visible = false; + legendSG.Visible = false; + ClearGZData(); + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 权限管理 + /// + /// + /// + private void ribbonTabItem2_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + panelOfTable.Visible = false; + //zhanshi = false; + redSH = false; + splitContainer1.Panel2Collapsed = true; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + legendSC.Visible = false; + legendSG.Visible = false; + ClearGZData(); + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + GSOFeature dpFeatuer = null; + /// + /// 双屏分析,点击管段分析 + /// + /// + /// + private void buttonItem8_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItem8.Text); + + //FrmCompareFeature frmCompareFeature = new FrmCompareFeature(globeControl1, globeControl2, layerTemp, layerTemp2,m_PipelineLayerNames,sgPipeLayersNames); + int width = this.Width; + FrmCompareFeature.ShowForm(globeControl1, globeControl2, layerTemp, layerTemp2, m_PipelineLayerNames, sgPipeLayersNames,width); + //frmCompareFeature.Location = new Point((this.Width - frmCompareFeature.Width)/2,50); + //frmCompareFeature.Show(this); + + } + /// + /// 红线审核导出图片 + /// + /// + /// + private void buttonItemDCTP_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemDCTP.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))); + */ + int mapWidth = 0; + int mapHeight = 0; + Point pt = getUpperLeftPoint(pt1, pt2, out mapWidth, out mapHeight); + int rightBottomX = pt.X + mapWidth; + int rightBottomY = pt.Y + mapHeight; + Image myImg = new Bitmap(mapWidth, mapHeight); + Graphics g = Graphics.FromImage(myImg); + g.CopyFromScreen(pt, new Point(0, 0), new Size(rightBottomX, rightBottomY)); + + 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; + } + } + } + /// + /// 标识器全区域统计 + /// + /// + /// + private void 标识器分类统计ToolStripMenuItem_Click(object sender, EventArgs e) + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + FrmBSQStatis bsqStatis = new FrmBSQStatis(); + bsqStatis.Show(this); + } + /// + /// 标识器绘制区域统计 + /// + /// + /// + private void 标识器分类统计ToolStripMenuItem1_Click(object sender, EventArgs e) + { + trackflag = "BSQDuoBianXiangStatis"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + } + + #region 保存和加载审核库加载的图层 + /* + private void saveLayerList(TreeNodeCollection treeNodeList) + { + string configPath = Application.StartupPath + "\\configLayerList.xml"; + try + { + XmlDocument doc = new XmlDocument(); + doc.Load(configPath); + XmlNode dbParams = doc.SelectSingleNode("Params/dbparams"); + XmlNode dbLayers = doc.SelectSingleNode("Params/dblayers"); + XmlNode layers = doc.SelectSingleNode("Params/layers"); + dbParams.RemoveAll(); + dbLayers.RemoveAll(); + layers.RemoveAll(); + + List listDS = new List(); + String shDatasourceName = Utility.sgdbip + "/" + Utility.sgdbname + "_" + Utility.sgdbuser; + bool flag = false; + + for (int i = 0; i < globeControl1.Globe.DataManager.DataSourceCount; i++) + { + GSODataSource ds = globeControl1.Globe.DataManager.GetDataSourceAt(i); + if (ds != null && ds.Type == EnumDataSourceType.SqlServer || ds.Type == EnumDataSourceType.Oracle) + { + if (ds.Name == shDatasourceName) + { + //防止因为多次连接同一个数据库 + if (flag == true) + { + break; + } + flag = true; + listDS.Add(ds); + GSODataSourceCnn conn = ds.GetConnectionInfo(); + + XmlElement dbparam = doc.CreateElement("shdbparam"); + XmlElement ip = doc.CreateElement("ship"); + ip.InnerText = conn.Server; + + XmlElement dbname = doc.CreateElement("shdbname"); + dbname.InnerText = conn.Database; + + XmlElement username = doc.CreateElement("shusername"); + username.InnerText = conn.User; + + XmlElement password = doc.CreateElement("shpassword"); + password.InnerText = conn.Password; + + XmlElement type = doc.CreateElement("shtype"); + if (ds.Type == EnumDataSourceType.SqlServer) + { + type.InnerText = "sqlserver"; + } + else + { + type.InnerText = "oracle"; + } + + dbparam.AppendChild(ip); + dbparam.AppendChild(dbname); + dbparam.AppendChild(username); + dbparam.AppendChild(password); + dbparam.AppendChild(type); + dbParams.AppendChild(dbparam); + } + + } + } + + for (int i = 0; i < treeNodeList.Count; i++) + { + GSOLayer layer = treeNodeList[i].Tag as GSOLayer; + if (Path.GetExtension(layer.Name) == "") + { + XmlElement dbLayer = doc.CreateElement("dblayer"); + XmlAttribute attri = doc.CreateAttribute("dbindex"); + for (int j = 0; j < listDS.Count; j++) + { + if (layer.Dataset.DataSource.Name == listDS[j].Name) + { + attri.Value = j.ToString(); + break; + } + } + dbLayer.Attributes.Append(attri); + dbLayer.InnerText = layer.Name; + + dbLayers.AppendChild(dbLayer); + } + else + { + XmlElement dbLayer = doc.CreateElement("layer"); + dbLayer.InnerText = layer.Name; + layers.AppendChild(dbLayer); + } + } + + doc.Save(configPath); + } + catch (Exception e) + { + + } + } + + private void openLayerList() + { + layerManagerNode.Nodes.Clear(); + + string configPath = Application.StartupPath + "\\configLayerList.xml"; + try + { + XmlDocument doc = new XmlDocument(); + doc.Load(configPath); + XmlNode dbParams = doc.SelectSingleNode("Params/dbparams"); + XmlNode dbLayers = doc.SelectSingleNode("Params/dblayers"); + XmlNode layers = doc.SelectSingleNode("Params/layers"); + + List listDS = new List(); + for (int i = 0; i < dbParams.ChildNodes.Count; i++) + { + string ip = ""; + string dbname = ""; + string username = ""; + string password = ""; + string type = ""; + XmlNode node = dbParams.ChildNodes.Item(i); + for (int j = 0; j < node.ChildNodes.Count; j++) + { + XmlNode nodeChild = node.ChildNodes.Item(j); + + if (nodeChild != null && nodeChild.Name == "ship") + { + ip = nodeChild.InnerText; + } + else if (nodeChild != null && nodeChild.Name == "shdbname") + { + dbname = nodeChild.InnerText; + } + else if (nodeChild != null && nodeChild.Name == "shusername") + { + username = nodeChild.InnerText; + } + else if (nodeChild != null && nodeChild.Name == "shpassword") + { + password = nodeChild.InnerText; + } + else if (nodeChild != null && nodeChild.Name == "shtype") + { + type = nodeChild.InnerText; + } + } + + if (type == "sqlserver") + { + GSODataSource ds = globeControl1.Globe.DataManager.OpenSqlServerDataSource(ip, "", dbname, username, password); + listDS.Add(ds); + } + else if (type == "oracle") + { + GSODataSource ds = globeControl1.Globe.DataManager.OpenOracleDataSource(ip + "/" + dbname, "", "", username, password); + listDS.Add(ds); + } + } + + for (int i = 0; i < dbLayers.ChildNodes.Count; i++) + { + XmlNode node = dbLayers.ChildNodes.Item(i); + if (node != null) + { + string layerName = node.InnerText; + XmlAttribute attri = node.Attributes["dbindex"]; + if (attri != null) + { + int dbIndex = -1; + if (int.TryParse(attri.Value, out dbIndex)) + { + GSODataset dataset = listDS[dbIndex].GetDatasetByName(layerName); + globeControl1.Globe.Layers.Add(dataset); + //更新树节点 + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + TreeNode layerNode = new TreeNode(); + layerNode.Tag = layer; + layerNode.Text = layer.Dataset.Caption; + layerNode.ImageIndex = 0; + layerNode.SelectedImageIndex = 0; + layerNode.Checked = layer.Visible; + layerManagerNode.Nodes.Insert(0, layerNode); + // layerManagerNode.Expand(); + + + } + } + } + } + for (int i = 0; i < layers.ChildNodes.Count; i++) + { + XmlNode node = layers.ChildNodes.Item(i); + if (node != null) + { + string layerName = node.InnerText; + globeControl1.Globe.Layers.Add(layerName); + + //更新树节点 + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + TreeNode layerNode = new TreeNode(); + layerNode.Tag = layer; + layerNode.Text = layer.Dataset.Caption; + layerNode.ImageIndex = 0; + layerNode.SelectedImageIndex = 0; + layerNode.Checked = layer.Visible; + layerManagerNode.Nodes.Insert(0, layerNode); + } + } + layerManagerNode.Expand(); + } + catch (Exception e) + { + + } + } + * */ + #endregion + + private void btn_check_history_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_check_history.Text); + + if (FrmCheckHistory.isOpen == true) + { + return; + } + FrmCheckHistory frm = new FrmCheckHistory(globeControl1, globeControl2); + frm.addNode += new AddNodeToLayerManagerNode(addNodeToLayerManagerNode); + frm.Show(); + + } + + private void buttonItem查看数据_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItem查看数据.Text); + + FrmThreeOracle tr = new FrmThreeOracle(globeControl1); + + if (tr.ShowDialog() == DialogResult.OK) + { + addNodeToLayerManagerNode(tr.rukuLayer); + globeControl1.Refresh(); + } + } + /// + /// 规划数据入库 + /// + /// + /// + private void buttonItemGHRK_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemGHRK.Text); + + FrmGHRK ghrk = new FrmGHRK(globeControl1, layerManagerNode); + ghrk.Show(this); + } + + private void btn_user_info_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_user_info.Text); + + if (!FrmSysUserInfoManger.IS_OPEN) + { + FrmSysUserInfoManger frm = new FrmSysUserInfoManger(); + frm.ShowDialog(); + } + } + + private void btn_role_info_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_role_info.Text); + + if (FrmRoleInfoManager.IS_OPEN) + { + return; + } + FrmRoleInfoManager frm = new FrmRoleInfoManager(); + frm.ShowDialog(); + } + + private void btn_resc_info_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_resc_info.Text); + + if (!SysRescInfoManager.IS_OPEN) + { + SysRescInfoManager frm = new SysRescInfoManager(); + frm.ShowDialog(); + } + } + + private void btn_role_resc_Click(object sender, EventArgs e) + { + + LogManager.saveLog(Utility.userName, this.btn_role_resc.Text); + + if (!FrmRoleRescManager.IS_OPEN) + { + FrmRoleRescManager frm = new FrmRoleRescManager(); + frm.ShowDialog(); + } + } + + private void btn_user_role_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_user_role.Text); + + if (FrmUserRole.IS_OPEN) + { + return; + } + FrmUserRole frm = new FrmUserRole(); + frm.ShowDialog(); + } + + private void btn_document_info_Click(object sender, EventArgs e) + { + + LogManager.saveLog(Utility.userName, this.btn_document_info.Text); + + //if (FormDocumentManager.IS_OPEN) + //{ + // return; + //} + //FormDocumentManager frm = new FormDocumentManager(); + //frm.ShowDialog(); + + //if (FormDocumentManager.IS_OPEN) + //{ + // return; + //} + //new FormDocumentManager().ShowDialog(); + if (FormDocumentManager.IS_OPEN) + { + return; + } + this.Cursor = Cursors.WaitCursor; + FormDocumentManager frm = new FormDocumentManager(); + frm.changeCursor += new ChangeCursor(changeCursorToDefault); + frm.ShowDialog(); + + } + + private void changeCursorToDefault() + { + this.Cursor = Cursors.Default; + } + + /// + /// 判断CAD文件是否有投影信息 + /// + /// + /// + Boolean CheckDatasetGeoReference(GSODataset dataset) + { + Boolean bSuccess = false; + if (dataset.GeoReferenceType == EnumGeoReferenceType.Flat) + { + if (MessageBox.Show("数据没有空间参考信息,请设置空间参考信息!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation) == DialogResult.OK) + { + String strPath = Path.GetDirectoryName(Application.ExecutablePath) + "\\Coordinate Systems"; + OpenFileDialog dlg = new OpenFileDialog(); + + dlg.InitialDirectory = strPath; + dlg.RestoreDirectory = true; + + dlg.Filter = "投影文件|*.prj||"; + if (dlg.ShowDialog() == DialogResult.OK) + { + bSuccess = dataset.LoadProjectionFromESRIFile(dlg.FileName); + } + } + } + else + { + return true; + } + return bSuccess; + } + + private void buttonItemexp_CAD_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemexp_CAD.Text); + + OpenFileDialog dlg = new OpenFileDialog(); + dlg.Filter = "支持格式(*.dwg)|*.dwg"; + dlg.Multiselect = true; + if (dlg.ShowDialog() == DialogResult.OK) + { + for (int i = 0; i < dlg.FileNames.Length; i++) + { + //this.Cursor = Cursors.WaitCursor; + string strDataPath = dlg.FileNames[i]; + + #region + //string strDataPathPrj = strDataPath.ToLower().Replace(".dwg", ".lprj"); + + //if (File.Exists(strDataPathPrj) == false) + //{ + // if (MessageBox.Show("数据没有空间参考信息,请设置空间参考信息!", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation) == DialogResult.OK) + // { + // String strPath = Application.StartupPath + "\\Coordinate Systems"; + // OpenFileDialog dlgPrj = new OpenFileDialog(); + // dlgPrj.InitialDirectory = strPath; + // dlgPrj.RestoreDirectory = true; + // dlgPrj.Multiselect = false; + // dlg.Filter = "投影文件|*.prj"; + // if (dlg.ShowDialog() == DialogResult.OK) + // { + // this.Cursor = Cursors.WaitCursor; + // string proj4 = GSODataEngineUtility.ConvertEsriPrjFileToProj4(dlg.FileName); + // using (StreamWriter stream = new StreamWriter(strDataPathPrj, false)) + // { + // stream.WriteLine("0prj4" + proj4 + ""); + // } + // AddLayerData(strDataPath); + // //globeControl1.Globe.Layers.Add(strDataPath); + + // this.Cursor = Cursors.Default; + // } + // else + // { + // AddLayerData(strDataPath); + // //globeControl1.Globe.Layers.Add(strDataPath); + // } + // } + // else + // { + // AddLayerData(strDataPath); + // //globeControl1.Globe.Layers.Add(strDataPath); + // } + + //} + //else + //{ + // //globeControl1.Globe.Layers.Add(strDataPath); + // AddLayerData(strDataPath); + //} + #endregion + AddLayerData(strDataPath); + //this.Cursor = Cursors.Default; + } + } + + 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, 100); + + globeControl1.Refresh(); + } + } + + private void btn_password_edit_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_password_edit.Text); + + if (FrmChangePassword.IS_OPEN) + { + return; + } + FrmChangePassword frm = new FrmChangePassword(); + frm.ShowDialog(); + } + /// + /// 多孔管线入库 + /// + /// + /// + private void buttonItem9_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL4_2.Text); + + if (ds == null) + { + MessageBox.Show("请先连接数据库", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + ConnectDB(null, null); + } + if (ds == null) + return; + + FrmMultiPipelineModelDB frm = new FrmMultiPipelineModelDB(globeControl1, ds); + if (frm.ShowDialog() == DialogResult.OK) + { + addNodeToLayerManagerNode(frm.rukuLayer); + } + //frm.Show(); + } + private void 导出CADToolStripMenuItem1_Click(object sender, EventArgs e) + { + TreeNode node = layerNodeContexMenu.Tag as TreeNode; + if (node == null) + { + MessageBox.Show("请在左侧节点集中选择要导出的图层", "提示"); + return; + } + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(node.Text.Trim()); + if (layer == null || layer.GetAllFeatures().Length <= 0) + { + MessageBox.Show("要导出的图层为空", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + return; + } + string strProjectName = Utility.projectStr; + if (strProjectName != "") + { + SaveFileDialog dlg = new SaveFileDialog(); + dlg.Filter = "*.dwg|*.dwg|*.dxf|*.dxf"; + dlg.FileName = layer.Caption; + if (dlg.ShowDialog(this) == DialogResult.OK) + { + globeControl1.Globe.MemoryLayer.SaveAs(dlg.FileName); + GSOLayer newlayer = globeControl1.Globe.Layers.Add(dlg.FileName); + newlayer.RemoveAllFeature(); + int featureCount = layer.GetAllFeatures().Length; + for (int i = 0; i < featureCount; i++) + { + GSOFeature feature = layer.GetAt(i); + if (feature != null && feature.Geometry != null) + { + if (feature.Geometry.Type == EnumGeometryType.GeoPolyline3D) + { + feature.Geometry.Style = new GSOSimpleLineStyle3D(); + } + else if (feature.Geometry.Type == EnumGeometryType.GeoPolygon3D) + { + feature.Geometry.Style = new GSOSimplePolygonStyle3D(); + } + newlayer.AddFeature(feature); + } + } + newlayer.Save(); + newlayer.Dataset.DataSource.RemoveDataset(newlayer.Dataset); + globeControl1.Globe.Layers.Remove(newlayer); + MessageBox.Show("导出CAD完成!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + } + } + } + + private void buttonItemGBJC_Click(object sender, EventArgs e) + { + FrmGBJC gb = new FrmGBJC(globeControl1, globeControl2, layerTemp, layerTemp2); + gb.Show(this); + } + + #region 右屏管纵数据控制 + private void 五十米主干道ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = true; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + + private void 三十六米次干道ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = true; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + + private void 四十二米次干道ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = true; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + + private void 二十四米一块板ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = true; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + + private void 二十四米三块板ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = true; + } + + private void 二十四米停车带ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = true; + lendendGZ24_3.Visible = false; + } + + private void 二十六米大堤路ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = true; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + + private void 清除管纵数据ToolStripMenuItem_Click(object sender, EventArgs e) + { + ClearGZData(); + } + + private void ClearGZData() + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + #endregion + + private void buttonItemPasswordReset_Click(object sender, EventArgs e) + { + Frm_password_reset reset = new Frm_password_reset(); + reset.Show(); + } + + private void pictureBox1_Paint(object sender, PaintEventArgs e) + { + int Width = this.Width; + string welcomeUser = "欢迎您:" + Utility.userName; + Graphics g = e.Graphics; + g.DrawString(welcomeUser, new Font("宋体", 12), new SolidBrush(Color.Black), Width - 180, 50); + } + + } +} \ No newline at end of file diff --git a/Cyberpipe.csproj b/Cyberpipe.csproj index 3a45ad8..d22f590 100644 --- a/Cyberpipe.csproj +++ b/Cyberpipe.csproj @@ -402,12 +402,6 @@ FrmBACKORACLE.cs - - Form - - - FrmBSQDuoBianXingStatis.cs - Form @@ -1271,9 +1265,6 @@ FrmBACKORACLE.cs - - FrmBSQDuoBianXingStatis.cs - FrmBSQStatis.cs diff --git a/FeatureStatisticsService.cs b/FeatureStatisticsService.cs index e833e5f..c7de210 100644 --- a/FeatureStatisticsService.cs +++ b/FeatureStatisticsService.cs @@ -273,19 +273,15 @@ /// 获取特定区域图层的管线列表,并将其总长度统计出来 ///
TODOLIST:将Intersects_Pipeline在MainFrm中去除 /// - /// + /// + /// 要统计的长度 /// public static GSOFeatures getLayerPipes(GSOGeoPolygon3D polygon, GSOLayer layer, out double length) { length = 0; if (layer == null) return null; - GSOFeatureLayer flayer = layer as GSOFeatureLayer; - GSOFeatureDataset fdataset = flayer.Dataset as GSOFeatureDataset; - GSOFeatures feats = null; - - feats = polygon == null?flayer.GetAllFeatures():flayer.FindFeaturesInPolygon(polygon, false); - + GSOFeatures feats = getLayerFeatures(polygon, layer); double totallength = 0.00; for (int i = 0; i < feats.Length; i++) { @@ -301,5 +297,17 @@ return feats; } + /// + /// 获取区域图层内的feature列表,MainFrm.PolygonIntersectAnalysis和此方法重复,需要整理删除 + /// + /// + /// + /// + public static GSOFeatures getLayerFeatures(GSOGeoPolygon3D polygon, GSOLayer layer) + { + if (layer == null) return null; + GSOFeatureLayer flayer = layer as GSOFeatureLayer; + return polygon == null ? flayer.GetAllFeatures() : flayer.FindFeaturesInPolygon(polygon, false); + } } } diff --git a/FrmAllWorkWellStatis.cs b/FrmAllWorkWellStatis.cs index 7bf65dc..bd0f81b 100644 --- a/FrmAllWorkWellStatis.cs +++ b/FrmAllWorkWellStatis.cs @@ -19,17 +19,7 @@ private Dictionary map = null; private GSOGlobeControl globeControl1; private GSOGeoPolygon3D polygon; - //TODOLIST:用晓伟的代理进行操作,功能拆分细化 - //public FrmAllWorkWellStatis(GSOGeoPolygon3D polygon, DataGridView dataGridViewX11, ToolStripStatusLabel toolStripNumbers1, GSOGlobeControl ctl, PanelEx p) - //{ - // InitializeComponent(); - // panel = p; - // dataGridViewX1 = dataGridViewX11; - // toolStripNumbers = toolStripNumbers1; - // globeControl1 = ctl; - // map = getAccsMap(polygon); - //} public FrmAllWorkWellStatis(GSOGlobeControl ctl,GSOGeoPolygon3D polygon, MainFrm.DataGridViewDelegate InitDataGridViewX1) { InitializeComponent(); @@ -117,8 +107,9 @@ sql = "select " + getpipeLineFields.getFields(layername, globeControl1) + " from " + layer.Name; sql += " where 1>2 "; - for (int i = 0; i < fs.Length && fs[i].GetFieldDefn("编号") != null; i++) + for (int i = 0; i < fs.Length; i++) { + if (fs[i].GetFieldDefn("编号") == null) continue; sql += " or 编号 = '" + fs[i].GetValue("编号").ToString() + "'"; } diff --git a/FrmBSQDuoBianXingStatis.Designer.cs b/FrmBSQDuoBianXingStatis.Designer.cs deleted file mode 100644 index bda6842..0000000 --- a/FrmBSQDuoBianXingStatis.Designer.cs +++ /dev/null @@ -1,87 +0,0 @@ -namespace Cyberpipe -{ - partial class FrmBSQDuoBianXingStatis - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea1 = new System.Windows.Forms.DataVisualization.Charting.ChartArea(); - this.groupBox1 = new System.Windows.Forms.GroupBox(); - this.chart1 = new System.Windows.Forms.DataVisualization.Charting.Chart(); - this.groupBox1.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.chart1)).BeginInit(); - this.SuspendLayout(); - // - // groupBox1 - // - this.groupBox1.Controls.Add(this.chart1); - this.groupBox1.Dock = System.Windows.Forms.DockStyle.Fill; - this.groupBox1.Location = new System.Drawing.Point(0, 0); - this.groupBox1.Name = "groupBox1"; - this.groupBox1.Size = new System.Drawing.Size(592, 384); - this.groupBox1.TabIndex = 0; - this.groupBox1.TabStop = false; - this.groupBox1.Text = "统计结果信息"; - // - // chart1 - // - chartArea1.AxisX.MajorGrid.Enabled = false; - chartArea1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(191)))), ((int)(((byte)(219)))), ((int)(((byte)(255))))); - chartArea1.BackGradientStyle = System.Windows.Forms.DataVisualization.Charting.GradientStyle.TopBottom; - chartArea1.Name = "ChartArea1"; - this.chart1.ChartAreas.Add(chartArea1); - this.chart1.Dock = System.Windows.Forms.DockStyle.Fill; - this.chart1.Location = new System.Drawing.Point(3, 17); - this.chart1.Name = "chart1"; - this.chart1.Size = new System.Drawing.Size(586, 364); - this.chart1.TabIndex = 0; - this.chart1.Text = "chart1"; - // - // FrmBSQDuoBianXingStatis - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(592, 384); - this.Controls.Add(this.groupBox1); - this.DoubleBuffered = true; - this.Name = "FrmBSQDuoBianXingStatis"; - this.ShowIcon = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; - this.Text = "多边形区域统计"; - this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FrmBSQDuoBianXingStatis_FormClosing); - this.Load += new System.EventHandler(this.FrmBSQDuoBianXingStatis_Load); - this.groupBox1.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)(this.chart1)).EndInit(); - this.ResumeLayout(false); - - } - - #endregion - - private System.Windows.Forms.GroupBox groupBox1; - private System.Windows.Forms.DataVisualization.Charting.Chart chart1; - } -} \ No newline at end of file diff --git a/FrmBSQDuoBianXingStatis.cs b/FrmBSQDuoBianXingStatis.cs deleted file mode 100644 index 80b567e..0000000 --- a/FrmBSQDuoBianXingStatis.cs +++ /dev/null @@ -1,179 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Windows.Forms; -using DevComponents.DotNetBar; -using System.Data.SqlClient; -using System.Windows.Forms.DataVisualization.Charting; -using GeoScene.Data; -using GeoScene.Engine; -using GeoScene.Globe; -using System.Data.OracleClient; - -namespace Cyberpipe -{ - public partial class FrmBSQDuoBianXingStatis : Office2007Form - { - Dictionary bsq = new Dictionary(); - Dictionary bsq1 = new Dictionary(); - static FrmBSQDuoBianXingStatis frm; - GSOGlobeControl globeControl1; - List list = new List(); - public static List pipeLists = new List(); - - string[] codeStr = new string[50]; - string[] nameStr = new string[30]; - public static List typeLists; - - public FrmBSQDuoBianXingStatis(Dictionary workWellLen, GSOGlobeControl glb,List _list) - { - InitializeComponent(); - bsq = workWellLen; - globeControl1 = glb; - list = _list; - } - - private void FrmBSQDuoBianXingStatis_Load(object sender, EventArgs e) - { - FrmBSQDuoBianXingStatisFenLei(); - try - { - chart1.Series.Add("标识器"); - chart1.ChartAreas["ChartArea1"].AxisX.Title = "标识器类型"; - chart1.ChartAreas["ChartArea1"].AxisY.Title = "标识器数量"; - chart1.ChartAreas["ChartArea1"].AxisX.Interval = 1; - chart1.Series["标识器"].ChartType = SeriesChartType.Column; - chart1.Series["标识器"]["DrawingStyle"] = "Cylinder"; - - chart1.Series["标识器"].Points.DataBindXY(bsq1.Keys, bsq1.Values); - if (bsq1.Values.Count == 0) - { - MessageBox.Show("该区域没有标识器信息", "提示"); - this.Close(); - return; - } - else - { - for (int m = 0; m < bsq1.Values.Count; m++) - { - if (chart1.Series["标识器"].Points[m].YValues[0].ToString() != "0") - { - chart1.Series["标识器"].Points[m].Label = chart1.Series[0].Points[m].YValues[0].ToString(); - } - } - } - } - catch (Exception ex) - { - //ErrorLog.PublishError(ex); - } - } - - private void FrmBSQDuoBianXingStatis_FormClosing(object sender, FormClosingEventArgs e) - { - frm = null; - globeControl1.Globe.ClearAnalysis(); - globeControl1.Globe.MemoryLayer.RemoveAllFeature(); - } - - - private void FrmBSQDuoBianXingStatisFenLei() - { - try - { - bool flag2 = false; - for (int i = 0; i < Utility.listPipelineType.Count; i++) - { - - for (int j = 0; j < pipeLists.Count; j++) - { - if (pipeLists[j] == Utility.listPipelineType[i].type) - { - flag2 = true; - break; - } - } - if (!flag2 && Utility.listPipelineType[i].type != "标识器") - { - pipeLists.Add(Utility.listPipelineType[i].type); - } - flag2 = false; - } - - typeLists = new List(); - for (int num = 0; num < pipeLists.Count; num++) - { - typeList ls = new typeList(0, pipeLists[num]); - typeLists.Add(ls); - } - - GSOFeatures fs = list[0]; - string pipetype = "标识器"; - foreach (string key in bsq.Keys) - { - if (key.StartsWith(pipetype)) - { - pipetype = key; - break; - } - } - if (fs.Length > 0) - { - for (int i = 0; i < fs.Length; i++) - { - string str = fs[i].GetValue("对象名称").ToString(); - codeStr = str.Split(','); - for (int n = 0; n < codeStr.Length; n++) - { - for (int ii = 0; ii < Utility.listPipelineType.Count; ii++) - { - if (Utility.listPipelineType[ii].code == codeStr[n]) - { - for (int m = 0; m < typeLists.Count; m++) - { - if (Utility.listPipelineType[ii].type == typeLists[m].type) - { - typeLists[m].num++; - break; - } - } - break; - } - } - } - } - } - - for (int i = 0; i < typeLists.Count; i++) - { - if (typeLists[i].num > 0) - bsq1.Add(typeLists[i].type, typeLists[i].num); - } - - } - catch (Exception ex) - { - //ErrorLog.PublishError(ex); - //MessageBox.Show(ex.Message); - } - - } - public class typeList - { - public int num; - public string type; - - public typeList(int _num, string _type) - { - num = _num; - type = _type; - } - } - - - } -} diff --git a/FrmBSQDuoBianXingStatis.resx b/FrmBSQDuoBianXingStatis.resx deleted file mode 100644 index 1af7de1..0000000 --- a/FrmBSQDuoBianXingStatis.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/FrmBSQStatis.Designer.cs b/FrmBSQStatis.Designer.cs index 2509c7d..ee9b1e7 100644 --- a/FrmBSQStatis.Designer.cs +++ b/FrmBSQStatis.Designer.cs @@ -57,6 +57,7 @@ this.ShowIcon = false; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "标识器全区域统计"; + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FrmBSQStatis_FormClosing); this.Load += new System.EventHandler(this.FrmBSQStatis_Load); ((System.ComponentModel.ISupportInitialize)(this.chartStatis)).EndInit(); this.ResumeLayout(false); diff --git a/FrmBSQStatis.cs b/FrmBSQStatis.cs index 4b25eda..e7c4926 100644 --- a/FrmBSQStatis.cs +++ b/FrmBSQStatis.cs @@ -18,94 +18,18 @@ { public partial class FrmBSQStatis : Office2007Form { - public Dictionary bsq = new Dictionary(); - //SqlConnection conn; - public static List typeLists; - OracleConnection conn; - string connectString; + private Dictionary bsq = new Dictionary(); + private GSOGlobeControl globeControl1; + private GSOGeoPolygon3D polygon; - public FrmBSQStatis() + public FrmBSQStatis(GSOGlobeControl globeControl1,GSOGeoPolygon3D polygon) { + this.globeControl1 = globeControl1; + this.polygon = polygon; InitializeComponent(); - BSQNumStatis(); + bsq = getBSQNameAndNumMap(polygon); } - string[] codeStr = new string[50]; - string[] nameStr = new string[30]; - public static List pipeLists = new List(); - - private void BSQNumStatis() - { - bool flag2 = false; - for (int i = 0; i < Utility.listPipelineType.Count; i++) - { - for (int j = 0; j < pipeLists.Count; j++) - { - if (pipeLists[j] == Utility.listPipelineType[i].type) - { - flag2 = true; - break; - } - } - if (!flag2 && Utility.listPipelineType[i].type != "标识器") - { - pipeLists.Add(Utility.listPipelineType[i].type); - } - flag2 = false; - } - - typeLists = new List(); - for (int num = 0; num 0) - bsq.Add(typeLists[i].type, typeLists[i].num); - } - - } - catch (Exception ex) - { - - } - } private void FrmBSQStatis_Load(object sender, EventArgs e) { @@ -136,17 +60,88 @@ } } - public class typeList + private Dictionary getBSQNameAndNumMap(GSOGeoPolygon3D polygon) { - public int num; - public string type; - public typeList(int _num, string _type) + Dictionary result = new Dictionary(); + Dictionary codeAndType = new Dictionary(); + //得到type的种类 + for (int i = 0; i < Utility.listPipelineType.Count; i++) { - num = _num; - type = _type; + if (!result.ContainsKey(Utility.listPipelineType[i].type) && Utility.listPipelineType[i].type != "标识器") + { + result.Add(Utility.listPipelineType[i].type, 0); + codeAndType.Add(Utility.listPipelineType[i].code, Utility.listPipelineType[i].type); + } + } + + return polygon == null ? getAllAreaMap(result, codeAndType) : getBSQMapByPolygon(polygon, result, codeAndType); + } + public Dictionary getAllAreaMap(Dictionary typeAndCount,Dictionary codeAndType) + { + try + { + OracleConnection conn = OledbHelper.sqlConnection(); + conn.Open(); + OracleCommand cmd; + cmd = new OracleCommand("select 对象类型 from 标识器", conn); + OracleDataReader dr = cmd.ExecuteReader(); + + while (dr.Read()) + { + string str = Convert.ToString(dr["对象类型"]); + if (str == null) continue; + foreach (string key in codeAndType.Keys) + { + if (str.Contains(key)) + { + typeAndCount[codeAndType[key]] += 1; + } + } + } + conn.Close(); + } + catch (Exception ex) + { + LogHelper.WriteLog(typeof(FrmBSQStatis),ex.Message.ToString()); + } + return typeAndCount; + } + + + public Dictionary getBSQMapByPolygon(GSOGeoPolygon3D polygon,Dictionary typeAndCount, Dictionary codeAndType) + { + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption("标识器"); + GSOFeatures bsqFs = FeatureStatisticsService.getLayerFeatures(polygon, layer); + if (bsqFs == null || bsqFs.Length <= 0) { + LogHelper.WriteLog(typeof(FrmBSQStatis),"标识器图层下的Feature为空"); + return null; + } + + for (int i = 0; i < bsqFs.Length; i++) + { + string str = bsqFs[i].GetValue("对象类型").ToString(); + + foreach (string key in codeAndType.Keys) + { + if (str.Contains(key)) + { + typeAndCount[codeAndType[key]] += 1; + } + } + } + + return typeAndCount; + } + + private void FrmBSQStatis_FormClosing(object sender, FormClosingEventArgs e) + { + globeControl1.Globe.ClearAnalysis(); + } + + } } diff --git a/FrmValveStatistics.cs b/FrmValveStatistics.cs index 672f97a..17dad6c 100644 --- a/FrmValveStatistics.cs +++ b/FrmValveStatistics.cs @@ -120,6 +120,7 @@ sql += " where 1>2 "; for (int i = 0; i < fs.Length; i++) { + if (fs[i].GetValue("编号") == null) continue; sql += " or 编号 = '" + fs[i].GetValue("编号").ToString() + "'"; } diff --git a/FrmpipeDeepstatis.cs b/FrmpipeDeepstatis.cs index 879801a..c7edbc3 100644 --- a/FrmpipeDeepstatis.cs +++ b/FrmpipeDeepstatis.cs @@ -164,88 +164,6 @@ } } - //if (clbPipeLine.CheckedItems.Count > 0) - //{ - // if (dataGridViewX2.Rows.Count > 0) - // { - // for (int i = 0; i < clbPipeLine.CheckedItems.Count; i++) - // { - // GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(clbPipeLine.CheckedItems[i].ToString()); - // GSOFeatureLayer flayer = layer as GSOFeatureLayer; - // GSOFeatures feats = new GSOFeatures(); - // if (polygon == null) - // feats = flayer.GetAllFeatures(); - // else - // feats = flayer.FindFeaturesInPolygon(polygon, false); - // for (int j = 0; j < dataGridViewX2.Rows.Count; j++) - // { - // double totalLength = 0.00; - // int ncount = 0; - // for (int m = 0; m < feats.Length; m++) - // { - // GSOFeature feat = feats[m]; - // float radius = feat.GetFieldAsFloat("起始埋深"); - // bool upCompare = true; - // bool downCompare = true; - // if (dataGridViewX2.Rows[j].Cells["下限"].Value != null || dataGridViewX2.Rows[j].Cells["上限"].Value != null) - // { - // if (dataGridViewX2.Rows[j].Cells["下限"].Value != null) - // { - // if (dataGridViewX2.Rows[j].Cells["下限"].Value.ToString() != "") - // { - // if (radius >= Convert.ToDouble(dataGridViewX2.Rows[j].Cells["下限"].Value)) - // { - // downCompare = true; - // } - // else - // downCompare = false; - // } - // } - // if (dataGridViewX2.Rows[j].Cells["上限"].Value != null) - // { - // if (dataGridViewX2.Rows[j].Cells["上限"].Value.ToString() != "") - // { - // if (radius <= Convert.ToDouble(dataGridViewX2.Rows[j].Cells["上限"].Value)) - // { - // upCompare = true; - // } - // else - // upCompare = false; - // } - // } - // if (upCompare && downCompare) - // { - // GSOGeoPolyline3D line = feat.Geometry as GSOGeoPolyline3D; - // double length = line.GetSpaceLength(true, 6378137); - // totalLength += length; - // ncount += 1; - // } - // } - // } - // if (dataGridViewX2.Rows[j].Cells["下限"].Value != null || dataGridViewX2.Rows[j].Cells["上限"].Value != null) - // { - // DataGridViewRow row = new DataGridViewRow(); - // int index = dataGridViewX1.Rows.Add(row); - // row = dataGridViewX1.Rows[index]; - // row.Cells["图层名称"].Value = layer.Caption; - // row.Cells["埋深范围"].Value = dataGridViewX2.Rows[j].Cells["下限"].Value + "-" + dataGridViewX2.Rows[j].Cells["上限"].Value; - // row.Cells["条数"].Value = ncount; - // row.Cells["总长度"].Value =Math.Round(totalLength,2); - - // dic.Add(layer.Caption + "," + row.Cells["埋深范围"].Value.ToString()+","+row.Cells["总长度"].Value.ToString(), ncount); - // } - // } - // } - // } - // else - // { - // MessageBox.Show("请添加分段!"); - // } - //} - //else - //{ - // MessageBox.Show("请选择图层!"); - //} showPipeWidget(); } catch (Exception ex) diff --git a/FrmpipeMaterialGather.cs b/FrmpipeMaterialGather.cs index b7ab1d2..3e9f45d 100644 --- a/FrmpipeMaterialGather.cs +++ b/FrmpipeMaterialGather.cs @@ -180,79 +180,6 @@ } - //if (clbPipeLine.CheckedItems.Count > 0) - //{ - // for (int i = 0; i < clbPipeLine.CheckedItems.Count; i++) - // { - // GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(clbPipeLine.CheckedItems[i].ToString()); - // GSOFeatureLayer flayer = layer as GSOFeatureLayer; - // GSOFeatures feats = new GSOFeatures(); - // if (polygon == null) - // feats = flayer.GetAllFeatures(); - // else - // feats = flayer.FindFeaturesInPolygon(polygon, false); - // List lstDiameter = new List(); - - // for (int j = 0; j < clbmaterials.CheckedItems.Count; j++) - // { - // if (!lstDiameter.Contains(clbmaterials.CheckedItems[j].ToString())) - // { - // lstDiameter.Add(clbmaterials.CheckedItems[j].ToString()); - // } - // } - // //lstDiameter.Sort(); - // if (lstDiameter.Count > 0) - // { - // for (int m = 0; m < lstDiameter.Count; m++) - // { - // double totalLength = 0.00; - // int ncount = 0; - // for (int j = 0; j < feats.Length; j++) - // { - // if (lstDiameter[m] != "无") - // { - // if (feats[j].GetFieldAsString("材质") == lstDiameter[m]) - // { - // GSOGeoPolyline3D line = feats[j].Geometry as GSOGeoPolyline3D; - // if (line != null) - // { - // double length = line.GetSpaceLength(true, 6378137); - // totalLength += length; - // ncount += 1; - // } - // } - // } - // else - // { - // if (feats[j].GetFieldAsString("材质") == "") - // { - // GSOGeoPolyline3D line = feats[j].Geometry as GSOGeoPolyline3D; - // if (line != null) - // { - // double length = line.GetSpaceLength(true, 6378137); - // totalLength += length; - // ncount += 1; - // } - // } - // } - // } - // DataGridViewRow row = new DataGridViewRow(); - // int index = dataGridViewX1.Rows.Add(row); - // row = dataGridViewX1.Rows[index]; - // row.Cells["图层名称"].Value = layer.Caption; - // row.Cells["材质"].Value = lstDiameter[m]; - // row.Cells["条数"].Value = ncount; - // row.Cells["总长度"].Value = Math.Round(totalLength); - - // dic.Add(layer.Caption + "," + row.Cells["材质"].Value.ToString(), ncount); - // } - // } - // } - //} - //else - //{ - // MessageBox.Show("请选择图层!"); - //} showPipeWidget(); } catch (Exception ex) diff --git a/Frmpipediameterstatis.cs b/Frmpipediameterstatis.cs index 9953ac0..aa482d8 100644 --- a/Frmpipediameterstatis.cs +++ b/Frmpipediameterstatis.cs @@ -27,12 +27,9 @@ frm = new Frmpipediameterstatis(_globeControl1, pipeLayers, visibleId); frm.Show(_globeControl1.Parent); } - else + else if (frm.WindowState == FormWindowState.Minimized) { - if (frm.WindowState == FormWindowState.Minimized) - { - frm.WindowState = FormWindowState.Normal; - } + frm.WindowState = FormWindowState.Normal; } } @@ -208,7 +205,8 @@ } catch (Exception ex) { - MessageBox.Show(ex.Message); + LogHelper.WriteLog(typeof(Frmpipediameterstatis), ex.Message); + //MessageBox.Show(ex.Message); LogError.PublishError(ex); } } @@ -290,76 +288,77 @@ /// private void btnExport_Click(object sender, EventArgs e) { - if (dataGridViewX1.Rows.Count > 0) + if (dataGridViewX1.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 = DateTime.Now.ToString("yyyyMMdd") + ".xls"; - if (dlg.ShowDialog() == DialogResult.OK) + MessageBox.Show("统计结果为空,请重新统计之后再导出Excel!", "提示"); + return; + } + + SaveFileDialog dlg = new SaveFileDialog(); + dlg.Filter = "Excel files (*.xls)|*.xls"; + dlg.FilterIndex = 0; + dlg.RestoreDirectory = true; + //dlg.CreatePrompt = true; + dlg.Title = "保存为Excel文件"; + dlg.FileName = 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 { - Stream myStream; - myStream = dlg.OpenFile(); - StreamWriter sw = new StreamWriter(myStream, System.Text.Encoding.GetEncoding(-0)); - string columnTitle = ""; - try + sw.WriteLine("日期:" + DateTime.Now.ToString("yyyy-MM-dd")); + + //写入列标题 + for (int i = 0; i < dataGridViewX1.ColumnCount; i++) { - sw.WriteLine("日期:" + DateTime.Now.ToString("yyyy-MM-dd")); - - //写入列标题 - for (int i = 0; i < dataGridViewX1.ColumnCount; i++) + if (i > 0) { - if (i > 0) - { - columnTitle += "\t"; - } - columnTitle += dataGridViewX1.Columns[i].HeaderText; + columnTitle += "\t"; } - sw.WriteLine(columnTitle); - - //写入列内容 - for (int j = 0; j < dataGridViewX1.Rows.Count; j++) - { - string columnValue = ""; - for (int k = 0; k < dataGridViewX1.Columns.Count; k++) - { - if (k > 0) - { - columnValue += "\t"; - } - if (dataGridViewX1.Rows[j].Cells[k].Value == null) - columnValue += ""; - else - columnValue += dataGridViewX1.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); - } + columnTitle += dataGridViewX1.Columns[i].HeaderText; } - catch (Exception ex) + sw.WriteLine(columnTitle); + + //写入列内容 + for (int j = 0; j < dataGridViewX1.Rows.Count; j++) { - MessageBox.Show(ex.ToString()); + string columnValue = ""; + for (int k = 0; k < dataGridViewX1.Columns.Count; k++) + { + if (k > 0) + { + columnValue += "\t"; + } + if (dataGridViewX1.Rows[j].Cells[k].Value == null) + columnValue += ""; + else + columnValue += dataGridViewX1.Rows[j].Cells[k].Value.ToString().Trim(); + } + + sw.WriteLine(columnValue); } - finally + sw.Close(); + myStream.Close(); + if (MessageBox.Show("导出Excel文件成功!是否打开?", "提示", MessageBoxButtons.YesNo) == DialogResult.Yes) { - sw.Close(); - myStream.Close(); + System.Diagnostics.Process.Start(dlg.FileName); } } + catch (Exception ex) + { + MessageBox.Show(ex.ToString()); + } + finally + { + sw.Close(); + myStream.Close(); + } } - else - { - MessageBox.Show("统计结果为空,请重新统计之后再导出Excel!","提示"); - } + + } /// /// 绘制区域分段统计 diff --git a/MainFrm.cs b/MainFrm.cs index 0b7e393..9bfb70e 100644 --- a/MainFrm.cs +++ b/MainFrm.cs @@ -2667,12 +2667,195 @@ FrmBaseLineProfillAnalysis dlg = new FrmBaseLineProfillAnalysis(globeControl1.Globe, e.Polyline); dlg.Show(this); globeControl1.Globe.ClearLastTrackPolyline(); + /* + FrmRoadHDM f = new FrmRoadHDM(); + f.Show() + * **/ } else { } trackPolylineEndMode = EnumTrackPolylineEndMode.Default_Analysis; + /* + ArrayList arraylistPoint = new ArrayList(); + ArrayList arraylistLine = new ArrayList(); + + // globeControl1.Globe.ClearLastTrackPolyline(); + + if (e.Polyline != null) + { + //横断面分析 + if (buttonItemFX2_1.Checked || buttonItemFX2_3.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 (buttonItemFX2_1.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 (buttonItemFX2_4.Checked) + { + FrmBaseLineProfillAnalysis dlg = new FrmBaseLineProfillAnalysis(globeControl1.Globe, e.Polyline); + dlg.Show(this); + globeControl1.Globe.ClearLastTrackPolyline(); + } + else if (buttonItemFX4_3.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(); + * **/ } #endregion @@ -2713,16 +2896,20 @@ case "valvequery": FrmValveStatistics frm = new FrmValveStatistics(globeControl1,polygon, new DataGridViewDelegate(InitDataGridViewX1)); frm.Show(this); + //panelEx6.Visible = true; + toolStripFeatureLength.Text = ""; globeControl1.Globe.Action = EnumAction3D.ActionNull; break; case "PipelineDistanceStatistics": + FrmAllPipelineStatis frm1 = new FrmAllPipelineStatis(globeControl1, polygon, new DataGridViewDelegate(InitDataGridViewX1), m_PipelineLayerNames); frm1.Show(this); globeControl1.Globe.Action = EnumAction3D.ActionNull; break; case "PipelineSpatialQuery": + FrmAllPipelineStatis.ShowForm(globeControl1,polygon,new DataGridViewDelegate(InitDataGridViewX1),m_PipelineLayerNames); globeControl1.Globe.ClearAnalysis(); globeControl1.Globe.Action = EnumAction3D.ActionNull; @@ -2771,18 +2958,19 @@ break; case "BSQDuoBianXiangStatis": - GSOFeature f2 = new GSOFeature(); - f2.Geometry = e.Polygon; - f2.Geometry.AltitudeMode = EnumAltitudeMode.Absolute; - globeControl1.Globe.MemoryLayer.AddFeature(f2); - f2.Geometry.MoveZ(3); - workWellLen.Clear(); - List listBSQ = new List(); + //GSOFeature f2 = new GSOFeature(); + //f2.Geometry = e.Polygon; + //f2.Geometry.AltitudeMode = EnumAltitudeMode.Absolute; + //globeControl1.Globe.MemoryLayer.AddFeature(f2); + //f2.Geometry.MoveZ(3); + //workWellLen.Clear(); + //List listBSQ = new List(); - GSOFeatures bsqFeatures = PolygonIntersectAnalysis(e.Polygon, "标识器"); - listBSQ.Add(bsqFeatures); + //GSOFeatures bsqFeatures = PolygonIntersectAnalysis(e.Polygon, "标识器"); + //listBSQ.Add(bsqFeatures); - FrmBSQDuoBianXingStatis bsqFrm = new FrmBSQDuoBianXingStatis(workWellLen, globeControl1, listBSQ); + //FrmBSQDuoBianXingStatis bsqFrm = new FrmBSQDuoBianXingStatis(workWellLen, globeControl1, listBSQ); + FrmBSQStatis bsqFrm = new FrmBSQStatis(globeControl1,e.Polygon); bsqFrm.Show(this); globeControl1.Globe.Action = EnumAction3D.ActionNull; break; @@ -4351,6 +4539,26 @@ } /// + /// 在窗体的底部状态栏上显示 综合管线条件查询结果 + /// + /// + /// + 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 + " 条记录 | "; + } + } + + /// /// 统计管线的里程数 /// /// @@ -6824,6 +7032,54 @@ } /// + /// 创建label要素 功能 + /// + /// 添加label要素的feature + /// feature的位置 + /// label要素名字 + /// feature名字 + /// label要素距离点的位置 + /// + 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; + } + + + + /// /// 获取指定两点组成的线的长度 功能 /// /// @@ -9266,8 +9522,19 @@ //日志记录 LogManager.saveLog(Utility.userName, "管线长度统计"); + //pipeLineDis.Clear(); + //List list = new List(); + //for (int i = 0; i < m_PipelineLayerNames.Count; i++) + //{ + // GSOFeatures fs = Intersects_Pipeline(null, m_PipelineLayerNames[i]); + // if (fs!=null) + // list.Add(fs); + //} + + //FrmAllPipelineStatis frm = new FrmAllPipelineStatis(0, pipeLineDis, list, globeControl1, new DataGridViewDelegate(InitDataGridViewX1)); FrmAllPipelineStatis frm = new FrmAllPipelineStatis(globeControl1,null, new DataGridViewDelegate(InitDataGridViewX1), m_PipelineLayerNames); frm.Show(this); + } /// /// 管线长度绘制区域统计 @@ -9293,6 +9560,25 @@ //日志记录 LogManager.saveLog(Utility.userName, "阀门数量统计"); + //workWellLen.Clear(); + //List list = new List(); + ////找到所有阀门 + //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, globeControl1, new DataGridViewDelegate(InitDataGridViewX1)); FrmValveStatistics frm = new FrmValveStatistics(globeControl1, null, new DataGridViewDelegate(InitDataGridViewX1)); frm.Show(this); @@ -9318,9 +9604,7 @@ /// /// private void buttonItemTJ3_ALL_Click(object sender, EventArgs e) - { - //日志记录 - LogManager.saveLog(Utility.userName, "井盖数量统计"); + { FrmAllWorkWellStatis frm = new FrmAllWorkWellStatis(globeControl1, null, new DataGridViewDelegate(InitDataGridViewX1)); frm.Show(this); } @@ -9333,7 +9617,7 @@ { //日志记录 LogManager.saveLog(Utility.userName, "井盖数量统计"); - + trackflag = "workwellquery"; globeControl1.Globe.Action = EnumAction3D.TrackPolygon; globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; @@ -11142,7 +11426,7 @@ Cyberpipe.Forms.FrmPipelineModelDB frm = new Cyberpipe.Forms.FrmPipelineModelDB(globeControl1, ds); if (frm.ShowDialog() == DialogResult.OK) { - //addNodeToLayerManagerNode(frm.rukuLayer); + addNodeToLayerManagerNode(frm.rukuLayer); } } /// @@ -12377,7 +12661,8 @@ private void 标识器分类统计ToolStripMenuItem_Click(object sender, EventArgs e) { globeControl1.Globe.Action = EnumAction3D.ActionNull; - FrmBSQStatis bsqStatis = new FrmBSQStatis(); + FrmBSQStatis bsqStatis = new FrmBSQStatis(globeControl1,null); + //FrmBSQStatis bsqStatis = new FrmBSQStatis(); bsqStatis.Show(this); } /// diff --git a/MainFrm.cs.BACKUP.9016.cs b/MainFrm.cs.BACKUP.9016.cs new file mode 100644 index 0000000..28cb7fa --- /dev/null +++ b/MainFrm.cs.BACKUP.9016.cs @@ -0,0 +1,13074 @@ +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; + + GSOBalloon featureTooltip2; + GSOBalloonEx balloonEx2; + + GSOLayer layerTemp; + GSOLayer layerTemp2; + FrmShResult frmShResult = null; + FrmRedlineResult frmredResult = null; + FrmMnModify frmModify = null; + public bool frmRedlineResult = false; + public bool boolfrmShResult = false; + public bool boolfrmModify = false; + + List m_PipelineLayerNames = new List();//线图层名称 + List workwellLayerNames = new List();//工井图层名称 + List valueLayerNames = new List();//阀门图层名称 + List instrumenLayerNames = new List();//附属物图层名称 + List pipefittingLayerNames = new List();//管件图层名称 + List sgPipeLayersNames = new List();//施工管线图层名称 + 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 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; + public string redLayer = null; + //GSOLayer redLayer1 = null; + bool redSH = false; + string redDt = "红线"; + //双屏对比 + //bool zhanshi=false; + Thread t = null; + private GSOHudButton legendSC;//定义图例 + private GSOHudButton legendSG;//定义图例 + //管纵图 + private GSOHudButton lendendGZ50; + private GSOHudButton lendendGZ36; + private GSOHudButton lendendGZ42; + private GSOHudButton lendendGZ24_1; + private GSOHudButton lendendGZ24_2; + private GSOHudButton lendendGZ24_3; + private GSOHudButton lendendGZ26; + + GSOGeoPoint3D bsqPT; + + FrmYJSHTC frmSh = null;//一键审核窗口全局变量wxl + FrmWait frmWait = null;//一键审核等待窗口 + //FrmWait frmWait2 = null;//文档操作等待窗口 + + float mouseDownX1,mouseDownY1; + float mouseDownX2,mouseDownY2; + /// + /// + /// + 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; + + featureTooltip2 = new GSOBalloon(globeControl2.Handle); + balloonEx2 = new GSOBalloonEx(globeControl2.Handle); + Utility.SetBallons(featureTooltip, balloonEx); + + panelOfTable.Height = 200; + + RigthMenuSet(); + + MenuSet(); + + } + /// + /// 右屏中添加管纵图片 + /// + private void AddGZ() + { + + lendendGZ50 = new GSOHudButton(); + lendendGZ50.SetImage(Application.StartupPath + "/Resource/管纵/50.png"); + lendendGZ50.SetOffset(0, 0); + lendendGZ50.MinOpaque = 1; + lendendGZ50.MaxOpaque = 1; + lendendGZ50.FadeOut = false; + lendendGZ50.Name = "lendendGZ50"; + lendendGZ50.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ50); + lendendGZ50.Visible = false; + + lendendGZ36 = new GSOHudButton(); + lendendGZ36.SetImage(Application.StartupPath + "/Resource/管纵/36.png"); + lendendGZ36.SetOffset(0, 0); + lendendGZ36.MinOpaque = 1; + lendendGZ36.MaxOpaque = 1; + lendendGZ36.FadeOut = false; + lendendGZ36.Name = "lendendGZ36"; + lendendGZ36.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ36); + lendendGZ36.Visible = false; + + lendendGZ42 = new GSOHudButton(); + lendendGZ42.SetImage(Application.StartupPath + "/Resource/管纵/42.png"); + lendendGZ42.SetOffset(0, 0); + lendendGZ42.MinOpaque = 1; + lendendGZ42.MaxOpaque = 1; + lendendGZ42.FadeOut = false; + lendendGZ42.Name = "lendendGZ42"; + lendendGZ42.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ42); + lendendGZ42.Visible = false; + + lendendGZ24_1 = new GSOHudButton(); + lendendGZ24_1.SetImage(Application.StartupPath + "/Resource/管纵/24_1.png"); + lendendGZ24_1.SetOffset(0, 0); + lendendGZ24_1.MinOpaque = 1; + lendendGZ24_1.MaxOpaque = 1; + lendendGZ24_1.FadeOut = false; + lendendGZ24_1.Name = "lendendGZ24_1"; + lendendGZ24_1.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ24_1); + lendendGZ24_1.Visible = false; + + lendendGZ24_2 = new GSOHudButton(); + lendendGZ24_2.SetImage(Application.StartupPath + "/Resource/管纵/24_2.png"); + lendendGZ24_2.SetOffset(0, 0); + lendendGZ24_2.MinOpaque = 1; + lendendGZ24_2.MaxOpaque = 1; + lendendGZ24_2.FadeOut = false; + lendendGZ24_2.Name = "lendendGZ24_2"; + lendendGZ24_2.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ24_2); + lendendGZ24_2.Visible = false; + + lendendGZ24_3 = new GSOHudButton(); + lendendGZ24_3.SetImage(Application.StartupPath + "/Resource/管纵/24_3.png"); + lendendGZ24_3.SetOffset(0, 0); + lendendGZ24_3.MinOpaque = 1; + lendendGZ24_3.MaxOpaque = 1; + lendendGZ24_3.FadeOut = false; + lendendGZ24_3.Name = "lendendGZ24_3"; + lendendGZ24_3.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ24_3); + lendendGZ24_3.Visible = false; + + lendendGZ26 = new GSOHudButton(); + lendendGZ26.SetImage(Application.StartupPath + "/Resource/管纵/26.png"); + lendendGZ26.SetOffset(0, 0); + lendendGZ26.MinOpaque = 1; + lendendGZ26.MaxOpaque = 1; + lendendGZ26.FadeOut = false; + lendendGZ26.Name = "lendendGZ26"; + lendendGZ26.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ26); + lendendGZ26.Visible = false; + + } + + public void RigthMenuSet() + { + if (Utility.userRole.IndexOf("清除分析") < 0) + { + toolRightMenu.Items.Remove(清除分析ToolStripMenuItem); + } + + #region 区域分析 + if (Utility.userRole.IndexOf("区域分析") < 0) + { + toolRightMenu.Items.Remove(区域分析ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("缓冲区分析") < 0) + { + 区域分析ToolStripMenuItem.DropDownItems.Remove(缓冲区分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("附属物分析") < 0) + { + 区域分析ToolStripMenuItem.DropDownItems.Remove(附属物分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("无源淹没分析") < 0) + { + 区域分析ToolStripMenuItem.DropDownItems.Remove(无源淹没分析ToolStripMenuItem); + } + } + #endregion + + #region 视域分析 + if (Utility.userRole.IndexOf("视域分析") < 0) + { + toolRightMenu.Items.Remove(视域分析ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("通视分析") < 0) + { + 视域分析ToolStripMenuItem.DropDownItems.Remove(通视分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("可视域分析") < 0) + { + 视域分析ToolStripMenuItem.DropDownItems.Remove(可视域分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("可视包络分析") < 0) + { + 视域分析ToolStripMenuItem.DropDownItems.Remove(可视包络分析ToolStripMenuItem); + } + } + #endregion + + #region 开发分析 + if (Utility.userRole.IndexOf("开挖分析") < 0) + { + toolRightMenu.Items.Remove(开挖分析ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("多边形开挖") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(多边形开挖ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("挖方量分析") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(挖方量分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("沿线开挖") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(沿线开挖ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("创建隧道") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(创建隧道ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("隐藏隧道") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(隐藏隧道ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("删除隧道") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(删除隧道ToolStripMenuItem); + } + } + #endregion + + #region 拓扑分析 + if (Utility.userRole.IndexOf("拓扑分析") < 0) + { + toolRightMenu.Items.Remove(拓扑分析ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("创建拓扑") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(创建拓扑ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("上游分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(上游分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("下游分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(下游分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("流向分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(流向分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("关阀分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(关阀分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("连通分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(连通分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("爆管分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(爆管分析ToolStripMenuItem); + } + } + #endregion + + #region 断面分析 + if (Utility.userRole.IndexOf("断面分析") < 0) + { + toolRightMenu.Items.Remove(断面分析ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("横断面分析") < 0) + { + 断面分析ToolStripMenuItem.DropDownItems.Remove(横断面分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("纵断面分析") < 0) + { + 断面分析ToolStripMenuItem.DropDownItems.Remove(纵断面分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("道路断面分析") < 0) + { + 断面分析ToolStripMenuItem.DropDownItems.Remove(道路断面分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("基线剖面分析") < 0) + { + 断面分析ToolStripMenuItem.DropDownItems.Remove(基线剖面分析ToolStripMenuItem); + } + } + #endregion + + #region 绘制区域统计 + if (Utility.userRole.IndexOf("绘制区域统计") < 0) + { + toolRightMenu.Items.Remove(绘制区域统计ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("绘制区域管线长度统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管线长度统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域阀门数量统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(阀门数量统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域井盖数量统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(井盖数量统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域管径分段统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管径分段统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域埋深分段统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(埋深分段统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域管径分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管径分类统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域材质分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(材质分类统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域附属物分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(附属物分类统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域标识器分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(标识器分类统计ToolStripMenuItem1); + } + + } + #endregion + + #region 全区域统计 + if (Utility.userRole.IndexOf("全区域统计") < 0) + { + toolRightMenu.Items.Remove(全区域统计ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("全区域管线长度统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管线长度统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域阀门数量统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(阀门数量统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域井盖数量统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(井盖数量统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域管径分段统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管径分段统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域埋深分段统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(埋深分段统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域管径分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管径分类统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域材质分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(材质分类统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域附属物分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(附属物分类统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域标识器分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(标识器分类统计ToolStripMenuItem); + } + + } + #endregion + + #region 查询 + if (Utility.userRole.IndexOf("查询") < 0) + { + toolRightMenu.Items.Remove(查询ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("空间查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(空间查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("编号查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(编号查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("坐标查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(坐标查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("管径查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(管径查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("材质查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(材质查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("基本查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(基本查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("复合查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(复合查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("关联查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(关联查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("关键字查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(关键字查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("附属物查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(附属物查询ToolStripMenuItem); + } + } + #endregion + + #region 标注 + if (Utility.userRole.IndexOf("标注") < 0) + { + toolRightMenu.Items.Remove(标注ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("标高标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(标高标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("管径标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(管径标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("埋深标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(埋深标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("坐标标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(坐标标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("距离标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(距离标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("自定义标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(自定义标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("扯旗标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(扯旗标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("坡度标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(坡度标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("属性标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(属性标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("标注管理") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(标注管理ToolStripMenuItem); + } + } + #endregion + + #region 飞行 + if (Utility.userRole.IndexOf("飞行") < 0) + { + toolRightMenu.Items.Remove(飞行ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("自定义飞行") < 0) + { + 飞行ToolStripMenuItem.DropDownItems.Remove(自定义飞行ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("飞行到目标点") < 0) + { + 飞行ToolStripMenuItem.DropDownItems.Remove(飞行到目标点ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("绕中心点飞行") < 0) + { + 飞行ToolStripMenuItem.DropDownItems.Remove(绕中心点飞行ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("绕眼睛飞行") < 0) + { + 飞行ToolStripMenuItem.DropDownItems.Remove(绕眼睛飞行ToolStripMenuItem); + } + } + #endregion + + #region 编辑 + if (Utility.userRole.IndexOf("编辑") < 0) + { + toolRightMenu.Items.Remove(编辑ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("平移对象") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(平移对象ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("升降对象") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(升降对象ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("旋转对象") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(旋转对象ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("连接管段") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(连接管段ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("导出文件") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(导出文件ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("前进") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(前进ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("后退") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(删除模型ToolStripMenuItem); + } + } + #endregion + + #region 量算 + if (Utility.userRole.IndexOf("量算") < 0) + { + toolRightMenu.Items.Remove(量算ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("水平距离") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(水平距离ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("垂直距离") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(垂直距离ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("空间距离") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(空间距离ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("地表距离") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(地表距离ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("高度量算") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(高度量算ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("水平面积") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(水平面积ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("地表面积") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(地表面积ToolStripMenuItem1); + } + } + #endregion + } + + public void MenuSet() + { + + #region 权限管理 + if (Utility.userRole.IndexOf("权限管理") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem2); + } + else + { + + if (Utility.userRole.IndexOf("用户管理") < 0) + { + btn_user_info.Visible = false; + } + if (Utility.userRole.IndexOf("角色管理") < 0) + { + btn_role_info.Visible = false; + } + if (Utility.userRole.IndexOf("资源管理") < 0) + { + btn_resc_info.Visible = false; + } + if (Utility.userRole.IndexOf("角色授权") < 0) + { + btn_role_resc.Visible = false; + } + if (Utility.userRole.IndexOf("用户授权") < 0) + { + btn_user_role.Visible = false; + } + if (Utility.userRole.IndexOf("密码修改") < 0) + { + btn_password_edit.Visible = false; + } + + } + #endregion + + #region 基础工具 + if (Utility.userRole.IndexOf("基础工具") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem1); + } + else + { + if (Utility.userRole.IndexOf("地上模式") < 0) + { + buttonItem87.Visible = false; + } + if (Utility.userRole.IndexOf("地下模式") < 0) + { + buttonItem88.Visible = false; + } + if (Utility.userRole.IndexOf("行走模式") < 0) + { + buttonItem27.Visible = false; + } + if (Utility.userRole.IndexOf("透明度设置") < 0) + { + sliderGroundTransSet1.Visible = false; + } + if (Utility.userRole.IndexOf("快速定位") < 0) + { + buttonItem91.Visible = false; + } + if (Utility.userRole.IndexOf("图层管理") < 0) + { + buttonItem1.Visible = false; + } + if (Utility.userRole.IndexOf("图例管理") < 0) + { + btnlegendSet.Visible = false; + } + if (Utility.userRole.IndexOf("全屏显示") < 0) + { + buttonItem89.Visible = false; + } + if (Utility.userRole.IndexOf("导出图片") < 0) + { + btnOutputJPG.Visible = false; + } + + } + #endregion + + #region 一键审核 + if (Utility.userRole.IndexOf("一键审核") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem11); + } + #endregion + + #region 红线审核 + if (Utility.userRole.IndexOf("红线审核") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem6); + } + #endregion + + #region 双屏对比 + if (Utility.userRole.IndexOf("双屏对比") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem9); + } + #endregion + + #region 文档管理 + if (Utility.userRole.IndexOf("文档管理") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem4); + } + #endregion + + #region 基础管理 + if (Utility.userRole.IndexOf("基础管理") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem14); + } + else + { + if (Utility.userRole.IndexOf("专题图审批") < 0) + { + buttonItemZTT3_2.Visible = false; + } + if (Utility.userRole.IndexOf("打印审批") < 0) + { + buttonItemZTT4_2.Visible = false; + } + if (Utility.userRole.IndexOf("拷贝审批") < 0) + { + buttonItemZTT5_2.Visible = false; + } + } + + #endregion + + if (ribbonControl1.Items.Count <= 0) + { + ribbonControl1.Visible = false; + } + } + + #region Fan Zhang 重构现有代码 + //初始化控件布局 + private void initLayout() + { + 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.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.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.labelX21.Width = (int)(this.labelX21.Width * myScreen); + this.labelX22.Width = (int)(this.labelX22.Width * myScreen); + this.labelX24.Width = (int)(this.labelX24.Width * myScreen); + } + sideBar1.Visible = false; + 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]); + } + + splitContainer1.Panel2Collapsed = true; + + buttonItem87.Checked = true;//默认地上模式 + ribbonTabItem1.Select(); //初始化状态为浏览 + + sideBarPanelItem3.Visible = false; + layerTree.Visible = false; + controlContainerItem3.Visible = false; + if (sideBarPanelItem4.Visible == true) + { + sideBar1.Visible = true; + controlContainerItem5.Visible = true; + } + else + { + sideBar1.Visible = false; + } + Refresh(); + sliderGroundTransSet1.Value = optiValue; + sliderItem1.Value = optiValue; + sliderItem2.Value = optiValue; + sliderItem3.Value = optiValue; + + } + + //初始化地球控件 + private void initGlobalControl() + { + //选择 + btnToolSelect = new GSOHudButton(); + btnToolSelect.SetImage(Application.StartupPath + "\\Resource\\image\\select1.png"); + btnToolSelect.FadeOut = false; + btnToolSelect.Align = EnumAlign.TopLeft; + btnToolSelect.SetOffset(20, 50); + btnToolSelect.Name = "1"; + btnToolSelect.HeightFixed = true; + btnToolSelect.WidthFixed = true; + globeControl1.Globe.AddHudControl(btnToolSelect); + globeControl2.Globe.AddHudControl(btnToolSelect); + + //浏览 + 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); + + //图例 + legend = new GSOHudButton(); + legend.SetImage(Application.StartupPath + "/Resource/图例P.jpg");//图例P + legend.SetOffset(0, 15); + legend.MinOpaque = 1; + legend.MaxOpaque = 1; + legend.FadeOut = false; + legend.Name = "legend"; + legend.Align = EnumAlign.BottomRight; + legend.Visible = false; + globeControl1.Globe.AddHudControl(legend); + + //实测 + legendSC = new GSOHudButton(); + legendSC.SetImage(Application.StartupPath + "/Resource/sc.jpg"); + legendSC.SetOffset(0, 15); + legendSC.MinOpaque = 1; + legendSC.MaxOpaque = 1; + legendSC.FadeOut = false; + legendSC.Name = "legendSC"; + legendSC.Align = EnumAlign.BottomRight; + globeControl1.Globe.AddHudControl(legendSC); + legendSC.Visible = false; + + //施工 + legendSG = new GSOHudButton(); + legendSG.SetImage(Application.StartupPath + "/Resource/sg.jpg"); + legendSG.SetOffset(0, 15); + legendSG.MinOpaque = 1; + legendSG.MaxOpaque = 1; + legendSG.FadeOut = false; + legendSG.Name = "legendSG"; + legendSG.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(legendSG); + legendSG.Visible = false; + + //管纵 + AddGZ(); + + 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; + globeControl1.Globe.IsReleaseMemOutOfView = true; + globeControl1.Globe.ControlPanel.Visible = true; + + globeControl2.Globe.UnderGroundFloor.Visible = false; + globeControl2.Globe.OverviewControl.Visible = false; + globeControl2.Globe.ScalerControl.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; + globeControl2.Globe.IsReleaseMemOutOfView = true; + globeControl2.Globe.ControlPanel.Visible = false; + + 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); + + //添加临时图层 + layerTemp = globeControl1.Globe.Layers.Add(Application.StartupPath + "\\tempLgdData.lgd"); + layerTemp2 = globeControl2.Globe.Layers.Add(Application.StartupPath + "\\tempLgdData2.lgd"); + if (layerTemp != null) + { + layerTemp.MaxVisibleAltitude = 1000; + } + + //添加城市7线图层 + 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"); + + //注册对应事件 + this.registerEvent(); + } + + //注册地球事件 + private bool registerEvent() + { + if (globeControl1 == null || globeControl2 == null) + { + return false; + } + 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); + + globeControl2.FeatureMouseClickEvent += new FeatureMouseClickEventHandler(globeControl2_FeatureMouseClickEvent); + globeControl2.CameraBeginMoveEvent += new CameraBeginMoveEventHandler(globeControl2_CameraBeginMoveEvent); + + globeControl1.MouseDoubleClick += new MouseEventHandler(globeControl1_MouseDoubleClick); + globeControl1.MouseClick += new MouseEventHandler(globeControl1_MouseClick); + globeControl1.MouseDown += new MouseEventHandler(globeControl1_MouseDown); + + globeControl2.MouseClick += new MouseEventHandler(globeControl2_MouseClick); + globeControl2.MouseDown += new MouseEventHandler(globeControl2_MouseDown); + + 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); + + return true; + } + + //加载两个地球数据 + private void loadData() + { + Thread t1 = new Thread(new ThreadStart(doLoadDataForGlobalControl1)); + t1.IsBackground = true; + t1.Start(); + + + } + + delegate void LoadDataForGlobalControl(); + + private void connectServer() + { + globeControl1.Globe.ConnectServer(Utility.serverip, Utility.serverport, "", ""); //加载locaServer中的数据 + globeControl2.Globe.ConnectServer(Utility.serverip, Utility.serverport, "", ""); //加载locaServer中的数据 + //初始化TreeView + // 勾选实测图层 + foreach (TreeNode tn in layerTree.Nodes) + { + if (tn.Nodes.Count > 0) + { + if (tn.Text == "实测数据") + { + tn.Checked = true; + foreach (TreeNode tnChild in tn.Nodes) + { + tnChild.Checked = true; + foreach (TreeNode tnGrandChild in tnChild.Nodes) + { + tnGrandChild.Checked = true; + } + } + } + } + } + } + + private void doLoadDataForGlobalControl1() + { + try + { + + globeControl1.Globe.Layers.MoveDown(10000); + //加载实测管线数据 + Utility.dataSource = globeControl1.Globe.DataManager.OpenOracleDataSource(Utility.DBServer.Trim() + "/" + Utility.dbdatabase.Trim(), "", "", Utility.userID, Utility.DBPassword); + + if (Utility.dataSource != null) + { + for (int j = 0; j < Utility.dataSource.DatasetCount; j++) + { + GSODataset dataset = Utility.dataSource.GetDatasetAt(j); + if (dataset != null && dictionaryNetLayerNameAndCaption.ContainsKey(dataset.Caption)) + { + dataset.Caption = dataset.Name; + globeControl1.Globe.Layers.Add(dataset); + } + } + } + //隐藏红线图层 + globeControl1.Globe.Layers.GetLayerByCaption("红线").Visible = false; + + //globleControl1中加载规划数据 + GSODataSource ghDS = globeControl1.Globe.DataManager.OpenOracleDataSource(Utility.ghdbip + "/" + Utility.ghdbname, "", "", Utility.ghdbuser, Utility.ghdbpwd); + if (ghDS != null) + { + for (int j = 0; j < ghDS.DatasetCount; j++) + { + GSODataset dataset = ghDS.GetDatasetAt(j); + if (dataset != null && dictionaryNetLayerNameAndCaption.ContainsKey(dataset.Caption)) + { + dataset.Caption = dataset.Name; + globeControl1.Globe.Layers.Add(dataset); + globeControl1.Globe.Layers[0].Visible = false; + } + } + } + + //globeControl1,globeControl2中加载施工数据 + GSODataSource sgDS = globeControl1.Globe.DataManager.OpenOracleDataSource(Utility.sgdbip + "/" + Utility.sgdbname, "", "", Utility.sgdbuser, Utility.sgdbpwd); + if (sgDS != null) + { + for (int m = 0; m < sgDS.DatasetCount; m++) + { + GSODataset dataset = sgDS.GetDatasetAt(m); + if (dataset != null && !dataset.Caption.Contains("SH") && dictionaryNetLayerNameAndCaption.ContainsKey(dataset.Caption)) + { + dataset.Caption = dataset.Name; + globeControl1.Globe.Layers.Add(dataset); + globeControl1.Globe.Layers[0].Visible = false; + + globeControl2.Globe.Layers.Add(dataset); + globeControl2.Globe.Layers[0].Visible = true; + } + } + } + + LoadDataForGlobalControl ss = new LoadDataForGlobalControl(connectServer); + ss(); + + } + catch (Exception ex) + { + MessageBox.Show(ex.Message); + } + } + + private void initLayerTree() + { + //加载临时图层节点 + layerManagerNode = new TreeNode(); + layerManagerNode.ImageIndex = 0; + layerManagerNode.SelectedImageIndex = 0; + layerManagerNode.Checked = true; + layerManagerNode.Text = "临时图层"; + layerTree.Nodes.Add(layerManagerNode); + + XmlDocument doc = new XmlDocument(); + doc.Load(filename); + XmlNodeList xmlLayerNodes = doc.SelectNodes("//layer"); + + foreach (XmlNode xmlLayerNode in xmlLayerNodes) + { + + //TODO LIST:创建一级TreeNode(实测、规划、施工) + TreeNode nodelayer = new TreeNode(); + string layerName = xmlLayerNode.Attributes["label"].Value; + nodelayer.Text = layerName; + nodelayer.Checked = false; + layerTree.Nodes.Add(nodelayer); + + XmlNodeList xmlChildLayerNodes = xmlLayerNode.ChildNodes; + foreach (XmlNode xmlChildLayerNode in xmlChildLayerNodes) + { + //TODO LIST:创建二级TreeNode节点 + TreeNode secondLevelNode = new TreeNode(); + string layerType = xmlChildLayerNode.Attributes["label"].Value; + secondLevelNode.Text = layerType; + + if (xmlChildLayerNode.Attributes["type"] != null) + { //道路图层特殊处理 + string type = xmlChildLayerNode.Attributes["type"].Value; + secondLevelNode.Tag = type + "|" + layerType; + } + else + { + secondLevelNode.Tag = layerType; + } + secondLevelNode.Checked = false; + nodelayer.Nodes.Add(secondLevelNode); + + XmlNodeList xmlActitualLayerNodes = xmlChildLayerNode.ChildNodes; + + foreach (XmlNode xmlActitualLayerNode in xmlActitualLayerNodes) + { + //TODO LIST:创建三级图层节点 + TreeNode layerNode = new TreeNode(); + string actutallylayerType = xmlActitualLayerNode.Attributes["type"].Value; + string actutallylayerName = xmlActitualLayerNode.Attributes["layer"].Value; + string actutallyLabelName = xmlActitualLayerNode.Attributes["label"].Value; + + layerNode.Text = actutallyLabelName; + layerNode.Tag = layerType + "|" + actutallyLabelName; + layerNode.Checked = false; + secondLevelNode.Nodes.Add(layerNode); + } + + } + + } + + } + + /** + * 读取Config.xml文件,初始化以下全局Map + * m_PipelineLayerNames:管线 + * workwellLayerNames:工井 + * valueLayerNames:阀门 + * instrumenLayerNames:附属物 + * pipefittingLayerNames:特征管点 + * sgPipeLayersNames:施工管线 + **/ + private void initGlobalMap() + { + XmlDocument doc = new XmlDocument(); + doc.Load(filename); + XmlNodeList xmlLayerNodes = doc.SelectNodes("//layerchild"); + + foreach (XmlNode xmlLayerNode in xmlLayerNodes) + { + string layerType = xmlLayerNode.Attributes["type"].Value; + string layerName1 = xmlLayerNode.Attributes["layer"].Value; + string layerchildName = xmlLayerNode.Attributes["label"].Value; + + dictionaryNetLayerNameAndCaption.Add(layerName1, layerchildName); + + if (layerType != "db") + { + if (xmlLayerNode.Attributes["isRoad"] != null) + { + roadLayerName = layerchildName; + } + } + else if (xmlLayerNode.Attributes["isPipeLine"] != null) + { + m_PipelineLayerNames.Add(layerchildName); + g1layername.Add(layerName1); + } + else if (xmlLayerNode.Attributes["isWorkWell"] != null) + { + workwellLayerNames.Add(layerchildName); + g1layername.Add(layerName1); + } + else if (xmlLayerNode.Attributes["isValve"] != null) + { + valueLayerNames.Add(layerchildName); + g1layername.Add(layerName1); + } + else if (xmlLayerNode.Attributes["isAccess"] != null) + { + instrumenLayerNames.Add(layerchildName); + g1layername.Add(layerName1); + } + else if (xmlLayerNode.Attributes["isCharacter"] != null) + { + pipefittingLayerNames.Add(layerchildName); + g1layername.Add(layerName1); + } + else if (xmlLayerNode.Attributes["isSgData"] != null) + { + sgPipeLayersNames.Add(layerchildName); + g1layername.Add(layerName1); + } + + } + } + + private void initMarkerTree() + { + 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); + } + } + } + } + + private void MainFrm_Load(object sender, EventArgs e) + { + + this.initGlobalControl(); + this.initGlobalMap(); + this.initLayerTree(); + this.initMarkerTree(); + this.initLayout(); + this.loadData(); + + + double x = Convert.ToDouble(Utility.Query_Roads["绿岛"].ToString().Split(',')[0]); + double y = Convert.ToDouble(Utility.Query_Roads["绿岛"].ToString().Split(',')[1]); + double z = Convert.ToDouble(Utility.Query_Roads["绿岛"].ToString().Split(',')[2]); + jumpToCameraState(x, y, z); + + + } + + #endregion + + /// + /// 每次gis服务加载时都会触发的 + /// + /// + /// + 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 dictionaryNetLayerNameAndCaption = new Dictionary(); + 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 配置用户权限 + /// + /// 向数据库插入功能列表 + /// + private void insertControlToDatabase() + { + ArrayList listItem = new ArrayList(); + List subListItem = new List(); + 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) + { + GSOCameraState camera = globeControl2.Globe.CameraState; + globeControl1.Globe.JumpToCameraState(camera); + } + } + + void globeControl1_BeforeSceneRenderEvent(object sender, BeforeSceneRenderEventArgs e) + { + if (globeControl1.Focused) + { + 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); + } + } + } + + /// + /// 检查数据集是否有坐标系信息 + /// + /// + /// + 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 = "0prj4" + lprjStr + ""; + + bSuccess = dataset.LoadProjectionFromESRIFile(dlg.FileName); + + string lprjFileName = strDataPath.Substring(0, strDataPath.LastIndexOf(".")) + ".lprj"; + StreamWriter writer = new StreamWriter(lprjFileName, false); + writer.Write(lprjFileContent); + writer.Close(); + + } + } + } + else + { + return true; + } + return bSuccess; + } + + /// + /// 矩形拉框结束事件处理函数 + /// + /// + /// + 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))); + */ + + int mapWidth = 0; + int mapHeight = 0; + Point pt = getUpperLeftPoint(pt1, pt2, out mapWidth, out mapHeight); + int rightBottomX = pt.X + mapWidth; + int rightBottomY = pt.Y + mapHeight; + Image myImg = new Bitmap(mapWidth, mapHeight); + Graphics g = Graphics.FromImage(myImg); + g.CopyFromScreen(pt, new Point(0, 0), new Size(rightBottomX, rightBottomY)); + + 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; + } + } + /// + /// 定位正北正90度俯视 + /// + /// + /// + /// + 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; + } + } + /// + /// layerTree选中后事件处理 + /// + /// + /// + 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); + } + /// + /// 树节点选中方法 + /// + /// + 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); + } + } + } + + } + /// + /// 改变所有子节点的状态 + /// + /// + /// + 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; + LayerFlyMenuItem.Visible = true; + } + + LayerSelectableMenuItem.Visible = true; + LayerEditableMenuItem.Visible = true; + SaveLayerMenuItem.Visible = true; + LayerFlyMenuItem.Visible = true; + 导出CADToolStripMenuItem1.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]); + if (layer != null) + { + LayerSelectableMenuItem.Checked = layer.Selectable; + LayerEditableMenuItem.Checked = layer.Editable; + } + else + { + return; + } + } + 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; + } + } + } + } + } + + /// + /// 删除临时添加的本地数据图层 + /// + /// + /// + 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); + for (int i = globeControl1.Globe.Layers.Count-1; i >=0; i--) + { + if (globeControl1.Globe.Layers[i].Caption == layer.Caption) + { + globeControl1.Globe.Layers.Remove(globeControl1.Globe.Layers[i]); + } + } + + 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 定位ToolStripMenuItem_Click(object sender, EventArgs e) + { + TreeNode node = layerTree.SelectedNode; + + if (node != null) + { + if (node.Parent.Text.Trim() == "临时图层") + { + GSOLayer lsLayer = globeControl1.Globe.Layers.GetLayerByCaption(node.Text.ToString()); + double x = lsLayer.LatLonBounds.Center.X; + double y = lsLayer.LatLonBounds.Center.Y; + if (x == 0 && y == 0) + { + x = lsLayer.Bounds.Center.X; + y = lsLayer.Bounds.Center.Y; + } + + globeControl1.Globe.FlyToPosition(new GSOPoint3d(x, y, 10), EnumAltitudeMode.Absolute); + } + else + { + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(node.Tag.ToString().Split('|')[1]); + + if (layer != null) + { + if (layer.Caption == "红线") + { + globeControl1.Globe.FlyToPosition(new GSOPoint3d(120.610963, 31.188121, 50), EnumAltitudeMode.Absolute, -4, 50, 1000); + globeControl1.Globe.FlyToPointSpeed = 10000000; + globeControl1.Globe.Action = EnumAction3D.SelectObject; + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = true; + } + globeControl1.Refresh(); + } + else + { + double x = layer.LatLonBounds.Center.X; + double y = layer.LatLonBounds.Center.Y; + globeControl1.Globe.FlyToPosition(new GSOPoint3d(x, y, 100), EnumAltitudeMode.Absolute); + } + } + } + } + else + { + return; + } + + } + + private void layerTree_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e) + { + if(this.layerTree.SelectedNode!=null) + { + if (this.layerTree.SelectedNode.Tag.ToString().Contains("|")) + { + string nodeTag = this.layerTree.SelectedNode.Tag.ToString().Split('|')[1]; + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(nodeTag); + if (layer != null) + { + if (layer.Caption == "红线") + { + globeControl1.Globe.FlyToPosition(new GSOPoint3d(120.610963, 31.188121, 50), EnumAltitudeMode.Absolute, -4, 50, 1000); + globeControl1.Globe.FlyToPointSpeed = 10000000; + globeControl1.Globe.Action = EnumAction3D.SelectObject; + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = true; + } + globeControl1.Refresh(); + } + else { + double x = layer.LatLonBounds.Center.X; + double y = layer.LatLonBounds.Center.Y; + globeControl1.Globe.FlyToPosition(new GSOPoint3d(x, y, 0), EnumAltitudeMode.Absolute); + } + } + } + if (this.layerTree.SelectedNode.Tag is GSOLayer) + { + GSOLayer layer = this.layerTree.SelectedNode.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 (this.layerTree.SelectedNode.Tag is GSOFeature) + { + GSOFeature feature = this.layerTree.SelectedNode.Tag as GSOFeature; + if (feature.Geometry != null) + { + globeControl1.Globe.FlyToPosition(feature.Geometry.GeoCenterPoint, EnumAltitudeMode.Absolute, 0, 0, 10); + } + else + { + globeControl1.Globe.FlyToFeature(feature); + } + } + } + } + + /// + /// 在三维场景移动时,隐藏气泡globeControl1 + /// + /// + /// + void globeControl1_CameraBeginMoveEvent(object sender, CameraBeginMoveEventArgs e) + { + if (featureTooltip.IsVisible()) + { + featureTooltip.HideBalloon(); + } + if (balloonEx.IsVisible()) + { + balloonEx.HideBalloon(); + } + } + + /// + /// 在三维场景移动时,隐藏气泡globeControl2 + /// + /// + /// + void globeControl2_CameraBeginMoveEvent(object sender, CameraBeginMoveEventArgs e) + { + if (featureTooltip2.IsVisible()) + { + featureTooltip2.HideBalloon(); + } + if (balloonEx2.IsVisible()) + { + balloonEx2.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(); + } + } + + #region Fan 横断面 + /// + /// 横断面分析、基线剖面分析、道路断面分析等 + /// + /// + /// + private static EnumTrackPolylineEndMode trackPolylineEndMode; + + void globeControl1_TrackPolylineEndEvent(object sender, TrackPolylineEndEventArgs e) + { + //横断面分析、道路横断面分析 + if (trackPolylineEndMode == EnumTrackPolylineEndMode.HDM_Analysis|| + trackPolylineEndMode == EnumTrackPolylineEndMode.DLDM_Analysis) + { + Dictionary hdmDic = SectionAnalysisTool.HDMAnalysis(this.globeControl1, + e.Polyline, this.m_PipelineLayerNames); + FrmHDMAnalysis3 frm = new FrmHDMAnalysis3(hdmDic, this.globeControl1, + trackPolylineEndMode); + frm.Show(this); + } + //基线剖面分析 + else if (trackPolylineEndMode == EnumTrackPolylineEndMode.JXPM_Analysis) + { + FrmBaseLineProfillAnalysis dlg = new FrmBaseLineProfillAnalysis(globeControl1.Globe, e.Polyline); + dlg.Show(this); + globeControl1.Globe.ClearLastTrackPolyline(); + } + else + { + + } + trackPolylineEndMode = EnumTrackPolylineEndMode.Default_Analysis; + } + #endregion + + private GSOFeatures PolygonIntersectAnalysis(GSOGeoPolygon3D polygon, string pipelinetype) + { + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(pipelinetype); + 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(pipelinetype, feats.Length); + return feats; + } + /// + /// 根据范围统计阀门、管线、工井等, 开挖分析, 挖方量分析 + /// + /// + /// + void globeControl1_TrackPolygonEndEvent(object sender, TrackPolygonEndEventArgs e) + { + if (globeControl1.Globe.Action == EnumAction3D.TrackPolygon && e.Polygon != null) + { + GSOGeoPolygon3D polygon = e.Polygon; + + switch (trackflag) + { + case "valvequery": + FrmValveStatistics frm = new FrmValveStatistics(globeControl1,polygon, new DataGridViewDelegate(InitDataGridViewX1)); + frm.Show(this); + globeControl1.Globe.Action = EnumAction3D.ActionNull; + break; + + case "PipelineDistanceStatistics": +<<<<<<< HEAD +======= + +>>>>>>> d2d0088a6b3c53c1a96b7f1997f4d3443c0ee8c0 + FrmAllPipelineStatis frm1 = new FrmAllPipelineStatis(globeControl1, polygon, new DataGridViewDelegate(InitDataGridViewX1), m_PipelineLayerNames); + frm1.Show(this); + globeControl1.Globe.Action = EnumAction3D.ActionNull; + + break; + case "PipelineSpatialQuery": +<<<<<<< HEAD +======= + +>>>>>>> d2d0088a6b3c53c1a96b7f1997f4d3443c0ee8c0 + FrmAllPipelineStatis.ShowForm(globeControl1,polygon,new DataGridViewDelegate(InitDataGridViewX1),m_PipelineLayerNames); + globeControl1.Globe.ClearAnalysis(); + globeControl1.Globe.Action = EnumAction3D.ActionNull; + + break; + case "workwellquery": + FrmAllWorkWellStatis frmWell = new FrmAllWorkWellStatis(globeControl1, polygon, new DataGridViewDelegate(InitDataGridViewX1)); + 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 "BSQDuoBianXiangStatis": + + //GSOFeature f2 = new GSOFeature(); + //f2.Geometry = e.Polygon; + //f2.Geometry.AltitudeMode = EnumAltitudeMode.Absolute; + //globeControl1.Globe.MemoryLayer.AddFeature(f2); + //f2.Geometry.MoveZ(3); + //workWellLen.Clear(); + //List listBSQ = new List(); + + //GSOFeatures bsqFeatures = PolygonIntersectAnalysis(e.Polygon, "标识器"); + //listBSQ.Add(bsqFeatures); + + //FrmBSQDuoBianXingStatis bsqFrm = new FrmBSQDuoBianXingStatis(workWellLen, globeControl1, listBSQ); + FrmBSQStatis bsqFrm = new FrmBSQStatis(globeControl1,e.Polygon); + bsqFrm.Show(this); + globeControl1.Globe.Action = EnumAction3D.ActionNull; + break; + + case "": + break; + default: + break; + } + } + } + + #region 验证端口 + /* + /// + /// 验证端口 + /// + /// + 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 + + /// + /// 鼠标悬浮提示 + /// + /// + /// + 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); + } + } + + /// + /// 添加管线绘制完成事件, 红线工具绘制完成 + /// + /// + /// + 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; + + + } + } + + /// + /// 获取globeControl1中鼠标按下的坐标供区别鼠标右键和滚轮按下事件 + /// + /// + /// + void globeControl1_MouseDown(object sender, MouseEventArgs e) + { + mouseDownX1 = e.X; + mouseDownY1 = e.Y; + } + /// + /// 获取globeControl2中鼠标按下的坐标供区别鼠标右键和滚轮按下事件 + /// + /// + /// + void globeControl2_MouseDown(object sender, MouseEventArgs e) + { + mouseDownX2 = e.X; + mouseDownY2 = e.Y; + } + /// + /// + /// + /// + /// + void globeControl2_MouseClick(object sender, MouseEventArgs e) + { + if (e.Button == MouseButtons.Right) + { + if (e.X == mouseDownX2 && e.Y == mouseDownY2) + { + RightScreenToolMenu.Show(globeControl2, e.X, e.Y); + } + else + { + return; + } + } + } + /// + /// + /// + /// + /// + void globeControl1_MouseClick(object sender, MouseEventArgs e) + { + if (e.Button == MouseButtons.Left) + { + if (globeControl1.Globe.Action == EnumAction3D.VisibilityAnalysis) + { + buttonItemFX5_1.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; + + bsqPT = pt; + + if (buttonItemLS5.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 (e.X == mouseDownX1 && e.Y == mouseDownY1) + { + toolRightMenu.Show(globeControl1, e.X, e.Y); + if (buttonItemLS5.Checked) + { + buttonItemLS5.Checked = false; + } + } + else + { + return; + } + } + globeControl1.Refresh(); + } + + /// + /// 判断网络图片是否存在 + /// + /// + /// + 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; + } + + /// + /// 鼠标点击, 弹出气泡功能globeControl1 + /// + /// + /// + void globeControl1_FeatureMouseClickEvent(object sender, FeatureMouseClickEventArgs e) + { + GSOFeature feature = e.Feature; + + string str1 = ""; + if (feature != null) + { + if (feature.GetFieldDefn("图片编码") != null)// + { + str1 = GetBubbleInfo(feature, globeControl1); + if (RemoteFileExists(Utility.PicRootURL + feature.GetValue("图片编码").ToString())) + { + str1 += ""; + } + else if (RemoteFileExists(Utility.PicDefaultURL)) + { + str1 += ""; + } + } + else if (isFeatureContainsBianhao(feature)) //管线模型图层 + { + str1 = GetBubbleInfo(feature, globeControl1); + } + + 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; + } + } + } + + /// + /// 鼠标点击, 弹出气泡功能globeControl2 + /// + /// + /// + void globeControl2_FeatureMouseClickEvent(object sender, FeatureMouseClickEventArgs e) + { + GSOFeature feature = e.Feature; + + string str1 = ""; + if (feature != null) + { + if (feature.GetFieldDefn("图片编码") != null) // + { + str1 = GetBubbleInfo(feature, globeControl2); + if (RemoteFileExists(Utility.PicRootURL + feature.GetValue("图片编码").ToString())) + { + str1 += ""; + } + else if (RemoteFileExists(Utility.PicDefaultURL)) + { + str1 += ""; + } + } + else if (isFeatureContainsBianhao(feature)) //管线模型图层 + { + str1 = GetBubbleInfo(feature, globeControl2); + } + + if (str1 != "") + { + + featureTooltip2.HideBalloon(); + balloonEx2.HideBalloon(); + balloonEx2.SetSize(EnumSizeIndexEx.CONTENT_CX, 480); + balloonEx2.SetSize(EnumSizeIndexEx.CONTENT_CY, 420); + balloonEx2.ShowBalloon((int)e.MousePos.X, (int)e.MousePos.Y, str1); + + return; + } + } + } + + /// + /// 拼接气泡表格字符串 + /// + /// + /// + private string GetBubbleInfo(GSOFeature feature,GSOGlobeControl globeControl) + { + if (feature == null) + { + return ""; + } + string str = ""; + str = ""; + 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 += ""; + + 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.get_Fields(layerName, globeControl); + } + if (queryFields != null) + { + string[] param = { "," }; + string[] fieldNames = queryFields.Split(param, StringSplitOptions.RemoveEmptyEntries); + for (int j = 0; j < fieldNames.Length; 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 (name1 == "模型路径") + { + continue; + } + 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 (field1.Type == EnumFieldType.Double) + { + double dl1 = feature.GetFieldAsDouble(j); + if (!name1.Contains("管径") && !name1.Contains("电压") && !name1.Contains("角度")) + { + name1 += "_米"; + } + value1 = dl1.ToString("0.00"); + } + 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 (name2 == "模型路径") + { + continue; + } + + 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 (field2.Type == EnumFieldType.Double) + { + double dl2 = feature.GetFieldAsDouble(j + 1); + if (!name2.Contains("管径") && !name2.Contains("电压") && !name2.Contains("角度")) + { + name2 += "_米"; + } + value2 = dl2.ToString("0.00"); + } + else + { + if (!feature.IsFieldValueNull(j + 1)) + { + value2 = feature.GetValue(j + 1).ToString(); + } + } + } + } + + j++; + } + str += ""; + } + } + str += "
" + title + " " + feature.GetFieldAsString(featureIDFieldName) + "
" + + name1 + + "
" + + value1 + + "
" + + name2 + + "
" + + value2 + "
"; + return str; + } + + string filename = Utility.filename; + List g1layername = new List(); + + /// + /// 获取目标图层 + /// + /// + 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; + } + /// + /// 添加图层 + /// + /// + /// + /// + 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 = 5000; + return templayer.Visible; + } + catch (Exception ex) + { + return false; + } + } + /// + /// 菜单上的 三维导航 工具按钮 + /// + /// + /// + private void buttonItem86_Click(object sender, EventArgs e) + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + } + + /// + /// 地上模式 菜单按钮 + /// + /// + /// + 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(); + + } + } + /// + /// 地下模式 菜单按钮 + /// + /// + /// + 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(); + } + } + /// + /// 行走模式 菜单按钮 + /// + /// + /// + 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; + } + } + /// + /// 地面透明度设置 菜单 + /// + /// + /// + private void sliderGroundTransSet1_ValueChanged(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.sliderGroundTransSet1.Text); + + globeControl1.Globe.GroundOpaque = 100 - sliderGroundTransSet1.Value; + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(roadLayerName);//("180fd"); + if (layer != null) + { + layer.Opaque = 100 - sliderGroundTransSet1.Value; + } + //if (buttonItemSPDB.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; + } + /// + /// 图例 菜单按钮 + /// + /// + /// + 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(); + } + /// + /// 快速定位 菜单按钮 + /// + /// + /// + private void buttonItem91_Click(object sender, EventArgs e) // + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItem91.Text); + FrmFlyToPosition fly = new FrmFlyToPosition(globeControl1); + fly.Show(this); + } + /// + /// 图层管理 菜单按钮 + /// + /// + /// + 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; + + //修改图层管理与标注管理、覆土审查、水平净距分析、垂直净距分析和碰撞分析控件之间的逻辑关系 + controlContainerItem5.Visible = false; + sideBar1.Visible = false; + sideBarPanelItem4.Visible = false; + panel3.Visible = false; + sideBar1.ExpandedPanel = sideBarPanelItem3; + buttonItemBZ11.Checked = false; + + //20160624 + /* + if (sideBarPanelItem4.Visible == true) + { + sideBar1.Visible = true; + controlContainerItem5.Visible = true; + } + else + { + sideBar1.Visible = false; + } + */ + Refresh(); + + } + } + /// + /// 全屏显示 菜单按钮 + /// + /// + /// + 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; + /// + /// 全屏显示功能实现 + /// + 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(); + } + } + + /// + /// 设置窗体宽、高 + /// + /// + /// + private void SetFullScreen(int width, int height) + { + this.Width = width; + this.Height = height; + } + + /// + /// 全屏功能的快捷键F5 + /// + /// + /// + 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); + } + } + /* + /// + /// 输出地图 + /// + /// + /// + /// + 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; + } + * */ + + private Point getUpperLeftPoint(Point p1, Point p2, out int mapWidth, out int mapHeight) // + { + Rectangle rc = new Rectangle(); + + p1 = this.globeControl1.PointToScreen(p1); + p2 = this.globeControl1.PointToScreen(p2); + + int x = Screen.PrimaryScreen.Bounds.X; + int y = Screen.PrimaryScreen.Bounds.Y; + int screenWidth = SystemInformation.WorkingArea.Width; + int screenHeight = SystemInformation.WorkingArea.Height; + + if (p1.X < x) + rc.X = x; + else + rc.X = p1.X; + + if (p1.Y < y) + rc.Y = y; + else + rc.Y = p1.Y; + + p1.X = rc.Left; + p1.Y = rc.Top; + + if (p2.X > screenWidth) + p2.X = screenWidth; + else + p2.X = p2.X; + + if (p2.Y > screenHeight) + p2.Y = screenHeight; + else + p2.Y = p2.Y; + + rc.Width = p2.X - rc.X; + rc.Height = p2.Y - rc.Y; + + mapWidth = rc.Width; + mapHeight = rc.Height; + Point pt = new Point(rc.Left, rc.Top); + return pt; + } + + Image printImage; + /// + /// 打印 菜单 + /// + /// + /// + 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))); + */ + int mapWidth = 0; + int mapHeight = 0; + Point pt = getUpperLeftPoint(pt1, pt2, out mapWidth, out mapHeight); + int rightBottomX = pt.X + mapWidth; + int rightBottomY = pt.Y + mapHeight; + Image myImg = new Bitmap(mapWidth, mapHeight); + Graphics g = Graphics.FromImage(myImg); + g.CopyFromScreen(pt, new Point(0, 0), new Size(rightBottomX, rightBottomY)); + + + 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); + } + /// + /// 输出地图 菜单 + /// + /// + /// + private void btnOutputJPG_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btnOutputJPG.Text); + + //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))); + */ + int mapWidth = 0; + int mapHeight = 0; + Point pt = getUpperLeftPoint(pt1, pt2, out mapWidth, out mapHeight); + int rightBottomX = pt.X + mapWidth; + int rightBottomY = pt.Y + mapHeight; + Image myImg = new Bitmap(mapWidth, mapHeight); + Graphics g = Graphics.FromImage(myImg); + g.CopyFromScreen(pt, new Point(0, 0), new Size(rightBottomX, rightBottomY)); + + 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; + } + } + } + + /// + /// 统计管线的里程数 + /// + /// + /// + /// + 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; + } + + /// + /// 窗体下方属性表格 右键菜单中的 “定位”菜单 + /// + /// + /// + 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); + + } + + /// + /// 表格中右键 “单个闪烁” 菜单 + /// + /// + /// + private void LightMenu_Click(object sender, EventArgs e) + { + flashflag = "single"; + timer1.Start(); + } + /// + /// 表格中右键 “全部闪烁” 菜单 + /// + /// + /// + private void AllLightMenuItem_Click(object sender, EventArgs e) + { + flashflag = "all"; + timer1.Start(); + } + + /// + /// 使用timer实现管线的闪烁效果 + /// + /// + /// + 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; + } + } + + /// + /// 绘制线 菜单 + /// + /// + /// + private void btnAddLine_Click(object sender, EventArgs e) + { + globeControl1.Globe.DestLayerFeatureAdd = globeControl1.Globe.MemoryLayer; + globeControl1.Globe.Action = EnumAction3D.DrawPolyline; + } + /// + /// 绘制面 菜单 + /// + /// + /// + private void btnAddPolygon_Click(object sender, EventArgs e) + { + globeControl1.Globe.DestLayerFeatureAdd = globeControl1.Globe.MemoryLayer; + globeControl1.Globe.Action = EnumAction3D.DrawPolygon; + } + /// + /// 图层目录树 右键菜单中的 目标图层 菜单 + /// + /// + /// + 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; + } + } + /// + /// 图层目录树 右键菜单中的 可选择 菜单 + /// + /// + /// + 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; + } + /// + /// 图层目录树 右键菜单中的 可编辑 菜单 + /// + /// + /// + 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; + } + /// + /// 图层目录树 右键菜单中的 保存 菜单 + /// + /// + /// + 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(); + } + + /// + /// 根据多边形范围统计管线的里程 + /// + /// + /// + /// 返回查询到的管线要素集合 + 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 pipeLineDis = new Dictionary(); + Dictionary workWellLen = new Dictionary(); + + + + + /// + /// 查找指定图层中在 指定范围内的feature对象集合 + /// + /// + /// + /// + 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; + } + /// + /// 清除结果 菜单 + /// + /// + /// + private void buttonItem47_Click(object sender, EventArgs e) + { + globeControl1.Globe.ClearAnalysis(); + dataGridViewX1.DataSource = null; + panelOfTable.Visible = false; + clearFeatureHighLight(); + } + /// + /// 设置菜单的选中状态 + /// + private void ActionToolMenuChecked() + { + if (globeControl1.Globe.Action != EnumAction3D.TrackPolyline) + { + buttonItemFX2_1.Checked = false; + buttonItemFX2_4.Checked = false; + buttonItemFX2_3.Checked = false; + buttonItemFX4_3.Checked = false; + } + if (globeControl1.Globe.Action != EnumAction3D.NormalHit) + { + buttonItemFX3_6.Checked = false; + // ClearConnexityAnalysis(); + + buttonItemFX3_5.Checked = false; + // ClearCloseValvesAnalysis(); + } + if (globeControl1.Globe.Action != EnumAction3D.TrackPolygon) + { + buttonItemFX4_2.Checked = false; + buttonItemFX4_1.Checked = false; + } + } + + /// + /// 主窗体关闭事件处理 + /// + /// + /// + private void MainFrm_FormClosing(object sender, FormClosingEventArgs e) + { + + if (MessageBox.Show("是否退出系统?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) + { + e.Cancel = true; + } + else { + globeControl1.Globe.MemoryLayer.SaveAs(Application.StartupPath + "/MyPlace.kml"); + } + + //saveLayerList(layerManagerNode.Nodes); + //注销id号为103的热键设定 + // UnregisterHotKey(Handle, 103); + } + + /// + /// 显示流向 功能 + /// + /// + /// + /// + 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(); + } + + FrmCloseValves frm; + + FrmBoosterValvers frmbooster = null; + + /// + /// 垂直净距分析 功能界面中的 选择图层复选框 选中状态改变事件处理 + /// + /// + /// + 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(); + } + /// + /// 水平净距分析 功能界面中的 选择图层复选框 选中状态改变事件处理 + /// + /// + /// + 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(); + } + /// + /// 垂直净距分析 功能界面中的 选择管线复选框 选中状态改变事件处理 + /// + /// + /// + private void checkBoxX1_CheckedChanged(object sender, EventArgs e) + { + clearFeatureHighLight(); + if (checkBoxX1.Checked) + { + comboBoxEx1.SelectedItem = null; + 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; + } + } + /// + /// 水平净距分析 功能界面中的 选择管线复选框 选中状态改变事件处理 + /// + /// + /// + private void checkBoxX1_CheckedChanged_shuiping(object sender, EventArgs e) + { + clearFeatureHighLight();//清除高亮 + if (checkBoxX7.Checked) + { + comboBoxEx4.SelectedItem = null; + 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(); + /// + /// 垂直净距分析 功能界面中的 选择图层下拉框 选中项改变 事件处理 + /// + /// + /// + 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; + } + } + } + /// + /// 水平净距分析 功能界面中的 选择图层下拉框 选中项改变 事件处理 + /// + /// + /// + 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 featCount = new Dictionary(); + Dictionary featLenth = new Dictionary(); + Dictionary m_FeaturesWithBianhao = new Dictionary();//记录编号和对应的标注点的位置 + GSOFeatures polygonJingJuAnalysises = new GSOFeatures(); + + /// + /// 垂直净距分析 功能界面中的 开始分析按钮 事件处理 + /// + /// + /// + 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; + } + + /// + /// 在指定的两点组成的线的中间添加一个marker对象,并将marker对象添加到指定的图层中 + /// + /// + /// + /// + /// + /// + 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; + } + + /// + /// 计算指定feature对象与除了该feature所在图层之外的 所有管线图层中的所有feature对象 的垂直距离 并在表格中记录符合要求的管线 + /// + /// + /// + /// + /// + private void VerticalDistanceAnalysis(string type, GSOFeature selectedFeature, List _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(); + } + /// + /// 垂直净距分析中 表格行的 双击定位 功能。 与覆土分析的实现方法不同,主要原因是需要标注垂距 + /// + /// + /// + 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); + } + } + } + } + + /// + /// 水平净距分析 功能界面中 开始分析按钮 的事件处理 + /// + /// + /// + 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; + } + + + /// + /// 计算指定feature对象与除了该feature所在图层之外的 所有管线图层中的所有feature对象 的水平距离 并记录符合要求的管线 功能 + /// + /// + /// + /// + /// + private void HorizontalDistanceAnalysis(GSOFeature selectedFeature, List _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)); + } + } + } + } + } + /// + /// 水平净距分析 功能界面中 表格的 双击定位 功能 + /// + /// + /// + 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); + } + } + } + } + } + /// + /// 碰撞分析 功能界面中 开始分析按钮 事件处理 + /// + /// + /// + 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; + } + /// + /// 碰撞分析功能界面中 表格的 双击定位 功能 + /// + /// + /// + 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); + } + } + } + } + + + + /// + /// 覆土分析功能操作界面中的 选择管线 复选框选中状态改变事件处理 + /// + /// + /// + private void checkBoxX5_CheckedChanged(object sender, EventArgs e) + { + clearFeatureHighLight(); + if (checkBoxX5.Checked) + { + comboBoxEx3.SelectedItem = null; + 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; + } + } + /// + /// 覆土分析功能操作界面中的 选择图层 复选框选中状态改变事件处理 + /// + /// + /// + 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(); + } + /// + /// 覆土分析功能操作界面中的 图层下拉框选中项改变事件处理 + /// + /// + /// + 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; + } + } + } + /// + /// 覆土分析功能操作界面中的 开始分析 按钮事件处理 + /// + /// + /// + 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; + + + GSOPoint3d markerPosition = new GSOPoint3d(); + 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]; + GSOPoint3d pt = new GSOPoint3d(); + + 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"); + + pt.X = pts[m].X; + pt.Y = pts[m].Y; + pt.Z = 0; + markerPosition = LabelVerticalDistance(layerTemp, pts[m], pt, Convert.ToDouble(dataGridViewX7.Rows[idx].Cells[2].Value), true); + 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]; + GSOPoint3d pt = new GSOPoint3d(); + 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"); + + pt.X = pts[m].X; + pt.Y = pts[m].Y; + pt.Z = 0; + markerPosition = LabelVerticalDistance(layerTemp, pts[m], pt, Convert.ToDouble(dataGridViewX7.Rows[idx].Cells[2].Value), true); + + 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; + } + + /// + /// 覆土分析中 表格的 双击定位 功能 + /// + /// + /// + 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); + } + } + } + } + } + /// + /// 覆土分析功能操作界面中的 导出Excel按钮 事件处理 + /// + /// + /// + private void buttonX10_Click(object sender, EventArgs e) + { + if (dataGridViewX7.Rows.Count > 0) + { + ExportExcel("覆土分析", dataGridViewX7, null); + } + else + { + MessageBox.Show("表格内容为空!", "提示"); + } + } + /// + /// 覆土分析功能操作界面底部的 关闭 按钮事件处理 + /// + /// + /// + 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(); + layerTemp.RemoveAllFeature(); + + if (buttonItem1.Checked) + { + sideBar1.ExpandedPanel = sideBarPanelItem3; + } + else + { + sideBar1.Visible = false; + } + globeControl1.Refresh(); + + //Refresh(); + } + + + /// + /// 垂直净距分析 功能界面中 清除分析结果按钮 事件处理 + /// + /// + /// + 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(); + } + /// + /// 水平净距分析 功能界面中 清除分析结果按钮 事件处理 + /// + /// + /// + 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(); + } + + /// + /// 垂直净距分析功能界面中 关闭按钮 事件处理 + /// + /// + /// + 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(); + } + /// + /// 水平净距分析功能界面中 删除缓冲区按钮 事件处理 + /// + /// + /// + private void buttonX14_Click(object sender, EventArgs e) + { + 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(); + } + + /// + /// 导出指定DataGridView控件中的内容 + /// + /// + /// + 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(); + } + } + } + } + + /// + /// 垂直净距分析功能界面中 导出Excel按钮 事件处理 + /// + /// + /// + private void buttonX4_Click(object sender, EventArgs e) + { + if (dataGridViewX3.Rows.Count > 0) + { + ExportExcel("垂直净距分析", dataGridViewX3, listBox1); + } + else + { + MessageBox.Show("表格内容为空!", "提示"); + } + } + /// + /// 水平净距分析功能界面中 导出Excel按钮 事件处理 + /// + /// + /// + private void buttonX4_Click_shuiping(object sender, EventArgs e) + { + if (dataGridViewX9.Rows.Count > 0) + { + ExportExcel("水平净距分析", dataGridViewX9, listBox3); + } + else + { + MessageBox.Show("表格内容为空!", "提示"); + } + } + + + /// + /// 清除所有坑 菜单 + /// + /// + /// + private void buttonItem3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItem3.Text); + + globeControl1.Globe.RemoveAllPits(); + } + + //} + /// + /// 大气层 菜单 + /// + /// + /// + private void buttonItem17_Click_1(object sender, EventArgs e) + { + globeControl1.Globe.Atmosphere.Visible = !globeControl1.Globe.Atmosphere.Visible; + buttonItemSH1.Checked = globeControl1.Globe.Atmosphere.Visible; + globeControl1.Refresh(); + } + /// + /// 经纬网 菜单 + /// + /// + /// + private void buttonItem20_Click(object sender, EventArgs e) + { + globeControl1.Globe.LatLonGrid.Visible = !globeControl1.Globe.LatLonGrid.Visible; + buttonItemSH3.Checked = globeControl1.Globe.LatLonGrid.Visible; + globeControl1.Globe.Refresh(); + } + /// + /// 状态条 菜单 + /// + /// + /// + private void buttonItem21_Click_1(object sender, EventArgs e) + { + globeControl1.Globe.StatusBar.Visible = !globeControl1.Globe.StatusBar.Visible; + buttonItemSH4.Checked = globeControl1.Globe.StatusBar.Visible; + globeControl1.Globe.Refresh(); + } + + + + /// + /// 添加指定路径下的数据 功能 + /// + /// + /// + 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); + //CheckDatasetGeoReference(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; + } + return objRes; + } + /// + /// 刷新目录树 功能 + /// + 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); + } + } + /// + /// 判断图层是否包含字段列表 + /// + /// + /// + 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; + } + + /// + /// 统计指定图层在指定范围内的所有feature对象 + /// + /// + /// + /// + 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; + } + /// + /// 碰撞分析功能界面中 选择管线复选框 选中状态改变事件处理 + /// + /// + /// + private void checkBoxX3_CheckedChanged(object sender, EventArgs e) + { + clearFeatureHighLight(); + if (checkBoxX3.Checked) + { + comboBoxEx2.SelectedItem = null; + 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; + } + } + /// + /// 碰撞分析功能界面中 选择图层复选框 选中状态改变事件处理 + /// + /// + /// + 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(); + } + /// + /// 碰撞分析功能界面中 选择图层下拉框 选中项改变事件处理 + /// + /// + /// + 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; + } + } + } + /// + /// 清除所有图层中的所有feature对象的高亮状态 功能 + /// + 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); + } + } + } + } + for (int i = 0; i < globeControl2.Globe.Layers.Count; i++) + { + GSOLayer layer = globeControl2.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; + } + } + } + + if (globeControl1.Globe.Action == EnumAction3D.SelectObject) + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + //globeControl1.Globe.Action = EnumAction3D.SelectObject; + } + } + + /// + /// 碰撞分析功能界面中 清除分析结果按钮 事件处理 + /// + /// + /// + 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(); + } + /// + /// 碰撞分析功能界面中 导出Excel按钮 事件处理 + /// + /// + /// + private void buttonX6_Click(object sender, EventArgs e) + { + if (dataGridViewX5.Rows.Count > 0) + { + ExportExcel("碰撞分析", dataGridViewX5, listBox2); + } + else + { + MessageBox.Show("表格内容为空!", "提示"); + } + } + /// + /// 导出CAD 菜单 + /// + /// + /// + private void btnExportCAD_Click(object sender, EventArgs e) + { + FrmExportCADS frm = new FrmExportCADS(globeControl1, m_PipelineLayerNames); + frm.ShowDialog(); + } + + ///// + ///// 区域分析 菜单 + ///// + ///// + ///// + //private void buttonItem50_Click(object sender, EventArgs e) + //{ + // buttonItem50.Checked = !buttonItem50.Checked; + // ribbonBarQY.Visible = buttonItem50.Checked; + // ribbonBarQY.Location = new Point(0, 0); + //} + + + /// + /// 连接数据库 菜单事件处理 + /// + /// + /// + 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; + } + } + } + /// + /// 数据验证 菜单 + /// + /// + /// + private void buttonItem80_Click(object sender, EventArgs e) + { + FrmValiData frm = new FrmValiData(globeControl1); + frm.ShowDialog(); + } + /// + /// 根据指定图层创建图层节点并将节点添加到图层管理节点的子节点集合中 + /// + /// + 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; + + if (!layerManagerNode.Nodes.Contains(node)) + { + layerManagerNode.Nodes.Insert(0, node); + layerManagerNode.Expand(); + } + } + } + /// + /// 数据库备份 菜单 + /// + /// + /// + 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(); + } + } + } + + + + #region Fan 去掉 + //GSOFeature emitterFeature; // 粒子要素 + /// + /// 添加火苗 功能 + /// + /// + /// + /// + 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); + + } + /// + /// 添加喷泉 功能 + /// + /// + /// + /// + 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); + } + #endregion + + /// + /// 获取指定图层中最后一个feature对象的名称对应的整数 + /// + /// + /// + 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; + } + /// + /// 设置除指定标注图层之外的所有标注图层不可见 + /// + /// + 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; + } + } + } + } + } + + /// + /// 判断选中的对象是否为管线 + /// + /// 被选中管线 + /// 返回一根线 + 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; + } + + /// + /// 获取指定两点组成的线的长度 功能 + /// + /// + /// + /// + 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; + } + + /// + /// 图层节点树中 节点 右键单击事件处理 + /// + /// + /// + 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; + } + } + } + } + } + + /// + /// 标注管理、传感器管理 图层目录树的右键菜单中的 刷新列表 菜单 + /// + /// + /// + 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); + } + } + /// + /// 给指定的图层节点添加代表feature对象的子节点 + /// + /// + private void RefreshTreeNodeLayerFeatureList(TreeNode layerTreeNode) + { + layerTreeNode.Nodes.Clear(); + GSOLayer layer = (GSOLayer)layerTreeNode.Tag; + // 只将类型为内存数据集的图层列出,如果是其它类型的数据集可能数据量太大,没发显示在树控件中 + if (layer.Dataset is GSOFeatureDataset) + { + VisitFeature3Ds(layer.GetAllFeatures(), layerTreeNode); + } + } + + /// + /// 标注管理、传感器管理 图层目录树的右键菜单中的 移除所有 菜单 + /// + /// + /// + 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(); + } + } + + /// + /// 图层目录树的 节点对应的复选框选中状态改变事件处理 + /// + /// + /// + private void layerMarkerTree_AfterCheck(object sender, TreeViewEventArgs e) + { + if (e.Action != TreeViewAction.Unknown) + { + CheckTreeNode(e.Node, e.Node.Checked); + } + } + /// + /// 改变指定节点对应的复选框的选中状态 + /// + /// + /// + private void CheckTreeNode(TreeNode node, Boolean bChecked) + { + CheckChildTreeNode(node, bChecked); + globeControl1.Globe.Refresh(); + } + /// + /// 改变指定节点的子节点对应的复选框的选中状态 + /// + /// + /// + 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); + } + } + /// + /// 标注管理、传感器管理 目录树中的feature节点的右键菜单中的 删除 菜单 + /// + /// + /// + 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(); + } + } + + /// + /// 双屏对比 菜单 + /// + /// + /// + //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(); + // } + //} + /// + /// 模拟分析 菜单 + /// + /// + /// + //private void buttonItem51_Click(object sender, EventArgs e) + //{ + // buttonItem51.Checked = !buttonItem51.Checked; + // ribbonBarMN.Visible = buttonItem51.Checked; + // ribbonBarMN.Location = new Point(0, 0); + //} + + /// + /// 双屏设置 菜单 + /// + /// + /// + //private void buttonItem96_Click(object sender, EventArgs e) + //{ + // FrmLayerControl frm = new FrmLayerControl(layerTree,globeControl1,globeControl2); + // frm.Show(this); + //} + /// + /// 双屏联动 菜单 + /// + /// + /// + //private void buttonItem95_Click(object sender, EventArgs e) + //{ + // buttonItem95.Checked = !buttonItem95.Checked; + //} + ///// + /// 添加用户仓库 菜单 + /// + /// + /// + private void buttonItem108_Click(object sender, EventArgs e) + { + FrmUserRepo frm = new FrmUserRepo(-1); + frm.ShowDialog(); + } + /// + /// 用户仓库管理 菜单 + /// + /// + /// + private void buttonItem111_Click(object sender, EventArgs e) + { + FrmUserRepoMgr frm = new FrmUserRepoMgr(); + frm.ShowDialog(); + } + /// + /// 添加分系统 菜单 + /// + /// + /// + private void buttonItem112_Click(object sender, EventArgs e) + { + //FrmAPP frm = new FrmAPP(-1); + //frm.ShowDialog(); + } + /// + /// 分系统管理 菜单 + /// + /// + /// + private void buttonItem113_Click(object sender, EventArgs e) + { + //FrmAPPMgr frm = new FrmAPPMgr(); + //frm.ShowDialog(); + } + /// + /// 添加操作 菜单 + /// + /// + /// + private void buttonItem114_Click(object sender, EventArgs e) + { + FrmOper frm = new FrmOper(-1); + frm.ShowDialog(); + } + /// + /// 操作管理 菜单 + /// + /// + /// + private void buttonItem115_Click(object sender, EventArgs e) + { + FrmOperMgr frm = new FrmOperMgr(); + frm.ShowDialog(); + } + /// + /// 添加资源 菜单 + /// + /// + /// + private void buttonItem116_Click(object sender, EventArgs e) + { + FrmRESC frm = new FrmRESC(-1); + frm.ShowDialog(); + } + /// + /// 资源管理 菜单 + /// + /// + /// + private void buttonItem117_Click(object sender, EventArgs e) + { + FrmRESCMgr frm = new FrmRESCMgr(); + frm.ShowDialog(); + } + /// + /// 添加权限 菜单 + /// + /// + /// + private void buttonItem118_Click(object sender, EventArgs e) + { + FrmPerm frm = new FrmPerm(-1); + frm.ShowDialog(); + } + /// + /// 权限管理 菜单 + /// + /// + /// + private void buttonItem119_Click(object sender, EventArgs e) + { + FrmPermMgr frm = new FrmPermMgr(); + frm.ShowDialog(); + } + /// + /// 添加访问控制 菜单 + /// + /// + /// + private void buttonItem120_Click(object sender, EventArgs e) + { + FrmAccess frm = new FrmAccess(-1); + frm.ShowDialog(); + } + /// + /// 访问控制管理 菜单 + /// + /// + /// + private void buttonItem121_Click(object sender, EventArgs e) + { + FrmAccessMgr frm = new FrmAccessMgr(); + frm.ShowDialog(); + } + /// + /// 部门类型管理 菜单 + /// + /// + /// + private void buttonItem122_Click(object sender, EventArgs e) + { + FrmRegionTypeMgr frm = new FrmRegionTypeMgr(); + frm.ShowDialog(); + } + /// + /// 添加用户 菜单 + /// + /// + /// + private void buttonItem127_Click(object sender, EventArgs e) + { + FrmUserAdd frm = new FrmUserAdd(-1); + frm.ShowDialog(); + } + /// + /// 用户信息管理 菜单 + /// + /// + /// + private void buttonItem128_Click_1(object sender, EventArgs e) + { + FrmUserManager frm = new FrmUserManager(); + frm.ShowDialog(); + } + /// + /// 添加角色 菜单 + /// + /// + /// + private void 添加角色_Click(object sender, EventArgs e) + { + FrmRole frm = new FrmRole(-1); + frm.ShowDialog(); + } + /// + /// 所有角色管理 菜单 + /// + /// + /// + private void 角色管理_Click(object sender, EventArgs e) + { + FrmRoleMgr frm = new FrmRoleMgr(); + frm.ShowDialog(); + } + + /// + /// 部门角色管理 菜单 + /// + /// + /// + private void buttonItem133_Click(object sender, EventArgs e) + { + FrmRegionRoleMgr frm = new FrmRegionRoleMgr(); + frm.ShowDialog(); + } + /// + /// 部门管理 菜单 + /// + /// + /// + private void buttonItem130_Click(object sender, EventArgs e) + { + FrmRegionMgr frm = new FrmRegionMgr(); + frm.ShowDialog(); + } + + /// + /// 日志管理 菜单 + /// + /// + /// + private void buttonItem135_Click(object sender, EventArgs e) + { + FrmLogManager frm = new FrmLogManager(); + frm.ShowDialog(); + } + /// + /// 传感器信息查询 菜单 + /// + /// + /// + 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); + } + } + } + /// + /// 根据指定的图层的caption属性的值在配置文件中查找对应的数据库中的表的名称 + /// + /// 图层的caption属性的值 + /// 对应的数据库中的表的名称 + 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; + } + /// + /// 根据数据库中的表的名称 查找对应的表中的字段名称的集合 + /// + /// 数据库中的表的名称 + /// 对应的表中的字段名称的集合 + 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; + } + + /// + /// 历史曲线查询 菜单 + /// + /// + /// + 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; + /// + /// 传感器在线报警 菜单 + /// + /// + /// + 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); + } + /// + /// 传感器报警 功能中的 定时器 的触发事件处理 + /// + /// + /// + 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; + } + } + } + } + } + } + } + + + /// + /// 沿线运动 菜单 + /// + /// + /// + private void buttonItem138_Click(object sender, EventArgs e) + { + if (globeControl1.Globe.SelectedObject == null) + { + MessageBox.Show("请先选择一条线!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + return; + } + + GSOFeature lineFeature = globeControl1.Globe.SelectedObject; + if (lineFeature.Geometry == null || lineFeature.Geometry.Type != EnumGeometryType.GeoPolyline3D) + { + MessageBox.Show("请先选择一条线!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + return; + } + + OpenFileDialog dlg = new OpenFileDialog(); + dlg.Filter = "*.gcm;*.3ds|*.gcm;*.3ds|*.3ds|*.3ds|*.gcm|*.gcm"; + if (dlg.ShowDialog() == DialogResult.OK) + { + GSOGeoModel model = new GSOGeoModel(); + model.FilePath = dlg.FileName; + + GSOGeoDynamicRoute dynamicRoute = new GSOGeoDynamicRoute(); + dynamicRoute.ActorGeometry = model; + + GSORoute route = new GSORoute(); + GSOGeoPolyline3D geoline = (GSOGeoPolyline3D)lineFeature.Geometry; + for (int i = 0; i < geoline[0].Count; i++) + { + route.Add(geoline[0][i]); + } + route.CircleRoute = false; + route.Speed = 30; + route.RotateSpeed = 50; + route.AltitudeMode = geoline.AltitudeMode; + dynamicRoute.Route = route; + + GSOFeature feature = new GSOFeature(); + + dynamicRoute.Play(); + feature.Geometry = dynamicRoute; + + //GSOLabel gsoLabel = new GSOLabel(); + //gsoLabel.Text = "模型测试"; + //feature.Label = gsoLabel; + globeControl1.Globe.MinModelVisibleSize = 0; + + globeControl1.Globe.MemoryLayer.AddFeature(feature); + globeControl1.Globe.Refresh(); + } + } + /// + /// 回退 菜单 + /// + /// + /// + private void buttonItem99_Click(object sender, EventArgs e) + { + globeControl1.Globe.UnDoEdit(); + } + /// + /// 前进 菜单 + /// + /// + /// + private void buttonItem100_Click(object sender, EventArgs e) + { + globeControl1.Globe.ReDoEdit(); + } + /// + /// 水平净距 功能界面中的 标签内容改变事件处理 + /// + /// + /// + 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() + "米的管线有:"; + } + } + } + /// + /// 垂直净距 功能界面中的 标签内容改变事件处理 + /// + /// + /// + 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() + "米的管线有:"; + } + } + } + /// + /// 覆土分析 功能界面中的 标签内容改变事件处理 + /// + /// + /// + 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() + "米的管线有:"; + } + } + } + + /// + /// 传感器分类查询 全区域 菜单 + /// + /// + /// + private void buttonItemSensor全区域查询_Click(object sender, EventArgs e) + { + FrmAccessoriesSensor.ShowForm(globeControl1, instrumenLayerNames, 0); + } + /// + /// 传感器分类查询 绘制区域 菜单 + /// + /// + /// + private void buttonItemSensor绘制区域查询_Click(object sender, EventArgs e) + { + FrmAccessoriesSensor.ShowForm(globeControl1, instrumenLayerNames, 1); + } + + + /// + /// 碰撞分析 功能界面中 关闭按钮 事件处理 + /// + /// + /// + 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(); + } + /// + /// 覆土分析 功能界面中的 清除分析结果 按钮事件处理 + /// + /// + /// + 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(); + } + /// + /// 数字预处理 功能 + /// + /// + /// + private void 数字预处理buttonItem140_Click(object sender, EventArgs e) + { + FrmEditShapeFile frm = new FrmEditShapeFile(globeControl1); + frm.ShowDialog(this); + } + + + /// + /// 导出矢量 功能 将图层导出为kml和shp格式数据 + /// + /// + /// + private void 导出矢量buttonItem140_Click(object sender, EventArgs e) + { + List listVectorNames = new List(); + for (int i = 0; i < m_PipelineLayerNames.Count; i++) + { + 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 = ""; + /// + /// 绘制城市七线 功能按钮 + /// + /// + /// + 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; + } + } + } + /// + /// 七线审核 功能按钮 + /// + /// + /// + private void 七线审核buttonItem141_Click(object sender, EventArgs e) + { + FrmCityServerLineAnalysis frm = new FrmCityServerLineAnalysis(globeControl1, m_PipelineLayerNames); + frm.ShowDialog(this); + } + + /// + /// 间距分析 开始分析按钮 分析绘制的七线和管线的距离是否符合标准 + /// + /// + /// + 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; + } + /// + /// 间距分析 清除分析结果 + /// + /// + /// + 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(); + } + /// + /// 间距分析 导出Excel按钮 将间距分析的结果以Excel表格的形式导出 + /// + /// + /// + private void buttonExportExcel_Click(object sender, EventArgs e) + { + if (dataGridViewAnalysisResult.Rows.Count > 0) + { + ExportExcel("间距分析", dataGridViewAnalysisResult, listBoxStasticsResult); + } + else + { + MessageBox.Show("表格内容为空!", "提示"); + } + } + /// + /// 间距分析 关闭按钮 + /// + /// + /// + 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(); + } + /// + /// 间距分析 分析结果表格双击定位 + /// + /// + /// + 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); + } + } + } + } + /// + /// 间距分析 选择管线复选框 + /// + /// + /// + private void checkBoxSelectPipeline_CheckedChanged(object sender, EventArgs e) + { + clearFeatureHighLight();//清除高亮 + if (checkBoxSelectPipeline.Checked) + { + comboBoxLayer.SelectedItem = null; + 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; + } + } + /// + /// 间距分析 选择图层复选框 + /// + /// + /// + 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(); + } + /// + /// 间距分析 选择图层下拉框 + /// + /// + /// + 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; + } + } + } + + + + /// + /// 管线自动缩进 菜单 + /// + /// + /// + private void 管线自动缩进buttonItem140_Click(object sender, EventArgs e) + { + FrmPipelineIndented frm = new FrmPipelineIndented(globeControl1, m_PipelineLayerNames, workwellLayerNames); + 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 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); + // } + //} + + /// + /// 统计指定图层在指定范围内的所有feature对象 + /// + /// + /// + /// + 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) + { + 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 setLayerVisible(string layerName) + { + GSOLayer templayer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + if (templayer != null) + { + templayer.Visible = false; + } + globeControl1.Globe.Refresh(); + } + + /// + /// 连接数据库 + /// + /// + /// + private void buttonItem129_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL4_1.Text); + + FrmDatabaseParaSetting2 frm = new FrmDatabaseParaSetting2(globeControl1); + if (frm.ShowDialog() == DialogResult.OK) + { + ds = FrmDatabaseParaSetting2.ds; + if (ds != null) + { + ds.IsCloseSaved = false; + } + } + } + + /// + /// 一键审核---导入数据 + /// + /// + /// + private void buttonItem127_Click_2(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, "打开数据"); + + try + { + //if (shds == null) + //{ + //没连的话,直接连接审核库; //审核库配置读配置文件 + string dbIp = Utility.sgdbip; + string database = Utility.sgdbname; + string user = Utility.sgdbuser; + string pass = Utility.sgdbpwd; + /* + 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; + //} + } + catch (Exception ex) + { + LogError.PublishError(ex); + MessageBox.Show("内存过载请清理内存,并重新启动规划分析!", "提示"); + return; + } + + } + + /// + ///自动导出图片 + /// + /// + /// + private void buttonItem130_Click_1(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, "导出审核图"); + + 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))); + */ + + int mapWidth = 0; + int mapHeight = 0; + Point pt = getUpperLeftPoint(pt1, pt2, out mapWidth, out mapHeight); + int rightBottomX = pt.X + mapWidth; + int rightBottomY = pt.Y + mapHeight; + Image myImg = new Bitmap(mapWidth, mapHeight); + Graphics g = Graphics.FromImage(myImg); + g.CopyFromScreen(pt, new Point(0, 0), new Size(rightBottomX, rightBottomY)); + + 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; + } + } + } + /// + /// 一键审核功能 + ///
+ /// + /// + private void buttonItem128_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItem128.Text); + //垂直净距标准 + + frmSh = new FrmYJSHTC(globeControl1, globeControl2,layerTree); + + if (frmSh.ShowDialog() == DialogResult.OK) + { + frmWait = new FrmWait("一键审核……"); + frmWait.Location = new Point(this.Width - frmWait.Width - 10, this.Height - frmWait.Height - 50); + frmWait.Owner = this; + frmWait.Show(); + Thread thread = new Thread(new ThreadStart(doWork)); + thread.IsBackground = true; + thread.Start(); + } + } + + void doWork() + { + FrmShResult frmShResult = null; + + double dVerticalJingJuBiaoZhun = 1, dHorizontalJingJuBiaoZhun = 1; + if (frmSh.rukuLayer != null) + { + #region + this.Invoke((EventHandler)delegate + { + try + { + List managerLayerList = new List(); + for (int i = 0; i < layerManagerNode.Nodes.Count; i++) + { + managerLayerList.Add(layerManagerNode.Nodes[i].Text); + } + if (!managerLayerList.Contains(frmSh.rukuLayer.Caption)) + { + TreeNode node = new TreeNode(); + node.Tag = frmSh.rukuLayer; + node.Text = frmSh.rukuLayer.Dataset.Caption; + node.ImageIndex = 0; + node.SelectedImageIndex = 0; + node.Checked = frmSh.rukuLayer.Visible; + layerManagerNode.Nodes.Insert(0, node); + layerManagerNode.Expand(); + } + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "提示"); + } + }); + #endregion + + shlayername = frmSh.rukuLayer.Name; + globeControl1.Refresh(); + } + + if (frmShResult != null && !frmShResult.IsDisposed) + { + try + { + clearFeatureHighLight(); + ClearRedlineAnalyseResult(); + frmShResult.Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message); + } + } + + 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.analysis(); + + //MainFrm窗体显示控制,回到一键审核Tab + this.Invoke((EventHandler)delegate + { + frmShResult.Show(); + frmWait.Close(); + //将tab页恢复到一键审核 + ribbonTabItem11.Checked = true; + try + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + //zhanshi = false; + splitContainer1.Panel2Collapsed = true; + + panelOfTable.Visible = false; + legendSC.Visible = false; + legendSG.Visible = false; + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + } + catch (Exception ex) + { + MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + + }); + + boolfrmShResult = true; + } + else + { + + } + } + + + /// + /// 清除渲染结果 + /// + 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(); + } + /// + /// 已审核的图层 + /// + /// + /// + private void buttonItem132_Click_1(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItem132.Text); + + if (shds == null) + { + //没连的话,直接连接审核库; //审核库配置读配置文件 + string dbIp = Utility.sgdbip; + string database = Utility.sgdbname; + string user = Utility.sgdbuser; + string pass = Utility.sgdbpwd; + + /* + 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; + //} + + } + /// + /// 审核入库 + /// + /// + /// + private void buttonItem133_Click_1(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, "审核入库"); + FrmShRK frmShrk = new FrmShRK(globeControl1); + frmShrk.Show(); + } + /// + /// 模拟设计修改 + /// + /// + /// + private void buttonItem134_Click_1(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, "模拟设计修改"); + + 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 + { + + } + + } + + + /// + /// 绘制垂线 + /// + /// + /// + 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); + } + /// + /// 比较两个点是否是同一个点 + /// + /// + /// + /// + 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; + } + /// + /// 获得点到线的垂线距离及垂点 + /// + /// + /// + /// + /// + 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); + 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]; + } + /// + /// 获得斜率 + /// + /// + /// + /// + /// + /// + /// + 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); + } + } + /// + /// 根据默认投影参数,经纬度转xyz + /// + /// + /// + /// + 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; + } + /// + /// 根据投影参数,经纬度转xyz + /// + /// + /// + /// + /// + 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; + } + /// + /// 根据默认投影参数,xyz转经纬度 + /// + /// + /// + /// + 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; + } + /// + /// 根据投影参数,Xyz转经纬度 + /// + /// + /// + /// + /// + 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; + } + /// + /// 获得inpolygon的管线长度 + /// + /// + 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; + } + + + /// + /// 一键审核中调节透明度 + /// + /// + /// + private void sliderItem1_ValueChanged(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.sliderItem1.Text); + + globeControl1.Globe.GroundOpaque = 100 - sliderItem1.Value; + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(roadLayerName);//("180fd"); + if (layer != null) + { + layer.Opaque = 100 - sliderItem1.Value; + } + + optiValue = sliderItem1.Value; + } + /// + /// 红线审核中的透明度分析 + /// + /// + /// + private void sliderItem3_ValueChanged(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.sliderItem3.Text); + + globeControl1.Globe.GroundOpaque = 100 - sliderItem3.Value; + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(roadLayerName);//("180fd"); + if (layer != null) + { + layer.Opaque = 100 - sliderItem3.Value; + } + optiValue = sliderItem3.Value; + } + + #region yanxiaowei + //初始化DataGridViewX1控件 + public delegate void DataGridViewDelegate(DataTable dt, string strLable, string strLayer, bool initDataGrid); + /// + /// 代理函数,操作DatgridViewX1 + /// + /// + /// + public void InitDataGridViewX1(DataTable dt, string strLable, string strLayer, bool initDataGrid) + { + if (initDataGrid == true) + { + dataGridViewX1.DataSource = dt; + panelOfTable.Visible = true; + toolStripNumbers.Text = strLable; + dataGridViewX1.Tag = strLayer; + } + else + { + dataGridViewX1.DataSource = null; + dataGridViewX1.Refresh(); + panelOfTable.Visible = false; + toolStripNumbers.Text = ""; + dataGridViewX1.Tag = ""; + globeControl1.Globe.MemoryLayer.RemoveAllFeature();//清除双击产生的标注 + } + } + FrmAnalysisGuiHuaResult from; + /// + /// 主窗体下方属性表格 双击定位 功能 + /// + /// + /// + private void dataGridViewX1_MouseDoubleClick(object sender, MouseEventArgs e) + { + if (redSH == false) + { + 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 if (dataGridViewX1.Columns.Contains("标识器编号")) + { + featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["标识器编号"].Value.ToString(); + } + featureName = featureName.Trim(); + + GSOLayer layer = null; + layer = globeControl1.Globe.Layers.GetLayerByCaption(dataGridViewX1.Tag.ToString()); + + if (layer == null) return; + + GSOFeatures features = layer.GetFeatureByName(featureName, false); + if (features.Length == 0) return; + GSOFeature rowFeature = features[0]; + + ClassSearchAnalysis.AddMakerToLineFeature(globeControl1, rowFeature); + + } + } + } + else + { + if (e.Button == MouseButtons.Left) + { + if (from != null && !from.IsDisposed) + { + try + { + from.Close(); + } + catch (Exception ex) + { + LogError.PublishError(ex); + } + } + try + { + DataGridView.HitTestInfo hittestinfo = dataGridViewX1.HitTest(e.X, e.Y); + if (hittestinfo.RowIndex >= 0) + { + string layer = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["管线类型"].Value.ToString(); + string hxName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["红线编号"].Value.ToString(); + FrmAnalysisGuiHuaResult frm = new FrmAnalysisGuiHuaResult(globeControl1, lineStruct, featsList, + panelOfTable, dataGridViewX1, layer, hxName); + frm.Location = new Point(this.Width - frm.Width - 10, this.Height - frm.Height - 20); + frm.Show(this); + + from = frm; + } + } + catch (Exception ex) + { + LogError.PublishError(ex); + } + } + } + } + + /// + /// 空间查询 + /// + /// + /// + private void buttonItemSearch1_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemSearch1.Text); + + trackflag = "PipelineSpatialQuery"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; + + } + /// + /// 关键字查询 + /// + /// + /// + private void buttonItemSearch9_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch9.Text); + + FrmKeywordQuery.ShowForm(globeControl1, m_PipelineLayerNames, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 编号查询 + /// + /// + /// + private void buttonItemSearch2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch2.Text); + + FrmCodingQuery.ShowForm(globeControl1, m_PipelineLayerNames, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 坐标查询 + /// + /// + /// + private void buttonItemSearch3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch3.Text); + + FrmSetLatLonPos.ShowForm(globeControl1); + } + /// + /// 附属物查询 + /// + /// + /// + private void buttonItemSearch10_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch10.Text); + + FrmFittingQuery.ShowForm(globeControl1, instrumenLayerNames, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 管径查询 + /// + /// + /// + private void buttonItemSearch4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch4.Text); + + FrmDiameterQuery.ShowForm(globeControl1, m_PipelineLayerNames, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 材质查询 + /// + /// + /// + private void buttonItemSearch5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch5.Text); + + FrmMaterialSel.ShowForm(globeControl1, m_PipelineLayerNames, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 基本查询 + /// + /// + /// + private void buttonItemSearch6_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch6.Text); + + FrmBasicQuery.ShowForm(globeControl1, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 复合查询 + /// + /// + /// + private void buttonItemSearch7_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch7.Text); + + FrmQuerySQL.ShowForm(globeControl1, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 关联查询 + /// + /// + /// + private void buttonItemSearch8_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch8.Text); + + if (globeControl1.Globe.SelObjectCount != 1) + { + MessageBox.Show("请选中一个对象!", "提示"); + return; + } + + 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 || (feature.Geometry.Type == EnumGeometryType.GeoPolygon3D + || feature.Geometry.Type == EnumGeometryType.GeoWater)) + return; + else + { + ClassSearchAnalysis.ResultRelationAnalysis(globeControl1, feature, valueLayerNames, workwellLayerNames, + instrumenLayerNames, pipefittingLayerNames, m_PipelineLayerNames, valueAllowance); + } + } + } + #endregion + /// + /// 清除分析 + /// + /// + /// + private void buttonItemClear_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemClear.Text); + + globeControl1.Globe.ClearMeasure(); + layerTemp.RemoveAllFeature(); + layerTemp2.RemoveAllFeature(); + buttonItemLS5.Checked = false; + + dataGridViewX1.DataSource = null; + panelOfTable.Visible = false; + + 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); + + NetworkAnalysisTool.ClearAllTopAnalysis(this.globeControl1); + // 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();//清除所有坑 + + 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(); + } + } + + clearFeatureHighLight();//取消管线高亮 + + GSOLayer layerGround = globeControl1.Globe.Layers.GetLayerByCaption(roadLayerName);//("180fd"); + if (layerGround != null) + { + layerGround.Visible = true; + } + globeControl1.Refresh(); + globeControl2.Refresh(); + ClearRedlineAnalyseResult(); + globeControl1.Globe.Action = EnumAction3D.ActionNull; + } + /// + /// 管线长度全区域统计 + /// + /// + /// + private void buttonItemTJ1_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管线长度统计"); + + FrmAllPipelineStatis frm = new FrmAllPipelineStatis(globeControl1,null, new DataGridViewDelegate(InitDataGridViewX1), m_PipelineLayerNames); + frm.Show(this); + } + /// + /// 管线长度绘制区域统计 + /// + /// + /// + private void buttonItemTJ1_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管线长度统计"); + + trackflag = "PipelineDistanceStatistics"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; + } + /// + /// 阀门数量全区域统计 + /// + /// + /// + private void buttonItemTJ2_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "阀门数量统计"); + + FrmValveStatistics frm = new FrmValveStatistics(globeControl1, null, new DataGridViewDelegate(InitDataGridViewX1)); + frm.Show(this); + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + } + /// + /// 阀门数量绘制区域统计 + /// + /// + /// + private void buttonItemTJ2_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "阀门数量统计"); + + trackflag = "valvequery"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; + } + /// + /// 井盖数量全区域统计 + /// + /// + /// + private void buttonItemTJ3_ALL_Click(object sender, EventArgs e) +<<<<<<< HEAD + { + //日志记录 + LogManager.saveLog(Utility.userName, "井盖数量统计"); +======= + { +>>>>>>> d2d0088a6b3c53c1a96b7f1997f4d3443c0ee8c0 + FrmAllWorkWellStatis frm = new FrmAllWorkWellStatis(globeControl1, null, new DataGridViewDelegate(InitDataGridViewX1)); + frm.Show(this); + } + /// + /// 井盖数量绘制区域统计 + /// + /// + /// + private void buttonItemTJ3_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "井盖数量统计"); + + trackflag = "workwellquery"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; + } + /// + /// 管径分段统计全区域统计 + /// + /// + /// + private void buttonItemTJ4_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管径分段统计"); + + Frmpipediameterstatis.ShowForm(globeControl1, m_PipelineLayerNames, 0); + } + /// + /// 管径分段统计绘制区域统计 + /// + /// + /// + private void buttonItemTJ4_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管径分段统计"); + + trackflag = null; + Frmpipediameterstatis.ShowForm(globeControl1, m_PipelineLayerNames, 1); + } + /// + /// 埋深分段统计全区域统计 + /// + /// + /// + private void buttonItemTJ5_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "埋深分段统计"); + FrmpipeDeepstatis.ShowForm(globeControl1, m_PipelineLayerNames, 0); + } + /// + /// 埋深分段统计绘制区域统计 + /// + /// + /// + private void buttonItemTJ5_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "埋深分段统计"); + trackflag = null; + FrmpipeDeepstatis.ShowForm(globeControl1, m_PipelineLayerNames, 1); + } + /// + /// 管径分类统计全区域统计 + /// + /// + /// + private void buttonItemTJ6_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管径分类汇总"); + + FrmpipeDiametergather.ShowForm(globeControl1, m_PipelineLayerNames, 0); + } + /// + /// 管径分类统计绘制区域统计 + /// + /// + /// + private void buttonItemTJ6_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管径分类汇总"); + + trackflag = null; + FrmpipeDiametergather.ShowForm(globeControl1, m_PipelineLayerNames, 1); + } + /// + /// 材质分类统计全区域统计 + /// + /// + /// + private void buttonItemTJ7_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "材质分类汇总"); + + FrmpipeMaterialGather.ShowForm(globeControl1, m_PipelineLayerNames, 0); + } + /// + /// 材质分类统计绘制区域统计 + /// + /// + /// + private void buttonItemTJ7_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "材质分类汇总"); + + trackflag = null; + FrmpipeMaterialGather.ShowForm(globeControl1, m_PipelineLayerNames, 1); + } + /// + /// 附属物分类统计全区域统计 + /// + /// + /// + private void buttonItemTJ8_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "附属物分类汇总"); + + FrmAccessoriesgather.ShowForm(globeControl1, instrumenLayerNames, 0); + } + /// + /// 附属物分类统计绘制区域统计 + /// + /// + /// + private void buttonItemTJ8_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "附属物分类汇总"); + + trackflag = null; + FrmAccessoriesgather.ShowForm(globeControl1, instrumenLayerNames, 1); + } + /// + /// 碰撞分析 + /// + /// + /// + private void buttonItemFX1_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_4.Text); + + this.dataGridViewX4.Size = new System.Drawing.Size(195, 120); + 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(); + } + /// + /// 覆土分析 + /// + /// + /// + private void buttonItemFX1_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX5_1.Text); + this.dataGridViewX6.Size = new System.Drawing.Size(195, 120); + 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(); + } + /// + /// 间距分析 + /// + /// + /// + private void buttonItemFX1_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX1_3.Text); + + this.dataGridViewLineList.Size = new System.Drawing.Size(185, 120); + 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(); + } + /// + /// 垂直净距分析 + /// + /// + /// + private void buttonItemFX1_4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX1_4.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(); + } + /// + /// 水平净距分析 + /// + /// + /// + private void buttonItemFX1_5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_6.Text); + this.dataGridViewX8.Size = new System.Drawing.Size(185, 120); + 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(); + } + + #region Predaotr,断面分析 + /// + /// 横断面分析 + /// + /// + /// + private void buttonItemFX2_1_Click(object sender, EventArgs e) + { + globeControl1.Globe.Action = EnumAction3D.TrackPolyline; + globeControl1.Globe.TrackPolylineTool.VerticalLineVisible = true; + globeControl1.Globe.TrackPolylineTool.TrackMode = EnumTrackMode.SpaceTrack; + trackPolylineEndMode = EnumTrackPolylineEndMode.HDM_Analysis; + + } + /// + /// 纵断面分析 + /// + /// + /// + private void buttonItemFX2_2_Click(object sender, EventArgs e) + { + if (globeControl1.Globe.SelObjectCount<1) + { + MessageBox.Show("请选择一条或者多条管线!", "提示", MessageBoxButtons.OK, + MessageBoxIcon.Information); + return; + } + 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); + } + } + List feats = SectionAnalysisTool.ZDMAnalysis(selectFeatures); + if (feats != null && feats.Count >= 1) + { + FrmProfileAnalysis frm = new FrmProfileAnalysis(globeControl1, feats); + frm.Show(this); + } + } + /// + /// 道路断面分析 + /// + /// + /// + private void buttonItemFX2_3_Click(object sender, EventArgs e) + { + globeControl1.Globe.Action = EnumAction3D.TrackPolyline; + globeControl1.Globe.TrackPolylineTool.VerticalLineVisible = true; + globeControl1.Globe.TrackPolylineTool.TrackMode = EnumTrackMode.SpaceTrack; + trackPolylineEndMode = EnumTrackPolylineEndMode.DLDM_Analysis; + + } + /// + /// 基线剖面分析 + /// + /// + /// + private void buttonItemFX2_4_Click(object sender, EventArgs e) + { + globeControl1.Globe.Action = EnumAction3D.TrackPolyline; + globeControl1.Globe.TrackPolylineTool.VerticalLineVisible = true; + globeControl1.Globe.TrackPolylineTool.TrackMode = EnumTrackMode.SpaceTrack; + trackPolylineEndMode = EnumTrackPolylineEndMode.JXPM_Analysis; + + } + + #endregion + /// + /// 创建拓扑 + /// + /// + /// + private void buttonItemFX3_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX3_1.Text); + + FrmGenAndFaMenTopu frm = new FrmGenAndFaMenTopu(globeControl1, m_PipelineLayerNames, valueLayerNames); + frm.Show(this); + } + #region Predator :拓扑分析 + /// + /// 上游分析 + /// + /// + /// + private void buttonItemFX3_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX3_2.Text); + NetworkTraceUpDown(true); + } + /// + /// 下游分析 + /// + /// + /// + private void buttonItemFX3_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX3_3.Text); + NetworkTraceUpDown(false); + } + + /// + /// 上下游追踪 功能 + /// + /// + private void NetworkTraceUpDown(Boolean bTraceUp) + { + GSOFeature selLineFeature = globeControl1.Globe.SelectedObject; + if (selLineFeature == null || selLineFeature.Geometry == null || selLineFeature.Geometry.Type != EnumGeometryType.GeoPolyline3D) + { + MessageBox.Show("请点击“编辑”—“选中对象”选择一条线!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); + return; + } + GSOLayer selLayer = globeControl1.Globe.SelectedObjectLayer; + + NetworkAnalysisTool.TraceUpDownAnalysis(bTraceUp, + selLineFeature, selLayer); + } + + /// + /// 流向分析 + /// + /// + /// + private void buttonItemFX3_4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX3_4.Text); + + FrmFlow frm = new FrmFlow(globeControl1, m_PipelineLayerNames); + frm.Show(this); + } + /// + /// 关阀分析 + /// + /// + /// + private void buttonItemFX3_5_Click(object sender, EventArgs e) + { + if (globeControl1.Globe.SelObjectCount < 1) + { + MessageBox.Show("请选中至少一根管线!!"); + buttonItemFX3_5.Checked = false; + return; + } + GSOLayer resLayer = null; + GSOFeature resFeature = null; + globeControl1.Globe.GetSelectObject(0, out resFeature, out resLayer); + + String pipeLayerName = resLayer.Caption; + String pipeLayerNamePrefix = pipeLayerName.Substring(0, pipeLayerName.IndexOf("管线")); + GSOLayer valveLayer = globeControl1.Globe.Layers[pipeLayerNamePrefix + "阀门"]; + if (valveLayer == null) + { + MessageBox.Show("无" + pipeLayerNamePrefix+"阀门图层", "提示"); + return; + } + + GSOFeatures valveFeats = NetworkAnalysisTool.CloseValvesAnalysis(resFeature, + resLayer, valveLayer); + + if (valveFeats != null) + { + FrmCloseValves frm = new FrmCloseValves(this.globeControl1, valveFeats); + frm.Show(this); + } + else + { + MessageBox.Show("未找到关闭阀门"); + } + } + + /// + /// 连通分析 + /// + /// + /// + private void buttonItemFX3_6_Click(object sender, EventArgs e) + { + if (globeControl1.Globe.SelObjectCount < 2) + { + MessageBox.Show("请选中至少两个管线!!"); + buttonItemFX3_6.Checked = false; + return; + } + GSOFeature selFeat0, selFeat1; + GSOLayer layer0,layer1; + globeControl1.Globe.GetSelectObject(0, out selFeat0, out layer0); + globeControl1.Globe.GetSelectObject(1, out selFeat1, out layer1); + + if (!layer0.IsSameInnerObject(layer1)) + { + MessageBox.Show("不在同一个图层!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); + buttonItemFX3_6.Checked = false; + return; + } + NetworkAnalysisTool.ConnexityAnalysis(selFeat0, selFeat1, layer0); + } + /// + /// 爆管分析 + /// + /// + /// + private void buttonItemFX3_7_Click(object sender, EventArgs e) + { + NetworkTraceUpDown(true); //上游追踪: + + GSOFeature selLineFeature = globeControl1.Globe.SelectedObject; + if (selLineFeature == null || selLineFeature.Geometry == null || selLineFeature.Geometry.Type != EnumGeometryType.GeoPolyline3D) + { + MessageBox.Show("请点击“编辑”—“选中对象”选择一条线!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); + return; + } + GSOLayer selLayer = globeControl1.Globe.SelectedObjectLayer; + + NetworkAnalysisTool.ExplodeAnalysis(this.globeControl1,selLineFeature,selLayer); + + this.buttonItemFX3_5_Click(sender, e); //关阀分析: + + } + + #endregion + /// + /// 多边形开挖 + /// + /// + /// + private void buttonItemFX4_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_1.Text); + + trackflag = "pit"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; //是这个么?是的,在模型上 + } + /// + /// 挖方量分析 + /// + /// + /// + private void buttonItemFX4_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_2.Text); + + trackflag = "digFillAnalysis"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; + ActionToolMenuChecked(); + } + /// + /// 沿线开挖 + /// + /// + /// + private void buttonItemFX4_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_3.Text); + + if (!buttonItemFX4_3.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; + buttonItemFX4_3.Checked = true; + } + } + else + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + buttonItemFX4_3.Checked = false; + globeControl1.Globe.TrackPolylineTool.VerticalLineVisible = false; + } + ActionToolMenuChecked(); + } + /// + /// 创建隧道 + /// + /// + /// + private void buttonItemFX4_4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_4.Text); + + 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("场景中未加载隧道图层!", "提示"); + } + } + /// + /// 隐藏隧道 + /// + /// + /// + private void buttonItemFX4_5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_5.Text); + + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption("隧道"); + if (layer != null) + { + layer.Visible = !layer.Visible; + } + } + /// + /// 删除隧道 + /// + /// + /// + private void buttonItemFX4_6_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_6.Text); + + 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("请选中要删除的隧道!", "提示"); + } + } + /// + /// 通视分析 + /// + /// + /// + private void buttonItemFX5_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX5_1.Text); + + if (globeControl1.Globe.Action != EnumAction3D.VisibilityAnalysis) + { + //btnSpaceVisibilityAnalysis.Checked = true; + globeControl1.Globe.Action = EnumAction3D.VisibilityAnalysis; + } + else + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + // SetButtonChecked(); + } + } + /// + /// 可视域分析 + /// + /// + /// + private void buttonItemFX5_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX5_2.Text); + + globeControl1.Globe.Action = EnumAction3D.ViewshedAnalysis; + } + /// + /// 可视包络分析 + /// + /// + /// + private void buttonItemFX5_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX5_3.Text); + + globeControl1.Globe.Action = EnumAction3D.ViewEnvelopeAnalysis; + } + /// + /// 缓冲区分析 + /// + /// + /// + private void buttonItemFX6_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX6_1.Text); + + GSOFeature feat = globeControl1.Globe.SelectedObject; + if (feat == null) + { + MessageBox.Show("请选择要分析的要素!"); + return; + } + if (feat.Geometry.Type == EnumGeometryType.GeoPolyline3D) + { + GSOGeoPolyline3D line1 = feat.Geometry as GSOGeoPolyline3D; + if (line1 == null) + { + MessageBox.Show("请选择一条管线!"); + return; + } + + FrmBufferAnalysis frm = new FrmBufferAnalysis(globeControl1, line1, layerTemp); + frm.Show(this); + } + else + { + FrmBufferAnalysisBSQ frm = new FrmBufferAnalysisBSQ(globeControl1, layerTemp, bsqPT); + frm.Show(this); + } + + } + /// + /// 附属物分析 + /// + /// + /// + private void buttonItemFX6_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX6_2.Text); + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + FrmAccessoryAnalysis dlg = new FrmAccessoryAnalysis(globeControl1, layerTemp); + dlg.Show(this); + } + /// + /// 无源淹没分析 + /// + /// + /// + private void buttonItemFX6_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX6_3.Text); + + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + trackflag = "FloodAnalysis"; + } + /// + /// 水平距离 + /// + /// + /// + private void buttonItemLS1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS1.Text); + + globeControl1.Globe.Action = EnumAction3D.MeasureDistance; + globeControl1.Globe.DistanceRuler.SpaceMeasure = false; + buttonItemLS5.Checked = false; + } + /// + /// 垂直距离 + /// + /// + /// + private void buttonItemLS2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS2.Text); + + buttonItemLS5.Checked = false; + globeControl1.Globe.Action = EnumAction3D.MeasureHeight; + globeControl1.Globe.DistanceRuler.SpaceMeasure = false; + } + /// + /// 空间距离 + /// + /// + /// + private void buttonItemLS3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS3.Text); + + buttonItemLS5.Checked = false; + globeControl1.Globe.Action = EnumAction3D.MeasureDistance; + globeControl1.Globe.DistanceRuler.SpaceMeasure = true; + } + /// + /// 地表距离 + /// + /// + /// + private void buttonItemLS4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS4.Text); + + buttonItemLS5.Checked = false; + globeControl1.Globe.Action = EnumAction3D.MeasureDistance; + globeControl1.Globe.DistanceRuler.SpaceMeasure = false; + } + /// + /// 高度量算 + /// + /// + /// + private void buttonItemLS5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS5.Text); + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + buttonItemLS5.Checked = !buttonItemLS5.Checked; + if (buttonItemLS5.Checked) + { + globeControl1.Globe.Action = EnumAction3D.SelectObject; + } + } + /// + /// 水平面积 + /// + /// + /// + private void buttonItemLS6_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS6.Text); + + buttonItemLS5.Checked = false; + globeControl1.Globe.Action = EnumAction3D.MeasureArea; + globeControl1.Globe.AreaRuler.SpaceMeasure = true; + } + /// + /// 地表面积 + /// + /// + /// + private void buttonItemLS7_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS7.Text); + + buttonItemLS5.Checked = false; + globeControl1.Globe.Action = EnumAction3D.MeasureArea; + globeControl1.Globe.AreaRuler.SpaceMeasure = false; + + } + + # region Fan 重构标注代码 + /// + /// 标高标注 + /// + /// + /// + private void buttonItemSZ1_Click(object sender, EventArgs e) + { + GSOFeature resFeature = IsPipeLineOfSelectedObj(); + if (resFeature == null) + { + MessageBox.Show("请选中一根管线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + GSOGeoPolyline3D selLine = resFeature.Geometry as GSOGeoPolyline3D; + if (selLine[0].Count <= 1) + { + return; + } + + MarkTools.getInstance().showMarker(resFeature, + globeControl1, EnumMarkLayer.Mark_Altitude, ""); + } + /// + /// 管径标注 + /// + GSOFeature radiusMarkerFeature; + private void buttonItemBZ2_Click(object sender, EventArgs e) + { + GSOFeature resFeature = IsPipeLineOfSelectedObj(); + if (resFeature == null) + { + MessageBox.Show("请选中一根管线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + GSOGeoPolyline3D selLine = resFeature.Geometry as GSOGeoPolyline3D; + if (selLine[0].Count <= 1) + { + return; + } + + MarkTools.getInstance().showMarker(resFeature, + globeControl1, EnumMarkLayer.Mark_Diameter, ""); + } + /// + /// 埋深标注 + /// + /// + /// + private void buttonItemBZ3_Click(object sender, EventArgs e) + { + GSOFeature resFeature = IsPipeLineOfSelectedObj(); + if (resFeature == null) + { + MessageBox.Show("请选中一根管线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + GSOGeoPolyline3D selLine = resFeature.Geometry as GSOGeoPolyline3D; + if (selLine[0].Count <=1) + { + return; + } + + MarkTools.getInstance().showMarker(resFeature, + globeControl1, EnumMarkLayer.Mark_Depth, ""); + + } + /// + /// 坐标标注 + /// + /// + /// + private void buttonItemBZ4_Click(object sender, EventArgs e) + { + GSOFeature resFeature = IsPipeLineOfSelectedObj(); + if (resFeature == null) + { + MessageBox.Show("请选中一根管线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + GSOGeoPolyline3D selLine = resFeature.Geometry as GSOGeoPolyline3D; + if (selLine[0].Count <= 1) + { + return; + } + MarkTools.getInstance().showMarker(resFeature, + globeControl1, EnumMarkLayer.Mark_Location, ""); + } + /// + /// 距离标注 + /// + bool distanceMarker = false; + private void buttonItemBZ5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBZ5.Text); + + globeControl1.Globe.Action = EnumAction3D.TrackPolyline; + //globeControl1.Globe.DistanceRuler.MeasureMode = EnumDistanceMeasureMode.HVSLineMeasure; + distanceMarker = true; + } + /// + /// 自定义标注 + /// + /// + /// + private void buttonItemBZ6_Click(object sender, EventArgs e) + { + GSOFeature f = globeControl1.Globe.SelectedObject; + GSOLayer l = globeControl1.Globe.SelectedObjectLayer; + FrmCustomLabel frm = new FrmCustomLabel(globeControl1, l, f); + if (frm.ShowDialog() == DialogResult.OK) + { + MarkTools.getInstance().showMarker(f, globeControl1, EnumMarkLayer.Mark_Custom, frm.labelText); + } + } + /// + /// 扯旗标注 + /// + /// + /// + private void buttonItemBZ7_Click(object sender, EventArgs e) + { + GSOFeature f = globeControl1.Globe.SelectedObject; + GSOLayer l = globeControl1.Globe.SelectedObjectLayer; + FrmMarker frm = new FrmMarker(); + if (frm.ShowDialog() == DialogResult.OK) + { + MarkTools.getInstance().showMarker(f, globeControl1, EnumMarkLayer.Mark_Custom, frm.markerContent); + } + } + /// + /// 坡度标注 + /// + /// + /// + private void buttonItemBZ8_Click(object sender, EventArgs e) + { + GSOFeature resFeature = IsPipeLineOfSelectedObj(); + if (resFeature == null) + { + MessageBox.Show("请选中一根管线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + GSOGeoPolyline3D selLine = resFeature.Geometry as GSOGeoPolyline3D; + if (selLine[0].Count <= 1) + { + return; + } + + MarkTools.getInstance().showMarker(resFeature, + globeControl1, EnumMarkLayer.Mark_Slope, ""); + } + /// + /// 属性标注 + /// + /// + /// + private void buttonItemBZ9_Click(object sender, EventArgs e) + { + GSOFeature f = globeControl1.Globe.SelectedObject; + GSOLayer l = globeControl1.Globe.SelectedObjectLayer; + FrmPropertiesMarker frm = new FrmPropertiesMarker(globeControl1, l, f); + if (frm.ShowDialog() == DialogResult.OK) + { + MarkTools.getInstance().showMarker(f, globeControl1, EnumMarkLayer.Mark_Property, frm.labelText); + } + } + /// + /// 红线工具 + /// + /// + /// + private void buttonItemBZ10_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBZ10.Text); + 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; + } + } + /// + /// 标注管理 + /// + /// + /// + private void buttonItemBZ11_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBZ11.Text); + + buttonItemBZ11.Checked = !buttonItemBZ11.Checked; + 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 (buttonItemBZ11.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(); + } + } + + #endregion + /// + /// 飞行到目标点 + /// + /// + /// + private void buttonItemFXGJ1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFXGJ1.Text); + + FrmSetFlytoPos.ShowForm(globeControl1); + + } + /// + /// 自定义飞行 + /// + /// + /// + private void buttonItemFXGJ2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFXGJ2.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); + } + } + /// + /// 绕中心点飞行 + /// + /// + /// + private void buttonItemFXGJ3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFXGJ3.Text); + + globeControl1.Globe.FlyAroundCenter(10000, EnumFlyRepeatValueType.MiliSeconds); + globeControl1.Globe.CurFlyID = 1; + } + /// + /// 绕眼睛飞行 + /// + /// + /// + private void buttonItemFXGJ4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFXGJ4.Text); + + globeControl1.Globe.FlyAroundEye(720, EnumFlyRepeatValueType.Degrees); + globeControl1.Globe.CurFlyID = 2; + } + + /// + /// 权限管理 + /// + /// + /// + private void buttonItemXT1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT1.Text); + + FrmUserRoleMgr frm = new FrmUserRoleMgr(); + frm.ShowDialog(); + } + /// + /// 数据库管理 + /// + /// + /// + private void buttonItemXT2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT2.Text); + + //查看数据库列表 + FrmDbManager frm = new FrmDbManager(); + frm.ShowDialog(); + } + /// + /// 用户列表 + /// + /// + /// + private void buttonItemXT3_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT3_1.Text); + + FrmUserManager frm = new FrmUserManager(); + frm.ShowDialog(); + } + /// + /// 创建新用户 + /// + /// + /// + private void buttonItemXT3_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT3_2.Text); + + FrmUserAdd frm = new FrmUserAdd(-1); + frm.ShowDialog(); + } + /// + /// 人员修改 + /// + /// + /// + private void buttonItemXT4_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT4_2.Text); + + FrmAppUSER appUSER = new FrmAppUSER(); + appUSER.ShowDialog(); + } + /// + /// 增加人员 + /// + /// + /// + private void buttonItemXT4_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT4_1.Text); + + FrmAppUSERRESET appUSERRESET = new FrmAppUSERRESET(); + appUSERRESET.ShowDialog(); + } + /// + /// 统计数据 + /// + /// + /// + private void buttonItemZTT1_Click(object sender, EventArgs e) + { + ////日志记录 + //LogManager.saveLog(Utility.userName, this.buttonItemZTT1.Text); + + //PATM patm = new PATM(); + //patm.operation = "Statistic"; + //patm.Text = "统计专题图管理"; + //patm.ShowDialog(); + } + /// + /// 热点功能统计 + /// + /// + /// + private void buttonItemZTT2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT2.Text); + + FrmHotFuncStat frmhfs = new FrmHotFuncStat(); + frmhfs.ShowDialog(); + } + + private void buttonItemZTT3_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT3_1.Text); + + FrmAPP appfrm = new FrmAPP("专题图申请"); + appfrm.ShowDialog(); + } + + private void buttonItemZTT3_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT3_2.Text); + + FrmAPPFORASK appForask = new FrmAPPFORASK("专题图审核"); + appForask.ShowDialog(); + } + + private void buttonItemZTT3_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT3_3.Text); + + FrmAPPregion appregion = new FrmAPPregion("专题图审核"); + appregion.ShowDialog(); + } + + private void buttonItemZTT4_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT4_1.Text); + + FrmAPP appfrm = new FrmAPP("打印申请"); + appfrm.ShowDialog(); + } + + private void buttonItemZTT4_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT4_2.Text); + + FrmAPPFORASK appForask = new FrmAPPFORASK("打印审核"); + appForask.ShowDialog(); + } + + private void buttonItemZTT4_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT4_3.Text); + + FrmAPPregion appregion = new FrmAPPregion("打印审核"); + appregion.ShowDialog(); + } + + private void buttonItemZTT5_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT5_1.Text); + + FrmAPP appfrm = new FrmAPP("拷贝申请"); + appfrm.ShowDialog(); + } + + private void buttonItemZTT5_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT5_2.Text); + + FrmAPPFORASK appForask = new FrmAPPFORASK("拷贝审核"); + appForask.ShowDialog(); + } + + private void buttonItemZTT5_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT5_3.Text); + + FrmAPPregion appregion = new FrmAPPregion("拷贝审核"); + appregion.Show(); + } + + private int connectServerCount = 0; + + /// + /// 还原球到实测库 + /// + 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); + } + + if (layerManagerNode.Nodes.Count > 0) + { + for (int i = layerManagerNode.Nodes.Count - 1; i >= 0; i--) + { + layerManagerNode.Nodes[i].Remove(); + + } + } + + globeControl1.Refresh(); + + } + + private void buttonItemSPSZ_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSPSZ.Text); + + FrmLayerControl frm = new FrmLayerControl(layerTree, globeControl1, globeControl2); + frm.Show(this); + } + + /// + /// 碰撞审查 + /// + /// + /// + private void buttonItemSH1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSH1.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 buttonItemSH2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSH2.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 buttonItemSH3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSH3.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 buttonItemSH4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSH4.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 buttonItemSH5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSH5.Text); + FrmCityServerLineAnalysis frm = new FrmCityServerLineAnalysis(globeControl1, m_PipelineLayerNames); + frm.Show(this); + } + #region 数据管理-导入文件 + ///// + ///// 数据管理-导入本地坐标系文件 + ///// + ///// + ///// + //private void buttonItemSJGL1_1_Click(object sender, EventArgs e) + //{ + // //日志记录 + // LogManager.saveLog(Utility.userName, this.buttonItemSJGL1_1.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(); + // } + // } + //} + + ///// + ///// 数据管理-导入其他坐标系文件 + ///// + ///// + ///// + //private void buttonItemSJGL1_2_Click(object sender, EventArgs e) + //{ + // //日志记录 + // LogManager.saveLog(Utility.userName, this.buttonItemSJGL1_2.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(); + // } + // } + //} + #endregion + /// + /// 数据质量检查 + /// + /// + /// + private void buttonItemSJGL2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL2.Text); + FrmValiData frm = new FrmValiData(globeControl1); + frm.ShowDialog(); + } + /// + /// 数据预处理 + /// + /// + /// + private void buttonItemSJGL3_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL3.Text); + + FrmEditShapeFile frm = new FrmEditShapeFile(globeControl1); + frm.ShowDialog(this); + } + /// + /// 连接数据库 + /// + /// + /// + private void buttonItemSJGL4_1_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL4_1.Text); + + FrmDatabaseParaSetting frm = new FrmDatabaseParaSetting(globeControl1); + if (frm.ShowDialog() == DialogResult.OK) + { + ds = FrmDatabaseParaSetting.ds; + if (ds != null) + { + ds.IsCloseSaved = false; + } + } + } + /// + /// 管线入库 + /// + /// + /// + private void buttonItemSJGL4_2_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL4_2.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 buttonItemSJGL4_3_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL4_3.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 buttonItemSJGL5_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL5.Text); + + Cyberpipe.Forms.FrmProject frm = new Cyberpipe.Forms.FrmProject(); + frm.ShowDialog(); + } + /// + /// 元数据基本管理 + /// + /// + /// + private void buttonItemSJGL6_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL6_1.Text); + + FrmMetadata frmmd = new FrmMetadata(); + frmmd.ShowDialog(); + } + /// + /// 元数据查询管理 + /// + /// + /// + private void buttonItemSJGL6_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL6_2.Text); + + FrmMetadataStat frmmds = new FrmMetadataStat(); + //frmmds.Show(); + frmmds.ShowDialog(); + } + /// + /// 操作日志管理 + /// + /// + /// + private void buttonItemSJGL7_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL7.Text); + + FrmLogOper frmlo = new FrmLogOper(); + frmlo.ShowDialog(); + } + /// + /// 数据字典管理 + /// + /// + /// + private void buttonItemSJGL8_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL8.Text); + + FrmMDDictory frmmdd = new FrmMDDictory(); + frmmdd.ShowDialog(); + } + /// + /// 数据库备份 + /// + /// + /// + private void buttonItemSJGL9_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL9.Text); + + //新 + FrmBACKORACLE backOracle = new FrmBACKORACLE(); + backOracle.Show(); + } + /// + /// 创建管段 + /// + /// + /// + private void buttonItemBJ1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ1.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; + } + } + /// + /// 创建附属物 + /// + /// + /// + private void buttonItemBJ2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ2.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); + } + } + /// + /// 创建特征管点 + /// + /// + /// + private void buttonItemBJ3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ3.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); + } + } + /// + /// 绘制城市七线 + /// + /// + /// + private void buttonItemBJ4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ4.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; + } + } + } + /// + /// 选中对象 + /// + /// + /// + private void buttonItemBJ5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ5.Text); + + globeControl1.Globe.Action = EnumAction3D.SelectObject; + } + /// + /// 平移对象 + /// + /// + /// + private void buttonItemBJ6_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ6.Text); + + globeControl1.Globe.Action = EnumAction3D.MoveObject; + } + /// + /// 升降对象 + /// + /// + /// + private void buttonItemBJ7_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ7.Text); + + globeControl1.Globe.Action = EnumAction3D.ElevateObject; + } + /// + /// 旋转对象 + /// + /// + /// + private void buttonItemBJ8_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ8.Text); + + globeControl1.Globe.Action = EnumAction3D.RotateObject; + } + /// + /// 连接管段 + /// + /// + /// + private void buttonItemBJ9_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ9.Text); + + if (globeControl1.Globe.SelObjectCount < 2) + { + MessageBox.Show("对不起,请至少选中2个对象!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + return; + } + globeControl1.Globe.InsertJointPipeline(false); + } + /// + /// 后退 + /// + /// + /// + private void buttonItemBJ11_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemBJ11.Text); + globeControl1.Globe.UnDoEdit(); + } + /// + /// 前进 + /// + /// + /// + private void buttonItemBJ12_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemBJ12.Text); + + globeControl1.Globe.ReDoEdit(); + } + /// + /// 导出CAD + /// + /// + /// + private void buttonItemBJ10_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ10_1.Text); + + #region 导出成dxf格式 + List listVectorNames = new List(); + 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(); + #endregion + } + /// + /// 导出矢量 + /// + /// + /// + private void buttonItemBJ10_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ10_2.Text); + + List listVectorNames = new List(); + 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 buttonItemBJ13_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemBJ13.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(); + } + } + MessageBox.Show("删除成功!", "提示"); + } + else + { + MessageBox.Show("请选中要删除的模型!", "提示"); + } + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + } + + private void buttonItemHX1_1_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]; + string filePath = dlg.FileName; + string lastname = Path.GetFileName(filePath); + + 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(); + } + + } + } + } + + public struct LineStruct + { + public string layerName; + public string layerCode; + public string lineLength; + public string hxName; + } + + List lineStruct = new List(); + List featsList = new List(); + + /// + /// 红线审核 + /// + /// + /// + private void buttonItemHX2_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemHX2.Text); + redSH = true; + featsList.Clear(); + lineStruct.Clear(); + List listPipelineLayers = new List(); + + GSOLayer layer = null; + for (int i = 0; i < m_PipelineLayerNames.Count; i++) + { + layer = globeControl1.Globe.Layers.GetLayerByCaption(m_PipelineLayerNames[i]); + if (layer != null) + { + listPipelineLayers.Add(layer); + } + } + //yanxiaowei 重构 + GSOFeatures selectFeatures=new GSOFeatures(); + for (int i = 0; i < globeControl1.Globe.SelObjectCount; i++) + { + GSOFeature feature = null; + globeControl1.Globe.GetSelectObject(i, out feature, out layer); + selectFeatures.Add(feature); + } + DataTable table=new DataTable(); + + ClassGSOTool.CalculateRedLineResult(out table, redSH, selectFeatures, globeControl1, + listPipelineLayers,out lineStruct, out featsList); + + if (table.Rows.Count != 0) + AddDatagridView(table); + else + { + MessageBox.Show("没有侵入地块红线的管线数据!", "提示"); + dataGridViewX1.DataSource = null; + panelOfTable.Visible = false; + return; + } + } + + private void AddDatagridView(DataTable table) + { + dataGridViewX1.DataSource = table; + panelOfTable.Visible = true; + panelOfTable.Height = 200; + toolStripNumbers.Text = "红线审核 |共有:" + table.Rows.Count + "条"; + toolStripDropDownButton3.Visible = true; + } + /// + /// 主窗体 下方的工具条中的 导出.xls文件 按钮事件处理 + /// + /// + /// + private void toolStripDropDownButton3_Click(object sender, EventArgs e) + { + if (dataGridViewX1.Rows.Count == 0) + { + MessageBox.Show("表格内容为空!", "提示"); + return; + } + + string strSaveFile = string.Empty; + SaveFileDialog savefiledialog = new SaveFileDialog(); + savefiledialog.Filter = "Excel文件|*.xls,*.xlsx"; + savefiledialog.AddExtension = true; + savefiledialog.FileName = "红线审核"; + if (savefiledialog.ShowDialog() == DialogResult.OK) + strSaveFile = savefiledialog.FileName; + else return; + + ExpEXCEL.ExpToExcel(dataGridViewX1, strSaveFile, "红线审核", lineStruct, featsList); + MessageBox.Show("导出成功!"); + } + /// + /// 去除集合中重复的管线 + /// + /// + /// + /// + private GSOFeatures getFeaturesByFilter(GSOFeatures features, string fieldName) + { + if (features == null) + { + return null; + } + GSOFeatures featuresGet = new GSOFeatures(); + for (int i = 0; i < features.Length; i++) + { + GSOFeature featureFromFS = features[i]; + string fieldValueFromFS = featureFromFS.GetValue(fieldName).ToString().Trim(); + bool isHas = false; + for (int j = featuresGet.Length - 1; j >= 0; j--) + { + GSOFeature featureFromFSGet = featuresGet[j]; + string fieldValueFromFSGet = featureFromFSGet.GetValue(fieldName).ToString().Trim(); + if (fieldValueFromFS.Equals(fieldValueFromFSGet)) + { + isHas = true; + break; + } + } + if (isHas == false) + { + featuresGet.Add(featureFromFS.Clone()); + } + } + return featuresGet; + } + + private void sliderItem2_ValueChanged(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.sliderItem2.Text); + + globeControl1.Globe.GroundOpaque = 100 - sliderItem2.Value; + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(roadLayerName);//("180fd"); + if (layer != null) + { + layer.Opaque = 100 - sliderItem2.Value; + } + layer = globeControl2.Globe.Layers.GetLayerByCaption("180fd");//("180fd"); + if (layer != null) + { + layer.Opaque = 100 - sliderItem2.Value; + } + globeControl2.Globe.GroundOpaque = 100 - sliderItem2.Value; + + optiValue = sliderItem2.Value; + } + /// + /// 数据管理导入文件 + /// + /// + /// + private void buttonItemSJGL1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL1.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.Multiselect = true; + if (dlg.ShowDialog() == DialogResult.OK) + { + //自定义lprj文件名,从程序中复制一lprj文件。 + string filePath = dlg.FileName; + string lastname = Path.GetFileName(filePath); + + 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, 100); + + globeControl1.Refresh(); + } + } + } + + private void buttonItemHX1_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemHX1.Text); + + GSODataSource dataSpace = globeControl1.Globe.DataManager.OpenOracleDataSource(Utility.DBServer.Trim() + "/" + Utility.dbdatabase.Trim(), "", "", Utility.userID, Utility.DBPassword); + string filepath = ""; + //日志记录 + OpenFileDialog dlg = new OpenFileDialog(); + dlg.Filter = "矢量数据(*.shp)|*.shp|矢量数据(*.lgd)|*.lgd|CAD数据(*.dxf)|*.dxf|全部支持格式(*.lgd,*.shp,*.dxf)|*.lgd;*.shp;*.dxf;"; + dlg.Multiselect = true; + + #region 临时图层显示 + if (dlg.ShowDialog() == DialogResult.OK) + { + string filePath = dlg.FileName; + string lastname = Path.GetFileName(filePath); + + #region + for (int i = 0; i < dlg.FileNames.Length; i++) + { + string strDataPath = dlg.FileNames[i]; + filepath = strDataPath; + + GSOLayer layer = globeControl1.Globe.Layers.Add(strDataPath); + GSOFeatures RedFeatures = layer.GetAllFeatures(); + + 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(); + RedFeatures = features; + 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; + } + + /////////////////////////////////////////////////////////////////////////////////////////// + globeControl1.Globe.Layers.MoveTo(0, globeControl1.Globe.Layers.Count - 1); + globeControl1.Refresh(); + } + + IModelBuilder modelBuilder = new RedLineBuilder(); + + modelBuilder.batchInsert(dataSpace, redDt, RedFeatures); + + } + #endregion + + } + #endregion + } + /// + /// 定位 + /// + /// + /// + private void buttonItemLocation_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemLocation.Text); + + FrmFlyToPosition fly = new FrmFlyToPosition(globeControl1,globeControl2); + fly.Show(this); + } + /// + /// 2015-10-17演示代码 红线审核 + /// + /// + /// + private void ribbonTabItem6_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.FlyToPosition(new GSOPoint3d(120.610963, 31.188121, 50), EnumAltitudeMode.Absolute, -4, 50, 800); + globeControl1.Globe.FlyToPointSpeed = 10000000; + globeControl1.Globe.Action = EnumAction3D.SelectObject; + globeControl1.Refresh(); + + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + + //zhanshi = false; + redSH = true; + splitContainer1.Panel2Collapsed = true; + legendSG.Visible = false; + legendSC.Visible = false; + ClearGZData(); + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = true; + } + + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 基础工具 + /// + /// + /// + private void ribbonTabItem1_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + //zhanshi = false; + redSH = false; + splitContainer1.Panel2Collapsed = true; + panelOfTable.Visible = false; + legendSC.Visible = false; + legendSG.Visible = false; + ClearGZData(); + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + + + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 一键审核 + /// + /// + /// + private void ribbonTabItem11_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + //zhanshi = false; + redSH = false; + splitContainer1.Panel2Collapsed = true; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + panelOfTable.Visible = false; + legendSC.Visible = false; + legendSG.Visible = false; + ClearGZData(); + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + + + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 右屏添加冰箱数据 + /// + void AddDataToGlobeControl2() + { + + bool modelDataBool = false; + for (int i = globeControl2.Globe.Layers.Count - 1; i >= 0; i--) + { + GSOLayer layer = globeControl2.Globe.Layers[i]; + if (layer.Name.Contains("fttp:")) + { + modelDataBool = true; + break; + } + } + + if (modelDataBool == false) + { + GSOLayer ly = globeControl1.Globe.Layers.GetLayerByCaption("天地图地图"); + globeControl2.Globe.Layers.Add(ly); + } + else + { + return; + } + } + /// + /// 双屏对比 + /// + /// + /// + private void ribbonTabItem9_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent += new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent += new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + panelOfTable.Visible = false; + + splitContainer1.Panel2Collapsed = false; + //zhanshi = true; + redSH = false; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + sliderItem2.Value = 100 - globeControl1.Globe.GroundOpaque; + globeControl2.Globe.GroundOpaque = globeControl1.Globe.GroundOpaque; + legendSC.Visible = true; + legendSG.Visible = true; + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + AddDataToGlobeControl2(); + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 文档管理 + /// + /// + /// + private void ribbonTabItem4_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + panelOfTable.Visible = false; + //zhanshi = false; + redSH = false; + splitContainer1.Panel2Collapsed = true; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + legendSC.Visible = false; + legendSG.Visible = false; + ClearGZData(); + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 基础管理 + /// + /// + /// + private void ribbonTabItem14_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + panelOfTable.Visible = false; + //zhanshi = false; + redSH = false; + splitContainer1.Panel2Collapsed = true; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + legendSC.Visible = false; + legendSG.Visible = false; + ClearGZData(); + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 权限管理 + /// + /// + /// + private void ribbonTabItem2_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + panelOfTable.Visible = false; + //zhanshi = false; + redSH = false; + splitContainer1.Panel2Collapsed = true; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + legendSC.Visible = false; + legendSG.Visible = false; + ClearGZData(); + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + GSOFeature dpFeatuer = null; + /// + /// 双屏分析,点击管段分析 + /// + /// + /// + private void buttonItem8_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItem8.Text); + + //FrmCompareFeature frmCompareFeature = new FrmCompareFeature(globeControl1, globeControl2, layerTemp, layerTemp2,m_PipelineLayerNames,sgPipeLayersNames); + int width = this.Width; + FrmCompareFeature.ShowForm(globeControl1, globeControl2, layerTemp, layerTemp2, m_PipelineLayerNames, sgPipeLayersNames,width); + //frmCompareFeature.Location = new Point((this.Width - frmCompareFeature.Width)/2,50); + //frmCompareFeature.Show(this); + + } + /// + /// 红线审核导出图片 + /// + /// + /// + private void buttonItemDCTP_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemDCTP.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))); + */ + int mapWidth = 0; + int mapHeight = 0; + Point pt = getUpperLeftPoint(pt1, pt2, out mapWidth, out mapHeight); + int rightBottomX = pt.X + mapWidth; + int rightBottomY = pt.Y + mapHeight; + Image myImg = new Bitmap(mapWidth, mapHeight); + Graphics g = Graphics.FromImage(myImg); + g.CopyFromScreen(pt, new Point(0, 0), new Size(rightBottomX, rightBottomY)); + + 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; + } + } + } + /// + /// 标识器全区域统计 + /// + /// + /// + private void 标识器分类统计ToolStripMenuItem_Click(object sender, EventArgs e) + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + FrmBSQStatis bsqStatis = new FrmBSQStatis(globeControl1,null); + //FrmBSQStatis bsqStatis = new FrmBSQStatis(); + bsqStatis.Show(this); + } + /// + /// 标识器绘制区域统计 + /// + /// + /// + private void 标识器分类统计ToolStripMenuItem1_Click(object sender, EventArgs e) + { + trackflag = "BSQDuoBianXiangStatis"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + } + + #region 保存和加载审核库加载的图层 + /* + private void saveLayerList(TreeNodeCollection treeNodeList) + { + string configPath = Application.StartupPath + "\\configLayerList.xml"; + try + { + XmlDocument doc = new XmlDocument(); + doc.Load(configPath); + XmlNode dbParams = doc.SelectSingleNode("Params/dbparams"); + XmlNode dbLayers = doc.SelectSingleNode("Params/dblayers"); + XmlNode layers = doc.SelectSingleNode("Params/layers"); + dbParams.RemoveAll(); + dbLayers.RemoveAll(); + layers.RemoveAll(); + + List listDS = new List(); + String shDatasourceName = Utility.sgdbip + "/" + Utility.sgdbname + "_" + Utility.sgdbuser; + bool flag = false; + + for (int i = 0; i < globeControl1.Globe.DataManager.DataSourceCount; i++) + { + GSODataSource ds = globeControl1.Globe.DataManager.GetDataSourceAt(i); + if (ds != null && ds.Type == EnumDataSourceType.SqlServer || ds.Type == EnumDataSourceType.Oracle) + { + if (ds.Name == shDatasourceName) + { + //防止因为多次连接同一个数据库 + if (flag == true) + { + break; + } + flag = true; + listDS.Add(ds); + GSODataSourceCnn conn = ds.GetConnectionInfo(); + + XmlElement dbparam = doc.CreateElement("shdbparam"); + XmlElement ip = doc.CreateElement("ship"); + ip.InnerText = conn.Server; + + XmlElement dbname = doc.CreateElement("shdbname"); + dbname.InnerText = conn.Database; + + XmlElement username = doc.CreateElement("shusername"); + username.InnerText = conn.User; + + XmlElement password = doc.CreateElement("shpassword"); + password.InnerText = conn.Password; + + XmlElement type = doc.CreateElement("shtype"); + if (ds.Type == EnumDataSourceType.SqlServer) + { + type.InnerText = "sqlserver"; + } + else + { + type.InnerText = "oracle"; + } + + dbparam.AppendChild(ip); + dbparam.AppendChild(dbname); + dbparam.AppendChild(username); + dbparam.AppendChild(password); + dbparam.AppendChild(type); + dbParams.AppendChild(dbparam); + } + + } + } + + for (int i = 0; i < treeNodeList.Count; i++) + { + GSOLayer layer = treeNodeList[i].Tag as GSOLayer; + if (Path.GetExtension(layer.Name) == "") + { + XmlElement dbLayer = doc.CreateElement("dblayer"); + XmlAttribute attri = doc.CreateAttribute("dbindex"); + for (int j = 0; j < listDS.Count; j++) + { + if (layer.Dataset.DataSource.Name == listDS[j].Name) + { + attri.Value = j.ToString(); + break; + } + } + dbLayer.Attributes.Append(attri); + dbLayer.InnerText = layer.Name; + + dbLayers.AppendChild(dbLayer); + } + else + { + XmlElement dbLayer = doc.CreateElement("layer"); + dbLayer.InnerText = layer.Name; + layers.AppendChild(dbLayer); + } + } + + doc.Save(configPath); + } + catch (Exception e) + { + + } + } + + private void openLayerList() + { + layerManagerNode.Nodes.Clear(); + + string configPath = Application.StartupPath + "\\configLayerList.xml"; + try + { + XmlDocument doc = new XmlDocument(); + doc.Load(configPath); + XmlNode dbParams = doc.SelectSingleNode("Params/dbparams"); + XmlNode dbLayers = doc.SelectSingleNode("Params/dblayers"); + XmlNode layers = doc.SelectSingleNode("Params/layers"); + + List listDS = new List(); + for (int i = 0; i < dbParams.ChildNodes.Count; i++) + { + string ip = ""; + string dbname = ""; + string username = ""; + string password = ""; + string type = ""; + XmlNode node = dbParams.ChildNodes.Item(i); + for (int j = 0; j < node.ChildNodes.Count; j++) + { + XmlNode nodeChild = node.ChildNodes.Item(j); + + if (nodeChild != null && nodeChild.Name == "ship") + { + ip = nodeChild.InnerText; + } + else if (nodeChild != null && nodeChild.Name == "shdbname") + { + dbname = nodeChild.InnerText; + } + else if (nodeChild != null && nodeChild.Name == "shusername") + { + username = nodeChild.InnerText; + } + else if (nodeChild != null && nodeChild.Name == "shpassword") + { + password = nodeChild.InnerText; + } + else if (nodeChild != null && nodeChild.Name == "shtype") + { + type = nodeChild.InnerText; + } + } + + if (type == "sqlserver") + { + GSODataSource ds = globeControl1.Globe.DataManager.OpenSqlServerDataSource(ip, "", dbname, username, password); + listDS.Add(ds); + } + else if (type == "oracle") + { + GSODataSource ds = globeControl1.Globe.DataManager.OpenOracleDataSource(ip + "/" + dbname, "", "", username, password); + listDS.Add(ds); + } + } + + for (int i = 0; i < dbLayers.ChildNodes.Count; i++) + { + XmlNode node = dbLayers.ChildNodes.Item(i); + if (node != null) + { + string layerName = node.InnerText; + XmlAttribute attri = node.Attributes["dbindex"]; + if (attri != null) + { + int dbIndex = -1; + if (int.TryParse(attri.Value, out dbIndex)) + { + GSODataset dataset = listDS[dbIndex].GetDatasetByName(layerName); + globeControl1.Globe.Layers.Add(dataset); + //更新树节点 + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + TreeNode layerNode = new TreeNode(); + layerNode.Tag = layer; + layerNode.Text = layer.Dataset.Caption; + layerNode.ImageIndex = 0; + layerNode.SelectedImageIndex = 0; + layerNode.Checked = layer.Visible; + layerManagerNode.Nodes.Insert(0, layerNode); + // layerManagerNode.Expand(); + + + } + } + } + } + for (int i = 0; i < layers.ChildNodes.Count; i++) + { + XmlNode node = layers.ChildNodes.Item(i); + if (node != null) + { + string layerName = node.InnerText; + globeControl1.Globe.Layers.Add(layerName); + + //更新树节点 + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + TreeNode layerNode = new TreeNode(); + layerNode.Tag = layer; + layerNode.Text = layer.Dataset.Caption; + layerNode.ImageIndex = 0; + layerNode.SelectedImageIndex = 0; + layerNode.Checked = layer.Visible; + layerManagerNode.Nodes.Insert(0, layerNode); + } + } + layerManagerNode.Expand(); + } + catch (Exception e) + { + + } + } + * */ + #endregion + + private void btn_check_history_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_check_history.Text); + + if (FrmCheckHistory.isOpen == true) + { + return; + } + FrmCheckHistory frm = new FrmCheckHistory(globeControl1, globeControl2); + frm.addNode += new AddNodeToLayerManagerNode(addNodeToLayerManagerNode); + frm.Show(); + + } + + private void buttonItem查看数据_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItem查看数据.Text); + + FrmThreeOracle tr = new FrmThreeOracle(globeControl1); + + if (tr.ShowDialog() == DialogResult.OK) + { + addNodeToLayerManagerNode(tr.rukuLayer); + globeControl1.Refresh(); + } + } + /// + /// 规划数据入库 + /// + /// + /// + private void buttonItemGHRK_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemGHRK.Text); + + FrmGHRK ghrk = new FrmGHRK(globeControl1, layerManagerNode); + ghrk.Show(this); + } + + private void btn_user_info_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_user_info.Text); + + if (!FrmSysUserInfoManger.IS_OPEN) + { + FrmSysUserInfoManger frm = new FrmSysUserInfoManger(); + frm.ShowDialog(); + } + } + + private void btn_role_info_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_role_info.Text); + + if (FrmRoleInfoManager.IS_OPEN) + { + return; + } + FrmRoleInfoManager frm = new FrmRoleInfoManager(); + frm.ShowDialog(); + } + + private void btn_resc_info_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_resc_info.Text); + + if (!SysRescInfoManager.IS_OPEN) + { + SysRescInfoManager frm = new SysRescInfoManager(); + frm.ShowDialog(); + } + } + + private void btn_role_resc_Click(object sender, EventArgs e) + { + + LogManager.saveLog(Utility.userName, this.btn_role_resc.Text); + + if (!FrmRoleRescManager.IS_OPEN) + { + FrmRoleRescManager frm = new FrmRoleRescManager(); + frm.ShowDialog(); + } + } + + private void btn_user_role_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_user_role.Text); + + if (FrmUserRole.IS_OPEN) + { + return; + } + FrmUserRole frm = new FrmUserRole(); + frm.ShowDialog(); + } + + private void btn_document_info_Click(object sender, EventArgs e) + { + + LogManager.saveLog(Utility.userName, this.btn_document_info.Text); + + //if (FormDocumentManager.IS_OPEN) + //{ + // return; + //} + //FormDocumentManager frm = new FormDocumentManager(); + //frm.ShowDialog(); + + //if (FormDocumentManager.IS_OPEN) + //{ + // return; + //} + //new FormDocumentManager().ShowDialog(); + if (FormDocumentManager.IS_OPEN) + { + return; + } + this.Cursor = Cursors.WaitCursor; + FormDocumentManager frm = new FormDocumentManager(); + frm.changeCursor += new ChangeCursor(changeCursorToDefault); + frm.ShowDialog(); + + } + + private void changeCursorToDefault() + { + this.Cursor = Cursors.Default; + } + + /// + /// 判断CAD文件是否有投影信息 + /// + /// + /// + Boolean CheckDatasetGeoReference(GSODataset dataset) + { + Boolean bSuccess = false; + if (dataset.GeoReferenceType == EnumGeoReferenceType.Flat) + { + if (MessageBox.Show("数据没有空间参考信息,请设置空间参考信息!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation) == DialogResult.OK) + { + String strPath = Path.GetDirectoryName(Application.ExecutablePath) + "\\Coordinate Systems"; + OpenFileDialog dlg = new OpenFileDialog(); + + dlg.InitialDirectory = strPath; + dlg.RestoreDirectory = true; + + dlg.Filter = "投影文件|*.prj||"; + if (dlg.ShowDialog() == DialogResult.OK) + { + bSuccess = dataset.LoadProjectionFromESRIFile(dlg.FileName); + } + } + } + else + { + return true; + } + return bSuccess; + } + + private void buttonItemexp_CAD_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemexp_CAD.Text); + + OpenFileDialog dlg = new OpenFileDialog(); + dlg.Filter = "支持格式(*.dwg)|*.dwg"; + dlg.Multiselect = true; + if (dlg.ShowDialog() == DialogResult.OK) + { + for (int i = 0; i < dlg.FileNames.Length; i++) + { + //this.Cursor = Cursors.WaitCursor; + string strDataPath = dlg.FileNames[i]; + + #region + //string strDataPathPrj = strDataPath.ToLower().Replace(".dwg", ".lprj"); + + //if (File.Exists(strDataPathPrj) == false) + //{ + // if (MessageBox.Show("数据没有空间参考信息,请设置空间参考信息!", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation) == DialogResult.OK) + // { + // String strPath = Application.StartupPath + "\\Coordinate Systems"; + // OpenFileDialog dlgPrj = new OpenFileDialog(); + // dlgPrj.InitialDirectory = strPath; + // dlgPrj.RestoreDirectory = true; + // dlgPrj.Multiselect = false; + // dlg.Filter = "投影文件|*.prj"; + // if (dlg.ShowDialog() == DialogResult.OK) + // { + // this.Cursor = Cursors.WaitCursor; + // string proj4 = GSODataEngineUtility.ConvertEsriPrjFileToProj4(dlg.FileName); + // using (StreamWriter stream = new StreamWriter(strDataPathPrj, false)) + // { + // stream.WriteLine("0prj4" + proj4 + ""); + // } + // AddLayerData(strDataPath); + // //globeControl1.Globe.Layers.Add(strDataPath); + + // this.Cursor = Cursors.Default; + // } + // else + // { + // AddLayerData(strDataPath); + // //globeControl1.Globe.Layers.Add(strDataPath); + // } + // } + // else + // { + // AddLayerData(strDataPath); + // //globeControl1.Globe.Layers.Add(strDataPath); + // } + + //} + //else + //{ + // //globeControl1.Globe.Layers.Add(strDataPath); + // AddLayerData(strDataPath); + //} + #endregion + AddLayerData(strDataPath); + //this.Cursor = Cursors.Default; + } + } + + 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, 100); + + globeControl1.Refresh(); + } + } + + private void btn_password_edit_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_password_edit.Text); + + if (FrmChangePassword.IS_OPEN) + { + return; + } + FrmChangePassword frm = new FrmChangePassword(); + frm.ShowDialog(); + } + /// + /// 多孔管线入库 + /// + /// + /// + private void buttonItem9_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL4_2.Text); + + if (ds == null) + { + MessageBox.Show("请先连接数据库", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + ConnectDB(null, null); + } + if (ds == null) + return; + + FrmMultiPipelineModelDB frm = new FrmMultiPipelineModelDB(globeControl1, ds); + if (frm.ShowDialog() == DialogResult.OK) + { + addNodeToLayerManagerNode(frm.rukuLayer); + } + //frm.Show(); + } + private void 导出CADToolStripMenuItem1_Click(object sender, EventArgs e) + { + TreeNode node = layerNodeContexMenu.Tag as TreeNode; + if (node == null) + { + MessageBox.Show("请在左侧节点集中选择要导出的图层", "提示"); + return; + } + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(node.Text.Trim()); + if (layer == null || layer.GetAllFeatures().Length <= 0) + { + MessageBox.Show("要导出的图层为空", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + return; + } + string strProjectName = Utility.projectStr; + if (strProjectName != "") + { + SaveFileDialog dlg = new SaveFileDialog(); + dlg.Filter = "*.dwg|*.dwg|*.dxf|*.dxf"; + dlg.FileName = layer.Caption; + if (dlg.ShowDialog(this) == DialogResult.OK) + { + globeControl1.Globe.MemoryLayer.SaveAs(dlg.FileName); + GSOLayer newlayer = globeControl1.Globe.Layers.Add(dlg.FileName); + newlayer.RemoveAllFeature(); + int featureCount = layer.GetAllFeatures().Length; + for (int i = 0; i < featureCount; i++) + { + GSOFeature feature = layer.GetAt(i); + if (feature != null && feature.Geometry != null) + { + if (feature.Geometry.Type == EnumGeometryType.GeoPolyline3D) + { + feature.Geometry.Style = new GSOSimpleLineStyle3D(); + } + else if (feature.Geometry.Type == EnumGeometryType.GeoPolygon3D) + { + feature.Geometry.Style = new GSOSimplePolygonStyle3D(); + } + newlayer.AddFeature(feature); + } + } + newlayer.Save(); + newlayer.Dataset.DataSource.RemoveDataset(newlayer.Dataset); + globeControl1.Globe.Layers.Remove(newlayer); + MessageBox.Show("导出CAD完成!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + } + } + } + + private void buttonItemGBJC_Click(object sender, EventArgs e) + { + FrmGBJC gb = new FrmGBJC(globeControl1, globeControl2, layerTemp, layerTemp2); + gb.Show(this); + } + + #region 右屏管纵数据控制 + private void 五十米主干道ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = true; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + + private void 三十六米次干道ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = true; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + + private void 四十二米次干道ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = true; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + + private void 二十四米一块板ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = true; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + + private void 二十四米三块板ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = true; + } + + private void 二十四米停车带ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = true; + lendendGZ24_3.Visible = false; + } + + private void 二十六米大堤路ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = true; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + + private void 清除管纵数据ToolStripMenuItem_Click(object sender, EventArgs e) + { + ClearGZData(); + } + + private void ClearGZData() + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + #endregion + + private void buttonItemPasswordReset_Click(object sender, EventArgs e) + { + Frm_password_reset reset = new Frm_password_reset(); + reset.Show(); + } + + private void pictureBox1_Paint(object sender, PaintEventArgs e) + { + int Width = this.Width; + string welcomeUser = "欢迎您:" + Utility.userName; + Graphics g = e.Graphics; + g.DrawString(welcomeUser, new Font("宋体", 12), new SolidBrush(Color.Black), Width - 180, 50); + } + + } +} \ No newline at end of file diff --git a/MainFrm.cs.BASE.9016.cs b/MainFrm.cs.BASE.9016.cs new file mode 100644 index 0000000..e530fbd --- /dev/null +++ b/MainFrm.cs.BASE.9016.cs @@ -0,0 +1,13442 @@ +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; + + GSOBalloon featureTooltip2; + GSOBalloonEx balloonEx2; + + GSOLayer layerTemp; + GSOLayer layerTemp2; + FrmShResult frmShResult = null; + FrmRedlineResult frmredResult = null; + FrmMnModify frmModify = null; + public bool frmRedlineResult = false; + public bool boolfrmShResult = false; + public bool boolfrmModify = false; + + List m_PipelineLayerNames = new List();//线图层名称 + List workwellLayerNames = new List();//工井图层名称 + List valueLayerNames = new List();//阀门图层名称 + List instrumenLayerNames = new List();//附属物图层名称 + List pipefittingLayerNames = new List();//管件图层名称 + List sgPipeLayersNames = new List();//施工管线图层名称 + 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 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; + public string redLayer = null; + //GSOLayer redLayer1 = null; + bool redSH = false; + string redDt = "红线"; + //双屏对比 + //bool zhanshi=false; + Thread t = null; + private GSOHudButton legendSC;//定义图例 + private GSOHudButton legendSG;//定义图例 + //管纵图 + private GSOHudButton lendendGZ50; + private GSOHudButton lendendGZ36; + private GSOHudButton lendendGZ42; + private GSOHudButton lendendGZ24_1; + private GSOHudButton lendendGZ24_2; + private GSOHudButton lendendGZ24_3; + private GSOHudButton lendendGZ26; + + GSOGeoPoint3D bsqPT; + + FrmYJSHTC frmSh = null;//一键审核窗口全局变量wxl + FrmWait frmWait = null;//一键审核等待窗口 + //FrmWait frmWait2 = null;//文档操作等待窗口 + + float mouseDownX1,mouseDownY1; + float mouseDownX2,mouseDownY2; + /// + /// + /// + 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; + + featureTooltip2 = new GSOBalloon(globeControl2.Handle); + balloonEx2 = new GSOBalloonEx(globeControl2.Handle); + Utility.SetBallons(featureTooltip, balloonEx); + + panelOfTable.Height = 200; + + RigthMenuSet(); + + MenuSet(); + + } + /// + /// 右屏中添加管纵图片 + /// + private void AddGZ() + { + + lendendGZ50 = new GSOHudButton(); + lendendGZ50.SetImage(Application.StartupPath + "/Resource/管纵/50.png"); + lendendGZ50.SetOffset(0, 0); + lendendGZ50.MinOpaque = 1; + lendendGZ50.MaxOpaque = 1; + lendendGZ50.FadeOut = false; + lendendGZ50.Name = "lendendGZ50"; + lendendGZ50.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ50); + lendendGZ50.Visible = false; + + lendendGZ36 = new GSOHudButton(); + lendendGZ36.SetImage(Application.StartupPath + "/Resource/管纵/36.png"); + lendendGZ36.SetOffset(0, 0); + lendendGZ36.MinOpaque = 1; + lendendGZ36.MaxOpaque = 1; + lendendGZ36.FadeOut = false; + lendendGZ36.Name = "lendendGZ36"; + lendendGZ36.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ36); + lendendGZ36.Visible = false; + + lendendGZ42 = new GSOHudButton(); + lendendGZ42.SetImage(Application.StartupPath + "/Resource/管纵/42.png"); + lendendGZ42.SetOffset(0, 0); + lendendGZ42.MinOpaque = 1; + lendendGZ42.MaxOpaque = 1; + lendendGZ42.FadeOut = false; + lendendGZ42.Name = "lendendGZ42"; + lendendGZ42.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ42); + lendendGZ42.Visible = false; + + lendendGZ24_1 = new GSOHudButton(); + lendendGZ24_1.SetImage(Application.StartupPath + "/Resource/管纵/24_1.png"); + lendendGZ24_1.SetOffset(0, 0); + lendendGZ24_1.MinOpaque = 1; + lendendGZ24_1.MaxOpaque = 1; + lendendGZ24_1.FadeOut = false; + lendendGZ24_1.Name = "lendendGZ24_1"; + lendendGZ24_1.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ24_1); + lendendGZ24_1.Visible = false; + + lendendGZ24_2 = new GSOHudButton(); + lendendGZ24_2.SetImage(Application.StartupPath + "/Resource/管纵/24_2.png"); + lendendGZ24_2.SetOffset(0, 0); + lendendGZ24_2.MinOpaque = 1; + lendendGZ24_2.MaxOpaque = 1; + lendendGZ24_2.FadeOut = false; + lendendGZ24_2.Name = "lendendGZ24_2"; + lendendGZ24_2.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ24_2); + lendendGZ24_2.Visible = false; + + lendendGZ24_3 = new GSOHudButton(); + lendendGZ24_3.SetImage(Application.StartupPath + "/Resource/管纵/24_3.png"); + lendendGZ24_3.SetOffset(0, 0); + lendendGZ24_3.MinOpaque = 1; + lendendGZ24_3.MaxOpaque = 1; + lendendGZ24_3.FadeOut = false; + lendendGZ24_3.Name = "lendendGZ24_3"; + lendendGZ24_3.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ24_3); + lendendGZ24_3.Visible = false; + + lendendGZ26 = new GSOHudButton(); + lendendGZ26.SetImage(Application.StartupPath + "/Resource/管纵/26.png"); + lendendGZ26.SetOffset(0, 0); + lendendGZ26.MinOpaque = 1; + lendendGZ26.MaxOpaque = 1; + lendendGZ26.FadeOut = false; + lendendGZ26.Name = "lendendGZ26"; + lendendGZ26.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ26); + lendendGZ26.Visible = false; + + } + + public void RigthMenuSet() + { + if (Utility.userRole.IndexOf("清除分析") < 0) + { + toolRightMenu.Items.Remove(清除分析ToolStripMenuItem); + } + + #region 区域分析 + if (Utility.userRole.IndexOf("区域分析") < 0) + { + toolRightMenu.Items.Remove(区域分析ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("缓冲区分析") < 0) + { + 区域分析ToolStripMenuItem.DropDownItems.Remove(缓冲区分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("附属物分析") < 0) + { + 区域分析ToolStripMenuItem.DropDownItems.Remove(附属物分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("无源淹没分析") < 0) + { + 区域分析ToolStripMenuItem.DropDownItems.Remove(无源淹没分析ToolStripMenuItem); + } + } + #endregion + + #region 视域分析 + if (Utility.userRole.IndexOf("视域分析") < 0) + { + toolRightMenu.Items.Remove(视域分析ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("通视分析") < 0) + { + 视域分析ToolStripMenuItem.DropDownItems.Remove(通视分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("可视域分析") < 0) + { + 视域分析ToolStripMenuItem.DropDownItems.Remove(可视域分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("可视包络分析") < 0) + { + 视域分析ToolStripMenuItem.DropDownItems.Remove(可视包络分析ToolStripMenuItem); + } + } + #endregion + + #region 开发分析 + if (Utility.userRole.IndexOf("开挖分析") < 0) + { + toolRightMenu.Items.Remove(开挖分析ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("多边形开挖") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(多边形开挖ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("挖方量分析") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(挖方量分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("沿线开挖") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(沿线开挖ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("创建隧道") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(创建隧道ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("隐藏隧道") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(隐藏隧道ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("删除隧道") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(删除隧道ToolStripMenuItem); + } + } + #endregion + + #region 拓扑分析 + if (Utility.userRole.IndexOf("拓扑分析") < 0) + { + toolRightMenu.Items.Remove(拓扑分析ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("创建拓扑") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(创建拓扑ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("上游分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(上游分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("下游分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(下游分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("流向分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(流向分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("关阀分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(关阀分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("连通分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(连通分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("爆管分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(爆管分析ToolStripMenuItem); + } + } + #endregion + + #region 断面分析 + if (Utility.userRole.IndexOf("断面分析") < 0) + { + toolRightMenu.Items.Remove(断面分析ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("横断面分析") < 0) + { + 断面分析ToolStripMenuItem.DropDownItems.Remove(横断面分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("纵断面分析") < 0) + { + 断面分析ToolStripMenuItem.DropDownItems.Remove(纵断面分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("道路断面分析") < 0) + { + 断面分析ToolStripMenuItem.DropDownItems.Remove(道路断面分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("基线剖面分析") < 0) + { + 断面分析ToolStripMenuItem.DropDownItems.Remove(基线剖面分析ToolStripMenuItem); + } + } + #endregion + + #region 绘制区域统计 + if (Utility.userRole.IndexOf("绘制区域统计") < 0) + { + toolRightMenu.Items.Remove(绘制区域统计ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("绘制区域管线长度统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管线长度统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域阀门数量统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(阀门数量统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域井盖数量统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(井盖数量统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域管径分段统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管径分段统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域埋深分段统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(埋深分段统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域管径分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管径分类统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域材质分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(材质分类统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域附属物分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(附属物分类统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域标识器分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(标识器分类统计ToolStripMenuItem1); + } + + } + #endregion + + #region 全区域统计 + if (Utility.userRole.IndexOf("全区域统计") < 0) + { + toolRightMenu.Items.Remove(全区域统计ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("全区域管线长度统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管线长度统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域阀门数量统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(阀门数量统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域井盖数量统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(井盖数量统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域管径分段统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管径分段统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域埋深分段统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(埋深分段统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域管径分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管径分类统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域材质分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(材质分类统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域附属物分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(附属物分类统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域标识器分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(标识器分类统计ToolStripMenuItem); + } + + } + #endregion + + #region 查询 + if (Utility.userRole.IndexOf("查询") < 0) + { + toolRightMenu.Items.Remove(查询ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("空间查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(空间查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("编号查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(编号查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("坐标查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(坐标查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("管径查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(管径查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("材质查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(材质查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("基本查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(基本查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("复合查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(复合查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("关联查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(关联查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("关键字查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(关键字查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("附属物查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(附属物查询ToolStripMenuItem); + } + } + #endregion + + #region 标注 + if (Utility.userRole.IndexOf("标注") < 0) + { + toolRightMenu.Items.Remove(标注ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("标高标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(标高标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("管径标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(管径标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("埋深标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(埋深标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("坐标标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(坐标标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("距离标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(距离标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("自定义标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(自定义标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("扯旗标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(扯旗标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("坡度标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(坡度标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("属性标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(属性标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("标注管理") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(标注管理ToolStripMenuItem); + } + } + #endregion + + #region 飞行 + if (Utility.userRole.IndexOf("飞行") < 0) + { + toolRightMenu.Items.Remove(飞行ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("自定义飞行") < 0) + { + 飞行ToolStripMenuItem.DropDownItems.Remove(自定义飞行ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("飞行到目标点") < 0) + { + 飞行ToolStripMenuItem.DropDownItems.Remove(飞行到目标点ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("绕中心点飞行") < 0) + { + 飞行ToolStripMenuItem.DropDownItems.Remove(绕中心点飞行ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("绕眼睛飞行") < 0) + { + 飞行ToolStripMenuItem.DropDownItems.Remove(绕眼睛飞行ToolStripMenuItem); + } + } + #endregion + + #region 编辑 + if (Utility.userRole.IndexOf("编辑") < 0) + { + toolRightMenu.Items.Remove(编辑ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("平移对象") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(平移对象ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("升降对象") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(升降对象ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("旋转对象") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(旋转对象ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("连接管段") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(连接管段ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("导出文件") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(导出文件ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("前进") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(前进ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("后退") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(删除模型ToolStripMenuItem); + } + } + #endregion + + #region 量算 + if (Utility.userRole.IndexOf("量算") < 0) + { + toolRightMenu.Items.Remove(量算ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("水平距离") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(水平距离ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("垂直距离") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(垂直距离ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("空间距离") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(空间距离ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("地表距离") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(地表距离ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("高度量算") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(高度量算ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("水平面积") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(水平面积ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("地表面积") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(地表面积ToolStripMenuItem1); + } + } + #endregion + } + + public void MenuSet() + { + + #region 权限管理 + if (Utility.userRole.IndexOf("权限管理") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem2); + } + else + { + + if (Utility.userRole.IndexOf("用户管理") < 0) + { + btn_user_info.Visible = false; + } + if (Utility.userRole.IndexOf("角色管理") < 0) + { + btn_role_info.Visible = false; + } + if (Utility.userRole.IndexOf("资源管理") < 0) + { + btn_resc_info.Visible = false; + } + if (Utility.userRole.IndexOf("角色授权") < 0) + { + btn_role_resc.Visible = false; + } + if (Utility.userRole.IndexOf("用户授权") < 0) + { + btn_user_role.Visible = false; + } + if (Utility.userRole.IndexOf("密码修改") < 0) + { + btn_password_edit.Visible = false; + } + + } + #endregion + + #region 基础工具 + if (Utility.userRole.IndexOf("基础工具") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem1); + } + else + { + if (Utility.userRole.IndexOf("地上模式") < 0) + { + buttonItem87.Visible = false; + } + if (Utility.userRole.IndexOf("地下模式") < 0) + { + buttonItem88.Visible = false; + } + if (Utility.userRole.IndexOf("行走模式") < 0) + { + buttonItem27.Visible = false; + } + if (Utility.userRole.IndexOf("透明度设置") < 0) + { + sliderGroundTransSet1.Visible = false; + } + if (Utility.userRole.IndexOf("快速定位") < 0) + { + buttonItem91.Visible = false; + } + if (Utility.userRole.IndexOf("图层管理") < 0) + { + buttonItem1.Visible = false; + } + if (Utility.userRole.IndexOf("图例管理") < 0) + { + btnlegendSet.Visible = false; + } + if (Utility.userRole.IndexOf("全屏显示") < 0) + { + buttonItem89.Visible = false; + } + if (Utility.userRole.IndexOf("导出图片") < 0) + { + btnOutputJPG.Visible = false; + } + + } + #endregion + + #region 一键审核 + if (Utility.userRole.IndexOf("一键审核") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem11); + } + #endregion + + #region 红线审核 + if (Utility.userRole.IndexOf("红线审核") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem6); + } + #endregion + + #region 双屏对比 + if (Utility.userRole.IndexOf("双屏对比") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem9); + } + #endregion + + #region 文档管理 + if (Utility.userRole.IndexOf("文档管理") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem4); + } + #endregion + + #region 基础管理 + if (Utility.userRole.IndexOf("基础管理") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem14); + } + else + { + if (Utility.userRole.IndexOf("专题图审批") < 0) + { + buttonItemZTT3_2.Visible = false; + } + if (Utility.userRole.IndexOf("打印审批") < 0) + { + buttonItemZTT4_2.Visible = false; + } + if (Utility.userRole.IndexOf("拷贝审批") < 0) + { + buttonItemZTT5_2.Visible = false; + } + } + + #endregion + + if (ribbonControl1.Items.Count <= 0) + { + ribbonControl1.Visible = false; + } + } + + #region Fan Zhang 重构现有代码 + //初始化控件布局 + private void initLayout() + { + 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.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.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.labelX21.Width = (int)(this.labelX21.Width * myScreen); + this.labelX22.Width = (int)(this.labelX22.Width * myScreen); + this.labelX24.Width = (int)(this.labelX24.Width * myScreen); + } + sideBar1.Visible = false; + 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]); + } + + splitContainer1.Panel2Collapsed = true; + + buttonItem87.Checked = true;//默认地上模式 + ribbonTabItem1.Select(); //初始化状态为浏览 + + sideBarPanelItem3.Visible = false; + layerTree.Visible = false; + controlContainerItem3.Visible = false; + if (sideBarPanelItem4.Visible == true) + { + sideBar1.Visible = true; + controlContainerItem5.Visible = true; + } + else + { + sideBar1.Visible = false; + } + Refresh(); + sliderGroundTransSet1.Value = optiValue; + sliderItem1.Value = optiValue; + sliderItem2.Value = optiValue; + sliderItem3.Value = optiValue; + + } + + //初始化地球控件 + private void initGlobalControl() + { + //选择 + btnToolSelect = new GSOHudButton(); + btnToolSelect.SetImage(Application.StartupPath + "\\Resource\\image\\select1.png"); + btnToolSelect.FadeOut = false; + btnToolSelect.Align = EnumAlign.TopLeft; + btnToolSelect.SetOffset(20, 50); + btnToolSelect.Name = "1"; + btnToolSelect.HeightFixed = true; + btnToolSelect.WidthFixed = true; + globeControl1.Globe.AddHudControl(btnToolSelect); + globeControl2.Globe.AddHudControl(btnToolSelect); + + //浏览 + 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); + + //图例 + legend = new GSOHudButton(); + legend.SetImage(Application.StartupPath + "/Resource/图例P.jpg");//图例P + legend.SetOffset(0, 15); + legend.MinOpaque = 1; + legend.MaxOpaque = 1; + legend.FadeOut = false; + legend.Name = "legend"; + legend.Align = EnumAlign.BottomRight; + legend.Visible = false; + globeControl1.Globe.AddHudControl(legend); + + //实测 + legendSC = new GSOHudButton(); + legendSC.SetImage(Application.StartupPath + "/Resource/sc.jpg"); + legendSC.SetOffset(0, 15); + legendSC.MinOpaque = 1; + legendSC.MaxOpaque = 1; + legendSC.FadeOut = false; + legendSC.Name = "legendSC"; + legendSC.Align = EnumAlign.BottomRight; + globeControl1.Globe.AddHudControl(legendSC); + legendSC.Visible = false; + + //施工 + legendSG = new GSOHudButton(); + legendSG.SetImage(Application.StartupPath + "/Resource/sg.jpg"); + legendSG.SetOffset(0, 15); + legendSG.MinOpaque = 1; + legendSG.MaxOpaque = 1; + legendSG.FadeOut = false; + legendSG.Name = "legendSG"; + legendSG.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(legendSG); + legendSG.Visible = false; + + //管纵 + AddGZ(); + + 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; + globeControl1.Globe.IsReleaseMemOutOfView = true; + globeControl1.Globe.ControlPanel.Visible = true; + + globeControl2.Globe.UnderGroundFloor.Visible = false; + globeControl2.Globe.OverviewControl.Visible = false; + globeControl2.Globe.ScalerControl.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; + globeControl2.Globe.IsReleaseMemOutOfView = true; + globeControl2.Globe.ControlPanel.Visible = false; + + 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); + + //添加临时图层 + layerTemp = globeControl1.Globe.Layers.Add(Application.StartupPath + "\\tempLgdData.lgd"); + layerTemp2 = globeControl2.Globe.Layers.Add(Application.StartupPath + "\\tempLgdData2.lgd"); + if (layerTemp != null) + { + layerTemp.MaxVisibleAltitude = 1000; + } + + //添加城市7线图层 + 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"); + + //注册对应事件 + this.registerEvent(); + } + + //注册地球事件 + private bool registerEvent() + { + if (globeControl1 == null || globeControl2 == null) + { + return false; + } + 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); + + globeControl2.FeatureMouseClickEvent += new FeatureMouseClickEventHandler(globeControl2_FeatureMouseClickEvent); + globeControl2.CameraBeginMoveEvent += new CameraBeginMoveEventHandler(globeControl2_CameraBeginMoveEvent); + + globeControl1.MouseDoubleClick += new MouseEventHandler(globeControl1_MouseDoubleClick); + globeControl1.MouseClick += new MouseEventHandler(globeControl1_MouseClick); + globeControl1.MouseDown += new MouseEventHandler(globeControl1_MouseDown); + + globeControl2.MouseClick += new MouseEventHandler(globeControl2_MouseClick); + globeControl2.MouseDown += new MouseEventHandler(globeControl2_MouseDown); + + 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); + + return true; + } + + //加载两个地球数据 + private void loadData() + { + Thread t1 = new Thread(new ThreadStart(doLoadDataForGlobalControl1)); + t1.IsBackground = true; + t1.Start(); + + + } + + delegate void LoadDataForGlobalControl(); + + private void connectServer() + { + globeControl1.Globe.ConnectServer(Utility.serverip, Utility.serverport, "", ""); //加载locaServer中的数据 + globeControl2.Globe.ConnectServer(Utility.serverip, Utility.serverport, "", ""); //加载locaServer中的数据 + //初始化TreeView + // 勾选实测图层 + foreach (TreeNode tn in layerTree.Nodes) + { + if (tn.Nodes.Count > 0) + { + if (tn.Text == "实测数据") + { + tn.Checked = true; + foreach (TreeNode tnChild in tn.Nodes) + { + tnChild.Checked = true; + foreach (TreeNode tnGrandChild in tnChild.Nodes) + { + tnGrandChild.Checked = true; + } + } + } + } + } + } + + private void doLoadDataForGlobalControl1() + { + try + { + + globeControl1.Globe.Layers.MoveDown(10000); + //加载实测管线数据 + Utility.dataSource = globeControl1.Globe.DataManager.OpenOracleDataSource(Utility.DBServer.Trim() + "/" + Utility.dbdatabase.Trim(), "", "", Utility.userID, Utility.DBPassword); + + if (Utility.dataSource != null) + { + for (int j = 0; j < Utility.dataSource.DatasetCount; j++) + { + GSODataset dataset = Utility.dataSource.GetDatasetAt(j); + if (dataset != null && dictionaryNetLayerNameAndCaption.ContainsKey(dataset.Caption)) + { + dataset.Caption = dataset.Name; + globeControl1.Globe.Layers.Add(dataset); + } + } + } + //隐藏红线图层 + globeControl1.Globe.Layers.GetLayerByCaption("红线").Visible = false; + + //globleControl1中加载规划数据 + GSODataSource ghDS = globeControl1.Globe.DataManager.OpenOracleDataSource(Utility.ghdbip + "/" + Utility.ghdbname, "", "", Utility.ghdbuser, Utility.ghdbpwd); + if (ghDS != null) + { + for (int j = 0; j < ghDS.DatasetCount; j++) + { + GSODataset dataset = ghDS.GetDatasetAt(j); + if (dataset != null && dictionaryNetLayerNameAndCaption.ContainsKey(dataset.Caption)) + { + dataset.Caption = dataset.Name; + globeControl1.Globe.Layers.Add(dataset); + globeControl1.Globe.Layers[0].Visible = false; + } + } + } + + //globeControl1,globeControl2中加载施工数据 + GSODataSource sgDS = globeControl1.Globe.DataManager.OpenOracleDataSource(Utility.sgdbip + "/" + Utility.sgdbname, "", "", Utility.sgdbuser, Utility.sgdbpwd); + if (sgDS != null) + { + for (int m = 0; m < sgDS.DatasetCount; m++) + { + GSODataset dataset = sgDS.GetDatasetAt(m); + if (dataset != null && !dataset.Caption.Contains("SH") && dictionaryNetLayerNameAndCaption.ContainsKey(dataset.Caption)) + { + dataset.Caption = dataset.Name; + globeControl1.Globe.Layers.Add(dataset); + globeControl1.Globe.Layers[0].Visible = false; + + globeControl2.Globe.Layers.Add(dataset); + globeControl2.Globe.Layers[0].Visible = true; + } + } + } + + LoadDataForGlobalControl ss = new LoadDataForGlobalControl(connectServer); + ss(); + + } + catch (Exception ex) + { + MessageBox.Show(ex.Message); + } + } + + private void initLayerTree() + { + //加载临时图层节点 + layerManagerNode = new TreeNode(); + layerManagerNode.ImageIndex = 0; + layerManagerNode.SelectedImageIndex = 0; + layerManagerNode.Checked = true; + layerManagerNode.Text = "临时图层"; + layerTree.Nodes.Add(layerManagerNode); + + XmlDocument doc = new XmlDocument(); + doc.Load(filename); + XmlNodeList xmlLayerNodes = doc.SelectNodes("//layer"); + + foreach (XmlNode xmlLayerNode in xmlLayerNodes) + { + + //TODO LIST:创建一级TreeNode(实测、规划、施工) + TreeNode nodelayer = new TreeNode(); + string layerName = xmlLayerNode.Attributes["label"].Value; + nodelayer.Text = layerName; + nodelayer.Checked = false; + layerTree.Nodes.Add(nodelayer); + + XmlNodeList xmlChildLayerNodes = xmlLayerNode.ChildNodes; + foreach (XmlNode xmlChildLayerNode in xmlChildLayerNodes) + { + //TODO LIST:创建二级TreeNode节点 + TreeNode secondLevelNode = new TreeNode(); + string layerType = xmlChildLayerNode.Attributes["label"].Value; + secondLevelNode.Text = layerType; + + if (xmlChildLayerNode.Attributes["type"] != null) + { //道路图层特殊处理 + string type = xmlChildLayerNode.Attributes["type"].Value; + secondLevelNode.Tag = type + "|" + layerType; + } + else + { + secondLevelNode.Tag = layerType; + } + secondLevelNode.Checked = false; + nodelayer.Nodes.Add(secondLevelNode); + + XmlNodeList xmlActitualLayerNodes = xmlChildLayerNode.ChildNodes; + + foreach (XmlNode xmlActitualLayerNode in xmlActitualLayerNodes) + { + //TODO LIST:创建三级图层节点 + TreeNode layerNode = new TreeNode(); + string actutallylayerType = xmlActitualLayerNode.Attributes["type"].Value; + string actutallylayerName = xmlActitualLayerNode.Attributes["layer"].Value; + string actutallyLabelName = xmlActitualLayerNode.Attributes["label"].Value; + + layerNode.Text = actutallyLabelName; + layerNode.Tag = layerType + "|" + actutallyLabelName; + layerNode.Checked = false; + secondLevelNode.Nodes.Add(layerNode); + } + + } + + } + + } + + /** + * 读取Config.xml文件,初始化以下全局Map + * m_PipelineLayerNames:管线 + * workwellLayerNames:工井 + * valueLayerNames:阀门 + * instrumenLayerNames:附属物 + * pipefittingLayerNames:特征管点 + * sgPipeLayersNames:施工管线 + **/ + private void initGlobalMap() + { + XmlDocument doc = new XmlDocument(); + doc.Load(filename); + XmlNodeList xmlLayerNodes = doc.SelectNodes("//layerchild"); + + foreach (XmlNode xmlLayerNode in xmlLayerNodes) + { + string layerType = xmlLayerNode.Attributes["type"].Value; + string layerName1 = xmlLayerNode.Attributes["layer"].Value; + string layerchildName = xmlLayerNode.Attributes["label"].Value; + + dictionaryNetLayerNameAndCaption.Add(layerName1, layerchildName); + + if (layerType != "db") + { + if (xmlLayerNode.Attributes["isRoad"] != null) + { + roadLayerName = layerchildName; + } + } + else if (xmlLayerNode.Attributes["isPipeLine"] != null) + { + m_PipelineLayerNames.Add(layerchildName); + g1layername.Add(layerName1); + } + else if (xmlLayerNode.Attributes["isWorkWell"] != null) + { + workwellLayerNames.Add(layerchildName); + g1layername.Add(layerName1); + } + else if (xmlLayerNode.Attributes["isValve"] != null) + { + valueLayerNames.Add(layerchildName); + g1layername.Add(layerName1); + } + else if (xmlLayerNode.Attributes["isAccess"] != null) + { + instrumenLayerNames.Add(layerchildName); + g1layername.Add(layerName1); + } + else if (xmlLayerNode.Attributes["isCharacter"] != null) + { + pipefittingLayerNames.Add(layerchildName); + g1layername.Add(layerName1); + } + else if (xmlLayerNode.Attributes["isSgData"] != null) + { + sgPipeLayersNames.Add(layerchildName); + g1layername.Add(layerName1); + } + + } + } + + private void initMarkerTree() + { + 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); + } + } + } + } + + private void MainFrm_Load(object sender, EventArgs e) + { + + this.initGlobalControl(); + this.initGlobalMap(); + this.initLayerTree(); + this.initMarkerTree(); + this.initLayout(); + this.loadData(); + + + double x = Convert.ToDouble(Utility.Query_Roads["绿岛"].ToString().Split(',')[0]); + double y = Convert.ToDouble(Utility.Query_Roads["绿岛"].ToString().Split(',')[1]); + double z = Convert.ToDouble(Utility.Query_Roads["绿岛"].ToString().Split(',')[2]); + jumpToCameraState(x, y, z); + + + } + + #endregion + + /// + /// 每次gis服务加载时都会触发的 + /// + /// + /// + 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 dictionaryNetLayerNameAndCaption = new Dictionary(); + 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 配置用户权限 + /// + /// 向数据库插入功能列表 + /// + private void insertControlToDatabase() + { + ArrayList listItem = new ArrayList(); + List subListItem = new List(); + 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) + { + GSOCameraState camera = globeControl2.Globe.CameraState; + globeControl1.Globe.JumpToCameraState(camera); + } + } + + void globeControl1_BeforeSceneRenderEvent(object sender, BeforeSceneRenderEventArgs e) + { + if (globeControl1.Focused) + { + 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); + } + } + } + + /// + /// 检查数据集是否有坐标系信息 + /// + /// + /// + 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 = "0prj4" + lprjStr + ""; + + bSuccess = dataset.LoadProjectionFromESRIFile(dlg.FileName); + + string lprjFileName = strDataPath.Substring(0, strDataPath.LastIndexOf(".")) + ".lprj"; + StreamWriter writer = new StreamWriter(lprjFileName, false); + writer.Write(lprjFileContent); + writer.Close(); + + } + } + } + else + { + return true; + } + return bSuccess; + } + + /// + /// 矩形拉框结束事件处理函数 + /// + /// + /// + 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))); + */ + + int mapWidth = 0; + int mapHeight = 0; + Point pt = getUpperLeftPoint(pt1, pt2, out mapWidth, out mapHeight); + int rightBottomX = pt.X + mapWidth; + int rightBottomY = pt.Y + mapHeight; + Image myImg = new Bitmap(mapWidth, mapHeight); + Graphics g = Graphics.FromImage(myImg); + g.CopyFromScreen(pt, new Point(0, 0), new Size(rightBottomX, rightBottomY)); + + 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; + } + } + /// + /// 定位正北正90度俯视 + /// + /// + /// + /// + 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; + } + } + /// + /// layerTree选中后事件处理 + /// + /// + /// + 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); + } + /// + /// 树节点选中方法 + /// + /// + 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); + } + } + } + + } + /// + /// 改变所有子节点的状态 + /// + /// + /// + 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; + LayerFlyMenuItem.Visible = true; + } + + LayerSelectableMenuItem.Visible = true; + LayerEditableMenuItem.Visible = true; + SaveLayerMenuItem.Visible = true; + LayerFlyMenuItem.Visible = true; + 导出CADToolStripMenuItem1.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]); + if (layer != null) + { + LayerSelectableMenuItem.Checked = layer.Selectable; + LayerEditableMenuItem.Checked = layer.Editable; + } + else + { + return; + } + } + 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; + } + } + } + } + } + + /// + /// 删除临时添加的本地数据图层 + /// + /// + /// + 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); + for (int i = globeControl1.Globe.Layers.Count-1; i >=0; i--) + { + if (globeControl1.Globe.Layers[i].Caption == layer.Caption) + { + globeControl1.Globe.Layers.Remove(globeControl1.Globe.Layers[i]); + } + } + + 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 定位ToolStripMenuItem_Click(object sender, EventArgs e) + { + TreeNode node = layerTree.SelectedNode; + + if (node != null) + { + if (node.Parent.Text.Trim() == "临时图层") + { + GSOLayer lsLayer = globeControl1.Globe.Layers.GetLayerByCaption(node.Text.ToString()); + double x = lsLayer.LatLonBounds.Center.X; + double y = lsLayer.LatLonBounds.Center.Y; + if (x == 0 && y == 0) + { + x = lsLayer.Bounds.Center.X; + y = lsLayer.Bounds.Center.Y; + } + + globeControl1.Globe.FlyToPosition(new GSOPoint3d(x, y, 10), EnumAltitudeMode.Absolute); + } + else + { + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(node.Tag.ToString().Split('|')[1]); + + if (layer != null) + { + if (layer.Caption == "红线") + { + globeControl1.Globe.FlyToPosition(new GSOPoint3d(120.610963, 31.188121, 50), EnumAltitudeMode.Absolute, -4, 50, 1000); + globeControl1.Globe.FlyToPointSpeed = 10000000; + globeControl1.Globe.Action = EnumAction3D.SelectObject; + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = true; + } + globeControl1.Refresh(); + } + else + { + double x = layer.LatLonBounds.Center.X; + double y = layer.LatLonBounds.Center.Y; + globeControl1.Globe.FlyToPosition(new GSOPoint3d(x, y, 100), EnumAltitudeMode.Absolute); + } + } + } + } + else + { + return; + } + + } + + private void layerTree_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e) + { + if(this.layerTree.SelectedNode!=null) + { + if (this.layerTree.SelectedNode.Tag.ToString().Contains("|")) + { + string nodeTag = this.layerTree.SelectedNode.Tag.ToString().Split('|')[1]; + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(nodeTag); + if (layer != null) + { + if (layer.Caption == "红线") + { + globeControl1.Globe.FlyToPosition(new GSOPoint3d(120.610963, 31.188121, 50), EnumAltitudeMode.Absolute, -4, 50, 1000); + globeControl1.Globe.FlyToPointSpeed = 10000000; + globeControl1.Globe.Action = EnumAction3D.SelectObject; + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = true; + } + globeControl1.Refresh(); + } + else { + double x = layer.LatLonBounds.Center.X; + double y = layer.LatLonBounds.Center.Y; + globeControl1.Globe.FlyToPosition(new GSOPoint3d(x, y, 0), EnumAltitudeMode.Absolute); + } + } + } + if (this.layerTree.SelectedNode.Tag is GSOLayer) + { + GSOLayer layer = this.layerTree.SelectedNode.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 (this.layerTree.SelectedNode.Tag is GSOFeature) + { + GSOFeature feature = this.layerTree.SelectedNode.Tag as GSOFeature; + if (feature.Geometry != null) + { + globeControl1.Globe.FlyToPosition(feature.Geometry.GeoCenterPoint, EnumAltitudeMode.Absolute, 0, 0, 10); + } + else + { + globeControl1.Globe.FlyToFeature(feature); + } + } + } + } + + /// + /// 在三维场景移动时,隐藏气泡globeControl1 + /// + /// + /// + void globeControl1_CameraBeginMoveEvent(object sender, CameraBeginMoveEventArgs e) + { + if (featureTooltip.IsVisible()) + { + featureTooltip.HideBalloon(); + } + if (balloonEx.IsVisible()) + { + balloonEx.HideBalloon(); + } + } + + /// + /// 在三维场景移动时,隐藏气泡globeControl2 + /// + /// + /// + void globeControl2_CameraBeginMoveEvent(object sender, CameraBeginMoveEventArgs e) + { + if (featureTooltip2.IsVisible()) + { + featureTooltip2.HideBalloon(); + } + if (balloonEx2.IsVisible()) + { + balloonEx2.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(); + } + } + + #region Fan 横断面 + /// + /// 横断面分析、基线剖面分析、道路断面分析等 + /// + /// + /// + private static EnumTrackPolylineEndMode trackPolylineEndMode; + + void globeControl1_TrackPolylineEndEvent(object sender, TrackPolylineEndEventArgs e) + { + //横断面分析、道路横断面分析 + if (trackPolylineEndMode == EnumTrackPolylineEndMode.HDM_Analysis|| + trackPolylineEndMode == EnumTrackPolylineEndMode.DLDM_Analysis) + { + Dictionary hdmDic = SectionAnalysisTool.HDMAnalysis(this.globeControl1, + e.Polyline, this.m_PipelineLayerNames); + FrmHDMAnalysis3 frm = new FrmHDMAnalysis3(hdmDic, this.globeControl1, + trackPolylineEndMode); + frm.Show(this); + } + //基线剖面分析 + else if (trackPolylineEndMode == EnumTrackPolylineEndMode.JXPM_Analysis) + { + FrmBaseLineProfillAnalysis dlg = new FrmBaseLineProfillAnalysis(globeControl1.Globe, e.Polyline); + dlg.Show(this); + globeControl1.Globe.ClearLastTrackPolyline(); + /* + FrmRoadHDM f = new FrmRoadHDM(); + f.Show() + * **/ + } + else + { + + } + trackPolylineEndMode = EnumTrackPolylineEndMode.Default_Analysis; + /* + ArrayList arraylistPoint = new ArrayList(); + ArrayList arraylistLine = new ArrayList(); + + // globeControl1.Globe.ClearLastTrackPolyline(); + + if (e.Polyline != null) + { + //横断面分析 + if (buttonItemFX2_1.Checked || buttonItemFX2_3.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 (buttonItemFX2_1.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 (buttonItemFX2_4.Checked) + { + FrmBaseLineProfillAnalysis dlg = new FrmBaseLineProfillAnalysis(globeControl1.Globe, e.Polyline); + dlg.Show(this); + globeControl1.Globe.ClearLastTrackPolyline(); + } + else if (buttonItemFX4_3.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(); + * **/ + } + #endregion + + private GSOFeatures PolygonIntersectAnalysis(GSOGeoPolygon3D polygon, string pipelinetype) + { + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(pipelinetype); + 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(pipelinetype, feats.Length); + return feats; + } + /// + /// 根据范围统计阀门、管线、工井等, 开挖分析, 挖方量分析 + /// + /// + /// + void globeControl1_TrackPolygonEndEvent(object sender, TrackPolygonEndEventArgs e) + { + if (globeControl1.Globe.Action == EnumAction3D.TrackPolygon && e.Polygon != null) + { + GSOGeoPolygon3D polygon = e.Polygon; + + switch (trackflag) + { + case "valvequery": + //workWellLen.Clear(); + //List list = new List(); + ////找到所有阀门 + //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, globeControl1, new DataGridViewDelegate(InitDataGridViewX1)); + FrmValveStatistics frm = new FrmValveStatistics(globeControl1,polygon, new DataGridViewDelegate(InitDataGridViewX1)); + frm.Show(this); + //panelEx6.Visible = true; + toolStripFeatureLength.Text = ""; + globeControl1.Globe.Action = EnumAction3D.ActionNull; + break; + + case "PipelineDistanceStatistics": + //pipeLineDis.Clear(); + //List list1 = new List(); + //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, globeControl1, new DataGridViewDelegate(InitDataGridViewX1)); + FrmAllPipelineStatis frm1 = new FrmAllPipelineStatis(globeControl1, polygon, new DataGridViewDelegate(InitDataGridViewX1), m_PipelineLayerNames); + frm1.Show(this); + globeControl1.Globe.Action = EnumAction3D.ActionNull; + + break; + case "PipelineSpatialQuery": + //pipeLineDis.Clear(); + //List list2 = new List(); + //for (int i = 0; i < m_PipelineLayerNames.Count; i++) + //{ + // GSOFeatures fs = Intersects_Pipeline(polygon, m_PipelineLayerNames[i]); + // if (fs != null) + // { + // list2.Add(fs); + // } + //} + + //FrmAllPipelineStatis.ShowForm(1, pipeLineDis, list2, globeControl1, new DataGridViewDelegate(InitDataGridViewX1)); + FrmAllPipelineStatis.ShowForm(globeControl1,polygon,new DataGridViewDelegate(InitDataGridViewX1),m_PipelineLayerNames); + globeControl1.Globe.ClearAnalysis(); + globeControl1.Globe.Action = EnumAction3D.ActionNull; + + break; + case "workwellquery": + //workWellLen.Clear(); + //List listWell = new List(); + ////找到所有井 + //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(polygon, dataGridViewX1, toolStripNumbers, globeControl1, panelOfTable); + FrmAllWorkWellStatis frmWell = new FrmAllWorkWellStatis(globeControl1, polygon, new DataGridViewDelegate(InitDataGridViewX1)); + 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 "BSQDuoBianXiangStatis": + + GSOFeature f2 = new GSOFeature(); + f2.Geometry = e.Polygon; + f2.Geometry.AltitudeMode = EnumAltitudeMode.Absolute; + globeControl1.Globe.MemoryLayer.AddFeature(f2); + f2.Geometry.MoveZ(3); + workWellLen.Clear(); + List listBSQ = new List(); + + GSOFeatures bsqFeatures = PolygonIntersectAnalysis(e.Polygon, "标识器"); + listBSQ.Add(bsqFeatures); + + FrmBSQDuoBianXingStatis bsqFrm = new FrmBSQDuoBianXingStatis(workWellLen, globeControl1, listBSQ); + bsqFrm.Show(this); + globeControl1.Globe.Action = EnumAction3D.ActionNull; + break; + + case "": + break; + default: + break; + } + } + } + + #region 验证端口 + /* + /// + /// 验证端口 + /// + /// + 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 + + /// + /// 鼠标悬浮提示 + /// + /// + /// + 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); + } + } + + /// + /// 添加管线绘制完成事件, 红线工具绘制完成 + /// + /// + /// + 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; + + + } + } + + /// + /// 获取globeControl1中鼠标按下的坐标供区别鼠标右键和滚轮按下事件 + /// + /// + /// + void globeControl1_MouseDown(object sender, MouseEventArgs e) + { + mouseDownX1 = e.X; + mouseDownY1 = e.Y; + } + /// + /// 获取globeControl2中鼠标按下的坐标供区别鼠标右键和滚轮按下事件 + /// + /// + /// + void globeControl2_MouseDown(object sender, MouseEventArgs e) + { + mouseDownX2 = e.X; + mouseDownY2 = e.Y; + } + /// + /// + /// + /// + /// + void globeControl2_MouseClick(object sender, MouseEventArgs e) + { + if (e.Button == MouseButtons.Right) + { + if (e.X == mouseDownX2 && e.Y == mouseDownY2) + { + RightScreenToolMenu.Show(globeControl2, e.X, e.Y); + } + else + { + return; + } + } + } + /// + /// + /// + /// + /// + void globeControl1_MouseClick(object sender, MouseEventArgs e) + { + if (e.Button == MouseButtons.Left) + { + if (globeControl1.Globe.Action == EnumAction3D.VisibilityAnalysis) + { + buttonItemFX5_1.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; + + bsqPT = pt; + + if (buttonItemLS5.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 (e.X == mouseDownX1 && e.Y == mouseDownY1) + { + toolRightMenu.Show(globeControl1, e.X, e.Y); + if (buttonItemLS5.Checked) + { + buttonItemLS5.Checked = false; + } + } + else + { + return; + } + } + globeControl1.Refresh(); + } + + /// + /// 判断网络图片是否存在 + /// + /// + /// + 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; + } + + /// + /// 鼠标点击, 弹出气泡功能globeControl1 + /// + /// + /// + void globeControl1_FeatureMouseClickEvent(object sender, FeatureMouseClickEventArgs e) + { + GSOFeature feature = e.Feature; + + string str1 = ""; + if (feature != null) + { + if (feature.GetFieldDefn("图片编码") != null)// + { + str1 = GetBubbleInfo(feature, globeControl1); + if (RemoteFileExists(Utility.PicRootURL + feature.GetValue("图片编码").ToString())) + { + str1 += ""; + } + else if (RemoteFileExists(Utility.PicDefaultURL)) + { + str1 += ""; + } + } + else if (isFeatureContainsBianhao(feature)) //管线模型图层 + { + str1 = GetBubbleInfo(feature, globeControl1); + } + + 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; + } + } + } + + /// + /// 鼠标点击, 弹出气泡功能globeControl2 + /// + /// + /// + void globeControl2_FeatureMouseClickEvent(object sender, FeatureMouseClickEventArgs e) + { + GSOFeature feature = e.Feature; + + string str1 = ""; + if (feature != null) + { + if (feature.GetFieldDefn("图片编码") != null) // + { + str1 = GetBubbleInfo(feature, globeControl2); + if (RemoteFileExists(Utility.PicRootURL + feature.GetValue("图片编码").ToString())) + { + str1 += ""; + } + else if (RemoteFileExists(Utility.PicDefaultURL)) + { + str1 += ""; + } + } + else if (isFeatureContainsBianhao(feature)) //管线模型图层 + { + str1 = GetBubbleInfo(feature, globeControl2); + } + + if (str1 != "") + { + + featureTooltip2.HideBalloon(); + balloonEx2.HideBalloon(); + balloonEx2.SetSize(EnumSizeIndexEx.CONTENT_CX, 480); + balloonEx2.SetSize(EnumSizeIndexEx.CONTENT_CY, 420); + balloonEx2.ShowBalloon((int)e.MousePos.X, (int)e.MousePos.Y, str1); + + return; + } + } + } + + /// + /// 拼接气泡表格字符串 + /// + /// + /// + private string GetBubbleInfo(GSOFeature feature,GSOGlobeControl globeControl) + { + if (feature == null) + { + return ""; + } + string str = ""; + str = ""; + 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 += ""; + + 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.get_Fields(layerName, globeControl); + } + if (queryFields != null) + { + string[] param = { "," }; + string[] fieldNames = queryFields.Split(param, StringSplitOptions.RemoveEmptyEntries); + for (int j = 0; j < fieldNames.Length; 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 (name1 == "模型路径") + { + continue; + } + 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 (field1.Type == EnumFieldType.Double) + { + double dl1 = feature.GetFieldAsDouble(j); + if (!name1.Contains("管径") && !name1.Contains("电压") && !name1.Contains("角度")) + { + name1 += "_米"; + } + value1 = dl1.ToString("0.00"); + } + 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 (name2 == "模型路径") + { + continue; + } + + 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 (field2.Type == EnumFieldType.Double) + { + double dl2 = feature.GetFieldAsDouble(j + 1); + if (!name2.Contains("管径") && !name2.Contains("电压") && !name2.Contains("角度")) + { + name2 += "_米"; + } + value2 = dl2.ToString("0.00"); + } + else + { + if (!feature.IsFieldValueNull(j + 1)) + { + value2 = feature.GetValue(j + 1).ToString(); + } + } + } + } + + j++; + } + str += ""; + } + } + str += "
" + title + " " + feature.GetFieldAsString(featureIDFieldName) + "
" + + name1 + + "
" + + value1 + + "
" + + name2 + + "
" + + value2 + "
"; + return str; + } + + string filename = Utility.filename; + List g1layername = new List(); + + /// + /// 获取目标图层 + /// + /// + 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; + } + /// + /// 添加图层 + /// + /// + /// + /// + 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 = 5000; + return templayer.Visible; + } + catch (Exception ex) + { + return false; + } + } + /// + /// 菜单上的 三维导航 工具按钮 + /// + /// + /// + private void buttonItem86_Click(object sender, EventArgs e) + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + } + + /// + /// 地上模式 菜单按钮 + /// + /// + /// + 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(); + + } + } + /// + /// 地下模式 菜单按钮 + /// + /// + /// + 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(); + } + } + /// + /// 行走模式 菜单按钮 + /// + /// + /// + 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; + } + } + /// + /// 地面透明度设置 菜单 + /// + /// + /// + private void sliderGroundTransSet1_ValueChanged(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.sliderGroundTransSet1.Text); + + globeControl1.Globe.GroundOpaque = 100 - sliderGroundTransSet1.Value; + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(roadLayerName);//("180fd"); + if (layer != null) + { + layer.Opaque = 100 - sliderGroundTransSet1.Value; + } + //if (buttonItemSPDB.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; + } + /// + /// 图例 菜单按钮 + /// + /// + /// + 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(); + } + /// + /// 快速定位 菜单按钮 + /// + /// + /// + private void buttonItem91_Click(object sender, EventArgs e) // + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItem91.Text); + FrmFlyToPosition fly = new FrmFlyToPosition(globeControl1); + fly.Show(this); + } + /// + /// 图层管理 菜单按钮 + /// + /// + /// + 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; + + //修改图层管理与标注管理、覆土审查、水平净距分析、垂直净距分析和碰撞分析控件之间的逻辑关系 + controlContainerItem5.Visible = false; + sideBar1.Visible = false; + sideBarPanelItem4.Visible = false; + panel3.Visible = false; + sideBar1.ExpandedPanel = sideBarPanelItem3; + buttonItemBZ11.Checked = false; + + //20160624 + /* + if (sideBarPanelItem4.Visible == true) + { + sideBar1.Visible = true; + controlContainerItem5.Visible = true; + } + else + { + sideBar1.Visible = false; + } + */ + Refresh(); + + } + } + /// + /// 全屏显示 菜单按钮 + /// + /// + /// + 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; + /// + /// 全屏显示功能实现 + /// + 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(); + } + } + + /// + /// 设置窗体宽、高 + /// + /// + /// + private void SetFullScreen(int width, int height) + { + this.Width = width; + this.Height = height; + } + + /// + /// 全屏功能的快捷键F5 + /// + /// + /// + 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); + } + } + /* + /// + /// 输出地图 + /// + /// + /// + /// + 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; + } + * */ + + private Point getUpperLeftPoint(Point p1, Point p2, out int mapWidth, out int mapHeight) // + { + Rectangle rc = new Rectangle(); + + p1 = this.globeControl1.PointToScreen(p1); + p2 = this.globeControl1.PointToScreen(p2); + + int x = Screen.PrimaryScreen.Bounds.X; + int y = Screen.PrimaryScreen.Bounds.Y; + int screenWidth = SystemInformation.WorkingArea.Width; + int screenHeight = SystemInformation.WorkingArea.Height; + + if (p1.X < x) + rc.X = x; + else + rc.X = p1.X; + + if (p1.Y < y) + rc.Y = y; + else + rc.Y = p1.Y; + + p1.X = rc.Left; + p1.Y = rc.Top; + + if (p2.X > screenWidth) + p2.X = screenWidth; + else + p2.X = p2.X; + + if (p2.Y > screenHeight) + p2.Y = screenHeight; + else + p2.Y = p2.Y; + + rc.Width = p2.X - rc.X; + rc.Height = p2.Y - rc.Y; + + mapWidth = rc.Width; + mapHeight = rc.Height; + Point pt = new Point(rc.Left, rc.Top); + return pt; + } + + Image printImage; + /// + /// 打印 菜单 + /// + /// + /// + 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))); + */ + int mapWidth = 0; + int mapHeight = 0; + Point pt = getUpperLeftPoint(pt1, pt2, out mapWidth, out mapHeight); + int rightBottomX = pt.X + mapWidth; + int rightBottomY = pt.Y + mapHeight; + Image myImg = new Bitmap(mapWidth, mapHeight); + Graphics g = Graphics.FromImage(myImg); + g.CopyFromScreen(pt, new Point(0, 0), new Size(rightBottomX, rightBottomY)); + + + 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); + } + /// + /// 输出地图 菜单 + /// + /// + /// + private void btnOutputJPG_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btnOutputJPG.Text); + + //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))); + */ + int mapWidth = 0; + int mapHeight = 0; + Point pt = getUpperLeftPoint(pt1, pt2, out mapWidth, out mapHeight); + int rightBottomX = pt.X + mapWidth; + int rightBottomY = pt.Y + mapHeight; + Image myImg = new Bitmap(mapWidth, mapHeight); + Graphics g = Graphics.FromImage(myImg); + g.CopyFromScreen(pt, new Point(0, 0), new Size(rightBottomX, rightBottomY)); + + 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; + } + } + } + + /// + /// 在窗体的底部状态栏上显示 综合管线条件查询结果 + /// + /// + /// + 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 + " 条记录 | "; + } + } + + /// + /// 统计管线的里程数 + /// + /// + /// + /// + 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; + } + + /// + /// 窗体下方属性表格 右键菜单中的 “定位”菜单 + /// + /// + /// + 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); + + } + + /// + /// 表格中右键 “单个闪烁” 菜单 + /// + /// + /// + private void LightMenu_Click(object sender, EventArgs e) + { + flashflag = "single"; + timer1.Start(); + } + /// + /// 表格中右键 “全部闪烁” 菜单 + /// + /// + /// + private void AllLightMenuItem_Click(object sender, EventArgs e) + { + flashflag = "all"; + timer1.Start(); + } + + /// + /// 使用timer实现管线的闪烁效果 + /// + /// + /// + 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; + } + } + + /// + /// 绘制线 菜单 + /// + /// + /// + private void btnAddLine_Click(object sender, EventArgs e) + { + globeControl1.Globe.DestLayerFeatureAdd = globeControl1.Globe.MemoryLayer; + globeControl1.Globe.Action = EnumAction3D.DrawPolyline; + } + /// + /// 绘制面 菜单 + /// + /// + /// + private void btnAddPolygon_Click(object sender, EventArgs e) + { + globeControl1.Globe.DestLayerFeatureAdd = globeControl1.Globe.MemoryLayer; + globeControl1.Globe.Action = EnumAction3D.DrawPolygon; + } + /// + /// 图层目录树 右键菜单中的 目标图层 菜单 + /// + /// + /// + 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; + } + } + /// + /// 图层目录树 右键菜单中的 可选择 菜单 + /// + /// + /// + 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; + } + /// + /// 图层目录树 右键菜单中的 可编辑 菜单 + /// + /// + /// + 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; + } + /// + /// 图层目录树 右键菜单中的 保存 菜单 + /// + /// + /// + 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(); + } + + /// + /// 根据多边形范围统计管线的里程 + /// + /// + /// + /// 返回查询到的管线要素集合 + 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 pipeLineDis = new Dictionary(); + Dictionary workWellLen = new Dictionary(); + + + + + /// + /// 查找指定图层中在 指定范围内的feature对象集合 + /// + /// + /// + /// + 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; + } + /// + /// 清除结果 菜单 + /// + /// + /// + private void buttonItem47_Click(object sender, EventArgs e) + { + globeControl1.Globe.ClearAnalysis(); + dataGridViewX1.DataSource = null; + panelOfTable.Visible = false; + clearFeatureHighLight(); + } + /// + /// 设置菜单的选中状态 + /// + private void ActionToolMenuChecked() + { + if (globeControl1.Globe.Action != EnumAction3D.TrackPolyline) + { + buttonItemFX2_1.Checked = false; + buttonItemFX2_4.Checked = false; + buttonItemFX2_3.Checked = false; + buttonItemFX4_3.Checked = false; + } + if (globeControl1.Globe.Action != EnumAction3D.NormalHit) + { + buttonItemFX3_6.Checked = false; + // ClearConnexityAnalysis(); + + buttonItemFX3_5.Checked = false; + // ClearCloseValvesAnalysis(); + } + if (globeControl1.Globe.Action != EnumAction3D.TrackPolygon) + { + buttonItemFX4_2.Checked = false; + buttonItemFX4_1.Checked = false; + } + } + + /// + /// 主窗体关闭事件处理 + /// + /// + /// + private void MainFrm_FormClosing(object sender, FormClosingEventArgs e) + { + + if (MessageBox.Show("是否退出系统?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) + { + e.Cancel = true; + } + else { + globeControl1.Globe.MemoryLayer.SaveAs(Application.StartupPath + "/MyPlace.kml"); + } + + //saveLayerList(layerManagerNode.Nodes); + //注销id号为103的热键设定 + // UnregisterHotKey(Handle, 103); + } + + /// + /// 显示流向 功能 + /// + /// + /// + /// + 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(); + } + + FrmCloseValves frm; + + FrmBoosterValvers frmbooster = null; + + /// + /// 垂直净距分析 功能界面中的 选择图层复选框 选中状态改变事件处理 + /// + /// + /// + 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(); + } + /// + /// 水平净距分析 功能界面中的 选择图层复选框 选中状态改变事件处理 + /// + /// + /// + 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(); + } + /// + /// 垂直净距分析 功能界面中的 选择管线复选框 选中状态改变事件处理 + /// + /// + /// + private void checkBoxX1_CheckedChanged(object sender, EventArgs e) + { + clearFeatureHighLight(); + if (checkBoxX1.Checked) + { + comboBoxEx1.SelectedItem = null; + 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; + } + } + /// + /// 水平净距分析 功能界面中的 选择管线复选框 选中状态改变事件处理 + /// + /// + /// + private void checkBoxX1_CheckedChanged_shuiping(object sender, EventArgs e) + { + clearFeatureHighLight();//清除高亮 + if (checkBoxX7.Checked) + { + comboBoxEx4.SelectedItem = null; + 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(); + /// + /// 垂直净距分析 功能界面中的 选择图层下拉框 选中项改变 事件处理 + /// + /// + /// + 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; + } + } + } + /// + /// 水平净距分析 功能界面中的 选择图层下拉框 选中项改变 事件处理 + /// + /// + /// + 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 featCount = new Dictionary(); + Dictionary featLenth = new Dictionary(); + Dictionary m_FeaturesWithBianhao = new Dictionary();//记录编号和对应的标注点的位置 + GSOFeatures polygonJingJuAnalysises = new GSOFeatures(); + + /// + /// 垂直净距分析 功能界面中的 开始分析按钮 事件处理 + /// + /// + /// + 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; + } + + /// + /// 在指定的两点组成的线的中间添加一个marker对象,并将marker对象添加到指定的图层中 + /// + /// + /// + /// + /// + /// + 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; + } + + /// + /// 计算指定feature对象与除了该feature所在图层之外的 所有管线图层中的所有feature对象 的垂直距离 并在表格中记录符合要求的管线 + /// + /// + /// + /// + /// + private void VerticalDistanceAnalysis(string type, GSOFeature selectedFeature, List _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(); + } + /// + /// 垂直净距分析中 表格行的 双击定位 功能。 与覆土分析的实现方法不同,主要原因是需要标注垂距 + /// + /// + /// + 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); + } + } + } + } + + /// + /// 水平净距分析 功能界面中 开始分析按钮 的事件处理 + /// + /// + /// + 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; + } + + + /// + /// 计算指定feature对象与除了该feature所在图层之外的 所有管线图层中的所有feature对象 的水平距离 并记录符合要求的管线 功能 + /// + /// + /// + /// + /// + private void HorizontalDistanceAnalysis(GSOFeature selectedFeature, List _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)); + } + } + } + } + } + /// + /// 水平净距分析 功能界面中 表格的 双击定位 功能 + /// + /// + /// + 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); + } + } + } + } + } + /// + /// 碰撞分析 功能界面中 开始分析按钮 事件处理 + /// + /// + /// + 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; + } + /// + /// 碰撞分析功能界面中 表格的 双击定位 功能 + /// + /// + /// + 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); + } + } + } + } + + + + /// + /// 覆土分析功能操作界面中的 选择管线 复选框选中状态改变事件处理 + /// + /// + /// + private void checkBoxX5_CheckedChanged(object sender, EventArgs e) + { + clearFeatureHighLight(); + if (checkBoxX5.Checked) + { + comboBoxEx3.SelectedItem = null; + 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; + } + } + /// + /// 覆土分析功能操作界面中的 选择图层 复选框选中状态改变事件处理 + /// + /// + /// + 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(); + } + /// + /// 覆土分析功能操作界面中的 图层下拉框选中项改变事件处理 + /// + /// + /// + 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; + } + } + } + /// + /// 覆土分析功能操作界面中的 开始分析 按钮事件处理 + /// + /// + /// + 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; + + + GSOPoint3d markerPosition = new GSOPoint3d(); + 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]; + GSOPoint3d pt = new GSOPoint3d(); + + 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"); + + pt.X = pts[m].X; + pt.Y = pts[m].Y; + pt.Z = 0; + markerPosition = LabelVerticalDistance(layerTemp, pts[m], pt, Convert.ToDouble(dataGridViewX7.Rows[idx].Cells[2].Value), true); + 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]; + GSOPoint3d pt = new GSOPoint3d(); + 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"); + + pt.X = pts[m].X; + pt.Y = pts[m].Y; + pt.Z = 0; + markerPosition = LabelVerticalDistance(layerTemp, pts[m], pt, Convert.ToDouble(dataGridViewX7.Rows[idx].Cells[2].Value), true); + + 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; + } + + /// + /// 覆土分析中 表格的 双击定位 功能 + /// + /// + /// + 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); + } + } + } + } + } + /// + /// 覆土分析功能操作界面中的 导出Excel按钮 事件处理 + /// + /// + /// + private void buttonX10_Click(object sender, EventArgs e) + { + if (dataGridViewX7.Rows.Count > 0) + { + ExportExcel("覆土分析", dataGridViewX7, null); + } + else + { + MessageBox.Show("表格内容为空!", "提示"); + } + } + /// + /// 覆土分析功能操作界面底部的 关闭 按钮事件处理 + /// + /// + /// + 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(); + layerTemp.RemoveAllFeature(); + + if (buttonItem1.Checked) + { + sideBar1.ExpandedPanel = sideBarPanelItem3; + } + else + { + sideBar1.Visible = false; + } + globeControl1.Refresh(); + + //Refresh(); + } + + + /// + /// 垂直净距分析 功能界面中 清除分析结果按钮 事件处理 + /// + /// + /// + 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(); + } + /// + /// 水平净距分析 功能界面中 清除分析结果按钮 事件处理 + /// + /// + /// + 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(); + } + + /// + /// 垂直净距分析功能界面中 关闭按钮 事件处理 + /// + /// + /// + 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(); + } + /// + /// 水平净距分析功能界面中 删除缓冲区按钮 事件处理 + /// + /// + /// + private void buttonX14_Click(object sender, EventArgs e) + { + 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(); + } + + /// + /// 导出指定DataGridView控件中的内容 + /// + /// + /// + 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(); + } + } + } + } + + /// + /// 垂直净距分析功能界面中 导出Excel按钮 事件处理 + /// + /// + /// + private void buttonX4_Click(object sender, EventArgs e) + { + if (dataGridViewX3.Rows.Count > 0) + { + ExportExcel("垂直净距分析", dataGridViewX3, listBox1); + } + else + { + MessageBox.Show("表格内容为空!", "提示"); + } + } + /// + /// 水平净距分析功能界面中 导出Excel按钮 事件处理 + /// + /// + /// + private void buttonX4_Click_shuiping(object sender, EventArgs e) + { + if (dataGridViewX9.Rows.Count > 0) + { + ExportExcel("水平净距分析", dataGridViewX9, listBox3); + } + else + { + MessageBox.Show("表格内容为空!", "提示"); + } + } + + + /// + /// 清除所有坑 菜单 + /// + /// + /// + private void buttonItem3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItem3.Text); + + globeControl1.Globe.RemoveAllPits(); + } + + //} + /// + /// 大气层 菜单 + /// + /// + /// + private void buttonItem17_Click_1(object sender, EventArgs e) + { + globeControl1.Globe.Atmosphere.Visible = !globeControl1.Globe.Atmosphere.Visible; + buttonItemSH1.Checked = globeControl1.Globe.Atmosphere.Visible; + globeControl1.Refresh(); + } + /// + /// 经纬网 菜单 + /// + /// + /// + private void buttonItem20_Click(object sender, EventArgs e) + { + globeControl1.Globe.LatLonGrid.Visible = !globeControl1.Globe.LatLonGrid.Visible; + buttonItemSH3.Checked = globeControl1.Globe.LatLonGrid.Visible; + globeControl1.Globe.Refresh(); + } + /// + /// 状态条 菜单 + /// + /// + /// + private void buttonItem21_Click_1(object sender, EventArgs e) + { + globeControl1.Globe.StatusBar.Visible = !globeControl1.Globe.StatusBar.Visible; + buttonItemSH4.Checked = globeControl1.Globe.StatusBar.Visible; + globeControl1.Globe.Refresh(); + } + + + + /// + /// 添加指定路径下的数据 功能 + /// + /// + /// + 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); + //CheckDatasetGeoReference(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; + } + return objRes; + } + /// + /// 刷新目录树 功能 + /// + 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); + } + } + /// + /// 判断图层是否包含字段列表 + /// + /// + /// + 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; + } + + /// + /// 统计指定图层在指定范围内的所有feature对象 + /// + /// + /// + /// + 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; + } + /// + /// 碰撞分析功能界面中 选择管线复选框 选中状态改变事件处理 + /// + /// + /// + private void checkBoxX3_CheckedChanged(object sender, EventArgs e) + { + clearFeatureHighLight(); + if (checkBoxX3.Checked) + { + comboBoxEx2.SelectedItem = null; + 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; + } + } + /// + /// 碰撞分析功能界面中 选择图层复选框 选中状态改变事件处理 + /// + /// + /// + 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(); + } + /// + /// 碰撞分析功能界面中 选择图层下拉框 选中项改变事件处理 + /// + /// + /// + 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; + } + } + } + /// + /// 清除所有图层中的所有feature对象的高亮状态 功能 + /// + 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); + } + } + } + } + for (int i = 0; i < globeControl2.Globe.Layers.Count; i++) + { + GSOLayer layer = globeControl2.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; + } + } + } + + if (globeControl1.Globe.Action == EnumAction3D.SelectObject) + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + //globeControl1.Globe.Action = EnumAction3D.SelectObject; + } + } + + /// + /// 碰撞分析功能界面中 清除分析结果按钮 事件处理 + /// + /// + /// + 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(); + } + /// + /// 碰撞分析功能界面中 导出Excel按钮 事件处理 + /// + /// + /// + private void buttonX6_Click(object sender, EventArgs e) + { + if (dataGridViewX5.Rows.Count > 0) + { + ExportExcel("碰撞分析", dataGridViewX5, listBox2); + } + else + { + MessageBox.Show("表格内容为空!", "提示"); + } + } + /// + /// 导出CAD 菜单 + /// + /// + /// + private void btnExportCAD_Click(object sender, EventArgs e) + { + FrmExportCADS frm = new FrmExportCADS(globeControl1, m_PipelineLayerNames); + frm.ShowDialog(); + } + + ///// + ///// 区域分析 菜单 + ///// + ///// + ///// + //private void buttonItem50_Click(object sender, EventArgs e) + //{ + // buttonItem50.Checked = !buttonItem50.Checked; + // ribbonBarQY.Visible = buttonItem50.Checked; + // ribbonBarQY.Location = new Point(0, 0); + //} + + + /// + /// 连接数据库 菜单事件处理 + /// + /// + /// + 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; + } + } + } + /// + /// 数据验证 菜单 + /// + /// + /// + private void buttonItem80_Click(object sender, EventArgs e) + { + FrmValiData frm = new FrmValiData(globeControl1); + frm.ShowDialog(); + } + /// + /// 根据指定图层创建图层节点并将节点添加到图层管理节点的子节点集合中 + /// + /// + 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; + + if (!layerManagerNode.Nodes.Contains(node)) + { + layerManagerNode.Nodes.Insert(0, node); + layerManagerNode.Expand(); + } + } + } + /// + /// 数据库备份 菜单 + /// + /// + /// + 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(); + } + } + } + + + + #region Fan 去掉 + //GSOFeature emitterFeature; // 粒子要素 + /// + /// 添加火苗 功能 + /// + /// + /// + /// + 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); + + } + /// + /// 添加喷泉 功能 + /// + /// + /// + /// + 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); + } + #endregion + + /// + /// 获取指定图层中最后一个feature对象的名称对应的整数 + /// + /// + /// + 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; + } + /// + /// 设置除指定标注图层之外的所有标注图层不可见 + /// + /// + 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; + } + } + } + } + } + + /// + /// 判断选中的对象是否为管线 + /// + /// 被选中管线 + /// 返回一根线 + 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; + } + + /// + /// 创建label要素 功能 + /// + /// 添加label要素的feature + /// feature的位置 + /// label要素名字 + /// feature名字 + /// label要素距离点的位置 + /// + 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; + } + + + + /// + /// 获取指定两点组成的线的长度 功能 + /// + /// + /// + /// + 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; + } + + /// + /// 图层节点树中 节点 右键单击事件处理 + /// + /// + /// + 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; + } + } + } + } + } + + /// + /// 标注管理、传感器管理 图层目录树的右键菜单中的 刷新列表 菜单 + /// + /// + /// + 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); + } + } + /// + /// 给指定的图层节点添加代表feature对象的子节点 + /// + /// + private void RefreshTreeNodeLayerFeatureList(TreeNode layerTreeNode) + { + layerTreeNode.Nodes.Clear(); + GSOLayer layer = (GSOLayer)layerTreeNode.Tag; + // 只将类型为内存数据集的图层列出,如果是其它类型的数据集可能数据量太大,没发显示在树控件中 + if (layer.Dataset is GSOFeatureDataset) + { + VisitFeature3Ds(layer.GetAllFeatures(), layerTreeNode); + } + } + + /// + /// 标注管理、传感器管理 图层目录树的右键菜单中的 移除所有 菜单 + /// + /// + /// + 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(); + } + } + + /// + /// 图层目录树的 节点对应的复选框选中状态改变事件处理 + /// + /// + /// + private void layerMarkerTree_AfterCheck(object sender, TreeViewEventArgs e) + { + if (e.Action != TreeViewAction.Unknown) + { + CheckTreeNode(e.Node, e.Node.Checked); + } + } + /// + /// 改变指定节点对应的复选框的选中状态 + /// + /// + /// + private void CheckTreeNode(TreeNode node, Boolean bChecked) + { + CheckChildTreeNode(node, bChecked); + globeControl1.Globe.Refresh(); + } + /// + /// 改变指定节点的子节点对应的复选框的选中状态 + /// + /// + /// + 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); + } + } + /// + /// 标注管理、传感器管理 目录树中的feature节点的右键菜单中的 删除 菜单 + /// + /// + /// + 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(); + } + } + + /// + /// 双屏对比 菜单 + /// + /// + /// + //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(); + // } + //} + /// + /// 模拟分析 菜单 + /// + /// + /// + //private void buttonItem51_Click(object sender, EventArgs e) + //{ + // buttonItem51.Checked = !buttonItem51.Checked; + // ribbonBarMN.Visible = buttonItem51.Checked; + // ribbonBarMN.Location = new Point(0, 0); + //} + + /// + /// 双屏设置 菜单 + /// + /// + /// + //private void buttonItem96_Click(object sender, EventArgs e) + //{ + // FrmLayerControl frm = new FrmLayerControl(layerTree,globeControl1,globeControl2); + // frm.Show(this); + //} + /// + /// 双屏联动 菜单 + /// + /// + /// + //private void buttonItem95_Click(object sender, EventArgs e) + //{ + // buttonItem95.Checked = !buttonItem95.Checked; + //} + ///// + /// 添加用户仓库 菜单 + /// + /// + /// + private void buttonItem108_Click(object sender, EventArgs e) + { + FrmUserRepo frm = new FrmUserRepo(-1); + frm.ShowDialog(); + } + /// + /// 用户仓库管理 菜单 + /// + /// + /// + private void buttonItem111_Click(object sender, EventArgs e) + { + FrmUserRepoMgr frm = new FrmUserRepoMgr(); + frm.ShowDialog(); + } + /// + /// 添加分系统 菜单 + /// + /// + /// + private void buttonItem112_Click(object sender, EventArgs e) + { + //FrmAPP frm = new FrmAPP(-1); + //frm.ShowDialog(); + } + /// + /// 分系统管理 菜单 + /// + /// + /// + private void buttonItem113_Click(object sender, EventArgs e) + { + //FrmAPPMgr frm = new FrmAPPMgr(); + //frm.ShowDialog(); + } + /// + /// 添加操作 菜单 + /// + /// + /// + private void buttonItem114_Click(object sender, EventArgs e) + { + FrmOper frm = new FrmOper(-1); + frm.ShowDialog(); + } + /// + /// 操作管理 菜单 + /// + /// + /// + private void buttonItem115_Click(object sender, EventArgs e) + { + FrmOperMgr frm = new FrmOperMgr(); + frm.ShowDialog(); + } + /// + /// 添加资源 菜单 + /// + /// + /// + private void buttonItem116_Click(object sender, EventArgs e) + { + FrmRESC frm = new FrmRESC(-1); + frm.ShowDialog(); + } + /// + /// 资源管理 菜单 + /// + /// + /// + private void buttonItem117_Click(object sender, EventArgs e) + { + FrmRESCMgr frm = new FrmRESCMgr(); + frm.ShowDialog(); + } + /// + /// 添加权限 菜单 + /// + /// + /// + private void buttonItem118_Click(object sender, EventArgs e) + { + FrmPerm frm = new FrmPerm(-1); + frm.ShowDialog(); + } + /// + /// 权限管理 菜单 + /// + /// + /// + private void buttonItem119_Click(object sender, EventArgs e) + { + FrmPermMgr frm = new FrmPermMgr(); + frm.ShowDialog(); + } + /// + /// 添加访问控制 菜单 + /// + /// + /// + private void buttonItem120_Click(object sender, EventArgs e) + { + FrmAccess frm = new FrmAccess(-1); + frm.ShowDialog(); + } + /// + /// 访问控制管理 菜单 + /// + /// + /// + private void buttonItem121_Click(object sender, EventArgs e) + { + FrmAccessMgr frm = new FrmAccessMgr(); + frm.ShowDialog(); + } + /// + /// 部门类型管理 菜单 + /// + /// + /// + private void buttonItem122_Click(object sender, EventArgs e) + { + FrmRegionTypeMgr frm = new FrmRegionTypeMgr(); + frm.ShowDialog(); + } + /// + /// 添加用户 菜单 + /// + /// + /// + private void buttonItem127_Click(object sender, EventArgs e) + { + FrmUserAdd frm = new FrmUserAdd(-1); + frm.ShowDialog(); + } + /// + /// 用户信息管理 菜单 + /// + /// + /// + private void buttonItem128_Click_1(object sender, EventArgs e) + { + FrmUserManager frm = new FrmUserManager(); + frm.ShowDialog(); + } + /// + /// 添加角色 菜单 + /// + /// + /// + private void 添加角色_Click(object sender, EventArgs e) + { + FrmRole frm = new FrmRole(-1); + frm.ShowDialog(); + } + /// + /// 所有角色管理 菜单 + /// + /// + /// + private void 角色管理_Click(object sender, EventArgs e) + { + FrmRoleMgr frm = new FrmRoleMgr(); + frm.ShowDialog(); + } + + /// + /// 部门角色管理 菜单 + /// + /// + /// + private void buttonItem133_Click(object sender, EventArgs e) + { + FrmRegionRoleMgr frm = new FrmRegionRoleMgr(); + frm.ShowDialog(); + } + /// + /// 部门管理 菜单 + /// + /// + /// + private void buttonItem130_Click(object sender, EventArgs e) + { + FrmRegionMgr frm = new FrmRegionMgr(); + frm.ShowDialog(); + } + + /// + /// 日志管理 菜单 + /// + /// + /// + private void buttonItem135_Click(object sender, EventArgs e) + { + FrmLogManager frm = new FrmLogManager(); + frm.ShowDialog(); + } + /// + /// 传感器信息查询 菜单 + /// + /// + /// + 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); + } + } + } + /// + /// 根据指定的图层的caption属性的值在配置文件中查找对应的数据库中的表的名称 + /// + /// 图层的caption属性的值 + /// 对应的数据库中的表的名称 + 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; + } + /// + /// 根据数据库中的表的名称 查找对应的表中的字段名称的集合 + /// + /// 数据库中的表的名称 + /// 对应的表中的字段名称的集合 + 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; + } + + /// + /// 历史曲线查询 菜单 + /// + /// + /// + 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; + /// + /// 传感器在线报警 菜单 + /// + /// + /// + 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); + } + /// + /// 传感器报警 功能中的 定时器 的触发事件处理 + /// + /// + /// + 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; + } + } + } + } + } + } + } + + + /// + /// 沿线运动 菜单 + /// + /// + /// + private void buttonItem138_Click(object sender, EventArgs e) + { + if (globeControl1.Globe.SelectedObject == null) + { + MessageBox.Show("请先选择一条线!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + return; + } + + GSOFeature lineFeature = globeControl1.Globe.SelectedObject; + if (lineFeature.Geometry == null || lineFeature.Geometry.Type != EnumGeometryType.GeoPolyline3D) + { + MessageBox.Show("请先选择一条线!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + return; + } + + OpenFileDialog dlg = new OpenFileDialog(); + dlg.Filter = "*.gcm;*.3ds|*.gcm;*.3ds|*.3ds|*.3ds|*.gcm|*.gcm"; + if (dlg.ShowDialog() == DialogResult.OK) + { + GSOGeoModel model = new GSOGeoModel(); + model.FilePath = dlg.FileName; + + GSOGeoDynamicRoute dynamicRoute = new GSOGeoDynamicRoute(); + dynamicRoute.ActorGeometry = model; + + GSORoute route = new GSORoute(); + GSOGeoPolyline3D geoline = (GSOGeoPolyline3D)lineFeature.Geometry; + for (int i = 0; i < geoline[0].Count; i++) + { + route.Add(geoline[0][i]); + } + route.CircleRoute = false; + route.Speed = 30; + route.RotateSpeed = 50; + route.AltitudeMode = geoline.AltitudeMode; + dynamicRoute.Route = route; + + GSOFeature feature = new GSOFeature(); + + dynamicRoute.Play(); + feature.Geometry = dynamicRoute; + + //GSOLabel gsoLabel = new GSOLabel(); + //gsoLabel.Text = "模型测试"; + //feature.Label = gsoLabel; + globeControl1.Globe.MinModelVisibleSize = 0; + + globeControl1.Globe.MemoryLayer.AddFeature(feature); + globeControl1.Globe.Refresh(); + } + } + /// + /// 回退 菜单 + /// + /// + /// + private void buttonItem99_Click(object sender, EventArgs e) + { + globeControl1.Globe.UnDoEdit(); + } + /// + /// 前进 菜单 + /// + /// + /// + private void buttonItem100_Click(object sender, EventArgs e) + { + globeControl1.Globe.ReDoEdit(); + } + /// + /// 水平净距 功能界面中的 标签内容改变事件处理 + /// + /// + /// + 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() + "米的管线有:"; + } + } + } + /// + /// 垂直净距 功能界面中的 标签内容改变事件处理 + /// + /// + /// + 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() + "米的管线有:"; + } + } + } + /// + /// 覆土分析 功能界面中的 标签内容改变事件处理 + /// + /// + /// + 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() + "米的管线有:"; + } + } + } + + /// + /// 传感器分类查询 全区域 菜单 + /// + /// + /// + private void buttonItemSensor全区域查询_Click(object sender, EventArgs e) + { + FrmAccessoriesSensor.ShowForm(globeControl1, instrumenLayerNames, 0); + } + /// + /// 传感器分类查询 绘制区域 菜单 + /// + /// + /// + private void buttonItemSensor绘制区域查询_Click(object sender, EventArgs e) + { + FrmAccessoriesSensor.ShowForm(globeControl1, instrumenLayerNames, 1); + } + + + /// + /// 碰撞分析 功能界面中 关闭按钮 事件处理 + /// + /// + /// + 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(); + } + /// + /// 覆土分析 功能界面中的 清除分析结果 按钮事件处理 + /// + /// + /// + 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(); + } + /// + /// 数字预处理 功能 + /// + /// + /// + private void 数字预处理buttonItem140_Click(object sender, EventArgs e) + { + FrmEditShapeFile frm = new FrmEditShapeFile(globeControl1); + frm.ShowDialog(this); + } + + + /// + /// 导出矢量 功能 将图层导出为kml和shp格式数据 + /// + /// + /// + private void 导出矢量buttonItem140_Click(object sender, EventArgs e) + { + List listVectorNames = new List(); + for (int i = 0; i < m_PipelineLayerNames.Count; i++) + { + 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 = ""; + /// + /// 绘制城市七线 功能按钮 + /// + /// + /// + 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; + } + } + } + /// + /// 七线审核 功能按钮 + /// + /// + /// + private void 七线审核buttonItem141_Click(object sender, EventArgs e) + { + FrmCityServerLineAnalysis frm = new FrmCityServerLineAnalysis(globeControl1, m_PipelineLayerNames); + frm.ShowDialog(this); + } + + /// + /// 间距分析 开始分析按钮 分析绘制的七线和管线的距离是否符合标准 + /// + /// + /// + 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; + } + /// + /// 间距分析 清除分析结果 + /// + /// + /// + 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(); + } + /// + /// 间距分析 导出Excel按钮 将间距分析的结果以Excel表格的形式导出 + /// + /// + /// + private void buttonExportExcel_Click(object sender, EventArgs e) + { + if (dataGridViewAnalysisResult.Rows.Count > 0) + { + ExportExcel("间距分析", dataGridViewAnalysisResult, listBoxStasticsResult); + } + else + { + MessageBox.Show("表格内容为空!", "提示"); + } + } + /// + /// 间距分析 关闭按钮 + /// + /// + /// + 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(); + } + /// + /// 间距分析 分析结果表格双击定位 + /// + /// + /// + 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); + } + } + } + } + /// + /// 间距分析 选择管线复选框 + /// + /// + /// + private void checkBoxSelectPipeline_CheckedChanged(object sender, EventArgs e) + { + clearFeatureHighLight();//清除高亮 + if (checkBoxSelectPipeline.Checked) + { + comboBoxLayer.SelectedItem = null; + 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; + } + } + /// + /// 间距分析 选择图层复选框 + /// + /// + /// + 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(); + } + /// + /// 间距分析 选择图层下拉框 + /// + /// + /// + 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; + } + } + } + + + + /// + /// 管线自动缩进 菜单 + /// + /// + /// + private void 管线自动缩进buttonItem140_Click(object sender, EventArgs e) + { + FrmPipelineIndented frm = new FrmPipelineIndented(globeControl1, m_PipelineLayerNames, workwellLayerNames); + 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 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); + // } + //} + + /// + /// 统计指定图层在指定范围内的所有feature对象 + /// + /// + /// + /// + 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) + { + 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 setLayerVisible(string layerName) + { + GSOLayer templayer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + if (templayer != null) + { + templayer.Visible = false; + } + globeControl1.Globe.Refresh(); + } + + /// + /// 连接数据库 + /// + /// + /// + private void buttonItem129_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL4_1.Text); + + FrmDatabaseParaSetting2 frm = new FrmDatabaseParaSetting2(globeControl1); + if (frm.ShowDialog() == DialogResult.OK) + { + ds = FrmDatabaseParaSetting2.ds; + if (ds != null) + { + ds.IsCloseSaved = false; + } + } + } + + /// + /// 一键审核---导入数据 + /// + /// + /// + private void buttonItem127_Click_2(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, "打开数据"); + + try + { + //if (shds == null) + //{ + //没连的话,直接连接审核库; //审核库配置读配置文件 + string dbIp = Utility.sgdbip; + string database = Utility.sgdbname; + string user = Utility.sgdbuser; + string pass = Utility.sgdbpwd; + /* + 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; + //} + } + catch (Exception ex) + { + LogError.PublishError(ex); + MessageBox.Show("内存过载请清理内存,并重新启动规划分析!", "提示"); + return; + } + + } + + /// + ///自动导出图片 + /// + /// + /// + private void buttonItem130_Click_1(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, "导出审核图"); + + 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))); + */ + + int mapWidth = 0; + int mapHeight = 0; + Point pt = getUpperLeftPoint(pt1, pt2, out mapWidth, out mapHeight); + int rightBottomX = pt.X + mapWidth; + int rightBottomY = pt.Y + mapHeight; + Image myImg = new Bitmap(mapWidth, mapHeight); + Graphics g = Graphics.FromImage(myImg); + g.CopyFromScreen(pt, new Point(0, 0), new Size(rightBottomX, rightBottomY)); + + 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; + } + } + } + /// + /// 一键审核功能 + ///
+ /// + /// + private void buttonItem128_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItem128.Text); + //垂直净距标准 + + frmSh = new FrmYJSHTC(globeControl1, globeControl2,layerTree); + + if (frmSh.ShowDialog() == DialogResult.OK) + { + frmWait = new FrmWait("一键审核……"); + frmWait.Location = new Point(this.Width - frmWait.Width - 10, this.Height - frmWait.Height - 50); + frmWait.Owner = this; + frmWait.Show(); + Thread thread = new Thread(new ThreadStart(doWork)); + thread.IsBackground = true; + thread.Start(); + } + } + + void doWork() + { + FrmShResult frmShResult = null; + + double dVerticalJingJuBiaoZhun = 1, dHorizontalJingJuBiaoZhun = 1; + if (frmSh.rukuLayer != null) + { + #region + this.Invoke((EventHandler)delegate + { + try + { + List managerLayerList = new List(); + for (int i = 0; i < layerManagerNode.Nodes.Count; i++) + { + managerLayerList.Add(layerManagerNode.Nodes[i].Text); + } + if (!managerLayerList.Contains(frmSh.rukuLayer.Caption)) + { + TreeNode node = new TreeNode(); + node.Tag = frmSh.rukuLayer; + node.Text = frmSh.rukuLayer.Dataset.Caption; + node.ImageIndex = 0; + node.SelectedImageIndex = 0; + node.Checked = frmSh.rukuLayer.Visible; + layerManagerNode.Nodes.Insert(0, node); + layerManagerNode.Expand(); + } + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "提示"); + } + }); + #endregion + + shlayername = frmSh.rukuLayer.Name; + globeControl1.Refresh(); + } + + if (frmShResult != null && !frmShResult.IsDisposed) + { + try + { + clearFeatureHighLight(); + ClearRedlineAnalyseResult(); + frmShResult.Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message); + } + } + + 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.analysis(); + + //MainFrm窗体显示控制,回到一键审核Tab + this.Invoke((EventHandler)delegate + { + frmShResult.Show(); + frmWait.Close(); + //将tab页恢复到一键审核 + ribbonTabItem11.Checked = true; + try + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + //zhanshi = false; + splitContainer1.Panel2Collapsed = true; + + panelOfTable.Visible = false; + legendSC.Visible = false; + legendSG.Visible = false; + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + } + catch (Exception ex) + { + MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + + }); + + boolfrmShResult = true; + } + else + { + + } + } + + + /// + /// 清除渲染结果 + /// + 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(); + } + /// + /// 已审核的图层 + /// + /// + /// + private void buttonItem132_Click_1(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItem132.Text); + + if (shds == null) + { + //没连的话,直接连接审核库; //审核库配置读配置文件 + string dbIp = Utility.sgdbip; + string database = Utility.sgdbname; + string user = Utility.sgdbuser; + string pass = Utility.sgdbpwd; + + /* + 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; + //} + + } + /// + /// 审核入库 + /// + /// + /// + private void buttonItem133_Click_1(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, "审核入库"); + FrmShRK frmShrk = new FrmShRK(globeControl1); + frmShrk.Show(); + } + /// + /// 模拟设计修改 + /// + /// + /// + private void buttonItem134_Click_1(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, "模拟设计修改"); + + 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 + { + + } + + } + + + /// + /// 绘制垂线 + /// + /// + /// + 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); + } + /// + /// 比较两个点是否是同一个点 + /// + /// + /// + /// + 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; + } + /// + /// 获得点到线的垂线距离及垂点 + /// + /// + /// + /// + /// + 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); + 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]; + } + /// + /// 获得斜率 + /// + /// + /// + /// + /// + /// + /// + 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); + } + } + /// + /// 根据默认投影参数,经纬度转xyz + /// + /// + /// + /// + 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; + } + /// + /// 根据投影参数,经纬度转xyz + /// + /// + /// + /// + /// + 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; + } + /// + /// 根据默认投影参数,xyz转经纬度 + /// + /// + /// + /// + 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; + } + /// + /// 根据投影参数,Xyz转经纬度 + /// + /// + /// + /// + /// + 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; + } + /// + /// 获得inpolygon的管线长度 + /// + /// + 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; + } + + + /// + /// 一键审核中调节透明度 + /// + /// + /// + private void sliderItem1_ValueChanged(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.sliderItem1.Text); + + globeControl1.Globe.GroundOpaque = 100 - sliderItem1.Value; + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(roadLayerName);//("180fd"); + if (layer != null) + { + layer.Opaque = 100 - sliderItem1.Value; + } + + optiValue = sliderItem1.Value; + } + /// + /// 红线审核中的透明度分析 + /// + /// + /// + private void sliderItem3_ValueChanged(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.sliderItem3.Text); + + globeControl1.Globe.GroundOpaque = 100 - sliderItem3.Value; + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(roadLayerName);//("180fd"); + if (layer != null) + { + layer.Opaque = 100 - sliderItem3.Value; + } + optiValue = sliderItem3.Value; + } + + #region yanxiaowei + //初始化DataGridViewX1控件 + public delegate void DataGridViewDelegate(DataTable dt, string strLable, string strLayer, bool initDataGrid); + /// + /// 代理函数,操作DatgridViewX1 + /// + /// + /// + public void InitDataGridViewX1(DataTable dt, string strLable, string strLayer, bool initDataGrid) + { + if (initDataGrid == true) + { + dataGridViewX1.DataSource = dt; + panelOfTable.Visible = true; + toolStripNumbers.Text = strLable; + dataGridViewX1.Tag = strLayer; + } + else + { + dataGridViewX1.DataSource = null; + dataGridViewX1.Refresh(); + panelOfTable.Visible = false; + toolStripNumbers.Text = ""; + dataGridViewX1.Tag = ""; + globeControl1.Globe.MemoryLayer.RemoveAllFeature();//清除双击产生的标注 + } + } + FrmAnalysisGuiHuaResult from; + /// + /// 主窗体下方属性表格 双击定位 功能 + /// + /// + /// + private void dataGridViewX1_MouseDoubleClick(object sender, MouseEventArgs e) + { + if (redSH == false) + { + 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 if (dataGridViewX1.Columns.Contains("标识器编号")) + { + featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["标识器编号"].Value.ToString(); + } + featureName = featureName.Trim(); + + GSOLayer layer = null; + layer = globeControl1.Globe.Layers.GetLayerByCaption(dataGridViewX1.Tag.ToString()); + + if (layer == null) return; + + GSOFeatures features = layer.GetFeatureByName(featureName, false); + if (features.Length == 0) return; + GSOFeature rowFeature = features[0]; + + ClassSearchAnalysis.AddMakerToLineFeature(globeControl1, rowFeature); + + } + } + } + else + { + if (e.Button == MouseButtons.Left) + { + if (from != null && !from.IsDisposed) + { + try + { + from.Close(); + } + catch (Exception ex) + { + LogError.PublishError(ex); + } + } + try + { + DataGridView.HitTestInfo hittestinfo = dataGridViewX1.HitTest(e.X, e.Y); + if (hittestinfo.RowIndex >= 0) + { + string layer = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["管线类型"].Value.ToString(); + string hxName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["红线编号"].Value.ToString(); + FrmAnalysisGuiHuaResult frm = new FrmAnalysisGuiHuaResult(globeControl1, lineStruct, featsList, + panelOfTable, dataGridViewX1, layer, hxName); + frm.Location = new Point(this.Width - frm.Width - 10, this.Height - frm.Height - 20); + frm.Show(this); + + from = frm; + } + } + catch (Exception ex) + { + LogError.PublishError(ex); + } + } + } + } + + /// + /// 空间查询 + /// + /// + /// + private void buttonItemSearch1_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemSearch1.Text); + + trackflag = "PipelineSpatialQuery"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; + + } + /// + /// 关键字查询 + /// + /// + /// + private void buttonItemSearch9_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch9.Text); + + FrmKeywordQuery.ShowForm(globeControl1, m_PipelineLayerNames, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 编号查询 + /// + /// + /// + private void buttonItemSearch2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch2.Text); + + FrmCodingQuery.ShowForm(globeControl1, m_PipelineLayerNames, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 坐标查询 + /// + /// + /// + private void buttonItemSearch3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch3.Text); + + FrmSetLatLonPos.ShowForm(globeControl1); + } + /// + /// 附属物查询 + /// + /// + /// + private void buttonItemSearch10_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch10.Text); + + FrmFittingQuery.ShowForm(globeControl1, instrumenLayerNames, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 管径查询 + /// + /// + /// + private void buttonItemSearch4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch4.Text); + + FrmDiameterQuery.ShowForm(globeControl1, m_PipelineLayerNames, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 材质查询 + /// + /// + /// + private void buttonItemSearch5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch5.Text); + + FrmMaterialSel.ShowForm(globeControl1, m_PipelineLayerNames, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 基本查询 + /// + /// + /// + private void buttonItemSearch6_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch6.Text); + + FrmBasicQuery.ShowForm(globeControl1, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 复合查询 + /// + /// + /// + private void buttonItemSearch7_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch7.Text); + + FrmQuerySQL.ShowForm(globeControl1, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 关联查询 + /// + /// + /// + private void buttonItemSearch8_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch8.Text); + + if (globeControl1.Globe.SelObjectCount != 1) + { + MessageBox.Show("请选中一个对象!", "提示"); + return; + } + + 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 || (feature.Geometry.Type == EnumGeometryType.GeoPolygon3D + || feature.Geometry.Type == EnumGeometryType.GeoWater)) + return; + else + { + ClassSearchAnalysis.ResultRelationAnalysis(globeControl1, feature, valueLayerNames, workwellLayerNames, + instrumenLayerNames, pipefittingLayerNames, m_PipelineLayerNames, valueAllowance); + } + } + } + #endregion + /// + /// 清除分析 + /// + /// + /// + private void buttonItemClear_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemClear.Text); + + globeControl1.Globe.ClearMeasure(); + layerTemp.RemoveAllFeature(); + layerTemp2.RemoveAllFeature(); + buttonItemLS5.Checked = false; + + dataGridViewX1.DataSource = null; + panelOfTable.Visible = false; + + 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); + + NetworkAnalysisTool.ClearAllTopAnalysis(this.globeControl1); + // 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();//清除所有坑 + + 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(); + } + } + + clearFeatureHighLight();//取消管线高亮 + + GSOLayer layerGround = globeControl1.Globe.Layers.GetLayerByCaption(roadLayerName);//("180fd"); + if (layerGround != null) + { + layerGround.Visible = true; + } + globeControl1.Refresh(); + globeControl2.Refresh(); + ClearRedlineAnalyseResult(); + globeControl1.Globe.Action = EnumAction3D.ActionNull; + } + /// + /// 管线长度全区域统计 + /// + /// + /// + private void buttonItemTJ1_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管线长度统计"); + + //pipeLineDis.Clear(); + //List list = new List(); + //for (int i = 0; i < m_PipelineLayerNames.Count; i++) + //{ + // GSOFeatures fs = Intersects_Pipeline(null, m_PipelineLayerNames[i]); + // if (fs!=null) + // list.Add(fs); + //} + + //FrmAllPipelineStatis frm = new FrmAllPipelineStatis(0, pipeLineDis, list, globeControl1, new DataGridViewDelegate(InitDataGridViewX1)); + FrmAllPipelineStatis frm = new FrmAllPipelineStatis(globeControl1,null, new DataGridViewDelegate(InitDataGridViewX1), m_PipelineLayerNames); + frm.Show(this); + + } + /// + /// 管线长度绘制区域统计 + /// + /// + /// + private void buttonItemTJ1_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管线长度统计"); + + trackflag = "PipelineDistanceStatistics"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; + } + /// + /// 阀门数量全区域统计 + /// + /// + /// + private void buttonItemTJ2_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "阀门数量统计"); + + //workWellLen.Clear(); + //List list = new List(); + ////找到所有阀门 + //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, globeControl1, new DataGridViewDelegate(InitDataGridViewX1)); + FrmValveStatistics frm = new FrmValveStatistics(globeControl1, null, new DataGridViewDelegate(InitDataGridViewX1)); + frm.Show(this); + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + } + /// + /// 阀门数量绘制区域统计 + /// + /// + /// + private void buttonItemTJ2_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "阀门数量统计"); + + trackflag = "valvequery"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; + } + /// + /// 井盖数量全区域统计 + /// + /// + /// + private void buttonItemTJ3_ALL_Click(object sender, EventArgs e) + { + //日志记录 + //LogManager.saveLog(Utility.userName, "井盖数量统计"); + + //workWellLen.Clear(); + //List list = new List(); + + //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(null, dataGridViewX1, toolStripNumbers, globeControl1, panelOfTable); + FrmAllWorkWellStatis frm = new FrmAllWorkWellStatis(globeControl1, null, new DataGridViewDelegate(InitDataGridViewX1)); + frm.Show(this); + } + /// + /// 井盖数量绘制区域统计 + /// + /// + /// + private void buttonItemTJ3_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "井盖数量统计"); + + trackflag = "workwellquery"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; + } + /// + /// 管径分段统计全区域统计 + /// + /// + /// + private void buttonItemTJ4_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管径分段统计"); + + Frmpipediameterstatis.ShowForm(globeControl1, m_PipelineLayerNames, 0); + } + /// + /// 管径分段统计绘制区域统计 + /// + /// + /// + private void buttonItemTJ4_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管径分段统计"); + + trackflag = null; + Frmpipediameterstatis.ShowForm(globeControl1, m_PipelineLayerNames, 1); + } + /// + /// 埋深分段统计全区域统计 + /// + /// + /// + private void buttonItemTJ5_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "埋深分段统计"); + FrmpipeDeepstatis.ShowForm(globeControl1, m_PipelineLayerNames, 0); + } + /// + /// 埋深分段统计绘制区域统计 + /// + /// + /// + private void buttonItemTJ5_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "埋深分段统计"); + trackflag = null; + FrmpipeDeepstatis.ShowForm(globeControl1, m_PipelineLayerNames, 1); + } + /// + /// 管径分类统计全区域统计 + /// + /// + /// + private void buttonItemTJ6_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管径分类汇总"); + + FrmpipeDiametergather.ShowForm(globeControl1, m_PipelineLayerNames, 0); + } + /// + /// 管径分类统计绘制区域统计 + /// + /// + /// + private void buttonItemTJ6_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管径分类汇总"); + + trackflag = null; + FrmpipeDiametergather.ShowForm(globeControl1, m_PipelineLayerNames, 1); + } + /// + /// 材质分类统计全区域统计 + /// + /// + /// + private void buttonItemTJ7_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "材质分类汇总"); + + FrmpipeMaterialGather.ShowForm(globeControl1, m_PipelineLayerNames, 0); + } + /// + /// 材质分类统计绘制区域统计 + /// + /// + /// + private void buttonItemTJ7_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "材质分类汇总"); + + trackflag = null; + FrmpipeMaterialGather.ShowForm(globeControl1, m_PipelineLayerNames, 1); + } + /// + /// 附属物分类统计全区域统计 + /// + /// + /// + private void buttonItemTJ8_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "附属物分类汇总"); + + FrmAccessoriesgather.ShowForm(globeControl1, instrumenLayerNames, 0); + } + /// + /// 附属物分类统计绘制区域统计 + /// + /// + /// + private void buttonItemTJ8_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "附属物分类汇总"); + + trackflag = null; + FrmAccessoriesgather.ShowForm(globeControl1, instrumenLayerNames, 1); + } + /// + /// 碰撞分析 + /// + /// + /// + private void buttonItemFX1_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_4.Text); + + this.dataGridViewX4.Size = new System.Drawing.Size(195, 120); + 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(); + } + /// + /// 覆土分析 + /// + /// + /// + private void buttonItemFX1_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX5_1.Text); + this.dataGridViewX6.Size = new System.Drawing.Size(195, 120); + 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(); + } + /// + /// 间距分析 + /// + /// + /// + private void buttonItemFX1_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX1_3.Text); + + this.dataGridViewLineList.Size = new System.Drawing.Size(185, 120); + 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(); + } + /// + /// 垂直净距分析 + /// + /// + /// + private void buttonItemFX1_4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX1_4.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(); + } + /// + /// 水平净距分析 + /// + /// + /// + private void buttonItemFX1_5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_6.Text); + this.dataGridViewX8.Size = new System.Drawing.Size(185, 120); + 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(); + } + + #region Predaotr,断面分析 + /// + /// 横断面分析 + /// + /// + /// + private void buttonItemFX2_1_Click(object sender, EventArgs e) + { + globeControl1.Globe.Action = EnumAction3D.TrackPolyline; + globeControl1.Globe.TrackPolylineTool.VerticalLineVisible = true; + globeControl1.Globe.TrackPolylineTool.TrackMode = EnumTrackMode.SpaceTrack; + trackPolylineEndMode = EnumTrackPolylineEndMode.HDM_Analysis; + + } + /// + /// 纵断面分析 + /// + /// + /// + private void buttonItemFX2_2_Click(object sender, EventArgs e) + { + if (globeControl1.Globe.SelObjectCount<1) + { + MessageBox.Show("请选择一条或者多条管线!", "提示", MessageBoxButtons.OK, + MessageBoxIcon.Information); + return; + } + 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); + } + } + List feats = SectionAnalysisTool.ZDMAnalysis(selectFeatures); + if (feats != null && feats.Count >= 1) + { + FrmProfileAnalysis frm = new FrmProfileAnalysis(globeControl1, feats); + frm.Show(this); + } + } + /// + /// 道路断面分析 + /// + /// + /// + private void buttonItemFX2_3_Click(object sender, EventArgs e) + { + globeControl1.Globe.Action = EnumAction3D.TrackPolyline; + globeControl1.Globe.TrackPolylineTool.VerticalLineVisible = true; + globeControl1.Globe.TrackPolylineTool.TrackMode = EnumTrackMode.SpaceTrack; + trackPolylineEndMode = EnumTrackPolylineEndMode.DLDM_Analysis; + + } + /// + /// 基线剖面分析 + /// + /// + /// + private void buttonItemFX2_4_Click(object sender, EventArgs e) + { + globeControl1.Globe.Action = EnumAction3D.TrackPolyline; + globeControl1.Globe.TrackPolylineTool.VerticalLineVisible = true; + globeControl1.Globe.TrackPolylineTool.TrackMode = EnumTrackMode.SpaceTrack; + trackPolylineEndMode = EnumTrackPolylineEndMode.JXPM_Analysis; + + } + + #endregion + /// + /// 创建拓扑 + /// + /// + /// + private void buttonItemFX3_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX3_1.Text); + + FrmGenAndFaMenTopu frm = new FrmGenAndFaMenTopu(globeControl1, m_PipelineLayerNames, valueLayerNames); + frm.Show(this); + } + #region Predator :拓扑分析 + /// + /// 上游分析 + /// + /// + /// + private void buttonItemFX3_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX3_2.Text); + NetworkTraceUpDown(true); + } + /// + /// 下游分析 + /// + /// + /// + private void buttonItemFX3_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX3_3.Text); + NetworkTraceUpDown(false); + } + + /// + /// 上下游追踪 功能 + /// + /// + private void NetworkTraceUpDown(Boolean bTraceUp) + { + GSOFeature selLineFeature = globeControl1.Globe.SelectedObject; + if (selLineFeature == null || selLineFeature.Geometry == null || selLineFeature.Geometry.Type != EnumGeometryType.GeoPolyline3D) + { + MessageBox.Show("请点击“编辑”—“选中对象”选择一条线!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); + return; + } + GSOLayer selLayer = globeControl1.Globe.SelectedObjectLayer; + + NetworkAnalysisTool.TraceUpDownAnalysis(bTraceUp, + selLineFeature, selLayer); + } + + /// + /// 流向分析 + /// + /// + /// + private void buttonItemFX3_4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX3_4.Text); + + FrmFlow frm = new FrmFlow(globeControl1, m_PipelineLayerNames); + frm.Show(this); + } + /// + /// 关阀分析 + /// + /// + /// + private void buttonItemFX3_5_Click(object sender, EventArgs e) + { + if (globeControl1.Globe.SelObjectCount < 1) + { + MessageBox.Show("请选中至少一根管线!!"); + buttonItemFX3_5.Checked = false; + return; + } + GSOLayer resLayer = null; + GSOFeature resFeature = null; + globeControl1.Globe.GetSelectObject(0, out resFeature, out resLayer); + + String pipeLayerName = resLayer.Caption; + String pipeLayerNamePrefix = pipeLayerName.Substring(0, pipeLayerName.IndexOf("管线")); + GSOLayer valveLayer = globeControl1.Globe.Layers[pipeLayerNamePrefix + "阀门"]; + if (valveLayer == null) + { + MessageBox.Show("无" + pipeLayerNamePrefix+"阀门图层", "提示"); + return; + } + + GSOFeatures valveFeats = NetworkAnalysisTool.CloseValvesAnalysis(resFeature, + resLayer, valveLayer); + + if (valveFeats != null) + { + FrmCloseValves frm = new FrmCloseValves(this.globeControl1, valveFeats); + frm.Show(this); + } + else + { + MessageBox.Show("未找到关闭阀门"); + } + } + + /// + /// 连通分析 + /// + /// + /// + private void buttonItemFX3_6_Click(object sender, EventArgs e) + { + if (globeControl1.Globe.SelObjectCount < 2) + { + MessageBox.Show("请选中至少两个管线!!"); + buttonItemFX3_6.Checked = false; + return; + } + GSOFeature selFeat0, selFeat1; + GSOLayer layer0,layer1; + globeControl1.Globe.GetSelectObject(0, out selFeat0, out layer0); + globeControl1.Globe.GetSelectObject(1, out selFeat1, out layer1); + + if (!layer0.IsSameInnerObject(layer1)) + { + MessageBox.Show("不在同一个图层!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); + buttonItemFX3_6.Checked = false; + return; + } + NetworkAnalysisTool.ConnexityAnalysis(selFeat0, selFeat1, layer0); + } + /// + /// 爆管分析 + /// + /// + /// + private void buttonItemFX3_7_Click(object sender, EventArgs e) + { + NetworkTraceUpDown(true); //上游追踪: + + GSOFeature selLineFeature = globeControl1.Globe.SelectedObject; + if (selLineFeature == null || selLineFeature.Geometry == null || selLineFeature.Geometry.Type != EnumGeometryType.GeoPolyline3D) + { + MessageBox.Show("请点击“编辑”—“选中对象”选择一条线!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); + return; + } + GSOLayer selLayer = globeControl1.Globe.SelectedObjectLayer; + + NetworkAnalysisTool.ExplodeAnalysis(this.globeControl1,selLineFeature,selLayer); + + this.buttonItemFX3_5_Click(sender, e); //关阀分析: + + } + + #endregion + /// + /// 多边形开挖 + /// + /// + /// + private void buttonItemFX4_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_1.Text); + + trackflag = "pit"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; //是这个么?是的,在模型上 + } + /// + /// 挖方量分析 + /// + /// + /// + private void buttonItemFX4_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_2.Text); + + trackflag = "digFillAnalysis"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; + ActionToolMenuChecked(); + } + /// + /// 沿线开挖 + /// + /// + /// + private void buttonItemFX4_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_3.Text); + + if (!buttonItemFX4_3.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; + buttonItemFX4_3.Checked = true; + } + } + else + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + buttonItemFX4_3.Checked = false; + globeControl1.Globe.TrackPolylineTool.VerticalLineVisible = false; + } + ActionToolMenuChecked(); + } + /// + /// 创建隧道 + /// + /// + /// + private void buttonItemFX4_4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_4.Text); + + 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("场景中未加载隧道图层!", "提示"); + } + } + /// + /// 隐藏隧道 + /// + /// + /// + private void buttonItemFX4_5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_5.Text); + + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption("隧道"); + if (layer != null) + { + layer.Visible = !layer.Visible; + } + } + /// + /// 删除隧道 + /// + /// + /// + private void buttonItemFX4_6_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_6.Text); + + 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("请选中要删除的隧道!", "提示"); + } + } + /// + /// 通视分析 + /// + /// + /// + private void buttonItemFX5_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX5_1.Text); + + if (globeControl1.Globe.Action != EnumAction3D.VisibilityAnalysis) + { + //btnSpaceVisibilityAnalysis.Checked = true; + globeControl1.Globe.Action = EnumAction3D.VisibilityAnalysis; + } + else + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + // SetButtonChecked(); + } + } + /// + /// 可视域分析 + /// + /// + /// + private void buttonItemFX5_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX5_2.Text); + + globeControl1.Globe.Action = EnumAction3D.ViewshedAnalysis; + } + /// + /// 可视包络分析 + /// + /// + /// + private void buttonItemFX5_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX5_3.Text); + + globeControl1.Globe.Action = EnumAction3D.ViewEnvelopeAnalysis; + } + /// + /// 缓冲区分析 + /// + /// + /// + private void buttonItemFX6_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX6_1.Text); + + GSOFeature feat = globeControl1.Globe.SelectedObject; + if (feat == null) + { + MessageBox.Show("请选择要分析的要素!"); + return; + } + if (feat.Geometry.Type == EnumGeometryType.GeoPolyline3D) + { + GSOGeoPolyline3D line1 = feat.Geometry as GSOGeoPolyline3D; + if (line1 == null) + { + MessageBox.Show("请选择一条管线!"); + return; + } + + FrmBufferAnalysis frm = new FrmBufferAnalysis(globeControl1, line1, layerTemp); + frm.Show(this); + } + else + { + FrmBufferAnalysisBSQ frm = new FrmBufferAnalysisBSQ(globeControl1, layerTemp, bsqPT); + frm.Show(this); + } + + } + /// + /// 附属物分析 + /// + /// + /// + private void buttonItemFX6_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX6_2.Text); + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + FrmAccessoryAnalysis dlg = new FrmAccessoryAnalysis(globeControl1, layerTemp); + dlg.Show(this); + } + /// + /// 无源淹没分析 + /// + /// + /// + private void buttonItemFX6_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX6_3.Text); + + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + trackflag = "FloodAnalysis"; + } + /// + /// 水平距离 + /// + /// + /// + private void buttonItemLS1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS1.Text); + + globeControl1.Globe.Action = EnumAction3D.MeasureDistance; + globeControl1.Globe.DistanceRuler.SpaceMeasure = false; + buttonItemLS5.Checked = false; + } + /// + /// 垂直距离 + /// + /// + /// + private void buttonItemLS2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS2.Text); + + buttonItemLS5.Checked = false; + globeControl1.Globe.Action = EnumAction3D.MeasureHeight; + globeControl1.Globe.DistanceRuler.SpaceMeasure = false; + } + /// + /// 空间距离 + /// + /// + /// + private void buttonItemLS3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS3.Text); + + buttonItemLS5.Checked = false; + globeControl1.Globe.Action = EnumAction3D.MeasureDistance; + globeControl1.Globe.DistanceRuler.SpaceMeasure = true; + } + /// + /// 地表距离 + /// + /// + /// + private void buttonItemLS4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS4.Text); + + buttonItemLS5.Checked = false; + globeControl1.Globe.Action = EnumAction3D.MeasureDistance; + globeControl1.Globe.DistanceRuler.SpaceMeasure = false; + } + /// + /// 高度量算 + /// + /// + /// + private void buttonItemLS5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS5.Text); + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + buttonItemLS5.Checked = !buttonItemLS5.Checked; + if (buttonItemLS5.Checked) + { + globeControl1.Globe.Action = EnumAction3D.SelectObject; + } + } + /// + /// 水平面积 + /// + /// + /// + private void buttonItemLS6_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS6.Text); + + buttonItemLS5.Checked = false; + globeControl1.Globe.Action = EnumAction3D.MeasureArea; + globeControl1.Globe.AreaRuler.SpaceMeasure = true; + } + /// + /// 地表面积 + /// + /// + /// + private void buttonItemLS7_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS7.Text); + + buttonItemLS5.Checked = false; + globeControl1.Globe.Action = EnumAction3D.MeasureArea; + globeControl1.Globe.AreaRuler.SpaceMeasure = false; + + } + + # region Fan 重构标注代码 + /// + /// 标高标注 + /// + /// + /// + private void buttonItemSZ1_Click(object sender, EventArgs e) + { + GSOFeature resFeature = IsPipeLineOfSelectedObj(); + if (resFeature == null) + { + MessageBox.Show("请选中一根管线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + GSOGeoPolyline3D selLine = resFeature.Geometry as GSOGeoPolyline3D; + if (selLine[0].Count <= 1) + { + return; + } + + MarkTools.getInstance().showMarker(resFeature, + globeControl1, EnumMarkLayer.Mark_Altitude, ""); + } + /// + /// 管径标注 + /// + GSOFeature radiusMarkerFeature; + private void buttonItemBZ2_Click(object sender, EventArgs e) + { + GSOFeature resFeature = IsPipeLineOfSelectedObj(); + if (resFeature == null) + { + MessageBox.Show("请选中一根管线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + GSOGeoPolyline3D selLine = resFeature.Geometry as GSOGeoPolyline3D; + if (selLine[0].Count <= 1) + { + return; + } + + MarkTools.getInstance().showMarker(resFeature, + globeControl1, EnumMarkLayer.Mark_Diameter, ""); + } + /// + /// 埋深标注 + /// + /// + /// + private void buttonItemBZ3_Click(object sender, EventArgs e) + { + GSOFeature resFeature = IsPipeLineOfSelectedObj(); + if (resFeature == null) + { + MessageBox.Show("请选中一根管线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + GSOGeoPolyline3D selLine = resFeature.Geometry as GSOGeoPolyline3D; + if (selLine[0].Count <=1) + { + return; + } + + MarkTools.getInstance().showMarker(resFeature, + globeControl1, EnumMarkLayer.Mark_Depth, ""); + + } + /// + /// 坐标标注 + /// + /// + /// + private void buttonItemBZ4_Click(object sender, EventArgs e) + { + GSOFeature resFeature = IsPipeLineOfSelectedObj(); + if (resFeature == null) + { + MessageBox.Show("请选中一根管线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + GSOGeoPolyline3D selLine = resFeature.Geometry as GSOGeoPolyline3D; + if (selLine[0].Count <= 1) + { + return; + } + MarkTools.getInstance().showMarker(resFeature, + globeControl1, EnumMarkLayer.Mark_Location, ""); + } + /// + /// 距离标注 + /// + bool distanceMarker = false; + private void buttonItemBZ5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBZ5.Text); + + globeControl1.Globe.Action = EnumAction3D.TrackPolyline; + //globeControl1.Globe.DistanceRuler.MeasureMode = EnumDistanceMeasureMode.HVSLineMeasure; + distanceMarker = true; + } + /// + /// 自定义标注 + /// + /// + /// + private void buttonItemBZ6_Click(object sender, EventArgs e) + { + GSOFeature f = globeControl1.Globe.SelectedObject; + GSOLayer l = globeControl1.Globe.SelectedObjectLayer; + FrmCustomLabel frm = new FrmCustomLabel(globeControl1, l, f); + if (frm.ShowDialog() == DialogResult.OK) + { + MarkTools.getInstance().showMarker(f, globeControl1, EnumMarkLayer.Mark_Custom, frm.labelText); + } + } + /// + /// 扯旗标注 + /// + /// + /// + private void buttonItemBZ7_Click(object sender, EventArgs e) + { + GSOFeature f = globeControl1.Globe.SelectedObject; + GSOLayer l = globeControl1.Globe.SelectedObjectLayer; + FrmMarker frm = new FrmMarker(); + if (frm.ShowDialog() == DialogResult.OK) + { + MarkTools.getInstance().showMarker(f, globeControl1, EnumMarkLayer.Mark_Custom, frm.markerContent); + } + } + /// + /// 坡度标注 + /// + /// + /// + private void buttonItemBZ8_Click(object sender, EventArgs e) + { + GSOFeature resFeature = IsPipeLineOfSelectedObj(); + if (resFeature == null) + { + MessageBox.Show("请选中一根管线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + GSOGeoPolyline3D selLine = resFeature.Geometry as GSOGeoPolyline3D; + if (selLine[0].Count <= 1) + { + return; + } + + MarkTools.getInstance().showMarker(resFeature, + globeControl1, EnumMarkLayer.Mark_Slope, ""); + } + /// + /// 属性标注 + /// + /// + /// + private void buttonItemBZ9_Click(object sender, EventArgs e) + { + GSOFeature f = globeControl1.Globe.SelectedObject; + GSOLayer l = globeControl1.Globe.SelectedObjectLayer; + FrmPropertiesMarker frm = new FrmPropertiesMarker(globeControl1, l, f); + if (frm.ShowDialog() == DialogResult.OK) + { + MarkTools.getInstance().showMarker(f, globeControl1, EnumMarkLayer.Mark_Property, frm.labelText); + } + } + /// + /// 红线工具 + /// + /// + /// + private void buttonItemBZ10_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBZ10.Text); + 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; + } + } + /// + /// 标注管理 + /// + /// + /// + private void buttonItemBZ11_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBZ11.Text); + + buttonItemBZ11.Checked = !buttonItemBZ11.Checked; + 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 (buttonItemBZ11.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(); + } + } + + #endregion + /// + /// 飞行到目标点 + /// + /// + /// + private void buttonItemFXGJ1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFXGJ1.Text); + + FrmSetFlytoPos.ShowForm(globeControl1); + + } + /// + /// 自定义飞行 + /// + /// + /// + private void buttonItemFXGJ2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFXGJ2.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); + } + } + /// + /// 绕中心点飞行 + /// + /// + /// + private void buttonItemFXGJ3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFXGJ3.Text); + + globeControl1.Globe.FlyAroundCenter(10000, EnumFlyRepeatValueType.MiliSeconds); + globeControl1.Globe.CurFlyID = 1; + } + /// + /// 绕眼睛飞行 + /// + /// + /// + private void buttonItemFXGJ4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFXGJ4.Text); + + globeControl1.Globe.FlyAroundEye(720, EnumFlyRepeatValueType.Degrees); + globeControl1.Globe.CurFlyID = 2; + } + + /// + /// 权限管理 + /// + /// + /// + private void buttonItemXT1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT1.Text); + + FrmUserRoleMgr frm = new FrmUserRoleMgr(); + frm.ShowDialog(); + } + /// + /// 数据库管理 + /// + /// + /// + private void buttonItemXT2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT2.Text); + + //查看数据库列表 + FrmDbManager frm = new FrmDbManager(); + frm.ShowDialog(); + } + /// + /// 用户列表 + /// + /// + /// + private void buttonItemXT3_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT3_1.Text); + + FrmUserManager frm = new FrmUserManager(); + frm.ShowDialog(); + } + /// + /// 创建新用户 + /// + /// + /// + private void buttonItemXT3_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT3_2.Text); + + FrmUserAdd frm = new FrmUserAdd(-1); + frm.ShowDialog(); + } + /// + /// 人员修改 + /// + /// + /// + private void buttonItemXT4_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT4_2.Text); + + FrmAppUSER appUSER = new FrmAppUSER(); + appUSER.ShowDialog(); + } + /// + /// 增加人员 + /// + /// + /// + private void buttonItemXT4_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT4_1.Text); + + FrmAppUSERRESET appUSERRESET = new FrmAppUSERRESET(); + appUSERRESET.ShowDialog(); + } + /// + /// 统计数据 + /// + /// + /// + private void buttonItemZTT1_Click(object sender, EventArgs e) + { + ////日志记录 + //LogManager.saveLog(Utility.userName, this.buttonItemZTT1.Text); + + //PATM patm = new PATM(); + //patm.operation = "Statistic"; + //patm.Text = "统计专题图管理"; + //patm.ShowDialog(); + } + /// + /// 热点功能统计 + /// + /// + /// + private void buttonItemZTT2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT2.Text); + + FrmHotFuncStat frmhfs = new FrmHotFuncStat(); + frmhfs.ShowDialog(); + } + + private void buttonItemZTT3_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT3_1.Text); + + FrmAPP appfrm = new FrmAPP("专题图申请"); + appfrm.ShowDialog(); + } + + private void buttonItemZTT3_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT3_2.Text); + + FrmAPPFORASK appForask = new FrmAPPFORASK("专题图审核"); + appForask.ShowDialog(); + } + + private void buttonItemZTT3_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT3_3.Text); + + FrmAPPregion appregion = new FrmAPPregion("专题图审核"); + appregion.ShowDialog(); + } + + private void buttonItemZTT4_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT4_1.Text); + + FrmAPP appfrm = new FrmAPP("打印申请"); + appfrm.ShowDialog(); + } + + private void buttonItemZTT4_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT4_2.Text); + + FrmAPPFORASK appForask = new FrmAPPFORASK("打印审核"); + appForask.ShowDialog(); + } + + private void buttonItemZTT4_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT4_3.Text); + + FrmAPPregion appregion = new FrmAPPregion("打印审核"); + appregion.ShowDialog(); + } + + private void buttonItemZTT5_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT5_1.Text); + + FrmAPP appfrm = new FrmAPP("拷贝申请"); + appfrm.ShowDialog(); + } + + private void buttonItemZTT5_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT5_2.Text); + + FrmAPPFORASK appForask = new FrmAPPFORASK("拷贝审核"); + appForask.ShowDialog(); + } + + private void buttonItemZTT5_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT5_3.Text); + + FrmAPPregion appregion = new FrmAPPregion("拷贝审核"); + appregion.Show(); + } + + private int connectServerCount = 0; + + /// + /// 还原球到实测库 + /// + 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); + } + + if (layerManagerNode.Nodes.Count > 0) + { + for (int i = layerManagerNode.Nodes.Count - 1; i >= 0; i--) + { + layerManagerNode.Nodes[i].Remove(); + + } + } + + globeControl1.Refresh(); + + } + + private void buttonItemSPSZ_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSPSZ.Text); + + FrmLayerControl frm = new FrmLayerControl(layerTree, globeControl1, globeControl2); + frm.Show(this); + } + + /// + /// 碰撞审查 + /// + /// + /// + private void buttonItemSH1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSH1.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 buttonItemSH2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSH2.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 buttonItemSH3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSH3.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 buttonItemSH4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSH4.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 buttonItemSH5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSH5.Text); + FrmCityServerLineAnalysis frm = new FrmCityServerLineAnalysis(globeControl1, m_PipelineLayerNames); + frm.Show(this); + } + #region 数据管理-导入文件 + ///// + ///// 数据管理-导入本地坐标系文件 + ///// + ///// + ///// + //private void buttonItemSJGL1_1_Click(object sender, EventArgs e) + //{ + // //日志记录 + // LogManager.saveLog(Utility.userName, this.buttonItemSJGL1_1.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(); + // } + // } + //} + + ///// + ///// 数据管理-导入其他坐标系文件 + ///// + ///// + ///// + //private void buttonItemSJGL1_2_Click(object sender, EventArgs e) + //{ + // //日志记录 + // LogManager.saveLog(Utility.userName, this.buttonItemSJGL1_2.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(); + // } + // } + //} + #endregion + /// + /// 数据质量检查 + /// + /// + /// + private void buttonItemSJGL2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL2.Text); + FrmValiData frm = new FrmValiData(globeControl1); + frm.ShowDialog(); + } + /// + /// 数据预处理 + /// + /// + /// + private void buttonItemSJGL3_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL3.Text); + + FrmEditShapeFile frm = new FrmEditShapeFile(globeControl1); + frm.ShowDialog(this); + } + /// + /// 连接数据库 + /// + /// + /// + private void buttonItemSJGL4_1_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL4_1.Text); + + FrmDatabaseParaSetting frm = new FrmDatabaseParaSetting(globeControl1); + if (frm.ShowDialog() == DialogResult.OK) + { + ds = FrmDatabaseParaSetting.ds; + if (ds != null) + { + ds.IsCloseSaved = false; + } + } + } + /// + /// 管线入库 + /// + /// + /// + private void buttonItemSJGL4_2_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL4_2.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 buttonItemSJGL4_3_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL4_3.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 buttonItemSJGL5_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL5.Text); + + Cyberpipe.Forms.FrmProject frm = new Cyberpipe.Forms.FrmProject(); + frm.ShowDialog(); + } + /// + /// 元数据基本管理 + /// + /// + /// + private void buttonItemSJGL6_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL6_1.Text); + + FrmMetadata frmmd = new FrmMetadata(); + frmmd.ShowDialog(); + } + /// + /// 元数据查询管理 + /// + /// + /// + private void buttonItemSJGL6_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL6_2.Text); + + FrmMetadataStat frmmds = new FrmMetadataStat(); + //frmmds.Show(); + frmmds.ShowDialog(); + } + /// + /// 操作日志管理 + /// + /// + /// + private void buttonItemSJGL7_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL7.Text); + + FrmLogOper frmlo = new FrmLogOper(); + frmlo.ShowDialog(); + } + /// + /// 数据字典管理 + /// + /// + /// + private void buttonItemSJGL8_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL8.Text); + + FrmMDDictory frmmdd = new FrmMDDictory(); + frmmdd.ShowDialog(); + } + /// + /// 数据库备份 + /// + /// + /// + private void buttonItemSJGL9_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL9.Text); + + //新 + FrmBACKORACLE backOracle = new FrmBACKORACLE(); + backOracle.Show(); + } + /// + /// 创建管段 + /// + /// + /// + private void buttonItemBJ1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ1.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; + } + } + /// + /// 创建附属物 + /// + /// + /// + private void buttonItemBJ2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ2.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); + } + } + /// + /// 创建特征管点 + /// + /// + /// + private void buttonItemBJ3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ3.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); + } + } + /// + /// 绘制城市七线 + /// + /// + /// + private void buttonItemBJ4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ4.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; + } + } + } + /// + /// 选中对象 + /// + /// + /// + private void buttonItemBJ5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ5.Text); + + globeControl1.Globe.Action = EnumAction3D.SelectObject; + } + /// + /// 平移对象 + /// + /// + /// + private void buttonItemBJ6_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ6.Text); + + globeControl1.Globe.Action = EnumAction3D.MoveObject; + } + /// + /// 升降对象 + /// + /// + /// + private void buttonItemBJ7_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ7.Text); + + globeControl1.Globe.Action = EnumAction3D.ElevateObject; + } + /// + /// 旋转对象 + /// + /// + /// + private void buttonItemBJ8_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ8.Text); + + globeControl1.Globe.Action = EnumAction3D.RotateObject; + } + /// + /// 连接管段 + /// + /// + /// + private void buttonItemBJ9_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ9.Text); + + if (globeControl1.Globe.SelObjectCount < 2) + { + MessageBox.Show("对不起,请至少选中2个对象!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + return; + } + globeControl1.Globe.InsertJointPipeline(false); + } + /// + /// 后退 + /// + /// + /// + private void buttonItemBJ11_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemBJ11.Text); + globeControl1.Globe.UnDoEdit(); + } + /// + /// 前进 + /// + /// + /// + private void buttonItemBJ12_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemBJ12.Text); + + globeControl1.Globe.ReDoEdit(); + } + /// + /// 导出CAD + /// + /// + /// + private void buttonItemBJ10_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ10_1.Text); + + #region 导出成dxf格式 + List listVectorNames = new List(); + 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(); + #endregion + } + /// + /// 导出矢量 + /// + /// + /// + private void buttonItemBJ10_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ10_2.Text); + + List listVectorNames = new List(); + 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 buttonItemBJ13_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemBJ13.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(); + } + } + MessageBox.Show("删除成功!", "提示"); + } + else + { + MessageBox.Show("请选中要删除的模型!", "提示"); + } + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + } + + private void buttonItemHX1_1_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]; + string filePath = dlg.FileName; + string lastname = Path.GetFileName(filePath); + + 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(); + } + + } + } + } + + public struct LineStruct + { + public string layerName; + public string layerCode; + public string lineLength; + public string hxName; + } + + List lineStruct = new List(); + List featsList = new List(); + + /// + /// 红线审核 + /// + /// + /// + private void buttonItemHX2_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemHX2.Text); + redSH = true; + featsList.Clear(); + lineStruct.Clear(); + List listPipelineLayers = new List(); + + GSOLayer layer = null; + for (int i = 0; i < m_PipelineLayerNames.Count; i++) + { + layer = globeControl1.Globe.Layers.GetLayerByCaption(m_PipelineLayerNames[i]); + if (layer != null) + { + listPipelineLayers.Add(layer); + } + } + //yanxiaowei 重构 + GSOFeatures selectFeatures=new GSOFeatures(); + for (int i = 0; i < globeControl1.Globe.SelObjectCount; i++) + { + GSOFeature feature = null; + globeControl1.Globe.GetSelectObject(i, out feature, out layer); + selectFeatures.Add(feature); + } + DataTable table=new DataTable(); + + ClassGSOTool.CalculateRedLineResult(out table, redSH, selectFeatures, globeControl1, + listPipelineLayers,out lineStruct, out featsList); + + if (table.Rows.Count != 0) + AddDatagridView(table); + else + { + MessageBox.Show("没有侵入地块红线的管线数据!", "提示"); + dataGridViewX1.DataSource = null; + panelOfTable.Visible = false; + return; + } + } + + private void AddDatagridView(DataTable table) + { + dataGridViewX1.DataSource = table; + panelOfTable.Visible = true; + panelOfTable.Height = 200; + toolStripNumbers.Text = "红线审核 |共有:" + table.Rows.Count + "条"; + toolStripDropDownButton3.Visible = true; + } + /// + /// 主窗体 下方的工具条中的 导出.xls文件 按钮事件处理 + /// + /// + /// + private void toolStripDropDownButton3_Click(object sender, EventArgs e) + { + if (dataGridViewX1.Rows.Count == 0) + { + MessageBox.Show("表格内容为空!", "提示"); + return; + } + + string strSaveFile = string.Empty; + SaveFileDialog savefiledialog = new SaveFileDialog(); + savefiledialog.Filter = "Excel文件|*.xls,*.xlsx"; + savefiledialog.AddExtension = true; + savefiledialog.FileName = "红线审核"; + if (savefiledialog.ShowDialog() == DialogResult.OK) + strSaveFile = savefiledialog.FileName; + else return; + + ExpEXCEL.ExpToExcel(dataGridViewX1, strSaveFile, "红线审核", lineStruct, featsList); + MessageBox.Show("导出成功!"); + } + /// + /// 去除集合中重复的管线 + /// + /// + /// + /// + private GSOFeatures getFeaturesByFilter(GSOFeatures features, string fieldName) + { + if (features == null) + { + return null; + } + GSOFeatures featuresGet = new GSOFeatures(); + for (int i = 0; i < features.Length; i++) + { + GSOFeature featureFromFS = features[i]; + string fieldValueFromFS = featureFromFS.GetValue(fieldName).ToString().Trim(); + bool isHas = false; + for (int j = featuresGet.Length - 1; j >= 0; j--) + { + GSOFeature featureFromFSGet = featuresGet[j]; + string fieldValueFromFSGet = featureFromFSGet.GetValue(fieldName).ToString().Trim(); + if (fieldValueFromFS.Equals(fieldValueFromFSGet)) + { + isHas = true; + break; + } + } + if (isHas == false) + { + featuresGet.Add(featureFromFS.Clone()); + } + } + return featuresGet; + } + + private void sliderItem2_ValueChanged(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.sliderItem2.Text); + + globeControl1.Globe.GroundOpaque = 100 - sliderItem2.Value; + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(roadLayerName);//("180fd"); + if (layer != null) + { + layer.Opaque = 100 - sliderItem2.Value; + } + layer = globeControl2.Globe.Layers.GetLayerByCaption("180fd");//("180fd"); + if (layer != null) + { + layer.Opaque = 100 - sliderItem2.Value; + } + globeControl2.Globe.GroundOpaque = 100 - sliderItem2.Value; + + optiValue = sliderItem2.Value; + } + /// + /// 数据管理导入文件 + /// + /// + /// + private void buttonItemSJGL1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL1.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.Multiselect = true; + if (dlg.ShowDialog() == DialogResult.OK) + { + //自定义lprj文件名,从程序中复制一lprj文件。 + string filePath = dlg.FileName; + string lastname = Path.GetFileName(filePath); + + 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, 100); + + globeControl1.Refresh(); + } + } + } + + private void buttonItemHX1_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemHX1.Text); + + GSODataSource dataSpace = globeControl1.Globe.DataManager.OpenOracleDataSource(Utility.DBServer.Trim() + "/" + Utility.dbdatabase.Trim(), "", "", Utility.userID, Utility.DBPassword); + string filepath = ""; + //日志记录 + OpenFileDialog dlg = new OpenFileDialog(); + dlg.Filter = "矢量数据(*.shp)|*.shp|矢量数据(*.lgd)|*.lgd|CAD数据(*.dxf)|*.dxf|全部支持格式(*.lgd,*.shp,*.dxf)|*.lgd;*.shp;*.dxf;"; + dlg.Multiselect = true; + + #region 临时图层显示 + if (dlg.ShowDialog() == DialogResult.OK) + { + string filePath = dlg.FileName; + string lastname = Path.GetFileName(filePath); + + #region + for (int i = 0; i < dlg.FileNames.Length; i++) + { + string strDataPath = dlg.FileNames[i]; + filepath = strDataPath; + + GSOLayer layer = globeControl1.Globe.Layers.Add(strDataPath); + GSOFeatures RedFeatures = layer.GetAllFeatures(); + + 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(); + RedFeatures = features; + 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; + } + + /////////////////////////////////////////////////////////////////////////////////////////// + globeControl1.Globe.Layers.MoveTo(0, globeControl1.Globe.Layers.Count - 1); + globeControl1.Refresh(); + } + + IModelBuilder modelBuilder = new RedLineBuilder(); + + modelBuilder.batchInsert(dataSpace, redDt, RedFeatures); + + } + #endregion + + } + #endregion + } + /// + /// 定位 + /// + /// + /// + private void buttonItemLocation_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemLocation.Text); + + FrmFlyToPosition fly = new FrmFlyToPosition(globeControl1,globeControl2); + fly.Show(this); + } + /// + /// 2015-10-17演示代码 红线审核 + /// + /// + /// + private void ribbonTabItem6_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.FlyToPosition(new GSOPoint3d(120.610963, 31.188121, 50), EnumAltitudeMode.Absolute, -4, 50, 800); + globeControl1.Globe.FlyToPointSpeed = 10000000; + globeControl1.Globe.Action = EnumAction3D.SelectObject; + globeControl1.Refresh(); + + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + + //zhanshi = false; + redSH = true; + splitContainer1.Panel2Collapsed = true; + legendSG.Visible = false; + legendSC.Visible = false; + ClearGZData(); + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = true; + } + + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 基础工具 + /// + /// + /// + private void ribbonTabItem1_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + //zhanshi = false; + redSH = false; + splitContainer1.Panel2Collapsed = true; + panelOfTable.Visible = false; + legendSC.Visible = false; + legendSG.Visible = false; + ClearGZData(); + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + + + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 一键审核 + /// + /// + /// + private void ribbonTabItem11_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + //zhanshi = false; + redSH = false; + splitContainer1.Panel2Collapsed = true; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + panelOfTable.Visible = false; + legendSC.Visible = false; + legendSG.Visible = false; + ClearGZData(); + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + + + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 右屏添加冰箱数据 + /// + void AddDataToGlobeControl2() + { + + bool modelDataBool = false; + for (int i = globeControl2.Globe.Layers.Count - 1; i >= 0; i--) + { + GSOLayer layer = globeControl2.Globe.Layers[i]; + if (layer.Name.Contains("fttp:")) + { + modelDataBool = true; + break; + } + } + + if (modelDataBool == false) + { + GSOLayer ly = globeControl1.Globe.Layers.GetLayerByCaption("天地图地图"); + globeControl2.Globe.Layers.Add(ly); + } + else + { + return; + } + } + /// + /// 双屏对比 + /// + /// + /// + private void ribbonTabItem9_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent += new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent += new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + panelOfTable.Visible = false; + + splitContainer1.Panel2Collapsed = false; + //zhanshi = true; + redSH = false; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + sliderItem2.Value = 100 - globeControl1.Globe.GroundOpaque; + globeControl2.Globe.GroundOpaque = globeControl1.Globe.GroundOpaque; + legendSC.Visible = true; + legendSG.Visible = true; + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + AddDataToGlobeControl2(); + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 文档管理 + /// + /// + /// + private void ribbonTabItem4_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + panelOfTable.Visible = false; + //zhanshi = false; + redSH = false; + splitContainer1.Panel2Collapsed = true; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + legendSC.Visible = false; + legendSG.Visible = false; + ClearGZData(); + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 基础管理 + /// + /// + /// + private void ribbonTabItem14_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + panelOfTable.Visible = false; + //zhanshi = false; + redSH = false; + splitContainer1.Panel2Collapsed = true; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + legendSC.Visible = false; + legendSG.Visible = false; + ClearGZData(); + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 权限管理 + /// + /// + /// + private void ribbonTabItem2_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + panelOfTable.Visible = false; + //zhanshi = false; + redSH = false; + splitContainer1.Panel2Collapsed = true; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + legendSC.Visible = false; + legendSG.Visible = false; + ClearGZData(); + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + GSOFeature dpFeatuer = null; + /// + /// 双屏分析,点击管段分析 + /// + /// + /// + private void buttonItem8_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItem8.Text); + + //FrmCompareFeature frmCompareFeature = new FrmCompareFeature(globeControl1, globeControl2, layerTemp, layerTemp2,m_PipelineLayerNames,sgPipeLayersNames); + int width = this.Width; + FrmCompareFeature.ShowForm(globeControl1, globeControl2, layerTemp, layerTemp2, m_PipelineLayerNames, sgPipeLayersNames,width); + //frmCompareFeature.Location = new Point((this.Width - frmCompareFeature.Width)/2,50); + //frmCompareFeature.Show(this); + + } + /// + /// 红线审核导出图片 + /// + /// + /// + private void buttonItemDCTP_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemDCTP.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))); + */ + int mapWidth = 0; + int mapHeight = 0; + Point pt = getUpperLeftPoint(pt1, pt2, out mapWidth, out mapHeight); + int rightBottomX = pt.X + mapWidth; + int rightBottomY = pt.Y + mapHeight; + Image myImg = new Bitmap(mapWidth, mapHeight); + Graphics g = Graphics.FromImage(myImg); + g.CopyFromScreen(pt, new Point(0, 0), new Size(rightBottomX, rightBottomY)); + + 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; + } + } + } + /// + /// 标识器全区域统计 + /// + /// + /// + private void 标识器分类统计ToolStripMenuItem_Click(object sender, EventArgs e) + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + FrmBSQStatis bsqStatis = new FrmBSQStatis(); + bsqStatis.Show(this); + } + /// + /// 标识器绘制区域统计 + /// + /// + /// + private void 标识器分类统计ToolStripMenuItem1_Click(object sender, EventArgs e) + { + trackflag = "BSQDuoBianXiangStatis"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + } + + #region 保存和加载审核库加载的图层 + /* + private void saveLayerList(TreeNodeCollection treeNodeList) + { + string configPath = Application.StartupPath + "\\configLayerList.xml"; + try + { + XmlDocument doc = new XmlDocument(); + doc.Load(configPath); + XmlNode dbParams = doc.SelectSingleNode("Params/dbparams"); + XmlNode dbLayers = doc.SelectSingleNode("Params/dblayers"); + XmlNode layers = doc.SelectSingleNode("Params/layers"); + dbParams.RemoveAll(); + dbLayers.RemoveAll(); + layers.RemoveAll(); + + List listDS = new List(); + String shDatasourceName = Utility.sgdbip + "/" + Utility.sgdbname + "_" + Utility.sgdbuser; + bool flag = false; + + for (int i = 0; i < globeControl1.Globe.DataManager.DataSourceCount; i++) + { + GSODataSource ds = globeControl1.Globe.DataManager.GetDataSourceAt(i); + if (ds != null && ds.Type == EnumDataSourceType.SqlServer || ds.Type == EnumDataSourceType.Oracle) + { + if (ds.Name == shDatasourceName) + { + //防止因为多次连接同一个数据库 + if (flag == true) + { + break; + } + flag = true; + listDS.Add(ds); + GSODataSourceCnn conn = ds.GetConnectionInfo(); + + XmlElement dbparam = doc.CreateElement("shdbparam"); + XmlElement ip = doc.CreateElement("ship"); + ip.InnerText = conn.Server; + + XmlElement dbname = doc.CreateElement("shdbname"); + dbname.InnerText = conn.Database; + + XmlElement username = doc.CreateElement("shusername"); + username.InnerText = conn.User; + + XmlElement password = doc.CreateElement("shpassword"); + password.InnerText = conn.Password; + + XmlElement type = doc.CreateElement("shtype"); + if (ds.Type == EnumDataSourceType.SqlServer) + { + type.InnerText = "sqlserver"; + } + else + { + type.InnerText = "oracle"; + } + + dbparam.AppendChild(ip); + dbparam.AppendChild(dbname); + dbparam.AppendChild(username); + dbparam.AppendChild(password); + dbparam.AppendChild(type); + dbParams.AppendChild(dbparam); + } + + } + } + + for (int i = 0; i < treeNodeList.Count; i++) + { + GSOLayer layer = treeNodeList[i].Tag as GSOLayer; + if (Path.GetExtension(layer.Name) == "") + { + XmlElement dbLayer = doc.CreateElement("dblayer"); + XmlAttribute attri = doc.CreateAttribute("dbindex"); + for (int j = 0; j < listDS.Count; j++) + { + if (layer.Dataset.DataSource.Name == listDS[j].Name) + { + attri.Value = j.ToString(); + break; + } + } + dbLayer.Attributes.Append(attri); + dbLayer.InnerText = layer.Name; + + dbLayers.AppendChild(dbLayer); + } + else + { + XmlElement dbLayer = doc.CreateElement("layer"); + dbLayer.InnerText = layer.Name; + layers.AppendChild(dbLayer); + } + } + + doc.Save(configPath); + } + catch (Exception e) + { + + } + } + + private void openLayerList() + { + layerManagerNode.Nodes.Clear(); + + string configPath = Application.StartupPath + "\\configLayerList.xml"; + try + { + XmlDocument doc = new XmlDocument(); + doc.Load(configPath); + XmlNode dbParams = doc.SelectSingleNode("Params/dbparams"); + XmlNode dbLayers = doc.SelectSingleNode("Params/dblayers"); + XmlNode layers = doc.SelectSingleNode("Params/layers"); + + List listDS = new List(); + for (int i = 0; i < dbParams.ChildNodes.Count; i++) + { + string ip = ""; + string dbname = ""; + string username = ""; + string password = ""; + string type = ""; + XmlNode node = dbParams.ChildNodes.Item(i); + for (int j = 0; j < node.ChildNodes.Count; j++) + { + XmlNode nodeChild = node.ChildNodes.Item(j); + + if (nodeChild != null && nodeChild.Name == "ship") + { + ip = nodeChild.InnerText; + } + else if (nodeChild != null && nodeChild.Name == "shdbname") + { + dbname = nodeChild.InnerText; + } + else if (nodeChild != null && nodeChild.Name == "shusername") + { + username = nodeChild.InnerText; + } + else if (nodeChild != null && nodeChild.Name == "shpassword") + { + password = nodeChild.InnerText; + } + else if (nodeChild != null && nodeChild.Name == "shtype") + { + type = nodeChild.InnerText; + } + } + + if (type == "sqlserver") + { + GSODataSource ds = globeControl1.Globe.DataManager.OpenSqlServerDataSource(ip, "", dbname, username, password); + listDS.Add(ds); + } + else if (type == "oracle") + { + GSODataSource ds = globeControl1.Globe.DataManager.OpenOracleDataSource(ip + "/" + dbname, "", "", username, password); + listDS.Add(ds); + } + } + + for (int i = 0; i < dbLayers.ChildNodes.Count; i++) + { + XmlNode node = dbLayers.ChildNodes.Item(i); + if (node != null) + { + string layerName = node.InnerText; + XmlAttribute attri = node.Attributes["dbindex"]; + if (attri != null) + { + int dbIndex = -1; + if (int.TryParse(attri.Value, out dbIndex)) + { + GSODataset dataset = listDS[dbIndex].GetDatasetByName(layerName); + globeControl1.Globe.Layers.Add(dataset); + //更新树节点 + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + TreeNode layerNode = new TreeNode(); + layerNode.Tag = layer; + layerNode.Text = layer.Dataset.Caption; + layerNode.ImageIndex = 0; + layerNode.SelectedImageIndex = 0; + layerNode.Checked = layer.Visible; + layerManagerNode.Nodes.Insert(0, layerNode); + // layerManagerNode.Expand(); + + + } + } + } + } + for (int i = 0; i < layers.ChildNodes.Count; i++) + { + XmlNode node = layers.ChildNodes.Item(i); + if (node != null) + { + string layerName = node.InnerText; + globeControl1.Globe.Layers.Add(layerName); + + //更新树节点 + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + TreeNode layerNode = new TreeNode(); + layerNode.Tag = layer; + layerNode.Text = layer.Dataset.Caption; + layerNode.ImageIndex = 0; + layerNode.SelectedImageIndex = 0; + layerNode.Checked = layer.Visible; + layerManagerNode.Nodes.Insert(0, layerNode); + } + } + layerManagerNode.Expand(); + } + catch (Exception e) + { + + } + } + * */ + #endregion + + private void btn_check_history_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_check_history.Text); + + if (FrmCheckHistory.isOpen == true) + { + return; + } + FrmCheckHistory frm = new FrmCheckHistory(globeControl1, globeControl2); + frm.addNode += new AddNodeToLayerManagerNode(addNodeToLayerManagerNode); + frm.Show(); + + } + + private void buttonItem查看数据_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItem查看数据.Text); + + FrmThreeOracle tr = new FrmThreeOracle(globeControl1); + + if (tr.ShowDialog() == DialogResult.OK) + { + addNodeToLayerManagerNode(tr.rukuLayer); + globeControl1.Refresh(); + } + } + /// + /// 规划数据入库 + /// + /// + /// + private void buttonItemGHRK_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemGHRK.Text); + + FrmGHRK ghrk = new FrmGHRK(globeControl1, layerManagerNode); + ghrk.Show(this); + } + + private void btn_user_info_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_user_info.Text); + + if (!FrmSysUserInfoManger.IS_OPEN) + { + FrmSysUserInfoManger frm = new FrmSysUserInfoManger(); + frm.ShowDialog(); + } + } + + private void btn_role_info_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_role_info.Text); + + if (FrmRoleInfoManager.IS_OPEN) + { + return; + } + FrmRoleInfoManager frm = new FrmRoleInfoManager(); + frm.ShowDialog(); + } + + private void btn_resc_info_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_resc_info.Text); + + if (!SysRescInfoManager.IS_OPEN) + { + SysRescInfoManager frm = new SysRescInfoManager(); + frm.ShowDialog(); + } + } + + private void btn_role_resc_Click(object sender, EventArgs e) + { + + LogManager.saveLog(Utility.userName, this.btn_role_resc.Text); + + if (!FrmRoleRescManager.IS_OPEN) + { + FrmRoleRescManager frm = new FrmRoleRescManager(); + frm.ShowDialog(); + } + } + + private void btn_user_role_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_user_role.Text); + + if (FrmUserRole.IS_OPEN) + { + return; + } + FrmUserRole frm = new FrmUserRole(); + frm.ShowDialog(); + } + + private void btn_document_info_Click(object sender, EventArgs e) + { + + LogManager.saveLog(Utility.userName, this.btn_document_info.Text); + + //if (FormDocumentManager.IS_OPEN) + //{ + // return; + //} + //FormDocumentManager frm = new FormDocumentManager(); + //frm.ShowDialog(); + + //if (FormDocumentManager.IS_OPEN) + //{ + // return; + //} + //new FormDocumentManager().ShowDialog(); + if (FormDocumentManager.IS_OPEN) + { + return; + } + this.Cursor = Cursors.WaitCursor; + FormDocumentManager frm = new FormDocumentManager(); + frm.changeCursor += new ChangeCursor(changeCursorToDefault); + frm.ShowDialog(); + + } + + private void changeCursorToDefault() + { + this.Cursor = Cursors.Default; + } + + /// + /// 判断CAD文件是否有投影信息 + /// + /// + /// + Boolean CheckDatasetGeoReference(GSODataset dataset) + { + Boolean bSuccess = false; + if (dataset.GeoReferenceType == EnumGeoReferenceType.Flat) + { + if (MessageBox.Show("数据没有空间参考信息,请设置空间参考信息!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation) == DialogResult.OK) + { + String strPath = Path.GetDirectoryName(Application.ExecutablePath) + "\\Coordinate Systems"; + OpenFileDialog dlg = new OpenFileDialog(); + + dlg.InitialDirectory = strPath; + dlg.RestoreDirectory = true; + + dlg.Filter = "投影文件|*.prj||"; + if (dlg.ShowDialog() == DialogResult.OK) + { + bSuccess = dataset.LoadProjectionFromESRIFile(dlg.FileName); + } + } + } + else + { + return true; + } + return bSuccess; + } + + private void buttonItemexp_CAD_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemexp_CAD.Text); + + OpenFileDialog dlg = new OpenFileDialog(); + dlg.Filter = "支持格式(*.dwg)|*.dwg"; + dlg.Multiselect = true; + if (dlg.ShowDialog() == DialogResult.OK) + { + for (int i = 0; i < dlg.FileNames.Length; i++) + { + //this.Cursor = Cursors.WaitCursor; + string strDataPath = dlg.FileNames[i]; + + #region + //string strDataPathPrj = strDataPath.ToLower().Replace(".dwg", ".lprj"); + + //if (File.Exists(strDataPathPrj) == false) + //{ + // if (MessageBox.Show("数据没有空间参考信息,请设置空间参考信息!", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation) == DialogResult.OK) + // { + // String strPath = Application.StartupPath + "\\Coordinate Systems"; + // OpenFileDialog dlgPrj = new OpenFileDialog(); + // dlgPrj.InitialDirectory = strPath; + // dlgPrj.RestoreDirectory = true; + // dlgPrj.Multiselect = false; + // dlg.Filter = "投影文件|*.prj"; + // if (dlg.ShowDialog() == DialogResult.OK) + // { + // this.Cursor = Cursors.WaitCursor; + // string proj4 = GSODataEngineUtility.ConvertEsriPrjFileToProj4(dlg.FileName); + // using (StreamWriter stream = new StreamWriter(strDataPathPrj, false)) + // { + // stream.WriteLine("0prj4" + proj4 + ""); + // } + // AddLayerData(strDataPath); + // //globeControl1.Globe.Layers.Add(strDataPath); + + // this.Cursor = Cursors.Default; + // } + // else + // { + // AddLayerData(strDataPath); + // //globeControl1.Globe.Layers.Add(strDataPath); + // } + // } + // else + // { + // AddLayerData(strDataPath); + // //globeControl1.Globe.Layers.Add(strDataPath); + // } + + //} + //else + //{ + // //globeControl1.Globe.Layers.Add(strDataPath); + // AddLayerData(strDataPath); + //} + #endregion + AddLayerData(strDataPath); + //this.Cursor = Cursors.Default; + } + } + + 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, 100); + + globeControl1.Refresh(); + } + } + + private void btn_password_edit_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_password_edit.Text); + + if (FrmChangePassword.IS_OPEN) + { + return; + } + FrmChangePassword frm = new FrmChangePassword(); + frm.ShowDialog(); + } + /// + /// 多孔管线入库 + /// + /// + /// + private void buttonItem9_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL4_2.Text); + + if (ds == null) + { + MessageBox.Show("请先连接数据库", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + ConnectDB(null, null); + } + if (ds == null) + return; + + FrmMultiPipelineModelDB frm = new FrmMultiPipelineModelDB(globeControl1, ds); + if (frm.ShowDialog() == DialogResult.OK) + { + addNodeToLayerManagerNode(frm.rukuLayer); + } + //frm.Show(); + } + private void 导出CADToolStripMenuItem1_Click(object sender, EventArgs e) + { + TreeNode node = layerNodeContexMenu.Tag as TreeNode; + if (node == null) + { + MessageBox.Show("请在左侧节点集中选择要导出的图层", "提示"); + return; + } + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(node.Text.Trim()); + if (layer == null || layer.GetAllFeatures().Length <= 0) + { + MessageBox.Show("要导出的图层为空", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + return; + } + string strProjectName = Utility.projectStr; + if (strProjectName != "") + { + SaveFileDialog dlg = new SaveFileDialog(); + dlg.Filter = "*.dwg|*.dwg|*.dxf|*.dxf"; + dlg.FileName = layer.Caption; + if (dlg.ShowDialog(this) == DialogResult.OK) + { + globeControl1.Globe.MemoryLayer.SaveAs(dlg.FileName); + GSOLayer newlayer = globeControl1.Globe.Layers.Add(dlg.FileName); + newlayer.RemoveAllFeature(); + int featureCount = layer.GetAllFeatures().Length; + for (int i = 0; i < featureCount; i++) + { + GSOFeature feature = layer.GetAt(i); + if (feature != null && feature.Geometry != null) + { + if (feature.Geometry.Type == EnumGeometryType.GeoPolyline3D) + { + feature.Geometry.Style = new GSOSimpleLineStyle3D(); + } + else if (feature.Geometry.Type == EnumGeometryType.GeoPolygon3D) + { + feature.Geometry.Style = new GSOSimplePolygonStyle3D(); + } + newlayer.AddFeature(feature); + } + } + newlayer.Save(); + newlayer.Dataset.DataSource.RemoveDataset(newlayer.Dataset); + globeControl1.Globe.Layers.Remove(newlayer); + MessageBox.Show("导出CAD完成!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + } + } + } + + private void buttonItemGBJC_Click(object sender, EventArgs e) + { + FrmGBJC gb = new FrmGBJC(globeControl1, globeControl2, layerTemp, layerTemp2); + gb.Show(this); + } + + #region 右屏管纵数据控制 + private void 五十米主干道ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = true; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + + private void 三十六米次干道ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = true; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + + private void 四十二米次干道ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = true; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + + private void 二十四米一块板ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = true; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + + private void 二十四米三块板ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = true; + } + + private void 二十四米停车带ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = true; + lendendGZ24_3.Visible = false; + } + + private void 二十六米大堤路ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = true; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + + private void 清除管纵数据ToolStripMenuItem_Click(object sender, EventArgs e) + { + ClearGZData(); + } + + private void ClearGZData() + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + #endregion + + private void buttonItemPasswordReset_Click(object sender, EventArgs e) + { + Frm_password_reset reset = new Frm_password_reset(); + reset.Show(); + } + + private void pictureBox1_Paint(object sender, PaintEventArgs e) + { + int Width = this.Width; + string welcomeUser = "欢迎您:" + Utility.userName; + Graphics g = e.Graphics; + g.DrawString(welcomeUser, new Font("宋体", 12), new SolidBrush(Color.Black), Width - 180, 50); + } + + } +} \ No newline at end of file diff --git a/MainFrm.cs.LOCAL.9016.cs b/MainFrm.cs.LOCAL.9016.cs new file mode 100644 index 0000000..0b7e393 --- /dev/null +++ b/MainFrm.cs.LOCAL.9016.cs @@ -0,0 +1,13060 @@ +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; + + GSOBalloon featureTooltip2; + GSOBalloonEx balloonEx2; + + GSOLayer layerTemp; + GSOLayer layerTemp2; + FrmShResult frmShResult = null; + FrmRedlineResult frmredResult = null; + FrmMnModify frmModify = null; + public bool frmRedlineResult = false; + public bool boolfrmShResult = false; + public bool boolfrmModify = false; + + List m_PipelineLayerNames = new List();//线图层名称 + List workwellLayerNames = new List();//工井图层名称 + List valueLayerNames = new List();//阀门图层名称 + List instrumenLayerNames = new List();//附属物图层名称 + List pipefittingLayerNames = new List();//管件图层名称 + List sgPipeLayersNames = new List();//施工管线图层名称 + 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 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; + public string redLayer = null; + //GSOLayer redLayer1 = null; + bool redSH = false; + string redDt = "红线"; + //双屏对比 + //bool zhanshi=false; + Thread t = null; + private GSOHudButton legendSC;//定义图例 + private GSOHudButton legendSG;//定义图例 + //管纵图 + private GSOHudButton lendendGZ50; + private GSOHudButton lendendGZ36; + private GSOHudButton lendendGZ42; + private GSOHudButton lendendGZ24_1; + private GSOHudButton lendendGZ24_2; + private GSOHudButton lendendGZ24_3; + private GSOHudButton lendendGZ26; + + GSOGeoPoint3D bsqPT; + + FrmYJSHTC frmSh = null;//一键审核窗口全局变量wxl + FrmWait frmWait = null;//一键审核等待窗口 + //FrmWait frmWait2 = null;//文档操作等待窗口 + + float mouseDownX1,mouseDownY1; + float mouseDownX2,mouseDownY2; + /// + /// + /// + 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; + + featureTooltip2 = new GSOBalloon(globeControl2.Handle); + balloonEx2 = new GSOBalloonEx(globeControl2.Handle); + Utility.SetBallons(featureTooltip, balloonEx); + + panelOfTable.Height = 200; + + RigthMenuSet(); + + MenuSet(); + + } + /// + /// 右屏中添加管纵图片 + /// + private void AddGZ() + { + + lendendGZ50 = new GSOHudButton(); + lendendGZ50.SetImage(Application.StartupPath + "/Resource/管纵/50.png"); + lendendGZ50.SetOffset(0, 0); + lendendGZ50.MinOpaque = 1; + lendendGZ50.MaxOpaque = 1; + lendendGZ50.FadeOut = false; + lendendGZ50.Name = "lendendGZ50"; + lendendGZ50.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ50); + lendendGZ50.Visible = false; + + lendendGZ36 = new GSOHudButton(); + lendendGZ36.SetImage(Application.StartupPath + "/Resource/管纵/36.png"); + lendendGZ36.SetOffset(0, 0); + lendendGZ36.MinOpaque = 1; + lendendGZ36.MaxOpaque = 1; + lendendGZ36.FadeOut = false; + lendendGZ36.Name = "lendendGZ36"; + lendendGZ36.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ36); + lendendGZ36.Visible = false; + + lendendGZ42 = new GSOHudButton(); + lendendGZ42.SetImage(Application.StartupPath + "/Resource/管纵/42.png"); + lendendGZ42.SetOffset(0, 0); + lendendGZ42.MinOpaque = 1; + lendendGZ42.MaxOpaque = 1; + lendendGZ42.FadeOut = false; + lendendGZ42.Name = "lendendGZ42"; + lendendGZ42.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ42); + lendendGZ42.Visible = false; + + lendendGZ24_1 = new GSOHudButton(); + lendendGZ24_1.SetImage(Application.StartupPath + "/Resource/管纵/24_1.png"); + lendendGZ24_1.SetOffset(0, 0); + lendendGZ24_1.MinOpaque = 1; + lendendGZ24_1.MaxOpaque = 1; + lendendGZ24_1.FadeOut = false; + lendendGZ24_1.Name = "lendendGZ24_1"; + lendendGZ24_1.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ24_1); + lendendGZ24_1.Visible = false; + + lendendGZ24_2 = new GSOHudButton(); + lendendGZ24_2.SetImage(Application.StartupPath + "/Resource/管纵/24_2.png"); + lendendGZ24_2.SetOffset(0, 0); + lendendGZ24_2.MinOpaque = 1; + lendendGZ24_2.MaxOpaque = 1; + lendendGZ24_2.FadeOut = false; + lendendGZ24_2.Name = "lendendGZ24_2"; + lendendGZ24_2.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ24_2); + lendendGZ24_2.Visible = false; + + lendendGZ24_3 = new GSOHudButton(); + lendendGZ24_3.SetImage(Application.StartupPath + "/Resource/管纵/24_3.png"); + lendendGZ24_3.SetOffset(0, 0); + lendendGZ24_3.MinOpaque = 1; + lendendGZ24_3.MaxOpaque = 1; + lendendGZ24_3.FadeOut = false; + lendendGZ24_3.Name = "lendendGZ24_3"; + lendendGZ24_3.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ24_3); + lendendGZ24_3.Visible = false; + + lendendGZ26 = new GSOHudButton(); + lendendGZ26.SetImage(Application.StartupPath + "/Resource/管纵/26.png"); + lendendGZ26.SetOffset(0, 0); + lendendGZ26.MinOpaque = 1; + lendendGZ26.MaxOpaque = 1; + lendendGZ26.FadeOut = false; + lendendGZ26.Name = "lendendGZ26"; + lendendGZ26.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ26); + lendendGZ26.Visible = false; + + } + + public void RigthMenuSet() + { + if (Utility.userRole.IndexOf("清除分析") < 0) + { + toolRightMenu.Items.Remove(清除分析ToolStripMenuItem); + } + + #region 区域分析 + if (Utility.userRole.IndexOf("区域分析") < 0) + { + toolRightMenu.Items.Remove(区域分析ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("缓冲区分析") < 0) + { + 区域分析ToolStripMenuItem.DropDownItems.Remove(缓冲区分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("附属物分析") < 0) + { + 区域分析ToolStripMenuItem.DropDownItems.Remove(附属物分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("无源淹没分析") < 0) + { + 区域分析ToolStripMenuItem.DropDownItems.Remove(无源淹没分析ToolStripMenuItem); + } + } + #endregion + + #region 视域分析 + if (Utility.userRole.IndexOf("视域分析") < 0) + { + toolRightMenu.Items.Remove(视域分析ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("通视分析") < 0) + { + 视域分析ToolStripMenuItem.DropDownItems.Remove(通视分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("可视域分析") < 0) + { + 视域分析ToolStripMenuItem.DropDownItems.Remove(可视域分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("可视包络分析") < 0) + { + 视域分析ToolStripMenuItem.DropDownItems.Remove(可视包络分析ToolStripMenuItem); + } + } + #endregion + + #region 开发分析 + if (Utility.userRole.IndexOf("开挖分析") < 0) + { + toolRightMenu.Items.Remove(开挖分析ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("多边形开挖") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(多边形开挖ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("挖方量分析") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(挖方量分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("沿线开挖") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(沿线开挖ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("创建隧道") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(创建隧道ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("隐藏隧道") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(隐藏隧道ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("删除隧道") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(删除隧道ToolStripMenuItem); + } + } + #endregion + + #region 拓扑分析 + if (Utility.userRole.IndexOf("拓扑分析") < 0) + { + toolRightMenu.Items.Remove(拓扑分析ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("创建拓扑") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(创建拓扑ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("上游分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(上游分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("下游分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(下游分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("流向分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(流向分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("关阀分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(关阀分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("连通分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(连通分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("爆管分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(爆管分析ToolStripMenuItem); + } + } + #endregion + + #region 断面分析 + if (Utility.userRole.IndexOf("断面分析") < 0) + { + toolRightMenu.Items.Remove(断面分析ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("横断面分析") < 0) + { + 断面分析ToolStripMenuItem.DropDownItems.Remove(横断面分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("纵断面分析") < 0) + { + 断面分析ToolStripMenuItem.DropDownItems.Remove(纵断面分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("道路断面分析") < 0) + { + 断面分析ToolStripMenuItem.DropDownItems.Remove(道路断面分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("基线剖面分析") < 0) + { + 断面分析ToolStripMenuItem.DropDownItems.Remove(基线剖面分析ToolStripMenuItem); + } + } + #endregion + + #region 绘制区域统计 + if (Utility.userRole.IndexOf("绘制区域统计") < 0) + { + toolRightMenu.Items.Remove(绘制区域统计ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("绘制区域管线长度统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管线长度统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域阀门数量统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(阀门数量统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域井盖数量统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(井盖数量统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域管径分段统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管径分段统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域埋深分段统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(埋深分段统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域管径分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管径分类统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域材质分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(材质分类统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域附属物分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(附属物分类统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域标识器分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(标识器分类统计ToolStripMenuItem1); + } + + } + #endregion + + #region 全区域统计 + if (Utility.userRole.IndexOf("全区域统计") < 0) + { + toolRightMenu.Items.Remove(全区域统计ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("全区域管线长度统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管线长度统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域阀门数量统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(阀门数量统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域井盖数量统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(井盖数量统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域管径分段统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管径分段统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域埋深分段统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(埋深分段统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域管径分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管径分类统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域材质分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(材质分类统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域附属物分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(附属物分类统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域标识器分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(标识器分类统计ToolStripMenuItem); + } + + } + #endregion + + #region 查询 + if (Utility.userRole.IndexOf("查询") < 0) + { + toolRightMenu.Items.Remove(查询ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("空间查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(空间查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("编号查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(编号查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("坐标查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(坐标查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("管径查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(管径查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("材质查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(材质查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("基本查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(基本查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("复合查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(复合查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("关联查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(关联查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("关键字查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(关键字查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("附属物查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(附属物查询ToolStripMenuItem); + } + } + #endregion + + #region 标注 + if (Utility.userRole.IndexOf("标注") < 0) + { + toolRightMenu.Items.Remove(标注ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("标高标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(标高标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("管径标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(管径标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("埋深标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(埋深标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("坐标标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(坐标标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("距离标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(距离标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("自定义标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(自定义标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("扯旗标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(扯旗标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("坡度标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(坡度标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("属性标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(属性标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("标注管理") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(标注管理ToolStripMenuItem); + } + } + #endregion + + #region 飞行 + if (Utility.userRole.IndexOf("飞行") < 0) + { + toolRightMenu.Items.Remove(飞行ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("自定义飞行") < 0) + { + 飞行ToolStripMenuItem.DropDownItems.Remove(自定义飞行ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("飞行到目标点") < 0) + { + 飞行ToolStripMenuItem.DropDownItems.Remove(飞行到目标点ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("绕中心点飞行") < 0) + { + 飞行ToolStripMenuItem.DropDownItems.Remove(绕中心点飞行ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("绕眼睛飞行") < 0) + { + 飞行ToolStripMenuItem.DropDownItems.Remove(绕眼睛飞行ToolStripMenuItem); + } + } + #endregion + + #region 编辑 + if (Utility.userRole.IndexOf("编辑") < 0) + { + toolRightMenu.Items.Remove(编辑ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("平移对象") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(平移对象ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("升降对象") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(升降对象ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("旋转对象") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(旋转对象ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("连接管段") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(连接管段ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("导出文件") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(导出文件ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("前进") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(前进ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("后退") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(删除模型ToolStripMenuItem); + } + } + #endregion + + #region 量算 + if (Utility.userRole.IndexOf("量算") < 0) + { + toolRightMenu.Items.Remove(量算ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("水平距离") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(水平距离ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("垂直距离") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(垂直距离ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("空间距离") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(空间距离ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("地表距离") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(地表距离ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("高度量算") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(高度量算ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("水平面积") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(水平面积ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("地表面积") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(地表面积ToolStripMenuItem1); + } + } + #endregion + } + + public void MenuSet() + { + + #region 权限管理 + if (Utility.userRole.IndexOf("权限管理") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem2); + } + else + { + + if (Utility.userRole.IndexOf("用户管理") < 0) + { + btn_user_info.Visible = false; + } + if (Utility.userRole.IndexOf("角色管理") < 0) + { + btn_role_info.Visible = false; + } + if (Utility.userRole.IndexOf("资源管理") < 0) + { + btn_resc_info.Visible = false; + } + if (Utility.userRole.IndexOf("角色授权") < 0) + { + btn_role_resc.Visible = false; + } + if (Utility.userRole.IndexOf("用户授权") < 0) + { + btn_user_role.Visible = false; + } + if (Utility.userRole.IndexOf("密码修改") < 0) + { + btn_password_edit.Visible = false; + } + + } + #endregion + + #region 基础工具 + if (Utility.userRole.IndexOf("基础工具") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem1); + } + else + { + if (Utility.userRole.IndexOf("地上模式") < 0) + { + buttonItem87.Visible = false; + } + if (Utility.userRole.IndexOf("地下模式") < 0) + { + buttonItem88.Visible = false; + } + if (Utility.userRole.IndexOf("行走模式") < 0) + { + buttonItem27.Visible = false; + } + if (Utility.userRole.IndexOf("透明度设置") < 0) + { + sliderGroundTransSet1.Visible = false; + } + if (Utility.userRole.IndexOf("快速定位") < 0) + { + buttonItem91.Visible = false; + } + if (Utility.userRole.IndexOf("图层管理") < 0) + { + buttonItem1.Visible = false; + } + if (Utility.userRole.IndexOf("图例管理") < 0) + { + btnlegendSet.Visible = false; + } + if (Utility.userRole.IndexOf("全屏显示") < 0) + { + buttonItem89.Visible = false; + } + if (Utility.userRole.IndexOf("导出图片") < 0) + { + btnOutputJPG.Visible = false; + } + + } + #endregion + + #region 一键审核 + if (Utility.userRole.IndexOf("一键审核") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem11); + } + #endregion + + #region 红线审核 + if (Utility.userRole.IndexOf("红线审核") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem6); + } + #endregion + + #region 双屏对比 + if (Utility.userRole.IndexOf("双屏对比") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem9); + } + #endregion + + #region 文档管理 + if (Utility.userRole.IndexOf("文档管理") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem4); + } + #endregion + + #region 基础管理 + if (Utility.userRole.IndexOf("基础管理") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem14); + } + else + { + if (Utility.userRole.IndexOf("专题图审批") < 0) + { + buttonItemZTT3_2.Visible = false; + } + if (Utility.userRole.IndexOf("打印审批") < 0) + { + buttonItemZTT4_2.Visible = false; + } + if (Utility.userRole.IndexOf("拷贝审批") < 0) + { + buttonItemZTT5_2.Visible = false; + } + } + + #endregion + + if (ribbonControl1.Items.Count <= 0) + { + ribbonControl1.Visible = false; + } + } + + #region Fan Zhang 重构现有代码 + //初始化控件布局 + private void initLayout() + { + 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.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.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.labelX21.Width = (int)(this.labelX21.Width * myScreen); + this.labelX22.Width = (int)(this.labelX22.Width * myScreen); + this.labelX24.Width = (int)(this.labelX24.Width * myScreen); + } + sideBar1.Visible = false; + 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]); + } + + splitContainer1.Panel2Collapsed = true; + + buttonItem87.Checked = true;//默认地上模式 + ribbonTabItem1.Select(); //初始化状态为浏览 + + sideBarPanelItem3.Visible = false; + layerTree.Visible = false; + controlContainerItem3.Visible = false; + if (sideBarPanelItem4.Visible == true) + { + sideBar1.Visible = true; + controlContainerItem5.Visible = true; + } + else + { + sideBar1.Visible = false; + } + Refresh(); + sliderGroundTransSet1.Value = optiValue; + sliderItem1.Value = optiValue; + sliderItem2.Value = optiValue; + sliderItem3.Value = optiValue; + + } + + //初始化地球控件 + private void initGlobalControl() + { + //选择 + btnToolSelect = new GSOHudButton(); + btnToolSelect.SetImage(Application.StartupPath + "\\Resource\\image\\select1.png"); + btnToolSelect.FadeOut = false; + btnToolSelect.Align = EnumAlign.TopLeft; + btnToolSelect.SetOffset(20, 50); + btnToolSelect.Name = "1"; + btnToolSelect.HeightFixed = true; + btnToolSelect.WidthFixed = true; + globeControl1.Globe.AddHudControl(btnToolSelect); + globeControl2.Globe.AddHudControl(btnToolSelect); + + //浏览 + 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); + + //图例 + legend = new GSOHudButton(); + legend.SetImage(Application.StartupPath + "/Resource/图例P.jpg");//图例P + legend.SetOffset(0, 15); + legend.MinOpaque = 1; + legend.MaxOpaque = 1; + legend.FadeOut = false; + legend.Name = "legend"; + legend.Align = EnumAlign.BottomRight; + legend.Visible = false; + globeControl1.Globe.AddHudControl(legend); + + //实测 + legendSC = new GSOHudButton(); + legendSC.SetImage(Application.StartupPath + "/Resource/sc.jpg"); + legendSC.SetOffset(0, 15); + legendSC.MinOpaque = 1; + legendSC.MaxOpaque = 1; + legendSC.FadeOut = false; + legendSC.Name = "legendSC"; + legendSC.Align = EnumAlign.BottomRight; + globeControl1.Globe.AddHudControl(legendSC); + legendSC.Visible = false; + + //施工 + legendSG = new GSOHudButton(); + legendSG.SetImage(Application.StartupPath + "/Resource/sg.jpg"); + legendSG.SetOffset(0, 15); + legendSG.MinOpaque = 1; + legendSG.MaxOpaque = 1; + legendSG.FadeOut = false; + legendSG.Name = "legendSG"; + legendSG.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(legendSG); + legendSG.Visible = false; + + //管纵 + AddGZ(); + + 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; + globeControl1.Globe.IsReleaseMemOutOfView = true; + globeControl1.Globe.ControlPanel.Visible = true; + + globeControl2.Globe.UnderGroundFloor.Visible = false; + globeControl2.Globe.OverviewControl.Visible = false; + globeControl2.Globe.ScalerControl.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; + globeControl2.Globe.IsReleaseMemOutOfView = true; + globeControl2.Globe.ControlPanel.Visible = false; + + 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); + + //添加临时图层 + layerTemp = globeControl1.Globe.Layers.Add(Application.StartupPath + "\\tempLgdData.lgd"); + layerTemp2 = globeControl2.Globe.Layers.Add(Application.StartupPath + "\\tempLgdData2.lgd"); + if (layerTemp != null) + { + layerTemp.MaxVisibleAltitude = 1000; + } + + //添加城市7线图层 + 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"); + + //注册对应事件 + this.registerEvent(); + } + + //注册地球事件 + private bool registerEvent() + { + if (globeControl1 == null || globeControl2 == null) + { + return false; + } + 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); + + globeControl2.FeatureMouseClickEvent += new FeatureMouseClickEventHandler(globeControl2_FeatureMouseClickEvent); + globeControl2.CameraBeginMoveEvent += new CameraBeginMoveEventHandler(globeControl2_CameraBeginMoveEvent); + + globeControl1.MouseDoubleClick += new MouseEventHandler(globeControl1_MouseDoubleClick); + globeControl1.MouseClick += new MouseEventHandler(globeControl1_MouseClick); + globeControl1.MouseDown += new MouseEventHandler(globeControl1_MouseDown); + + globeControl2.MouseClick += new MouseEventHandler(globeControl2_MouseClick); + globeControl2.MouseDown += new MouseEventHandler(globeControl2_MouseDown); + + 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); + + return true; + } + + //加载两个地球数据 + private void loadData() + { + Thread t1 = new Thread(new ThreadStart(doLoadDataForGlobalControl1)); + t1.IsBackground = true; + t1.Start(); + + + } + + delegate void LoadDataForGlobalControl(); + + private void connectServer() + { + globeControl1.Globe.ConnectServer(Utility.serverip, Utility.serverport, "", ""); //加载locaServer中的数据 + globeControl2.Globe.ConnectServer(Utility.serverip, Utility.serverport, "", ""); //加载locaServer中的数据 + //初始化TreeView + // 勾选实测图层 + foreach (TreeNode tn in layerTree.Nodes) + { + if (tn.Nodes.Count > 0) + { + if (tn.Text == "实测数据") + { + tn.Checked = true; + foreach (TreeNode tnChild in tn.Nodes) + { + tnChild.Checked = true; + foreach (TreeNode tnGrandChild in tnChild.Nodes) + { + tnGrandChild.Checked = true; + } + } + } + } + } + } + + private void doLoadDataForGlobalControl1() + { + try + { + + globeControl1.Globe.Layers.MoveDown(10000); + //加载实测管线数据 + Utility.dataSource = globeControl1.Globe.DataManager.OpenOracleDataSource(Utility.DBServer.Trim() + "/" + Utility.dbdatabase.Trim(), "", "", Utility.userID, Utility.DBPassword); + + if (Utility.dataSource != null) + { + for (int j = 0; j < Utility.dataSource.DatasetCount; j++) + { + GSODataset dataset = Utility.dataSource.GetDatasetAt(j); + if (dataset != null && dictionaryNetLayerNameAndCaption.ContainsKey(dataset.Caption)) + { + dataset.Caption = dataset.Name; + globeControl1.Globe.Layers.Add(dataset); + } + } + } + //隐藏红线图层 + globeControl1.Globe.Layers.GetLayerByCaption("红线").Visible = false; + + //globleControl1中加载规划数据 + GSODataSource ghDS = globeControl1.Globe.DataManager.OpenOracleDataSource(Utility.ghdbip + "/" + Utility.ghdbname, "", "", Utility.ghdbuser, Utility.ghdbpwd); + if (ghDS != null) + { + for (int j = 0; j < ghDS.DatasetCount; j++) + { + GSODataset dataset = ghDS.GetDatasetAt(j); + if (dataset != null && dictionaryNetLayerNameAndCaption.ContainsKey(dataset.Caption)) + { + dataset.Caption = dataset.Name; + globeControl1.Globe.Layers.Add(dataset); + globeControl1.Globe.Layers[0].Visible = false; + } + } + } + + //globeControl1,globeControl2中加载施工数据 + GSODataSource sgDS = globeControl1.Globe.DataManager.OpenOracleDataSource(Utility.sgdbip + "/" + Utility.sgdbname, "", "", Utility.sgdbuser, Utility.sgdbpwd); + if (sgDS != null) + { + for (int m = 0; m < sgDS.DatasetCount; m++) + { + GSODataset dataset = sgDS.GetDatasetAt(m); + if (dataset != null && !dataset.Caption.Contains("SH") && dictionaryNetLayerNameAndCaption.ContainsKey(dataset.Caption)) + { + dataset.Caption = dataset.Name; + globeControl1.Globe.Layers.Add(dataset); + globeControl1.Globe.Layers[0].Visible = false; + + globeControl2.Globe.Layers.Add(dataset); + globeControl2.Globe.Layers[0].Visible = true; + } + } + } + + LoadDataForGlobalControl ss = new LoadDataForGlobalControl(connectServer); + ss(); + + } + catch (Exception ex) + { + MessageBox.Show(ex.Message); + } + } + + private void initLayerTree() + { + //加载临时图层节点 + layerManagerNode = new TreeNode(); + layerManagerNode.ImageIndex = 0; + layerManagerNode.SelectedImageIndex = 0; + layerManagerNode.Checked = true; + layerManagerNode.Text = "临时图层"; + layerTree.Nodes.Add(layerManagerNode); + + XmlDocument doc = new XmlDocument(); + doc.Load(filename); + XmlNodeList xmlLayerNodes = doc.SelectNodes("//layer"); + + foreach (XmlNode xmlLayerNode in xmlLayerNodes) + { + + //TODO LIST:创建一级TreeNode(实测、规划、施工) + TreeNode nodelayer = new TreeNode(); + string layerName = xmlLayerNode.Attributes["label"].Value; + nodelayer.Text = layerName; + nodelayer.Checked = false; + layerTree.Nodes.Add(nodelayer); + + XmlNodeList xmlChildLayerNodes = xmlLayerNode.ChildNodes; + foreach (XmlNode xmlChildLayerNode in xmlChildLayerNodes) + { + //TODO LIST:创建二级TreeNode节点 + TreeNode secondLevelNode = new TreeNode(); + string layerType = xmlChildLayerNode.Attributes["label"].Value; + secondLevelNode.Text = layerType; + + if (xmlChildLayerNode.Attributes["type"] != null) + { //道路图层特殊处理 + string type = xmlChildLayerNode.Attributes["type"].Value; + secondLevelNode.Tag = type + "|" + layerType; + } + else + { + secondLevelNode.Tag = layerType; + } + secondLevelNode.Checked = false; + nodelayer.Nodes.Add(secondLevelNode); + + XmlNodeList xmlActitualLayerNodes = xmlChildLayerNode.ChildNodes; + + foreach (XmlNode xmlActitualLayerNode in xmlActitualLayerNodes) + { + //TODO LIST:创建三级图层节点 + TreeNode layerNode = new TreeNode(); + string actutallylayerType = xmlActitualLayerNode.Attributes["type"].Value; + string actutallylayerName = xmlActitualLayerNode.Attributes["layer"].Value; + string actutallyLabelName = xmlActitualLayerNode.Attributes["label"].Value; + + layerNode.Text = actutallyLabelName; + layerNode.Tag = layerType + "|" + actutallyLabelName; + layerNode.Checked = false; + secondLevelNode.Nodes.Add(layerNode); + } + + } + + } + + } + + /** + * 读取Config.xml文件,初始化以下全局Map + * m_PipelineLayerNames:管线 + * workwellLayerNames:工井 + * valueLayerNames:阀门 + * instrumenLayerNames:附属物 + * pipefittingLayerNames:特征管点 + * sgPipeLayersNames:施工管线 + **/ + private void initGlobalMap() + { + XmlDocument doc = new XmlDocument(); + doc.Load(filename); + XmlNodeList xmlLayerNodes = doc.SelectNodes("//layerchild"); + + foreach (XmlNode xmlLayerNode in xmlLayerNodes) + { + string layerType = xmlLayerNode.Attributes["type"].Value; + string layerName1 = xmlLayerNode.Attributes["layer"].Value; + string layerchildName = xmlLayerNode.Attributes["label"].Value; + + dictionaryNetLayerNameAndCaption.Add(layerName1, layerchildName); + + if (layerType != "db") + { + if (xmlLayerNode.Attributes["isRoad"] != null) + { + roadLayerName = layerchildName; + } + } + else if (xmlLayerNode.Attributes["isPipeLine"] != null) + { + m_PipelineLayerNames.Add(layerchildName); + g1layername.Add(layerName1); + } + else if (xmlLayerNode.Attributes["isWorkWell"] != null) + { + workwellLayerNames.Add(layerchildName); + g1layername.Add(layerName1); + } + else if (xmlLayerNode.Attributes["isValve"] != null) + { + valueLayerNames.Add(layerchildName); + g1layername.Add(layerName1); + } + else if (xmlLayerNode.Attributes["isAccess"] != null) + { + instrumenLayerNames.Add(layerchildName); + g1layername.Add(layerName1); + } + else if (xmlLayerNode.Attributes["isCharacter"] != null) + { + pipefittingLayerNames.Add(layerchildName); + g1layername.Add(layerName1); + } + else if (xmlLayerNode.Attributes["isSgData"] != null) + { + sgPipeLayersNames.Add(layerchildName); + g1layername.Add(layerName1); + } + + } + } + + private void initMarkerTree() + { + 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); + } + } + } + } + + private void MainFrm_Load(object sender, EventArgs e) + { + + this.initGlobalControl(); + this.initGlobalMap(); + this.initLayerTree(); + this.initMarkerTree(); + this.initLayout(); + this.loadData(); + + + double x = Convert.ToDouble(Utility.Query_Roads["绿岛"].ToString().Split(',')[0]); + double y = Convert.ToDouble(Utility.Query_Roads["绿岛"].ToString().Split(',')[1]); + double z = Convert.ToDouble(Utility.Query_Roads["绿岛"].ToString().Split(',')[2]); + jumpToCameraState(x, y, z); + + + } + + #endregion + + /// + /// 每次gis服务加载时都会触发的 + /// + /// + /// + 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 dictionaryNetLayerNameAndCaption = new Dictionary(); + 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 配置用户权限 + /// + /// 向数据库插入功能列表 + /// + private void insertControlToDatabase() + { + ArrayList listItem = new ArrayList(); + List subListItem = new List(); + 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) + { + GSOCameraState camera = globeControl2.Globe.CameraState; + globeControl1.Globe.JumpToCameraState(camera); + } + } + + void globeControl1_BeforeSceneRenderEvent(object sender, BeforeSceneRenderEventArgs e) + { + if (globeControl1.Focused) + { + 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); + } + } + } + + /// + /// 检查数据集是否有坐标系信息 + /// + /// + /// + 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 = "0prj4" + lprjStr + ""; + + bSuccess = dataset.LoadProjectionFromESRIFile(dlg.FileName); + + string lprjFileName = strDataPath.Substring(0, strDataPath.LastIndexOf(".")) + ".lprj"; + StreamWriter writer = new StreamWriter(lprjFileName, false); + writer.Write(lprjFileContent); + writer.Close(); + + } + } + } + else + { + return true; + } + return bSuccess; + } + + /// + /// 矩形拉框结束事件处理函数 + /// + /// + /// + 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))); + */ + + int mapWidth = 0; + int mapHeight = 0; + Point pt = getUpperLeftPoint(pt1, pt2, out mapWidth, out mapHeight); + int rightBottomX = pt.X + mapWidth; + int rightBottomY = pt.Y + mapHeight; + Image myImg = new Bitmap(mapWidth, mapHeight); + Graphics g = Graphics.FromImage(myImg); + g.CopyFromScreen(pt, new Point(0, 0), new Size(rightBottomX, rightBottomY)); + + 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; + } + } + /// + /// 定位正北正90度俯视 + /// + /// + /// + /// + 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; + } + } + /// + /// layerTree选中后事件处理 + /// + /// + /// + 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); + } + /// + /// 树节点选中方法 + /// + /// + 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); + } + } + } + + } + /// + /// 改变所有子节点的状态 + /// + /// + /// + 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; + LayerFlyMenuItem.Visible = true; + } + + LayerSelectableMenuItem.Visible = true; + LayerEditableMenuItem.Visible = true; + SaveLayerMenuItem.Visible = true; + LayerFlyMenuItem.Visible = true; + 导出CADToolStripMenuItem1.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]); + if (layer != null) + { + LayerSelectableMenuItem.Checked = layer.Selectable; + LayerEditableMenuItem.Checked = layer.Editable; + } + else + { + return; + } + } + 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; + } + } + } + } + } + + /// + /// 删除临时添加的本地数据图层 + /// + /// + /// + 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); + for (int i = globeControl1.Globe.Layers.Count-1; i >=0; i--) + { + if (globeControl1.Globe.Layers[i].Caption == layer.Caption) + { + globeControl1.Globe.Layers.Remove(globeControl1.Globe.Layers[i]); + } + } + + 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 定位ToolStripMenuItem_Click(object sender, EventArgs e) + { + TreeNode node = layerTree.SelectedNode; + + if (node != null) + { + if (node.Parent.Text.Trim() == "临时图层") + { + GSOLayer lsLayer = globeControl1.Globe.Layers.GetLayerByCaption(node.Text.ToString()); + double x = lsLayer.LatLonBounds.Center.X; + double y = lsLayer.LatLonBounds.Center.Y; + if (x == 0 && y == 0) + { + x = lsLayer.Bounds.Center.X; + y = lsLayer.Bounds.Center.Y; + } + + globeControl1.Globe.FlyToPosition(new GSOPoint3d(x, y, 10), EnumAltitudeMode.Absolute); + } + else + { + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(node.Tag.ToString().Split('|')[1]); + + if (layer != null) + { + if (layer.Caption == "红线") + { + globeControl1.Globe.FlyToPosition(new GSOPoint3d(120.610963, 31.188121, 50), EnumAltitudeMode.Absolute, -4, 50, 1000); + globeControl1.Globe.FlyToPointSpeed = 10000000; + globeControl1.Globe.Action = EnumAction3D.SelectObject; + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = true; + } + globeControl1.Refresh(); + } + else + { + double x = layer.LatLonBounds.Center.X; + double y = layer.LatLonBounds.Center.Y; + globeControl1.Globe.FlyToPosition(new GSOPoint3d(x, y, 100), EnumAltitudeMode.Absolute); + } + } + } + } + else + { + return; + } + + } + + private void layerTree_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e) + { + if(this.layerTree.SelectedNode!=null) + { + if (this.layerTree.SelectedNode.Tag.ToString().Contains("|")) + { + string nodeTag = this.layerTree.SelectedNode.Tag.ToString().Split('|')[1]; + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(nodeTag); + if (layer != null) + { + if (layer.Caption == "红线") + { + globeControl1.Globe.FlyToPosition(new GSOPoint3d(120.610963, 31.188121, 50), EnumAltitudeMode.Absolute, -4, 50, 1000); + globeControl1.Globe.FlyToPointSpeed = 10000000; + globeControl1.Globe.Action = EnumAction3D.SelectObject; + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = true; + } + globeControl1.Refresh(); + } + else { + double x = layer.LatLonBounds.Center.X; + double y = layer.LatLonBounds.Center.Y; + globeControl1.Globe.FlyToPosition(new GSOPoint3d(x, y, 0), EnumAltitudeMode.Absolute); + } + } + } + if (this.layerTree.SelectedNode.Tag is GSOLayer) + { + GSOLayer layer = this.layerTree.SelectedNode.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 (this.layerTree.SelectedNode.Tag is GSOFeature) + { + GSOFeature feature = this.layerTree.SelectedNode.Tag as GSOFeature; + if (feature.Geometry != null) + { + globeControl1.Globe.FlyToPosition(feature.Geometry.GeoCenterPoint, EnumAltitudeMode.Absolute, 0, 0, 10); + } + else + { + globeControl1.Globe.FlyToFeature(feature); + } + } + } + } + + /// + /// 在三维场景移动时,隐藏气泡globeControl1 + /// + /// + /// + void globeControl1_CameraBeginMoveEvent(object sender, CameraBeginMoveEventArgs e) + { + if (featureTooltip.IsVisible()) + { + featureTooltip.HideBalloon(); + } + if (balloonEx.IsVisible()) + { + balloonEx.HideBalloon(); + } + } + + /// + /// 在三维场景移动时,隐藏气泡globeControl2 + /// + /// + /// + void globeControl2_CameraBeginMoveEvent(object sender, CameraBeginMoveEventArgs e) + { + if (featureTooltip2.IsVisible()) + { + featureTooltip2.HideBalloon(); + } + if (balloonEx2.IsVisible()) + { + balloonEx2.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(); + } + } + + #region Fan 横断面 + /// + /// 横断面分析、基线剖面分析、道路断面分析等 + /// + /// + /// + private static EnumTrackPolylineEndMode trackPolylineEndMode; + + void globeControl1_TrackPolylineEndEvent(object sender, TrackPolylineEndEventArgs e) + { + //横断面分析、道路横断面分析 + if (trackPolylineEndMode == EnumTrackPolylineEndMode.HDM_Analysis|| + trackPolylineEndMode == EnumTrackPolylineEndMode.DLDM_Analysis) + { + Dictionary hdmDic = SectionAnalysisTool.HDMAnalysis(this.globeControl1, + e.Polyline, this.m_PipelineLayerNames); + FrmHDMAnalysis3 frm = new FrmHDMAnalysis3(hdmDic, this.globeControl1, + trackPolylineEndMode); + frm.Show(this); + } + //基线剖面分析 + else if (trackPolylineEndMode == EnumTrackPolylineEndMode.JXPM_Analysis) + { + FrmBaseLineProfillAnalysis dlg = new FrmBaseLineProfillAnalysis(globeControl1.Globe, e.Polyline); + dlg.Show(this); + globeControl1.Globe.ClearLastTrackPolyline(); + } + else + { + + } + trackPolylineEndMode = EnumTrackPolylineEndMode.Default_Analysis; + } + #endregion + + private GSOFeatures PolygonIntersectAnalysis(GSOGeoPolygon3D polygon, string pipelinetype) + { + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(pipelinetype); + 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(pipelinetype, feats.Length); + return feats; + } + /// + /// 根据范围统计阀门、管线、工井等, 开挖分析, 挖方量分析 + /// + /// + /// + void globeControl1_TrackPolygonEndEvent(object sender, TrackPolygonEndEventArgs e) + { + if (globeControl1.Globe.Action == EnumAction3D.TrackPolygon && e.Polygon != null) + { + GSOGeoPolygon3D polygon = e.Polygon; + + switch (trackflag) + { + case "valvequery": + FrmValveStatistics frm = new FrmValveStatistics(globeControl1,polygon, new DataGridViewDelegate(InitDataGridViewX1)); + frm.Show(this); + globeControl1.Globe.Action = EnumAction3D.ActionNull; + break; + + case "PipelineDistanceStatistics": + FrmAllPipelineStatis frm1 = new FrmAllPipelineStatis(globeControl1, polygon, new DataGridViewDelegate(InitDataGridViewX1), m_PipelineLayerNames); + frm1.Show(this); + globeControl1.Globe.Action = EnumAction3D.ActionNull; + + break; + case "PipelineSpatialQuery": + FrmAllPipelineStatis.ShowForm(globeControl1,polygon,new DataGridViewDelegate(InitDataGridViewX1),m_PipelineLayerNames); + globeControl1.Globe.ClearAnalysis(); + globeControl1.Globe.Action = EnumAction3D.ActionNull; + + break; + case "workwellquery": + FrmAllWorkWellStatis frmWell = new FrmAllWorkWellStatis(globeControl1, polygon, new DataGridViewDelegate(InitDataGridViewX1)); + 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 "BSQDuoBianXiangStatis": + + GSOFeature f2 = new GSOFeature(); + f2.Geometry = e.Polygon; + f2.Geometry.AltitudeMode = EnumAltitudeMode.Absolute; + globeControl1.Globe.MemoryLayer.AddFeature(f2); + f2.Geometry.MoveZ(3); + workWellLen.Clear(); + List listBSQ = new List(); + + GSOFeatures bsqFeatures = PolygonIntersectAnalysis(e.Polygon, "标识器"); + listBSQ.Add(bsqFeatures); + + FrmBSQDuoBianXingStatis bsqFrm = new FrmBSQDuoBianXingStatis(workWellLen, globeControl1, listBSQ); + bsqFrm.Show(this); + globeControl1.Globe.Action = EnumAction3D.ActionNull; + break; + + case "": + break; + default: + break; + } + } + } + + #region 验证端口 + /* + /// + /// 验证端口 + /// + /// + 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 + + /// + /// 鼠标悬浮提示 + /// + /// + /// + 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); + } + } + + /// + /// 添加管线绘制完成事件, 红线工具绘制完成 + /// + /// + /// + 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; + + + } + } + + /// + /// 获取globeControl1中鼠标按下的坐标供区别鼠标右键和滚轮按下事件 + /// + /// + /// + void globeControl1_MouseDown(object sender, MouseEventArgs e) + { + mouseDownX1 = e.X; + mouseDownY1 = e.Y; + } + /// + /// 获取globeControl2中鼠标按下的坐标供区别鼠标右键和滚轮按下事件 + /// + /// + /// + void globeControl2_MouseDown(object sender, MouseEventArgs e) + { + mouseDownX2 = e.X; + mouseDownY2 = e.Y; + } + /// + /// + /// + /// + /// + void globeControl2_MouseClick(object sender, MouseEventArgs e) + { + if (e.Button == MouseButtons.Right) + { + if (e.X == mouseDownX2 && e.Y == mouseDownY2) + { + RightScreenToolMenu.Show(globeControl2, e.X, e.Y); + } + else + { + return; + } + } + } + /// + /// + /// + /// + /// + void globeControl1_MouseClick(object sender, MouseEventArgs e) + { + if (e.Button == MouseButtons.Left) + { + if (globeControl1.Globe.Action == EnumAction3D.VisibilityAnalysis) + { + buttonItemFX5_1.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; + + bsqPT = pt; + + if (buttonItemLS5.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 (e.X == mouseDownX1 && e.Y == mouseDownY1) + { + toolRightMenu.Show(globeControl1, e.X, e.Y); + if (buttonItemLS5.Checked) + { + buttonItemLS5.Checked = false; + } + } + else + { + return; + } + } + globeControl1.Refresh(); + } + + /// + /// 判断网络图片是否存在 + /// + /// + /// + 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; + } + + /// + /// 鼠标点击, 弹出气泡功能globeControl1 + /// + /// + /// + void globeControl1_FeatureMouseClickEvent(object sender, FeatureMouseClickEventArgs e) + { + GSOFeature feature = e.Feature; + + string str1 = ""; + if (feature != null) + { + if (feature.GetFieldDefn("图片编码") != null)// + { + str1 = GetBubbleInfo(feature, globeControl1); + if (RemoteFileExists(Utility.PicRootURL + feature.GetValue("图片编码").ToString())) + { + str1 += ""; + } + else if (RemoteFileExists(Utility.PicDefaultURL)) + { + str1 += ""; + } + } + else if (isFeatureContainsBianhao(feature)) //管线模型图层 + { + str1 = GetBubbleInfo(feature, globeControl1); + } + + 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; + } + } + } + + /// + /// 鼠标点击, 弹出气泡功能globeControl2 + /// + /// + /// + void globeControl2_FeatureMouseClickEvent(object sender, FeatureMouseClickEventArgs e) + { + GSOFeature feature = e.Feature; + + string str1 = ""; + if (feature != null) + { + if (feature.GetFieldDefn("图片编码") != null) // + { + str1 = GetBubbleInfo(feature, globeControl2); + if (RemoteFileExists(Utility.PicRootURL + feature.GetValue("图片编码").ToString())) + { + str1 += ""; + } + else if (RemoteFileExists(Utility.PicDefaultURL)) + { + str1 += ""; + } + } + else if (isFeatureContainsBianhao(feature)) //管线模型图层 + { + str1 = GetBubbleInfo(feature, globeControl2); + } + + if (str1 != "") + { + + featureTooltip2.HideBalloon(); + balloonEx2.HideBalloon(); + balloonEx2.SetSize(EnumSizeIndexEx.CONTENT_CX, 480); + balloonEx2.SetSize(EnumSizeIndexEx.CONTENT_CY, 420); + balloonEx2.ShowBalloon((int)e.MousePos.X, (int)e.MousePos.Y, str1); + + return; + } + } + } + + /// + /// 拼接气泡表格字符串 + /// + /// + /// + private string GetBubbleInfo(GSOFeature feature,GSOGlobeControl globeControl) + { + if (feature == null) + { + return ""; + } + string str = ""; + str = ""; + 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 += ""; + + 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.get_Fields(layerName, globeControl); + } + if (queryFields != null) + { + string[] param = { "," }; + string[] fieldNames = queryFields.Split(param, StringSplitOptions.RemoveEmptyEntries); + for (int j = 0; j < fieldNames.Length; 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 (name1 == "模型路径") + { + continue; + } + 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 (field1.Type == EnumFieldType.Double) + { + double dl1 = feature.GetFieldAsDouble(j); + if (!name1.Contains("管径") && !name1.Contains("电压") && !name1.Contains("角度")) + { + name1 += "_米"; + } + value1 = dl1.ToString("0.00"); + } + 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 (name2 == "模型路径") + { + continue; + } + + 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 (field2.Type == EnumFieldType.Double) + { + double dl2 = feature.GetFieldAsDouble(j + 1); + if (!name2.Contains("管径") && !name2.Contains("电压") && !name2.Contains("角度")) + { + name2 += "_米"; + } + value2 = dl2.ToString("0.00"); + } + else + { + if (!feature.IsFieldValueNull(j + 1)) + { + value2 = feature.GetValue(j + 1).ToString(); + } + } + } + } + + j++; + } + str += ""; + } + } + str += "
" + title + " " + feature.GetFieldAsString(featureIDFieldName) + "
" + + name1 + + "
" + + value1 + + "
" + + name2 + + "
" + + value2 + "
"; + return str; + } + + string filename = Utility.filename; + List g1layername = new List(); + + /// + /// 获取目标图层 + /// + /// + 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; + } + /// + /// 添加图层 + /// + /// + /// + /// + 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 = 5000; + return templayer.Visible; + } + catch (Exception ex) + { + return false; + } + } + /// + /// 菜单上的 三维导航 工具按钮 + /// + /// + /// + private void buttonItem86_Click(object sender, EventArgs e) + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + } + + /// + /// 地上模式 菜单按钮 + /// + /// + /// + 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(); + + } + } + /// + /// 地下模式 菜单按钮 + /// + /// + /// + 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(); + } + } + /// + /// 行走模式 菜单按钮 + /// + /// + /// + 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; + } + } + /// + /// 地面透明度设置 菜单 + /// + /// + /// + private void sliderGroundTransSet1_ValueChanged(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.sliderGroundTransSet1.Text); + + globeControl1.Globe.GroundOpaque = 100 - sliderGroundTransSet1.Value; + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(roadLayerName);//("180fd"); + if (layer != null) + { + layer.Opaque = 100 - sliderGroundTransSet1.Value; + } + //if (buttonItemSPDB.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; + } + /// + /// 图例 菜单按钮 + /// + /// + /// + 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(); + } + /// + /// 快速定位 菜单按钮 + /// + /// + /// + private void buttonItem91_Click(object sender, EventArgs e) // + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItem91.Text); + FrmFlyToPosition fly = new FrmFlyToPosition(globeControl1); + fly.Show(this); + } + /// + /// 图层管理 菜单按钮 + /// + /// + /// + 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; + + //修改图层管理与标注管理、覆土审查、水平净距分析、垂直净距分析和碰撞分析控件之间的逻辑关系 + controlContainerItem5.Visible = false; + sideBar1.Visible = false; + sideBarPanelItem4.Visible = false; + panel3.Visible = false; + sideBar1.ExpandedPanel = sideBarPanelItem3; + buttonItemBZ11.Checked = false; + + //20160624 + /* + if (sideBarPanelItem4.Visible == true) + { + sideBar1.Visible = true; + controlContainerItem5.Visible = true; + } + else + { + sideBar1.Visible = false; + } + */ + Refresh(); + + } + } + /// + /// 全屏显示 菜单按钮 + /// + /// + /// + 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; + /// + /// 全屏显示功能实现 + /// + 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(); + } + } + + /// + /// 设置窗体宽、高 + /// + /// + /// + private void SetFullScreen(int width, int height) + { + this.Width = width; + this.Height = height; + } + + /// + /// 全屏功能的快捷键F5 + /// + /// + /// + 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); + } + } + /* + /// + /// 输出地图 + /// + /// + /// + /// + 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; + } + * */ + + private Point getUpperLeftPoint(Point p1, Point p2, out int mapWidth, out int mapHeight) // + { + Rectangle rc = new Rectangle(); + + p1 = this.globeControl1.PointToScreen(p1); + p2 = this.globeControl1.PointToScreen(p2); + + int x = Screen.PrimaryScreen.Bounds.X; + int y = Screen.PrimaryScreen.Bounds.Y; + int screenWidth = SystemInformation.WorkingArea.Width; + int screenHeight = SystemInformation.WorkingArea.Height; + + if (p1.X < x) + rc.X = x; + else + rc.X = p1.X; + + if (p1.Y < y) + rc.Y = y; + else + rc.Y = p1.Y; + + p1.X = rc.Left; + p1.Y = rc.Top; + + if (p2.X > screenWidth) + p2.X = screenWidth; + else + p2.X = p2.X; + + if (p2.Y > screenHeight) + p2.Y = screenHeight; + else + p2.Y = p2.Y; + + rc.Width = p2.X - rc.X; + rc.Height = p2.Y - rc.Y; + + mapWidth = rc.Width; + mapHeight = rc.Height; + Point pt = new Point(rc.Left, rc.Top); + return pt; + } + + Image printImage; + /// + /// 打印 菜单 + /// + /// + /// + 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))); + */ + int mapWidth = 0; + int mapHeight = 0; + Point pt = getUpperLeftPoint(pt1, pt2, out mapWidth, out mapHeight); + int rightBottomX = pt.X + mapWidth; + int rightBottomY = pt.Y + mapHeight; + Image myImg = new Bitmap(mapWidth, mapHeight); + Graphics g = Graphics.FromImage(myImg); + g.CopyFromScreen(pt, new Point(0, 0), new Size(rightBottomX, rightBottomY)); + + + 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); + } + /// + /// 输出地图 菜单 + /// + /// + /// + private void btnOutputJPG_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btnOutputJPG.Text); + + //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))); + */ + int mapWidth = 0; + int mapHeight = 0; + Point pt = getUpperLeftPoint(pt1, pt2, out mapWidth, out mapHeight); + int rightBottomX = pt.X + mapWidth; + int rightBottomY = pt.Y + mapHeight; + Image myImg = new Bitmap(mapWidth, mapHeight); + Graphics g = Graphics.FromImage(myImg); + g.CopyFromScreen(pt, new Point(0, 0), new Size(rightBottomX, rightBottomY)); + + 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; + } + } + } + + /// + /// 统计管线的里程数 + /// + /// + /// + /// + 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; + } + + /// + /// 窗体下方属性表格 右键菜单中的 “定位”菜单 + /// + /// + /// + 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); + + } + + /// + /// 表格中右键 “单个闪烁” 菜单 + /// + /// + /// + private void LightMenu_Click(object sender, EventArgs e) + { + flashflag = "single"; + timer1.Start(); + } + /// + /// 表格中右键 “全部闪烁” 菜单 + /// + /// + /// + private void AllLightMenuItem_Click(object sender, EventArgs e) + { + flashflag = "all"; + timer1.Start(); + } + + /// + /// 使用timer实现管线的闪烁效果 + /// + /// + /// + 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; + } + } + + /// + /// 绘制线 菜单 + /// + /// + /// + private void btnAddLine_Click(object sender, EventArgs e) + { + globeControl1.Globe.DestLayerFeatureAdd = globeControl1.Globe.MemoryLayer; + globeControl1.Globe.Action = EnumAction3D.DrawPolyline; + } + /// + /// 绘制面 菜单 + /// + /// + /// + private void btnAddPolygon_Click(object sender, EventArgs e) + { + globeControl1.Globe.DestLayerFeatureAdd = globeControl1.Globe.MemoryLayer; + globeControl1.Globe.Action = EnumAction3D.DrawPolygon; + } + /// + /// 图层目录树 右键菜单中的 目标图层 菜单 + /// + /// + /// + 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; + } + } + /// + /// 图层目录树 右键菜单中的 可选择 菜单 + /// + /// + /// + 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; + } + /// + /// 图层目录树 右键菜单中的 可编辑 菜单 + /// + /// + /// + 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; + } + /// + /// 图层目录树 右键菜单中的 保存 菜单 + /// + /// + /// + 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(); + } + + /// + /// 根据多边形范围统计管线的里程 + /// + /// + /// + /// 返回查询到的管线要素集合 + 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 pipeLineDis = new Dictionary(); + Dictionary workWellLen = new Dictionary(); + + + + + /// + /// 查找指定图层中在 指定范围内的feature对象集合 + /// + /// + /// + /// + 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; + } + /// + /// 清除结果 菜单 + /// + /// + /// + private void buttonItem47_Click(object sender, EventArgs e) + { + globeControl1.Globe.ClearAnalysis(); + dataGridViewX1.DataSource = null; + panelOfTable.Visible = false; + clearFeatureHighLight(); + } + /// + /// 设置菜单的选中状态 + /// + private void ActionToolMenuChecked() + { + if (globeControl1.Globe.Action != EnumAction3D.TrackPolyline) + { + buttonItemFX2_1.Checked = false; + buttonItemFX2_4.Checked = false; + buttonItemFX2_3.Checked = false; + buttonItemFX4_3.Checked = false; + } + if (globeControl1.Globe.Action != EnumAction3D.NormalHit) + { + buttonItemFX3_6.Checked = false; + // ClearConnexityAnalysis(); + + buttonItemFX3_5.Checked = false; + // ClearCloseValvesAnalysis(); + } + if (globeControl1.Globe.Action != EnumAction3D.TrackPolygon) + { + buttonItemFX4_2.Checked = false; + buttonItemFX4_1.Checked = false; + } + } + + /// + /// 主窗体关闭事件处理 + /// + /// + /// + private void MainFrm_FormClosing(object sender, FormClosingEventArgs e) + { + + if (MessageBox.Show("是否退出系统?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) + { + e.Cancel = true; + } + else { + globeControl1.Globe.MemoryLayer.SaveAs(Application.StartupPath + "/MyPlace.kml"); + } + + //saveLayerList(layerManagerNode.Nodes); + //注销id号为103的热键设定 + // UnregisterHotKey(Handle, 103); + } + + /// + /// 显示流向 功能 + /// + /// + /// + /// + 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(); + } + + FrmCloseValves frm; + + FrmBoosterValvers frmbooster = null; + + /// + /// 垂直净距分析 功能界面中的 选择图层复选框 选中状态改变事件处理 + /// + /// + /// + 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(); + } + /// + /// 水平净距分析 功能界面中的 选择图层复选框 选中状态改变事件处理 + /// + /// + /// + 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(); + } + /// + /// 垂直净距分析 功能界面中的 选择管线复选框 选中状态改变事件处理 + /// + /// + /// + private void checkBoxX1_CheckedChanged(object sender, EventArgs e) + { + clearFeatureHighLight(); + if (checkBoxX1.Checked) + { + comboBoxEx1.SelectedItem = null; + 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; + } + } + /// + /// 水平净距分析 功能界面中的 选择管线复选框 选中状态改变事件处理 + /// + /// + /// + private void checkBoxX1_CheckedChanged_shuiping(object sender, EventArgs e) + { + clearFeatureHighLight();//清除高亮 + if (checkBoxX7.Checked) + { + comboBoxEx4.SelectedItem = null; + 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(); + /// + /// 垂直净距分析 功能界面中的 选择图层下拉框 选中项改变 事件处理 + /// + /// + /// + 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; + } + } + } + /// + /// 水平净距分析 功能界面中的 选择图层下拉框 选中项改变 事件处理 + /// + /// + /// + 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 featCount = new Dictionary(); + Dictionary featLenth = new Dictionary(); + Dictionary m_FeaturesWithBianhao = new Dictionary();//记录编号和对应的标注点的位置 + GSOFeatures polygonJingJuAnalysises = new GSOFeatures(); + + /// + /// 垂直净距分析 功能界面中的 开始分析按钮 事件处理 + /// + /// + /// + 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; + } + + /// + /// 在指定的两点组成的线的中间添加一个marker对象,并将marker对象添加到指定的图层中 + /// + /// + /// + /// + /// + /// + 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; + } + + /// + /// 计算指定feature对象与除了该feature所在图层之外的 所有管线图层中的所有feature对象 的垂直距离 并在表格中记录符合要求的管线 + /// + /// + /// + /// + /// + private void VerticalDistanceAnalysis(string type, GSOFeature selectedFeature, List _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(); + } + /// + /// 垂直净距分析中 表格行的 双击定位 功能。 与覆土分析的实现方法不同,主要原因是需要标注垂距 + /// + /// + /// + 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); + } + } + } + } + + /// + /// 水平净距分析 功能界面中 开始分析按钮 的事件处理 + /// + /// + /// + 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; + } + + + /// + /// 计算指定feature对象与除了该feature所在图层之外的 所有管线图层中的所有feature对象 的水平距离 并记录符合要求的管线 功能 + /// + /// + /// + /// + /// + private void HorizontalDistanceAnalysis(GSOFeature selectedFeature, List _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)); + } + } + } + } + } + /// + /// 水平净距分析 功能界面中 表格的 双击定位 功能 + /// + /// + /// + 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); + } + } + } + } + } + /// + /// 碰撞分析 功能界面中 开始分析按钮 事件处理 + /// + /// + /// + 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; + } + /// + /// 碰撞分析功能界面中 表格的 双击定位 功能 + /// + /// + /// + 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); + } + } + } + } + + + + /// + /// 覆土分析功能操作界面中的 选择管线 复选框选中状态改变事件处理 + /// + /// + /// + private void checkBoxX5_CheckedChanged(object sender, EventArgs e) + { + clearFeatureHighLight(); + if (checkBoxX5.Checked) + { + comboBoxEx3.SelectedItem = null; + 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; + } + } + /// + /// 覆土分析功能操作界面中的 选择图层 复选框选中状态改变事件处理 + /// + /// + /// + 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(); + } + /// + /// 覆土分析功能操作界面中的 图层下拉框选中项改变事件处理 + /// + /// + /// + 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; + } + } + } + /// + /// 覆土分析功能操作界面中的 开始分析 按钮事件处理 + /// + /// + /// + 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; + + + GSOPoint3d markerPosition = new GSOPoint3d(); + 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]; + GSOPoint3d pt = new GSOPoint3d(); + + 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"); + + pt.X = pts[m].X; + pt.Y = pts[m].Y; + pt.Z = 0; + markerPosition = LabelVerticalDistance(layerTemp, pts[m], pt, Convert.ToDouble(dataGridViewX7.Rows[idx].Cells[2].Value), true); + 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]; + GSOPoint3d pt = new GSOPoint3d(); + 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"); + + pt.X = pts[m].X; + pt.Y = pts[m].Y; + pt.Z = 0; + markerPosition = LabelVerticalDistance(layerTemp, pts[m], pt, Convert.ToDouble(dataGridViewX7.Rows[idx].Cells[2].Value), true); + + 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; + } + + /// + /// 覆土分析中 表格的 双击定位 功能 + /// + /// + /// + 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); + } + } + } + } + } + /// + /// 覆土分析功能操作界面中的 导出Excel按钮 事件处理 + /// + /// + /// + private void buttonX10_Click(object sender, EventArgs e) + { + if (dataGridViewX7.Rows.Count > 0) + { + ExportExcel("覆土分析", dataGridViewX7, null); + } + else + { + MessageBox.Show("表格内容为空!", "提示"); + } + } + /// + /// 覆土分析功能操作界面底部的 关闭 按钮事件处理 + /// + /// + /// + 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(); + layerTemp.RemoveAllFeature(); + + if (buttonItem1.Checked) + { + sideBar1.ExpandedPanel = sideBarPanelItem3; + } + else + { + sideBar1.Visible = false; + } + globeControl1.Refresh(); + + //Refresh(); + } + + + /// + /// 垂直净距分析 功能界面中 清除分析结果按钮 事件处理 + /// + /// + /// + 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(); + } + /// + /// 水平净距分析 功能界面中 清除分析结果按钮 事件处理 + /// + /// + /// + 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(); + } + + /// + /// 垂直净距分析功能界面中 关闭按钮 事件处理 + /// + /// + /// + 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(); + } + /// + /// 水平净距分析功能界面中 删除缓冲区按钮 事件处理 + /// + /// + /// + private void buttonX14_Click(object sender, EventArgs e) + { + 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(); + } + + /// + /// 导出指定DataGridView控件中的内容 + /// + /// + /// + 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(); + } + } + } + } + + /// + /// 垂直净距分析功能界面中 导出Excel按钮 事件处理 + /// + /// + /// + private void buttonX4_Click(object sender, EventArgs e) + { + if (dataGridViewX3.Rows.Count > 0) + { + ExportExcel("垂直净距分析", dataGridViewX3, listBox1); + } + else + { + MessageBox.Show("表格内容为空!", "提示"); + } + } + /// + /// 水平净距分析功能界面中 导出Excel按钮 事件处理 + /// + /// + /// + private void buttonX4_Click_shuiping(object sender, EventArgs e) + { + if (dataGridViewX9.Rows.Count > 0) + { + ExportExcel("水平净距分析", dataGridViewX9, listBox3); + } + else + { + MessageBox.Show("表格内容为空!", "提示"); + } + } + + + /// + /// 清除所有坑 菜单 + /// + /// + /// + private void buttonItem3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItem3.Text); + + globeControl1.Globe.RemoveAllPits(); + } + + //} + /// + /// 大气层 菜单 + /// + /// + /// + private void buttonItem17_Click_1(object sender, EventArgs e) + { + globeControl1.Globe.Atmosphere.Visible = !globeControl1.Globe.Atmosphere.Visible; + buttonItemSH1.Checked = globeControl1.Globe.Atmosphere.Visible; + globeControl1.Refresh(); + } + /// + /// 经纬网 菜单 + /// + /// + /// + private void buttonItem20_Click(object sender, EventArgs e) + { + globeControl1.Globe.LatLonGrid.Visible = !globeControl1.Globe.LatLonGrid.Visible; + buttonItemSH3.Checked = globeControl1.Globe.LatLonGrid.Visible; + globeControl1.Globe.Refresh(); + } + /// + /// 状态条 菜单 + /// + /// + /// + private void buttonItem21_Click_1(object sender, EventArgs e) + { + globeControl1.Globe.StatusBar.Visible = !globeControl1.Globe.StatusBar.Visible; + buttonItemSH4.Checked = globeControl1.Globe.StatusBar.Visible; + globeControl1.Globe.Refresh(); + } + + + + /// + /// 添加指定路径下的数据 功能 + /// + /// + /// + 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); + //CheckDatasetGeoReference(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; + } + return objRes; + } + /// + /// 刷新目录树 功能 + /// + 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); + } + } + /// + /// 判断图层是否包含字段列表 + /// + /// + /// + 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; + } + + /// + /// 统计指定图层在指定范围内的所有feature对象 + /// + /// + /// + /// + 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; + } + /// + /// 碰撞分析功能界面中 选择管线复选框 选中状态改变事件处理 + /// + /// + /// + private void checkBoxX3_CheckedChanged(object sender, EventArgs e) + { + clearFeatureHighLight(); + if (checkBoxX3.Checked) + { + comboBoxEx2.SelectedItem = null; + 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; + } + } + /// + /// 碰撞分析功能界面中 选择图层复选框 选中状态改变事件处理 + /// + /// + /// + 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(); + } + /// + /// 碰撞分析功能界面中 选择图层下拉框 选中项改变事件处理 + /// + /// + /// + 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; + } + } + } + /// + /// 清除所有图层中的所有feature对象的高亮状态 功能 + /// + 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); + } + } + } + } + for (int i = 0; i < globeControl2.Globe.Layers.Count; i++) + { + GSOLayer layer = globeControl2.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; + } + } + } + + if (globeControl1.Globe.Action == EnumAction3D.SelectObject) + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + //globeControl1.Globe.Action = EnumAction3D.SelectObject; + } + } + + /// + /// 碰撞分析功能界面中 清除分析结果按钮 事件处理 + /// + /// + /// + 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(); + } + /// + /// 碰撞分析功能界面中 导出Excel按钮 事件处理 + /// + /// + /// + private void buttonX6_Click(object sender, EventArgs e) + { + if (dataGridViewX5.Rows.Count > 0) + { + ExportExcel("碰撞分析", dataGridViewX5, listBox2); + } + else + { + MessageBox.Show("表格内容为空!", "提示"); + } + } + /// + /// 导出CAD 菜单 + /// + /// + /// + private void btnExportCAD_Click(object sender, EventArgs e) + { + FrmExportCADS frm = new FrmExportCADS(globeControl1, m_PipelineLayerNames); + frm.ShowDialog(); + } + + ///// + ///// 区域分析 菜单 + ///// + ///// + ///// + //private void buttonItem50_Click(object sender, EventArgs e) + //{ + // buttonItem50.Checked = !buttonItem50.Checked; + // ribbonBarQY.Visible = buttonItem50.Checked; + // ribbonBarQY.Location = new Point(0, 0); + //} + + + /// + /// 连接数据库 菜单事件处理 + /// + /// + /// + 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; + } + } + } + /// + /// 数据验证 菜单 + /// + /// + /// + private void buttonItem80_Click(object sender, EventArgs e) + { + FrmValiData frm = new FrmValiData(globeControl1); + frm.ShowDialog(); + } + /// + /// 根据指定图层创建图层节点并将节点添加到图层管理节点的子节点集合中 + /// + /// + 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; + + if (!layerManagerNode.Nodes.Contains(node)) + { + layerManagerNode.Nodes.Insert(0, node); + layerManagerNode.Expand(); + } + } + } + /// + /// 数据库备份 菜单 + /// + /// + /// + 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(); + } + } + } + + + + #region Fan 去掉 + //GSOFeature emitterFeature; // 粒子要素 + /// + /// 添加火苗 功能 + /// + /// + /// + /// + 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); + + } + /// + /// 添加喷泉 功能 + /// + /// + /// + /// + 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); + } + #endregion + + /// + /// 获取指定图层中最后一个feature对象的名称对应的整数 + /// + /// + /// + 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; + } + /// + /// 设置除指定标注图层之外的所有标注图层不可见 + /// + /// + 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; + } + } + } + } + } + + /// + /// 判断选中的对象是否为管线 + /// + /// 被选中管线 + /// 返回一根线 + 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; + } + + /// + /// 获取指定两点组成的线的长度 功能 + /// + /// + /// + /// + 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; + } + + /// + /// 图层节点树中 节点 右键单击事件处理 + /// + /// + /// + 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; + } + } + } + } + } + + /// + /// 标注管理、传感器管理 图层目录树的右键菜单中的 刷新列表 菜单 + /// + /// + /// + 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); + } + } + /// + /// 给指定的图层节点添加代表feature对象的子节点 + /// + /// + private void RefreshTreeNodeLayerFeatureList(TreeNode layerTreeNode) + { + layerTreeNode.Nodes.Clear(); + GSOLayer layer = (GSOLayer)layerTreeNode.Tag; + // 只将类型为内存数据集的图层列出,如果是其它类型的数据集可能数据量太大,没发显示在树控件中 + if (layer.Dataset is GSOFeatureDataset) + { + VisitFeature3Ds(layer.GetAllFeatures(), layerTreeNode); + } + } + + /// + /// 标注管理、传感器管理 图层目录树的右键菜单中的 移除所有 菜单 + /// + /// + /// + 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(); + } + } + + /// + /// 图层目录树的 节点对应的复选框选中状态改变事件处理 + /// + /// + /// + private void layerMarkerTree_AfterCheck(object sender, TreeViewEventArgs e) + { + if (e.Action != TreeViewAction.Unknown) + { + CheckTreeNode(e.Node, e.Node.Checked); + } + } + /// + /// 改变指定节点对应的复选框的选中状态 + /// + /// + /// + private void CheckTreeNode(TreeNode node, Boolean bChecked) + { + CheckChildTreeNode(node, bChecked); + globeControl1.Globe.Refresh(); + } + /// + /// 改变指定节点的子节点对应的复选框的选中状态 + /// + /// + /// + 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); + } + } + /// + /// 标注管理、传感器管理 目录树中的feature节点的右键菜单中的 删除 菜单 + /// + /// + /// + 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(); + } + } + + /// + /// 双屏对比 菜单 + /// + /// + /// + //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(); + // } + //} + /// + /// 模拟分析 菜单 + /// + /// + /// + //private void buttonItem51_Click(object sender, EventArgs e) + //{ + // buttonItem51.Checked = !buttonItem51.Checked; + // ribbonBarMN.Visible = buttonItem51.Checked; + // ribbonBarMN.Location = new Point(0, 0); + //} + + /// + /// 双屏设置 菜单 + /// + /// + /// + //private void buttonItem96_Click(object sender, EventArgs e) + //{ + // FrmLayerControl frm = new FrmLayerControl(layerTree,globeControl1,globeControl2); + // frm.Show(this); + //} + /// + /// 双屏联动 菜单 + /// + /// + /// + //private void buttonItem95_Click(object sender, EventArgs e) + //{ + // buttonItem95.Checked = !buttonItem95.Checked; + //} + ///// + /// 添加用户仓库 菜单 + /// + /// + /// + private void buttonItem108_Click(object sender, EventArgs e) + { + FrmUserRepo frm = new FrmUserRepo(-1); + frm.ShowDialog(); + } + /// + /// 用户仓库管理 菜单 + /// + /// + /// + private void buttonItem111_Click(object sender, EventArgs e) + { + FrmUserRepoMgr frm = new FrmUserRepoMgr(); + frm.ShowDialog(); + } + /// + /// 添加分系统 菜单 + /// + /// + /// + private void buttonItem112_Click(object sender, EventArgs e) + { + //FrmAPP frm = new FrmAPP(-1); + //frm.ShowDialog(); + } + /// + /// 分系统管理 菜单 + /// + /// + /// + private void buttonItem113_Click(object sender, EventArgs e) + { + //FrmAPPMgr frm = new FrmAPPMgr(); + //frm.ShowDialog(); + } + /// + /// 添加操作 菜单 + /// + /// + /// + private void buttonItem114_Click(object sender, EventArgs e) + { + FrmOper frm = new FrmOper(-1); + frm.ShowDialog(); + } + /// + /// 操作管理 菜单 + /// + /// + /// + private void buttonItem115_Click(object sender, EventArgs e) + { + FrmOperMgr frm = new FrmOperMgr(); + frm.ShowDialog(); + } + /// + /// 添加资源 菜单 + /// + /// + /// + private void buttonItem116_Click(object sender, EventArgs e) + { + FrmRESC frm = new FrmRESC(-1); + frm.ShowDialog(); + } + /// + /// 资源管理 菜单 + /// + /// + /// + private void buttonItem117_Click(object sender, EventArgs e) + { + FrmRESCMgr frm = new FrmRESCMgr(); + frm.ShowDialog(); + } + /// + /// 添加权限 菜单 + /// + /// + /// + private void buttonItem118_Click(object sender, EventArgs e) + { + FrmPerm frm = new FrmPerm(-1); + frm.ShowDialog(); + } + /// + /// 权限管理 菜单 + /// + /// + /// + private void buttonItem119_Click(object sender, EventArgs e) + { + FrmPermMgr frm = new FrmPermMgr(); + frm.ShowDialog(); + } + /// + /// 添加访问控制 菜单 + /// + /// + /// + private void buttonItem120_Click(object sender, EventArgs e) + { + FrmAccess frm = new FrmAccess(-1); + frm.ShowDialog(); + } + /// + /// 访问控制管理 菜单 + /// + /// + /// + private void buttonItem121_Click(object sender, EventArgs e) + { + FrmAccessMgr frm = new FrmAccessMgr(); + frm.ShowDialog(); + } + /// + /// 部门类型管理 菜单 + /// + /// + /// + private void buttonItem122_Click(object sender, EventArgs e) + { + FrmRegionTypeMgr frm = new FrmRegionTypeMgr(); + frm.ShowDialog(); + } + /// + /// 添加用户 菜单 + /// + /// + /// + private void buttonItem127_Click(object sender, EventArgs e) + { + FrmUserAdd frm = new FrmUserAdd(-1); + frm.ShowDialog(); + } + /// + /// 用户信息管理 菜单 + /// + /// + /// + private void buttonItem128_Click_1(object sender, EventArgs e) + { + FrmUserManager frm = new FrmUserManager(); + frm.ShowDialog(); + } + /// + /// 添加角色 菜单 + /// + /// + /// + private void 添加角色_Click(object sender, EventArgs e) + { + FrmRole frm = new FrmRole(-1); + frm.ShowDialog(); + } + /// + /// 所有角色管理 菜单 + /// + /// + /// + private void 角色管理_Click(object sender, EventArgs e) + { + FrmRoleMgr frm = new FrmRoleMgr(); + frm.ShowDialog(); + } + + /// + /// 部门角色管理 菜单 + /// + /// + /// + private void buttonItem133_Click(object sender, EventArgs e) + { + FrmRegionRoleMgr frm = new FrmRegionRoleMgr(); + frm.ShowDialog(); + } + /// + /// 部门管理 菜单 + /// + /// + /// + private void buttonItem130_Click(object sender, EventArgs e) + { + FrmRegionMgr frm = new FrmRegionMgr(); + frm.ShowDialog(); + } + + /// + /// 日志管理 菜单 + /// + /// + /// + private void buttonItem135_Click(object sender, EventArgs e) + { + FrmLogManager frm = new FrmLogManager(); + frm.ShowDialog(); + } + /// + /// 传感器信息查询 菜单 + /// + /// + /// + 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); + } + } + } + /// + /// 根据指定的图层的caption属性的值在配置文件中查找对应的数据库中的表的名称 + /// + /// 图层的caption属性的值 + /// 对应的数据库中的表的名称 + 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; + } + /// + /// 根据数据库中的表的名称 查找对应的表中的字段名称的集合 + /// + /// 数据库中的表的名称 + /// 对应的表中的字段名称的集合 + 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; + } + + /// + /// 历史曲线查询 菜单 + /// + /// + /// + 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; + /// + /// 传感器在线报警 菜单 + /// + /// + /// + 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); + } + /// + /// 传感器报警 功能中的 定时器 的触发事件处理 + /// + /// + /// + 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; + } + } + } + } + } + } + } + + + /// + /// 沿线运动 菜单 + /// + /// + /// + private void buttonItem138_Click(object sender, EventArgs e) + { + if (globeControl1.Globe.SelectedObject == null) + { + MessageBox.Show("请先选择一条线!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + return; + } + + GSOFeature lineFeature = globeControl1.Globe.SelectedObject; + if (lineFeature.Geometry == null || lineFeature.Geometry.Type != EnumGeometryType.GeoPolyline3D) + { + MessageBox.Show("请先选择一条线!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + return; + } + + OpenFileDialog dlg = new OpenFileDialog(); + dlg.Filter = "*.gcm;*.3ds|*.gcm;*.3ds|*.3ds|*.3ds|*.gcm|*.gcm"; + if (dlg.ShowDialog() == DialogResult.OK) + { + GSOGeoModel model = new GSOGeoModel(); + model.FilePath = dlg.FileName; + + GSOGeoDynamicRoute dynamicRoute = new GSOGeoDynamicRoute(); + dynamicRoute.ActorGeometry = model; + + GSORoute route = new GSORoute(); + GSOGeoPolyline3D geoline = (GSOGeoPolyline3D)lineFeature.Geometry; + for (int i = 0; i < geoline[0].Count; i++) + { + route.Add(geoline[0][i]); + } + route.CircleRoute = false; + route.Speed = 30; + route.RotateSpeed = 50; + route.AltitudeMode = geoline.AltitudeMode; + dynamicRoute.Route = route; + + GSOFeature feature = new GSOFeature(); + + dynamicRoute.Play(); + feature.Geometry = dynamicRoute; + + //GSOLabel gsoLabel = new GSOLabel(); + //gsoLabel.Text = "模型测试"; + //feature.Label = gsoLabel; + globeControl1.Globe.MinModelVisibleSize = 0; + + globeControl1.Globe.MemoryLayer.AddFeature(feature); + globeControl1.Globe.Refresh(); + } + } + /// + /// 回退 菜单 + /// + /// + /// + private void buttonItem99_Click(object sender, EventArgs e) + { + globeControl1.Globe.UnDoEdit(); + } + /// + /// 前进 菜单 + /// + /// + /// + private void buttonItem100_Click(object sender, EventArgs e) + { + globeControl1.Globe.ReDoEdit(); + } + /// + /// 水平净距 功能界面中的 标签内容改变事件处理 + /// + /// + /// + 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() + "米的管线有:"; + } + } + } + /// + /// 垂直净距 功能界面中的 标签内容改变事件处理 + /// + /// + /// + 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() + "米的管线有:"; + } + } + } + /// + /// 覆土分析 功能界面中的 标签内容改变事件处理 + /// + /// + /// + 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() + "米的管线有:"; + } + } + } + + /// + /// 传感器分类查询 全区域 菜单 + /// + /// + /// + private void buttonItemSensor全区域查询_Click(object sender, EventArgs e) + { + FrmAccessoriesSensor.ShowForm(globeControl1, instrumenLayerNames, 0); + } + /// + /// 传感器分类查询 绘制区域 菜单 + /// + /// + /// + private void buttonItemSensor绘制区域查询_Click(object sender, EventArgs e) + { + FrmAccessoriesSensor.ShowForm(globeControl1, instrumenLayerNames, 1); + } + + + /// + /// 碰撞分析 功能界面中 关闭按钮 事件处理 + /// + /// + /// + 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(); + } + /// + /// 覆土分析 功能界面中的 清除分析结果 按钮事件处理 + /// + /// + /// + 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(); + } + /// + /// 数字预处理 功能 + /// + /// + /// + private void 数字预处理buttonItem140_Click(object sender, EventArgs e) + { + FrmEditShapeFile frm = new FrmEditShapeFile(globeControl1); + frm.ShowDialog(this); + } + + + /// + /// 导出矢量 功能 将图层导出为kml和shp格式数据 + /// + /// + /// + private void 导出矢量buttonItem140_Click(object sender, EventArgs e) + { + List listVectorNames = new List(); + for (int i = 0; i < m_PipelineLayerNames.Count; i++) + { + 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 = ""; + /// + /// 绘制城市七线 功能按钮 + /// + /// + /// + 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; + } + } + } + /// + /// 七线审核 功能按钮 + /// + /// + /// + private void 七线审核buttonItem141_Click(object sender, EventArgs e) + { + FrmCityServerLineAnalysis frm = new FrmCityServerLineAnalysis(globeControl1, m_PipelineLayerNames); + frm.ShowDialog(this); + } + + /// + /// 间距分析 开始分析按钮 分析绘制的七线和管线的距离是否符合标准 + /// + /// + /// + 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; + } + /// + /// 间距分析 清除分析结果 + /// + /// + /// + 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(); + } + /// + /// 间距分析 导出Excel按钮 将间距分析的结果以Excel表格的形式导出 + /// + /// + /// + private void buttonExportExcel_Click(object sender, EventArgs e) + { + if (dataGridViewAnalysisResult.Rows.Count > 0) + { + ExportExcel("间距分析", dataGridViewAnalysisResult, listBoxStasticsResult); + } + else + { + MessageBox.Show("表格内容为空!", "提示"); + } + } + /// + /// 间距分析 关闭按钮 + /// + /// + /// + 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(); + } + /// + /// 间距分析 分析结果表格双击定位 + /// + /// + /// + 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); + } + } + } + } + /// + /// 间距分析 选择管线复选框 + /// + /// + /// + private void checkBoxSelectPipeline_CheckedChanged(object sender, EventArgs e) + { + clearFeatureHighLight();//清除高亮 + if (checkBoxSelectPipeline.Checked) + { + comboBoxLayer.SelectedItem = null; + 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; + } + } + /// + /// 间距分析 选择图层复选框 + /// + /// + /// + 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(); + } + /// + /// 间距分析 选择图层下拉框 + /// + /// + /// + 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; + } + } + } + + + + /// + /// 管线自动缩进 菜单 + /// + /// + /// + private void 管线自动缩进buttonItem140_Click(object sender, EventArgs e) + { + FrmPipelineIndented frm = new FrmPipelineIndented(globeControl1, m_PipelineLayerNames, workwellLayerNames); + 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 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); + // } + //} + + /// + /// 统计指定图层在指定范围内的所有feature对象 + /// + /// + /// + /// + 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) + { + 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 setLayerVisible(string layerName) + { + GSOLayer templayer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + if (templayer != null) + { + templayer.Visible = false; + } + globeControl1.Globe.Refresh(); + } + + /// + /// 连接数据库 + /// + /// + /// + private void buttonItem129_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL4_1.Text); + + FrmDatabaseParaSetting2 frm = new FrmDatabaseParaSetting2(globeControl1); + if (frm.ShowDialog() == DialogResult.OK) + { + ds = FrmDatabaseParaSetting2.ds; + if (ds != null) + { + ds.IsCloseSaved = false; + } + } + } + + /// + /// 一键审核---导入数据 + /// + /// + /// + private void buttonItem127_Click_2(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, "打开数据"); + + try + { + //if (shds == null) + //{ + //没连的话,直接连接审核库; //审核库配置读配置文件 + string dbIp = Utility.sgdbip; + string database = Utility.sgdbname; + string user = Utility.sgdbuser; + string pass = Utility.sgdbpwd; + /* + 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; + //} + } + catch (Exception ex) + { + LogError.PublishError(ex); + MessageBox.Show("内存过载请清理内存,并重新启动规划分析!", "提示"); + return; + } + + } + + /// + ///自动导出图片 + /// + /// + /// + private void buttonItem130_Click_1(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, "导出审核图"); + + 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))); + */ + + int mapWidth = 0; + int mapHeight = 0; + Point pt = getUpperLeftPoint(pt1, pt2, out mapWidth, out mapHeight); + int rightBottomX = pt.X + mapWidth; + int rightBottomY = pt.Y + mapHeight; + Image myImg = new Bitmap(mapWidth, mapHeight); + Graphics g = Graphics.FromImage(myImg); + g.CopyFromScreen(pt, new Point(0, 0), new Size(rightBottomX, rightBottomY)); + + 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; + } + } + } + /// + /// 一键审核功能 + ///
+ /// + /// + private void buttonItem128_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItem128.Text); + //垂直净距标准 + + frmSh = new FrmYJSHTC(globeControl1, globeControl2,layerTree); + + if (frmSh.ShowDialog() == DialogResult.OK) + { + frmWait = new FrmWait("一键审核……"); + frmWait.Location = new Point(this.Width - frmWait.Width - 10, this.Height - frmWait.Height - 50); + frmWait.Owner = this; + frmWait.Show(); + Thread thread = new Thread(new ThreadStart(doWork)); + thread.IsBackground = true; + thread.Start(); + } + } + + void doWork() + { + FrmShResult frmShResult = null; + + double dVerticalJingJuBiaoZhun = 1, dHorizontalJingJuBiaoZhun = 1; + if (frmSh.rukuLayer != null) + { + #region + this.Invoke((EventHandler)delegate + { + try + { + List managerLayerList = new List(); + for (int i = 0; i < layerManagerNode.Nodes.Count; i++) + { + managerLayerList.Add(layerManagerNode.Nodes[i].Text); + } + if (!managerLayerList.Contains(frmSh.rukuLayer.Caption)) + { + TreeNode node = new TreeNode(); + node.Tag = frmSh.rukuLayer; + node.Text = frmSh.rukuLayer.Dataset.Caption; + node.ImageIndex = 0; + node.SelectedImageIndex = 0; + node.Checked = frmSh.rukuLayer.Visible; + layerManagerNode.Nodes.Insert(0, node); + layerManagerNode.Expand(); + } + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "提示"); + } + }); + #endregion + + shlayername = frmSh.rukuLayer.Name; + globeControl1.Refresh(); + } + + if (frmShResult != null && !frmShResult.IsDisposed) + { + try + { + clearFeatureHighLight(); + ClearRedlineAnalyseResult(); + frmShResult.Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message); + } + } + + 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.analysis(); + + //MainFrm窗体显示控制,回到一键审核Tab + this.Invoke((EventHandler)delegate + { + frmShResult.Show(); + frmWait.Close(); + //将tab页恢复到一键审核 + ribbonTabItem11.Checked = true; + try + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + //zhanshi = false; + splitContainer1.Panel2Collapsed = true; + + panelOfTable.Visible = false; + legendSC.Visible = false; + legendSG.Visible = false; + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + } + catch (Exception ex) + { + MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + + }); + + boolfrmShResult = true; + } + else + { + + } + } + + + /// + /// 清除渲染结果 + /// + 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(); + } + /// + /// 已审核的图层 + /// + /// + /// + private void buttonItem132_Click_1(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItem132.Text); + + if (shds == null) + { + //没连的话,直接连接审核库; //审核库配置读配置文件 + string dbIp = Utility.sgdbip; + string database = Utility.sgdbname; + string user = Utility.sgdbuser; + string pass = Utility.sgdbpwd; + + /* + 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; + //} + + } + /// + /// 审核入库 + /// + /// + /// + private void buttonItem133_Click_1(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, "审核入库"); + FrmShRK frmShrk = new FrmShRK(globeControl1); + frmShrk.Show(); + } + /// + /// 模拟设计修改 + /// + /// + /// + private void buttonItem134_Click_1(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, "模拟设计修改"); + + 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 + { + + } + + } + + + /// + /// 绘制垂线 + /// + /// + /// + 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); + } + /// + /// 比较两个点是否是同一个点 + /// + /// + /// + /// + 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; + } + /// + /// 获得点到线的垂线距离及垂点 + /// + /// + /// + /// + /// + 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); + 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]; + } + /// + /// 获得斜率 + /// + /// + /// + /// + /// + /// + /// + 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); + } + } + /// + /// 根据默认投影参数,经纬度转xyz + /// + /// + /// + /// + 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; + } + /// + /// 根据投影参数,经纬度转xyz + /// + /// + /// + /// + /// + 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; + } + /// + /// 根据默认投影参数,xyz转经纬度 + /// + /// + /// + /// + 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; + } + /// + /// 根据投影参数,Xyz转经纬度 + /// + /// + /// + /// + /// + 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; + } + /// + /// 获得inpolygon的管线长度 + /// + /// + 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; + } + + + /// + /// 一键审核中调节透明度 + /// + /// + /// + private void sliderItem1_ValueChanged(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.sliderItem1.Text); + + globeControl1.Globe.GroundOpaque = 100 - sliderItem1.Value; + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(roadLayerName);//("180fd"); + if (layer != null) + { + layer.Opaque = 100 - sliderItem1.Value; + } + + optiValue = sliderItem1.Value; + } + /// + /// 红线审核中的透明度分析 + /// + /// + /// + private void sliderItem3_ValueChanged(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.sliderItem3.Text); + + globeControl1.Globe.GroundOpaque = 100 - sliderItem3.Value; + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(roadLayerName);//("180fd"); + if (layer != null) + { + layer.Opaque = 100 - sliderItem3.Value; + } + optiValue = sliderItem3.Value; + } + + #region yanxiaowei + //初始化DataGridViewX1控件 + public delegate void DataGridViewDelegate(DataTable dt, string strLable, string strLayer, bool initDataGrid); + /// + /// 代理函数,操作DatgridViewX1 + /// + /// + /// + public void InitDataGridViewX1(DataTable dt, string strLable, string strLayer, bool initDataGrid) + { + if (initDataGrid == true) + { + dataGridViewX1.DataSource = dt; + panelOfTable.Visible = true; + toolStripNumbers.Text = strLable; + dataGridViewX1.Tag = strLayer; + } + else + { + dataGridViewX1.DataSource = null; + dataGridViewX1.Refresh(); + panelOfTable.Visible = false; + toolStripNumbers.Text = ""; + dataGridViewX1.Tag = ""; + globeControl1.Globe.MemoryLayer.RemoveAllFeature();//清除双击产生的标注 + } + } + FrmAnalysisGuiHuaResult from; + /// + /// 主窗体下方属性表格 双击定位 功能 + /// + /// + /// + private void dataGridViewX1_MouseDoubleClick(object sender, MouseEventArgs e) + { + if (redSH == false) + { + 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 if (dataGridViewX1.Columns.Contains("标识器编号")) + { + featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["标识器编号"].Value.ToString(); + } + featureName = featureName.Trim(); + + GSOLayer layer = null; + layer = globeControl1.Globe.Layers.GetLayerByCaption(dataGridViewX1.Tag.ToString()); + + if (layer == null) return; + + GSOFeatures features = layer.GetFeatureByName(featureName, false); + if (features.Length == 0) return; + GSOFeature rowFeature = features[0]; + + ClassSearchAnalysis.AddMakerToLineFeature(globeControl1, rowFeature); + + } + } + } + else + { + if (e.Button == MouseButtons.Left) + { + if (from != null && !from.IsDisposed) + { + try + { + from.Close(); + } + catch (Exception ex) + { + LogError.PublishError(ex); + } + } + try + { + DataGridView.HitTestInfo hittestinfo = dataGridViewX1.HitTest(e.X, e.Y); + if (hittestinfo.RowIndex >= 0) + { + string layer = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["管线类型"].Value.ToString(); + string hxName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["红线编号"].Value.ToString(); + FrmAnalysisGuiHuaResult frm = new FrmAnalysisGuiHuaResult(globeControl1, lineStruct, featsList, + panelOfTable, dataGridViewX1, layer, hxName); + frm.Location = new Point(this.Width - frm.Width - 10, this.Height - frm.Height - 20); + frm.Show(this); + + from = frm; + } + } + catch (Exception ex) + { + LogError.PublishError(ex); + } + } + } + } + + /// + /// 空间查询 + /// + /// + /// + private void buttonItemSearch1_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemSearch1.Text); + + trackflag = "PipelineSpatialQuery"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; + + } + /// + /// 关键字查询 + /// + /// + /// + private void buttonItemSearch9_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch9.Text); + + FrmKeywordQuery.ShowForm(globeControl1, m_PipelineLayerNames, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 编号查询 + /// + /// + /// + private void buttonItemSearch2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch2.Text); + + FrmCodingQuery.ShowForm(globeControl1, m_PipelineLayerNames, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 坐标查询 + /// + /// + /// + private void buttonItemSearch3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch3.Text); + + FrmSetLatLonPos.ShowForm(globeControl1); + } + /// + /// 附属物查询 + /// + /// + /// + private void buttonItemSearch10_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch10.Text); + + FrmFittingQuery.ShowForm(globeControl1, instrumenLayerNames, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 管径查询 + /// + /// + /// + private void buttonItemSearch4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch4.Text); + + FrmDiameterQuery.ShowForm(globeControl1, m_PipelineLayerNames, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 材质查询 + /// + /// + /// + private void buttonItemSearch5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch5.Text); + + FrmMaterialSel.ShowForm(globeControl1, m_PipelineLayerNames, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 基本查询 + /// + /// + /// + private void buttonItemSearch6_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch6.Text); + + FrmBasicQuery.ShowForm(globeControl1, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 复合查询 + /// + /// + /// + private void buttonItemSearch7_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch7.Text); + + FrmQuerySQL.ShowForm(globeControl1, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 关联查询 + /// + /// + /// + private void buttonItemSearch8_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch8.Text); + + if (globeControl1.Globe.SelObjectCount != 1) + { + MessageBox.Show("请选中一个对象!", "提示"); + return; + } + + 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 || (feature.Geometry.Type == EnumGeometryType.GeoPolygon3D + || feature.Geometry.Type == EnumGeometryType.GeoWater)) + return; + else + { + ClassSearchAnalysis.ResultRelationAnalysis(globeControl1, feature, valueLayerNames, workwellLayerNames, + instrumenLayerNames, pipefittingLayerNames, m_PipelineLayerNames, valueAllowance); + } + } + } + #endregion + /// + /// 清除分析 + /// + /// + /// + private void buttonItemClear_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemClear.Text); + + globeControl1.Globe.ClearMeasure(); + layerTemp.RemoveAllFeature(); + layerTemp2.RemoveAllFeature(); + buttonItemLS5.Checked = false; + + dataGridViewX1.DataSource = null; + panelOfTable.Visible = false; + + 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); + + NetworkAnalysisTool.ClearAllTopAnalysis(this.globeControl1); + // 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();//清除所有坑 + + 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(); + } + } + + clearFeatureHighLight();//取消管线高亮 + + GSOLayer layerGround = globeControl1.Globe.Layers.GetLayerByCaption(roadLayerName);//("180fd"); + if (layerGround != null) + { + layerGround.Visible = true; + } + globeControl1.Refresh(); + globeControl2.Refresh(); + ClearRedlineAnalyseResult(); + globeControl1.Globe.Action = EnumAction3D.ActionNull; + } + /// + /// 管线长度全区域统计 + /// + /// + /// + private void buttonItemTJ1_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管线长度统计"); + + FrmAllPipelineStatis frm = new FrmAllPipelineStatis(globeControl1,null, new DataGridViewDelegate(InitDataGridViewX1), m_PipelineLayerNames); + frm.Show(this); + } + /// + /// 管线长度绘制区域统计 + /// + /// + /// + private void buttonItemTJ1_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管线长度统计"); + + trackflag = "PipelineDistanceStatistics"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; + } + /// + /// 阀门数量全区域统计 + /// + /// + /// + private void buttonItemTJ2_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "阀门数量统计"); + + FrmValveStatistics frm = new FrmValveStatistics(globeControl1, null, new DataGridViewDelegate(InitDataGridViewX1)); + frm.Show(this); + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + } + /// + /// 阀门数量绘制区域统计 + /// + /// + /// + private void buttonItemTJ2_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "阀门数量统计"); + + trackflag = "valvequery"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; + } + /// + /// 井盖数量全区域统计 + /// + /// + /// + private void buttonItemTJ3_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "井盖数量统计"); + FrmAllWorkWellStatis frm = new FrmAllWorkWellStatis(globeControl1, null, new DataGridViewDelegate(InitDataGridViewX1)); + frm.Show(this); + } + /// + /// 井盖数量绘制区域统计 + /// + /// + /// + private void buttonItemTJ3_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "井盖数量统计"); + + trackflag = "workwellquery"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; + } + /// + /// 管径分段统计全区域统计 + /// + /// + /// + private void buttonItemTJ4_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管径分段统计"); + + Frmpipediameterstatis.ShowForm(globeControl1, m_PipelineLayerNames, 0); + } + /// + /// 管径分段统计绘制区域统计 + /// + /// + /// + private void buttonItemTJ4_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管径分段统计"); + + trackflag = null; + Frmpipediameterstatis.ShowForm(globeControl1, m_PipelineLayerNames, 1); + } + /// + /// 埋深分段统计全区域统计 + /// + /// + /// + private void buttonItemTJ5_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "埋深分段统计"); + FrmpipeDeepstatis.ShowForm(globeControl1, m_PipelineLayerNames, 0); + } + /// + /// 埋深分段统计绘制区域统计 + /// + /// + /// + private void buttonItemTJ5_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "埋深分段统计"); + trackflag = null; + FrmpipeDeepstatis.ShowForm(globeControl1, m_PipelineLayerNames, 1); + } + /// + /// 管径分类统计全区域统计 + /// + /// + /// + private void buttonItemTJ6_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管径分类汇总"); + + FrmpipeDiametergather.ShowForm(globeControl1, m_PipelineLayerNames, 0); + } + /// + /// 管径分类统计绘制区域统计 + /// + /// + /// + private void buttonItemTJ6_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管径分类汇总"); + + trackflag = null; + FrmpipeDiametergather.ShowForm(globeControl1, m_PipelineLayerNames, 1); + } + /// + /// 材质分类统计全区域统计 + /// + /// + /// + private void buttonItemTJ7_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "材质分类汇总"); + + FrmpipeMaterialGather.ShowForm(globeControl1, m_PipelineLayerNames, 0); + } + /// + /// 材质分类统计绘制区域统计 + /// + /// + /// + private void buttonItemTJ7_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "材质分类汇总"); + + trackflag = null; + FrmpipeMaterialGather.ShowForm(globeControl1, m_PipelineLayerNames, 1); + } + /// + /// 附属物分类统计全区域统计 + /// + /// + /// + private void buttonItemTJ8_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "附属物分类汇总"); + + FrmAccessoriesgather.ShowForm(globeControl1, instrumenLayerNames, 0); + } + /// + /// 附属物分类统计绘制区域统计 + /// + /// + /// + private void buttonItemTJ8_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "附属物分类汇总"); + + trackflag = null; + FrmAccessoriesgather.ShowForm(globeControl1, instrumenLayerNames, 1); + } + /// + /// 碰撞分析 + /// + /// + /// + private void buttonItemFX1_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_4.Text); + + this.dataGridViewX4.Size = new System.Drawing.Size(195, 120); + 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(); + } + /// + /// 覆土分析 + /// + /// + /// + private void buttonItemFX1_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX5_1.Text); + this.dataGridViewX6.Size = new System.Drawing.Size(195, 120); + 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(); + } + /// + /// 间距分析 + /// + /// + /// + private void buttonItemFX1_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX1_3.Text); + + this.dataGridViewLineList.Size = new System.Drawing.Size(185, 120); + 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(); + } + /// + /// 垂直净距分析 + /// + /// + /// + private void buttonItemFX1_4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX1_4.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(); + } + /// + /// 水平净距分析 + /// + /// + /// + private void buttonItemFX1_5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_6.Text); + this.dataGridViewX8.Size = new System.Drawing.Size(185, 120); + 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(); + } + + #region Predaotr,断面分析 + /// + /// 横断面分析 + /// + /// + /// + private void buttonItemFX2_1_Click(object sender, EventArgs e) + { + globeControl1.Globe.Action = EnumAction3D.TrackPolyline; + globeControl1.Globe.TrackPolylineTool.VerticalLineVisible = true; + globeControl1.Globe.TrackPolylineTool.TrackMode = EnumTrackMode.SpaceTrack; + trackPolylineEndMode = EnumTrackPolylineEndMode.HDM_Analysis; + + } + /// + /// 纵断面分析 + /// + /// + /// + private void buttonItemFX2_2_Click(object sender, EventArgs e) + { + if (globeControl1.Globe.SelObjectCount<1) + { + MessageBox.Show("请选择一条或者多条管线!", "提示", MessageBoxButtons.OK, + MessageBoxIcon.Information); + return; + } + 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); + } + } + List feats = SectionAnalysisTool.ZDMAnalysis(selectFeatures); + if (feats != null && feats.Count >= 1) + { + FrmProfileAnalysis frm = new FrmProfileAnalysis(globeControl1, feats); + frm.Show(this); + } + } + /// + /// 道路断面分析 + /// + /// + /// + private void buttonItemFX2_3_Click(object sender, EventArgs e) + { + globeControl1.Globe.Action = EnumAction3D.TrackPolyline; + globeControl1.Globe.TrackPolylineTool.VerticalLineVisible = true; + globeControl1.Globe.TrackPolylineTool.TrackMode = EnumTrackMode.SpaceTrack; + trackPolylineEndMode = EnumTrackPolylineEndMode.DLDM_Analysis; + + } + /// + /// 基线剖面分析 + /// + /// + /// + private void buttonItemFX2_4_Click(object sender, EventArgs e) + { + globeControl1.Globe.Action = EnumAction3D.TrackPolyline; + globeControl1.Globe.TrackPolylineTool.VerticalLineVisible = true; + globeControl1.Globe.TrackPolylineTool.TrackMode = EnumTrackMode.SpaceTrack; + trackPolylineEndMode = EnumTrackPolylineEndMode.JXPM_Analysis; + + } + + #endregion + /// + /// 创建拓扑 + /// + /// + /// + private void buttonItemFX3_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX3_1.Text); + + FrmGenAndFaMenTopu frm = new FrmGenAndFaMenTopu(globeControl1, m_PipelineLayerNames, valueLayerNames); + frm.Show(this); + } + #region Predator :拓扑分析 + /// + /// 上游分析 + /// + /// + /// + private void buttonItemFX3_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX3_2.Text); + NetworkTraceUpDown(true); + } + /// + /// 下游分析 + /// + /// + /// + private void buttonItemFX3_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX3_3.Text); + NetworkTraceUpDown(false); + } + + /// + /// 上下游追踪 功能 + /// + /// + private void NetworkTraceUpDown(Boolean bTraceUp) + { + GSOFeature selLineFeature = globeControl1.Globe.SelectedObject; + if (selLineFeature == null || selLineFeature.Geometry == null || selLineFeature.Geometry.Type != EnumGeometryType.GeoPolyline3D) + { + MessageBox.Show("请点击“编辑”—“选中对象”选择一条线!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); + return; + } + GSOLayer selLayer = globeControl1.Globe.SelectedObjectLayer; + + NetworkAnalysisTool.TraceUpDownAnalysis(bTraceUp, + selLineFeature, selLayer); + } + + /// + /// 流向分析 + /// + /// + /// + private void buttonItemFX3_4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX3_4.Text); + + FrmFlow frm = new FrmFlow(globeControl1, m_PipelineLayerNames); + frm.Show(this); + } + /// + /// 关阀分析 + /// + /// + /// + private void buttonItemFX3_5_Click(object sender, EventArgs e) + { + if (globeControl1.Globe.SelObjectCount < 1) + { + MessageBox.Show("请选中至少一根管线!!"); + buttonItemFX3_5.Checked = false; + return; + } + GSOLayer resLayer = null; + GSOFeature resFeature = null; + globeControl1.Globe.GetSelectObject(0, out resFeature, out resLayer); + + String pipeLayerName = resLayer.Caption; + String pipeLayerNamePrefix = pipeLayerName.Substring(0, pipeLayerName.IndexOf("管线")); + GSOLayer valveLayer = globeControl1.Globe.Layers[pipeLayerNamePrefix + "阀门"]; + if (valveLayer == null) + { + MessageBox.Show("无" + pipeLayerNamePrefix+"阀门图层", "提示"); + return; + } + + GSOFeatures valveFeats = NetworkAnalysisTool.CloseValvesAnalysis(resFeature, + resLayer, valveLayer); + + if (valveFeats != null) + { + FrmCloseValves frm = new FrmCloseValves(this.globeControl1, valveFeats); + frm.Show(this); + } + else + { + MessageBox.Show("未找到关闭阀门"); + } + } + + /// + /// 连通分析 + /// + /// + /// + private void buttonItemFX3_6_Click(object sender, EventArgs e) + { + if (globeControl1.Globe.SelObjectCount < 2) + { + MessageBox.Show("请选中至少两个管线!!"); + buttonItemFX3_6.Checked = false; + return; + } + GSOFeature selFeat0, selFeat1; + GSOLayer layer0,layer1; + globeControl1.Globe.GetSelectObject(0, out selFeat0, out layer0); + globeControl1.Globe.GetSelectObject(1, out selFeat1, out layer1); + + if (!layer0.IsSameInnerObject(layer1)) + { + MessageBox.Show("不在同一个图层!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); + buttonItemFX3_6.Checked = false; + return; + } + NetworkAnalysisTool.ConnexityAnalysis(selFeat0, selFeat1, layer0); + } + /// + /// 爆管分析 + /// + /// + /// + private void buttonItemFX3_7_Click(object sender, EventArgs e) + { + NetworkTraceUpDown(true); //上游追踪: + + GSOFeature selLineFeature = globeControl1.Globe.SelectedObject; + if (selLineFeature == null || selLineFeature.Geometry == null || selLineFeature.Geometry.Type != EnumGeometryType.GeoPolyline3D) + { + MessageBox.Show("请点击“编辑”—“选中对象”选择一条线!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); + return; + } + GSOLayer selLayer = globeControl1.Globe.SelectedObjectLayer; + + NetworkAnalysisTool.ExplodeAnalysis(this.globeControl1,selLineFeature,selLayer); + + this.buttonItemFX3_5_Click(sender, e); //关阀分析: + + } + + #endregion + /// + /// 多边形开挖 + /// + /// + /// + private void buttonItemFX4_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_1.Text); + + trackflag = "pit"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; //是这个么?是的,在模型上 + } + /// + /// 挖方量分析 + /// + /// + /// + private void buttonItemFX4_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_2.Text); + + trackflag = "digFillAnalysis"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; + ActionToolMenuChecked(); + } + /// + /// 沿线开挖 + /// + /// + /// + private void buttonItemFX4_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_3.Text); + + if (!buttonItemFX4_3.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; + buttonItemFX4_3.Checked = true; + } + } + else + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + buttonItemFX4_3.Checked = false; + globeControl1.Globe.TrackPolylineTool.VerticalLineVisible = false; + } + ActionToolMenuChecked(); + } + /// + /// 创建隧道 + /// + /// + /// + private void buttonItemFX4_4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_4.Text); + + 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("场景中未加载隧道图层!", "提示"); + } + } + /// + /// 隐藏隧道 + /// + /// + /// + private void buttonItemFX4_5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_5.Text); + + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption("隧道"); + if (layer != null) + { + layer.Visible = !layer.Visible; + } + } + /// + /// 删除隧道 + /// + /// + /// + private void buttonItemFX4_6_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_6.Text); + + 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("请选中要删除的隧道!", "提示"); + } + } + /// + /// 通视分析 + /// + /// + /// + private void buttonItemFX5_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX5_1.Text); + + if (globeControl1.Globe.Action != EnumAction3D.VisibilityAnalysis) + { + //btnSpaceVisibilityAnalysis.Checked = true; + globeControl1.Globe.Action = EnumAction3D.VisibilityAnalysis; + } + else + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + // SetButtonChecked(); + } + } + /// + /// 可视域分析 + /// + /// + /// + private void buttonItemFX5_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX5_2.Text); + + globeControl1.Globe.Action = EnumAction3D.ViewshedAnalysis; + } + /// + /// 可视包络分析 + /// + /// + /// + private void buttonItemFX5_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX5_3.Text); + + globeControl1.Globe.Action = EnumAction3D.ViewEnvelopeAnalysis; + } + /// + /// 缓冲区分析 + /// + /// + /// + private void buttonItemFX6_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX6_1.Text); + + GSOFeature feat = globeControl1.Globe.SelectedObject; + if (feat == null) + { + MessageBox.Show("请选择要分析的要素!"); + return; + } + if (feat.Geometry.Type == EnumGeometryType.GeoPolyline3D) + { + GSOGeoPolyline3D line1 = feat.Geometry as GSOGeoPolyline3D; + if (line1 == null) + { + MessageBox.Show("请选择一条管线!"); + return; + } + + FrmBufferAnalysis frm = new FrmBufferAnalysis(globeControl1, line1, layerTemp); + frm.Show(this); + } + else + { + FrmBufferAnalysisBSQ frm = new FrmBufferAnalysisBSQ(globeControl1, layerTemp, bsqPT); + frm.Show(this); + } + + } + /// + /// 附属物分析 + /// + /// + /// + private void buttonItemFX6_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX6_2.Text); + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + FrmAccessoryAnalysis dlg = new FrmAccessoryAnalysis(globeControl1, layerTemp); + dlg.Show(this); + } + /// + /// 无源淹没分析 + /// + /// + /// + private void buttonItemFX6_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX6_3.Text); + + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + trackflag = "FloodAnalysis"; + } + /// + /// 水平距离 + /// + /// + /// + private void buttonItemLS1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS1.Text); + + globeControl1.Globe.Action = EnumAction3D.MeasureDistance; + globeControl1.Globe.DistanceRuler.SpaceMeasure = false; + buttonItemLS5.Checked = false; + } + /// + /// 垂直距离 + /// + /// + /// + private void buttonItemLS2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS2.Text); + + buttonItemLS5.Checked = false; + globeControl1.Globe.Action = EnumAction3D.MeasureHeight; + globeControl1.Globe.DistanceRuler.SpaceMeasure = false; + } + /// + /// 空间距离 + /// + /// + /// + private void buttonItemLS3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS3.Text); + + buttonItemLS5.Checked = false; + globeControl1.Globe.Action = EnumAction3D.MeasureDistance; + globeControl1.Globe.DistanceRuler.SpaceMeasure = true; + } + /// + /// 地表距离 + /// + /// + /// + private void buttonItemLS4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS4.Text); + + buttonItemLS5.Checked = false; + globeControl1.Globe.Action = EnumAction3D.MeasureDistance; + globeControl1.Globe.DistanceRuler.SpaceMeasure = false; + } + /// + /// 高度量算 + /// + /// + /// + private void buttonItemLS5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS5.Text); + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + buttonItemLS5.Checked = !buttonItemLS5.Checked; + if (buttonItemLS5.Checked) + { + globeControl1.Globe.Action = EnumAction3D.SelectObject; + } + } + /// + /// 水平面积 + /// + /// + /// + private void buttonItemLS6_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS6.Text); + + buttonItemLS5.Checked = false; + globeControl1.Globe.Action = EnumAction3D.MeasureArea; + globeControl1.Globe.AreaRuler.SpaceMeasure = true; + } + /// + /// 地表面积 + /// + /// + /// + private void buttonItemLS7_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS7.Text); + + buttonItemLS5.Checked = false; + globeControl1.Globe.Action = EnumAction3D.MeasureArea; + globeControl1.Globe.AreaRuler.SpaceMeasure = false; + + } + + # region Fan 重构标注代码 + /// + /// 标高标注 + /// + /// + /// + private void buttonItemSZ1_Click(object sender, EventArgs e) + { + GSOFeature resFeature = IsPipeLineOfSelectedObj(); + if (resFeature == null) + { + MessageBox.Show("请选中一根管线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + GSOGeoPolyline3D selLine = resFeature.Geometry as GSOGeoPolyline3D; + if (selLine[0].Count <= 1) + { + return; + } + + MarkTools.getInstance().showMarker(resFeature, + globeControl1, EnumMarkLayer.Mark_Altitude, ""); + } + /// + /// 管径标注 + /// + GSOFeature radiusMarkerFeature; + private void buttonItemBZ2_Click(object sender, EventArgs e) + { + GSOFeature resFeature = IsPipeLineOfSelectedObj(); + if (resFeature == null) + { + MessageBox.Show("请选中一根管线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + GSOGeoPolyline3D selLine = resFeature.Geometry as GSOGeoPolyline3D; + if (selLine[0].Count <= 1) + { + return; + } + + MarkTools.getInstance().showMarker(resFeature, + globeControl1, EnumMarkLayer.Mark_Diameter, ""); + } + /// + /// 埋深标注 + /// + /// + /// + private void buttonItemBZ3_Click(object sender, EventArgs e) + { + GSOFeature resFeature = IsPipeLineOfSelectedObj(); + if (resFeature == null) + { + MessageBox.Show("请选中一根管线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + GSOGeoPolyline3D selLine = resFeature.Geometry as GSOGeoPolyline3D; + if (selLine[0].Count <=1) + { + return; + } + + MarkTools.getInstance().showMarker(resFeature, + globeControl1, EnumMarkLayer.Mark_Depth, ""); + + } + /// + /// 坐标标注 + /// + /// + /// + private void buttonItemBZ4_Click(object sender, EventArgs e) + { + GSOFeature resFeature = IsPipeLineOfSelectedObj(); + if (resFeature == null) + { + MessageBox.Show("请选中一根管线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + GSOGeoPolyline3D selLine = resFeature.Geometry as GSOGeoPolyline3D; + if (selLine[0].Count <= 1) + { + return; + } + MarkTools.getInstance().showMarker(resFeature, + globeControl1, EnumMarkLayer.Mark_Location, ""); + } + /// + /// 距离标注 + /// + bool distanceMarker = false; + private void buttonItemBZ5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBZ5.Text); + + globeControl1.Globe.Action = EnumAction3D.TrackPolyline; + //globeControl1.Globe.DistanceRuler.MeasureMode = EnumDistanceMeasureMode.HVSLineMeasure; + distanceMarker = true; + } + /// + /// 自定义标注 + /// + /// + /// + private void buttonItemBZ6_Click(object sender, EventArgs e) + { + GSOFeature f = globeControl1.Globe.SelectedObject; + GSOLayer l = globeControl1.Globe.SelectedObjectLayer; + FrmCustomLabel frm = new FrmCustomLabel(globeControl1, l, f); + if (frm.ShowDialog() == DialogResult.OK) + { + MarkTools.getInstance().showMarker(f, globeControl1, EnumMarkLayer.Mark_Custom, frm.labelText); + } + } + /// + /// 扯旗标注 + /// + /// + /// + private void buttonItemBZ7_Click(object sender, EventArgs e) + { + GSOFeature f = globeControl1.Globe.SelectedObject; + GSOLayer l = globeControl1.Globe.SelectedObjectLayer; + FrmMarker frm = new FrmMarker(); + if (frm.ShowDialog() == DialogResult.OK) + { + MarkTools.getInstance().showMarker(f, globeControl1, EnumMarkLayer.Mark_Custom, frm.markerContent); + } + } + /// + /// 坡度标注 + /// + /// + /// + private void buttonItemBZ8_Click(object sender, EventArgs e) + { + GSOFeature resFeature = IsPipeLineOfSelectedObj(); + if (resFeature == null) + { + MessageBox.Show("请选中一根管线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + GSOGeoPolyline3D selLine = resFeature.Geometry as GSOGeoPolyline3D; + if (selLine[0].Count <= 1) + { + return; + } + + MarkTools.getInstance().showMarker(resFeature, + globeControl1, EnumMarkLayer.Mark_Slope, ""); + } + /// + /// 属性标注 + /// + /// + /// + private void buttonItemBZ9_Click(object sender, EventArgs e) + { + GSOFeature f = globeControl1.Globe.SelectedObject; + GSOLayer l = globeControl1.Globe.SelectedObjectLayer; + FrmPropertiesMarker frm = new FrmPropertiesMarker(globeControl1, l, f); + if (frm.ShowDialog() == DialogResult.OK) + { + MarkTools.getInstance().showMarker(f, globeControl1, EnumMarkLayer.Mark_Property, frm.labelText); + } + } + /// + /// 红线工具 + /// + /// + /// + private void buttonItemBZ10_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBZ10.Text); + 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; + } + } + /// + /// 标注管理 + /// + /// + /// + private void buttonItemBZ11_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBZ11.Text); + + buttonItemBZ11.Checked = !buttonItemBZ11.Checked; + 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 (buttonItemBZ11.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(); + } + } + + #endregion + /// + /// 飞行到目标点 + /// + /// + /// + private void buttonItemFXGJ1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFXGJ1.Text); + + FrmSetFlytoPos.ShowForm(globeControl1); + + } + /// + /// 自定义飞行 + /// + /// + /// + private void buttonItemFXGJ2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFXGJ2.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); + } + } + /// + /// 绕中心点飞行 + /// + /// + /// + private void buttonItemFXGJ3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFXGJ3.Text); + + globeControl1.Globe.FlyAroundCenter(10000, EnumFlyRepeatValueType.MiliSeconds); + globeControl1.Globe.CurFlyID = 1; + } + /// + /// 绕眼睛飞行 + /// + /// + /// + private void buttonItemFXGJ4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFXGJ4.Text); + + globeControl1.Globe.FlyAroundEye(720, EnumFlyRepeatValueType.Degrees); + globeControl1.Globe.CurFlyID = 2; + } + + /// + /// 权限管理 + /// + /// + /// + private void buttonItemXT1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT1.Text); + + FrmUserRoleMgr frm = new FrmUserRoleMgr(); + frm.ShowDialog(); + } + /// + /// 数据库管理 + /// + /// + /// + private void buttonItemXT2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT2.Text); + + //查看数据库列表 + FrmDbManager frm = new FrmDbManager(); + frm.ShowDialog(); + } + /// + /// 用户列表 + /// + /// + /// + private void buttonItemXT3_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT3_1.Text); + + FrmUserManager frm = new FrmUserManager(); + frm.ShowDialog(); + } + /// + /// 创建新用户 + /// + /// + /// + private void buttonItemXT3_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT3_2.Text); + + FrmUserAdd frm = new FrmUserAdd(-1); + frm.ShowDialog(); + } + /// + /// 人员修改 + /// + /// + /// + private void buttonItemXT4_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT4_2.Text); + + FrmAppUSER appUSER = new FrmAppUSER(); + appUSER.ShowDialog(); + } + /// + /// 增加人员 + /// + /// + /// + private void buttonItemXT4_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT4_1.Text); + + FrmAppUSERRESET appUSERRESET = new FrmAppUSERRESET(); + appUSERRESET.ShowDialog(); + } + /// + /// 统计数据 + /// + /// + /// + private void buttonItemZTT1_Click(object sender, EventArgs e) + { + ////日志记录 + //LogManager.saveLog(Utility.userName, this.buttonItemZTT1.Text); + + //PATM patm = new PATM(); + //patm.operation = "Statistic"; + //patm.Text = "统计专题图管理"; + //patm.ShowDialog(); + } + /// + /// 热点功能统计 + /// + /// + /// + private void buttonItemZTT2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT2.Text); + + FrmHotFuncStat frmhfs = new FrmHotFuncStat(); + frmhfs.ShowDialog(); + } + + private void buttonItemZTT3_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT3_1.Text); + + FrmAPP appfrm = new FrmAPP("专题图申请"); + appfrm.ShowDialog(); + } + + private void buttonItemZTT3_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT3_2.Text); + + FrmAPPFORASK appForask = new FrmAPPFORASK("专题图审核"); + appForask.ShowDialog(); + } + + private void buttonItemZTT3_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT3_3.Text); + + FrmAPPregion appregion = new FrmAPPregion("专题图审核"); + appregion.ShowDialog(); + } + + private void buttonItemZTT4_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT4_1.Text); + + FrmAPP appfrm = new FrmAPP("打印申请"); + appfrm.ShowDialog(); + } + + private void buttonItemZTT4_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT4_2.Text); + + FrmAPPFORASK appForask = new FrmAPPFORASK("打印审核"); + appForask.ShowDialog(); + } + + private void buttonItemZTT4_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT4_3.Text); + + FrmAPPregion appregion = new FrmAPPregion("打印审核"); + appregion.ShowDialog(); + } + + private void buttonItemZTT5_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT5_1.Text); + + FrmAPP appfrm = new FrmAPP("拷贝申请"); + appfrm.ShowDialog(); + } + + private void buttonItemZTT5_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT5_2.Text); + + FrmAPPFORASK appForask = new FrmAPPFORASK("拷贝审核"); + appForask.ShowDialog(); + } + + private void buttonItemZTT5_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT5_3.Text); + + FrmAPPregion appregion = new FrmAPPregion("拷贝审核"); + appregion.Show(); + } + + private int connectServerCount = 0; + + /// + /// 还原球到实测库 + /// + 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); + } + + if (layerManagerNode.Nodes.Count > 0) + { + for (int i = layerManagerNode.Nodes.Count - 1; i >= 0; i--) + { + layerManagerNode.Nodes[i].Remove(); + + } + } + + globeControl1.Refresh(); + + } + + private void buttonItemSPSZ_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSPSZ.Text); + + FrmLayerControl frm = new FrmLayerControl(layerTree, globeControl1, globeControl2); + frm.Show(this); + } + + /// + /// 碰撞审查 + /// + /// + /// + private void buttonItemSH1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSH1.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 buttonItemSH2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSH2.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 buttonItemSH3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSH3.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 buttonItemSH4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSH4.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 buttonItemSH5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSH5.Text); + FrmCityServerLineAnalysis frm = new FrmCityServerLineAnalysis(globeControl1, m_PipelineLayerNames); + frm.Show(this); + } + #region 数据管理-导入文件 + ///// + ///// 数据管理-导入本地坐标系文件 + ///// + ///// + ///// + //private void buttonItemSJGL1_1_Click(object sender, EventArgs e) + //{ + // //日志记录 + // LogManager.saveLog(Utility.userName, this.buttonItemSJGL1_1.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(); + // } + // } + //} + + ///// + ///// 数据管理-导入其他坐标系文件 + ///// + ///// + ///// + //private void buttonItemSJGL1_2_Click(object sender, EventArgs e) + //{ + // //日志记录 + // LogManager.saveLog(Utility.userName, this.buttonItemSJGL1_2.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(); + // } + // } + //} + #endregion + /// + /// 数据质量检查 + /// + /// + /// + private void buttonItemSJGL2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL2.Text); + FrmValiData frm = new FrmValiData(globeControl1); + frm.ShowDialog(); + } + /// + /// 数据预处理 + /// + /// + /// + private void buttonItemSJGL3_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL3.Text); + + FrmEditShapeFile frm = new FrmEditShapeFile(globeControl1); + frm.ShowDialog(this); + } + /// + /// 连接数据库 + /// + /// + /// + private void buttonItemSJGL4_1_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL4_1.Text); + + FrmDatabaseParaSetting frm = new FrmDatabaseParaSetting(globeControl1); + if (frm.ShowDialog() == DialogResult.OK) + { + ds = FrmDatabaseParaSetting.ds; + if (ds != null) + { + ds.IsCloseSaved = false; + } + } + } + /// + /// 管线入库 + /// + /// + /// + private void buttonItemSJGL4_2_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL4_2.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 buttonItemSJGL4_3_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL4_3.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 buttonItemSJGL5_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL5.Text); + + Cyberpipe.Forms.FrmProject frm = new Cyberpipe.Forms.FrmProject(); + frm.ShowDialog(); + } + /// + /// 元数据基本管理 + /// + /// + /// + private void buttonItemSJGL6_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL6_1.Text); + + FrmMetadata frmmd = new FrmMetadata(); + frmmd.ShowDialog(); + } + /// + /// 元数据查询管理 + /// + /// + /// + private void buttonItemSJGL6_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL6_2.Text); + + FrmMetadataStat frmmds = new FrmMetadataStat(); + //frmmds.Show(); + frmmds.ShowDialog(); + } + /// + /// 操作日志管理 + /// + /// + /// + private void buttonItemSJGL7_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL7.Text); + + FrmLogOper frmlo = new FrmLogOper(); + frmlo.ShowDialog(); + } + /// + /// 数据字典管理 + /// + /// + /// + private void buttonItemSJGL8_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL8.Text); + + FrmMDDictory frmmdd = new FrmMDDictory(); + frmmdd.ShowDialog(); + } + /// + /// 数据库备份 + /// + /// + /// + private void buttonItemSJGL9_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL9.Text); + + //新 + FrmBACKORACLE backOracle = new FrmBACKORACLE(); + backOracle.Show(); + } + /// + /// 创建管段 + /// + /// + /// + private void buttonItemBJ1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ1.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; + } + } + /// + /// 创建附属物 + /// + /// + /// + private void buttonItemBJ2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ2.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); + } + } + /// + /// 创建特征管点 + /// + /// + /// + private void buttonItemBJ3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ3.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); + } + } + /// + /// 绘制城市七线 + /// + /// + /// + private void buttonItemBJ4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ4.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; + } + } + } + /// + /// 选中对象 + /// + /// + /// + private void buttonItemBJ5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ5.Text); + + globeControl1.Globe.Action = EnumAction3D.SelectObject; + } + /// + /// 平移对象 + /// + /// + /// + private void buttonItemBJ6_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ6.Text); + + globeControl1.Globe.Action = EnumAction3D.MoveObject; + } + /// + /// 升降对象 + /// + /// + /// + private void buttonItemBJ7_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ7.Text); + + globeControl1.Globe.Action = EnumAction3D.ElevateObject; + } + /// + /// 旋转对象 + /// + /// + /// + private void buttonItemBJ8_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ8.Text); + + globeControl1.Globe.Action = EnumAction3D.RotateObject; + } + /// + /// 连接管段 + /// + /// + /// + private void buttonItemBJ9_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ9.Text); + + if (globeControl1.Globe.SelObjectCount < 2) + { + MessageBox.Show("对不起,请至少选中2个对象!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + return; + } + globeControl1.Globe.InsertJointPipeline(false); + } + /// + /// 后退 + /// + /// + /// + private void buttonItemBJ11_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemBJ11.Text); + globeControl1.Globe.UnDoEdit(); + } + /// + /// 前进 + /// + /// + /// + private void buttonItemBJ12_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemBJ12.Text); + + globeControl1.Globe.ReDoEdit(); + } + /// + /// 导出CAD + /// + /// + /// + private void buttonItemBJ10_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ10_1.Text); + + #region 导出成dxf格式 + List listVectorNames = new List(); + 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(); + #endregion + } + /// + /// 导出矢量 + /// + /// + /// + private void buttonItemBJ10_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ10_2.Text); + + List listVectorNames = new List(); + 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 buttonItemBJ13_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemBJ13.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(); + } + } + MessageBox.Show("删除成功!", "提示"); + } + else + { + MessageBox.Show("请选中要删除的模型!", "提示"); + } + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + } + + private void buttonItemHX1_1_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]; + string filePath = dlg.FileName; + string lastname = Path.GetFileName(filePath); + + 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(); + } + + } + } + } + + public struct LineStruct + { + public string layerName; + public string layerCode; + public string lineLength; + public string hxName; + } + + List lineStruct = new List(); + List featsList = new List(); + + /// + /// 红线审核 + /// + /// + /// + private void buttonItemHX2_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemHX2.Text); + redSH = true; + featsList.Clear(); + lineStruct.Clear(); + List listPipelineLayers = new List(); + + GSOLayer layer = null; + for (int i = 0; i < m_PipelineLayerNames.Count; i++) + { + layer = globeControl1.Globe.Layers.GetLayerByCaption(m_PipelineLayerNames[i]); + if (layer != null) + { + listPipelineLayers.Add(layer); + } + } + //yanxiaowei 重构 + GSOFeatures selectFeatures=new GSOFeatures(); + for (int i = 0; i < globeControl1.Globe.SelObjectCount; i++) + { + GSOFeature feature = null; + globeControl1.Globe.GetSelectObject(i, out feature, out layer); + selectFeatures.Add(feature); + } + DataTable table=new DataTable(); + + ClassGSOTool.CalculateRedLineResult(out table, redSH, selectFeatures, globeControl1, + listPipelineLayers,out lineStruct, out featsList); + + if (table.Rows.Count != 0) + AddDatagridView(table); + else + { + MessageBox.Show("没有侵入地块红线的管线数据!", "提示"); + dataGridViewX1.DataSource = null; + panelOfTable.Visible = false; + return; + } + } + + private void AddDatagridView(DataTable table) + { + dataGridViewX1.DataSource = table; + panelOfTable.Visible = true; + panelOfTable.Height = 200; + toolStripNumbers.Text = "红线审核 |共有:" + table.Rows.Count + "条"; + toolStripDropDownButton3.Visible = true; + } + /// + /// 主窗体 下方的工具条中的 导出.xls文件 按钮事件处理 + /// + /// + /// + private void toolStripDropDownButton3_Click(object sender, EventArgs e) + { + if (dataGridViewX1.Rows.Count == 0) + { + MessageBox.Show("表格内容为空!", "提示"); + return; + } + + string strSaveFile = string.Empty; + SaveFileDialog savefiledialog = new SaveFileDialog(); + savefiledialog.Filter = "Excel文件|*.xls,*.xlsx"; + savefiledialog.AddExtension = true; + savefiledialog.FileName = "红线审核"; + if (savefiledialog.ShowDialog() == DialogResult.OK) + strSaveFile = savefiledialog.FileName; + else return; + + ExpEXCEL.ExpToExcel(dataGridViewX1, strSaveFile, "红线审核", lineStruct, featsList); + MessageBox.Show("导出成功!"); + } + /// + /// 去除集合中重复的管线 + /// + /// + /// + /// + private GSOFeatures getFeaturesByFilter(GSOFeatures features, string fieldName) + { + if (features == null) + { + return null; + } + GSOFeatures featuresGet = new GSOFeatures(); + for (int i = 0; i < features.Length; i++) + { + GSOFeature featureFromFS = features[i]; + string fieldValueFromFS = featureFromFS.GetValue(fieldName).ToString().Trim(); + bool isHas = false; + for (int j = featuresGet.Length - 1; j >= 0; j--) + { + GSOFeature featureFromFSGet = featuresGet[j]; + string fieldValueFromFSGet = featureFromFSGet.GetValue(fieldName).ToString().Trim(); + if (fieldValueFromFS.Equals(fieldValueFromFSGet)) + { + isHas = true; + break; + } + } + if (isHas == false) + { + featuresGet.Add(featureFromFS.Clone()); + } + } + return featuresGet; + } + + private void sliderItem2_ValueChanged(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.sliderItem2.Text); + + globeControl1.Globe.GroundOpaque = 100 - sliderItem2.Value; + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(roadLayerName);//("180fd"); + if (layer != null) + { + layer.Opaque = 100 - sliderItem2.Value; + } + layer = globeControl2.Globe.Layers.GetLayerByCaption("180fd");//("180fd"); + if (layer != null) + { + layer.Opaque = 100 - sliderItem2.Value; + } + globeControl2.Globe.GroundOpaque = 100 - sliderItem2.Value; + + optiValue = sliderItem2.Value; + } + /// + /// 数据管理导入文件 + /// + /// + /// + private void buttonItemSJGL1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL1.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.Multiselect = true; + if (dlg.ShowDialog() == DialogResult.OK) + { + //自定义lprj文件名,从程序中复制一lprj文件。 + string filePath = dlg.FileName; + string lastname = Path.GetFileName(filePath); + + 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, 100); + + globeControl1.Refresh(); + } + } + } + + private void buttonItemHX1_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemHX1.Text); + + GSODataSource dataSpace = globeControl1.Globe.DataManager.OpenOracleDataSource(Utility.DBServer.Trim() + "/" + Utility.dbdatabase.Trim(), "", "", Utility.userID, Utility.DBPassword); + string filepath = ""; + //日志记录 + OpenFileDialog dlg = new OpenFileDialog(); + dlg.Filter = "矢量数据(*.shp)|*.shp|矢量数据(*.lgd)|*.lgd|CAD数据(*.dxf)|*.dxf|全部支持格式(*.lgd,*.shp,*.dxf)|*.lgd;*.shp;*.dxf;"; + dlg.Multiselect = true; + + #region 临时图层显示 + if (dlg.ShowDialog() == DialogResult.OK) + { + string filePath = dlg.FileName; + string lastname = Path.GetFileName(filePath); + + #region + for (int i = 0; i < dlg.FileNames.Length; i++) + { + string strDataPath = dlg.FileNames[i]; + filepath = strDataPath; + + GSOLayer layer = globeControl1.Globe.Layers.Add(strDataPath); + GSOFeatures RedFeatures = layer.GetAllFeatures(); + + 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(); + RedFeatures = features; + 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; + } + + /////////////////////////////////////////////////////////////////////////////////////////// + globeControl1.Globe.Layers.MoveTo(0, globeControl1.Globe.Layers.Count - 1); + globeControl1.Refresh(); + } + + IModelBuilder modelBuilder = new RedLineBuilder(); + + modelBuilder.batchInsert(dataSpace, redDt, RedFeatures); + + } + #endregion + + } + #endregion + } + /// + /// 定位 + /// + /// + /// + private void buttonItemLocation_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemLocation.Text); + + FrmFlyToPosition fly = new FrmFlyToPosition(globeControl1,globeControl2); + fly.Show(this); + } + /// + /// 2015-10-17演示代码 红线审核 + /// + /// + /// + private void ribbonTabItem6_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.FlyToPosition(new GSOPoint3d(120.610963, 31.188121, 50), EnumAltitudeMode.Absolute, -4, 50, 800); + globeControl1.Globe.FlyToPointSpeed = 10000000; + globeControl1.Globe.Action = EnumAction3D.SelectObject; + globeControl1.Refresh(); + + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + + //zhanshi = false; + redSH = true; + splitContainer1.Panel2Collapsed = true; + legendSG.Visible = false; + legendSC.Visible = false; + ClearGZData(); + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = true; + } + + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 基础工具 + /// + /// + /// + private void ribbonTabItem1_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + //zhanshi = false; + redSH = false; + splitContainer1.Panel2Collapsed = true; + panelOfTable.Visible = false; + legendSC.Visible = false; + legendSG.Visible = false; + ClearGZData(); + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + + + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 一键审核 + /// + /// + /// + private void ribbonTabItem11_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + //zhanshi = false; + redSH = false; + splitContainer1.Panel2Collapsed = true; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + panelOfTable.Visible = false; + legendSC.Visible = false; + legendSG.Visible = false; + ClearGZData(); + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + + + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 右屏添加冰箱数据 + /// + void AddDataToGlobeControl2() + { + + bool modelDataBool = false; + for (int i = globeControl2.Globe.Layers.Count - 1; i >= 0; i--) + { + GSOLayer layer = globeControl2.Globe.Layers[i]; + if (layer.Name.Contains("fttp:")) + { + modelDataBool = true; + break; + } + } + + if (modelDataBool == false) + { + GSOLayer ly = globeControl1.Globe.Layers.GetLayerByCaption("天地图地图"); + globeControl2.Globe.Layers.Add(ly); + } + else + { + return; + } + } + /// + /// 双屏对比 + /// + /// + /// + private void ribbonTabItem9_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent += new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent += new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + panelOfTable.Visible = false; + + splitContainer1.Panel2Collapsed = false; + //zhanshi = true; + redSH = false; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + sliderItem2.Value = 100 - globeControl1.Globe.GroundOpaque; + globeControl2.Globe.GroundOpaque = globeControl1.Globe.GroundOpaque; + legendSC.Visible = true; + legendSG.Visible = true; + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + AddDataToGlobeControl2(); + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 文档管理 + /// + /// + /// + private void ribbonTabItem4_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + panelOfTable.Visible = false; + //zhanshi = false; + redSH = false; + splitContainer1.Panel2Collapsed = true; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + legendSC.Visible = false; + legendSG.Visible = false; + ClearGZData(); + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 基础管理 + /// + /// + /// + private void ribbonTabItem14_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + panelOfTable.Visible = false; + //zhanshi = false; + redSH = false; + splitContainer1.Panel2Collapsed = true; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + legendSC.Visible = false; + legendSG.Visible = false; + ClearGZData(); + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 权限管理 + /// + /// + /// + private void ribbonTabItem2_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + panelOfTable.Visible = false; + //zhanshi = false; + redSH = false; + splitContainer1.Panel2Collapsed = true; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + legendSC.Visible = false; + legendSG.Visible = false; + ClearGZData(); + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + GSOFeature dpFeatuer = null; + /// + /// 双屏分析,点击管段分析 + /// + /// + /// + private void buttonItem8_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItem8.Text); + + //FrmCompareFeature frmCompareFeature = new FrmCompareFeature(globeControl1, globeControl2, layerTemp, layerTemp2,m_PipelineLayerNames,sgPipeLayersNames); + int width = this.Width; + FrmCompareFeature.ShowForm(globeControl1, globeControl2, layerTemp, layerTemp2, m_PipelineLayerNames, sgPipeLayersNames,width); + //frmCompareFeature.Location = new Point((this.Width - frmCompareFeature.Width)/2,50); + //frmCompareFeature.Show(this); + + } + /// + /// 红线审核导出图片 + /// + /// + /// + private void buttonItemDCTP_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemDCTP.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))); + */ + int mapWidth = 0; + int mapHeight = 0; + Point pt = getUpperLeftPoint(pt1, pt2, out mapWidth, out mapHeight); + int rightBottomX = pt.X + mapWidth; + int rightBottomY = pt.Y + mapHeight; + Image myImg = new Bitmap(mapWidth, mapHeight); + Graphics g = Graphics.FromImage(myImg); + g.CopyFromScreen(pt, new Point(0, 0), new Size(rightBottomX, rightBottomY)); + + 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; + } + } + } + /// + /// 标识器全区域统计 + /// + /// + /// + private void 标识器分类统计ToolStripMenuItem_Click(object sender, EventArgs e) + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + FrmBSQStatis bsqStatis = new FrmBSQStatis(); + bsqStatis.Show(this); + } + /// + /// 标识器绘制区域统计 + /// + /// + /// + private void 标识器分类统计ToolStripMenuItem1_Click(object sender, EventArgs e) + { + trackflag = "BSQDuoBianXiangStatis"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + } + + #region 保存和加载审核库加载的图层 + /* + private void saveLayerList(TreeNodeCollection treeNodeList) + { + string configPath = Application.StartupPath + "\\configLayerList.xml"; + try + { + XmlDocument doc = new XmlDocument(); + doc.Load(configPath); + XmlNode dbParams = doc.SelectSingleNode("Params/dbparams"); + XmlNode dbLayers = doc.SelectSingleNode("Params/dblayers"); + XmlNode layers = doc.SelectSingleNode("Params/layers"); + dbParams.RemoveAll(); + dbLayers.RemoveAll(); + layers.RemoveAll(); + + List listDS = new List(); + String shDatasourceName = Utility.sgdbip + "/" + Utility.sgdbname + "_" + Utility.sgdbuser; + bool flag = false; + + for (int i = 0; i < globeControl1.Globe.DataManager.DataSourceCount; i++) + { + GSODataSource ds = globeControl1.Globe.DataManager.GetDataSourceAt(i); + if (ds != null && ds.Type == EnumDataSourceType.SqlServer || ds.Type == EnumDataSourceType.Oracle) + { + if (ds.Name == shDatasourceName) + { + //防止因为多次连接同一个数据库 + if (flag == true) + { + break; + } + flag = true; + listDS.Add(ds); + GSODataSourceCnn conn = ds.GetConnectionInfo(); + + XmlElement dbparam = doc.CreateElement("shdbparam"); + XmlElement ip = doc.CreateElement("ship"); + ip.InnerText = conn.Server; + + XmlElement dbname = doc.CreateElement("shdbname"); + dbname.InnerText = conn.Database; + + XmlElement username = doc.CreateElement("shusername"); + username.InnerText = conn.User; + + XmlElement password = doc.CreateElement("shpassword"); + password.InnerText = conn.Password; + + XmlElement type = doc.CreateElement("shtype"); + if (ds.Type == EnumDataSourceType.SqlServer) + { + type.InnerText = "sqlserver"; + } + else + { + type.InnerText = "oracle"; + } + + dbparam.AppendChild(ip); + dbparam.AppendChild(dbname); + dbparam.AppendChild(username); + dbparam.AppendChild(password); + dbparam.AppendChild(type); + dbParams.AppendChild(dbparam); + } + + } + } + + for (int i = 0; i < treeNodeList.Count; i++) + { + GSOLayer layer = treeNodeList[i].Tag as GSOLayer; + if (Path.GetExtension(layer.Name) == "") + { + XmlElement dbLayer = doc.CreateElement("dblayer"); + XmlAttribute attri = doc.CreateAttribute("dbindex"); + for (int j = 0; j < listDS.Count; j++) + { + if (layer.Dataset.DataSource.Name == listDS[j].Name) + { + attri.Value = j.ToString(); + break; + } + } + dbLayer.Attributes.Append(attri); + dbLayer.InnerText = layer.Name; + + dbLayers.AppendChild(dbLayer); + } + else + { + XmlElement dbLayer = doc.CreateElement("layer"); + dbLayer.InnerText = layer.Name; + layers.AppendChild(dbLayer); + } + } + + doc.Save(configPath); + } + catch (Exception e) + { + + } + } + + private void openLayerList() + { + layerManagerNode.Nodes.Clear(); + + string configPath = Application.StartupPath + "\\configLayerList.xml"; + try + { + XmlDocument doc = new XmlDocument(); + doc.Load(configPath); + XmlNode dbParams = doc.SelectSingleNode("Params/dbparams"); + XmlNode dbLayers = doc.SelectSingleNode("Params/dblayers"); + XmlNode layers = doc.SelectSingleNode("Params/layers"); + + List listDS = new List(); + for (int i = 0; i < dbParams.ChildNodes.Count; i++) + { + string ip = ""; + string dbname = ""; + string username = ""; + string password = ""; + string type = ""; + XmlNode node = dbParams.ChildNodes.Item(i); + for (int j = 0; j < node.ChildNodes.Count; j++) + { + XmlNode nodeChild = node.ChildNodes.Item(j); + + if (nodeChild != null && nodeChild.Name == "ship") + { + ip = nodeChild.InnerText; + } + else if (nodeChild != null && nodeChild.Name == "shdbname") + { + dbname = nodeChild.InnerText; + } + else if (nodeChild != null && nodeChild.Name == "shusername") + { + username = nodeChild.InnerText; + } + else if (nodeChild != null && nodeChild.Name == "shpassword") + { + password = nodeChild.InnerText; + } + else if (nodeChild != null && nodeChild.Name == "shtype") + { + type = nodeChild.InnerText; + } + } + + if (type == "sqlserver") + { + GSODataSource ds = globeControl1.Globe.DataManager.OpenSqlServerDataSource(ip, "", dbname, username, password); + listDS.Add(ds); + } + else if (type == "oracle") + { + GSODataSource ds = globeControl1.Globe.DataManager.OpenOracleDataSource(ip + "/" + dbname, "", "", username, password); + listDS.Add(ds); + } + } + + for (int i = 0; i < dbLayers.ChildNodes.Count; i++) + { + XmlNode node = dbLayers.ChildNodes.Item(i); + if (node != null) + { + string layerName = node.InnerText; + XmlAttribute attri = node.Attributes["dbindex"]; + if (attri != null) + { + int dbIndex = -1; + if (int.TryParse(attri.Value, out dbIndex)) + { + GSODataset dataset = listDS[dbIndex].GetDatasetByName(layerName); + globeControl1.Globe.Layers.Add(dataset); + //更新树节点 + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + TreeNode layerNode = new TreeNode(); + layerNode.Tag = layer; + layerNode.Text = layer.Dataset.Caption; + layerNode.ImageIndex = 0; + layerNode.SelectedImageIndex = 0; + layerNode.Checked = layer.Visible; + layerManagerNode.Nodes.Insert(0, layerNode); + // layerManagerNode.Expand(); + + + } + } + } + } + for (int i = 0; i < layers.ChildNodes.Count; i++) + { + XmlNode node = layers.ChildNodes.Item(i); + if (node != null) + { + string layerName = node.InnerText; + globeControl1.Globe.Layers.Add(layerName); + + //更新树节点 + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + TreeNode layerNode = new TreeNode(); + layerNode.Tag = layer; + layerNode.Text = layer.Dataset.Caption; + layerNode.ImageIndex = 0; + layerNode.SelectedImageIndex = 0; + layerNode.Checked = layer.Visible; + layerManagerNode.Nodes.Insert(0, layerNode); + } + } + layerManagerNode.Expand(); + } + catch (Exception e) + { + + } + } + * */ + #endregion + + private void btn_check_history_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_check_history.Text); + + if (FrmCheckHistory.isOpen == true) + { + return; + } + FrmCheckHistory frm = new FrmCheckHistory(globeControl1, globeControl2); + frm.addNode += new AddNodeToLayerManagerNode(addNodeToLayerManagerNode); + frm.Show(); + + } + + private void buttonItem查看数据_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItem查看数据.Text); + + FrmThreeOracle tr = new FrmThreeOracle(globeControl1); + + if (tr.ShowDialog() == DialogResult.OK) + { + addNodeToLayerManagerNode(tr.rukuLayer); + globeControl1.Refresh(); + } + } + /// + /// 规划数据入库 + /// + /// + /// + private void buttonItemGHRK_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemGHRK.Text); + + FrmGHRK ghrk = new FrmGHRK(globeControl1, layerManagerNode); + ghrk.Show(this); + } + + private void btn_user_info_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_user_info.Text); + + if (!FrmSysUserInfoManger.IS_OPEN) + { + FrmSysUserInfoManger frm = new FrmSysUserInfoManger(); + frm.ShowDialog(); + } + } + + private void btn_role_info_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_role_info.Text); + + if (FrmRoleInfoManager.IS_OPEN) + { + return; + } + FrmRoleInfoManager frm = new FrmRoleInfoManager(); + frm.ShowDialog(); + } + + private void btn_resc_info_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_resc_info.Text); + + if (!SysRescInfoManager.IS_OPEN) + { + SysRescInfoManager frm = new SysRescInfoManager(); + frm.ShowDialog(); + } + } + + private void btn_role_resc_Click(object sender, EventArgs e) + { + + LogManager.saveLog(Utility.userName, this.btn_role_resc.Text); + + if (!FrmRoleRescManager.IS_OPEN) + { + FrmRoleRescManager frm = new FrmRoleRescManager(); + frm.ShowDialog(); + } + } + + private void btn_user_role_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_user_role.Text); + + if (FrmUserRole.IS_OPEN) + { + return; + } + FrmUserRole frm = new FrmUserRole(); + frm.ShowDialog(); + } + + private void btn_document_info_Click(object sender, EventArgs e) + { + + LogManager.saveLog(Utility.userName, this.btn_document_info.Text); + + //if (FormDocumentManager.IS_OPEN) + //{ + // return; + //} + //FormDocumentManager frm = new FormDocumentManager(); + //frm.ShowDialog(); + + //if (FormDocumentManager.IS_OPEN) + //{ + // return; + //} + //new FormDocumentManager().ShowDialog(); + if (FormDocumentManager.IS_OPEN) + { + return; + } + this.Cursor = Cursors.WaitCursor; + FormDocumentManager frm = new FormDocumentManager(); + frm.changeCursor += new ChangeCursor(changeCursorToDefault); + frm.ShowDialog(); + + } + + private void changeCursorToDefault() + { + this.Cursor = Cursors.Default; + } + + /// + /// 判断CAD文件是否有投影信息 + /// + /// + /// + Boolean CheckDatasetGeoReference(GSODataset dataset) + { + Boolean bSuccess = false; + if (dataset.GeoReferenceType == EnumGeoReferenceType.Flat) + { + if (MessageBox.Show("数据没有空间参考信息,请设置空间参考信息!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation) == DialogResult.OK) + { + String strPath = Path.GetDirectoryName(Application.ExecutablePath) + "\\Coordinate Systems"; + OpenFileDialog dlg = new OpenFileDialog(); + + dlg.InitialDirectory = strPath; + dlg.RestoreDirectory = true; + + dlg.Filter = "投影文件|*.prj||"; + if (dlg.ShowDialog() == DialogResult.OK) + { + bSuccess = dataset.LoadProjectionFromESRIFile(dlg.FileName); + } + } + } + else + { + return true; + } + return bSuccess; + } + + private void buttonItemexp_CAD_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemexp_CAD.Text); + + OpenFileDialog dlg = new OpenFileDialog(); + dlg.Filter = "支持格式(*.dwg)|*.dwg"; + dlg.Multiselect = true; + if (dlg.ShowDialog() == DialogResult.OK) + { + for (int i = 0; i < dlg.FileNames.Length; i++) + { + //this.Cursor = Cursors.WaitCursor; + string strDataPath = dlg.FileNames[i]; + + #region + //string strDataPathPrj = strDataPath.ToLower().Replace(".dwg", ".lprj"); + + //if (File.Exists(strDataPathPrj) == false) + //{ + // if (MessageBox.Show("数据没有空间参考信息,请设置空间参考信息!", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation) == DialogResult.OK) + // { + // String strPath = Application.StartupPath + "\\Coordinate Systems"; + // OpenFileDialog dlgPrj = new OpenFileDialog(); + // dlgPrj.InitialDirectory = strPath; + // dlgPrj.RestoreDirectory = true; + // dlgPrj.Multiselect = false; + // dlg.Filter = "投影文件|*.prj"; + // if (dlg.ShowDialog() == DialogResult.OK) + // { + // this.Cursor = Cursors.WaitCursor; + // string proj4 = GSODataEngineUtility.ConvertEsriPrjFileToProj4(dlg.FileName); + // using (StreamWriter stream = new StreamWriter(strDataPathPrj, false)) + // { + // stream.WriteLine("0prj4" + proj4 + ""); + // } + // AddLayerData(strDataPath); + // //globeControl1.Globe.Layers.Add(strDataPath); + + // this.Cursor = Cursors.Default; + // } + // else + // { + // AddLayerData(strDataPath); + // //globeControl1.Globe.Layers.Add(strDataPath); + // } + // } + // else + // { + // AddLayerData(strDataPath); + // //globeControl1.Globe.Layers.Add(strDataPath); + // } + + //} + //else + //{ + // //globeControl1.Globe.Layers.Add(strDataPath); + // AddLayerData(strDataPath); + //} + #endregion + AddLayerData(strDataPath); + //this.Cursor = Cursors.Default; + } + } + + 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, 100); + + globeControl1.Refresh(); + } + } + + private void btn_password_edit_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_password_edit.Text); + + if (FrmChangePassword.IS_OPEN) + { + return; + } + FrmChangePassword frm = new FrmChangePassword(); + frm.ShowDialog(); + } + /// + /// 多孔管线入库 + /// + /// + /// + private void buttonItem9_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL4_2.Text); + + if (ds == null) + { + MessageBox.Show("请先连接数据库", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + ConnectDB(null, null); + } + if (ds == null) + return; + + FrmMultiPipelineModelDB frm = new FrmMultiPipelineModelDB(globeControl1, ds); + if (frm.ShowDialog() == DialogResult.OK) + { + addNodeToLayerManagerNode(frm.rukuLayer); + } + //frm.Show(); + } + private void 导出CADToolStripMenuItem1_Click(object sender, EventArgs e) + { + TreeNode node = layerNodeContexMenu.Tag as TreeNode; + if (node == null) + { + MessageBox.Show("请在左侧节点集中选择要导出的图层", "提示"); + return; + } + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(node.Text.Trim()); + if (layer == null || layer.GetAllFeatures().Length <= 0) + { + MessageBox.Show("要导出的图层为空", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + return; + } + string strProjectName = Utility.projectStr; + if (strProjectName != "") + { + SaveFileDialog dlg = new SaveFileDialog(); + dlg.Filter = "*.dwg|*.dwg|*.dxf|*.dxf"; + dlg.FileName = layer.Caption; + if (dlg.ShowDialog(this) == DialogResult.OK) + { + globeControl1.Globe.MemoryLayer.SaveAs(dlg.FileName); + GSOLayer newlayer = globeControl1.Globe.Layers.Add(dlg.FileName); + newlayer.RemoveAllFeature(); + int featureCount = layer.GetAllFeatures().Length; + for (int i = 0; i < featureCount; i++) + { + GSOFeature feature = layer.GetAt(i); + if (feature != null && feature.Geometry != null) + { + if (feature.Geometry.Type == EnumGeometryType.GeoPolyline3D) + { + feature.Geometry.Style = new GSOSimpleLineStyle3D(); + } + else if (feature.Geometry.Type == EnumGeometryType.GeoPolygon3D) + { + feature.Geometry.Style = new GSOSimplePolygonStyle3D(); + } + newlayer.AddFeature(feature); + } + } + newlayer.Save(); + newlayer.Dataset.DataSource.RemoveDataset(newlayer.Dataset); + globeControl1.Globe.Layers.Remove(newlayer); + MessageBox.Show("导出CAD完成!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + } + } + } + + private void buttonItemGBJC_Click(object sender, EventArgs e) + { + FrmGBJC gb = new FrmGBJC(globeControl1, globeControl2, layerTemp, layerTemp2); + gb.Show(this); + } + + #region 右屏管纵数据控制 + private void 五十米主干道ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = true; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + + private void 三十六米次干道ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = true; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + + private void 四十二米次干道ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = true; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + + private void 二十四米一块板ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = true; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + + private void 二十四米三块板ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = true; + } + + private void 二十四米停车带ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = true; + lendendGZ24_3.Visible = false; + } + + private void 二十六米大堤路ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = true; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + + private void 清除管纵数据ToolStripMenuItem_Click(object sender, EventArgs e) + { + ClearGZData(); + } + + private void ClearGZData() + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + #endregion + + private void buttonItemPasswordReset_Click(object sender, EventArgs e) + { + Frm_password_reset reset = new Frm_password_reset(); + reset.Show(); + } + + private void pictureBox1_Paint(object sender, PaintEventArgs e) + { + int Width = this.Width; + string welcomeUser = "欢迎您:" + Utility.userName; + Graphics g = e.Graphics; + g.DrawString(welcomeUser, new Font("宋体", 12), new SolidBrush(Color.Black), Width - 180, 50); + } + + } +} \ No newline at end of file diff --git a/Cyberpipe.csproj b/Cyberpipe.csproj index 3a45ad8..d22f590 100644 --- a/Cyberpipe.csproj +++ b/Cyberpipe.csproj @@ -402,12 +402,6 @@ FrmBACKORACLE.cs - - Form - - - FrmBSQDuoBianXingStatis.cs - Form @@ -1271,9 +1265,6 @@ FrmBACKORACLE.cs - - FrmBSQDuoBianXingStatis.cs - FrmBSQStatis.cs diff --git a/FeatureStatisticsService.cs b/FeatureStatisticsService.cs index e833e5f..c7de210 100644 --- a/FeatureStatisticsService.cs +++ b/FeatureStatisticsService.cs @@ -273,19 +273,15 @@ /// 获取特定区域图层的管线列表,并将其总长度统计出来 ///
TODOLIST:将Intersects_Pipeline在MainFrm中去除 /// - /// + /// + /// 要统计的长度 /// public static GSOFeatures getLayerPipes(GSOGeoPolygon3D polygon, GSOLayer layer, out double length) { length = 0; if (layer == null) return null; - GSOFeatureLayer flayer = layer as GSOFeatureLayer; - GSOFeatureDataset fdataset = flayer.Dataset as GSOFeatureDataset; - GSOFeatures feats = null; - - feats = polygon == null?flayer.GetAllFeatures():flayer.FindFeaturesInPolygon(polygon, false); - + GSOFeatures feats = getLayerFeatures(polygon, layer); double totallength = 0.00; for (int i = 0; i < feats.Length; i++) { @@ -301,5 +297,17 @@ return feats; } + /// + /// 获取区域图层内的feature列表,MainFrm.PolygonIntersectAnalysis和此方法重复,需要整理删除 + /// + /// + /// + /// + public static GSOFeatures getLayerFeatures(GSOGeoPolygon3D polygon, GSOLayer layer) + { + if (layer == null) return null; + GSOFeatureLayer flayer = layer as GSOFeatureLayer; + return polygon == null ? flayer.GetAllFeatures() : flayer.FindFeaturesInPolygon(polygon, false); + } } } diff --git a/FrmAllWorkWellStatis.cs b/FrmAllWorkWellStatis.cs index 7bf65dc..bd0f81b 100644 --- a/FrmAllWorkWellStatis.cs +++ b/FrmAllWorkWellStatis.cs @@ -19,17 +19,7 @@ private Dictionary map = null; private GSOGlobeControl globeControl1; private GSOGeoPolygon3D polygon; - //TODOLIST:用晓伟的代理进行操作,功能拆分细化 - //public FrmAllWorkWellStatis(GSOGeoPolygon3D polygon, DataGridView dataGridViewX11, ToolStripStatusLabel toolStripNumbers1, GSOGlobeControl ctl, PanelEx p) - //{ - // InitializeComponent(); - // panel = p; - // dataGridViewX1 = dataGridViewX11; - // toolStripNumbers = toolStripNumbers1; - // globeControl1 = ctl; - // map = getAccsMap(polygon); - //} public FrmAllWorkWellStatis(GSOGlobeControl ctl,GSOGeoPolygon3D polygon, MainFrm.DataGridViewDelegate InitDataGridViewX1) { InitializeComponent(); @@ -117,8 +107,9 @@ sql = "select " + getpipeLineFields.getFields(layername, globeControl1) + " from " + layer.Name; sql += " where 1>2 "; - for (int i = 0; i < fs.Length && fs[i].GetFieldDefn("编号") != null; i++) + for (int i = 0; i < fs.Length; i++) { + if (fs[i].GetFieldDefn("编号") == null) continue; sql += " or 编号 = '" + fs[i].GetValue("编号").ToString() + "'"; } diff --git a/FrmBSQDuoBianXingStatis.Designer.cs b/FrmBSQDuoBianXingStatis.Designer.cs deleted file mode 100644 index bda6842..0000000 --- a/FrmBSQDuoBianXingStatis.Designer.cs +++ /dev/null @@ -1,87 +0,0 @@ -namespace Cyberpipe -{ - partial class FrmBSQDuoBianXingStatis - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea1 = new System.Windows.Forms.DataVisualization.Charting.ChartArea(); - this.groupBox1 = new System.Windows.Forms.GroupBox(); - this.chart1 = new System.Windows.Forms.DataVisualization.Charting.Chart(); - this.groupBox1.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.chart1)).BeginInit(); - this.SuspendLayout(); - // - // groupBox1 - // - this.groupBox1.Controls.Add(this.chart1); - this.groupBox1.Dock = System.Windows.Forms.DockStyle.Fill; - this.groupBox1.Location = new System.Drawing.Point(0, 0); - this.groupBox1.Name = "groupBox1"; - this.groupBox1.Size = new System.Drawing.Size(592, 384); - this.groupBox1.TabIndex = 0; - this.groupBox1.TabStop = false; - this.groupBox1.Text = "统计结果信息"; - // - // chart1 - // - chartArea1.AxisX.MajorGrid.Enabled = false; - chartArea1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(191)))), ((int)(((byte)(219)))), ((int)(((byte)(255))))); - chartArea1.BackGradientStyle = System.Windows.Forms.DataVisualization.Charting.GradientStyle.TopBottom; - chartArea1.Name = "ChartArea1"; - this.chart1.ChartAreas.Add(chartArea1); - this.chart1.Dock = System.Windows.Forms.DockStyle.Fill; - this.chart1.Location = new System.Drawing.Point(3, 17); - this.chart1.Name = "chart1"; - this.chart1.Size = new System.Drawing.Size(586, 364); - this.chart1.TabIndex = 0; - this.chart1.Text = "chart1"; - // - // FrmBSQDuoBianXingStatis - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(592, 384); - this.Controls.Add(this.groupBox1); - this.DoubleBuffered = true; - this.Name = "FrmBSQDuoBianXingStatis"; - this.ShowIcon = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; - this.Text = "多边形区域统计"; - this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FrmBSQDuoBianXingStatis_FormClosing); - this.Load += new System.EventHandler(this.FrmBSQDuoBianXingStatis_Load); - this.groupBox1.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)(this.chart1)).EndInit(); - this.ResumeLayout(false); - - } - - #endregion - - private System.Windows.Forms.GroupBox groupBox1; - private System.Windows.Forms.DataVisualization.Charting.Chart chart1; - } -} \ No newline at end of file diff --git a/FrmBSQDuoBianXingStatis.cs b/FrmBSQDuoBianXingStatis.cs deleted file mode 100644 index 80b567e..0000000 --- a/FrmBSQDuoBianXingStatis.cs +++ /dev/null @@ -1,179 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Windows.Forms; -using DevComponents.DotNetBar; -using System.Data.SqlClient; -using System.Windows.Forms.DataVisualization.Charting; -using GeoScene.Data; -using GeoScene.Engine; -using GeoScene.Globe; -using System.Data.OracleClient; - -namespace Cyberpipe -{ - public partial class FrmBSQDuoBianXingStatis : Office2007Form - { - Dictionary bsq = new Dictionary(); - Dictionary bsq1 = new Dictionary(); - static FrmBSQDuoBianXingStatis frm; - GSOGlobeControl globeControl1; - List list = new List(); - public static List pipeLists = new List(); - - string[] codeStr = new string[50]; - string[] nameStr = new string[30]; - public static List typeLists; - - public FrmBSQDuoBianXingStatis(Dictionary workWellLen, GSOGlobeControl glb,List _list) - { - InitializeComponent(); - bsq = workWellLen; - globeControl1 = glb; - list = _list; - } - - private void FrmBSQDuoBianXingStatis_Load(object sender, EventArgs e) - { - FrmBSQDuoBianXingStatisFenLei(); - try - { - chart1.Series.Add("标识器"); - chart1.ChartAreas["ChartArea1"].AxisX.Title = "标识器类型"; - chart1.ChartAreas["ChartArea1"].AxisY.Title = "标识器数量"; - chart1.ChartAreas["ChartArea1"].AxisX.Interval = 1; - chart1.Series["标识器"].ChartType = SeriesChartType.Column; - chart1.Series["标识器"]["DrawingStyle"] = "Cylinder"; - - chart1.Series["标识器"].Points.DataBindXY(bsq1.Keys, bsq1.Values); - if (bsq1.Values.Count == 0) - { - MessageBox.Show("该区域没有标识器信息", "提示"); - this.Close(); - return; - } - else - { - for (int m = 0; m < bsq1.Values.Count; m++) - { - if (chart1.Series["标识器"].Points[m].YValues[0].ToString() != "0") - { - chart1.Series["标识器"].Points[m].Label = chart1.Series[0].Points[m].YValues[0].ToString(); - } - } - } - } - catch (Exception ex) - { - //ErrorLog.PublishError(ex); - } - } - - private void FrmBSQDuoBianXingStatis_FormClosing(object sender, FormClosingEventArgs e) - { - frm = null; - globeControl1.Globe.ClearAnalysis(); - globeControl1.Globe.MemoryLayer.RemoveAllFeature(); - } - - - private void FrmBSQDuoBianXingStatisFenLei() - { - try - { - bool flag2 = false; - for (int i = 0; i < Utility.listPipelineType.Count; i++) - { - - for (int j = 0; j < pipeLists.Count; j++) - { - if (pipeLists[j] == Utility.listPipelineType[i].type) - { - flag2 = true; - break; - } - } - if (!flag2 && Utility.listPipelineType[i].type != "标识器") - { - pipeLists.Add(Utility.listPipelineType[i].type); - } - flag2 = false; - } - - typeLists = new List(); - for (int num = 0; num < pipeLists.Count; num++) - { - typeList ls = new typeList(0, pipeLists[num]); - typeLists.Add(ls); - } - - GSOFeatures fs = list[0]; - string pipetype = "标识器"; - foreach (string key in bsq.Keys) - { - if (key.StartsWith(pipetype)) - { - pipetype = key; - break; - } - } - if (fs.Length > 0) - { - for (int i = 0; i < fs.Length; i++) - { - string str = fs[i].GetValue("对象名称").ToString(); - codeStr = str.Split(','); - for (int n = 0; n < codeStr.Length; n++) - { - for (int ii = 0; ii < Utility.listPipelineType.Count; ii++) - { - if (Utility.listPipelineType[ii].code == codeStr[n]) - { - for (int m = 0; m < typeLists.Count; m++) - { - if (Utility.listPipelineType[ii].type == typeLists[m].type) - { - typeLists[m].num++; - break; - } - } - break; - } - } - } - } - } - - for (int i = 0; i < typeLists.Count; i++) - { - if (typeLists[i].num > 0) - bsq1.Add(typeLists[i].type, typeLists[i].num); - } - - } - catch (Exception ex) - { - //ErrorLog.PublishError(ex); - //MessageBox.Show(ex.Message); - } - - } - public class typeList - { - public int num; - public string type; - - public typeList(int _num, string _type) - { - num = _num; - type = _type; - } - } - - - } -} diff --git a/FrmBSQDuoBianXingStatis.resx b/FrmBSQDuoBianXingStatis.resx deleted file mode 100644 index 1af7de1..0000000 --- a/FrmBSQDuoBianXingStatis.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/FrmBSQStatis.Designer.cs b/FrmBSQStatis.Designer.cs index 2509c7d..ee9b1e7 100644 --- a/FrmBSQStatis.Designer.cs +++ b/FrmBSQStatis.Designer.cs @@ -57,6 +57,7 @@ this.ShowIcon = false; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "标识器全区域统计"; + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FrmBSQStatis_FormClosing); this.Load += new System.EventHandler(this.FrmBSQStatis_Load); ((System.ComponentModel.ISupportInitialize)(this.chartStatis)).EndInit(); this.ResumeLayout(false); diff --git a/FrmBSQStatis.cs b/FrmBSQStatis.cs index 4b25eda..e7c4926 100644 --- a/FrmBSQStatis.cs +++ b/FrmBSQStatis.cs @@ -18,94 +18,18 @@ { public partial class FrmBSQStatis : Office2007Form { - public Dictionary bsq = new Dictionary(); - //SqlConnection conn; - public static List typeLists; - OracleConnection conn; - string connectString; + private Dictionary bsq = new Dictionary(); + private GSOGlobeControl globeControl1; + private GSOGeoPolygon3D polygon; - public FrmBSQStatis() + public FrmBSQStatis(GSOGlobeControl globeControl1,GSOGeoPolygon3D polygon) { + this.globeControl1 = globeControl1; + this.polygon = polygon; InitializeComponent(); - BSQNumStatis(); + bsq = getBSQNameAndNumMap(polygon); } - string[] codeStr = new string[50]; - string[] nameStr = new string[30]; - public static List pipeLists = new List(); - - private void BSQNumStatis() - { - bool flag2 = false; - for (int i = 0; i < Utility.listPipelineType.Count; i++) - { - for (int j = 0; j < pipeLists.Count; j++) - { - if (pipeLists[j] == Utility.listPipelineType[i].type) - { - flag2 = true; - break; - } - } - if (!flag2 && Utility.listPipelineType[i].type != "标识器") - { - pipeLists.Add(Utility.listPipelineType[i].type); - } - flag2 = false; - } - - typeLists = new List(); - for (int num = 0; num 0) - bsq.Add(typeLists[i].type, typeLists[i].num); - } - - } - catch (Exception ex) - { - - } - } private void FrmBSQStatis_Load(object sender, EventArgs e) { @@ -136,17 +60,88 @@ } } - public class typeList + private Dictionary getBSQNameAndNumMap(GSOGeoPolygon3D polygon) { - public int num; - public string type; - public typeList(int _num, string _type) + Dictionary result = new Dictionary(); + Dictionary codeAndType = new Dictionary(); + //得到type的种类 + for (int i = 0; i < Utility.listPipelineType.Count; i++) { - num = _num; - type = _type; + if (!result.ContainsKey(Utility.listPipelineType[i].type) && Utility.listPipelineType[i].type != "标识器") + { + result.Add(Utility.listPipelineType[i].type, 0); + codeAndType.Add(Utility.listPipelineType[i].code, Utility.listPipelineType[i].type); + } + } + + return polygon == null ? getAllAreaMap(result, codeAndType) : getBSQMapByPolygon(polygon, result, codeAndType); + } + public Dictionary getAllAreaMap(Dictionary typeAndCount,Dictionary codeAndType) + { + try + { + OracleConnection conn = OledbHelper.sqlConnection(); + conn.Open(); + OracleCommand cmd; + cmd = new OracleCommand("select 对象类型 from 标识器", conn); + OracleDataReader dr = cmd.ExecuteReader(); + + while (dr.Read()) + { + string str = Convert.ToString(dr["对象类型"]); + if (str == null) continue; + foreach (string key in codeAndType.Keys) + { + if (str.Contains(key)) + { + typeAndCount[codeAndType[key]] += 1; + } + } + } + conn.Close(); + } + catch (Exception ex) + { + LogHelper.WriteLog(typeof(FrmBSQStatis),ex.Message.ToString()); + } + return typeAndCount; + } + + + public Dictionary getBSQMapByPolygon(GSOGeoPolygon3D polygon,Dictionary typeAndCount, Dictionary codeAndType) + { + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption("标识器"); + GSOFeatures bsqFs = FeatureStatisticsService.getLayerFeatures(polygon, layer); + if (bsqFs == null || bsqFs.Length <= 0) { + LogHelper.WriteLog(typeof(FrmBSQStatis),"标识器图层下的Feature为空"); + return null; + } + + for (int i = 0; i < bsqFs.Length; i++) + { + string str = bsqFs[i].GetValue("对象类型").ToString(); + + foreach (string key in codeAndType.Keys) + { + if (str.Contains(key)) + { + typeAndCount[codeAndType[key]] += 1; + } + } + } + + return typeAndCount; + } + + private void FrmBSQStatis_FormClosing(object sender, FormClosingEventArgs e) + { + globeControl1.Globe.ClearAnalysis(); + } + + } } diff --git a/FrmValveStatistics.cs b/FrmValveStatistics.cs index 672f97a..17dad6c 100644 --- a/FrmValveStatistics.cs +++ b/FrmValveStatistics.cs @@ -120,6 +120,7 @@ sql += " where 1>2 "; for (int i = 0; i < fs.Length; i++) { + if (fs[i].GetValue("编号") == null) continue; sql += " or 编号 = '" + fs[i].GetValue("编号").ToString() + "'"; } diff --git a/FrmpipeDeepstatis.cs b/FrmpipeDeepstatis.cs index 879801a..c7edbc3 100644 --- a/FrmpipeDeepstatis.cs +++ b/FrmpipeDeepstatis.cs @@ -164,88 +164,6 @@ } } - //if (clbPipeLine.CheckedItems.Count > 0) - //{ - // if (dataGridViewX2.Rows.Count > 0) - // { - // for (int i = 0; i < clbPipeLine.CheckedItems.Count; i++) - // { - // GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(clbPipeLine.CheckedItems[i].ToString()); - // GSOFeatureLayer flayer = layer as GSOFeatureLayer; - // GSOFeatures feats = new GSOFeatures(); - // if (polygon == null) - // feats = flayer.GetAllFeatures(); - // else - // feats = flayer.FindFeaturesInPolygon(polygon, false); - // for (int j = 0; j < dataGridViewX2.Rows.Count; j++) - // { - // double totalLength = 0.00; - // int ncount = 0; - // for (int m = 0; m < feats.Length; m++) - // { - // GSOFeature feat = feats[m]; - // float radius = feat.GetFieldAsFloat("起始埋深"); - // bool upCompare = true; - // bool downCompare = true; - // if (dataGridViewX2.Rows[j].Cells["下限"].Value != null || dataGridViewX2.Rows[j].Cells["上限"].Value != null) - // { - // if (dataGridViewX2.Rows[j].Cells["下限"].Value != null) - // { - // if (dataGridViewX2.Rows[j].Cells["下限"].Value.ToString() != "") - // { - // if (radius >= Convert.ToDouble(dataGridViewX2.Rows[j].Cells["下限"].Value)) - // { - // downCompare = true; - // } - // else - // downCompare = false; - // } - // } - // if (dataGridViewX2.Rows[j].Cells["上限"].Value != null) - // { - // if (dataGridViewX2.Rows[j].Cells["上限"].Value.ToString() != "") - // { - // if (radius <= Convert.ToDouble(dataGridViewX2.Rows[j].Cells["上限"].Value)) - // { - // upCompare = true; - // } - // else - // upCompare = false; - // } - // } - // if (upCompare && downCompare) - // { - // GSOGeoPolyline3D line = feat.Geometry as GSOGeoPolyline3D; - // double length = line.GetSpaceLength(true, 6378137); - // totalLength += length; - // ncount += 1; - // } - // } - // } - // if (dataGridViewX2.Rows[j].Cells["下限"].Value != null || dataGridViewX2.Rows[j].Cells["上限"].Value != null) - // { - // DataGridViewRow row = new DataGridViewRow(); - // int index = dataGridViewX1.Rows.Add(row); - // row = dataGridViewX1.Rows[index]; - // row.Cells["图层名称"].Value = layer.Caption; - // row.Cells["埋深范围"].Value = dataGridViewX2.Rows[j].Cells["下限"].Value + "-" + dataGridViewX2.Rows[j].Cells["上限"].Value; - // row.Cells["条数"].Value = ncount; - // row.Cells["总长度"].Value =Math.Round(totalLength,2); - - // dic.Add(layer.Caption + "," + row.Cells["埋深范围"].Value.ToString()+","+row.Cells["总长度"].Value.ToString(), ncount); - // } - // } - // } - // } - // else - // { - // MessageBox.Show("请添加分段!"); - // } - //} - //else - //{ - // MessageBox.Show("请选择图层!"); - //} showPipeWidget(); } catch (Exception ex) diff --git a/FrmpipeMaterialGather.cs b/FrmpipeMaterialGather.cs index b7ab1d2..3e9f45d 100644 --- a/FrmpipeMaterialGather.cs +++ b/FrmpipeMaterialGather.cs @@ -180,79 +180,6 @@ } - //if (clbPipeLine.CheckedItems.Count > 0) - //{ - // for (int i = 0; i < clbPipeLine.CheckedItems.Count; i++) - // { - // GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(clbPipeLine.CheckedItems[i].ToString()); - // GSOFeatureLayer flayer = layer as GSOFeatureLayer; - // GSOFeatures feats = new GSOFeatures(); - // if (polygon == null) - // feats = flayer.GetAllFeatures(); - // else - // feats = flayer.FindFeaturesInPolygon(polygon, false); - // List lstDiameter = new List(); - - // for (int j = 0; j < clbmaterials.CheckedItems.Count; j++) - // { - // if (!lstDiameter.Contains(clbmaterials.CheckedItems[j].ToString())) - // { - // lstDiameter.Add(clbmaterials.CheckedItems[j].ToString()); - // } - // } - // //lstDiameter.Sort(); - // if (lstDiameter.Count > 0) - // { - // for (int m = 0; m < lstDiameter.Count; m++) - // { - // double totalLength = 0.00; - // int ncount = 0; - // for (int j = 0; j < feats.Length; j++) - // { - // if (lstDiameter[m] != "无") - // { - // if (feats[j].GetFieldAsString("材质") == lstDiameter[m]) - // { - // GSOGeoPolyline3D line = feats[j].Geometry as GSOGeoPolyline3D; - // if (line != null) - // { - // double length = line.GetSpaceLength(true, 6378137); - // totalLength += length; - // ncount += 1; - // } - // } - // } - // else - // { - // if (feats[j].GetFieldAsString("材质") == "") - // { - // GSOGeoPolyline3D line = feats[j].Geometry as GSOGeoPolyline3D; - // if (line != null) - // { - // double length = line.GetSpaceLength(true, 6378137); - // totalLength += length; - // ncount += 1; - // } - // } - // } - // } - // DataGridViewRow row = new DataGridViewRow(); - // int index = dataGridViewX1.Rows.Add(row); - // row = dataGridViewX1.Rows[index]; - // row.Cells["图层名称"].Value = layer.Caption; - // row.Cells["材质"].Value = lstDiameter[m]; - // row.Cells["条数"].Value = ncount; - // row.Cells["总长度"].Value = Math.Round(totalLength); - - // dic.Add(layer.Caption + "," + row.Cells["材质"].Value.ToString(), ncount); - // } - // } - // } - //} - //else - //{ - // MessageBox.Show("请选择图层!"); - //} showPipeWidget(); } catch (Exception ex) diff --git a/Frmpipediameterstatis.cs b/Frmpipediameterstatis.cs index 9953ac0..aa482d8 100644 --- a/Frmpipediameterstatis.cs +++ b/Frmpipediameterstatis.cs @@ -27,12 +27,9 @@ frm = new Frmpipediameterstatis(_globeControl1, pipeLayers, visibleId); frm.Show(_globeControl1.Parent); } - else + else if (frm.WindowState == FormWindowState.Minimized) { - if (frm.WindowState == FormWindowState.Minimized) - { - frm.WindowState = FormWindowState.Normal; - } + frm.WindowState = FormWindowState.Normal; } } @@ -208,7 +205,8 @@ } catch (Exception ex) { - MessageBox.Show(ex.Message); + LogHelper.WriteLog(typeof(Frmpipediameterstatis), ex.Message); + //MessageBox.Show(ex.Message); LogError.PublishError(ex); } } @@ -290,76 +288,77 @@ /// private void btnExport_Click(object sender, EventArgs e) { - if (dataGridViewX1.Rows.Count > 0) + if (dataGridViewX1.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 = DateTime.Now.ToString("yyyyMMdd") + ".xls"; - if (dlg.ShowDialog() == DialogResult.OK) + MessageBox.Show("统计结果为空,请重新统计之后再导出Excel!", "提示"); + return; + } + + SaveFileDialog dlg = new SaveFileDialog(); + dlg.Filter = "Excel files (*.xls)|*.xls"; + dlg.FilterIndex = 0; + dlg.RestoreDirectory = true; + //dlg.CreatePrompt = true; + dlg.Title = "保存为Excel文件"; + dlg.FileName = 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 { - Stream myStream; - myStream = dlg.OpenFile(); - StreamWriter sw = new StreamWriter(myStream, System.Text.Encoding.GetEncoding(-0)); - string columnTitle = ""; - try + sw.WriteLine("日期:" + DateTime.Now.ToString("yyyy-MM-dd")); + + //写入列标题 + for (int i = 0; i < dataGridViewX1.ColumnCount; i++) { - sw.WriteLine("日期:" + DateTime.Now.ToString("yyyy-MM-dd")); - - //写入列标题 - for (int i = 0; i < dataGridViewX1.ColumnCount; i++) + if (i > 0) { - if (i > 0) - { - columnTitle += "\t"; - } - columnTitle += dataGridViewX1.Columns[i].HeaderText; + columnTitle += "\t"; } - sw.WriteLine(columnTitle); - - //写入列内容 - for (int j = 0; j < dataGridViewX1.Rows.Count; j++) - { - string columnValue = ""; - for (int k = 0; k < dataGridViewX1.Columns.Count; k++) - { - if (k > 0) - { - columnValue += "\t"; - } - if (dataGridViewX1.Rows[j].Cells[k].Value == null) - columnValue += ""; - else - columnValue += dataGridViewX1.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); - } + columnTitle += dataGridViewX1.Columns[i].HeaderText; } - catch (Exception ex) + sw.WriteLine(columnTitle); + + //写入列内容 + for (int j = 0; j < dataGridViewX1.Rows.Count; j++) { - MessageBox.Show(ex.ToString()); + string columnValue = ""; + for (int k = 0; k < dataGridViewX1.Columns.Count; k++) + { + if (k > 0) + { + columnValue += "\t"; + } + if (dataGridViewX1.Rows[j].Cells[k].Value == null) + columnValue += ""; + else + columnValue += dataGridViewX1.Rows[j].Cells[k].Value.ToString().Trim(); + } + + sw.WriteLine(columnValue); } - finally + sw.Close(); + myStream.Close(); + if (MessageBox.Show("导出Excel文件成功!是否打开?", "提示", MessageBoxButtons.YesNo) == DialogResult.Yes) { - sw.Close(); - myStream.Close(); + System.Diagnostics.Process.Start(dlg.FileName); } } + catch (Exception ex) + { + MessageBox.Show(ex.ToString()); + } + finally + { + sw.Close(); + myStream.Close(); + } } - else - { - MessageBox.Show("统计结果为空,请重新统计之后再导出Excel!","提示"); - } + + } /// /// 绘制区域分段统计 diff --git a/MainFrm.cs b/MainFrm.cs index 0b7e393..9bfb70e 100644 --- a/MainFrm.cs +++ b/MainFrm.cs @@ -2667,12 +2667,195 @@ FrmBaseLineProfillAnalysis dlg = new FrmBaseLineProfillAnalysis(globeControl1.Globe, e.Polyline); dlg.Show(this); globeControl1.Globe.ClearLastTrackPolyline(); + /* + FrmRoadHDM f = new FrmRoadHDM(); + f.Show() + * **/ } else { } trackPolylineEndMode = EnumTrackPolylineEndMode.Default_Analysis; + /* + ArrayList arraylistPoint = new ArrayList(); + ArrayList arraylistLine = new ArrayList(); + + // globeControl1.Globe.ClearLastTrackPolyline(); + + if (e.Polyline != null) + { + //横断面分析 + if (buttonItemFX2_1.Checked || buttonItemFX2_3.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 (buttonItemFX2_1.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 (buttonItemFX2_4.Checked) + { + FrmBaseLineProfillAnalysis dlg = new FrmBaseLineProfillAnalysis(globeControl1.Globe, e.Polyline); + dlg.Show(this); + globeControl1.Globe.ClearLastTrackPolyline(); + } + else if (buttonItemFX4_3.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(); + * **/ } #endregion @@ -2713,16 +2896,20 @@ case "valvequery": FrmValveStatistics frm = new FrmValveStatistics(globeControl1,polygon, new DataGridViewDelegate(InitDataGridViewX1)); frm.Show(this); + //panelEx6.Visible = true; + toolStripFeatureLength.Text = ""; globeControl1.Globe.Action = EnumAction3D.ActionNull; break; case "PipelineDistanceStatistics": + FrmAllPipelineStatis frm1 = new FrmAllPipelineStatis(globeControl1, polygon, new DataGridViewDelegate(InitDataGridViewX1), m_PipelineLayerNames); frm1.Show(this); globeControl1.Globe.Action = EnumAction3D.ActionNull; break; case "PipelineSpatialQuery": + FrmAllPipelineStatis.ShowForm(globeControl1,polygon,new DataGridViewDelegate(InitDataGridViewX1),m_PipelineLayerNames); globeControl1.Globe.ClearAnalysis(); globeControl1.Globe.Action = EnumAction3D.ActionNull; @@ -2771,18 +2958,19 @@ break; case "BSQDuoBianXiangStatis": - GSOFeature f2 = new GSOFeature(); - f2.Geometry = e.Polygon; - f2.Geometry.AltitudeMode = EnumAltitudeMode.Absolute; - globeControl1.Globe.MemoryLayer.AddFeature(f2); - f2.Geometry.MoveZ(3); - workWellLen.Clear(); - List listBSQ = new List(); + //GSOFeature f2 = new GSOFeature(); + //f2.Geometry = e.Polygon; + //f2.Geometry.AltitudeMode = EnumAltitudeMode.Absolute; + //globeControl1.Globe.MemoryLayer.AddFeature(f2); + //f2.Geometry.MoveZ(3); + //workWellLen.Clear(); + //List listBSQ = new List(); - GSOFeatures bsqFeatures = PolygonIntersectAnalysis(e.Polygon, "标识器"); - listBSQ.Add(bsqFeatures); + //GSOFeatures bsqFeatures = PolygonIntersectAnalysis(e.Polygon, "标识器"); + //listBSQ.Add(bsqFeatures); - FrmBSQDuoBianXingStatis bsqFrm = new FrmBSQDuoBianXingStatis(workWellLen, globeControl1, listBSQ); + //FrmBSQDuoBianXingStatis bsqFrm = new FrmBSQDuoBianXingStatis(workWellLen, globeControl1, listBSQ); + FrmBSQStatis bsqFrm = new FrmBSQStatis(globeControl1,e.Polygon); bsqFrm.Show(this); globeControl1.Globe.Action = EnumAction3D.ActionNull; break; @@ -4351,6 +4539,26 @@ } /// + /// 在窗体的底部状态栏上显示 综合管线条件查询结果 + /// + /// + /// + 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 + " 条记录 | "; + } + } + + /// /// 统计管线的里程数 /// /// @@ -6824,6 +7032,54 @@ } /// + /// 创建label要素 功能 + /// + /// 添加label要素的feature + /// feature的位置 + /// label要素名字 + /// feature名字 + /// label要素距离点的位置 + /// + 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; + } + + + + /// /// 获取指定两点组成的线的长度 功能 /// /// @@ -9266,8 +9522,19 @@ //日志记录 LogManager.saveLog(Utility.userName, "管线长度统计"); + //pipeLineDis.Clear(); + //List list = new List(); + //for (int i = 0; i < m_PipelineLayerNames.Count; i++) + //{ + // GSOFeatures fs = Intersects_Pipeline(null, m_PipelineLayerNames[i]); + // if (fs!=null) + // list.Add(fs); + //} + + //FrmAllPipelineStatis frm = new FrmAllPipelineStatis(0, pipeLineDis, list, globeControl1, new DataGridViewDelegate(InitDataGridViewX1)); FrmAllPipelineStatis frm = new FrmAllPipelineStatis(globeControl1,null, new DataGridViewDelegate(InitDataGridViewX1), m_PipelineLayerNames); frm.Show(this); + } /// /// 管线长度绘制区域统计 @@ -9293,6 +9560,25 @@ //日志记录 LogManager.saveLog(Utility.userName, "阀门数量统计"); + //workWellLen.Clear(); + //List list = new List(); + ////找到所有阀门 + //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, globeControl1, new DataGridViewDelegate(InitDataGridViewX1)); FrmValveStatistics frm = new FrmValveStatistics(globeControl1, null, new DataGridViewDelegate(InitDataGridViewX1)); frm.Show(this); @@ -9318,9 +9604,7 @@ /// /// private void buttonItemTJ3_ALL_Click(object sender, EventArgs e) - { - //日志记录 - LogManager.saveLog(Utility.userName, "井盖数量统计"); + { FrmAllWorkWellStatis frm = new FrmAllWorkWellStatis(globeControl1, null, new DataGridViewDelegate(InitDataGridViewX1)); frm.Show(this); } @@ -9333,7 +9617,7 @@ { //日志记录 LogManager.saveLog(Utility.userName, "井盖数量统计"); - + trackflag = "workwellquery"; globeControl1.Globe.Action = EnumAction3D.TrackPolygon; globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; @@ -11142,7 +11426,7 @@ Cyberpipe.Forms.FrmPipelineModelDB frm = new Cyberpipe.Forms.FrmPipelineModelDB(globeControl1, ds); if (frm.ShowDialog() == DialogResult.OK) { - //addNodeToLayerManagerNode(frm.rukuLayer); + addNodeToLayerManagerNode(frm.rukuLayer); } } /// @@ -12377,7 +12661,8 @@ private void 标识器分类统计ToolStripMenuItem_Click(object sender, EventArgs e) { globeControl1.Globe.Action = EnumAction3D.ActionNull; - FrmBSQStatis bsqStatis = new FrmBSQStatis(); + FrmBSQStatis bsqStatis = new FrmBSQStatis(globeControl1,null); + //FrmBSQStatis bsqStatis = new FrmBSQStatis(); bsqStatis.Show(this); } /// diff --git a/MainFrm.cs.BACKUP.9016.cs b/MainFrm.cs.BACKUP.9016.cs new file mode 100644 index 0000000..28cb7fa --- /dev/null +++ b/MainFrm.cs.BACKUP.9016.cs @@ -0,0 +1,13074 @@ +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; + + GSOBalloon featureTooltip2; + GSOBalloonEx balloonEx2; + + GSOLayer layerTemp; + GSOLayer layerTemp2; + FrmShResult frmShResult = null; + FrmRedlineResult frmredResult = null; + FrmMnModify frmModify = null; + public bool frmRedlineResult = false; + public bool boolfrmShResult = false; + public bool boolfrmModify = false; + + List m_PipelineLayerNames = new List();//线图层名称 + List workwellLayerNames = new List();//工井图层名称 + List valueLayerNames = new List();//阀门图层名称 + List instrumenLayerNames = new List();//附属物图层名称 + List pipefittingLayerNames = new List();//管件图层名称 + List sgPipeLayersNames = new List();//施工管线图层名称 + 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 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; + public string redLayer = null; + //GSOLayer redLayer1 = null; + bool redSH = false; + string redDt = "红线"; + //双屏对比 + //bool zhanshi=false; + Thread t = null; + private GSOHudButton legendSC;//定义图例 + private GSOHudButton legendSG;//定义图例 + //管纵图 + private GSOHudButton lendendGZ50; + private GSOHudButton lendendGZ36; + private GSOHudButton lendendGZ42; + private GSOHudButton lendendGZ24_1; + private GSOHudButton lendendGZ24_2; + private GSOHudButton lendendGZ24_3; + private GSOHudButton lendendGZ26; + + GSOGeoPoint3D bsqPT; + + FrmYJSHTC frmSh = null;//一键审核窗口全局变量wxl + FrmWait frmWait = null;//一键审核等待窗口 + //FrmWait frmWait2 = null;//文档操作等待窗口 + + float mouseDownX1,mouseDownY1; + float mouseDownX2,mouseDownY2; + /// + /// + /// + 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; + + featureTooltip2 = new GSOBalloon(globeControl2.Handle); + balloonEx2 = new GSOBalloonEx(globeControl2.Handle); + Utility.SetBallons(featureTooltip, balloonEx); + + panelOfTable.Height = 200; + + RigthMenuSet(); + + MenuSet(); + + } + /// + /// 右屏中添加管纵图片 + /// + private void AddGZ() + { + + lendendGZ50 = new GSOHudButton(); + lendendGZ50.SetImage(Application.StartupPath + "/Resource/管纵/50.png"); + lendendGZ50.SetOffset(0, 0); + lendendGZ50.MinOpaque = 1; + lendendGZ50.MaxOpaque = 1; + lendendGZ50.FadeOut = false; + lendendGZ50.Name = "lendendGZ50"; + lendendGZ50.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ50); + lendendGZ50.Visible = false; + + lendendGZ36 = new GSOHudButton(); + lendendGZ36.SetImage(Application.StartupPath + "/Resource/管纵/36.png"); + lendendGZ36.SetOffset(0, 0); + lendendGZ36.MinOpaque = 1; + lendendGZ36.MaxOpaque = 1; + lendendGZ36.FadeOut = false; + lendendGZ36.Name = "lendendGZ36"; + lendendGZ36.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ36); + lendendGZ36.Visible = false; + + lendendGZ42 = new GSOHudButton(); + lendendGZ42.SetImage(Application.StartupPath + "/Resource/管纵/42.png"); + lendendGZ42.SetOffset(0, 0); + lendendGZ42.MinOpaque = 1; + lendendGZ42.MaxOpaque = 1; + lendendGZ42.FadeOut = false; + lendendGZ42.Name = "lendendGZ42"; + lendendGZ42.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ42); + lendendGZ42.Visible = false; + + lendendGZ24_1 = new GSOHudButton(); + lendendGZ24_1.SetImage(Application.StartupPath + "/Resource/管纵/24_1.png"); + lendendGZ24_1.SetOffset(0, 0); + lendendGZ24_1.MinOpaque = 1; + lendendGZ24_1.MaxOpaque = 1; + lendendGZ24_1.FadeOut = false; + lendendGZ24_1.Name = "lendendGZ24_1"; + lendendGZ24_1.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ24_1); + lendendGZ24_1.Visible = false; + + lendendGZ24_2 = new GSOHudButton(); + lendendGZ24_2.SetImage(Application.StartupPath + "/Resource/管纵/24_2.png"); + lendendGZ24_2.SetOffset(0, 0); + lendendGZ24_2.MinOpaque = 1; + lendendGZ24_2.MaxOpaque = 1; + lendendGZ24_2.FadeOut = false; + lendendGZ24_2.Name = "lendendGZ24_2"; + lendendGZ24_2.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ24_2); + lendendGZ24_2.Visible = false; + + lendendGZ24_3 = new GSOHudButton(); + lendendGZ24_3.SetImage(Application.StartupPath + "/Resource/管纵/24_3.png"); + lendendGZ24_3.SetOffset(0, 0); + lendendGZ24_3.MinOpaque = 1; + lendendGZ24_3.MaxOpaque = 1; + lendendGZ24_3.FadeOut = false; + lendendGZ24_3.Name = "lendendGZ24_3"; + lendendGZ24_3.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ24_3); + lendendGZ24_3.Visible = false; + + lendendGZ26 = new GSOHudButton(); + lendendGZ26.SetImage(Application.StartupPath + "/Resource/管纵/26.png"); + lendendGZ26.SetOffset(0, 0); + lendendGZ26.MinOpaque = 1; + lendendGZ26.MaxOpaque = 1; + lendendGZ26.FadeOut = false; + lendendGZ26.Name = "lendendGZ26"; + lendendGZ26.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ26); + lendendGZ26.Visible = false; + + } + + public void RigthMenuSet() + { + if (Utility.userRole.IndexOf("清除分析") < 0) + { + toolRightMenu.Items.Remove(清除分析ToolStripMenuItem); + } + + #region 区域分析 + if (Utility.userRole.IndexOf("区域分析") < 0) + { + toolRightMenu.Items.Remove(区域分析ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("缓冲区分析") < 0) + { + 区域分析ToolStripMenuItem.DropDownItems.Remove(缓冲区分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("附属物分析") < 0) + { + 区域分析ToolStripMenuItem.DropDownItems.Remove(附属物分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("无源淹没分析") < 0) + { + 区域分析ToolStripMenuItem.DropDownItems.Remove(无源淹没分析ToolStripMenuItem); + } + } + #endregion + + #region 视域分析 + if (Utility.userRole.IndexOf("视域分析") < 0) + { + toolRightMenu.Items.Remove(视域分析ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("通视分析") < 0) + { + 视域分析ToolStripMenuItem.DropDownItems.Remove(通视分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("可视域分析") < 0) + { + 视域分析ToolStripMenuItem.DropDownItems.Remove(可视域分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("可视包络分析") < 0) + { + 视域分析ToolStripMenuItem.DropDownItems.Remove(可视包络分析ToolStripMenuItem); + } + } + #endregion + + #region 开发分析 + if (Utility.userRole.IndexOf("开挖分析") < 0) + { + toolRightMenu.Items.Remove(开挖分析ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("多边形开挖") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(多边形开挖ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("挖方量分析") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(挖方量分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("沿线开挖") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(沿线开挖ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("创建隧道") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(创建隧道ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("隐藏隧道") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(隐藏隧道ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("删除隧道") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(删除隧道ToolStripMenuItem); + } + } + #endregion + + #region 拓扑分析 + if (Utility.userRole.IndexOf("拓扑分析") < 0) + { + toolRightMenu.Items.Remove(拓扑分析ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("创建拓扑") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(创建拓扑ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("上游分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(上游分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("下游分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(下游分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("流向分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(流向分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("关阀分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(关阀分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("连通分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(连通分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("爆管分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(爆管分析ToolStripMenuItem); + } + } + #endregion + + #region 断面分析 + if (Utility.userRole.IndexOf("断面分析") < 0) + { + toolRightMenu.Items.Remove(断面分析ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("横断面分析") < 0) + { + 断面分析ToolStripMenuItem.DropDownItems.Remove(横断面分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("纵断面分析") < 0) + { + 断面分析ToolStripMenuItem.DropDownItems.Remove(纵断面分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("道路断面分析") < 0) + { + 断面分析ToolStripMenuItem.DropDownItems.Remove(道路断面分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("基线剖面分析") < 0) + { + 断面分析ToolStripMenuItem.DropDownItems.Remove(基线剖面分析ToolStripMenuItem); + } + } + #endregion + + #region 绘制区域统计 + if (Utility.userRole.IndexOf("绘制区域统计") < 0) + { + toolRightMenu.Items.Remove(绘制区域统计ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("绘制区域管线长度统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管线长度统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域阀门数量统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(阀门数量统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域井盖数量统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(井盖数量统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域管径分段统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管径分段统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域埋深分段统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(埋深分段统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域管径分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管径分类统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域材质分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(材质分类统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域附属物分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(附属物分类统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域标识器分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(标识器分类统计ToolStripMenuItem1); + } + + } + #endregion + + #region 全区域统计 + if (Utility.userRole.IndexOf("全区域统计") < 0) + { + toolRightMenu.Items.Remove(全区域统计ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("全区域管线长度统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管线长度统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域阀门数量统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(阀门数量统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域井盖数量统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(井盖数量统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域管径分段统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管径分段统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域埋深分段统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(埋深分段统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域管径分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管径分类统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域材质分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(材质分类统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域附属物分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(附属物分类统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域标识器分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(标识器分类统计ToolStripMenuItem); + } + + } + #endregion + + #region 查询 + if (Utility.userRole.IndexOf("查询") < 0) + { + toolRightMenu.Items.Remove(查询ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("空间查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(空间查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("编号查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(编号查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("坐标查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(坐标查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("管径查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(管径查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("材质查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(材质查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("基本查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(基本查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("复合查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(复合查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("关联查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(关联查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("关键字查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(关键字查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("附属物查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(附属物查询ToolStripMenuItem); + } + } + #endregion + + #region 标注 + if (Utility.userRole.IndexOf("标注") < 0) + { + toolRightMenu.Items.Remove(标注ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("标高标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(标高标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("管径标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(管径标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("埋深标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(埋深标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("坐标标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(坐标标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("距离标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(距离标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("自定义标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(自定义标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("扯旗标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(扯旗标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("坡度标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(坡度标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("属性标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(属性标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("标注管理") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(标注管理ToolStripMenuItem); + } + } + #endregion + + #region 飞行 + if (Utility.userRole.IndexOf("飞行") < 0) + { + toolRightMenu.Items.Remove(飞行ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("自定义飞行") < 0) + { + 飞行ToolStripMenuItem.DropDownItems.Remove(自定义飞行ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("飞行到目标点") < 0) + { + 飞行ToolStripMenuItem.DropDownItems.Remove(飞行到目标点ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("绕中心点飞行") < 0) + { + 飞行ToolStripMenuItem.DropDownItems.Remove(绕中心点飞行ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("绕眼睛飞行") < 0) + { + 飞行ToolStripMenuItem.DropDownItems.Remove(绕眼睛飞行ToolStripMenuItem); + } + } + #endregion + + #region 编辑 + if (Utility.userRole.IndexOf("编辑") < 0) + { + toolRightMenu.Items.Remove(编辑ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("平移对象") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(平移对象ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("升降对象") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(升降对象ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("旋转对象") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(旋转对象ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("连接管段") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(连接管段ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("导出文件") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(导出文件ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("前进") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(前进ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("后退") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(删除模型ToolStripMenuItem); + } + } + #endregion + + #region 量算 + if (Utility.userRole.IndexOf("量算") < 0) + { + toolRightMenu.Items.Remove(量算ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("水平距离") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(水平距离ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("垂直距离") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(垂直距离ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("空间距离") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(空间距离ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("地表距离") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(地表距离ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("高度量算") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(高度量算ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("水平面积") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(水平面积ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("地表面积") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(地表面积ToolStripMenuItem1); + } + } + #endregion + } + + public void MenuSet() + { + + #region 权限管理 + if (Utility.userRole.IndexOf("权限管理") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem2); + } + else + { + + if (Utility.userRole.IndexOf("用户管理") < 0) + { + btn_user_info.Visible = false; + } + if (Utility.userRole.IndexOf("角色管理") < 0) + { + btn_role_info.Visible = false; + } + if (Utility.userRole.IndexOf("资源管理") < 0) + { + btn_resc_info.Visible = false; + } + if (Utility.userRole.IndexOf("角色授权") < 0) + { + btn_role_resc.Visible = false; + } + if (Utility.userRole.IndexOf("用户授权") < 0) + { + btn_user_role.Visible = false; + } + if (Utility.userRole.IndexOf("密码修改") < 0) + { + btn_password_edit.Visible = false; + } + + } + #endregion + + #region 基础工具 + if (Utility.userRole.IndexOf("基础工具") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem1); + } + else + { + if (Utility.userRole.IndexOf("地上模式") < 0) + { + buttonItem87.Visible = false; + } + if (Utility.userRole.IndexOf("地下模式") < 0) + { + buttonItem88.Visible = false; + } + if (Utility.userRole.IndexOf("行走模式") < 0) + { + buttonItem27.Visible = false; + } + if (Utility.userRole.IndexOf("透明度设置") < 0) + { + sliderGroundTransSet1.Visible = false; + } + if (Utility.userRole.IndexOf("快速定位") < 0) + { + buttonItem91.Visible = false; + } + if (Utility.userRole.IndexOf("图层管理") < 0) + { + buttonItem1.Visible = false; + } + if (Utility.userRole.IndexOf("图例管理") < 0) + { + btnlegendSet.Visible = false; + } + if (Utility.userRole.IndexOf("全屏显示") < 0) + { + buttonItem89.Visible = false; + } + if (Utility.userRole.IndexOf("导出图片") < 0) + { + btnOutputJPG.Visible = false; + } + + } + #endregion + + #region 一键审核 + if (Utility.userRole.IndexOf("一键审核") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem11); + } + #endregion + + #region 红线审核 + if (Utility.userRole.IndexOf("红线审核") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem6); + } + #endregion + + #region 双屏对比 + if (Utility.userRole.IndexOf("双屏对比") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem9); + } + #endregion + + #region 文档管理 + if (Utility.userRole.IndexOf("文档管理") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem4); + } + #endregion + + #region 基础管理 + if (Utility.userRole.IndexOf("基础管理") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem14); + } + else + { + if (Utility.userRole.IndexOf("专题图审批") < 0) + { + buttonItemZTT3_2.Visible = false; + } + if (Utility.userRole.IndexOf("打印审批") < 0) + { + buttonItemZTT4_2.Visible = false; + } + if (Utility.userRole.IndexOf("拷贝审批") < 0) + { + buttonItemZTT5_2.Visible = false; + } + } + + #endregion + + if (ribbonControl1.Items.Count <= 0) + { + ribbonControl1.Visible = false; + } + } + + #region Fan Zhang 重构现有代码 + //初始化控件布局 + private void initLayout() + { + 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.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.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.labelX21.Width = (int)(this.labelX21.Width * myScreen); + this.labelX22.Width = (int)(this.labelX22.Width * myScreen); + this.labelX24.Width = (int)(this.labelX24.Width * myScreen); + } + sideBar1.Visible = false; + 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]); + } + + splitContainer1.Panel2Collapsed = true; + + buttonItem87.Checked = true;//默认地上模式 + ribbonTabItem1.Select(); //初始化状态为浏览 + + sideBarPanelItem3.Visible = false; + layerTree.Visible = false; + controlContainerItem3.Visible = false; + if (sideBarPanelItem4.Visible == true) + { + sideBar1.Visible = true; + controlContainerItem5.Visible = true; + } + else + { + sideBar1.Visible = false; + } + Refresh(); + sliderGroundTransSet1.Value = optiValue; + sliderItem1.Value = optiValue; + sliderItem2.Value = optiValue; + sliderItem3.Value = optiValue; + + } + + //初始化地球控件 + private void initGlobalControl() + { + //选择 + btnToolSelect = new GSOHudButton(); + btnToolSelect.SetImage(Application.StartupPath + "\\Resource\\image\\select1.png"); + btnToolSelect.FadeOut = false; + btnToolSelect.Align = EnumAlign.TopLeft; + btnToolSelect.SetOffset(20, 50); + btnToolSelect.Name = "1"; + btnToolSelect.HeightFixed = true; + btnToolSelect.WidthFixed = true; + globeControl1.Globe.AddHudControl(btnToolSelect); + globeControl2.Globe.AddHudControl(btnToolSelect); + + //浏览 + 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); + + //图例 + legend = new GSOHudButton(); + legend.SetImage(Application.StartupPath + "/Resource/图例P.jpg");//图例P + legend.SetOffset(0, 15); + legend.MinOpaque = 1; + legend.MaxOpaque = 1; + legend.FadeOut = false; + legend.Name = "legend"; + legend.Align = EnumAlign.BottomRight; + legend.Visible = false; + globeControl1.Globe.AddHudControl(legend); + + //实测 + legendSC = new GSOHudButton(); + legendSC.SetImage(Application.StartupPath + "/Resource/sc.jpg"); + legendSC.SetOffset(0, 15); + legendSC.MinOpaque = 1; + legendSC.MaxOpaque = 1; + legendSC.FadeOut = false; + legendSC.Name = "legendSC"; + legendSC.Align = EnumAlign.BottomRight; + globeControl1.Globe.AddHudControl(legendSC); + legendSC.Visible = false; + + //施工 + legendSG = new GSOHudButton(); + legendSG.SetImage(Application.StartupPath + "/Resource/sg.jpg"); + legendSG.SetOffset(0, 15); + legendSG.MinOpaque = 1; + legendSG.MaxOpaque = 1; + legendSG.FadeOut = false; + legendSG.Name = "legendSG"; + legendSG.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(legendSG); + legendSG.Visible = false; + + //管纵 + AddGZ(); + + 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; + globeControl1.Globe.IsReleaseMemOutOfView = true; + globeControl1.Globe.ControlPanel.Visible = true; + + globeControl2.Globe.UnderGroundFloor.Visible = false; + globeControl2.Globe.OverviewControl.Visible = false; + globeControl2.Globe.ScalerControl.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; + globeControl2.Globe.IsReleaseMemOutOfView = true; + globeControl2.Globe.ControlPanel.Visible = false; + + 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); + + //添加临时图层 + layerTemp = globeControl1.Globe.Layers.Add(Application.StartupPath + "\\tempLgdData.lgd"); + layerTemp2 = globeControl2.Globe.Layers.Add(Application.StartupPath + "\\tempLgdData2.lgd"); + if (layerTemp != null) + { + layerTemp.MaxVisibleAltitude = 1000; + } + + //添加城市7线图层 + 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"); + + //注册对应事件 + this.registerEvent(); + } + + //注册地球事件 + private bool registerEvent() + { + if (globeControl1 == null || globeControl2 == null) + { + return false; + } + 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); + + globeControl2.FeatureMouseClickEvent += new FeatureMouseClickEventHandler(globeControl2_FeatureMouseClickEvent); + globeControl2.CameraBeginMoveEvent += new CameraBeginMoveEventHandler(globeControl2_CameraBeginMoveEvent); + + globeControl1.MouseDoubleClick += new MouseEventHandler(globeControl1_MouseDoubleClick); + globeControl1.MouseClick += new MouseEventHandler(globeControl1_MouseClick); + globeControl1.MouseDown += new MouseEventHandler(globeControl1_MouseDown); + + globeControl2.MouseClick += new MouseEventHandler(globeControl2_MouseClick); + globeControl2.MouseDown += new MouseEventHandler(globeControl2_MouseDown); + + 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); + + return true; + } + + //加载两个地球数据 + private void loadData() + { + Thread t1 = new Thread(new ThreadStart(doLoadDataForGlobalControl1)); + t1.IsBackground = true; + t1.Start(); + + + } + + delegate void LoadDataForGlobalControl(); + + private void connectServer() + { + globeControl1.Globe.ConnectServer(Utility.serverip, Utility.serverport, "", ""); //加载locaServer中的数据 + globeControl2.Globe.ConnectServer(Utility.serverip, Utility.serverport, "", ""); //加载locaServer中的数据 + //初始化TreeView + // 勾选实测图层 + foreach (TreeNode tn in layerTree.Nodes) + { + if (tn.Nodes.Count > 0) + { + if (tn.Text == "实测数据") + { + tn.Checked = true; + foreach (TreeNode tnChild in tn.Nodes) + { + tnChild.Checked = true; + foreach (TreeNode tnGrandChild in tnChild.Nodes) + { + tnGrandChild.Checked = true; + } + } + } + } + } + } + + private void doLoadDataForGlobalControl1() + { + try + { + + globeControl1.Globe.Layers.MoveDown(10000); + //加载实测管线数据 + Utility.dataSource = globeControl1.Globe.DataManager.OpenOracleDataSource(Utility.DBServer.Trim() + "/" + Utility.dbdatabase.Trim(), "", "", Utility.userID, Utility.DBPassword); + + if (Utility.dataSource != null) + { + for (int j = 0; j < Utility.dataSource.DatasetCount; j++) + { + GSODataset dataset = Utility.dataSource.GetDatasetAt(j); + if (dataset != null && dictionaryNetLayerNameAndCaption.ContainsKey(dataset.Caption)) + { + dataset.Caption = dataset.Name; + globeControl1.Globe.Layers.Add(dataset); + } + } + } + //隐藏红线图层 + globeControl1.Globe.Layers.GetLayerByCaption("红线").Visible = false; + + //globleControl1中加载规划数据 + GSODataSource ghDS = globeControl1.Globe.DataManager.OpenOracleDataSource(Utility.ghdbip + "/" + Utility.ghdbname, "", "", Utility.ghdbuser, Utility.ghdbpwd); + if (ghDS != null) + { + for (int j = 0; j < ghDS.DatasetCount; j++) + { + GSODataset dataset = ghDS.GetDatasetAt(j); + if (dataset != null && dictionaryNetLayerNameAndCaption.ContainsKey(dataset.Caption)) + { + dataset.Caption = dataset.Name; + globeControl1.Globe.Layers.Add(dataset); + globeControl1.Globe.Layers[0].Visible = false; + } + } + } + + //globeControl1,globeControl2中加载施工数据 + GSODataSource sgDS = globeControl1.Globe.DataManager.OpenOracleDataSource(Utility.sgdbip + "/" + Utility.sgdbname, "", "", Utility.sgdbuser, Utility.sgdbpwd); + if (sgDS != null) + { + for (int m = 0; m < sgDS.DatasetCount; m++) + { + GSODataset dataset = sgDS.GetDatasetAt(m); + if (dataset != null && !dataset.Caption.Contains("SH") && dictionaryNetLayerNameAndCaption.ContainsKey(dataset.Caption)) + { + dataset.Caption = dataset.Name; + globeControl1.Globe.Layers.Add(dataset); + globeControl1.Globe.Layers[0].Visible = false; + + globeControl2.Globe.Layers.Add(dataset); + globeControl2.Globe.Layers[0].Visible = true; + } + } + } + + LoadDataForGlobalControl ss = new LoadDataForGlobalControl(connectServer); + ss(); + + } + catch (Exception ex) + { + MessageBox.Show(ex.Message); + } + } + + private void initLayerTree() + { + //加载临时图层节点 + layerManagerNode = new TreeNode(); + layerManagerNode.ImageIndex = 0; + layerManagerNode.SelectedImageIndex = 0; + layerManagerNode.Checked = true; + layerManagerNode.Text = "临时图层"; + layerTree.Nodes.Add(layerManagerNode); + + XmlDocument doc = new XmlDocument(); + doc.Load(filename); + XmlNodeList xmlLayerNodes = doc.SelectNodes("//layer"); + + foreach (XmlNode xmlLayerNode in xmlLayerNodes) + { + + //TODO LIST:创建一级TreeNode(实测、规划、施工) + TreeNode nodelayer = new TreeNode(); + string layerName = xmlLayerNode.Attributes["label"].Value; + nodelayer.Text = layerName; + nodelayer.Checked = false; + layerTree.Nodes.Add(nodelayer); + + XmlNodeList xmlChildLayerNodes = xmlLayerNode.ChildNodes; + foreach (XmlNode xmlChildLayerNode in xmlChildLayerNodes) + { + //TODO LIST:创建二级TreeNode节点 + TreeNode secondLevelNode = new TreeNode(); + string layerType = xmlChildLayerNode.Attributes["label"].Value; + secondLevelNode.Text = layerType; + + if (xmlChildLayerNode.Attributes["type"] != null) + { //道路图层特殊处理 + string type = xmlChildLayerNode.Attributes["type"].Value; + secondLevelNode.Tag = type + "|" + layerType; + } + else + { + secondLevelNode.Tag = layerType; + } + secondLevelNode.Checked = false; + nodelayer.Nodes.Add(secondLevelNode); + + XmlNodeList xmlActitualLayerNodes = xmlChildLayerNode.ChildNodes; + + foreach (XmlNode xmlActitualLayerNode in xmlActitualLayerNodes) + { + //TODO LIST:创建三级图层节点 + TreeNode layerNode = new TreeNode(); + string actutallylayerType = xmlActitualLayerNode.Attributes["type"].Value; + string actutallylayerName = xmlActitualLayerNode.Attributes["layer"].Value; + string actutallyLabelName = xmlActitualLayerNode.Attributes["label"].Value; + + layerNode.Text = actutallyLabelName; + layerNode.Tag = layerType + "|" + actutallyLabelName; + layerNode.Checked = false; + secondLevelNode.Nodes.Add(layerNode); + } + + } + + } + + } + + /** + * 读取Config.xml文件,初始化以下全局Map + * m_PipelineLayerNames:管线 + * workwellLayerNames:工井 + * valueLayerNames:阀门 + * instrumenLayerNames:附属物 + * pipefittingLayerNames:特征管点 + * sgPipeLayersNames:施工管线 + **/ + private void initGlobalMap() + { + XmlDocument doc = new XmlDocument(); + doc.Load(filename); + XmlNodeList xmlLayerNodes = doc.SelectNodes("//layerchild"); + + foreach (XmlNode xmlLayerNode in xmlLayerNodes) + { + string layerType = xmlLayerNode.Attributes["type"].Value; + string layerName1 = xmlLayerNode.Attributes["layer"].Value; + string layerchildName = xmlLayerNode.Attributes["label"].Value; + + dictionaryNetLayerNameAndCaption.Add(layerName1, layerchildName); + + if (layerType != "db") + { + if (xmlLayerNode.Attributes["isRoad"] != null) + { + roadLayerName = layerchildName; + } + } + else if (xmlLayerNode.Attributes["isPipeLine"] != null) + { + m_PipelineLayerNames.Add(layerchildName); + g1layername.Add(layerName1); + } + else if (xmlLayerNode.Attributes["isWorkWell"] != null) + { + workwellLayerNames.Add(layerchildName); + g1layername.Add(layerName1); + } + else if (xmlLayerNode.Attributes["isValve"] != null) + { + valueLayerNames.Add(layerchildName); + g1layername.Add(layerName1); + } + else if (xmlLayerNode.Attributes["isAccess"] != null) + { + instrumenLayerNames.Add(layerchildName); + g1layername.Add(layerName1); + } + else if (xmlLayerNode.Attributes["isCharacter"] != null) + { + pipefittingLayerNames.Add(layerchildName); + g1layername.Add(layerName1); + } + else if (xmlLayerNode.Attributes["isSgData"] != null) + { + sgPipeLayersNames.Add(layerchildName); + g1layername.Add(layerName1); + } + + } + } + + private void initMarkerTree() + { + 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); + } + } + } + } + + private void MainFrm_Load(object sender, EventArgs e) + { + + this.initGlobalControl(); + this.initGlobalMap(); + this.initLayerTree(); + this.initMarkerTree(); + this.initLayout(); + this.loadData(); + + + double x = Convert.ToDouble(Utility.Query_Roads["绿岛"].ToString().Split(',')[0]); + double y = Convert.ToDouble(Utility.Query_Roads["绿岛"].ToString().Split(',')[1]); + double z = Convert.ToDouble(Utility.Query_Roads["绿岛"].ToString().Split(',')[2]); + jumpToCameraState(x, y, z); + + + } + + #endregion + + /// + /// 每次gis服务加载时都会触发的 + /// + /// + /// + 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 dictionaryNetLayerNameAndCaption = new Dictionary(); + 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 配置用户权限 + /// + /// 向数据库插入功能列表 + /// + private void insertControlToDatabase() + { + ArrayList listItem = new ArrayList(); + List subListItem = new List(); + 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) + { + GSOCameraState camera = globeControl2.Globe.CameraState; + globeControl1.Globe.JumpToCameraState(camera); + } + } + + void globeControl1_BeforeSceneRenderEvent(object sender, BeforeSceneRenderEventArgs e) + { + if (globeControl1.Focused) + { + 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); + } + } + } + + /// + /// 检查数据集是否有坐标系信息 + /// + /// + /// + 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 = "0prj4" + lprjStr + ""; + + bSuccess = dataset.LoadProjectionFromESRIFile(dlg.FileName); + + string lprjFileName = strDataPath.Substring(0, strDataPath.LastIndexOf(".")) + ".lprj"; + StreamWriter writer = new StreamWriter(lprjFileName, false); + writer.Write(lprjFileContent); + writer.Close(); + + } + } + } + else + { + return true; + } + return bSuccess; + } + + /// + /// 矩形拉框结束事件处理函数 + /// + /// + /// + 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))); + */ + + int mapWidth = 0; + int mapHeight = 0; + Point pt = getUpperLeftPoint(pt1, pt2, out mapWidth, out mapHeight); + int rightBottomX = pt.X + mapWidth; + int rightBottomY = pt.Y + mapHeight; + Image myImg = new Bitmap(mapWidth, mapHeight); + Graphics g = Graphics.FromImage(myImg); + g.CopyFromScreen(pt, new Point(0, 0), new Size(rightBottomX, rightBottomY)); + + 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; + } + } + /// + /// 定位正北正90度俯视 + /// + /// + /// + /// + 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; + } + } + /// + /// layerTree选中后事件处理 + /// + /// + /// + 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); + } + /// + /// 树节点选中方法 + /// + /// + 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); + } + } + } + + } + /// + /// 改变所有子节点的状态 + /// + /// + /// + 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; + LayerFlyMenuItem.Visible = true; + } + + LayerSelectableMenuItem.Visible = true; + LayerEditableMenuItem.Visible = true; + SaveLayerMenuItem.Visible = true; + LayerFlyMenuItem.Visible = true; + 导出CADToolStripMenuItem1.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]); + if (layer != null) + { + LayerSelectableMenuItem.Checked = layer.Selectable; + LayerEditableMenuItem.Checked = layer.Editable; + } + else + { + return; + } + } + 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; + } + } + } + } + } + + /// + /// 删除临时添加的本地数据图层 + /// + /// + /// + 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); + for (int i = globeControl1.Globe.Layers.Count-1; i >=0; i--) + { + if (globeControl1.Globe.Layers[i].Caption == layer.Caption) + { + globeControl1.Globe.Layers.Remove(globeControl1.Globe.Layers[i]); + } + } + + 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 定位ToolStripMenuItem_Click(object sender, EventArgs e) + { + TreeNode node = layerTree.SelectedNode; + + if (node != null) + { + if (node.Parent.Text.Trim() == "临时图层") + { + GSOLayer lsLayer = globeControl1.Globe.Layers.GetLayerByCaption(node.Text.ToString()); + double x = lsLayer.LatLonBounds.Center.X; + double y = lsLayer.LatLonBounds.Center.Y; + if (x == 0 && y == 0) + { + x = lsLayer.Bounds.Center.X; + y = lsLayer.Bounds.Center.Y; + } + + globeControl1.Globe.FlyToPosition(new GSOPoint3d(x, y, 10), EnumAltitudeMode.Absolute); + } + else + { + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(node.Tag.ToString().Split('|')[1]); + + if (layer != null) + { + if (layer.Caption == "红线") + { + globeControl1.Globe.FlyToPosition(new GSOPoint3d(120.610963, 31.188121, 50), EnumAltitudeMode.Absolute, -4, 50, 1000); + globeControl1.Globe.FlyToPointSpeed = 10000000; + globeControl1.Globe.Action = EnumAction3D.SelectObject; + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = true; + } + globeControl1.Refresh(); + } + else + { + double x = layer.LatLonBounds.Center.X; + double y = layer.LatLonBounds.Center.Y; + globeControl1.Globe.FlyToPosition(new GSOPoint3d(x, y, 100), EnumAltitudeMode.Absolute); + } + } + } + } + else + { + return; + } + + } + + private void layerTree_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e) + { + if(this.layerTree.SelectedNode!=null) + { + if (this.layerTree.SelectedNode.Tag.ToString().Contains("|")) + { + string nodeTag = this.layerTree.SelectedNode.Tag.ToString().Split('|')[1]; + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(nodeTag); + if (layer != null) + { + if (layer.Caption == "红线") + { + globeControl1.Globe.FlyToPosition(new GSOPoint3d(120.610963, 31.188121, 50), EnumAltitudeMode.Absolute, -4, 50, 1000); + globeControl1.Globe.FlyToPointSpeed = 10000000; + globeControl1.Globe.Action = EnumAction3D.SelectObject; + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = true; + } + globeControl1.Refresh(); + } + else { + double x = layer.LatLonBounds.Center.X; + double y = layer.LatLonBounds.Center.Y; + globeControl1.Globe.FlyToPosition(new GSOPoint3d(x, y, 0), EnumAltitudeMode.Absolute); + } + } + } + if (this.layerTree.SelectedNode.Tag is GSOLayer) + { + GSOLayer layer = this.layerTree.SelectedNode.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 (this.layerTree.SelectedNode.Tag is GSOFeature) + { + GSOFeature feature = this.layerTree.SelectedNode.Tag as GSOFeature; + if (feature.Geometry != null) + { + globeControl1.Globe.FlyToPosition(feature.Geometry.GeoCenterPoint, EnumAltitudeMode.Absolute, 0, 0, 10); + } + else + { + globeControl1.Globe.FlyToFeature(feature); + } + } + } + } + + /// + /// 在三维场景移动时,隐藏气泡globeControl1 + /// + /// + /// + void globeControl1_CameraBeginMoveEvent(object sender, CameraBeginMoveEventArgs e) + { + if (featureTooltip.IsVisible()) + { + featureTooltip.HideBalloon(); + } + if (balloonEx.IsVisible()) + { + balloonEx.HideBalloon(); + } + } + + /// + /// 在三维场景移动时,隐藏气泡globeControl2 + /// + /// + /// + void globeControl2_CameraBeginMoveEvent(object sender, CameraBeginMoveEventArgs e) + { + if (featureTooltip2.IsVisible()) + { + featureTooltip2.HideBalloon(); + } + if (balloonEx2.IsVisible()) + { + balloonEx2.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(); + } + } + + #region Fan 横断面 + /// + /// 横断面分析、基线剖面分析、道路断面分析等 + /// + /// + /// + private static EnumTrackPolylineEndMode trackPolylineEndMode; + + void globeControl1_TrackPolylineEndEvent(object sender, TrackPolylineEndEventArgs e) + { + //横断面分析、道路横断面分析 + if (trackPolylineEndMode == EnumTrackPolylineEndMode.HDM_Analysis|| + trackPolylineEndMode == EnumTrackPolylineEndMode.DLDM_Analysis) + { + Dictionary hdmDic = SectionAnalysisTool.HDMAnalysis(this.globeControl1, + e.Polyline, this.m_PipelineLayerNames); + FrmHDMAnalysis3 frm = new FrmHDMAnalysis3(hdmDic, this.globeControl1, + trackPolylineEndMode); + frm.Show(this); + } + //基线剖面分析 + else if (trackPolylineEndMode == EnumTrackPolylineEndMode.JXPM_Analysis) + { + FrmBaseLineProfillAnalysis dlg = new FrmBaseLineProfillAnalysis(globeControl1.Globe, e.Polyline); + dlg.Show(this); + globeControl1.Globe.ClearLastTrackPolyline(); + } + else + { + + } + trackPolylineEndMode = EnumTrackPolylineEndMode.Default_Analysis; + } + #endregion + + private GSOFeatures PolygonIntersectAnalysis(GSOGeoPolygon3D polygon, string pipelinetype) + { + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(pipelinetype); + 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(pipelinetype, feats.Length); + return feats; + } + /// + /// 根据范围统计阀门、管线、工井等, 开挖分析, 挖方量分析 + /// + /// + /// + void globeControl1_TrackPolygonEndEvent(object sender, TrackPolygonEndEventArgs e) + { + if (globeControl1.Globe.Action == EnumAction3D.TrackPolygon && e.Polygon != null) + { + GSOGeoPolygon3D polygon = e.Polygon; + + switch (trackflag) + { + case "valvequery": + FrmValveStatistics frm = new FrmValveStatistics(globeControl1,polygon, new DataGridViewDelegate(InitDataGridViewX1)); + frm.Show(this); + globeControl1.Globe.Action = EnumAction3D.ActionNull; + break; + + case "PipelineDistanceStatistics": +<<<<<<< HEAD +======= + +>>>>>>> d2d0088a6b3c53c1a96b7f1997f4d3443c0ee8c0 + FrmAllPipelineStatis frm1 = new FrmAllPipelineStatis(globeControl1, polygon, new DataGridViewDelegate(InitDataGridViewX1), m_PipelineLayerNames); + frm1.Show(this); + globeControl1.Globe.Action = EnumAction3D.ActionNull; + + break; + case "PipelineSpatialQuery": +<<<<<<< HEAD +======= + +>>>>>>> d2d0088a6b3c53c1a96b7f1997f4d3443c0ee8c0 + FrmAllPipelineStatis.ShowForm(globeControl1,polygon,new DataGridViewDelegate(InitDataGridViewX1),m_PipelineLayerNames); + globeControl1.Globe.ClearAnalysis(); + globeControl1.Globe.Action = EnumAction3D.ActionNull; + + break; + case "workwellquery": + FrmAllWorkWellStatis frmWell = new FrmAllWorkWellStatis(globeControl1, polygon, new DataGridViewDelegate(InitDataGridViewX1)); + 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 "BSQDuoBianXiangStatis": + + //GSOFeature f2 = new GSOFeature(); + //f2.Geometry = e.Polygon; + //f2.Geometry.AltitudeMode = EnumAltitudeMode.Absolute; + //globeControl1.Globe.MemoryLayer.AddFeature(f2); + //f2.Geometry.MoveZ(3); + //workWellLen.Clear(); + //List listBSQ = new List(); + + //GSOFeatures bsqFeatures = PolygonIntersectAnalysis(e.Polygon, "标识器"); + //listBSQ.Add(bsqFeatures); + + //FrmBSQDuoBianXingStatis bsqFrm = new FrmBSQDuoBianXingStatis(workWellLen, globeControl1, listBSQ); + FrmBSQStatis bsqFrm = new FrmBSQStatis(globeControl1,e.Polygon); + bsqFrm.Show(this); + globeControl1.Globe.Action = EnumAction3D.ActionNull; + break; + + case "": + break; + default: + break; + } + } + } + + #region 验证端口 + /* + /// + /// 验证端口 + /// + /// + 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 + + /// + /// 鼠标悬浮提示 + /// + /// + /// + 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); + } + } + + /// + /// 添加管线绘制完成事件, 红线工具绘制完成 + /// + /// + /// + 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; + + + } + } + + /// + /// 获取globeControl1中鼠标按下的坐标供区别鼠标右键和滚轮按下事件 + /// + /// + /// + void globeControl1_MouseDown(object sender, MouseEventArgs e) + { + mouseDownX1 = e.X; + mouseDownY1 = e.Y; + } + /// + /// 获取globeControl2中鼠标按下的坐标供区别鼠标右键和滚轮按下事件 + /// + /// + /// + void globeControl2_MouseDown(object sender, MouseEventArgs e) + { + mouseDownX2 = e.X; + mouseDownY2 = e.Y; + } + /// + /// + /// + /// + /// + void globeControl2_MouseClick(object sender, MouseEventArgs e) + { + if (e.Button == MouseButtons.Right) + { + if (e.X == mouseDownX2 && e.Y == mouseDownY2) + { + RightScreenToolMenu.Show(globeControl2, e.X, e.Y); + } + else + { + return; + } + } + } + /// + /// + /// + /// + /// + void globeControl1_MouseClick(object sender, MouseEventArgs e) + { + if (e.Button == MouseButtons.Left) + { + if (globeControl1.Globe.Action == EnumAction3D.VisibilityAnalysis) + { + buttonItemFX5_1.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; + + bsqPT = pt; + + if (buttonItemLS5.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 (e.X == mouseDownX1 && e.Y == mouseDownY1) + { + toolRightMenu.Show(globeControl1, e.X, e.Y); + if (buttonItemLS5.Checked) + { + buttonItemLS5.Checked = false; + } + } + else + { + return; + } + } + globeControl1.Refresh(); + } + + /// + /// 判断网络图片是否存在 + /// + /// + /// + 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; + } + + /// + /// 鼠标点击, 弹出气泡功能globeControl1 + /// + /// + /// + void globeControl1_FeatureMouseClickEvent(object sender, FeatureMouseClickEventArgs e) + { + GSOFeature feature = e.Feature; + + string str1 = ""; + if (feature != null) + { + if (feature.GetFieldDefn("图片编码") != null)// + { + str1 = GetBubbleInfo(feature, globeControl1); + if (RemoteFileExists(Utility.PicRootURL + feature.GetValue("图片编码").ToString())) + { + str1 += ""; + } + else if (RemoteFileExists(Utility.PicDefaultURL)) + { + str1 += ""; + } + } + else if (isFeatureContainsBianhao(feature)) //管线模型图层 + { + str1 = GetBubbleInfo(feature, globeControl1); + } + + 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; + } + } + } + + /// + /// 鼠标点击, 弹出气泡功能globeControl2 + /// + /// + /// + void globeControl2_FeatureMouseClickEvent(object sender, FeatureMouseClickEventArgs e) + { + GSOFeature feature = e.Feature; + + string str1 = ""; + if (feature != null) + { + if (feature.GetFieldDefn("图片编码") != null) // + { + str1 = GetBubbleInfo(feature, globeControl2); + if (RemoteFileExists(Utility.PicRootURL + feature.GetValue("图片编码").ToString())) + { + str1 += ""; + } + else if (RemoteFileExists(Utility.PicDefaultURL)) + { + str1 += ""; + } + } + else if (isFeatureContainsBianhao(feature)) //管线模型图层 + { + str1 = GetBubbleInfo(feature, globeControl2); + } + + if (str1 != "") + { + + featureTooltip2.HideBalloon(); + balloonEx2.HideBalloon(); + balloonEx2.SetSize(EnumSizeIndexEx.CONTENT_CX, 480); + balloonEx2.SetSize(EnumSizeIndexEx.CONTENT_CY, 420); + balloonEx2.ShowBalloon((int)e.MousePos.X, (int)e.MousePos.Y, str1); + + return; + } + } + } + + /// + /// 拼接气泡表格字符串 + /// + /// + /// + private string GetBubbleInfo(GSOFeature feature,GSOGlobeControl globeControl) + { + if (feature == null) + { + return ""; + } + string str = ""; + str = ""; + 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 += ""; + + 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.get_Fields(layerName, globeControl); + } + if (queryFields != null) + { + string[] param = { "," }; + string[] fieldNames = queryFields.Split(param, StringSplitOptions.RemoveEmptyEntries); + for (int j = 0; j < fieldNames.Length; 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 (name1 == "模型路径") + { + continue; + } + 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 (field1.Type == EnumFieldType.Double) + { + double dl1 = feature.GetFieldAsDouble(j); + if (!name1.Contains("管径") && !name1.Contains("电压") && !name1.Contains("角度")) + { + name1 += "_米"; + } + value1 = dl1.ToString("0.00"); + } + 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 (name2 == "模型路径") + { + continue; + } + + 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 (field2.Type == EnumFieldType.Double) + { + double dl2 = feature.GetFieldAsDouble(j + 1); + if (!name2.Contains("管径") && !name2.Contains("电压") && !name2.Contains("角度")) + { + name2 += "_米"; + } + value2 = dl2.ToString("0.00"); + } + else + { + if (!feature.IsFieldValueNull(j + 1)) + { + value2 = feature.GetValue(j + 1).ToString(); + } + } + } + } + + j++; + } + str += ""; + } + } + str += "
" + title + " " + feature.GetFieldAsString(featureIDFieldName) + "
" + + name1 + + "
" + + value1 + + "
" + + name2 + + "
" + + value2 + "
"; + return str; + } + + string filename = Utility.filename; + List g1layername = new List(); + + /// + /// 获取目标图层 + /// + /// + 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; + } + /// + /// 添加图层 + /// + /// + /// + /// + 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 = 5000; + return templayer.Visible; + } + catch (Exception ex) + { + return false; + } + } + /// + /// 菜单上的 三维导航 工具按钮 + /// + /// + /// + private void buttonItem86_Click(object sender, EventArgs e) + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + } + + /// + /// 地上模式 菜单按钮 + /// + /// + /// + 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(); + + } + } + /// + /// 地下模式 菜单按钮 + /// + /// + /// + 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(); + } + } + /// + /// 行走模式 菜单按钮 + /// + /// + /// + 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; + } + } + /// + /// 地面透明度设置 菜单 + /// + /// + /// + private void sliderGroundTransSet1_ValueChanged(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.sliderGroundTransSet1.Text); + + globeControl1.Globe.GroundOpaque = 100 - sliderGroundTransSet1.Value; + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(roadLayerName);//("180fd"); + if (layer != null) + { + layer.Opaque = 100 - sliderGroundTransSet1.Value; + } + //if (buttonItemSPDB.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; + } + /// + /// 图例 菜单按钮 + /// + /// + /// + 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(); + } + /// + /// 快速定位 菜单按钮 + /// + /// + /// + private void buttonItem91_Click(object sender, EventArgs e) // + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItem91.Text); + FrmFlyToPosition fly = new FrmFlyToPosition(globeControl1); + fly.Show(this); + } + /// + /// 图层管理 菜单按钮 + /// + /// + /// + 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; + + //修改图层管理与标注管理、覆土审查、水平净距分析、垂直净距分析和碰撞分析控件之间的逻辑关系 + controlContainerItem5.Visible = false; + sideBar1.Visible = false; + sideBarPanelItem4.Visible = false; + panel3.Visible = false; + sideBar1.ExpandedPanel = sideBarPanelItem3; + buttonItemBZ11.Checked = false; + + //20160624 + /* + if (sideBarPanelItem4.Visible == true) + { + sideBar1.Visible = true; + controlContainerItem5.Visible = true; + } + else + { + sideBar1.Visible = false; + } + */ + Refresh(); + + } + } + /// + /// 全屏显示 菜单按钮 + /// + /// + /// + 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; + /// + /// 全屏显示功能实现 + /// + 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(); + } + } + + /// + /// 设置窗体宽、高 + /// + /// + /// + private void SetFullScreen(int width, int height) + { + this.Width = width; + this.Height = height; + } + + /// + /// 全屏功能的快捷键F5 + /// + /// + /// + 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); + } + } + /* + /// + /// 输出地图 + /// + /// + /// + /// + 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; + } + * */ + + private Point getUpperLeftPoint(Point p1, Point p2, out int mapWidth, out int mapHeight) // + { + Rectangle rc = new Rectangle(); + + p1 = this.globeControl1.PointToScreen(p1); + p2 = this.globeControl1.PointToScreen(p2); + + int x = Screen.PrimaryScreen.Bounds.X; + int y = Screen.PrimaryScreen.Bounds.Y; + int screenWidth = SystemInformation.WorkingArea.Width; + int screenHeight = SystemInformation.WorkingArea.Height; + + if (p1.X < x) + rc.X = x; + else + rc.X = p1.X; + + if (p1.Y < y) + rc.Y = y; + else + rc.Y = p1.Y; + + p1.X = rc.Left; + p1.Y = rc.Top; + + if (p2.X > screenWidth) + p2.X = screenWidth; + else + p2.X = p2.X; + + if (p2.Y > screenHeight) + p2.Y = screenHeight; + else + p2.Y = p2.Y; + + rc.Width = p2.X - rc.X; + rc.Height = p2.Y - rc.Y; + + mapWidth = rc.Width; + mapHeight = rc.Height; + Point pt = new Point(rc.Left, rc.Top); + return pt; + } + + Image printImage; + /// + /// 打印 菜单 + /// + /// + /// + 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))); + */ + int mapWidth = 0; + int mapHeight = 0; + Point pt = getUpperLeftPoint(pt1, pt2, out mapWidth, out mapHeight); + int rightBottomX = pt.X + mapWidth; + int rightBottomY = pt.Y + mapHeight; + Image myImg = new Bitmap(mapWidth, mapHeight); + Graphics g = Graphics.FromImage(myImg); + g.CopyFromScreen(pt, new Point(0, 0), new Size(rightBottomX, rightBottomY)); + + + 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); + } + /// + /// 输出地图 菜单 + /// + /// + /// + private void btnOutputJPG_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btnOutputJPG.Text); + + //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))); + */ + int mapWidth = 0; + int mapHeight = 0; + Point pt = getUpperLeftPoint(pt1, pt2, out mapWidth, out mapHeight); + int rightBottomX = pt.X + mapWidth; + int rightBottomY = pt.Y + mapHeight; + Image myImg = new Bitmap(mapWidth, mapHeight); + Graphics g = Graphics.FromImage(myImg); + g.CopyFromScreen(pt, new Point(0, 0), new Size(rightBottomX, rightBottomY)); + + 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; + } + } + } + + /// + /// 统计管线的里程数 + /// + /// + /// + /// + 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; + } + + /// + /// 窗体下方属性表格 右键菜单中的 “定位”菜单 + /// + /// + /// + 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); + + } + + /// + /// 表格中右键 “单个闪烁” 菜单 + /// + /// + /// + private void LightMenu_Click(object sender, EventArgs e) + { + flashflag = "single"; + timer1.Start(); + } + /// + /// 表格中右键 “全部闪烁” 菜单 + /// + /// + /// + private void AllLightMenuItem_Click(object sender, EventArgs e) + { + flashflag = "all"; + timer1.Start(); + } + + /// + /// 使用timer实现管线的闪烁效果 + /// + /// + /// + 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; + } + } + + /// + /// 绘制线 菜单 + /// + /// + /// + private void btnAddLine_Click(object sender, EventArgs e) + { + globeControl1.Globe.DestLayerFeatureAdd = globeControl1.Globe.MemoryLayer; + globeControl1.Globe.Action = EnumAction3D.DrawPolyline; + } + /// + /// 绘制面 菜单 + /// + /// + /// + private void btnAddPolygon_Click(object sender, EventArgs e) + { + globeControl1.Globe.DestLayerFeatureAdd = globeControl1.Globe.MemoryLayer; + globeControl1.Globe.Action = EnumAction3D.DrawPolygon; + } + /// + /// 图层目录树 右键菜单中的 目标图层 菜单 + /// + /// + /// + 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; + } + } + /// + /// 图层目录树 右键菜单中的 可选择 菜单 + /// + /// + /// + 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; + } + /// + /// 图层目录树 右键菜单中的 可编辑 菜单 + /// + /// + /// + 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; + } + /// + /// 图层目录树 右键菜单中的 保存 菜单 + /// + /// + /// + 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(); + } + + /// + /// 根据多边形范围统计管线的里程 + /// + /// + /// + /// 返回查询到的管线要素集合 + 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 pipeLineDis = new Dictionary(); + Dictionary workWellLen = new Dictionary(); + + + + + /// + /// 查找指定图层中在 指定范围内的feature对象集合 + /// + /// + /// + /// + 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; + } + /// + /// 清除结果 菜单 + /// + /// + /// + private void buttonItem47_Click(object sender, EventArgs e) + { + globeControl1.Globe.ClearAnalysis(); + dataGridViewX1.DataSource = null; + panelOfTable.Visible = false; + clearFeatureHighLight(); + } + /// + /// 设置菜单的选中状态 + /// + private void ActionToolMenuChecked() + { + if (globeControl1.Globe.Action != EnumAction3D.TrackPolyline) + { + buttonItemFX2_1.Checked = false; + buttonItemFX2_4.Checked = false; + buttonItemFX2_3.Checked = false; + buttonItemFX4_3.Checked = false; + } + if (globeControl1.Globe.Action != EnumAction3D.NormalHit) + { + buttonItemFX3_6.Checked = false; + // ClearConnexityAnalysis(); + + buttonItemFX3_5.Checked = false; + // ClearCloseValvesAnalysis(); + } + if (globeControl1.Globe.Action != EnumAction3D.TrackPolygon) + { + buttonItemFX4_2.Checked = false; + buttonItemFX4_1.Checked = false; + } + } + + /// + /// 主窗体关闭事件处理 + /// + /// + /// + private void MainFrm_FormClosing(object sender, FormClosingEventArgs e) + { + + if (MessageBox.Show("是否退出系统?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) + { + e.Cancel = true; + } + else { + globeControl1.Globe.MemoryLayer.SaveAs(Application.StartupPath + "/MyPlace.kml"); + } + + //saveLayerList(layerManagerNode.Nodes); + //注销id号为103的热键设定 + // UnregisterHotKey(Handle, 103); + } + + /// + /// 显示流向 功能 + /// + /// + /// + /// + 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(); + } + + FrmCloseValves frm; + + FrmBoosterValvers frmbooster = null; + + /// + /// 垂直净距分析 功能界面中的 选择图层复选框 选中状态改变事件处理 + /// + /// + /// + 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(); + } + /// + /// 水平净距分析 功能界面中的 选择图层复选框 选中状态改变事件处理 + /// + /// + /// + 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(); + } + /// + /// 垂直净距分析 功能界面中的 选择管线复选框 选中状态改变事件处理 + /// + /// + /// + private void checkBoxX1_CheckedChanged(object sender, EventArgs e) + { + clearFeatureHighLight(); + if (checkBoxX1.Checked) + { + comboBoxEx1.SelectedItem = null; + 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; + } + } + /// + /// 水平净距分析 功能界面中的 选择管线复选框 选中状态改变事件处理 + /// + /// + /// + private void checkBoxX1_CheckedChanged_shuiping(object sender, EventArgs e) + { + clearFeatureHighLight();//清除高亮 + if (checkBoxX7.Checked) + { + comboBoxEx4.SelectedItem = null; + 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(); + /// + /// 垂直净距分析 功能界面中的 选择图层下拉框 选中项改变 事件处理 + /// + /// + /// + 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; + } + } + } + /// + /// 水平净距分析 功能界面中的 选择图层下拉框 选中项改变 事件处理 + /// + /// + /// + 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 featCount = new Dictionary(); + Dictionary featLenth = new Dictionary(); + Dictionary m_FeaturesWithBianhao = new Dictionary();//记录编号和对应的标注点的位置 + GSOFeatures polygonJingJuAnalysises = new GSOFeatures(); + + /// + /// 垂直净距分析 功能界面中的 开始分析按钮 事件处理 + /// + /// + /// + 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; + } + + /// + /// 在指定的两点组成的线的中间添加一个marker对象,并将marker对象添加到指定的图层中 + /// + /// + /// + /// + /// + /// + 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; + } + + /// + /// 计算指定feature对象与除了该feature所在图层之外的 所有管线图层中的所有feature对象 的垂直距离 并在表格中记录符合要求的管线 + /// + /// + /// + /// + /// + private void VerticalDistanceAnalysis(string type, GSOFeature selectedFeature, List _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(); + } + /// + /// 垂直净距分析中 表格行的 双击定位 功能。 与覆土分析的实现方法不同,主要原因是需要标注垂距 + /// + /// + /// + 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); + } + } + } + } + + /// + /// 水平净距分析 功能界面中 开始分析按钮 的事件处理 + /// + /// + /// + 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; + } + + + /// + /// 计算指定feature对象与除了该feature所在图层之外的 所有管线图层中的所有feature对象 的水平距离 并记录符合要求的管线 功能 + /// + /// + /// + /// + /// + private void HorizontalDistanceAnalysis(GSOFeature selectedFeature, List _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)); + } + } + } + } + } + /// + /// 水平净距分析 功能界面中 表格的 双击定位 功能 + /// + /// + /// + 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); + } + } + } + } + } + /// + /// 碰撞分析 功能界面中 开始分析按钮 事件处理 + /// + /// + /// + 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; + } + /// + /// 碰撞分析功能界面中 表格的 双击定位 功能 + /// + /// + /// + 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); + } + } + } + } + + + + /// + /// 覆土分析功能操作界面中的 选择管线 复选框选中状态改变事件处理 + /// + /// + /// + private void checkBoxX5_CheckedChanged(object sender, EventArgs e) + { + clearFeatureHighLight(); + if (checkBoxX5.Checked) + { + comboBoxEx3.SelectedItem = null; + 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; + } + } + /// + /// 覆土分析功能操作界面中的 选择图层 复选框选中状态改变事件处理 + /// + /// + /// + 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(); + } + /// + /// 覆土分析功能操作界面中的 图层下拉框选中项改变事件处理 + /// + /// + /// + 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; + } + } + } + /// + /// 覆土分析功能操作界面中的 开始分析 按钮事件处理 + /// + /// + /// + 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; + + + GSOPoint3d markerPosition = new GSOPoint3d(); + 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]; + GSOPoint3d pt = new GSOPoint3d(); + + 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"); + + pt.X = pts[m].X; + pt.Y = pts[m].Y; + pt.Z = 0; + markerPosition = LabelVerticalDistance(layerTemp, pts[m], pt, Convert.ToDouble(dataGridViewX7.Rows[idx].Cells[2].Value), true); + 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]; + GSOPoint3d pt = new GSOPoint3d(); + 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"); + + pt.X = pts[m].X; + pt.Y = pts[m].Y; + pt.Z = 0; + markerPosition = LabelVerticalDistance(layerTemp, pts[m], pt, Convert.ToDouble(dataGridViewX7.Rows[idx].Cells[2].Value), true); + + 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; + } + + /// + /// 覆土分析中 表格的 双击定位 功能 + /// + /// + /// + 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); + } + } + } + } + } + /// + /// 覆土分析功能操作界面中的 导出Excel按钮 事件处理 + /// + /// + /// + private void buttonX10_Click(object sender, EventArgs e) + { + if (dataGridViewX7.Rows.Count > 0) + { + ExportExcel("覆土分析", dataGridViewX7, null); + } + else + { + MessageBox.Show("表格内容为空!", "提示"); + } + } + /// + /// 覆土分析功能操作界面底部的 关闭 按钮事件处理 + /// + /// + /// + 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(); + layerTemp.RemoveAllFeature(); + + if (buttonItem1.Checked) + { + sideBar1.ExpandedPanel = sideBarPanelItem3; + } + else + { + sideBar1.Visible = false; + } + globeControl1.Refresh(); + + //Refresh(); + } + + + /// + /// 垂直净距分析 功能界面中 清除分析结果按钮 事件处理 + /// + /// + /// + 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(); + } + /// + /// 水平净距分析 功能界面中 清除分析结果按钮 事件处理 + /// + /// + /// + 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(); + } + + /// + /// 垂直净距分析功能界面中 关闭按钮 事件处理 + /// + /// + /// + 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(); + } + /// + /// 水平净距分析功能界面中 删除缓冲区按钮 事件处理 + /// + /// + /// + private void buttonX14_Click(object sender, EventArgs e) + { + 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(); + } + + /// + /// 导出指定DataGridView控件中的内容 + /// + /// + /// + 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(); + } + } + } + } + + /// + /// 垂直净距分析功能界面中 导出Excel按钮 事件处理 + /// + /// + /// + private void buttonX4_Click(object sender, EventArgs e) + { + if (dataGridViewX3.Rows.Count > 0) + { + ExportExcel("垂直净距分析", dataGridViewX3, listBox1); + } + else + { + MessageBox.Show("表格内容为空!", "提示"); + } + } + /// + /// 水平净距分析功能界面中 导出Excel按钮 事件处理 + /// + /// + /// + private void buttonX4_Click_shuiping(object sender, EventArgs e) + { + if (dataGridViewX9.Rows.Count > 0) + { + ExportExcel("水平净距分析", dataGridViewX9, listBox3); + } + else + { + MessageBox.Show("表格内容为空!", "提示"); + } + } + + + /// + /// 清除所有坑 菜单 + /// + /// + /// + private void buttonItem3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItem3.Text); + + globeControl1.Globe.RemoveAllPits(); + } + + //} + /// + /// 大气层 菜单 + /// + /// + /// + private void buttonItem17_Click_1(object sender, EventArgs e) + { + globeControl1.Globe.Atmosphere.Visible = !globeControl1.Globe.Atmosphere.Visible; + buttonItemSH1.Checked = globeControl1.Globe.Atmosphere.Visible; + globeControl1.Refresh(); + } + /// + /// 经纬网 菜单 + /// + /// + /// + private void buttonItem20_Click(object sender, EventArgs e) + { + globeControl1.Globe.LatLonGrid.Visible = !globeControl1.Globe.LatLonGrid.Visible; + buttonItemSH3.Checked = globeControl1.Globe.LatLonGrid.Visible; + globeControl1.Globe.Refresh(); + } + /// + /// 状态条 菜单 + /// + /// + /// + private void buttonItem21_Click_1(object sender, EventArgs e) + { + globeControl1.Globe.StatusBar.Visible = !globeControl1.Globe.StatusBar.Visible; + buttonItemSH4.Checked = globeControl1.Globe.StatusBar.Visible; + globeControl1.Globe.Refresh(); + } + + + + /// + /// 添加指定路径下的数据 功能 + /// + /// + /// + 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); + //CheckDatasetGeoReference(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; + } + return objRes; + } + /// + /// 刷新目录树 功能 + /// + 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); + } + } + /// + /// 判断图层是否包含字段列表 + /// + /// + /// + 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; + } + + /// + /// 统计指定图层在指定范围内的所有feature对象 + /// + /// + /// + /// + 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; + } + /// + /// 碰撞分析功能界面中 选择管线复选框 选中状态改变事件处理 + /// + /// + /// + private void checkBoxX3_CheckedChanged(object sender, EventArgs e) + { + clearFeatureHighLight(); + if (checkBoxX3.Checked) + { + comboBoxEx2.SelectedItem = null; + 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; + } + } + /// + /// 碰撞分析功能界面中 选择图层复选框 选中状态改变事件处理 + /// + /// + /// + 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(); + } + /// + /// 碰撞分析功能界面中 选择图层下拉框 选中项改变事件处理 + /// + /// + /// + 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; + } + } + } + /// + /// 清除所有图层中的所有feature对象的高亮状态 功能 + /// + 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); + } + } + } + } + for (int i = 0; i < globeControl2.Globe.Layers.Count; i++) + { + GSOLayer layer = globeControl2.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; + } + } + } + + if (globeControl1.Globe.Action == EnumAction3D.SelectObject) + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + //globeControl1.Globe.Action = EnumAction3D.SelectObject; + } + } + + /// + /// 碰撞分析功能界面中 清除分析结果按钮 事件处理 + /// + /// + /// + 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(); + } + /// + /// 碰撞分析功能界面中 导出Excel按钮 事件处理 + /// + /// + /// + private void buttonX6_Click(object sender, EventArgs e) + { + if (dataGridViewX5.Rows.Count > 0) + { + ExportExcel("碰撞分析", dataGridViewX5, listBox2); + } + else + { + MessageBox.Show("表格内容为空!", "提示"); + } + } + /// + /// 导出CAD 菜单 + /// + /// + /// + private void btnExportCAD_Click(object sender, EventArgs e) + { + FrmExportCADS frm = new FrmExportCADS(globeControl1, m_PipelineLayerNames); + frm.ShowDialog(); + } + + ///// + ///// 区域分析 菜单 + ///// + ///// + ///// + //private void buttonItem50_Click(object sender, EventArgs e) + //{ + // buttonItem50.Checked = !buttonItem50.Checked; + // ribbonBarQY.Visible = buttonItem50.Checked; + // ribbonBarQY.Location = new Point(0, 0); + //} + + + /// + /// 连接数据库 菜单事件处理 + /// + /// + /// + 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; + } + } + } + /// + /// 数据验证 菜单 + /// + /// + /// + private void buttonItem80_Click(object sender, EventArgs e) + { + FrmValiData frm = new FrmValiData(globeControl1); + frm.ShowDialog(); + } + /// + /// 根据指定图层创建图层节点并将节点添加到图层管理节点的子节点集合中 + /// + /// + 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; + + if (!layerManagerNode.Nodes.Contains(node)) + { + layerManagerNode.Nodes.Insert(0, node); + layerManagerNode.Expand(); + } + } + } + /// + /// 数据库备份 菜单 + /// + /// + /// + 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(); + } + } + } + + + + #region Fan 去掉 + //GSOFeature emitterFeature; // 粒子要素 + /// + /// 添加火苗 功能 + /// + /// + /// + /// + 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); + + } + /// + /// 添加喷泉 功能 + /// + /// + /// + /// + 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); + } + #endregion + + /// + /// 获取指定图层中最后一个feature对象的名称对应的整数 + /// + /// + /// + 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; + } + /// + /// 设置除指定标注图层之外的所有标注图层不可见 + /// + /// + 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; + } + } + } + } + } + + /// + /// 判断选中的对象是否为管线 + /// + /// 被选中管线 + /// 返回一根线 + 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; + } + + /// + /// 获取指定两点组成的线的长度 功能 + /// + /// + /// + /// + 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; + } + + /// + /// 图层节点树中 节点 右键单击事件处理 + /// + /// + /// + 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; + } + } + } + } + } + + /// + /// 标注管理、传感器管理 图层目录树的右键菜单中的 刷新列表 菜单 + /// + /// + /// + 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); + } + } + /// + /// 给指定的图层节点添加代表feature对象的子节点 + /// + /// + private void RefreshTreeNodeLayerFeatureList(TreeNode layerTreeNode) + { + layerTreeNode.Nodes.Clear(); + GSOLayer layer = (GSOLayer)layerTreeNode.Tag; + // 只将类型为内存数据集的图层列出,如果是其它类型的数据集可能数据量太大,没发显示在树控件中 + if (layer.Dataset is GSOFeatureDataset) + { + VisitFeature3Ds(layer.GetAllFeatures(), layerTreeNode); + } + } + + /// + /// 标注管理、传感器管理 图层目录树的右键菜单中的 移除所有 菜单 + /// + /// + /// + 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(); + } + } + + /// + /// 图层目录树的 节点对应的复选框选中状态改变事件处理 + /// + /// + /// + private void layerMarkerTree_AfterCheck(object sender, TreeViewEventArgs e) + { + if (e.Action != TreeViewAction.Unknown) + { + CheckTreeNode(e.Node, e.Node.Checked); + } + } + /// + /// 改变指定节点对应的复选框的选中状态 + /// + /// + /// + private void CheckTreeNode(TreeNode node, Boolean bChecked) + { + CheckChildTreeNode(node, bChecked); + globeControl1.Globe.Refresh(); + } + /// + /// 改变指定节点的子节点对应的复选框的选中状态 + /// + /// + /// + 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); + } + } + /// + /// 标注管理、传感器管理 目录树中的feature节点的右键菜单中的 删除 菜单 + /// + /// + /// + 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(); + } + } + + /// + /// 双屏对比 菜单 + /// + /// + /// + //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(); + // } + //} + /// + /// 模拟分析 菜单 + /// + /// + /// + //private void buttonItem51_Click(object sender, EventArgs e) + //{ + // buttonItem51.Checked = !buttonItem51.Checked; + // ribbonBarMN.Visible = buttonItem51.Checked; + // ribbonBarMN.Location = new Point(0, 0); + //} + + /// + /// 双屏设置 菜单 + /// + /// + /// + //private void buttonItem96_Click(object sender, EventArgs e) + //{ + // FrmLayerControl frm = new FrmLayerControl(layerTree,globeControl1,globeControl2); + // frm.Show(this); + //} + /// + /// 双屏联动 菜单 + /// + /// + /// + //private void buttonItem95_Click(object sender, EventArgs e) + //{ + // buttonItem95.Checked = !buttonItem95.Checked; + //} + ///// + /// 添加用户仓库 菜单 + /// + /// + /// + private void buttonItem108_Click(object sender, EventArgs e) + { + FrmUserRepo frm = new FrmUserRepo(-1); + frm.ShowDialog(); + } + /// + /// 用户仓库管理 菜单 + /// + /// + /// + private void buttonItem111_Click(object sender, EventArgs e) + { + FrmUserRepoMgr frm = new FrmUserRepoMgr(); + frm.ShowDialog(); + } + /// + /// 添加分系统 菜单 + /// + /// + /// + private void buttonItem112_Click(object sender, EventArgs e) + { + //FrmAPP frm = new FrmAPP(-1); + //frm.ShowDialog(); + } + /// + /// 分系统管理 菜单 + /// + /// + /// + private void buttonItem113_Click(object sender, EventArgs e) + { + //FrmAPPMgr frm = new FrmAPPMgr(); + //frm.ShowDialog(); + } + /// + /// 添加操作 菜单 + /// + /// + /// + private void buttonItem114_Click(object sender, EventArgs e) + { + FrmOper frm = new FrmOper(-1); + frm.ShowDialog(); + } + /// + /// 操作管理 菜单 + /// + /// + /// + private void buttonItem115_Click(object sender, EventArgs e) + { + FrmOperMgr frm = new FrmOperMgr(); + frm.ShowDialog(); + } + /// + /// 添加资源 菜单 + /// + /// + /// + private void buttonItem116_Click(object sender, EventArgs e) + { + FrmRESC frm = new FrmRESC(-1); + frm.ShowDialog(); + } + /// + /// 资源管理 菜单 + /// + /// + /// + private void buttonItem117_Click(object sender, EventArgs e) + { + FrmRESCMgr frm = new FrmRESCMgr(); + frm.ShowDialog(); + } + /// + /// 添加权限 菜单 + /// + /// + /// + private void buttonItem118_Click(object sender, EventArgs e) + { + FrmPerm frm = new FrmPerm(-1); + frm.ShowDialog(); + } + /// + /// 权限管理 菜单 + /// + /// + /// + private void buttonItem119_Click(object sender, EventArgs e) + { + FrmPermMgr frm = new FrmPermMgr(); + frm.ShowDialog(); + } + /// + /// 添加访问控制 菜单 + /// + /// + /// + private void buttonItem120_Click(object sender, EventArgs e) + { + FrmAccess frm = new FrmAccess(-1); + frm.ShowDialog(); + } + /// + /// 访问控制管理 菜单 + /// + /// + /// + private void buttonItem121_Click(object sender, EventArgs e) + { + FrmAccessMgr frm = new FrmAccessMgr(); + frm.ShowDialog(); + } + /// + /// 部门类型管理 菜单 + /// + /// + /// + private void buttonItem122_Click(object sender, EventArgs e) + { + FrmRegionTypeMgr frm = new FrmRegionTypeMgr(); + frm.ShowDialog(); + } + /// + /// 添加用户 菜单 + /// + /// + /// + private void buttonItem127_Click(object sender, EventArgs e) + { + FrmUserAdd frm = new FrmUserAdd(-1); + frm.ShowDialog(); + } + /// + /// 用户信息管理 菜单 + /// + /// + /// + private void buttonItem128_Click_1(object sender, EventArgs e) + { + FrmUserManager frm = new FrmUserManager(); + frm.ShowDialog(); + } + /// + /// 添加角色 菜单 + /// + /// + /// + private void 添加角色_Click(object sender, EventArgs e) + { + FrmRole frm = new FrmRole(-1); + frm.ShowDialog(); + } + /// + /// 所有角色管理 菜单 + /// + /// + /// + private void 角色管理_Click(object sender, EventArgs e) + { + FrmRoleMgr frm = new FrmRoleMgr(); + frm.ShowDialog(); + } + + /// + /// 部门角色管理 菜单 + /// + /// + /// + private void buttonItem133_Click(object sender, EventArgs e) + { + FrmRegionRoleMgr frm = new FrmRegionRoleMgr(); + frm.ShowDialog(); + } + /// + /// 部门管理 菜单 + /// + /// + /// + private void buttonItem130_Click(object sender, EventArgs e) + { + FrmRegionMgr frm = new FrmRegionMgr(); + frm.ShowDialog(); + } + + /// + /// 日志管理 菜单 + /// + /// + /// + private void buttonItem135_Click(object sender, EventArgs e) + { + FrmLogManager frm = new FrmLogManager(); + frm.ShowDialog(); + } + /// + /// 传感器信息查询 菜单 + /// + /// + /// + 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); + } + } + } + /// + /// 根据指定的图层的caption属性的值在配置文件中查找对应的数据库中的表的名称 + /// + /// 图层的caption属性的值 + /// 对应的数据库中的表的名称 + 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; + } + /// + /// 根据数据库中的表的名称 查找对应的表中的字段名称的集合 + /// + /// 数据库中的表的名称 + /// 对应的表中的字段名称的集合 + 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; + } + + /// + /// 历史曲线查询 菜单 + /// + /// + /// + 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; + /// + /// 传感器在线报警 菜单 + /// + /// + /// + 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); + } + /// + /// 传感器报警 功能中的 定时器 的触发事件处理 + /// + /// + /// + 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; + } + } + } + } + } + } + } + + + /// + /// 沿线运动 菜单 + /// + /// + /// + private void buttonItem138_Click(object sender, EventArgs e) + { + if (globeControl1.Globe.SelectedObject == null) + { + MessageBox.Show("请先选择一条线!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + return; + } + + GSOFeature lineFeature = globeControl1.Globe.SelectedObject; + if (lineFeature.Geometry == null || lineFeature.Geometry.Type != EnumGeometryType.GeoPolyline3D) + { + MessageBox.Show("请先选择一条线!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + return; + } + + OpenFileDialog dlg = new OpenFileDialog(); + dlg.Filter = "*.gcm;*.3ds|*.gcm;*.3ds|*.3ds|*.3ds|*.gcm|*.gcm"; + if (dlg.ShowDialog() == DialogResult.OK) + { + GSOGeoModel model = new GSOGeoModel(); + model.FilePath = dlg.FileName; + + GSOGeoDynamicRoute dynamicRoute = new GSOGeoDynamicRoute(); + dynamicRoute.ActorGeometry = model; + + GSORoute route = new GSORoute(); + GSOGeoPolyline3D geoline = (GSOGeoPolyline3D)lineFeature.Geometry; + for (int i = 0; i < geoline[0].Count; i++) + { + route.Add(geoline[0][i]); + } + route.CircleRoute = false; + route.Speed = 30; + route.RotateSpeed = 50; + route.AltitudeMode = geoline.AltitudeMode; + dynamicRoute.Route = route; + + GSOFeature feature = new GSOFeature(); + + dynamicRoute.Play(); + feature.Geometry = dynamicRoute; + + //GSOLabel gsoLabel = new GSOLabel(); + //gsoLabel.Text = "模型测试"; + //feature.Label = gsoLabel; + globeControl1.Globe.MinModelVisibleSize = 0; + + globeControl1.Globe.MemoryLayer.AddFeature(feature); + globeControl1.Globe.Refresh(); + } + } + /// + /// 回退 菜单 + /// + /// + /// + private void buttonItem99_Click(object sender, EventArgs e) + { + globeControl1.Globe.UnDoEdit(); + } + /// + /// 前进 菜单 + /// + /// + /// + private void buttonItem100_Click(object sender, EventArgs e) + { + globeControl1.Globe.ReDoEdit(); + } + /// + /// 水平净距 功能界面中的 标签内容改变事件处理 + /// + /// + /// + 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() + "米的管线有:"; + } + } + } + /// + /// 垂直净距 功能界面中的 标签内容改变事件处理 + /// + /// + /// + 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() + "米的管线有:"; + } + } + } + /// + /// 覆土分析 功能界面中的 标签内容改变事件处理 + /// + /// + /// + 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() + "米的管线有:"; + } + } + } + + /// + /// 传感器分类查询 全区域 菜单 + /// + /// + /// + private void buttonItemSensor全区域查询_Click(object sender, EventArgs e) + { + FrmAccessoriesSensor.ShowForm(globeControl1, instrumenLayerNames, 0); + } + /// + /// 传感器分类查询 绘制区域 菜单 + /// + /// + /// + private void buttonItemSensor绘制区域查询_Click(object sender, EventArgs e) + { + FrmAccessoriesSensor.ShowForm(globeControl1, instrumenLayerNames, 1); + } + + + /// + /// 碰撞分析 功能界面中 关闭按钮 事件处理 + /// + /// + /// + 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(); + } + /// + /// 覆土分析 功能界面中的 清除分析结果 按钮事件处理 + /// + /// + /// + 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(); + } + /// + /// 数字预处理 功能 + /// + /// + /// + private void 数字预处理buttonItem140_Click(object sender, EventArgs e) + { + FrmEditShapeFile frm = new FrmEditShapeFile(globeControl1); + frm.ShowDialog(this); + } + + + /// + /// 导出矢量 功能 将图层导出为kml和shp格式数据 + /// + /// + /// + private void 导出矢量buttonItem140_Click(object sender, EventArgs e) + { + List listVectorNames = new List(); + for (int i = 0; i < m_PipelineLayerNames.Count; i++) + { + 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 = ""; + /// + /// 绘制城市七线 功能按钮 + /// + /// + /// + 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; + } + } + } + /// + /// 七线审核 功能按钮 + /// + /// + /// + private void 七线审核buttonItem141_Click(object sender, EventArgs e) + { + FrmCityServerLineAnalysis frm = new FrmCityServerLineAnalysis(globeControl1, m_PipelineLayerNames); + frm.ShowDialog(this); + } + + /// + /// 间距分析 开始分析按钮 分析绘制的七线和管线的距离是否符合标准 + /// + /// + /// + 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; + } + /// + /// 间距分析 清除分析结果 + /// + /// + /// + 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(); + } + /// + /// 间距分析 导出Excel按钮 将间距分析的结果以Excel表格的形式导出 + /// + /// + /// + private void buttonExportExcel_Click(object sender, EventArgs e) + { + if (dataGridViewAnalysisResult.Rows.Count > 0) + { + ExportExcel("间距分析", dataGridViewAnalysisResult, listBoxStasticsResult); + } + else + { + MessageBox.Show("表格内容为空!", "提示"); + } + } + /// + /// 间距分析 关闭按钮 + /// + /// + /// + 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(); + } + /// + /// 间距分析 分析结果表格双击定位 + /// + /// + /// + 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); + } + } + } + } + /// + /// 间距分析 选择管线复选框 + /// + /// + /// + private void checkBoxSelectPipeline_CheckedChanged(object sender, EventArgs e) + { + clearFeatureHighLight();//清除高亮 + if (checkBoxSelectPipeline.Checked) + { + comboBoxLayer.SelectedItem = null; + 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; + } + } + /// + /// 间距分析 选择图层复选框 + /// + /// + /// + 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(); + } + /// + /// 间距分析 选择图层下拉框 + /// + /// + /// + 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; + } + } + } + + + + /// + /// 管线自动缩进 菜单 + /// + /// + /// + private void 管线自动缩进buttonItem140_Click(object sender, EventArgs e) + { + FrmPipelineIndented frm = new FrmPipelineIndented(globeControl1, m_PipelineLayerNames, workwellLayerNames); + 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 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); + // } + //} + + /// + /// 统计指定图层在指定范围内的所有feature对象 + /// + /// + /// + /// + 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) + { + 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 setLayerVisible(string layerName) + { + GSOLayer templayer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + if (templayer != null) + { + templayer.Visible = false; + } + globeControl1.Globe.Refresh(); + } + + /// + /// 连接数据库 + /// + /// + /// + private void buttonItem129_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL4_1.Text); + + FrmDatabaseParaSetting2 frm = new FrmDatabaseParaSetting2(globeControl1); + if (frm.ShowDialog() == DialogResult.OK) + { + ds = FrmDatabaseParaSetting2.ds; + if (ds != null) + { + ds.IsCloseSaved = false; + } + } + } + + /// + /// 一键审核---导入数据 + /// + /// + /// + private void buttonItem127_Click_2(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, "打开数据"); + + try + { + //if (shds == null) + //{ + //没连的话,直接连接审核库; //审核库配置读配置文件 + string dbIp = Utility.sgdbip; + string database = Utility.sgdbname; + string user = Utility.sgdbuser; + string pass = Utility.sgdbpwd; + /* + 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; + //} + } + catch (Exception ex) + { + LogError.PublishError(ex); + MessageBox.Show("内存过载请清理内存,并重新启动规划分析!", "提示"); + return; + } + + } + + /// + ///自动导出图片 + /// + /// + /// + private void buttonItem130_Click_1(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, "导出审核图"); + + 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))); + */ + + int mapWidth = 0; + int mapHeight = 0; + Point pt = getUpperLeftPoint(pt1, pt2, out mapWidth, out mapHeight); + int rightBottomX = pt.X + mapWidth; + int rightBottomY = pt.Y + mapHeight; + Image myImg = new Bitmap(mapWidth, mapHeight); + Graphics g = Graphics.FromImage(myImg); + g.CopyFromScreen(pt, new Point(0, 0), new Size(rightBottomX, rightBottomY)); + + 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; + } + } + } + /// + /// 一键审核功能 + ///
+ /// + /// + private void buttonItem128_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItem128.Text); + //垂直净距标准 + + frmSh = new FrmYJSHTC(globeControl1, globeControl2,layerTree); + + if (frmSh.ShowDialog() == DialogResult.OK) + { + frmWait = new FrmWait("一键审核……"); + frmWait.Location = new Point(this.Width - frmWait.Width - 10, this.Height - frmWait.Height - 50); + frmWait.Owner = this; + frmWait.Show(); + Thread thread = new Thread(new ThreadStart(doWork)); + thread.IsBackground = true; + thread.Start(); + } + } + + void doWork() + { + FrmShResult frmShResult = null; + + double dVerticalJingJuBiaoZhun = 1, dHorizontalJingJuBiaoZhun = 1; + if (frmSh.rukuLayer != null) + { + #region + this.Invoke((EventHandler)delegate + { + try + { + List managerLayerList = new List(); + for (int i = 0; i < layerManagerNode.Nodes.Count; i++) + { + managerLayerList.Add(layerManagerNode.Nodes[i].Text); + } + if (!managerLayerList.Contains(frmSh.rukuLayer.Caption)) + { + TreeNode node = new TreeNode(); + node.Tag = frmSh.rukuLayer; + node.Text = frmSh.rukuLayer.Dataset.Caption; + node.ImageIndex = 0; + node.SelectedImageIndex = 0; + node.Checked = frmSh.rukuLayer.Visible; + layerManagerNode.Nodes.Insert(0, node); + layerManagerNode.Expand(); + } + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "提示"); + } + }); + #endregion + + shlayername = frmSh.rukuLayer.Name; + globeControl1.Refresh(); + } + + if (frmShResult != null && !frmShResult.IsDisposed) + { + try + { + clearFeatureHighLight(); + ClearRedlineAnalyseResult(); + frmShResult.Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message); + } + } + + 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.analysis(); + + //MainFrm窗体显示控制,回到一键审核Tab + this.Invoke((EventHandler)delegate + { + frmShResult.Show(); + frmWait.Close(); + //将tab页恢复到一键审核 + ribbonTabItem11.Checked = true; + try + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + //zhanshi = false; + splitContainer1.Panel2Collapsed = true; + + panelOfTable.Visible = false; + legendSC.Visible = false; + legendSG.Visible = false; + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + } + catch (Exception ex) + { + MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + + }); + + boolfrmShResult = true; + } + else + { + + } + } + + + /// + /// 清除渲染结果 + /// + 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(); + } + /// + /// 已审核的图层 + /// + /// + /// + private void buttonItem132_Click_1(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItem132.Text); + + if (shds == null) + { + //没连的话,直接连接审核库; //审核库配置读配置文件 + string dbIp = Utility.sgdbip; + string database = Utility.sgdbname; + string user = Utility.sgdbuser; + string pass = Utility.sgdbpwd; + + /* + 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; + //} + + } + /// + /// 审核入库 + /// + /// + /// + private void buttonItem133_Click_1(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, "审核入库"); + FrmShRK frmShrk = new FrmShRK(globeControl1); + frmShrk.Show(); + } + /// + /// 模拟设计修改 + /// + /// + /// + private void buttonItem134_Click_1(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, "模拟设计修改"); + + 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 + { + + } + + } + + + /// + /// 绘制垂线 + /// + /// + /// + 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); + } + /// + /// 比较两个点是否是同一个点 + /// + /// + /// + /// + 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; + } + /// + /// 获得点到线的垂线距离及垂点 + /// + /// + /// + /// + /// + 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); + 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]; + } + /// + /// 获得斜率 + /// + /// + /// + /// + /// + /// + /// + 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); + } + } + /// + /// 根据默认投影参数,经纬度转xyz + /// + /// + /// + /// + 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; + } + /// + /// 根据投影参数,经纬度转xyz + /// + /// + /// + /// + /// + 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; + } + /// + /// 根据默认投影参数,xyz转经纬度 + /// + /// + /// + /// + 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; + } + /// + /// 根据投影参数,Xyz转经纬度 + /// + /// + /// + /// + /// + 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; + } + /// + /// 获得inpolygon的管线长度 + /// + /// + 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; + } + + + /// + /// 一键审核中调节透明度 + /// + /// + /// + private void sliderItem1_ValueChanged(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.sliderItem1.Text); + + globeControl1.Globe.GroundOpaque = 100 - sliderItem1.Value; + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(roadLayerName);//("180fd"); + if (layer != null) + { + layer.Opaque = 100 - sliderItem1.Value; + } + + optiValue = sliderItem1.Value; + } + /// + /// 红线审核中的透明度分析 + /// + /// + /// + private void sliderItem3_ValueChanged(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.sliderItem3.Text); + + globeControl1.Globe.GroundOpaque = 100 - sliderItem3.Value; + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(roadLayerName);//("180fd"); + if (layer != null) + { + layer.Opaque = 100 - sliderItem3.Value; + } + optiValue = sliderItem3.Value; + } + + #region yanxiaowei + //初始化DataGridViewX1控件 + public delegate void DataGridViewDelegate(DataTable dt, string strLable, string strLayer, bool initDataGrid); + /// + /// 代理函数,操作DatgridViewX1 + /// + /// + /// + public void InitDataGridViewX1(DataTable dt, string strLable, string strLayer, bool initDataGrid) + { + if (initDataGrid == true) + { + dataGridViewX1.DataSource = dt; + panelOfTable.Visible = true; + toolStripNumbers.Text = strLable; + dataGridViewX1.Tag = strLayer; + } + else + { + dataGridViewX1.DataSource = null; + dataGridViewX1.Refresh(); + panelOfTable.Visible = false; + toolStripNumbers.Text = ""; + dataGridViewX1.Tag = ""; + globeControl1.Globe.MemoryLayer.RemoveAllFeature();//清除双击产生的标注 + } + } + FrmAnalysisGuiHuaResult from; + /// + /// 主窗体下方属性表格 双击定位 功能 + /// + /// + /// + private void dataGridViewX1_MouseDoubleClick(object sender, MouseEventArgs e) + { + if (redSH == false) + { + 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 if (dataGridViewX1.Columns.Contains("标识器编号")) + { + featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["标识器编号"].Value.ToString(); + } + featureName = featureName.Trim(); + + GSOLayer layer = null; + layer = globeControl1.Globe.Layers.GetLayerByCaption(dataGridViewX1.Tag.ToString()); + + if (layer == null) return; + + GSOFeatures features = layer.GetFeatureByName(featureName, false); + if (features.Length == 0) return; + GSOFeature rowFeature = features[0]; + + ClassSearchAnalysis.AddMakerToLineFeature(globeControl1, rowFeature); + + } + } + } + else + { + if (e.Button == MouseButtons.Left) + { + if (from != null && !from.IsDisposed) + { + try + { + from.Close(); + } + catch (Exception ex) + { + LogError.PublishError(ex); + } + } + try + { + DataGridView.HitTestInfo hittestinfo = dataGridViewX1.HitTest(e.X, e.Y); + if (hittestinfo.RowIndex >= 0) + { + string layer = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["管线类型"].Value.ToString(); + string hxName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["红线编号"].Value.ToString(); + FrmAnalysisGuiHuaResult frm = new FrmAnalysisGuiHuaResult(globeControl1, lineStruct, featsList, + panelOfTable, dataGridViewX1, layer, hxName); + frm.Location = new Point(this.Width - frm.Width - 10, this.Height - frm.Height - 20); + frm.Show(this); + + from = frm; + } + } + catch (Exception ex) + { + LogError.PublishError(ex); + } + } + } + } + + /// + /// 空间查询 + /// + /// + /// + private void buttonItemSearch1_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemSearch1.Text); + + trackflag = "PipelineSpatialQuery"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; + + } + /// + /// 关键字查询 + /// + /// + /// + private void buttonItemSearch9_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch9.Text); + + FrmKeywordQuery.ShowForm(globeControl1, m_PipelineLayerNames, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 编号查询 + /// + /// + /// + private void buttonItemSearch2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch2.Text); + + FrmCodingQuery.ShowForm(globeControl1, m_PipelineLayerNames, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 坐标查询 + /// + /// + /// + private void buttonItemSearch3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch3.Text); + + FrmSetLatLonPos.ShowForm(globeControl1); + } + /// + /// 附属物查询 + /// + /// + /// + private void buttonItemSearch10_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch10.Text); + + FrmFittingQuery.ShowForm(globeControl1, instrumenLayerNames, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 管径查询 + /// + /// + /// + private void buttonItemSearch4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch4.Text); + + FrmDiameterQuery.ShowForm(globeControl1, m_PipelineLayerNames, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 材质查询 + /// + /// + /// + private void buttonItemSearch5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch5.Text); + + FrmMaterialSel.ShowForm(globeControl1, m_PipelineLayerNames, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 基本查询 + /// + /// + /// + private void buttonItemSearch6_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch6.Text); + + FrmBasicQuery.ShowForm(globeControl1, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 复合查询 + /// + /// + /// + private void buttonItemSearch7_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch7.Text); + + FrmQuerySQL.ShowForm(globeControl1, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 关联查询 + /// + /// + /// + private void buttonItemSearch8_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch8.Text); + + if (globeControl1.Globe.SelObjectCount != 1) + { + MessageBox.Show("请选中一个对象!", "提示"); + return; + } + + 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 || (feature.Geometry.Type == EnumGeometryType.GeoPolygon3D + || feature.Geometry.Type == EnumGeometryType.GeoWater)) + return; + else + { + ClassSearchAnalysis.ResultRelationAnalysis(globeControl1, feature, valueLayerNames, workwellLayerNames, + instrumenLayerNames, pipefittingLayerNames, m_PipelineLayerNames, valueAllowance); + } + } + } + #endregion + /// + /// 清除分析 + /// + /// + /// + private void buttonItemClear_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemClear.Text); + + globeControl1.Globe.ClearMeasure(); + layerTemp.RemoveAllFeature(); + layerTemp2.RemoveAllFeature(); + buttonItemLS5.Checked = false; + + dataGridViewX1.DataSource = null; + panelOfTable.Visible = false; + + 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); + + NetworkAnalysisTool.ClearAllTopAnalysis(this.globeControl1); + // 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();//清除所有坑 + + 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(); + } + } + + clearFeatureHighLight();//取消管线高亮 + + GSOLayer layerGround = globeControl1.Globe.Layers.GetLayerByCaption(roadLayerName);//("180fd"); + if (layerGround != null) + { + layerGround.Visible = true; + } + globeControl1.Refresh(); + globeControl2.Refresh(); + ClearRedlineAnalyseResult(); + globeControl1.Globe.Action = EnumAction3D.ActionNull; + } + /// + /// 管线长度全区域统计 + /// + /// + /// + private void buttonItemTJ1_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管线长度统计"); + + FrmAllPipelineStatis frm = new FrmAllPipelineStatis(globeControl1,null, new DataGridViewDelegate(InitDataGridViewX1), m_PipelineLayerNames); + frm.Show(this); + } + /// + /// 管线长度绘制区域统计 + /// + /// + /// + private void buttonItemTJ1_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管线长度统计"); + + trackflag = "PipelineDistanceStatistics"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; + } + /// + /// 阀门数量全区域统计 + /// + /// + /// + private void buttonItemTJ2_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "阀门数量统计"); + + FrmValveStatistics frm = new FrmValveStatistics(globeControl1, null, new DataGridViewDelegate(InitDataGridViewX1)); + frm.Show(this); + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + } + /// + /// 阀门数量绘制区域统计 + /// + /// + /// + private void buttonItemTJ2_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "阀门数量统计"); + + trackflag = "valvequery"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; + } + /// + /// 井盖数量全区域统计 + /// + /// + /// + private void buttonItemTJ3_ALL_Click(object sender, EventArgs e) +<<<<<<< HEAD + { + //日志记录 + LogManager.saveLog(Utility.userName, "井盖数量统计"); +======= + { +>>>>>>> d2d0088a6b3c53c1a96b7f1997f4d3443c0ee8c0 + FrmAllWorkWellStatis frm = new FrmAllWorkWellStatis(globeControl1, null, new DataGridViewDelegate(InitDataGridViewX1)); + frm.Show(this); + } + /// + /// 井盖数量绘制区域统计 + /// + /// + /// + private void buttonItemTJ3_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "井盖数量统计"); + + trackflag = "workwellquery"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; + } + /// + /// 管径分段统计全区域统计 + /// + /// + /// + private void buttonItemTJ4_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管径分段统计"); + + Frmpipediameterstatis.ShowForm(globeControl1, m_PipelineLayerNames, 0); + } + /// + /// 管径分段统计绘制区域统计 + /// + /// + /// + private void buttonItemTJ4_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管径分段统计"); + + trackflag = null; + Frmpipediameterstatis.ShowForm(globeControl1, m_PipelineLayerNames, 1); + } + /// + /// 埋深分段统计全区域统计 + /// + /// + /// + private void buttonItemTJ5_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "埋深分段统计"); + FrmpipeDeepstatis.ShowForm(globeControl1, m_PipelineLayerNames, 0); + } + /// + /// 埋深分段统计绘制区域统计 + /// + /// + /// + private void buttonItemTJ5_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "埋深分段统计"); + trackflag = null; + FrmpipeDeepstatis.ShowForm(globeControl1, m_PipelineLayerNames, 1); + } + /// + /// 管径分类统计全区域统计 + /// + /// + /// + private void buttonItemTJ6_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管径分类汇总"); + + FrmpipeDiametergather.ShowForm(globeControl1, m_PipelineLayerNames, 0); + } + /// + /// 管径分类统计绘制区域统计 + /// + /// + /// + private void buttonItemTJ6_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管径分类汇总"); + + trackflag = null; + FrmpipeDiametergather.ShowForm(globeControl1, m_PipelineLayerNames, 1); + } + /// + /// 材质分类统计全区域统计 + /// + /// + /// + private void buttonItemTJ7_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "材质分类汇总"); + + FrmpipeMaterialGather.ShowForm(globeControl1, m_PipelineLayerNames, 0); + } + /// + /// 材质分类统计绘制区域统计 + /// + /// + /// + private void buttonItemTJ7_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "材质分类汇总"); + + trackflag = null; + FrmpipeMaterialGather.ShowForm(globeControl1, m_PipelineLayerNames, 1); + } + /// + /// 附属物分类统计全区域统计 + /// + /// + /// + private void buttonItemTJ8_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "附属物分类汇总"); + + FrmAccessoriesgather.ShowForm(globeControl1, instrumenLayerNames, 0); + } + /// + /// 附属物分类统计绘制区域统计 + /// + /// + /// + private void buttonItemTJ8_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "附属物分类汇总"); + + trackflag = null; + FrmAccessoriesgather.ShowForm(globeControl1, instrumenLayerNames, 1); + } + /// + /// 碰撞分析 + /// + /// + /// + private void buttonItemFX1_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_4.Text); + + this.dataGridViewX4.Size = new System.Drawing.Size(195, 120); + 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(); + } + /// + /// 覆土分析 + /// + /// + /// + private void buttonItemFX1_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX5_1.Text); + this.dataGridViewX6.Size = new System.Drawing.Size(195, 120); + 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(); + } + /// + /// 间距分析 + /// + /// + /// + private void buttonItemFX1_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX1_3.Text); + + this.dataGridViewLineList.Size = new System.Drawing.Size(185, 120); + 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(); + } + /// + /// 垂直净距分析 + /// + /// + /// + private void buttonItemFX1_4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX1_4.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(); + } + /// + /// 水平净距分析 + /// + /// + /// + private void buttonItemFX1_5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_6.Text); + this.dataGridViewX8.Size = new System.Drawing.Size(185, 120); + 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(); + } + + #region Predaotr,断面分析 + /// + /// 横断面分析 + /// + /// + /// + private void buttonItemFX2_1_Click(object sender, EventArgs e) + { + globeControl1.Globe.Action = EnumAction3D.TrackPolyline; + globeControl1.Globe.TrackPolylineTool.VerticalLineVisible = true; + globeControl1.Globe.TrackPolylineTool.TrackMode = EnumTrackMode.SpaceTrack; + trackPolylineEndMode = EnumTrackPolylineEndMode.HDM_Analysis; + + } + /// + /// 纵断面分析 + /// + /// + /// + private void buttonItemFX2_2_Click(object sender, EventArgs e) + { + if (globeControl1.Globe.SelObjectCount<1) + { + MessageBox.Show("请选择一条或者多条管线!", "提示", MessageBoxButtons.OK, + MessageBoxIcon.Information); + return; + } + 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); + } + } + List feats = SectionAnalysisTool.ZDMAnalysis(selectFeatures); + if (feats != null && feats.Count >= 1) + { + FrmProfileAnalysis frm = new FrmProfileAnalysis(globeControl1, feats); + frm.Show(this); + } + } + /// + /// 道路断面分析 + /// + /// + /// + private void buttonItemFX2_3_Click(object sender, EventArgs e) + { + globeControl1.Globe.Action = EnumAction3D.TrackPolyline; + globeControl1.Globe.TrackPolylineTool.VerticalLineVisible = true; + globeControl1.Globe.TrackPolylineTool.TrackMode = EnumTrackMode.SpaceTrack; + trackPolylineEndMode = EnumTrackPolylineEndMode.DLDM_Analysis; + + } + /// + /// 基线剖面分析 + /// + /// + /// + private void buttonItemFX2_4_Click(object sender, EventArgs e) + { + globeControl1.Globe.Action = EnumAction3D.TrackPolyline; + globeControl1.Globe.TrackPolylineTool.VerticalLineVisible = true; + globeControl1.Globe.TrackPolylineTool.TrackMode = EnumTrackMode.SpaceTrack; + trackPolylineEndMode = EnumTrackPolylineEndMode.JXPM_Analysis; + + } + + #endregion + /// + /// 创建拓扑 + /// + /// + /// + private void buttonItemFX3_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX3_1.Text); + + FrmGenAndFaMenTopu frm = new FrmGenAndFaMenTopu(globeControl1, m_PipelineLayerNames, valueLayerNames); + frm.Show(this); + } + #region Predator :拓扑分析 + /// + /// 上游分析 + /// + /// + /// + private void buttonItemFX3_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX3_2.Text); + NetworkTraceUpDown(true); + } + /// + /// 下游分析 + /// + /// + /// + private void buttonItemFX3_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX3_3.Text); + NetworkTraceUpDown(false); + } + + /// + /// 上下游追踪 功能 + /// + /// + private void NetworkTraceUpDown(Boolean bTraceUp) + { + GSOFeature selLineFeature = globeControl1.Globe.SelectedObject; + if (selLineFeature == null || selLineFeature.Geometry == null || selLineFeature.Geometry.Type != EnumGeometryType.GeoPolyline3D) + { + MessageBox.Show("请点击“编辑”—“选中对象”选择一条线!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); + return; + } + GSOLayer selLayer = globeControl1.Globe.SelectedObjectLayer; + + NetworkAnalysisTool.TraceUpDownAnalysis(bTraceUp, + selLineFeature, selLayer); + } + + /// + /// 流向分析 + /// + /// + /// + private void buttonItemFX3_4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX3_4.Text); + + FrmFlow frm = new FrmFlow(globeControl1, m_PipelineLayerNames); + frm.Show(this); + } + /// + /// 关阀分析 + /// + /// + /// + private void buttonItemFX3_5_Click(object sender, EventArgs e) + { + if (globeControl1.Globe.SelObjectCount < 1) + { + MessageBox.Show("请选中至少一根管线!!"); + buttonItemFX3_5.Checked = false; + return; + } + GSOLayer resLayer = null; + GSOFeature resFeature = null; + globeControl1.Globe.GetSelectObject(0, out resFeature, out resLayer); + + String pipeLayerName = resLayer.Caption; + String pipeLayerNamePrefix = pipeLayerName.Substring(0, pipeLayerName.IndexOf("管线")); + GSOLayer valveLayer = globeControl1.Globe.Layers[pipeLayerNamePrefix + "阀门"]; + if (valveLayer == null) + { + MessageBox.Show("无" + pipeLayerNamePrefix+"阀门图层", "提示"); + return; + } + + GSOFeatures valveFeats = NetworkAnalysisTool.CloseValvesAnalysis(resFeature, + resLayer, valveLayer); + + if (valveFeats != null) + { + FrmCloseValves frm = new FrmCloseValves(this.globeControl1, valveFeats); + frm.Show(this); + } + else + { + MessageBox.Show("未找到关闭阀门"); + } + } + + /// + /// 连通分析 + /// + /// + /// + private void buttonItemFX3_6_Click(object sender, EventArgs e) + { + if (globeControl1.Globe.SelObjectCount < 2) + { + MessageBox.Show("请选中至少两个管线!!"); + buttonItemFX3_6.Checked = false; + return; + } + GSOFeature selFeat0, selFeat1; + GSOLayer layer0,layer1; + globeControl1.Globe.GetSelectObject(0, out selFeat0, out layer0); + globeControl1.Globe.GetSelectObject(1, out selFeat1, out layer1); + + if (!layer0.IsSameInnerObject(layer1)) + { + MessageBox.Show("不在同一个图层!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); + buttonItemFX3_6.Checked = false; + return; + } + NetworkAnalysisTool.ConnexityAnalysis(selFeat0, selFeat1, layer0); + } + /// + /// 爆管分析 + /// + /// + /// + private void buttonItemFX3_7_Click(object sender, EventArgs e) + { + NetworkTraceUpDown(true); //上游追踪: + + GSOFeature selLineFeature = globeControl1.Globe.SelectedObject; + if (selLineFeature == null || selLineFeature.Geometry == null || selLineFeature.Geometry.Type != EnumGeometryType.GeoPolyline3D) + { + MessageBox.Show("请点击“编辑”—“选中对象”选择一条线!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); + return; + } + GSOLayer selLayer = globeControl1.Globe.SelectedObjectLayer; + + NetworkAnalysisTool.ExplodeAnalysis(this.globeControl1,selLineFeature,selLayer); + + this.buttonItemFX3_5_Click(sender, e); //关阀分析: + + } + + #endregion + /// + /// 多边形开挖 + /// + /// + /// + private void buttonItemFX4_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_1.Text); + + trackflag = "pit"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; //是这个么?是的,在模型上 + } + /// + /// 挖方量分析 + /// + /// + /// + private void buttonItemFX4_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_2.Text); + + trackflag = "digFillAnalysis"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; + ActionToolMenuChecked(); + } + /// + /// 沿线开挖 + /// + /// + /// + private void buttonItemFX4_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_3.Text); + + if (!buttonItemFX4_3.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; + buttonItemFX4_3.Checked = true; + } + } + else + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + buttonItemFX4_3.Checked = false; + globeControl1.Globe.TrackPolylineTool.VerticalLineVisible = false; + } + ActionToolMenuChecked(); + } + /// + /// 创建隧道 + /// + /// + /// + private void buttonItemFX4_4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_4.Text); + + 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("场景中未加载隧道图层!", "提示"); + } + } + /// + /// 隐藏隧道 + /// + /// + /// + private void buttonItemFX4_5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_5.Text); + + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption("隧道"); + if (layer != null) + { + layer.Visible = !layer.Visible; + } + } + /// + /// 删除隧道 + /// + /// + /// + private void buttonItemFX4_6_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_6.Text); + + 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("请选中要删除的隧道!", "提示"); + } + } + /// + /// 通视分析 + /// + /// + /// + private void buttonItemFX5_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX5_1.Text); + + if (globeControl1.Globe.Action != EnumAction3D.VisibilityAnalysis) + { + //btnSpaceVisibilityAnalysis.Checked = true; + globeControl1.Globe.Action = EnumAction3D.VisibilityAnalysis; + } + else + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + // SetButtonChecked(); + } + } + /// + /// 可视域分析 + /// + /// + /// + private void buttonItemFX5_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX5_2.Text); + + globeControl1.Globe.Action = EnumAction3D.ViewshedAnalysis; + } + /// + /// 可视包络分析 + /// + /// + /// + private void buttonItemFX5_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX5_3.Text); + + globeControl1.Globe.Action = EnumAction3D.ViewEnvelopeAnalysis; + } + /// + /// 缓冲区分析 + /// + /// + /// + private void buttonItemFX6_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX6_1.Text); + + GSOFeature feat = globeControl1.Globe.SelectedObject; + if (feat == null) + { + MessageBox.Show("请选择要分析的要素!"); + return; + } + if (feat.Geometry.Type == EnumGeometryType.GeoPolyline3D) + { + GSOGeoPolyline3D line1 = feat.Geometry as GSOGeoPolyline3D; + if (line1 == null) + { + MessageBox.Show("请选择一条管线!"); + return; + } + + FrmBufferAnalysis frm = new FrmBufferAnalysis(globeControl1, line1, layerTemp); + frm.Show(this); + } + else + { + FrmBufferAnalysisBSQ frm = new FrmBufferAnalysisBSQ(globeControl1, layerTemp, bsqPT); + frm.Show(this); + } + + } + /// + /// 附属物分析 + /// + /// + /// + private void buttonItemFX6_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX6_2.Text); + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + FrmAccessoryAnalysis dlg = new FrmAccessoryAnalysis(globeControl1, layerTemp); + dlg.Show(this); + } + /// + /// 无源淹没分析 + /// + /// + /// + private void buttonItemFX6_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX6_3.Text); + + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + trackflag = "FloodAnalysis"; + } + /// + /// 水平距离 + /// + /// + /// + private void buttonItemLS1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS1.Text); + + globeControl1.Globe.Action = EnumAction3D.MeasureDistance; + globeControl1.Globe.DistanceRuler.SpaceMeasure = false; + buttonItemLS5.Checked = false; + } + /// + /// 垂直距离 + /// + /// + /// + private void buttonItemLS2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS2.Text); + + buttonItemLS5.Checked = false; + globeControl1.Globe.Action = EnumAction3D.MeasureHeight; + globeControl1.Globe.DistanceRuler.SpaceMeasure = false; + } + /// + /// 空间距离 + /// + /// + /// + private void buttonItemLS3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS3.Text); + + buttonItemLS5.Checked = false; + globeControl1.Globe.Action = EnumAction3D.MeasureDistance; + globeControl1.Globe.DistanceRuler.SpaceMeasure = true; + } + /// + /// 地表距离 + /// + /// + /// + private void buttonItemLS4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS4.Text); + + buttonItemLS5.Checked = false; + globeControl1.Globe.Action = EnumAction3D.MeasureDistance; + globeControl1.Globe.DistanceRuler.SpaceMeasure = false; + } + /// + /// 高度量算 + /// + /// + /// + private void buttonItemLS5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS5.Text); + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + buttonItemLS5.Checked = !buttonItemLS5.Checked; + if (buttonItemLS5.Checked) + { + globeControl1.Globe.Action = EnumAction3D.SelectObject; + } + } + /// + /// 水平面积 + /// + /// + /// + private void buttonItemLS6_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS6.Text); + + buttonItemLS5.Checked = false; + globeControl1.Globe.Action = EnumAction3D.MeasureArea; + globeControl1.Globe.AreaRuler.SpaceMeasure = true; + } + /// + /// 地表面积 + /// + /// + /// + private void buttonItemLS7_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS7.Text); + + buttonItemLS5.Checked = false; + globeControl1.Globe.Action = EnumAction3D.MeasureArea; + globeControl1.Globe.AreaRuler.SpaceMeasure = false; + + } + + # region Fan 重构标注代码 + /// + /// 标高标注 + /// + /// + /// + private void buttonItemSZ1_Click(object sender, EventArgs e) + { + GSOFeature resFeature = IsPipeLineOfSelectedObj(); + if (resFeature == null) + { + MessageBox.Show("请选中一根管线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + GSOGeoPolyline3D selLine = resFeature.Geometry as GSOGeoPolyline3D; + if (selLine[0].Count <= 1) + { + return; + } + + MarkTools.getInstance().showMarker(resFeature, + globeControl1, EnumMarkLayer.Mark_Altitude, ""); + } + /// + /// 管径标注 + /// + GSOFeature radiusMarkerFeature; + private void buttonItemBZ2_Click(object sender, EventArgs e) + { + GSOFeature resFeature = IsPipeLineOfSelectedObj(); + if (resFeature == null) + { + MessageBox.Show("请选中一根管线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + GSOGeoPolyline3D selLine = resFeature.Geometry as GSOGeoPolyline3D; + if (selLine[0].Count <= 1) + { + return; + } + + MarkTools.getInstance().showMarker(resFeature, + globeControl1, EnumMarkLayer.Mark_Diameter, ""); + } + /// + /// 埋深标注 + /// + /// + /// + private void buttonItemBZ3_Click(object sender, EventArgs e) + { + GSOFeature resFeature = IsPipeLineOfSelectedObj(); + if (resFeature == null) + { + MessageBox.Show("请选中一根管线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + GSOGeoPolyline3D selLine = resFeature.Geometry as GSOGeoPolyline3D; + if (selLine[0].Count <=1) + { + return; + } + + MarkTools.getInstance().showMarker(resFeature, + globeControl1, EnumMarkLayer.Mark_Depth, ""); + + } + /// + /// 坐标标注 + /// + /// + /// + private void buttonItemBZ4_Click(object sender, EventArgs e) + { + GSOFeature resFeature = IsPipeLineOfSelectedObj(); + if (resFeature == null) + { + MessageBox.Show("请选中一根管线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + GSOGeoPolyline3D selLine = resFeature.Geometry as GSOGeoPolyline3D; + if (selLine[0].Count <= 1) + { + return; + } + MarkTools.getInstance().showMarker(resFeature, + globeControl1, EnumMarkLayer.Mark_Location, ""); + } + /// + /// 距离标注 + /// + bool distanceMarker = false; + private void buttonItemBZ5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBZ5.Text); + + globeControl1.Globe.Action = EnumAction3D.TrackPolyline; + //globeControl1.Globe.DistanceRuler.MeasureMode = EnumDistanceMeasureMode.HVSLineMeasure; + distanceMarker = true; + } + /// + /// 自定义标注 + /// + /// + /// + private void buttonItemBZ6_Click(object sender, EventArgs e) + { + GSOFeature f = globeControl1.Globe.SelectedObject; + GSOLayer l = globeControl1.Globe.SelectedObjectLayer; + FrmCustomLabel frm = new FrmCustomLabel(globeControl1, l, f); + if (frm.ShowDialog() == DialogResult.OK) + { + MarkTools.getInstance().showMarker(f, globeControl1, EnumMarkLayer.Mark_Custom, frm.labelText); + } + } + /// + /// 扯旗标注 + /// + /// + /// + private void buttonItemBZ7_Click(object sender, EventArgs e) + { + GSOFeature f = globeControl1.Globe.SelectedObject; + GSOLayer l = globeControl1.Globe.SelectedObjectLayer; + FrmMarker frm = new FrmMarker(); + if (frm.ShowDialog() == DialogResult.OK) + { + MarkTools.getInstance().showMarker(f, globeControl1, EnumMarkLayer.Mark_Custom, frm.markerContent); + } + } + /// + /// 坡度标注 + /// + /// + /// + private void buttonItemBZ8_Click(object sender, EventArgs e) + { + GSOFeature resFeature = IsPipeLineOfSelectedObj(); + if (resFeature == null) + { + MessageBox.Show("请选中一根管线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + GSOGeoPolyline3D selLine = resFeature.Geometry as GSOGeoPolyline3D; + if (selLine[0].Count <= 1) + { + return; + } + + MarkTools.getInstance().showMarker(resFeature, + globeControl1, EnumMarkLayer.Mark_Slope, ""); + } + /// + /// 属性标注 + /// + /// + /// + private void buttonItemBZ9_Click(object sender, EventArgs e) + { + GSOFeature f = globeControl1.Globe.SelectedObject; + GSOLayer l = globeControl1.Globe.SelectedObjectLayer; + FrmPropertiesMarker frm = new FrmPropertiesMarker(globeControl1, l, f); + if (frm.ShowDialog() == DialogResult.OK) + { + MarkTools.getInstance().showMarker(f, globeControl1, EnumMarkLayer.Mark_Property, frm.labelText); + } + } + /// + /// 红线工具 + /// + /// + /// + private void buttonItemBZ10_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBZ10.Text); + 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; + } + } + /// + /// 标注管理 + /// + /// + /// + private void buttonItemBZ11_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBZ11.Text); + + buttonItemBZ11.Checked = !buttonItemBZ11.Checked; + 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 (buttonItemBZ11.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(); + } + } + + #endregion + /// + /// 飞行到目标点 + /// + /// + /// + private void buttonItemFXGJ1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFXGJ1.Text); + + FrmSetFlytoPos.ShowForm(globeControl1); + + } + /// + /// 自定义飞行 + /// + /// + /// + private void buttonItemFXGJ2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFXGJ2.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); + } + } + /// + /// 绕中心点飞行 + /// + /// + /// + private void buttonItemFXGJ3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFXGJ3.Text); + + globeControl1.Globe.FlyAroundCenter(10000, EnumFlyRepeatValueType.MiliSeconds); + globeControl1.Globe.CurFlyID = 1; + } + /// + /// 绕眼睛飞行 + /// + /// + /// + private void buttonItemFXGJ4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFXGJ4.Text); + + globeControl1.Globe.FlyAroundEye(720, EnumFlyRepeatValueType.Degrees); + globeControl1.Globe.CurFlyID = 2; + } + + /// + /// 权限管理 + /// + /// + /// + private void buttonItemXT1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT1.Text); + + FrmUserRoleMgr frm = new FrmUserRoleMgr(); + frm.ShowDialog(); + } + /// + /// 数据库管理 + /// + /// + /// + private void buttonItemXT2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT2.Text); + + //查看数据库列表 + FrmDbManager frm = new FrmDbManager(); + frm.ShowDialog(); + } + /// + /// 用户列表 + /// + /// + /// + private void buttonItemXT3_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT3_1.Text); + + FrmUserManager frm = new FrmUserManager(); + frm.ShowDialog(); + } + /// + /// 创建新用户 + /// + /// + /// + private void buttonItemXT3_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT3_2.Text); + + FrmUserAdd frm = new FrmUserAdd(-1); + frm.ShowDialog(); + } + /// + /// 人员修改 + /// + /// + /// + private void buttonItemXT4_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT4_2.Text); + + FrmAppUSER appUSER = new FrmAppUSER(); + appUSER.ShowDialog(); + } + /// + /// 增加人员 + /// + /// + /// + private void buttonItemXT4_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT4_1.Text); + + FrmAppUSERRESET appUSERRESET = new FrmAppUSERRESET(); + appUSERRESET.ShowDialog(); + } + /// + /// 统计数据 + /// + /// + /// + private void buttonItemZTT1_Click(object sender, EventArgs e) + { + ////日志记录 + //LogManager.saveLog(Utility.userName, this.buttonItemZTT1.Text); + + //PATM patm = new PATM(); + //patm.operation = "Statistic"; + //patm.Text = "统计专题图管理"; + //patm.ShowDialog(); + } + /// + /// 热点功能统计 + /// + /// + /// + private void buttonItemZTT2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT2.Text); + + FrmHotFuncStat frmhfs = new FrmHotFuncStat(); + frmhfs.ShowDialog(); + } + + private void buttonItemZTT3_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT3_1.Text); + + FrmAPP appfrm = new FrmAPP("专题图申请"); + appfrm.ShowDialog(); + } + + private void buttonItemZTT3_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT3_2.Text); + + FrmAPPFORASK appForask = new FrmAPPFORASK("专题图审核"); + appForask.ShowDialog(); + } + + private void buttonItemZTT3_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT3_3.Text); + + FrmAPPregion appregion = new FrmAPPregion("专题图审核"); + appregion.ShowDialog(); + } + + private void buttonItemZTT4_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT4_1.Text); + + FrmAPP appfrm = new FrmAPP("打印申请"); + appfrm.ShowDialog(); + } + + private void buttonItemZTT4_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT4_2.Text); + + FrmAPPFORASK appForask = new FrmAPPFORASK("打印审核"); + appForask.ShowDialog(); + } + + private void buttonItemZTT4_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT4_3.Text); + + FrmAPPregion appregion = new FrmAPPregion("打印审核"); + appregion.ShowDialog(); + } + + private void buttonItemZTT5_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT5_1.Text); + + FrmAPP appfrm = new FrmAPP("拷贝申请"); + appfrm.ShowDialog(); + } + + private void buttonItemZTT5_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT5_2.Text); + + FrmAPPFORASK appForask = new FrmAPPFORASK("拷贝审核"); + appForask.ShowDialog(); + } + + private void buttonItemZTT5_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT5_3.Text); + + FrmAPPregion appregion = new FrmAPPregion("拷贝审核"); + appregion.Show(); + } + + private int connectServerCount = 0; + + /// + /// 还原球到实测库 + /// + 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); + } + + if (layerManagerNode.Nodes.Count > 0) + { + for (int i = layerManagerNode.Nodes.Count - 1; i >= 0; i--) + { + layerManagerNode.Nodes[i].Remove(); + + } + } + + globeControl1.Refresh(); + + } + + private void buttonItemSPSZ_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSPSZ.Text); + + FrmLayerControl frm = new FrmLayerControl(layerTree, globeControl1, globeControl2); + frm.Show(this); + } + + /// + /// 碰撞审查 + /// + /// + /// + private void buttonItemSH1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSH1.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 buttonItemSH2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSH2.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 buttonItemSH3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSH3.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 buttonItemSH4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSH4.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 buttonItemSH5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSH5.Text); + FrmCityServerLineAnalysis frm = new FrmCityServerLineAnalysis(globeControl1, m_PipelineLayerNames); + frm.Show(this); + } + #region 数据管理-导入文件 + ///// + ///// 数据管理-导入本地坐标系文件 + ///// + ///// + ///// + //private void buttonItemSJGL1_1_Click(object sender, EventArgs e) + //{ + // //日志记录 + // LogManager.saveLog(Utility.userName, this.buttonItemSJGL1_1.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(); + // } + // } + //} + + ///// + ///// 数据管理-导入其他坐标系文件 + ///// + ///// + ///// + //private void buttonItemSJGL1_2_Click(object sender, EventArgs e) + //{ + // //日志记录 + // LogManager.saveLog(Utility.userName, this.buttonItemSJGL1_2.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(); + // } + // } + //} + #endregion + /// + /// 数据质量检查 + /// + /// + /// + private void buttonItemSJGL2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL2.Text); + FrmValiData frm = new FrmValiData(globeControl1); + frm.ShowDialog(); + } + /// + /// 数据预处理 + /// + /// + /// + private void buttonItemSJGL3_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL3.Text); + + FrmEditShapeFile frm = new FrmEditShapeFile(globeControl1); + frm.ShowDialog(this); + } + /// + /// 连接数据库 + /// + /// + /// + private void buttonItemSJGL4_1_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL4_1.Text); + + FrmDatabaseParaSetting frm = new FrmDatabaseParaSetting(globeControl1); + if (frm.ShowDialog() == DialogResult.OK) + { + ds = FrmDatabaseParaSetting.ds; + if (ds != null) + { + ds.IsCloseSaved = false; + } + } + } + /// + /// 管线入库 + /// + /// + /// + private void buttonItemSJGL4_2_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL4_2.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 buttonItemSJGL4_3_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL4_3.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 buttonItemSJGL5_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL5.Text); + + Cyberpipe.Forms.FrmProject frm = new Cyberpipe.Forms.FrmProject(); + frm.ShowDialog(); + } + /// + /// 元数据基本管理 + /// + /// + /// + private void buttonItemSJGL6_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL6_1.Text); + + FrmMetadata frmmd = new FrmMetadata(); + frmmd.ShowDialog(); + } + /// + /// 元数据查询管理 + /// + /// + /// + private void buttonItemSJGL6_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL6_2.Text); + + FrmMetadataStat frmmds = new FrmMetadataStat(); + //frmmds.Show(); + frmmds.ShowDialog(); + } + /// + /// 操作日志管理 + /// + /// + /// + private void buttonItemSJGL7_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL7.Text); + + FrmLogOper frmlo = new FrmLogOper(); + frmlo.ShowDialog(); + } + /// + /// 数据字典管理 + /// + /// + /// + private void buttonItemSJGL8_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL8.Text); + + FrmMDDictory frmmdd = new FrmMDDictory(); + frmmdd.ShowDialog(); + } + /// + /// 数据库备份 + /// + /// + /// + private void buttonItemSJGL9_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL9.Text); + + //新 + FrmBACKORACLE backOracle = new FrmBACKORACLE(); + backOracle.Show(); + } + /// + /// 创建管段 + /// + /// + /// + private void buttonItemBJ1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ1.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; + } + } + /// + /// 创建附属物 + /// + /// + /// + private void buttonItemBJ2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ2.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); + } + } + /// + /// 创建特征管点 + /// + /// + /// + private void buttonItemBJ3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ3.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); + } + } + /// + /// 绘制城市七线 + /// + /// + /// + private void buttonItemBJ4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ4.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; + } + } + } + /// + /// 选中对象 + /// + /// + /// + private void buttonItemBJ5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ5.Text); + + globeControl1.Globe.Action = EnumAction3D.SelectObject; + } + /// + /// 平移对象 + /// + /// + /// + private void buttonItemBJ6_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ6.Text); + + globeControl1.Globe.Action = EnumAction3D.MoveObject; + } + /// + /// 升降对象 + /// + /// + /// + private void buttonItemBJ7_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ7.Text); + + globeControl1.Globe.Action = EnumAction3D.ElevateObject; + } + /// + /// 旋转对象 + /// + /// + /// + private void buttonItemBJ8_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ8.Text); + + globeControl1.Globe.Action = EnumAction3D.RotateObject; + } + /// + /// 连接管段 + /// + /// + /// + private void buttonItemBJ9_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ9.Text); + + if (globeControl1.Globe.SelObjectCount < 2) + { + MessageBox.Show("对不起,请至少选中2个对象!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + return; + } + globeControl1.Globe.InsertJointPipeline(false); + } + /// + /// 后退 + /// + /// + /// + private void buttonItemBJ11_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemBJ11.Text); + globeControl1.Globe.UnDoEdit(); + } + /// + /// 前进 + /// + /// + /// + private void buttonItemBJ12_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemBJ12.Text); + + globeControl1.Globe.ReDoEdit(); + } + /// + /// 导出CAD + /// + /// + /// + private void buttonItemBJ10_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ10_1.Text); + + #region 导出成dxf格式 + List listVectorNames = new List(); + 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(); + #endregion + } + /// + /// 导出矢量 + /// + /// + /// + private void buttonItemBJ10_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ10_2.Text); + + List listVectorNames = new List(); + 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 buttonItemBJ13_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemBJ13.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(); + } + } + MessageBox.Show("删除成功!", "提示"); + } + else + { + MessageBox.Show("请选中要删除的模型!", "提示"); + } + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + } + + private void buttonItemHX1_1_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]; + string filePath = dlg.FileName; + string lastname = Path.GetFileName(filePath); + + 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(); + } + + } + } + } + + public struct LineStruct + { + public string layerName; + public string layerCode; + public string lineLength; + public string hxName; + } + + List lineStruct = new List(); + List featsList = new List(); + + /// + /// 红线审核 + /// + /// + /// + private void buttonItemHX2_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemHX2.Text); + redSH = true; + featsList.Clear(); + lineStruct.Clear(); + List listPipelineLayers = new List(); + + GSOLayer layer = null; + for (int i = 0; i < m_PipelineLayerNames.Count; i++) + { + layer = globeControl1.Globe.Layers.GetLayerByCaption(m_PipelineLayerNames[i]); + if (layer != null) + { + listPipelineLayers.Add(layer); + } + } + //yanxiaowei 重构 + GSOFeatures selectFeatures=new GSOFeatures(); + for (int i = 0; i < globeControl1.Globe.SelObjectCount; i++) + { + GSOFeature feature = null; + globeControl1.Globe.GetSelectObject(i, out feature, out layer); + selectFeatures.Add(feature); + } + DataTable table=new DataTable(); + + ClassGSOTool.CalculateRedLineResult(out table, redSH, selectFeatures, globeControl1, + listPipelineLayers,out lineStruct, out featsList); + + if (table.Rows.Count != 0) + AddDatagridView(table); + else + { + MessageBox.Show("没有侵入地块红线的管线数据!", "提示"); + dataGridViewX1.DataSource = null; + panelOfTable.Visible = false; + return; + } + } + + private void AddDatagridView(DataTable table) + { + dataGridViewX1.DataSource = table; + panelOfTable.Visible = true; + panelOfTable.Height = 200; + toolStripNumbers.Text = "红线审核 |共有:" + table.Rows.Count + "条"; + toolStripDropDownButton3.Visible = true; + } + /// + /// 主窗体 下方的工具条中的 导出.xls文件 按钮事件处理 + /// + /// + /// + private void toolStripDropDownButton3_Click(object sender, EventArgs e) + { + if (dataGridViewX1.Rows.Count == 0) + { + MessageBox.Show("表格内容为空!", "提示"); + return; + } + + string strSaveFile = string.Empty; + SaveFileDialog savefiledialog = new SaveFileDialog(); + savefiledialog.Filter = "Excel文件|*.xls,*.xlsx"; + savefiledialog.AddExtension = true; + savefiledialog.FileName = "红线审核"; + if (savefiledialog.ShowDialog() == DialogResult.OK) + strSaveFile = savefiledialog.FileName; + else return; + + ExpEXCEL.ExpToExcel(dataGridViewX1, strSaveFile, "红线审核", lineStruct, featsList); + MessageBox.Show("导出成功!"); + } + /// + /// 去除集合中重复的管线 + /// + /// + /// + /// + private GSOFeatures getFeaturesByFilter(GSOFeatures features, string fieldName) + { + if (features == null) + { + return null; + } + GSOFeatures featuresGet = new GSOFeatures(); + for (int i = 0; i < features.Length; i++) + { + GSOFeature featureFromFS = features[i]; + string fieldValueFromFS = featureFromFS.GetValue(fieldName).ToString().Trim(); + bool isHas = false; + for (int j = featuresGet.Length - 1; j >= 0; j--) + { + GSOFeature featureFromFSGet = featuresGet[j]; + string fieldValueFromFSGet = featureFromFSGet.GetValue(fieldName).ToString().Trim(); + if (fieldValueFromFS.Equals(fieldValueFromFSGet)) + { + isHas = true; + break; + } + } + if (isHas == false) + { + featuresGet.Add(featureFromFS.Clone()); + } + } + return featuresGet; + } + + private void sliderItem2_ValueChanged(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.sliderItem2.Text); + + globeControl1.Globe.GroundOpaque = 100 - sliderItem2.Value; + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(roadLayerName);//("180fd"); + if (layer != null) + { + layer.Opaque = 100 - sliderItem2.Value; + } + layer = globeControl2.Globe.Layers.GetLayerByCaption("180fd");//("180fd"); + if (layer != null) + { + layer.Opaque = 100 - sliderItem2.Value; + } + globeControl2.Globe.GroundOpaque = 100 - sliderItem2.Value; + + optiValue = sliderItem2.Value; + } + /// + /// 数据管理导入文件 + /// + /// + /// + private void buttonItemSJGL1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL1.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.Multiselect = true; + if (dlg.ShowDialog() == DialogResult.OK) + { + //自定义lprj文件名,从程序中复制一lprj文件。 + string filePath = dlg.FileName; + string lastname = Path.GetFileName(filePath); + + 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, 100); + + globeControl1.Refresh(); + } + } + } + + private void buttonItemHX1_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemHX1.Text); + + GSODataSource dataSpace = globeControl1.Globe.DataManager.OpenOracleDataSource(Utility.DBServer.Trim() + "/" + Utility.dbdatabase.Trim(), "", "", Utility.userID, Utility.DBPassword); + string filepath = ""; + //日志记录 + OpenFileDialog dlg = new OpenFileDialog(); + dlg.Filter = "矢量数据(*.shp)|*.shp|矢量数据(*.lgd)|*.lgd|CAD数据(*.dxf)|*.dxf|全部支持格式(*.lgd,*.shp,*.dxf)|*.lgd;*.shp;*.dxf;"; + dlg.Multiselect = true; + + #region 临时图层显示 + if (dlg.ShowDialog() == DialogResult.OK) + { + string filePath = dlg.FileName; + string lastname = Path.GetFileName(filePath); + + #region + for (int i = 0; i < dlg.FileNames.Length; i++) + { + string strDataPath = dlg.FileNames[i]; + filepath = strDataPath; + + GSOLayer layer = globeControl1.Globe.Layers.Add(strDataPath); + GSOFeatures RedFeatures = layer.GetAllFeatures(); + + 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(); + RedFeatures = features; + 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; + } + + /////////////////////////////////////////////////////////////////////////////////////////// + globeControl1.Globe.Layers.MoveTo(0, globeControl1.Globe.Layers.Count - 1); + globeControl1.Refresh(); + } + + IModelBuilder modelBuilder = new RedLineBuilder(); + + modelBuilder.batchInsert(dataSpace, redDt, RedFeatures); + + } + #endregion + + } + #endregion + } + /// + /// 定位 + /// + /// + /// + private void buttonItemLocation_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemLocation.Text); + + FrmFlyToPosition fly = new FrmFlyToPosition(globeControl1,globeControl2); + fly.Show(this); + } + /// + /// 2015-10-17演示代码 红线审核 + /// + /// + /// + private void ribbonTabItem6_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.FlyToPosition(new GSOPoint3d(120.610963, 31.188121, 50), EnumAltitudeMode.Absolute, -4, 50, 800); + globeControl1.Globe.FlyToPointSpeed = 10000000; + globeControl1.Globe.Action = EnumAction3D.SelectObject; + globeControl1.Refresh(); + + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + + //zhanshi = false; + redSH = true; + splitContainer1.Panel2Collapsed = true; + legendSG.Visible = false; + legendSC.Visible = false; + ClearGZData(); + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = true; + } + + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 基础工具 + /// + /// + /// + private void ribbonTabItem1_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + //zhanshi = false; + redSH = false; + splitContainer1.Panel2Collapsed = true; + panelOfTable.Visible = false; + legendSC.Visible = false; + legendSG.Visible = false; + ClearGZData(); + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + + + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 一键审核 + /// + /// + /// + private void ribbonTabItem11_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + //zhanshi = false; + redSH = false; + splitContainer1.Panel2Collapsed = true; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + panelOfTable.Visible = false; + legendSC.Visible = false; + legendSG.Visible = false; + ClearGZData(); + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + + + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 右屏添加冰箱数据 + /// + void AddDataToGlobeControl2() + { + + bool modelDataBool = false; + for (int i = globeControl2.Globe.Layers.Count - 1; i >= 0; i--) + { + GSOLayer layer = globeControl2.Globe.Layers[i]; + if (layer.Name.Contains("fttp:")) + { + modelDataBool = true; + break; + } + } + + if (modelDataBool == false) + { + GSOLayer ly = globeControl1.Globe.Layers.GetLayerByCaption("天地图地图"); + globeControl2.Globe.Layers.Add(ly); + } + else + { + return; + } + } + /// + /// 双屏对比 + /// + /// + /// + private void ribbonTabItem9_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent += new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent += new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + panelOfTable.Visible = false; + + splitContainer1.Panel2Collapsed = false; + //zhanshi = true; + redSH = false; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + sliderItem2.Value = 100 - globeControl1.Globe.GroundOpaque; + globeControl2.Globe.GroundOpaque = globeControl1.Globe.GroundOpaque; + legendSC.Visible = true; + legendSG.Visible = true; + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + AddDataToGlobeControl2(); + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 文档管理 + /// + /// + /// + private void ribbonTabItem4_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + panelOfTable.Visible = false; + //zhanshi = false; + redSH = false; + splitContainer1.Panel2Collapsed = true; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + legendSC.Visible = false; + legendSG.Visible = false; + ClearGZData(); + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 基础管理 + /// + /// + /// + private void ribbonTabItem14_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + panelOfTable.Visible = false; + //zhanshi = false; + redSH = false; + splitContainer1.Panel2Collapsed = true; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + legendSC.Visible = false; + legendSG.Visible = false; + ClearGZData(); + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 权限管理 + /// + /// + /// + private void ribbonTabItem2_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + panelOfTable.Visible = false; + //zhanshi = false; + redSH = false; + splitContainer1.Panel2Collapsed = true; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + legendSC.Visible = false; + legendSG.Visible = false; + ClearGZData(); + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + GSOFeature dpFeatuer = null; + /// + /// 双屏分析,点击管段分析 + /// + /// + /// + private void buttonItem8_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItem8.Text); + + //FrmCompareFeature frmCompareFeature = new FrmCompareFeature(globeControl1, globeControl2, layerTemp, layerTemp2,m_PipelineLayerNames,sgPipeLayersNames); + int width = this.Width; + FrmCompareFeature.ShowForm(globeControl1, globeControl2, layerTemp, layerTemp2, m_PipelineLayerNames, sgPipeLayersNames,width); + //frmCompareFeature.Location = new Point((this.Width - frmCompareFeature.Width)/2,50); + //frmCompareFeature.Show(this); + + } + /// + /// 红线审核导出图片 + /// + /// + /// + private void buttonItemDCTP_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemDCTP.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))); + */ + int mapWidth = 0; + int mapHeight = 0; + Point pt = getUpperLeftPoint(pt1, pt2, out mapWidth, out mapHeight); + int rightBottomX = pt.X + mapWidth; + int rightBottomY = pt.Y + mapHeight; + Image myImg = new Bitmap(mapWidth, mapHeight); + Graphics g = Graphics.FromImage(myImg); + g.CopyFromScreen(pt, new Point(0, 0), new Size(rightBottomX, rightBottomY)); + + 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; + } + } + } + /// + /// 标识器全区域统计 + /// + /// + /// + private void 标识器分类统计ToolStripMenuItem_Click(object sender, EventArgs e) + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + FrmBSQStatis bsqStatis = new FrmBSQStatis(globeControl1,null); + //FrmBSQStatis bsqStatis = new FrmBSQStatis(); + bsqStatis.Show(this); + } + /// + /// 标识器绘制区域统计 + /// + /// + /// + private void 标识器分类统计ToolStripMenuItem1_Click(object sender, EventArgs e) + { + trackflag = "BSQDuoBianXiangStatis"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + } + + #region 保存和加载审核库加载的图层 + /* + private void saveLayerList(TreeNodeCollection treeNodeList) + { + string configPath = Application.StartupPath + "\\configLayerList.xml"; + try + { + XmlDocument doc = new XmlDocument(); + doc.Load(configPath); + XmlNode dbParams = doc.SelectSingleNode("Params/dbparams"); + XmlNode dbLayers = doc.SelectSingleNode("Params/dblayers"); + XmlNode layers = doc.SelectSingleNode("Params/layers"); + dbParams.RemoveAll(); + dbLayers.RemoveAll(); + layers.RemoveAll(); + + List listDS = new List(); + String shDatasourceName = Utility.sgdbip + "/" + Utility.sgdbname + "_" + Utility.sgdbuser; + bool flag = false; + + for (int i = 0; i < globeControl1.Globe.DataManager.DataSourceCount; i++) + { + GSODataSource ds = globeControl1.Globe.DataManager.GetDataSourceAt(i); + if (ds != null && ds.Type == EnumDataSourceType.SqlServer || ds.Type == EnumDataSourceType.Oracle) + { + if (ds.Name == shDatasourceName) + { + //防止因为多次连接同一个数据库 + if (flag == true) + { + break; + } + flag = true; + listDS.Add(ds); + GSODataSourceCnn conn = ds.GetConnectionInfo(); + + XmlElement dbparam = doc.CreateElement("shdbparam"); + XmlElement ip = doc.CreateElement("ship"); + ip.InnerText = conn.Server; + + XmlElement dbname = doc.CreateElement("shdbname"); + dbname.InnerText = conn.Database; + + XmlElement username = doc.CreateElement("shusername"); + username.InnerText = conn.User; + + XmlElement password = doc.CreateElement("shpassword"); + password.InnerText = conn.Password; + + XmlElement type = doc.CreateElement("shtype"); + if (ds.Type == EnumDataSourceType.SqlServer) + { + type.InnerText = "sqlserver"; + } + else + { + type.InnerText = "oracle"; + } + + dbparam.AppendChild(ip); + dbparam.AppendChild(dbname); + dbparam.AppendChild(username); + dbparam.AppendChild(password); + dbparam.AppendChild(type); + dbParams.AppendChild(dbparam); + } + + } + } + + for (int i = 0; i < treeNodeList.Count; i++) + { + GSOLayer layer = treeNodeList[i].Tag as GSOLayer; + if (Path.GetExtension(layer.Name) == "") + { + XmlElement dbLayer = doc.CreateElement("dblayer"); + XmlAttribute attri = doc.CreateAttribute("dbindex"); + for (int j = 0; j < listDS.Count; j++) + { + if (layer.Dataset.DataSource.Name == listDS[j].Name) + { + attri.Value = j.ToString(); + break; + } + } + dbLayer.Attributes.Append(attri); + dbLayer.InnerText = layer.Name; + + dbLayers.AppendChild(dbLayer); + } + else + { + XmlElement dbLayer = doc.CreateElement("layer"); + dbLayer.InnerText = layer.Name; + layers.AppendChild(dbLayer); + } + } + + doc.Save(configPath); + } + catch (Exception e) + { + + } + } + + private void openLayerList() + { + layerManagerNode.Nodes.Clear(); + + string configPath = Application.StartupPath + "\\configLayerList.xml"; + try + { + XmlDocument doc = new XmlDocument(); + doc.Load(configPath); + XmlNode dbParams = doc.SelectSingleNode("Params/dbparams"); + XmlNode dbLayers = doc.SelectSingleNode("Params/dblayers"); + XmlNode layers = doc.SelectSingleNode("Params/layers"); + + List listDS = new List(); + for (int i = 0; i < dbParams.ChildNodes.Count; i++) + { + string ip = ""; + string dbname = ""; + string username = ""; + string password = ""; + string type = ""; + XmlNode node = dbParams.ChildNodes.Item(i); + for (int j = 0; j < node.ChildNodes.Count; j++) + { + XmlNode nodeChild = node.ChildNodes.Item(j); + + if (nodeChild != null && nodeChild.Name == "ship") + { + ip = nodeChild.InnerText; + } + else if (nodeChild != null && nodeChild.Name == "shdbname") + { + dbname = nodeChild.InnerText; + } + else if (nodeChild != null && nodeChild.Name == "shusername") + { + username = nodeChild.InnerText; + } + else if (nodeChild != null && nodeChild.Name == "shpassword") + { + password = nodeChild.InnerText; + } + else if (nodeChild != null && nodeChild.Name == "shtype") + { + type = nodeChild.InnerText; + } + } + + if (type == "sqlserver") + { + GSODataSource ds = globeControl1.Globe.DataManager.OpenSqlServerDataSource(ip, "", dbname, username, password); + listDS.Add(ds); + } + else if (type == "oracle") + { + GSODataSource ds = globeControl1.Globe.DataManager.OpenOracleDataSource(ip + "/" + dbname, "", "", username, password); + listDS.Add(ds); + } + } + + for (int i = 0; i < dbLayers.ChildNodes.Count; i++) + { + XmlNode node = dbLayers.ChildNodes.Item(i); + if (node != null) + { + string layerName = node.InnerText; + XmlAttribute attri = node.Attributes["dbindex"]; + if (attri != null) + { + int dbIndex = -1; + if (int.TryParse(attri.Value, out dbIndex)) + { + GSODataset dataset = listDS[dbIndex].GetDatasetByName(layerName); + globeControl1.Globe.Layers.Add(dataset); + //更新树节点 + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + TreeNode layerNode = new TreeNode(); + layerNode.Tag = layer; + layerNode.Text = layer.Dataset.Caption; + layerNode.ImageIndex = 0; + layerNode.SelectedImageIndex = 0; + layerNode.Checked = layer.Visible; + layerManagerNode.Nodes.Insert(0, layerNode); + // layerManagerNode.Expand(); + + + } + } + } + } + for (int i = 0; i < layers.ChildNodes.Count; i++) + { + XmlNode node = layers.ChildNodes.Item(i); + if (node != null) + { + string layerName = node.InnerText; + globeControl1.Globe.Layers.Add(layerName); + + //更新树节点 + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + TreeNode layerNode = new TreeNode(); + layerNode.Tag = layer; + layerNode.Text = layer.Dataset.Caption; + layerNode.ImageIndex = 0; + layerNode.SelectedImageIndex = 0; + layerNode.Checked = layer.Visible; + layerManagerNode.Nodes.Insert(0, layerNode); + } + } + layerManagerNode.Expand(); + } + catch (Exception e) + { + + } + } + * */ + #endregion + + private void btn_check_history_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_check_history.Text); + + if (FrmCheckHistory.isOpen == true) + { + return; + } + FrmCheckHistory frm = new FrmCheckHistory(globeControl1, globeControl2); + frm.addNode += new AddNodeToLayerManagerNode(addNodeToLayerManagerNode); + frm.Show(); + + } + + private void buttonItem查看数据_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItem查看数据.Text); + + FrmThreeOracle tr = new FrmThreeOracle(globeControl1); + + if (tr.ShowDialog() == DialogResult.OK) + { + addNodeToLayerManagerNode(tr.rukuLayer); + globeControl1.Refresh(); + } + } + /// + /// 规划数据入库 + /// + /// + /// + private void buttonItemGHRK_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemGHRK.Text); + + FrmGHRK ghrk = new FrmGHRK(globeControl1, layerManagerNode); + ghrk.Show(this); + } + + private void btn_user_info_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_user_info.Text); + + if (!FrmSysUserInfoManger.IS_OPEN) + { + FrmSysUserInfoManger frm = new FrmSysUserInfoManger(); + frm.ShowDialog(); + } + } + + private void btn_role_info_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_role_info.Text); + + if (FrmRoleInfoManager.IS_OPEN) + { + return; + } + FrmRoleInfoManager frm = new FrmRoleInfoManager(); + frm.ShowDialog(); + } + + private void btn_resc_info_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_resc_info.Text); + + if (!SysRescInfoManager.IS_OPEN) + { + SysRescInfoManager frm = new SysRescInfoManager(); + frm.ShowDialog(); + } + } + + private void btn_role_resc_Click(object sender, EventArgs e) + { + + LogManager.saveLog(Utility.userName, this.btn_role_resc.Text); + + if (!FrmRoleRescManager.IS_OPEN) + { + FrmRoleRescManager frm = new FrmRoleRescManager(); + frm.ShowDialog(); + } + } + + private void btn_user_role_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_user_role.Text); + + if (FrmUserRole.IS_OPEN) + { + return; + } + FrmUserRole frm = new FrmUserRole(); + frm.ShowDialog(); + } + + private void btn_document_info_Click(object sender, EventArgs e) + { + + LogManager.saveLog(Utility.userName, this.btn_document_info.Text); + + //if (FormDocumentManager.IS_OPEN) + //{ + // return; + //} + //FormDocumentManager frm = new FormDocumentManager(); + //frm.ShowDialog(); + + //if (FormDocumentManager.IS_OPEN) + //{ + // return; + //} + //new FormDocumentManager().ShowDialog(); + if (FormDocumentManager.IS_OPEN) + { + return; + } + this.Cursor = Cursors.WaitCursor; + FormDocumentManager frm = new FormDocumentManager(); + frm.changeCursor += new ChangeCursor(changeCursorToDefault); + frm.ShowDialog(); + + } + + private void changeCursorToDefault() + { + this.Cursor = Cursors.Default; + } + + /// + /// 判断CAD文件是否有投影信息 + /// + /// + /// + Boolean CheckDatasetGeoReference(GSODataset dataset) + { + Boolean bSuccess = false; + if (dataset.GeoReferenceType == EnumGeoReferenceType.Flat) + { + if (MessageBox.Show("数据没有空间参考信息,请设置空间参考信息!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation) == DialogResult.OK) + { + String strPath = Path.GetDirectoryName(Application.ExecutablePath) + "\\Coordinate Systems"; + OpenFileDialog dlg = new OpenFileDialog(); + + dlg.InitialDirectory = strPath; + dlg.RestoreDirectory = true; + + dlg.Filter = "投影文件|*.prj||"; + if (dlg.ShowDialog() == DialogResult.OK) + { + bSuccess = dataset.LoadProjectionFromESRIFile(dlg.FileName); + } + } + } + else + { + return true; + } + return bSuccess; + } + + private void buttonItemexp_CAD_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemexp_CAD.Text); + + OpenFileDialog dlg = new OpenFileDialog(); + dlg.Filter = "支持格式(*.dwg)|*.dwg"; + dlg.Multiselect = true; + if (dlg.ShowDialog() == DialogResult.OK) + { + for (int i = 0; i < dlg.FileNames.Length; i++) + { + //this.Cursor = Cursors.WaitCursor; + string strDataPath = dlg.FileNames[i]; + + #region + //string strDataPathPrj = strDataPath.ToLower().Replace(".dwg", ".lprj"); + + //if (File.Exists(strDataPathPrj) == false) + //{ + // if (MessageBox.Show("数据没有空间参考信息,请设置空间参考信息!", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation) == DialogResult.OK) + // { + // String strPath = Application.StartupPath + "\\Coordinate Systems"; + // OpenFileDialog dlgPrj = new OpenFileDialog(); + // dlgPrj.InitialDirectory = strPath; + // dlgPrj.RestoreDirectory = true; + // dlgPrj.Multiselect = false; + // dlg.Filter = "投影文件|*.prj"; + // if (dlg.ShowDialog() == DialogResult.OK) + // { + // this.Cursor = Cursors.WaitCursor; + // string proj4 = GSODataEngineUtility.ConvertEsriPrjFileToProj4(dlg.FileName); + // using (StreamWriter stream = new StreamWriter(strDataPathPrj, false)) + // { + // stream.WriteLine("0prj4" + proj4 + ""); + // } + // AddLayerData(strDataPath); + // //globeControl1.Globe.Layers.Add(strDataPath); + + // this.Cursor = Cursors.Default; + // } + // else + // { + // AddLayerData(strDataPath); + // //globeControl1.Globe.Layers.Add(strDataPath); + // } + // } + // else + // { + // AddLayerData(strDataPath); + // //globeControl1.Globe.Layers.Add(strDataPath); + // } + + //} + //else + //{ + // //globeControl1.Globe.Layers.Add(strDataPath); + // AddLayerData(strDataPath); + //} + #endregion + AddLayerData(strDataPath); + //this.Cursor = Cursors.Default; + } + } + + 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, 100); + + globeControl1.Refresh(); + } + } + + private void btn_password_edit_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_password_edit.Text); + + if (FrmChangePassword.IS_OPEN) + { + return; + } + FrmChangePassword frm = new FrmChangePassword(); + frm.ShowDialog(); + } + /// + /// 多孔管线入库 + /// + /// + /// + private void buttonItem9_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL4_2.Text); + + if (ds == null) + { + MessageBox.Show("请先连接数据库", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + ConnectDB(null, null); + } + if (ds == null) + return; + + FrmMultiPipelineModelDB frm = new FrmMultiPipelineModelDB(globeControl1, ds); + if (frm.ShowDialog() == DialogResult.OK) + { + addNodeToLayerManagerNode(frm.rukuLayer); + } + //frm.Show(); + } + private void 导出CADToolStripMenuItem1_Click(object sender, EventArgs e) + { + TreeNode node = layerNodeContexMenu.Tag as TreeNode; + if (node == null) + { + MessageBox.Show("请在左侧节点集中选择要导出的图层", "提示"); + return; + } + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(node.Text.Trim()); + if (layer == null || layer.GetAllFeatures().Length <= 0) + { + MessageBox.Show("要导出的图层为空", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + return; + } + string strProjectName = Utility.projectStr; + if (strProjectName != "") + { + SaveFileDialog dlg = new SaveFileDialog(); + dlg.Filter = "*.dwg|*.dwg|*.dxf|*.dxf"; + dlg.FileName = layer.Caption; + if (dlg.ShowDialog(this) == DialogResult.OK) + { + globeControl1.Globe.MemoryLayer.SaveAs(dlg.FileName); + GSOLayer newlayer = globeControl1.Globe.Layers.Add(dlg.FileName); + newlayer.RemoveAllFeature(); + int featureCount = layer.GetAllFeatures().Length; + for (int i = 0; i < featureCount; i++) + { + GSOFeature feature = layer.GetAt(i); + if (feature != null && feature.Geometry != null) + { + if (feature.Geometry.Type == EnumGeometryType.GeoPolyline3D) + { + feature.Geometry.Style = new GSOSimpleLineStyle3D(); + } + else if (feature.Geometry.Type == EnumGeometryType.GeoPolygon3D) + { + feature.Geometry.Style = new GSOSimplePolygonStyle3D(); + } + newlayer.AddFeature(feature); + } + } + newlayer.Save(); + newlayer.Dataset.DataSource.RemoveDataset(newlayer.Dataset); + globeControl1.Globe.Layers.Remove(newlayer); + MessageBox.Show("导出CAD完成!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + } + } + } + + private void buttonItemGBJC_Click(object sender, EventArgs e) + { + FrmGBJC gb = new FrmGBJC(globeControl1, globeControl2, layerTemp, layerTemp2); + gb.Show(this); + } + + #region 右屏管纵数据控制 + private void 五十米主干道ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = true; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + + private void 三十六米次干道ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = true; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + + private void 四十二米次干道ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = true; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + + private void 二十四米一块板ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = true; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + + private void 二十四米三块板ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = true; + } + + private void 二十四米停车带ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = true; + lendendGZ24_3.Visible = false; + } + + private void 二十六米大堤路ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = true; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + + private void 清除管纵数据ToolStripMenuItem_Click(object sender, EventArgs e) + { + ClearGZData(); + } + + private void ClearGZData() + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + #endregion + + private void buttonItemPasswordReset_Click(object sender, EventArgs e) + { + Frm_password_reset reset = new Frm_password_reset(); + reset.Show(); + } + + private void pictureBox1_Paint(object sender, PaintEventArgs e) + { + int Width = this.Width; + string welcomeUser = "欢迎您:" + Utility.userName; + Graphics g = e.Graphics; + g.DrawString(welcomeUser, new Font("宋体", 12), new SolidBrush(Color.Black), Width - 180, 50); + } + + } +} \ No newline at end of file diff --git a/MainFrm.cs.BASE.9016.cs b/MainFrm.cs.BASE.9016.cs new file mode 100644 index 0000000..e530fbd --- /dev/null +++ b/MainFrm.cs.BASE.9016.cs @@ -0,0 +1,13442 @@ +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; + + GSOBalloon featureTooltip2; + GSOBalloonEx balloonEx2; + + GSOLayer layerTemp; + GSOLayer layerTemp2; + FrmShResult frmShResult = null; + FrmRedlineResult frmredResult = null; + FrmMnModify frmModify = null; + public bool frmRedlineResult = false; + public bool boolfrmShResult = false; + public bool boolfrmModify = false; + + List m_PipelineLayerNames = new List();//线图层名称 + List workwellLayerNames = new List();//工井图层名称 + List valueLayerNames = new List();//阀门图层名称 + List instrumenLayerNames = new List();//附属物图层名称 + List pipefittingLayerNames = new List();//管件图层名称 + List sgPipeLayersNames = new List();//施工管线图层名称 + 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 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; + public string redLayer = null; + //GSOLayer redLayer1 = null; + bool redSH = false; + string redDt = "红线"; + //双屏对比 + //bool zhanshi=false; + Thread t = null; + private GSOHudButton legendSC;//定义图例 + private GSOHudButton legendSG;//定义图例 + //管纵图 + private GSOHudButton lendendGZ50; + private GSOHudButton lendendGZ36; + private GSOHudButton lendendGZ42; + private GSOHudButton lendendGZ24_1; + private GSOHudButton lendendGZ24_2; + private GSOHudButton lendendGZ24_3; + private GSOHudButton lendendGZ26; + + GSOGeoPoint3D bsqPT; + + FrmYJSHTC frmSh = null;//一键审核窗口全局变量wxl + FrmWait frmWait = null;//一键审核等待窗口 + //FrmWait frmWait2 = null;//文档操作等待窗口 + + float mouseDownX1,mouseDownY1; + float mouseDownX2,mouseDownY2; + /// + /// + /// + 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; + + featureTooltip2 = new GSOBalloon(globeControl2.Handle); + balloonEx2 = new GSOBalloonEx(globeControl2.Handle); + Utility.SetBallons(featureTooltip, balloonEx); + + panelOfTable.Height = 200; + + RigthMenuSet(); + + MenuSet(); + + } + /// + /// 右屏中添加管纵图片 + /// + private void AddGZ() + { + + lendendGZ50 = new GSOHudButton(); + lendendGZ50.SetImage(Application.StartupPath + "/Resource/管纵/50.png"); + lendendGZ50.SetOffset(0, 0); + lendendGZ50.MinOpaque = 1; + lendendGZ50.MaxOpaque = 1; + lendendGZ50.FadeOut = false; + lendendGZ50.Name = "lendendGZ50"; + lendendGZ50.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ50); + lendendGZ50.Visible = false; + + lendendGZ36 = new GSOHudButton(); + lendendGZ36.SetImage(Application.StartupPath + "/Resource/管纵/36.png"); + lendendGZ36.SetOffset(0, 0); + lendendGZ36.MinOpaque = 1; + lendendGZ36.MaxOpaque = 1; + lendendGZ36.FadeOut = false; + lendendGZ36.Name = "lendendGZ36"; + lendendGZ36.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ36); + lendendGZ36.Visible = false; + + lendendGZ42 = new GSOHudButton(); + lendendGZ42.SetImage(Application.StartupPath + "/Resource/管纵/42.png"); + lendendGZ42.SetOffset(0, 0); + lendendGZ42.MinOpaque = 1; + lendendGZ42.MaxOpaque = 1; + lendendGZ42.FadeOut = false; + lendendGZ42.Name = "lendendGZ42"; + lendendGZ42.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ42); + lendendGZ42.Visible = false; + + lendendGZ24_1 = new GSOHudButton(); + lendendGZ24_1.SetImage(Application.StartupPath + "/Resource/管纵/24_1.png"); + lendendGZ24_1.SetOffset(0, 0); + lendendGZ24_1.MinOpaque = 1; + lendendGZ24_1.MaxOpaque = 1; + lendendGZ24_1.FadeOut = false; + lendendGZ24_1.Name = "lendendGZ24_1"; + lendendGZ24_1.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ24_1); + lendendGZ24_1.Visible = false; + + lendendGZ24_2 = new GSOHudButton(); + lendendGZ24_2.SetImage(Application.StartupPath + "/Resource/管纵/24_2.png"); + lendendGZ24_2.SetOffset(0, 0); + lendendGZ24_2.MinOpaque = 1; + lendendGZ24_2.MaxOpaque = 1; + lendendGZ24_2.FadeOut = false; + lendendGZ24_2.Name = "lendendGZ24_2"; + lendendGZ24_2.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ24_2); + lendendGZ24_2.Visible = false; + + lendendGZ24_3 = new GSOHudButton(); + lendendGZ24_3.SetImage(Application.StartupPath + "/Resource/管纵/24_3.png"); + lendendGZ24_3.SetOffset(0, 0); + lendendGZ24_3.MinOpaque = 1; + lendendGZ24_3.MaxOpaque = 1; + lendendGZ24_3.FadeOut = false; + lendendGZ24_3.Name = "lendendGZ24_3"; + lendendGZ24_3.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ24_3); + lendendGZ24_3.Visible = false; + + lendendGZ26 = new GSOHudButton(); + lendendGZ26.SetImage(Application.StartupPath + "/Resource/管纵/26.png"); + lendendGZ26.SetOffset(0, 0); + lendendGZ26.MinOpaque = 1; + lendendGZ26.MaxOpaque = 1; + lendendGZ26.FadeOut = false; + lendendGZ26.Name = "lendendGZ26"; + lendendGZ26.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ26); + lendendGZ26.Visible = false; + + } + + public void RigthMenuSet() + { + if (Utility.userRole.IndexOf("清除分析") < 0) + { + toolRightMenu.Items.Remove(清除分析ToolStripMenuItem); + } + + #region 区域分析 + if (Utility.userRole.IndexOf("区域分析") < 0) + { + toolRightMenu.Items.Remove(区域分析ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("缓冲区分析") < 0) + { + 区域分析ToolStripMenuItem.DropDownItems.Remove(缓冲区分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("附属物分析") < 0) + { + 区域分析ToolStripMenuItem.DropDownItems.Remove(附属物分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("无源淹没分析") < 0) + { + 区域分析ToolStripMenuItem.DropDownItems.Remove(无源淹没分析ToolStripMenuItem); + } + } + #endregion + + #region 视域分析 + if (Utility.userRole.IndexOf("视域分析") < 0) + { + toolRightMenu.Items.Remove(视域分析ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("通视分析") < 0) + { + 视域分析ToolStripMenuItem.DropDownItems.Remove(通视分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("可视域分析") < 0) + { + 视域分析ToolStripMenuItem.DropDownItems.Remove(可视域分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("可视包络分析") < 0) + { + 视域分析ToolStripMenuItem.DropDownItems.Remove(可视包络分析ToolStripMenuItem); + } + } + #endregion + + #region 开发分析 + if (Utility.userRole.IndexOf("开挖分析") < 0) + { + toolRightMenu.Items.Remove(开挖分析ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("多边形开挖") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(多边形开挖ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("挖方量分析") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(挖方量分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("沿线开挖") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(沿线开挖ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("创建隧道") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(创建隧道ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("隐藏隧道") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(隐藏隧道ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("删除隧道") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(删除隧道ToolStripMenuItem); + } + } + #endregion + + #region 拓扑分析 + if (Utility.userRole.IndexOf("拓扑分析") < 0) + { + toolRightMenu.Items.Remove(拓扑分析ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("创建拓扑") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(创建拓扑ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("上游分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(上游分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("下游分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(下游分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("流向分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(流向分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("关阀分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(关阀分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("连通分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(连通分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("爆管分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(爆管分析ToolStripMenuItem); + } + } + #endregion + + #region 断面分析 + if (Utility.userRole.IndexOf("断面分析") < 0) + { + toolRightMenu.Items.Remove(断面分析ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("横断面分析") < 0) + { + 断面分析ToolStripMenuItem.DropDownItems.Remove(横断面分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("纵断面分析") < 0) + { + 断面分析ToolStripMenuItem.DropDownItems.Remove(纵断面分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("道路断面分析") < 0) + { + 断面分析ToolStripMenuItem.DropDownItems.Remove(道路断面分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("基线剖面分析") < 0) + { + 断面分析ToolStripMenuItem.DropDownItems.Remove(基线剖面分析ToolStripMenuItem); + } + } + #endregion + + #region 绘制区域统计 + if (Utility.userRole.IndexOf("绘制区域统计") < 0) + { + toolRightMenu.Items.Remove(绘制区域统计ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("绘制区域管线长度统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管线长度统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域阀门数量统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(阀门数量统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域井盖数量统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(井盖数量统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域管径分段统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管径分段统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域埋深分段统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(埋深分段统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域管径分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管径分类统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域材质分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(材质分类统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域附属物分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(附属物分类统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域标识器分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(标识器分类统计ToolStripMenuItem1); + } + + } + #endregion + + #region 全区域统计 + if (Utility.userRole.IndexOf("全区域统计") < 0) + { + toolRightMenu.Items.Remove(全区域统计ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("全区域管线长度统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管线长度统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域阀门数量统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(阀门数量统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域井盖数量统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(井盖数量统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域管径分段统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管径分段统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域埋深分段统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(埋深分段统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域管径分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管径分类统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域材质分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(材质分类统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域附属物分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(附属物分类统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域标识器分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(标识器分类统计ToolStripMenuItem); + } + + } + #endregion + + #region 查询 + if (Utility.userRole.IndexOf("查询") < 0) + { + toolRightMenu.Items.Remove(查询ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("空间查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(空间查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("编号查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(编号查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("坐标查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(坐标查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("管径查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(管径查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("材质查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(材质查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("基本查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(基本查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("复合查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(复合查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("关联查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(关联查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("关键字查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(关键字查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("附属物查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(附属物查询ToolStripMenuItem); + } + } + #endregion + + #region 标注 + if (Utility.userRole.IndexOf("标注") < 0) + { + toolRightMenu.Items.Remove(标注ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("标高标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(标高标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("管径标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(管径标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("埋深标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(埋深标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("坐标标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(坐标标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("距离标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(距离标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("自定义标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(自定义标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("扯旗标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(扯旗标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("坡度标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(坡度标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("属性标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(属性标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("标注管理") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(标注管理ToolStripMenuItem); + } + } + #endregion + + #region 飞行 + if (Utility.userRole.IndexOf("飞行") < 0) + { + toolRightMenu.Items.Remove(飞行ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("自定义飞行") < 0) + { + 飞行ToolStripMenuItem.DropDownItems.Remove(自定义飞行ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("飞行到目标点") < 0) + { + 飞行ToolStripMenuItem.DropDownItems.Remove(飞行到目标点ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("绕中心点飞行") < 0) + { + 飞行ToolStripMenuItem.DropDownItems.Remove(绕中心点飞行ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("绕眼睛飞行") < 0) + { + 飞行ToolStripMenuItem.DropDownItems.Remove(绕眼睛飞行ToolStripMenuItem); + } + } + #endregion + + #region 编辑 + if (Utility.userRole.IndexOf("编辑") < 0) + { + toolRightMenu.Items.Remove(编辑ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("平移对象") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(平移对象ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("升降对象") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(升降对象ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("旋转对象") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(旋转对象ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("连接管段") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(连接管段ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("导出文件") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(导出文件ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("前进") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(前进ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("后退") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(删除模型ToolStripMenuItem); + } + } + #endregion + + #region 量算 + if (Utility.userRole.IndexOf("量算") < 0) + { + toolRightMenu.Items.Remove(量算ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("水平距离") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(水平距离ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("垂直距离") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(垂直距离ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("空间距离") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(空间距离ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("地表距离") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(地表距离ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("高度量算") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(高度量算ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("水平面积") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(水平面积ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("地表面积") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(地表面积ToolStripMenuItem1); + } + } + #endregion + } + + public void MenuSet() + { + + #region 权限管理 + if (Utility.userRole.IndexOf("权限管理") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem2); + } + else + { + + if (Utility.userRole.IndexOf("用户管理") < 0) + { + btn_user_info.Visible = false; + } + if (Utility.userRole.IndexOf("角色管理") < 0) + { + btn_role_info.Visible = false; + } + if (Utility.userRole.IndexOf("资源管理") < 0) + { + btn_resc_info.Visible = false; + } + if (Utility.userRole.IndexOf("角色授权") < 0) + { + btn_role_resc.Visible = false; + } + if (Utility.userRole.IndexOf("用户授权") < 0) + { + btn_user_role.Visible = false; + } + if (Utility.userRole.IndexOf("密码修改") < 0) + { + btn_password_edit.Visible = false; + } + + } + #endregion + + #region 基础工具 + if (Utility.userRole.IndexOf("基础工具") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem1); + } + else + { + if (Utility.userRole.IndexOf("地上模式") < 0) + { + buttonItem87.Visible = false; + } + if (Utility.userRole.IndexOf("地下模式") < 0) + { + buttonItem88.Visible = false; + } + if (Utility.userRole.IndexOf("行走模式") < 0) + { + buttonItem27.Visible = false; + } + if (Utility.userRole.IndexOf("透明度设置") < 0) + { + sliderGroundTransSet1.Visible = false; + } + if (Utility.userRole.IndexOf("快速定位") < 0) + { + buttonItem91.Visible = false; + } + if (Utility.userRole.IndexOf("图层管理") < 0) + { + buttonItem1.Visible = false; + } + if (Utility.userRole.IndexOf("图例管理") < 0) + { + btnlegendSet.Visible = false; + } + if (Utility.userRole.IndexOf("全屏显示") < 0) + { + buttonItem89.Visible = false; + } + if (Utility.userRole.IndexOf("导出图片") < 0) + { + btnOutputJPG.Visible = false; + } + + } + #endregion + + #region 一键审核 + if (Utility.userRole.IndexOf("一键审核") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem11); + } + #endregion + + #region 红线审核 + if (Utility.userRole.IndexOf("红线审核") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem6); + } + #endregion + + #region 双屏对比 + if (Utility.userRole.IndexOf("双屏对比") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem9); + } + #endregion + + #region 文档管理 + if (Utility.userRole.IndexOf("文档管理") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem4); + } + #endregion + + #region 基础管理 + if (Utility.userRole.IndexOf("基础管理") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem14); + } + else + { + if (Utility.userRole.IndexOf("专题图审批") < 0) + { + buttonItemZTT3_2.Visible = false; + } + if (Utility.userRole.IndexOf("打印审批") < 0) + { + buttonItemZTT4_2.Visible = false; + } + if (Utility.userRole.IndexOf("拷贝审批") < 0) + { + buttonItemZTT5_2.Visible = false; + } + } + + #endregion + + if (ribbonControl1.Items.Count <= 0) + { + ribbonControl1.Visible = false; + } + } + + #region Fan Zhang 重构现有代码 + //初始化控件布局 + private void initLayout() + { + 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.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.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.labelX21.Width = (int)(this.labelX21.Width * myScreen); + this.labelX22.Width = (int)(this.labelX22.Width * myScreen); + this.labelX24.Width = (int)(this.labelX24.Width * myScreen); + } + sideBar1.Visible = false; + 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]); + } + + splitContainer1.Panel2Collapsed = true; + + buttonItem87.Checked = true;//默认地上模式 + ribbonTabItem1.Select(); //初始化状态为浏览 + + sideBarPanelItem3.Visible = false; + layerTree.Visible = false; + controlContainerItem3.Visible = false; + if (sideBarPanelItem4.Visible == true) + { + sideBar1.Visible = true; + controlContainerItem5.Visible = true; + } + else + { + sideBar1.Visible = false; + } + Refresh(); + sliderGroundTransSet1.Value = optiValue; + sliderItem1.Value = optiValue; + sliderItem2.Value = optiValue; + sliderItem3.Value = optiValue; + + } + + //初始化地球控件 + private void initGlobalControl() + { + //选择 + btnToolSelect = new GSOHudButton(); + btnToolSelect.SetImage(Application.StartupPath + "\\Resource\\image\\select1.png"); + btnToolSelect.FadeOut = false; + btnToolSelect.Align = EnumAlign.TopLeft; + btnToolSelect.SetOffset(20, 50); + btnToolSelect.Name = "1"; + btnToolSelect.HeightFixed = true; + btnToolSelect.WidthFixed = true; + globeControl1.Globe.AddHudControl(btnToolSelect); + globeControl2.Globe.AddHudControl(btnToolSelect); + + //浏览 + 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); + + //图例 + legend = new GSOHudButton(); + legend.SetImage(Application.StartupPath + "/Resource/图例P.jpg");//图例P + legend.SetOffset(0, 15); + legend.MinOpaque = 1; + legend.MaxOpaque = 1; + legend.FadeOut = false; + legend.Name = "legend"; + legend.Align = EnumAlign.BottomRight; + legend.Visible = false; + globeControl1.Globe.AddHudControl(legend); + + //实测 + legendSC = new GSOHudButton(); + legendSC.SetImage(Application.StartupPath + "/Resource/sc.jpg"); + legendSC.SetOffset(0, 15); + legendSC.MinOpaque = 1; + legendSC.MaxOpaque = 1; + legendSC.FadeOut = false; + legendSC.Name = "legendSC"; + legendSC.Align = EnumAlign.BottomRight; + globeControl1.Globe.AddHudControl(legendSC); + legendSC.Visible = false; + + //施工 + legendSG = new GSOHudButton(); + legendSG.SetImage(Application.StartupPath + "/Resource/sg.jpg"); + legendSG.SetOffset(0, 15); + legendSG.MinOpaque = 1; + legendSG.MaxOpaque = 1; + legendSG.FadeOut = false; + legendSG.Name = "legendSG"; + legendSG.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(legendSG); + legendSG.Visible = false; + + //管纵 + AddGZ(); + + 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; + globeControl1.Globe.IsReleaseMemOutOfView = true; + globeControl1.Globe.ControlPanel.Visible = true; + + globeControl2.Globe.UnderGroundFloor.Visible = false; + globeControl2.Globe.OverviewControl.Visible = false; + globeControl2.Globe.ScalerControl.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; + globeControl2.Globe.IsReleaseMemOutOfView = true; + globeControl2.Globe.ControlPanel.Visible = false; + + 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); + + //添加临时图层 + layerTemp = globeControl1.Globe.Layers.Add(Application.StartupPath + "\\tempLgdData.lgd"); + layerTemp2 = globeControl2.Globe.Layers.Add(Application.StartupPath + "\\tempLgdData2.lgd"); + if (layerTemp != null) + { + layerTemp.MaxVisibleAltitude = 1000; + } + + //添加城市7线图层 + 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"); + + //注册对应事件 + this.registerEvent(); + } + + //注册地球事件 + private bool registerEvent() + { + if (globeControl1 == null || globeControl2 == null) + { + return false; + } + 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); + + globeControl2.FeatureMouseClickEvent += new FeatureMouseClickEventHandler(globeControl2_FeatureMouseClickEvent); + globeControl2.CameraBeginMoveEvent += new CameraBeginMoveEventHandler(globeControl2_CameraBeginMoveEvent); + + globeControl1.MouseDoubleClick += new MouseEventHandler(globeControl1_MouseDoubleClick); + globeControl1.MouseClick += new MouseEventHandler(globeControl1_MouseClick); + globeControl1.MouseDown += new MouseEventHandler(globeControl1_MouseDown); + + globeControl2.MouseClick += new MouseEventHandler(globeControl2_MouseClick); + globeControl2.MouseDown += new MouseEventHandler(globeControl2_MouseDown); + + 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); + + return true; + } + + //加载两个地球数据 + private void loadData() + { + Thread t1 = new Thread(new ThreadStart(doLoadDataForGlobalControl1)); + t1.IsBackground = true; + t1.Start(); + + + } + + delegate void LoadDataForGlobalControl(); + + private void connectServer() + { + globeControl1.Globe.ConnectServer(Utility.serverip, Utility.serverport, "", ""); //加载locaServer中的数据 + globeControl2.Globe.ConnectServer(Utility.serverip, Utility.serverport, "", ""); //加载locaServer中的数据 + //初始化TreeView + // 勾选实测图层 + foreach (TreeNode tn in layerTree.Nodes) + { + if (tn.Nodes.Count > 0) + { + if (tn.Text == "实测数据") + { + tn.Checked = true; + foreach (TreeNode tnChild in tn.Nodes) + { + tnChild.Checked = true; + foreach (TreeNode tnGrandChild in tnChild.Nodes) + { + tnGrandChild.Checked = true; + } + } + } + } + } + } + + private void doLoadDataForGlobalControl1() + { + try + { + + globeControl1.Globe.Layers.MoveDown(10000); + //加载实测管线数据 + Utility.dataSource = globeControl1.Globe.DataManager.OpenOracleDataSource(Utility.DBServer.Trim() + "/" + Utility.dbdatabase.Trim(), "", "", Utility.userID, Utility.DBPassword); + + if (Utility.dataSource != null) + { + for (int j = 0; j < Utility.dataSource.DatasetCount; j++) + { + GSODataset dataset = Utility.dataSource.GetDatasetAt(j); + if (dataset != null && dictionaryNetLayerNameAndCaption.ContainsKey(dataset.Caption)) + { + dataset.Caption = dataset.Name; + globeControl1.Globe.Layers.Add(dataset); + } + } + } + //隐藏红线图层 + globeControl1.Globe.Layers.GetLayerByCaption("红线").Visible = false; + + //globleControl1中加载规划数据 + GSODataSource ghDS = globeControl1.Globe.DataManager.OpenOracleDataSource(Utility.ghdbip + "/" + Utility.ghdbname, "", "", Utility.ghdbuser, Utility.ghdbpwd); + if (ghDS != null) + { + for (int j = 0; j < ghDS.DatasetCount; j++) + { + GSODataset dataset = ghDS.GetDatasetAt(j); + if (dataset != null && dictionaryNetLayerNameAndCaption.ContainsKey(dataset.Caption)) + { + dataset.Caption = dataset.Name; + globeControl1.Globe.Layers.Add(dataset); + globeControl1.Globe.Layers[0].Visible = false; + } + } + } + + //globeControl1,globeControl2中加载施工数据 + GSODataSource sgDS = globeControl1.Globe.DataManager.OpenOracleDataSource(Utility.sgdbip + "/" + Utility.sgdbname, "", "", Utility.sgdbuser, Utility.sgdbpwd); + if (sgDS != null) + { + for (int m = 0; m < sgDS.DatasetCount; m++) + { + GSODataset dataset = sgDS.GetDatasetAt(m); + if (dataset != null && !dataset.Caption.Contains("SH") && dictionaryNetLayerNameAndCaption.ContainsKey(dataset.Caption)) + { + dataset.Caption = dataset.Name; + globeControl1.Globe.Layers.Add(dataset); + globeControl1.Globe.Layers[0].Visible = false; + + globeControl2.Globe.Layers.Add(dataset); + globeControl2.Globe.Layers[0].Visible = true; + } + } + } + + LoadDataForGlobalControl ss = new LoadDataForGlobalControl(connectServer); + ss(); + + } + catch (Exception ex) + { + MessageBox.Show(ex.Message); + } + } + + private void initLayerTree() + { + //加载临时图层节点 + layerManagerNode = new TreeNode(); + layerManagerNode.ImageIndex = 0; + layerManagerNode.SelectedImageIndex = 0; + layerManagerNode.Checked = true; + layerManagerNode.Text = "临时图层"; + layerTree.Nodes.Add(layerManagerNode); + + XmlDocument doc = new XmlDocument(); + doc.Load(filename); + XmlNodeList xmlLayerNodes = doc.SelectNodes("//layer"); + + foreach (XmlNode xmlLayerNode in xmlLayerNodes) + { + + //TODO LIST:创建一级TreeNode(实测、规划、施工) + TreeNode nodelayer = new TreeNode(); + string layerName = xmlLayerNode.Attributes["label"].Value; + nodelayer.Text = layerName; + nodelayer.Checked = false; + layerTree.Nodes.Add(nodelayer); + + XmlNodeList xmlChildLayerNodes = xmlLayerNode.ChildNodes; + foreach (XmlNode xmlChildLayerNode in xmlChildLayerNodes) + { + //TODO LIST:创建二级TreeNode节点 + TreeNode secondLevelNode = new TreeNode(); + string layerType = xmlChildLayerNode.Attributes["label"].Value; + secondLevelNode.Text = layerType; + + if (xmlChildLayerNode.Attributes["type"] != null) + { //道路图层特殊处理 + string type = xmlChildLayerNode.Attributes["type"].Value; + secondLevelNode.Tag = type + "|" + layerType; + } + else + { + secondLevelNode.Tag = layerType; + } + secondLevelNode.Checked = false; + nodelayer.Nodes.Add(secondLevelNode); + + XmlNodeList xmlActitualLayerNodes = xmlChildLayerNode.ChildNodes; + + foreach (XmlNode xmlActitualLayerNode in xmlActitualLayerNodes) + { + //TODO LIST:创建三级图层节点 + TreeNode layerNode = new TreeNode(); + string actutallylayerType = xmlActitualLayerNode.Attributes["type"].Value; + string actutallylayerName = xmlActitualLayerNode.Attributes["layer"].Value; + string actutallyLabelName = xmlActitualLayerNode.Attributes["label"].Value; + + layerNode.Text = actutallyLabelName; + layerNode.Tag = layerType + "|" + actutallyLabelName; + layerNode.Checked = false; + secondLevelNode.Nodes.Add(layerNode); + } + + } + + } + + } + + /** + * 读取Config.xml文件,初始化以下全局Map + * m_PipelineLayerNames:管线 + * workwellLayerNames:工井 + * valueLayerNames:阀门 + * instrumenLayerNames:附属物 + * pipefittingLayerNames:特征管点 + * sgPipeLayersNames:施工管线 + **/ + private void initGlobalMap() + { + XmlDocument doc = new XmlDocument(); + doc.Load(filename); + XmlNodeList xmlLayerNodes = doc.SelectNodes("//layerchild"); + + foreach (XmlNode xmlLayerNode in xmlLayerNodes) + { + string layerType = xmlLayerNode.Attributes["type"].Value; + string layerName1 = xmlLayerNode.Attributes["layer"].Value; + string layerchildName = xmlLayerNode.Attributes["label"].Value; + + dictionaryNetLayerNameAndCaption.Add(layerName1, layerchildName); + + if (layerType != "db") + { + if (xmlLayerNode.Attributes["isRoad"] != null) + { + roadLayerName = layerchildName; + } + } + else if (xmlLayerNode.Attributes["isPipeLine"] != null) + { + m_PipelineLayerNames.Add(layerchildName); + g1layername.Add(layerName1); + } + else if (xmlLayerNode.Attributes["isWorkWell"] != null) + { + workwellLayerNames.Add(layerchildName); + g1layername.Add(layerName1); + } + else if (xmlLayerNode.Attributes["isValve"] != null) + { + valueLayerNames.Add(layerchildName); + g1layername.Add(layerName1); + } + else if (xmlLayerNode.Attributes["isAccess"] != null) + { + instrumenLayerNames.Add(layerchildName); + g1layername.Add(layerName1); + } + else if (xmlLayerNode.Attributes["isCharacter"] != null) + { + pipefittingLayerNames.Add(layerchildName); + g1layername.Add(layerName1); + } + else if (xmlLayerNode.Attributes["isSgData"] != null) + { + sgPipeLayersNames.Add(layerchildName); + g1layername.Add(layerName1); + } + + } + } + + private void initMarkerTree() + { + 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); + } + } + } + } + + private void MainFrm_Load(object sender, EventArgs e) + { + + this.initGlobalControl(); + this.initGlobalMap(); + this.initLayerTree(); + this.initMarkerTree(); + this.initLayout(); + this.loadData(); + + + double x = Convert.ToDouble(Utility.Query_Roads["绿岛"].ToString().Split(',')[0]); + double y = Convert.ToDouble(Utility.Query_Roads["绿岛"].ToString().Split(',')[1]); + double z = Convert.ToDouble(Utility.Query_Roads["绿岛"].ToString().Split(',')[2]); + jumpToCameraState(x, y, z); + + + } + + #endregion + + /// + /// 每次gis服务加载时都会触发的 + /// + /// + /// + 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 dictionaryNetLayerNameAndCaption = new Dictionary(); + 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 配置用户权限 + /// + /// 向数据库插入功能列表 + /// + private void insertControlToDatabase() + { + ArrayList listItem = new ArrayList(); + List subListItem = new List(); + 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) + { + GSOCameraState camera = globeControl2.Globe.CameraState; + globeControl1.Globe.JumpToCameraState(camera); + } + } + + void globeControl1_BeforeSceneRenderEvent(object sender, BeforeSceneRenderEventArgs e) + { + if (globeControl1.Focused) + { + 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); + } + } + } + + /// + /// 检查数据集是否有坐标系信息 + /// + /// + /// + 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 = "0prj4" + lprjStr + ""; + + bSuccess = dataset.LoadProjectionFromESRIFile(dlg.FileName); + + string lprjFileName = strDataPath.Substring(0, strDataPath.LastIndexOf(".")) + ".lprj"; + StreamWriter writer = new StreamWriter(lprjFileName, false); + writer.Write(lprjFileContent); + writer.Close(); + + } + } + } + else + { + return true; + } + return bSuccess; + } + + /// + /// 矩形拉框结束事件处理函数 + /// + /// + /// + 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))); + */ + + int mapWidth = 0; + int mapHeight = 0; + Point pt = getUpperLeftPoint(pt1, pt2, out mapWidth, out mapHeight); + int rightBottomX = pt.X + mapWidth; + int rightBottomY = pt.Y + mapHeight; + Image myImg = new Bitmap(mapWidth, mapHeight); + Graphics g = Graphics.FromImage(myImg); + g.CopyFromScreen(pt, new Point(0, 0), new Size(rightBottomX, rightBottomY)); + + 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; + } + } + /// + /// 定位正北正90度俯视 + /// + /// + /// + /// + 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; + } + } + /// + /// layerTree选中后事件处理 + /// + /// + /// + 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); + } + /// + /// 树节点选中方法 + /// + /// + 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); + } + } + } + + } + /// + /// 改变所有子节点的状态 + /// + /// + /// + 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; + LayerFlyMenuItem.Visible = true; + } + + LayerSelectableMenuItem.Visible = true; + LayerEditableMenuItem.Visible = true; + SaveLayerMenuItem.Visible = true; + LayerFlyMenuItem.Visible = true; + 导出CADToolStripMenuItem1.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]); + if (layer != null) + { + LayerSelectableMenuItem.Checked = layer.Selectable; + LayerEditableMenuItem.Checked = layer.Editable; + } + else + { + return; + } + } + 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; + } + } + } + } + } + + /// + /// 删除临时添加的本地数据图层 + /// + /// + /// + 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); + for (int i = globeControl1.Globe.Layers.Count-1; i >=0; i--) + { + if (globeControl1.Globe.Layers[i].Caption == layer.Caption) + { + globeControl1.Globe.Layers.Remove(globeControl1.Globe.Layers[i]); + } + } + + 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 定位ToolStripMenuItem_Click(object sender, EventArgs e) + { + TreeNode node = layerTree.SelectedNode; + + if (node != null) + { + if (node.Parent.Text.Trim() == "临时图层") + { + GSOLayer lsLayer = globeControl1.Globe.Layers.GetLayerByCaption(node.Text.ToString()); + double x = lsLayer.LatLonBounds.Center.X; + double y = lsLayer.LatLonBounds.Center.Y; + if (x == 0 && y == 0) + { + x = lsLayer.Bounds.Center.X; + y = lsLayer.Bounds.Center.Y; + } + + globeControl1.Globe.FlyToPosition(new GSOPoint3d(x, y, 10), EnumAltitudeMode.Absolute); + } + else + { + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(node.Tag.ToString().Split('|')[1]); + + if (layer != null) + { + if (layer.Caption == "红线") + { + globeControl1.Globe.FlyToPosition(new GSOPoint3d(120.610963, 31.188121, 50), EnumAltitudeMode.Absolute, -4, 50, 1000); + globeControl1.Globe.FlyToPointSpeed = 10000000; + globeControl1.Globe.Action = EnumAction3D.SelectObject; + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = true; + } + globeControl1.Refresh(); + } + else + { + double x = layer.LatLonBounds.Center.X; + double y = layer.LatLonBounds.Center.Y; + globeControl1.Globe.FlyToPosition(new GSOPoint3d(x, y, 100), EnumAltitudeMode.Absolute); + } + } + } + } + else + { + return; + } + + } + + private void layerTree_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e) + { + if(this.layerTree.SelectedNode!=null) + { + if (this.layerTree.SelectedNode.Tag.ToString().Contains("|")) + { + string nodeTag = this.layerTree.SelectedNode.Tag.ToString().Split('|')[1]; + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(nodeTag); + if (layer != null) + { + if (layer.Caption == "红线") + { + globeControl1.Globe.FlyToPosition(new GSOPoint3d(120.610963, 31.188121, 50), EnumAltitudeMode.Absolute, -4, 50, 1000); + globeControl1.Globe.FlyToPointSpeed = 10000000; + globeControl1.Globe.Action = EnumAction3D.SelectObject; + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = true; + } + globeControl1.Refresh(); + } + else { + double x = layer.LatLonBounds.Center.X; + double y = layer.LatLonBounds.Center.Y; + globeControl1.Globe.FlyToPosition(new GSOPoint3d(x, y, 0), EnumAltitudeMode.Absolute); + } + } + } + if (this.layerTree.SelectedNode.Tag is GSOLayer) + { + GSOLayer layer = this.layerTree.SelectedNode.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 (this.layerTree.SelectedNode.Tag is GSOFeature) + { + GSOFeature feature = this.layerTree.SelectedNode.Tag as GSOFeature; + if (feature.Geometry != null) + { + globeControl1.Globe.FlyToPosition(feature.Geometry.GeoCenterPoint, EnumAltitudeMode.Absolute, 0, 0, 10); + } + else + { + globeControl1.Globe.FlyToFeature(feature); + } + } + } + } + + /// + /// 在三维场景移动时,隐藏气泡globeControl1 + /// + /// + /// + void globeControl1_CameraBeginMoveEvent(object sender, CameraBeginMoveEventArgs e) + { + if (featureTooltip.IsVisible()) + { + featureTooltip.HideBalloon(); + } + if (balloonEx.IsVisible()) + { + balloonEx.HideBalloon(); + } + } + + /// + /// 在三维场景移动时,隐藏气泡globeControl2 + /// + /// + /// + void globeControl2_CameraBeginMoveEvent(object sender, CameraBeginMoveEventArgs e) + { + if (featureTooltip2.IsVisible()) + { + featureTooltip2.HideBalloon(); + } + if (balloonEx2.IsVisible()) + { + balloonEx2.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(); + } + } + + #region Fan 横断面 + /// + /// 横断面分析、基线剖面分析、道路断面分析等 + /// + /// + /// + private static EnumTrackPolylineEndMode trackPolylineEndMode; + + void globeControl1_TrackPolylineEndEvent(object sender, TrackPolylineEndEventArgs e) + { + //横断面分析、道路横断面分析 + if (trackPolylineEndMode == EnumTrackPolylineEndMode.HDM_Analysis|| + trackPolylineEndMode == EnumTrackPolylineEndMode.DLDM_Analysis) + { + Dictionary hdmDic = SectionAnalysisTool.HDMAnalysis(this.globeControl1, + e.Polyline, this.m_PipelineLayerNames); + FrmHDMAnalysis3 frm = new FrmHDMAnalysis3(hdmDic, this.globeControl1, + trackPolylineEndMode); + frm.Show(this); + } + //基线剖面分析 + else if (trackPolylineEndMode == EnumTrackPolylineEndMode.JXPM_Analysis) + { + FrmBaseLineProfillAnalysis dlg = new FrmBaseLineProfillAnalysis(globeControl1.Globe, e.Polyline); + dlg.Show(this); + globeControl1.Globe.ClearLastTrackPolyline(); + /* + FrmRoadHDM f = new FrmRoadHDM(); + f.Show() + * **/ + } + else + { + + } + trackPolylineEndMode = EnumTrackPolylineEndMode.Default_Analysis; + /* + ArrayList arraylistPoint = new ArrayList(); + ArrayList arraylistLine = new ArrayList(); + + // globeControl1.Globe.ClearLastTrackPolyline(); + + if (e.Polyline != null) + { + //横断面分析 + if (buttonItemFX2_1.Checked || buttonItemFX2_3.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 (buttonItemFX2_1.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 (buttonItemFX2_4.Checked) + { + FrmBaseLineProfillAnalysis dlg = new FrmBaseLineProfillAnalysis(globeControl1.Globe, e.Polyline); + dlg.Show(this); + globeControl1.Globe.ClearLastTrackPolyline(); + } + else if (buttonItemFX4_3.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(); + * **/ + } + #endregion + + private GSOFeatures PolygonIntersectAnalysis(GSOGeoPolygon3D polygon, string pipelinetype) + { + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(pipelinetype); + 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(pipelinetype, feats.Length); + return feats; + } + /// + /// 根据范围统计阀门、管线、工井等, 开挖分析, 挖方量分析 + /// + /// + /// + void globeControl1_TrackPolygonEndEvent(object sender, TrackPolygonEndEventArgs e) + { + if (globeControl1.Globe.Action == EnumAction3D.TrackPolygon && e.Polygon != null) + { + GSOGeoPolygon3D polygon = e.Polygon; + + switch (trackflag) + { + case "valvequery": + //workWellLen.Clear(); + //List list = new List(); + ////找到所有阀门 + //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, globeControl1, new DataGridViewDelegate(InitDataGridViewX1)); + FrmValveStatistics frm = new FrmValveStatistics(globeControl1,polygon, new DataGridViewDelegate(InitDataGridViewX1)); + frm.Show(this); + //panelEx6.Visible = true; + toolStripFeatureLength.Text = ""; + globeControl1.Globe.Action = EnumAction3D.ActionNull; + break; + + case "PipelineDistanceStatistics": + //pipeLineDis.Clear(); + //List list1 = new List(); + //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, globeControl1, new DataGridViewDelegate(InitDataGridViewX1)); + FrmAllPipelineStatis frm1 = new FrmAllPipelineStatis(globeControl1, polygon, new DataGridViewDelegate(InitDataGridViewX1), m_PipelineLayerNames); + frm1.Show(this); + globeControl1.Globe.Action = EnumAction3D.ActionNull; + + break; + case "PipelineSpatialQuery": + //pipeLineDis.Clear(); + //List list2 = new List(); + //for (int i = 0; i < m_PipelineLayerNames.Count; i++) + //{ + // GSOFeatures fs = Intersects_Pipeline(polygon, m_PipelineLayerNames[i]); + // if (fs != null) + // { + // list2.Add(fs); + // } + //} + + //FrmAllPipelineStatis.ShowForm(1, pipeLineDis, list2, globeControl1, new DataGridViewDelegate(InitDataGridViewX1)); + FrmAllPipelineStatis.ShowForm(globeControl1,polygon,new DataGridViewDelegate(InitDataGridViewX1),m_PipelineLayerNames); + globeControl1.Globe.ClearAnalysis(); + globeControl1.Globe.Action = EnumAction3D.ActionNull; + + break; + case "workwellquery": + //workWellLen.Clear(); + //List listWell = new List(); + ////找到所有井 + //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(polygon, dataGridViewX1, toolStripNumbers, globeControl1, panelOfTable); + FrmAllWorkWellStatis frmWell = new FrmAllWorkWellStatis(globeControl1, polygon, new DataGridViewDelegate(InitDataGridViewX1)); + 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 "BSQDuoBianXiangStatis": + + GSOFeature f2 = new GSOFeature(); + f2.Geometry = e.Polygon; + f2.Geometry.AltitudeMode = EnumAltitudeMode.Absolute; + globeControl1.Globe.MemoryLayer.AddFeature(f2); + f2.Geometry.MoveZ(3); + workWellLen.Clear(); + List listBSQ = new List(); + + GSOFeatures bsqFeatures = PolygonIntersectAnalysis(e.Polygon, "标识器"); + listBSQ.Add(bsqFeatures); + + FrmBSQDuoBianXingStatis bsqFrm = new FrmBSQDuoBianXingStatis(workWellLen, globeControl1, listBSQ); + bsqFrm.Show(this); + globeControl1.Globe.Action = EnumAction3D.ActionNull; + break; + + case "": + break; + default: + break; + } + } + } + + #region 验证端口 + /* + /// + /// 验证端口 + /// + /// + 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 + + /// + /// 鼠标悬浮提示 + /// + /// + /// + 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); + } + } + + /// + /// 添加管线绘制完成事件, 红线工具绘制完成 + /// + /// + /// + 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; + + + } + } + + /// + /// 获取globeControl1中鼠标按下的坐标供区别鼠标右键和滚轮按下事件 + /// + /// + /// + void globeControl1_MouseDown(object sender, MouseEventArgs e) + { + mouseDownX1 = e.X; + mouseDownY1 = e.Y; + } + /// + /// 获取globeControl2中鼠标按下的坐标供区别鼠标右键和滚轮按下事件 + /// + /// + /// + void globeControl2_MouseDown(object sender, MouseEventArgs e) + { + mouseDownX2 = e.X; + mouseDownY2 = e.Y; + } + /// + /// + /// + /// + /// + void globeControl2_MouseClick(object sender, MouseEventArgs e) + { + if (e.Button == MouseButtons.Right) + { + if (e.X == mouseDownX2 && e.Y == mouseDownY2) + { + RightScreenToolMenu.Show(globeControl2, e.X, e.Y); + } + else + { + return; + } + } + } + /// + /// + /// + /// + /// + void globeControl1_MouseClick(object sender, MouseEventArgs e) + { + if (e.Button == MouseButtons.Left) + { + if (globeControl1.Globe.Action == EnumAction3D.VisibilityAnalysis) + { + buttonItemFX5_1.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; + + bsqPT = pt; + + if (buttonItemLS5.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 (e.X == mouseDownX1 && e.Y == mouseDownY1) + { + toolRightMenu.Show(globeControl1, e.X, e.Y); + if (buttonItemLS5.Checked) + { + buttonItemLS5.Checked = false; + } + } + else + { + return; + } + } + globeControl1.Refresh(); + } + + /// + /// 判断网络图片是否存在 + /// + /// + /// + 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; + } + + /// + /// 鼠标点击, 弹出气泡功能globeControl1 + /// + /// + /// + void globeControl1_FeatureMouseClickEvent(object sender, FeatureMouseClickEventArgs e) + { + GSOFeature feature = e.Feature; + + string str1 = ""; + if (feature != null) + { + if (feature.GetFieldDefn("图片编码") != null)// + { + str1 = GetBubbleInfo(feature, globeControl1); + if (RemoteFileExists(Utility.PicRootURL + feature.GetValue("图片编码").ToString())) + { + str1 += ""; + } + else if (RemoteFileExists(Utility.PicDefaultURL)) + { + str1 += ""; + } + } + else if (isFeatureContainsBianhao(feature)) //管线模型图层 + { + str1 = GetBubbleInfo(feature, globeControl1); + } + + 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; + } + } + } + + /// + /// 鼠标点击, 弹出气泡功能globeControl2 + /// + /// + /// + void globeControl2_FeatureMouseClickEvent(object sender, FeatureMouseClickEventArgs e) + { + GSOFeature feature = e.Feature; + + string str1 = ""; + if (feature != null) + { + if (feature.GetFieldDefn("图片编码") != null) // + { + str1 = GetBubbleInfo(feature, globeControl2); + if (RemoteFileExists(Utility.PicRootURL + feature.GetValue("图片编码").ToString())) + { + str1 += ""; + } + else if (RemoteFileExists(Utility.PicDefaultURL)) + { + str1 += ""; + } + } + else if (isFeatureContainsBianhao(feature)) //管线模型图层 + { + str1 = GetBubbleInfo(feature, globeControl2); + } + + if (str1 != "") + { + + featureTooltip2.HideBalloon(); + balloonEx2.HideBalloon(); + balloonEx2.SetSize(EnumSizeIndexEx.CONTENT_CX, 480); + balloonEx2.SetSize(EnumSizeIndexEx.CONTENT_CY, 420); + balloonEx2.ShowBalloon((int)e.MousePos.X, (int)e.MousePos.Y, str1); + + return; + } + } + } + + /// + /// 拼接气泡表格字符串 + /// + /// + /// + private string GetBubbleInfo(GSOFeature feature,GSOGlobeControl globeControl) + { + if (feature == null) + { + return ""; + } + string str = ""; + str = ""; + 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 += ""; + + 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.get_Fields(layerName, globeControl); + } + if (queryFields != null) + { + string[] param = { "," }; + string[] fieldNames = queryFields.Split(param, StringSplitOptions.RemoveEmptyEntries); + for (int j = 0; j < fieldNames.Length; 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 (name1 == "模型路径") + { + continue; + } + 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 (field1.Type == EnumFieldType.Double) + { + double dl1 = feature.GetFieldAsDouble(j); + if (!name1.Contains("管径") && !name1.Contains("电压") && !name1.Contains("角度")) + { + name1 += "_米"; + } + value1 = dl1.ToString("0.00"); + } + 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 (name2 == "模型路径") + { + continue; + } + + 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 (field2.Type == EnumFieldType.Double) + { + double dl2 = feature.GetFieldAsDouble(j + 1); + if (!name2.Contains("管径") && !name2.Contains("电压") && !name2.Contains("角度")) + { + name2 += "_米"; + } + value2 = dl2.ToString("0.00"); + } + else + { + if (!feature.IsFieldValueNull(j + 1)) + { + value2 = feature.GetValue(j + 1).ToString(); + } + } + } + } + + j++; + } + str += ""; + } + } + str += "
" + title + " " + feature.GetFieldAsString(featureIDFieldName) + "
" + + name1 + + "
" + + value1 + + "
" + + name2 + + "
" + + value2 + "
"; + return str; + } + + string filename = Utility.filename; + List g1layername = new List(); + + /// + /// 获取目标图层 + /// + /// + 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; + } + /// + /// 添加图层 + /// + /// + /// + /// + 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 = 5000; + return templayer.Visible; + } + catch (Exception ex) + { + return false; + } + } + /// + /// 菜单上的 三维导航 工具按钮 + /// + /// + /// + private void buttonItem86_Click(object sender, EventArgs e) + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + } + + /// + /// 地上模式 菜单按钮 + /// + /// + /// + 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(); + + } + } + /// + /// 地下模式 菜单按钮 + /// + /// + /// + 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(); + } + } + /// + /// 行走模式 菜单按钮 + /// + /// + /// + 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; + } + } + /// + /// 地面透明度设置 菜单 + /// + /// + /// + private void sliderGroundTransSet1_ValueChanged(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.sliderGroundTransSet1.Text); + + globeControl1.Globe.GroundOpaque = 100 - sliderGroundTransSet1.Value; + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(roadLayerName);//("180fd"); + if (layer != null) + { + layer.Opaque = 100 - sliderGroundTransSet1.Value; + } + //if (buttonItemSPDB.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; + } + /// + /// 图例 菜单按钮 + /// + /// + /// + 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(); + } + /// + /// 快速定位 菜单按钮 + /// + /// + /// + private void buttonItem91_Click(object sender, EventArgs e) // + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItem91.Text); + FrmFlyToPosition fly = new FrmFlyToPosition(globeControl1); + fly.Show(this); + } + /// + /// 图层管理 菜单按钮 + /// + /// + /// + 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; + + //修改图层管理与标注管理、覆土审查、水平净距分析、垂直净距分析和碰撞分析控件之间的逻辑关系 + controlContainerItem5.Visible = false; + sideBar1.Visible = false; + sideBarPanelItem4.Visible = false; + panel3.Visible = false; + sideBar1.ExpandedPanel = sideBarPanelItem3; + buttonItemBZ11.Checked = false; + + //20160624 + /* + if (sideBarPanelItem4.Visible == true) + { + sideBar1.Visible = true; + controlContainerItem5.Visible = true; + } + else + { + sideBar1.Visible = false; + } + */ + Refresh(); + + } + } + /// + /// 全屏显示 菜单按钮 + /// + /// + /// + 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; + /// + /// 全屏显示功能实现 + /// + 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(); + } + } + + /// + /// 设置窗体宽、高 + /// + /// + /// + private void SetFullScreen(int width, int height) + { + this.Width = width; + this.Height = height; + } + + /// + /// 全屏功能的快捷键F5 + /// + /// + /// + 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); + } + } + /* + /// + /// 输出地图 + /// + /// + /// + /// + 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; + } + * */ + + private Point getUpperLeftPoint(Point p1, Point p2, out int mapWidth, out int mapHeight) // + { + Rectangle rc = new Rectangle(); + + p1 = this.globeControl1.PointToScreen(p1); + p2 = this.globeControl1.PointToScreen(p2); + + int x = Screen.PrimaryScreen.Bounds.X; + int y = Screen.PrimaryScreen.Bounds.Y; + int screenWidth = SystemInformation.WorkingArea.Width; + int screenHeight = SystemInformation.WorkingArea.Height; + + if (p1.X < x) + rc.X = x; + else + rc.X = p1.X; + + if (p1.Y < y) + rc.Y = y; + else + rc.Y = p1.Y; + + p1.X = rc.Left; + p1.Y = rc.Top; + + if (p2.X > screenWidth) + p2.X = screenWidth; + else + p2.X = p2.X; + + if (p2.Y > screenHeight) + p2.Y = screenHeight; + else + p2.Y = p2.Y; + + rc.Width = p2.X - rc.X; + rc.Height = p2.Y - rc.Y; + + mapWidth = rc.Width; + mapHeight = rc.Height; + Point pt = new Point(rc.Left, rc.Top); + return pt; + } + + Image printImage; + /// + /// 打印 菜单 + /// + /// + /// + 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))); + */ + int mapWidth = 0; + int mapHeight = 0; + Point pt = getUpperLeftPoint(pt1, pt2, out mapWidth, out mapHeight); + int rightBottomX = pt.X + mapWidth; + int rightBottomY = pt.Y + mapHeight; + Image myImg = new Bitmap(mapWidth, mapHeight); + Graphics g = Graphics.FromImage(myImg); + g.CopyFromScreen(pt, new Point(0, 0), new Size(rightBottomX, rightBottomY)); + + + 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); + } + /// + /// 输出地图 菜单 + /// + /// + /// + private void btnOutputJPG_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btnOutputJPG.Text); + + //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))); + */ + int mapWidth = 0; + int mapHeight = 0; + Point pt = getUpperLeftPoint(pt1, pt2, out mapWidth, out mapHeight); + int rightBottomX = pt.X + mapWidth; + int rightBottomY = pt.Y + mapHeight; + Image myImg = new Bitmap(mapWidth, mapHeight); + Graphics g = Graphics.FromImage(myImg); + g.CopyFromScreen(pt, new Point(0, 0), new Size(rightBottomX, rightBottomY)); + + 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; + } + } + } + + /// + /// 在窗体的底部状态栏上显示 综合管线条件查询结果 + /// + /// + /// + 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 + " 条记录 | "; + } + } + + /// + /// 统计管线的里程数 + /// + /// + /// + /// + 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; + } + + /// + /// 窗体下方属性表格 右键菜单中的 “定位”菜单 + /// + /// + /// + 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); + + } + + /// + /// 表格中右键 “单个闪烁” 菜单 + /// + /// + /// + private void LightMenu_Click(object sender, EventArgs e) + { + flashflag = "single"; + timer1.Start(); + } + /// + /// 表格中右键 “全部闪烁” 菜单 + /// + /// + /// + private void AllLightMenuItem_Click(object sender, EventArgs e) + { + flashflag = "all"; + timer1.Start(); + } + + /// + /// 使用timer实现管线的闪烁效果 + /// + /// + /// + 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; + } + } + + /// + /// 绘制线 菜单 + /// + /// + /// + private void btnAddLine_Click(object sender, EventArgs e) + { + globeControl1.Globe.DestLayerFeatureAdd = globeControl1.Globe.MemoryLayer; + globeControl1.Globe.Action = EnumAction3D.DrawPolyline; + } + /// + /// 绘制面 菜单 + /// + /// + /// + private void btnAddPolygon_Click(object sender, EventArgs e) + { + globeControl1.Globe.DestLayerFeatureAdd = globeControl1.Globe.MemoryLayer; + globeControl1.Globe.Action = EnumAction3D.DrawPolygon; + } + /// + /// 图层目录树 右键菜单中的 目标图层 菜单 + /// + /// + /// + 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; + } + } + /// + /// 图层目录树 右键菜单中的 可选择 菜单 + /// + /// + /// + 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; + } + /// + /// 图层目录树 右键菜单中的 可编辑 菜单 + /// + /// + /// + 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; + } + /// + /// 图层目录树 右键菜单中的 保存 菜单 + /// + /// + /// + 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(); + } + + /// + /// 根据多边形范围统计管线的里程 + /// + /// + /// + /// 返回查询到的管线要素集合 + 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 pipeLineDis = new Dictionary(); + Dictionary workWellLen = new Dictionary(); + + + + + /// + /// 查找指定图层中在 指定范围内的feature对象集合 + /// + /// + /// + /// + 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; + } + /// + /// 清除结果 菜单 + /// + /// + /// + private void buttonItem47_Click(object sender, EventArgs e) + { + globeControl1.Globe.ClearAnalysis(); + dataGridViewX1.DataSource = null; + panelOfTable.Visible = false; + clearFeatureHighLight(); + } + /// + /// 设置菜单的选中状态 + /// + private void ActionToolMenuChecked() + { + if (globeControl1.Globe.Action != EnumAction3D.TrackPolyline) + { + buttonItemFX2_1.Checked = false; + buttonItemFX2_4.Checked = false; + buttonItemFX2_3.Checked = false; + buttonItemFX4_3.Checked = false; + } + if (globeControl1.Globe.Action != EnumAction3D.NormalHit) + { + buttonItemFX3_6.Checked = false; + // ClearConnexityAnalysis(); + + buttonItemFX3_5.Checked = false; + // ClearCloseValvesAnalysis(); + } + if (globeControl1.Globe.Action != EnumAction3D.TrackPolygon) + { + buttonItemFX4_2.Checked = false; + buttonItemFX4_1.Checked = false; + } + } + + /// + /// 主窗体关闭事件处理 + /// + /// + /// + private void MainFrm_FormClosing(object sender, FormClosingEventArgs e) + { + + if (MessageBox.Show("是否退出系统?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) + { + e.Cancel = true; + } + else { + globeControl1.Globe.MemoryLayer.SaveAs(Application.StartupPath + "/MyPlace.kml"); + } + + //saveLayerList(layerManagerNode.Nodes); + //注销id号为103的热键设定 + // UnregisterHotKey(Handle, 103); + } + + /// + /// 显示流向 功能 + /// + /// + /// + /// + 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(); + } + + FrmCloseValves frm; + + FrmBoosterValvers frmbooster = null; + + /// + /// 垂直净距分析 功能界面中的 选择图层复选框 选中状态改变事件处理 + /// + /// + /// + 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(); + } + /// + /// 水平净距分析 功能界面中的 选择图层复选框 选中状态改变事件处理 + /// + /// + /// + 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(); + } + /// + /// 垂直净距分析 功能界面中的 选择管线复选框 选中状态改变事件处理 + /// + /// + /// + private void checkBoxX1_CheckedChanged(object sender, EventArgs e) + { + clearFeatureHighLight(); + if (checkBoxX1.Checked) + { + comboBoxEx1.SelectedItem = null; + 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; + } + } + /// + /// 水平净距分析 功能界面中的 选择管线复选框 选中状态改变事件处理 + /// + /// + /// + private void checkBoxX1_CheckedChanged_shuiping(object sender, EventArgs e) + { + clearFeatureHighLight();//清除高亮 + if (checkBoxX7.Checked) + { + comboBoxEx4.SelectedItem = null; + 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(); + /// + /// 垂直净距分析 功能界面中的 选择图层下拉框 选中项改变 事件处理 + /// + /// + /// + 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; + } + } + } + /// + /// 水平净距分析 功能界面中的 选择图层下拉框 选中项改变 事件处理 + /// + /// + /// + 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 featCount = new Dictionary(); + Dictionary featLenth = new Dictionary(); + Dictionary m_FeaturesWithBianhao = new Dictionary();//记录编号和对应的标注点的位置 + GSOFeatures polygonJingJuAnalysises = new GSOFeatures(); + + /// + /// 垂直净距分析 功能界面中的 开始分析按钮 事件处理 + /// + /// + /// + 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; + } + + /// + /// 在指定的两点组成的线的中间添加一个marker对象,并将marker对象添加到指定的图层中 + /// + /// + /// + /// + /// + /// + 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; + } + + /// + /// 计算指定feature对象与除了该feature所在图层之外的 所有管线图层中的所有feature对象 的垂直距离 并在表格中记录符合要求的管线 + /// + /// + /// + /// + /// + private void VerticalDistanceAnalysis(string type, GSOFeature selectedFeature, List _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(); + } + /// + /// 垂直净距分析中 表格行的 双击定位 功能。 与覆土分析的实现方法不同,主要原因是需要标注垂距 + /// + /// + /// + 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); + } + } + } + } + + /// + /// 水平净距分析 功能界面中 开始分析按钮 的事件处理 + /// + /// + /// + 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; + } + + + /// + /// 计算指定feature对象与除了该feature所在图层之外的 所有管线图层中的所有feature对象 的水平距离 并记录符合要求的管线 功能 + /// + /// + /// + /// + /// + private void HorizontalDistanceAnalysis(GSOFeature selectedFeature, List _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)); + } + } + } + } + } + /// + /// 水平净距分析 功能界面中 表格的 双击定位 功能 + /// + /// + /// + 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); + } + } + } + } + } + /// + /// 碰撞分析 功能界面中 开始分析按钮 事件处理 + /// + /// + /// + 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; + } + /// + /// 碰撞分析功能界面中 表格的 双击定位 功能 + /// + /// + /// + 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); + } + } + } + } + + + + /// + /// 覆土分析功能操作界面中的 选择管线 复选框选中状态改变事件处理 + /// + /// + /// + private void checkBoxX5_CheckedChanged(object sender, EventArgs e) + { + clearFeatureHighLight(); + if (checkBoxX5.Checked) + { + comboBoxEx3.SelectedItem = null; + 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; + } + } + /// + /// 覆土分析功能操作界面中的 选择图层 复选框选中状态改变事件处理 + /// + /// + /// + 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(); + } + /// + /// 覆土分析功能操作界面中的 图层下拉框选中项改变事件处理 + /// + /// + /// + 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; + } + } + } + /// + /// 覆土分析功能操作界面中的 开始分析 按钮事件处理 + /// + /// + /// + 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; + + + GSOPoint3d markerPosition = new GSOPoint3d(); + 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]; + GSOPoint3d pt = new GSOPoint3d(); + + 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"); + + pt.X = pts[m].X; + pt.Y = pts[m].Y; + pt.Z = 0; + markerPosition = LabelVerticalDistance(layerTemp, pts[m], pt, Convert.ToDouble(dataGridViewX7.Rows[idx].Cells[2].Value), true); + 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]; + GSOPoint3d pt = new GSOPoint3d(); + 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"); + + pt.X = pts[m].X; + pt.Y = pts[m].Y; + pt.Z = 0; + markerPosition = LabelVerticalDistance(layerTemp, pts[m], pt, Convert.ToDouble(dataGridViewX7.Rows[idx].Cells[2].Value), true); + + 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; + } + + /// + /// 覆土分析中 表格的 双击定位 功能 + /// + /// + /// + 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); + } + } + } + } + } + /// + /// 覆土分析功能操作界面中的 导出Excel按钮 事件处理 + /// + /// + /// + private void buttonX10_Click(object sender, EventArgs e) + { + if (dataGridViewX7.Rows.Count > 0) + { + ExportExcel("覆土分析", dataGridViewX7, null); + } + else + { + MessageBox.Show("表格内容为空!", "提示"); + } + } + /// + /// 覆土分析功能操作界面底部的 关闭 按钮事件处理 + /// + /// + /// + 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(); + layerTemp.RemoveAllFeature(); + + if (buttonItem1.Checked) + { + sideBar1.ExpandedPanel = sideBarPanelItem3; + } + else + { + sideBar1.Visible = false; + } + globeControl1.Refresh(); + + //Refresh(); + } + + + /// + /// 垂直净距分析 功能界面中 清除分析结果按钮 事件处理 + /// + /// + /// + 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(); + } + /// + /// 水平净距分析 功能界面中 清除分析结果按钮 事件处理 + /// + /// + /// + 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(); + } + + /// + /// 垂直净距分析功能界面中 关闭按钮 事件处理 + /// + /// + /// + 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(); + } + /// + /// 水平净距分析功能界面中 删除缓冲区按钮 事件处理 + /// + /// + /// + private void buttonX14_Click(object sender, EventArgs e) + { + 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(); + } + + /// + /// 导出指定DataGridView控件中的内容 + /// + /// + /// + 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(); + } + } + } + } + + /// + /// 垂直净距分析功能界面中 导出Excel按钮 事件处理 + /// + /// + /// + private void buttonX4_Click(object sender, EventArgs e) + { + if (dataGridViewX3.Rows.Count > 0) + { + ExportExcel("垂直净距分析", dataGridViewX3, listBox1); + } + else + { + MessageBox.Show("表格内容为空!", "提示"); + } + } + /// + /// 水平净距分析功能界面中 导出Excel按钮 事件处理 + /// + /// + /// + private void buttonX4_Click_shuiping(object sender, EventArgs e) + { + if (dataGridViewX9.Rows.Count > 0) + { + ExportExcel("水平净距分析", dataGridViewX9, listBox3); + } + else + { + MessageBox.Show("表格内容为空!", "提示"); + } + } + + + /// + /// 清除所有坑 菜单 + /// + /// + /// + private void buttonItem3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItem3.Text); + + globeControl1.Globe.RemoveAllPits(); + } + + //} + /// + /// 大气层 菜单 + /// + /// + /// + private void buttonItem17_Click_1(object sender, EventArgs e) + { + globeControl1.Globe.Atmosphere.Visible = !globeControl1.Globe.Atmosphere.Visible; + buttonItemSH1.Checked = globeControl1.Globe.Atmosphere.Visible; + globeControl1.Refresh(); + } + /// + /// 经纬网 菜单 + /// + /// + /// + private void buttonItem20_Click(object sender, EventArgs e) + { + globeControl1.Globe.LatLonGrid.Visible = !globeControl1.Globe.LatLonGrid.Visible; + buttonItemSH3.Checked = globeControl1.Globe.LatLonGrid.Visible; + globeControl1.Globe.Refresh(); + } + /// + /// 状态条 菜单 + /// + /// + /// + private void buttonItem21_Click_1(object sender, EventArgs e) + { + globeControl1.Globe.StatusBar.Visible = !globeControl1.Globe.StatusBar.Visible; + buttonItemSH4.Checked = globeControl1.Globe.StatusBar.Visible; + globeControl1.Globe.Refresh(); + } + + + + /// + /// 添加指定路径下的数据 功能 + /// + /// + /// + 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); + //CheckDatasetGeoReference(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; + } + return objRes; + } + /// + /// 刷新目录树 功能 + /// + 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); + } + } + /// + /// 判断图层是否包含字段列表 + /// + /// + /// + 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; + } + + /// + /// 统计指定图层在指定范围内的所有feature对象 + /// + /// + /// + /// + 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; + } + /// + /// 碰撞分析功能界面中 选择管线复选框 选中状态改变事件处理 + /// + /// + /// + private void checkBoxX3_CheckedChanged(object sender, EventArgs e) + { + clearFeatureHighLight(); + if (checkBoxX3.Checked) + { + comboBoxEx2.SelectedItem = null; + 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; + } + } + /// + /// 碰撞分析功能界面中 选择图层复选框 选中状态改变事件处理 + /// + /// + /// + 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(); + } + /// + /// 碰撞分析功能界面中 选择图层下拉框 选中项改变事件处理 + /// + /// + /// + 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; + } + } + } + /// + /// 清除所有图层中的所有feature对象的高亮状态 功能 + /// + 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); + } + } + } + } + for (int i = 0; i < globeControl2.Globe.Layers.Count; i++) + { + GSOLayer layer = globeControl2.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; + } + } + } + + if (globeControl1.Globe.Action == EnumAction3D.SelectObject) + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + //globeControl1.Globe.Action = EnumAction3D.SelectObject; + } + } + + /// + /// 碰撞分析功能界面中 清除分析结果按钮 事件处理 + /// + /// + /// + 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(); + } + /// + /// 碰撞分析功能界面中 导出Excel按钮 事件处理 + /// + /// + /// + private void buttonX6_Click(object sender, EventArgs e) + { + if (dataGridViewX5.Rows.Count > 0) + { + ExportExcel("碰撞分析", dataGridViewX5, listBox2); + } + else + { + MessageBox.Show("表格内容为空!", "提示"); + } + } + /// + /// 导出CAD 菜单 + /// + /// + /// + private void btnExportCAD_Click(object sender, EventArgs e) + { + FrmExportCADS frm = new FrmExportCADS(globeControl1, m_PipelineLayerNames); + frm.ShowDialog(); + } + + ///// + ///// 区域分析 菜单 + ///// + ///// + ///// + //private void buttonItem50_Click(object sender, EventArgs e) + //{ + // buttonItem50.Checked = !buttonItem50.Checked; + // ribbonBarQY.Visible = buttonItem50.Checked; + // ribbonBarQY.Location = new Point(0, 0); + //} + + + /// + /// 连接数据库 菜单事件处理 + /// + /// + /// + 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; + } + } + } + /// + /// 数据验证 菜单 + /// + /// + /// + private void buttonItem80_Click(object sender, EventArgs e) + { + FrmValiData frm = new FrmValiData(globeControl1); + frm.ShowDialog(); + } + /// + /// 根据指定图层创建图层节点并将节点添加到图层管理节点的子节点集合中 + /// + /// + 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; + + if (!layerManagerNode.Nodes.Contains(node)) + { + layerManagerNode.Nodes.Insert(0, node); + layerManagerNode.Expand(); + } + } + } + /// + /// 数据库备份 菜单 + /// + /// + /// + 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(); + } + } + } + + + + #region Fan 去掉 + //GSOFeature emitterFeature; // 粒子要素 + /// + /// 添加火苗 功能 + /// + /// + /// + /// + 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); + + } + /// + /// 添加喷泉 功能 + /// + /// + /// + /// + 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); + } + #endregion + + /// + /// 获取指定图层中最后一个feature对象的名称对应的整数 + /// + /// + /// + 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; + } + /// + /// 设置除指定标注图层之外的所有标注图层不可见 + /// + /// + 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; + } + } + } + } + } + + /// + /// 判断选中的对象是否为管线 + /// + /// 被选中管线 + /// 返回一根线 + 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; + } + + /// + /// 创建label要素 功能 + /// + /// 添加label要素的feature + /// feature的位置 + /// label要素名字 + /// feature名字 + /// label要素距离点的位置 + /// + 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; + } + + + + /// + /// 获取指定两点组成的线的长度 功能 + /// + /// + /// + /// + 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; + } + + /// + /// 图层节点树中 节点 右键单击事件处理 + /// + /// + /// + 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; + } + } + } + } + } + + /// + /// 标注管理、传感器管理 图层目录树的右键菜单中的 刷新列表 菜单 + /// + /// + /// + 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); + } + } + /// + /// 给指定的图层节点添加代表feature对象的子节点 + /// + /// + private void RefreshTreeNodeLayerFeatureList(TreeNode layerTreeNode) + { + layerTreeNode.Nodes.Clear(); + GSOLayer layer = (GSOLayer)layerTreeNode.Tag; + // 只将类型为内存数据集的图层列出,如果是其它类型的数据集可能数据量太大,没发显示在树控件中 + if (layer.Dataset is GSOFeatureDataset) + { + VisitFeature3Ds(layer.GetAllFeatures(), layerTreeNode); + } + } + + /// + /// 标注管理、传感器管理 图层目录树的右键菜单中的 移除所有 菜单 + /// + /// + /// + 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(); + } + } + + /// + /// 图层目录树的 节点对应的复选框选中状态改变事件处理 + /// + /// + /// + private void layerMarkerTree_AfterCheck(object sender, TreeViewEventArgs e) + { + if (e.Action != TreeViewAction.Unknown) + { + CheckTreeNode(e.Node, e.Node.Checked); + } + } + /// + /// 改变指定节点对应的复选框的选中状态 + /// + /// + /// + private void CheckTreeNode(TreeNode node, Boolean bChecked) + { + CheckChildTreeNode(node, bChecked); + globeControl1.Globe.Refresh(); + } + /// + /// 改变指定节点的子节点对应的复选框的选中状态 + /// + /// + /// + 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); + } + } + /// + /// 标注管理、传感器管理 目录树中的feature节点的右键菜单中的 删除 菜单 + /// + /// + /// + 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(); + } + } + + /// + /// 双屏对比 菜单 + /// + /// + /// + //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(); + // } + //} + /// + /// 模拟分析 菜单 + /// + /// + /// + //private void buttonItem51_Click(object sender, EventArgs e) + //{ + // buttonItem51.Checked = !buttonItem51.Checked; + // ribbonBarMN.Visible = buttonItem51.Checked; + // ribbonBarMN.Location = new Point(0, 0); + //} + + /// + /// 双屏设置 菜单 + /// + /// + /// + //private void buttonItem96_Click(object sender, EventArgs e) + //{ + // FrmLayerControl frm = new FrmLayerControl(layerTree,globeControl1,globeControl2); + // frm.Show(this); + //} + /// + /// 双屏联动 菜单 + /// + /// + /// + //private void buttonItem95_Click(object sender, EventArgs e) + //{ + // buttonItem95.Checked = !buttonItem95.Checked; + //} + ///// + /// 添加用户仓库 菜单 + /// + /// + /// + private void buttonItem108_Click(object sender, EventArgs e) + { + FrmUserRepo frm = new FrmUserRepo(-1); + frm.ShowDialog(); + } + /// + /// 用户仓库管理 菜单 + /// + /// + /// + private void buttonItem111_Click(object sender, EventArgs e) + { + FrmUserRepoMgr frm = new FrmUserRepoMgr(); + frm.ShowDialog(); + } + /// + /// 添加分系统 菜单 + /// + /// + /// + private void buttonItem112_Click(object sender, EventArgs e) + { + //FrmAPP frm = new FrmAPP(-1); + //frm.ShowDialog(); + } + /// + /// 分系统管理 菜单 + /// + /// + /// + private void buttonItem113_Click(object sender, EventArgs e) + { + //FrmAPPMgr frm = new FrmAPPMgr(); + //frm.ShowDialog(); + } + /// + /// 添加操作 菜单 + /// + /// + /// + private void buttonItem114_Click(object sender, EventArgs e) + { + FrmOper frm = new FrmOper(-1); + frm.ShowDialog(); + } + /// + /// 操作管理 菜单 + /// + /// + /// + private void buttonItem115_Click(object sender, EventArgs e) + { + FrmOperMgr frm = new FrmOperMgr(); + frm.ShowDialog(); + } + /// + /// 添加资源 菜单 + /// + /// + /// + private void buttonItem116_Click(object sender, EventArgs e) + { + FrmRESC frm = new FrmRESC(-1); + frm.ShowDialog(); + } + /// + /// 资源管理 菜单 + /// + /// + /// + private void buttonItem117_Click(object sender, EventArgs e) + { + FrmRESCMgr frm = new FrmRESCMgr(); + frm.ShowDialog(); + } + /// + /// 添加权限 菜单 + /// + /// + /// + private void buttonItem118_Click(object sender, EventArgs e) + { + FrmPerm frm = new FrmPerm(-1); + frm.ShowDialog(); + } + /// + /// 权限管理 菜单 + /// + /// + /// + private void buttonItem119_Click(object sender, EventArgs e) + { + FrmPermMgr frm = new FrmPermMgr(); + frm.ShowDialog(); + } + /// + /// 添加访问控制 菜单 + /// + /// + /// + private void buttonItem120_Click(object sender, EventArgs e) + { + FrmAccess frm = new FrmAccess(-1); + frm.ShowDialog(); + } + /// + /// 访问控制管理 菜单 + /// + /// + /// + private void buttonItem121_Click(object sender, EventArgs e) + { + FrmAccessMgr frm = new FrmAccessMgr(); + frm.ShowDialog(); + } + /// + /// 部门类型管理 菜单 + /// + /// + /// + private void buttonItem122_Click(object sender, EventArgs e) + { + FrmRegionTypeMgr frm = new FrmRegionTypeMgr(); + frm.ShowDialog(); + } + /// + /// 添加用户 菜单 + /// + /// + /// + private void buttonItem127_Click(object sender, EventArgs e) + { + FrmUserAdd frm = new FrmUserAdd(-1); + frm.ShowDialog(); + } + /// + /// 用户信息管理 菜单 + /// + /// + /// + private void buttonItem128_Click_1(object sender, EventArgs e) + { + FrmUserManager frm = new FrmUserManager(); + frm.ShowDialog(); + } + /// + /// 添加角色 菜单 + /// + /// + /// + private void 添加角色_Click(object sender, EventArgs e) + { + FrmRole frm = new FrmRole(-1); + frm.ShowDialog(); + } + /// + /// 所有角色管理 菜单 + /// + /// + /// + private void 角色管理_Click(object sender, EventArgs e) + { + FrmRoleMgr frm = new FrmRoleMgr(); + frm.ShowDialog(); + } + + /// + /// 部门角色管理 菜单 + /// + /// + /// + private void buttonItem133_Click(object sender, EventArgs e) + { + FrmRegionRoleMgr frm = new FrmRegionRoleMgr(); + frm.ShowDialog(); + } + /// + /// 部门管理 菜单 + /// + /// + /// + private void buttonItem130_Click(object sender, EventArgs e) + { + FrmRegionMgr frm = new FrmRegionMgr(); + frm.ShowDialog(); + } + + /// + /// 日志管理 菜单 + /// + /// + /// + private void buttonItem135_Click(object sender, EventArgs e) + { + FrmLogManager frm = new FrmLogManager(); + frm.ShowDialog(); + } + /// + /// 传感器信息查询 菜单 + /// + /// + /// + 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); + } + } + } + /// + /// 根据指定的图层的caption属性的值在配置文件中查找对应的数据库中的表的名称 + /// + /// 图层的caption属性的值 + /// 对应的数据库中的表的名称 + 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; + } + /// + /// 根据数据库中的表的名称 查找对应的表中的字段名称的集合 + /// + /// 数据库中的表的名称 + /// 对应的表中的字段名称的集合 + 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; + } + + /// + /// 历史曲线查询 菜单 + /// + /// + /// + 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; + /// + /// 传感器在线报警 菜单 + /// + /// + /// + 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); + } + /// + /// 传感器报警 功能中的 定时器 的触发事件处理 + /// + /// + /// + 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; + } + } + } + } + } + } + } + + + /// + /// 沿线运动 菜单 + /// + /// + /// + private void buttonItem138_Click(object sender, EventArgs e) + { + if (globeControl1.Globe.SelectedObject == null) + { + MessageBox.Show("请先选择一条线!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + return; + } + + GSOFeature lineFeature = globeControl1.Globe.SelectedObject; + if (lineFeature.Geometry == null || lineFeature.Geometry.Type != EnumGeometryType.GeoPolyline3D) + { + MessageBox.Show("请先选择一条线!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + return; + } + + OpenFileDialog dlg = new OpenFileDialog(); + dlg.Filter = "*.gcm;*.3ds|*.gcm;*.3ds|*.3ds|*.3ds|*.gcm|*.gcm"; + if (dlg.ShowDialog() == DialogResult.OK) + { + GSOGeoModel model = new GSOGeoModel(); + model.FilePath = dlg.FileName; + + GSOGeoDynamicRoute dynamicRoute = new GSOGeoDynamicRoute(); + dynamicRoute.ActorGeometry = model; + + GSORoute route = new GSORoute(); + GSOGeoPolyline3D geoline = (GSOGeoPolyline3D)lineFeature.Geometry; + for (int i = 0; i < geoline[0].Count; i++) + { + route.Add(geoline[0][i]); + } + route.CircleRoute = false; + route.Speed = 30; + route.RotateSpeed = 50; + route.AltitudeMode = geoline.AltitudeMode; + dynamicRoute.Route = route; + + GSOFeature feature = new GSOFeature(); + + dynamicRoute.Play(); + feature.Geometry = dynamicRoute; + + //GSOLabel gsoLabel = new GSOLabel(); + //gsoLabel.Text = "模型测试"; + //feature.Label = gsoLabel; + globeControl1.Globe.MinModelVisibleSize = 0; + + globeControl1.Globe.MemoryLayer.AddFeature(feature); + globeControl1.Globe.Refresh(); + } + } + /// + /// 回退 菜单 + /// + /// + /// + private void buttonItem99_Click(object sender, EventArgs e) + { + globeControl1.Globe.UnDoEdit(); + } + /// + /// 前进 菜单 + /// + /// + /// + private void buttonItem100_Click(object sender, EventArgs e) + { + globeControl1.Globe.ReDoEdit(); + } + /// + /// 水平净距 功能界面中的 标签内容改变事件处理 + /// + /// + /// + 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() + "米的管线有:"; + } + } + } + /// + /// 垂直净距 功能界面中的 标签内容改变事件处理 + /// + /// + /// + 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() + "米的管线有:"; + } + } + } + /// + /// 覆土分析 功能界面中的 标签内容改变事件处理 + /// + /// + /// + 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() + "米的管线有:"; + } + } + } + + /// + /// 传感器分类查询 全区域 菜单 + /// + /// + /// + private void buttonItemSensor全区域查询_Click(object sender, EventArgs e) + { + FrmAccessoriesSensor.ShowForm(globeControl1, instrumenLayerNames, 0); + } + /// + /// 传感器分类查询 绘制区域 菜单 + /// + /// + /// + private void buttonItemSensor绘制区域查询_Click(object sender, EventArgs e) + { + FrmAccessoriesSensor.ShowForm(globeControl1, instrumenLayerNames, 1); + } + + + /// + /// 碰撞分析 功能界面中 关闭按钮 事件处理 + /// + /// + /// + 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(); + } + /// + /// 覆土分析 功能界面中的 清除分析结果 按钮事件处理 + /// + /// + /// + 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(); + } + /// + /// 数字预处理 功能 + /// + /// + /// + private void 数字预处理buttonItem140_Click(object sender, EventArgs e) + { + FrmEditShapeFile frm = new FrmEditShapeFile(globeControl1); + frm.ShowDialog(this); + } + + + /// + /// 导出矢量 功能 将图层导出为kml和shp格式数据 + /// + /// + /// + private void 导出矢量buttonItem140_Click(object sender, EventArgs e) + { + List listVectorNames = new List(); + for (int i = 0; i < m_PipelineLayerNames.Count; i++) + { + 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 = ""; + /// + /// 绘制城市七线 功能按钮 + /// + /// + /// + 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; + } + } + } + /// + /// 七线审核 功能按钮 + /// + /// + /// + private void 七线审核buttonItem141_Click(object sender, EventArgs e) + { + FrmCityServerLineAnalysis frm = new FrmCityServerLineAnalysis(globeControl1, m_PipelineLayerNames); + frm.ShowDialog(this); + } + + /// + /// 间距分析 开始分析按钮 分析绘制的七线和管线的距离是否符合标准 + /// + /// + /// + 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; + } + /// + /// 间距分析 清除分析结果 + /// + /// + /// + 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(); + } + /// + /// 间距分析 导出Excel按钮 将间距分析的结果以Excel表格的形式导出 + /// + /// + /// + private void buttonExportExcel_Click(object sender, EventArgs e) + { + if (dataGridViewAnalysisResult.Rows.Count > 0) + { + ExportExcel("间距分析", dataGridViewAnalysisResult, listBoxStasticsResult); + } + else + { + MessageBox.Show("表格内容为空!", "提示"); + } + } + /// + /// 间距分析 关闭按钮 + /// + /// + /// + 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(); + } + /// + /// 间距分析 分析结果表格双击定位 + /// + /// + /// + 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); + } + } + } + } + /// + /// 间距分析 选择管线复选框 + /// + /// + /// + private void checkBoxSelectPipeline_CheckedChanged(object sender, EventArgs e) + { + clearFeatureHighLight();//清除高亮 + if (checkBoxSelectPipeline.Checked) + { + comboBoxLayer.SelectedItem = null; + 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; + } + } + /// + /// 间距分析 选择图层复选框 + /// + /// + /// + 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(); + } + /// + /// 间距分析 选择图层下拉框 + /// + /// + /// + 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; + } + } + } + + + + /// + /// 管线自动缩进 菜单 + /// + /// + /// + private void 管线自动缩进buttonItem140_Click(object sender, EventArgs e) + { + FrmPipelineIndented frm = new FrmPipelineIndented(globeControl1, m_PipelineLayerNames, workwellLayerNames); + 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 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); + // } + //} + + /// + /// 统计指定图层在指定范围内的所有feature对象 + /// + /// + /// + /// + 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) + { + 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 setLayerVisible(string layerName) + { + GSOLayer templayer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + if (templayer != null) + { + templayer.Visible = false; + } + globeControl1.Globe.Refresh(); + } + + /// + /// 连接数据库 + /// + /// + /// + private void buttonItem129_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL4_1.Text); + + FrmDatabaseParaSetting2 frm = new FrmDatabaseParaSetting2(globeControl1); + if (frm.ShowDialog() == DialogResult.OK) + { + ds = FrmDatabaseParaSetting2.ds; + if (ds != null) + { + ds.IsCloseSaved = false; + } + } + } + + /// + /// 一键审核---导入数据 + /// + /// + /// + private void buttonItem127_Click_2(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, "打开数据"); + + try + { + //if (shds == null) + //{ + //没连的话,直接连接审核库; //审核库配置读配置文件 + string dbIp = Utility.sgdbip; + string database = Utility.sgdbname; + string user = Utility.sgdbuser; + string pass = Utility.sgdbpwd; + /* + 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; + //} + } + catch (Exception ex) + { + LogError.PublishError(ex); + MessageBox.Show("内存过载请清理内存,并重新启动规划分析!", "提示"); + return; + } + + } + + /// + ///自动导出图片 + /// + /// + /// + private void buttonItem130_Click_1(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, "导出审核图"); + + 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))); + */ + + int mapWidth = 0; + int mapHeight = 0; + Point pt = getUpperLeftPoint(pt1, pt2, out mapWidth, out mapHeight); + int rightBottomX = pt.X + mapWidth; + int rightBottomY = pt.Y + mapHeight; + Image myImg = new Bitmap(mapWidth, mapHeight); + Graphics g = Graphics.FromImage(myImg); + g.CopyFromScreen(pt, new Point(0, 0), new Size(rightBottomX, rightBottomY)); + + 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; + } + } + } + /// + /// 一键审核功能 + ///
+ /// + /// + private void buttonItem128_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItem128.Text); + //垂直净距标准 + + frmSh = new FrmYJSHTC(globeControl1, globeControl2,layerTree); + + if (frmSh.ShowDialog() == DialogResult.OK) + { + frmWait = new FrmWait("一键审核……"); + frmWait.Location = new Point(this.Width - frmWait.Width - 10, this.Height - frmWait.Height - 50); + frmWait.Owner = this; + frmWait.Show(); + Thread thread = new Thread(new ThreadStart(doWork)); + thread.IsBackground = true; + thread.Start(); + } + } + + void doWork() + { + FrmShResult frmShResult = null; + + double dVerticalJingJuBiaoZhun = 1, dHorizontalJingJuBiaoZhun = 1; + if (frmSh.rukuLayer != null) + { + #region + this.Invoke((EventHandler)delegate + { + try + { + List managerLayerList = new List(); + for (int i = 0; i < layerManagerNode.Nodes.Count; i++) + { + managerLayerList.Add(layerManagerNode.Nodes[i].Text); + } + if (!managerLayerList.Contains(frmSh.rukuLayer.Caption)) + { + TreeNode node = new TreeNode(); + node.Tag = frmSh.rukuLayer; + node.Text = frmSh.rukuLayer.Dataset.Caption; + node.ImageIndex = 0; + node.SelectedImageIndex = 0; + node.Checked = frmSh.rukuLayer.Visible; + layerManagerNode.Nodes.Insert(0, node); + layerManagerNode.Expand(); + } + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "提示"); + } + }); + #endregion + + shlayername = frmSh.rukuLayer.Name; + globeControl1.Refresh(); + } + + if (frmShResult != null && !frmShResult.IsDisposed) + { + try + { + clearFeatureHighLight(); + ClearRedlineAnalyseResult(); + frmShResult.Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message); + } + } + + 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.analysis(); + + //MainFrm窗体显示控制,回到一键审核Tab + this.Invoke((EventHandler)delegate + { + frmShResult.Show(); + frmWait.Close(); + //将tab页恢复到一键审核 + ribbonTabItem11.Checked = true; + try + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + //zhanshi = false; + splitContainer1.Panel2Collapsed = true; + + panelOfTable.Visible = false; + legendSC.Visible = false; + legendSG.Visible = false; + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + } + catch (Exception ex) + { + MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + + }); + + boolfrmShResult = true; + } + else + { + + } + } + + + /// + /// 清除渲染结果 + /// + 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(); + } + /// + /// 已审核的图层 + /// + /// + /// + private void buttonItem132_Click_1(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItem132.Text); + + if (shds == null) + { + //没连的话,直接连接审核库; //审核库配置读配置文件 + string dbIp = Utility.sgdbip; + string database = Utility.sgdbname; + string user = Utility.sgdbuser; + string pass = Utility.sgdbpwd; + + /* + 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; + //} + + } + /// + /// 审核入库 + /// + /// + /// + private void buttonItem133_Click_1(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, "审核入库"); + FrmShRK frmShrk = new FrmShRK(globeControl1); + frmShrk.Show(); + } + /// + /// 模拟设计修改 + /// + /// + /// + private void buttonItem134_Click_1(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, "模拟设计修改"); + + 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 + { + + } + + } + + + /// + /// 绘制垂线 + /// + /// + /// + 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); + } + /// + /// 比较两个点是否是同一个点 + /// + /// + /// + /// + 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; + } + /// + /// 获得点到线的垂线距离及垂点 + /// + /// + /// + /// + /// + 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); + 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]; + } + /// + /// 获得斜率 + /// + /// + /// + /// + /// + /// + /// + 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); + } + } + /// + /// 根据默认投影参数,经纬度转xyz + /// + /// + /// + /// + 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; + } + /// + /// 根据投影参数,经纬度转xyz + /// + /// + /// + /// + /// + 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; + } + /// + /// 根据默认投影参数,xyz转经纬度 + /// + /// + /// + /// + 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; + } + /// + /// 根据投影参数,Xyz转经纬度 + /// + /// + /// + /// + /// + 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; + } + /// + /// 获得inpolygon的管线长度 + /// + /// + 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; + } + + + /// + /// 一键审核中调节透明度 + /// + /// + /// + private void sliderItem1_ValueChanged(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.sliderItem1.Text); + + globeControl1.Globe.GroundOpaque = 100 - sliderItem1.Value; + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(roadLayerName);//("180fd"); + if (layer != null) + { + layer.Opaque = 100 - sliderItem1.Value; + } + + optiValue = sliderItem1.Value; + } + /// + /// 红线审核中的透明度分析 + /// + /// + /// + private void sliderItem3_ValueChanged(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.sliderItem3.Text); + + globeControl1.Globe.GroundOpaque = 100 - sliderItem3.Value; + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(roadLayerName);//("180fd"); + if (layer != null) + { + layer.Opaque = 100 - sliderItem3.Value; + } + optiValue = sliderItem3.Value; + } + + #region yanxiaowei + //初始化DataGridViewX1控件 + public delegate void DataGridViewDelegate(DataTable dt, string strLable, string strLayer, bool initDataGrid); + /// + /// 代理函数,操作DatgridViewX1 + /// + /// + /// + public void InitDataGridViewX1(DataTable dt, string strLable, string strLayer, bool initDataGrid) + { + if (initDataGrid == true) + { + dataGridViewX1.DataSource = dt; + panelOfTable.Visible = true; + toolStripNumbers.Text = strLable; + dataGridViewX1.Tag = strLayer; + } + else + { + dataGridViewX1.DataSource = null; + dataGridViewX1.Refresh(); + panelOfTable.Visible = false; + toolStripNumbers.Text = ""; + dataGridViewX1.Tag = ""; + globeControl1.Globe.MemoryLayer.RemoveAllFeature();//清除双击产生的标注 + } + } + FrmAnalysisGuiHuaResult from; + /// + /// 主窗体下方属性表格 双击定位 功能 + /// + /// + /// + private void dataGridViewX1_MouseDoubleClick(object sender, MouseEventArgs e) + { + if (redSH == false) + { + 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 if (dataGridViewX1.Columns.Contains("标识器编号")) + { + featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["标识器编号"].Value.ToString(); + } + featureName = featureName.Trim(); + + GSOLayer layer = null; + layer = globeControl1.Globe.Layers.GetLayerByCaption(dataGridViewX1.Tag.ToString()); + + if (layer == null) return; + + GSOFeatures features = layer.GetFeatureByName(featureName, false); + if (features.Length == 0) return; + GSOFeature rowFeature = features[0]; + + ClassSearchAnalysis.AddMakerToLineFeature(globeControl1, rowFeature); + + } + } + } + else + { + if (e.Button == MouseButtons.Left) + { + if (from != null && !from.IsDisposed) + { + try + { + from.Close(); + } + catch (Exception ex) + { + LogError.PublishError(ex); + } + } + try + { + DataGridView.HitTestInfo hittestinfo = dataGridViewX1.HitTest(e.X, e.Y); + if (hittestinfo.RowIndex >= 0) + { + string layer = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["管线类型"].Value.ToString(); + string hxName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["红线编号"].Value.ToString(); + FrmAnalysisGuiHuaResult frm = new FrmAnalysisGuiHuaResult(globeControl1, lineStruct, featsList, + panelOfTable, dataGridViewX1, layer, hxName); + frm.Location = new Point(this.Width - frm.Width - 10, this.Height - frm.Height - 20); + frm.Show(this); + + from = frm; + } + } + catch (Exception ex) + { + LogError.PublishError(ex); + } + } + } + } + + /// + /// 空间查询 + /// + /// + /// + private void buttonItemSearch1_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemSearch1.Text); + + trackflag = "PipelineSpatialQuery"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; + + } + /// + /// 关键字查询 + /// + /// + /// + private void buttonItemSearch9_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch9.Text); + + FrmKeywordQuery.ShowForm(globeControl1, m_PipelineLayerNames, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 编号查询 + /// + /// + /// + private void buttonItemSearch2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch2.Text); + + FrmCodingQuery.ShowForm(globeControl1, m_PipelineLayerNames, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 坐标查询 + /// + /// + /// + private void buttonItemSearch3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch3.Text); + + FrmSetLatLonPos.ShowForm(globeControl1); + } + /// + /// 附属物查询 + /// + /// + /// + private void buttonItemSearch10_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch10.Text); + + FrmFittingQuery.ShowForm(globeControl1, instrumenLayerNames, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 管径查询 + /// + /// + /// + private void buttonItemSearch4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch4.Text); + + FrmDiameterQuery.ShowForm(globeControl1, m_PipelineLayerNames, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 材质查询 + /// + /// + /// + private void buttonItemSearch5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch5.Text); + + FrmMaterialSel.ShowForm(globeControl1, m_PipelineLayerNames, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 基本查询 + /// + /// + /// + private void buttonItemSearch6_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch6.Text); + + FrmBasicQuery.ShowForm(globeControl1, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 复合查询 + /// + /// + /// + private void buttonItemSearch7_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch7.Text); + + FrmQuerySQL.ShowForm(globeControl1, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 关联查询 + /// + /// + /// + private void buttonItemSearch8_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch8.Text); + + if (globeControl1.Globe.SelObjectCount != 1) + { + MessageBox.Show("请选中一个对象!", "提示"); + return; + } + + 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 || (feature.Geometry.Type == EnumGeometryType.GeoPolygon3D + || feature.Geometry.Type == EnumGeometryType.GeoWater)) + return; + else + { + ClassSearchAnalysis.ResultRelationAnalysis(globeControl1, feature, valueLayerNames, workwellLayerNames, + instrumenLayerNames, pipefittingLayerNames, m_PipelineLayerNames, valueAllowance); + } + } + } + #endregion + /// + /// 清除分析 + /// + /// + /// + private void buttonItemClear_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemClear.Text); + + globeControl1.Globe.ClearMeasure(); + layerTemp.RemoveAllFeature(); + layerTemp2.RemoveAllFeature(); + buttonItemLS5.Checked = false; + + dataGridViewX1.DataSource = null; + panelOfTable.Visible = false; + + 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); + + NetworkAnalysisTool.ClearAllTopAnalysis(this.globeControl1); + // 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();//清除所有坑 + + 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(); + } + } + + clearFeatureHighLight();//取消管线高亮 + + GSOLayer layerGround = globeControl1.Globe.Layers.GetLayerByCaption(roadLayerName);//("180fd"); + if (layerGround != null) + { + layerGround.Visible = true; + } + globeControl1.Refresh(); + globeControl2.Refresh(); + ClearRedlineAnalyseResult(); + globeControl1.Globe.Action = EnumAction3D.ActionNull; + } + /// + /// 管线长度全区域统计 + /// + /// + /// + private void buttonItemTJ1_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管线长度统计"); + + //pipeLineDis.Clear(); + //List list = new List(); + //for (int i = 0; i < m_PipelineLayerNames.Count; i++) + //{ + // GSOFeatures fs = Intersects_Pipeline(null, m_PipelineLayerNames[i]); + // if (fs!=null) + // list.Add(fs); + //} + + //FrmAllPipelineStatis frm = new FrmAllPipelineStatis(0, pipeLineDis, list, globeControl1, new DataGridViewDelegate(InitDataGridViewX1)); + FrmAllPipelineStatis frm = new FrmAllPipelineStatis(globeControl1,null, new DataGridViewDelegate(InitDataGridViewX1), m_PipelineLayerNames); + frm.Show(this); + + } + /// + /// 管线长度绘制区域统计 + /// + /// + /// + private void buttonItemTJ1_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管线长度统计"); + + trackflag = "PipelineDistanceStatistics"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; + } + /// + /// 阀门数量全区域统计 + /// + /// + /// + private void buttonItemTJ2_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "阀门数量统计"); + + //workWellLen.Clear(); + //List list = new List(); + ////找到所有阀门 + //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, globeControl1, new DataGridViewDelegate(InitDataGridViewX1)); + FrmValveStatistics frm = new FrmValveStatistics(globeControl1, null, new DataGridViewDelegate(InitDataGridViewX1)); + frm.Show(this); + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + } + /// + /// 阀门数量绘制区域统计 + /// + /// + /// + private void buttonItemTJ2_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "阀门数量统计"); + + trackflag = "valvequery"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; + } + /// + /// 井盖数量全区域统计 + /// + /// + /// + private void buttonItemTJ3_ALL_Click(object sender, EventArgs e) + { + //日志记录 + //LogManager.saveLog(Utility.userName, "井盖数量统计"); + + //workWellLen.Clear(); + //List list = new List(); + + //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(null, dataGridViewX1, toolStripNumbers, globeControl1, panelOfTable); + FrmAllWorkWellStatis frm = new FrmAllWorkWellStatis(globeControl1, null, new DataGridViewDelegate(InitDataGridViewX1)); + frm.Show(this); + } + /// + /// 井盖数量绘制区域统计 + /// + /// + /// + private void buttonItemTJ3_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "井盖数量统计"); + + trackflag = "workwellquery"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; + } + /// + /// 管径分段统计全区域统计 + /// + /// + /// + private void buttonItemTJ4_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管径分段统计"); + + Frmpipediameterstatis.ShowForm(globeControl1, m_PipelineLayerNames, 0); + } + /// + /// 管径分段统计绘制区域统计 + /// + /// + /// + private void buttonItemTJ4_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管径分段统计"); + + trackflag = null; + Frmpipediameterstatis.ShowForm(globeControl1, m_PipelineLayerNames, 1); + } + /// + /// 埋深分段统计全区域统计 + /// + /// + /// + private void buttonItemTJ5_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "埋深分段统计"); + FrmpipeDeepstatis.ShowForm(globeControl1, m_PipelineLayerNames, 0); + } + /// + /// 埋深分段统计绘制区域统计 + /// + /// + /// + private void buttonItemTJ5_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "埋深分段统计"); + trackflag = null; + FrmpipeDeepstatis.ShowForm(globeControl1, m_PipelineLayerNames, 1); + } + /// + /// 管径分类统计全区域统计 + /// + /// + /// + private void buttonItemTJ6_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管径分类汇总"); + + FrmpipeDiametergather.ShowForm(globeControl1, m_PipelineLayerNames, 0); + } + /// + /// 管径分类统计绘制区域统计 + /// + /// + /// + private void buttonItemTJ6_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管径分类汇总"); + + trackflag = null; + FrmpipeDiametergather.ShowForm(globeControl1, m_PipelineLayerNames, 1); + } + /// + /// 材质分类统计全区域统计 + /// + /// + /// + private void buttonItemTJ7_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "材质分类汇总"); + + FrmpipeMaterialGather.ShowForm(globeControl1, m_PipelineLayerNames, 0); + } + /// + /// 材质分类统计绘制区域统计 + /// + /// + /// + private void buttonItemTJ7_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "材质分类汇总"); + + trackflag = null; + FrmpipeMaterialGather.ShowForm(globeControl1, m_PipelineLayerNames, 1); + } + /// + /// 附属物分类统计全区域统计 + /// + /// + /// + private void buttonItemTJ8_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "附属物分类汇总"); + + FrmAccessoriesgather.ShowForm(globeControl1, instrumenLayerNames, 0); + } + /// + /// 附属物分类统计绘制区域统计 + /// + /// + /// + private void buttonItemTJ8_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "附属物分类汇总"); + + trackflag = null; + FrmAccessoriesgather.ShowForm(globeControl1, instrumenLayerNames, 1); + } + /// + /// 碰撞分析 + /// + /// + /// + private void buttonItemFX1_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_4.Text); + + this.dataGridViewX4.Size = new System.Drawing.Size(195, 120); + 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(); + } + /// + /// 覆土分析 + /// + /// + /// + private void buttonItemFX1_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX5_1.Text); + this.dataGridViewX6.Size = new System.Drawing.Size(195, 120); + 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(); + } + /// + /// 间距分析 + /// + /// + /// + private void buttonItemFX1_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX1_3.Text); + + this.dataGridViewLineList.Size = new System.Drawing.Size(185, 120); + 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(); + } + /// + /// 垂直净距分析 + /// + /// + /// + private void buttonItemFX1_4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX1_4.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(); + } + /// + /// 水平净距分析 + /// + /// + /// + private void buttonItemFX1_5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_6.Text); + this.dataGridViewX8.Size = new System.Drawing.Size(185, 120); + 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(); + } + + #region Predaotr,断面分析 + /// + /// 横断面分析 + /// + /// + /// + private void buttonItemFX2_1_Click(object sender, EventArgs e) + { + globeControl1.Globe.Action = EnumAction3D.TrackPolyline; + globeControl1.Globe.TrackPolylineTool.VerticalLineVisible = true; + globeControl1.Globe.TrackPolylineTool.TrackMode = EnumTrackMode.SpaceTrack; + trackPolylineEndMode = EnumTrackPolylineEndMode.HDM_Analysis; + + } + /// + /// 纵断面分析 + /// + /// + /// + private void buttonItemFX2_2_Click(object sender, EventArgs e) + { + if (globeControl1.Globe.SelObjectCount<1) + { + MessageBox.Show("请选择一条或者多条管线!", "提示", MessageBoxButtons.OK, + MessageBoxIcon.Information); + return; + } + 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); + } + } + List feats = SectionAnalysisTool.ZDMAnalysis(selectFeatures); + if (feats != null && feats.Count >= 1) + { + FrmProfileAnalysis frm = new FrmProfileAnalysis(globeControl1, feats); + frm.Show(this); + } + } + /// + /// 道路断面分析 + /// + /// + /// + private void buttonItemFX2_3_Click(object sender, EventArgs e) + { + globeControl1.Globe.Action = EnumAction3D.TrackPolyline; + globeControl1.Globe.TrackPolylineTool.VerticalLineVisible = true; + globeControl1.Globe.TrackPolylineTool.TrackMode = EnumTrackMode.SpaceTrack; + trackPolylineEndMode = EnumTrackPolylineEndMode.DLDM_Analysis; + + } + /// + /// 基线剖面分析 + /// + /// + /// + private void buttonItemFX2_4_Click(object sender, EventArgs e) + { + globeControl1.Globe.Action = EnumAction3D.TrackPolyline; + globeControl1.Globe.TrackPolylineTool.VerticalLineVisible = true; + globeControl1.Globe.TrackPolylineTool.TrackMode = EnumTrackMode.SpaceTrack; + trackPolylineEndMode = EnumTrackPolylineEndMode.JXPM_Analysis; + + } + + #endregion + /// + /// 创建拓扑 + /// + /// + /// + private void buttonItemFX3_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX3_1.Text); + + FrmGenAndFaMenTopu frm = new FrmGenAndFaMenTopu(globeControl1, m_PipelineLayerNames, valueLayerNames); + frm.Show(this); + } + #region Predator :拓扑分析 + /// + /// 上游分析 + /// + /// + /// + private void buttonItemFX3_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX3_2.Text); + NetworkTraceUpDown(true); + } + /// + /// 下游分析 + /// + /// + /// + private void buttonItemFX3_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX3_3.Text); + NetworkTraceUpDown(false); + } + + /// + /// 上下游追踪 功能 + /// + /// + private void NetworkTraceUpDown(Boolean bTraceUp) + { + GSOFeature selLineFeature = globeControl1.Globe.SelectedObject; + if (selLineFeature == null || selLineFeature.Geometry == null || selLineFeature.Geometry.Type != EnumGeometryType.GeoPolyline3D) + { + MessageBox.Show("请点击“编辑”—“选中对象”选择一条线!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); + return; + } + GSOLayer selLayer = globeControl1.Globe.SelectedObjectLayer; + + NetworkAnalysisTool.TraceUpDownAnalysis(bTraceUp, + selLineFeature, selLayer); + } + + /// + /// 流向分析 + /// + /// + /// + private void buttonItemFX3_4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX3_4.Text); + + FrmFlow frm = new FrmFlow(globeControl1, m_PipelineLayerNames); + frm.Show(this); + } + /// + /// 关阀分析 + /// + /// + /// + private void buttonItemFX3_5_Click(object sender, EventArgs e) + { + if (globeControl1.Globe.SelObjectCount < 1) + { + MessageBox.Show("请选中至少一根管线!!"); + buttonItemFX3_5.Checked = false; + return; + } + GSOLayer resLayer = null; + GSOFeature resFeature = null; + globeControl1.Globe.GetSelectObject(0, out resFeature, out resLayer); + + String pipeLayerName = resLayer.Caption; + String pipeLayerNamePrefix = pipeLayerName.Substring(0, pipeLayerName.IndexOf("管线")); + GSOLayer valveLayer = globeControl1.Globe.Layers[pipeLayerNamePrefix + "阀门"]; + if (valveLayer == null) + { + MessageBox.Show("无" + pipeLayerNamePrefix+"阀门图层", "提示"); + return; + } + + GSOFeatures valveFeats = NetworkAnalysisTool.CloseValvesAnalysis(resFeature, + resLayer, valveLayer); + + if (valveFeats != null) + { + FrmCloseValves frm = new FrmCloseValves(this.globeControl1, valveFeats); + frm.Show(this); + } + else + { + MessageBox.Show("未找到关闭阀门"); + } + } + + /// + /// 连通分析 + /// + /// + /// + private void buttonItemFX3_6_Click(object sender, EventArgs e) + { + if (globeControl1.Globe.SelObjectCount < 2) + { + MessageBox.Show("请选中至少两个管线!!"); + buttonItemFX3_6.Checked = false; + return; + } + GSOFeature selFeat0, selFeat1; + GSOLayer layer0,layer1; + globeControl1.Globe.GetSelectObject(0, out selFeat0, out layer0); + globeControl1.Globe.GetSelectObject(1, out selFeat1, out layer1); + + if (!layer0.IsSameInnerObject(layer1)) + { + MessageBox.Show("不在同一个图层!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); + buttonItemFX3_6.Checked = false; + return; + } + NetworkAnalysisTool.ConnexityAnalysis(selFeat0, selFeat1, layer0); + } + /// + /// 爆管分析 + /// + /// + /// + private void buttonItemFX3_7_Click(object sender, EventArgs e) + { + NetworkTraceUpDown(true); //上游追踪: + + GSOFeature selLineFeature = globeControl1.Globe.SelectedObject; + if (selLineFeature == null || selLineFeature.Geometry == null || selLineFeature.Geometry.Type != EnumGeometryType.GeoPolyline3D) + { + MessageBox.Show("请点击“编辑”—“选中对象”选择一条线!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); + return; + } + GSOLayer selLayer = globeControl1.Globe.SelectedObjectLayer; + + NetworkAnalysisTool.ExplodeAnalysis(this.globeControl1,selLineFeature,selLayer); + + this.buttonItemFX3_5_Click(sender, e); //关阀分析: + + } + + #endregion + /// + /// 多边形开挖 + /// + /// + /// + private void buttonItemFX4_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_1.Text); + + trackflag = "pit"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; //是这个么?是的,在模型上 + } + /// + /// 挖方量分析 + /// + /// + /// + private void buttonItemFX4_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_2.Text); + + trackflag = "digFillAnalysis"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; + ActionToolMenuChecked(); + } + /// + /// 沿线开挖 + /// + /// + /// + private void buttonItemFX4_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_3.Text); + + if (!buttonItemFX4_3.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; + buttonItemFX4_3.Checked = true; + } + } + else + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + buttonItemFX4_3.Checked = false; + globeControl1.Globe.TrackPolylineTool.VerticalLineVisible = false; + } + ActionToolMenuChecked(); + } + /// + /// 创建隧道 + /// + /// + /// + private void buttonItemFX4_4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_4.Text); + + 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("场景中未加载隧道图层!", "提示"); + } + } + /// + /// 隐藏隧道 + /// + /// + /// + private void buttonItemFX4_5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_5.Text); + + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption("隧道"); + if (layer != null) + { + layer.Visible = !layer.Visible; + } + } + /// + /// 删除隧道 + /// + /// + /// + private void buttonItemFX4_6_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_6.Text); + + 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("请选中要删除的隧道!", "提示"); + } + } + /// + /// 通视分析 + /// + /// + /// + private void buttonItemFX5_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX5_1.Text); + + if (globeControl1.Globe.Action != EnumAction3D.VisibilityAnalysis) + { + //btnSpaceVisibilityAnalysis.Checked = true; + globeControl1.Globe.Action = EnumAction3D.VisibilityAnalysis; + } + else + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + // SetButtonChecked(); + } + } + /// + /// 可视域分析 + /// + /// + /// + private void buttonItemFX5_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX5_2.Text); + + globeControl1.Globe.Action = EnumAction3D.ViewshedAnalysis; + } + /// + /// 可视包络分析 + /// + /// + /// + private void buttonItemFX5_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX5_3.Text); + + globeControl1.Globe.Action = EnumAction3D.ViewEnvelopeAnalysis; + } + /// + /// 缓冲区分析 + /// + /// + /// + private void buttonItemFX6_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX6_1.Text); + + GSOFeature feat = globeControl1.Globe.SelectedObject; + if (feat == null) + { + MessageBox.Show("请选择要分析的要素!"); + return; + } + if (feat.Geometry.Type == EnumGeometryType.GeoPolyline3D) + { + GSOGeoPolyline3D line1 = feat.Geometry as GSOGeoPolyline3D; + if (line1 == null) + { + MessageBox.Show("请选择一条管线!"); + return; + } + + FrmBufferAnalysis frm = new FrmBufferAnalysis(globeControl1, line1, layerTemp); + frm.Show(this); + } + else + { + FrmBufferAnalysisBSQ frm = new FrmBufferAnalysisBSQ(globeControl1, layerTemp, bsqPT); + frm.Show(this); + } + + } + /// + /// 附属物分析 + /// + /// + /// + private void buttonItemFX6_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX6_2.Text); + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + FrmAccessoryAnalysis dlg = new FrmAccessoryAnalysis(globeControl1, layerTemp); + dlg.Show(this); + } + /// + /// 无源淹没分析 + /// + /// + /// + private void buttonItemFX6_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX6_3.Text); + + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + trackflag = "FloodAnalysis"; + } + /// + /// 水平距离 + /// + /// + /// + private void buttonItemLS1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS1.Text); + + globeControl1.Globe.Action = EnumAction3D.MeasureDistance; + globeControl1.Globe.DistanceRuler.SpaceMeasure = false; + buttonItemLS5.Checked = false; + } + /// + /// 垂直距离 + /// + /// + /// + private void buttonItemLS2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS2.Text); + + buttonItemLS5.Checked = false; + globeControl1.Globe.Action = EnumAction3D.MeasureHeight; + globeControl1.Globe.DistanceRuler.SpaceMeasure = false; + } + /// + /// 空间距离 + /// + /// + /// + private void buttonItemLS3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS3.Text); + + buttonItemLS5.Checked = false; + globeControl1.Globe.Action = EnumAction3D.MeasureDistance; + globeControl1.Globe.DistanceRuler.SpaceMeasure = true; + } + /// + /// 地表距离 + /// + /// + /// + private void buttonItemLS4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS4.Text); + + buttonItemLS5.Checked = false; + globeControl1.Globe.Action = EnumAction3D.MeasureDistance; + globeControl1.Globe.DistanceRuler.SpaceMeasure = false; + } + /// + /// 高度量算 + /// + /// + /// + private void buttonItemLS5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS5.Text); + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + buttonItemLS5.Checked = !buttonItemLS5.Checked; + if (buttonItemLS5.Checked) + { + globeControl1.Globe.Action = EnumAction3D.SelectObject; + } + } + /// + /// 水平面积 + /// + /// + /// + private void buttonItemLS6_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS6.Text); + + buttonItemLS5.Checked = false; + globeControl1.Globe.Action = EnumAction3D.MeasureArea; + globeControl1.Globe.AreaRuler.SpaceMeasure = true; + } + /// + /// 地表面积 + /// + /// + /// + private void buttonItemLS7_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS7.Text); + + buttonItemLS5.Checked = false; + globeControl1.Globe.Action = EnumAction3D.MeasureArea; + globeControl1.Globe.AreaRuler.SpaceMeasure = false; + + } + + # region Fan 重构标注代码 + /// + /// 标高标注 + /// + /// + /// + private void buttonItemSZ1_Click(object sender, EventArgs e) + { + GSOFeature resFeature = IsPipeLineOfSelectedObj(); + if (resFeature == null) + { + MessageBox.Show("请选中一根管线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + GSOGeoPolyline3D selLine = resFeature.Geometry as GSOGeoPolyline3D; + if (selLine[0].Count <= 1) + { + return; + } + + MarkTools.getInstance().showMarker(resFeature, + globeControl1, EnumMarkLayer.Mark_Altitude, ""); + } + /// + /// 管径标注 + /// + GSOFeature radiusMarkerFeature; + private void buttonItemBZ2_Click(object sender, EventArgs e) + { + GSOFeature resFeature = IsPipeLineOfSelectedObj(); + if (resFeature == null) + { + MessageBox.Show("请选中一根管线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + GSOGeoPolyline3D selLine = resFeature.Geometry as GSOGeoPolyline3D; + if (selLine[0].Count <= 1) + { + return; + } + + MarkTools.getInstance().showMarker(resFeature, + globeControl1, EnumMarkLayer.Mark_Diameter, ""); + } + /// + /// 埋深标注 + /// + /// + /// + private void buttonItemBZ3_Click(object sender, EventArgs e) + { + GSOFeature resFeature = IsPipeLineOfSelectedObj(); + if (resFeature == null) + { + MessageBox.Show("请选中一根管线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + GSOGeoPolyline3D selLine = resFeature.Geometry as GSOGeoPolyline3D; + if (selLine[0].Count <=1) + { + return; + } + + MarkTools.getInstance().showMarker(resFeature, + globeControl1, EnumMarkLayer.Mark_Depth, ""); + + } + /// + /// 坐标标注 + /// + /// + /// + private void buttonItemBZ4_Click(object sender, EventArgs e) + { + GSOFeature resFeature = IsPipeLineOfSelectedObj(); + if (resFeature == null) + { + MessageBox.Show("请选中一根管线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + GSOGeoPolyline3D selLine = resFeature.Geometry as GSOGeoPolyline3D; + if (selLine[0].Count <= 1) + { + return; + } + MarkTools.getInstance().showMarker(resFeature, + globeControl1, EnumMarkLayer.Mark_Location, ""); + } + /// + /// 距离标注 + /// + bool distanceMarker = false; + private void buttonItemBZ5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBZ5.Text); + + globeControl1.Globe.Action = EnumAction3D.TrackPolyline; + //globeControl1.Globe.DistanceRuler.MeasureMode = EnumDistanceMeasureMode.HVSLineMeasure; + distanceMarker = true; + } + /// + /// 自定义标注 + /// + /// + /// + private void buttonItemBZ6_Click(object sender, EventArgs e) + { + GSOFeature f = globeControl1.Globe.SelectedObject; + GSOLayer l = globeControl1.Globe.SelectedObjectLayer; + FrmCustomLabel frm = new FrmCustomLabel(globeControl1, l, f); + if (frm.ShowDialog() == DialogResult.OK) + { + MarkTools.getInstance().showMarker(f, globeControl1, EnumMarkLayer.Mark_Custom, frm.labelText); + } + } + /// + /// 扯旗标注 + /// + /// + /// + private void buttonItemBZ7_Click(object sender, EventArgs e) + { + GSOFeature f = globeControl1.Globe.SelectedObject; + GSOLayer l = globeControl1.Globe.SelectedObjectLayer; + FrmMarker frm = new FrmMarker(); + if (frm.ShowDialog() == DialogResult.OK) + { + MarkTools.getInstance().showMarker(f, globeControl1, EnumMarkLayer.Mark_Custom, frm.markerContent); + } + } + /// + /// 坡度标注 + /// + /// + /// + private void buttonItemBZ8_Click(object sender, EventArgs e) + { + GSOFeature resFeature = IsPipeLineOfSelectedObj(); + if (resFeature == null) + { + MessageBox.Show("请选中一根管线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + GSOGeoPolyline3D selLine = resFeature.Geometry as GSOGeoPolyline3D; + if (selLine[0].Count <= 1) + { + return; + } + + MarkTools.getInstance().showMarker(resFeature, + globeControl1, EnumMarkLayer.Mark_Slope, ""); + } + /// + /// 属性标注 + /// + /// + /// + private void buttonItemBZ9_Click(object sender, EventArgs e) + { + GSOFeature f = globeControl1.Globe.SelectedObject; + GSOLayer l = globeControl1.Globe.SelectedObjectLayer; + FrmPropertiesMarker frm = new FrmPropertiesMarker(globeControl1, l, f); + if (frm.ShowDialog() == DialogResult.OK) + { + MarkTools.getInstance().showMarker(f, globeControl1, EnumMarkLayer.Mark_Property, frm.labelText); + } + } + /// + /// 红线工具 + /// + /// + /// + private void buttonItemBZ10_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBZ10.Text); + 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; + } + } + /// + /// 标注管理 + /// + /// + /// + private void buttonItemBZ11_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBZ11.Text); + + buttonItemBZ11.Checked = !buttonItemBZ11.Checked; + 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 (buttonItemBZ11.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(); + } + } + + #endregion + /// + /// 飞行到目标点 + /// + /// + /// + private void buttonItemFXGJ1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFXGJ1.Text); + + FrmSetFlytoPos.ShowForm(globeControl1); + + } + /// + /// 自定义飞行 + /// + /// + /// + private void buttonItemFXGJ2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFXGJ2.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); + } + } + /// + /// 绕中心点飞行 + /// + /// + /// + private void buttonItemFXGJ3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFXGJ3.Text); + + globeControl1.Globe.FlyAroundCenter(10000, EnumFlyRepeatValueType.MiliSeconds); + globeControl1.Globe.CurFlyID = 1; + } + /// + /// 绕眼睛飞行 + /// + /// + /// + private void buttonItemFXGJ4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFXGJ4.Text); + + globeControl1.Globe.FlyAroundEye(720, EnumFlyRepeatValueType.Degrees); + globeControl1.Globe.CurFlyID = 2; + } + + /// + /// 权限管理 + /// + /// + /// + private void buttonItemXT1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT1.Text); + + FrmUserRoleMgr frm = new FrmUserRoleMgr(); + frm.ShowDialog(); + } + /// + /// 数据库管理 + /// + /// + /// + private void buttonItemXT2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT2.Text); + + //查看数据库列表 + FrmDbManager frm = new FrmDbManager(); + frm.ShowDialog(); + } + /// + /// 用户列表 + /// + /// + /// + private void buttonItemXT3_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT3_1.Text); + + FrmUserManager frm = new FrmUserManager(); + frm.ShowDialog(); + } + /// + /// 创建新用户 + /// + /// + /// + private void buttonItemXT3_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT3_2.Text); + + FrmUserAdd frm = new FrmUserAdd(-1); + frm.ShowDialog(); + } + /// + /// 人员修改 + /// + /// + /// + private void buttonItemXT4_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT4_2.Text); + + FrmAppUSER appUSER = new FrmAppUSER(); + appUSER.ShowDialog(); + } + /// + /// 增加人员 + /// + /// + /// + private void buttonItemXT4_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT4_1.Text); + + FrmAppUSERRESET appUSERRESET = new FrmAppUSERRESET(); + appUSERRESET.ShowDialog(); + } + /// + /// 统计数据 + /// + /// + /// + private void buttonItemZTT1_Click(object sender, EventArgs e) + { + ////日志记录 + //LogManager.saveLog(Utility.userName, this.buttonItemZTT1.Text); + + //PATM patm = new PATM(); + //patm.operation = "Statistic"; + //patm.Text = "统计专题图管理"; + //patm.ShowDialog(); + } + /// + /// 热点功能统计 + /// + /// + /// + private void buttonItemZTT2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT2.Text); + + FrmHotFuncStat frmhfs = new FrmHotFuncStat(); + frmhfs.ShowDialog(); + } + + private void buttonItemZTT3_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT3_1.Text); + + FrmAPP appfrm = new FrmAPP("专题图申请"); + appfrm.ShowDialog(); + } + + private void buttonItemZTT3_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT3_2.Text); + + FrmAPPFORASK appForask = new FrmAPPFORASK("专题图审核"); + appForask.ShowDialog(); + } + + private void buttonItemZTT3_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT3_3.Text); + + FrmAPPregion appregion = new FrmAPPregion("专题图审核"); + appregion.ShowDialog(); + } + + private void buttonItemZTT4_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT4_1.Text); + + FrmAPP appfrm = new FrmAPP("打印申请"); + appfrm.ShowDialog(); + } + + private void buttonItemZTT4_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT4_2.Text); + + FrmAPPFORASK appForask = new FrmAPPFORASK("打印审核"); + appForask.ShowDialog(); + } + + private void buttonItemZTT4_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT4_3.Text); + + FrmAPPregion appregion = new FrmAPPregion("打印审核"); + appregion.ShowDialog(); + } + + private void buttonItemZTT5_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT5_1.Text); + + FrmAPP appfrm = new FrmAPP("拷贝申请"); + appfrm.ShowDialog(); + } + + private void buttonItemZTT5_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT5_2.Text); + + FrmAPPFORASK appForask = new FrmAPPFORASK("拷贝审核"); + appForask.ShowDialog(); + } + + private void buttonItemZTT5_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT5_3.Text); + + FrmAPPregion appregion = new FrmAPPregion("拷贝审核"); + appregion.Show(); + } + + private int connectServerCount = 0; + + /// + /// 还原球到实测库 + /// + 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); + } + + if (layerManagerNode.Nodes.Count > 0) + { + for (int i = layerManagerNode.Nodes.Count - 1; i >= 0; i--) + { + layerManagerNode.Nodes[i].Remove(); + + } + } + + globeControl1.Refresh(); + + } + + private void buttonItemSPSZ_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSPSZ.Text); + + FrmLayerControl frm = new FrmLayerControl(layerTree, globeControl1, globeControl2); + frm.Show(this); + } + + /// + /// 碰撞审查 + /// + /// + /// + private void buttonItemSH1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSH1.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 buttonItemSH2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSH2.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 buttonItemSH3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSH3.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 buttonItemSH4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSH4.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 buttonItemSH5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSH5.Text); + FrmCityServerLineAnalysis frm = new FrmCityServerLineAnalysis(globeControl1, m_PipelineLayerNames); + frm.Show(this); + } + #region 数据管理-导入文件 + ///// + ///// 数据管理-导入本地坐标系文件 + ///// + ///// + ///// + //private void buttonItemSJGL1_1_Click(object sender, EventArgs e) + //{ + // //日志记录 + // LogManager.saveLog(Utility.userName, this.buttonItemSJGL1_1.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(); + // } + // } + //} + + ///// + ///// 数据管理-导入其他坐标系文件 + ///// + ///// + ///// + //private void buttonItemSJGL1_2_Click(object sender, EventArgs e) + //{ + // //日志记录 + // LogManager.saveLog(Utility.userName, this.buttonItemSJGL1_2.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(); + // } + // } + //} + #endregion + /// + /// 数据质量检查 + /// + /// + /// + private void buttonItemSJGL2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL2.Text); + FrmValiData frm = new FrmValiData(globeControl1); + frm.ShowDialog(); + } + /// + /// 数据预处理 + /// + /// + /// + private void buttonItemSJGL3_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL3.Text); + + FrmEditShapeFile frm = new FrmEditShapeFile(globeControl1); + frm.ShowDialog(this); + } + /// + /// 连接数据库 + /// + /// + /// + private void buttonItemSJGL4_1_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL4_1.Text); + + FrmDatabaseParaSetting frm = new FrmDatabaseParaSetting(globeControl1); + if (frm.ShowDialog() == DialogResult.OK) + { + ds = FrmDatabaseParaSetting.ds; + if (ds != null) + { + ds.IsCloseSaved = false; + } + } + } + /// + /// 管线入库 + /// + /// + /// + private void buttonItemSJGL4_2_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL4_2.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 buttonItemSJGL4_3_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL4_3.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 buttonItemSJGL5_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL5.Text); + + Cyberpipe.Forms.FrmProject frm = new Cyberpipe.Forms.FrmProject(); + frm.ShowDialog(); + } + /// + /// 元数据基本管理 + /// + /// + /// + private void buttonItemSJGL6_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL6_1.Text); + + FrmMetadata frmmd = new FrmMetadata(); + frmmd.ShowDialog(); + } + /// + /// 元数据查询管理 + /// + /// + /// + private void buttonItemSJGL6_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL6_2.Text); + + FrmMetadataStat frmmds = new FrmMetadataStat(); + //frmmds.Show(); + frmmds.ShowDialog(); + } + /// + /// 操作日志管理 + /// + /// + /// + private void buttonItemSJGL7_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL7.Text); + + FrmLogOper frmlo = new FrmLogOper(); + frmlo.ShowDialog(); + } + /// + /// 数据字典管理 + /// + /// + /// + private void buttonItemSJGL8_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL8.Text); + + FrmMDDictory frmmdd = new FrmMDDictory(); + frmmdd.ShowDialog(); + } + /// + /// 数据库备份 + /// + /// + /// + private void buttonItemSJGL9_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL9.Text); + + //新 + FrmBACKORACLE backOracle = new FrmBACKORACLE(); + backOracle.Show(); + } + /// + /// 创建管段 + /// + /// + /// + private void buttonItemBJ1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ1.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; + } + } + /// + /// 创建附属物 + /// + /// + /// + private void buttonItemBJ2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ2.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); + } + } + /// + /// 创建特征管点 + /// + /// + /// + private void buttonItemBJ3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ3.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); + } + } + /// + /// 绘制城市七线 + /// + /// + /// + private void buttonItemBJ4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ4.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; + } + } + } + /// + /// 选中对象 + /// + /// + /// + private void buttonItemBJ5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ5.Text); + + globeControl1.Globe.Action = EnumAction3D.SelectObject; + } + /// + /// 平移对象 + /// + /// + /// + private void buttonItemBJ6_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ6.Text); + + globeControl1.Globe.Action = EnumAction3D.MoveObject; + } + /// + /// 升降对象 + /// + /// + /// + private void buttonItemBJ7_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ7.Text); + + globeControl1.Globe.Action = EnumAction3D.ElevateObject; + } + /// + /// 旋转对象 + /// + /// + /// + private void buttonItemBJ8_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ8.Text); + + globeControl1.Globe.Action = EnumAction3D.RotateObject; + } + /// + /// 连接管段 + /// + /// + /// + private void buttonItemBJ9_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ9.Text); + + if (globeControl1.Globe.SelObjectCount < 2) + { + MessageBox.Show("对不起,请至少选中2个对象!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + return; + } + globeControl1.Globe.InsertJointPipeline(false); + } + /// + /// 后退 + /// + /// + /// + private void buttonItemBJ11_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemBJ11.Text); + globeControl1.Globe.UnDoEdit(); + } + /// + /// 前进 + /// + /// + /// + private void buttonItemBJ12_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemBJ12.Text); + + globeControl1.Globe.ReDoEdit(); + } + /// + /// 导出CAD + /// + /// + /// + private void buttonItemBJ10_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ10_1.Text); + + #region 导出成dxf格式 + List listVectorNames = new List(); + 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(); + #endregion + } + /// + /// 导出矢量 + /// + /// + /// + private void buttonItemBJ10_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ10_2.Text); + + List listVectorNames = new List(); + 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 buttonItemBJ13_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemBJ13.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(); + } + } + MessageBox.Show("删除成功!", "提示"); + } + else + { + MessageBox.Show("请选中要删除的模型!", "提示"); + } + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + } + + private void buttonItemHX1_1_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]; + string filePath = dlg.FileName; + string lastname = Path.GetFileName(filePath); + + 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(); + } + + } + } + } + + public struct LineStruct + { + public string layerName; + public string layerCode; + public string lineLength; + public string hxName; + } + + List lineStruct = new List(); + List featsList = new List(); + + /// + /// 红线审核 + /// + /// + /// + private void buttonItemHX2_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemHX2.Text); + redSH = true; + featsList.Clear(); + lineStruct.Clear(); + List listPipelineLayers = new List(); + + GSOLayer layer = null; + for (int i = 0; i < m_PipelineLayerNames.Count; i++) + { + layer = globeControl1.Globe.Layers.GetLayerByCaption(m_PipelineLayerNames[i]); + if (layer != null) + { + listPipelineLayers.Add(layer); + } + } + //yanxiaowei 重构 + GSOFeatures selectFeatures=new GSOFeatures(); + for (int i = 0; i < globeControl1.Globe.SelObjectCount; i++) + { + GSOFeature feature = null; + globeControl1.Globe.GetSelectObject(i, out feature, out layer); + selectFeatures.Add(feature); + } + DataTable table=new DataTable(); + + ClassGSOTool.CalculateRedLineResult(out table, redSH, selectFeatures, globeControl1, + listPipelineLayers,out lineStruct, out featsList); + + if (table.Rows.Count != 0) + AddDatagridView(table); + else + { + MessageBox.Show("没有侵入地块红线的管线数据!", "提示"); + dataGridViewX1.DataSource = null; + panelOfTable.Visible = false; + return; + } + } + + private void AddDatagridView(DataTable table) + { + dataGridViewX1.DataSource = table; + panelOfTable.Visible = true; + panelOfTable.Height = 200; + toolStripNumbers.Text = "红线审核 |共有:" + table.Rows.Count + "条"; + toolStripDropDownButton3.Visible = true; + } + /// + /// 主窗体 下方的工具条中的 导出.xls文件 按钮事件处理 + /// + /// + /// + private void toolStripDropDownButton3_Click(object sender, EventArgs e) + { + if (dataGridViewX1.Rows.Count == 0) + { + MessageBox.Show("表格内容为空!", "提示"); + return; + } + + string strSaveFile = string.Empty; + SaveFileDialog savefiledialog = new SaveFileDialog(); + savefiledialog.Filter = "Excel文件|*.xls,*.xlsx"; + savefiledialog.AddExtension = true; + savefiledialog.FileName = "红线审核"; + if (savefiledialog.ShowDialog() == DialogResult.OK) + strSaveFile = savefiledialog.FileName; + else return; + + ExpEXCEL.ExpToExcel(dataGridViewX1, strSaveFile, "红线审核", lineStruct, featsList); + MessageBox.Show("导出成功!"); + } + /// + /// 去除集合中重复的管线 + /// + /// + /// + /// + private GSOFeatures getFeaturesByFilter(GSOFeatures features, string fieldName) + { + if (features == null) + { + return null; + } + GSOFeatures featuresGet = new GSOFeatures(); + for (int i = 0; i < features.Length; i++) + { + GSOFeature featureFromFS = features[i]; + string fieldValueFromFS = featureFromFS.GetValue(fieldName).ToString().Trim(); + bool isHas = false; + for (int j = featuresGet.Length - 1; j >= 0; j--) + { + GSOFeature featureFromFSGet = featuresGet[j]; + string fieldValueFromFSGet = featureFromFSGet.GetValue(fieldName).ToString().Trim(); + if (fieldValueFromFS.Equals(fieldValueFromFSGet)) + { + isHas = true; + break; + } + } + if (isHas == false) + { + featuresGet.Add(featureFromFS.Clone()); + } + } + return featuresGet; + } + + private void sliderItem2_ValueChanged(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.sliderItem2.Text); + + globeControl1.Globe.GroundOpaque = 100 - sliderItem2.Value; + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(roadLayerName);//("180fd"); + if (layer != null) + { + layer.Opaque = 100 - sliderItem2.Value; + } + layer = globeControl2.Globe.Layers.GetLayerByCaption("180fd");//("180fd"); + if (layer != null) + { + layer.Opaque = 100 - sliderItem2.Value; + } + globeControl2.Globe.GroundOpaque = 100 - sliderItem2.Value; + + optiValue = sliderItem2.Value; + } + /// + /// 数据管理导入文件 + /// + /// + /// + private void buttonItemSJGL1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL1.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.Multiselect = true; + if (dlg.ShowDialog() == DialogResult.OK) + { + //自定义lprj文件名,从程序中复制一lprj文件。 + string filePath = dlg.FileName; + string lastname = Path.GetFileName(filePath); + + 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, 100); + + globeControl1.Refresh(); + } + } + } + + private void buttonItemHX1_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemHX1.Text); + + GSODataSource dataSpace = globeControl1.Globe.DataManager.OpenOracleDataSource(Utility.DBServer.Trim() + "/" + Utility.dbdatabase.Trim(), "", "", Utility.userID, Utility.DBPassword); + string filepath = ""; + //日志记录 + OpenFileDialog dlg = new OpenFileDialog(); + dlg.Filter = "矢量数据(*.shp)|*.shp|矢量数据(*.lgd)|*.lgd|CAD数据(*.dxf)|*.dxf|全部支持格式(*.lgd,*.shp,*.dxf)|*.lgd;*.shp;*.dxf;"; + dlg.Multiselect = true; + + #region 临时图层显示 + if (dlg.ShowDialog() == DialogResult.OK) + { + string filePath = dlg.FileName; + string lastname = Path.GetFileName(filePath); + + #region + for (int i = 0; i < dlg.FileNames.Length; i++) + { + string strDataPath = dlg.FileNames[i]; + filepath = strDataPath; + + GSOLayer layer = globeControl1.Globe.Layers.Add(strDataPath); + GSOFeatures RedFeatures = layer.GetAllFeatures(); + + 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(); + RedFeatures = features; + 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; + } + + /////////////////////////////////////////////////////////////////////////////////////////// + globeControl1.Globe.Layers.MoveTo(0, globeControl1.Globe.Layers.Count - 1); + globeControl1.Refresh(); + } + + IModelBuilder modelBuilder = new RedLineBuilder(); + + modelBuilder.batchInsert(dataSpace, redDt, RedFeatures); + + } + #endregion + + } + #endregion + } + /// + /// 定位 + /// + /// + /// + private void buttonItemLocation_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemLocation.Text); + + FrmFlyToPosition fly = new FrmFlyToPosition(globeControl1,globeControl2); + fly.Show(this); + } + /// + /// 2015-10-17演示代码 红线审核 + /// + /// + /// + private void ribbonTabItem6_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.FlyToPosition(new GSOPoint3d(120.610963, 31.188121, 50), EnumAltitudeMode.Absolute, -4, 50, 800); + globeControl1.Globe.FlyToPointSpeed = 10000000; + globeControl1.Globe.Action = EnumAction3D.SelectObject; + globeControl1.Refresh(); + + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + + //zhanshi = false; + redSH = true; + splitContainer1.Panel2Collapsed = true; + legendSG.Visible = false; + legendSC.Visible = false; + ClearGZData(); + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = true; + } + + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 基础工具 + /// + /// + /// + private void ribbonTabItem1_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + //zhanshi = false; + redSH = false; + splitContainer1.Panel2Collapsed = true; + panelOfTable.Visible = false; + legendSC.Visible = false; + legendSG.Visible = false; + ClearGZData(); + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + + + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 一键审核 + /// + /// + /// + private void ribbonTabItem11_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + //zhanshi = false; + redSH = false; + splitContainer1.Panel2Collapsed = true; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + panelOfTable.Visible = false; + legendSC.Visible = false; + legendSG.Visible = false; + ClearGZData(); + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + + + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 右屏添加冰箱数据 + /// + void AddDataToGlobeControl2() + { + + bool modelDataBool = false; + for (int i = globeControl2.Globe.Layers.Count - 1; i >= 0; i--) + { + GSOLayer layer = globeControl2.Globe.Layers[i]; + if (layer.Name.Contains("fttp:")) + { + modelDataBool = true; + break; + } + } + + if (modelDataBool == false) + { + GSOLayer ly = globeControl1.Globe.Layers.GetLayerByCaption("天地图地图"); + globeControl2.Globe.Layers.Add(ly); + } + else + { + return; + } + } + /// + /// 双屏对比 + /// + /// + /// + private void ribbonTabItem9_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent += new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent += new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + panelOfTable.Visible = false; + + splitContainer1.Panel2Collapsed = false; + //zhanshi = true; + redSH = false; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + sliderItem2.Value = 100 - globeControl1.Globe.GroundOpaque; + globeControl2.Globe.GroundOpaque = globeControl1.Globe.GroundOpaque; + legendSC.Visible = true; + legendSG.Visible = true; + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + AddDataToGlobeControl2(); + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 文档管理 + /// + /// + /// + private void ribbonTabItem4_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + panelOfTable.Visible = false; + //zhanshi = false; + redSH = false; + splitContainer1.Panel2Collapsed = true; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + legendSC.Visible = false; + legendSG.Visible = false; + ClearGZData(); + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 基础管理 + /// + /// + /// + private void ribbonTabItem14_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + panelOfTable.Visible = false; + //zhanshi = false; + redSH = false; + splitContainer1.Panel2Collapsed = true; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + legendSC.Visible = false; + legendSG.Visible = false; + ClearGZData(); + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 权限管理 + /// + /// + /// + private void ribbonTabItem2_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + panelOfTable.Visible = false; + //zhanshi = false; + redSH = false; + splitContainer1.Panel2Collapsed = true; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + legendSC.Visible = false; + legendSG.Visible = false; + ClearGZData(); + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + GSOFeature dpFeatuer = null; + /// + /// 双屏分析,点击管段分析 + /// + /// + /// + private void buttonItem8_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItem8.Text); + + //FrmCompareFeature frmCompareFeature = new FrmCompareFeature(globeControl1, globeControl2, layerTemp, layerTemp2,m_PipelineLayerNames,sgPipeLayersNames); + int width = this.Width; + FrmCompareFeature.ShowForm(globeControl1, globeControl2, layerTemp, layerTemp2, m_PipelineLayerNames, sgPipeLayersNames,width); + //frmCompareFeature.Location = new Point((this.Width - frmCompareFeature.Width)/2,50); + //frmCompareFeature.Show(this); + + } + /// + /// 红线审核导出图片 + /// + /// + /// + private void buttonItemDCTP_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemDCTP.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))); + */ + int mapWidth = 0; + int mapHeight = 0; + Point pt = getUpperLeftPoint(pt1, pt2, out mapWidth, out mapHeight); + int rightBottomX = pt.X + mapWidth; + int rightBottomY = pt.Y + mapHeight; + Image myImg = new Bitmap(mapWidth, mapHeight); + Graphics g = Graphics.FromImage(myImg); + g.CopyFromScreen(pt, new Point(0, 0), new Size(rightBottomX, rightBottomY)); + + 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; + } + } + } + /// + /// 标识器全区域统计 + /// + /// + /// + private void 标识器分类统计ToolStripMenuItem_Click(object sender, EventArgs e) + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + FrmBSQStatis bsqStatis = new FrmBSQStatis(); + bsqStatis.Show(this); + } + /// + /// 标识器绘制区域统计 + /// + /// + /// + private void 标识器分类统计ToolStripMenuItem1_Click(object sender, EventArgs e) + { + trackflag = "BSQDuoBianXiangStatis"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + } + + #region 保存和加载审核库加载的图层 + /* + private void saveLayerList(TreeNodeCollection treeNodeList) + { + string configPath = Application.StartupPath + "\\configLayerList.xml"; + try + { + XmlDocument doc = new XmlDocument(); + doc.Load(configPath); + XmlNode dbParams = doc.SelectSingleNode("Params/dbparams"); + XmlNode dbLayers = doc.SelectSingleNode("Params/dblayers"); + XmlNode layers = doc.SelectSingleNode("Params/layers"); + dbParams.RemoveAll(); + dbLayers.RemoveAll(); + layers.RemoveAll(); + + List listDS = new List(); + String shDatasourceName = Utility.sgdbip + "/" + Utility.sgdbname + "_" + Utility.sgdbuser; + bool flag = false; + + for (int i = 0; i < globeControl1.Globe.DataManager.DataSourceCount; i++) + { + GSODataSource ds = globeControl1.Globe.DataManager.GetDataSourceAt(i); + if (ds != null && ds.Type == EnumDataSourceType.SqlServer || ds.Type == EnumDataSourceType.Oracle) + { + if (ds.Name == shDatasourceName) + { + //防止因为多次连接同一个数据库 + if (flag == true) + { + break; + } + flag = true; + listDS.Add(ds); + GSODataSourceCnn conn = ds.GetConnectionInfo(); + + XmlElement dbparam = doc.CreateElement("shdbparam"); + XmlElement ip = doc.CreateElement("ship"); + ip.InnerText = conn.Server; + + XmlElement dbname = doc.CreateElement("shdbname"); + dbname.InnerText = conn.Database; + + XmlElement username = doc.CreateElement("shusername"); + username.InnerText = conn.User; + + XmlElement password = doc.CreateElement("shpassword"); + password.InnerText = conn.Password; + + XmlElement type = doc.CreateElement("shtype"); + if (ds.Type == EnumDataSourceType.SqlServer) + { + type.InnerText = "sqlserver"; + } + else + { + type.InnerText = "oracle"; + } + + dbparam.AppendChild(ip); + dbparam.AppendChild(dbname); + dbparam.AppendChild(username); + dbparam.AppendChild(password); + dbparam.AppendChild(type); + dbParams.AppendChild(dbparam); + } + + } + } + + for (int i = 0; i < treeNodeList.Count; i++) + { + GSOLayer layer = treeNodeList[i].Tag as GSOLayer; + if (Path.GetExtension(layer.Name) == "") + { + XmlElement dbLayer = doc.CreateElement("dblayer"); + XmlAttribute attri = doc.CreateAttribute("dbindex"); + for (int j = 0; j < listDS.Count; j++) + { + if (layer.Dataset.DataSource.Name == listDS[j].Name) + { + attri.Value = j.ToString(); + break; + } + } + dbLayer.Attributes.Append(attri); + dbLayer.InnerText = layer.Name; + + dbLayers.AppendChild(dbLayer); + } + else + { + XmlElement dbLayer = doc.CreateElement("layer"); + dbLayer.InnerText = layer.Name; + layers.AppendChild(dbLayer); + } + } + + doc.Save(configPath); + } + catch (Exception e) + { + + } + } + + private void openLayerList() + { + layerManagerNode.Nodes.Clear(); + + string configPath = Application.StartupPath + "\\configLayerList.xml"; + try + { + XmlDocument doc = new XmlDocument(); + doc.Load(configPath); + XmlNode dbParams = doc.SelectSingleNode("Params/dbparams"); + XmlNode dbLayers = doc.SelectSingleNode("Params/dblayers"); + XmlNode layers = doc.SelectSingleNode("Params/layers"); + + List listDS = new List(); + for (int i = 0; i < dbParams.ChildNodes.Count; i++) + { + string ip = ""; + string dbname = ""; + string username = ""; + string password = ""; + string type = ""; + XmlNode node = dbParams.ChildNodes.Item(i); + for (int j = 0; j < node.ChildNodes.Count; j++) + { + XmlNode nodeChild = node.ChildNodes.Item(j); + + if (nodeChild != null && nodeChild.Name == "ship") + { + ip = nodeChild.InnerText; + } + else if (nodeChild != null && nodeChild.Name == "shdbname") + { + dbname = nodeChild.InnerText; + } + else if (nodeChild != null && nodeChild.Name == "shusername") + { + username = nodeChild.InnerText; + } + else if (nodeChild != null && nodeChild.Name == "shpassword") + { + password = nodeChild.InnerText; + } + else if (nodeChild != null && nodeChild.Name == "shtype") + { + type = nodeChild.InnerText; + } + } + + if (type == "sqlserver") + { + GSODataSource ds = globeControl1.Globe.DataManager.OpenSqlServerDataSource(ip, "", dbname, username, password); + listDS.Add(ds); + } + else if (type == "oracle") + { + GSODataSource ds = globeControl1.Globe.DataManager.OpenOracleDataSource(ip + "/" + dbname, "", "", username, password); + listDS.Add(ds); + } + } + + for (int i = 0; i < dbLayers.ChildNodes.Count; i++) + { + XmlNode node = dbLayers.ChildNodes.Item(i); + if (node != null) + { + string layerName = node.InnerText; + XmlAttribute attri = node.Attributes["dbindex"]; + if (attri != null) + { + int dbIndex = -1; + if (int.TryParse(attri.Value, out dbIndex)) + { + GSODataset dataset = listDS[dbIndex].GetDatasetByName(layerName); + globeControl1.Globe.Layers.Add(dataset); + //更新树节点 + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + TreeNode layerNode = new TreeNode(); + layerNode.Tag = layer; + layerNode.Text = layer.Dataset.Caption; + layerNode.ImageIndex = 0; + layerNode.SelectedImageIndex = 0; + layerNode.Checked = layer.Visible; + layerManagerNode.Nodes.Insert(0, layerNode); + // layerManagerNode.Expand(); + + + } + } + } + } + for (int i = 0; i < layers.ChildNodes.Count; i++) + { + XmlNode node = layers.ChildNodes.Item(i); + if (node != null) + { + string layerName = node.InnerText; + globeControl1.Globe.Layers.Add(layerName); + + //更新树节点 + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + TreeNode layerNode = new TreeNode(); + layerNode.Tag = layer; + layerNode.Text = layer.Dataset.Caption; + layerNode.ImageIndex = 0; + layerNode.SelectedImageIndex = 0; + layerNode.Checked = layer.Visible; + layerManagerNode.Nodes.Insert(0, layerNode); + } + } + layerManagerNode.Expand(); + } + catch (Exception e) + { + + } + } + * */ + #endregion + + private void btn_check_history_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_check_history.Text); + + if (FrmCheckHistory.isOpen == true) + { + return; + } + FrmCheckHistory frm = new FrmCheckHistory(globeControl1, globeControl2); + frm.addNode += new AddNodeToLayerManagerNode(addNodeToLayerManagerNode); + frm.Show(); + + } + + private void buttonItem查看数据_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItem查看数据.Text); + + FrmThreeOracle tr = new FrmThreeOracle(globeControl1); + + if (tr.ShowDialog() == DialogResult.OK) + { + addNodeToLayerManagerNode(tr.rukuLayer); + globeControl1.Refresh(); + } + } + /// + /// 规划数据入库 + /// + /// + /// + private void buttonItemGHRK_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemGHRK.Text); + + FrmGHRK ghrk = new FrmGHRK(globeControl1, layerManagerNode); + ghrk.Show(this); + } + + private void btn_user_info_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_user_info.Text); + + if (!FrmSysUserInfoManger.IS_OPEN) + { + FrmSysUserInfoManger frm = new FrmSysUserInfoManger(); + frm.ShowDialog(); + } + } + + private void btn_role_info_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_role_info.Text); + + if (FrmRoleInfoManager.IS_OPEN) + { + return; + } + FrmRoleInfoManager frm = new FrmRoleInfoManager(); + frm.ShowDialog(); + } + + private void btn_resc_info_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_resc_info.Text); + + if (!SysRescInfoManager.IS_OPEN) + { + SysRescInfoManager frm = new SysRescInfoManager(); + frm.ShowDialog(); + } + } + + private void btn_role_resc_Click(object sender, EventArgs e) + { + + LogManager.saveLog(Utility.userName, this.btn_role_resc.Text); + + if (!FrmRoleRescManager.IS_OPEN) + { + FrmRoleRescManager frm = new FrmRoleRescManager(); + frm.ShowDialog(); + } + } + + private void btn_user_role_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_user_role.Text); + + if (FrmUserRole.IS_OPEN) + { + return; + } + FrmUserRole frm = new FrmUserRole(); + frm.ShowDialog(); + } + + private void btn_document_info_Click(object sender, EventArgs e) + { + + LogManager.saveLog(Utility.userName, this.btn_document_info.Text); + + //if (FormDocumentManager.IS_OPEN) + //{ + // return; + //} + //FormDocumentManager frm = new FormDocumentManager(); + //frm.ShowDialog(); + + //if (FormDocumentManager.IS_OPEN) + //{ + // return; + //} + //new FormDocumentManager().ShowDialog(); + if (FormDocumentManager.IS_OPEN) + { + return; + } + this.Cursor = Cursors.WaitCursor; + FormDocumentManager frm = new FormDocumentManager(); + frm.changeCursor += new ChangeCursor(changeCursorToDefault); + frm.ShowDialog(); + + } + + private void changeCursorToDefault() + { + this.Cursor = Cursors.Default; + } + + /// + /// 判断CAD文件是否有投影信息 + /// + /// + /// + Boolean CheckDatasetGeoReference(GSODataset dataset) + { + Boolean bSuccess = false; + if (dataset.GeoReferenceType == EnumGeoReferenceType.Flat) + { + if (MessageBox.Show("数据没有空间参考信息,请设置空间参考信息!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation) == DialogResult.OK) + { + String strPath = Path.GetDirectoryName(Application.ExecutablePath) + "\\Coordinate Systems"; + OpenFileDialog dlg = new OpenFileDialog(); + + dlg.InitialDirectory = strPath; + dlg.RestoreDirectory = true; + + dlg.Filter = "投影文件|*.prj||"; + if (dlg.ShowDialog() == DialogResult.OK) + { + bSuccess = dataset.LoadProjectionFromESRIFile(dlg.FileName); + } + } + } + else + { + return true; + } + return bSuccess; + } + + private void buttonItemexp_CAD_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemexp_CAD.Text); + + OpenFileDialog dlg = new OpenFileDialog(); + dlg.Filter = "支持格式(*.dwg)|*.dwg"; + dlg.Multiselect = true; + if (dlg.ShowDialog() == DialogResult.OK) + { + for (int i = 0; i < dlg.FileNames.Length; i++) + { + //this.Cursor = Cursors.WaitCursor; + string strDataPath = dlg.FileNames[i]; + + #region + //string strDataPathPrj = strDataPath.ToLower().Replace(".dwg", ".lprj"); + + //if (File.Exists(strDataPathPrj) == false) + //{ + // if (MessageBox.Show("数据没有空间参考信息,请设置空间参考信息!", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation) == DialogResult.OK) + // { + // String strPath = Application.StartupPath + "\\Coordinate Systems"; + // OpenFileDialog dlgPrj = new OpenFileDialog(); + // dlgPrj.InitialDirectory = strPath; + // dlgPrj.RestoreDirectory = true; + // dlgPrj.Multiselect = false; + // dlg.Filter = "投影文件|*.prj"; + // if (dlg.ShowDialog() == DialogResult.OK) + // { + // this.Cursor = Cursors.WaitCursor; + // string proj4 = GSODataEngineUtility.ConvertEsriPrjFileToProj4(dlg.FileName); + // using (StreamWriter stream = new StreamWriter(strDataPathPrj, false)) + // { + // stream.WriteLine("0prj4" + proj4 + ""); + // } + // AddLayerData(strDataPath); + // //globeControl1.Globe.Layers.Add(strDataPath); + + // this.Cursor = Cursors.Default; + // } + // else + // { + // AddLayerData(strDataPath); + // //globeControl1.Globe.Layers.Add(strDataPath); + // } + // } + // else + // { + // AddLayerData(strDataPath); + // //globeControl1.Globe.Layers.Add(strDataPath); + // } + + //} + //else + //{ + // //globeControl1.Globe.Layers.Add(strDataPath); + // AddLayerData(strDataPath); + //} + #endregion + AddLayerData(strDataPath); + //this.Cursor = Cursors.Default; + } + } + + 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, 100); + + globeControl1.Refresh(); + } + } + + private void btn_password_edit_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_password_edit.Text); + + if (FrmChangePassword.IS_OPEN) + { + return; + } + FrmChangePassword frm = new FrmChangePassword(); + frm.ShowDialog(); + } + /// + /// 多孔管线入库 + /// + /// + /// + private void buttonItem9_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL4_2.Text); + + if (ds == null) + { + MessageBox.Show("请先连接数据库", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + ConnectDB(null, null); + } + if (ds == null) + return; + + FrmMultiPipelineModelDB frm = new FrmMultiPipelineModelDB(globeControl1, ds); + if (frm.ShowDialog() == DialogResult.OK) + { + addNodeToLayerManagerNode(frm.rukuLayer); + } + //frm.Show(); + } + private void 导出CADToolStripMenuItem1_Click(object sender, EventArgs e) + { + TreeNode node = layerNodeContexMenu.Tag as TreeNode; + if (node == null) + { + MessageBox.Show("请在左侧节点集中选择要导出的图层", "提示"); + return; + } + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(node.Text.Trim()); + if (layer == null || layer.GetAllFeatures().Length <= 0) + { + MessageBox.Show("要导出的图层为空", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + return; + } + string strProjectName = Utility.projectStr; + if (strProjectName != "") + { + SaveFileDialog dlg = new SaveFileDialog(); + dlg.Filter = "*.dwg|*.dwg|*.dxf|*.dxf"; + dlg.FileName = layer.Caption; + if (dlg.ShowDialog(this) == DialogResult.OK) + { + globeControl1.Globe.MemoryLayer.SaveAs(dlg.FileName); + GSOLayer newlayer = globeControl1.Globe.Layers.Add(dlg.FileName); + newlayer.RemoveAllFeature(); + int featureCount = layer.GetAllFeatures().Length; + for (int i = 0; i < featureCount; i++) + { + GSOFeature feature = layer.GetAt(i); + if (feature != null && feature.Geometry != null) + { + if (feature.Geometry.Type == EnumGeometryType.GeoPolyline3D) + { + feature.Geometry.Style = new GSOSimpleLineStyle3D(); + } + else if (feature.Geometry.Type == EnumGeometryType.GeoPolygon3D) + { + feature.Geometry.Style = new GSOSimplePolygonStyle3D(); + } + newlayer.AddFeature(feature); + } + } + newlayer.Save(); + newlayer.Dataset.DataSource.RemoveDataset(newlayer.Dataset); + globeControl1.Globe.Layers.Remove(newlayer); + MessageBox.Show("导出CAD完成!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + } + } + } + + private void buttonItemGBJC_Click(object sender, EventArgs e) + { + FrmGBJC gb = new FrmGBJC(globeControl1, globeControl2, layerTemp, layerTemp2); + gb.Show(this); + } + + #region 右屏管纵数据控制 + private void 五十米主干道ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = true; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + + private void 三十六米次干道ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = true; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + + private void 四十二米次干道ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = true; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + + private void 二十四米一块板ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = true; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + + private void 二十四米三块板ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = true; + } + + private void 二十四米停车带ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = true; + lendendGZ24_3.Visible = false; + } + + private void 二十六米大堤路ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = true; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + + private void 清除管纵数据ToolStripMenuItem_Click(object sender, EventArgs e) + { + ClearGZData(); + } + + private void ClearGZData() + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + #endregion + + private void buttonItemPasswordReset_Click(object sender, EventArgs e) + { + Frm_password_reset reset = new Frm_password_reset(); + reset.Show(); + } + + private void pictureBox1_Paint(object sender, PaintEventArgs e) + { + int Width = this.Width; + string welcomeUser = "欢迎您:" + Utility.userName; + Graphics g = e.Graphics; + g.DrawString(welcomeUser, new Font("宋体", 12), new SolidBrush(Color.Black), Width - 180, 50); + } + + } +} \ No newline at end of file diff --git a/MainFrm.cs.LOCAL.9016.cs b/MainFrm.cs.LOCAL.9016.cs new file mode 100644 index 0000000..0b7e393 --- /dev/null +++ b/MainFrm.cs.LOCAL.9016.cs @@ -0,0 +1,13060 @@ +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; + + GSOBalloon featureTooltip2; + GSOBalloonEx balloonEx2; + + GSOLayer layerTemp; + GSOLayer layerTemp2; + FrmShResult frmShResult = null; + FrmRedlineResult frmredResult = null; + FrmMnModify frmModify = null; + public bool frmRedlineResult = false; + public bool boolfrmShResult = false; + public bool boolfrmModify = false; + + List m_PipelineLayerNames = new List();//线图层名称 + List workwellLayerNames = new List();//工井图层名称 + List valueLayerNames = new List();//阀门图层名称 + List instrumenLayerNames = new List();//附属物图层名称 + List pipefittingLayerNames = new List();//管件图层名称 + List sgPipeLayersNames = new List();//施工管线图层名称 + 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 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; + public string redLayer = null; + //GSOLayer redLayer1 = null; + bool redSH = false; + string redDt = "红线"; + //双屏对比 + //bool zhanshi=false; + Thread t = null; + private GSOHudButton legendSC;//定义图例 + private GSOHudButton legendSG;//定义图例 + //管纵图 + private GSOHudButton lendendGZ50; + private GSOHudButton lendendGZ36; + private GSOHudButton lendendGZ42; + private GSOHudButton lendendGZ24_1; + private GSOHudButton lendendGZ24_2; + private GSOHudButton lendendGZ24_3; + private GSOHudButton lendendGZ26; + + GSOGeoPoint3D bsqPT; + + FrmYJSHTC frmSh = null;//一键审核窗口全局变量wxl + FrmWait frmWait = null;//一键审核等待窗口 + //FrmWait frmWait2 = null;//文档操作等待窗口 + + float mouseDownX1,mouseDownY1; + float mouseDownX2,mouseDownY2; + /// + /// + /// + 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; + + featureTooltip2 = new GSOBalloon(globeControl2.Handle); + balloonEx2 = new GSOBalloonEx(globeControl2.Handle); + Utility.SetBallons(featureTooltip, balloonEx); + + panelOfTable.Height = 200; + + RigthMenuSet(); + + MenuSet(); + + } + /// + /// 右屏中添加管纵图片 + /// + private void AddGZ() + { + + lendendGZ50 = new GSOHudButton(); + lendendGZ50.SetImage(Application.StartupPath + "/Resource/管纵/50.png"); + lendendGZ50.SetOffset(0, 0); + lendendGZ50.MinOpaque = 1; + lendendGZ50.MaxOpaque = 1; + lendendGZ50.FadeOut = false; + lendendGZ50.Name = "lendendGZ50"; + lendendGZ50.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ50); + lendendGZ50.Visible = false; + + lendendGZ36 = new GSOHudButton(); + lendendGZ36.SetImage(Application.StartupPath + "/Resource/管纵/36.png"); + lendendGZ36.SetOffset(0, 0); + lendendGZ36.MinOpaque = 1; + lendendGZ36.MaxOpaque = 1; + lendendGZ36.FadeOut = false; + lendendGZ36.Name = "lendendGZ36"; + lendendGZ36.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ36); + lendendGZ36.Visible = false; + + lendendGZ42 = new GSOHudButton(); + lendendGZ42.SetImage(Application.StartupPath + "/Resource/管纵/42.png"); + lendendGZ42.SetOffset(0, 0); + lendendGZ42.MinOpaque = 1; + lendendGZ42.MaxOpaque = 1; + lendendGZ42.FadeOut = false; + lendendGZ42.Name = "lendendGZ42"; + lendendGZ42.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ42); + lendendGZ42.Visible = false; + + lendendGZ24_1 = new GSOHudButton(); + lendendGZ24_1.SetImage(Application.StartupPath + "/Resource/管纵/24_1.png"); + lendendGZ24_1.SetOffset(0, 0); + lendendGZ24_1.MinOpaque = 1; + lendendGZ24_1.MaxOpaque = 1; + lendendGZ24_1.FadeOut = false; + lendendGZ24_1.Name = "lendendGZ24_1"; + lendendGZ24_1.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ24_1); + lendendGZ24_1.Visible = false; + + lendendGZ24_2 = new GSOHudButton(); + lendendGZ24_2.SetImage(Application.StartupPath + "/Resource/管纵/24_2.png"); + lendendGZ24_2.SetOffset(0, 0); + lendendGZ24_2.MinOpaque = 1; + lendendGZ24_2.MaxOpaque = 1; + lendendGZ24_2.FadeOut = false; + lendendGZ24_2.Name = "lendendGZ24_2"; + lendendGZ24_2.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ24_2); + lendendGZ24_2.Visible = false; + + lendendGZ24_3 = new GSOHudButton(); + lendendGZ24_3.SetImage(Application.StartupPath + "/Resource/管纵/24_3.png"); + lendendGZ24_3.SetOffset(0, 0); + lendendGZ24_3.MinOpaque = 1; + lendendGZ24_3.MaxOpaque = 1; + lendendGZ24_3.FadeOut = false; + lendendGZ24_3.Name = "lendendGZ24_3"; + lendendGZ24_3.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ24_3); + lendendGZ24_3.Visible = false; + + lendendGZ26 = new GSOHudButton(); + lendendGZ26.SetImage(Application.StartupPath + "/Resource/管纵/26.png"); + lendendGZ26.SetOffset(0, 0); + lendendGZ26.MinOpaque = 1; + lendendGZ26.MaxOpaque = 1; + lendendGZ26.FadeOut = false; + lendendGZ26.Name = "lendendGZ26"; + lendendGZ26.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ26); + lendendGZ26.Visible = false; + + } + + public void RigthMenuSet() + { + if (Utility.userRole.IndexOf("清除分析") < 0) + { + toolRightMenu.Items.Remove(清除分析ToolStripMenuItem); + } + + #region 区域分析 + if (Utility.userRole.IndexOf("区域分析") < 0) + { + toolRightMenu.Items.Remove(区域分析ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("缓冲区分析") < 0) + { + 区域分析ToolStripMenuItem.DropDownItems.Remove(缓冲区分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("附属物分析") < 0) + { + 区域分析ToolStripMenuItem.DropDownItems.Remove(附属物分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("无源淹没分析") < 0) + { + 区域分析ToolStripMenuItem.DropDownItems.Remove(无源淹没分析ToolStripMenuItem); + } + } + #endregion + + #region 视域分析 + if (Utility.userRole.IndexOf("视域分析") < 0) + { + toolRightMenu.Items.Remove(视域分析ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("通视分析") < 0) + { + 视域分析ToolStripMenuItem.DropDownItems.Remove(通视分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("可视域分析") < 0) + { + 视域分析ToolStripMenuItem.DropDownItems.Remove(可视域分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("可视包络分析") < 0) + { + 视域分析ToolStripMenuItem.DropDownItems.Remove(可视包络分析ToolStripMenuItem); + } + } + #endregion + + #region 开发分析 + if (Utility.userRole.IndexOf("开挖分析") < 0) + { + toolRightMenu.Items.Remove(开挖分析ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("多边形开挖") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(多边形开挖ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("挖方量分析") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(挖方量分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("沿线开挖") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(沿线开挖ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("创建隧道") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(创建隧道ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("隐藏隧道") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(隐藏隧道ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("删除隧道") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(删除隧道ToolStripMenuItem); + } + } + #endregion + + #region 拓扑分析 + if (Utility.userRole.IndexOf("拓扑分析") < 0) + { + toolRightMenu.Items.Remove(拓扑分析ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("创建拓扑") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(创建拓扑ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("上游分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(上游分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("下游分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(下游分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("流向分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(流向分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("关阀分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(关阀分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("连通分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(连通分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("爆管分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(爆管分析ToolStripMenuItem); + } + } + #endregion + + #region 断面分析 + if (Utility.userRole.IndexOf("断面分析") < 0) + { + toolRightMenu.Items.Remove(断面分析ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("横断面分析") < 0) + { + 断面分析ToolStripMenuItem.DropDownItems.Remove(横断面分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("纵断面分析") < 0) + { + 断面分析ToolStripMenuItem.DropDownItems.Remove(纵断面分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("道路断面分析") < 0) + { + 断面分析ToolStripMenuItem.DropDownItems.Remove(道路断面分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("基线剖面分析") < 0) + { + 断面分析ToolStripMenuItem.DropDownItems.Remove(基线剖面分析ToolStripMenuItem); + } + } + #endregion + + #region 绘制区域统计 + if (Utility.userRole.IndexOf("绘制区域统计") < 0) + { + toolRightMenu.Items.Remove(绘制区域统计ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("绘制区域管线长度统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管线长度统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域阀门数量统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(阀门数量统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域井盖数量统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(井盖数量统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域管径分段统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管径分段统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域埋深分段统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(埋深分段统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域管径分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管径分类统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域材质分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(材质分类统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域附属物分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(附属物分类统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域标识器分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(标识器分类统计ToolStripMenuItem1); + } + + } + #endregion + + #region 全区域统计 + if (Utility.userRole.IndexOf("全区域统计") < 0) + { + toolRightMenu.Items.Remove(全区域统计ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("全区域管线长度统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管线长度统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域阀门数量统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(阀门数量统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域井盖数量统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(井盖数量统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域管径分段统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管径分段统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域埋深分段统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(埋深分段统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域管径分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管径分类统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域材质分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(材质分类统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域附属物分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(附属物分类统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域标识器分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(标识器分类统计ToolStripMenuItem); + } + + } + #endregion + + #region 查询 + if (Utility.userRole.IndexOf("查询") < 0) + { + toolRightMenu.Items.Remove(查询ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("空间查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(空间查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("编号查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(编号查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("坐标查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(坐标查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("管径查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(管径查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("材质查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(材质查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("基本查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(基本查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("复合查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(复合查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("关联查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(关联查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("关键字查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(关键字查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("附属物查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(附属物查询ToolStripMenuItem); + } + } + #endregion + + #region 标注 + if (Utility.userRole.IndexOf("标注") < 0) + { + toolRightMenu.Items.Remove(标注ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("标高标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(标高标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("管径标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(管径标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("埋深标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(埋深标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("坐标标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(坐标标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("距离标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(距离标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("自定义标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(自定义标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("扯旗标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(扯旗标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("坡度标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(坡度标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("属性标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(属性标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("标注管理") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(标注管理ToolStripMenuItem); + } + } + #endregion + + #region 飞行 + if (Utility.userRole.IndexOf("飞行") < 0) + { + toolRightMenu.Items.Remove(飞行ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("自定义飞行") < 0) + { + 飞行ToolStripMenuItem.DropDownItems.Remove(自定义飞行ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("飞行到目标点") < 0) + { + 飞行ToolStripMenuItem.DropDownItems.Remove(飞行到目标点ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("绕中心点飞行") < 0) + { + 飞行ToolStripMenuItem.DropDownItems.Remove(绕中心点飞行ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("绕眼睛飞行") < 0) + { + 飞行ToolStripMenuItem.DropDownItems.Remove(绕眼睛飞行ToolStripMenuItem); + } + } + #endregion + + #region 编辑 + if (Utility.userRole.IndexOf("编辑") < 0) + { + toolRightMenu.Items.Remove(编辑ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("平移对象") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(平移对象ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("升降对象") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(升降对象ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("旋转对象") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(旋转对象ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("连接管段") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(连接管段ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("导出文件") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(导出文件ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("前进") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(前进ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("后退") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(删除模型ToolStripMenuItem); + } + } + #endregion + + #region 量算 + if (Utility.userRole.IndexOf("量算") < 0) + { + toolRightMenu.Items.Remove(量算ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("水平距离") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(水平距离ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("垂直距离") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(垂直距离ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("空间距离") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(空间距离ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("地表距离") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(地表距离ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("高度量算") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(高度量算ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("水平面积") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(水平面积ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("地表面积") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(地表面积ToolStripMenuItem1); + } + } + #endregion + } + + public void MenuSet() + { + + #region 权限管理 + if (Utility.userRole.IndexOf("权限管理") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem2); + } + else + { + + if (Utility.userRole.IndexOf("用户管理") < 0) + { + btn_user_info.Visible = false; + } + if (Utility.userRole.IndexOf("角色管理") < 0) + { + btn_role_info.Visible = false; + } + if (Utility.userRole.IndexOf("资源管理") < 0) + { + btn_resc_info.Visible = false; + } + if (Utility.userRole.IndexOf("角色授权") < 0) + { + btn_role_resc.Visible = false; + } + if (Utility.userRole.IndexOf("用户授权") < 0) + { + btn_user_role.Visible = false; + } + if (Utility.userRole.IndexOf("密码修改") < 0) + { + btn_password_edit.Visible = false; + } + + } + #endregion + + #region 基础工具 + if (Utility.userRole.IndexOf("基础工具") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem1); + } + else + { + if (Utility.userRole.IndexOf("地上模式") < 0) + { + buttonItem87.Visible = false; + } + if (Utility.userRole.IndexOf("地下模式") < 0) + { + buttonItem88.Visible = false; + } + if (Utility.userRole.IndexOf("行走模式") < 0) + { + buttonItem27.Visible = false; + } + if (Utility.userRole.IndexOf("透明度设置") < 0) + { + sliderGroundTransSet1.Visible = false; + } + if (Utility.userRole.IndexOf("快速定位") < 0) + { + buttonItem91.Visible = false; + } + if (Utility.userRole.IndexOf("图层管理") < 0) + { + buttonItem1.Visible = false; + } + if (Utility.userRole.IndexOf("图例管理") < 0) + { + btnlegendSet.Visible = false; + } + if (Utility.userRole.IndexOf("全屏显示") < 0) + { + buttonItem89.Visible = false; + } + if (Utility.userRole.IndexOf("导出图片") < 0) + { + btnOutputJPG.Visible = false; + } + + } + #endregion + + #region 一键审核 + if (Utility.userRole.IndexOf("一键审核") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem11); + } + #endregion + + #region 红线审核 + if (Utility.userRole.IndexOf("红线审核") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem6); + } + #endregion + + #region 双屏对比 + if (Utility.userRole.IndexOf("双屏对比") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem9); + } + #endregion + + #region 文档管理 + if (Utility.userRole.IndexOf("文档管理") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem4); + } + #endregion + + #region 基础管理 + if (Utility.userRole.IndexOf("基础管理") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem14); + } + else + { + if (Utility.userRole.IndexOf("专题图审批") < 0) + { + buttonItemZTT3_2.Visible = false; + } + if (Utility.userRole.IndexOf("打印审批") < 0) + { + buttonItemZTT4_2.Visible = false; + } + if (Utility.userRole.IndexOf("拷贝审批") < 0) + { + buttonItemZTT5_2.Visible = false; + } + } + + #endregion + + if (ribbonControl1.Items.Count <= 0) + { + ribbonControl1.Visible = false; + } + } + + #region Fan Zhang 重构现有代码 + //初始化控件布局 + private void initLayout() + { + 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.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.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.labelX21.Width = (int)(this.labelX21.Width * myScreen); + this.labelX22.Width = (int)(this.labelX22.Width * myScreen); + this.labelX24.Width = (int)(this.labelX24.Width * myScreen); + } + sideBar1.Visible = false; + 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]); + } + + splitContainer1.Panel2Collapsed = true; + + buttonItem87.Checked = true;//默认地上模式 + ribbonTabItem1.Select(); //初始化状态为浏览 + + sideBarPanelItem3.Visible = false; + layerTree.Visible = false; + controlContainerItem3.Visible = false; + if (sideBarPanelItem4.Visible == true) + { + sideBar1.Visible = true; + controlContainerItem5.Visible = true; + } + else + { + sideBar1.Visible = false; + } + Refresh(); + sliderGroundTransSet1.Value = optiValue; + sliderItem1.Value = optiValue; + sliderItem2.Value = optiValue; + sliderItem3.Value = optiValue; + + } + + //初始化地球控件 + private void initGlobalControl() + { + //选择 + btnToolSelect = new GSOHudButton(); + btnToolSelect.SetImage(Application.StartupPath + "\\Resource\\image\\select1.png"); + btnToolSelect.FadeOut = false; + btnToolSelect.Align = EnumAlign.TopLeft; + btnToolSelect.SetOffset(20, 50); + btnToolSelect.Name = "1"; + btnToolSelect.HeightFixed = true; + btnToolSelect.WidthFixed = true; + globeControl1.Globe.AddHudControl(btnToolSelect); + globeControl2.Globe.AddHudControl(btnToolSelect); + + //浏览 + 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); + + //图例 + legend = new GSOHudButton(); + legend.SetImage(Application.StartupPath + "/Resource/图例P.jpg");//图例P + legend.SetOffset(0, 15); + legend.MinOpaque = 1; + legend.MaxOpaque = 1; + legend.FadeOut = false; + legend.Name = "legend"; + legend.Align = EnumAlign.BottomRight; + legend.Visible = false; + globeControl1.Globe.AddHudControl(legend); + + //实测 + legendSC = new GSOHudButton(); + legendSC.SetImage(Application.StartupPath + "/Resource/sc.jpg"); + legendSC.SetOffset(0, 15); + legendSC.MinOpaque = 1; + legendSC.MaxOpaque = 1; + legendSC.FadeOut = false; + legendSC.Name = "legendSC"; + legendSC.Align = EnumAlign.BottomRight; + globeControl1.Globe.AddHudControl(legendSC); + legendSC.Visible = false; + + //施工 + legendSG = new GSOHudButton(); + legendSG.SetImage(Application.StartupPath + "/Resource/sg.jpg"); + legendSG.SetOffset(0, 15); + legendSG.MinOpaque = 1; + legendSG.MaxOpaque = 1; + legendSG.FadeOut = false; + legendSG.Name = "legendSG"; + legendSG.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(legendSG); + legendSG.Visible = false; + + //管纵 + AddGZ(); + + 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; + globeControl1.Globe.IsReleaseMemOutOfView = true; + globeControl1.Globe.ControlPanel.Visible = true; + + globeControl2.Globe.UnderGroundFloor.Visible = false; + globeControl2.Globe.OverviewControl.Visible = false; + globeControl2.Globe.ScalerControl.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; + globeControl2.Globe.IsReleaseMemOutOfView = true; + globeControl2.Globe.ControlPanel.Visible = false; + + 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); + + //添加临时图层 + layerTemp = globeControl1.Globe.Layers.Add(Application.StartupPath + "\\tempLgdData.lgd"); + layerTemp2 = globeControl2.Globe.Layers.Add(Application.StartupPath + "\\tempLgdData2.lgd"); + if (layerTemp != null) + { + layerTemp.MaxVisibleAltitude = 1000; + } + + //添加城市7线图层 + 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"); + + //注册对应事件 + this.registerEvent(); + } + + //注册地球事件 + private bool registerEvent() + { + if (globeControl1 == null || globeControl2 == null) + { + return false; + } + 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); + + globeControl2.FeatureMouseClickEvent += new FeatureMouseClickEventHandler(globeControl2_FeatureMouseClickEvent); + globeControl2.CameraBeginMoveEvent += new CameraBeginMoveEventHandler(globeControl2_CameraBeginMoveEvent); + + globeControl1.MouseDoubleClick += new MouseEventHandler(globeControl1_MouseDoubleClick); + globeControl1.MouseClick += new MouseEventHandler(globeControl1_MouseClick); + globeControl1.MouseDown += new MouseEventHandler(globeControl1_MouseDown); + + globeControl2.MouseClick += new MouseEventHandler(globeControl2_MouseClick); + globeControl2.MouseDown += new MouseEventHandler(globeControl2_MouseDown); + + 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); + + return true; + } + + //加载两个地球数据 + private void loadData() + { + Thread t1 = new Thread(new ThreadStart(doLoadDataForGlobalControl1)); + t1.IsBackground = true; + t1.Start(); + + + } + + delegate void LoadDataForGlobalControl(); + + private void connectServer() + { + globeControl1.Globe.ConnectServer(Utility.serverip, Utility.serverport, "", ""); //加载locaServer中的数据 + globeControl2.Globe.ConnectServer(Utility.serverip, Utility.serverport, "", ""); //加载locaServer中的数据 + //初始化TreeView + // 勾选实测图层 + foreach (TreeNode tn in layerTree.Nodes) + { + if (tn.Nodes.Count > 0) + { + if (tn.Text == "实测数据") + { + tn.Checked = true; + foreach (TreeNode tnChild in tn.Nodes) + { + tnChild.Checked = true; + foreach (TreeNode tnGrandChild in tnChild.Nodes) + { + tnGrandChild.Checked = true; + } + } + } + } + } + } + + private void doLoadDataForGlobalControl1() + { + try + { + + globeControl1.Globe.Layers.MoveDown(10000); + //加载实测管线数据 + Utility.dataSource = globeControl1.Globe.DataManager.OpenOracleDataSource(Utility.DBServer.Trim() + "/" + Utility.dbdatabase.Trim(), "", "", Utility.userID, Utility.DBPassword); + + if (Utility.dataSource != null) + { + for (int j = 0; j < Utility.dataSource.DatasetCount; j++) + { + GSODataset dataset = Utility.dataSource.GetDatasetAt(j); + if (dataset != null && dictionaryNetLayerNameAndCaption.ContainsKey(dataset.Caption)) + { + dataset.Caption = dataset.Name; + globeControl1.Globe.Layers.Add(dataset); + } + } + } + //隐藏红线图层 + globeControl1.Globe.Layers.GetLayerByCaption("红线").Visible = false; + + //globleControl1中加载规划数据 + GSODataSource ghDS = globeControl1.Globe.DataManager.OpenOracleDataSource(Utility.ghdbip + "/" + Utility.ghdbname, "", "", Utility.ghdbuser, Utility.ghdbpwd); + if (ghDS != null) + { + for (int j = 0; j < ghDS.DatasetCount; j++) + { + GSODataset dataset = ghDS.GetDatasetAt(j); + if (dataset != null && dictionaryNetLayerNameAndCaption.ContainsKey(dataset.Caption)) + { + dataset.Caption = dataset.Name; + globeControl1.Globe.Layers.Add(dataset); + globeControl1.Globe.Layers[0].Visible = false; + } + } + } + + //globeControl1,globeControl2中加载施工数据 + GSODataSource sgDS = globeControl1.Globe.DataManager.OpenOracleDataSource(Utility.sgdbip + "/" + Utility.sgdbname, "", "", Utility.sgdbuser, Utility.sgdbpwd); + if (sgDS != null) + { + for (int m = 0; m < sgDS.DatasetCount; m++) + { + GSODataset dataset = sgDS.GetDatasetAt(m); + if (dataset != null && !dataset.Caption.Contains("SH") && dictionaryNetLayerNameAndCaption.ContainsKey(dataset.Caption)) + { + dataset.Caption = dataset.Name; + globeControl1.Globe.Layers.Add(dataset); + globeControl1.Globe.Layers[0].Visible = false; + + globeControl2.Globe.Layers.Add(dataset); + globeControl2.Globe.Layers[0].Visible = true; + } + } + } + + LoadDataForGlobalControl ss = new LoadDataForGlobalControl(connectServer); + ss(); + + } + catch (Exception ex) + { + MessageBox.Show(ex.Message); + } + } + + private void initLayerTree() + { + //加载临时图层节点 + layerManagerNode = new TreeNode(); + layerManagerNode.ImageIndex = 0; + layerManagerNode.SelectedImageIndex = 0; + layerManagerNode.Checked = true; + layerManagerNode.Text = "临时图层"; + layerTree.Nodes.Add(layerManagerNode); + + XmlDocument doc = new XmlDocument(); + doc.Load(filename); + XmlNodeList xmlLayerNodes = doc.SelectNodes("//layer"); + + foreach (XmlNode xmlLayerNode in xmlLayerNodes) + { + + //TODO LIST:创建一级TreeNode(实测、规划、施工) + TreeNode nodelayer = new TreeNode(); + string layerName = xmlLayerNode.Attributes["label"].Value; + nodelayer.Text = layerName; + nodelayer.Checked = false; + layerTree.Nodes.Add(nodelayer); + + XmlNodeList xmlChildLayerNodes = xmlLayerNode.ChildNodes; + foreach (XmlNode xmlChildLayerNode in xmlChildLayerNodes) + { + //TODO LIST:创建二级TreeNode节点 + TreeNode secondLevelNode = new TreeNode(); + string layerType = xmlChildLayerNode.Attributes["label"].Value; + secondLevelNode.Text = layerType; + + if (xmlChildLayerNode.Attributes["type"] != null) + { //道路图层特殊处理 + string type = xmlChildLayerNode.Attributes["type"].Value; + secondLevelNode.Tag = type + "|" + layerType; + } + else + { + secondLevelNode.Tag = layerType; + } + secondLevelNode.Checked = false; + nodelayer.Nodes.Add(secondLevelNode); + + XmlNodeList xmlActitualLayerNodes = xmlChildLayerNode.ChildNodes; + + foreach (XmlNode xmlActitualLayerNode in xmlActitualLayerNodes) + { + //TODO LIST:创建三级图层节点 + TreeNode layerNode = new TreeNode(); + string actutallylayerType = xmlActitualLayerNode.Attributes["type"].Value; + string actutallylayerName = xmlActitualLayerNode.Attributes["layer"].Value; + string actutallyLabelName = xmlActitualLayerNode.Attributes["label"].Value; + + layerNode.Text = actutallyLabelName; + layerNode.Tag = layerType + "|" + actutallyLabelName; + layerNode.Checked = false; + secondLevelNode.Nodes.Add(layerNode); + } + + } + + } + + } + + /** + * 读取Config.xml文件,初始化以下全局Map + * m_PipelineLayerNames:管线 + * workwellLayerNames:工井 + * valueLayerNames:阀门 + * instrumenLayerNames:附属物 + * pipefittingLayerNames:特征管点 + * sgPipeLayersNames:施工管线 + **/ + private void initGlobalMap() + { + XmlDocument doc = new XmlDocument(); + doc.Load(filename); + XmlNodeList xmlLayerNodes = doc.SelectNodes("//layerchild"); + + foreach (XmlNode xmlLayerNode in xmlLayerNodes) + { + string layerType = xmlLayerNode.Attributes["type"].Value; + string layerName1 = xmlLayerNode.Attributes["layer"].Value; + string layerchildName = xmlLayerNode.Attributes["label"].Value; + + dictionaryNetLayerNameAndCaption.Add(layerName1, layerchildName); + + if (layerType != "db") + { + if (xmlLayerNode.Attributes["isRoad"] != null) + { + roadLayerName = layerchildName; + } + } + else if (xmlLayerNode.Attributes["isPipeLine"] != null) + { + m_PipelineLayerNames.Add(layerchildName); + g1layername.Add(layerName1); + } + else if (xmlLayerNode.Attributes["isWorkWell"] != null) + { + workwellLayerNames.Add(layerchildName); + g1layername.Add(layerName1); + } + else if (xmlLayerNode.Attributes["isValve"] != null) + { + valueLayerNames.Add(layerchildName); + g1layername.Add(layerName1); + } + else if (xmlLayerNode.Attributes["isAccess"] != null) + { + instrumenLayerNames.Add(layerchildName); + g1layername.Add(layerName1); + } + else if (xmlLayerNode.Attributes["isCharacter"] != null) + { + pipefittingLayerNames.Add(layerchildName); + g1layername.Add(layerName1); + } + else if (xmlLayerNode.Attributes["isSgData"] != null) + { + sgPipeLayersNames.Add(layerchildName); + g1layername.Add(layerName1); + } + + } + } + + private void initMarkerTree() + { + 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); + } + } + } + } + + private void MainFrm_Load(object sender, EventArgs e) + { + + this.initGlobalControl(); + this.initGlobalMap(); + this.initLayerTree(); + this.initMarkerTree(); + this.initLayout(); + this.loadData(); + + + double x = Convert.ToDouble(Utility.Query_Roads["绿岛"].ToString().Split(',')[0]); + double y = Convert.ToDouble(Utility.Query_Roads["绿岛"].ToString().Split(',')[1]); + double z = Convert.ToDouble(Utility.Query_Roads["绿岛"].ToString().Split(',')[2]); + jumpToCameraState(x, y, z); + + + } + + #endregion + + /// + /// 每次gis服务加载时都会触发的 + /// + /// + /// + 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 dictionaryNetLayerNameAndCaption = new Dictionary(); + 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 配置用户权限 + /// + /// 向数据库插入功能列表 + /// + private void insertControlToDatabase() + { + ArrayList listItem = new ArrayList(); + List subListItem = new List(); + 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) + { + GSOCameraState camera = globeControl2.Globe.CameraState; + globeControl1.Globe.JumpToCameraState(camera); + } + } + + void globeControl1_BeforeSceneRenderEvent(object sender, BeforeSceneRenderEventArgs e) + { + if (globeControl1.Focused) + { + 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); + } + } + } + + /// + /// 检查数据集是否有坐标系信息 + /// + /// + /// + 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 = "0prj4" + lprjStr + ""; + + bSuccess = dataset.LoadProjectionFromESRIFile(dlg.FileName); + + string lprjFileName = strDataPath.Substring(0, strDataPath.LastIndexOf(".")) + ".lprj"; + StreamWriter writer = new StreamWriter(lprjFileName, false); + writer.Write(lprjFileContent); + writer.Close(); + + } + } + } + else + { + return true; + } + return bSuccess; + } + + /// + /// 矩形拉框结束事件处理函数 + /// + /// + /// + 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))); + */ + + int mapWidth = 0; + int mapHeight = 0; + Point pt = getUpperLeftPoint(pt1, pt2, out mapWidth, out mapHeight); + int rightBottomX = pt.X + mapWidth; + int rightBottomY = pt.Y + mapHeight; + Image myImg = new Bitmap(mapWidth, mapHeight); + Graphics g = Graphics.FromImage(myImg); + g.CopyFromScreen(pt, new Point(0, 0), new Size(rightBottomX, rightBottomY)); + + 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; + } + } + /// + /// 定位正北正90度俯视 + /// + /// + /// + /// + 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; + } + } + /// + /// layerTree选中后事件处理 + /// + /// + /// + 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); + } + /// + /// 树节点选中方法 + /// + /// + 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); + } + } + } + + } + /// + /// 改变所有子节点的状态 + /// + /// + /// + 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; + LayerFlyMenuItem.Visible = true; + } + + LayerSelectableMenuItem.Visible = true; + LayerEditableMenuItem.Visible = true; + SaveLayerMenuItem.Visible = true; + LayerFlyMenuItem.Visible = true; + 导出CADToolStripMenuItem1.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]); + if (layer != null) + { + LayerSelectableMenuItem.Checked = layer.Selectable; + LayerEditableMenuItem.Checked = layer.Editable; + } + else + { + return; + } + } + 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; + } + } + } + } + } + + /// + /// 删除临时添加的本地数据图层 + /// + /// + /// + 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); + for (int i = globeControl1.Globe.Layers.Count-1; i >=0; i--) + { + if (globeControl1.Globe.Layers[i].Caption == layer.Caption) + { + globeControl1.Globe.Layers.Remove(globeControl1.Globe.Layers[i]); + } + } + + 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 定位ToolStripMenuItem_Click(object sender, EventArgs e) + { + TreeNode node = layerTree.SelectedNode; + + if (node != null) + { + if (node.Parent.Text.Trim() == "临时图层") + { + GSOLayer lsLayer = globeControl1.Globe.Layers.GetLayerByCaption(node.Text.ToString()); + double x = lsLayer.LatLonBounds.Center.X; + double y = lsLayer.LatLonBounds.Center.Y; + if (x == 0 && y == 0) + { + x = lsLayer.Bounds.Center.X; + y = lsLayer.Bounds.Center.Y; + } + + globeControl1.Globe.FlyToPosition(new GSOPoint3d(x, y, 10), EnumAltitudeMode.Absolute); + } + else + { + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(node.Tag.ToString().Split('|')[1]); + + if (layer != null) + { + if (layer.Caption == "红线") + { + globeControl1.Globe.FlyToPosition(new GSOPoint3d(120.610963, 31.188121, 50), EnumAltitudeMode.Absolute, -4, 50, 1000); + globeControl1.Globe.FlyToPointSpeed = 10000000; + globeControl1.Globe.Action = EnumAction3D.SelectObject; + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = true; + } + globeControl1.Refresh(); + } + else + { + double x = layer.LatLonBounds.Center.X; + double y = layer.LatLonBounds.Center.Y; + globeControl1.Globe.FlyToPosition(new GSOPoint3d(x, y, 100), EnumAltitudeMode.Absolute); + } + } + } + } + else + { + return; + } + + } + + private void layerTree_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e) + { + if(this.layerTree.SelectedNode!=null) + { + if (this.layerTree.SelectedNode.Tag.ToString().Contains("|")) + { + string nodeTag = this.layerTree.SelectedNode.Tag.ToString().Split('|')[1]; + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(nodeTag); + if (layer != null) + { + if (layer.Caption == "红线") + { + globeControl1.Globe.FlyToPosition(new GSOPoint3d(120.610963, 31.188121, 50), EnumAltitudeMode.Absolute, -4, 50, 1000); + globeControl1.Globe.FlyToPointSpeed = 10000000; + globeControl1.Globe.Action = EnumAction3D.SelectObject; + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = true; + } + globeControl1.Refresh(); + } + else { + double x = layer.LatLonBounds.Center.X; + double y = layer.LatLonBounds.Center.Y; + globeControl1.Globe.FlyToPosition(new GSOPoint3d(x, y, 0), EnumAltitudeMode.Absolute); + } + } + } + if (this.layerTree.SelectedNode.Tag is GSOLayer) + { + GSOLayer layer = this.layerTree.SelectedNode.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 (this.layerTree.SelectedNode.Tag is GSOFeature) + { + GSOFeature feature = this.layerTree.SelectedNode.Tag as GSOFeature; + if (feature.Geometry != null) + { + globeControl1.Globe.FlyToPosition(feature.Geometry.GeoCenterPoint, EnumAltitudeMode.Absolute, 0, 0, 10); + } + else + { + globeControl1.Globe.FlyToFeature(feature); + } + } + } + } + + /// + /// 在三维场景移动时,隐藏气泡globeControl1 + /// + /// + /// + void globeControl1_CameraBeginMoveEvent(object sender, CameraBeginMoveEventArgs e) + { + if (featureTooltip.IsVisible()) + { + featureTooltip.HideBalloon(); + } + if (balloonEx.IsVisible()) + { + balloonEx.HideBalloon(); + } + } + + /// + /// 在三维场景移动时,隐藏气泡globeControl2 + /// + /// + /// + void globeControl2_CameraBeginMoveEvent(object sender, CameraBeginMoveEventArgs e) + { + if (featureTooltip2.IsVisible()) + { + featureTooltip2.HideBalloon(); + } + if (balloonEx2.IsVisible()) + { + balloonEx2.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(); + } + } + + #region Fan 横断面 + /// + /// 横断面分析、基线剖面分析、道路断面分析等 + /// + /// + /// + private static EnumTrackPolylineEndMode trackPolylineEndMode; + + void globeControl1_TrackPolylineEndEvent(object sender, TrackPolylineEndEventArgs e) + { + //横断面分析、道路横断面分析 + if (trackPolylineEndMode == EnumTrackPolylineEndMode.HDM_Analysis|| + trackPolylineEndMode == EnumTrackPolylineEndMode.DLDM_Analysis) + { + Dictionary hdmDic = SectionAnalysisTool.HDMAnalysis(this.globeControl1, + e.Polyline, this.m_PipelineLayerNames); + FrmHDMAnalysis3 frm = new FrmHDMAnalysis3(hdmDic, this.globeControl1, + trackPolylineEndMode); + frm.Show(this); + } + //基线剖面分析 + else if (trackPolylineEndMode == EnumTrackPolylineEndMode.JXPM_Analysis) + { + FrmBaseLineProfillAnalysis dlg = new FrmBaseLineProfillAnalysis(globeControl1.Globe, e.Polyline); + dlg.Show(this); + globeControl1.Globe.ClearLastTrackPolyline(); + } + else + { + + } + trackPolylineEndMode = EnumTrackPolylineEndMode.Default_Analysis; + } + #endregion + + private GSOFeatures PolygonIntersectAnalysis(GSOGeoPolygon3D polygon, string pipelinetype) + { + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(pipelinetype); + 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(pipelinetype, feats.Length); + return feats; + } + /// + /// 根据范围统计阀门、管线、工井等, 开挖分析, 挖方量分析 + /// + /// + /// + void globeControl1_TrackPolygonEndEvent(object sender, TrackPolygonEndEventArgs e) + { + if (globeControl1.Globe.Action == EnumAction3D.TrackPolygon && e.Polygon != null) + { + GSOGeoPolygon3D polygon = e.Polygon; + + switch (trackflag) + { + case "valvequery": + FrmValveStatistics frm = new FrmValveStatistics(globeControl1,polygon, new DataGridViewDelegate(InitDataGridViewX1)); + frm.Show(this); + globeControl1.Globe.Action = EnumAction3D.ActionNull; + break; + + case "PipelineDistanceStatistics": + FrmAllPipelineStatis frm1 = new FrmAllPipelineStatis(globeControl1, polygon, new DataGridViewDelegate(InitDataGridViewX1), m_PipelineLayerNames); + frm1.Show(this); + globeControl1.Globe.Action = EnumAction3D.ActionNull; + + break; + case "PipelineSpatialQuery": + FrmAllPipelineStatis.ShowForm(globeControl1,polygon,new DataGridViewDelegate(InitDataGridViewX1),m_PipelineLayerNames); + globeControl1.Globe.ClearAnalysis(); + globeControl1.Globe.Action = EnumAction3D.ActionNull; + + break; + case "workwellquery": + FrmAllWorkWellStatis frmWell = new FrmAllWorkWellStatis(globeControl1, polygon, new DataGridViewDelegate(InitDataGridViewX1)); + 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 "BSQDuoBianXiangStatis": + + GSOFeature f2 = new GSOFeature(); + f2.Geometry = e.Polygon; + f2.Geometry.AltitudeMode = EnumAltitudeMode.Absolute; + globeControl1.Globe.MemoryLayer.AddFeature(f2); + f2.Geometry.MoveZ(3); + workWellLen.Clear(); + List listBSQ = new List(); + + GSOFeatures bsqFeatures = PolygonIntersectAnalysis(e.Polygon, "标识器"); + listBSQ.Add(bsqFeatures); + + FrmBSQDuoBianXingStatis bsqFrm = new FrmBSQDuoBianXingStatis(workWellLen, globeControl1, listBSQ); + bsqFrm.Show(this); + globeControl1.Globe.Action = EnumAction3D.ActionNull; + break; + + case "": + break; + default: + break; + } + } + } + + #region 验证端口 + /* + /// + /// 验证端口 + /// + /// + 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 + + /// + /// 鼠标悬浮提示 + /// + /// + /// + 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); + } + } + + /// + /// 添加管线绘制完成事件, 红线工具绘制完成 + /// + /// + /// + 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; + + + } + } + + /// + /// 获取globeControl1中鼠标按下的坐标供区别鼠标右键和滚轮按下事件 + /// + /// + /// + void globeControl1_MouseDown(object sender, MouseEventArgs e) + { + mouseDownX1 = e.X; + mouseDownY1 = e.Y; + } + /// + /// 获取globeControl2中鼠标按下的坐标供区别鼠标右键和滚轮按下事件 + /// + /// + /// + void globeControl2_MouseDown(object sender, MouseEventArgs e) + { + mouseDownX2 = e.X; + mouseDownY2 = e.Y; + } + /// + /// + /// + /// + /// + void globeControl2_MouseClick(object sender, MouseEventArgs e) + { + if (e.Button == MouseButtons.Right) + { + if (e.X == mouseDownX2 && e.Y == mouseDownY2) + { + RightScreenToolMenu.Show(globeControl2, e.X, e.Y); + } + else + { + return; + } + } + } + /// + /// + /// + /// + /// + void globeControl1_MouseClick(object sender, MouseEventArgs e) + { + if (e.Button == MouseButtons.Left) + { + if (globeControl1.Globe.Action == EnumAction3D.VisibilityAnalysis) + { + buttonItemFX5_1.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; + + bsqPT = pt; + + if (buttonItemLS5.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 (e.X == mouseDownX1 && e.Y == mouseDownY1) + { + toolRightMenu.Show(globeControl1, e.X, e.Y); + if (buttonItemLS5.Checked) + { + buttonItemLS5.Checked = false; + } + } + else + { + return; + } + } + globeControl1.Refresh(); + } + + /// + /// 判断网络图片是否存在 + /// + /// + /// + 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; + } + + /// + /// 鼠标点击, 弹出气泡功能globeControl1 + /// + /// + /// + void globeControl1_FeatureMouseClickEvent(object sender, FeatureMouseClickEventArgs e) + { + GSOFeature feature = e.Feature; + + string str1 = ""; + if (feature != null) + { + if (feature.GetFieldDefn("图片编码") != null)// + { + str1 = GetBubbleInfo(feature, globeControl1); + if (RemoteFileExists(Utility.PicRootURL + feature.GetValue("图片编码").ToString())) + { + str1 += ""; + } + else if (RemoteFileExists(Utility.PicDefaultURL)) + { + str1 += ""; + } + } + else if (isFeatureContainsBianhao(feature)) //管线模型图层 + { + str1 = GetBubbleInfo(feature, globeControl1); + } + + 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; + } + } + } + + /// + /// 鼠标点击, 弹出气泡功能globeControl2 + /// + /// + /// + void globeControl2_FeatureMouseClickEvent(object sender, FeatureMouseClickEventArgs e) + { + GSOFeature feature = e.Feature; + + string str1 = ""; + if (feature != null) + { + if (feature.GetFieldDefn("图片编码") != null) // + { + str1 = GetBubbleInfo(feature, globeControl2); + if (RemoteFileExists(Utility.PicRootURL + feature.GetValue("图片编码").ToString())) + { + str1 += ""; + } + else if (RemoteFileExists(Utility.PicDefaultURL)) + { + str1 += ""; + } + } + else if (isFeatureContainsBianhao(feature)) //管线模型图层 + { + str1 = GetBubbleInfo(feature, globeControl2); + } + + if (str1 != "") + { + + featureTooltip2.HideBalloon(); + balloonEx2.HideBalloon(); + balloonEx2.SetSize(EnumSizeIndexEx.CONTENT_CX, 480); + balloonEx2.SetSize(EnumSizeIndexEx.CONTENT_CY, 420); + balloonEx2.ShowBalloon((int)e.MousePos.X, (int)e.MousePos.Y, str1); + + return; + } + } + } + + /// + /// 拼接气泡表格字符串 + /// + /// + /// + private string GetBubbleInfo(GSOFeature feature,GSOGlobeControl globeControl) + { + if (feature == null) + { + return ""; + } + string str = ""; + str = ""; + 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 += ""; + + 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.get_Fields(layerName, globeControl); + } + if (queryFields != null) + { + string[] param = { "," }; + string[] fieldNames = queryFields.Split(param, StringSplitOptions.RemoveEmptyEntries); + for (int j = 0; j < fieldNames.Length; 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 (name1 == "模型路径") + { + continue; + } + 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 (field1.Type == EnumFieldType.Double) + { + double dl1 = feature.GetFieldAsDouble(j); + if (!name1.Contains("管径") && !name1.Contains("电压") && !name1.Contains("角度")) + { + name1 += "_米"; + } + value1 = dl1.ToString("0.00"); + } + 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 (name2 == "模型路径") + { + continue; + } + + 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 (field2.Type == EnumFieldType.Double) + { + double dl2 = feature.GetFieldAsDouble(j + 1); + if (!name2.Contains("管径") && !name2.Contains("电压") && !name2.Contains("角度")) + { + name2 += "_米"; + } + value2 = dl2.ToString("0.00"); + } + else + { + if (!feature.IsFieldValueNull(j + 1)) + { + value2 = feature.GetValue(j + 1).ToString(); + } + } + } + } + + j++; + } + str += ""; + } + } + str += "
" + title + " " + feature.GetFieldAsString(featureIDFieldName) + "
" + + name1 + + "
" + + value1 + + "
" + + name2 + + "
" + + value2 + "
"; + return str; + } + + string filename = Utility.filename; + List g1layername = new List(); + + /// + /// 获取目标图层 + /// + /// + 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; + } + /// + /// 添加图层 + /// + /// + /// + /// + 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 = 5000; + return templayer.Visible; + } + catch (Exception ex) + { + return false; + } + } + /// + /// 菜单上的 三维导航 工具按钮 + /// + /// + /// + private void buttonItem86_Click(object sender, EventArgs e) + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + } + + /// + /// 地上模式 菜单按钮 + /// + /// + /// + 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(); + + } + } + /// + /// 地下模式 菜单按钮 + /// + /// + /// + 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(); + } + } + /// + /// 行走模式 菜单按钮 + /// + /// + /// + 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; + } + } + /// + /// 地面透明度设置 菜单 + /// + /// + /// + private void sliderGroundTransSet1_ValueChanged(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.sliderGroundTransSet1.Text); + + globeControl1.Globe.GroundOpaque = 100 - sliderGroundTransSet1.Value; + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(roadLayerName);//("180fd"); + if (layer != null) + { + layer.Opaque = 100 - sliderGroundTransSet1.Value; + } + //if (buttonItemSPDB.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; + } + /// + /// 图例 菜单按钮 + /// + /// + /// + 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(); + } + /// + /// 快速定位 菜单按钮 + /// + /// + /// + private void buttonItem91_Click(object sender, EventArgs e) // + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItem91.Text); + FrmFlyToPosition fly = new FrmFlyToPosition(globeControl1); + fly.Show(this); + } + /// + /// 图层管理 菜单按钮 + /// + /// + /// + 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; + + //修改图层管理与标注管理、覆土审查、水平净距分析、垂直净距分析和碰撞分析控件之间的逻辑关系 + controlContainerItem5.Visible = false; + sideBar1.Visible = false; + sideBarPanelItem4.Visible = false; + panel3.Visible = false; + sideBar1.ExpandedPanel = sideBarPanelItem3; + buttonItemBZ11.Checked = false; + + //20160624 + /* + if (sideBarPanelItem4.Visible == true) + { + sideBar1.Visible = true; + controlContainerItem5.Visible = true; + } + else + { + sideBar1.Visible = false; + } + */ + Refresh(); + + } + } + /// + /// 全屏显示 菜单按钮 + /// + /// + /// + 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; + /// + /// 全屏显示功能实现 + /// + 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(); + } + } + + /// + /// 设置窗体宽、高 + /// + /// + /// + private void SetFullScreen(int width, int height) + { + this.Width = width; + this.Height = height; + } + + /// + /// 全屏功能的快捷键F5 + /// + /// + /// + 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); + } + } + /* + /// + /// 输出地图 + /// + /// + /// + /// + 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; + } + * */ + + private Point getUpperLeftPoint(Point p1, Point p2, out int mapWidth, out int mapHeight) // + { + Rectangle rc = new Rectangle(); + + p1 = this.globeControl1.PointToScreen(p1); + p2 = this.globeControl1.PointToScreen(p2); + + int x = Screen.PrimaryScreen.Bounds.X; + int y = Screen.PrimaryScreen.Bounds.Y; + int screenWidth = SystemInformation.WorkingArea.Width; + int screenHeight = SystemInformation.WorkingArea.Height; + + if (p1.X < x) + rc.X = x; + else + rc.X = p1.X; + + if (p1.Y < y) + rc.Y = y; + else + rc.Y = p1.Y; + + p1.X = rc.Left; + p1.Y = rc.Top; + + if (p2.X > screenWidth) + p2.X = screenWidth; + else + p2.X = p2.X; + + if (p2.Y > screenHeight) + p2.Y = screenHeight; + else + p2.Y = p2.Y; + + rc.Width = p2.X - rc.X; + rc.Height = p2.Y - rc.Y; + + mapWidth = rc.Width; + mapHeight = rc.Height; + Point pt = new Point(rc.Left, rc.Top); + return pt; + } + + Image printImage; + /// + /// 打印 菜单 + /// + /// + /// + 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))); + */ + int mapWidth = 0; + int mapHeight = 0; + Point pt = getUpperLeftPoint(pt1, pt2, out mapWidth, out mapHeight); + int rightBottomX = pt.X + mapWidth; + int rightBottomY = pt.Y + mapHeight; + Image myImg = new Bitmap(mapWidth, mapHeight); + Graphics g = Graphics.FromImage(myImg); + g.CopyFromScreen(pt, new Point(0, 0), new Size(rightBottomX, rightBottomY)); + + + 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); + } + /// + /// 输出地图 菜单 + /// + /// + /// + private void btnOutputJPG_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btnOutputJPG.Text); + + //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))); + */ + int mapWidth = 0; + int mapHeight = 0; + Point pt = getUpperLeftPoint(pt1, pt2, out mapWidth, out mapHeight); + int rightBottomX = pt.X + mapWidth; + int rightBottomY = pt.Y + mapHeight; + Image myImg = new Bitmap(mapWidth, mapHeight); + Graphics g = Graphics.FromImage(myImg); + g.CopyFromScreen(pt, new Point(0, 0), new Size(rightBottomX, rightBottomY)); + + 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; + } + } + } + + /// + /// 统计管线的里程数 + /// + /// + /// + /// + 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; + } + + /// + /// 窗体下方属性表格 右键菜单中的 “定位”菜单 + /// + /// + /// + 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); + + } + + /// + /// 表格中右键 “单个闪烁” 菜单 + /// + /// + /// + private void LightMenu_Click(object sender, EventArgs e) + { + flashflag = "single"; + timer1.Start(); + } + /// + /// 表格中右键 “全部闪烁” 菜单 + /// + /// + /// + private void AllLightMenuItem_Click(object sender, EventArgs e) + { + flashflag = "all"; + timer1.Start(); + } + + /// + /// 使用timer实现管线的闪烁效果 + /// + /// + /// + 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; + } + } + + /// + /// 绘制线 菜单 + /// + /// + /// + private void btnAddLine_Click(object sender, EventArgs e) + { + globeControl1.Globe.DestLayerFeatureAdd = globeControl1.Globe.MemoryLayer; + globeControl1.Globe.Action = EnumAction3D.DrawPolyline; + } + /// + /// 绘制面 菜单 + /// + /// + /// + private void btnAddPolygon_Click(object sender, EventArgs e) + { + globeControl1.Globe.DestLayerFeatureAdd = globeControl1.Globe.MemoryLayer; + globeControl1.Globe.Action = EnumAction3D.DrawPolygon; + } + /// + /// 图层目录树 右键菜单中的 目标图层 菜单 + /// + /// + /// + 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; + } + } + /// + /// 图层目录树 右键菜单中的 可选择 菜单 + /// + /// + /// + 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; + } + /// + /// 图层目录树 右键菜单中的 可编辑 菜单 + /// + /// + /// + 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; + } + /// + /// 图层目录树 右键菜单中的 保存 菜单 + /// + /// + /// + 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(); + } + + /// + /// 根据多边形范围统计管线的里程 + /// + /// + /// + /// 返回查询到的管线要素集合 + 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 pipeLineDis = new Dictionary(); + Dictionary workWellLen = new Dictionary(); + + + + + /// + /// 查找指定图层中在 指定范围内的feature对象集合 + /// + /// + /// + /// + 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; + } + /// + /// 清除结果 菜单 + /// + /// + /// + private void buttonItem47_Click(object sender, EventArgs e) + { + globeControl1.Globe.ClearAnalysis(); + dataGridViewX1.DataSource = null; + panelOfTable.Visible = false; + clearFeatureHighLight(); + } + /// + /// 设置菜单的选中状态 + /// + private void ActionToolMenuChecked() + { + if (globeControl1.Globe.Action != EnumAction3D.TrackPolyline) + { + buttonItemFX2_1.Checked = false; + buttonItemFX2_4.Checked = false; + buttonItemFX2_3.Checked = false; + buttonItemFX4_3.Checked = false; + } + if (globeControl1.Globe.Action != EnumAction3D.NormalHit) + { + buttonItemFX3_6.Checked = false; + // ClearConnexityAnalysis(); + + buttonItemFX3_5.Checked = false; + // ClearCloseValvesAnalysis(); + } + if (globeControl1.Globe.Action != EnumAction3D.TrackPolygon) + { + buttonItemFX4_2.Checked = false; + buttonItemFX4_1.Checked = false; + } + } + + /// + /// 主窗体关闭事件处理 + /// + /// + /// + private void MainFrm_FormClosing(object sender, FormClosingEventArgs e) + { + + if (MessageBox.Show("是否退出系统?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) + { + e.Cancel = true; + } + else { + globeControl1.Globe.MemoryLayer.SaveAs(Application.StartupPath + "/MyPlace.kml"); + } + + //saveLayerList(layerManagerNode.Nodes); + //注销id号为103的热键设定 + // UnregisterHotKey(Handle, 103); + } + + /// + /// 显示流向 功能 + /// + /// + /// + /// + 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(); + } + + FrmCloseValves frm; + + FrmBoosterValvers frmbooster = null; + + /// + /// 垂直净距分析 功能界面中的 选择图层复选框 选中状态改变事件处理 + /// + /// + /// + 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(); + } + /// + /// 水平净距分析 功能界面中的 选择图层复选框 选中状态改变事件处理 + /// + /// + /// + 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(); + } + /// + /// 垂直净距分析 功能界面中的 选择管线复选框 选中状态改变事件处理 + /// + /// + /// + private void checkBoxX1_CheckedChanged(object sender, EventArgs e) + { + clearFeatureHighLight(); + if (checkBoxX1.Checked) + { + comboBoxEx1.SelectedItem = null; + 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; + } + } + /// + /// 水平净距分析 功能界面中的 选择管线复选框 选中状态改变事件处理 + /// + /// + /// + private void checkBoxX1_CheckedChanged_shuiping(object sender, EventArgs e) + { + clearFeatureHighLight();//清除高亮 + if (checkBoxX7.Checked) + { + comboBoxEx4.SelectedItem = null; + 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(); + /// + /// 垂直净距分析 功能界面中的 选择图层下拉框 选中项改变 事件处理 + /// + /// + /// + 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; + } + } + } + /// + /// 水平净距分析 功能界面中的 选择图层下拉框 选中项改变 事件处理 + /// + /// + /// + 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 featCount = new Dictionary(); + Dictionary featLenth = new Dictionary(); + Dictionary m_FeaturesWithBianhao = new Dictionary();//记录编号和对应的标注点的位置 + GSOFeatures polygonJingJuAnalysises = new GSOFeatures(); + + /// + /// 垂直净距分析 功能界面中的 开始分析按钮 事件处理 + /// + /// + /// + 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; + } + + /// + /// 在指定的两点组成的线的中间添加一个marker对象,并将marker对象添加到指定的图层中 + /// + /// + /// + /// + /// + /// + 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; + } + + /// + /// 计算指定feature对象与除了该feature所在图层之外的 所有管线图层中的所有feature对象 的垂直距离 并在表格中记录符合要求的管线 + /// + /// + /// + /// + /// + private void VerticalDistanceAnalysis(string type, GSOFeature selectedFeature, List _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(); + } + /// + /// 垂直净距分析中 表格行的 双击定位 功能。 与覆土分析的实现方法不同,主要原因是需要标注垂距 + /// + /// + /// + 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); + } + } + } + } + + /// + /// 水平净距分析 功能界面中 开始分析按钮 的事件处理 + /// + /// + /// + 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; + } + + + /// + /// 计算指定feature对象与除了该feature所在图层之外的 所有管线图层中的所有feature对象 的水平距离 并记录符合要求的管线 功能 + /// + /// + /// + /// + /// + private void HorizontalDistanceAnalysis(GSOFeature selectedFeature, List _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)); + } + } + } + } + } + /// + /// 水平净距分析 功能界面中 表格的 双击定位 功能 + /// + /// + /// + 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); + } + } + } + } + } + /// + /// 碰撞分析 功能界面中 开始分析按钮 事件处理 + /// + /// + /// + 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; + } + /// + /// 碰撞分析功能界面中 表格的 双击定位 功能 + /// + /// + /// + 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); + } + } + } + } + + + + /// + /// 覆土分析功能操作界面中的 选择管线 复选框选中状态改变事件处理 + /// + /// + /// + private void checkBoxX5_CheckedChanged(object sender, EventArgs e) + { + clearFeatureHighLight(); + if (checkBoxX5.Checked) + { + comboBoxEx3.SelectedItem = null; + 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; + } + } + /// + /// 覆土分析功能操作界面中的 选择图层 复选框选中状态改变事件处理 + /// + /// + /// + 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(); + } + /// + /// 覆土分析功能操作界面中的 图层下拉框选中项改变事件处理 + /// + /// + /// + 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; + } + } + } + /// + /// 覆土分析功能操作界面中的 开始分析 按钮事件处理 + /// + /// + /// + 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; + + + GSOPoint3d markerPosition = new GSOPoint3d(); + 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]; + GSOPoint3d pt = new GSOPoint3d(); + + 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"); + + pt.X = pts[m].X; + pt.Y = pts[m].Y; + pt.Z = 0; + markerPosition = LabelVerticalDistance(layerTemp, pts[m], pt, Convert.ToDouble(dataGridViewX7.Rows[idx].Cells[2].Value), true); + 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]; + GSOPoint3d pt = new GSOPoint3d(); + 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"); + + pt.X = pts[m].X; + pt.Y = pts[m].Y; + pt.Z = 0; + markerPosition = LabelVerticalDistance(layerTemp, pts[m], pt, Convert.ToDouble(dataGridViewX7.Rows[idx].Cells[2].Value), true); + + 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; + } + + /// + /// 覆土分析中 表格的 双击定位 功能 + /// + /// + /// + 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); + } + } + } + } + } + /// + /// 覆土分析功能操作界面中的 导出Excel按钮 事件处理 + /// + /// + /// + private void buttonX10_Click(object sender, EventArgs e) + { + if (dataGridViewX7.Rows.Count > 0) + { + ExportExcel("覆土分析", dataGridViewX7, null); + } + else + { + MessageBox.Show("表格内容为空!", "提示"); + } + } + /// + /// 覆土分析功能操作界面底部的 关闭 按钮事件处理 + /// + /// + /// + 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(); + layerTemp.RemoveAllFeature(); + + if (buttonItem1.Checked) + { + sideBar1.ExpandedPanel = sideBarPanelItem3; + } + else + { + sideBar1.Visible = false; + } + globeControl1.Refresh(); + + //Refresh(); + } + + + /// + /// 垂直净距分析 功能界面中 清除分析结果按钮 事件处理 + /// + /// + /// + 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(); + } + /// + /// 水平净距分析 功能界面中 清除分析结果按钮 事件处理 + /// + /// + /// + 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(); + } + + /// + /// 垂直净距分析功能界面中 关闭按钮 事件处理 + /// + /// + /// + 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(); + } + /// + /// 水平净距分析功能界面中 删除缓冲区按钮 事件处理 + /// + /// + /// + private void buttonX14_Click(object sender, EventArgs e) + { + 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(); + } + + /// + /// 导出指定DataGridView控件中的内容 + /// + /// + /// + 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(); + } + } + } + } + + /// + /// 垂直净距分析功能界面中 导出Excel按钮 事件处理 + /// + /// + /// + private void buttonX4_Click(object sender, EventArgs e) + { + if (dataGridViewX3.Rows.Count > 0) + { + ExportExcel("垂直净距分析", dataGridViewX3, listBox1); + } + else + { + MessageBox.Show("表格内容为空!", "提示"); + } + } + /// + /// 水平净距分析功能界面中 导出Excel按钮 事件处理 + /// + /// + /// + private void buttonX4_Click_shuiping(object sender, EventArgs e) + { + if (dataGridViewX9.Rows.Count > 0) + { + ExportExcel("水平净距分析", dataGridViewX9, listBox3); + } + else + { + MessageBox.Show("表格内容为空!", "提示"); + } + } + + + /// + /// 清除所有坑 菜单 + /// + /// + /// + private void buttonItem3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItem3.Text); + + globeControl1.Globe.RemoveAllPits(); + } + + //} + /// + /// 大气层 菜单 + /// + /// + /// + private void buttonItem17_Click_1(object sender, EventArgs e) + { + globeControl1.Globe.Atmosphere.Visible = !globeControl1.Globe.Atmosphere.Visible; + buttonItemSH1.Checked = globeControl1.Globe.Atmosphere.Visible; + globeControl1.Refresh(); + } + /// + /// 经纬网 菜单 + /// + /// + /// + private void buttonItem20_Click(object sender, EventArgs e) + { + globeControl1.Globe.LatLonGrid.Visible = !globeControl1.Globe.LatLonGrid.Visible; + buttonItemSH3.Checked = globeControl1.Globe.LatLonGrid.Visible; + globeControl1.Globe.Refresh(); + } + /// + /// 状态条 菜单 + /// + /// + /// + private void buttonItem21_Click_1(object sender, EventArgs e) + { + globeControl1.Globe.StatusBar.Visible = !globeControl1.Globe.StatusBar.Visible; + buttonItemSH4.Checked = globeControl1.Globe.StatusBar.Visible; + globeControl1.Globe.Refresh(); + } + + + + /// + /// 添加指定路径下的数据 功能 + /// + /// + /// + 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); + //CheckDatasetGeoReference(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; + } + return objRes; + } + /// + /// 刷新目录树 功能 + /// + 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); + } + } + /// + /// 判断图层是否包含字段列表 + /// + /// + /// + 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; + } + + /// + /// 统计指定图层在指定范围内的所有feature对象 + /// + /// + /// + /// + 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; + } + /// + /// 碰撞分析功能界面中 选择管线复选框 选中状态改变事件处理 + /// + /// + /// + private void checkBoxX3_CheckedChanged(object sender, EventArgs e) + { + clearFeatureHighLight(); + if (checkBoxX3.Checked) + { + comboBoxEx2.SelectedItem = null; + 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; + } + } + /// + /// 碰撞分析功能界面中 选择图层复选框 选中状态改变事件处理 + /// + /// + /// + 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(); + } + /// + /// 碰撞分析功能界面中 选择图层下拉框 选中项改变事件处理 + /// + /// + /// + 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; + } + } + } + /// + /// 清除所有图层中的所有feature对象的高亮状态 功能 + /// + 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); + } + } + } + } + for (int i = 0; i < globeControl2.Globe.Layers.Count; i++) + { + GSOLayer layer = globeControl2.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; + } + } + } + + if (globeControl1.Globe.Action == EnumAction3D.SelectObject) + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + //globeControl1.Globe.Action = EnumAction3D.SelectObject; + } + } + + /// + /// 碰撞分析功能界面中 清除分析结果按钮 事件处理 + /// + /// + /// + 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(); + } + /// + /// 碰撞分析功能界面中 导出Excel按钮 事件处理 + /// + /// + /// + private void buttonX6_Click(object sender, EventArgs e) + { + if (dataGridViewX5.Rows.Count > 0) + { + ExportExcel("碰撞分析", dataGridViewX5, listBox2); + } + else + { + MessageBox.Show("表格内容为空!", "提示"); + } + } + /// + /// 导出CAD 菜单 + /// + /// + /// + private void btnExportCAD_Click(object sender, EventArgs e) + { + FrmExportCADS frm = new FrmExportCADS(globeControl1, m_PipelineLayerNames); + frm.ShowDialog(); + } + + ///// + ///// 区域分析 菜单 + ///// + ///// + ///// + //private void buttonItem50_Click(object sender, EventArgs e) + //{ + // buttonItem50.Checked = !buttonItem50.Checked; + // ribbonBarQY.Visible = buttonItem50.Checked; + // ribbonBarQY.Location = new Point(0, 0); + //} + + + /// + /// 连接数据库 菜单事件处理 + /// + /// + /// + 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; + } + } + } + /// + /// 数据验证 菜单 + /// + /// + /// + private void buttonItem80_Click(object sender, EventArgs e) + { + FrmValiData frm = new FrmValiData(globeControl1); + frm.ShowDialog(); + } + /// + /// 根据指定图层创建图层节点并将节点添加到图层管理节点的子节点集合中 + /// + /// + 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; + + if (!layerManagerNode.Nodes.Contains(node)) + { + layerManagerNode.Nodes.Insert(0, node); + layerManagerNode.Expand(); + } + } + } + /// + /// 数据库备份 菜单 + /// + /// + /// + 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(); + } + } + } + + + + #region Fan 去掉 + //GSOFeature emitterFeature; // 粒子要素 + /// + /// 添加火苗 功能 + /// + /// + /// + /// + 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); + + } + /// + /// 添加喷泉 功能 + /// + /// + /// + /// + 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); + } + #endregion + + /// + /// 获取指定图层中最后一个feature对象的名称对应的整数 + /// + /// + /// + 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; + } + /// + /// 设置除指定标注图层之外的所有标注图层不可见 + /// + /// + 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; + } + } + } + } + } + + /// + /// 判断选中的对象是否为管线 + /// + /// 被选中管线 + /// 返回一根线 + 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; + } + + /// + /// 获取指定两点组成的线的长度 功能 + /// + /// + /// + /// + 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; + } + + /// + /// 图层节点树中 节点 右键单击事件处理 + /// + /// + /// + 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; + } + } + } + } + } + + /// + /// 标注管理、传感器管理 图层目录树的右键菜单中的 刷新列表 菜单 + /// + /// + /// + 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); + } + } + /// + /// 给指定的图层节点添加代表feature对象的子节点 + /// + /// + private void RefreshTreeNodeLayerFeatureList(TreeNode layerTreeNode) + { + layerTreeNode.Nodes.Clear(); + GSOLayer layer = (GSOLayer)layerTreeNode.Tag; + // 只将类型为内存数据集的图层列出,如果是其它类型的数据集可能数据量太大,没发显示在树控件中 + if (layer.Dataset is GSOFeatureDataset) + { + VisitFeature3Ds(layer.GetAllFeatures(), layerTreeNode); + } + } + + /// + /// 标注管理、传感器管理 图层目录树的右键菜单中的 移除所有 菜单 + /// + /// + /// + 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(); + } + } + + /// + /// 图层目录树的 节点对应的复选框选中状态改变事件处理 + /// + /// + /// + private void layerMarkerTree_AfterCheck(object sender, TreeViewEventArgs e) + { + if (e.Action != TreeViewAction.Unknown) + { + CheckTreeNode(e.Node, e.Node.Checked); + } + } + /// + /// 改变指定节点对应的复选框的选中状态 + /// + /// + /// + private void CheckTreeNode(TreeNode node, Boolean bChecked) + { + CheckChildTreeNode(node, bChecked); + globeControl1.Globe.Refresh(); + } + /// + /// 改变指定节点的子节点对应的复选框的选中状态 + /// + /// + /// + 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); + } + } + /// + /// 标注管理、传感器管理 目录树中的feature节点的右键菜单中的 删除 菜单 + /// + /// + /// + 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(); + } + } + + /// + /// 双屏对比 菜单 + /// + /// + /// + //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(); + // } + //} + /// + /// 模拟分析 菜单 + /// + /// + /// + //private void buttonItem51_Click(object sender, EventArgs e) + //{ + // buttonItem51.Checked = !buttonItem51.Checked; + // ribbonBarMN.Visible = buttonItem51.Checked; + // ribbonBarMN.Location = new Point(0, 0); + //} + + /// + /// 双屏设置 菜单 + /// + /// + /// + //private void buttonItem96_Click(object sender, EventArgs e) + //{ + // FrmLayerControl frm = new FrmLayerControl(layerTree,globeControl1,globeControl2); + // frm.Show(this); + //} + /// + /// 双屏联动 菜单 + /// + /// + /// + //private void buttonItem95_Click(object sender, EventArgs e) + //{ + // buttonItem95.Checked = !buttonItem95.Checked; + //} + ///// + /// 添加用户仓库 菜单 + /// + /// + /// + private void buttonItem108_Click(object sender, EventArgs e) + { + FrmUserRepo frm = new FrmUserRepo(-1); + frm.ShowDialog(); + } + /// + /// 用户仓库管理 菜单 + /// + /// + /// + private void buttonItem111_Click(object sender, EventArgs e) + { + FrmUserRepoMgr frm = new FrmUserRepoMgr(); + frm.ShowDialog(); + } + /// + /// 添加分系统 菜单 + /// + /// + /// + private void buttonItem112_Click(object sender, EventArgs e) + { + //FrmAPP frm = new FrmAPP(-1); + //frm.ShowDialog(); + } + /// + /// 分系统管理 菜单 + /// + /// + /// + private void buttonItem113_Click(object sender, EventArgs e) + { + //FrmAPPMgr frm = new FrmAPPMgr(); + //frm.ShowDialog(); + } + /// + /// 添加操作 菜单 + /// + /// + /// + private void buttonItem114_Click(object sender, EventArgs e) + { + FrmOper frm = new FrmOper(-1); + frm.ShowDialog(); + } + /// + /// 操作管理 菜单 + /// + /// + /// + private void buttonItem115_Click(object sender, EventArgs e) + { + FrmOperMgr frm = new FrmOperMgr(); + frm.ShowDialog(); + } + /// + /// 添加资源 菜单 + /// + /// + /// + private void buttonItem116_Click(object sender, EventArgs e) + { + FrmRESC frm = new FrmRESC(-1); + frm.ShowDialog(); + } + /// + /// 资源管理 菜单 + /// + /// + /// + private void buttonItem117_Click(object sender, EventArgs e) + { + FrmRESCMgr frm = new FrmRESCMgr(); + frm.ShowDialog(); + } + /// + /// 添加权限 菜单 + /// + /// + /// + private void buttonItem118_Click(object sender, EventArgs e) + { + FrmPerm frm = new FrmPerm(-1); + frm.ShowDialog(); + } + /// + /// 权限管理 菜单 + /// + /// + /// + private void buttonItem119_Click(object sender, EventArgs e) + { + FrmPermMgr frm = new FrmPermMgr(); + frm.ShowDialog(); + } + /// + /// 添加访问控制 菜单 + /// + /// + /// + private void buttonItem120_Click(object sender, EventArgs e) + { + FrmAccess frm = new FrmAccess(-1); + frm.ShowDialog(); + } + /// + /// 访问控制管理 菜单 + /// + /// + /// + private void buttonItem121_Click(object sender, EventArgs e) + { + FrmAccessMgr frm = new FrmAccessMgr(); + frm.ShowDialog(); + } + /// + /// 部门类型管理 菜单 + /// + /// + /// + private void buttonItem122_Click(object sender, EventArgs e) + { + FrmRegionTypeMgr frm = new FrmRegionTypeMgr(); + frm.ShowDialog(); + } + /// + /// 添加用户 菜单 + /// + /// + /// + private void buttonItem127_Click(object sender, EventArgs e) + { + FrmUserAdd frm = new FrmUserAdd(-1); + frm.ShowDialog(); + } + /// + /// 用户信息管理 菜单 + /// + /// + /// + private void buttonItem128_Click_1(object sender, EventArgs e) + { + FrmUserManager frm = new FrmUserManager(); + frm.ShowDialog(); + } + /// + /// 添加角色 菜单 + /// + /// + /// + private void 添加角色_Click(object sender, EventArgs e) + { + FrmRole frm = new FrmRole(-1); + frm.ShowDialog(); + } + /// + /// 所有角色管理 菜单 + /// + /// + /// + private void 角色管理_Click(object sender, EventArgs e) + { + FrmRoleMgr frm = new FrmRoleMgr(); + frm.ShowDialog(); + } + + /// + /// 部门角色管理 菜单 + /// + /// + /// + private void buttonItem133_Click(object sender, EventArgs e) + { + FrmRegionRoleMgr frm = new FrmRegionRoleMgr(); + frm.ShowDialog(); + } + /// + /// 部门管理 菜单 + /// + /// + /// + private void buttonItem130_Click(object sender, EventArgs e) + { + FrmRegionMgr frm = new FrmRegionMgr(); + frm.ShowDialog(); + } + + /// + /// 日志管理 菜单 + /// + /// + /// + private void buttonItem135_Click(object sender, EventArgs e) + { + FrmLogManager frm = new FrmLogManager(); + frm.ShowDialog(); + } + /// + /// 传感器信息查询 菜单 + /// + /// + /// + 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); + } + } + } + /// + /// 根据指定的图层的caption属性的值在配置文件中查找对应的数据库中的表的名称 + /// + /// 图层的caption属性的值 + /// 对应的数据库中的表的名称 + 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; + } + /// + /// 根据数据库中的表的名称 查找对应的表中的字段名称的集合 + /// + /// 数据库中的表的名称 + /// 对应的表中的字段名称的集合 + 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; + } + + /// + /// 历史曲线查询 菜单 + /// + /// + /// + 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; + /// + /// 传感器在线报警 菜单 + /// + /// + /// + 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); + } + /// + /// 传感器报警 功能中的 定时器 的触发事件处理 + /// + /// + /// + 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; + } + } + } + } + } + } + } + + + /// + /// 沿线运动 菜单 + /// + /// + /// + private void buttonItem138_Click(object sender, EventArgs e) + { + if (globeControl1.Globe.SelectedObject == null) + { + MessageBox.Show("请先选择一条线!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + return; + } + + GSOFeature lineFeature = globeControl1.Globe.SelectedObject; + if (lineFeature.Geometry == null || lineFeature.Geometry.Type != EnumGeometryType.GeoPolyline3D) + { + MessageBox.Show("请先选择一条线!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + return; + } + + OpenFileDialog dlg = new OpenFileDialog(); + dlg.Filter = "*.gcm;*.3ds|*.gcm;*.3ds|*.3ds|*.3ds|*.gcm|*.gcm"; + if (dlg.ShowDialog() == DialogResult.OK) + { + GSOGeoModel model = new GSOGeoModel(); + model.FilePath = dlg.FileName; + + GSOGeoDynamicRoute dynamicRoute = new GSOGeoDynamicRoute(); + dynamicRoute.ActorGeometry = model; + + GSORoute route = new GSORoute(); + GSOGeoPolyline3D geoline = (GSOGeoPolyline3D)lineFeature.Geometry; + for (int i = 0; i < geoline[0].Count; i++) + { + route.Add(geoline[0][i]); + } + route.CircleRoute = false; + route.Speed = 30; + route.RotateSpeed = 50; + route.AltitudeMode = geoline.AltitudeMode; + dynamicRoute.Route = route; + + GSOFeature feature = new GSOFeature(); + + dynamicRoute.Play(); + feature.Geometry = dynamicRoute; + + //GSOLabel gsoLabel = new GSOLabel(); + //gsoLabel.Text = "模型测试"; + //feature.Label = gsoLabel; + globeControl1.Globe.MinModelVisibleSize = 0; + + globeControl1.Globe.MemoryLayer.AddFeature(feature); + globeControl1.Globe.Refresh(); + } + } + /// + /// 回退 菜单 + /// + /// + /// + private void buttonItem99_Click(object sender, EventArgs e) + { + globeControl1.Globe.UnDoEdit(); + } + /// + /// 前进 菜单 + /// + /// + /// + private void buttonItem100_Click(object sender, EventArgs e) + { + globeControl1.Globe.ReDoEdit(); + } + /// + /// 水平净距 功能界面中的 标签内容改变事件处理 + /// + /// + /// + 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() + "米的管线有:"; + } + } + } + /// + /// 垂直净距 功能界面中的 标签内容改变事件处理 + /// + /// + /// + 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() + "米的管线有:"; + } + } + } + /// + /// 覆土分析 功能界面中的 标签内容改变事件处理 + /// + /// + /// + 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() + "米的管线有:"; + } + } + } + + /// + /// 传感器分类查询 全区域 菜单 + /// + /// + /// + private void buttonItemSensor全区域查询_Click(object sender, EventArgs e) + { + FrmAccessoriesSensor.ShowForm(globeControl1, instrumenLayerNames, 0); + } + /// + /// 传感器分类查询 绘制区域 菜单 + /// + /// + /// + private void buttonItemSensor绘制区域查询_Click(object sender, EventArgs e) + { + FrmAccessoriesSensor.ShowForm(globeControl1, instrumenLayerNames, 1); + } + + + /// + /// 碰撞分析 功能界面中 关闭按钮 事件处理 + /// + /// + /// + 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(); + } + /// + /// 覆土分析 功能界面中的 清除分析结果 按钮事件处理 + /// + /// + /// + 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(); + } + /// + /// 数字预处理 功能 + /// + /// + /// + private void 数字预处理buttonItem140_Click(object sender, EventArgs e) + { + FrmEditShapeFile frm = new FrmEditShapeFile(globeControl1); + frm.ShowDialog(this); + } + + + /// + /// 导出矢量 功能 将图层导出为kml和shp格式数据 + /// + /// + /// + private void 导出矢量buttonItem140_Click(object sender, EventArgs e) + { + List listVectorNames = new List(); + for (int i = 0; i < m_PipelineLayerNames.Count; i++) + { + 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 = ""; + /// + /// 绘制城市七线 功能按钮 + /// + /// + /// + 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; + } + } + } + /// + /// 七线审核 功能按钮 + /// + /// + /// + private void 七线审核buttonItem141_Click(object sender, EventArgs e) + { + FrmCityServerLineAnalysis frm = new FrmCityServerLineAnalysis(globeControl1, m_PipelineLayerNames); + frm.ShowDialog(this); + } + + /// + /// 间距分析 开始分析按钮 分析绘制的七线和管线的距离是否符合标准 + /// + /// + /// + 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; + } + /// + /// 间距分析 清除分析结果 + /// + /// + /// + 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(); + } + /// + /// 间距分析 导出Excel按钮 将间距分析的结果以Excel表格的形式导出 + /// + /// + /// + private void buttonExportExcel_Click(object sender, EventArgs e) + { + if (dataGridViewAnalysisResult.Rows.Count > 0) + { + ExportExcel("间距分析", dataGridViewAnalysisResult, listBoxStasticsResult); + } + else + { + MessageBox.Show("表格内容为空!", "提示"); + } + } + /// + /// 间距分析 关闭按钮 + /// + /// + /// + 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(); + } + /// + /// 间距分析 分析结果表格双击定位 + /// + /// + /// + 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); + } + } + } + } + /// + /// 间距分析 选择管线复选框 + /// + /// + /// + private void checkBoxSelectPipeline_CheckedChanged(object sender, EventArgs e) + { + clearFeatureHighLight();//清除高亮 + if (checkBoxSelectPipeline.Checked) + { + comboBoxLayer.SelectedItem = null; + 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; + } + } + /// + /// 间距分析 选择图层复选框 + /// + /// + /// + 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(); + } + /// + /// 间距分析 选择图层下拉框 + /// + /// + /// + 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; + } + } + } + + + + /// + /// 管线自动缩进 菜单 + /// + /// + /// + private void 管线自动缩进buttonItem140_Click(object sender, EventArgs e) + { + FrmPipelineIndented frm = new FrmPipelineIndented(globeControl1, m_PipelineLayerNames, workwellLayerNames); + 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 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); + // } + //} + + /// + /// 统计指定图层在指定范围内的所有feature对象 + /// + /// + /// + /// + 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) + { + 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 setLayerVisible(string layerName) + { + GSOLayer templayer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + if (templayer != null) + { + templayer.Visible = false; + } + globeControl1.Globe.Refresh(); + } + + /// + /// 连接数据库 + /// + /// + /// + private void buttonItem129_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL4_1.Text); + + FrmDatabaseParaSetting2 frm = new FrmDatabaseParaSetting2(globeControl1); + if (frm.ShowDialog() == DialogResult.OK) + { + ds = FrmDatabaseParaSetting2.ds; + if (ds != null) + { + ds.IsCloseSaved = false; + } + } + } + + /// + /// 一键审核---导入数据 + /// + /// + /// + private void buttonItem127_Click_2(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, "打开数据"); + + try + { + //if (shds == null) + //{ + //没连的话,直接连接审核库; //审核库配置读配置文件 + string dbIp = Utility.sgdbip; + string database = Utility.sgdbname; + string user = Utility.sgdbuser; + string pass = Utility.sgdbpwd; + /* + 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; + //} + } + catch (Exception ex) + { + LogError.PublishError(ex); + MessageBox.Show("内存过载请清理内存,并重新启动规划分析!", "提示"); + return; + } + + } + + /// + ///自动导出图片 + /// + /// + /// + private void buttonItem130_Click_1(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, "导出审核图"); + + 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))); + */ + + int mapWidth = 0; + int mapHeight = 0; + Point pt = getUpperLeftPoint(pt1, pt2, out mapWidth, out mapHeight); + int rightBottomX = pt.X + mapWidth; + int rightBottomY = pt.Y + mapHeight; + Image myImg = new Bitmap(mapWidth, mapHeight); + Graphics g = Graphics.FromImage(myImg); + g.CopyFromScreen(pt, new Point(0, 0), new Size(rightBottomX, rightBottomY)); + + 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; + } + } + } + /// + /// 一键审核功能 + ///
+ /// + /// + private void buttonItem128_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItem128.Text); + //垂直净距标准 + + frmSh = new FrmYJSHTC(globeControl1, globeControl2,layerTree); + + if (frmSh.ShowDialog() == DialogResult.OK) + { + frmWait = new FrmWait("一键审核……"); + frmWait.Location = new Point(this.Width - frmWait.Width - 10, this.Height - frmWait.Height - 50); + frmWait.Owner = this; + frmWait.Show(); + Thread thread = new Thread(new ThreadStart(doWork)); + thread.IsBackground = true; + thread.Start(); + } + } + + void doWork() + { + FrmShResult frmShResult = null; + + double dVerticalJingJuBiaoZhun = 1, dHorizontalJingJuBiaoZhun = 1; + if (frmSh.rukuLayer != null) + { + #region + this.Invoke((EventHandler)delegate + { + try + { + List managerLayerList = new List(); + for (int i = 0; i < layerManagerNode.Nodes.Count; i++) + { + managerLayerList.Add(layerManagerNode.Nodes[i].Text); + } + if (!managerLayerList.Contains(frmSh.rukuLayer.Caption)) + { + TreeNode node = new TreeNode(); + node.Tag = frmSh.rukuLayer; + node.Text = frmSh.rukuLayer.Dataset.Caption; + node.ImageIndex = 0; + node.SelectedImageIndex = 0; + node.Checked = frmSh.rukuLayer.Visible; + layerManagerNode.Nodes.Insert(0, node); + layerManagerNode.Expand(); + } + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "提示"); + } + }); + #endregion + + shlayername = frmSh.rukuLayer.Name; + globeControl1.Refresh(); + } + + if (frmShResult != null && !frmShResult.IsDisposed) + { + try + { + clearFeatureHighLight(); + ClearRedlineAnalyseResult(); + frmShResult.Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message); + } + } + + 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.analysis(); + + //MainFrm窗体显示控制,回到一键审核Tab + this.Invoke((EventHandler)delegate + { + frmShResult.Show(); + frmWait.Close(); + //将tab页恢复到一键审核 + ribbonTabItem11.Checked = true; + try + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + //zhanshi = false; + splitContainer1.Panel2Collapsed = true; + + panelOfTable.Visible = false; + legendSC.Visible = false; + legendSG.Visible = false; + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + } + catch (Exception ex) + { + MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + + }); + + boolfrmShResult = true; + } + else + { + + } + } + + + /// + /// 清除渲染结果 + /// + 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(); + } + /// + /// 已审核的图层 + /// + /// + /// + private void buttonItem132_Click_1(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItem132.Text); + + if (shds == null) + { + //没连的话,直接连接审核库; //审核库配置读配置文件 + string dbIp = Utility.sgdbip; + string database = Utility.sgdbname; + string user = Utility.sgdbuser; + string pass = Utility.sgdbpwd; + + /* + 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; + //} + + } + /// + /// 审核入库 + /// + /// + /// + private void buttonItem133_Click_1(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, "审核入库"); + FrmShRK frmShrk = new FrmShRK(globeControl1); + frmShrk.Show(); + } + /// + /// 模拟设计修改 + /// + /// + /// + private void buttonItem134_Click_1(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, "模拟设计修改"); + + 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 + { + + } + + } + + + /// + /// 绘制垂线 + /// + /// + /// + 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); + } + /// + /// 比较两个点是否是同一个点 + /// + /// + /// + /// + 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; + } + /// + /// 获得点到线的垂线距离及垂点 + /// + /// + /// + /// + /// + 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); + 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]; + } + /// + /// 获得斜率 + /// + /// + /// + /// + /// + /// + /// + 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); + } + } + /// + /// 根据默认投影参数,经纬度转xyz + /// + /// + /// + /// + 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; + } + /// + /// 根据投影参数,经纬度转xyz + /// + /// + /// + /// + /// + 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; + } + /// + /// 根据默认投影参数,xyz转经纬度 + /// + /// + /// + /// + 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; + } + /// + /// 根据投影参数,Xyz转经纬度 + /// + /// + /// + /// + /// + 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; + } + /// + /// 获得inpolygon的管线长度 + /// + /// + 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; + } + + + /// + /// 一键审核中调节透明度 + /// + /// + /// + private void sliderItem1_ValueChanged(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.sliderItem1.Text); + + globeControl1.Globe.GroundOpaque = 100 - sliderItem1.Value; + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(roadLayerName);//("180fd"); + if (layer != null) + { + layer.Opaque = 100 - sliderItem1.Value; + } + + optiValue = sliderItem1.Value; + } + /// + /// 红线审核中的透明度分析 + /// + /// + /// + private void sliderItem3_ValueChanged(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.sliderItem3.Text); + + globeControl1.Globe.GroundOpaque = 100 - sliderItem3.Value; + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(roadLayerName);//("180fd"); + if (layer != null) + { + layer.Opaque = 100 - sliderItem3.Value; + } + optiValue = sliderItem3.Value; + } + + #region yanxiaowei + //初始化DataGridViewX1控件 + public delegate void DataGridViewDelegate(DataTable dt, string strLable, string strLayer, bool initDataGrid); + /// + /// 代理函数,操作DatgridViewX1 + /// + /// + /// + public void InitDataGridViewX1(DataTable dt, string strLable, string strLayer, bool initDataGrid) + { + if (initDataGrid == true) + { + dataGridViewX1.DataSource = dt; + panelOfTable.Visible = true; + toolStripNumbers.Text = strLable; + dataGridViewX1.Tag = strLayer; + } + else + { + dataGridViewX1.DataSource = null; + dataGridViewX1.Refresh(); + panelOfTable.Visible = false; + toolStripNumbers.Text = ""; + dataGridViewX1.Tag = ""; + globeControl1.Globe.MemoryLayer.RemoveAllFeature();//清除双击产生的标注 + } + } + FrmAnalysisGuiHuaResult from; + /// + /// 主窗体下方属性表格 双击定位 功能 + /// + /// + /// + private void dataGridViewX1_MouseDoubleClick(object sender, MouseEventArgs e) + { + if (redSH == false) + { + 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 if (dataGridViewX1.Columns.Contains("标识器编号")) + { + featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["标识器编号"].Value.ToString(); + } + featureName = featureName.Trim(); + + GSOLayer layer = null; + layer = globeControl1.Globe.Layers.GetLayerByCaption(dataGridViewX1.Tag.ToString()); + + if (layer == null) return; + + GSOFeatures features = layer.GetFeatureByName(featureName, false); + if (features.Length == 0) return; + GSOFeature rowFeature = features[0]; + + ClassSearchAnalysis.AddMakerToLineFeature(globeControl1, rowFeature); + + } + } + } + else + { + if (e.Button == MouseButtons.Left) + { + if (from != null && !from.IsDisposed) + { + try + { + from.Close(); + } + catch (Exception ex) + { + LogError.PublishError(ex); + } + } + try + { + DataGridView.HitTestInfo hittestinfo = dataGridViewX1.HitTest(e.X, e.Y); + if (hittestinfo.RowIndex >= 0) + { + string layer = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["管线类型"].Value.ToString(); + string hxName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["红线编号"].Value.ToString(); + FrmAnalysisGuiHuaResult frm = new FrmAnalysisGuiHuaResult(globeControl1, lineStruct, featsList, + panelOfTable, dataGridViewX1, layer, hxName); + frm.Location = new Point(this.Width - frm.Width - 10, this.Height - frm.Height - 20); + frm.Show(this); + + from = frm; + } + } + catch (Exception ex) + { + LogError.PublishError(ex); + } + } + } + } + + /// + /// 空间查询 + /// + /// + /// + private void buttonItemSearch1_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemSearch1.Text); + + trackflag = "PipelineSpatialQuery"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; + + } + /// + /// 关键字查询 + /// + /// + /// + private void buttonItemSearch9_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch9.Text); + + FrmKeywordQuery.ShowForm(globeControl1, m_PipelineLayerNames, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 编号查询 + /// + /// + /// + private void buttonItemSearch2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch2.Text); + + FrmCodingQuery.ShowForm(globeControl1, m_PipelineLayerNames, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 坐标查询 + /// + /// + /// + private void buttonItemSearch3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch3.Text); + + FrmSetLatLonPos.ShowForm(globeControl1); + } + /// + /// 附属物查询 + /// + /// + /// + private void buttonItemSearch10_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch10.Text); + + FrmFittingQuery.ShowForm(globeControl1, instrumenLayerNames, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 管径查询 + /// + /// + /// + private void buttonItemSearch4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch4.Text); + + FrmDiameterQuery.ShowForm(globeControl1, m_PipelineLayerNames, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 材质查询 + /// + /// + /// + private void buttonItemSearch5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch5.Text); + + FrmMaterialSel.ShowForm(globeControl1, m_PipelineLayerNames, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 基本查询 + /// + /// + /// + private void buttonItemSearch6_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch6.Text); + + FrmBasicQuery.ShowForm(globeControl1, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 复合查询 + /// + /// + /// + private void buttonItemSearch7_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch7.Text); + + FrmQuerySQL.ShowForm(globeControl1, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 关联查询 + /// + /// + /// + private void buttonItemSearch8_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch8.Text); + + if (globeControl1.Globe.SelObjectCount != 1) + { + MessageBox.Show("请选中一个对象!", "提示"); + return; + } + + 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 || (feature.Geometry.Type == EnumGeometryType.GeoPolygon3D + || feature.Geometry.Type == EnumGeometryType.GeoWater)) + return; + else + { + ClassSearchAnalysis.ResultRelationAnalysis(globeControl1, feature, valueLayerNames, workwellLayerNames, + instrumenLayerNames, pipefittingLayerNames, m_PipelineLayerNames, valueAllowance); + } + } + } + #endregion + /// + /// 清除分析 + /// + /// + /// + private void buttonItemClear_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemClear.Text); + + globeControl1.Globe.ClearMeasure(); + layerTemp.RemoveAllFeature(); + layerTemp2.RemoveAllFeature(); + buttonItemLS5.Checked = false; + + dataGridViewX1.DataSource = null; + panelOfTable.Visible = false; + + 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); + + NetworkAnalysisTool.ClearAllTopAnalysis(this.globeControl1); + // 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();//清除所有坑 + + 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(); + } + } + + clearFeatureHighLight();//取消管线高亮 + + GSOLayer layerGround = globeControl1.Globe.Layers.GetLayerByCaption(roadLayerName);//("180fd"); + if (layerGround != null) + { + layerGround.Visible = true; + } + globeControl1.Refresh(); + globeControl2.Refresh(); + ClearRedlineAnalyseResult(); + globeControl1.Globe.Action = EnumAction3D.ActionNull; + } + /// + /// 管线长度全区域统计 + /// + /// + /// + private void buttonItemTJ1_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管线长度统计"); + + FrmAllPipelineStatis frm = new FrmAllPipelineStatis(globeControl1,null, new DataGridViewDelegate(InitDataGridViewX1), m_PipelineLayerNames); + frm.Show(this); + } + /// + /// 管线长度绘制区域统计 + /// + /// + /// + private void buttonItemTJ1_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管线长度统计"); + + trackflag = "PipelineDistanceStatistics"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; + } + /// + /// 阀门数量全区域统计 + /// + /// + /// + private void buttonItemTJ2_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "阀门数量统计"); + + FrmValveStatistics frm = new FrmValveStatistics(globeControl1, null, new DataGridViewDelegate(InitDataGridViewX1)); + frm.Show(this); + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + } + /// + /// 阀门数量绘制区域统计 + /// + /// + /// + private void buttonItemTJ2_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "阀门数量统计"); + + trackflag = "valvequery"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; + } + /// + /// 井盖数量全区域统计 + /// + /// + /// + private void buttonItemTJ3_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "井盖数量统计"); + FrmAllWorkWellStatis frm = new FrmAllWorkWellStatis(globeControl1, null, new DataGridViewDelegate(InitDataGridViewX1)); + frm.Show(this); + } + /// + /// 井盖数量绘制区域统计 + /// + /// + /// + private void buttonItemTJ3_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "井盖数量统计"); + + trackflag = "workwellquery"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; + } + /// + /// 管径分段统计全区域统计 + /// + /// + /// + private void buttonItemTJ4_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管径分段统计"); + + Frmpipediameterstatis.ShowForm(globeControl1, m_PipelineLayerNames, 0); + } + /// + /// 管径分段统计绘制区域统计 + /// + /// + /// + private void buttonItemTJ4_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管径分段统计"); + + trackflag = null; + Frmpipediameterstatis.ShowForm(globeControl1, m_PipelineLayerNames, 1); + } + /// + /// 埋深分段统计全区域统计 + /// + /// + /// + private void buttonItemTJ5_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "埋深分段统计"); + FrmpipeDeepstatis.ShowForm(globeControl1, m_PipelineLayerNames, 0); + } + /// + /// 埋深分段统计绘制区域统计 + /// + /// + /// + private void buttonItemTJ5_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "埋深分段统计"); + trackflag = null; + FrmpipeDeepstatis.ShowForm(globeControl1, m_PipelineLayerNames, 1); + } + /// + /// 管径分类统计全区域统计 + /// + /// + /// + private void buttonItemTJ6_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管径分类汇总"); + + FrmpipeDiametergather.ShowForm(globeControl1, m_PipelineLayerNames, 0); + } + /// + /// 管径分类统计绘制区域统计 + /// + /// + /// + private void buttonItemTJ6_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管径分类汇总"); + + trackflag = null; + FrmpipeDiametergather.ShowForm(globeControl1, m_PipelineLayerNames, 1); + } + /// + /// 材质分类统计全区域统计 + /// + /// + /// + private void buttonItemTJ7_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "材质分类汇总"); + + FrmpipeMaterialGather.ShowForm(globeControl1, m_PipelineLayerNames, 0); + } + /// + /// 材质分类统计绘制区域统计 + /// + /// + /// + private void buttonItemTJ7_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "材质分类汇总"); + + trackflag = null; + FrmpipeMaterialGather.ShowForm(globeControl1, m_PipelineLayerNames, 1); + } + /// + /// 附属物分类统计全区域统计 + /// + /// + /// + private void buttonItemTJ8_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "附属物分类汇总"); + + FrmAccessoriesgather.ShowForm(globeControl1, instrumenLayerNames, 0); + } + /// + /// 附属物分类统计绘制区域统计 + /// + /// + /// + private void buttonItemTJ8_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "附属物分类汇总"); + + trackflag = null; + FrmAccessoriesgather.ShowForm(globeControl1, instrumenLayerNames, 1); + } + /// + /// 碰撞分析 + /// + /// + /// + private void buttonItemFX1_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_4.Text); + + this.dataGridViewX4.Size = new System.Drawing.Size(195, 120); + 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(); + } + /// + /// 覆土分析 + /// + /// + /// + private void buttonItemFX1_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX5_1.Text); + this.dataGridViewX6.Size = new System.Drawing.Size(195, 120); + 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(); + } + /// + /// 间距分析 + /// + /// + /// + private void buttonItemFX1_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX1_3.Text); + + this.dataGridViewLineList.Size = new System.Drawing.Size(185, 120); + 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(); + } + /// + /// 垂直净距分析 + /// + /// + /// + private void buttonItemFX1_4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX1_4.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(); + } + /// + /// 水平净距分析 + /// + /// + /// + private void buttonItemFX1_5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_6.Text); + this.dataGridViewX8.Size = new System.Drawing.Size(185, 120); + 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(); + } + + #region Predaotr,断面分析 + /// + /// 横断面分析 + /// + /// + /// + private void buttonItemFX2_1_Click(object sender, EventArgs e) + { + globeControl1.Globe.Action = EnumAction3D.TrackPolyline; + globeControl1.Globe.TrackPolylineTool.VerticalLineVisible = true; + globeControl1.Globe.TrackPolylineTool.TrackMode = EnumTrackMode.SpaceTrack; + trackPolylineEndMode = EnumTrackPolylineEndMode.HDM_Analysis; + + } + /// + /// 纵断面分析 + /// + /// + /// + private void buttonItemFX2_2_Click(object sender, EventArgs e) + { + if (globeControl1.Globe.SelObjectCount<1) + { + MessageBox.Show("请选择一条或者多条管线!", "提示", MessageBoxButtons.OK, + MessageBoxIcon.Information); + return; + } + 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); + } + } + List feats = SectionAnalysisTool.ZDMAnalysis(selectFeatures); + if (feats != null && feats.Count >= 1) + { + FrmProfileAnalysis frm = new FrmProfileAnalysis(globeControl1, feats); + frm.Show(this); + } + } + /// + /// 道路断面分析 + /// + /// + /// + private void buttonItemFX2_3_Click(object sender, EventArgs e) + { + globeControl1.Globe.Action = EnumAction3D.TrackPolyline; + globeControl1.Globe.TrackPolylineTool.VerticalLineVisible = true; + globeControl1.Globe.TrackPolylineTool.TrackMode = EnumTrackMode.SpaceTrack; + trackPolylineEndMode = EnumTrackPolylineEndMode.DLDM_Analysis; + + } + /// + /// 基线剖面分析 + /// + /// + /// + private void buttonItemFX2_4_Click(object sender, EventArgs e) + { + globeControl1.Globe.Action = EnumAction3D.TrackPolyline; + globeControl1.Globe.TrackPolylineTool.VerticalLineVisible = true; + globeControl1.Globe.TrackPolylineTool.TrackMode = EnumTrackMode.SpaceTrack; + trackPolylineEndMode = EnumTrackPolylineEndMode.JXPM_Analysis; + + } + + #endregion + /// + /// 创建拓扑 + /// + /// + /// + private void buttonItemFX3_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX3_1.Text); + + FrmGenAndFaMenTopu frm = new FrmGenAndFaMenTopu(globeControl1, m_PipelineLayerNames, valueLayerNames); + frm.Show(this); + } + #region Predator :拓扑分析 + /// + /// 上游分析 + /// + /// + /// + private void buttonItemFX3_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX3_2.Text); + NetworkTraceUpDown(true); + } + /// + /// 下游分析 + /// + /// + /// + private void buttonItemFX3_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX3_3.Text); + NetworkTraceUpDown(false); + } + + /// + /// 上下游追踪 功能 + /// + /// + private void NetworkTraceUpDown(Boolean bTraceUp) + { + GSOFeature selLineFeature = globeControl1.Globe.SelectedObject; + if (selLineFeature == null || selLineFeature.Geometry == null || selLineFeature.Geometry.Type != EnumGeometryType.GeoPolyline3D) + { + MessageBox.Show("请点击“编辑”—“选中对象”选择一条线!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); + return; + } + GSOLayer selLayer = globeControl1.Globe.SelectedObjectLayer; + + NetworkAnalysisTool.TraceUpDownAnalysis(bTraceUp, + selLineFeature, selLayer); + } + + /// + /// 流向分析 + /// + /// + /// + private void buttonItemFX3_4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX3_4.Text); + + FrmFlow frm = new FrmFlow(globeControl1, m_PipelineLayerNames); + frm.Show(this); + } + /// + /// 关阀分析 + /// + /// + /// + private void buttonItemFX3_5_Click(object sender, EventArgs e) + { + if (globeControl1.Globe.SelObjectCount < 1) + { + MessageBox.Show("请选中至少一根管线!!"); + buttonItemFX3_5.Checked = false; + return; + } + GSOLayer resLayer = null; + GSOFeature resFeature = null; + globeControl1.Globe.GetSelectObject(0, out resFeature, out resLayer); + + String pipeLayerName = resLayer.Caption; + String pipeLayerNamePrefix = pipeLayerName.Substring(0, pipeLayerName.IndexOf("管线")); + GSOLayer valveLayer = globeControl1.Globe.Layers[pipeLayerNamePrefix + "阀门"]; + if (valveLayer == null) + { + MessageBox.Show("无" + pipeLayerNamePrefix+"阀门图层", "提示"); + return; + } + + GSOFeatures valveFeats = NetworkAnalysisTool.CloseValvesAnalysis(resFeature, + resLayer, valveLayer); + + if (valveFeats != null) + { + FrmCloseValves frm = new FrmCloseValves(this.globeControl1, valveFeats); + frm.Show(this); + } + else + { + MessageBox.Show("未找到关闭阀门"); + } + } + + /// + /// 连通分析 + /// + /// + /// + private void buttonItemFX3_6_Click(object sender, EventArgs e) + { + if (globeControl1.Globe.SelObjectCount < 2) + { + MessageBox.Show("请选中至少两个管线!!"); + buttonItemFX3_6.Checked = false; + return; + } + GSOFeature selFeat0, selFeat1; + GSOLayer layer0,layer1; + globeControl1.Globe.GetSelectObject(0, out selFeat0, out layer0); + globeControl1.Globe.GetSelectObject(1, out selFeat1, out layer1); + + if (!layer0.IsSameInnerObject(layer1)) + { + MessageBox.Show("不在同一个图层!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); + buttonItemFX3_6.Checked = false; + return; + } + NetworkAnalysisTool.ConnexityAnalysis(selFeat0, selFeat1, layer0); + } + /// + /// 爆管分析 + /// + /// + /// + private void buttonItemFX3_7_Click(object sender, EventArgs e) + { + NetworkTraceUpDown(true); //上游追踪: + + GSOFeature selLineFeature = globeControl1.Globe.SelectedObject; + if (selLineFeature == null || selLineFeature.Geometry == null || selLineFeature.Geometry.Type != EnumGeometryType.GeoPolyline3D) + { + MessageBox.Show("请点击“编辑”—“选中对象”选择一条线!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); + return; + } + GSOLayer selLayer = globeControl1.Globe.SelectedObjectLayer; + + NetworkAnalysisTool.ExplodeAnalysis(this.globeControl1,selLineFeature,selLayer); + + this.buttonItemFX3_5_Click(sender, e); //关阀分析: + + } + + #endregion + /// + /// 多边形开挖 + /// + /// + /// + private void buttonItemFX4_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_1.Text); + + trackflag = "pit"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; //是这个么?是的,在模型上 + } + /// + /// 挖方量分析 + /// + /// + /// + private void buttonItemFX4_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_2.Text); + + trackflag = "digFillAnalysis"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; + ActionToolMenuChecked(); + } + /// + /// 沿线开挖 + /// + /// + /// + private void buttonItemFX4_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_3.Text); + + if (!buttonItemFX4_3.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; + buttonItemFX4_3.Checked = true; + } + } + else + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + buttonItemFX4_3.Checked = false; + globeControl1.Globe.TrackPolylineTool.VerticalLineVisible = false; + } + ActionToolMenuChecked(); + } + /// + /// 创建隧道 + /// + /// + /// + private void buttonItemFX4_4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_4.Text); + + 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("场景中未加载隧道图层!", "提示"); + } + } + /// + /// 隐藏隧道 + /// + /// + /// + private void buttonItemFX4_5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_5.Text); + + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption("隧道"); + if (layer != null) + { + layer.Visible = !layer.Visible; + } + } + /// + /// 删除隧道 + /// + /// + /// + private void buttonItemFX4_6_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_6.Text); + + 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("请选中要删除的隧道!", "提示"); + } + } + /// + /// 通视分析 + /// + /// + /// + private void buttonItemFX5_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX5_1.Text); + + if (globeControl1.Globe.Action != EnumAction3D.VisibilityAnalysis) + { + //btnSpaceVisibilityAnalysis.Checked = true; + globeControl1.Globe.Action = EnumAction3D.VisibilityAnalysis; + } + else + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + // SetButtonChecked(); + } + } + /// + /// 可视域分析 + /// + /// + /// + private void buttonItemFX5_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX5_2.Text); + + globeControl1.Globe.Action = EnumAction3D.ViewshedAnalysis; + } + /// + /// 可视包络分析 + /// + /// + /// + private void buttonItemFX5_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX5_3.Text); + + globeControl1.Globe.Action = EnumAction3D.ViewEnvelopeAnalysis; + } + /// + /// 缓冲区分析 + /// + /// + /// + private void buttonItemFX6_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX6_1.Text); + + GSOFeature feat = globeControl1.Globe.SelectedObject; + if (feat == null) + { + MessageBox.Show("请选择要分析的要素!"); + return; + } + if (feat.Geometry.Type == EnumGeometryType.GeoPolyline3D) + { + GSOGeoPolyline3D line1 = feat.Geometry as GSOGeoPolyline3D; + if (line1 == null) + { + MessageBox.Show("请选择一条管线!"); + return; + } + + FrmBufferAnalysis frm = new FrmBufferAnalysis(globeControl1, line1, layerTemp); + frm.Show(this); + } + else + { + FrmBufferAnalysisBSQ frm = new FrmBufferAnalysisBSQ(globeControl1, layerTemp, bsqPT); + frm.Show(this); + } + + } + /// + /// 附属物分析 + /// + /// + /// + private void buttonItemFX6_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX6_2.Text); + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + FrmAccessoryAnalysis dlg = new FrmAccessoryAnalysis(globeControl1, layerTemp); + dlg.Show(this); + } + /// + /// 无源淹没分析 + /// + /// + /// + private void buttonItemFX6_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX6_3.Text); + + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + trackflag = "FloodAnalysis"; + } + /// + /// 水平距离 + /// + /// + /// + private void buttonItemLS1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS1.Text); + + globeControl1.Globe.Action = EnumAction3D.MeasureDistance; + globeControl1.Globe.DistanceRuler.SpaceMeasure = false; + buttonItemLS5.Checked = false; + } + /// + /// 垂直距离 + /// + /// + /// + private void buttonItemLS2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS2.Text); + + buttonItemLS5.Checked = false; + globeControl1.Globe.Action = EnumAction3D.MeasureHeight; + globeControl1.Globe.DistanceRuler.SpaceMeasure = false; + } + /// + /// 空间距离 + /// + /// + /// + private void buttonItemLS3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS3.Text); + + buttonItemLS5.Checked = false; + globeControl1.Globe.Action = EnumAction3D.MeasureDistance; + globeControl1.Globe.DistanceRuler.SpaceMeasure = true; + } + /// + /// 地表距离 + /// + /// + /// + private void buttonItemLS4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS4.Text); + + buttonItemLS5.Checked = false; + globeControl1.Globe.Action = EnumAction3D.MeasureDistance; + globeControl1.Globe.DistanceRuler.SpaceMeasure = false; + } + /// + /// 高度量算 + /// + /// + /// + private void buttonItemLS5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS5.Text); + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + buttonItemLS5.Checked = !buttonItemLS5.Checked; + if (buttonItemLS5.Checked) + { + globeControl1.Globe.Action = EnumAction3D.SelectObject; + } + } + /// + /// 水平面积 + /// + /// + /// + private void buttonItemLS6_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS6.Text); + + buttonItemLS5.Checked = false; + globeControl1.Globe.Action = EnumAction3D.MeasureArea; + globeControl1.Globe.AreaRuler.SpaceMeasure = true; + } + /// + /// 地表面积 + /// + /// + /// + private void buttonItemLS7_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS7.Text); + + buttonItemLS5.Checked = false; + globeControl1.Globe.Action = EnumAction3D.MeasureArea; + globeControl1.Globe.AreaRuler.SpaceMeasure = false; + + } + + # region Fan 重构标注代码 + /// + /// 标高标注 + /// + /// + /// + private void buttonItemSZ1_Click(object sender, EventArgs e) + { + GSOFeature resFeature = IsPipeLineOfSelectedObj(); + if (resFeature == null) + { + MessageBox.Show("请选中一根管线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + GSOGeoPolyline3D selLine = resFeature.Geometry as GSOGeoPolyline3D; + if (selLine[0].Count <= 1) + { + return; + } + + MarkTools.getInstance().showMarker(resFeature, + globeControl1, EnumMarkLayer.Mark_Altitude, ""); + } + /// + /// 管径标注 + /// + GSOFeature radiusMarkerFeature; + private void buttonItemBZ2_Click(object sender, EventArgs e) + { + GSOFeature resFeature = IsPipeLineOfSelectedObj(); + if (resFeature == null) + { + MessageBox.Show("请选中一根管线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + GSOGeoPolyline3D selLine = resFeature.Geometry as GSOGeoPolyline3D; + if (selLine[0].Count <= 1) + { + return; + } + + MarkTools.getInstance().showMarker(resFeature, + globeControl1, EnumMarkLayer.Mark_Diameter, ""); + } + /// + /// 埋深标注 + /// + /// + /// + private void buttonItemBZ3_Click(object sender, EventArgs e) + { + GSOFeature resFeature = IsPipeLineOfSelectedObj(); + if (resFeature == null) + { + MessageBox.Show("请选中一根管线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + GSOGeoPolyline3D selLine = resFeature.Geometry as GSOGeoPolyline3D; + if (selLine[0].Count <=1) + { + return; + } + + MarkTools.getInstance().showMarker(resFeature, + globeControl1, EnumMarkLayer.Mark_Depth, ""); + + } + /// + /// 坐标标注 + /// + /// + /// + private void buttonItemBZ4_Click(object sender, EventArgs e) + { + GSOFeature resFeature = IsPipeLineOfSelectedObj(); + if (resFeature == null) + { + MessageBox.Show("请选中一根管线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + GSOGeoPolyline3D selLine = resFeature.Geometry as GSOGeoPolyline3D; + if (selLine[0].Count <= 1) + { + return; + } + MarkTools.getInstance().showMarker(resFeature, + globeControl1, EnumMarkLayer.Mark_Location, ""); + } + /// + /// 距离标注 + /// + bool distanceMarker = false; + private void buttonItemBZ5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBZ5.Text); + + globeControl1.Globe.Action = EnumAction3D.TrackPolyline; + //globeControl1.Globe.DistanceRuler.MeasureMode = EnumDistanceMeasureMode.HVSLineMeasure; + distanceMarker = true; + } + /// + /// 自定义标注 + /// + /// + /// + private void buttonItemBZ6_Click(object sender, EventArgs e) + { + GSOFeature f = globeControl1.Globe.SelectedObject; + GSOLayer l = globeControl1.Globe.SelectedObjectLayer; + FrmCustomLabel frm = new FrmCustomLabel(globeControl1, l, f); + if (frm.ShowDialog() == DialogResult.OK) + { + MarkTools.getInstance().showMarker(f, globeControl1, EnumMarkLayer.Mark_Custom, frm.labelText); + } + } + /// + /// 扯旗标注 + /// + /// + /// + private void buttonItemBZ7_Click(object sender, EventArgs e) + { + GSOFeature f = globeControl1.Globe.SelectedObject; + GSOLayer l = globeControl1.Globe.SelectedObjectLayer; + FrmMarker frm = new FrmMarker(); + if (frm.ShowDialog() == DialogResult.OK) + { + MarkTools.getInstance().showMarker(f, globeControl1, EnumMarkLayer.Mark_Custom, frm.markerContent); + } + } + /// + /// 坡度标注 + /// + /// + /// + private void buttonItemBZ8_Click(object sender, EventArgs e) + { + GSOFeature resFeature = IsPipeLineOfSelectedObj(); + if (resFeature == null) + { + MessageBox.Show("请选中一根管线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + GSOGeoPolyline3D selLine = resFeature.Geometry as GSOGeoPolyline3D; + if (selLine[0].Count <= 1) + { + return; + } + + MarkTools.getInstance().showMarker(resFeature, + globeControl1, EnumMarkLayer.Mark_Slope, ""); + } + /// + /// 属性标注 + /// + /// + /// + private void buttonItemBZ9_Click(object sender, EventArgs e) + { + GSOFeature f = globeControl1.Globe.SelectedObject; + GSOLayer l = globeControl1.Globe.SelectedObjectLayer; + FrmPropertiesMarker frm = new FrmPropertiesMarker(globeControl1, l, f); + if (frm.ShowDialog() == DialogResult.OK) + { + MarkTools.getInstance().showMarker(f, globeControl1, EnumMarkLayer.Mark_Property, frm.labelText); + } + } + /// + /// 红线工具 + /// + /// + /// + private void buttonItemBZ10_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBZ10.Text); + 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; + } + } + /// + /// 标注管理 + /// + /// + /// + private void buttonItemBZ11_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBZ11.Text); + + buttonItemBZ11.Checked = !buttonItemBZ11.Checked; + 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 (buttonItemBZ11.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(); + } + } + + #endregion + /// + /// 飞行到目标点 + /// + /// + /// + private void buttonItemFXGJ1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFXGJ1.Text); + + FrmSetFlytoPos.ShowForm(globeControl1); + + } + /// + /// 自定义飞行 + /// + /// + /// + private void buttonItemFXGJ2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFXGJ2.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); + } + } + /// + /// 绕中心点飞行 + /// + /// + /// + private void buttonItemFXGJ3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFXGJ3.Text); + + globeControl1.Globe.FlyAroundCenter(10000, EnumFlyRepeatValueType.MiliSeconds); + globeControl1.Globe.CurFlyID = 1; + } + /// + /// 绕眼睛飞行 + /// + /// + /// + private void buttonItemFXGJ4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFXGJ4.Text); + + globeControl1.Globe.FlyAroundEye(720, EnumFlyRepeatValueType.Degrees); + globeControl1.Globe.CurFlyID = 2; + } + + /// + /// 权限管理 + /// + /// + /// + private void buttonItemXT1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT1.Text); + + FrmUserRoleMgr frm = new FrmUserRoleMgr(); + frm.ShowDialog(); + } + /// + /// 数据库管理 + /// + /// + /// + private void buttonItemXT2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT2.Text); + + //查看数据库列表 + FrmDbManager frm = new FrmDbManager(); + frm.ShowDialog(); + } + /// + /// 用户列表 + /// + /// + /// + private void buttonItemXT3_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT3_1.Text); + + FrmUserManager frm = new FrmUserManager(); + frm.ShowDialog(); + } + /// + /// 创建新用户 + /// + /// + /// + private void buttonItemXT3_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT3_2.Text); + + FrmUserAdd frm = new FrmUserAdd(-1); + frm.ShowDialog(); + } + /// + /// 人员修改 + /// + /// + /// + private void buttonItemXT4_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT4_2.Text); + + FrmAppUSER appUSER = new FrmAppUSER(); + appUSER.ShowDialog(); + } + /// + /// 增加人员 + /// + /// + /// + private void buttonItemXT4_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT4_1.Text); + + FrmAppUSERRESET appUSERRESET = new FrmAppUSERRESET(); + appUSERRESET.ShowDialog(); + } + /// + /// 统计数据 + /// + /// + /// + private void buttonItemZTT1_Click(object sender, EventArgs e) + { + ////日志记录 + //LogManager.saveLog(Utility.userName, this.buttonItemZTT1.Text); + + //PATM patm = new PATM(); + //patm.operation = "Statistic"; + //patm.Text = "统计专题图管理"; + //patm.ShowDialog(); + } + /// + /// 热点功能统计 + /// + /// + /// + private void buttonItemZTT2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT2.Text); + + FrmHotFuncStat frmhfs = new FrmHotFuncStat(); + frmhfs.ShowDialog(); + } + + private void buttonItemZTT3_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT3_1.Text); + + FrmAPP appfrm = new FrmAPP("专题图申请"); + appfrm.ShowDialog(); + } + + private void buttonItemZTT3_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT3_2.Text); + + FrmAPPFORASK appForask = new FrmAPPFORASK("专题图审核"); + appForask.ShowDialog(); + } + + private void buttonItemZTT3_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT3_3.Text); + + FrmAPPregion appregion = new FrmAPPregion("专题图审核"); + appregion.ShowDialog(); + } + + private void buttonItemZTT4_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT4_1.Text); + + FrmAPP appfrm = new FrmAPP("打印申请"); + appfrm.ShowDialog(); + } + + private void buttonItemZTT4_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT4_2.Text); + + FrmAPPFORASK appForask = new FrmAPPFORASK("打印审核"); + appForask.ShowDialog(); + } + + private void buttonItemZTT4_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT4_3.Text); + + FrmAPPregion appregion = new FrmAPPregion("打印审核"); + appregion.ShowDialog(); + } + + private void buttonItemZTT5_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT5_1.Text); + + FrmAPP appfrm = new FrmAPP("拷贝申请"); + appfrm.ShowDialog(); + } + + private void buttonItemZTT5_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT5_2.Text); + + FrmAPPFORASK appForask = new FrmAPPFORASK("拷贝审核"); + appForask.ShowDialog(); + } + + private void buttonItemZTT5_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT5_3.Text); + + FrmAPPregion appregion = new FrmAPPregion("拷贝审核"); + appregion.Show(); + } + + private int connectServerCount = 0; + + /// + /// 还原球到实测库 + /// + 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); + } + + if (layerManagerNode.Nodes.Count > 0) + { + for (int i = layerManagerNode.Nodes.Count - 1; i >= 0; i--) + { + layerManagerNode.Nodes[i].Remove(); + + } + } + + globeControl1.Refresh(); + + } + + private void buttonItemSPSZ_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSPSZ.Text); + + FrmLayerControl frm = new FrmLayerControl(layerTree, globeControl1, globeControl2); + frm.Show(this); + } + + /// + /// 碰撞审查 + /// + /// + /// + private void buttonItemSH1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSH1.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 buttonItemSH2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSH2.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 buttonItemSH3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSH3.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 buttonItemSH4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSH4.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 buttonItemSH5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSH5.Text); + FrmCityServerLineAnalysis frm = new FrmCityServerLineAnalysis(globeControl1, m_PipelineLayerNames); + frm.Show(this); + } + #region 数据管理-导入文件 + ///// + ///// 数据管理-导入本地坐标系文件 + ///// + ///// + ///// + //private void buttonItemSJGL1_1_Click(object sender, EventArgs e) + //{ + // //日志记录 + // LogManager.saveLog(Utility.userName, this.buttonItemSJGL1_1.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(); + // } + // } + //} + + ///// + ///// 数据管理-导入其他坐标系文件 + ///// + ///// + ///// + //private void buttonItemSJGL1_2_Click(object sender, EventArgs e) + //{ + // //日志记录 + // LogManager.saveLog(Utility.userName, this.buttonItemSJGL1_2.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(); + // } + // } + //} + #endregion + /// + /// 数据质量检查 + /// + /// + /// + private void buttonItemSJGL2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL2.Text); + FrmValiData frm = new FrmValiData(globeControl1); + frm.ShowDialog(); + } + /// + /// 数据预处理 + /// + /// + /// + private void buttonItemSJGL3_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL3.Text); + + FrmEditShapeFile frm = new FrmEditShapeFile(globeControl1); + frm.ShowDialog(this); + } + /// + /// 连接数据库 + /// + /// + /// + private void buttonItemSJGL4_1_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL4_1.Text); + + FrmDatabaseParaSetting frm = new FrmDatabaseParaSetting(globeControl1); + if (frm.ShowDialog() == DialogResult.OK) + { + ds = FrmDatabaseParaSetting.ds; + if (ds != null) + { + ds.IsCloseSaved = false; + } + } + } + /// + /// 管线入库 + /// + /// + /// + private void buttonItemSJGL4_2_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL4_2.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 buttonItemSJGL4_3_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL4_3.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 buttonItemSJGL5_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL5.Text); + + Cyberpipe.Forms.FrmProject frm = new Cyberpipe.Forms.FrmProject(); + frm.ShowDialog(); + } + /// + /// 元数据基本管理 + /// + /// + /// + private void buttonItemSJGL6_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL6_1.Text); + + FrmMetadata frmmd = new FrmMetadata(); + frmmd.ShowDialog(); + } + /// + /// 元数据查询管理 + /// + /// + /// + private void buttonItemSJGL6_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL6_2.Text); + + FrmMetadataStat frmmds = new FrmMetadataStat(); + //frmmds.Show(); + frmmds.ShowDialog(); + } + /// + /// 操作日志管理 + /// + /// + /// + private void buttonItemSJGL7_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL7.Text); + + FrmLogOper frmlo = new FrmLogOper(); + frmlo.ShowDialog(); + } + /// + /// 数据字典管理 + /// + /// + /// + private void buttonItemSJGL8_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL8.Text); + + FrmMDDictory frmmdd = new FrmMDDictory(); + frmmdd.ShowDialog(); + } + /// + /// 数据库备份 + /// + /// + /// + private void buttonItemSJGL9_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL9.Text); + + //新 + FrmBACKORACLE backOracle = new FrmBACKORACLE(); + backOracle.Show(); + } + /// + /// 创建管段 + /// + /// + /// + private void buttonItemBJ1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ1.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; + } + } + /// + /// 创建附属物 + /// + /// + /// + private void buttonItemBJ2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ2.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); + } + } + /// + /// 创建特征管点 + /// + /// + /// + private void buttonItemBJ3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ3.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); + } + } + /// + /// 绘制城市七线 + /// + /// + /// + private void buttonItemBJ4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ4.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; + } + } + } + /// + /// 选中对象 + /// + /// + /// + private void buttonItemBJ5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ5.Text); + + globeControl1.Globe.Action = EnumAction3D.SelectObject; + } + /// + /// 平移对象 + /// + /// + /// + private void buttonItemBJ6_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ6.Text); + + globeControl1.Globe.Action = EnumAction3D.MoveObject; + } + /// + /// 升降对象 + /// + /// + /// + private void buttonItemBJ7_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ7.Text); + + globeControl1.Globe.Action = EnumAction3D.ElevateObject; + } + /// + /// 旋转对象 + /// + /// + /// + private void buttonItemBJ8_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ8.Text); + + globeControl1.Globe.Action = EnumAction3D.RotateObject; + } + /// + /// 连接管段 + /// + /// + /// + private void buttonItemBJ9_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ9.Text); + + if (globeControl1.Globe.SelObjectCount < 2) + { + MessageBox.Show("对不起,请至少选中2个对象!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + return; + } + globeControl1.Globe.InsertJointPipeline(false); + } + /// + /// 后退 + /// + /// + /// + private void buttonItemBJ11_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemBJ11.Text); + globeControl1.Globe.UnDoEdit(); + } + /// + /// 前进 + /// + /// + /// + private void buttonItemBJ12_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemBJ12.Text); + + globeControl1.Globe.ReDoEdit(); + } + /// + /// 导出CAD + /// + /// + /// + private void buttonItemBJ10_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ10_1.Text); + + #region 导出成dxf格式 + List listVectorNames = new List(); + 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(); + #endregion + } + /// + /// 导出矢量 + /// + /// + /// + private void buttonItemBJ10_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ10_2.Text); + + List listVectorNames = new List(); + 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 buttonItemBJ13_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemBJ13.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(); + } + } + MessageBox.Show("删除成功!", "提示"); + } + else + { + MessageBox.Show("请选中要删除的模型!", "提示"); + } + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + } + + private void buttonItemHX1_1_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]; + string filePath = dlg.FileName; + string lastname = Path.GetFileName(filePath); + + 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(); + } + + } + } + } + + public struct LineStruct + { + public string layerName; + public string layerCode; + public string lineLength; + public string hxName; + } + + List lineStruct = new List(); + List featsList = new List(); + + /// + /// 红线审核 + /// + /// + /// + private void buttonItemHX2_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemHX2.Text); + redSH = true; + featsList.Clear(); + lineStruct.Clear(); + List listPipelineLayers = new List(); + + GSOLayer layer = null; + for (int i = 0; i < m_PipelineLayerNames.Count; i++) + { + layer = globeControl1.Globe.Layers.GetLayerByCaption(m_PipelineLayerNames[i]); + if (layer != null) + { + listPipelineLayers.Add(layer); + } + } + //yanxiaowei 重构 + GSOFeatures selectFeatures=new GSOFeatures(); + for (int i = 0; i < globeControl1.Globe.SelObjectCount; i++) + { + GSOFeature feature = null; + globeControl1.Globe.GetSelectObject(i, out feature, out layer); + selectFeatures.Add(feature); + } + DataTable table=new DataTable(); + + ClassGSOTool.CalculateRedLineResult(out table, redSH, selectFeatures, globeControl1, + listPipelineLayers,out lineStruct, out featsList); + + if (table.Rows.Count != 0) + AddDatagridView(table); + else + { + MessageBox.Show("没有侵入地块红线的管线数据!", "提示"); + dataGridViewX1.DataSource = null; + panelOfTable.Visible = false; + return; + } + } + + private void AddDatagridView(DataTable table) + { + dataGridViewX1.DataSource = table; + panelOfTable.Visible = true; + panelOfTable.Height = 200; + toolStripNumbers.Text = "红线审核 |共有:" + table.Rows.Count + "条"; + toolStripDropDownButton3.Visible = true; + } + /// + /// 主窗体 下方的工具条中的 导出.xls文件 按钮事件处理 + /// + /// + /// + private void toolStripDropDownButton3_Click(object sender, EventArgs e) + { + if (dataGridViewX1.Rows.Count == 0) + { + MessageBox.Show("表格内容为空!", "提示"); + return; + } + + string strSaveFile = string.Empty; + SaveFileDialog savefiledialog = new SaveFileDialog(); + savefiledialog.Filter = "Excel文件|*.xls,*.xlsx"; + savefiledialog.AddExtension = true; + savefiledialog.FileName = "红线审核"; + if (savefiledialog.ShowDialog() == DialogResult.OK) + strSaveFile = savefiledialog.FileName; + else return; + + ExpEXCEL.ExpToExcel(dataGridViewX1, strSaveFile, "红线审核", lineStruct, featsList); + MessageBox.Show("导出成功!"); + } + /// + /// 去除集合中重复的管线 + /// + /// + /// + /// + private GSOFeatures getFeaturesByFilter(GSOFeatures features, string fieldName) + { + if (features == null) + { + return null; + } + GSOFeatures featuresGet = new GSOFeatures(); + for (int i = 0; i < features.Length; i++) + { + GSOFeature featureFromFS = features[i]; + string fieldValueFromFS = featureFromFS.GetValue(fieldName).ToString().Trim(); + bool isHas = false; + for (int j = featuresGet.Length - 1; j >= 0; j--) + { + GSOFeature featureFromFSGet = featuresGet[j]; + string fieldValueFromFSGet = featureFromFSGet.GetValue(fieldName).ToString().Trim(); + if (fieldValueFromFS.Equals(fieldValueFromFSGet)) + { + isHas = true; + break; + } + } + if (isHas == false) + { + featuresGet.Add(featureFromFS.Clone()); + } + } + return featuresGet; + } + + private void sliderItem2_ValueChanged(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.sliderItem2.Text); + + globeControl1.Globe.GroundOpaque = 100 - sliderItem2.Value; + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(roadLayerName);//("180fd"); + if (layer != null) + { + layer.Opaque = 100 - sliderItem2.Value; + } + layer = globeControl2.Globe.Layers.GetLayerByCaption("180fd");//("180fd"); + if (layer != null) + { + layer.Opaque = 100 - sliderItem2.Value; + } + globeControl2.Globe.GroundOpaque = 100 - sliderItem2.Value; + + optiValue = sliderItem2.Value; + } + /// + /// 数据管理导入文件 + /// + /// + /// + private void buttonItemSJGL1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL1.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.Multiselect = true; + if (dlg.ShowDialog() == DialogResult.OK) + { + //自定义lprj文件名,从程序中复制一lprj文件。 + string filePath = dlg.FileName; + string lastname = Path.GetFileName(filePath); + + 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, 100); + + globeControl1.Refresh(); + } + } + } + + private void buttonItemHX1_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemHX1.Text); + + GSODataSource dataSpace = globeControl1.Globe.DataManager.OpenOracleDataSource(Utility.DBServer.Trim() + "/" + Utility.dbdatabase.Trim(), "", "", Utility.userID, Utility.DBPassword); + string filepath = ""; + //日志记录 + OpenFileDialog dlg = new OpenFileDialog(); + dlg.Filter = "矢量数据(*.shp)|*.shp|矢量数据(*.lgd)|*.lgd|CAD数据(*.dxf)|*.dxf|全部支持格式(*.lgd,*.shp,*.dxf)|*.lgd;*.shp;*.dxf;"; + dlg.Multiselect = true; + + #region 临时图层显示 + if (dlg.ShowDialog() == DialogResult.OK) + { + string filePath = dlg.FileName; + string lastname = Path.GetFileName(filePath); + + #region + for (int i = 0; i < dlg.FileNames.Length; i++) + { + string strDataPath = dlg.FileNames[i]; + filepath = strDataPath; + + GSOLayer layer = globeControl1.Globe.Layers.Add(strDataPath); + GSOFeatures RedFeatures = layer.GetAllFeatures(); + + 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(); + RedFeatures = features; + 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; + } + + /////////////////////////////////////////////////////////////////////////////////////////// + globeControl1.Globe.Layers.MoveTo(0, globeControl1.Globe.Layers.Count - 1); + globeControl1.Refresh(); + } + + IModelBuilder modelBuilder = new RedLineBuilder(); + + modelBuilder.batchInsert(dataSpace, redDt, RedFeatures); + + } + #endregion + + } + #endregion + } + /// + /// 定位 + /// + /// + /// + private void buttonItemLocation_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemLocation.Text); + + FrmFlyToPosition fly = new FrmFlyToPosition(globeControl1,globeControl2); + fly.Show(this); + } + /// + /// 2015-10-17演示代码 红线审核 + /// + /// + /// + private void ribbonTabItem6_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.FlyToPosition(new GSOPoint3d(120.610963, 31.188121, 50), EnumAltitudeMode.Absolute, -4, 50, 800); + globeControl1.Globe.FlyToPointSpeed = 10000000; + globeControl1.Globe.Action = EnumAction3D.SelectObject; + globeControl1.Refresh(); + + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + + //zhanshi = false; + redSH = true; + splitContainer1.Panel2Collapsed = true; + legendSG.Visible = false; + legendSC.Visible = false; + ClearGZData(); + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = true; + } + + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 基础工具 + /// + /// + /// + private void ribbonTabItem1_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + //zhanshi = false; + redSH = false; + splitContainer1.Panel2Collapsed = true; + panelOfTable.Visible = false; + legendSC.Visible = false; + legendSG.Visible = false; + ClearGZData(); + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + + + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 一键审核 + /// + /// + /// + private void ribbonTabItem11_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + //zhanshi = false; + redSH = false; + splitContainer1.Panel2Collapsed = true; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + panelOfTable.Visible = false; + legendSC.Visible = false; + legendSG.Visible = false; + ClearGZData(); + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + + + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 右屏添加冰箱数据 + /// + void AddDataToGlobeControl2() + { + + bool modelDataBool = false; + for (int i = globeControl2.Globe.Layers.Count - 1; i >= 0; i--) + { + GSOLayer layer = globeControl2.Globe.Layers[i]; + if (layer.Name.Contains("fttp:")) + { + modelDataBool = true; + break; + } + } + + if (modelDataBool == false) + { + GSOLayer ly = globeControl1.Globe.Layers.GetLayerByCaption("天地图地图"); + globeControl2.Globe.Layers.Add(ly); + } + else + { + return; + } + } + /// + /// 双屏对比 + /// + /// + /// + private void ribbonTabItem9_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent += new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent += new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + panelOfTable.Visible = false; + + splitContainer1.Panel2Collapsed = false; + //zhanshi = true; + redSH = false; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + sliderItem2.Value = 100 - globeControl1.Globe.GroundOpaque; + globeControl2.Globe.GroundOpaque = globeControl1.Globe.GroundOpaque; + legendSC.Visible = true; + legendSG.Visible = true; + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + AddDataToGlobeControl2(); + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 文档管理 + /// + /// + /// + private void ribbonTabItem4_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + panelOfTable.Visible = false; + //zhanshi = false; + redSH = false; + splitContainer1.Panel2Collapsed = true; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + legendSC.Visible = false; + legendSG.Visible = false; + ClearGZData(); + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 基础管理 + /// + /// + /// + private void ribbonTabItem14_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + panelOfTable.Visible = false; + //zhanshi = false; + redSH = false; + splitContainer1.Panel2Collapsed = true; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + legendSC.Visible = false; + legendSG.Visible = false; + ClearGZData(); + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 权限管理 + /// + /// + /// + private void ribbonTabItem2_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + panelOfTable.Visible = false; + //zhanshi = false; + redSH = false; + splitContainer1.Panel2Collapsed = true; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + legendSC.Visible = false; + legendSG.Visible = false; + ClearGZData(); + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + GSOFeature dpFeatuer = null; + /// + /// 双屏分析,点击管段分析 + /// + /// + /// + private void buttonItem8_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItem8.Text); + + //FrmCompareFeature frmCompareFeature = new FrmCompareFeature(globeControl1, globeControl2, layerTemp, layerTemp2,m_PipelineLayerNames,sgPipeLayersNames); + int width = this.Width; + FrmCompareFeature.ShowForm(globeControl1, globeControl2, layerTemp, layerTemp2, m_PipelineLayerNames, sgPipeLayersNames,width); + //frmCompareFeature.Location = new Point((this.Width - frmCompareFeature.Width)/2,50); + //frmCompareFeature.Show(this); + + } + /// + /// 红线审核导出图片 + /// + /// + /// + private void buttonItemDCTP_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemDCTP.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))); + */ + int mapWidth = 0; + int mapHeight = 0; + Point pt = getUpperLeftPoint(pt1, pt2, out mapWidth, out mapHeight); + int rightBottomX = pt.X + mapWidth; + int rightBottomY = pt.Y + mapHeight; + Image myImg = new Bitmap(mapWidth, mapHeight); + Graphics g = Graphics.FromImage(myImg); + g.CopyFromScreen(pt, new Point(0, 0), new Size(rightBottomX, rightBottomY)); + + 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; + } + } + } + /// + /// 标识器全区域统计 + /// + /// + /// + private void 标识器分类统计ToolStripMenuItem_Click(object sender, EventArgs e) + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + FrmBSQStatis bsqStatis = new FrmBSQStatis(); + bsqStatis.Show(this); + } + /// + /// 标识器绘制区域统计 + /// + /// + /// + private void 标识器分类统计ToolStripMenuItem1_Click(object sender, EventArgs e) + { + trackflag = "BSQDuoBianXiangStatis"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + } + + #region 保存和加载审核库加载的图层 + /* + private void saveLayerList(TreeNodeCollection treeNodeList) + { + string configPath = Application.StartupPath + "\\configLayerList.xml"; + try + { + XmlDocument doc = new XmlDocument(); + doc.Load(configPath); + XmlNode dbParams = doc.SelectSingleNode("Params/dbparams"); + XmlNode dbLayers = doc.SelectSingleNode("Params/dblayers"); + XmlNode layers = doc.SelectSingleNode("Params/layers"); + dbParams.RemoveAll(); + dbLayers.RemoveAll(); + layers.RemoveAll(); + + List listDS = new List(); + String shDatasourceName = Utility.sgdbip + "/" + Utility.sgdbname + "_" + Utility.sgdbuser; + bool flag = false; + + for (int i = 0; i < globeControl1.Globe.DataManager.DataSourceCount; i++) + { + GSODataSource ds = globeControl1.Globe.DataManager.GetDataSourceAt(i); + if (ds != null && ds.Type == EnumDataSourceType.SqlServer || ds.Type == EnumDataSourceType.Oracle) + { + if (ds.Name == shDatasourceName) + { + //防止因为多次连接同一个数据库 + if (flag == true) + { + break; + } + flag = true; + listDS.Add(ds); + GSODataSourceCnn conn = ds.GetConnectionInfo(); + + XmlElement dbparam = doc.CreateElement("shdbparam"); + XmlElement ip = doc.CreateElement("ship"); + ip.InnerText = conn.Server; + + XmlElement dbname = doc.CreateElement("shdbname"); + dbname.InnerText = conn.Database; + + XmlElement username = doc.CreateElement("shusername"); + username.InnerText = conn.User; + + XmlElement password = doc.CreateElement("shpassword"); + password.InnerText = conn.Password; + + XmlElement type = doc.CreateElement("shtype"); + if (ds.Type == EnumDataSourceType.SqlServer) + { + type.InnerText = "sqlserver"; + } + else + { + type.InnerText = "oracle"; + } + + dbparam.AppendChild(ip); + dbparam.AppendChild(dbname); + dbparam.AppendChild(username); + dbparam.AppendChild(password); + dbparam.AppendChild(type); + dbParams.AppendChild(dbparam); + } + + } + } + + for (int i = 0; i < treeNodeList.Count; i++) + { + GSOLayer layer = treeNodeList[i].Tag as GSOLayer; + if (Path.GetExtension(layer.Name) == "") + { + XmlElement dbLayer = doc.CreateElement("dblayer"); + XmlAttribute attri = doc.CreateAttribute("dbindex"); + for (int j = 0; j < listDS.Count; j++) + { + if (layer.Dataset.DataSource.Name == listDS[j].Name) + { + attri.Value = j.ToString(); + break; + } + } + dbLayer.Attributes.Append(attri); + dbLayer.InnerText = layer.Name; + + dbLayers.AppendChild(dbLayer); + } + else + { + XmlElement dbLayer = doc.CreateElement("layer"); + dbLayer.InnerText = layer.Name; + layers.AppendChild(dbLayer); + } + } + + doc.Save(configPath); + } + catch (Exception e) + { + + } + } + + private void openLayerList() + { + layerManagerNode.Nodes.Clear(); + + string configPath = Application.StartupPath + "\\configLayerList.xml"; + try + { + XmlDocument doc = new XmlDocument(); + doc.Load(configPath); + XmlNode dbParams = doc.SelectSingleNode("Params/dbparams"); + XmlNode dbLayers = doc.SelectSingleNode("Params/dblayers"); + XmlNode layers = doc.SelectSingleNode("Params/layers"); + + List listDS = new List(); + for (int i = 0; i < dbParams.ChildNodes.Count; i++) + { + string ip = ""; + string dbname = ""; + string username = ""; + string password = ""; + string type = ""; + XmlNode node = dbParams.ChildNodes.Item(i); + for (int j = 0; j < node.ChildNodes.Count; j++) + { + XmlNode nodeChild = node.ChildNodes.Item(j); + + if (nodeChild != null && nodeChild.Name == "ship") + { + ip = nodeChild.InnerText; + } + else if (nodeChild != null && nodeChild.Name == "shdbname") + { + dbname = nodeChild.InnerText; + } + else if (nodeChild != null && nodeChild.Name == "shusername") + { + username = nodeChild.InnerText; + } + else if (nodeChild != null && nodeChild.Name == "shpassword") + { + password = nodeChild.InnerText; + } + else if (nodeChild != null && nodeChild.Name == "shtype") + { + type = nodeChild.InnerText; + } + } + + if (type == "sqlserver") + { + GSODataSource ds = globeControl1.Globe.DataManager.OpenSqlServerDataSource(ip, "", dbname, username, password); + listDS.Add(ds); + } + else if (type == "oracle") + { + GSODataSource ds = globeControl1.Globe.DataManager.OpenOracleDataSource(ip + "/" + dbname, "", "", username, password); + listDS.Add(ds); + } + } + + for (int i = 0; i < dbLayers.ChildNodes.Count; i++) + { + XmlNode node = dbLayers.ChildNodes.Item(i); + if (node != null) + { + string layerName = node.InnerText; + XmlAttribute attri = node.Attributes["dbindex"]; + if (attri != null) + { + int dbIndex = -1; + if (int.TryParse(attri.Value, out dbIndex)) + { + GSODataset dataset = listDS[dbIndex].GetDatasetByName(layerName); + globeControl1.Globe.Layers.Add(dataset); + //更新树节点 + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + TreeNode layerNode = new TreeNode(); + layerNode.Tag = layer; + layerNode.Text = layer.Dataset.Caption; + layerNode.ImageIndex = 0; + layerNode.SelectedImageIndex = 0; + layerNode.Checked = layer.Visible; + layerManagerNode.Nodes.Insert(0, layerNode); + // layerManagerNode.Expand(); + + + } + } + } + } + for (int i = 0; i < layers.ChildNodes.Count; i++) + { + XmlNode node = layers.ChildNodes.Item(i); + if (node != null) + { + string layerName = node.InnerText; + globeControl1.Globe.Layers.Add(layerName); + + //更新树节点 + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + TreeNode layerNode = new TreeNode(); + layerNode.Tag = layer; + layerNode.Text = layer.Dataset.Caption; + layerNode.ImageIndex = 0; + layerNode.SelectedImageIndex = 0; + layerNode.Checked = layer.Visible; + layerManagerNode.Nodes.Insert(0, layerNode); + } + } + layerManagerNode.Expand(); + } + catch (Exception e) + { + + } + } + * */ + #endregion + + private void btn_check_history_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_check_history.Text); + + if (FrmCheckHistory.isOpen == true) + { + return; + } + FrmCheckHistory frm = new FrmCheckHistory(globeControl1, globeControl2); + frm.addNode += new AddNodeToLayerManagerNode(addNodeToLayerManagerNode); + frm.Show(); + + } + + private void buttonItem查看数据_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItem查看数据.Text); + + FrmThreeOracle tr = new FrmThreeOracle(globeControl1); + + if (tr.ShowDialog() == DialogResult.OK) + { + addNodeToLayerManagerNode(tr.rukuLayer); + globeControl1.Refresh(); + } + } + /// + /// 规划数据入库 + /// + /// + /// + private void buttonItemGHRK_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemGHRK.Text); + + FrmGHRK ghrk = new FrmGHRK(globeControl1, layerManagerNode); + ghrk.Show(this); + } + + private void btn_user_info_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_user_info.Text); + + if (!FrmSysUserInfoManger.IS_OPEN) + { + FrmSysUserInfoManger frm = new FrmSysUserInfoManger(); + frm.ShowDialog(); + } + } + + private void btn_role_info_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_role_info.Text); + + if (FrmRoleInfoManager.IS_OPEN) + { + return; + } + FrmRoleInfoManager frm = new FrmRoleInfoManager(); + frm.ShowDialog(); + } + + private void btn_resc_info_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_resc_info.Text); + + if (!SysRescInfoManager.IS_OPEN) + { + SysRescInfoManager frm = new SysRescInfoManager(); + frm.ShowDialog(); + } + } + + private void btn_role_resc_Click(object sender, EventArgs e) + { + + LogManager.saveLog(Utility.userName, this.btn_role_resc.Text); + + if (!FrmRoleRescManager.IS_OPEN) + { + FrmRoleRescManager frm = new FrmRoleRescManager(); + frm.ShowDialog(); + } + } + + private void btn_user_role_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_user_role.Text); + + if (FrmUserRole.IS_OPEN) + { + return; + } + FrmUserRole frm = new FrmUserRole(); + frm.ShowDialog(); + } + + private void btn_document_info_Click(object sender, EventArgs e) + { + + LogManager.saveLog(Utility.userName, this.btn_document_info.Text); + + //if (FormDocumentManager.IS_OPEN) + //{ + // return; + //} + //FormDocumentManager frm = new FormDocumentManager(); + //frm.ShowDialog(); + + //if (FormDocumentManager.IS_OPEN) + //{ + // return; + //} + //new FormDocumentManager().ShowDialog(); + if (FormDocumentManager.IS_OPEN) + { + return; + } + this.Cursor = Cursors.WaitCursor; + FormDocumentManager frm = new FormDocumentManager(); + frm.changeCursor += new ChangeCursor(changeCursorToDefault); + frm.ShowDialog(); + + } + + private void changeCursorToDefault() + { + this.Cursor = Cursors.Default; + } + + /// + /// 判断CAD文件是否有投影信息 + /// + /// + /// + Boolean CheckDatasetGeoReference(GSODataset dataset) + { + Boolean bSuccess = false; + if (dataset.GeoReferenceType == EnumGeoReferenceType.Flat) + { + if (MessageBox.Show("数据没有空间参考信息,请设置空间参考信息!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation) == DialogResult.OK) + { + String strPath = Path.GetDirectoryName(Application.ExecutablePath) + "\\Coordinate Systems"; + OpenFileDialog dlg = new OpenFileDialog(); + + dlg.InitialDirectory = strPath; + dlg.RestoreDirectory = true; + + dlg.Filter = "投影文件|*.prj||"; + if (dlg.ShowDialog() == DialogResult.OK) + { + bSuccess = dataset.LoadProjectionFromESRIFile(dlg.FileName); + } + } + } + else + { + return true; + } + return bSuccess; + } + + private void buttonItemexp_CAD_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemexp_CAD.Text); + + OpenFileDialog dlg = new OpenFileDialog(); + dlg.Filter = "支持格式(*.dwg)|*.dwg"; + dlg.Multiselect = true; + if (dlg.ShowDialog() == DialogResult.OK) + { + for (int i = 0; i < dlg.FileNames.Length; i++) + { + //this.Cursor = Cursors.WaitCursor; + string strDataPath = dlg.FileNames[i]; + + #region + //string strDataPathPrj = strDataPath.ToLower().Replace(".dwg", ".lprj"); + + //if (File.Exists(strDataPathPrj) == false) + //{ + // if (MessageBox.Show("数据没有空间参考信息,请设置空间参考信息!", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation) == DialogResult.OK) + // { + // String strPath = Application.StartupPath + "\\Coordinate Systems"; + // OpenFileDialog dlgPrj = new OpenFileDialog(); + // dlgPrj.InitialDirectory = strPath; + // dlgPrj.RestoreDirectory = true; + // dlgPrj.Multiselect = false; + // dlg.Filter = "投影文件|*.prj"; + // if (dlg.ShowDialog() == DialogResult.OK) + // { + // this.Cursor = Cursors.WaitCursor; + // string proj4 = GSODataEngineUtility.ConvertEsriPrjFileToProj4(dlg.FileName); + // using (StreamWriter stream = new StreamWriter(strDataPathPrj, false)) + // { + // stream.WriteLine("0prj4" + proj4 + ""); + // } + // AddLayerData(strDataPath); + // //globeControl1.Globe.Layers.Add(strDataPath); + + // this.Cursor = Cursors.Default; + // } + // else + // { + // AddLayerData(strDataPath); + // //globeControl1.Globe.Layers.Add(strDataPath); + // } + // } + // else + // { + // AddLayerData(strDataPath); + // //globeControl1.Globe.Layers.Add(strDataPath); + // } + + //} + //else + //{ + // //globeControl1.Globe.Layers.Add(strDataPath); + // AddLayerData(strDataPath); + //} + #endregion + AddLayerData(strDataPath); + //this.Cursor = Cursors.Default; + } + } + + 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, 100); + + globeControl1.Refresh(); + } + } + + private void btn_password_edit_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_password_edit.Text); + + if (FrmChangePassword.IS_OPEN) + { + return; + } + FrmChangePassword frm = new FrmChangePassword(); + frm.ShowDialog(); + } + /// + /// 多孔管线入库 + /// + /// + /// + private void buttonItem9_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL4_2.Text); + + if (ds == null) + { + MessageBox.Show("请先连接数据库", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + ConnectDB(null, null); + } + if (ds == null) + return; + + FrmMultiPipelineModelDB frm = new FrmMultiPipelineModelDB(globeControl1, ds); + if (frm.ShowDialog() == DialogResult.OK) + { + addNodeToLayerManagerNode(frm.rukuLayer); + } + //frm.Show(); + } + private void 导出CADToolStripMenuItem1_Click(object sender, EventArgs e) + { + TreeNode node = layerNodeContexMenu.Tag as TreeNode; + if (node == null) + { + MessageBox.Show("请在左侧节点集中选择要导出的图层", "提示"); + return; + } + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(node.Text.Trim()); + if (layer == null || layer.GetAllFeatures().Length <= 0) + { + MessageBox.Show("要导出的图层为空", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + return; + } + string strProjectName = Utility.projectStr; + if (strProjectName != "") + { + SaveFileDialog dlg = new SaveFileDialog(); + dlg.Filter = "*.dwg|*.dwg|*.dxf|*.dxf"; + dlg.FileName = layer.Caption; + if (dlg.ShowDialog(this) == DialogResult.OK) + { + globeControl1.Globe.MemoryLayer.SaveAs(dlg.FileName); + GSOLayer newlayer = globeControl1.Globe.Layers.Add(dlg.FileName); + newlayer.RemoveAllFeature(); + int featureCount = layer.GetAllFeatures().Length; + for (int i = 0; i < featureCount; i++) + { + GSOFeature feature = layer.GetAt(i); + if (feature != null && feature.Geometry != null) + { + if (feature.Geometry.Type == EnumGeometryType.GeoPolyline3D) + { + feature.Geometry.Style = new GSOSimpleLineStyle3D(); + } + else if (feature.Geometry.Type == EnumGeometryType.GeoPolygon3D) + { + feature.Geometry.Style = new GSOSimplePolygonStyle3D(); + } + newlayer.AddFeature(feature); + } + } + newlayer.Save(); + newlayer.Dataset.DataSource.RemoveDataset(newlayer.Dataset); + globeControl1.Globe.Layers.Remove(newlayer); + MessageBox.Show("导出CAD完成!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + } + } + } + + private void buttonItemGBJC_Click(object sender, EventArgs e) + { + FrmGBJC gb = new FrmGBJC(globeControl1, globeControl2, layerTemp, layerTemp2); + gb.Show(this); + } + + #region 右屏管纵数据控制 + private void 五十米主干道ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = true; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + + private void 三十六米次干道ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = true; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + + private void 四十二米次干道ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = true; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + + private void 二十四米一块板ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = true; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + + private void 二十四米三块板ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = true; + } + + private void 二十四米停车带ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = true; + lendendGZ24_3.Visible = false; + } + + private void 二十六米大堤路ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = true; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + + private void 清除管纵数据ToolStripMenuItem_Click(object sender, EventArgs e) + { + ClearGZData(); + } + + private void ClearGZData() + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + #endregion + + private void buttonItemPasswordReset_Click(object sender, EventArgs e) + { + Frm_password_reset reset = new Frm_password_reset(); + reset.Show(); + } + + private void pictureBox1_Paint(object sender, PaintEventArgs e) + { + int Width = this.Width; + string welcomeUser = "欢迎您:" + Utility.userName; + Graphics g = e.Graphics; + g.DrawString(welcomeUser, new Font("宋体", 12), new SolidBrush(Color.Black), Width - 180, 50); + } + + } +} \ No newline at end of file diff --git a/MainFrm.cs.REMOTE.9016.cs b/MainFrm.cs.REMOTE.9016.cs new file mode 100644 index 0000000..9bfb70e --- /dev/null +++ b/MainFrm.cs.REMOTE.9016.cs @@ -0,0 +1,13345 @@ +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; + + GSOBalloon featureTooltip2; + GSOBalloonEx balloonEx2; + + GSOLayer layerTemp; + GSOLayer layerTemp2; + FrmShResult frmShResult = null; + FrmRedlineResult frmredResult = null; + FrmMnModify frmModify = null; + public bool frmRedlineResult = false; + public bool boolfrmShResult = false; + public bool boolfrmModify = false; + + List m_PipelineLayerNames = new List();//线图层名称 + List workwellLayerNames = new List();//工井图层名称 + List valueLayerNames = new List();//阀门图层名称 + List instrumenLayerNames = new List();//附属物图层名称 + List pipefittingLayerNames = new List();//管件图层名称 + List sgPipeLayersNames = new List();//施工管线图层名称 + 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 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; + public string redLayer = null; + //GSOLayer redLayer1 = null; + bool redSH = false; + string redDt = "红线"; + //双屏对比 + //bool zhanshi=false; + Thread t = null; + private GSOHudButton legendSC;//定义图例 + private GSOHudButton legendSG;//定义图例 + //管纵图 + private GSOHudButton lendendGZ50; + private GSOHudButton lendendGZ36; + private GSOHudButton lendendGZ42; + private GSOHudButton lendendGZ24_1; + private GSOHudButton lendendGZ24_2; + private GSOHudButton lendendGZ24_3; + private GSOHudButton lendendGZ26; + + GSOGeoPoint3D bsqPT; + + FrmYJSHTC frmSh = null;//一键审核窗口全局变量wxl + FrmWait frmWait = null;//一键审核等待窗口 + //FrmWait frmWait2 = null;//文档操作等待窗口 + + float mouseDownX1,mouseDownY1; + float mouseDownX2,mouseDownY2; + /// + /// + /// + 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; + + featureTooltip2 = new GSOBalloon(globeControl2.Handle); + balloonEx2 = new GSOBalloonEx(globeControl2.Handle); + Utility.SetBallons(featureTooltip, balloonEx); + + panelOfTable.Height = 200; + + RigthMenuSet(); + + MenuSet(); + + } + /// + /// 右屏中添加管纵图片 + /// + private void AddGZ() + { + + lendendGZ50 = new GSOHudButton(); + lendendGZ50.SetImage(Application.StartupPath + "/Resource/管纵/50.png"); + lendendGZ50.SetOffset(0, 0); + lendendGZ50.MinOpaque = 1; + lendendGZ50.MaxOpaque = 1; + lendendGZ50.FadeOut = false; + lendendGZ50.Name = "lendendGZ50"; + lendendGZ50.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ50); + lendendGZ50.Visible = false; + + lendendGZ36 = new GSOHudButton(); + lendendGZ36.SetImage(Application.StartupPath + "/Resource/管纵/36.png"); + lendendGZ36.SetOffset(0, 0); + lendendGZ36.MinOpaque = 1; + lendendGZ36.MaxOpaque = 1; + lendendGZ36.FadeOut = false; + lendendGZ36.Name = "lendendGZ36"; + lendendGZ36.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ36); + lendendGZ36.Visible = false; + + lendendGZ42 = new GSOHudButton(); + lendendGZ42.SetImage(Application.StartupPath + "/Resource/管纵/42.png"); + lendendGZ42.SetOffset(0, 0); + lendendGZ42.MinOpaque = 1; + lendendGZ42.MaxOpaque = 1; + lendendGZ42.FadeOut = false; + lendendGZ42.Name = "lendendGZ42"; + lendendGZ42.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ42); + lendendGZ42.Visible = false; + + lendendGZ24_1 = new GSOHudButton(); + lendendGZ24_1.SetImage(Application.StartupPath + "/Resource/管纵/24_1.png"); + lendendGZ24_1.SetOffset(0, 0); + lendendGZ24_1.MinOpaque = 1; + lendendGZ24_1.MaxOpaque = 1; + lendendGZ24_1.FadeOut = false; + lendendGZ24_1.Name = "lendendGZ24_1"; + lendendGZ24_1.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ24_1); + lendendGZ24_1.Visible = false; + + lendendGZ24_2 = new GSOHudButton(); + lendendGZ24_2.SetImage(Application.StartupPath + "/Resource/管纵/24_2.png"); + lendendGZ24_2.SetOffset(0, 0); + lendendGZ24_2.MinOpaque = 1; + lendendGZ24_2.MaxOpaque = 1; + lendendGZ24_2.FadeOut = false; + lendendGZ24_2.Name = "lendendGZ24_2"; + lendendGZ24_2.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ24_2); + lendendGZ24_2.Visible = false; + + lendendGZ24_3 = new GSOHudButton(); + lendendGZ24_3.SetImage(Application.StartupPath + "/Resource/管纵/24_3.png"); + lendendGZ24_3.SetOffset(0, 0); + lendendGZ24_3.MinOpaque = 1; + lendendGZ24_3.MaxOpaque = 1; + lendendGZ24_3.FadeOut = false; + lendendGZ24_3.Name = "lendendGZ24_3"; + lendendGZ24_3.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ24_3); + lendendGZ24_3.Visible = false; + + lendendGZ26 = new GSOHudButton(); + lendendGZ26.SetImage(Application.StartupPath + "/Resource/管纵/26.png"); + lendendGZ26.SetOffset(0, 0); + lendendGZ26.MinOpaque = 1; + lendendGZ26.MaxOpaque = 1; + lendendGZ26.FadeOut = false; + lendendGZ26.Name = "lendendGZ26"; + lendendGZ26.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ26); + lendendGZ26.Visible = false; + + } + + public void RigthMenuSet() + { + if (Utility.userRole.IndexOf("清除分析") < 0) + { + toolRightMenu.Items.Remove(清除分析ToolStripMenuItem); + } + + #region 区域分析 + if (Utility.userRole.IndexOf("区域分析") < 0) + { + toolRightMenu.Items.Remove(区域分析ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("缓冲区分析") < 0) + { + 区域分析ToolStripMenuItem.DropDownItems.Remove(缓冲区分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("附属物分析") < 0) + { + 区域分析ToolStripMenuItem.DropDownItems.Remove(附属物分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("无源淹没分析") < 0) + { + 区域分析ToolStripMenuItem.DropDownItems.Remove(无源淹没分析ToolStripMenuItem); + } + } + #endregion + + #region 视域分析 + if (Utility.userRole.IndexOf("视域分析") < 0) + { + toolRightMenu.Items.Remove(视域分析ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("通视分析") < 0) + { + 视域分析ToolStripMenuItem.DropDownItems.Remove(通视分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("可视域分析") < 0) + { + 视域分析ToolStripMenuItem.DropDownItems.Remove(可视域分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("可视包络分析") < 0) + { + 视域分析ToolStripMenuItem.DropDownItems.Remove(可视包络分析ToolStripMenuItem); + } + } + #endregion + + #region 开发分析 + if (Utility.userRole.IndexOf("开挖分析") < 0) + { + toolRightMenu.Items.Remove(开挖分析ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("多边形开挖") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(多边形开挖ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("挖方量分析") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(挖方量分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("沿线开挖") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(沿线开挖ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("创建隧道") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(创建隧道ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("隐藏隧道") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(隐藏隧道ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("删除隧道") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(删除隧道ToolStripMenuItem); + } + } + #endregion + + #region 拓扑分析 + if (Utility.userRole.IndexOf("拓扑分析") < 0) + { + toolRightMenu.Items.Remove(拓扑分析ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("创建拓扑") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(创建拓扑ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("上游分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(上游分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("下游分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(下游分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("流向分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(流向分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("关阀分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(关阀分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("连通分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(连通分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("爆管分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(爆管分析ToolStripMenuItem); + } + } + #endregion + + #region 断面分析 + if (Utility.userRole.IndexOf("断面分析") < 0) + { + toolRightMenu.Items.Remove(断面分析ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("横断面分析") < 0) + { + 断面分析ToolStripMenuItem.DropDownItems.Remove(横断面分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("纵断面分析") < 0) + { + 断面分析ToolStripMenuItem.DropDownItems.Remove(纵断面分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("道路断面分析") < 0) + { + 断面分析ToolStripMenuItem.DropDownItems.Remove(道路断面分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("基线剖面分析") < 0) + { + 断面分析ToolStripMenuItem.DropDownItems.Remove(基线剖面分析ToolStripMenuItem); + } + } + #endregion + + #region 绘制区域统计 + if (Utility.userRole.IndexOf("绘制区域统计") < 0) + { + toolRightMenu.Items.Remove(绘制区域统计ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("绘制区域管线长度统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管线长度统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域阀门数量统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(阀门数量统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域井盖数量统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(井盖数量统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域管径分段统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管径分段统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域埋深分段统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(埋深分段统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域管径分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管径分类统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域材质分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(材质分类统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域附属物分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(附属物分类统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域标识器分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(标识器分类统计ToolStripMenuItem1); + } + + } + #endregion + + #region 全区域统计 + if (Utility.userRole.IndexOf("全区域统计") < 0) + { + toolRightMenu.Items.Remove(全区域统计ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("全区域管线长度统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管线长度统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域阀门数量统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(阀门数量统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域井盖数量统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(井盖数量统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域管径分段统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管径分段统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域埋深分段统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(埋深分段统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域管径分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管径分类统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域材质分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(材质分类统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域附属物分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(附属物分类统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域标识器分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(标识器分类统计ToolStripMenuItem); + } + + } + #endregion + + #region 查询 + if (Utility.userRole.IndexOf("查询") < 0) + { + toolRightMenu.Items.Remove(查询ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("空间查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(空间查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("编号查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(编号查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("坐标查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(坐标查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("管径查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(管径查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("材质查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(材质查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("基本查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(基本查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("复合查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(复合查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("关联查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(关联查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("关键字查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(关键字查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("附属物查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(附属物查询ToolStripMenuItem); + } + } + #endregion + + #region 标注 + if (Utility.userRole.IndexOf("标注") < 0) + { + toolRightMenu.Items.Remove(标注ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("标高标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(标高标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("管径标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(管径标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("埋深标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(埋深标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("坐标标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(坐标标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("距离标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(距离标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("自定义标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(自定义标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("扯旗标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(扯旗标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("坡度标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(坡度标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("属性标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(属性标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("标注管理") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(标注管理ToolStripMenuItem); + } + } + #endregion + + #region 飞行 + if (Utility.userRole.IndexOf("飞行") < 0) + { + toolRightMenu.Items.Remove(飞行ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("自定义飞行") < 0) + { + 飞行ToolStripMenuItem.DropDownItems.Remove(自定义飞行ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("飞行到目标点") < 0) + { + 飞行ToolStripMenuItem.DropDownItems.Remove(飞行到目标点ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("绕中心点飞行") < 0) + { + 飞行ToolStripMenuItem.DropDownItems.Remove(绕中心点飞行ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("绕眼睛飞行") < 0) + { + 飞行ToolStripMenuItem.DropDownItems.Remove(绕眼睛飞行ToolStripMenuItem); + } + } + #endregion + + #region 编辑 + if (Utility.userRole.IndexOf("编辑") < 0) + { + toolRightMenu.Items.Remove(编辑ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("平移对象") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(平移对象ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("升降对象") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(升降对象ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("旋转对象") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(旋转对象ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("连接管段") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(连接管段ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("导出文件") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(导出文件ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("前进") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(前进ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("后退") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(删除模型ToolStripMenuItem); + } + } + #endregion + + #region 量算 + if (Utility.userRole.IndexOf("量算") < 0) + { + toolRightMenu.Items.Remove(量算ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("水平距离") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(水平距离ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("垂直距离") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(垂直距离ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("空间距离") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(空间距离ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("地表距离") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(地表距离ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("高度量算") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(高度量算ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("水平面积") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(水平面积ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("地表面积") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(地表面积ToolStripMenuItem1); + } + } + #endregion + } + + public void MenuSet() + { + + #region 权限管理 + if (Utility.userRole.IndexOf("权限管理") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem2); + } + else + { + + if (Utility.userRole.IndexOf("用户管理") < 0) + { + btn_user_info.Visible = false; + } + if (Utility.userRole.IndexOf("角色管理") < 0) + { + btn_role_info.Visible = false; + } + if (Utility.userRole.IndexOf("资源管理") < 0) + { + btn_resc_info.Visible = false; + } + if (Utility.userRole.IndexOf("角色授权") < 0) + { + btn_role_resc.Visible = false; + } + if (Utility.userRole.IndexOf("用户授权") < 0) + { + btn_user_role.Visible = false; + } + if (Utility.userRole.IndexOf("密码修改") < 0) + { + btn_password_edit.Visible = false; + } + + } + #endregion + + #region 基础工具 + if (Utility.userRole.IndexOf("基础工具") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem1); + } + else + { + if (Utility.userRole.IndexOf("地上模式") < 0) + { + buttonItem87.Visible = false; + } + if (Utility.userRole.IndexOf("地下模式") < 0) + { + buttonItem88.Visible = false; + } + if (Utility.userRole.IndexOf("行走模式") < 0) + { + buttonItem27.Visible = false; + } + if (Utility.userRole.IndexOf("透明度设置") < 0) + { + sliderGroundTransSet1.Visible = false; + } + if (Utility.userRole.IndexOf("快速定位") < 0) + { + buttonItem91.Visible = false; + } + if (Utility.userRole.IndexOf("图层管理") < 0) + { + buttonItem1.Visible = false; + } + if (Utility.userRole.IndexOf("图例管理") < 0) + { + btnlegendSet.Visible = false; + } + if (Utility.userRole.IndexOf("全屏显示") < 0) + { + buttonItem89.Visible = false; + } + if (Utility.userRole.IndexOf("导出图片") < 0) + { + btnOutputJPG.Visible = false; + } + + } + #endregion + + #region 一键审核 + if (Utility.userRole.IndexOf("一键审核") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem11); + } + #endregion + + #region 红线审核 + if (Utility.userRole.IndexOf("红线审核") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem6); + } + #endregion + + #region 双屏对比 + if (Utility.userRole.IndexOf("双屏对比") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem9); + } + #endregion + + #region 文档管理 + if (Utility.userRole.IndexOf("文档管理") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem4); + } + #endregion + + #region 基础管理 + if (Utility.userRole.IndexOf("基础管理") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem14); + } + else + { + if (Utility.userRole.IndexOf("专题图审批") < 0) + { + buttonItemZTT3_2.Visible = false; + } + if (Utility.userRole.IndexOf("打印审批") < 0) + { + buttonItemZTT4_2.Visible = false; + } + if (Utility.userRole.IndexOf("拷贝审批") < 0) + { + buttonItemZTT5_2.Visible = false; + } + } + + #endregion + + if (ribbonControl1.Items.Count <= 0) + { + ribbonControl1.Visible = false; + } + } + + #region Fan Zhang 重构现有代码 + //初始化控件布局 + private void initLayout() + { + 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.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.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.labelX21.Width = (int)(this.labelX21.Width * myScreen); + this.labelX22.Width = (int)(this.labelX22.Width * myScreen); + this.labelX24.Width = (int)(this.labelX24.Width * myScreen); + } + sideBar1.Visible = false; + 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]); + } + + splitContainer1.Panel2Collapsed = true; + + buttonItem87.Checked = true;//默认地上模式 + ribbonTabItem1.Select(); //初始化状态为浏览 + + sideBarPanelItem3.Visible = false; + layerTree.Visible = false; + controlContainerItem3.Visible = false; + if (sideBarPanelItem4.Visible == true) + { + sideBar1.Visible = true; + controlContainerItem5.Visible = true; + } + else + { + sideBar1.Visible = false; + } + Refresh(); + sliderGroundTransSet1.Value = optiValue; + sliderItem1.Value = optiValue; + sliderItem2.Value = optiValue; + sliderItem3.Value = optiValue; + + } + + //初始化地球控件 + private void initGlobalControl() + { + //选择 + btnToolSelect = new GSOHudButton(); + btnToolSelect.SetImage(Application.StartupPath + "\\Resource\\image\\select1.png"); + btnToolSelect.FadeOut = false; + btnToolSelect.Align = EnumAlign.TopLeft; + btnToolSelect.SetOffset(20, 50); + btnToolSelect.Name = "1"; + btnToolSelect.HeightFixed = true; + btnToolSelect.WidthFixed = true; + globeControl1.Globe.AddHudControl(btnToolSelect); + globeControl2.Globe.AddHudControl(btnToolSelect); + + //浏览 + 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); + + //图例 + legend = new GSOHudButton(); + legend.SetImage(Application.StartupPath + "/Resource/图例P.jpg");//图例P + legend.SetOffset(0, 15); + legend.MinOpaque = 1; + legend.MaxOpaque = 1; + legend.FadeOut = false; + legend.Name = "legend"; + legend.Align = EnumAlign.BottomRight; + legend.Visible = false; + globeControl1.Globe.AddHudControl(legend); + + //实测 + legendSC = new GSOHudButton(); + legendSC.SetImage(Application.StartupPath + "/Resource/sc.jpg"); + legendSC.SetOffset(0, 15); + legendSC.MinOpaque = 1; + legendSC.MaxOpaque = 1; + legendSC.FadeOut = false; + legendSC.Name = "legendSC"; + legendSC.Align = EnumAlign.BottomRight; + globeControl1.Globe.AddHudControl(legendSC); + legendSC.Visible = false; + + //施工 + legendSG = new GSOHudButton(); + legendSG.SetImage(Application.StartupPath + "/Resource/sg.jpg"); + legendSG.SetOffset(0, 15); + legendSG.MinOpaque = 1; + legendSG.MaxOpaque = 1; + legendSG.FadeOut = false; + legendSG.Name = "legendSG"; + legendSG.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(legendSG); + legendSG.Visible = false; + + //管纵 + AddGZ(); + + 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; + globeControl1.Globe.IsReleaseMemOutOfView = true; + globeControl1.Globe.ControlPanel.Visible = true; + + globeControl2.Globe.UnderGroundFloor.Visible = false; + globeControl2.Globe.OverviewControl.Visible = false; + globeControl2.Globe.ScalerControl.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; + globeControl2.Globe.IsReleaseMemOutOfView = true; + globeControl2.Globe.ControlPanel.Visible = false; + + 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); + + //添加临时图层 + layerTemp = globeControl1.Globe.Layers.Add(Application.StartupPath + "\\tempLgdData.lgd"); + layerTemp2 = globeControl2.Globe.Layers.Add(Application.StartupPath + "\\tempLgdData2.lgd"); + if (layerTemp != null) + { + layerTemp.MaxVisibleAltitude = 1000; + } + + //添加城市7线图层 + 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"); + + //注册对应事件 + this.registerEvent(); + } + + //注册地球事件 + private bool registerEvent() + { + if (globeControl1 == null || globeControl2 == null) + { + return false; + } + 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); + + globeControl2.FeatureMouseClickEvent += new FeatureMouseClickEventHandler(globeControl2_FeatureMouseClickEvent); + globeControl2.CameraBeginMoveEvent += new CameraBeginMoveEventHandler(globeControl2_CameraBeginMoveEvent); + + globeControl1.MouseDoubleClick += new MouseEventHandler(globeControl1_MouseDoubleClick); + globeControl1.MouseClick += new MouseEventHandler(globeControl1_MouseClick); + globeControl1.MouseDown += new MouseEventHandler(globeControl1_MouseDown); + + globeControl2.MouseClick += new MouseEventHandler(globeControl2_MouseClick); + globeControl2.MouseDown += new MouseEventHandler(globeControl2_MouseDown); + + 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); + + return true; + } + + //加载两个地球数据 + private void loadData() + { + Thread t1 = new Thread(new ThreadStart(doLoadDataForGlobalControl1)); + t1.IsBackground = true; + t1.Start(); + + + } + + delegate void LoadDataForGlobalControl(); + + private void connectServer() + { + globeControl1.Globe.ConnectServer(Utility.serverip, Utility.serverport, "", ""); //加载locaServer中的数据 + globeControl2.Globe.ConnectServer(Utility.serverip, Utility.serverport, "", ""); //加载locaServer中的数据 + //初始化TreeView + // 勾选实测图层 + foreach (TreeNode tn in layerTree.Nodes) + { + if (tn.Nodes.Count > 0) + { + if (tn.Text == "实测数据") + { + tn.Checked = true; + foreach (TreeNode tnChild in tn.Nodes) + { + tnChild.Checked = true; + foreach (TreeNode tnGrandChild in tnChild.Nodes) + { + tnGrandChild.Checked = true; + } + } + } + } + } + } + + private void doLoadDataForGlobalControl1() + { + try + { + + globeControl1.Globe.Layers.MoveDown(10000); + //加载实测管线数据 + Utility.dataSource = globeControl1.Globe.DataManager.OpenOracleDataSource(Utility.DBServer.Trim() + "/" + Utility.dbdatabase.Trim(), "", "", Utility.userID, Utility.DBPassword); + + if (Utility.dataSource != null) + { + for (int j = 0; j < Utility.dataSource.DatasetCount; j++) + { + GSODataset dataset = Utility.dataSource.GetDatasetAt(j); + if (dataset != null && dictionaryNetLayerNameAndCaption.ContainsKey(dataset.Caption)) + { + dataset.Caption = dataset.Name; + globeControl1.Globe.Layers.Add(dataset); + } + } + } + //隐藏红线图层 + globeControl1.Globe.Layers.GetLayerByCaption("红线").Visible = false; + + //globleControl1中加载规划数据 + GSODataSource ghDS = globeControl1.Globe.DataManager.OpenOracleDataSource(Utility.ghdbip + "/" + Utility.ghdbname, "", "", Utility.ghdbuser, Utility.ghdbpwd); + if (ghDS != null) + { + for (int j = 0; j < ghDS.DatasetCount; j++) + { + GSODataset dataset = ghDS.GetDatasetAt(j); + if (dataset != null && dictionaryNetLayerNameAndCaption.ContainsKey(dataset.Caption)) + { + dataset.Caption = dataset.Name; + globeControl1.Globe.Layers.Add(dataset); + globeControl1.Globe.Layers[0].Visible = false; + } + } + } + + //globeControl1,globeControl2中加载施工数据 + GSODataSource sgDS = globeControl1.Globe.DataManager.OpenOracleDataSource(Utility.sgdbip + "/" + Utility.sgdbname, "", "", Utility.sgdbuser, Utility.sgdbpwd); + if (sgDS != null) + { + for (int m = 0; m < sgDS.DatasetCount; m++) + { + GSODataset dataset = sgDS.GetDatasetAt(m); + if (dataset != null && !dataset.Caption.Contains("SH") && dictionaryNetLayerNameAndCaption.ContainsKey(dataset.Caption)) + { + dataset.Caption = dataset.Name; + globeControl1.Globe.Layers.Add(dataset); + globeControl1.Globe.Layers[0].Visible = false; + + globeControl2.Globe.Layers.Add(dataset); + globeControl2.Globe.Layers[0].Visible = true; + } + } + } + + LoadDataForGlobalControl ss = new LoadDataForGlobalControl(connectServer); + ss(); + + } + catch (Exception ex) + { + MessageBox.Show(ex.Message); + } + } + + private void initLayerTree() + { + //加载临时图层节点 + layerManagerNode = new TreeNode(); + layerManagerNode.ImageIndex = 0; + layerManagerNode.SelectedImageIndex = 0; + layerManagerNode.Checked = true; + layerManagerNode.Text = "临时图层"; + layerTree.Nodes.Add(layerManagerNode); + + XmlDocument doc = new XmlDocument(); + doc.Load(filename); + XmlNodeList xmlLayerNodes = doc.SelectNodes("//layer"); + + foreach (XmlNode xmlLayerNode in xmlLayerNodes) + { + + //TODO LIST:创建一级TreeNode(实测、规划、施工) + TreeNode nodelayer = new TreeNode(); + string layerName = xmlLayerNode.Attributes["label"].Value; + nodelayer.Text = layerName; + nodelayer.Checked = false; + layerTree.Nodes.Add(nodelayer); + + XmlNodeList xmlChildLayerNodes = xmlLayerNode.ChildNodes; + foreach (XmlNode xmlChildLayerNode in xmlChildLayerNodes) + { + //TODO LIST:创建二级TreeNode节点 + TreeNode secondLevelNode = new TreeNode(); + string layerType = xmlChildLayerNode.Attributes["label"].Value; + secondLevelNode.Text = layerType; + + if (xmlChildLayerNode.Attributes["type"] != null) + { //道路图层特殊处理 + string type = xmlChildLayerNode.Attributes["type"].Value; + secondLevelNode.Tag = type + "|" + layerType; + } + else + { + secondLevelNode.Tag = layerType; + } + secondLevelNode.Checked = false; + nodelayer.Nodes.Add(secondLevelNode); + + XmlNodeList xmlActitualLayerNodes = xmlChildLayerNode.ChildNodes; + + foreach (XmlNode xmlActitualLayerNode in xmlActitualLayerNodes) + { + //TODO LIST:创建三级图层节点 + TreeNode layerNode = new TreeNode(); + string actutallylayerType = xmlActitualLayerNode.Attributes["type"].Value; + string actutallylayerName = xmlActitualLayerNode.Attributes["layer"].Value; + string actutallyLabelName = xmlActitualLayerNode.Attributes["label"].Value; + + layerNode.Text = actutallyLabelName; + layerNode.Tag = layerType + "|" + actutallyLabelName; + layerNode.Checked = false; + secondLevelNode.Nodes.Add(layerNode); + } + + } + + } + + } + + /** + * 读取Config.xml文件,初始化以下全局Map + * m_PipelineLayerNames:管线 + * workwellLayerNames:工井 + * valueLayerNames:阀门 + * instrumenLayerNames:附属物 + * pipefittingLayerNames:特征管点 + * sgPipeLayersNames:施工管线 + **/ + private void initGlobalMap() + { + XmlDocument doc = new XmlDocument(); + doc.Load(filename); + XmlNodeList xmlLayerNodes = doc.SelectNodes("//layerchild"); + + foreach (XmlNode xmlLayerNode in xmlLayerNodes) + { + string layerType = xmlLayerNode.Attributes["type"].Value; + string layerName1 = xmlLayerNode.Attributes["layer"].Value; + string layerchildName = xmlLayerNode.Attributes["label"].Value; + + dictionaryNetLayerNameAndCaption.Add(layerName1, layerchildName); + + if (layerType != "db") + { + if (xmlLayerNode.Attributes["isRoad"] != null) + { + roadLayerName = layerchildName; + } + } + else if (xmlLayerNode.Attributes["isPipeLine"] != null) + { + m_PipelineLayerNames.Add(layerchildName); + g1layername.Add(layerName1); + } + else if (xmlLayerNode.Attributes["isWorkWell"] != null) + { + workwellLayerNames.Add(layerchildName); + g1layername.Add(layerName1); + } + else if (xmlLayerNode.Attributes["isValve"] != null) + { + valueLayerNames.Add(layerchildName); + g1layername.Add(layerName1); + } + else if (xmlLayerNode.Attributes["isAccess"] != null) + { + instrumenLayerNames.Add(layerchildName); + g1layername.Add(layerName1); + } + else if (xmlLayerNode.Attributes["isCharacter"] != null) + { + pipefittingLayerNames.Add(layerchildName); + g1layername.Add(layerName1); + } + else if (xmlLayerNode.Attributes["isSgData"] != null) + { + sgPipeLayersNames.Add(layerchildName); + g1layername.Add(layerName1); + } + + } + } + + private void initMarkerTree() + { + 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); + } + } + } + } + + private void MainFrm_Load(object sender, EventArgs e) + { + + this.initGlobalControl(); + this.initGlobalMap(); + this.initLayerTree(); + this.initMarkerTree(); + this.initLayout(); + this.loadData(); + + + double x = Convert.ToDouble(Utility.Query_Roads["绿岛"].ToString().Split(',')[0]); + double y = Convert.ToDouble(Utility.Query_Roads["绿岛"].ToString().Split(',')[1]); + double z = Convert.ToDouble(Utility.Query_Roads["绿岛"].ToString().Split(',')[2]); + jumpToCameraState(x, y, z); + + + } + + #endregion + + /// + /// 每次gis服务加载时都会触发的 + /// + /// + /// + 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 dictionaryNetLayerNameAndCaption = new Dictionary(); + 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 配置用户权限 + /// + /// 向数据库插入功能列表 + /// + private void insertControlToDatabase() + { + ArrayList listItem = new ArrayList(); + List subListItem = new List(); + 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) + { + GSOCameraState camera = globeControl2.Globe.CameraState; + globeControl1.Globe.JumpToCameraState(camera); + } + } + + void globeControl1_BeforeSceneRenderEvent(object sender, BeforeSceneRenderEventArgs e) + { + if (globeControl1.Focused) + { + 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); + } + } + } + + /// + /// 检查数据集是否有坐标系信息 + /// + /// + /// + 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 = "0prj4" + lprjStr + ""; + + bSuccess = dataset.LoadProjectionFromESRIFile(dlg.FileName); + + string lprjFileName = strDataPath.Substring(0, strDataPath.LastIndexOf(".")) + ".lprj"; + StreamWriter writer = new StreamWriter(lprjFileName, false); + writer.Write(lprjFileContent); + writer.Close(); + + } + } + } + else + { + return true; + } + return bSuccess; + } + + /// + /// 矩形拉框结束事件处理函数 + /// + /// + /// + 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))); + */ + + int mapWidth = 0; + int mapHeight = 0; + Point pt = getUpperLeftPoint(pt1, pt2, out mapWidth, out mapHeight); + int rightBottomX = pt.X + mapWidth; + int rightBottomY = pt.Y + mapHeight; + Image myImg = new Bitmap(mapWidth, mapHeight); + Graphics g = Graphics.FromImage(myImg); + g.CopyFromScreen(pt, new Point(0, 0), new Size(rightBottomX, rightBottomY)); + + 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; + } + } + /// + /// 定位正北正90度俯视 + /// + /// + /// + /// + 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; + } + } + /// + /// layerTree选中后事件处理 + /// + /// + /// + 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); + } + /// + /// 树节点选中方法 + /// + /// + 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); + } + } + } + + } + /// + /// 改变所有子节点的状态 + /// + /// + /// + 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; + LayerFlyMenuItem.Visible = true; + } + + LayerSelectableMenuItem.Visible = true; + LayerEditableMenuItem.Visible = true; + SaveLayerMenuItem.Visible = true; + LayerFlyMenuItem.Visible = true; + 导出CADToolStripMenuItem1.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]); + if (layer != null) + { + LayerSelectableMenuItem.Checked = layer.Selectable; + LayerEditableMenuItem.Checked = layer.Editable; + } + else + { + return; + } + } + 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; + } + } + } + } + } + + /// + /// 删除临时添加的本地数据图层 + /// + /// + /// + 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); + for (int i = globeControl1.Globe.Layers.Count-1; i >=0; i--) + { + if (globeControl1.Globe.Layers[i].Caption == layer.Caption) + { + globeControl1.Globe.Layers.Remove(globeControl1.Globe.Layers[i]); + } + } + + 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 定位ToolStripMenuItem_Click(object sender, EventArgs e) + { + TreeNode node = layerTree.SelectedNode; + + if (node != null) + { + if (node.Parent.Text.Trim() == "临时图层") + { + GSOLayer lsLayer = globeControl1.Globe.Layers.GetLayerByCaption(node.Text.ToString()); + double x = lsLayer.LatLonBounds.Center.X; + double y = lsLayer.LatLonBounds.Center.Y; + if (x == 0 && y == 0) + { + x = lsLayer.Bounds.Center.X; + y = lsLayer.Bounds.Center.Y; + } + + globeControl1.Globe.FlyToPosition(new GSOPoint3d(x, y, 10), EnumAltitudeMode.Absolute); + } + else + { + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(node.Tag.ToString().Split('|')[1]); + + if (layer != null) + { + if (layer.Caption == "红线") + { + globeControl1.Globe.FlyToPosition(new GSOPoint3d(120.610963, 31.188121, 50), EnumAltitudeMode.Absolute, -4, 50, 1000); + globeControl1.Globe.FlyToPointSpeed = 10000000; + globeControl1.Globe.Action = EnumAction3D.SelectObject; + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = true; + } + globeControl1.Refresh(); + } + else + { + double x = layer.LatLonBounds.Center.X; + double y = layer.LatLonBounds.Center.Y; + globeControl1.Globe.FlyToPosition(new GSOPoint3d(x, y, 100), EnumAltitudeMode.Absolute); + } + } + } + } + else + { + return; + } + + } + + private void layerTree_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e) + { + if(this.layerTree.SelectedNode!=null) + { + if (this.layerTree.SelectedNode.Tag.ToString().Contains("|")) + { + string nodeTag = this.layerTree.SelectedNode.Tag.ToString().Split('|')[1]; + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(nodeTag); + if (layer != null) + { + if (layer.Caption == "红线") + { + globeControl1.Globe.FlyToPosition(new GSOPoint3d(120.610963, 31.188121, 50), EnumAltitudeMode.Absolute, -4, 50, 1000); + globeControl1.Globe.FlyToPointSpeed = 10000000; + globeControl1.Globe.Action = EnumAction3D.SelectObject; + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = true; + } + globeControl1.Refresh(); + } + else { + double x = layer.LatLonBounds.Center.X; + double y = layer.LatLonBounds.Center.Y; + globeControl1.Globe.FlyToPosition(new GSOPoint3d(x, y, 0), EnumAltitudeMode.Absolute); + } + } + } + if (this.layerTree.SelectedNode.Tag is GSOLayer) + { + GSOLayer layer = this.layerTree.SelectedNode.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 (this.layerTree.SelectedNode.Tag is GSOFeature) + { + GSOFeature feature = this.layerTree.SelectedNode.Tag as GSOFeature; + if (feature.Geometry != null) + { + globeControl1.Globe.FlyToPosition(feature.Geometry.GeoCenterPoint, EnumAltitudeMode.Absolute, 0, 0, 10); + } + else + { + globeControl1.Globe.FlyToFeature(feature); + } + } + } + } + + /// + /// 在三维场景移动时,隐藏气泡globeControl1 + /// + /// + /// + void globeControl1_CameraBeginMoveEvent(object sender, CameraBeginMoveEventArgs e) + { + if (featureTooltip.IsVisible()) + { + featureTooltip.HideBalloon(); + } + if (balloonEx.IsVisible()) + { + balloonEx.HideBalloon(); + } + } + + /// + /// 在三维场景移动时,隐藏气泡globeControl2 + /// + /// + /// + void globeControl2_CameraBeginMoveEvent(object sender, CameraBeginMoveEventArgs e) + { + if (featureTooltip2.IsVisible()) + { + featureTooltip2.HideBalloon(); + } + if (balloonEx2.IsVisible()) + { + balloonEx2.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(); + } + } + + #region Fan 横断面 + /// + /// 横断面分析、基线剖面分析、道路断面分析等 + /// + /// + /// + private static EnumTrackPolylineEndMode trackPolylineEndMode; + + void globeControl1_TrackPolylineEndEvent(object sender, TrackPolylineEndEventArgs e) + { + //横断面分析、道路横断面分析 + if (trackPolylineEndMode == EnumTrackPolylineEndMode.HDM_Analysis|| + trackPolylineEndMode == EnumTrackPolylineEndMode.DLDM_Analysis) + { + Dictionary hdmDic = SectionAnalysisTool.HDMAnalysis(this.globeControl1, + e.Polyline, this.m_PipelineLayerNames); + FrmHDMAnalysis3 frm = new FrmHDMAnalysis3(hdmDic, this.globeControl1, + trackPolylineEndMode); + frm.Show(this); + } + //基线剖面分析 + else if (trackPolylineEndMode == EnumTrackPolylineEndMode.JXPM_Analysis) + { + FrmBaseLineProfillAnalysis dlg = new FrmBaseLineProfillAnalysis(globeControl1.Globe, e.Polyline); + dlg.Show(this); + globeControl1.Globe.ClearLastTrackPolyline(); + /* + FrmRoadHDM f = new FrmRoadHDM(); + f.Show() + * **/ + } + else + { + + } + trackPolylineEndMode = EnumTrackPolylineEndMode.Default_Analysis; + /* + ArrayList arraylistPoint = new ArrayList(); + ArrayList arraylistLine = new ArrayList(); + + // globeControl1.Globe.ClearLastTrackPolyline(); + + if (e.Polyline != null) + { + //横断面分析 + if (buttonItemFX2_1.Checked || buttonItemFX2_3.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 (buttonItemFX2_1.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 (buttonItemFX2_4.Checked) + { + FrmBaseLineProfillAnalysis dlg = new FrmBaseLineProfillAnalysis(globeControl1.Globe, e.Polyline); + dlg.Show(this); + globeControl1.Globe.ClearLastTrackPolyline(); + } + else if (buttonItemFX4_3.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(); + * **/ + } + #endregion + + private GSOFeatures PolygonIntersectAnalysis(GSOGeoPolygon3D polygon, string pipelinetype) + { + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(pipelinetype); + 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(pipelinetype, feats.Length); + return feats; + } + /// + /// 根据范围统计阀门、管线、工井等, 开挖分析, 挖方量分析 + /// + /// + /// + void globeControl1_TrackPolygonEndEvent(object sender, TrackPolygonEndEventArgs e) + { + if (globeControl1.Globe.Action == EnumAction3D.TrackPolygon && e.Polygon != null) + { + GSOGeoPolygon3D polygon = e.Polygon; + + switch (trackflag) + { + case "valvequery": + FrmValveStatistics frm = new FrmValveStatistics(globeControl1,polygon, new DataGridViewDelegate(InitDataGridViewX1)); + frm.Show(this); + //panelEx6.Visible = true; + toolStripFeatureLength.Text = ""; + globeControl1.Globe.Action = EnumAction3D.ActionNull; + break; + + case "PipelineDistanceStatistics": + + FrmAllPipelineStatis frm1 = new FrmAllPipelineStatis(globeControl1, polygon, new DataGridViewDelegate(InitDataGridViewX1), m_PipelineLayerNames); + frm1.Show(this); + globeControl1.Globe.Action = EnumAction3D.ActionNull; + + break; + case "PipelineSpatialQuery": + + FrmAllPipelineStatis.ShowForm(globeControl1,polygon,new DataGridViewDelegate(InitDataGridViewX1),m_PipelineLayerNames); + globeControl1.Globe.ClearAnalysis(); + globeControl1.Globe.Action = EnumAction3D.ActionNull; + + break; + case "workwellquery": + FrmAllWorkWellStatis frmWell = new FrmAllWorkWellStatis(globeControl1, polygon, new DataGridViewDelegate(InitDataGridViewX1)); + 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 "BSQDuoBianXiangStatis": + + //GSOFeature f2 = new GSOFeature(); + //f2.Geometry = e.Polygon; + //f2.Geometry.AltitudeMode = EnumAltitudeMode.Absolute; + //globeControl1.Globe.MemoryLayer.AddFeature(f2); + //f2.Geometry.MoveZ(3); + //workWellLen.Clear(); + //List listBSQ = new List(); + + //GSOFeatures bsqFeatures = PolygonIntersectAnalysis(e.Polygon, "标识器"); + //listBSQ.Add(bsqFeatures); + + //FrmBSQDuoBianXingStatis bsqFrm = new FrmBSQDuoBianXingStatis(workWellLen, globeControl1, listBSQ); + FrmBSQStatis bsqFrm = new FrmBSQStatis(globeControl1,e.Polygon); + bsqFrm.Show(this); + globeControl1.Globe.Action = EnumAction3D.ActionNull; + break; + + case "": + break; + default: + break; + } + } + } + + #region 验证端口 + /* + /// + /// 验证端口 + /// + /// + 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 + + /// + /// 鼠标悬浮提示 + /// + /// + /// + 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); + } + } + + /// + /// 添加管线绘制完成事件, 红线工具绘制完成 + /// + /// + /// + 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; + + + } + } + + /// + /// 获取globeControl1中鼠标按下的坐标供区别鼠标右键和滚轮按下事件 + /// + /// + /// + void globeControl1_MouseDown(object sender, MouseEventArgs e) + { + mouseDownX1 = e.X; + mouseDownY1 = e.Y; + } + /// + /// 获取globeControl2中鼠标按下的坐标供区别鼠标右键和滚轮按下事件 + /// + /// + /// + void globeControl2_MouseDown(object sender, MouseEventArgs e) + { + mouseDownX2 = e.X; + mouseDownY2 = e.Y; + } + /// + /// + /// + /// + /// + void globeControl2_MouseClick(object sender, MouseEventArgs e) + { + if (e.Button == MouseButtons.Right) + { + if (e.X == mouseDownX2 && e.Y == mouseDownY2) + { + RightScreenToolMenu.Show(globeControl2, e.X, e.Y); + } + else + { + return; + } + } + } + /// + /// + /// + /// + /// + void globeControl1_MouseClick(object sender, MouseEventArgs e) + { + if (e.Button == MouseButtons.Left) + { + if (globeControl1.Globe.Action == EnumAction3D.VisibilityAnalysis) + { + buttonItemFX5_1.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; + + bsqPT = pt; + + if (buttonItemLS5.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 (e.X == mouseDownX1 && e.Y == mouseDownY1) + { + toolRightMenu.Show(globeControl1, e.X, e.Y); + if (buttonItemLS5.Checked) + { + buttonItemLS5.Checked = false; + } + } + else + { + return; + } + } + globeControl1.Refresh(); + } + + /// + /// 判断网络图片是否存在 + /// + /// + /// + 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; + } + + /// + /// 鼠标点击, 弹出气泡功能globeControl1 + /// + /// + /// + void globeControl1_FeatureMouseClickEvent(object sender, FeatureMouseClickEventArgs e) + { + GSOFeature feature = e.Feature; + + string str1 = ""; + if (feature != null) + { + if (feature.GetFieldDefn("图片编码") != null)// + { + str1 = GetBubbleInfo(feature, globeControl1); + if (RemoteFileExists(Utility.PicRootURL + feature.GetValue("图片编码").ToString())) + { + str1 += ""; + } + else if (RemoteFileExists(Utility.PicDefaultURL)) + { + str1 += ""; + } + } + else if (isFeatureContainsBianhao(feature)) //管线模型图层 + { + str1 = GetBubbleInfo(feature, globeControl1); + } + + 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; + } + } + } + + /// + /// 鼠标点击, 弹出气泡功能globeControl2 + /// + /// + /// + void globeControl2_FeatureMouseClickEvent(object sender, FeatureMouseClickEventArgs e) + { + GSOFeature feature = e.Feature; + + string str1 = ""; + if (feature != null) + { + if (feature.GetFieldDefn("图片编码") != null) // + { + str1 = GetBubbleInfo(feature, globeControl2); + if (RemoteFileExists(Utility.PicRootURL + feature.GetValue("图片编码").ToString())) + { + str1 += ""; + } + else if (RemoteFileExists(Utility.PicDefaultURL)) + { + str1 += ""; + } + } + else if (isFeatureContainsBianhao(feature)) //管线模型图层 + { + str1 = GetBubbleInfo(feature, globeControl2); + } + + if (str1 != "") + { + + featureTooltip2.HideBalloon(); + balloonEx2.HideBalloon(); + balloonEx2.SetSize(EnumSizeIndexEx.CONTENT_CX, 480); + balloonEx2.SetSize(EnumSizeIndexEx.CONTENT_CY, 420); + balloonEx2.ShowBalloon((int)e.MousePos.X, (int)e.MousePos.Y, str1); + + return; + } + } + } + + /// + /// 拼接气泡表格字符串 + /// + /// + /// + private string GetBubbleInfo(GSOFeature feature,GSOGlobeControl globeControl) + { + if (feature == null) + { + return ""; + } + string str = ""; + str = ""; + 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 += ""; + + 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.get_Fields(layerName, globeControl); + } + if (queryFields != null) + { + string[] param = { "," }; + string[] fieldNames = queryFields.Split(param, StringSplitOptions.RemoveEmptyEntries); + for (int j = 0; j < fieldNames.Length; 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 (name1 == "模型路径") + { + continue; + } + 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 (field1.Type == EnumFieldType.Double) + { + double dl1 = feature.GetFieldAsDouble(j); + if (!name1.Contains("管径") && !name1.Contains("电压") && !name1.Contains("角度")) + { + name1 += "_米"; + } + value1 = dl1.ToString("0.00"); + } + 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 (name2 == "模型路径") + { + continue; + } + + 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 (field2.Type == EnumFieldType.Double) + { + double dl2 = feature.GetFieldAsDouble(j + 1); + if (!name2.Contains("管径") && !name2.Contains("电压") && !name2.Contains("角度")) + { + name2 += "_米"; + } + value2 = dl2.ToString("0.00"); + } + else + { + if (!feature.IsFieldValueNull(j + 1)) + { + value2 = feature.GetValue(j + 1).ToString(); + } + } + } + } + + j++; + } + str += ""; + } + } + str += "
" + title + " " + feature.GetFieldAsString(featureIDFieldName) + "
" + + name1 + + "
" + + value1 + + "
" + + name2 + + "
" + + value2 + "
"; + return str; + } + + string filename = Utility.filename; + List g1layername = new List(); + + /// + /// 获取目标图层 + /// + /// + 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; + } + /// + /// 添加图层 + /// + /// + /// + /// + 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 = 5000; + return templayer.Visible; + } + catch (Exception ex) + { + return false; + } + } + /// + /// 菜单上的 三维导航 工具按钮 + /// + /// + /// + private void buttonItem86_Click(object sender, EventArgs e) + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + } + + /// + /// 地上模式 菜单按钮 + /// + /// + /// + 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(); + + } + } + /// + /// 地下模式 菜单按钮 + /// + /// + /// + 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(); + } + } + /// + /// 行走模式 菜单按钮 + /// + /// + /// + 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; + } + } + /// + /// 地面透明度设置 菜单 + /// + /// + /// + private void sliderGroundTransSet1_ValueChanged(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.sliderGroundTransSet1.Text); + + globeControl1.Globe.GroundOpaque = 100 - sliderGroundTransSet1.Value; + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(roadLayerName);//("180fd"); + if (layer != null) + { + layer.Opaque = 100 - sliderGroundTransSet1.Value; + } + //if (buttonItemSPDB.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; + } + /// + /// 图例 菜单按钮 + /// + /// + /// + 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(); + } + /// + /// 快速定位 菜单按钮 + /// + /// + /// + private void buttonItem91_Click(object sender, EventArgs e) // + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItem91.Text); + FrmFlyToPosition fly = new FrmFlyToPosition(globeControl1); + fly.Show(this); + } + /// + /// 图层管理 菜单按钮 + /// + /// + /// + 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; + + //修改图层管理与标注管理、覆土审查、水平净距分析、垂直净距分析和碰撞分析控件之间的逻辑关系 + controlContainerItem5.Visible = false; + sideBar1.Visible = false; + sideBarPanelItem4.Visible = false; + panel3.Visible = false; + sideBar1.ExpandedPanel = sideBarPanelItem3; + buttonItemBZ11.Checked = false; + + //20160624 + /* + if (sideBarPanelItem4.Visible == true) + { + sideBar1.Visible = true; + controlContainerItem5.Visible = true; + } + else + { + sideBar1.Visible = false; + } + */ + Refresh(); + + } + } + /// + /// 全屏显示 菜单按钮 + /// + /// + /// + 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; + /// + /// 全屏显示功能实现 + /// + 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(); + } + } + + /// + /// 设置窗体宽、高 + /// + /// + /// + private void SetFullScreen(int width, int height) + { + this.Width = width; + this.Height = height; + } + + /// + /// 全屏功能的快捷键F5 + /// + /// + /// + 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); + } + } + /* + /// + /// 输出地图 + /// + /// + /// + /// + 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; + } + * */ + + private Point getUpperLeftPoint(Point p1, Point p2, out int mapWidth, out int mapHeight) // + { + Rectangle rc = new Rectangle(); + + p1 = this.globeControl1.PointToScreen(p1); + p2 = this.globeControl1.PointToScreen(p2); + + int x = Screen.PrimaryScreen.Bounds.X; + int y = Screen.PrimaryScreen.Bounds.Y; + int screenWidth = SystemInformation.WorkingArea.Width; + int screenHeight = SystemInformation.WorkingArea.Height; + + if (p1.X < x) + rc.X = x; + else + rc.X = p1.X; + + if (p1.Y < y) + rc.Y = y; + else + rc.Y = p1.Y; + + p1.X = rc.Left; + p1.Y = rc.Top; + + if (p2.X > screenWidth) + p2.X = screenWidth; + else + p2.X = p2.X; + + if (p2.Y > screenHeight) + p2.Y = screenHeight; + else + p2.Y = p2.Y; + + rc.Width = p2.X - rc.X; + rc.Height = p2.Y - rc.Y; + + mapWidth = rc.Width; + mapHeight = rc.Height; + Point pt = new Point(rc.Left, rc.Top); + return pt; + } + + Image printImage; + /// + /// 打印 菜单 + /// + /// + /// + 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))); + */ + int mapWidth = 0; + int mapHeight = 0; + Point pt = getUpperLeftPoint(pt1, pt2, out mapWidth, out mapHeight); + int rightBottomX = pt.X + mapWidth; + int rightBottomY = pt.Y + mapHeight; + Image myImg = new Bitmap(mapWidth, mapHeight); + Graphics g = Graphics.FromImage(myImg); + g.CopyFromScreen(pt, new Point(0, 0), new Size(rightBottomX, rightBottomY)); + + + 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); + } + /// + /// 输出地图 菜单 + /// + /// + /// + private void btnOutputJPG_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btnOutputJPG.Text); + + //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))); + */ + int mapWidth = 0; + int mapHeight = 0; + Point pt = getUpperLeftPoint(pt1, pt2, out mapWidth, out mapHeight); + int rightBottomX = pt.X + mapWidth; + int rightBottomY = pt.Y + mapHeight; + Image myImg = new Bitmap(mapWidth, mapHeight); + Graphics g = Graphics.FromImage(myImg); + g.CopyFromScreen(pt, new Point(0, 0), new Size(rightBottomX, rightBottomY)); + + 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; + } + } + } + + /// + /// 在窗体的底部状态栏上显示 综合管线条件查询结果 + /// + /// + /// + 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 + " 条记录 | "; + } + } + + /// + /// 统计管线的里程数 + /// + /// + /// + /// + 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; + } + + /// + /// 窗体下方属性表格 右键菜单中的 “定位”菜单 + /// + /// + /// + 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); + + } + + /// + /// 表格中右键 “单个闪烁” 菜单 + /// + /// + /// + private void LightMenu_Click(object sender, EventArgs e) + { + flashflag = "single"; + timer1.Start(); + } + /// + /// 表格中右键 “全部闪烁” 菜单 + /// + /// + /// + private void AllLightMenuItem_Click(object sender, EventArgs e) + { + flashflag = "all"; + timer1.Start(); + } + + /// + /// 使用timer实现管线的闪烁效果 + /// + /// + /// + 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; + } + } + + /// + /// 绘制线 菜单 + /// + /// + /// + private void btnAddLine_Click(object sender, EventArgs e) + { + globeControl1.Globe.DestLayerFeatureAdd = globeControl1.Globe.MemoryLayer; + globeControl1.Globe.Action = EnumAction3D.DrawPolyline; + } + /// + /// 绘制面 菜单 + /// + /// + /// + private void btnAddPolygon_Click(object sender, EventArgs e) + { + globeControl1.Globe.DestLayerFeatureAdd = globeControl1.Globe.MemoryLayer; + globeControl1.Globe.Action = EnumAction3D.DrawPolygon; + } + /// + /// 图层目录树 右键菜单中的 目标图层 菜单 + /// + /// + /// + 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; + } + } + /// + /// 图层目录树 右键菜单中的 可选择 菜单 + /// + /// + /// + 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; + } + /// + /// 图层目录树 右键菜单中的 可编辑 菜单 + /// + /// + /// + 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; + } + /// + /// 图层目录树 右键菜单中的 保存 菜单 + /// + /// + /// + 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(); + } + + /// + /// 根据多边形范围统计管线的里程 + /// + /// + /// + /// 返回查询到的管线要素集合 + 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 pipeLineDis = new Dictionary(); + Dictionary workWellLen = new Dictionary(); + + + + + /// + /// 查找指定图层中在 指定范围内的feature对象集合 + /// + /// + /// + /// + 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; + } + /// + /// 清除结果 菜单 + /// + /// + /// + private void buttonItem47_Click(object sender, EventArgs e) + { + globeControl1.Globe.ClearAnalysis(); + dataGridViewX1.DataSource = null; + panelOfTable.Visible = false; + clearFeatureHighLight(); + } + /// + /// 设置菜单的选中状态 + /// + private void ActionToolMenuChecked() + { + if (globeControl1.Globe.Action != EnumAction3D.TrackPolyline) + { + buttonItemFX2_1.Checked = false; + buttonItemFX2_4.Checked = false; + buttonItemFX2_3.Checked = false; + buttonItemFX4_3.Checked = false; + } + if (globeControl1.Globe.Action != EnumAction3D.NormalHit) + { + buttonItemFX3_6.Checked = false; + // ClearConnexityAnalysis(); + + buttonItemFX3_5.Checked = false; + // ClearCloseValvesAnalysis(); + } + if (globeControl1.Globe.Action != EnumAction3D.TrackPolygon) + { + buttonItemFX4_2.Checked = false; + buttonItemFX4_1.Checked = false; + } + } + + /// + /// 主窗体关闭事件处理 + /// + /// + /// + private void MainFrm_FormClosing(object sender, FormClosingEventArgs e) + { + + if (MessageBox.Show("是否退出系统?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) + { + e.Cancel = true; + } + else { + globeControl1.Globe.MemoryLayer.SaveAs(Application.StartupPath + "/MyPlace.kml"); + } + + //saveLayerList(layerManagerNode.Nodes); + //注销id号为103的热键设定 + // UnregisterHotKey(Handle, 103); + } + + /// + /// 显示流向 功能 + /// + /// + /// + /// + 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(); + } + + FrmCloseValves frm; + + FrmBoosterValvers frmbooster = null; + + /// + /// 垂直净距分析 功能界面中的 选择图层复选框 选中状态改变事件处理 + /// + /// + /// + 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(); + } + /// + /// 水平净距分析 功能界面中的 选择图层复选框 选中状态改变事件处理 + /// + /// + /// + 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(); + } + /// + /// 垂直净距分析 功能界面中的 选择管线复选框 选中状态改变事件处理 + /// + /// + /// + private void checkBoxX1_CheckedChanged(object sender, EventArgs e) + { + clearFeatureHighLight(); + if (checkBoxX1.Checked) + { + comboBoxEx1.SelectedItem = null; + 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; + } + } + /// + /// 水平净距分析 功能界面中的 选择管线复选框 选中状态改变事件处理 + /// + /// + /// + private void checkBoxX1_CheckedChanged_shuiping(object sender, EventArgs e) + { + clearFeatureHighLight();//清除高亮 + if (checkBoxX7.Checked) + { + comboBoxEx4.SelectedItem = null; + 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(); + /// + /// 垂直净距分析 功能界面中的 选择图层下拉框 选中项改变 事件处理 + /// + /// + /// + 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; + } + } + } + /// + /// 水平净距分析 功能界面中的 选择图层下拉框 选中项改变 事件处理 + /// + /// + /// + 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 featCount = new Dictionary(); + Dictionary featLenth = new Dictionary(); + Dictionary m_FeaturesWithBianhao = new Dictionary();//记录编号和对应的标注点的位置 + GSOFeatures polygonJingJuAnalysises = new GSOFeatures(); + + /// + /// 垂直净距分析 功能界面中的 开始分析按钮 事件处理 + /// + /// + /// + 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; + } + + /// + /// 在指定的两点组成的线的中间添加一个marker对象,并将marker对象添加到指定的图层中 + /// + /// + /// + /// + /// + /// + 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; + } + + /// + /// 计算指定feature对象与除了该feature所在图层之外的 所有管线图层中的所有feature对象 的垂直距离 并在表格中记录符合要求的管线 + /// + /// + /// + /// + /// + private void VerticalDistanceAnalysis(string type, GSOFeature selectedFeature, List _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(); + } + /// + /// 垂直净距分析中 表格行的 双击定位 功能。 与覆土分析的实现方法不同,主要原因是需要标注垂距 + /// + /// + /// + 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); + } + } + } + } + + /// + /// 水平净距分析 功能界面中 开始分析按钮 的事件处理 + /// + /// + /// + 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; + } + + + /// + /// 计算指定feature对象与除了该feature所在图层之外的 所有管线图层中的所有feature对象 的水平距离 并记录符合要求的管线 功能 + /// + /// + /// + /// + /// + private void HorizontalDistanceAnalysis(GSOFeature selectedFeature, List _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)); + } + } + } + } + } + /// + /// 水平净距分析 功能界面中 表格的 双击定位 功能 + /// + /// + /// + 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); + } + } + } + } + } + /// + /// 碰撞分析 功能界面中 开始分析按钮 事件处理 + /// + /// + /// + 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; + } + /// + /// 碰撞分析功能界面中 表格的 双击定位 功能 + /// + /// + /// + 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); + } + } + } + } + + + + /// + /// 覆土分析功能操作界面中的 选择管线 复选框选中状态改变事件处理 + /// + /// + /// + private void checkBoxX5_CheckedChanged(object sender, EventArgs e) + { + clearFeatureHighLight(); + if (checkBoxX5.Checked) + { + comboBoxEx3.SelectedItem = null; + 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; + } + } + /// + /// 覆土分析功能操作界面中的 选择图层 复选框选中状态改变事件处理 + /// + /// + /// + 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(); + } + /// + /// 覆土分析功能操作界面中的 图层下拉框选中项改变事件处理 + /// + /// + /// + 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; + } + } + } + /// + /// 覆土分析功能操作界面中的 开始分析 按钮事件处理 + /// + /// + /// + 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; + + + GSOPoint3d markerPosition = new GSOPoint3d(); + 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]; + GSOPoint3d pt = new GSOPoint3d(); + + 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"); + + pt.X = pts[m].X; + pt.Y = pts[m].Y; + pt.Z = 0; + markerPosition = LabelVerticalDistance(layerTemp, pts[m], pt, Convert.ToDouble(dataGridViewX7.Rows[idx].Cells[2].Value), true); + 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]; + GSOPoint3d pt = new GSOPoint3d(); + 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"); + + pt.X = pts[m].X; + pt.Y = pts[m].Y; + pt.Z = 0; + markerPosition = LabelVerticalDistance(layerTemp, pts[m], pt, Convert.ToDouble(dataGridViewX7.Rows[idx].Cells[2].Value), true); + + 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; + } + + /// + /// 覆土分析中 表格的 双击定位 功能 + /// + /// + /// + 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); + } + } + } + } + } + /// + /// 覆土分析功能操作界面中的 导出Excel按钮 事件处理 + /// + /// + /// + private void buttonX10_Click(object sender, EventArgs e) + { + if (dataGridViewX7.Rows.Count > 0) + { + ExportExcel("覆土分析", dataGridViewX7, null); + } + else + { + MessageBox.Show("表格内容为空!", "提示"); + } + } + /// + /// 覆土分析功能操作界面底部的 关闭 按钮事件处理 + /// + /// + /// + 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(); + layerTemp.RemoveAllFeature(); + + if (buttonItem1.Checked) + { + sideBar1.ExpandedPanel = sideBarPanelItem3; + } + else + { + sideBar1.Visible = false; + } + globeControl1.Refresh(); + + //Refresh(); + } + + + /// + /// 垂直净距分析 功能界面中 清除分析结果按钮 事件处理 + /// + /// + /// + 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(); + } + /// + /// 水平净距分析 功能界面中 清除分析结果按钮 事件处理 + /// + /// + /// + 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(); + } + + /// + /// 垂直净距分析功能界面中 关闭按钮 事件处理 + /// + /// + /// + 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(); + } + /// + /// 水平净距分析功能界面中 删除缓冲区按钮 事件处理 + /// + /// + /// + private void buttonX14_Click(object sender, EventArgs e) + { + 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(); + } + + /// + /// 导出指定DataGridView控件中的内容 + /// + /// + /// + 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(); + } + } + } + } + + /// + /// 垂直净距分析功能界面中 导出Excel按钮 事件处理 + /// + /// + /// + private void buttonX4_Click(object sender, EventArgs e) + { + if (dataGridViewX3.Rows.Count > 0) + { + ExportExcel("垂直净距分析", dataGridViewX3, listBox1); + } + else + { + MessageBox.Show("表格内容为空!", "提示"); + } + } + /// + /// 水平净距分析功能界面中 导出Excel按钮 事件处理 + /// + /// + /// + private void buttonX4_Click_shuiping(object sender, EventArgs e) + { + if (dataGridViewX9.Rows.Count > 0) + { + ExportExcel("水平净距分析", dataGridViewX9, listBox3); + } + else + { + MessageBox.Show("表格内容为空!", "提示"); + } + } + + + /// + /// 清除所有坑 菜单 + /// + /// + /// + private void buttonItem3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItem3.Text); + + globeControl1.Globe.RemoveAllPits(); + } + + //} + /// + /// 大气层 菜单 + /// + /// + /// + private void buttonItem17_Click_1(object sender, EventArgs e) + { + globeControl1.Globe.Atmosphere.Visible = !globeControl1.Globe.Atmosphere.Visible; + buttonItemSH1.Checked = globeControl1.Globe.Atmosphere.Visible; + globeControl1.Refresh(); + } + /// + /// 经纬网 菜单 + /// + /// + /// + private void buttonItem20_Click(object sender, EventArgs e) + { + globeControl1.Globe.LatLonGrid.Visible = !globeControl1.Globe.LatLonGrid.Visible; + buttonItemSH3.Checked = globeControl1.Globe.LatLonGrid.Visible; + globeControl1.Globe.Refresh(); + } + /// + /// 状态条 菜单 + /// + /// + /// + private void buttonItem21_Click_1(object sender, EventArgs e) + { + globeControl1.Globe.StatusBar.Visible = !globeControl1.Globe.StatusBar.Visible; + buttonItemSH4.Checked = globeControl1.Globe.StatusBar.Visible; + globeControl1.Globe.Refresh(); + } + + + + /// + /// 添加指定路径下的数据 功能 + /// + /// + /// + 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); + //CheckDatasetGeoReference(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; + } + return objRes; + } + /// + /// 刷新目录树 功能 + /// + 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); + } + } + /// + /// 判断图层是否包含字段列表 + /// + /// + /// + 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; + } + + /// + /// 统计指定图层在指定范围内的所有feature对象 + /// + /// + /// + /// + 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; + } + /// + /// 碰撞分析功能界面中 选择管线复选框 选中状态改变事件处理 + /// + /// + /// + private void checkBoxX3_CheckedChanged(object sender, EventArgs e) + { + clearFeatureHighLight(); + if (checkBoxX3.Checked) + { + comboBoxEx2.SelectedItem = null; + 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; + } + } + /// + /// 碰撞分析功能界面中 选择图层复选框 选中状态改变事件处理 + /// + /// + /// + 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(); + } + /// + /// 碰撞分析功能界面中 选择图层下拉框 选中项改变事件处理 + /// + /// + /// + 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; + } + } + } + /// + /// 清除所有图层中的所有feature对象的高亮状态 功能 + /// + 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); + } + } + } + } + for (int i = 0; i < globeControl2.Globe.Layers.Count; i++) + { + GSOLayer layer = globeControl2.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; + } + } + } + + if (globeControl1.Globe.Action == EnumAction3D.SelectObject) + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + //globeControl1.Globe.Action = EnumAction3D.SelectObject; + } + } + + /// + /// 碰撞分析功能界面中 清除分析结果按钮 事件处理 + /// + /// + /// + 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(); + } + /// + /// 碰撞分析功能界面中 导出Excel按钮 事件处理 + /// + /// + /// + private void buttonX6_Click(object sender, EventArgs e) + { + if (dataGridViewX5.Rows.Count > 0) + { + ExportExcel("碰撞分析", dataGridViewX5, listBox2); + } + else + { + MessageBox.Show("表格内容为空!", "提示"); + } + } + /// + /// 导出CAD 菜单 + /// + /// + /// + private void btnExportCAD_Click(object sender, EventArgs e) + { + FrmExportCADS frm = new FrmExportCADS(globeControl1, m_PipelineLayerNames); + frm.ShowDialog(); + } + + ///// + ///// 区域分析 菜单 + ///// + ///// + ///// + //private void buttonItem50_Click(object sender, EventArgs e) + //{ + // buttonItem50.Checked = !buttonItem50.Checked; + // ribbonBarQY.Visible = buttonItem50.Checked; + // ribbonBarQY.Location = new Point(0, 0); + //} + + + /// + /// 连接数据库 菜单事件处理 + /// + /// + /// + 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; + } + } + } + /// + /// 数据验证 菜单 + /// + /// + /// + private void buttonItem80_Click(object sender, EventArgs e) + { + FrmValiData frm = new FrmValiData(globeControl1); + frm.ShowDialog(); + } + /// + /// 根据指定图层创建图层节点并将节点添加到图层管理节点的子节点集合中 + /// + /// + 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; + + if (!layerManagerNode.Nodes.Contains(node)) + { + layerManagerNode.Nodes.Insert(0, node); + layerManagerNode.Expand(); + } + } + } + /// + /// 数据库备份 菜单 + /// + /// + /// + 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(); + } + } + } + + + + #region Fan 去掉 + //GSOFeature emitterFeature; // 粒子要素 + /// + /// 添加火苗 功能 + /// + /// + /// + /// + 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); + + } + /// + /// 添加喷泉 功能 + /// + /// + /// + /// + 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); + } + #endregion + + /// + /// 获取指定图层中最后一个feature对象的名称对应的整数 + /// + /// + /// + 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; + } + /// + /// 设置除指定标注图层之外的所有标注图层不可见 + /// + /// + 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; + } + } + } + } + } + + /// + /// 判断选中的对象是否为管线 + /// + /// 被选中管线 + /// 返回一根线 + 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; + } + + /// + /// 创建label要素 功能 + /// + /// 添加label要素的feature + /// feature的位置 + /// label要素名字 + /// feature名字 + /// label要素距离点的位置 + /// + 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; + } + + + + /// + /// 获取指定两点组成的线的长度 功能 + /// + /// + /// + /// + 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; + } + + /// + /// 图层节点树中 节点 右键单击事件处理 + /// + /// + /// + 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; + } + } + } + } + } + + /// + /// 标注管理、传感器管理 图层目录树的右键菜单中的 刷新列表 菜单 + /// + /// + /// + 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); + } + } + /// + /// 给指定的图层节点添加代表feature对象的子节点 + /// + /// + private void RefreshTreeNodeLayerFeatureList(TreeNode layerTreeNode) + { + layerTreeNode.Nodes.Clear(); + GSOLayer layer = (GSOLayer)layerTreeNode.Tag; + // 只将类型为内存数据集的图层列出,如果是其它类型的数据集可能数据量太大,没发显示在树控件中 + if (layer.Dataset is GSOFeatureDataset) + { + VisitFeature3Ds(layer.GetAllFeatures(), layerTreeNode); + } + } + + /// + /// 标注管理、传感器管理 图层目录树的右键菜单中的 移除所有 菜单 + /// + /// + /// + 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(); + } + } + + /// + /// 图层目录树的 节点对应的复选框选中状态改变事件处理 + /// + /// + /// + private void layerMarkerTree_AfterCheck(object sender, TreeViewEventArgs e) + { + if (e.Action != TreeViewAction.Unknown) + { + CheckTreeNode(e.Node, e.Node.Checked); + } + } + /// + /// 改变指定节点对应的复选框的选中状态 + /// + /// + /// + private void CheckTreeNode(TreeNode node, Boolean bChecked) + { + CheckChildTreeNode(node, bChecked); + globeControl1.Globe.Refresh(); + } + /// + /// 改变指定节点的子节点对应的复选框的选中状态 + /// + /// + /// + 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); + } + } + /// + /// 标注管理、传感器管理 目录树中的feature节点的右键菜单中的 删除 菜单 + /// + /// + /// + 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(); + } + } + + /// + /// 双屏对比 菜单 + /// + /// + /// + //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(); + // } + //} + /// + /// 模拟分析 菜单 + /// + /// + /// + //private void buttonItem51_Click(object sender, EventArgs e) + //{ + // buttonItem51.Checked = !buttonItem51.Checked; + // ribbonBarMN.Visible = buttonItem51.Checked; + // ribbonBarMN.Location = new Point(0, 0); + //} + + /// + /// 双屏设置 菜单 + /// + /// + /// + //private void buttonItem96_Click(object sender, EventArgs e) + //{ + // FrmLayerControl frm = new FrmLayerControl(layerTree,globeControl1,globeControl2); + // frm.Show(this); + //} + /// + /// 双屏联动 菜单 + /// + /// + /// + //private void buttonItem95_Click(object sender, EventArgs e) + //{ + // buttonItem95.Checked = !buttonItem95.Checked; + //} + ///// + /// 添加用户仓库 菜单 + /// + /// + /// + private void buttonItem108_Click(object sender, EventArgs e) + { + FrmUserRepo frm = new FrmUserRepo(-1); + frm.ShowDialog(); + } + /// + /// 用户仓库管理 菜单 + /// + /// + /// + private void buttonItem111_Click(object sender, EventArgs e) + { + FrmUserRepoMgr frm = new FrmUserRepoMgr(); + frm.ShowDialog(); + } + /// + /// 添加分系统 菜单 + /// + /// + /// + private void buttonItem112_Click(object sender, EventArgs e) + { + //FrmAPP frm = new FrmAPP(-1); + //frm.ShowDialog(); + } + /// + /// 分系统管理 菜单 + /// + /// + /// + private void buttonItem113_Click(object sender, EventArgs e) + { + //FrmAPPMgr frm = new FrmAPPMgr(); + //frm.ShowDialog(); + } + /// + /// 添加操作 菜单 + /// + /// + /// + private void buttonItem114_Click(object sender, EventArgs e) + { + FrmOper frm = new FrmOper(-1); + frm.ShowDialog(); + } + /// + /// 操作管理 菜单 + /// + /// + /// + private void buttonItem115_Click(object sender, EventArgs e) + { + FrmOperMgr frm = new FrmOperMgr(); + frm.ShowDialog(); + } + /// + /// 添加资源 菜单 + /// + /// + /// + private void buttonItem116_Click(object sender, EventArgs e) + { + FrmRESC frm = new FrmRESC(-1); + frm.ShowDialog(); + } + /// + /// 资源管理 菜单 + /// + /// + /// + private void buttonItem117_Click(object sender, EventArgs e) + { + FrmRESCMgr frm = new FrmRESCMgr(); + frm.ShowDialog(); + } + /// + /// 添加权限 菜单 + /// + /// + /// + private void buttonItem118_Click(object sender, EventArgs e) + { + FrmPerm frm = new FrmPerm(-1); + frm.ShowDialog(); + } + /// + /// 权限管理 菜单 + /// + /// + /// + private void buttonItem119_Click(object sender, EventArgs e) + { + FrmPermMgr frm = new FrmPermMgr(); + frm.ShowDialog(); + } + /// + /// 添加访问控制 菜单 + /// + /// + /// + private void buttonItem120_Click(object sender, EventArgs e) + { + FrmAccess frm = new FrmAccess(-1); + frm.ShowDialog(); + } + /// + /// 访问控制管理 菜单 + /// + /// + /// + private void buttonItem121_Click(object sender, EventArgs e) + { + FrmAccessMgr frm = new FrmAccessMgr(); + frm.ShowDialog(); + } + /// + /// 部门类型管理 菜单 + /// + /// + /// + private void buttonItem122_Click(object sender, EventArgs e) + { + FrmRegionTypeMgr frm = new FrmRegionTypeMgr(); + frm.ShowDialog(); + } + /// + /// 添加用户 菜单 + /// + /// + /// + private void buttonItem127_Click(object sender, EventArgs e) + { + FrmUserAdd frm = new FrmUserAdd(-1); + frm.ShowDialog(); + } + /// + /// 用户信息管理 菜单 + /// + /// + /// + private void buttonItem128_Click_1(object sender, EventArgs e) + { + FrmUserManager frm = new FrmUserManager(); + frm.ShowDialog(); + } + /// + /// 添加角色 菜单 + /// + /// + /// + private void 添加角色_Click(object sender, EventArgs e) + { + FrmRole frm = new FrmRole(-1); + frm.ShowDialog(); + } + /// + /// 所有角色管理 菜单 + /// + /// + /// + private void 角色管理_Click(object sender, EventArgs e) + { + FrmRoleMgr frm = new FrmRoleMgr(); + frm.ShowDialog(); + } + + /// + /// 部门角色管理 菜单 + /// + /// + /// + private void buttonItem133_Click(object sender, EventArgs e) + { + FrmRegionRoleMgr frm = new FrmRegionRoleMgr(); + frm.ShowDialog(); + } + /// + /// 部门管理 菜单 + /// + /// + /// + private void buttonItem130_Click(object sender, EventArgs e) + { + FrmRegionMgr frm = new FrmRegionMgr(); + frm.ShowDialog(); + } + + /// + /// 日志管理 菜单 + /// + /// + /// + private void buttonItem135_Click(object sender, EventArgs e) + { + FrmLogManager frm = new FrmLogManager(); + frm.ShowDialog(); + } + /// + /// 传感器信息查询 菜单 + /// + /// + /// + 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); + } + } + } + /// + /// 根据指定的图层的caption属性的值在配置文件中查找对应的数据库中的表的名称 + /// + /// 图层的caption属性的值 + /// 对应的数据库中的表的名称 + 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; + } + /// + /// 根据数据库中的表的名称 查找对应的表中的字段名称的集合 + /// + /// 数据库中的表的名称 + /// 对应的表中的字段名称的集合 + 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; + } + + /// + /// 历史曲线查询 菜单 + /// + /// + /// + 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; + /// + /// 传感器在线报警 菜单 + /// + /// + /// + 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); + } + /// + /// 传感器报警 功能中的 定时器 的触发事件处理 + /// + /// + /// + 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; + } + } + } + } + } + } + } + + + /// + /// 沿线运动 菜单 + /// + /// + /// + private void buttonItem138_Click(object sender, EventArgs e) + { + if (globeControl1.Globe.SelectedObject == null) + { + MessageBox.Show("请先选择一条线!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + return; + } + + GSOFeature lineFeature = globeControl1.Globe.SelectedObject; + if (lineFeature.Geometry == null || lineFeature.Geometry.Type != EnumGeometryType.GeoPolyline3D) + { + MessageBox.Show("请先选择一条线!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + return; + } + + OpenFileDialog dlg = new OpenFileDialog(); + dlg.Filter = "*.gcm;*.3ds|*.gcm;*.3ds|*.3ds|*.3ds|*.gcm|*.gcm"; + if (dlg.ShowDialog() == DialogResult.OK) + { + GSOGeoModel model = new GSOGeoModel(); + model.FilePath = dlg.FileName; + + GSOGeoDynamicRoute dynamicRoute = new GSOGeoDynamicRoute(); + dynamicRoute.ActorGeometry = model; + + GSORoute route = new GSORoute(); + GSOGeoPolyline3D geoline = (GSOGeoPolyline3D)lineFeature.Geometry; + for (int i = 0; i < geoline[0].Count; i++) + { + route.Add(geoline[0][i]); + } + route.CircleRoute = false; + route.Speed = 30; + route.RotateSpeed = 50; + route.AltitudeMode = geoline.AltitudeMode; + dynamicRoute.Route = route; + + GSOFeature feature = new GSOFeature(); + + dynamicRoute.Play(); + feature.Geometry = dynamicRoute; + + //GSOLabel gsoLabel = new GSOLabel(); + //gsoLabel.Text = "模型测试"; + //feature.Label = gsoLabel; + globeControl1.Globe.MinModelVisibleSize = 0; + + globeControl1.Globe.MemoryLayer.AddFeature(feature); + globeControl1.Globe.Refresh(); + } + } + /// + /// 回退 菜单 + /// + /// + /// + private void buttonItem99_Click(object sender, EventArgs e) + { + globeControl1.Globe.UnDoEdit(); + } + /// + /// 前进 菜单 + /// + /// + /// + private void buttonItem100_Click(object sender, EventArgs e) + { + globeControl1.Globe.ReDoEdit(); + } + /// + /// 水平净距 功能界面中的 标签内容改变事件处理 + /// + /// + /// + 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() + "米的管线有:"; + } + } + } + /// + /// 垂直净距 功能界面中的 标签内容改变事件处理 + /// + /// + /// + 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() + "米的管线有:"; + } + } + } + /// + /// 覆土分析 功能界面中的 标签内容改变事件处理 + /// + /// + /// + 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() + "米的管线有:"; + } + } + } + + /// + /// 传感器分类查询 全区域 菜单 + /// + /// + /// + private void buttonItemSensor全区域查询_Click(object sender, EventArgs e) + { + FrmAccessoriesSensor.ShowForm(globeControl1, instrumenLayerNames, 0); + } + /// + /// 传感器分类查询 绘制区域 菜单 + /// + /// + /// + private void buttonItemSensor绘制区域查询_Click(object sender, EventArgs e) + { + FrmAccessoriesSensor.ShowForm(globeControl1, instrumenLayerNames, 1); + } + + + /// + /// 碰撞分析 功能界面中 关闭按钮 事件处理 + /// + /// + /// + 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(); + } + /// + /// 覆土分析 功能界面中的 清除分析结果 按钮事件处理 + /// + /// + /// + 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(); + } + /// + /// 数字预处理 功能 + /// + /// + /// + private void 数字预处理buttonItem140_Click(object sender, EventArgs e) + { + FrmEditShapeFile frm = new FrmEditShapeFile(globeControl1); + frm.ShowDialog(this); + } + + + /// + /// 导出矢量 功能 将图层导出为kml和shp格式数据 + /// + /// + /// + private void 导出矢量buttonItem140_Click(object sender, EventArgs e) + { + List listVectorNames = new List(); + for (int i = 0; i < m_PipelineLayerNames.Count; i++) + { + 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 = ""; + /// + /// 绘制城市七线 功能按钮 + /// + /// + /// + 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; + } + } + } + /// + /// 七线审核 功能按钮 + /// + /// + /// + private void 七线审核buttonItem141_Click(object sender, EventArgs e) + { + FrmCityServerLineAnalysis frm = new FrmCityServerLineAnalysis(globeControl1, m_PipelineLayerNames); + frm.ShowDialog(this); + } + + /// + /// 间距分析 开始分析按钮 分析绘制的七线和管线的距离是否符合标准 + /// + /// + /// + 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; + } + /// + /// 间距分析 清除分析结果 + /// + /// + /// + 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(); + } + /// + /// 间距分析 导出Excel按钮 将间距分析的结果以Excel表格的形式导出 + /// + /// + /// + private void buttonExportExcel_Click(object sender, EventArgs e) + { + if (dataGridViewAnalysisResult.Rows.Count > 0) + { + ExportExcel("间距分析", dataGridViewAnalysisResult, listBoxStasticsResult); + } + else + { + MessageBox.Show("表格内容为空!", "提示"); + } + } + /// + /// 间距分析 关闭按钮 + /// + /// + /// + 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(); + } + /// + /// 间距分析 分析结果表格双击定位 + /// + /// + /// + 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); + } + } + } + } + /// + /// 间距分析 选择管线复选框 + /// + /// + /// + private void checkBoxSelectPipeline_CheckedChanged(object sender, EventArgs e) + { + clearFeatureHighLight();//清除高亮 + if (checkBoxSelectPipeline.Checked) + { + comboBoxLayer.SelectedItem = null; + 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; + } + } + /// + /// 间距分析 选择图层复选框 + /// + /// + /// + 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(); + } + /// + /// 间距分析 选择图层下拉框 + /// + /// + /// + 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; + } + } + } + + + + /// + /// 管线自动缩进 菜单 + /// + /// + /// + private void 管线自动缩进buttonItem140_Click(object sender, EventArgs e) + { + FrmPipelineIndented frm = new FrmPipelineIndented(globeControl1, m_PipelineLayerNames, workwellLayerNames); + 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 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); + // } + //} + + /// + /// 统计指定图层在指定范围内的所有feature对象 + /// + /// + /// + /// + 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) + { + 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 setLayerVisible(string layerName) + { + GSOLayer templayer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + if (templayer != null) + { + templayer.Visible = false; + } + globeControl1.Globe.Refresh(); + } + + /// + /// 连接数据库 + /// + /// + /// + private void buttonItem129_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL4_1.Text); + + FrmDatabaseParaSetting2 frm = new FrmDatabaseParaSetting2(globeControl1); + if (frm.ShowDialog() == DialogResult.OK) + { + ds = FrmDatabaseParaSetting2.ds; + if (ds != null) + { + ds.IsCloseSaved = false; + } + } + } + + /// + /// 一键审核---导入数据 + /// + /// + /// + private void buttonItem127_Click_2(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, "打开数据"); + + try + { + //if (shds == null) + //{ + //没连的话,直接连接审核库; //审核库配置读配置文件 + string dbIp = Utility.sgdbip; + string database = Utility.sgdbname; + string user = Utility.sgdbuser; + string pass = Utility.sgdbpwd; + /* + 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; + //} + } + catch (Exception ex) + { + LogError.PublishError(ex); + MessageBox.Show("内存过载请清理内存,并重新启动规划分析!", "提示"); + return; + } + + } + + /// + ///自动导出图片 + /// + /// + /// + private void buttonItem130_Click_1(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, "导出审核图"); + + 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))); + */ + + int mapWidth = 0; + int mapHeight = 0; + Point pt = getUpperLeftPoint(pt1, pt2, out mapWidth, out mapHeight); + int rightBottomX = pt.X + mapWidth; + int rightBottomY = pt.Y + mapHeight; + Image myImg = new Bitmap(mapWidth, mapHeight); + Graphics g = Graphics.FromImage(myImg); + g.CopyFromScreen(pt, new Point(0, 0), new Size(rightBottomX, rightBottomY)); + + 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; + } + } + } + /// + /// 一键审核功能 + ///
+ /// + /// + private void buttonItem128_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItem128.Text); + //垂直净距标准 + + frmSh = new FrmYJSHTC(globeControl1, globeControl2,layerTree); + + if (frmSh.ShowDialog() == DialogResult.OK) + { + frmWait = new FrmWait("一键审核……"); + frmWait.Location = new Point(this.Width - frmWait.Width - 10, this.Height - frmWait.Height - 50); + frmWait.Owner = this; + frmWait.Show(); + Thread thread = new Thread(new ThreadStart(doWork)); + thread.IsBackground = true; + thread.Start(); + } + } + + void doWork() + { + FrmShResult frmShResult = null; + + double dVerticalJingJuBiaoZhun = 1, dHorizontalJingJuBiaoZhun = 1; + if (frmSh.rukuLayer != null) + { + #region + this.Invoke((EventHandler)delegate + { + try + { + List managerLayerList = new List(); + for (int i = 0; i < layerManagerNode.Nodes.Count; i++) + { + managerLayerList.Add(layerManagerNode.Nodes[i].Text); + } + if (!managerLayerList.Contains(frmSh.rukuLayer.Caption)) + { + TreeNode node = new TreeNode(); + node.Tag = frmSh.rukuLayer; + node.Text = frmSh.rukuLayer.Dataset.Caption; + node.ImageIndex = 0; + node.SelectedImageIndex = 0; + node.Checked = frmSh.rukuLayer.Visible; + layerManagerNode.Nodes.Insert(0, node); + layerManagerNode.Expand(); + } + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "提示"); + } + }); + #endregion + + shlayername = frmSh.rukuLayer.Name; + globeControl1.Refresh(); + } + + if (frmShResult != null && !frmShResult.IsDisposed) + { + try + { + clearFeatureHighLight(); + ClearRedlineAnalyseResult(); + frmShResult.Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message); + } + } + + 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.analysis(); + + //MainFrm窗体显示控制,回到一键审核Tab + this.Invoke((EventHandler)delegate + { + frmShResult.Show(); + frmWait.Close(); + //将tab页恢复到一键审核 + ribbonTabItem11.Checked = true; + try + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + //zhanshi = false; + splitContainer1.Panel2Collapsed = true; + + panelOfTable.Visible = false; + legendSC.Visible = false; + legendSG.Visible = false; + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + } + catch (Exception ex) + { + MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + + }); + + boolfrmShResult = true; + } + else + { + + } + } + + + /// + /// 清除渲染结果 + /// + 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(); + } + /// + /// 已审核的图层 + /// + /// + /// + private void buttonItem132_Click_1(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItem132.Text); + + if (shds == null) + { + //没连的话,直接连接审核库; //审核库配置读配置文件 + string dbIp = Utility.sgdbip; + string database = Utility.sgdbname; + string user = Utility.sgdbuser; + string pass = Utility.sgdbpwd; + + /* + 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; + //} + + } + /// + /// 审核入库 + /// + /// + /// + private void buttonItem133_Click_1(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, "审核入库"); + FrmShRK frmShrk = new FrmShRK(globeControl1); + frmShrk.Show(); + } + /// + /// 模拟设计修改 + /// + /// + /// + private void buttonItem134_Click_1(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, "模拟设计修改"); + + 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 + { + + } + + } + + + /// + /// 绘制垂线 + /// + /// + /// + 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); + } + /// + /// 比较两个点是否是同一个点 + /// + /// + /// + /// + 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; + } + /// + /// 获得点到线的垂线距离及垂点 + /// + /// + /// + /// + /// + 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); + 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]; + } + /// + /// 获得斜率 + /// + /// + /// + /// + /// + /// + /// + 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); + } + } + /// + /// 根据默认投影参数,经纬度转xyz + /// + /// + /// + /// + 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; + } + /// + /// 根据投影参数,经纬度转xyz + /// + /// + /// + /// + /// + 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; + } + /// + /// 根据默认投影参数,xyz转经纬度 + /// + /// + /// + /// + 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; + } + /// + /// 根据投影参数,Xyz转经纬度 + /// + /// + /// + /// + /// + 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; + } + /// + /// 获得inpolygon的管线长度 + /// + /// + 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; + } + + + /// + /// 一键审核中调节透明度 + /// + /// + /// + private void sliderItem1_ValueChanged(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.sliderItem1.Text); + + globeControl1.Globe.GroundOpaque = 100 - sliderItem1.Value; + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(roadLayerName);//("180fd"); + if (layer != null) + { + layer.Opaque = 100 - sliderItem1.Value; + } + + optiValue = sliderItem1.Value; + } + /// + /// 红线审核中的透明度分析 + /// + /// + /// + private void sliderItem3_ValueChanged(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.sliderItem3.Text); + + globeControl1.Globe.GroundOpaque = 100 - sliderItem3.Value; + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(roadLayerName);//("180fd"); + if (layer != null) + { + layer.Opaque = 100 - sliderItem3.Value; + } + optiValue = sliderItem3.Value; + } + + #region yanxiaowei + //初始化DataGridViewX1控件 + public delegate void DataGridViewDelegate(DataTable dt, string strLable, string strLayer, bool initDataGrid); + /// + /// 代理函数,操作DatgridViewX1 + /// + /// + /// + public void InitDataGridViewX1(DataTable dt, string strLable, string strLayer, bool initDataGrid) + { + if (initDataGrid == true) + { + dataGridViewX1.DataSource = dt; + panelOfTable.Visible = true; + toolStripNumbers.Text = strLable; + dataGridViewX1.Tag = strLayer; + } + else + { + dataGridViewX1.DataSource = null; + dataGridViewX1.Refresh(); + panelOfTable.Visible = false; + toolStripNumbers.Text = ""; + dataGridViewX1.Tag = ""; + globeControl1.Globe.MemoryLayer.RemoveAllFeature();//清除双击产生的标注 + } + } + FrmAnalysisGuiHuaResult from; + /// + /// 主窗体下方属性表格 双击定位 功能 + /// + /// + /// + private void dataGridViewX1_MouseDoubleClick(object sender, MouseEventArgs e) + { + if (redSH == false) + { + 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 if (dataGridViewX1.Columns.Contains("标识器编号")) + { + featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["标识器编号"].Value.ToString(); + } + featureName = featureName.Trim(); + + GSOLayer layer = null; + layer = globeControl1.Globe.Layers.GetLayerByCaption(dataGridViewX1.Tag.ToString()); + + if (layer == null) return; + + GSOFeatures features = layer.GetFeatureByName(featureName, false); + if (features.Length == 0) return; + GSOFeature rowFeature = features[0]; + + ClassSearchAnalysis.AddMakerToLineFeature(globeControl1, rowFeature); + + } + } + } + else + { + if (e.Button == MouseButtons.Left) + { + if (from != null && !from.IsDisposed) + { + try + { + from.Close(); + } + catch (Exception ex) + { + LogError.PublishError(ex); + } + } + try + { + DataGridView.HitTestInfo hittestinfo = dataGridViewX1.HitTest(e.X, e.Y); + if (hittestinfo.RowIndex >= 0) + { + string layer = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["管线类型"].Value.ToString(); + string hxName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["红线编号"].Value.ToString(); + FrmAnalysisGuiHuaResult frm = new FrmAnalysisGuiHuaResult(globeControl1, lineStruct, featsList, + panelOfTable, dataGridViewX1, layer, hxName); + frm.Location = new Point(this.Width - frm.Width - 10, this.Height - frm.Height - 20); + frm.Show(this); + + from = frm; + } + } + catch (Exception ex) + { + LogError.PublishError(ex); + } + } + } + } + + /// + /// 空间查询 + /// + /// + /// + private void buttonItemSearch1_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemSearch1.Text); + + trackflag = "PipelineSpatialQuery"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; + + } + /// + /// 关键字查询 + /// + /// + /// + private void buttonItemSearch9_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch9.Text); + + FrmKeywordQuery.ShowForm(globeControl1, m_PipelineLayerNames, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 编号查询 + /// + /// + /// + private void buttonItemSearch2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch2.Text); + + FrmCodingQuery.ShowForm(globeControl1, m_PipelineLayerNames, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 坐标查询 + /// + /// + /// + private void buttonItemSearch3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch3.Text); + + FrmSetLatLonPos.ShowForm(globeControl1); + } + /// + /// 附属物查询 + /// + /// + /// + private void buttonItemSearch10_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch10.Text); + + FrmFittingQuery.ShowForm(globeControl1, instrumenLayerNames, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 管径查询 + /// + /// + /// + private void buttonItemSearch4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch4.Text); + + FrmDiameterQuery.ShowForm(globeControl1, m_PipelineLayerNames, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 材质查询 + /// + /// + /// + private void buttonItemSearch5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch5.Text); + + FrmMaterialSel.ShowForm(globeControl1, m_PipelineLayerNames, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 基本查询 + /// + /// + /// + private void buttonItemSearch6_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch6.Text); + + FrmBasicQuery.ShowForm(globeControl1, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 复合查询 + /// + /// + /// + private void buttonItemSearch7_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch7.Text); + + FrmQuerySQL.ShowForm(globeControl1, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 关联查询 + /// + /// + /// + private void buttonItemSearch8_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch8.Text); + + if (globeControl1.Globe.SelObjectCount != 1) + { + MessageBox.Show("请选中一个对象!", "提示"); + return; + } + + 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 || (feature.Geometry.Type == EnumGeometryType.GeoPolygon3D + || feature.Geometry.Type == EnumGeometryType.GeoWater)) + return; + else + { + ClassSearchAnalysis.ResultRelationAnalysis(globeControl1, feature, valueLayerNames, workwellLayerNames, + instrumenLayerNames, pipefittingLayerNames, m_PipelineLayerNames, valueAllowance); + } + } + } + #endregion + /// + /// 清除分析 + /// + /// + /// + private void buttonItemClear_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemClear.Text); + + globeControl1.Globe.ClearMeasure(); + layerTemp.RemoveAllFeature(); + layerTemp2.RemoveAllFeature(); + buttonItemLS5.Checked = false; + + dataGridViewX1.DataSource = null; + panelOfTable.Visible = false; + + 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); + + NetworkAnalysisTool.ClearAllTopAnalysis(this.globeControl1); + // 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();//清除所有坑 + + 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(); + } + } + + clearFeatureHighLight();//取消管线高亮 + + GSOLayer layerGround = globeControl1.Globe.Layers.GetLayerByCaption(roadLayerName);//("180fd"); + if (layerGround != null) + { + layerGround.Visible = true; + } + globeControl1.Refresh(); + globeControl2.Refresh(); + ClearRedlineAnalyseResult(); + globeControl1.Globe.Action = EnumAction3D.ActionNull; + } + /// + /// 管线长度全区域统计 + /// + /// + /// + private void buttonItemTJ1_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管线长度统计"); + + //pipeLineDis.Clear(); + //List list = new List(); + //for (int i = 0; i < m_PipelineLayerNames.Count; i++) + //{ + // GSOFeatures fs = Intersects_Pipeline(null, m_PipelineLayerNames[i]); + // if (fs!=null) + // list.Add(fs); + //} + + //FrmAllPipelineStatis frm = new FrmAllPipelineStatis(0, pipeLineDis, list, globeControl1, new DataGridViewDelegate(InitDataGridViewX1)); + FrmAllPipelineStatis frm = new FrmAllPipelineStatis(globeControl1,null, new DataGridViewDelegate(InitDataGridViewX1), m_PipelineLayerNames); + frm.Show(this); + + } + /// + /// 管线长度绘制区域统计 + /// + /// + /// + private void buttonItemTJ1_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管线长度统计"); + + trackflag = "PipelineDistanceStatistics"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; + } + /// + /// 阀门数量全区域统计 + /// + /// + /// + private void buttonItemTJ2_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "阀门数量统计"); + + //workWellLen.Clear(); + //List list = new List(); + ////找到所有阀门 + //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, globeControl1, new DataGridViewDelegate(InitDataGridViewX1)); + FrmValveStatistics frm = new FrmValveStatistics(globeControl1, null, new DataGridViewDelegate(InitDataGridViewX1)); + frm.Show(this); + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + } + /// + /// 阀门数量绘制区域统计 + /// + /// + /// + private void buttonItemTJ2_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "阀门数量统计"); + + trackflag = "valvequery"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; + } + /// + /// 井盖数量全区域统计 + /// + /// + /// + private void buttonItemTJ3_ALL_Click(object sender, EventArgs e) + { + FrmAllWorkWellStatis frm = new FrmAllWorkWellStatis(globeControl1, null, new DataGridViewDelegate(InitDataGridViewX1)); + frm.Show(this); + } + /// + /// 井盖数量绘制区域统计 + /// + /// + /// + private void buttonItemTJ3_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "井盖数量统计"); + + trackflag = "workwellquery"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; + } + /// + /// 管径分段统计全区域统计 + /// + /// + /// + private void buttonItemTJ4_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管径分段统计"); + + Frmpipediameterstatis.ShowForm(globeControl1, m_PipelineLayerNames, 0); + } + /// + /// 管径分段统计绘制区域统计 + /// + /// + /// + private void buttonItemTJ4_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管径分段统计"); + + trackflag = null; + Frmpipediameterstatis.ShowForm(globeControl1, m_PipelineLayerNames, 1); + } + /// + /// 埋深分段统计全区域统计 + /// + /// + /// + private void buttonItemTJ5_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "埋深分段统计"); + FrmpipeDeepstatis.ShowForm(globeControl1, m_PipelineLayerNames, 0); + } + /// + /// 埋深分段统计绘制区域统计 + /// + /// + /// + private void buttonItemTJ5_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "埋深分段统计"); + trackflag = null; + FrmpipeDeepstatis.ShowForm(globeControl1, m_PipelineLayerNames, 1); + } + /// + /// 管径分类统计全区域统计 + /// + /// + /// + private void buttonItemTJ6_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管径分类汇总"); + + FrmpipeDiametergather.ShowForm(globeControl1, m_PipelineLayerNames, 0); + } + /// + /// 管径分类统计绘制区域统计 + /// + /// + /// + private void buttonItemTJ6_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管径分类汇总"); + + trackflag = null; + FrmpipeDiametergather.ShowForm(globeControl1, m_PipelineLayerNames, 1); + } + /// + /// 材质分类统计全区域统计 + /// + /// + /// + private void buttonItemTJ7_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "材质分类汇总"); + + FrmpipeMaterialGather.ShowForm(globeControl1, m_PipelineLayerNames, 0); + } + /// + /// 材质分类统计绘制区域统计 + /// + /// + /// + private void buttonItemTJ7_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "材质分类汇总"); + + trackflag = null; + FrmpipeMaterialGather.ShowForm(globeControl1, m_PipelineLayerNames, 1); + } + /// + /// 附属物分类统计全区域统计 + /// + /// + /// + private void buttonItemTJ8_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "附属物分类汇总"); + + FrmAccessoriesgather.ShowForm(globeControl1, instrumenLayerNames, 0); + } + /// + /// 附属物分类统计绘制区域统计 + /// + /// + /// + private void buttonItemTJ8_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "附属物分类汇总"); + + trackflag = null; + FrmAccessoriesgather.ShowForm(globeControl1, instrumenLayerNames, 1); + } + /// + /// 碰撞分析 + /// + /// + /// + private void buttonItemFX1_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_4.Text); + + this.dataGridViewX4.Size = new System.Drawing.Size(195, 120); + 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(); + } + /// + /// 覆土分析 + /// + /// + /// + private void buttonItemFX1_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX5_1.Text); + this.dataGridViewX6.Size = new System.Drawing.Size(195, 120); + 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(); + } + /// + /// 间距分析 + /// + /// + /// + private void buttonItemFX1_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX1_3.Text); + + this.dataGridViewLineList.Size = new System.Drawing.Size(185, 120); + 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(); + } + /// + /// 垂直净距分析 + /// + /// + /// + private void buttonItemFX1_4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX1_4.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(); + } + /// + /// 水平净距分析 + /// + /// + /// + private void buttonItemFX1_5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_6.Text); + this.dataGridViewX8.Size = new System.Drawing.Size(185, 120); + 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(); + } + + #region Predaotr,断面分析 + /// + /// 横断面分析 + /// + /// + /// + private void buttonItemFX2_1_Click(object sender, EventArgs e) + { + globeControl1.Globe.Action = EnumAction3D.TrackPolyline; + globeControl1.Globe.TrackPolylineTool.VerticalLineVisible = true; + globeControl1.Globe.TrackPolylineTool.TrackMode = EnumTrackMode.SpaceTrack; + trackPolylineEndMode = EnumTrackPolylineEndMode.HDM_Analysis; + + } + /// + /// 纵断面分析 + /// + /// + /// + private void buttonItemFX2_2_Click(object sender, EventArgs e) + { + if (globeControl1.Globe.SelObjectCount<1) + { + MessageBox.Show("请选择一条或者多条管线!", "提示", MessageBoxButtons.OK, + MessageBoxIcon.Information); + return; + } + 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); + } + } + List feats = SectionAnalysisTool.ZDMAnalysis(selectFeatures); + if (feats != null && feats.Count >= 1) + { + FrmProfileAnalysis frm = new FrmProfileAnalysis(globeControl1, feats); + frm.Show(this); + } + } + /// + /// 道路断面分析 + /// + /// + /// + private void buttonItemFX2_3_Click(object sender, EventArgs e) + { + globeControl1.Globe.Action = EnumAction3D.TrackPolyline; + globeControl1.Globe.TrackPolylineTool.VerticalLineVisible = true; + globeControl1.Globe.TrackPolylineTool.TrackMode = EnumTrackMode.SpaceTrack; + trackPolylineEndMode = EnumTrackPolylineEndMode.DLDM_Analysis; + + } + /// + /// 基线剖面分析 + /// + /// + /// + private void buttonItemFX2_4_Click(object sender, EventArgs e) + { + globeControl1.Globe.Action = EnumAction3D.TrackPolyline; + globeControl1.Globe.TrackPolylineTool.VerticalLineVisible = true; + globeControl1.Globe.TrackPolylineTool.TrackMode = EnumTrackMode.SpaceTrack; + trackPolylineEndMode = EnumTrackPolylineEndMode.JXPM_Analysis; + + } + + #endregion + /// + /// 创建拓扑 + /// + /// + /// + private void buttonItemFX3_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX3_1.Text); + + FrmGenAndFaMenTopu frm = new FrmGenAndFaMenTopu(globeControl1, m_PipelineLayerNames, valueLayerNames); + frm.Show(this); + } + #region Predator :拓扑分析 + /// + /// 上游分析 + /// + /// + /// + private void buttonItemFX3_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX3_2.Text); + NetworkTraceUpDown(true); + } + /// + /// 下游分析 + /// + /// + /// + private void buttonItemFX3_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX3_3.Text); + NetworkTraceUpDown(false); + } + + /// + /// 上下游追踪 功能 + /// + /// + private void NetworkTraceUpDown(Boolean bTraceUp) + { + GSOFeature selLineFeature = globeControl1.Globe.SelectedObject; + if (selLineFeature == null || selLineFeature.Geometry == null || selLineFeature.Geometry.Type != EnumGeometryType.GeoPolyline3D) + { + MessageBox.Show("请点击“编辑”—“选中对象”选择一条线!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); + return; + } + GSOLayer selLayer = globeControl1.Globe.SelectedObjectLayer; + + NetworkAnalysisTool.TraceUpDownAnalysis(bTraceUp, + selLineFeature, selLayer); + } + + /// + /// 流向分析 + /// + /// + /// + private void buttonItemFX3_4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX3_4.Text); + + FrmFlow frm = new FrmFlow(globeControl1, m_PipelineLayerNames); + frm.Show(this); + } + /// + /// 关阀分析 + /// + /// + /// + private void buttonItemFX3_5_Click(object sender, EventArgs e) + { + if (globeControl1.Globe.SelObjectCount < 1) + { + MessageBox.Show("请选中至少一根管线!!"); + buttonItemFX3_5.Checked = false; + return; + } + GSOLayer resLayer = null; + GSOFeature resFeature = null; + globeControl1.Globe.GetSelectObject(0, out resFeature, out resLayer); + + String pipeLayerName = resLayer.Caption; + String pipeLayerNamePrefix = pipeLayerName.Substring(0, pipeLayerName.IndexOf("管线")); + GSOLayer valveLayer = globeControl1.Globe.Layers[pipeLayerNamePrefix + "阀门"]; + if (valveLayer == null) + { + MessageBox.Show("无" + pipeLayerNamePrefix+"阀门图层", "提示"); + return; + } + + GSOFeatures valveFeats = NetworkAnalysisTool.CloseValvesAnalysis(resFeature, + resLayer, valveLayer); + + if (valveFeats != null) + { + FrmCloseValves frm = new FrmCloseValves(this.globeControl1, valveFeats); + frm.Show(this); + } + else + { + MessageBox.Show("未找到关闭阀门"); + } + } + + /// + /// 连通分析 + /// + /// + /// + private void buttonItemFX3_6_Click(object sender, EventArgs e) + { + if (globeControl1.Globe.SelObjectCount < 2) + { + MessageBox.Show("请选中至少两个管线!!"); + buttonItemFX3_6.Checked = false; + return; + } + GSOFeature selFeat0, selFeat1; + GSOLayer layer0,layer1; + globeControl1.Globe.GetSelectObject(0, out selFeat0, out layer0); + globeControl1.Globe.GetSelectObject(1, out selFeat1, out layer1); + + if (!layer0.IsSameInnerObject(layer1)) + { + MessageBox.Show("不在同一个图层!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); + buttonItemFX3_6.Checked = false; + return; + } + NetworkAnalysisTool.ConnexityAnalysis(selFeat0, selFeat1, layer0); + } + /// + /// 爆管分析 + /// + /// + /// + private void buttonItemFX3_7_Click(object sender, EventArgs e) + { + NetworkTraceUpDown(true); //上游追踪: + + GSOFeature selLineFeature = globeControl1.Globe.SelectedObject; + if (selLineFeature == null || selLineFeature.Geometry == null || selLineFeature.Geometry.Type != EnumGeometryType.GeoPolyline3D) + { + MessageBox.Show("请点击“编辑”—“选中对象”选择一条线!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); + return; + } + GSOLayer selLayer = globeControl1.Globe.SelectedObjectLayer; + + NetworkAnalysisTool.ExplodeAnalysis(this.globeControl1,selLineFeature,selLayer); + + this.buttonItemFX3_5_Click(sender, e); //关阀分析: + + } + + #endregion + /// + /// 多边形开挖 + /// + /// + /// + private void buttonItemFX4_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_1.Text); + + trackflag = "pit"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; //是这个么?是的,在模型上 + } + /// + /// 挖方量分析 + /// + /// + /// + private void buttonItemFX4_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_2.Text); + + trackflag = "digFillAnalysis"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; + ActionToolMenuChecked(); + } + /// + /// 沿线开挖 + /// + /// + /// + private void buttonItemFX4_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_3.Text); + + if (!buttonItemFX4_3.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; + buttonItemFX4_3.Checked = true; + } + } + else + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + buttonItemFX4_3.Checked = false; + globeControl1.Globe.TrackPolylineTool.VerticalLineVisible = false; + } + ActionToolMenuChecked(); + } + /// + /// 创建隧道 + /// + /// + /// + private void buttonItemFX4_4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_4.Text); + + 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("场景中未加载隧道图层!", "提示"); + } + } + /// + /// 隐藏隧道 + /// + /// + /// + private void buttonItemFX4_5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_5.Text); + + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption("隧道"); + if (layer != null) + { + layer.Visible = !layer.Visible; + } + } + /// + /// 删除隧道 + /// + /// + /// + private void buttonItemFX4_6_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_6.Text); + + 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("请选中要删除的隧道!", "提示"); + } + } + /// + /// 通视分析 + /// + /// + /// + private void buttonItemFX5_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX5_1.Text); + + if (globeControl1.Globe.Action != EnumAction3D.VisibilityAnalysis) + { + //btnSpaceVisibilityAnalysis.Checked = true; + globeControl1.Globe.Action = EnumAction3D.VisibilityAnalysis; + } + else + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + // SetButtonChecked(); + } + } + /// + /// 可视域分析 + /// + /// + /// + private void buttonItemFX5_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX5_2.Text); + + globeControl1.Globe.Action = EnumAction3D.ViewshedAnalysis; + } + /// + /// 可视包络分析 + /// + /// + /// + private void buttonItemFX5_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX5_3.Text); + + globeControl1.Globe.Action = EnumAction3D.ViewEnvelopeAnalysis; + } + /// + /// 缓冲区分析 + /// + /// + /// + private void buttonItemFX6_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX6_1.Text); + + GSOFeature feat = globeControl1.Globe.SelectedObject; + if (feat == null) + { + MessageBox.Show("请选择要分析的要素!"); + return; + } + if (feat.Geometry.Type == EnumGeometryType.GeoPolyline3D) + { + GSOGeoPolyline3D line1 = feat.Geometry as GSOGeoPolyline3D; + if (line1 == null) + { + MessageBox.Show("请选择一条管线!"); + return; + } + + FrmBufferAnalysis frm = new FrmBufferAnalysis(globeControl1, line1, layerTemp); + frm.Show(this); + } + else + { + FrmBufferAnalysisBSQ frm = new FrmBufferAnalysisBSQ(globeControl1, layerTemp, bsqPT); + frm.Show(this); + } + + } + /// + /// 附属物分析 + /// + /// + /// + private void buttonItemFX6_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX6_2.Text); + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + FrmAccessoryAnalysis dlg = new FrmAccessoryAnalysis(globeControl1, layerTemp); + dlg.Show(this); + } + /// + /// 无源淹没分析 + /// + /// + /// + private void buttonItemFX6_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX6_3.Text); + + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + trackflag = "FloodAnalysis"; + } + /// + /// 水平距离 + /// + /// + /// + private void buttonItemLS1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS1.Text); + + globeControl1.Globe.Action = EnumAction3D.MeasureDistance; + globeControl1.Globe.DistanceRuler.SpaceMeasure = false; + buttonItemLS5.Checked = false; + } + /// + /// 垂直距离 + /// + /// + /// + private void buttonItemLS2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS2.Text); + + buttonItemLS5.Checked = false; + globeControl1.Globe.Action = EnumAction3D.MeasureHeight; + globeControl1.Globe.DistanceRuler.SpaceMeasure = false; + } + /// + /// 空间距离 + /// + /// + /// + private void buttonItemLS3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS3.Text); + + buttonItemLS5.Checked = false; + globeControl1.Globe.Action = EnumAction3D.MeasureDistance; + globeControl1.Globe.DistanceRuler.SpaceMeasure = true; + } + /// + /// 地表距离 + /// + /// + /// + private void buttonItemLS4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS4.Text); + + buttonItemLS5.Checked = false; + globeControl1.Globe.Action = EnumAction3D.MeasureDistance; + globeControl1.Globe.DistanceRuler.SpaceMeasure = false; + } + /// + /// 高度量算 + /// + /// + /// + private void buttonItemLS5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS5.Text); + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + buttonItemLS5.Checked = !buttonItemLS5.Checked; + if (buttonItemLS5.Checked) + { + globeControl1.Globe.Action = EnumAction3D.SelectObject; + } + } + /// + /// 水平面积 + /// + /// + /// + private void buttonItemLS6_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS6.Text); + + buttonItemLS5.Checked = false; + globeControl1.Globe.Action = EnumAction3D.MeasureArea; + globeControl1.Globe.AreaRuler.SpaceMeasure = true; + } + /// + /// 地表面积 + /// + /// + /// + private void buttonItemLS7_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS7.Text); + + buttonItemLS5.Checked = false; + globeControl1.Globe.Action = EnumAction3D.MeasureArea; + globeControl1.Globe.AreaRuler.SpaceMeasure = false; + + } + + # region Fan 重构标注代码 + /// + /// 标高标注 + /// + /// + /// + private void buttonItemSZ1_Click(object sender, EventArgs e) + { + GSOFeature resFeature = IsPipeLineOfSelectedObj(); + if (resFeature == null) + { + MessageBox.Show("请选中一根管线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + GSOGeoPolyline3D selLine = resFeature.Geometry as GSOGeoPolyline3D; + if (selLine[0].Count <= 1) + { + return; + } + + MarkTools.getInstance().showMarker(resFeature, + globeControl1, EnumMarkLayer.Mark_Altitude, ""); + } + /// + /// 管径标注 + /// + GSOFeature radiusMarkerFeature; + private void buttonItemBZ2_Click(object sender, EventArgs e) + { + GSOFeature resFeature = IsPipeLineOfSelectedObj(); + if (resFeature == null) + { + MessageBox.Show("请选中一根管线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + GSOGeoPolyline3D selLine = resFeature.Geometry as GSOGeoPolyline3D; + if (selLine[0].Count <= 1) + { + return; + } + + MarkTools.getInstance().showMarker(resFeature, + globeControl1, EnumMarkLayer.Mark_Diameter, ""); + } + /// + /// 埋深标注 + /// + /// + /// + private void buttonItemBZ3_Click(object sender, EventArgs e) + { + GSOFeature resFeature = IsPipeLineOfSelectedObj(); + if (resFeature == null) + { + MessageBox.Show("请选中一根管线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + GSOGeoPolyline3D selLine = resFeature.Geometry as GSOGeoPolyline3D; + if (selLine[0].Count <=1) + { + return; + } + + MarkTools.getInstance().showMarker(resFeature, + globeControl1, EnumMarkLayer.Mark_Depth, ""); + + } + /// + /// 坐标标注 + /// + /// + /// + private void buttonItemBZ4_Click(object sender, EventArgs e) + { + GSOFeature resFeature = IsPipeLineOfSelectedObj(); + if (resFeature == null) + { + MessageBox.Show("请选中一根管线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + GSOGeoPolyline3D selLine = resFeature.Geometry as GSOGeoPolyline3D; + if (selLine[0].Count <= 1) + { + return; + } + MarkTools.getInstance().showMarker(resFeature, + globeControl1, EnumMarkLayer.Mark_Location, ""); + } + /// + /// 距离标注 + /// + bool distanceMarker = false; + private void buttonItemBZ5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBZ5.Text); + + globeControl1.Globe.Action = EnumAction3D.TrackPolyline; + //globeControl1.Globe.DistanceRuler.MeasureMode = EnumDistanceMeasureMode.HVSLineMeasure; + distanceMarker = true; + } + /// + /// 自定义标注 + /// + /// + /// + private void buttonItemBZ6_Click(object sender, EventArgs e) + { + GSOFeature f = globeControl1.Globe.SelectedObject; + GSOLayer l = globeControl1.Globe.SelectedObjectLayer; + FrmCustomLabel frm = new FrmCustomLabel(globeControl1, l, f); + if (frm.ShowDialog() == DialogResult.OK) + { + MarkTools.getInstance().showMarker(f, globeControl1, EnumMarkLayer.Mark_Custom, frm.labelText); + } + } + /// + /// 扯旗标注 + /// + /// + /// + private void buttonItemBZ7_Click(object sender, EventArgs e) + { + GSOFeature f = globeControl1.Globe.SelectedObject; + GSOLayer l = globeControl1.Globe.SelectedObjectLayer; + FrmMarker frm = new FrmMarker(); + if (frm.ShowDialog() == DialogResult.OK) + { + MarkTools.getInstance().showMarker(f, globeControl1, EnumMarkLayer.Mark_Custom, frm.markerContent); + } + } + /// + /// 坡度标注 + /// + /// + /// + private void buttonItemBZ8_Click(object sender, EventArgs e) + { + GSOFeature resFeature = IsPipeLineOfSelectedObj(); + if (resFeature == null) + { + MessageBox.Show("请选中一根管线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + GSOGeoPolyline3D selLine = resFeature.Geometry as GSOGeoPolyline3D; + if (selLine[0].Count <= 1) + { + return; + } + + MarkTools.getInstance().showMarker(resFeature, + globeControl1, EnumMarkLayer.Mark_Slope, ""); + } + /// + /// 属性标注 + /// + /// + /// + private void buttonItemBZ9_Click(object sender, EventArgs e) + { + GSOFeature f = globeControl1.Globe.SelectedObject; + GSOLayer l = globeControl1.Globe.SelectedObjectLayer; + FrmPropertiesMarker frm = new FrmPropertiesMarker(globeControl1, l, f); + if (frm.ShowDialog() == DialogResult.OK) + { + MarkTools.getInstance().showMarker(f, globeControl1, EnumMarkLayer.Mark_Property, frm.labelText); + } + } + /// + /// 红线工具 + /// + /// + /// + private void buttonItemBZ10_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBZ10.Text); + 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; + } + } + /// + /// 标注管理 + /// + /// + /// + private void buttonItemBZ11_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBZ11.Text); + + buttonItemBZ11.Checked = !buttonItemBZ11.Checked; + 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 (buttonItemBZ11.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(); + } + } + + #endregion + /// + /// 飞行到目标点 + /// + /// + /// + private void buttonItemFXGJ1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFXGJ1.Text); + + FrmSetFlytoPos.ShowForm(globeControl1); + + } + /// + /// 自定义飞行 + /// + /// + /// + private void buttonItemFXGJ2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFXGJ2.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); + } + } + /// + /// 绕中心点飞行 + /// + /// + /// + private void buttonItemFXGJ3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFXGJ3.Text); + + globeControl1.Globe.FlyAroundCenter(10000, EnumFlyRepeatValueType.MiliSeconds); + globeControl1.Globe.CurFlyID = 1; + } + /// + /// 绕眼睛飞行 + /// + /// + /// + private void buttonItemFXGJ4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFXGJ4.Text); + + globeControl1.Globe.FlyAroundEye(720, EnumFlyRepeatValueType.Degrees); + globeControl1.Globe.CurFlyID = 2; + } + + /// + /// 权限管理 + /// + /// + /// + private void buttonItemXT1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT1.Text); + + FrmUserRoleMgr frm = new FrmUserRoleMgr(); + frm.ShowDialog(); + } + /// + /// 数据库管理 + /// + /// + /// + private void buttonItemXT2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT2.Text); + + //查看数据库列表 + FrmDbManager frm = new FrmDbManager(); + frm.ShowDialog(); + } + /// + /// 用户列表 + /// + /// + /// + private void buttonItemXT3_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT3_1.Text); + + FrmUserManager frm = new FrmUserManager(); + frm.ShowDialog(); + } + /// + /// 创建新用户 + /// + /// + /// + private void buttonItemXT3_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT3_2.Text); + + FrmUserAdd frm = new FrmUserAdd(-1); + frm.ShowDialog(); + } + /// + /// 人员修改 + /// + /// + /// + private void buttonItemXT4_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT4_2.Text); + + FrmAppUSER appUSER = new FrmAppUSER(); + appUSER.ShowDialog(); + } + /// + /// 增加人员 + /// + /// + /// + private void buttonItemXT4_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT4_1.Text); + + FrmAppUSERRESET appUSERRESET = new FrmAppUSERRESET(); + appUSERRESET.ShowDialog(); + } + /// + /// 统计数据 + /// + /// + /// + private void buttonItemZTT1_Click(object sender, EventArgs e) + { + ////日志记录 + //LogManager.saveLog(Utility.userName, this.buttonItemZTT1.Text); + + //PATM patm = new PATM(); + //patm.operation = "Statistic"; + //patm.Text = "统计专题图管理"; + //patm.ShowDialog(); + } + /// + /// 热点功能统计 + /// + /// + /// + private void buttonItemZTT2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT2.Text); + + FrmHotFuncStat frmhfs = new FrmHotFuncStat(); + frmhfs.ShowDialog(); + } + + private void buttonItemZTT3_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT3_1.Text); + + FrmAPP appfrm = new FrmAPP("专题图申请"); + appfrm.ShowDialog(); + } + + private void buttonItemZTT3_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT3_2.Text); + + FrmAPPFORASK appForask = new FrmAPPFORASK("专题图审核"); + appForask.ShowDialog(); + } + + private void buttonItemZTT3_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT3_3.Text); + + FrmAPPregion appregion = new FrmAPPregion("专题图审核"); + appregion.ShowDialog(); + } + + private void buttonItemZTT4_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT4_1.Text); + + FrmAPP appfrm = new FrmAPP("打印申请"); + appfrm.ShowDialog(); + } + + private void buttonItemZTT4_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT4_2.Text); + + FrmAPPFORASK appForask = new FrmAPPFORASK("打印审核"); + appForask.ShowDialog(); + } + + private void buttonItemZTT4_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT4_3.Text); + + FrmAPPregion appregion = new FrmAPPregion("打印审核"); + appregion.ShowDialog(); + } + + private void buttonItemZTT5_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT5_1.Text); + + FrmAPP appfrm = new FrmAPP("拷贝申请"); + appfrm.ShowDialog(); + } + + private void buttonItemZTT5_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT5_2.Text); + + FrmAPPFORASK appForask = new FrmAPPFORASK("拷贝审核"); + appForask.ShowDialog(); + } + + private void buttonItemZTT5_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT5_3.Text); + + FrmAPPregion appregion = new FrmAPPregion("拷贝审核"); + appregion.Show(); + } + + private int connectServerCount = 0; + + /// + /// 还原球到实测库 + /// + 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); + } + + if (layerManagerNode.Nodes.Count > 0) + { + for (int i = layerManagerNode.Nodes.Count - 1; i >= 0; i--) + { + layerManagerNode.Nodes[i].Remove(); + + } + } + + globeControl1.Refresh(); + + } + + private void buttonItemSPSZ_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSPSZ.Text); + + FrmLayerControl frm = new FrmLayerControl(layerTree, globeControl1, globeControl2); + frm.Show(this); + } + + /// + /// 碰撞审查 + /// + /// + /// + private void buttonItemSH1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSH1.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 buttonItemSH2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSH2.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 buttonItemSH3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSH3.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 buttonItemSH4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSH4.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 buttonItemSH5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSH5.Text); + FrmCityServerLineAnalysis frm = new FrmCityServerLineAnalysis(globeControl1, m_PipelineLayerNames); + frm.Show(this); + } + #region 数据管理-导入文件 + ///// + ///// 数据管理-导入本地坐标系文件 + ///// + ///// + ///// + //private void buttonItemSJGL1_1_Click(object sender, EventArgs e) + //{ + // //日志记录 + // LogManager.saveLog(Utility.userName, this.buttonItemSJGL1_1.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(); + // } + // } + //} + + ///// + ///// 数据管理-导入其他坐标系文件 + ///// + ///// + ///// + //private void buttonItemSJGL1_2_Click(object sender, EventArgs e) + //{ + // //日志记录 + // LogManager.saveLog(Utility.userName, this.buttonItemSJGL1_2.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(); + // } + // } + //} + #endregion + /// + /// 数据质量检查 + /// + /// + /// + private void buttonItemSJGL2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL2.Text); + FrmValiData frm = new FrmValiData(globeControl1); + frm.ShowDialog(); + } + /// + /// 数据预处理 + /// + /// + /// + private void buttonItemSJGL3_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL3.Text); + + FrmEditShapeFile frm = new FrmEditShapeFile(globeControl1); + frm.ShowDialog(this); + } + /// + /// 连接数据库 + /// + /// + /// + private void buttonItemSJGL4_1_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL4_1.Text); + + FrmDatabaseParaSetting frm = new FrmDatabaseParaSetting(globeControl1); + if (frm.ShowDialog() == DialogResult.OK) + { + ds = FrmDatabaseParaSetting.ds; + if (ds != null) + { + ds.IsCloseSaved = false; + } + } + } + /// + /// 管线入库 + /// + /// + /// + private void buttonItemSJGL4_2_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL4_2.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 buttonItemSJGL4_3_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL4_3.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 buttonItemSJGL5_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL5.Text); + + Cyberpipe.Forms.FrmProject frm = new Cyberpipe.Forms.FrmProject(); + frm.ShowDialog(); + } + /// + /// 元数据基本管理 + /// + /// + /// + private void buttonItemSJGL6_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL6_1.Text); + + FrmMetadata frmmd = new FrmMetadata(); + frmmd.ShowDialog(); + } + /// + /// 元数据查询管理 + /// + /// + /// + private void buttonItemSJGL6_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL6_2.Text); + + FrmMetadataStat frmmds = new FrmMetadataStat(); + //frmmds.Show(); + frmmds.ShowDialog(); + } + /// + /// 操作日志管理 + /// + /// + /// + private void buttonItemSJGL7_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL7.Text); + + FrmLogOper frmlo = new FrmLogOper(); + frmlo.ShowDialog(); + } + /// + /// 数据字典管理 + /// + /// + /// + private void buttonItemSJGL8_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL8.Text); + + FrmMDDictory frmmdd = new FrmMDDictory(); + frmmdd.ShowDialog(); + } + /// + /// 数据库备份 + /// + /// + /// + private void buttonItemSJGL9_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL9.Text); + + //新 + FrmBACKORACLE backOracle = new FrmBACKORACLE(); + backOracle.Show(); + } + /// + /// 创建管段 + /// + /// + /// + private void buttonItemBJ1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ1.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; + } + } + /// + /// 创建附属物 + /// + /// + /// + private void buttonItemBJ2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ2.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); + } + } + /// + /// 创建特征管点 + /// + /// + /// + private void buttonItemBJ3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ3.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); + } + } + /// + /// 绘制城市七线 + /// + /// + /// + private void buttonItemBJ4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ4.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; + } + } + } + /// + /// 选中对象 + /// + /// + /// + private void buttonItemBJ5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ5.Text); + + globeControl1.Globe.Action = EnumAction3D.SelectObject; + } + /// + /// 平移对象 + /// + /// + /// + private void buttonItemBJ6_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ6.Text); + + globeControl1.Globe.Action = EnumAction3D.MoveObject; + } + /// + /// 升降对象 + /// + /// + /// + private void buttonItemBJ7_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ7.Text); + + globeControl1.Globe.Action = EnumAction3D.ElevateObject; + } + /// + /// 旋转对象 + /// + /// + /// + private void buttonItemBJ8_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ8.Text); + + globeControl1.Globe.Action = EnumAction3D.RotateObject; + } + /// + /// 连接管段 + /// + /// + /// + private void buttonItemBJ9_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ9.Text); + + if (globeControl1.Globe.SelObjectCount < 2) + { + MessageBox.Show("对不起,请至少选中2个对象!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + return; + } + globeControl1.Globe.InsertJointPipeline(false); + } + /// + /// 后退 + /// + /// + /// + private void buttonItemBJ11_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemBJ11.Text); + globeControl1.Globe.UnDoEdit(); + } + /// + /// 前进 + /// + /// + /// + private void buttonItemBJ12_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemBJ12.Text); + + globeControl1.Globe.ReDoEdit(); + } + /// + /// 导出CAD + /// + /// + /// + private void buttonItemBJ10_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ10_1.Text); + + #region 导出成dxf格式 + List listVectorNames = new List(); + 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(); + #endregion + } + /// + /// 导出矢量 + /// + /// + /// + private void buttonItemBJ10_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ10_2.Text); + + List listVectorNames = new List(); + 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 buttonItemBJ13_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemBJ13.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(); + } + } + MessageBox.Show("删除成功!", "提示"); + } + else + { + MessageBox.Show("请选中要删除的模型!", "提示"); + } + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + } + + private void buttonItemHX1_1_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]; + string filePath = dlg.FileName; + string lastname = Path.GetFileName(filePath); + + 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(); + } + + } + } + } + + public struct LineStruct + { + public string layerName; + public string layerCode; + public string lineLength; + public string hxName; + } + + List lineStruct = new List(); + List featsList = new List(); + + /// + /// 红线审核 + /// + /// + /// + private void buttonItemHX2_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemHX2.Text); + redSH = true; + featsList.Clear(); + lineStruct.Clear(); + List listPipelineLayers = new List(); + + GSOLayer layer = null; + for (int i = 0; i < m_PipelineLayerNames.Count; i++) + { + layer = globeControl1.Globe.Layers.GetLayerByCaption(m_PipelineLayerNames[i]); + if (layer != null) + { + listPipelineLayers.Add(layer); + } + } + //yanxiaowei 重构 + GSOFeatures selectFeatures=new GSOFeatures(); + for (int i = 0; i < globeControl1.Globe.SelObjectCount; i++) + { + GSOFeature feature = null; + globeControl1.Globe.GetSelectObject(i, out feature, out layer); + selectFeatures.Add(feature); + } + DataTable table=new DataTable(); + + ClassGSOTool.CalculateRedLineResult(out table, redSH, selectFeatures, globeControl1, + listPipelineLayers,out lineStruct, out featsList); + + if (table.Rows.Count != 0) + AddDatagridView(table); + else + { + MessageBox.Show("没有侵入地块红线的管线数据!", "提示"); + dataGridViewX1.DataSource = null; + panelOfTable.Visible = false; + return; + } + } + + private void AddDatagridView(DataTable table) + { + dataGridViewX1.DataSource = table; + panelOfTable.Visible = true; + panelOfTable.Height = 200; + toolStripNumbers.Text = "红线审核 |共有:" + table.Rows.Count + "条"; + toolStripDropDownButton3.Visible = true; + } + /// + /// 主窗体 下方的工具条中的 导出.xls文件 按钮事件处理 + /// + /// + /// + private void toolStripDropDownButton3_Click(object sender, EventArgs e) + { + if (dataGridViewX1.Rows.Count == 0) + { + MessageBox.Show("表格内容为空!", "提示"); + return; + } + + string strSaveFile = string.Empty; + SaveFileDialog savefiledialog = new SaveFileDialog(); + savefiledialog.Filter = "Excel文件|*.xls,*.xlsx"; + savefiledialog.AddExtension = true; + savefiledialog.FileName = "红线审核"; + if (savefiledialog.ShowDialog() == DialogResult.OK) + strSaveFile = savefiledialog.FileName; + else return; + + ExpEXCEL.ExpToExcel(dataGridViewX1, strSaveFile, "红线审核", lineStruct, featsList); + MessageBox.Show("导出成功!"); + } + /// + /// 去除集合中重复的管线 + /// + /// + /// + /// + private GSOFeatures getFeaturesByFilter(GSOFeatures features, string fieldName) + { + if (features == null) + { + return null; + } + GSOFeatures featuresGet = new GSOFeatures(); + for (int i = 0; i < features.Length; i++) + { + GSOFeature featureFromFS = features[i]; + string fieldValueFromFS = featureFromFS.GetValue(fieldName).ToString().Trim(); + bool isHas = false; + for (int j = featuresGet.Length - 1; j >= 0; j--) + { + GSOFeature featureFromFSGet = featuresGet[j]; + string fieldValueFromFSGet = featureFromFSGet.GetValue(fieldName).ToString().Trim(); + if (fieldValueFromFS.Equals(fieldValueFromFSGet)) + { + isHas = true; + break; + } + } + if (isHas == false) + { + featuresGet.Add(featureFromFS.Clone()); + } + } + return featuresGet; + } + + private void sliderItem2_ValueChanged(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.sliderItem2.Text); + + globeControl1.Globe.GroundOpaque = 100 - sliderItem2.Value; + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(roadLayerName);//("180fd"); + if (layer != null) + { + layer.Opaque = 100 - sliderItem2.Value; + } + layer = globeControl2.Globe.Layers.GetLayerByCaption("180fd");//("180fd"); + if (layer != null) + { + layer.Opaque = 100 - sliderItem2.Value; + } + globeControl2.Globe.GroundOpaque = 100 - sliderItem2.Value; + + optiValue = sliderItem2.Value; + } + /// + /// 数据管理导入文件 + /// + /// + /// + private void buttonItemSJGL1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL1.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.Multiselect = true; + if (dlg.ShowDialog() == DialogResult.OK) + { + //自定义lprj文件名,从程序中复制一lprj文件。 + string filePath = dlg.FileName; + string lastname = Path.GetFileName(filePath); + + 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, 100); + + globeControl1.Refresh(); + } + } + } + + private void buttonItemHX1_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemHX1.Text); + + GSODataSource dataSpace = globeControl1.Globe.DataManager.OpenOracleDataSource(Utility.DBServer.Trim() + "/" + Utility.dbdatabase.Trim(), "", "", Utility.userID, Utility.DBPassword); + string filepath = ""; + //日志记录 + OpenFileDialog dlg = new OpenFileDialog(); + dlg.Filter = "矢量数据(*.shp)|*.shp|矢量数据(*.lgd)|*.lgd|CAD数据(*.dxf)|*.dxf|全部支持格式(*.lgd,*.shp,*.dxf)|*.lgd;*.shp;*.dxf;"; + dlg.Multiselect = true; + + #region 临时图层显示 + if (dlg.ShowDialog() == DialogResult.OK) + { + string filePath = dlg.FileName; + string lastname = Path.GetFileName(filePath); + + #region + for (int i = 0; i < dlg.FileNames.Length; i++) + { + string strDataPath = dlg.FileNames[i]; + filepath = strDataPath; + + GSOLayer layer = globeControl1.Globe.Layers.Add(strDataPath); + GSOFeatures RedFeatures = layer.GetAllFeatures(); + + 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(); + RedFeatures = features; + 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; + } + + /////////////////////////////////////////////////////////////////////////////////////////// + globeControl1.Globe.Layers.MoveTo(0, globeControl1.Globe.Layers.Count - 1); + globeControl1.Refresh(); + } + + IModelBuilder modelBuilder = new RedLineBuilder(); + + modelBuilder.batchInsert(dataSpace, redDt, RedFeatures); + + } + #endregion + + } + #endregion + } + /// + /// 定位 + /// + /// + /// + private void buttonItemLocation_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemLocation.Text); + + FrmFlyToPosition fly = new FrmFlyToPosition(globeControl1,globeControl2); + fly.Show(this); + } + /// + /// 2015-10-17演示代码 红线审核 + /// + /// + /// + private void ribbonTabItem6_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.FlyToPosition(new GSOPoint3d(120.610963, 31.188121, 50), EnumAltitudeMode.Absolute, -4, 50, 800); + globeControl1.Globe.FlyToPointSpeed = 10000000; + globeControl1.Globe.Action = EnumAction3D.SelectObject; + globeControl1.Refresh(); + + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + + //zhanshi = false; + redSH = true; + splitContainer1.Panel2Collapsed = true; + legendSG.Visible = false; + legendSC.Visible = false; + ClearGZData(); + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = true; + } + + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 基础工具 + /// + /// + /// + private void ribbonTabItem1_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + //zhanshi = false; + redSH = false; + splitContainer1.Panel2Collapsed = true; + panelOfTable.Visible = false; + legendSC.Visible = false; + legendSG.Visible = false; + ClearGZData(); + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + + + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 一键审核 + /// + /// + /// + private void ribbonTabItem11_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + //zhanshi = false; + redSH = false; + splitContainer1.Panel2Collapsed = true; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + panelOfTable.Visible = false; + legendSC.Visible = false; + legendSG.Visible = false; + ClearGZData(); + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + + + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 右屏添加冰箱数据 + /// + void AddDataToGlobeControl2() + { + + bool modelDataBool = false; + for (int i = globeControl2.Globe.Layers.Count - 1; i >= 0; i--) + { + GSOLayer layer = globeControl2.Globe.Layers[i]; + if (layer.Name.Contains("fttp:")) + { + modelDataBool = true; + break; + } + } + + if (modelDataBool == false) + { + GSOLayer ly = globeControl1.Globe.Layers.GetLayerByCaption("天地图地图"); + globeControl2.Globe.Layers.Add(ly); + } + else + { + return; + } + } + /// + /// 双屏对比 + /// + /// + /// + private void ribbonTabItem9_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent += new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent += new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + panelOfTable.Visible = false; + + splitContainer1.Panel2Collapsed = false; + //zhanshi = true; + redSH = false; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + sliderItem2.Value = 100 - globeControl1.Globe.GroundOpaque; + globeControl2.Globe.GroundOpaque = globeControl1.Globe.GroundOpaque; + legendSC.Visible = true; + legendSG.Visible = true; + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + AddDataToGlobeControl2(); + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 文档管理 + /// + /// + /// + private void ribbonTabItem4_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + panelOfTable.Visible = false; + //zhanshi = false; + redSH = false; + splitContainer1.Panel2Collapsed = true; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + legendSC.Visible = false; + legendSG.Visible = false; + ClearGZData(); + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 基础管理 + /// + /// + /// + private void ribbonTabItem14_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + panelOfTable.Visible = false; + //zhanshi = false; + redSH = false; + splitContainer1.Panel2Collapsed = true; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + legendSC.Visible = false; + legendSG.Visible = false; + ClearGZData(); + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 权限管理 + /// + /// + /// + private void ribbonTabItem2_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + panelOfTable.Visible = false; + //zhanshi = false; + redSH = false; + splitContainer1.Panel2Collapsed = true; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + legendSC.Visible = false; + legendSG.Visible = false; + ClearGZData(); + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + GSOFeature dpFeatuer = null; + /// + /// 双屏分析,点击管段分析 + /// + /// + /// + private void buttonItem8_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItem8.Text); + + //FrmCompareFeature frmCompareFeature = new FrmCompareFeature(globeControl1, globeControl2, layerTemp, layerTemp2,m_PipelineLayerNames,sgPipeLayersNames); + int width = this.Width; + FrmCompareFeature.ShowForm(globeControl1, globeControl2, layerTemp, layerTemp2, m_PipelineLayerNames, sgPipeLayersNames,width); + //frmCompareFeature.Location = new Point((this.Width - frmCompareFeature.Width)/2,50); + //frmCompareFeature.Show(this); + + } + /// + /// 红线审核导出图片 + /// + /// + /// + private void buttonItemDCTP_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemDCTP.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))); + */ + int mapWidth = 0; + int mapHeight = 0; + Point pt = getUpperLeftPoint(pt1, pt2, out mapWidth, out mapHeight); + int rightBottomX = pt.X + mapWidth; + int rightBottomY = pt.Y + mapHeight; + Image myImg = new Bitmap(mapWidth, mapHeight); + Graphics g = Graphics.FromImage(myImg); + g.CopyFromScreen(pt, new Point(0, 0), new Size(rightBottomX, rightBottomY)); + + 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; + } + } + } + /// + /// 标识器全区域统计 + /// + /// + /// + private void 标识器分类统计ToolStripMenuItem_Click(object sender, EventArgs e) + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + FrmBSQStatis bsqStatis = new FrmBSQStatis(globeControl1,null); + //FrmBSQStatis bsqStatis = new FrmBSQStatis(); + bsqStatis.Show(this); + } + /// + /// 标识器绘制区域统计 + /// + /// + /// + private void 标识器分类统计ToolStripMenuItem1_Click(object sender, EventArgs e) + { + trackflag = "BSQDuoBianXiangStatis"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + } + + #region 保存和加载审核库加载的图层 + /* + private void saveLayerList(TreeNodeCollection treeNodeList) + { + string configPath = Application.StartupPath + "\\configLayerList.xml"; + try + { + XmlDocument doc = new XmlDocument(); + doc.Load(configPath); + XmlNode dbParams = doc.SelectSingleNode("Params/dbparams"); + XmlNode dbLayers = doc.SelectSingleNode("Params/dblayers"); + XmlNode layers = doc.SelectSingleNode("Params/layers"); + dbParams.RemoveAll(); + dbLayers.RemoveAll(); + layers.RemoveAll(); + + List listDS = new List(); + String shDatasourceName = Utility.sgdbip + "/" + Utility.sgdbname + "_" + Utility.sgdbuser; + bool flag = false; + + for (int i = 0; i < globeControl1.Globe.DataManager.DataSourceCount; i++) + { + GSODataSource ds = globeControl1.Globe.DataManager.GetDataSourceAt(i); + if (ds != null && ds.Type == EnumDataSourceType.SqlServer || ds.Type == EnumDataSourceType.Oracle) + { + if (ds.Name == shDatasourceName) + { + //防止因为多次连接同一个数据库 + if (flag == true) + { + break; + } + flag = true; + listDS.Add(ds); + GSODataSourceCnn conn = ds.GetConnectionInfo(); + + XmlElement dbparam = doc.CreateElement("shdbparam"); + XmlElement ip = doc.CreateElement("ship"); + ip.InnerText = conn.Server; + + XmlElement dbname = doc.CreateElement("shdbname"); + dbname.InnerText = conn.Database; + + XmlElement username = doc.CreateElement("shusername"); + username.InnerText = conn.User; + + XmlElement password = doc.CreateElement("shpassword"); + password.InnerText = conn.Password; + + XmlElement type = doc.CreateElement("shtype"); + if (ds.Type == EnumDataSourceType.SqlServer) + { + type.InnerText = "sqlserver"; + } + else + { + type.InnerText = "oracle"; + } + + dbparam.AppendChild(ip); + dbparam.AppendChild(dbname); + dbparam.AppendChild(username); + dbparam.AppendChild(password); + dbparam.AppendChild(type); + dbParams.AppendChild(dbparam); + } + + } + } + + for (int i = 0; i < treeNodeList.Count; i++) + { + GSOLayer layer = treeNodeList[i].Tag as GSOLayer; + if (Path.GetExtension(layer.Name) == "") + { + XmlElement dbLayer = doc.CreateElement("dblayer"); + XmlAttribute attri = doc.CreateAttribute("dbindex"); + for (int j = 0; j < listDS.Count; j++) + { + if (layer.Dataset.DataSource.Name == listDS[j].Name) + { + attri.Value = j.ToString(); + break; + } + } + dbLayer.Attributes.Append(attri); + dbLayer.InnerText = layer.Name; + + dbLayers.AppendChild(dbLayer); + } + else + { + XmlElement dbLayer = doc.CreateElement("layer"); + dbLayer.InnerText = layer.Name; + layers.AppendChild(dbLayer); + } + } + + doc.Save(configPath); + } + catch (Exception e) + { + + } + } + + private void openLayerList() + { + layerManagerNode.Nodes.Clear(); + + string configPath = Application.StartupPath + "\\configLayerList.xml"; + try + { + XmlDocument doc = new XmlDocument(); + doc.Load(configPath); + XmlNode dbParams = doc.SelectSingleNode("Params/dbparams"); + XmlNode dbLayers = doc.SelectSingleNode("Params/dblayers"); + XmlNode layers = doc.SelectSingleNode("Params/layers"); + + List listDS = new List(); + for (int i = 0; i < dbParams.ChildNodes.Count; i++) + { + string ip = ""; + string dbname = ""; + string username = ""; + string password = ""; + string type = ""; + XmlNode node = dbParams.ChildNodes.Item(i); + for (int j = 0; j < node.ChildNodes.Count; j++) + { + XmlNode nodeChild = node.ChildNodes.Item(j); + + if (nodeChild != null && nodeChild.Name == "ship") + { + ip = nodeChild.InnerText; + } + else if (nodeChild != null && nodeChild.Name == "shdbname") + { + dbname = nodeChild.InnerText; + } + else if (nodeChild != null && nodeChild.Name == "shusername") + { + username = nodeChild.InnerText; + } + else if (nodeChild != null && nodeChild.Name == "shpassword") + { + password = nodeChild.InnerText; + } + else if (nodeChild != null && nodeChild.Name == "shtype") + { + type = nodeChild.InnerText; + } + } + + if (type == "sqlserver") + { + GSODataSource ds = globeControl1.Globe.DataManager.OpenSqlServerDataSource(ip, "", dbname, username, password); + listDS.Add(ds); + } + else if (type == "oracle") + { + GSODataSource ds = globeControl1.Globe.DataManager.OpenOracleDataSource(ip + "/" + dbname, "", "", username, password); + listDS.Add(ds); + } + } + + for (int i = 0; i < dbLayers.ChildNodes.Count; i++) + { + XmlNode node = dbLayers.ChildNodes.Item(i); + if (node != null) + { + string layerName = node.InnerText; + XmlAttribute attri = node.Attributes["dbindex"]; + if (attri != null) + { + int dbIndex = -1; + if (int.TryParse(attri.Value, out dbIndex)) + { + GSODataset dataset = listDS[dbIndex].GetDatasetByName(layerName); + globeControl1.Globe.Layers.Add(dataset); + //更新树节点 + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + TreeNode layerNode = new TreeNode(); + layerNode.Tag = layer; + layerNode.Text = layer.Dataset.Caption; + layerNode.ImageIndex = 0; + layerNode.SelectedImageIndex = 0; + layerNode.Checked = layer.Visible; + layerManagerNode.Nodes.Insert(0, layerNode); + // layerManagerNode.Expand(); + + + } + } + } + } + for (int i = 0; i < layers.ChildNodes.Count; i++) + { + XmlNode node = layers.ChildNodes.Item(i); + if (node != null) + { + string layerName = node.InnerText; + globeControl1.Globe.Layers.Add(layerName); + + //更新树节点 + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + TreeNode layerNode = new TreeNode(); + layerNode.Tag = layer; + layerNode.Text = layer.Dataset.Caption; + layerNode.ImageIndex = 0; + layerNode.SelectedImageIndex = 0; + layerNode.Checked = layer.Visible; + layerManagerNode.Nodes.Insert(0, layerNode); + } + } + layerManagerNode.Expand(); + } + catch (Exception e) + { + + } + } + * */ + #endregion + + private void btn_check_history_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_check_history.Text); + + if (FrmCheckHistory.isOpen == true) + { + return; + } + FrmCheckHistory frm = new FrmCheckHistory(globeControl1, globeControl2); + frm.addNode += new AddNodeToLayerManagerNode(addNodeToLayerManagerNode); + frm.Show(); + + } + + private void buttonItem查看数据_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItem查看数据.Text); + + FrmThreeOracle tr = new FrmThreeOracle(globeControl1); + + if (tr.ShowDialog() == DialogResult.OK) + { + addNodeToLayerManagerNode(tr.rukuLayer); + globeControl1.Refresh(); + } + } + /// + /// 规划数据入库 + /// + /// + /// + private void buttonItemGHRK_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemGHRK.Text); + + FrmGHRK ghrk = new FrmGHRK(globeControl1, layerManagerNode); + ghrk.Show(this); + } + + private void btn_user_info_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_user_info.Text); + + if (!FrmSysUserInfoManger.IS_OPEN) + { + FrmSysUserInfoManger frm = new FrmSysUserInfoManger(); + frm.ShowDialog(); + } + } + + private void btn_role_info_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_role_info.Text); + + if (FrmRoleInfoManager.IS_OPEN) + { + return; + } + FrmRoleInfoManager frm = new FrmRoleInfoManager(); + frm.ShowDialog(); + } + + private void btn_resc_info_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_resc_info.Text); + + if (!SysRescInfoManager.IS_OPEN) + { + SysRescInfoManager frm = new SysRescInfoManager(); + frm.ShowDialog(); + } + } + + private void btn_role_resc_Click(object sender, EventArgs e) + { + + LogManager.saveLog(Utility.userName, this.btn_role_resc.Text); + + if (!FrmRoleRescManager.IS_OPEN) + { + FrmRoleRescManager frm = new FrmRoleRescManager(); + frm.ShowDialog(); + } + } + + private void btn_user_role_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_user_role.Text); + + if (FrmUserRole.IS_OPEN) + { + return; + } + FrmUserRole frm = new FrmUserRole(); + frm.ShowDialog(); + } + + private void btn_document_info_Click(object sender, EventArgs e) + { + + LogManager.saveLog(Utility.userName, this.btn_document_info.Text); + + //if (FormDocumentManager.IS_OPEN) + //{ + // return; + //} + //FormDocumentManager frm = new FormDocumentManager(); + //frm.ShowDialog(); + + //if (FormDocumentManager.IS_OPEN) + //{ + // return; + //} + //new FormDocumentManager().ShowDialog(); + if (FormDocumentManager.IS_OPEN) + { + return; + } + this.Cursor = Cursors.WaitCursor; + FormDocumentManager frm = new FormDocumentManager(); + frm.changeCursor += new ChangeCursor(changeCursorToDefault); + frm.ShowDialog(); + + } + + private void changeCursorToDefault() + { + this.Cursor = Cursors.Default; + } + + /// + /// 判断CAD文件是否有投影信息 + /// + /// + /// + Boolean CheckDatasetGeoReference(GSODataset dataset) + { + Boolean bSuccess = false; + if (dataset.GeoReferenceType == EnumGeoReferenceType.Flat) + { + if (MessageBox.Show("数据没有空间参考信息,请设置空间参考信息!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation) == DialogResult.OK) + { + String strPath = Path.GetDirectoryName(Application.ExecutablePath) + "\\Coordinate Systems"; + OpenFileDialog dlg = new OpenFileDialog(); + + dlg.InitialDirectory = strPath; + dlg.RestoreDirectory = true; + + dlg.Filter = "投影文件|*.prj||"; + if (dlg.ShowDialog() == DialogResult.OK) + { + bSuccess = dataset.LoadProjectionFromESRIFile(dlg.FileName); + } + } + } + else + { + return true; + } + return bSuccess; + } + + private void buttonItemexp_CAD_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemexp_CAD.Text); + + OpenFileDialog dlg = new OpenFileDialog(); + dlg.Filter = "支持格式(*.dwg)|*.dwg"; + dlg.Multiselect = true; + if (dlg.ShowDialog() == DialogResult.OK) + { + for (int i = 0; i < dlg.FileNames.Length; i++) + { + //this.Cursor = Cursors.WaitCursor; + string strDataPath = dlg.FileNames[i]; + + #region + //string strDataPathPrj = strDataPath.ToLower().Replace(".dwg", ".lprj"); + + //if (File.Exists(strDataPathPrj) == false) + //{ + // if (MessageBox.Show("数据没有空间参考信息,请设置空间参考信息!", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation) == DialogResult.OK) + // { + // String strPath = Application.StartupPath + "\\Coordinate Systems"; + // OpenFileDialog dlgPrj = new OpenFileDialog(); + // dlgPrj.InitialDirectory = strPath; + // dlgPrj.RestoreDirectory = true; + // dlgPrj.Multiselect = false; + // dlg.Filter = "投影文件|*.prj"; + // if (dlg.ShowDialog() == DialogResult.OK) + // { + // this.Cursor = Cursors.WaitCursor; + // string proj4 = GSODataEngineUtility.ConvertEsriPrjFileToProj4(dlg.FileName); + // using (StreamWriter stream = new StreamWriter(strDataPathPrj, false)) + // { + // stream.WriteLine("0prj4" + proj4 + ""); + // } + // AddLayerData(strDataPath); + // //globeControl1.Globe.Layers.Add(strDataPath); + + // this.Cursor = Cursors.Default; + // } + // else + // { + // AddLayerData(strDataPath); + // //globeControl1.Globe.Layers.Add(strDataPath); + // } + // } + // else + // { + // AddLayerData(strDataPath); + // //globeControl1.Globe.Layers.Add(strDataPath); + // } + + //} + //else + //{ + // //globeControl1.Globe.Layers.Add(strDataPath); + // AddLayerData(strDataPath); + //} + #endregion + AddLayerData(strDataPath); + //this.Cursor = Cursors.Default; + } + } + + 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, 100); + + globeControl1.Refresh(); + } + } + + private void btn_password_edit_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_password_edit.Text); + + if (FrmChangePassword.IS_OPEN) + { + return; + } + FrmChangePassword frm = new FrmChangePassword(); + frm.ShowDialog(); + } + /// + /// 多孔管线入库 + /// + /// + /// + private void buttonItem9_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL4_2.Text); + + if (ds == null) + { + MessageBox.Show("请先连接数据库", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + ConnectDB(null, null); + } + if (ds == null) + return; + + FrmMultiPipelineModelDB frm = new FrmMultiPipelineModelDB(globeControl1, ds); + if (frm.ShowDialog() == DialogResult.OK) + { + addNodeToLayerManagerNode(frm.rukuLayer); + } + //frm.Show(); + } + private void 导出CADToolStripMenuItem1_Click(object sender, EventArgs e) + { + TreeNode node = layerNodeContexMenu.Tag as TreeNode; + if (node == null) + { + MessageBox.Show("请在左侧节点集中选择要导出的图层", "提示"); + return; + } + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(node.Text.Trim()); + if (layer == null || layer.GetAllFeatures().Length <= 0) + { + MessageBox.Show("要导出的图层为空", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + return; + } + string strProjectName = Utility.projectStr; + if (strProjectName != "") + { + SaveFileDialog dlg = new SaveFileDialog(); + dlg.Filter = "*.dwg|*.dwg|*.dxf|*.dxf"; + dlg.FileName = layer.Caption; + if (dlg.ShowDialog(this) == DialogResult.OK) + { + globeControl1.Globe.MemoryLayer.SaveAs(dlg.FileName); + GSOLayer newlayer = globeControl1.Globe.Layers.Add(dlg.FileName); + newlayer.RemoveAllFeature(); + int featureCount = layer.GetAllFeatures().Length; + for (int i = 0; i < featureCount; i++) + { + GSOFeature feature = layer.GetAt(i); + if (feature != null && feature.Geometry != null) + { + if (feature.Geometry.Type == EnumGeometryType.GeoPolyline3D) + { + feature.Geometry.Style = new GSOSimpleLineStyle3D(); + } + else if (feature.Geometry.Type == EnumGeometryType.GeoPolygon3D) + { + feature.Geometry.Style = new GSOSimplePolygonStyle3D(); + } + newlayer.AddFeature(feature); + } + } + newlayer.Save(); + newlayer.Dataset.DataSource.RemoveDataset(newlayer.Dataset); + globeControl1.Globe.Layers.Remove(newlayer); + MessageBox.Show("导出CAD完成!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + } + } + } + + private void buttonItemGBJC_Click(object sender, EventArgs e) + { + FrmGBJC gb = new FrmGBJC(globeControl1, globeControl2, layerTemp, layerTemp2); + gb.Show(this); + } + + #region 右屏管纵数据控制 + private void 五十米主干道ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = true; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + + private void 三十六米次干道ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = true; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + + private void 四十二米次干道ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = true; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + + private void 二十四米一块板ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = true; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + + private void 二十四米三块板ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = true; + } + + private void 二十四米停车带ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = true; + lendendGZ24_3.Visible = false; + } + + private void 二十六米大堤路ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = true; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + + private void 清除管纵数据ToolStripMenuItem_Click(object sender, EventArgs e) + { + ClearGZData(); + } + + private void ClearGZData() + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + #endregion + + private void buttonItemPasswordReset_Click(object sender, EventArgs e) + { + Frm_password_reset reset = new Frm_password_reset(); + reset.Show(); + } + + private void pictureBox1_Paint(object sender, PaintEventArgs e) + { + int Width = this.Width; + string welcomeUser = "欢迎您:" + Utility.userName; + Graphics g = e.Graphics; + g.DrawString(welcomeUser, new Font("宋体", 12), new SolidBrush(Color.Black), Width - 180, 50); + } + + } +} \ No newline at end of file diff --git a/Cyberpipe.csproj b/Cyberpipe.csproj index 3a45ad8..d22f590 100644 --- a/Cyberpipe.csproj +++ b/Cyberpipe.csproj @@ -402,12 +402,6 @@ FrmBACKORACLE.cs - - Form - - - FrmBSQDuoBianXingStatis.cs - Form @@ -1271,9 +1265,6 @@ FrmBACKORACLE.cs - - FrmBSQDuoBianXingStatis.cs - FrmBSQStatis.cs diff --git a/FeatureStatisticsService.cs b/FeatureStatisticsService.cs index e833e5f..c7de210 100644 --- a/FeatureStatisticsService.cs +++ b/FeatureStatisticsService.cs @@ -273,19 +273,15 @@ /// 获取特定区域图层的管线列表,并将其总长度统计出来 ///
TODOLIST:将Intersects_Pipeline在MainFrm中去除 /// - /// + /// + /// 要统计的长度 /// public static GSOFeatures getLayerPipes(GSOGeoPolygon3D polygon, GSOLayer layer, out double length) { length = 0; if (layer == null) return null; - GSOFeatureLayer flayer = layer as GSOFeatureLayer; - GSOFeatureDataset fdataset = flayer.Dataset as GSOFeatureDataset; - GSOFeatures feats = null; - - feats = polygon == null?flayer.GetAllFeatures():flayer.FindFeaturesInPolygon(polygon, false); - + GSOFeatures feats = getLayerFeatures(polygon, layer); double totallength = 0.00; for (int i = 0; i < feats.Length; i++) { @@ -301,5 +297,17 @@ return feats; } + /// + /// 获取区域图层内的feature列表,MainFrm.PolygonIntersectAnalysis和此方法重复,需要整理删除 + /// + /// + /// + /// + public static GSOFeatures getLayerFeatures(GSOGeoPolygon3D polygon, GSOLayer layer) + { + if (layer == null) return null; + GSOFeatureLayer flayer = layer as GSOFeatureLayer; + return polygon == null ? flayer.GetAllFeatures() : flayer.FindFeaturesInPolygon(polygon, false); + } } } diff --git a/FrmAllWorkWellStatis.cs b/FrmAllWorkWellStatis.cs index 7bf65dc..bd0f81b 100644 --- a/FrmAllWorkWellStatis.cs +++ b/FrmAllWorkWellStatis.cs @@ -19,17 +19,7 @@ private Dictionary map = null; private GSOGlobeControl globeControl1; private GSOGeoPolygon3D polygon; - //TODOLIST:用晓伟的代理进行操作,功能拆分细化 - //public FrmAllWorkWellStatis(GSOGeoPolygon3D polygon, DataGridView dataGridViewX11, ToolStripStatusLabel toolStripNumbers1, GSOGlobeControl ctl, PanelEx p) - //{ - // InitializeComponent(); - // panel = p; - // dataGridViewX1 = dataGridViewX11; - // toolStripNumbers = toolStripNumbers1; - // globeControl1 = ctl; - // map = getAccsMap(polygon); - //} public FrmAllWorkWellStatis(GSOGlobeControl ctl,GSOGeoPolygon3D polygon, MainFrm.DataGridViewDelegate InitDataGridViewX1) { InitializeComponent(); @@ -117,8 +107,9 @@ sql = "select " + getpipeLineFields.getFields(layername, globeControl1) + " from " + layer.Name; sql += " where 1>2 "; - for (int i = 0; i < fs.Length && fs[i].GetFieldDefn("编号") != null; i++) + for (int i = 0; i < fs.Length; i++) { + if (fs[i].GetFieldDefn("编号") == null) continue; sql += " or 编号 = '" + fs[i].GetValue("编号").ToString() + "'"; } diff --git a/FrmBSQDuoBianXingStatis.Designer.cs b/FrmBSQDuoBianXingStatis.Designer.cs deleted file mode 100644 index bda6842..0000000 --- a/FrmBSQDuoBianXingStatis.Designer.cs +++ /dev/null @@ -1,87 +0,0 @@ -namespace Cyberpipe -{ - partial class FrmBSQDuoBianXingStatis - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea1 = new System.Windows.Forms.DataVisualization.Charting.ChartArea(); - this.groupBox1 = new System.Windows.Forms.GroupBox(); - this.chart1 = new System.Windows.Forms.DataVisualization.Charting.Chart(); - this.groupBox1.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.chart1)).BeginInit(); - this.SuspendLayout(); - // - // groupBox1 - // - this.groupBox1.Controls.Add(this.chart1); - this.groupBox1.Dock = System.Windows.Forms.DockStyle.Fill; - this.groupBox1.Location = new System.Drawing.Point(0, 0); - this.groupBox1.Name = "groupBox1"; - this.groupBox1.Size = new System.Drawing.Size(592, 384); - this.groupBox1.TabIndex = 0; - this.groupBox1.TabStop = false; - this.groupBox1.Text = "统计结果信息"; - // - // chart1 - // - chartArea1.AxisX.MajorGrid.Enabled = false; - chartArea1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(191)))), ((int)(((byte)(219)))), ((int)(((byte)(255))))); - chartArea1.BackGradientStyle = System.Windows.Forms.DataVisualization.Charting.GradientStyle.TopBottom; - chartArea1.Name = "ChartArea1"; - this.chart1.ChartAreas.Add(chartArea1); - this.chart1.Dock = System.Windows.Forms.DockStyle.Fill; - this.chart1.Location = new System.Drawing.Point(3, 17); - this.chart1.Name = "chart1"; - this.chart1.Size = new System.Drawing.Size(586, 364); - this.chart1.TabIndex = 0; - this.chart1.Text = "chart1"; - // - // FrmBSQDuoBianXingStatis - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(592, 384); - this.Controls.Add(this.groupBox1); - this.DoubleBuffered = true; - this.Name = "FrmBSQDuoBianXingStatis"; - this.ShowIcon = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; - this.Text = "多边形区域统计"; - this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FrmBSQDuoBianXingStatis_FormClosing); - this.Load += new System.EventHandler(this.FrmBSQDuoBianXingStatis_Load); - this.groupBox1.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)(this.chart1)).EndInit(); - this.ResumeLayout(false); - - } - - #endregion - - private System.Windows.Forms.GroupBox groupBox1; - private System.Windows.Forms.DataVisualization.Charting.Chart chart1; - } -} \ No newline at end of file diff --git a/FrmBSQDuoBianXingStatis.cs b/FrmBSQDuoBianXingStatis.cs deleted file mode 100644 index 80b567e..0000000 --- a/FrmBSQDuoBianXingStatis.cs +++ /dev/null @@ -1,179 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Windows.Forms; -using DevComponents.DotNetBar; -using System.Data.SqlClient; -using System.Windows.Forms.DataVisualization.Charting; -using GeoScene.Data; -using GeoScene.Engine; -using GeoScene.Globe; -using System.Data.OracleClient; - -namespace Cyberpipe -{ - public partial class FrmBSQDuoBianXingStatis : Office2007Form - { - Dictionary bsq = new Dictionary(); - Dictionary bsq1 = new Dictionary(); - static FrmBSQDuoBianXingStatis frm; - GSOGlobeControl globeControl1; - List list = new List(); - public static List pipeLists = new List(); - - string[] codeStr = new string[50]; - string[] nameStr = new string[30]; - public static List typeLists; - - public FrmBSQDuoBianXingStatis(Dictionary workWellLen, GSOGlobeControl glb,List _list) - { - InitializeComponent(); - bsq = workWellLen; - globeControl1 = glb; - list = _list; - } - - private void FrmBSQDuoBianXingStatis_Load(object sender, EventArgs e) - { - FrmBSQDuoBianXingStatisFenLei(); - try - { - chart1.Series.Add("标识器"); - chart1.ChartAreas["ChartArea1"].AxisX.Title = "标识器类型"; - chart1.ChartAreas["ChartArea1"].AxisY.Title = "标识器数量"; - chart1.ChartAreas["ChartArea1"].AxisX.Interval = 1; - chart1.Series["标识器"].ChartType = SeriesChartType.Column; - chart1.Series["标识器"]["DrawingStyle"] = "Cylinder"; - - chart1.Series["标识器"].Points.DataBindXY(bsq1.Keys, bsq1.Values); - if (bsq1.Values.Count == 0) - { - MessageBox.Show("该区域没有标识器信息", "提示"); - this.Close(); - return; - } - else - { - for (int m = 0; m < bsq1.Values.Count; m++) - { - if (chart1.Series["标识器"].Points[m].YValues[0].ToString() != "0") - { - chart1.Series["标识器"].Points[m].Label = chart1.Series[0].Points[m].YValues[0].ToString(); - } - } - } - } - catch (Exception ex) - { - //ErrorLog.PublishError(ex); - } - } - - private void FrmBSQDuoBianXingStatis_FormClosing(object sender, FormClosingEventArgs e) - { - frm = null; - globeControl1.Globe.ClearAnalysis(); - globeControl1.Globe.MemoryLayer.RemoveAllFeature(); - } - - - private void FrmBSQDuoBianXingStatisFenLei() - { - try - { - bool flag2 = false; - for (int i = 0; i < Utility.listPipelineType.Count; i++) - { - - for (int j = 0; j < pipeLists.Count; j++) - { - if (pipeLists[j] == Utility.listPipelineType[i].type) - { - flag2 = true; - break; - } - } - if (!flag2 && Utility.listPipelineType[i].type != "标识器") - { - pipeLists.Add(Utility.listPipelineType[i].type); - } - flag2 = false; - } - - typeLists = new List(); - for (int num = 0; num < pipeLists.Count; num++) - { - typeList ls = new typeList(0, pipeLists[num]); - typeLists.Add(ls); - } - - GSOFeatures fs = list[0]; - string pipetype = "标识器"; - foreach (string key in bsq.Keys) - { - if (key.StartsWith(pipetype)) - { - pipetype = key; - break; - } - } - if (fs.Length > 0) - { - for (int i = 0; i < fs.Length; i++) - { - string str = fs[i].GetValue("对象名称").ToString(); - codeStr = str.Split(','); - for (int n = 0; n < codeStr.Length; n++) - { - for (int ii = 0; ii < Utility.listPipelineType.Count; ii++) - { - if (Utility.listPipelineType[ii].code == codeStr[n]) - { - for (int m = 0; m < typeLists.Count; m++) - { - if (Utility.listPipelineType[ii].type == typeLists[m].type) - { - typeLists[m].num++; - break; - } - } - break; - } - } - } - } - } - - for (int i = 0; i < typeLists.Count; i++) - { - if (typeLists[i].num > 0) - bsq1.Add(typeLists[i].type, typeLists[i].num); - } - - } - catch (Exception ex) - { - //ErrorLog.PublishError(ex); - //MessageBox.Show(ex.Message); - } - - } - public class typeList - { - public int num; - public string type; - - public typeList(int _num, string _type) - { - num = _num; - type = _type; - } - } - - - } -} diff --git a/FrmBSQDuoBianXingStatis.resx b/FrmBSQDuoBianXingStatis.resx deleted file mode 100644 index 1af7de1..0000000 --- a/FrmBSQDuoBianXingStatis.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/FrmBSQStatis.Designer.cs b/FrmBSQStatis.Designer.cs index 2509c7d..ee9b1e7 100644 --- a/FrmBSQStatis.Designer.cs +++ b/FrmBSQStatis.Designer.cs @@ -57,6 +57,7 @@ this.ShowIcon = false; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "标识器全区域统计"; + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FrmBSQStatis_FormClosing); this.Load += new System.EventHandler(this.FrmBSQStatis_Load); ((System.ComponentModel.ISupportInitialize)(this.chartStatis)).EndInit(); this.ResumeLayout(false); diff --git a/FrmBSQStatis.cs b/FrmBSQStatis.cs index 4b25eda..e7c4926 100644 --- a/FrmBSQStatis.cs +++ b/FrmBSQStatis.cs @@ -18,94 +18,18 @@ { public partial class FrmBSQStatis : Office2007Form { - public Dictionary bsq = new Dictionary(); - //SqlConnection conn; - public static List typeLists; - OracleConnection conn; - string connectString; + private Dictionary bsq = new Dictionary(); + private GSOGlobeControl globeControl1; + private GSOGeoPolygon3D polygon; - public FrmBSQStatis() + public FrmBSQStatis(GSOGlobeControl globeControl1,GSOGeoPolygon3D polygon) { + this.globeControl1 = globeControl1; + this.polygon = polygon; InitializeComponent(); - BSQNumStatis(); + bsq = getBSQNameAndNumMap(polygon); } - string[] codeStr = new string[50]; - string[] nameStr = new string[30]; - public static List pipeLists = new List(); - - private void BSQNumStatis() - { - bool flag2 = false; - for (int i = 0; i < Utility.listPipelineType.Count; i++) - { - for (int j = 0; j < pipeLists.Count; j++) - { - if (pipeLists[j] == Utility.listPipelineType[i].type) - { - flag2 = true; - break; - } - } - if (!flag2 && Utility.listPipelineType[i].type != "标识器") - { - pipeLists.Add(Utility.listPipelineType[i].type); - } - flag2 = false; - } - - typeLists = new List(); - for (int num = 0; num 0) - bsq.Add(typeLists[i].type, typeLists[i].num); - } - - } - catch (Exception ex) - { - - } - } private void FrmBSQStatis_Load(object sender, EventArgs e) { @@ -136,17 +60,88 @@ } } - public class typeList + private Dictionary getBSQNameAndNumMap(GSOGeoPolygon3D polygon) { - public int num; - public string type; - public typeList(int _num, string _type) + Dictionary result = new Dictionary(); + Dictionary codeAndType = new Dictionary(); + //得到type的种类 + for (int i = 0; i < Utility.listPipelineType.Count; i++) { - num = _num; - type = _type; + if (!result.ContainsKey(Utility.listPipelineType[i].type) && Utility.listPipelineType[i].type != "标识器") + { + result.Add(Utility.listPipelineType[i].type, 0); + codeAndType.Add(Utility.listPipelineType[i].code, Utility.listPipelineType[i].type); + } + } + + return polygon == null ? getAllAreaMap(result, codeAndType) : getBSQMapByPolygon(polygon, result, codeAndType); + } + public Dictionary getAllAreaMap(Dictionary typeAndCount,Dictionary codeAndType) + { + try + { + OracleConnection conn = OledbHelper.sqlConnection(); + conn.Open(); + OracleCommand cmd; + cmd = new OracleCommand("select 对象类型 from 标识器", conn); + OracleDataReader dr = cmd.ExecuteReader(); + + while (dr.Read()) + { + string str = Convert.ToString(dr["对象类型"]); + if (str == null) continue; + foreach (string key in codeAndType.Keys) + { + if (str.Contains(key)) + { + typeAndCount[codeAndType[key]] += 1; + } + } + } + conn.Close(); + } + catch (Exception ex) + { + LogHelper.WriteLog(typeof(FrmBSQStatis),ex.Message.ToString()); + } + return typeAndCount; + } + + + public Dictionary getBSQMapByPolygon(GSOGeoPolygon3D polygon,Dictionary typeAndCount, Dictionary codeAndType) + { + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption("标识器"); + GSOFeatures bsqFs = FeatureStatisticsService.getLayerFeatures(polygon, layer); + if (bsqFs == null || bsqFs.Length <= 0) { + LogHelper.WriteLog(typeof(FrmBSQStatis),"标识器图层下的Feature为空"); + return null; + } + + for (int i = 0; i < bsqFs.Length; i++) + { + string str = bsqFs[i].GetValue("对象类型").ToString(); + + foreach (string key in codeAndType.Keys) + { + if (str.Contains(key)) + { + typeAndCount[codeAndType[key]] += 1; + } + } + } + + return typeAndCount; + } + + private void FrmBSQStatis_FormClosing(object sender, FormClosingEventArgs e) + { + globeControl1.Globe.ClearAnalysis(); + } + + } } diff --git a/FrmValveStatistics.cs b/FrmValveStatistics.cs index 672f97a..17dad6c 100644 --- a/FrmValveStatistics.cs +++ b/FrmValveStatistics.cs @@ -120,6 +120,7 @@ sql += " where 1>2 "; for (int i = 0; i < fs.Length; i++) { + if (fs[i].GetValue("编号") == null) continue; sql += " or 编号 = '" + fs[i].GetValue("编号").ToString() + "'"; } diff --git a/FrmpipeDeepstatis.cs b/FrmpipeDeepstatis.cs index 879801a..c7edbc3 100644 --- a/FrmpipeDeepstatis.cs +++ b/FrmpipeDeepstatis.cs @@ -164,88 +164,6 @@ } } - //if (clbPipeLine.CheckedItems.Count > 0) - //{ - // if (dataGridViewX2.Rows.Count > 0) - // { - // for (int i = 0; i < clbPipeLine.CheckedItems.Count; i++) - // { - // GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(clbPipeLine.CheckedItems[i].ToString()); - // GSOFeatureLayer flayer = layer as GSOFeatureLayer; - // GSOFeatures feats = new GSOFeatures(); - // if (polygon == null) - // feats = flayer.GetAllFeatures(); - // else - // feats = flayer.FindFeaturesInPolygon(polygon, false); - // for (int j = 0; j < dataGridViewX2.Rows.Count; j++) - // { - // double totalLength = 0.00; - // int ncount = 0; - // for (int m = 0; m < feats.Length; m++) - // { - // GSOFeature feat = feats[m]; - // float radius = feat.GetFieldAsFloat("起始埋深"); - // bool upCompare = true; - // bool downCompare = true; - // if (dataGridViewX2.Rows[j].Cells["下限"].Value != null || dataGridViewX2.Rows[j].Cells["上限"].Value != null) - // { - // if (dataGridViewX2.Rows[j].Cells["下限"].Value != null) - // { - // if (dataGridViewX2.Rows[j].Cells["下限"].Value.ToString() != "") - // { - // if (radius >= Convert.ToDouble(dataGridViewX2.Rows[j].Cells["下限"].Value)) - // { - // downCompare = true; - // } - // else - // downCompare = false; - // } - // } - // if (dataGridViewX2.Rows[j].Cells["上限"].Value != null) - // { - // if (dataGridViewX2.Rows[j].Cells["上限"].Value.ToString() != "") - // { - // if (radius <= Convert.ToDouble(dataGridViewX2.Rows[j].Cells["上限"].Value)) - // { - // upCompare = true; - // } - // else - // upCompare = false; - // } - // } - // if (upCompare && downCompare) - // { - // GSOGeoPolyline3D line = feat.Geometry as GSOGeoPolyline3D; - // double length = line.GetSpaceLength(true, 6378137); - // totalLength += length; - // ncount += 1; - // } - // } - // } - // if (dataGridViewX2.Rows[j].Cells["下限"].Value != null || dataGridViewX2.Rows[j].Cells["上限"].Value != null) - // { - // DataGridViewRow row = new DataGridViewRow(); - // int index = dataGridViewX1.Rows.Add(row); - // row = dataGridViewX1.Rows[index]; - // row.Cells["图层名称"].Value = layer.Caption; - // row.Cells["埋深范围"].Value = dataGridViewX2.Rows[j].Cells["下限"].Value + "-" + dataGridViewX2.Rows[j].Cells["上限"].Value; - // row.Cells["条数"].Value = ncount; - // row.Cells["总长度"].Value =Math.Round(totalLength,2); - - // dic.Add(layer.Caption + "," + row.Cells["埋深范围"].Value.ToString()+","+row.Cells["总长度"].Value.ToString(), ncount); - // } - // } - // } - // } - // else - // { - // MessageBox.Show("请添加分段!"); - // } - //} - //else - //{ - // MessageBox.Show("请选择图层!"); - //} showPipeWidget(); } catch (Exception ex) diff --git a/FrmpipeMaterialGather.cs b/FrmpipeMaterialGather.cs index b7ab1d2..3e9f45d 100644 --- a/FrmpipeMaterialGather.cs +++ b/FrmpipeMaterialGather.cs @@ -180,79 +180,6 @@ } - //if (clbPipeLine.CheckedItems.Count > 0) - //{ - // for (int i = 0; i < clbPipeLine.CheckedItems.Count; i++) - // { - // GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(clbPipeLine.CheckedItems[i].ToString()); - // GSOFeatureLayer flayer = layer as GSOFeatureLayer; - // GSOFeatures feats = new GSOFeatures(); - // if (polygon == null) - // feats = flayer.GetAllFeatures(); - // else - // feats = flayer.FindFeaturesInPolygon(polygon, false); - // List lstDiameter = new List(); - - // for (int j = 0; j < clbmaterials.CheckedItems.Count; j++) - // { - // if (!lstDiameter.Contains(clbmaterials.CheckedItems[j].ToString())) - // { - // lstDiameter.Add(clbmaterials.CheckedItems[j].ToString()); - // } - // } - // //lstDiameter.Sort(); - // if (lstDiameter.Count > 0) - // { - // for (int m = 0; m < lstDiameter.Count; m++) - // { - // double totalLength = 0.00; - // int ncount = 0; - // for (int j = 0; j < feats.Length; j++) - // { - // if (lstDiameter[m] != "无") - // { - // if (feats[j].GetFieldAsString("材质") == lstDiameter[m]) - // { - // GSOGeoPolyline3D line = feats[j].Geometry as GSOGeoPolyline3D; - // if (line != null) - // { - // double length = line.GetSpaceLength(true, 6378137); - // totalLength += length; - // ncount += 1; - // } - // } - // } - // else - // { - // if (feats[j].GetFieldAsString("材质") == "") - // { - // GSOGeoPolyline3D line = feats[j].Geometry as GSOGeoPolyline3D; - // if (line != null) - // { - // double length = line.GetSpaceLength(true, 6378137); - // totalLength += length; - // ncount += 1; - // } - // } - // } - // } - // DataGridViewRow row = new DataGridViewRow(); - // int index = dataGridViewX1.Rows.Add(row); - // row = dataGridViewX1.Rows[index]; - // row.Cells["图层名称"].Value = layer.Caption; - // row.Cells["材质"].Value = lstDiameter[m]; - // row.Cells["条数"].Value = ncount; - // row.Cells["总长度"].Value = Math.Round(totalLength); - - // dic.Add(layer.Caption + "," + row.Cells["材质"].Value.ToString(), ncount); - // } - // } - // } - //} - //else - //{ - // MessageBox.Show("请选择图层!"); - //} showPipeWidget(); } catch (Exception ex) diff --git a/Frmpipediameterstatis.cs b/Frmpipediameterstatis.cs index 9953ac0..aa482d8 100644 --- a/Frmpipediameterstatis.cs +++ b/Frmpipediameterstatis.cs @@ -27,12 +27,9 @@ frm = new Frmpipediameterstatis(_globeControl1, pipeLayers, visibleId); frm.Show(_globeControl1.Parent); } - else + else if (frm.WindowState == FormWindowState.Minimized) { - if (frm.WindowState == FormWindowState.Minimized) - { - frm.WindowState = FormWindowState.Normal; - } + frm.WindowState = FormWindowState.Normal; } } @@ -208,7 +205,8 @@ } catch (Exception ex) { - MessageBox.Show(ex.Message); + LogHelper.WriteLog(typeof(Frmpipediameterstatis), ex.Message); + //MessageBox.Show(ex.Message); LogError.PublishError(ex); } } @@ -290,76 +288,77 @@ /// private void btnExport_Click(object sender, EventArgs e) { - if (dataGridViewX1.Rows.Count > 0) + if (dataGridViewX1.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 = DateTime.Now.ToString("yyyyMMdd") + ".xls"; - if (dlg.ShowDialog() == DialogResult.OK) + MessageBox.Show("统计结果为空,请重新统计之后再导出Excel!", "提示"); + return; + } + + SaveFileDialog dlg = new SaveFileDialog(); + dlg.Filter = "Excel files (*.xls)|*.xls"; + dlg.FilterIndex = 0; + dlg.RestoreDirectory = true; + //dlg.CreatePrompt = true; + dlg.Title = "保存为Excel文件"; + dlg.FileName = 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 { - Stream myStream; - myStream = dlg.OpenFile(); - StreamWriter sw = new StreamWriter(myStream, System.Text.Encoding.GetEncoding(-0)); - string columnTitle = ""; - try + sw.WriteLine("日期:" + DateTime.Now.ToString("yyyy-MM-dd")); + + //写入列标题 + for (int i = 0; i < dataGridViewX1.ColumnCount; i++) { - sw.WriteLine("日期:" + DateTime.Now.ToString("yyyy-MM-dd")); - - //写入列标题 - for (int i = 0; i < dataGridViewX1.ColumnCount; i++) + if (i > 0) { - if (i > 0) - { - columnTitle += "\t"; - } - columnTitle += dataGridViewX1.Columns[i].HeaderText; + columnTitle += "\t"; } - sw.WriteLine(columnTitle); - - //写入列内容 - for (int j = 0; j < dataGridViewX1.Rows.Count; j++) - { - string columnValue = ""; - for (int k = 0; k < dataGridViewX1.Columns.Count; k++) - { - if (k > 0) - { - columnValue += "\t"; - } - if (dataGridViewX1.Rows[j].Cells[k].Value == null) - columnValue += ""; - else - columnValue += dataGridViewX1.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); - } + columnTitle += dataGridViewX1.Columns[i].HeaderText; } - catch (Exception ex) + sw.WriteLine(columnTitle); + + //写入列内容 + for (int j = 0; j < dataGridViewX1.Rows.Count; j++) { - MessageBox.Show(ex.ToString()); + string columnValue = ""; + for (int k = 0; k < dataGridViewX1.Columns.Count; k++) + { + if (k > 0) + { + columnValue += "\t"; + } + if (dataGridViewX1.Rows[j].Cells[k].Value == null) + columnValue += ""; + else + columnValue += dataGridViewX1.Rows[j].Cells[k].Value.ToString().Trim(); + } + + sw.WriteLine(columnValue); } - finally + sw.Close(); + myStream.Close(); + if (MessageBox.Show("导出Excel文件成功!是否打开?", "提示", MessageBoxButtons.YesNo) == DialogResult.Yes) { - sw.Close(); - myStream.Close(); + System.Diagnostics.Process.Start(dlg.FileName); } } + catch (Exception ex) + { + MessageBox.Show(ex.ToString()); + } + finally + { + sw.Close(); + myStream.Close(); + } } - else - { - MessageBox.Show("统计结果为空,请重新统计之后再导出Excel!","提示"); - } + + } /// /// 绘制区域分段统计 diff --git a/MainFrm.cs b/MainFrm.cs index 0b7e393..9bfb70e 100644 --- a/MainFrm.cs +++ b/MainFrm.cs @@ -2667,12 +2667,195 @@ FrmBaseLineProfillAnalysis dlg = new FrmBaseLineProfillAnalysis(globeControl1.Globe, e.Polyline); dlg.Show(this); globeControl1.Globe.ClearLastTrackPolyline(); + /* + FrmRoadHDM f = new FrmRoadHDM(); + f.Show() + * **/ } else { } trackPolylineEndMode = EnumTrackPolylineEndMode.Default_Analysis; + /* + ArrayList arraylistPoint = new ArrayList(); + ArrayList arraylistLine = new ArrayList(); + + // globeControl1.Globe.ClearLastTrackPolyline(); + + if (e.Polyline != null) + { + //横断面分析 + if (buttonItemFX2_1.Checked || buttonItemFX2_3.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 (buttonItemFX2_1.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 (buttonItemFX2_4.Checked) + { + FrmBaseLineProfillAnalysis dlg = new FrmBaseLineProfillAnalysis(globeControl1.Globe, e.Polyline); + dlg.Show(this); + globeControl1.Globe.ClearLastTrackPolyline(); + } + else if (buttonItemFX4_3.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(); + * **/ } #endregion @@ -2713,16 +2896,20 @@ case "valvequery": FrmValveStatistics frm = new FrmValveStatistics(globeControl1,polygon, new DataGridViewDelegate(InitDataGridViewX1)); frm.Show(this); + //panelEx6.Visible = true; + toolStripFeatureLength.Text = ""; globeControl1.Globe.Action = EnumAction3D.ActionNull; break; case "PipelineDistanceStatistics": + FrmAllPipelineStatis frm1 = new FrmAllPipelineStatis(globeControl1, polygon, new DataGridViewDelegate(InitDataGridViewX1), m_PipelineLayerNames); frm1.Show(this); globeControl1.Globe.Action = EnumAction3D.ActionNull; break; case "PipelineSpatialQuery": + FrmAllPipelineStatis.ShowForm(globeControl1,polygon,new DataGridViewDelegate(InitDataGridViewX1),m_PipelineLayerNames); globeControl1.Globe.ClearAnalysis(); globeControl1.Globe.Action = EnumAction3D.ActionNull; @@ -2771,18 +2958,19 @@ break; case "BSQDuoBianXiangStatis": - GSOFeature f2 = new GSOFeature(); - f2.Geometry = e.Polygon; - f2.Geometry.AltitudeMode = EnumAltitudeMode.Absolute; - globeControl1.Globe.MemoryLayer.AddFeature(f2); - f2.Geometry.MoveZ(3); - workWellLen.Clear(); - List listBSQ = new List(); + //GSOFeature f2 = new GSOFeature(); + //f2.Geometry = e.Polygon; + //f2.Geometry.AltitudeMode = EnumAltitudeMode.Absolute; + //globeControl1.Globe.MemoryLayer.AddFeature(f2); + //f2.Geometry.MoveZ(3); + //workWellLen.Clear(); + //List listBSQ = new List(); - GSOFeatures bsqFeatures = PolygonIntersectAnalysis(e.Polygon, "标识器"); - listBSQ.Add(bsqFeatures); + //GSOFeatures bsqFeatures = PolygonIntersectAnalysis(e.Polygon, "标识器"); + //listBSQ.Add(bsqFeatures); - FrmBSQDuoBianXingStatis bsqFrm = new FrmBSQDuoBianXingStatis(workWellLen, globeControl1, listBSQ); + //FrmBSQDuoBianXingStatis bsqFrm = new FrmBSQDuoBianXingStatis(workWellLen, globeControl1, listBSQ); + FrmBSQStatis bsqFrm = new FrmBSQStatis(globeControl1,e.Polygon); bsqFrm.Show(this); globeControl1.Globe.Action = EnumAction3D.ActionNull; break; @@ -4351,6 +4539,26 @@ } /// + /// 在窗体的底部状态栏上显示 综合管线条件查询结果 + /// + /// + /// + 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 + " 条记录 | "; + } + } + + /// /// 统计管线的里程数 /// /// @@ -6824,6 +7032,54 @@ } /// + /// 创建label要素 功能 + /// + /// 添加label要素的feature + /// feature的位置 + /// label要素名字 + /// feature名字 + /// label要素距离点的位置 + /// + 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; + } + + + + /// /// 获取指定两点组成的线的长度 功能 /// /// @@ -9266,8 +9522,19 @@ //日志记录 LogManager.saveLog(Utility.userName, "管线长度统计"); + //pipeLineDis.Clear(); + //List list = new List(); + //for (int i = 0; i < m_PipelineLayerNames.Count; i++) + //{ + // GSOFeatures fs = Intersects_Pipeline(null, m_PipelineLayerNames[i]); + // if (fs!=null) + // list.Add(fs); + //} + + //FrmAllPipelineStatis frm = new FrmAllPipelineStatis(0, pipeLineDis, list, globeControl1, new DataGridViewDelegate(InitDataGridViewX1)); FrmAllPipelineStatis frm = new FrmAllPipelineStatis(globeControl1,null, new DataGridViewDelegate(InitDataGridViewX1), m_PipelineLayerNames); frm.Show(this); + } /// /// 管线长度绘制区域统计 @@ -9293,6 +9560,25 @@ //日志记录 LogManager.saveLog(Utility.userName, "阀门数量统计"); + //workWellLen.Clear(); + //List list = new List(); + ////找到所有阀门 + //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, globeControl1, new DataGridViewDelegate(InitDataGridViewX1)); FrmValveStatistics frm = new FrmValveStatistics(globeControl1, null, new DataGridViewDelegate(InitDataGridViewX1)); frm.Show(this); @@ -9318,9 +9604,7 @@ /// /// private void buttonItemTJ3_ALL_Click(object sender, EventArgs e) - { - //日志记录 - LogManager.saveLog(Utility.userName, "井盖数量统计"); + { FrmAllWorkWellStatis frm = new FrmAllWorkWellStatis(globeControl1, null, new DataGridViewDelegate(InitDataGridViewX1)); frm.Show(this); } @@ -9333,7 +9617,7 @@ { //日志记录 LogManager.saveLog(Utility.userName, "井盖数量统计"); - + trackflag = "workwellquery"; globeControl1.Globe.Action = EnumAction3D.TrackPolygon; globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; @@ -11142,7 +11426,7 @@ Cyberpipe.Forms.FrmPipelineModelDB frm = new Cyberpipe.Forms.FrmPipelineModelDB(globeControl1, ds); if (frm.ShowDialog() == DialogResult.OK) { - //addNodeToLayerManagerNode(frm.rukuLayer); + addNodeToLayerManagerNode(frm.rukuLayer); } } /// @@ -12377,7 +12661,8 @@ private void 标识器分类统计ToolStripMenuItem_Click(object sender, EventArgs e) { globeControl1.Globe.Action = EnumAction3D.ActionNull; - FrmBSQStatis bsqStatis = new FrmBSQStatis(); + FrmBSQStatis bsqStatis = new FrmBSQStatis(globeControl1,null); + //FrmBSQStatis bsqStatis = new FrmBSQStatis(); bsqStatis.Show(this); } /// diff --git a/MainFrm.cs.BACKUP.9016.cs b/MainFrm.cs.BACKUP.9016.cs new file mode 100644 index 0000000..28cb7fa --- /dev/null +++ b/MainFrm.cs.BACKUP.9016.cs @@ -0,0 +1,13074 @@ +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; + + GSOBalloon featureTooltip2; + GSOBalloonEx balloonEx2; + + GSOLayer layerTemp; + GSOLayer layerTemp2; + FrmShResult frmShResult = null; + FrmRedlineResult frmredResult = null; + FrmMnModify frmModify = null; + public bool frmRedlineResult = false; + public bool boolfrmShResult = false; + public bool boolfrmModify = false; + + List m_PipelineLayerNames = new List();//线图层名称 + List workwellLayerNames = new List();//工井图层名称 + List valueLayerNames = new List();//阀门图层名称 + List instrumenLayerNames = new List();//附属物图层名称 + List pipefittingLayerNames = new List();//管件图层名称 + List sgPipeLayersNames = new List();//施工管线图层名称 + 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 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; + public string redLayer = null; + //GSOLayer redLayer1 = null; + bool redSH = false; + string redDt = "红线"; + //双屏对比 + //bool zhanshi=false; + Thread t = null; + private GSOHudButton legendSC;//定义图例 + private GSOHudButton legendSG;//定义图例 + //管纵图 + private GSOHudButton lendendGZ50; + private GSOHudButton lendendGZ36; + private GSOHudButton lendendGZ42; + private GSOHudButton lendendGZ24_1; + private GSOHudButton lendendGZ24_2; + private GSOHudButton lendendGZ24_3; + private GSOHudButton lendendGZ26; + + GSOGeoPoint3D bsqPT; + + FrmYJSHTC frmSh = null;//一键审核窗口全局变量wxl + FrmWait frmWait = null;//一键审核等待窗口 + //FrmWait frmWait2 = null;//文档操作等待窗口 + + float mouseDownX1,mouseDownY1; + float mouseDownX2,mouseDownY2; + /// + /// + /// + 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; + + featureTooltip2 = new GSOBalloon(globeControl2.Handle); + balloonEx2 = new GSOBalloonEx(globeControl2.Handle); + Utility.SetBallons(featureTooltip, balloonEx); + + panelOfTable.Height = 200; + + RigthMenuSet(); + + MenuSet(); + + } + /// + /// 右屏中添加管纵图片 + /// + private void AddGZ() + { + + lendendGZ50 = new GSOHudButton(); + lendendGZ50.SetImage(Application.StartupPath + "/Resource/管纵/50.png"); + lendendGZ50.SetOffset(0, 0); + lendendGZ50.MinOpaque = 1; + lendendGZ50.MaxOpaque = 1; + lendendGZ50.FadeOut = false; + lendendGZ50.Name = "lendendGZ50"; + lendendGZ50.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ50); + lendendGZ50.Visible = false; + + lendendGZ36 = new GSOHudButton(); + lendendGZ36.SetImage(Application.StartupPath + "/Resource/管纵/36.png"); + lendendGZ36.SetOffset(0, 0); + lendendGZ36.MinOpaque = 1; + lendendGZ36.MaxOpaque = 1; + lendendGZ36.FadeOut = false; + lendendGZ36.Name = "lendendGZ36"; + lendendGZ36.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ36); + lendendGZ36.Visible = false; + + lendendGZ42 = new GSOHudButton(); + lendendGZ42.SetImage(Application.StartupPath + "/Resource/管纵/42.png"); + lendendGZ42.SetOffset(0, 0); + lendendGZ42.MinOpaque = 1; + lendendGZ42.MaxOpaque = 1; + lendendGZ42.FadeOut = false; + lendendGZ42.Name = "lendendGZ42"; + lendendGZ42.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ42); + lendendGZ42.Visible = false; + + lendendGZ24_1 = new GSOHudButton(); + lendendGZ24_1.SetImage(Application.StartupPath + "/Resource/管纵/24_1.png"); + lendendGZ24_1.SetOffset(0, 0); + lendendGZ24_1.MinOpaque = 1; + lendendGZ24_1.MaxOpaque = 1; + lendendGZ24_1.FadeOut = false; + lendendGZ24_1.Name = "lendendGZ24_1"; + lendendGZ24_1.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ24_1); + lendendGZ24_1.Visible = false; + + lendendGZ24_2 = new GSOHudButton(); + lendendGZ24_2.SetImage(Application.StartupPath + "/Resource/管纵/24_2.png"); + lendendGZ24_2.SetOffset(0, 0); + lendendGZ24_2.MinOpaque = 1; + lendendGZ24_2.MaxOpaque = 1; + lendendGZ24_2.FadeOut = false; + lendendGZ24_2.Name = "lendendGZ24_2"; + lendendGZ24_2.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ24_2); + lendendGZ24_2.Visible = false; + + lendendGZ24_3 = new GSOHudButton(); + lendendGZ24_3.SetImage(Application.StartupPath + "/Resource/管纵/24_3.png"); + lendendGZ24_3.SetOffset(0, 0); + lendendGZ24_3.MinOpaque = 1; + lendendGZ24_3.MaxOpaque = 1; + lendendGZ24_3.FadeOut = false; + lendendGZ24_3.Name = "lendendGZ24_3"; + lendendGZ24_3.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ24_3); + lendendGZ24_3.Visible = false; + + lendendGZ26 = new GSOHudButton(); + lendendGZ26.SetImage(Application.StartupPath + "/Resource/管纵/26.png"); + lendendGZ26.SetOffset(0, 0); + lendendGZ26.MinOpaque = 1; + lendendGZ26.MaxOpaque = 1; + lendendGZ26.FadeOut = false; + lendendGZ26.Name = "lendendGZ26"; + lendendGZ26.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ26); + lendendGZ26.Visible = false; + + } + + public void RigthMenuSet() + { + if (Utility.userRole.IndexOf("清除分析") < 0) + { + toolRightMenu.Items.Remove(清除分析ToolStripMenuItem); + } + + #region 区域分析 + if (Utility.userRole.IndexOf("区域分析") < 0) + { + toolRightMenu.Items.Remove(区域分析ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("缓冲区分析") < 0) + { + 区域分析ToolStripMenuItem.DropDownItems.Remove(缓冲区分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("附属物分析") < 0) + { + 区域分析ToolStripMenuItem.DropDownItems.Remove(附属物分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("无源淹没分析") < 0) + { + 区域分析ToolStripMenuItem.DropDownItems.Remove(无源淹没分析ToolStripMenuItem); + } + } + #endregion + + #region 视域分析 + if (Utility.userRole.IndexOf("视域分析") < 0) + { + toolRightMenu.Items.Remove(视域分析ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("通视分析") < 0) + { + 视域分析ToolStripMenuItem.DropDownItems.Remove(通视分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("可视域分析") < 0) + { + 视域分析ToolStripMenuItem.DropDownItems.Remove(可视域分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("可视包络分析") < 0) + { + 视域分析ToolStripMenuItem.DropDownItems.Remove(可视包络分析ToolStripMenuItem); + } + } + #endregion + + #region 开发分析 + if (Utility.userRole.IndexOf("开挖分析") < 0) + { + toolRightMenu.Items.Remove(开挖分析ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("多边形开挖") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(多边形开挖ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("挖方量分析") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(挖方量分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("沿线开挖") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(沿线开挖ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("创建隧道") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(创建隧道ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("隐藏隧道") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(隐藏隧道ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("删除隧道") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(删除隧道ToolStripMenuItem); + } + } + #endregion + + #region 拓扑分析 + if (Utility.userRole.IndexOf("拓扑分析") < 0) + { + toolRightMenu.Items.Remove(拓扑分析ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("创建拓扑") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(创建拓扑ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("上游分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(上游分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("下游分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(下游分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("流向分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(流向分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("关阀分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(关阀分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("连通分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(连通分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("爆管分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(爆管分析ToolStripMenuItem); + } + } + #endregion + + #region 断面分析 + if (Utility.userRole.IndexOf("断面分析") < 0) + { + toolRightMenu.Items.Remove(断面分析ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("横断面分析") < 0) + { + 断面分析ToolStripMenuItem.DropDownItems.Remove(横断面分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("纵断面分析") < 0) + { + 断面分析ToolStripMenuItem.DropDownItems.Remove(纵断面分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("道路断面分析") < 0) + { + 断面分析ToolStripMenuItem.DropDownItems.Remove(道路断面分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("基线剖面分析") < 0) + { + 断面分析ToolStripMenuItem.DropDownItems.Remove(基线剖面分析ToolStripMenuItem); + } + } + #endregion + + #region 绘制区域统计 + if (Utility.userRole.IndexOf("绘制区域统计") < 0) + { + toolRightMenu.Items.Remove(绘制区域统计ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("绘制区域管线长度统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管线长度统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域阀门数量统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(阀门数量统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域井盖数量统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(井盖数量统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域管径分段统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管径分段统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域埋深分段统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(埋深分段统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域管径分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管径分类统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域材质分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(材质分类统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域附属物分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(附属物分类统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域标识器分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(标识器分类统计ToolStripMenuItem1); + } + + } + #endregion + + #region 全区域统计 + if (Utility.userRole.IndexOf("全区域统计") < 0) + { + toolRightMenu.Items.Remove(全区域统计ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("全区域管线长度统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管线长度统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域阀门数量统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(阀门数量统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域井盖数量统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(井盖数量统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域管径分段统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管径分段统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域埋深分段统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(埋深分段统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域管径分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管径分类统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域材质分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(材质分类统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域附属物分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(附属物分类统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域标识器分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(标识器分类统计ToolStripMenuItem); + } + + } + #endregion + + #region 查询 + if (Utility.userRole.IndexOf("查询") < 0) + { + toolRightMenu.Items.Remove(查询ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("空间查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(空间查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("编号查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(编号查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("坐标查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(坐标查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("管径查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(管径查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("材质查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(材质查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("基本查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(基本查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("复合查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(复合查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("关联查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(关联查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("关键字查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(关键字查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("附属物查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(附属物查询ToolStripMenuItem); + } + } + #endregion + + #region 标注 + if (Utility.userRole.IndexOf("标注") < 0) + { + toolRightMenu.Items.Remove(标注ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("标高标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(标高标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("管径标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(管径标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("埋深标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(埋深标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("坐标标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(坐标标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("距离标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(距离标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("自定义标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(自定义标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("扯旗标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(扯旗标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("坡度标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(坡度标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("属性标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(属性标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("标注管理") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(标注管理ToolStripMenuItem); + } + } + #endregion + + #region 飞行 + if (Utility.userRole.IndexOf("飞行") < 0) + { + toolRightMenu.Items.Remove(飞行ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("自定义飞行") < 0) + { + 飞行ToolStripMenuItem.DropDownItems.Remove(自定义飞行ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("飞行到目标点") < 0) + { + 飞行ToolStripMenuItem.DropDownItems.Remove(飞行到目标点ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("绕中心点飞行") < 0) + { + 飞行ToolStripMenuItem.DropDownItems.Remove(绕中心点飞行ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("绕眼睛飞行") < 0) + { + 飞行ToolStripMenuItem.DropDownItems.Remove(绕眼睛飞行ToolStripMenuItem); + } + } + #endregion + + #region 编辑 + if (Utility.userRole.IndexOf("编辑") < 0) + { + toolRightMenu.Items.Remove(编辑ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("平移对象") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(平移对象ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("升降对象") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(升降对象ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("旋转对象") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(旋转对象ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("连接管段") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(连接管段ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("导出文件") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(导出文件ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("前进") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(前进ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("后退") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(删除模型ToolStripMenuItem); + } + } + #endregion + + #region 量算 + if (Utility.userRole.IndexOf("量算") < 0) + { + toolRightMenu.Items.Remove(量算ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("水平距离") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(水平距离ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("垂直距离") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(垂直距离ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("空间距离") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(空间距离ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("地表距离") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(地表距离ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("高度量算") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(高度量算ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("水平面积") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(水平面积ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("地表面积") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(地表面积ToolStripMenuItem1); + } + } + #endregion + } + + public void MenuSet() + { + + #region 权限管理 + if (Utility.userRole.IndexOf("权限管理") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem2); + } + else + { + + if (Utility.userRole.IndexOf("用户管理") < 0) + { + btn_user_info.Visible = false; + } + if (Utility.userRole.IndexOf("角色管理") < 0) + { + btn_role_info.Visible = false; + } + if (Utility.userRole.IndexOf("资源管理") < 0) + { + btn_resc_info.Visible = false; + } + if (Utility.userRole.IndexOf("角色授权") < 0) + { + btn_role_resc.Visible = false; + } + if (Utility.userRole.IndexOf("用户授权") < 0) + { + btn_user_role.Visible = false; + } + if (Utility.userRole.IndexOf("密码修改") < 0) + { + btn_password_edit.Visible = false; + } + + } + #endregion + + #region 基础工具 + if (Utility.userRole.IndexOf("基础工具") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem1); + } + else + { + if (Utility.userRole.IndexOf("地上模式") < 0) + { + buttonItem87.Visible = false; + } + if (Utility.userRole.IndexOf("地下模式") < 0) + { + buttonItem88.Visible = false; + } + if (Utility.userRole.IndexOf("行走模式") < 0) + { + buttonItem27.Visible = false; + } + if (Utility.userRole.IndexOf("透明度设置") < 0) + { + sliderGroundTransSet1.Visible = false; + } + if (Utility.userRole.IndexOf("快速定位") < 0) + { + buttonItem91.Visible = false; + } + if (Utility.userRole.IndexOf("图层管理") < 0) + { + buttonItem1.Visible = false; + } + if (Utility.userRole.IndexOf("图例管理") < 0) + { + btnlegendSet.Visible = false; + } + if (Utility.userRole.IndexOf("全屏显示") < 0) + { + buttonItem89.Visible = false; + } + if (Utility.userRole.IndexOf("导出图片") < 0) + { + btnOutputJPG.Visible = false; + } + + } + #endregion + + #region 一键审核 + if (Utility.userRole.IndexOf("一键审核") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem11); + } + #endregion + + #region 红线审核 + if (Utility.userRole.IndexOf("红线审核") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem6); + } + #endregion + + #region 双屏对比 + if (Utility.userRole.IndexOf("双屏对比") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem9); + } + #endregion + + #region 文档管理 + if (Utility.userRole.IndexOf("文档管理") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem4); + } + #endregion + + #region 基础管理 + if (Utility.userRole.IndexOf("基础管理") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem14); + } + else + { + if (Utility.userRole.IndexOf("专题图审批") < 0) + { + buttonItemZTT3_2.Visible = false; + } + if (Utility.userRole.IndexOf("打印审批") < 0) + { + buttonItemZTT4_2.Visible = false; + } + if (Utility.userRole.IndexOf("拷贝审批") < 0) + { + buttonItemZTT5_2.Visible = false; + } + } + + #endregion + + if (ribbonControl1.Items.Count <= 0) + { + ribbonControl1.Visible = false; + } + } + + #region Fan Zhang 重构现有代码 + //初始化控件布局 + private void initLayout() + { + 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.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.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.labelX21.Width = (int)(this.labelX21.Width * myScreen); + this.labelX22.Width = (int)(this.labelX22.Width * myScreen); + this.labelX24.Width = (int)(this.labelX24.Width * myScreen); + } + sideBar1.Visible = false; + 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]); + } + + splitContainer1.Panel2Collapsed = true; + + buttonItem87.Checked = true;//默认地上模式 + ribbonTabItem1.Select(); //初始化状态为浏览 + + sideBarPanelItem3.Visible = false; + layerTree.Visible = false; + controlContainerItem3.Visible = false; + if (sideBarPanelItem4.Visible == true) + { + sideBar1.Visible = true; + controlContainerItem5.Visible = true; + } + else + { + sideBar1.Visible = false; + } + Refresh(); + sliderGroundTransSet1.Value = optiValue; + sliderItem1.Value = optiValue; + sliderItem2.Value = optiValue; + sliderItem3.Value = optiValue; + + } + + //初始化地球控件 + private void initGlobalControl() + { + //选择 + btnToolSelect = new GSOHudButton(); + btnToolSelect.SetImage(Application.StartupPath + "\\Resource\\image\\select1.png"); + btnToolSelect.FadeOut = false; + btnToolSelect.Align = EnumAlign.TopLeft; + btnToolSelect.SetOffset(20, 50); + btnToolSelect.Name = "1"; + btnToolSelect.HeightFixed = true; + btnToolSelect.WidthFixed = true; + globeControl1.Globe.AddHudControl(btnToolSelect); + globeControl2.Globe.AddHudControl(btnToolSelect); + + //浏览 + 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); + + //图例 + legend = new GSOHudButton(); + legend.SetImage(Application.StartupPath + "/Resource/图例P.jpg");//图例P + legend.SetOffset(0, 15); + legend.MinOpaque = 1; + legend.MaxOpaque = 1; + legend.FadeOut = false; + legend.Name = "legend"; + legend.Align = EnumAlign.BottomRight; + legend.Visible = false; + globeControl1.Globe.AddHudControl(legend); + + //实测 + legendSC = new GSOHudButton(); + legendSC.SetImage(Application.StartupPath + "/Resource/sc.jpg"); + legendSC.SetOffset(0, 15); + legendSC.MinOpaque = 1; + legendSC.MaxOpaque = 1; + legendSC.FadeOut = false; + legendSC.Name = "legendSC"; + legendSC.Align = EnumAlign.BottomRight; + globeControl1.Globe.AddHudControl(legendSC); + legendSC.Visible = false; + + //施工 + legendSG = new GSOHudButton(); + legendSG.SetImage(Application.StartupPath + "/Resource/sg.jpg"); + legendSG.SetOffset(0, 15); + legendSG.MinOpaque = 1; + legendSG.MaxOpaque = 1; + legendSG.FadeOut = false; + legendSG.Name = "legendSG"; + legendSG.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(legendSG); + legendSG.Visible = false; + + //管纵 + AddGZ(); + + 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; + globeControl1.Globe.IsReleaseMemOutOfView = true; + globeControl1.Globe.ControlPanel.Visible = true; + + globeControl2.Globe.UnderGroundFloor.Visible = false; + globeControl2.Globe.OverviewControl.Visible = false; + globeControl2.Globe.ScalerControl.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; + globeControl2.Globe.IsReleaseMemOutOfView = true; + globeControl2.Globe.ControlPanel.Visible = false; + + 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); + + //添加临时图层 + layerTemp = globeControl1.Globe.Layers.Add(Application.StartupPath + "\\tempLgdData.lgd"); + layerTemp2 = globeControl2.Globe.Layers.Add(Application.StartupPath + "\\tempLgdData2.lgd"); + if (layerTemp != null) + { + layerTemp.MaxVisibleAltitude = 1000; + } + + //添加城市7线图层 + 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"); + + //注册对应事件 + this.registerEvent(); + } + + //注册地球事件 + private bool registerEvent() + { + if (globeControl1 == null || globeControl2 == null) + { + return false; + } + 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); + + globeControl2.FeatureMouseClickEvent += new FeatureMouseClickEventHandler(globeControl2_FeatureMouseClickEvent); + globeControl2.CameraBeginMoveEvent += new CameraBeginMoveEventHandler(globeControl2_CameraBeginMoveEvent); + + globeControl1.MouseDoubleClick += new MouseEventHandler(globeControl1_MouseDoubleClick); + globeControl1.MouseClick += new MouseEventHandler(globeControl1_MouseClick); + globeControl1.MouseDown += new MouseEventHandler(globeControl1_MouseDown); + + globeControl2.MouseClick += new MouseEventHandler(globeControl2_MouseClick); + globeControl2.MouseDown += new MouseEventHandler(globeControl2_MouseDown); + + 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); + + return true; + } + + //加载两个地球数据 + private void loadData() + { + Thread t1 = new Thread(new ThreadStart(doLoadDataForGlobalControl1)); + t1.IsBackground = true; + t1.Start(); + + + } + + delegate void LoadDataForGlobalControl(); + + private void connectServer() + { + globeControl1.Globe.ConnectServer(Utility.serverip, Utility.serverport, "", ""); //加载locaServer中的数据 + globeControl2.Globe.ConnectServer(Utility.serverip, Utility.serverport, "", ""); //加载locaServer中的数据 + //初始化TreeView + // 勾选实测图层 + foreach (TreeNode tn in layerTree.Nodes) + { + if (tn.Nodes.Count > 0) + { + if (tn.Text == "实测数据") + { + tn.Checked = true; + foreach (TreeNode tnChild in tn.Nodes) + { + tnChild.Checked = true; + foreach (TreeNode tnGrandChild in tnChild.Nodes) + { + tnGrandChild.Checked = true; + } + } + } + } + } + } + + private void doLoadDataForGlobalControl1() + { + try + { + + globeControl1.Globe.Layers.MoveDown(10000); + //加载实测管线数据 + Utility.dataSource = globeControl1.Globe.DataManager.OpenOracleDataSource(Utility.DBServer.Trim() + "/" + Utility.dbdatabase.Trim(), "", "", Utility.userID, Utility.DBPassword); + + if (Utility.dataSource != null) + { + for (int j = 0; j < Utility.dataSource.DatasetCount; j++) + { + GSODataset dataset = Utility.dataSource.GetDatasetAt(j); + if (dataset != null && dictionaryNetLayerNameAndCaption.ContainsKey(dataset.Caption)) + { + dataset.Caption = dataset.Name; + globeControl1.Globe.Layers.Add(dataset); + } + } + } + //隐藏红线图层 + globeControl1.Globe.Layers.GetLayerByCaption("红线").Visible = false; + + //globleControl1中加载规划数据 + GSODataSource ghDS = globeControl1.Globe.DataManager.OpenOracleDataSource(Utility.ghdbip + "/" + Utility.ghdbname, "", "", Utility.ghdbuser, Utility.ghdbpwd); + if (ghDS != null) + { + for (int j = 0; j < ghDS.DatasetCount; j++) + { + GSODataset dataset = ghDS.GetDatasetAt(j); + if (dataset != null && dictionaryNetLayerNameAndCaption.ContainsKey(dataset.Caption)) + { + dataset.Caption = dataset.Name; + globeControl1.Globe.Layers.Add(dataset); + globeControl1.Globe.Layers[0].Visible = false; + } + } + } + + //globeControl1,globeControl2中加载施工数据 + GSODataSource sgDS = globeControl1.Globe.DataManager.OpenOracleDataSource(Utility.sgdbip + "/" + Utility.sgdbname, "", "", Utility.sgdbuser, Utility.sgdbpwd); + if (sgDS != null) + { + for (int m = 0; m < sgDS.DatasetCount; m++) + { + GSODataset dataset = sgDS.GetDatasetAt(m); + if (dataset != null && !dataset.Caption.Contains("SH") && dictionaryNetLayerNameAndCaption.ContainsKey(dataset.Caption)) + { + dataset.Caption = dataset.Name; + globeControl1.Globe.Layers.Add(dataset); + globeControl1.Globe.Layers[0].Visible = false; + + globeControl2.Globe.Layers.Add(dataset); + globeControl2.Globe.Layers[0].Visible = true; + } + } + } + + LoadDataForGlobalControl ss = new LoadDataForGlobalControl(connectServer); + ss(); + + } + catch (Exception ex) + { + MessageBox.Show(ex.Message); + } + } + + private void initLayerTree() + { + //加载临时图层节点 + layerManagerNode = new TreeNode(); + layerManagerNode.ImageIndex = 0; + layerManagerNode.SelectedImageIndex = 0; + layerManagerNode.Checked = true; + layerManagerNode.Text = "临时图层"; + layerTree.Nodes.Add(layerManagerNode); + + XmlDocument doc = new XmlDocument(); + doc.Load(filename); + XmlNodeList xmlLayerNodes = doc.SelectNodes("//layer"); + + foreach (XmlNode xmlLayerNode in xmlLayerNodes) + { + + //TODO LIST:创建一级TreeNode(实测、规划、施工) + TreeNode nodelayer = new TreeNode(); + string layerName = xmlLayerNode.Attributes["label"].Value; + nodelayer.Text = layerName; + nodelayer.Checked = false; + layerTree.Nodes.Add(nodelayer); + + XmlNodeList xmlChildLayerNodes = xmlLayerNode.ChildNodes; + foreach (XmlNode xmlChildLayerNode in xmlChildLayerNodes) + { + //TODO LIST:创建二级TreeNode节点 + TreeNode secondLevelNode = new TreeNode(); + string layerType = xmlChildLayerNode.Attributes["label"].Value; + secondLevelNode.Text = layerType; + + if (xmlChildLayerNode.Attributes["type"] != null) + { //道路图层特殊处理 + string type = xmlChildLayerNode.Attributes["type"].Value; + secondLevelNode.Tag = type + "|" + layerType; + } + else + { + secondLevelNode.Tag = layerType; + } + secondLevelNode.Checked = false; + nodelayer.Nodes.Add(secondLevelNode); + + XmlNodeList xmlActitualLayerNodes = xmlChildLayerNode.ChildNodes; + + foreach (XmlNode xmlActitualLayerNode in xmlActitualLayerNodes) + { + //TODO LIST:创建三级图层节点 + TreeNode layerNode = new TreeNode(); + string actutallylayerType = xmlActitualLayerNode.Attributes["type"].Value; + string actutallylayerName = xmlActitualLayerNode.Attributes["layer"].Value; + string actutallyLabelName = xmlActitualLayerNode.Attributes["label"].Value; + + layerNode.Text = actutallyLabelName; + layerNode.Tag = layerType + "|" + actutallyLabelName; + layerNode.Checked = false; + secondLevelNode.Nodes.Add(layerNode); + } + + } + + } + + } + + /** + * 读取Config.xml文件,初始化以下全局Map + * m_PipelineLayerNames:管线 + * workwellLayerNames:工井 + * valueLayerNames:阀门 + * instrumenLayerNames:附属物 + * pipefittingLayerNames:特征管点 + * sgPipeLayersNames:施工管线 + **/ + private void initGlobalMap() + { + XmlDocument doc = new XmlDocument(); + doc.Load(filename); + XmlNodeList xmlLayerNodes = doc.SelectNodes("//layerchild"); + + foreach (XmlNode xmlLayerNode in xmlLayerNodes) + { + string layerType = xmlLayerNode.Attributes["type"].Value; + string layerName1 = xmlLayerNode.Attributes["layer"].Value; + string layerchildName = xmlLayerNode.Attributes["label"].Value; + + dictionaryNetLayerNameAndCaption.Add(layerName1, layerchildName); + + if (layerType != "db") + { + if (xmlLayerNode.Attributes["isRoad"] != null) + { + roadLayerName = layerchildName; + } + } + else if (xmlLayerNode.Attributes["isPipeLine"] != null) + { + m_PipelineLayerNames.Add(layerchildName); + g1layername.Add(layerName1); + } + else if (xmlLayerNode.Attributes["isWorkWell"] != null) + { + workwellLayerNames.Add(layerchildName); + g1layername.Add(layerName1); + } + else if (xmlLayerNode.Attributes["isValve"] != null) + { + valueLayerNames.Add(layerchildName); + g1layername.Add(layerName1); + } + else if (xmlLayerNode.Attributes["isAccess"] != null) + { + instrumenLayerNames.Add(layerchildName); + g1layername.Add(layerName1); + } + else if (xmlLayerNode.Attributes["isCharacter"] != null) + { + pipefittingLayerNames.Add(layerchildName); + g1layername.Add(layerName1); + } + else if (xmlLayerNode.Attributes["isSgData"] != null) + { + sgPipeLayersNames.Add(layerchildName); + g1layername.Add(layerName1); + } + + } + } + + private void initMarkerTree() + { + 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); + } + } + } + } + + private void MainFrm_Load(object sender, EventArgs e) + { + + this.initGlobalControl(); + this.initGlobalMap(); + this.initLayerTree(); + this.initMarkerTree(); + this.initLayout(); + this.loadData(); + + + double x = Convert.ToDouble(Utility.Query_Roads["绿岛"].ToString().Split(',')[0]); + double y = Convert.ToDouble(Utility.Query_Roads["绿岛"].ToString().Split(',')[1]); + double z = Convert.ToDouble(Utility.Query_Roads["绿岛"].ToString().Split(',')[2]); + jumpToCameraState(x, y, z); + + + } + + #endregion + + /// + /// 每次gis服务加载时都会触发的 + /// + /// + /// + 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 dictionaryNetLayerNameAndCaption = new Dictionary(); + 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 配置用户权限 + /// + /// 向数据库插入功能列表 + /// + private void insertControlToDatabase() + { + ArrayList listItem = new ArrayList(); + List subListItem = new List(); + 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) + { + GSOCameraState camera = globeControl2.Globe.CameraState; + globeControl1.Globe.JumpToCameraState(camera); + } + } + + void globeControl1_BeforeSceneRenderEvent(object sender, BeforeSceneRenderEventArgs e) + { + if (globeControl1.Focused) + { + 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); + } + } + } + + /// + /// 检查数据集是否有坐标系信息 + /// + /// + /// + 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 = "0prj4" + lprjStr + ""; + + bSuccess = dataset.LoadProjectionFromESRIFile(dlg.FileName); + + string lprjFileName = strDataPath.Substring(0, strDataPath.LastIndexOf(".")) + ".lprj"; + StreamWriter writer = new StreamWriter(lprjFileName, false); + writer.Write(lprjFileContent); + writer.Close(); + + } + } + } + else + { + return true; + } + return bSuccess; + } + + /// + /// 矩形拉框结束事件处理函数 + /// + /// + /// + 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))); + */ + + int mapWidth = 0; + int mapHeight = 0; + Point pt = getUpperLeftPoint(pt1, pt2, out mapWidth, out mapHeight); + int rightBottomX = pt.X + mapWidth; + int rightBottomY = pt.Y + mapHeight; + Image myImg = new Bitmap(mapWidth, mapHeight); + Graphics g = Graphics.FromImage(myImg); + g.CopyFromScreen(pt, new Point(0, 0), new Size(rightBottomX, rightBottomY)); + + 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; + } + } + /// + /// 定位正北正90度俯视 + /// + /// + /// + /// + 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; + } + } + /// + /// layerTree选中后事件处理 + /// + /// + /// + 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); + } + /// + /// 树节点选中方法 + /// + /// + 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); + } + } + } + + } + /// + /// 改变所有子节点的状态 + /// + /// + /// + 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; + LayerFlyMenuItem.Visible = true; + } + + LayerSelectableMenuItem.Visible = true; + LayerEditableMenuItem.Visible = true; + SaveLayerMenuItem.Visible = true; + LayerFlyMenuItem.Visible = true; + 导出CADToolStripMenuItem1.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]); + if (layer != null) + { + LayerSelectableMenuItem.Checked = layer.Selectable; + LayerEditableMenuItem.Checked = layer.Editable; + } + else + { + return; + } + } + 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; + } + } + } + } + } + + /// + /// 删除临时添加的本地数据图层 + /// + /// + /// + 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); + for (int i = globeControl1.Globe.Layers.Count-1; i >=0; i--) + { + if (globeControl1.Globe.Layers[i].Caption == layer.Caption) + { + globeControl1.Globe.Layers.Remove(globeControl1.Globe.Layers[i]); + } + } + + 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 定位ToolStripMenuItem_Click(object sender, EventArgs e) + { + TreeNode node = layerTree.SelectedNode; + + if (node != null) + { + if (node.Parent.Text.Trim() == "临时图层") + { + GSOLayer lsLayer = globeControl1.Globe.Layers.GetLayerByCaption(node.Text.ToString()); + double x = lsLayer.LatLonBounds.Center.X; + double y = lsLayer.LatLonBounds.Center.Y; + if (x == 0 && y == 0) + { + x = lsLayer.Bounds.Center.X; + y = lsLayer.Bounds.Center.Y; + } + + globeControl1.Globe.FlyToPosition(new GSOPoint3d(x, y, 10), EnumAltitudeMode.Absolute); + } + else + { + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(node.Tag.ToString().Split('|')[1]); + + if (layer != null) + { + if (layer.Caption == "红线") + { + globeControl1.Globe.FlyToPosition(new GSOPoint3d(120.610963, 31.188121, 50), EnumAltitudeMode.Absolute, -4, 50, 1000); + globeControl1.Globe.FlyToPointSpeed = 10000000; + globeControl1.Globe.Action = EnumAction3D.SelectObject; + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = true; + } + globeControl1.Refresh(); + } + else + { + double x = layer.LatLonBounds.Center.X; + double y = layer.LatLonBounds.Center.Y; + globeControl1.Globe.FlyToPosition(new GSOPoint3d(x, y, 100), EnumAltitudeMode.Absolute); + } + } + } + } + else + { + return; + } + + } + + private void layerTree_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e) + { + if(this.layerTree.SelectedNode!=null) + { + if (this.layerTree.SelectedNode.Tag.ToString().Contains("|")) + { + string nodeTag = this.layerTree.SelectedNode.Tag.ToString().Split('|')[1]; + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(nodeTag); + if (layer != null) + { + if (layer.Caption == "红线") + { + globeControl1.Globe.FlyToPosition(new GSOPoint3d(120.610963, 31.188121, 50), EnumAltitudeMode.Absolute, -4, 50, 1000); + globeControl1.Globe.FlyToPointSpeed = 10000000; + globeControl1.Globe.Action = EnumAction3D.SelectObject; + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = true; + } + globeControl1.Refresh(); + } + else { + double x = layer.LatLonBounds.Center.X; + double y = layer.LatLonBounds.Center.Y; + globeControl1.Globe.FlyToPosition(new GSOPoint3d(x, y, 0), EnumAltitudeMode.Absolute); + } + } + } + if (this.layerTree.SelectedNode.Tag is GSOLayer) + { + GSOLayer layer = this.layerTree.SelectedNode.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 (this.layerTree.SelectedNode.Tag is GSOFeature) + { + GSOFeature feature = this.layerTree.SelectedNode.Tag as GSOFeature; + if (feature.Geometry != null) + { + globeControl1.Globe.FlyToPosition(feature.Geometry.GeoCenterPoint, EnumAltitudeMode.Absolute, 0, 0, 10); + } + else + { + globeControl1.Globe.FlyToFeature(feature); + } + } + } + } + + /// + /// 在三维场景移动时,隐藏气泡globeControl1 + /// + /// + /// + void globeControl1_CameraBeginMoveEvent(object sender, CameraBeginMoveEventArgs e) + { + if (featureTooltip.IsVisible()) + { + featureTooltip.HideBalloon(); + } + if (balloonEx.IsVisible()) + { + balloonEx.HideBalloon(); + } + } + + /// + /// 在三维场景移动时,隐藏气泡globeControl2 + /// + /// + /// + void globeControl2_CameraBeginMoveEvent(object sender, CameraBeginMoveEventArgs e) + { + if (featureTooltip2.IsVisible()) + { + featureTooltip2.HideBalloon(); + } + if (balloonEx2.IsVisible()) + { + balloonEx2.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(); + } + } + + #region Fan 横断面 + /// + /// 横断面分析、基线剖面分析、道路断面分析等 + /// + /// + /// + private static EnumTrackPolylineEndMode trackPolylineEndMode; + + void globeControl1_TrackPolylineEndEvent(object sender, TrackPolylineEndEventArgs e) + { + //横断面分析、道路横断面分析 + if (trackPolylineEndMode == EnumTrackPolylineEndMode.HDM_Analysis|| + trackPolylineEndMode == EnumTrackPolylineEndMode.DLDM_Analysis) + { + Dictionary hdmDic = SectionAnalysisTool.HDMAnalysis(this.globeControl1, + e.Polyline, this.m_PipelineLayerNames); + FrmHDMAnalysis3 frm = new FrmHDMAnalysis3(hdmDic, this.globeControl1, + trackPolylineEndMode); + frm.Show(this); + } + //基线剖面分析 + else if (trackPolylineEndMode == EnumTrackPolylineEndMode.JXPM_Analysis) + { + FrmBaseLineProfillAnalysis dlg = new FrmBaseLineProfillAnalysis(globeControl1.Globe, e.Polyline); + dlg.Show(this); + globeControl1.Globe.ClearLastTrackPolyline(); + } + else + { + + } + trackPolylineEndMode = EnumTrackPolylineEndMode.Default_Analysis; + } + #endregion + + private GSOFeatures PolygonIntersectAnalysis(GSOGeoPolygon3D polygon, string pipelinetype) + { + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(pipelinetype); + 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(pipelinetype, feats.Length); + return feats; + } + /// + /// 根据范围统计阀门、管线、工井等, 开挖分析, 挖方量分析 + /// + /// + /// + void globeControl1_TrackPolygonEndEvent(object sender, TrackPolygonEndEventArgs e) + { + if (globeControl1.Globe.Action == EnumAction3D.TrackPolygon && e.Polygon != null) + { + GSOGeoPolygon3D polygon = e.Polygon; + + switch (trackflag) + { + case "valvequery": + FrmValveStatistics frm = new FrmValveStatistics(globeControl1,polygon, new DataGridViewDelegate(InitDataGridViewX1)); + frm.Show(this); + globeControl1.Globe.Action = EnumAction3D.ActionNull; + break; + + case "PipelineDistanceStatistics": +<<<<<<< HEAD +======= + +>>>>>>> d2d0088a6b3c53c1a96b7f1997f4d3443c0ee8c0 + FrmAllPipelineStatis frm1 = new FrmAllPipelineStatis(globeControl1, polygon, new DataGridViewDelegate(InitDataGridViewX1), m_PipelineLayerNames); + frm1.Show(this); + globeControl1.Globe.Action = EnumAction3D.ActionNull; + + break; + case "PipelineSpatialQuery": +<<<<<<< HEAD +======= + +>>>>>>> d2d0088a6b3c53c1a96b7f1997f4d3443c0ee8c0 + FrmAllPipelineStatis.ShowForm(globeControl1,polygon,new DataGridViewDelegate(InitDataGridViewX1),m_PipelineLayerNames); + globeControl1.Globe.ClearAnalysis(); + globeControl1.Globe.Action = EnumAction3D.ActionNull; + + break; + case "workwellquery": + FrmAllWorkWellStatis frmWell = new FrmAllWorkWellStatis(globeControl1, polygon, new DataGridViewDelegate(InitDataGridViewX1)); + 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 "BSQDuoBianXiangStatis": + + //GSOFeature f2 = new GSOFeature(); + //f2.Geometry = e.Polygon; + //f2.Geometry.AltitudeMode = EnumAltitudeMode.Absolute; + //globeControl1.Globe.MemoryLayer.AddFeature(f2); + //f2.Geometry.MoveZ(3); + //workWellLen.Clear(); + //List listBSQ = new List(); + + //GSOFeatures bsqFeatures = PolygonIntersectAnalysis(e.Polygon, "标识器"); + //listBSQ.Add(bsqFeatures); + + //FrmBSQDuoBianXingStatis bsqFrm = new FrmBSQDuoBianXingStatis(workWellLen, globeControl1, listBSQ); + FrmBSQStatis bsqFrm = new FrmBSQStatis(globeControl1,e.Polygon); + bsqFrm.Show(this); + globeControl1.Globe.Action = EnumAction3D.ActionNull; + break; + + case "": + break; + default: + break; + } + } + } + + #region 验证端口 + /* + /// + /// 验证端口 + /// + /// + 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 + + /// + /// 鼠标悬浮提示 + /// + /// + /// + 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); + } + } + + /// + /// 添加管线绘制完成事件, 红线工具绘制完成 + /// + /// + /// + 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; + + + } + } + + /// + /// 获取globeControl1中鼠标按下的坐标供区别鼠标右键和滚轮按下事件 + /// + /// + /// + void globeControl1_MouseDown(object sender, MouseEventArgs e) + { + mouseDownX1 = e.X; + mouseDownY1 = e.Y; + } + /// + /// 获取globeControl2中鼠标按下的坐标供区别鼠标右键和滚轮按下事件 + /// + /// + /// + void globeControl2_MouseDown(object sender, MouseEventArgs e) + { + mouseDownX2 = e.X; + mouseDownY2 = e.Y; + } + /// + /// + /// + /// + /// + void globeControl2_MouseClick(object sender, MouseEventArgs e) + { + if (e.Button == MouseButtons.Right) + { + if (e.X == mouseDownX2 && e.Y == mouseDownY2) + { + RightScreenToolMenu.Show(globeControl2, e.X, e.Y); + } + else + { + return; + } + } + } + /// + /// + /// + /// + /// + void globeControl1_MouseClick(object sender, MouseEventArgs e) + { + if (e.Button == MouseButtons.Left) + { + if (globeControl1.Globe.Action == EnumAction3D.VisibilityAnalysis) + { + buttonItemFX5_1.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; + + bsqPT = pt; + + if (buttonItemLS5.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 (e.X == mouseDownX1 && e.Y == mouseDownY1) + { + toolRightMenu.Show(globeControl1, e.X, e.Y); + if (buttonItemLS5.Checked) + { + buttonItemLS5.Checked = false; + } + } + else + { + return; + } + } + globeControl1.Refresh(); + } + + /// + /// 判断网络图片是否存在 + /// + /// + /// + 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; + } + + /// + /// 鼠标点击, 弹出气泡功能globeControl1 + /// + /// + /// + void globeControl1_FeatureMouseClickEvent(object sender, FeatureMouseClickEventArgs e) + { + GSOFeature feature = e.Feature; + + string str1 = ""; + if (feature != null) + { + if (feature.GetFieldDefn("图片编码") != null)// + { + str1 = GetBubbleInfo(feature, globeControl1); + if (RemoteFileExists(Utility.PicRootURL + feature.GetValue("图片编码").ToString())) + { + str1 += ""; + } + else if (RemoteFileExists(Utility.PicDefaultURL)) + { + str1 += ""; + } + } + else if (isFeatureContainsBianhao(feature)) //管线模型图层 + { + str1 = GetBubbleInfo(feature, globeControl1); + } + + 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; + } + } + } + + /// + /// 鼠标点击, 弹出气泡功能globeControl2 + /// + /// + /// + void globeControl2_FeatureMouseClickEvent(object sender, FeatureMouseClickEventArgs e) + { + GSOFeature feature = e.Feature; + + string str1 = ""; + if (feature != null) + { + if (feature.GetFieldDefn("图片编码") != null) // + { + str1 = GetBubbleInfo(feature, globeControl2); + if (RemoteFileExists(Utility.PicRootURL + feature.GetValue("图片编码").ToString())) + { + str1 += ""; + } + else if (RemoteFileExists(Utility.PicDefaultURL)) + { + str1 += ""; + } + } + else if (isFeatureContainsBianhao(feature)) //管线模型图层 + { + str1 = GetBubbleInfo(feature, globeControl2); + } + + if (str1 != "") + { + + featureTooltip2.HideBalloon(); + balloonEx2.HideBalloon(); + balloonEx2.SetSize(EnumSizeIndexEx.CONTENT_CX, 480); + balloonEx2.SetSize(EnumSizeIndexEx.CONTENT_CY, 420); + balloonEx2.ShowBalloon((int)e.MousePos.X, (int)e.MousePos.Y, str1); + + return; + } + } + } + + /// + /// 拼接气泡表格字符串 + /// + /// + /// + private string GetBubbleInfo(GSOFeature feature,GSOGlobeControl globeControl) + { + if (feature == null) + { + return ""; + } + string str = ""; + str = ""; + 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 += ""; + + 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.get_Fields(layerName, globeControl); + } + if (queryFields != null) + { + string[] param = { "," }; + string[] fieldNames = queryFields.Split(param, StringSplitOptions.RemoveEmptyEntries); + for (int j = 0; j < fieldNames.Length; 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 (name1 == "模型路径") + { + continue; + } + 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 (field1.Type == EnumFieldType.Double) + { + double dl1 = feature.GetFieldAsDouble(j); + if (!name1.Contains("管径") && !name1.Contains("电压") && !name1.Contains("角度")) + { + name1 += "_米"; + } + value1 = dl1.ToString("0.00"); + } + 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 (name2 == "模型路径") + { + continue; + } + + 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 (field2.Type == EnumFieldType.Double) + { + double dl2 = feature.GetFieldAsDouble(j + 1); + if (!name2.Contains("管径") && !name2.Contains("电压") && !name2.Contains("角度")) + { + name2 += "_米"; + } + value2 = dl2.ToString("0.00"); + } + else + { + if (!feature.IsFieldValueNull(j + 1)) + { + value2 = feature.GetValue(j + 1).ToString(); + } + } + } + } + + j++; + } + str += ""; + } + } + str += "
" + title + " " + feature.GetFieldAsString(featureIDFieldName) + "
" + + name1 + + "
" + + value1 + + "
" + + name2 + + "
" + + value2 + "
"; + return str; + } + + string filename = Utility.filename; + List g1layername = new List(); + + /// + /// 获取目标图层 + /// + /// + 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; + } + /// + /// 添加图层 + /// + /// + /// + /// + 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 = 5000; + return templayer.Visible; + } + catch (Exception ex) + { + return false; + } + } + /// + /// 菜单上的 三维导航 工具按钮 + /// + /// + /// + private void buttonItem86_Click(object sender, EventArgs e) + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + } + + /// + /// 地上模式 菜单按钮 + /// + /// + /// + 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(); + + } + } + /// + /// 地下模式 菜单按钮 + /// + /// + /// + 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(); + } + } + /// + /// 行走模式 菜单按钮 + /// + /// + /// + 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; + } + } + /// + /// 地面透明度设置 菜单 + /// + /// + /// + private void sliderGroundTransSet1_ValueChanged(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.sliderGroundTransSet1.Text); + + globeControl1.Globe.GroundOpaque = 100 - sliderGroundTransSet1.Value; + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(roadLayerName);//("180fd"); + if (layer != null) + { + layer.Opaque = 100 - sliderGroundTransSet1.Value; + } + //if (buttonItemSPDB.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; + } + /// + /// 图例 菜单按钮 + /// + /// + /// + 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(); + } + /// + /// 快速定位 菜单按钮 + /// + /// + /// + private void buttonItem91_Click(object sender, EventArgs e) // + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItem91.Text); + FrmFlyToPosition fly = new FrmFlyToPosition(globeControl1); + fly.Show(this); + } + /// + /// 图层管理 菜单按钮 + /// + /// + /// + 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; + + //修改图层管理与标注管理、覆土审查、水平净距分析、垂直净距分析和碰撞分析控件之间的逻辑关系 + controlContainerItem5.Visible = false; + sideBar1.Visible = false; + sideBarPanelItem4.Visible = false; + panel3.Visible = false; + sideBar1.ExpandedPanel = sideBarPanelItem3; + buttonItemBZ11.Checked = false; + + //20160624 + /* + if (sideBarPanelItem4.Visible == true) + { + sideBar1.Visible = true; + controlContainerItem5.Visible = true; + } + else + { + sideBar1.Visible = false; + } + */ + Refresh(); + + } + } + /// + /// 全屏显示 菜单按钮 + /// + /// + /// + 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; + /// + /// 全屏显示功能实现 + /// + 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(); + } + } + + /// + /// 设置窗体宽、高 + /// + /// + /// + private void SetFullScreen(int width, int height) + { + this.Width = width; + this.Height = height; + } + + /// + /// 全屏功能的快捷键F5 + /// + /// + /// + 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); + } + } + /* + /// + /// 输出地图 + /// + /// + /// + /// + 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; + } + * */ + + private Point getUpperLeftPoint(Point p1, Point p2, out int mapWidth, out int mapHeight) // + { + Rectangle rc = new Rectangle(); + + p1 = this.globeControl1.PointToScreen(p1); + p2 = this.globeControl1.PointToScreen(p2); + + int x = Screen.PrimaryScreen.Bounds.X; + int y = Screen.PrimaryScreen.Bounds.Y; + int screenWidth = SystemInformation.WorkingArea.Width; + int screenHeight = SystemInformation.WorkingArea.Height; + + if (p1.X < x) + rc.X = x; + else + rc.X = p1.X; + + if (p1.Y < y) + rc.Y = y; + else + rc.Y = p1.Y; + + p1.X = rc.Left; + p1.Y = rc.Top; + + if (p2.X > screenWidth) + p2.X = screenWidth; + else + p2.X = p2.X; + + if (p2.Y > screenHeight) + p2.Y = screenHeight; + else + p2.Y = p2.Y; + + rc.Width = p2.X - rc.X; + rc.Height = p2.Y - rc.Y; + + mapWidth = rc.Width; + mapHeight = rc.Height; + Point pt = new Point(rc.Left, rc.Top); + return pt; + } + + Image printImage; + /// + /// 打印 菜单 + /// + /// + /// + 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))); + */ + int mapWidth = 0; + int mapHeight = 0; + Point pt = getUpperLeftPoint(pt1, pt2, out mapWidth, out mapHeight); + int rightBottomX = pt.X + mapWidth; + int rightBottomY = pt.Y + mapHeight; + Image myImg = new Bitmap(mapWidth, mapHeight); + Graphics g = Graphics.FromImage(myImg); + g.CopyFromScreen(pt, new Point(0, 0), new Size(rightBottomX, rightBottomY)); + + + 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); + } + /// + /// 输出地图 菜单 + /// + /// + /// + private void btnOutputJPG_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btnOutputJPG.Text); + + //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))); + */ + int mapWidth = 0; + int mapHeight = 0; + Point pt = getUpperLeftPoint(pt1, pt2, out mapWidth, out mapHeight); + int rightBottomX = pt.X + mapWidth; + int rightBottomY = pt.Y + mapHeight; + Image myImg = new Bitmap(mapWidth, mapHeight); + Graphics g = Graphics.FromImage(myImg); + g.CopyFromScreen(pt, new Point(0, 0), new Size(rightBottomX, rightBottomY)); + + 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; + } + } + } + + /// + /// 统计管线的里程数 + /// + /// + /// + /// + 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; + } + + /// + /// 窗体下方属性表格 右键菜单中的 “定位”菜单 + /// + /// + /// + 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); + + } + + /// + /// 表格中右键 “单个闪烁” 菜单 + /// + /// + /// + private void LightMenu_Click(object sender, EventArgs e) + { + flashflag = "single"; + timer1.Start(); + } + /// + /// 表格中右键 “全部闪烁” 菜单 + /// + /// + /// + private void AllLightMenuItem_Click(object sender, EventArgs e) + { + flashflag = "all"; + timer1.Start(); + } + + /// + /// 使用timer实现管线的闪烁效果 + /// + /// + /// + 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; + } + } + + /// + /// 绘制线 菜单 + /// + /// + /// + private void btnAddLine_Click(object sender, EventArgs e) + { + globeControl1.Globe.DestLayerFeatureAdd = globeControl1.Globe.MemoryLayer; + globeControl1.Globe.Action = EnumAction3D.DrawPolyline; + } + /// + /// 绘制面 菜单 + /// + /// + /// + private void btnAddPolygon_Click(object sender, EventArgs e) + { + globeControl1.Globe.DestLayerFeatureAdd = globeControl1.Globe.MemoryLayer; + globeControl1.Globe.Action = EnumAction3D.DrawPolygon; + } + /// + /// 图层目录树 右键菜单中的 目标图层 菜单 + /// + /// + /// + 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; + } + } + /// + /// 图层目录树 右键菜单中的 可选择 菜单 + /// + /// + /// + 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; + } + /// + /// 图层目录树 右键菜单中的 可编辑 菜单 + /// + /// + /// + 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; + } + /// + /// 图层目录树 右键菜单中的 保存 菜单 + /// + /// + /// + 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(); + } + + /// + /// 根据多边形范围统计管线的里程 + /// + /// + /// + /// 返回查询到的管线要素集合 + 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 pipeLineDis = new Dictionary(); + Dictionary workWellLen = new Dictionary(); + + + + + /// + /// 查找指定图层中在 指定范围内的feature对象集合 + /// + /// + /// + /// + 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; + } + /// + /// 清除结果 菜单 + /// + /// + /// + private void buttonItem47_Click(object sender, EventArgs e) + { + globeControl1.Globe.ClearAnalysis(); + dataGridViewX1.DataSource = null; + panelOfTable.Visible = false; + clearFeatureHighLight(); + } + /// + /// 设置菜单的选中状态 + /// + private void ActionToolMenuChecked() + { + if (globeControl1.Globe.Action != EnumAction3D.TrackPolyline) + { + buttonItemFX2_1.Checked = false; + buttonItemFX2_4.Checked = false; + buttonItemFX2_3.Checked = false; + buttonItemFX4_3.Checked = false; + } + if (globeControl1.Globe.Action != EnumAction3D.NormalHit) + { + buttonItemFX3_6.Checked = false; + // ClearConnexityAnalysis(); + + buttonItemFX3_5.Checked = false; + // ClearCloseValvesAnalysis(); + } + if (globeControl1.Globe.Action != EnumAction3D.TrackPolygon) + { + buttonItemFX4_2.Checked = false; + buttonItemFX4_1.Checked = false; + } + } + + /// + /// 主窗体关闭事件处理 + /// + /// + /// + private void MainFrm_FormClosing(object sender, FormClosingEventArgs e) + { + + if (MessageBox.Show("是否退出系统?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) + { + e.Cancel = true; + } + else { + globeControl1.Globe.MemoryLayer.SaveAs(Application.StartupPath + "/MyPlace.kml"); + } + + //saveLayerList(layerManagerNode.Nodes); + //注销id号为103的热键设定 + // UnregisterHotKey(Handle, 103); + } + + /// + /// 显示流向 功能 + /// + /// + /// + /// + 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(); + } + + FrmCloseValves frm; + + FrmBoosterValvers frmbooster = null; + + /// + /// 垂直净距分析 功能界面中的 选择图层复选框 选中状态改变事件处理 + /// + /// + /// + 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(); + } + /// + /// 水平净距分析 功能界面中的 选择图层复选框 选中状态改变事件处理 + /// + /// + /// + 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(); + } + /// + /// 垂直净距分析 功能界面中的 选择管线复选框 选中状态改变事件处理 + /// + /// + /// + private void checkBoxX1_CheckedChanged(object sender, EventArgs e) + { + clearFeatureHighLight(); + if (checkBoxX1.Checked) + { + comboBoxEx1.SelectedItem = null; + 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; + } + } + /// + /// 水平净距分析 功能界面中的 选择管线复选框 选中状态改变事件处理 + /// + /// + /// + private void checkBoxX1_CheckedChanged_shuiping(object sender, EventArgs e) + { + clearFeatureHighLight();//清除高亮 + if (checkBoxX7.Checked) + { + comboBoxEx4.SelectedItem = null; + 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(); + /// + /// 垂直净距分析 功能界面中的 选择图层下拉框 选中项改变 事件处理 + /// + /// + /// + 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; + } + } + } + /// + /// 水平净距分析 功能界面中的 选择图层下拉框 选中项改变 事件处理 + /// + /// + /// + 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 featCount = new Dictionary(); + Dictionary featLenth = new Dictionary(); + Dictionary m_FeaturesWithBianhao = new Dictionary();//记录编号和对应的标注点的位置 + GSOFeatures polygonJingJuAnalysises = new GSOFeatures(); + + /// + /// 垂直净距分析 功能界面中的 开始分析按钮 事件处理 + /// + /// + /// + 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; + } + + /// + /// 在指定的两点组成的线的中间添加一个marker对象,并将marker对象添加到指定的图层中 + /// + /// + /// + /// + /// + /// + 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; + } + + /// + /// 计算指定feature对象与除了该feature所在图层之外的 所有管线图层中的所有feature对象 的垂直距离 并在表格中记录符合要求的管线 + /// + /// + /// + /// + /// + private void VerticalDistanceAnalysis(string type, GSOFeature selectedFeature, List _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(); + } + /// + /// 垂直净距分析中 表格行的 双击定位 功能。 与覆土分析的实现方法不同,主要原因是需要标注垂距 + /// + /// + /// + 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); + } + } + } + } + + /// + /// 水平净距分析 功能界面中 开始分析按钮 的事件处理 + /// + /// + /// + 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; + } + + + /// + /// 计算指定feature对象与除了该feature所在图层之外的 所有管线图层中的所有feature对象 的水平距离 并记录符合要求的管线 功能 + /// + /// + /// + /// + /// + private void HorizontalDistanceAnalysis(GSOFeature selectedFeature, List _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)); + } + } + } + } + } + /// + /// 水平净距分析 功能界面中 表格的 双击定位 功能 + /// + /// + /// + 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); + } + } + } + } + } + /// + /// 碰撞分析 功能界面中 开始分析按钮 事件处理 + /// + /// + /// + 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; + } + /// + /// 碰撞分析功能界面中 表格的 双击定位 功能 + /// + /// + /// + 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); + } + } + } + } + + + + /// + /// 覆土分析功能操作界面中的 选择管线 复选框选中状态改变事件处理 + /// + /// + /// + private void checkBoxX5_CheckedChanged(object sender, EventArgs e) + { + clearFeatureHighLight(); + if (checkBoxX5.Checked) + { + comboBoxEx3.SelectedItem = null; + 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; + } + } + /// + /// 覆土分析功能操作界面中的 选择图层 复选框选中状态改变事件处理 + /// + /// + /// + 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(); + } + /// + /// 覆土分析功能操作界面中的 图层下拉框选中项改变事件处理 + /// + /// + /// + 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; + } + } + } + /// + /// 覆土分析功能操作界面中的 开始分析 按钮事件处理 + /// + /// + /// + 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; + + + GSOPoint3d markerPosition = new GSOPoint3d(); + 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]; + GSOPoint3d pt = new GSOPoint3d(); + + 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"); + + pt.X = pts[m].X; + pt.Y = pts[m].Y; + pt.Z = 0; + markerPosition = LabelVerticalDistance(layerTemp, pts[m], pt, Convert.ToDouble(dataGridViewX7.Rows[idx].Cells[2].Value), true); + 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]; + GSOPoint3d pt = new GSOPoint3d(); + 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"); + + pt.X = pts[m].X; + pt.Y = pts[m].Y; + pt.Z = 0; + markerPosition = LabelVerticalDistance(layerTemp, pts[m], pt, Convert.ToDouble(dataGridViewX7.Rows[idx].Cells[2].Value), true); + + 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; + } + + /// + /// 覆土分析中 表格的 双击定位 功能 + /// + /// + /// + 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); + } + } + } + } + } + /// + /// 覆土分析功能操作界面中的 导出Excel按钮 事件处理 + /// + /// + /// + private void buttonX10_Click(object sender, EventArgs e) + { + if (dataGridViewX7.Rows.Count > 0) + { + ExportExcel("覆土分析", dataGridViewX7, null); + } + else + { + MessageBox.Show("表格内容为空!", "提示"); + } + } + /// + /// 覆土分析功能操作界面底部的 关闭 按钮事件处理 + /// + /// + /// + 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(); + layerTemp.RemoveAllFeature(); + + if (buttonItem1.Checked) + { + sideBar1.ExpandedPanel = sideBarPanelItem3; + } + else + { + sideBar1.Visible = false; + } + globeControl1.Refresh(); + + //Refresh(); + } + + + /// + /// 垂直净距分析 功能界面中 清除分析结果按钮 事件处理 + /// + /// + /// + 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(); + } + /// + /// 水平净距分析 功能界面中 清除分析结果按钮 事件处理 + /// + /// + /// + 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(); + } + + /// + /// 垂直净距分析功能界面中 关闭按钮 事件处理 + /// + /// + /// + 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(); + } + /// + /// 水平净距分析功能界面中 删除缓冲区按钮 事件处理 + /// + /// + /// + private void buttonX14_Click(object sender, EventArgs e) + { + 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(); + } + + /// + /// 导出指定DataGridView控件中的内容 + /// + /// + /// + 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(); + } + } + } + } + + /// + /// 垂直净距分析功能界面中 导出Excel按钮 事件处理 + /// + /// + /// + private void buttonX4_Click(object sender, EventArgs e) + { + if (dataGridViewX3.Rows.Count > 0) + { + ExportExcel("垂直净距分析", dataGridViewX3, listBox1); + } + else + { + MessageBox.Show("表格内容为空!", "提示"); + } + } + /// + /// 水平净距分析功能界面中 导出Excel按钮 事件处理 + /// + /// + /// + private void buttonX4_Click_shuiping(object sender, EventArgs e) + { + if (dataGridViewX9.Rows.Count > 0) + { + ExportExcel("水平净距分析", dataGridViewX9, listBox3); + } + else + { + MessageBox.Show("表格内容为空!", "提示"); + } + } + + + /// + /// 清除所有坑 菜单 + /// + /// + /// + private void buttonItem3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItem3.Text); + + globeControl1.Globe.RemoveAllPits(); + } + + //} + /// + /// 大气层 菜单 + /// + /// + /// + private void buttonItem17_Click_1(object sender, EventArgs e) + { + globeControl1.Globe.Atmosphere.Visible = !globeControl1.Globe.Atmosphere.Visible; + buttonItemSH1.Checked = globeControl1.Globe.Atmosphere.Visible; + globeControl1.Refresh(); + } + /// + /// 经纬网 菜单 + /// + /// + /// + private void buttonItem20_Click(object sender, EventArgs e) + { + globeControl1.Globe.LatLonGrid.Visible = !globeControl1.Globe.LatLonGrid.Visible; + buttonItemSH3.Checked = globeControl1.Globe.LatLonGrid.Visible; + globeControl1.Globe.Refresh(); + } + /// + /// 状态条 菜单 + /// + /// + /// + private void buttonItem21_Click_1(object sender, EventArgs e) + { + globeControl1.Globe.StatusBar.Visible = !globeControl1.Globe.StatusBar.Visible; + buttonItemSH4.Checked = globeControl1.Globe.StatusBar.Visible; + globeControl1.Globe.Refresh(); + } + + + + /// + /// 添加指定路径下的数据 功能 + /// + /// + /// + 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); + //CheckDatasetGeoReference(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; + } + return objRes; + } + /// + /// 刷新目录树 功能 + /// + 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); + } + } + /// + /// 判断图层是否包含字段列表 + /// + /// + /// + 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; + } + + /// + /// 统计指定图层在指定范围内的所有feature对象 + /// + /// + /// + /// + 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; + } + /// + /// 碰撞分析功能界面中 选择管线复选框 选中状态改变事件处理 + /// + /// + /// + private void checkBoxX3_CheckedChanged(object sender, EventArgs e) + { + clearFeatureHighLight(); + if (checkBoxX3.Checked) + { + comboBoxEx2.SelectedItem = null; + 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; + } + } + /// + /// 碰撞分析功能界面中 选择图层复选框 选中状态改变事件处理 + /// + /// + /// + 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(); + } + /// + /// 碰撞分析功能界面中 选择图层下拉框 选中项改变事件处理 + /// + /// + /// + 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; + } + } + } + /// + /// 清除所有图层中的所有feature对象的高亮状态 功能 + /// + 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); + } + } + } + } + for (int i = 0; i < globeControl2.Globe.Layers.Count; i++) + { + GSOLayer layer = globeControl2.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; + } + } + } + + if (globeControl1.Globe.Action == EnumAction3D.SelectObject) + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + //globeControl1.Globe.Action = EnumAction3D.SelectObject; + } + } + + /// + /// 碰撞分析功能界面中 清除分析结果按钮 事件处理 + /// + /// + /// + 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(); + } + /// + /// 碰撞分析功能界面中 导出Excel按钮 事件处理 + /// + /// + /// + private void buttonX6_Click(object sender, EventArgs e) + { + if (dataGridViewX5.Rows.Count > 0) + { + ExportExcel("碰撞分析", dataGridViewX5, listBox2); + } + else + { + MessageBox.Show("表格内容为空!", "提示"); + } + } + /// + /// 导出CAD 菜单 + /// + /// + /// + private void btnExportCAD_Click(object sender, EventArgs e) + { + FrmExportCADS frm = new FrmExportCADS(globeControl1, m_PipelineLayerNames); + frm.ShowDialog(); + } + + ///// + ///// 区域分析 菜单 + ///// + ///// + ///// + //private void buttonItem50_Click(object sender, EventArgs e) + //{ + // buttonItem50.Checked = !buttonItem50.Checked; + // ribbonBarQY.Visible = buttonItem50.Checked; + // ribbonBarQY.Location = new Point(0, 0); + //} + + + /// + /// 连接数据库 菜单事件处理 + /// + /// + /// + 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; + } + } + } + /// + /// 数据验证 菜单 + /// + /// + /// + private void buttonItem80_Click(object sender, EventArgs e) + { + FrmValiData frm = new FrmValiData(globeControl1); + frm.ShowDialog(); + } + /// + /// 根据指定图层创建图层节点并将节点添加到图层管理节点的子节点集合中 + /// + /// + 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; + + if (!layerManagerNode.Nodes.Contains(node)) + { + layerManagerNode.Nodes.Insert(0, node); + layerManagerNode.Expand(); + } + } + } + /// + /// 数据库备份 菜单 + /// + /// + /// + 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(); + } + } + } + + + + #region Fan 去掉 + //GSOFeature emitterFeature; // 粒子要素 + /// + /// 添加火苗 功能 + /// + /// + /// + /// + 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); + + } + /// + /// 添加喷泉 功能 + /// + /// + /// + /// + 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); + } + #endregion + + /// + /// 获取指定图层中最后一个feature对象的名称对应的整数 + /// + /// + /// + 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; + } + /// + /// 设置除指定标注图层之外的所有标注图层不可见 + /// + /// + 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; + } + } + } + } + } + + /// + /// 判断选中的对象是否为管线 + /// + /// 被选中管线 + /// 返回一根线 + 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; + } + + /// + /// 获取指定两点组成的线的长度 功能 + /// + /// + /// + /// + 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; + } + + /// + /// 图层节点树中 节点 右键单击事件处理 + /// + /// + /// + 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; + } + } + } + } + } + + /// + /// 标注管理、传感器管理 图层目录树的右键菜单中的 刷新列表 菜单 + /// + /// + /// + 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); + } + } + /// + /// 给指定的图层节点添加代表feature对象的子节点 + /// + /// + private void RefreshTreeNodeLayerFeatureList(TreeNode layerTreeNode) + { + layerTreeNode.Nodes.Clear(); + GSOLayer layer = (GSOLayer)layerTreeNode.Tag; + // 只将类型为内存数据集的图层列出,如果是其它类型的数据集可能数据量太大,没发显示在树控件中 + if (layer.Dataset is GSOFeatureDataset) + { + VisitFeature3Ds(layer.GetAllFeatures(), layerTreeNode); + } + } + + /// + /// 标注管理、传感器管理 图层目录树的右键菜单中的 移除所有 菜单 + /// + /// + /// + 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(); + } + } + + /// + /// 图层目录树的 节点对应的复选框选中状态改变事件处理 + /// + /// + /// + private void layerMarkerTree_AfterCheck(object sender, TreeViewEventArgs e) + { + if (e.Action != TreeViewAction.Unknown) + { + CheckTreeNode(e.Node, e.Node.Checked); + } + } + /// + /// 改变指定节点对应的复选框的选中状态 + /// + /// + /// + private void CheckTreeNode(TreeNode node, Boolean bChecked) + { + CheckChildTreeNode(node, bChecked); + globeControl1.Globe.Refresh(); + } + /// + /// 改变指定节点的子节点对应的复选框的选中状态 + /// + /// + /// + 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); + } + } + /// + /// 标注管理、传感器管理 目录树中的feature节点的右键菜单中的 删除 菜单 + /// + /// + /// + 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(); + } + } + + /// + /// 双屏对比 菜单 + /// + /// + /// + //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(); + // } + //} + /// + /// 模拟分析 菜单 + /// + /// + /// + //private void buttonItem51_Click(object sender, EventArgs e) + //{ + // buttonItem51.Checked = !buttonItem51.Checked; + // ribbonBarMN.Visible = buttonItem51.Checked; + // ribbonBarMN.Location = new Point(0, 0); + //} + + /// + /// 双屏设置 菜单 + /// + /// + /// + //private void buttonItem96_Click(object sender, EventArgs e) + //{ + // FrmLayerControl frm = new FrmLayerControl(layerTree,globeControl1,globeControl2); + // frm.Show(this); + //} + /// + /// 双屏联动 菜单 + /// + /// + /// + //private void buttonItem95_Click(object sender, EventArgs e) + //{ + // buttonItem95.Checked = !buttonItem95.Checked; + //} + ///// + /// 添加用户仓库 菜单 + /// + /// + /// + private void buttonItem108_Click(object sender, EventArgs e) + { + FrmUserRepo frm = new FrmUserRepo(-1); + frm.ShowDialog(); + } + /// + /// 用户仓库管理 菜单 + /// + /// + /// + private void buttonItem111_Click(object sender, EventArgs e) + { + FrmUserRepoMgr frm = new FrmUserRepoMgr(); + frm.ShowDialog(); + } + /// + /// 添加分系统 菜单 + /// + /// + /// + private void buttonItem112_Click(object sender, EventArgs e) + { + //FrmAPP frm = new FrmAPP(-1); + //frm.ShowDialog(); + } + /// + /// 分系统管理 菜单 + /// + /// + /// + private void buttonItem113_Click(object sender, EventArgs e) + { + //FrmAPPMgr frm = new FrmAPPMgr(); + //frm.ShowDialog(); + } + /// + /// 添加操作 菜单 + /// + /// + /// + private void buttonItem114_Click(object sender, EventArgs e) + { + FrmOper frm = new FrmOper(-1); + frm.ShowDialog(); + } + /// + /// 操作管理 菜单 + /// + /// + /// + private void buttonItem115_Click(object sender, EventArgs e) + { + FrmOperMgr frm = new FrmOperMgr(); + frm.ShowDialog(); + } + /// + /// 添加资源 菜单 + /// + /// + /// + private void buttonItem116_Click(object sender, EventArgs e) + { + FrmRESC frm = new FrmRESC(-1); + frm.ShowDialog(); + } + /// + /// 资源管理 菜单 + /// + /// + /// + private void buttonItem117_Click(object sender, EventArgs e) + { + FrmRESCMgr frm = new FrmRESCMgr(); + frm.ShowDialog(); + } + /// + /// 添加权限 菜单 + /// + /// + /// + private void buttonItem118_Click(object sender, EventArgs e) + { + FrmPerm frm = new FrmPerm(-1); + frm.ShowDialog(); + } + /// + /// 权限管理 菜单 + /// + /// + /// + private void buttonItem119_Click(object sender, EventArgs e) + { + FrmPermMgr frm = new FrmPermMgr(); + frm.ShowDialog(); + } + /// + /// 添加访问控制 菜单 + /// + /// + /// + private void buttonItem120_Click(object sender, EventArgs e) + { + FrmAccess frm = new FrmAccess(-1); + frm.ShowDialog(); + } + /// + /// 访问控制管理 菜单 + /// + /// + /// + private void buttonItem121_Click(object sender, EventArgs e) + { + FrmAccessMgr frm = new FrmAccessMgr(); + frm.ShowDialog(); + } + /// + /// 部门类型管理 菜单 + /// + /// + /// + private void buttonItem122_Click(object sender, EventArgs e) + { + FrmRegionTypeMgr frm = new FrmRegionTypeMgr(); + frm.ShowDialog(); + } + /// + /// 添加用户 菜单 + /// + /// + /// + private void buttonItem127_Click(object sender, EventArgs e) + { + FrmUserAdd frm = new FrmUserAdd(-1); + frm.ShowDialog(); + } + /// + /// 用户信息管理 菜单 + /// + /// + /// + private void buttonItem128_Click_1(object sender, EventArgs e) + { + FrmUserManager frm = new FrmUserManager(); + frm.ShowDialog(); + } + /// + /// 添加角色 菜单 + /// + /// + /// + private void 添加角色_Click(object sender, EventArgs e) + { + FrmRole frm = new FrmRole(-1); + frm.ShowDialog(); + } + /// + /// 所有角色管理 菜单 + /// + /// + /// + private void 角色管理_Click(object sender, EventArgs e) + { + FrmRoleMgr frm = new FrmRoleMgr(); + frm.ShowDialog(); + } + + /// + /// 部门角色管理 菜单 + /// + /// + /// + private void buttonItem133_Click(object sender, EventArgs e) + { + FrmRegionRoleMgr frm = new FrmRegionRoleMgr(); + frm.ShowDialog(); + } + /// + /// 部门管理 菜单 + /// + /// + /// + private void buttonItem130_Click(object sender, EventArgs e) + { + FrmRegionMgr frm = new FrmRegionMgr(); + frm.ShowDialog(); + } + + /// + /// 日志管理 菜单 + /// + /// + /// + private void buttonItem135_Click(object sender, EventArgs e) + { + FrmLogManager frm = new FrmLogManager(); + frm.ShowDialog(); + } + /// + /// 传感器信息查询 菜单 + /// + /// + /// + 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); + } + } + } + /// + /// 根据指定的图层的caption属性的值在配置文件中查找对应的数据库中的表的名称 + /// + /// 图层的caption属性的值 + /// 对应的数据库中的表的名称 + 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; + } + /// + /// 根据数据库中的表的名称 查找对应的表中的字段名称的集合 + /// + /// 数据库中的表的名称 + /// 对应的表中的字段名称的集合 + 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; + } + + /// + /// 历史曲线查询 菜单 + /// + /// + /// + 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; + /// + /// 传感器在线报警 菜单 + /// + /// + /// + 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); + } + /// + /// 传感器报警 功能中的 定时器 的触发事件处理 + /// + /// + /// + 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; + } + } + } + } + } + } + } + + + /// + /// 沿线运动 菜单 + /// + /// + /// + private void buttonItem138_Click(object sender, EventArgs e) + { + if (globeControl1.Globe.SelectedObject == null) + { + MessageBox.Show("请先选择一条线!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + return; + } + + GSOFeature lineFeature = globeControl1.Globe.SelectedObject; + if (lineFeature.Geometry == null || lineFeature.Geometry.Type != EnumGeometryType.GeoPolyline3D) + { + MessageBox.Show("请先选择一条线!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + return; + } + + OpenFileDialog dlg = new OpenFileDialog(); + dlg.Filter = "*.gcm;*.3ds|*.gcm;*.3ds|*.3ds|*.3ds|*.gcm|*.gcm"; + if (dlg.ShowDialog() == DialogResult.OK) + { + GSOGeoModel model = new GSOGeoModel(); + model.FilePath = dlg.FileName; + + GSOGeoDynamicRoute dynamicRoute = new GSOGeoDynamicRoute(); + dynamicRoute.ActorGeometry = model; + + GSORoute route = new GSORoute(); + GSOGeoPolyline3D geoline = (GSOGeoPolyline3D)lineFeature.Geometry; + for (int i = 0; i < geoline[0].Count; i++) + { + route.Add(geoline[0][i]); + } + route.CircleRoute = false; + route.Speed = 30; + route.RotateSpeed = 50; + route.AltitudeMode = geoline.AltitudeMode; + dynamicRoute.Route = route; + + GSOFeature feature = new GSOFeature(); + + dynamicRoute.Play(); + feature.Geometry = dynamicRoute; + + //GSOLabel gsoLabel = new GSOLabel(); + //gsoLabel.Text = "模型测试"; + //feature.Label = gsoLabel; + globeControl1.Globe.MinModelVisibleSize = 0; + + globeControl1.Globe.MemoryLayer.AddFeature(feature); + globeControl1.Globe.Refresh(); + } + } + /// + /// 回退 菜单 + /// + /// + /// + private void buttonItem99_Click(object sender, EventArgs e) + { + globeControl1.Globe.UnDoEdit(); + } + /// + /// 前进 菜单 + /// + /// + /// + private void buttonItem100_Click(object sender, EventArgs e) + { + globeControl1.Globe.ReDoEdit(); + } + /// + /// 水平净距 功能界面中的 标签内容改变事件处理 + /// + /// + /// + 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() + "米的管线有:"; + } + } + } + /// + /// 垂直净距 功能界面中的 标签内容改变事件处理 + /// + /// + /// + 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() + "米的管线有:"; + } + } + } + /// + /// 覆土分析 功能界面中的 标签内容改变事件处理 + /// + /// + /// + 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() + "米的管线有:"; + } + } + } + + /// + /// 传感器分类查询 全区域 菜单 + /// + /// + /// + private void buttonItemSensor全区域查询_Click(object sender, EventArgs e) + { + FrmAccessoriesSensor.ShowForm(globeControl1, instrumenLayerNames, 0); + } + /// + /// 传感器分类查询 绘制区域 菜单 + /// + /// + /// + private void buttonItemSensor绘制区域查询_Click(object sender, EventArgs e) + { + FrmAccessoriesSensor.ShowForm(globeControl1, instrumenLayerNames, 1); + } + + + /// + /// 碰撞分析 功能界面中 关闭按钮 事件处理 + /// + /// + /// + 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(); + } + /// + /// 覆土分析 功能界面中的 清除分析结果 按钮事件处理 + /// + /// + /// + 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(); + } + /// + /// 数字预处理 功能 + /// + /// + /// + private void 数字预处理buttonItem140_Click(object sender, EventArgs e) + { + FrmEditShapeFile frm = new FrmEditShapeFile(globeControl1); + frm.ShowDialog(this); + } + + + /// + /// 导出矢量 功能 将图层导出为kml和shp格式数据 + /// + /// + /// + private void 导出矢量buttonItem140_Click(object sender, EventArgs e) + { + List listVectorNames = new List(); + for (int i = 0; i < m_PipelineLayerNames.Count; i++) + { + 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 = ""; + /// + /// 绘制城市七线 功能按钮 + /// + /// + /// + 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; + } + } + } + /// + /// 七线审核 功能按钮 + /// + /// + /// + private void 七线审核buttonItem141_Click(object sender, EventArgs e) + { + FrmCityServerLineAnalysis frm = new FrmCityServerLineAnalysis(globeControl1, m_PipelineLayerNames); + frm.ShowDialog(this); + } + + /// + /// 间距分析 开始分析按钮 分析绘制的七线和管线的距离是否符合标准 + /// + /// + /// + 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; + } + /// + /// 间距分析 清除分析结果 + /// + /// + /// + 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(); + } + /// + /// 间距分析 导出Excel按钮 将间距分析的结果以Excel表格的形式导出 + /// + /// + /// + private void buttonExportExcel_Click(object sender, EventArgs e) + { + if (dataGridViewAnalysisResult.Rows.Count > 0) + { + ExportExcel("间距分析", dataGridViewAnalysisResult, listBoxStasticsResult); + } + else + { + MessageBox.Show("表格内容为空!", "提示"); + } + } + /// + /// 间距分析 关闭按钮 + /// + /// + /// + 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(); + } + /// + /// 间距分析 分析结果表格双击定位 + /// + /// + /// + 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); + } + } + } + } + /// + /// 间距分析 选择管线复选框 + /// + /// + /// + private void checkBoxSelectPipeline_CheckedChanged(object sender, EventArgs e) + { + clearFeatureHighLight();//清除高亮 + if (checkBoxSelectPipeline.Checked) + { + comboBoxLayer.SelectedItem = null; + 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; + } + } + /// + /// 间距分析 选择图层复选框 + /// + /// + /// + 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(); + } + /// + /// 间距分析 选择图层下拉框 + /// + /// + /// + 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; + } + } + } + + + + /// + /// 管线自动缩进 菜单 + /// + /// + /// + private void 管线自动缩进buttonItem140_Click(object sender, EventArgs e) + { + FrmPipelineIndented frm = new FrmPipelineIndented(globeControl1, m_PipelineLayerNames, workwellLayerNames); + 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 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); + // } + //} + + /// + /// 统计指定图层在指定范围内的所有feature对象 + /// + /// + /// + /// + 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) + { + 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 setLayerVisible(string layerName) + { + GSOLayer templayer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + if (templayer != null) + { + templayer.Visible = false; + } + globeControl1.Globe.Refresh(); + } + + /// + /// 连接数据库 + /// + /// + /// + private void buttonItem129_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL4_1.Text); + + FrmDatabaseParaSetting2 frm = new FrmDatabaseParaSetting2(globeControl1); + if (frm.ShowDialog() == DialogResult.OK) + { + ds = FrmDatabaseParaSetting2.ds; + if (ds != null) + { + ds.IsCloseSaved = false; + } + } + } + + /// + /// 一键审核---导入数据 + /// + /// + /// + private void buttonItem127_Click_2(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, "打开数据"); + + try + { + //if (shds == null) + //{ + //没连的话,直接连接审核库; //审核库配置读配置文件 + string dbIp = Utility.sgdbip; + string database = Utility.sgdbname; + string user = Utility.sgdbuser; + string pass = Utility.sgdbpwd; + /* + 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; + //} + } + catch (Exception ex) + { + LogError.PublishError(ex); + MessageBox.Show("内存过载请清理内存,并重新启动规划分析!", "提示"); + return; + } + + } + + /// + ///自动导出图片 + /// + /// + /// + private void buttonItem130_Click_1(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, "导出审核图"); + + 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))); + */ + + int mapWidth = 0; + int mapHeight = 0; + Point pt = getUpperLeftPoint(pt1, pt2, out mapWidth, out mapHeight); + int rightBottomX = pt.X + mapWidth; + int rightBottomY = pt.Y + mapHeight; + Image myImg = new Bitmap(mapWidth, mapHeight); + Graphics g = Graphics.FromImage(myImg); + g.CopyFromScreen(pt, new Point(0, 0), new Size(rightBottomX, rightBottomY)); + + 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; + } + } + } + /// + /// 一键审核功能 + ///
+ /// + /// + private void buttonItem128_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItem128.Text); + //垂直净距标准 + + frmSh = new FrmYJSHTC(globeControl1, globeControl2,layerTree); + + if (frmSh.ShowDialog() == DialogResult.OK) + { + frmWait = new FrmWait("一键审核……"); + frmWait.Location = new Point(this.Width - frmWait.Width - 10, this.Height - frmWait.Height - 50); + frmWait.Owner = this; + frmWait.Show(); + Thread thread = new Thread(new ThreadStart(doWork)); + thread.IsBackground = true; + thread.Start(); + } + } + + void doWork() + { + FrmShResult frmShResult = null; + + double dVerticalJingJuBiaoZhun = 1, dHorizontalJingJuBiaoZhun = 1; + if (frmSh.rukuLayer != null) + { + #region + this.Invoke((EventHandler)delegate + { + try + { + List managerLayerList = new List(); + for (int i = 0; i < layerManagerNode.Nodes.Count; i++) + { + managerLayerList.Add(layerManagerNode.Nodes[i].Text); + } + if (!managerLayerList.Contains(frmSh.rukuLayer.Caption)) + { + TreeNode node = new TreeNode(); + node.Tag = frmSh.rukuLayer; + node.Text = frmSh.rukuLayer.Dataset.Caption; + node.ImageIndex = 0; + node.SelectedImageIndex = 0; + node.Checked = frmSh.rukuLayer.Visible; + layerManagerNode.Nodes.Insert(0, node); + layerManagerNode.Expand(); + } + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "提示"); + } + }); + #endregion + + shlayername = frmSh.rukuLayer.Name; + globeControl1.Refresh(); + } + + if (frmShResult != null && !frmShResult.IsDisposed) + { + try + { + clearFeatureHighLight(); + ClearRedlineAnalyseResult(); + frmShResult.Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message); + } + } + + 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.analysis(); + + //MainFrm窗体显示控制,回到一键审核Tab + this.Invoke((EventHandler)delegate + { + frmShResult.Show(); + frmWait.Close(); + //将tab页恢复到一键审核 + ribbonTabItem11.Checked = true; + try + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + //zhanshi = false; + splitContainer1.Panel2Collapsed = true; + + panelOfTable.Visible = false; + legendSC.Visible = false; + legendSG.Visible = false; + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + } + catch (Exception ex) + { + MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + + }); + + boolfrmShResult = true; + } + else + { + + } + } + + + /// + /// 清除渲染结果 + /// + 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(); + } + /// + /// 已审核的图层 + /// + /// + /// + private void buttonItem132_Click_1(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItem132.Text); + + if (shds == null) + { + //没连的话,直接连接审核库; //审核库配置读配置文件 + string dbIp = Utility.sgdbip; + string database = Utility.sgdbname; + string user = Utility.sgdbuser; + string pass = Utility.sgdbpwd; + + /* + 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; + //} + + } + /// + /// 审核入库 + /// + /// + /// + private void buttonItem133_Click_1(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, "审核入库"); + FrmShRK frmShrk = new FrmShRK(globeControl1); + frmShrk.Show(); + } + /// + /// 模拟设计修改 + /// + /// + /// + private void buttonItem134_Click_1(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, "模拟设计修改"); + + 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 + { + + } + + } + + + /// + /// 绘制垂线 + /// + /// + /// + 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); + } + /// + /// 比较两个点是否是同一个点 + /// + /// + /// + /// + 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; + } + /// + /// 获得点到线的垂线距离及垂点 + /// + /// + /// + /// + /// + 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); + 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]; + } + /// + /// 获得斜率 + /// + /// + /// + /// + /// + /// + /// + 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); + } + } + /// + /// 根据默认投影参数,经纬度转xyz + /// + /// + /// + /// + 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; + } + /// + /// 根据投影参数,经纬度转xyz + /// + /// + /// + /// + /// + 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; + } + /// + /// 根据默认投影参数,xyz转经纬度 + /// + /// + /// + /// + 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; + } + /// + /// 根据投影参数,Xyz转经纬度 + /// + /// + /// + /// + /// + 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; + } + /// + /// 获得inpolygon的管线长度 + /// + /// + 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; + } + + + /// + /// 一键审核中调节透明度 + /// + /// + /// + private void sliderItem1_ValueChanged(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.sliderItem1.Text); + + globeControl1.Globe.GroundOpaque = 100 - sliderItem1.Value; + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(roadLayerName);//("180fd"); + if (layer != null) + { + layer.Opaque = 100 - sliderItem1.Value; + } + + optiValue = sliderItem1.Value; + } + /// + /// 红线审核中的透明度分析 + /// + /// + /// + private void sliderItem3_ValueChanged(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.sliderItem3.Text); + + globeControl1.Globe.GroundOpaque = 100 - sliderItem3.Value; + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(roadLayerName);//("180fd"); + if (layer != null) + { + layer.Opaque = 100 - sliderItem3.Value; + } + optiValue = sliderItem3.Value; + } + + #region yanxiaowei + //初始化DataGridViewX1控件 + public delegate void DataGridViewDelegate(DataTable dt, string strLable, string strLayer, bool initDataGrid); + /// + /// 代理函数,操作DatgridViewX1 + /// + /// + /// + public void InitDataGridViewX1(DataTable dt, string strLable, string strLayer, bool initDataGrid) + { + if (initDataGrid == true) + { + dataGridViewX1.DataSource = dt; + panelOfTable.Visible = true; + toolStripNumbers.Text = strLable; + dataGridViewX1.Tag = strLayer; + } + else + { + dataGridViewX1.DataSource = null; + dataGridViewX1.Refresh(); + panelOfTable.Visible = false; + toolStripNumbers.Text = ""; + dataGridViewX1.Tag = ""; + globeControl1.Globe.MemoryLayer.RemoveAllFeature();//清除双击产生的标注 + } + } + FrmAnalysisGuiHuaResult from; + /// + /// 主窗体下方属性表格 双击定位 功能 + /// + /// + /// + private void dataGridViewX1_MouseDoubleClick(object sender, MouseEventArgs e) + { + if (redSH == false) + { + 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 if (dataGridViewX1.Columns.Contains("标识器编号")) + { + featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["标识器编号"].Value.ToString(); + } + featureName = featureName.Trim(); + + GSOLayer layer = null; + layer = globeControl1.Globe.Layers.GetLayerByCaption(dataGridViewX1.Tag.ToString()); + + if (layer == null) return; + + GSOFeatures features = layer.GetFeatureByName(featureName, false); + if (features.Length == 0) return; + GSOFeature rowFeature = features[0]; + + ClassSearchAnalysis.AddMakerToLineFeature(globeControl1, rowFeature); + + } + } + } + else + { + if (e.Button == MouseButtons.Left) + { + if (from != null && !from.IsDisposed) + { + try + { + from.Close(); + } + catch (Exception ex) + { + LogError.PublishError(ex); + } + } + try + { + DataGridView.HitTestInfo hittestinfo = dataGridViewX1.HitTest(e.X, e.Y); + if (hittestinfo.RowIndex >= 0) + { + string layer = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["管线类型"].Value.ToString(); + string hxName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["红线编号"].Value.ToString(); + FrmAnalysisGuiHuaResult frm = new FrmAnalysisGuiHuaResult(globeControl1, lineStruct, featsList, + panelOfTable, dataGridViewX1, layer, hxName); + frm.Location = new Point(this.Width - frm.Width - 10, this.Height - frm.Height - 20); + frm.Show(this); + + from = frm; + } + } + catch (Exception ex) + { + LogError.PublishError(ex); + } + } + } + } + + /// + /// 空间查询 + /// + /// + /// + private void buttonItemSearch1_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemSearch1.Text); + + trackflag = "PipelineSpatialQuery"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; + + } + /// + /// 关键字查询 + /// + /// + /// + private void buttonItemSearch9_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch9.Text); + + FrmKeywordQuery.ShowForm(globeControl1, m_PipelineLayerNames, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 编号查询 + /// + /// + /// + private void buttonItemSearch2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch2.Text); + + FrmCodingQuery.ShowForm(globeControl1, m_PipelineLayerNames, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 坐标查询 + /// + /// + /// + private void buttonItemSearch3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch3.Text); + + FrmSetLatLonPos.ShowForm(globeControl1); + } + /// + /// 附属物查询 + /// + /// + /// + private void buttonItemSearch10_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch10.Text); + + FrmFittingQuery.ShowForm(globeControl1, instrumenLayerNames, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 管径查询 + /// + /// + /// + private void buttonItemSearch4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch4.Text); + + FrmDiameterQuery.ShowForm(globeControl1, m_PipelineLayerNames, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 材质查询 + /// + /// + /// + private void buttonItemSearch5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch5.Text); + + FrmMaterialSel.ShowForm(globeControl1, m_PipelineLayerNames, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 基本查询 + /// + /// + /// + private void buttonItemSearch6_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch6.Text); + + FrmBasicQuery.ShowForm(globeControl1, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 复合查询 + /// + /// + /// + private void buttonItemSearch7_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch7.Text); + + FrmQuerySQL.ShowForm(globeControl1, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 关联查询 + /// + /// + /// + private void buttonItemSearch8_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch8.Text); + + if (globeControl1.Globe.SelObjectCount != 1) + { + MessageBox.Show("请选中一个对象!", "提示"); + return; + } + + 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 || (feature.Geometry.Type == EnumGeometryType.GeoPolygon3D + || feature.Geometry.Type == EnumGeometryType.GeoWater)) + return; + else + { + ClassSearchAnalysis.ResultRelationAnalysis(globeControl1, feature, valueLayerNames, workwellLayerNames, + instrumenLayerNames, pipefittingLayerNames, m_PipelineLayerNames, valueAllowance); + } + } + } + #endregion + /// + /// 清除分析 + /// + /// + /// + private void buttonItemClear_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemClear.Text); + + globeControl1.Globe.ClearMeasure(); + layerTemp.RemoveAllFeature(); + layerTemp2.RemoveAllFeature(); + buttonItemLS5.Checked = false; + + dataGridViewX1.DataSource = null; + panelOfTable.Visible = false; + + 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); + + NetworkAnalysisTool.ClearAllTopAnalysis(this.globeControl1); + // 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();//清除所有坑 + + 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(); + } + } + + clearFeatureHighLight();//取消管线高亮 + + GSOLayer layerGround = globeControl1.Globe.Layers.GetLayerByCaption(roadLayerName);//("180fd"); + if (layerGround != null) + { + layerGround.Visible = true; + } + globeControl1.Refresh(); + globeControl2.Refresh(); + ClearRedlineAnalyseResult(); + globeControl1.Globe.Action = EnumAction3D.ActionNull; + } + /// + /// 管线长度全区域统计 + /// + /// + /// + private void buttonItemTJ1_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管线长度统计"); + + FrmAllPipelineStatis frm = new FrmAllPipelineStatis(globeControl1,null, new DataGridViewDelegate(InitDataGridViewX1), m_PipelineLayerNames); + frm.Show(this); + } + /// + /// 管线长度绘制区域统计 + /// + /// + /// + private void buttonItemTJ1_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管线长度统计"); + + trackflag = "PipelineDistanceStatistics"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; + } + /// + /// 阀门数量全区域统计 + /// + /// + /// + private void buttonItemTJ2_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "阀门数量统计"); + + FrmValveStatistics frm = new FrmValveStatistics(globeControl1, null, new DataGridViewDelegate(InitDataGridViewX1)); + frm.Show(this); + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + } + /// + /// 阀门数量绘制区域统计 + /// + /// + /// + private void buttonItemTJ2_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "阀门数量统计"); + + trackflag = "valvequery"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; + } + /// + /// 井盖数量全区域统计 + /// + /// + /// + private void buttonItemTJ3_ALL_Click(object sender, EventArgs e) +<<<<<<< HEAD + { + //日志记录 + LogManager.saveLog(Utility.userName, "井盖数量统计"); +======= + { +>>>>>>> d2d0088a6b3c53c1a96b7f1997f4d3443c0ee8c0 + FrmAllWorkWellStatis frm = new FrmAllWorkWellStatis(globeControl1, null, new DataGridViewDelegate(InitDataGridViewX1)); + frm.Show(this); + } + /// + /// 井盖数量绘制区域统计 + /// + /// + /// + private void buttonItemTJ3_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "井盖数量统计"); + + trackflag = "workwellquery"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; + } + /// + /// 管径分段统计全区域统计 + /// + /// + /// + private void buttonItemTJ4_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管径分段统计"); + + Frmpipediameterstatis.ShowForm(globeControl1, m_PipelineLayerNames, 0); + } + /// + /// 管径分段统计绘制区域统计 + /// + /// + /// + private void buttonItemTJ4_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管径分段统计"); + + trackflag = null; + Frmpipediameterstatis.ShowForm(globeControl1, m_PipelineLayerNames, 1); + } + /// + /// 埋深分段统计全区域统计 + /// + /// + /// + private void buttonItemTJ5_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "埋深分段统计"); + FrmpipeDeepstatis.ShowForm(globeControl1, m_PipelineLayerNames, 0); + } + /// + /// 埋深分段统计绘制区域统计 + /// + /// + /// + private void buttonItemTJ5_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "埋深分段统计"); + trackflag = null; + FrmpipeDeepstatis.ShowForm(globeControl1, m_PipelineLayerNames, 1); + } + /// + /// 管径分类统计全区域统计 + /// + /// + /// + private void buttonItemTJ6_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管径分类汇总"); + + FrmpipeDiametergather.ShowForm(globeControl1, m_PipelineLayerNames, 0); + } + /// + /// 管径分类统计绘制区域统计 + /// + /// + /// + private void buttonItemTJ6_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管径分类汇总"); + + trackflag = null; + FrmpipeDiametergather.ShowForm(globeControl1, m_PipelineLayerNames, 1); + } + /// + /// 材质分类统计全区域统计 + /// + /// + /// + private void buttonItemTJ7_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "材质分类汇总"); + + FrmpipeMaterialGather.ShowForm(globeControl1, m_PipelineLayerNames, 0); + } + /// + /// 材质分类统计绘制区域统计 + /// + /// + /// + private void buttonItemTJ7_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "材质分类汇总"); + + trackflag = null; + FrmpipeMaterialGather.ShowForm(globeControl1, m_PipelineLayerNames, 1); + } + /// + /// 附属物分类统计全区域统计 + /// + /// + /// + private void buttonItemTJ8_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "附属物分类汇总"); + + FrmAccessoriesgather.ShowForm(globeControl1, instrumenLayerNames, 0); + } + /// + /// 附属物分类统计绘制区域统计 + /// + /// + /// + private void buttonItemTJ8_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "附属物分类汇总"); + + trackflag = null; + FrmAccessoriesgather.ShowForm(globeControl1, instrumenLayerNames, 1); + } + /// + /// 碰撞分析 + /// + /// + /// + private void buttonItemFX1_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_4.Text); + + this.dataGridViewX4.Size = new System.Drawing.Size(195, 120); + 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(); + } + /// + /// 覆土分析 + /// + /// + /// + private void buttonItemFX1_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX5_1.Text); + this.dataGridViewX6.Size = new System.Drawing.Size(195, 120); + 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(); + } + /// + /// 间距分析 + /// + /// + /// + private void buttonItemFX1_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX1_3.Text); + + this.dataGridViewLineList.Size = new System.Drawing.Size(185, 120); + 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(); + } + /// + /// 垂直净距分析 + /// + /// + /// + private void buttonItemFX1_4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX1_4.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(); + } + /// + /// 水平净距分析 + /// + /// + /// + private void buttonItemFX1_5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_6.Text); + this.dataGridViewX8.Size = new System.Drawing.Size(185, 120); + 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(); + } + + #region Predaotr,断面分析 + /// + /// 横断面分析 + /// + /// + /// + private void buttonItemFX2_1_Click(object sender, EventArgs e) + { + globeControl1.Globe.Action = EnumAction3D.TrackPolyline; + globeControl1.Globe.TrackPolylineTool.VerticalLineVisible = true; + globeControl1.Globe.TrackPolylineTool.TrackMode = EnumTrackMode.SpaceTrack; + trackPolylineEndMode = EnumTrackPolylineEndMode.HDM_Analysis; + + } + /// + /// 纵断面分析 + /// + /// + /// + private void buttonItemFX2_2_Click(object sender, EventArgs e) + { + if (globeControl1.Globe.SelObjectCount<1) + { + MessageBox.Show("请选择一条或者多条管线!", "提示", MessageBoxButtons.OK, + MessageBoxIcon.Information); + return; + } + 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); + } + } + List feats = SectionAnalysisTool.ZDMAnalysis(selectFeatures); + if (feats != null && feats.Count >= 1) + { + FrmProfileAnalysis frm = new FrmProfileAnalysis(globeControl1, feats); + frm.Show(this); + } + } + /// + /// 道路断面分析 + /// + /// + /// + private void buttonItemFX2_3_Click(object sender, EventArgs e) + { + globeControl1.Globe.Action = EnumAction3D.TrackPolyline; + globeControl1.Globe.TrackPolylineTool.VerticalLineVisible = true; + globeControl1.Globe.TrackPolylineTool.TrackMode = EnumTrackMode.SpaceTrack; + trackPolylineEndMode = EnumTrackPolylineEndMode.DLDM_Analysis; + + } + /// + /// 基线剖面分析 + /// + /// + /// + private void buttonItemFX2_4_Click(object sender, EventArgs e) + { + globeControl1.Globe.Action = EnumAction3D.TrackPolyline; + globeControl1.Globe.TrackPolylineTool.VerticalLineVisible = true; + globeControl1.Globe.TrackPolylineTool.TrackMode = EnumTrackMode.SpaceTrack; + trackPolylineEndMode = EnumTrackPolylineEndMode.JXPM_Analysis; + + } + + #endregion + /// + /// 创建拓扑 + /// + /// + /// + private void buttonItemFX3_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX3_1.Text); + + FrmGenAndFaMenTopu frm = new FrmGenAndFaMenTopu(globeControl1, m_PipelineLayerNames, valueLayerNames); + frm.Show(this); + } + #region Predator :拓扑分析 + /// + /// 上游分析 + /// + /// + /// + private void buttonItemFX3_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX3_2.Text); + NetworkTraceUpDown(true); + } + /// + /// 下游分析 + /// + /// + /// + private void buttonItemFX3_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX3_3.Text); + NetworkTraceUpDown(false); + } + + /// + /// 上下游追踪 功能 + /// + /// + private void NetworkTraceUpDown(Boolean bTraceUp) + { + GSOFeature selLineFeature = globeControl1.Globe.SelectedObject; + if (selLineFeature == null || selLineFeature.Geometry == null || selLineFeature.Geometry.Type != EnumGeometryType.GeoPolyline3D) + { + MessageBox.Show("请点击“编辑”—“选中对象”选择一条线!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); + return; + } + GSOLayer selLayer = globeControl1.Globe.SelectedObjectLayer; + + NetworkAnalysisTool.TraceUpDownAnalysis(bTraceUp, + selLineFeature, selLayer); + } + + /// + /// 流向分析 + /// + /// + /// + private void buttonItemFX3_4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX3_4.Text); + + FrmFlow frm = new FrmFlow(globeControl1, m_PipelineLayerNames); + frm.Show(this); + } + /// + /// 关阀分析 + /// + /// + /// + private void buttonItemFX3_5_Click(object sender, EventArgs e) + { + if (globeControl1.Globe.SelObjectCount < 1) + { + MessageBox.Show("请选中至少一根管线!!"); + buttonItemFX3_5.Checked = false; + return; + } + GSOLayer resLayer = null; + GSOFeature resFeature = null; + globeControl1.Globe.GetSelectObject(0, out resFeature, out resLayer); + + String pipeLayerName = resLayer.Caption; + String pipeLayerNamePrefix = pipeLayerName.Substring(0, pipeLayerName.IndexOf("管线")); + GSOLayer valveLayer = globeControl1.Globe.Layers[pipeLayerNamePrefix + "阀门"]; + if (valveLayer == null) + { + MessageBox.Show("无" + pipeLayerNamePrefix+"阀门图层", "提示"); + return; + } + + GSOFeatures valveFeats = NetworkAnalysisTool.CloseValvesAnalysis(resFeature, + resLayer, valveLayer); + + if (valveFeats != null) + { + FrmCloseValves frm = new FrmCloseValves(this.globeControl1, valveFeats); + frm.Show(this); + } + else + { + MessageBox.Show("未找到关闭阀门"); + } + } + + /// + /// 连通分析 + /// + /// + /// + private void buttonItemFX3_6_Click(object sender, EventArgs e) + { + if (globeControl1.Globe.SelObjectCount < 2) + { + MessageBox.Show("请选中至少两个管线!!"); + buttonItemFX3_6.Checked = false; + return; + } + GSOFeature selFeat0, selFeat1; + GSOLayer layer0,layer1; + globeControl1.Globe.GetSelectObject(0, out selFeat0, out layer0); + globeControl1.Globe.GetSelectObject(1, out selFeat1, out layer1); + + if (!layer0.IsSameInnerObject(layer1)) + { + MessageBox.Show("不在同一个图层!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); + buttonItemFX3_6.Checked = false; + return; + } + NetworkAnalysisTool.ConnexityAnalysis(selFeat0, selFeat1, layer0); + } + /// + /// 爆管分析 + /// + /// + /// + private void buttonItemFX3_7_Click(object sender, EventArgs e) + { + NetworkTraceUpDown(true); //上游追踪: + + GSOFeature selLineFeature = globeControl1.Globe.SelectedObject; + if (selLineFeature == null || selLineFeature.Geometry == null || selLineFeature.Geometry.Type != EnumGeometryType.GeoPolyline3D) + { + MessageBox.Show("请点击“编辑”—“选中对象”选择一条线!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); + return; + } + GSOLayer selLayer = globeControl1.Globe.SelectedObjectLayer; + + NetworkAnalysisTool.ExplodeAnalysis(this.globeControl1,selLineFeature,selLayer); + + this.buttonItemFX3_5_Click(sender, e); //关阀分析: + + } + + #endregion + /// + /// 多边形开挖 + /// + /// + /// + private void buttonItemFX4_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_1.Text); + + trackflag = "pit"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; //是这个么?是的,在模型上 + } + /// + /// 挖方量分析 + /// + /// + /// + private void buttonItemFX4_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_2.Text); + + trackflag = "digFillAnalysis"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; + ActionToolMenuChecked(); + } + /// + /// 沿线开挖 + /// + /// + /// + private void buttonItemFX4_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_3.Text); + + if (!buttonItemFX4_3.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; + buttonItemFX4_3.Checked = true; + } + } + else + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + buttonItemFX4_3.Checked = false; + globeControl1.Globe.TrackPolylineTool.VerticalLineVisible = false; + } + ActionToolMenuChecked(); + } + /// + /// 创建隧道 + /// + /// + /// + private void buttonItemFX4_4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_4.Text); + + 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("场景中未加载隧道图层!", "提示"); + } + } + /// + /// 隐藏隧道 + /// + /// + /// + private void buttonItemFX4_5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_5.Text); + + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption("隧道"); + if (layer != null) + { + layer.Visible = !layer.Visible; + } + } + /// + /// 删除隧道 + /// + /// + /// + private void buttonItemFX4_6_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_6.Text); + + 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("请选中要删除的隧道!", "提示"); + } + } + /// + /// 通视分析 + /// + /// + /// + private void buttonItemFX5_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX5_1.Text); + + if (globeControl1.Globe.Action != EnumAction3D.VisibilityAnalysis) + { + //btnSpaceVisibilityAnalysis.Checked = true; + globeControl1.Globe.Action = EnumAction3D.VisibilityAnalysis; + } + else + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + // SetButtonChecked(); + } + } + /// + /// 可视域分析 + /// + /// + /// + private void buttonItemFX5_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX5_2.Text); + + globeControl1.Globe.Action = EnumAction3D.ViewshedAnalysis; + } + /// + /// 可视包络分析 + /// + /// + /// + private void buttonItemFX5_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX5_3.Text); + + globeControl1.Globe.Action = EnumAction3D.ViewEnvelopeAnalysis; + } + /// + /// 缓冲区分析 + /// + /// + /// + private void buttonItemFX6_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX6_1.Text); + + GSOFeature feat = globeControl1.Globe.SelectedObject; + if (feat == null) + { + MessageBox.Show("请选择要分析的要素!"); + return; + } + if (feat.Geometry.Type == EnumGeometryType.GeoPolyline3D) + { + GSOGeoPolyline3D line1 = feat.Geometry as GSOGeoPolyline3D; + if (line1 == null) + { + MessageBox.Show("请选择一条管线!"); + return; + } + + FrmBufferAnalysis frm = new FrmBufferAnalysis(globeControl1, line1, layerTemp); + frm.Show(this); + } + else + { + FrmBufferAnalysisBSQ frm = new FrmBufferAnalysisBSQ(globeControl1, layerTemp, bsqPT); + frm.Show(this); + } + + } + /// + /// 附属物分析 + /// + /// + /// + private void buttonItemFX6_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX6_2.Text); + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + FrmAccessoryAnalysis dlg = new FrmAccessoryAnalysis(globeControl1, layerTemp); + dlg.Show(this); + } + /// + /// 无源淹没分析 + /// + /// + /// + private void buttonItemFX6_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX6_3.Text); + + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + trackflag = "FloodAnalysis"; + } + /// + /// 水平距离 + /// + /// + /// + private void buttonItemLS1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS1.Text); + + globeControl1.Globe.Action = EnumAction3D.MeasureDistance; + globeControl1.Globe.DistanceRuler.SpaceMeasure = false; + buttonItemLS5.Checked = false; + } + /// + /// 垂直距离 + /// + /// + /// + private void buttonItemLS2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS2.Text); + + buttonItemLS5.Checked = false; + globeControl1.Globe.Action = EnumAction3D.MeasureHeight; + globeControl1.Globe.DistanceRuler.SpaceMeasure = false; + } + /// + /// 空间距离 + /// + /// + /// + private void buttonItemLS3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS3.Text); + + buttonItemLS5.Checked = false; + globeControl1.Globe.Action = EnumAction3D.MeasureDistance; + globeControl1.Globe.DistanceRuler.SpaceMeasure = true; + } + /// + /// 地表距离 + /// + /// + /// + private void buttonItemLS4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS4.Text); + + buttonItemLS5.Checked = false; + globeControl1.Globe.Action = EnumAction3D.MeasureDistance; + globeControl1.Globe.DistanceRuler.SpaceMeasure = false; + } + /// + /// 高度量算 + /// + /// + /// + private void buttonItemLS5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS5.Text); + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + buttonItemLS5.Checked = !buttonItemLS5.Checked; + if (buttonItemLS5.Checked) + { + globeControl1.Globe.Action = EnumAction3D.SelectObject; + } + } + /// + /// 水平面积 + /// + /// + /// + private void buttonItemLS6_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS6.Text); + + buttonItemLS5.Checked = false; + globeControl1.Globe.Action = EnumAction3D.MeasureArea; + globeControl1.Globe.AreaRuler.SpaceMeasure = true; + } + /// + /// 地表面积 + /// + /// + /// + private void buttonItemLS7_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS7.Text); + + buttonItemLS5.Checked = false; + globeControl1.Globe.Action = EnumAction3D.MeasureArea; + globeControl1.Globe.AreaRuler.SpaceMeasure = false; + + } + + # region Fan 重构标注代码 + /// + /// 标高标注 + /// + /// + /// + private void buttonItemSZ1_Click(object sender, EventArgs e) + { + GSOFeature resFeature = IsPipeLineOfSelectedObj(); + if (resFeature == null) + { + MessageBox.Show("请选中一根管线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + GSOGeoPolyline3D selLine = resFeature.Geometry as GSOGeoPolyline3D; + if (selLine[0].Count <= 1) + { + return; + } + + MarkTools.getInstance().showMarker(resFeature, + globeControl1, EnumMarkLayer.Mark_Altitude, ""); + } + /// + /// 管径标注 + /// + GSOFeature radiusMarkerFeature; + private void buttonItemBZ2_Click(object sender, EventArgs e) + { + GSOFeature resFeature = IsPipeLineOfSelectedObj(); + if (resFeature == null) + { + MessageBox.Show("请选中一根管线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + GSOGeoPolyline3D selLine = resFeature.Geometry as GSOGeoPolyline3D; + if (selLine[0].Count <= 1) + { + return; + } + + MarkTools.getInstance().showMarker(resFeature, + globeControl1, EnumMarkLayer.Mark_Diameter, ""); + } + /// + /// 埋深标注 + /// + /// + /// + private void buttonItemBZ3_Click(object sender, EventArgs e) + { + GSOFeature resFeature = IsPipeLineOfSelectedObj(); + if (resFeature == null) + { + MessageBox.Show("请选中一根管线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + GSOGeoPolyline3D selLine = resFeature.Geometry as GSOGeoPolyline3D; + if (selLine[0].Count <=1) + { + return; + } + + MarkTools.getInstance().showMarker(resFeature, + globeControl1, EnumMarkLayer.Mark_Depth, ""); + + } + /// + /// 坐标标注 + /// + /// + /// + private void buttonItemBZ4_Click(object sender, EventArgs e) + { + GSOFeature resFeature = IsPipeLineOfSelectedObj(); + if (resFeature == null) + { + MessageBox.Show("请选中一根管线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + GSOGeoPolyline3D selLine = resFeature.Geometry as GSOGeoPolyline3D; + if (selLine[0].Count <= 1) + { + return; + } + MarkTools.getInstance().showMarker(resFeature, + globeControl1, EnumMarkLayer.Mark_Location, ""); + } + /// + /// 距离标注 + /// + bool distanceMarker = false; + private void buttonItemBZ5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBZ5.Text); + + globeControl1.Globe.Action = EnumAction3D.TrackPolyline; + //globeControl1.Globe.DistanceRuler.MeasureMode = EnumDistanceMeasureMode.HVSLineMeasure; + distanceMarker = true; + } + /// + /// 自定义标注 + /// + /// + /// + private void buttonItemBZ6_Click(object sender, EventArgs e) + { + GSOFeature f = globeControl1.Globe.SelectedObject; + GSOLayer l = globeControl1.Globe.SelectedObjectLayer; + FrmCustomLabel frm = new FrmCustomLabel(globeControl1, l, f); + if (frm.ShowDialog() == DialogResult.OK) + { + MarkTools.getInstance().showMarker(f, globeControl1, EnumMarkLayer.Mark_Custom, frm.labelText); + } + } + /// + /// 扯旗标注 + /// + /// + /// + private void buttonItemBZ7_Click(object sender, EventArgs e) + { + GSOFeature f = globeControl1.Globe.SelectedObject; + GSOLayer l = globeControl1.Globe.SelectedObjectLayer; + FrmMarker frm = new FrmMarker(); + if (frm.ShowDialog() == DialogResult.OK) + { + MarkTools.getInstance().showMarker(f, globeControl1, EnumMarkLayer.Mark_Custom, frm.markerContent); + } + } + /// + /// 坡度标注 + /// + /// + /// + private void buttonItemBZ8_Click(object sender, EventArgs e) + { + GSOFeature resFeature = IsPipeLineOfSelectedObj(); + if (resFeature == null) + { + MessageBox.Show("请选中一根管线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + GSOGeoPolyline3D selLine = resFeature.Geometry as GSOGeoPolyline3D; + if (selLine[0].Count <= 1) + { + return; + } + + MarkTools.getInstance().showMarker(resFeature, + globeControl1, EnumMarkLayer.Mark_Slope, ""); + } + /// + /// 属性标注 + /// + /// + /// + private void buttonItemBZ9_Click(object sender, EventArgs e) + { + GSOFeature f = globeControl1.Globe.SelectedObject; + GSOLayer l = globeControl1.Globe.SelectedObjectLayer; + FrmPropertiesMarker frm = new FrmPropertiesMarker(globeControl1, l, f); + if (frm.ShowDialog() == DialogResult.OK) + { + MarkTools.getInstance().showMarker(f, globeControl1, EnumMarkLayer.Mark_Property, frm.labelText); + } + } + /// + /// 红线工具 + /// + /// + /// + private void buttonItemBZ10_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBZ10.Text); + 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; + } + } + /// + /// 标注管理 + /// + /// + /// + private void buttonItemBZ11_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBZ11.Text); + + buttonItemBZ11.Checked = !buttonItemBZ11.Checked; + 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 (buttonItemBZ11.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(); + } + } + + #endregion + /// + /// 飞行到目标点 + /// + /// + /// + private void buttonItemFXGJ1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFXGJ1.Text); + + FrmSetFlytoPos.ShowForm(globeControl1); + + } + /// + /// 自定义飞行 + /// + /// + /// + private void buttonItemFXGJ2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFXGJ2.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); + } + } + /// + /// 绕中心点飞行 + /// + /// + /// + private void buttonItemFXGJ3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFXGJ3.Text); + + globeControl1.Globe.FlyAroundCenter(10000, EnumFlyRepeatValueType.MiliSeconds); + globeControl1.Globe.CurFlyID = 1; + } + /// + /// 绕眼睛飞行 + /// + /// + /// + private void buttonItemFXGJ4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFXGJ4.Text); + + globeControl1.Globe.FlyAroundEye(720, EnumFlyRepeatValueType.Degrees); + globeControl1.Globe.CurFlyID = 2; + } + + /// + /// 权限管理 + /// + /// + /// + private void buttonItemXT1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT1.Text); + + FrmUserRoleMgr frm = new FrmUserRoleMgr(); + frm.ShowDialog(); + } + /// + /// 数据库管理 + /// + /// + /// + private void buttonItemXT2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT2.Text); + + //查看数据库列表 + FrmDbManager frm = new FrmDbManager(); + frm.ShowDialog(); + } + /// + /// 用户列表 + /// + /// + /// + private void buttonItemXT3_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT3_1.Text); + + FrmUserManager frm = new FrmUserManager(); + frm.ShowDialog(); + } + /// + /// 创建新用户 + /// + /// + /// + private void buttonItemXT3_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT3_2.Text); + + FrmUserAdd frm = new FrmUserAdd(-1); + frm.ShowDialog(); + } + /// + /// 人员修改 + /// + /// + /// + private void buttonItemXT4_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT4_2.Text); + + FrmAppUSER appUSER = new FrmAppUSER(); + appUSER.ShowDialog(); + } + /// + /// 增加人员 + /// + /// + /// + private void buttonItemXT4_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT4_1.Text); + + FrmAppUSERRESET appUSERRESET = new FrmAppUSERRESET(); + appUSERRESET.ShowDialog(); + } + /// + /// 统计数据 + /// + /// + /// + private void buttonItemZTT1_Click(object sender, EventArgs e) + { + ////日志记录 + //LogManager.saveLog(Utility.userName, this.buttonItemZTT1.Text); + + //PATM patm = new PATM(); + //patm.operation = "Statistic"; + //patm.Text = "统计专题图管理"; + //patm.ShowDialog(); + } + /// + /// 热点功能统计 + /// + /// + /// + private void buttonItemZTT2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT2.Text); + + FrmHotFuncStat frmhfs = new FrmHotFuncStat(); + frmhfs.ShowDialog(); + } + + private void buttonItemZTT3_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT3_1.Text); + + FrmAPP appfrm = new FrmAPP("专题图申请"); + appfrm.ShowDialog(); + } + + private void buttonItemZTT3_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT3_2.Text); + + FrmAPPFORASK appForask = new FrmAPPFORASK("专题图审核"); + appForask.ShowDialog(); + } + + private void buttonItemZTT3_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT3_3.Text); + + FrmAPPregion appregion = new FrmAPPregion("专题图审核"); + appregion.ShowDialog(); + } + + private void buttonItemZTT4_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT4_1.Text); + + FrmAPP appfrm = new FrmAPP("打印申请"); + appfrm.ShowDialog(); + } + + private void buttonItemZTT4_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT4_2.Text); + + FrmAPPFORASK appForask = new FrmAPPFORASK("打印审核"); + appForask.ShowDialog(); + } + + private void buttonItemZTT4_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT4_3.Text); + + FrmAPPregion appregion = new FrmAPPregion("打印审核"); + appregion.ShowDialog(); + } + + private void buttonItemZTT5_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT5_1.Text); + + FrmAPP appfrm = new FrmAPP("拷贝申请"); + appfrm.ShowDialog(); + } + + private void buttonItemZTT5_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT5_2.Text); + + FrmAPPFORASK appForask = new FrmAPPFORASK("拷贝审核"); + appForask.ShowDialog(); + } + + private void buttonItemZTT5_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT5_3.Text); + + FrmAPPregion appregion = new FrmAPPregion("拷贝审核"); + appregion.Show(); + } + + private int connectServerCount = 0; + + /// + /// 还原球到实测库 + /// + 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); + } + + if (layerManagerNode.Nodes.Count > 0) + { + for (int i = layerManagerNode.Nodes.Count - 1; i >= 0; i--) + { + layerManagerNode.Nodes[i].Remove(); + + } + } + + globeControl1.Refresh(); + + } + + private void buttonItemSPSZ_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSPSZ.Text); + + FrmLayerControl frm = new FrmLayerControl(layerTree, globeControl1, globeControl2); + frm.Show(this); + } + + /// + /// 碰撞审查 + /// + /// + /// + private void buttonItemSH1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSH1.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 buttonItemSH2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSH2.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 buttonItemSH3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSH3.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 buttonItemSH4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSH4.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 buttonItemSH5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSH5.Text); + FrmCityServerLineAnalysis frm = new FrmCityServerLineAnalysis(globeControl1, m_PipelineLayerNames); + frm.Show(this); + } + #region 数据管理-导入文件 + ///// + ///// 数据管理-导入本地坐标系文件 + ///// + ///// + ///// + //private void buttonItemSJGL1_1_Click(object sender, EventArgs e) + //{ + // //日志记录 + // LogManager.saveLog(Utility.userName, this.buttonItemSJGL1_1.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(); + // } + // } + //} + + ///// + ///// 数据管理-导入其他坐标系文件 + ///// + ///// + ///// + //private void buttonItemSJGL1_2_Click(object sender, EventArgs e) + //{ + // //日志记录 + // LogManager.saveLog(Utility.userName, this.buttonItemSJGL1_2.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(); + // } + // } + //} + #endregion + /// + /// 数据质量检查 + /// + /// + /// + private void buttonItemSJGL2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL2.Text); + FrmValiData frm = new FrmValiData(globeControl1); + frm.ShowDialog(); + } + /// + /// 数据预处理 + /// + /// + /// + private void buttonItemSJGL3_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL3.Text); + + FrmEditShapeFile frm = new FrmEditShapeFile(globeControl1); + frm.ShowDialog(this); + } + /// + /// 连接数据库 + /// + /// + /// + private void buttonItemSJGL4_1_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL4_1.Text); + + FrmDatabaseParaSetting frm = new FrmDatabaseParaSetting(globeControl1); + if (frm.ShowDialog() == DialogResult.OK) + { + ds = FrmDatabaseParaSetting.ds; + if (ds != null) + { + ds.IsCloseSaved = false; + } + } + } + /// + /// 管线入库 + /// + /// + /// + private void buttonItemSJGL4_2_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL4_2.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 buttonItemSJGL4_3_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL4_3.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 buttonItemSJGL5_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL5.Text); + + Cyberpipe.Forms.FrmProject frm = new Cyberpipe.Forms.FrmProject(); + frm.ShowDialog(); + } + /// + /// 元数据基本管理 + /// + /// + /// + private void buttonItemSJGL6_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL6_1.Text); + + FrmMetadata frmmd = new FrmMetadata(); + frmmd.ShowDialog(); + } + /// + /// 元数据查询管理 + /// + /// + /// + private void buttonItemSJGL6_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL6_2.Text); + + FrmMetadataStat frmmds = new FrmMetadataStat(); + //frmmds.Show(); + frmmds.ShowDialog(); + } + /// + /// 操作日志管理 + /// + /// + /// + private void buttonItemSJGL7_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL7.Text); + + FrmLogOper frmlo = new FrmLogOper(); + frmlo.ShowDialog(); + } + /// + /// 数据字典管理 + /// + /// + /// + private void buttonItemSJGL8_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL8.Text); + + FrmMDDictory frmmdd = new FrmMDDictory(); + frmmdd.ShowDialog(); + } + /// + /// 数据库备份 + /// + /// + /// + private void buttonItemSJGL9_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL9.Text); + + //新 + FrmBACKORACLE backOracle = new FrmBACKORACLE(); + backOracle.Show(); + } + /// + /// 创建管段 + /// + /// + /// + private void buttonItemBJ1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ1.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; + } + } + /// + /// 创建附属物 + /// + /// + /// + private void buttonItemBJ2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ2.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); + } + } + /// + /// 创建特征管点 + /// + /// + /// + private void buttonItemBJ3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ3.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); + } + } + /// + /// 绘制城市七线 + /// + /// + /// + private void buttonItemBJ4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ4.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; + } + } + } + /// + /// 选中对象 + /// + /// + /// + private void buttonItemBJ5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ5.Text); + + globeControl1.Globe.Action = EnumAction3D.SelectObject; + } + /// + /// 平移对象 + /// + /// + /// + private void buttonItemBJ6_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ6.Text); + + globeControl1.Globe.Action = EnumAction3D.MoveObject; + } + /// + /// 升降对象 + /// + /// + /// + private void buttonItemBJ7_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ7.Text); + + globeControl1.Globe.Action = EnumAction3D.ElevateObject; + } + /// + /// 旋转对象 + /// + /// + /// + private void buttonItemBJ8_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ8.Text); + + globeControl1.Globe.Action = EnumAction3D.RotateObject; + } + /// + /// 连接管段 + /// + /// + /// + private void buttonItemBJ9_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ9.Text); + + if (globeControl1.Globe.SelObjectCount < 2) + { + MessageBox.Show("对不起,请至少选中2个对象!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + return; + } + globeControl1.Globe.InsertJointPipeline(false); + } + /// + /// 后退 + /// + /// + /// + private void buttonItemBJ11_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemBJ11.Text); + globeControl1.Globe.UnDoEdit(); + } + /// + /// 前进 + /// + /// + /// + private void buttonItemBJ12_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemBJ12.Text); + + globeControl1.Globe.ReDoEdit(); + } + /// + /// 导出CAD + /// + /// + /// + private void buttonItemBJ10_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ10_1.Text); + + #region 导出成dxf格式 + List listVectorNames = new List(); + 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(); + #endregion + } + /// + /// 导出矢量 + /// + /// + /// + private void buttonItemBJ10_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ10_2.Text); + + List listVectorNames = new List(); + 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 buttonItemBJ13_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemBJ13.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(); + } + } + MessageBox.Show("删除成功!", "提示"); + } + else + { + MessageBox.Show("请选中要删除的模型!", "提示"); + } + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + } + + private void buttonItemHX1_1_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]; + string filePath = dlg.FileName; + string lastname = Path.GetFileName(filePath); + + 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(); + } + + } + } + } + + public struct LineStruct + { + public string layerName; + public string layerCode; + public string lineLength; + public string hxName; + } + + List lineStruct = new List(); + List featsList = new List(); + + /// + /// 红线审核 + /// + /// + /// + private void buttonItemHX2_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemHX2.Text); + redSH = true; + featsList.Clear(); + lineStruct.Clear(); + List listPipelineLayers = new List(); + + GSOLayer layer = null; + for (int i = 0; i < m_PipelineLayerNames.Count; i++) + { + layer = globeControl1.Globe.Layers.GetLayerByCaption(m_PipelineLayerNames[i]); + if (layer != null) + { + listPipelineLayers.Add(layer); + } + } + //yanxiaowei 重构 + GSOFeatures selectFeatures=new GSOFeatures(); + for (int i = 0; i < globeControl1.Globe.SelObjectCount; i++) + { + GSOFeature feature = null; + globeControl1.Globe.GetSelectObject(i, out feature, out layer); + selectFeatures.Add(feature); + } + DataTable table=new DataTable(); + + ClassGSOTool.CalculateRedLineResult(out table, redSH, selectFeatures, globeControl1, + listPipelineLayers,out lineStruct, out featsList); + + if (table.Rows.Count != 0) + AddDatagridView(table); + else + { + MessageBox.Show("没有侵入地块红线的管线数据!", "提示"); + dataGridViewX1.DataSource = null; + panelOfTable.Visible = false; + return; + } + } + + private void AddDatagridView(DataTable table) + { + dataGridViewX1.DataSource = table; + panelOfTable.Visible = true; + panelOfTable.Height = 200; + toolStripNumbers.Text = "红线审核 |共有:" + table.Rows.Count + "条"; + toolStripDropDownButton3.Visible = true; + } + /// + /// 主窗体 下方的工具条中的 导出.xls文件 按钮事件处理 + /// + /// + /// + private void toolStripDropDownButton3_Click(object sender, EventArgs e) + { + if (dataGridViewX1.Rows.Count == 0) + { + MessageBox.Show("表格内容为空!", "提示"); + return; + } + + string strSaveFile = string.Empty; + SaveFileDialog savefiledialog = new SaveFileDialog(); + savefiledialog.Filter = "Excel文件|*.xls,*.xlsx"; + savefiledialog.AddExtension = true; + savefiledialog.FileName = "红线审核"; + if (savefiledialog.ShowDialog() == DialogResult.OK) + strSaveFile = savefiledialog.FileName; + else return; + + ExpEXCEL.ExpToExcel(dataGridViewX1, strSaveFile, "红线审核", lineStruct, featsList); + MessageBox.Show("导出成功!"); + } + /// + /// 去除集合中重复的管线 + /// + /// + /// + /// + private GSOFeatures getFeaturesByFilter(GSOFeatures features, string fieldName) + { + if (features == null) + { + return null; + } + GSOFeatures featuresGet = new GSOFeatures(); + for (int i = 0; i < features.Length; i++) + { + GSOFeature featureFromFS = features[i]; + string fieldValueFromFS = featureFromFS.GetValue(fieldName).ToString().Trim(); + bool isHas = false; + for (int j = featuresGet.Length - 1; j >= 0; j--) + { + GSOFeature featureFromFSGet = featuresGet[j]; + string fieldValueFromFSGet = featureFromFSGet.GetValue(fieldName).ToString().Trim(); + if (fieldValueFromFS.Equals(fieldValueFromFSGet)) + { + isHas = true; + break; + } + } + if (isHas == false) + { + featuresGet.Add(featureFromFS.Clone()); + } + } + return featuresGet; + } + + private void sliderItem2_ValueChanged(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.sliderItem2.Text); + + globeControl1.Globe.GroundOpaque = 100 - sliderItem2.Value; + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(roadLayerName);//("180fd"); + if (layer != null) + { + layer.Opaque = 100 - sliderItem2.Value; + } + layer = globeControl2.Globe.Layers.GetLayerByCaption("180fd");//("180fd"); + if (layer != null) + { + layer.Opaque = 100 - sliderItem2.Value; + } + globeControl2.Globe.GroundOpaque = 100 - sliderItem2.Value; + + optiValue = sliderItem2.Value; + } + /// + /// 数据管理导入文件 + /// + /// + /// + private void buttonItemSJGL1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL1.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.Multiselect = true; + if (dlg.ShowDialog() == DialogResult.OK) + { + //自定义lprj文件名,从程序中复制一lprj文件。 + string filePath = dlg.FileName; + string lastname = Path.GetFileName(filePath); + + 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, 100); + + globeControl1.Refresh(); + } + } + } + + private void buttonItemHX1_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemHX1.Text); + + GSODataSource dataSpace = globeControl1.Globe.DataManager.OpenOracleDataSource(Utility.DBServer.Trim() + "/" + Utility.dbdatabase.Trim(), "", "", Utility.userID, Utility.DBPassword); + string filepath = ""; + //日志记录 + OpenFileDialog dlg = new OpenFileDialog(); + dlg.Filter = "矢量数据(*.shp)|*.shp|矢量数据(*.lgd)|*.lgd|CAD数据(*.dxf)|*.dxf|全部支持格式(*.lgd,*.shp,*.dxf)|*.lgd;*.shp;*.dxf;"; + dlg.Multiselect = true; + + #region 临时图层显示 + if (dlg.ShowDialog() == DialogResult.OK) + { + string filePath = dlg.FileName; + string lastname = Path.GetFileName(filePath); + + #region + for (int i = 0; i < dlg.FileNames.Length; i++) + { + string strDataPath = dlg.FileNames[i]; + filepath = strDataPath; + + GSOLayer layer = globeControl1.Globe.Layers.Add(strDataPath); + GSOFeatures RedFeatures = layer.GetAllFeatures(); + + 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(); + RedFeatures = features; + 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; + } + + /////////////////////////////////////////////////////////////////////////////////////////// + globeControl1.Globe.Layers.MoveTo(0, globeControl1.Globe.Layers.Count - 1); + globeControl1.Refresh(); + } + + IModelBuilder modelBuilder = new RedLineBuilder(); + + modelBuilder.batchInsert(dataSpace, redDt, RedFeatures); + + } + #endregion + + } + #endregion + } + /// + /// 定位 + /// + /// + /// + private void buttonItemLocation_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemLocation.Text); + + FrmFlyToPosition fly = new FrmFlyToPosition(globeControl1,globeControl2); + fly.Show(this); + } + /// + /// 2015-10-17演示代码 红线审核 + /// + /// + /// + private void ribbonTabItem6_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.FlyToPosition(new GSOPoint3d(120.610963, 31.188121, 50), EnumAltitudeMode.Absolute, -4, 50, 800); + globeControl1.Globe.FlyToPointSpeed = 10000000; + globeControl1.Globe.Action = EnumAction3D.SelectObject; + globeControl1.Refresh(); + + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + + //zhanshi = false; + redSH = true; + splitContainer1.Panel2Collapsed = true; + legendSG.Visible = false; + legendSC.Visible = false; + ClearGZData(); + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = true; + } + + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 基础工具 + /// + /// + /// + private void ribbonTabItem1_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + //zhanshi = false; + redSH = false; + splitContainer1.Panel2Collapsed = true; + panelOfTable.Visible = false; + legendSC.Visible = false; + legendSG.Visible = false; + ClearGZData(); + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + + + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 一键审核 + /// + /// + /// + private void ribbonTabItem11_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + //zhanshi = false; + redSH = false; + splitContainer1.Panel2Collapsed = true; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + panelOfTable.Visible = false; + legendSC.Visible = false; + legendSG.Visible = false; + ClearGZData(); + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + + + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 右屏添加冰箱数据 + /// + void AddDataToGlobeControl2() + { + + bool modelDataBool = false; + for (int i = globeControl2.Globe.Layers.Count - 1; i >= 0; i--) + { + GSOLayer layer = globeControl2.Globe.Layers[i]; + if (layer.Name.Contains("fttp:")) + { + modelDataBool = true; + break; + } + } + + if (modelDataBool == false) + { + GSOLayer ly = globeControl1.Globe.Layers.GetLayerByCaption("天地图地图"); + globeControl2.Globe.Layers.Add(ly); + } + else + { + return; + } + } + /// + /// 双屏对比 + /// + /// + /// + private void ribbonTabItem9_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent += new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent += new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + panelOfTable.Visible = false; + + splitContainer1.Panel2Collapsed = false; + //zhanshi = true; + redSH = false; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + sliderItem2.Value = 100 - globeControl1.Globe.GroundOpaque; + globeControl2.Globe.GroundOpaque = globeControl1.Globe.GroundOpaque; + legendSC.Visible = true; + legendSG.Visible = true; + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + AddDataToGlobeControl2(); + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 文档管理 + /// + /// + /// + private void ribbonTabItem4_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + panelOfTable.Visible = false; + //zhanshi = false; + redSH = false; + splitContainer1.Panel2Collapsed = true; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + legendSC.Visible = false; + legendSG.Visible = false; + ClearGZData(); + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 基础管理 + /// + /// + /// + private void ribbonTabItem14_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + panelOfTable.Visible = false; + //zhanshi = false; + redSH = false; + splitContainer1.Panel2Collapsed = true; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + legendSC.Visible = false; + legendSG.Visible = false; + ClearGZData(); + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 权限管理 + /// + /// + /// + private void ribbonTabItem2_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + panelOfTable.Visible = false; + //zhanshi = false; + redSH = false; + splitContainer1.Panel2Collapsed = true; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + legendSC.Visible = false; + legendSG.Visible = false; + ClearGZData(); + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + GSOFeature dpFeatuer = null; + /// + /// 双屏分析,点击管段分析 + /// + /// + /// + private void buttonItem8_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItem8.Text); + + //FrmCompareFeature frmCompareFeature = new FrmCompareFeature(globeControl1, globeControl2, layerTemp, layerTemp2,m_PipelineLayerNames,sgPipeLayersNames); + int width = this.Width; + FrmCompareFeature.ShowForm(globeControl1, globeControl2, layerTemp, layerTemp2, m_PipelineLayerNames, sgPipeLayersNames,width); + //frmCompareFeature.Location = new Point((this.Width - frmCompareFeature.Width)/2,50); + //frmCompareFeature.Show(this); + + } + /// + /// 红线审核导出图片 + /// + /// + /// + private void buttonItemDCTP_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemDCTP.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))); + */ + int mapWidth = 0; + int mapHeight = 0; + Point pt = getUpperLeftPoint(pt1, pt2, out mapWidth, out mapHeight); + int rightBottomX = pt.X + mapWidth; + int rightBottomY = pt.Y + mapHeight; + Image myImg = new Bitmap(mapWidth, mapHeight); + Graphics g = Graphics.FromImage(myImg); + g.CopyFromScreen(pt, new Point(0, 0), new Size(rightBottomX, rightBottomY)); + + 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; + } + } + } + /// + /// 标识器全区域统计 + /// + /// + /// + private void 标识器分类统计ToolStripMenuItem_Click(object sender, EventArgs e) + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + FrmBSQStatis bsqStatis = new FrmBSQStatis(globeControl1,null); + //FrmBSQStatis bsqStatis = new FrmBSQStatis(); + bsqStatis.Show(this); + } + /// + /// 标识器绘制区域统计 + /// + /// + /// + private void 标识器分类统计ToolStripMenuItem1_Click(object sender, EventArgs e) + { + trackflag = "BSQDuoBianXiangStatis"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + } + + #region 保存和加载审核库加载的图层 + /* + private void saveLayerList(TreeNodeCollection treeNodeList) + { + string configPath = Application.StartupPath + "\\configLayerList.xml"; + try + { + XmlDocument doc = new XmlDocument(); + doc.Load(configPath); + XmlNode dbParams = doc.SelectSingleNode("Params/dbparams"); + XmlNode dbLayers = doc.SelectSingleNode("Params/dblayers"); + XmlNode layers = doc.SelectSingleNode("Params/layers"); + dbParams.RemoveAll(); + dbLayers.RemoveAll(); + layers.RemoveAll(); + + List listDS = new List(); + String shDatasourceName = Utility.sgdbip + "/" + Utility.sgdbname + "_" + Utility.sgdbuser; + bool flag = false; + + for (int i = 0; i < globeControl1.Globe.DataManager.DataSourceCount; i++) + { + GSODataSource ds = globeControl1.Globe.DataManager.GetDataSourceAt(i); + if (ds != null && ds.Type == EnumDataSourceType.SqlServer || ds.Type == EnumDataSourceType.Oracle) + { + if (ds.Name == shDatasourceName) + { + //防止因为多次连接同一个数据库 + if (flag == true) + { + break; + } + flag = true; + listDS.Add(ds); + GSODataSourceCnn conn = ds.GetConnectionInfo(); + + XmlElement dbparam = doc.CreateElement("shdbparam"); + XmlElement ip = doc.CreateElement("ship"); + ip.InnerText = conn.Server; + + XmlElement dbname = doc.CreateElement("shdbname"); + dbname.InnerText = conn.Database; + + XmlElement username = doc.CreateElement("shusername"); + username.InnerText = conn.User; + + XmlElement password = doc.CreateElement("shpassword"); + password.InnerText = conn.Password; + + XmlElement type = doc.CreateElement("shtype"); + if (ds.Type == EnumDataSourceType.SqlServer) + { + type.InnerText = "sqlserver"; + } + else + { + type.InnerText = "oracle"; + } + + dbparam.AppendChild(ip); + dbparam.AppendChild(dbname); + dbparam.AppendChild(username); + dbparam.AppendChild(password); + dbparam.AppendChild(type); + dbParams.AppendChild(dbparam); + } + + } + } + + for (int i = 0; i < treeNodeList.Count; i++) + { + GSOLayer layer = treeNodeList[i].Tag as GSOLayer; + if (Path.GetExtension(layer.Name) == "") + { + XmlElement dbLayer = doc.CreateElement("dblayer"); + XmlAttribute attri = doc.CreateAttribute("dbindex"); + for (int j = 0; j < listDS.Count; j++) + { + if (layer.Dataset.DataSource.Name == listDS[j].Name) + { + attri.Value = j.ToString(); + break; + } + } + dbLayer.Attributes.Append(attri); + dbLayer.InnerText = layer.Name; + + dbLayers.AppendChild(dbLayer); + } + else + { + XmlElement dbLayer = doc.CreateElement("layer"); + dbLayer.InnerText = layer.Name; + layers.AppendChild(dbLayer); + } + } + + doc.Save(configPath); + } + catch (Exception e) + { + + } + } + + private void openLayerList() + { + layerManagerNode.Nodes.Clear(); + + string configPath = Application.StartupPath + "\\configLayerList.xml"; + try + { + XmlDocument doc = new XmlDocument(); + doc.Load(configPath); + XmlNode dbParams = doc.SelectSingleNode("Params/dbparams"); + XmlNode dbLayers = doc.SelectSingleNode("Params/dblayers"); + XmlNode layers = doc.SelectSingleNode("Params/layers"); + + List listDS = new List(); + for (int i = 0; i < dbParams.ChildNodes.Count; i++) + { + string ip = ""; + string dbname = ""; + string username = ""; + string password = ""; + string type = ""; + XmlNode node = dbParams.ChildNodes.Item(i); + for (int j = 0; j < node.ChildNodes.Count; j++) + { + XmlNode nodeChild = node.ChildNodes.Item(j); + + if (nodeChild != null && nodeChild.Name == "ship") + { + ip = nodeChild.InnerText; + } + else if (nodeChild != null && nodeChild.Name == "shdbname") + { + dbname = nodeChild.InnerText; + } + else if (nodeChild != null && nodeChild.Name == "shusername") + { + username = nodeChild.InnerText; + } + else if (nodeChild != null && nodeChild.Name == "shpassword") + { + password = nodeChild.InnerText; + } + else if (nodeChild != null && nodeChild.Name == "shtype") + { + type = nodeChild.InnerText; + } + } + + if (type == "sqlserver") + { + GSODataSource ds = globeControl1.Globe.DataManager.OpenSqlServerDataSource(ip, "", dbname, username, password); + listDS.Add(ds); + } + else if (type == "oracle") + { + GSODataSource ds = globeControl1.Globe.DataManager.OpenOracleDataSource(ip + "/" + dbname, "", "", username, password); + listDS.Add(ds); + } + } + + for (int i = 0; i < dbLayers.ChildNodes.Count; i++) + { + XmlNode node = dbLayers.ChildNodes.Item(i); + if (node != null) + { + string layerName = node.InnerText; + XmlAttribute attri = node.Attributes["dbindex"]; + if (attri != null) + { + int dbIndex = -1; + if (int.TryParse(attri.Value, out dbIndex)) + { + GSODataset dataset = listDS[dbIndex].GetDatasetByName(layerName); + globeControl1.Globe.Layers.Add(dataset); + //更新树节点 + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + TreeNode layerNode = new TreeNode(); + layerNode.Tag = layer; + layerNode.Text = layer.Dataset.Caption; + layerNode.ImageIndex = 0; + layerNode.SelectedImageIndex = 0; + layerNode.Checked = layer.Visible; + layerManagerNode.Nodes.Insert(0, layerNode); + // layerManagerNode.Expand(); + + + } + } + } + } + for (int i = 0; i < layers.ChildNodes.Count; i++) + { + XmlNode node = layers.ChildNodes.Item(i); + if (node != null) + { + string layerName = node.InnerText; + globeControl1.Globe.Layers.Add(layerName); + + //更新树节点 + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + TreeNode layerNode = new TreeNode(); + layerNode.Tag = layer; + layerNode.Text = layer.Dataset.Caption; + layerNode.ImageIndex = 0; + layerNode.SelectedImageIndex = 0; + layerNode.Checked = layer.Visible; + layerManagerNode.Nodes.Insert(0, layerNode); + } + } + layerManagerNode.Expand(); + } + catch (Exception e) + { + + } + } + * */ + #endregion + + private void btn_check_history_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_check_history.Text); + + if (FrmCheckHistory.isOpen == true) + { + return; + } + FrmCheckHistory frm = new FrmCheckHistory(globeControl1, globeControl2); + frm.addNode += new AddNodeToLayerManagerNode(addNodeToLayerManagerNode); + frm.Show(); + + } + + private void buttonItem查看数据_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItem查看数据.Text); + + FrmThreeOracle tr = new FrmThreeOracle(globeControl1); + + if (tr.ShowDialog() == DialogResult.OK) + { + addNodeToLayerManagerNode(tr.rukuLayer); + globeControl1.Refresh(); + } + } + /// + /// 规划数据入库 + /// + /// + /// + private void buttonItemGHRK_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemGHRK.Text); + + FrmGHRK ghrk = new FrmGHRK(globeControl1, layerManagerNode); + ghrk.Show(this); + } + + private void btn_user_info_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_user_info.Text); + + if (!FrmSysUserInfoManger.IS_OPEN) + { + FrmSysUserInfoManger frm = new FrmSysUserInfoManger(); + frm.ShowDialog(); + } + } + + private void btn_role_info_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_role_info.Text); + + if (FrmRoleInfoManager.IS_OPEN) + { + return; + } + FrmRoleInfoManager frm = new FrmRoleInfoManager(); + frm.ShowDialog(); + } + + private void btn_resc_info_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_resc_info.Text); + + if (!SysRescInfoManager.IS_OPEN) + { + SysRescInfoManager frm = new SysRescInfoManager(); + frm.ShowDialog(); + } + } + + private void btn_role_resc_Click(object sender, EventArgs e) + { + + LogManager.saveLog(Utility.userName, this.btn_role_resc.Text); + + if (!FrmRoleRescManager.IS_OPEN) + { + FrmRoleRescManager frm = new FrmRoleRescManager(); + frm.ShowDialog(); + } + } + + private void btn_user_role_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_user_role.Text); + + if (FrmUserRole.IS_OPEN) + { + return; + } + FrmUserRole frm = new FrmUserRole(); + frm.ShowDialog(); + } + + private void btn_document_info_Click(object sender, EventArgs e) + { + + LogManager.saveLog(Utility.userName, this.btn_document_info.Text); + + //if (FormDocumentManager.IS_OPEN) + //{ + // return; + //} + //FormDocumentManager frm = new FormDocumentManager(); + //frm.ShowDialog(); + + //if (FormDocumentManager.IS_OPEN) + //{ + // return; + //} + //new FormDocumentManager().ShowDialog(); + if (FormDocumentManager.IS_OPEN) + { + return; + } + this.Cursor = Cursors.WaitCursor; + FormDocumentManager frm = new FormDocumentManager(); + frm.changeCursor += new ChangeCursor(changeCursorToDefault); + frm.ShowDialog(); + + } + + private void changeCursorToDefault() + { + this.Cursor = Cursors.Default; + } + + /// + /// 判断CAD文件是否有投影信息 + /// + /// + /// + Boolean CheckDatasetGeoReference(GSODataset dataset) + { + Boolean bSuccess = false; + if (dataset.GeoReferenceType == EnumGeoReferenceType.Flat) + { + if (MessageBox.Show("数据没有空间参考信息,请设置空间参考信息!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation) == DialogResult.OK) + { + String strPath = Path.GetDirectoryName(Application.ExecutablePath) + "\\Coordinate Systems"; + OpenFileDialog dlg = new OpenFileDialog(); + + dlg.InitialDirectory = strPath; + dlg.RestoreDirectory = true; + + dlg.Filter = "投影文件|*.prj||"; + if (dlg.ShowDialog() == DialogResult.OK) + { + bSuccess = dataset.LoadProjectionFromESRIFile(dlg.FileName); + } + } + } + else + { + return true; + } + return bSuccess; + } + + private void buttonItemexp_CAD_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemexp_CAD.Text); + + OpenFileDialog dlg = new OpenFileDialog(); + dlg.Filter = "支持格式(*.dwg)|*.dwg"; + dlg.Multiselect = true; + if (dlg.ShowDialog() == DialogResult.OK) + { + for (int i = 0; i < dlg.FileNames.Length; i++) + { + //this.Cursor = Cursors.WaitCursor; + string strDataPath = dlg.FileNames[i]; + + #region + //string strDataPathPrj = strDataPath.ToLower().Replace(".dwg", ".lprj"); + + //if (File.Exists(strDataPathPrj) == false) + //{ + // if (MessageBox.Show("数据没有空间参考信息,请设置空间参考信息!", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation) == DialogResult.OK) + // { + // String strPath = Application.StartupPath + "\\Coordinate Systems"; + // OpenFileDialog dlgPrj = new OpenFileDialog(); + // dlgPrj.InitialDirectory = strPath; + // dlgPrj.RestoreDirectory = true; + // dlgPrj.Multiselect = false; + // dlg.Filter = "投影文件|*.prj"; + // if (dlg.ShowDialog() == DialogResult.OK) + // { + // this.Cursor = Cursors.WaitCursor; + // string proj4 = GSODataEngineUtility.ConvertEsriPrjFileToProj4(dlg.FileName); + // using (StreamWriter stream = new StreamWriter(strDataPathPrj, false)) + // { + // stream.WriteLine("0prj4" + proj4 + ""); + // } + // AddLayerData(strDataPath); + // //globeControl1.Globe.Layers.Add(strDataPath); + + // this.Cursor = Cursors.Default; + // } + // else + // { + // AddLayerData(strDataPath); + // //globeControl1.Globe.Layers.Add(strDataPath); + // } + // } + // else + // { + // AddLayerData(strDataPath); + // //globeControl1.Globe.Layers.Add(strDataPath); + // } + + //} + //else + //{ + // //globeControl1.Globe.Layers.Add(strDataPath); + // AddLayerData(strDataPath); + //} + #endregion + AddLayerData(strDataPath); + //this.Cursor = Cursors.Default; + } + } + + 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, 100); + + globeControl1.Refresh(); + } + } + + private void btn_password_edit_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_password_edit.Text); + + if (FrmChangePassword.IS_OPEN) + { + return; + } + FrmChangePassword frm = new FrmChangePassword(); + frm.ShowDialog(); + } + /// + /// 多孔管线入库 + /// + /// + /// + private void buttonItem9_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL4_2.Text); + + if (ds == null) + { + MessageBox.Show("请先连接数据库", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + ConnectDB(null, null); + } + if (ds == null) + return; + + FrmMultiPipelineModelDB frm = new FrmMultiPipelineModelDB(globeControl1, ds); + if (frm.ShowDialog() == DialogResult.OK) + { + addNodeToLayerManagerNode(frm.rukuLayer); + } + //frm.Show(); + } + private void 导出CADToolStripMenuItem1_Click(object sender, EventArgs e) + { + TreeNode node = layerNodeContexMenu.Tag as TreeNode; + if (node == null) + { + MessageBox.Show("请在左侧节点集中选择要导出的图层", "提示"); + return; + } + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(node.Text.Trim()); + if (layer == null || layer.GetAllFeatures().Length <= 0) + { + MessageBox.Show("要导出的图层为空", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + return; + } + string strProjectName = Utility.projectStr; + if (strProjectName != "") + { + SaveFileDialog dlg = new SaveFileDialog(); + dlg.Filter = "*.dwg|*.dwg|*.dxf|*.dxf"; + dlg.FileName = layer.Caption; + if (dlg.ShowDialog(this) == DialogResult.OK) + { + globeControl1.Globe.MemoryLayer.SaveAs(dlg.FileName); + GSOLayer newlayer = globeControl1.Globe.Layers.Add(dlg.FileName); + newlayer.RemoveAllFeature(); + int featureCount = layer.GetAllFeatures().Length; + for (int i = 0; i < featureCount; i++) + { + GSOFeature feature = layer.GetAt(i); + if (feature != null && feature.Geometry != null) + { + if (feature.Geometry.Type == EnumGeometryType.GeoPolyline3D) + { + feature.Geometry.Style = new GSOSimpleLineStyle3D(); + } + else if (feature.Geometry.Type == EnumGeometryType.GeoPolygon3D) + { + feature.Geometry.Style = new GSOSimplePolygonStyle3D(); + } + newlayer.AddFeature(feature); + } + } + newlayer.Save(); + newlayer.Dataset.DataSource.RemoveDataset(newlayer.Dataset); + globeControl1.Globe.Layers.Remove(newlayer); + MessageBox.Show("导出CAD完成!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + } + } + } + + private void buttonItemGBJC_Click(object sender, EventArgs e) + { + FrmGBJC gb = new FrmGBJC(globeControl1, globeControl2, layerTemp, layerTemp2); + gb.Show(this); + } + + #region 右屏管纵数据控制 + private void 五十米主干道ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = true; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + + private void 三十六米次干道ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = true; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + + private void 四十二米次干道ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = true; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + + private void 二十四米一块板ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = true; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + + private void 二十四米三块板ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = true; + } + + private void 二十四米停车带ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = true; + lendendGZ24_3.Visible = false; + } + + private void 二十六米大堤路ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = true; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + + private void 清除管纵数据ToolStripMenuItem_Click(object sender, EventArgs e) + { + ClearGZData(); + } + + private void ClearGZData() + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + #endregion + + private void buttonItemPasswordReset_Click(object sender, EventArgs e) + { + Frm_password_reset reset = new Frm_password_reset(); + reset.Show(); + } + + private void pictureBox1_Paint(object sender, PaintEventArgs e) + { + int Width = this.Width; + string welcomeUser = "欢迎您:" + Utility.userName; + Graphics g = e.Graphics; + g.DrawString(welcomeUser, new Font("宋体", 12), new SolidBrush(Color.Black), Width - 180, 50); + } + + } +} \ No newline at end of file diff --git a/MainFrm.cs.BASE.9016.cs b/MainFrm.cs.BASE.9016.cs new file mode 100644 index 0000000..e530fbd --- /dev/null +++ b/MainFrm.cs.BASE.9016.cs @@ -0,0 +1,13442 @@ +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; + + GSOBalloon featureTooltip2; + GSOBalloonEx balloonEx2; + + GSOLayer layerTemp; + GSOLayer layerTemp2; + FrmShResult frmShResult = null; + FrmRedlineResult frmredResult = null; + FrmMnModify frmModify = null; + public bool frmRedlineResult = false; + public bool boolfrmShResult = false; + public bool boolfrmModify = false; + + List m_PipelineLayerNames = new List();//线图层名称 + List workwellLayerNames = new List();//工井图层名称 + List valueLayerNames = new List();//阀门图层名称 + List instrumenLayerNames = new List();//附属物图层名称 + List pipefittingLayerNames = new List();//管件图层名称 + List sgPipeLayersNames = new List();//施工管线图层名称 + 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 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; + public string redLayer = null; + //GSOLayer redLayer1 = null; + bool redSH = false; + string redDt = "红线"; + //双屏对比 + //bool zhanshi=false; + Thread t = null; + private GSOHudButton legendSC;//定义图例 + private GSOHudButton legendSG;//定义图例 + //管纵图 + private GSOHudButton lendendGZ50; + private GSOHudButton lendendGZ36; + private GSOHudButton lendendGZ42; + private GSOHudButton lendendGZ24_1; + private GSOHudButton lendendGZ24_2; + private GSOHudButton lendendGZ24_3; + private GSOHudButton lendendGZ26; + + GSOGeoPoint3D bsqPT; + + FrmYJSHTC frmSh = null;//一键审核窗口全局变量wxl + FrmWait frmWait = null;//一键审核等待窗口 + //FrmWait frmWait2 = null;//文档操作等待窗口 + + float mouseDownX1,mouseDownY1; + float mouseDownX2,mouseDownY2; + /// + /// + /// + 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; + + featureTooltip2 = new GSOBalloon(globeControl2.Handle); + balloonEx2 = new GSOBalloonEx(globeControl2.Handle); + Utility.SetBallons(featureTooltip, balloonEx); + + panelOfTable.Height = 200; + + RigthMenuSet(); + + MenuSet(); + + } + /// + /// 右屏中添加管纵图片 + /// + private void AddGZ() + { + + lendendGZ50 = new GSOHudButton(); + lendendGZ50.SetImage(Application.StartupPath + "/Resource/管纵/50.png"); + lendendGZ50.SetOffset(0, 0); + lendendGZ50.MinOpaque = 1; + lendendGZ50.MaxOpaque = 1; + lendendGZ50.FadeOut = false; + lendendGZ50.Name = "lendendGZ50"; + lendendGZ50.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ50); + lendendGZ50.Visible = false; + + lendendGZ36 = new GSOHudButton(); + lendendGZ36.SetImage(Application.StartupPath + "/Resource/管纵/36.png"); + lendendGZ36.SetOffset(0, 0); + lendendGZ36.MinOpaque = 1; + lendendGZ36.MaxOpaque = 1; + lendendGZ36.FadeOut = false; + lendendGZ36.Name = "lendendGZ36"; + lendendGZ36.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ36); + lendendGZ36.Visible = false; + + lendendGZ42 = new GSOHudButton(); + lendendGZ42.SetImage(Application.StartupPath + "/Resource/管纵/42.png"); + lendendGZ42.SetOffset(0, 0); + lendendGZ42.MinOpaque = 1; + lendendGZ42.MaxOpaque = 1; + lendendGZ42.FadeOut = false; + lendendGZ42.Name = "lendendGZ42"; + lendendGZ42.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ42); + lendendGZ42.Visible = false; + + lendendGZ24_1 = new GSOHudButton(); + lendendGZ24_1.SetImage(Application.StartupPath + "/Resource/管纵/24_1.png"); + lendendGZ24_1.SetOffset(0, 0); + lendendGZ24_1.MinOpaque = 1; + lendendGZ24_1.MaxOpaque = 1; + lendendGZ24_1.FadeOut = false; + lendendGZ24_1.Name = "lendendGZ24_1"; + lendendGZ24_1.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ24_1); + lendendGZ24_1.Visible = false; + + lendendGZ24_2 = new GSOHudButton(); + lendendGZ24_2.SetImage(Application.StartupPath + "/Resource/管纵/24_2.png"); + lendendGZ24_2.SetOffset(0, 0); + lendendGZ24_2.MinOpaque = 1; + lendendGZ24_2.MaxOpaque = 1; + lendendGZ24_2.FadeOut = false; + lendendGZ24_2.Name = "lendendGZ24_2"; + lendendGZ24_2.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ24_2); + lendendGZ24_2.Visible = false; + + lendendGZ24_3 = new GSOHudButton(); + lendendGZ24_3.SetImage(Application.StartupPath + "/Resource/管纵/24_3.png"); + lendendGZ24_3.SetOffset(0, 0); + lendendGZ24_3.MinOpaque = 1; + lendendGZ24_3.MaxOpaque = 1; + lendendGZ24_3.FadeOut = false; + lendendGZ24_3.Name = "lendendGZ24_3"; + lendendGZ24_3.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ24_3); + lendendGZ24_3.Visible = false; + + lendendGZ26 = new GSOHudButton(); + lendendGZ26.SetImage(Application.StartupPath + "/Resource/管纵/26.png"); + lendendGZ26.SetOffset(0, 0); + lendendGZ26.MinOpaque = 1; + lendendGZ26.MaxOpaque = 1; + lendendGZ26.FadeOut = false; + lendendGZ26.Name = "lendendGZ26"; + lendendGZ26.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ26); + lendendGZ26.Visible = false; + + } + + public void RigthMenuSet() + { + if (Utility.userRole.IndexOf("清除分析") < 0) + { + toolRightMenu.Items.Remove(清除分析ToolStripMenuItem); + } + + #region 区域分析 + if (Utility.userRole.IndexOf("区域分析") < 0) + { + toolRightMenu.Items.Remove(区域分析ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("缓冲区分析") < 0) + { + 区域分析ToolStripMenuItem.DropDownItems.Remove(缓冲区分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("附属物分析") < 0) + { + 区域分析ToolStripMenuItem.DropDownItems.Remove(附属物分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("无源淹没分析") < 0) + { + 区域分析ToolStripMenuItem.DropDownItems.Remove(无源淹没分析ToolStripMenuItem); + } + } + #endregion + + #region 视域分析 + if (Utility.userRole.IndexOf("视域分析") < 0) + { + toolRightMenu.Items.Remove(视域分析ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("通视分析") < 0) + { + 视域分析ToolStripMenuItem.DropDownItems.Remove(通视分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("可视域分析") < 0) + { + 视域分析ToolStripMenuItem.DropDownItems.Remove(可视域分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("可视包络分析") < 0) + { + 视域分析ToolStripMenuItem.DropDownItems.Remove(可视包络分析ToolStripMenuItem); + } + } + #endregion + + #region 开发分析 + if (Utility.userRole.IndexOf("开挖分析") < 0) + { + toolRightMenu.Items.Remove(开挖分析ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("多边形开挖") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(多边形开挖ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("挖方量分析") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(挖方量分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("沿线开挖") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(沿线开挖ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("创建隧道") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(创建隧道ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("隐藏隧道") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(隐藏隧道ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("删除隧道") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(删除隧道ToolStripMenuItem); + } + } + #endregion + + #region 拓扑分析 + if (Utility.userRole.IndexOf("拓扑分析") < 0) + { + toolRightMenu.Items.Remove(拓扑分析ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("创建拓扑") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(创建拓扑ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("上游分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(上游分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("下游分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(下游分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("流向分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(流向分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("关阀分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(关阀分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("连通分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(连通分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("爆管分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(爆管分析ToolStripMenuItem); + } + } + #endregion + + #region 断面分析 + if (Utility.userRole.IndexOf("断面分析") < 0) + { + toolRightMenu.Items.Remove(断面分析ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("横断面分析") < 0) + { + 断面分析ToolStripMenuItem.DropDownItems.Remove(横断面分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("纵断面分析") < 0) + { + 断面分析ToolStripMenuItem.DropDownItems.Remove(纵断面分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("道路断面分析") < 0) + { + 断面分析ToolStripMenuItem.DropDownItems.Remove(道路断面分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("基线剖面分析") < 0) + { + 断面分析ToolStripMenuItem.DropDownItems.Remove(基线剖面分析ToolStripMenuItem); + } + } + #endregion + + #region 绘制区域统计 + if (Utility.userRole.IndexOf("绘制区域统计") < 0) + { + toolRightMenu.Items.Remove(绘制区域统计ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("绘制区域管线长度统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管线长度统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域阀门数量统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(阀门数量统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域井盖数量统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(井盖数量统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域管径分段统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管径分段统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域埋深分段统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(埋深分段统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域管径分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管径分类统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域材质分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(材质分类统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域附属物分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(附属物分类统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域标识器分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(标识器分类统计ToolStripMenuItem1); + } + + } + #endregion + + #region 全区域统计 + if (Utility.userRole.IndexOf("全区域统计") < 0) + { + toolRightMenu.Items.Remove(全区域统计ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("全区域管线长度统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管线长度统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域阀门数量统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(阀门数量统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域井盖数量统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(井盖数量统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域管径分段统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管径分段统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域埋深分段统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(埋深分段统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域管径分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管径分类统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域材质分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(材质分类统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域附属物分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(附属物分类统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域标识器分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(标识器分类统计ToolStripMenuItem); + } + + } + #endregion + + #region 查询 + if (Utility.userRole.IndexOf("查询") < 0) + { + toolRightMenu.Items.Remove(查询ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("空间查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(空间查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("编号查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(编号查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("坐标查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(坐标查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("管径查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(管径查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("材质查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(材质查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("基本查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(基本查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("复合查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(复合查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("关联查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(关联查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("关键字查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(关键字查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("附属物查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(附属物查询ToolStripMenuItem); + } + } + #endregion + + #region 标注 + if (Utility.userRole.IndexOf("标注") < 0) + { + toolRightMenu.Items.Remove(标注ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("标高标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(标高标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("管径标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(管径标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("埋深标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(埋深标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("坐标标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(坐标标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("距离标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(距离标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("自定义标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(自定义标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("扯旗标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(扯旗标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("坡度标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(坡度标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("属性标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(属性标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("标注管理") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(标注管理ToolStripMenuItem); + } + } + #endregion + + #region 飞行 + if (Utility.userRole.IndexOf("飞行") < 0) + { + toolRightMenu.Items.Remove(飞行ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("自定义飞行") < 0) + { + 飞行ToolStripMenuItem.DropDownItems.Remove(自定义飞行ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("飞行到目标点") < 0) + { + 飞行ToolStripMenuItem.DropDownItems.Remove(飞行到目标点ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("绕中心点飞行") < 0) + { + 飞行ToolStripMenuItem.DropDownItems.Remove(绕中心点飞行ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("绕眼睛飞行") < 0) + { + 飞行ToolStripMenuItem.DropDownItems.Remove(绕眼睛飞行ToolStripMenuItem); + } + } + #endregion + + #region 编辑 + if (Utility.userRole.IndexOf("编辑") < 0) + { + toolRightMenu.Items.Remove(编辑ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("平移对象") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(平移对象ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("升降对象") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(升降对象ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("旋转对象") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(旋转对象ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("连接管段") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(连接管段ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("导出文件") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(导出文件ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("前进") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(前进ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("后退") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(删除模型ToolStripMenuItem); + } + } + #endregion + + #region 量算 + if (Utility.userRole.IndexOf("量算") < 0) + { + toolRightMenu.Items.Remove(量算ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("水平距离") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(水平距离ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("垂直距离") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(垂直距离ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("空间距离") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(空间距离ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("地表距离") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(地表距离ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("高度量算") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(高度量算ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("水平面积") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(水平面积ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("地表面积") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(地表面积ToolStripMenuItem1); + } + } + #endregion + } + + public void MenuSet() + { + + #region 权限管理 + if (Utility.userRole.IndexOf("权限管理") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem2); + } + else + { + + if (Utility.userRole.IndexOf("用户管理") < 0) + { + btn_user_info.Visible = false; + } + if (Utility.userRole.IndexOf("角色管理") < 0) + { + btn_role_info.Visible = false; + } + if (Utility.userRole.IndexOf("资源管理") < 0) + { + btn_resc_info.Visible = false; + } + if (Utility.userRole.IndexOf("角色授权") < 0) + { + btn_role_resc.Visible = false; + } + if (Utility.userRole.IndexOf("用户授权") < 0) + { + btn_user_role.Visible = false; + } + if (Utility.userRole.IndexOf("密码修改") < 0) + { + btn_password_edit.Visible = false; + } + + } + #endregion + + #region 基础工具 + if (Utility.userRole.IndexOf("基础工具") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem1); + } + else + { + if (Utility.userRole.IndexOf("地上模式") < 0) + { + buttonItem87.Visible = false; + } + if (Utility.userRole.IndexOf("地下模式") < 0) + { + buttonItem88.Visible = false; + } + if (Utility.userRole.IndexOf("行走模式") < 0) + { + buttonItem27.Visible = false; + } + if (Utility.userRole.IndexOf("透明度设置") < 0) + { + sliderGroundTransSet1.Visible = false; + } + if (Utility.userRole.IndexOf("快速定位") < 0) + { + buttonItem91.Visible = false; + } + if (Utility.userRole.IndexOf("图层管理") < 0) + { + buttonItem1.Visible = false; + } + if (Utility.userRole.IndexOf("图例管理") < 0) + { + btnlegendSet.Visible = false; + } + if (Utility.userRole.IndexOf("全屏显示") < 0) + { + buttonItem89.Visible = false; + } + if (Utility.userRole.IndexOf("导出图片") < 0) + { + btnOutputJPG.Visible = false; + } + + } + #endregion + + #region 一键审核 + if (Utility.userRole.IndexOf("一键审核") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem11); + } + #endregion + + #region 红线审核 + if (Utility.userRole.IndexOf("红线审核") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem6); + } + #endregion + + #region 双屏对比 + if (Utility.userRole.IndexOf("双屏对比") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem9); + } + #endregion + + #region 文档管理 + if (Utility.userRole.IndexOf("文档管理") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem4); + } + #endregion + + #region 基础管理 + if (Utility.userRole.IndexOf("基础管理") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem14); + } + else + { + if (Utility.userRole.IndexOf("专题图审批") < 0) + { + buttonItemZTT3_2.Visible = false; + } + if (Utility.userRole.IndexOf("打印审批") < 0) + { + buttonItemZTT4_2.Visible = false; + } + if (Utility.userRole.IndexOf("拷贝审批") < 0) + { + buttonItemZTT5_2.Visible = false; + } + } + + #endregion + + if (ribbonControl1.Items.Count <= 0) + { + ribbonControl1.Visible = false; + } + } + + #region Fan Zhang 重构现有代码 + //初始化控件布局 + private void initLayout() + { + 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.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.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.labelX21.Width = (int)(this.labelX21.Width * myScreen); + this.labelX22.Width = (int)(this.labelX22.Width * myScreen); + this.labelX24.Width = (int)(this.labelX24.Width * myScreen); + } + sideBar1.Visible = false; + 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]); + } + + splitContainer1.Panel2Collapsed = true; + + buttonItem87.Checked = true;//默认地上模式 + ribbonTabItem1.Select(); //初始化状态为浏览 + + sideBarPanelItem3.Visible = false; + layerTree.Visible = false; + controlContainerItem3.Visible = false; + if (sideBarPanelItem4.Visible == true) + { + sideBar1.Visible = true; + controlContainerItem5.Visible = true; + } + else + { + sideBar1.Visible = false; + } + Refresh(); + sliderGroundTransSet1.Value = optiValue; + sliderItem1.Value = optiValue; + sliderItem2.Value = optiValue; + sliderItem3.Value = optiValue; + + } + + //初始化地球控件 + private void initGlobalControl() + { + //选择 + btnToolSelect = new GSOHudButton(); + btnToolSelect.SetImage(Application.StartupPath + "\\Resource\\image\\select1.png"); + btnToolSelect.FadeOut = false; + btnToolSelect.Align = EnumAlign.TopLeft; + btnToolSelect.SetOffset(20, 50); + btnToolSelect.Name = "1"; + btnToolSelect.HeightFixed = true; + btnToolSelect.WidthFixed = true; + globeControl1.Globe.AddHudControl(btnToolSelect); + globeControl2.Globe.AddHudControl(btnToolSelect); + + //浏览 + 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); + + //图例 + legend = new GSOHudButton(); + legend.SetImage(Application.StartupPath + "/Resource/图例P.jpg");//图例P + legend.SetOffset(0, 15); + legend.MinOpaque = 1; + legend.MaxOpaque = 1; + legend.FadeOut = false; + legend.Name = "legend"; + legend.Align = EnumAlign.BottomRight; + legend.Visible = false; + globeControl1.Globe.AddHudControl(legend); + + //实测 + legendSC = new GSOHudButton(); + legendSC.SetImage(Application.StartupPath + "/Resource/sc.jpg"); + legendSC.SetOffset(0, 15); + legendSC.MinOpaque = 1; + legendSC.MaxOpaque = 1; + legendSC.FadeOut = false; + legendSC.Name = "legendSC"; + legendSC.Align = EnumAlign.BottomRight; + globeControl1.Globe.AddHudControl(legendSC); + legendSC.Visible = false; + + //施工 + legendSG = new GSOHudButton(); + legendSG.SetImage(Application.StartupPath + "/Resource/sg.jpg"); + legendSG.SetOffset(0, 15); + legendSG.MinOpaque = 1; + legendSG.MaxOpaque = 1; + legendSG.FadeOut = false; + legendSG.Name = "legendSG"; + legendSG.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(legendSG); + legendSG.Visible = false; + + //管纵 + AddGZ(); + + 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; + globeControl1.Globe.IsReleaseMemOutOfView = true; + globeControl1.Globe.ControlPanel.Visible = true; + + globeControl2.Globe.UnderGroundFloor.Visible = false; + globeControl2.Globe.OverviewControl.Visible = false; + globeControl2.Globe.ScalerControl.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; + globeControl2.Globe.IsReleaseMemOutOfView = true; + globeControl2.Globe.ControlPanel.Visible = false; + + 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); + + //添加临时图层 + layerTemp = globeControl1.Globe.Layers.Add(Application.StartupPath + "\\tempLgdData.lgd"); + layerTemp2 = globeControl2.Globe.Layers.Add(Application.StartupPath + "\\tempLgdData2.lgd"); + if (layerTemp != null) + { + layerTemp.MaxVisibleAltitude = 1000; + } + + //添加城市7线图层 + 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"); + + //注册对应事件 + this.registerEvent(); + } + + //注册地球事件 + private bool registerEvent() + { + if (globeControl1 == null || globeControl2 == null) + { + return false; + } + 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); + + globeControl2.FeatureMouseClickEvent += new FeatureMouseClickEventHandler(globeControl2_FeatureMouseClickEvent); + globeControl2.CameraBeginMoveEvent += new CameraBeginMoveEventHandler(globeControl2_CameraBeginMoveEvent); + + globeControl1.MouseDoubleClick += new MouseEventHandler(globeControl1_MouseDoubleClick); + globeControl1.MouseClick += new MouseEventHandler(globeControl1_MouseClick); + globeControl1.MouseDown += new MouseEventHandler(globeControl1_MouseDown); + + globeControl2.MouseClick += new MouseEventHandler(globeControl2_MouseClick); + globeControl2.MouseDown += new MouseEventHandler(globeControl2_MouseDown); + + 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); + + return true; + } + + //加载两个地球数据 + private void loadData() + { + Thread t1 = new Thread(new ThreadStart(doLoadDataForGlobalControl1)); + t1.IsBackground = true; + t1.Start(); + + + } + + delegate void LoadDataForGlobalControl(); + + private void connectServer() + { + globeControl1.Globe.ConnectServer(Utility.serverip, Utility.serverport, "", ""); //加载locaServer中的数据 + globeControl2.Globe.ConnectServer(Utility.serverip, Utility.serverport, "", ""); //加载locaServer中的数据 + //初始化TreeView + // 勾选实测图层 + foreach (TreeNode tn in layerTree.Nodes) + { + if (tn.Nodes.Count > 0) + { + if (tn.Text == "实测数据") + { + tn.Checked = true; + foreach (TreeNode tnChild in tn.Nodes) + { + tnChild.Checked = true; + foreach (TreeNode tnGrandChild in tnChild.Nodes) + { + tnGrandChild.Checked = true; + } + } + } + } + } + } + + private void doLoadDataForGlobalControl1() + { + try + { + + globeControl1.Globe.Layers.MoveDown(10000); + //加载实测管线数据 + Utility.dataSource = globeControl1.Globe.DataManager.OpenOracleDataSource(Utility.DBServer.Trim() + "/" + Utility.dbdatabase.Trim(), "", "", Utility.userID, Utility.DBPassword); + + if (Utility.dataSource != null) + { + for (int j = 0; j < Utility.dataSource.DatasetCount; j++) + { + GSODataset dataset = Utility.dataSource.GetDatasetAt(j); + if (dataset != null && dictionaryNetLayerNameAndCaption.ContainsKey(dataset.Caption)) + { + dataset.Caption = dataset.Name; + globeControl1.Globe.Layers.Add(dataset); + } + } + } + //隐藏红线图层 + globeControl1.Globe.Layers.GetLayerByCaption("红线").Visible = false; + + //globleControl1中加载规划数据 + GSODataSource ghDS = globeControl1.Globe.DataManager.OpenOracleDataSource(Utility.ghdbip + "/" + Utility.ghdbname, "", "", Utility.ghdbuser, Utility.ghdbpwd); + if (ghDS != null) + { + for (int j = 0; j < ghDS.DatasetCount; j++) + { + GSODataset dataset = ghDS.GetDatasetAt(j); + if (dataset != null && dictionaryNetLayerNameAndCaption.ContainsKey(dataset.Caption)) + { + dataset.Caption = dataset.Name; + globeControl1.Globe.Layers.Add(dataset); + globeControl1.Globe.Layers[0].Visible = false; + } + } + } + + //globeControl1,globeControl2中加载施工数据 + GSODataSource sgDS = globeControl1.Globe.DataManager.OpenOracleDataSource(Utility.sgdbip + "/" + Utility.sgdbname, "", "", Utility.sgdbuser, Utility.sgdbpwd); + if (sgDS != null) + { + for (int m = 0; m < sgDS.DatasetCount; m++) + { + GSODataset dataset = sgDS.GetDatasetAt(m); + if (dataset != null && !dataset.Caption.Contains("SH") && dictionaryNetLayerNameAndCaption.ContainsKey(dataset.Caption)) + { + dataset.Caption = dataset.Name; + globeControl1.Globe.Layers.Add(dataset); + globeControl1.Globe.Layers[0].Visible = false; + + globeControl2.Globe.Layers.Add(dataset); + globeControl2.Globe.Layers[0].Visible = true; + } + } + } + + LoadDataForGlobalControl ss = new LoadDataForGlobalControl(connectServer); + ss(); + + } + catch (Exception ex) + { + MessageBox.Show(ex.Message); + } + } + + private void initLayerTree() + { + //加载临时图层节点 + layerManagerNode = new TreeNode(); + layerManagerNode.ImageIndex = 0; + layerManagerNode.SelectedImageIndex = 0; + layerManagerNode.Checked = true; + layerManagerNode.Text = "临时图层"; + layerTree.Nodes.Add(layerManagerNode); + + XmlDocument doc = new XmlDocument(); + doc.Load(filename); + XmlNodeList xmlLayerNodes = doc.SelectNodes("//layer"); + + foreach (XmlNode xmlLayerNode in xmlLayerNodes) + { + + //TODO LIST:创建一级TreeNode(实测、规划、施工) + TreeNode nodelayer = new TreeNode(); + string layerName = xmlLayerNode.Attributes["label"].Value; + nodelayer.Text = layerName; + nodelayer.Checked = false; + layerTree.Nodes.Add(nodelayer); + + XmlNodeList xmlChildLayerNodes = xmlLayerNode.ChildNodes; + foreach (XmlNode xmlChildLayerNode in xmlChildLayerNodes) + { + //TODO LIST:创建二级TreeNode节点 + TreeNode secondLevelNode = new TreeNode(); + string layerType = xmlChildLayerNode.Attributes["label"].Value; + secondLevelNode.Text = layerType; + + if (xmlChildLayerNode.Attributes["type"] != null) + { //道路图层特殊处理 + string type = xmlChildLayerNode.Attributes["type"].Value; + secondLevelNode.Tag = type + "|" + layerType; + } + else + { + secondLevelNode.Tag = layerType; + } + secondLevelNode.Checked = false; + nodelayer.Nodes.Add(secondLevelNode); + + XmlNodeList xmlActitualLayerNodes = xmlChildLayerNode.ChildNodes; + + foreach (XmlNode xmlActitualLayerNode in xmlActitualLayerNodes) + { + //TODO LIST:创建三级图层节点 + TreeNode layerNode = new TreeNode(); + string actutallylayerType = xmlActitualLayerNode.Attributes["type"].Value; + string actutallylayerName = xmlActitualLayerNode.Attributes["layer"].Value; + string actutallyLabelName = xmlActitualLayerNode.Attributes["label"].Value; + + layerNode.Text = actutallyLabelName; + layerNode.Tag = layerType + "|" + actutallyLabelName; + layerNode.Checked = false; + secondLevelNode.Nodes.Add(layerNode); + } + + } + + } + + } + + /** + * 读取Config.xml文件,初始化以下全局Map + * m_PipelineLayerNames:管线 + * workwellLayerNames:工井 + * valueLayerNames:阀门 + * instrumenLayerNames:附属物 + * pipefittingLayerNames:特征管点 + * sgPipeLayersNames:施工管线 + **/ + private void initGlobalMap() + { + XmlDocument doc = new XmlDocument(); + doc.Load(filename); + XmlNodeList xmlLayerNodes = doc.SelectNodes("//layerchild"); + + foreach (XmlNode xmlLayerNode in xmlLayerNodes) + { + string layerType = xmlLayerNode.Attributes["type"].Value; + string layerName1 = xmlLayerNode.Attributes["layer"].Value; + string layerchildName = xmlLayerNode.Attributes["label"].Value; + + dictionaryNetLayerNameAndCaption.Add(layerName1, layerchildName); + + if (layerType != "db") + { + if (xmlLayerNode.Attributes["isRoad"] != null) + { + roadLayerName = layerchildName; + } + } + else if (xmlLayerNode.Attributes["isPipeLine"] != null) + { + m_PipelineLayerNames.Add(layerchildName); + g1layername.Add(layerName1); + } + else if (xmlLayerNode.Attributes["isWorkWell"] != null) + { + workwellLayerNames.Add(layerchildName); + g1layername.Add(layerName1); + } + else if (xmlLayerNode.Attributes["isValve"] != null) + { + valueLayerNames.Add(layerchildName); + g1layername.Add(layerName1); + } + else if (xmlLayerNode.Attributes["isAccess"] != null) + { + instrumenLayerNames.Add(layerchildName); + g1layername.Add(layerName1); + } + else if (xmlLayerNode.Attributes["isCharacter"] != null) + { + pipefittingLayerNames.Add(layerchildName); + g1layername.Add(layerName1); + } + else if (xmlLayerNode.Attributes["isSgData"] != null) + { + sgPipeLayersNames.Add(layerchildName); + g1layername.Add(layerName1); + } + + } + } + + private void initMarkerTree() + { + 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); + } + } + } + } + + private void MainFrm_Load(object sender, EventArgs e) + { + + this.initGlobalControl(); + this.initGlobalMap(); + this.initLayerTree(); + this.initMarkerTree(); + this.initLayout(); + this.loadData(); + + + double x = Convert.ToDouble(Utility.Query_Roads["绿岛"].ToString().Split(',')[0]); + double y = Convert.ToDouble(Utility.Query_Roads["绿岛"].ToString().Split(',')[1]); + double z = Convert.ToDouble(Utility.Query_Roads["绿岛"].ToString().Split(',')[2]); + jumpToCameraState(x, y, z); + + + } + + #endregion + + /// + /// 每次gis服务加载时都会触发的 + /// + /// + /// + 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 dictionaryNetLayerNameAndCaption = new Dictionary(); + 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 配置用户权限 + /// + /// 向数据库插入功能列表 + /// + private void insertControlToDatabase() + { + ArrayList listItem = new ArrayList(); + List subListItem = new List(); + 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) + { + GSOCameraState camera = globeControl2.Globe.CameraState; + globeControl1.Globe.JumpToCameraState(camera); + } + } + + void globeControl1_BeforeSceneRenderEvent(object sender, BeforeSceneRenderEventArgs e) + { + if (globeControl1.Focused) + { + 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); + } + } + } + + /// + /// 检查数据集是否有坐标系信息 + /// + /// + /// + 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 = "0prj4" + lprjStr + ""; + + bSuccess = dataset.LoadProjectionFromESRIFile(dlg.FileName); + + string lprjFileName = strDataPath.Substring(0, strDataPath.LastIndexOf(".")) + ".lprj"; + StreamWriter writer = new StreamWriter(lprjFileName, false); + writer.Write(lprjFileContent); + writer.Close(); + + } + } + } + else + { + return true; + } + return bSuccess; + } + + /// + /// 矩形拉框结束事件处理函数 + /// + /// + /// + 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))); + */ + + int mapWidth = 0; + int mapHeight = 0; + Point pt = getUpperLeftPoint(pt1, pt2, out mapWidth, out mapHeight); + int rightBottomX = pt.X + mapWidth; + int rightBottomY = pt.Y + mapHeight; + Image myImg = new Bitmap(mapWidth, mapHeight); + Graphics g = Graphics.FromImage(myImg); + g.CopyFromScreen(pt, new Point(0, 0), new Size(rightBottomX, rightBottomY)); + + 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; + } + } + /// + /// 定位正北正90度俯视 + /// + /// + /// + /// + 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; + } + } + /// + /// layerTree选中后事件处理 + /// + /// + /// + 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); + } + /// + /// 树节点选中方法 + /// + /// + 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); + } + } + } + + } + /// + /// 改变所有子节点的状态 + /// + /// + /// + 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; + LayerFlyMenuItem.Visible = true; + } + + LayerSelectableMenuItem.Visible = true; + LayerEditableMenuItem.Visible = true; + SaveLayerMenuItem.Visible = true; + LayerFlyMenuItem.Visible = true; + 导出CADToolStripMenuItem1.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]); + if (layer != null) + { + LayerSelectableMenuItem.Checked = layer.Selectable; + LayerEditableMenuItem.Checked = layer.Editable; + } + else + { + return; + } + } + 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; + } + } + } + } + } + + /// + /// 删除临时添加的本地数据图层 + /// + /// + /// + 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); + for (int i = globeControl1.Globe.Layers.Count-1; i >=0; i--) + { + if (globeControl1.Globe.Layers[i].Caption == layer.Caption) + { + globeControl1.Globe.Layers.Remove(globeControl1.Globe.Layers[i]); + } + } + + 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 定位ToolStripMenuItem_Click(object sender, EventArgs e) + { + TreeNode node = layerTree.SelectedNode; + + if (node != null) + { + if (node.Parent.Text.Trim() == "临时图层") + { + GSOLayer lsLayer = globeControl1.Globe.Layers.GetLayerByCaption(node.Text.ToString()); + double x = lsLayer.LatLonBounds.Center.X; + double y = lsLayer.LatLonBounds.Center.Y; + if (x == 0 && y == 0) + { + x = lsLayer.Bounds.Center.X; + y = lsLayer.Bounds.Center.Y; + } + + globeControl1.Globe.FlyToPosition(new GSOPoint3d(x, y, 10), EnumAltitudeMode.Absolute); + } + else + { + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(node.Tag.ToString().Split('|')[1]); + + if (layer != null) + { + if (layer.Caption == "红线") + { + globeControl1.Globe.FlyToPosition(new GSOPoint3d(120.610963, 31.188121, 50), EnumAltitudeMode.Absolute, -4, 50, 1000); + globeControl1.Globe.FlyToPointSpeed = 10000000; + globeControl1.Globe.Action = EnumAction3D.SelectObject; + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = true; + } + globeControl1.Refresh(); + } + else + { + double x = layer.LatLonBounds.Center.X; + double y = layer.LatLonBounds.Center.Y; + globeControl1.Globe.FlyToPosition(new GSOPoint3d(x, y, 100), EnumAltitudeMode.Absolute); + } + } + } + } + else + { + return; + } + + } + + private void layerTree_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e) + { + if(this.layerTree.SelectedNode!=null) + { + if (this.layerTree.SelectedNode.Tag.ToString().Contains("|")) + { + string nodeTag = this.layerTree.SelectedNode.Tag.ToString().Split('|')[1]; + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(nodeTag); + if (layer != null) + { + if (layer.Caption == "红线") + { + globeControl1.Globe.FlyToPosition(new GSOPoint3d(120.610963, 31.188121, 50), EnumAltitudeMode.Absolute, -4, 50, 1000); + globeControl1.Globe.FlyToPointSpeed = 10000000; + globeControl1.Globe.Action = EnumAction3D.SelectObject; + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = true; + } + globeControl1.Refresh(); + } + else { + double x = layer.LatLonBounds.Center.X; + double y = layer.LatLonBounds.Center.Y; + globeControl1.Globe.FlyToPosition(new GSOPoint3d(x, y, 0), EnumAltitudeMode.Absolute); + } + } + } + if (this.layerTree.SelectedNode.Tag is GSOLayer) + { + GSOLayer layer = this.layerTree.SelectedNode.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 (this.layerTree.SelectedNode.Tag is GSOFeature) + { + GSOFeature feature = this.layerTree.SelectedNode.Tag as GSOFeature; + if (feature.Geometry != null) + { + globeControl1.Globe.FlyToPosition(feature.Geometry.GeoCenterPoint, EnumAltitudeMode.Absolute, 0, 0, 10); + } + else + { + globeControl1.Globe.FlyToFeature(feature); + } + } + } + } + + /// + /// 在三维场景移动时,隐藏气泡globeControl1 + /// + /// + /// + void globeControl1_CameraBeginMoveEvent(object sender, CameraBeginMoveEventArgs e) + { + if (featureTooltip.IsVisible()) + { + featureTooltip.HideBalloon(); + } + if (balloonEx.IsVisible()) + { + balloonEx.HideBalloon(); + } + } + + /// + /// 在三维场景移动时,隐藏气泡globeControl2 + /// + /// + /// + void globeControl2_CameraBeginMoveEvent(object sender, CameraBeginMoveEventArgs e) + { + if (featureTooltip2.IsVisible()) + { + featureTooltip2.HideBalloon(); + } + if (balloonEx2.IsVisible()) + { + balloonEx2.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(); + } + } + + #region Fan 横断面 + /// + /// 横断面分析、基线剖面分析、道路断面分析等 + /// + /// + /// + private static EnumTrackPolylineEndMode trackPolylineEndMode; + + void globeControl1_TrackPolylineEndEvent(object sender, TrackPolylineEndEventArgs e) + { + //横断面分析、道路横断面分析 + if (trackPolylineEndMode == EnumTrackPolylineEndMode.HDM_Analysis|| + trackPolylineEndMode == EnumTrackPolylineEndMode.DLDM_Analysis) + { + Dictionary hdmDic = SectionAnalysisTool.HDMAnalysis(this.globeControl1, + e.Polyline, this.m_PipelineLayerNames); + FrmHDMAnalysis3 frm = new FrmHDMAnalysis3(hdmDic, this.globeControl1, + trackPolylineEndMode); + frm.Show(this); + } + //基线剖面分析 + else if (trackPolylineEndMode == EnumTrackPolylineEndMode.JXPM_Analysis) + { + FrmBaseLineProfillAnalysis dlg = new FrmBaseLineProfillAnalysis(globeControl1.Globe, e.Polyline); + dlg.Show(this); + globeControl1.Globe.ClearLastTrackPolyline(); + /* + FrmRoadHDM f = new FrmRoadHDM(); + f.Show() + * **/ + } + else + { + + } + trackPolylineEndMode = EnumTrackPolylineEndMode.Default_Analysis; + /* + ArrayList arraylistPoint = new ArrayList(); + ArrayList arraylistLine = new ArrayList(); + + // globeControl1.Globe.ClearLastTrackPolyline(); + + if (e.Polyline != null) + { + //横断面分析 + if (buttonItemFX2_1.Checked || buttonItemFX2_3.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 (buttonItemFX2_1.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 (buttonItemFX2_4.Checked) + { + FrmBaseLineProfillAnalysis dlg = new FrmBaseLineProfillAnalysis(globeControl1.Globe, e.Polyline); + dlg.Show(this); + globeControl1.Globe.ClearLastTrackPolyline(); + } + else if (buttonItemFX4_3.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(); + * **/ + } + #endregion + + private GSOFeatures PolygonIntersectAnalysis(GSOGeoPolygon3D polygon, string pipelinetype) + { + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(pipelinetype); + 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(pipelinetype, feats.Length); + return feats; + } + /// + /// 根据范围统计阀门、管线、工井等, 开挖分析, 挖方量分析 + /// + /// + /// + void globeControl1_TrackPolygonEndEvent(object sender, TrackPolygonEndEventArgs e) + { + if (globeControl1.Globe.Action == EnumAction3D.TrackPolygon && e.Polygon != null) + { + GSOGeoPolygon3D polygon = e.Polygon; + + switch (trackflag) + { + case "valvequery": + //workWellLen.Clear(); + //List list = new List(); + ////找到所有阀门 + //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, globeControl1, new DataGridViewDelegate(InitDataGridViewX1)); + FrmValveStatistics frm = new FrmValveStatistics(globeControl1,polygon, new DataGridViewDelegate(InitDataGridViewX1)); + frm.Show(this); + //panelEx6.Visible = true; + toolStripFeatureLength.Text = ""; + globeControl1.Globe.Action = EnumAction3D.ActionNull; + break; + + case "PipelineDistanceStatistics": + //pipeLineDis.Clear(); + //List list1 = new List(); + //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, globeControl1, new DataGridViewDelegate(InitDataGridViewX1)); + FrmAllPipelineStatis frm1 = new FrmAllPipelineStatis(globeControl1, polygon, new DataGridViewDelegate(InitDataGridViewX1), m_PipelineLayerNames); + frm1.Show(this); + globeControl1.Globe.Action = EnumAction3D.ActionNull; + + break; + case "PipelineSpatialQuery": + //pipeLineDis.Clear(); + //List list2 = new List(); + //for (int i = 0; i < m_PipelineLayerNames.Count; i++) + //{ + // GSOFeatures fs = Intersects_Pipeline(polygon, m_PipelineLayerNames[i]); + // if (fs != null) + // { + // list2.Add(fs); + // } + //} + + //FrmAllPipelineStatis.ShowForm(1, pipeLineDis, list2, globeControl1, new DataGridViewDelegate(InitDataGridViewX1)); + FrmAllPipelineStatis.ShowForm(globeControl1,polygon,new DataGridViewDelegate(InitDataGridViewX1),m_PipelineLayerNames); + globeControl1.Globe.ClearAnalysis(); + globeControl1.Globe.Action = EnumAction3D.ActionNull; + + break; + case "workwellquery": + //workWellLen.Clear(); + //List listWell = new List(); + ////找到所有井 + //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(polygon, dataGridViewX1, toolStripNumbers, globeControl1, panelOfTable); + FrmAllWorkWellStatis frmWell = new FrmAllWorkWellStatis(globeControl1, polygon, new DataGridViewDelegate(InitDataGridViewX1)); + 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 "BSQDuoBianXiangStatis": + + GSOFeature f2 = new GSOFeature(); + f2.Geometry = e.Polygon; + f2.Geometry.AltitudeMode = EnumAltitudeMode.Absolute; + globeControl1.Globe.MemoryLayer.AddFeature(f2); + f2.Geometry.MoveZ(3); + workWellLen.Clear(); + List listBSQ = new List(); + + GSOFeatures bsqFeatures = PolygonIntersectAnalysis(e.Polygon, "标识器"); + listBSQ.Add(bsqFeatures); + + FrmBSQDuoBianXingStatis bsqFrm = new FrmBSQDuoBianXingStatis(workWellLen, globeControl1, listBSQ); + bsqFrm.Show(this); + globeControl1.Globe.Action = EnumAction3D.ActionNull; + break; + + case "": + break; + default: + break; + } + } + } + + #region 验证端口 + /* + /// + /// 验证端口 + /// + /// + 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 + + /// + /// 鼠标悬浮提示 + /// + /// + /// + 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); + } + } + + /// + /// 添加管线绘制完成事件, 红线工具绘制完成 + /// + /// + /// + 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; + + + } + } + + /// + /// 获取globeControl1中鼠标按下的坐标供区别鼠标右键和滚轮按下事件 + /// + /// + /// + void globeControl1_MouseDown(object sender, MouseEventArgs e) + { + mouseDownX1 = e.X; + mouseDownY1 = e.Y; + } + /// + /// 获取globeControl2中鼠标按下的坐标供区别鼠标右键和滚轮按下事件 + /// + /// + /// + void globeControl2_MouseDown(object sender, MouseEventArgs e) + { + mouseDownX2 = e.X; + mouseDownY2 = e.Y; + } + /// + /// + /// + /// + /// + void globeControl2_MouseClick(object sender, MouseEventArgs e) + { + if (e.Button == MouseButtons.Right) + { + if (e.X == mouseDownX2 && e.Y == mouseDownY2) + { + RightScreenToolMenu.Show(globeControl2, e.X, e.Y); + } + else + { + return; + } + } + } + /// + /// + /// + /// + /// + void globeControl1_MouseClick(object sender, MouseEventArgs e) + { + if (e.Button == MouseButtons.Left) + { + if (globeControl1.Globe.Action == EnumAction3D.VisibilityAnalysis) + { + buttonItemFX5_1.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; + + bsqPT = pt; + + if (buttonItemLS5.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 (e.X == mouseDownX1 && e.Y == mouseDownY1) + { + toolRightMenu.Show(globeControl1, e.X, e.Y); + if (buttonItemLS5.Checked) + { + buttonItemLS5.Checked = false; + } + } + else + { + return; + } + } + globeControl1.Refresh(); + } + + /// + /// 判断网络图片是否存在 + /// + /// + /// + 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; + } + + /// + /// 鼠标点击, 弹出气泡功能globeControl1 + /// + /// + /// + void globeControl1_FeatureMouseClickEvent(object sender, FeatureMouseClickEventArgs e) + { + GSOFeature feature = e.Feature; + + string str1 = ""; + if (feature != null) + { + if (feature.GetFieldDefn("图片编码") != null)// + { + str1 = GetBubbleInfo(feature, globeControl1); + if (RemoteFileExists(Utility.PicRootURL + feature.GetValue("图片编码").ToString())) + { + str1 += ""; + } + else if (RemoteFileExists(Utility.PicDefaultURL)) + { + str1 += ""; + } + } + else if (isFeatureContainsBianhao(feature)) //管线模型图层 + { + str1 = GetBubbleInfo(feature, globeControl1); + } + + 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; + } + } + } + + /// + /// 鼠标点击, 弹出气泡功能globeControl2 + /// + /// + /// + void globeControl2_FeatureMouseClickEvent(object sender, FeatureMouseClickEventArgs e) + { + GSOFeature feature = e.Feature; + + string str1 = ""; + if (feature != null) + { + if (feature.GetFieldDefn("图片编码") != null) // + { + str1 = GetBubbleInfo(feature, globeControl2); + if (RemoteFileExists(Utility.PicRootURL + feature.GetValue("图片编码").ToString())) + { + str1 += ""; + } + else if (RemoteFileExists(Utility.PicDefaultURL)) + { + str1 += ""; + } + } + else if (isFeatureContainsBianhao(feature)) //管线模型图层 + { + str1 = GetBubbleInfo(feature, globeControl2); + } + + if (str1 != "") + { + + featureTooltip2.HideBalloon(); + balloonEx2.HideBalloon(); + balloonEx2.SetSize(EnumSizeIndexEx.CONTENT_CX, 480); + balloonEx2.SetSize(EnumSizeIndexEx.CONTENT_CY, 420); + balloonEx2.ShowBalloon((int)e.MousePos.X, (int)e.MousePos.Y, str1); + + return; + } + } + } + + /// + /// 拼接气泡表格字符串 + /// + /// + /// + private string GetBubbleInfo(GSOFeature feature,GSOGlobeControl globeControl) + { + if (feature == null) + { + return ""; + } + string str = ""; + str = ""; + 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 += ""; + + 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.get_Fields(layerName, globeControl); + } + if (queryFields != null) + { + string[] param = { "," }; + string[] fieldNames = queryFields.Split(param, StringSplitOptions.RemoveEmptyEntries); + for (int j = 0; j < fieldNames.Length; 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 (name1 == "模型路径") + { + continue; + } + 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 (field1.Type == EnumFieldType.Double) + { + double dl1 = feature.GetFieldAsDouble(j); + if (!name1.Contains("管径") && !name1.Contains("电压") && !name1.Contains("角度")) + { + name1 += "_米"; + } + value1 = dl1.ToString("0.00"); + } + 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 (name2 == "模型路径") + { + continue; + } + + 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 (field2.Type == EnumFieldType.Double) + { + double dl2 = feature.GetFieldAsDouble(j + 1); + if (!name2.Contains("管径") && !name2.Contains("电压") && !name2.Contains("角度")) + { + name2 += "_米"; + } + value2 = dl2.ToString("0.00"); + } + else + { + if (!feature.IsFieldValueNull(j + 1)) + { + value2 = feature.GetValue(j + 1).ToString(); + } + } + } + } + + j++; + } + str += ""; + } + } + str += "
" + title + " " + feature.GetFieldAsString(featureIDFieldName) + "
" + + name1 + + "
" + + value1 + + "
" + + name2 + + "
" + + value2 + "
"; + return str; + } + + string filename = Utility.filename; + List g1layername = new List(); + + /// + /// 获取目标图层 + /// + /// + 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; + } + /// + /// 添加图层 + /// + /// + /// + /// + 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 = 5000; + return templayer.Visible; + } + catch (Exception ex) + { + return false; + } + } + /// + /// 菜单上的 三维导航 工具按钮 + /// + /// + /// + private void buttonItem86_Click(object sender, EventArgs e) + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + } + + /// + /// 地上模式 菜单按钮 + /// + /// + /// + 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(); + + } + } + /// + /// 地下模式 菜单按钮 + /// + /// + /// + 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(); + } + } + /// + /// 行走模式 菜单按钮 + /// + /// + /// + 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; + } + } + /// + /// 地面透明度设置 菜单 + /// + /// + /// + private void sliderGroundTransSet1_ValueChanged(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.sliderGroundTransSet1.Text); + + globeControl1.Globe.GroundOpaque = 100 - sliderGroundTransSet1.Value; + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(roadLayerName);//("180fd"); + if (layer != null) + { + layer.Opaque = 100 - sliderGroundTransSet1.Value; + } + //if (buttonItemSPDB.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; + } + /// + /// 图例 菜单按钮 + /// + /// + /// + 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(); + } + /// + /// 快速定位 菜单按钮 + /// + /// + /// + private void buttonItem91_Click(object sender, EventArgs e) // + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItem91.Text); + FrmFlyToPosition fly = new FrmFlyToPosition(globeControl1); + fly.Show(this); + } + /// + /// 图层管理 菜单按钮 + /// + /// + /// + 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; + + //修改图层管理与标注管理、覆土审查、水平净距分析、垂直净距分析和碰撞分析控件之间的逻辑关系 + controlContainerItem5.Visible = false; + sideBar1.Visible = false; + sideBarPanelItem4.Visible = false; + panel3.Visible = false; + sideBar1.ExpandedPanel = sideBarPanelItem3; + buttonItemBZ11.Checked = false; + + //20160624 + /* + if (sideBarPanelItem4.Visible == true) + { + sideBar1.Visible = true; + controlContainerItem5.Visible = true; + } + else + { + sideBar1.Visible = false; + } + */ + Refresh(); + + } + } + /// + /// 全屏显示 菜单按钮 + /// + /// + /// + 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; + /// + /// 全屏显示功能实现 + /// + 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(); + } + } + + /// + /// 设置窗体宽、高 + /// + /// + /// + private void SetFullScreen(int width, int height) + { + this.Width = width; + this.Height = height; + } + + /// + /// 全屏功能的快捷键F5 + /// + /// + /// + 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); + } + } + /* + /// + /// 输出地图 + /// + /// + /// + /// + 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; + } + * */ + + private Point getUpperLeftPoint(Point p1, Point p2, out int mapWidth, out int mapHeight) // + { + Rectangle rc = new Rectangle(); + + p1 = this.globeControl1.PointToScreen(p1); + p2 = this.globeControl1.PointToScreen(p2); + + int x = Screen.PrimaryScreen.Bounds.X; + int y = Screen.PrimaryScreen.Bounds.Y; + int screenWidth = SystemInformation.WorkingArea.Width; + int screenHeight = SystemInformation.WorkingArea.Height; + + if (p1.X < x) + rc.X = x; + else + rc.X = p1.X; + + if (p1.Y < y) + rc.Y = y; + else + rc.Y = p1.Y; + + p1.X = rc.Left; + p1.Y = rc.Top; + + if (p2.X > screenWidth) + p2.X = screenWidth; + else + p2.X = p2.X; + + if (p2.Y > screenHeight) + p2.Y = screenHeight; + else + p2.Y = p2.Y; + + rc.Width = p2.X - rc.X; + rc.Height = p2.Y - rc.Y; + + mapWidth = rc.Width; + mapHeight = rc.Height; + Point pt = new Point(rc.Left, rc.Top); + return pt; + } + + Image printImage; + /// + /// 打印 菜单 + /// + /// + /// + 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))); + */ + int mapWidth = 0; + int mapHeight = 0; + Point pt = getUpperLeftPoint(pt1, pt2, out mapWidth, out mapHeight); + int rightBottomX = pt.X + mapWidth; + int rightBottomY = pt.Y + mapHeight; + Image myImg = new Bitmap(mapWidth, mapHeight); + Graphics g = Graphics.FromImage(myImg); + g.CopyFromScreen(pt, new Point(0, 0), new Size(rightBottomX, rightBottomY)); + + + 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); + } + /// + /// 输出地图 菜单 + /// + /// + /// + private void btnOutputJPG_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btnOutputJPG.Text); + + //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))); + */ + int mapWidth = 0; + int mapHeight = 0; + Point pt = getUpperLeftPoint(pt1, pt2, out mapWidth, out mapHeight); + int rightBottomX = pt.X + mapWidth; + int rightBottomY = pt.Y + mapHeight; + Image myImg = new Bitmap(mapWidth, mapHeight); + Graphics g = Graphics.FromImage(myImg); + g.CopyFromScreen(pt, new Point(0, 0), new Size(rightBottomX, rightBottomY)); + + 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; + } + } + } + + /// + /// 在窗体的底部状态栏上显示 综合管线条件查询结果 + /// + /// + /// + 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 + " 条记录 | "; + } + } + + /// + /// 统计管线的里程数 + /// + /// + /// + /// + 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; + } + + /// + /// 窗体下方属性表格 右键菜单中的 “定位”菜单 + /// + /// + /// + 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); + + } + + /// + /// 表格中右键 “单个闪烁” 菜单 + /// + /// + /// + private void LightMenu_Click(object sender, EventArgs e) + { + flashflag = "single"; + timer1.Start(); + } + /// + /// 表格中右键 “全部闪烁” 菜单 + /// + /// + /// + private void AllLightMenuItem_Click(object sender, EventArgs e) + { + flashflag = "all"; + timer1.Start(); + } + + /// + /// 使用timer实现管线的闪烁效果 + /// + /// + /// + 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; + } + } + + /// + /// 绘制线 菜单 + /// + /// + /// + private void btnAddLine_Click(object sender, EventArgs e) + { + globeControl1.Globe.DestLayerFeatureAdd = globeControl1.Globe.MemoryLayer; + globeControl1.Globe.Action = EnumAction3D.DrawPolyline; + } + /// + /// 绘制面 菜单 + /// + /// + /// + private void btnAddPolygon_Click(object sender, EventArgs e) + { + globeControl1.Globe.DestLayerFeatureAdd = globeControl1.Globe.MemoryLayer; + globeControl1.Globe.Action = EnumAction3D.DrawPolygon; + } + /// + /// 图层目录树 右键菜单中的 目标图层 菜单 + /// + /// + /// + 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; + } + } + /// + /// 图层目录树 右键菜单中的 可选择 菜单 + /// + /// + /// + 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; + } + /// + /// 图层目录树 右键菜单中的 可编辑 菜单 + /// + /// + /// + 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; + } + /// + /// 图层目录树 右键菜单中的 保存 菜单 + /// + /// + /// + 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(); + } + + /// + /// 根据多边形范围统计管线的里程 + /// + /// + /// + /// 返回查询到的管线要素集合 + 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 pipeLineDis = new Dictionary(); + Dictionary workWellLen = new Dictionary(); + + + + + /// + /// 查找指定图层中在 指定范围内的feature对象集合 + /// + /// + /// + /// + 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; + } + /// + /// 清除结果 菜单 + /// + /// + /// + private void buttonItem47_Click(object sender, EventArgs e) + { + globeControl1.Globe.ClearAnalysis(); + dataGridViewX1.DataSource = null; + panelOfTable.Visible = false; + clearFeatureHighLight(); + } + /// + /// 设置菜单的选中状态 + /// + private void ActionToolMenuChecked() + { + if (globeControl1.Globe.Action != EnumAction3D.TrackPolyline) + { + buttonItemFX2_1.Checked = false; + buttonItemFX2_4.Checked = false; + buttonItemFX2_3.Checked = false; + buttonItemFX4_3.Checked = false; + } + if (globeControl1.Globe.Action != EnumAction3D.NormalHit) + { + buttonItemFX3_6.Checked = false; + // ClearConnexityAnalysis(); + + buttonItemFX3_5.Checked = false; + // ClearCloseValvesAnalysis(); + } + if (globeControl1.Globe.Action != EnumAction3D.TrackPolygon) + { + buttonItemFX4_2.Checked = false; + buttonItemFX4_1.Checked = false; + } + } + + /// + /// 主窗体关闭事件处理 + /// + /// + /// + private void MainFrm_FormClosing(object sender, FormClosingEventArgs e) + { + + if (MessageBox.Show("是否退出系统?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) + { + e.Cancel = true; + } + else { + globeControl1.Globe.MemoryLayer.SaveAs(Application.StartupPath + "/MyPlace.kml"); + } + + //saveLayerList(layerManagerNode.Nodes); + //注销id号为103的热键设定 + // UnregisterHotKey(Handle, 103); + } + + /// + /// 显示流向 功能 + /// + /// + /// + /// + 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(); + } + + FrmCloseValves frm; + + FrmBoosterValvers frmbooster = null; + + /// + /// 垂直净距分析 功能界面中的 选择图层复选框 选中状态改变事件处理 + /// + /// + /// + 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(); + } + /// + /// 水平净距分析 功能界面中的 选择图层复选框 选中状态改变事件处理 + /// + /// + /// + 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(); + } + /// + /// 垂直净距分析 功能界面中的 选择管线复选框 选中状态改变事件处理 + /// + /// + /// + private void checkBoxX1_CheckedChanged(object sender, EventArgs e) + { + clearFeatureHighLight(); + if (checkBoxX1.Checked) + { + comboBoxEx1.SelectedItem = null; + 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; + } + } + /// + /// 水平净距分析 功能界面中的 选择管线复选框 选中状态改变事件处理 + /// + /// + /// + private void checkBoxX1_CheckedChanged_shuiping(object sender, EventArgs e) + { + clearFeatureHighLight();//清除高亮 + if (checkBoxX7.Checked) + { + comboBoxEx4.SelectedItem = null; + 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(); + /// + /// 垂直净距分析 功能界面中的 选择图层下拉框 选中项改变 事件处理 + /// + /// + /// + 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; + } + } + } + /// + /// 水平净距分析 功能界面中的 选择图层下拉框 选中项改变 事件处理 + /// + /// + /// + 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 featCount = new Dictionary(); + Dictionary featLenth = new Dictionary(); + Dictionary m_FeaturesWithBianhao = new Dictionary();//记录编号和对应的标注点的位置 + GSOFeatures polygonJingJuAnalysises = new GSOFeatures(); + + /// + /// 垂直净距分析 功能界面中的 开始分析按钮 事件处理 + /// + /// + /// + 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; + } + + /// + /// 在指定的两点组成的线的中间添加一个marker对象,并将marker对象添加到指定的图层中 + /// + /// + /// + /// + /// + /// + 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; + } + + /// + /// 计算指定feature对象与除了该feature所在图层之外的 所有管线图层中的所有feature对象 的垂直距离 并在表格中记录符合要求的管线 + /// + /// + /// + /// + /// + private void VerticalDistanceAnalysis(string type, GSOFeature selectedFeature, List _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(); + } + /// + /// 垂直净距分析中 表格行的 双击定位 功能。 与覆土分析的实现方法不同,主要原因是需要标注垂距 + /// + /// + /// + 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); + } + } + } + } + + /// + /// 水平净距分析 功能界面中 开始分析按钮 的事件处理 + /// + /// + /// + 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; + } + + + /// + /// 计算指定feature对象与除了该feature所在图层之外的 所有管线图层中的所有feature对象 的水平距离 并记录符合要求的管线 功能 + /// + /// + /// + /// + /// + private void HorizontalDistanceAnalysis(GSOFeature selectedFeature, List _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)); + } + } + } + } + } + /// + /// 水平净距分析 功能界面中 表格的 双击定位 功能 + /// + /// + /// + 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); + } + } + } + } + } + /// + /// 碰撞分析 功能界面中 开始分析按钮 事件处理 + /// + /// + /// + 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; + } + /// + /// 碰撞分析功能界面中 表格的 双击定位 功能 + /// + /// + /// + 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); + } + } + } + } + + + + /// + /// 覆土分析功能操作界面中的 选择管线 复选框选中状态改变事件处理 + /// + /// + /// + private void checkBoxX5_CheckedChanged(object sender, EventArgs e) + { + clearFeatureHighLight(); + if (checkBoxX5.Checked) + { + comboBoxEx3.SelectedItem = null; + 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; + } + } + /// + /// 覆土分析功能操作界面中的 选择图层 复选框选中状态改变事件处理 + /// + /// + /// + 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(); + } + /// + /// 覆土分析功能操作界面中的 图层下拉框选中项改变事件处理 + /// + /// + /// + 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; + } + } + } + /// + /// 覆土分析功能操作界面中的 开始分析 按钮事件处理 + /// + /// + /// + 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; + + + GSOPoint3d markerPosition = new GSOPoint3d(); + 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]; + GSOPoint3d pt = new GSOPoint3d(); + + 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"); + + pt.X = pts[m].X; + pt.Y = pts[m].Y; + pt.Z = 0; + markerPosition = LabelVerticalDistance(layerTemp, pts[m], pt, Convert.ToDouble(dataGridViewX7.Rows[idx].Cells[2].Value), true); + 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]; + GSOPoint3d pt = new GSOPoint3d(); + 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"); + + pt.X = pts[m].X; + pt.Y = pts[m].Y; + pt.Z = 0; + markerPosition = LabelVerticalDistance(layerTemp, pts[m], pt, Convert.ToDouble(dataGridViewX7.Rows[idx].Cells[2].Value), true); + + 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; + } + + /// + /// 覆土分析中 表格的 双击定位 功能 + /// + /// + /// + 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); + } + } + } + } + } + /// + /// 覆土分析功能操作界面中的 导出Excel按钮 事件处理 + /// + /// + /// + private void buttonX10_Click(object sender, EventArgs e) + { + if (dataGridViewX7.Rows.Count > 0) + { + ExportExcel("覆土分析", dataGridViewX7, null); + } + else + { + MessageBox.Show("表格内容为空!", "提示"); + } + } + /// + /// 覆土分析功能操作界面底部的 关闭 按钮事件处理 + /// + /// + /// + 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(); + layerTemp.RemoveAllFeature(); + + if (buttonItem1.Checked) + { + sideBar1.ExpandedPanel = sideBarPanelItem3; + } + else + { + sideBar1.Visible = false; + } + globeControl1.Refresh(); + + //Refresh(); + } + + + /// + /// 垂直净距分析 功能界面中 清除分析结果按钮 事件处理 + /// + /// + /// + 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(); + } + /// + /// 水平净距分析 功能界面中 清除分析结果按钮 事件处理 + /// + /// + /// + 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(); + } + + /// + /// 垂直净距分析功能界面中 关闭按钮 事件处理 + /// + /// + /// + 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(); + } + /// + /// 水平净距分析功能界面中 删除缓冲区按钮 事件处理 + /// + /// + /// + private void buttonX14_Click(object sender, EventArgs e) + { + 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(); + } + + /// + /// 导出指定DataGridView控件中的内容 + /// + /// + /// + 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(); + } + } + } + } + + /// + /// 垂直净距分析功能界面中 导出Excel按钮 事件处理 + /// + /// + /// + private void buttonX4_Click(object sender, EventArgs e) + { + if (dataGridViewX3.Rows.Count > 0) + { + ExportExcel("垂直净距分析", dataGridViewX3, listBox1); + } + else + { + MessageBox.Show("表格内容为空!", "提示"); + } + } + /// + /// 水平净距分析功能界面中 导出Excel按钮 事件处理 + /// + /// + /// + private void buttonX4_Click_shuiping(object sender, EventArgs e) + { + if (dataGridViewX9.Rows.Count > 0) + { + ExportExcel("水平净距分析", dataGridViewX9, listBox3); + } + else + { + MessageBox.Show("表格内容为空!", "提示"); + } + } + + + /// + /// 清除所有坑 菜单 + /// + /// + /// + private void buttonItem3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItem3.Text); + + globeControl1.Globe.RemoveAllPits(); + } + + //} + /// + /// 大气层 菜单 + /// + /// + /// + private void buttonItem17_Click_1(object sender, EventArgs e) + { + globeControl1.Globe.Atmosphere.Visible = !globeControl1.Globe.Atmosphere.Visible; + buttonItemSH1.Checked = globeControl1.Globe.Atmosphere.Visible; + globeControl1.Refresh(); + } + /// + /// 经纬网 菜单 + /// + /// + /// + private void buttonItem20_Click(object sender, EventArgs e) + { + globeControl1.Globe.LatLonGrid.Visible = !globeControl1.Globe.LatLonGrid.Visible; + buttonItemSH3.Checked = globeControl1.Globe.LatLonGrid.Visible; + globeControl1.Globe.Refresh(); + } + /// + /// 状态条 菜单 + /// + /// + /// + private void buttonItem21_Click_1(object sender, EventArgs e) + { + globeControl1.Globe.StatusBar.Visible = !globeControl1.Globe.StatusBar.Visible; + buttonItemSH4.Checked = globeControl1.Globe.StatusBar.Visible; + globeControl1.Globe.Refresh(); + } + + + + /// + /// 添加指定路径下的数据 功能 + /// + /// + /// + 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); + //CheckDatasetGeoReference(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; + } + return objRes; + } + /// + /// 刷新目录树 功能 + /// + 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); + } + } + /// + /// 判断图层是否包含字段列表 + /// + /// + /// + 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; + } + + /// + /// 统计指定图层在指定范围内的所有feature对象 + /// + /// + /// + /// + 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; + } + /// + /// 碰撞分析功能界面中 选择管线复选框 选中状态改变事件处理 + /// + /// + /// + private void checkBoxX3_CheckedChanged(object sender, EventArgs e) + { + clearFeatureHighLight(); + if (checkBoxX3.Checked) + { + comboBoxEx2.SelectedItem = null; + 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; + } + } + /// + /// 碰撞分析功能界面中 选择图层复选框 选中状态改变事件处理 + /// + /// + /// + 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(); + } + /// + /// 碰撞分析功能界面中 选择图层下拉框 选中项改变事件处理 + /// + /// + /// + 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; + } + } + } + /// + /// 清除所有图层中的所有feature对象的高亮状态 功能 + /// + 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); + } + } + } + } + for (int i = 0; i < globeControl2.Globe.Layers.Count; i++) + { + GSOLayer layer = globeControl2.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; + } + } + } + + if (globeControl1.Globe.Action == EnumAction3D.SelectObject) + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + //globeControl1.Globe.Action = EnumAction3D.SelectObject; + } + } + + /// + /// 碰撞分析功能界面中 清除分析结果按钮 事件处理 + /// + /// + /// + 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(); + } + /// + /// 碰撞分析功能界面中 导出Excel按钮 事件处理 + /// + /// + /// + private void buttonX6_Click(object sender, EventArgs e) + { + if (dataGridViewX5.Rows.Count > 0) + { + ExportExcel("碰撞分析", dataGridViewX5, listBox2); + } + else + { + MessageBox.Show("表格内容为空!", "提示"); + } + } + /// + /// 导出CAD 菜单 + /// + /// + /// + private void btnExportCAD_Click(object sender, EventArgs e) + { + FrmExportCADS frm = new FrmExportCADS(globeControl1, m_PipelineLayerNames); + frm.ShowDialog(); + } + + ///// + ///// 区域分析 菜单 + ///// + ///// + ///// + //private void buttonItem50_Click(object sender, EventArgs e) + //{ + // buttonItem50.Checked = !buttonItem50.Checked; + // ribbonBarQY.Visible = buttonItem50.Checked; + // ribbonBarQY.Location = new Point(0, 0); + //} + + + /// + /// 连接数据库 菜单事件处理 + /// + /// + /// + 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; + } + } + } + /// + /// 数据验证 菜单 + /// + /// + /// + private void buttonItem80_Click(object sender, EventArgs e) + { + FrmValiData frm = new FrmValiData(globeControl1); + frm.ShowDialog(); + } + /// + /// 根据指定图层创建图层节点并将节点添加到图层管理节点的子节点集合中 + /// + /// + 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; + + if (!layerManagerNode.Nodes.Contains(node)) + { + layerManagerNode.Nodes.Insert(0, node); + layerManagerNode.Expand(); + } + } + } + /// + /// 数据库备份 菜单 + /// + /// + /// + 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(); + } + } + } + + + + #region Fan 去掉 + //GSOFeature emitterFeature; // 粒子要素 + /// + /// 添加火苗 功能 + /// + /// + /// + /// + 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); + + } + /// + /// 添加喷泉 功能 + /// + /// + /// + /// + 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); + } + #endregion + + /// + /// 获取指定图层中最后一个feature对象的名称对应的整数 + /// + /// + /// + 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; + } + /// + /// 设置除指定标注图层之外的所有标注图层不可见 + /// + /// + 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; + } + } + } + } + } + + /// + /// 判断选中的对象是否为管线 + /// + /// 被选中管线 + /// 返回一根线 + 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; + } + + /// + /// 创建label要素 功能 + /// + /// 添加label要素的feature + /// feature的位置 + /// label要素名字 + /// feature名字 + /// label要素距离点的位置 + /// + 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; + } + + + + /// + /// 获取指定两点组成的线的长度 功能 + /// + /// + /// + /// + 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; + } + + /// + /// 图层节点树中 节点 右键单击事件处理 + /// + /// + /// + 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; + } + } + } + } + } + + /// + /// 标注管理、传感器管理 图层目录树的右键菜单中的 刷新列表 菜单 + /// + /// + /// + 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); + } + } + /// + /// 给指定的图层节点添加代表feature对象的子节点 + /// + /// + private void RefreshTreeNodeLayerFeatureList(TreeNode layerTreeNode) + { + layerTreeNode.Nodes.Clear(); + GSOLayer layer = (GSOLayer)layerTreeNode.Tag; + // 只将类型为内存数据集的图层列出,如果是其它类型的数据集可能数据量太大,没发显示在树控件中 + if (layer.Dataset is GSOFeatureDataset) + { + VisitFeature3Ds(layer.GetAllFeatures(), layerTreeNode); + } + } + + /// + /// 标注管理、传感器管理 图层目录树的右键菜单中的 移除所有 菜单 + /// + /// + /// + 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(); + } + } + + /// + /// 图层目录树的 节点对应的复选框选中状态改变事件处理 + /// + /// + /// + private void layerMarkerTree_AfterCheck(object sender, TreeViewEventArgs e) + { + if (e.Action != TreeViewAction.Unknown) + { + CheckTreeNode(e.Node, e.Node.Checked); + } + } + /// + /// 改变指定节点对应的复选框的选中状态 + /// + /// + /// + private void CheckTreeNode(TreeNode node, Boolean bChecked) + { + CheckChildTreeNode(node, bChecked); + globeControl1.Globe.Refresh(); + } + /// + /// 改变指定节点的子节点对应的复选框的选中状态 + /// + /// + /// + 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); + } + } + /// + /// 标注管理、传感器管理 目录树中的feature节点的右键菜单中的 删除 菜单 + /// + /// + /// + 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(); + } + } + + /// + /// 双屏对比 菜单 + /// + /// + /// + //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(); + // } + //} + /// + /// 模拟分析 菜单 + /// + /// + /// + //private void buttonItem51_Click(object sender, EventArgs e) + //{ + // buttonItem51.Checked = !buttonItem51.Checked; + // ribbonBarMN.Visible = buttonItem51.Checked; + // ribbonBarMN.Location = new Point(0, 0); + //} + + /// + /// 双屏设置 菜单 + /// + /// + /// + //private void buttonItem96_Click(object sender, EventArgs e) + //{ + // FrmLayerControl frm = new FrmLayerControl(layerTree,globeControl1,globeControl2); + // frm.Show(this); + //} + /// + /// 双屏联动 菜单 + /// + /// + /// + //private void buttonItem95_Click(object sender, EventArgs e) + //{ + // buttonItem95.Checked = !buttonItem95.Checked; + //} + ///// + /// 添加用户仓库 菜单 + /// + /// + /// + private void buttonItem108_Click(object sender, EventArgs e) + { + FrmUserRepo frm = new FrmUserRepo(-1); + frm.ShowDialog(); + } + /// + /// 用户仓库管理 菜单 + /// + /// + /// + private void buttonItem111_Click(object sender, EventArgs e) + { + FrmUserRepoMgr frm = new FrmUserRepoMgr(); + frm.ShowDialog(); + } + /// + /// 添加分系统 菜单 + /// + /// + /// + private void buttonItem112_Click(object sender, EventArgs e) + { + //FrmAPP frm = new FrmAPP(-1); + //frm.ShowDialog(); + } + /// + /// 分系统管理 菜单 + /// + /// + /// + private void buttonItem113_Click(object sender, EventArgs e) + { + //FrmAPPMgr frm = new FrmAPPMgr(); + //frm.ShowDialog(); + } + /// + /// 添加操作 菜单 + /// + /// + /// + private void buttonItem114_Click(object sender, EventArgs e) + { + FrmOper frm = new FrmOper(-1); + frm.ShowDialog(); + } + /// + /// 操作管理 菜单 + /// + /// + /// + private void buttonItem115_Click(object sender, EventArgs e) + { + FrmOperMgr frm = new FrmOperMgr(); + frm.ShowDialog(); + } + /// + /// 添加资源 菜单 + /// + /// + /// + private void buttonItem116_Click(object sender, EventArgs e) + { + FrmRESC frm = new FrmRESC(-1); + frm.ShowDialog(); + } + /// + /// 资源管理 菜单 + /// + /// + /// + private void buttonItem117_Click(object sender, EventArgs e) + { + FrmRESCMgr frm = new FrmRESCMgr(); + frm.ShowDialog(); + } + /// + /// 添加权限 菜单 + /// + /// + /// + private void buttonItem118_Click(object sender, EventArgs e) + { + FrmPerm frm = new FrmPerm(-1); + frm.ShowDialog(); + } + /// + /// 权限管理 菜单 + /// + /// + /// + private void buttonItem119_Click(object sender, EventArgs e) + { + FrmPermMgr frm = new FrmPermMgr(); + frm.ShowDialog(); + } + /// + /// 添加访问控制 菜单 + /// + /// + /// + private void buttonItem120_Click(object sender, EventArgs e) + { + FrmAccess frm = new FrmAccess(-1); + frm.ShowDialog(); + } + /// + /// 访问控制管理 菜单 + /// + /// + /// + private void buttonItem121_Click(object sender, EventArgs e) + { + FrmAccessMgr frm = new FrmAccessMgr(); + frm.ShowDialog(); + } + /// + /// 部门类型管理 菜单 + /// + /// + /// + private void buttonItem122_Click(object sender, EventArgs e) + { + FrmRegionTypeMgr frm = new FrmRegionTypeMgr(); + frm.ShowDialog(); + } + /// + /// 添加用户 菜单 + /// + /// + /// + private void buttonItem127_Click(object sender, EventArgs e) + { + FrmUserAdd frm = new FrmUserAdd(-1); + frm.ShowDialog(); + } + /// + /// 用户信息管理 菜单 + /// + /// + /// + private void buttonItem128_Click_1(object sender, EventArgs e) + { + FrmUserManager frm = new FrmUserManager(); + frm.ShowDialog(); + } + /// + /// 添加角色 菜单 + /// + /// + /// + private void 添加角色_Click(object sender, EventArgs e) + { + FrmRole frm = new FrmRole(-1); + frm.ShowDialog(); + } + /// + /// 所有角色管理 菜单 + /// + /// + /// + private void 角色管理_Click(object sender, EventArgs e) + { + FrmRoleMgr frm = new FrmRoleMgr(); + frm.ShowDialog(); + } + + /// + /// 部门角色管理 菜单 + /// + /// + /// + private void buttonItem133_Click(object sender, EventArgs e) + { + FrmRegionRoleMgr frm = new FrmRegionRoleMgr(); + frm.ShowDialog(); + } + /// + /// 部门管理 菜单 + /// + /// + /// + private void buttonItem130_Click(object sender, EventArgs e) + { + FrmRegionMgr frm = new FrmRegionMgr(); + frm.ShowDialog(); + } + + /// + /// 日志管理 菜单 + /// + /// + /// + private void buttonItem135_Click(object sender, EventArgs e) + { + FrmLogManager frm = new FrmLogManager(); + frm.ShowDialog(); + } + /// + /// 传感器信息查询 菜单 + /// + /// + /// + 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); + } + } + } + /// + /// 根据指定的图层的caption属性的值在配置文件中查找对应的数据库中的表的名称 + /// + /// 图层的caption属性的值 + /// 对应的数据库中的表的名称 + 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; + } + /// + /// 根据数据库中的表的名称 查找对应的表中的字段名称的集合 + /// + /// 数据库中的表的名称 + /// 对应的表中的字段名称的集合 + 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; + } + + /// + /// 历史曲线查询 菜单 + /// + /// + /// + 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; + /// + /// 传感器在线报警 菜单 + /// + /// + /// + 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); + } + /// + /// 传感器报警 功能中的 定时器 的触发事件处理 + /// + /// + /// + 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; + } + } + } + } + } + } + } + + + /// + /// 沿线运动 菜单 + /// + /// + /// + private void buttonItem138_Click(object sender, EventArgs e) + { + if (globeControl1.Globe.SelectedObject == null) + { + MessageBox.Show("请先选择一条线!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + return; + } + + GSOFeature lineFeature = globeControl1.Globe.SelectedObject; + if (lineFeature.Geometry == null || lineFeature.Geometry.Type != EnumGeometryType.GeoPolyline3D) + { + MessageBox.Show("请先选择一条线!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + return; + } + + OpenFileDialog dlg = new OpenFileDialog(); + dlg.Filter = "*.gcm;*.3ds|*.gcm;*.3ds|*.3ds|*.3ds|*.gcm|*.gcm"; + if (dlg.ShowDialog() == DialogResult.OK) + { + GSOGeoModel model = new GSOGeoModel(); + model.FilePath = dlg.FileName; + + GSOGeoDynamicRoute dynamicRoute = new GSOGeoDynamicRoute(); + dynamicRoute.ActorGeometry = model; + + GSORoute route = new GSORoute(); + GSOGeoPolyline3D geoline = (GSOGeoPolyline3D)lineFeature.Geometry; + for (int i = 0; i < geoline[0].Count; i++) + { + route.Add(geoline[0][i]); + } + route.CircleRoute = false; + route.Speed = 30; + route.RotateSpeed = 50; + route.AltitudeMode = geoline.AltitudeMode; + dynamicRoute.Route = route; + + GSOFeature feature = new GSOFeature(); + + dynamicRoute.Play(); + feature.Geometry = dynamicRoute; + + //GSOLabel gsoLabel = new GSOLabel(); + //gsoLabel.Text = "模型测试"; + //feature.Label = gsoLabel; + globeControl1.Globe.MinModelVisibleSize = 0; + + globeControl1.Globe.MemoryLayer.AddFeature(feature); + globeControl1.Globe.Refresh(); + } + } + /// + /// 回退 菜单 + /// + /// + /// + private void buttonItem99_Click(object sender, EventArgs e) + { + globeControl1.Globe.UnDoEdit(); + } + /// + /// 前进 菜单 + /// + /// + /// + private void buttonItem100_Click(object sender, EventArgs e) + { + globeControl1.Globe.ReDoEdit(); + } + /// + /// 水平净距 功能界面中的 标签内容改变事件处理 + /// + /// + /// + 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() + "米的管线有:"; + } + } + } + /// + /// 垂直净距 功能界面中的 标签内容改变事件处理 + /// + /// + /// + 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() + "米的管线有:"; + } + } + } + /// + /// 覆土分析 功能界面中的 标签内容改变事件处理 + /// + /// + /// + 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() + "米的管线有:"; + } + } + } + + /// + /// 传感器分类查询 全区域 菜单 + /// + /// + /// + private void buttonItemSensor全区域查询_Click(object sender, EventArgs e) + { + FrmAccessoriesSensor.ShowForm(globeControl1, instrumenLayerNames, 0); + } + /// + /// 传感器分类查询 绘制区域 菜单 + /// + /// + /// + private void buttonItemSensor绘制区域查询_Click(object sender, EventArgs e) + { + FrmAccessoriesSensor.ShowForm(globeControl1, instrumenLayerNames, 1); + } + + + /// + /// 碰撞分析 功能界面中 关闭按钮 事件处理 + /// + /// + /// + 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(); + } + /// + /// 覆土分析 功能界面中的 清除分析结果 按钮事件处理 + /// + /// + /// + 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(); + } + /// + /// 数字预处理 功能 + /// + /// + /// + private void 数字预处理buttonItem140_Click(object sender, EventArgs e) + { + FrmEditShapeFile frm = new FrmEditShapeFile(globeControl1); + frm.ShowDialog(this); + } + + + /// + /// 导出矢量 功能 将图层导出为kml和shp格式数据 + /// + /// + /// + private void 导出矢量buttonItem140_Click(object sender, EventArgs e) + { + List listVectorNames = new List(); + for (int i = 0; i < m_PipelineLayerNames.Count; i++) + { + 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 = ""; + /// + /// 绘制城市七线 功能按钮 + /// + /// + /// + 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; + } + } + } + /// + /// 七线审核 功能按钮 + /// + /// + /// + private void 七线审核buttonItem141_Click(object sender, EventArgs e) + { + FrmCityServerLineAnalysis frm = new FrmCityServerLineAnalysis(globeControl1, m_PipelineLayerNames); + frm.ShowDialog(this); + } + + /// + /// 间距分析 开始分析按钮 分析绘制的七线和管线的距离是否符合标准 + /// + /// + /// + 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; + } + /// + /// 间距分析 清除分析结果 + /// + /// + /// + 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(); + } + /// + /// 间距分析 导出Excel按钮 将间距分析的结果以Excel表格的形式导出 + /// + /// + /// + private void buttonExportExcel_Click(object sender, EventArgs e) + { + if (dataGridViewAnalysisResult.Rows.Count > 0) + { + ExportExcel("间距分析", dataGridViewAnalysisResult, listBoxStasticsResult); + } + else + { + MessageBox.Show("表格内容为空!", "提示"); + } + } + /// + /// 间距分析 关闭按钮 + /// + /// + /// + 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(); + } + /// + /// 间距分析 分析结果表格双击定位 + /// + /// + /// + 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); + } + } + } + } + /// + /// 间距分析 选择管线复选框 + /// + /// + /// + private void checkBoxSelectPipeline_CheckedChanged(object sender, EventArgs e) + { + clearFeatureHighLight();//清除高亮 + if (checkBoxSelectPipeline.Checked) + { + comboBoxLayer.SelectedItem = null; + 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; + } + } + /// + /// 间距分析 选择图层复选框 + /// + /// + /// + 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(); + } + /// + /// 间距分析 选择图层下拉框 + /// + /// + /// + 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; + } + } + } + + + + /// + /// 管线自动缩进 菜单 + /// + /// + /// + private void 管线自动缩进buttonItem140_Click(object sender, EventArgs e) + { + FrmPipelineIndented frm = new FrmPipelineIndented(globeControl1, m_PipelineLayerNames, workwellLayerNames); + 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 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); + // } + //} + + /// + /// 统计指定图层在指定范围内的所有feature对象 + /// + /// + /// + /// + 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) + { + 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 setLayerVisible(string layerName) + { + GSOLayer templayer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + if (templayer != null) + { + templayer.Visible = false; + } + globeControl1.Globe.Refresh(); + } + + /// + /// 连接数据库 + /// + /// + /// + private void buttonItem129_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL4_1.Text); + + FrmDatabaseParaSetting2 frm = new FrmDatabaseParaSetting2(globeControl1); + if (frm.ShowDialog() == DialogResult.OK) + { + ds = FrmDatabaseParaSetting2.ds; + if (ds != null) + { + ds.IsCloseSaved = false; + } + } + } + + /// + /// 一键审核---导入数据 + /// + /// + /// + private void buttonItem127_Click_2(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, "打开数据"); + + try + { + //if (shds == null) + //{ + //没连的话,直接连接审核库; //审核库配置读配置文件 + string dbIp = Utility.sgdbip; + string database = Utility.sgdbname; + string user = Utility.sgdbuser; + string pass = Utility.sgdbpwd; + /* + 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; + //} + } + catch (Exception ex) + { + LogError.PublishError(ex); + MessageBox.Show("内存过载请清理内存,并重新启动规划分析!", "提示"); + return; + } + + } + + /// + ///自动导出图片 + /// + /// + /// + private void buttonItem130_Click_1(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, "导出审核图"); + + 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))); + */ + + int mapWidth = 0; + int mapHeight = 0; + Point pt = getUpperLeftPoint(pt1, pt2, out mapWidth, out mapHeight); + int rightBottomX = pt.X + mapWidth; + int rightBottomY = pt.Y + mapHeight; + Image myImg = new Bitmap(mapWidth, mapHeight); + Graphics g = Graphics.FromImage(myImg); + g.CopyFromScreen(pt, new Point(0, 0), new Size(rightBottomX, rightBottomY)); + + 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; + } + } + } + /// + /// 一键审核功能 + ///
+ /// + /// + private void buttonItem128_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItem128.Text); + //垂直净距标准 + + frmSh = new FrmYJSHTC(globeControl1, globeControl2,layerTree); + + if (frmSh.ShowDialog() == DialogResult.OK) + { + frmWait = new FrmWait("一键审核……"); + frmWait.Location = new Point(this.Width - frmWait.Width - 10, this.Height - frmWait.Height - 50); + frmWait.Owner = this; + frmWait.Show(); + Thread thread = new Thread(new ThreadStart(doWork)); + thread.IsBackground = true; + thread.Start(); + } + } + + void doWork() + { + FrmShResult frmShResult = null; + + double dVerticalJingJuBiaoZhun = 1, dHorizontalJingJuBiaoZhun = 1; + if (frmSh.rukuLayer != null) + { + #region + this.Invoke((EventHandler)delegate + { + try + { + List managerLayerList = new List(); + for (int i = 0; i < layerManagerNode.Nodes.Count; i++) + { + managerLayerList.Add(layerManagerNode.Nodes[i].Text); + } + if (!managerLayerList.Contains(frmSh.rukuLayer.Caption)) + { + TreeNode node = new TreeNode(); + node.Tag = frmSh.rukuLayer; + node.Text = frmSh.rukuLayer.Dataset.Caption; + node.ImageIndex = 0; + node.SelectedImageIndex = 0; + node.Checked = frmSh.rukuLayer.Visible; + layerManagerNode.Nodes.Insert(0, node); + layerManagerNode.Expand(); + } + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "提示"); + } + }); + #endregion + + shlayername = frmSh.rukuLayer.Name; + globeControl1.Refresh(); + } + + if (frmShResult != null && !frmShResult.IsDisposed) + { + try + { + clearFeatureHighLight(); + ClearRedlineAnalyseResult(); + frmShResult.Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message); + } + } + + 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.analysis(); + + //MainFrm窗体显示控制,回到一键审核Tab + this.Invoke((EventHandler)delegate + { + frmShResult.Show(); + frmWait.Close(); + //将tab页恢复到一键审核 + ribbonTabItem11.Checked = true; + try + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + //zhanshi = false; + splitContainer1.Panel2Collapsed = true; + + panelOfTable.Visible = false; + legendSC.Visible = false; + legendSG.Visible = false; + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + } + catch (Exception ex) + { + MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + + }); + + boolfrmShResult = true; + } + else + { + + } + } + + + /// + /// 清除渲染结果 + /// + 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(); + } + /// + /// 已审核的图层 + /// + /// + /// + private void buttonItem132_Click_1(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItem132.Text); + + if (shds == null) + { + //没连的话,直接连接审核库; //审核库配置读配置文件 + string dbIp = Utility.sgdbip; + string database = Utility.sgdbname; + string user = Utility.sgdbuser; + string pass = Utility.sgdbpwd; + + /* + 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; + //} + + } + /// + /// 审核入库 + /// + /// + /// + private void buttonItem133_Click_1(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, "审核入库"); + FrmShRK frmShrk = new FrmShRK(globeControl1); + frmShrk.Show(); + } + /// + /// 模拟设计修改 + /// + /// + /// + private void buttonItem134_Click_1(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, "模拟设计修改"); + + 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 + { + + } + + } + + + /// + /// 绘制垂线 + /// + /// + /// + 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); + } + /// + /// 比较两个点是否是同一个点 + /// + /// + /// + /// + 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; + } + /// + /// 获得点到线的垂线距离及垂点 + /// + /// + /// + /// + /// + 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); + 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]; + } + /// + /// 获得斜率 + /// + /// + /// + /// + /// + /// + /// + 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); + } + } + /// + /// 根据默认投影参数,经纬度转xyz + /// + /// + /// + /// + 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; + } + /// + /// 根据投影参数,经纬度转xyz + /// + /// + /// + /// + /// + 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; + } + /// + /// 根据默认投影参数,xyz转经纬度 + /// + /// + /// + /// + 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; + } + /// + /// 根据投影参数,Xyz转经纬度 + /// + /// + /// + /// + /// + 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; + } + /// + /// 获得inpolygon的管线长度 + /// + /// + 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; + } + + + /// + /// 一键审核中调节透明度 + /// + /// + /// + private void sliderItem1_ValueChanged(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.sliderItem1.Text); + + globeControl1.Globe.GroundOpaque = 100 - sliderItem1.Value; + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(roadLayerName);//("180fd"); + if (layer != null) + { + layer.Opaque = 100 - sliderItem1.Value; + } + + optiValue = sliderItem1.Value; + } + /// + /// 红线审核中的透明度分析 + /// + /// + /// + private void sliderItem3_ValueChanged(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.sliderItem3.Text); + + globeControl1.Globe.GroundOpaque = 100 - sliderItem3.Value; + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(roadLayerName);//("180fd"); + if (layer != null) + { + layer.Opaque = 100 - sliderItem3.Value; + } + optiValue = sliderItem3.Value; + } + + #region yanxiaowei + //初始化DataGridViewX1控件 + public delegate void DataGridViewDelegate(DataTable dt, string strLable, string strLayer, bool initDataGrid); + /// + /// 代理函数,操作DatgridViewX1 + /// + /// + /// + public void InitDataGridViewX1(DataTable dt, string strLable, string strLayer, bool initDataGrid) + { + if (initDataGrid == true) + { + dataGridViewX1.DataSource = dt; + panelOfTable.Visible = true; + toolStripNumbers.Text = strLable; + dataGridViewX1.Tag = strLayer; + } + else + { + dataGridViewX1.DataSource = null; + dataGridViewX1.Refresh(); + panelOfTable.Visible = false; + toolStripNumbers.Text = ""; + dataGridViewX1.Tag = ""; + globeControl1.Globe.MemoryLayer.RemoveAllFeature();//清除双击产生的标注 + } + } + FrmAnalysisGuiHuaResult from; + /// + /// 主窗体下方属性表格 双击定位 功能 + /// + /// + /// + private void dataGridViewX1_MouseDoubleClick(object sender, MouseEventArgs e) + { + if (redSH == false) + { + 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 if (dataGridViewX1.Columns.Contains("标识器编号")) + { + featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["标识器编号"].Value.ToString(); + } + featureName = featureName.Trim(); + + GSOLayer layer = null; + layer = globeControl1.Globe.Layers.GetLayerByCaption(dataGridViewX1.Tag.ToString()); + + if (layer == null) return; + + GSOFeatures features = layer.GetFeatureByName(featureName, false); + if (features.Length == 0) return; + GSOFeature rowFeature = features[0]; + + ClassSearchAnalysis.AddMakerToLineFeature(globeControl1, rowFeature); + + } + } + } + else + { + if (e.Button == MouseButtons.Left) + { + if (from != null && !from.IsDisposed) + { + try + { + from.Close(); + } + catch (Exception ex) + { + LogError.PublishError(ex); + } + } + try + { + DataGridView.HitTestInfo hittestinfo = dataGridViewX1.HitTest(e.X, e.Y); + if (hittestinfo.RowIndex >= 0) + { + string layer = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["管线类型"].Value.ToString(); + string hxName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["红线编号"].Value.ToString(); + FrmAnalysisGuiHuaResult frm = new FrmAnalysisGuiHuaResult(globeControl1, lineStruct, featsList, + panelOfTable, dataGridViewX1, layer, hxName); + frm.Location = new Point(this.Width - frm.Width - 10, this.Height - frm.Height - 20); + frm.Show(this); + + from = frm; + } + } + catch (Exception ex) + { + LogError.PublishError(ex); + } + } + } + } + + /// + /// 空间查询 + /// + /// + /// + private void buttonItemSearch1_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemSearch1.Text); + + trackflag = "PipelineSpatialQuery"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; + + } + /// + /// 关键字查询 + /// + /// + /// + private void buttonItemSearch9_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch9.Text); + + FrmKeywordQuery.ShowForm(globeControl1, m_PipelineLayerNames, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 编号查询 + /// + /// + /// + private void buttonItemSearch2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch2.Text); + + FrmCodingQuery.ShowForm(globeControl1, m_PipelineLayerNames, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 坐标查询 + /// + /// + /// + private void buttonItemSearch3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch3.Text); + + FrmSetLatLonPos.ShowForm(globeControl1); + } + /// + /// 附属物查询 + /// + /// + /// + private void buttonItemSearch10_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch10.Text); + + FrmFittingQuery.ShowForm(globeControl1, instrumenLayerNames, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 管径查询 + /// + /// + /// + private void buttonItemSearch4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch4.Text); + + FrmDiameterQuery.ShowForm(globeControl1, m_PipelineLayerNames, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 材质查询 + /// + /// + /// + private void buttonItemSearch5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch5.Text); + + FrmMaterialSel.ShowForm(globeControl1, m_PipelineLayerNames, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 基本查询 + /// + /// + /// + private void buttonItemSearch6_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch6.Text); + + FrmBasicQuery.ShowForm(globeControl1, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 复合查询 + /// + /// + /// + private void buttonItemSearch7_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch7.Text); + + FrmQuerySQL.ShowForm(globeControl1, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 关联查询 + /// + /// + /// + private void buttonItemSearch8_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch8.Text); + + if (globeControl1.Globe.SelObjectCount != 1) + { + MessageBox.Show("请选中一个对象!", "提示"); + return; + } + + 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 || (feature.Geometry.Type == EnumGeometryType.GeoPolygon3D + || feature.Geometry.Type == EnumGeometryType.GeoWater)) + return; + else + { + ClassSearchAnalysis.ResultRelationAnalysis(globeControl1, feature, valueLayerNames, workwellLayerNames, + instrumenLayerNames, pipefittingLayerNames, m_PipelineLayerNames, valueAllowance); + } + } + } + #endregion + /// + /// 清除分析 + /// + /// + /// + private void buttonItemClear_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemClear.Text); + + globeControl1.Globe.ClearMeasure(); + layerTemp.RemoveAllFeature(); + layerTemp2.RemoveAllFeature(); + buttonItemLS5.Checked = false; + + dataGridViewX1.DataSource = null; + panelOfTable.Visible = false; + + 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); + + NetworkAnalysisTool.ClearAllTopAnalysis(this.globeControl1); + // 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();//清除所有坑 + + 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(); + } + } + + clearFeatureHighLight();//取消管线高亮 + + GSOLayer layerGround = globeControl1.Globe.Layers.GetLayerByCaption(roadLayerName);//("180fd"); + if (layerGround != null) + { + layerGround.Visible = true; + } + globeControl1.Refresh(); + globeControl2.Refresh(); + ClearRedlineAnalyseResult(); + globeControl1.Globe.Action = EnumAction3D.ActionNull; + } + /// + /// 管线长度全区域统计 + /// + /// + /// + private void buttonItemTJ1_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管线长度统计"); + + //pipeLineDis.Clear(); + //List list = new List(); + //for (int i = 0; i < m_PipelineLayerNames.Count; i++) + //{ + // GSOFeatures fs = Intersects_Pipeline(null, m_PipelineLayerNames[i]); + // if (fs!=null) + // list.Add(fs); + //} + + //FrmAllPipelineStatis frm = new FrmAllPipelineStatis(0, pipeLineDis, list, globeControl1, new DataGridViewDelegate(InitDataGridViewX1)); + FrmAllPipelineStatis frm = new FrmAllPipelineStatis(globeControl1,null, new DataGridViewDelegate(InitDataGridViewX1), m_PipelineLayerNames); + frm.Show(this); + + } + /// + /// 管线长度绘制区域统计 + /// + /// + /// + private void buttonItemTJ1_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管线长度统计"); + + trackflag = "PipelineDistanceStatistics"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; + } + /// + /// 阀门数量全区域统计 + /// + /// + /// + private void buttonItemTJ2_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "阀门数量统计"); + + //workWellLen.Clear(); + //List list = new List(); + ////找到所有阀门 + //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, globeControl1, new DataGridViewDelegate(InitDataGridViewX1)); + FrmValveStatistics frm = new FrmValveStatistics(globeControl1, null, new DataGridViewDelegate(InitDataGridViewX1)); + frm.Show(this); + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + } + /// + /// 阀门数量绘制区域统计 + /// + /// + /// + private void buttonItemTJ2_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "阀门数量统计"); + + trackflag = "valvequery"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; + } + /// + /// 井盖数量全区域统计 + /// + /// + /// + private void buttonItemTJ3_ALL_Click(object sender, EventArgs e) + { + //日志记录 + //LogManager.saveLog(Utility.userName, "井盖数量统计"); + + //workWellLen.Clear(); + //List list = new List(); + + //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(null, dataGridViewX1, toolStripNumbers, globeControl1, panelOfTable); + FrmAllWorkWellStatis frm = new FrmAllWorkWellStatis(globeControl1, null, new DataGridViewDelegate(InitDataGridViewX1)); + frm.Show(this); + } + /// + /// 井盖数量绘制区域统计 + /// + /// + /// + private void buttonItemTJ3_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "井盖数量统计"); + + trackflag = "workwellquery"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; + } + /// + /// 管径分段统计全区域统计 + /// + /// + /// + private void buttonItemTJ4_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管径分段统计"); + + Frmpipediameterstatis.ShowForm(globeControl1, m_PipelineLayerNames, 0); + } + /// + /// 管径分段统计绘制区域统计 + /// + /// + /// + private void buttonItemTJ4_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管径分段统计"); + + trackflag = null; + Frmpipediameterstatis.ShowForm(globeControl1, m_PipelineLayerNames, 1); + } + /// + /// 埋深分段统计全区域统计 + /// + /// + /// + private void buttonItemTJ5_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "埋深分段统计"); + FrmpipeDeepstatis.ShowForm(globeControl1, m_PipelineLayerNames, 0); + } + /// + /// 埋深分段统计绘制区域统计 + /// + /// + /// + private void buttonItemTJ5_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "埋深分段统计"); + trackflag = null; + FrmpipeDeepstatis.ShowForm(globeControl1, m_PipelineLayerNames, 1); + } + /// + /// 管径分类统计全区域统计 + /// + /// + /// + private void buttonItemTJ6_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管径分类汇总"); + + FrmpipeDiametergather.ShowForm(globeControl1, m_PipelineLayerNames, 0); + } + /// + /// 管径分类统计绘制区域统计 + /// + /// + /// + private void buttonItemTJ6_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管径分类汇总"); + + trackflag = null; + FrmpipeDiametergather.ShowForm(globeControl1, m_PipelineLayerNames, 1); + } + /// + /// 材质分类统计全区域统计 + /// + /// + /// + private void buttonItemTJ7_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "材质分类汇总"); + + FrmpipeMaterialGather.ShowForm(globeControl1, m_PipelineLayerNames, 0); + } + /// + /// 材质分类统计绘制区域统计 + /// + /// + /// + private void buttonItemTJ7_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "材质分类汇总"); + + trackflag = null; + FrmpipeMaterialGather.ShowForm(globeControl1, m_PipelineLayerNames, 1); + } + /// + /// 附属物分类统计全区域统计 + /// + /// + /// + private void buttonItemTJ8_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "附属物分类汇总"); + + FrmAccessoriesgather.ShowForm(globeControl1, instrumenLayerNames, 0); + } + /// + /// 附属物分类统计绘制区域统计 + /// + /// + /// + private void buttonItemTJ8_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "附属物分类汇总"); + + trackflag = null; + FrmAccessoriesgather.ShowForm(globeControl1, instrumenLayerNames, 1); + } + /// + /// 碰撞分析 + /// + /// + /// + private void buttonItemFX1_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_4.Text); + + this.dataGridViewX4.Size = new System.Drawing.Size(195, 120); + 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(); + } + /// + /// 覆土分析 + /// + /// + /// + private void buttonItemFX1_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX5_1.Text); + this.dataGridViewX6.Size = new System.Drawing.Size(195, 120); + 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(); + } + /// + /// 间距分析 + /// + /// + /// + private void buttonItemFX1_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX1_3.Text); + + this.dataGridViewLineList.Size = new System.Drawing.Size(185, 120); + 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(); + } + /// + /// 垂直净距分析 + /// + /// + /// + private void buttonItemFX1_4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX1_4.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(); + } + /// + /// 水平净距分析 + /// + /// + /// + private void buttonItemFX1_5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_6.Text); + this.dataGridViewX8.Size = new System.Drawing.Size(185, 120); + 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(); + } + + #region Predaotr,断面分析 + /// + /// 横断面分析 + /// + /// + /// + private void buttonItemFX2_1_Click(object sender, EventArgs e) + { + globeControl1.Globe.Action = EnumAction3D.TrackPolyline; + globeControl1.Globe.TrackPolylineTool.VerticalLineVisible = true; + globeControl1.Globe.TrackPolylineTool.TrackMode = EnumTrackMode.SpaceTrack; + trackPolylineEndMode = EnumTrackPolylineEndMode.HDM_Analysis; + + } + /// + /// 纵断面分析 + /// + /// + /// + private void buttonItemFX2_2_Click(object sender, EventArgs e) + { + if (globeControl1.Globe.SelObjectCount<1) + { + MessageBox.Show("请选择一条或者多条管线!", "提示", MessageBoxButtons.OK, + MessageBoxIcon.Information); + return; + } + 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); + } + } + List feats = SectionAnalysisTool.ZDMAnalysis(selectFeatures); + if (feats != null && feats.Count >= 1) + { + FrmProfileAnalysis frm = new FrmProfileAnalysis(globeControl1, feats); + frm.Show(this); + } + } + /// + /// 道路断面分析 + /// + /// + /// + private void buttonItemFX2_3_Click(object sender, EventArgs e) + { + globeControl1.Globe.Action = EnumAction3D.TrackPolyline; + globeControl1.Globe.TrackPolylineTool.VerticalLineVisible = true; + globeControl1.Globe.TrackPolylineTool.TrackMode = EnumTrackMode.SpaceTrack; + trackPolylineEndMode = EnumTrackPolylineEndMode.DLDM_Analysis; + + } + /// + /// 基线剖面分析 + /// + /// + /// + private void buttonItemFX2_4_Click(object sender, EventArgs e) + { + globeControl1.Globe.Action = EnumAction3D.TrackPolyline; + globeControl1.Globe.TrackPolylineTool.VerticalLineVisible = true; + globeControl1.Globe.TrackPolylineTool.TrackMode = EnumTrackMode.SpaceTrack; + trackPolylineEndMode = EnumTrackPolylineEndMode.JXPM_Analysis; + + } + + #endregion + /// + /// 创建拓扑 + /// + /// + /// + private void buttonItemFX3_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX3_1.Text); + + FrmGenAndFaMenTopu frm = new FrmGenAndFaMenTopu(globeControl1, m_PipelineLayerNames, valueLayerNames); + frm.Show(this); + } + #region Predator :拓扑分析 + /// + /// 上游分析 + /// + /// + /// + private void buttonItemFX3_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX3_2.Text); + NetworkTraceUpDown(true); + } + /// + /// 下游分析 + /// + /// + /// + private void buttonItemFX3_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX3_3.Text); + NetworkTraceUpDown(false); + } + + /// + /// 上下游追踪 功能 + /// + /// + private void NetworkTraceUpDown(Boolean bTraceUp) + { + GSOFeature selLineFeature = globeControl1.Globe.SelectedObject; + if (selLineFeature == null || selLineFeature.Geometry == null || selLineFeature.Geometry.Type != EnumGeometryType.GeoPolyline3D) + { + MessageBox.Show("请点击“编辑”—“选中对象”选择一条线!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); + return; + } + GSOLayer selLayer = globeControl1.Globe.SelectedObjectLayer; + + NetworkAnalysisTool.TraceUpDownAnalysis(bTraceUp, + selLineFeature, selLayer); + } + + /// + /// 流向分析 + /// + /// + /// + private void buttonItemFX3_4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX3_4.Text); + + FrmFlow frm = new FrmFlow(globeControl1, m_PipelineLayerNames); + frm.Show(this); + } + /// + /// 关阀分析 + /// + /// + /// + private void buttonItemFX3_5_Click(object sender, EventArgs e) + { + if (globeControl1.Globe.SelObjectCount < 1) + { + MessageBox.Show("请选中至少一根管线!!"); + buttonItemFX3_5.Checked = false; + return; + } + GSOLayer resLayer = null; + GSOFeature resFeature = null; + globeControl1.Globe.GetSelectObject(0, out resFeature, out resLayer); + + String pipeLayerName = resLayer.Caption; + String pipeLayerNamePrefix = pipeLayerName.Substring(0, pipeLayerName.IndexOf("管线")); + GSOLayer valveLayer = globeControl1.Globe.Layers[pipeLayerNamePrefix + "阀门"]; + if (valveLayer == null) + { + MessageBox.Show("无" + pipeLayerNamePrefix+"阀门图层", "提示"); + return; + } + + GSOFeatures valveFeats = NetworkAnalysisTool.CloseValvesAnalysis(resFeature, + resLayer, valveLayer); + + if (valveFeats != null) + { + FrmCloseValves frm = new FrmCloseValves(this.globeControl1, valveFeats); + frm.Show(this); + } + else + { + MessageBox.Show("未找到关闭阀门"); + } + } + + /// + /// 连通分析 + /// + /// + /// + private void buttonItemFX3_6_Click(object sender, EventArgs e) + { + if (globeControl1.Globe.SelObjectCount < 2) + { + MessageBox.Show("请选中至少两个管线!!"); + buttonItemFX3_6.Checked = false; + return; + } + GSOFeature selFeat0, selFeat1; + GSOLayer layer0,layer1; + globeControl1.Globe.GetSelectObject(0, out selFeat0, out layer0); + globeControl1.Globe.GetSelectObject(1, out selFeat1, out layer1); + + if (!layer0.IsSameInnerObject(layer1)) + { + MessageBox.Show("不在同一个图层!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); + buttonItemFX3_6.Checked = false; + return; + } + NetworkAnalysisTool.ConnexityAnalysis(selFeat0, selFeat1, layer0); + } + /// + /// 爆管分析 + /// + /// + /// + private void buttonItemFX3_7_Click(object sender, EventArgs e) + { + NetworkTraceUpDown(true); //上游追踪: + + GSOFeature selLineFeature = globeControl1.Globe.SelectedObject; + if (selLineFeature == null || selLineFeature.Geometry == null || selLineFeature.Geometry.Type != EnumGeometryType.GeoPolyline3D) + { + MessageBox.Show("请点击“编辑”—“选中对象”选择一条线!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); + return; + } + GSOLayer selLayer = globeControl1.Globe.SelectedObjectLayer; + + NetworkAnalysisTool.ExplodeAnalysis(this.globeControl1,selLineFeature,selLayer); + + this.buttonItemFX3_5_Click(sender, e); //关阀分析: + + } + + #endregion + /// + /// 多边形开挖 + /// + /// + /// + private void buttonItemFX4_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_1.Text); + + trackflag = "pit"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; //是这个么?是的,在模型上 + } + /// + /// 挖方量分析 + /// + /// + /// + private void buttonItemFX4_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_2.Text); + + trackflag = "digFillAnalysis"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; + ActionToolMenuChecked(); + } + /// + /// 沿线开挖 + /// + /// + /// + private void buttonItemFX4_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_3.Text); + + if (!buttonItemFX4_3.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; + buttonItemFX4_3.Checked = true; + } + } + else + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + buttonItemFX4_3.Checked = false; + globeControl1.Globe.TrackPolylineTool.VerticalLineVisible = false; + } + ActionToolMenuChecked(); + } + /// + /// 创建隧道 + /// + /// + /// + private void buttonItemFX4_4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_4.Text); + + 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("场景中未加载隧道图层!", "提示"); + } + } + /// + /// 隐藏隧道 + /// + /// + /// + private void buttonItemFX4_5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_5.Text); + + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption("隧道"); + if (layer != null) + { + layer.Visible = !layer.Visible; + } + } + /// + /// 删除隧道 + /// + /// + /// + private void buttonItemFX4_6_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_6.Text); + + 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("请选中要删除的隧道!", "提示"); + } + } + /// + /// 通视分析 + /// + /// + /// + private void buttonItemFX5_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX5_1.Text); + + if (globeControl1.Globe.Action != EnumAction3D.VisibilityAnalysis) + { + //btnSpaceVisibilityAnalysis.Checked = true; + globeControl1.Globe.Action = EnumAction3D.VisibilityAnalysis; + } + else + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + // SetButtonChecked(); + } + } + /// + /// 可视域分析 + /// + /// + /// + private void buttonItemFX5_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX5_2.Text); + + globeControl1.Globe.Action = EnumAction3D.ViewshedAnalysis; + } + /// + /// 可视包络分析 + /// + /// + /// + private void buttonItemFX5_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX5_3.Text); + + globeControl1.Globe.Action = EnumAction3D.ViewEnvelopeAnalysis; + } + /// + /// 缓冲区分析 + /// + /// + /// + private void buttonItemFX6_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX6_1.Text); + + GSOFeature feat = globeControl1.Globe.SelectedObject; + if (feat == null) + { + MessageBox.Show("请选择要分析的要素!"); + return; + } + if (feat.Geometry.Type == EnumGeometryType.GeoPolyline3D) + { + GSOGeoPolyline3D line1 = feat.Geometry as GSOGeoPolyline3D; + if (line1 == null) + { + MessageBox.Show("请选择一条管线!"); + return; + } + + FrmBufferAnalysis frm = new FrmBufferAnalysis(globeControl1, line1, layerTemp); + frm.Show(this); + } + else + { + FrmBufferAnalysisBSQ frm = new FrmBufferAnalysisBSQ(globeControl1, layerTemp, bsqPT); + frm.Show(this); + } + + } + /// + /// 附属物分析 + /// + /// + /// + private void buttonItemFX6_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX6_2.Text); + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + FrmAccessoryAnalysis dlg = new FrmAccessoryAnalysis(globeControl1, layerTemp); + dlg.Show(this); + } + /// + /// 无源淹没分析 + /// + /// + /// + private void buttonItemFX6_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX6_3.Text); + + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + trackflag = "FloodAnalysis"; + } + /// + /// 水平距离 + /// + /// + /// + private void buttonItemLS1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS1.Text); + + globeControl1.Globe.Action = EnumAction3D.MeasureDistance; + globeControl1.Globe.DistanceRuler.SpaceMeasure = false; + buttonItemLS5.Checked = false; + } + /// + /// 垂直距离 + /// + /// + /// + private void buttonItemLS2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS2.Text); + + buttonItemLS5.Checked = false; + globeControl1.Globe.Action = EnumAction3D.MeasureHeight; + globeControl1.Globe.DistanceRuler.SpaceMeasure = false; + } + /// + /// 空间距离 + /// + /// + /// + private void buttonItemLS3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS3.Text); + + buttonItemLS5.Checked = false; + globeControl1.Globe.Action = EnumAction3D.MeasureDistance; + globeControl1.Globe.DistanceRuler.SpaceMeasure = true; + } + /// + /// 地表距离 + /// + /// + /// + private void buttonItemLS4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS4.Text); + + buttonItemLS5.Checked = false; + globeControl1.Globe.Action = EnumAction3D.MeasureDistance; + globeControl1.Globe.DistanceRuler.SpaceMeasure = false; + } + /// + /// 高度量算 + /// + /// + /// + private void buttonItemLS5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS5.Text); + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + buttonItemLS5.Checked = !buttonItemLS5.Checked; + if (buttonItemLS5.Checked) + { + globeControl1.Globe.Action = EnumAction3D.SelectObject; + } + } + /// + /// 水平面积 + /// + /// + /// + private void buttonItemLS6_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS6.Text); + + buttonItemLS5.Checked = false; + globeControl1.Globe.Action = EnumAction3D.MeasureArea; + globeControl1.Globe.AreaRuler.SpaceMeasure = true; + } + /// + /// 地表面积 + /// + /// + /// + private void buttonItemLS7_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS7.Text); + + buttonItemLS5.Checked = false; + globeControl1.Globe.Action = EnumAction3D.MeasureArea; + globeControl1.Globe.AreaRuler.SpaceMeasure = false; + + } + + # region Fan 重构标注代码 + /// + /// 标高标注 + /// + /// + /// + private void buttonItemSZ1_Click(object sender, EventArgs e) + { + GSOFeature resFeature = IsPipeLineOfSelectedObj(); + if (resFeature == null) + { + MessageBox.Show("请选中一根管线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + GSOGeoPolyline3D selLine = resFeature.Geometry as GSOGeoPolyline3D; + if (selLine[0].Count <= 1) + { + return; + } + + MarkTools.getInstance().showMarker(resFeature, + globeControl1, EnumMarkLayer.Mark_Altitude, ""); + } + /// + /// 管径标注 + /// + GSOFeature radiusMarkerFeature; + private void buttonItemBZ2_Click(object sender, EventArgs e) + { + GSOFeature resFeature = IsPipeLineOfSelectedObj(); + if (resFeature == null) + { + MessageBox.Show("请选中一根管线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + GSOGeoPolyline3D selLine = resFeature.Geometry as GSOGeoPolyline3D; + if (selLine[0].Count <= 1) + { + return; + } + + MarkTools.getInstance().showMarker(resFeature, + globeControl1, EnumMarkLayer.Mark_Diameter, ""); + } + /// + /// 埋深标注 + /// + /// + /// + private void buttonItemBZ3_Click(object sender, EventArgs e) + { + GSOFeature resFeature = IsPipeLineOfSelectedObj(); + if (resFeature == null) + { + MessageBox.Show("请选中一根管线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + GSOGeoPolyline3D selLine = resFeature.Geometry as GSOGeoPolyline3D; + if (selLine[0].Count <=1) + { + return; + } + + MarkTools.getInstance().showMarker(resFeature, + globeControl1, EnumMarkLayer.Mark_Depth, ""); + + } + /// + /// 坐标标注 + /// + /// + /// + private void buttonItemBZ4_Click(object sender, EventArgs e) + { + GSOFeature resFeature = IsPipeLineOfSelectedObj(); + if (resFeature == null) + { + MessageBox.Show("请选中一根管线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + GSOGeoPolyline3D selLine = resFeature.Geometry as GSOGeoPolyline3D; + if (selLine[0].Count <= 1) + { + return; + } + MarkTools.getInstance().showMarker(resFeature, + globeControl1, EnumMarkLayer.Mark_Location, ""); + } + /// + /// 距离标注 + /// + bool distanceMarker = false; + private void buttonItemBZ5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBZ5.Text); + + globeControl1.Globe.Action = EnumAction3D.TrackPolyline; + //globeControl1.Globe.DistanceRuler.MeasureMode = EnumDistanceMeasureMode.HVSLineMeasure; + distanceMarker = true; + } + /// + /// 自定义标注 + /// + /// + /// + private void buttonItemBZ6_Click(object sender, EventArgs e) + { + GSOFeature f = globeControl1.Globe.SelectedObject; + GSOLayer l = globeControl1.Globe.SelectedObjectLayer; + FrmCustomLabel frm = new FrmCustomLabel(globeControl1, l, f); + if (frm.ShowDialog() == DialogResult.OK) + { + MarkTools.getInstance().showMarker(f, globeControl1, EnumMarkLayer.Mark_Custom, frm.labelText); + } + } + /// + /// 扯旗标注 + /// + /// + /// + private void buttonItemBZ7_Click(object sender, EventArgs e) + { + GSOFeature f = globeControl1.Globe.SelectedObject; + GSOLayer l = globeControl1.Globe.SelectedObjectLayer; + FrmMarker frm = new FrmMarker(); + if (frm.ShowDialog() == DialogResult.OK) + { + MarkTools.getInstance().showMarker(f, globeControl1, EnumMarkLayer.Mark_Custom, frm.markerContent); + } + } + /// + /// 坡度标注 + /// + /// + /// + private void buttonItemBZ8_Click(object sender, EventArgs e) + { + GSOFeature resFeature = IsPipeLineOfSelectedObj(); + if (resFeature == null) + { + MessageBox.Show("请选中一根管线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + GSOGeoPolyline3D selLine = resFeature.Geometry as GSOGeoPolyline3D; + if (selLine[0].Count <= 1) + { + return; + } + + MarkTools.getInstance().showMarker(resFeature, + globeControl1, EnumMarkLayer.Mark_Slope, ""); + } + /// + /// 属性标注 + /// + /// + /// + private void buttonItemBZ9_Click(object sender, EventArgs e) + { + GSOFeature f = globeControl1.Globe.SelectedObject; + GSOLayer l = globeControl1.Globe.SelectedObjectLayer; + FrmPropertiesMarker frm = new FrmPropertiesMarker(globeControl1, l, f); + if (frm.ShowDialog() == DialogResult.OK) + { + MarkTools.getInstance().showMarker(f, globeControl1, EnumMarkLayer.Mark_Property, frm.labelText); + } + } + /// + /// 红线工具 + /// + /// + /// + private void buttonItemBZ10_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBZ10.Text); + 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; + } + } + /// + /// 标注管理 + /// + /// + /// + private void buttonItemBZ11_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBZ11.Text); + + buttonItemBZ11.Checked = !buttonItemBZ11.Checked; + 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 (buttonItemBZ11.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(); + } + } + + #endregion + /// + /// 飞行到目标点 + /// + /// + /// + private void buttonItemFXGJ1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFXGJ1.Text); + + FrmSetFlytoPos.ShowForm(globeControl1); + + } + /// + /// 自定义飞行 + /// + /// + /// + private void buttonItemFXGJ2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFXGJ2.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); + } + } + /// + /// 绕中心点飞行 + /// + /// + /// + private void buttonItemFXGJ3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFXGJ3.Text); + + globeControl1.Globe.FlyAroundCenter(10000, EnumFlyRepeatValueType.MiliSeconds); + globeControl1.Globe.CurFlyID = 1; + } + /// + /// 绕眼睛飞行 + /// + /// + /// + private void buttonItemFXGJ4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFXGJ4.Text); + + globeControl1.Globe.FlyAroundEye(720, EnumFlyRepeatValueType.Degrees); + globeControl1.Globe.CurFlyID = 2; + } + + /// + /// 权限管理 + /// + /// + /// + private void buttonItemXT1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT1.Text); + + FrmUserRoleMgr frm = new FrmUserRoleMgr(); + frm.ShowDialog(); + } + /// + /// 数据库管理 + /// + /// + /// + private void buttonItemXT2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT2.Text); + + //查看数据库列表 + FrmDbManager frm = new FrmDbManager(); + frm.ShowDialog(); + } + /// + /// 用户列表 + /// + /// + /// + private void buttonItemXT3_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT3_1.Text); + + FrmUserManager frm = new FrmUserManager(); + frm.ShowDialog(); + } + /// + /// 创建新用户 + /// + /// + /// + private void buttonItemXT3_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT3_2.Text); + + FrmUserAdd frm = new FrmUserAdd(-1); + frm.ShowDialog(); + } + /// + /// 人员修改 + /// + /// + /// + private void buttonItemXT4_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT4_2.Text); + + FrmAppUSER appUSER = new FrmAppUSER(); + appUSER.ShowDialog(); + } + /// + /// 增加人员 + /// + /// + /// + private void buttonItemXT4_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT4_1.Text); + + FrmAppUSERRESET appUSERRESET = new FrmAppUSERRESET(); + appUSERRESET.ShowDialog(); + } + /// + /// 统计数据 + /// + /// + /// + private void buttonItemZTT1_Click(object sender, EventArgs e) + { + ////日志记录 + //LogManager.saveLog(Utility.userName, this.buttonItemZTT1.Text); + + //PATM patm = new PATM(); + //patm.operation = "Statistic"; + //patm.Text = "统计专题图管理"; + //patm.ShowDialog(); + } + /// + /// 热点功能统计 + /// + /// + /// + private void buttonItemZTT2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT2.Text); + + FrmHotFuncStat frmhfs = new FrmHotFuncStat(); + frmhfs.ShowDialog(); + } + + private void buttonItemZTT3_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT3_1.Text); + + FrmAPP appfrm = new FrmAPP("专题图申请"); + appfrm.ShowDialog(); + } + + private void buttonItemZTT3_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT3_2.Text); + + FrmAPPFORASK appForask = new FrmAPPFORASK("专题图审核"); + appForask.ShowDialog(); + } + + private void buttonItemZTT3_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT3_3.Text); + + FrmAPPregion appregion = new FrmAPPregion("专题图审核"); + appregion.ShowDialog(); + } + + private void buttonItemZTT4_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT4_1.Text); + + FrmAPP appfrm = new FrmAPP("打印申请"); + appfrm.ShowDialog(); + } + + private void buttonItemZTT4_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT4_2.Text); + + FrmAPPFORASK appForask = new FrmAPPFORASK("打印审核"); + appForask.ShowDialog(); + } + + private void buttonItemZTT4_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT4_3.Text); + + FrmAPPregion appregion = new FrmAPPregion("打印审核"); + appregion.ShowDialog(); + } + + private void buttonItemZTT5_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT5_1.Text); + + FrmAPP appfrm = new FrmAPP("拷贝申请"); + appfrm.ShowDialog(); + } + + private void buttonItemZTT5_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT5_2.Text); + + FrmAPPFORASK appForask = new FrmAPPFORASK("拷贝审核"); + appForask.ShowDialog(); + } + + private void buttonItemZTT5_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT5_3.Text); + + FrmAPPregion appregion = new FrmAPPregion("拷贝审核"); + appregion.Show(); + } + + private int connectServerCount = 0; + + /// + /// 还原球到实测库 + /// + 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); + } + + if (layerManagerNode.Nodes.Count > 0) + { + for (int i = layerManagerNode.Nodes.Count - 1; i >= 0; i--) + { + layerManagerNode.Nodes[i].Remove(); + + } + } + + globeControl1.Refresh(); + + } + + private void buttonItemSPSZ_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSPSZ.Text); + + FrmLayerControl frm = new FrmLayerControl(layerTree, globeControl1, globeControl2); + frm.Show(this); + } + + /// + /// 碰撞审查 + /// + /// + /// + private void buttonItemSH1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSH1.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 buttonItemSH2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSH2.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 buttonItemSH3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSH3.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 buttonItemSH4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSH4.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 buttonItemSH5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSH5.Text); + FrmCityServerLineAnalysis frm = new FrmCityServerLineAnalysis(globeControl1, m_PipelineLayerNames); + frm.Show(this); + } + #region 数据管理-导入文件 + ///// + ///// 数据管理-导入本地坐标系文件 + ///// + ///// + ///// + //private void buttonItemSJGL1_1_Click(object sender, EventArgs e) + //{ + // //日志记录 + // LogManager.saveLog(Utility.userName, this.buttonItemSJGL1_1.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(); + // } + // } + //} + + ///// + ///// 数据管理-导入其他坐标系文件 + ///// + ///// + ///// + //private void buttonItemSJGL1_2_Click(object sender, EventArgs e) + //{ + // //日志记录 + // LogManager.saveLog(Utility.userName, this.buttonItemSJGL1_2.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(); + // } + // } + //} + #endregion + /// + /// 数据质量检查 + /// + /// + /// + private void buttonItemSJGL2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL2.Text); + FrmValiData frm = new FrmValiData(globeControl1); + frm.ShowDialog(); + } + /// + /// 数据预处理 + /// + /// + /// + private void buttonItemSJGL3_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL3.Text); + + FrmEditShapeFile frm = new FrmEditShapeFile(globeControl1); + frm.ShowDialog(this); + } + /// + /// 连接数据库 + /// + /// + /// + private void buttonItemSJGL4_1_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL4_1.Text); + + FrmDatabaseParaSetting frm = new FrmDatabaseParaSetting(globeControl1); + if (frm.ShowDialog() == DialogResult.OK) + { + ds = FrmDatabaseParaSetting.ds; + if (ds != null) + { + ds.IsCloseSaved = false; + } + } + } + /// + /// 管线入库 + /// + /// + /// + private void buttonItemSJGL4_2_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL4_2.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 buttonItemSJGL4_3_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL4_3.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 buttonItemSJGL5_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL5.Text); + + Cyberpipe.Forms.FrmProject frm = new Cyberpipe.Forms.FrmProject(); + frm.ShowDialog(); + } + /// + /// 元数据基本管理 + /// + /// + /// + private void buttonItemSJGL6_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL6_1.Text); + + FrmMetadata frmmd = new FrmMetadata(); + frmmd.ShowDialog(); + } + /// + /// 元数据查询管理 + /// + /// + /// + private void buttonItemSJGL6_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL6_2.Text); + + FrmMetadataStat frmmds = new FrmMetadataStat(); + //frmmds.Show(); + frmmds.ShowDialog(); + } + /// + /// 操作日志管理 + /// + /// + /// + private void buttonItemSJGL7_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL7.Text); + + FrmLogOper frmlo = new FrmLogOper(); + frmlo.ShowDialog(); + } + /// + /// 数据字典管理 + /// + /// + /// + private void buttonItemSJGL8_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL8.Text); + + FrmMDDictory frmmdd = new FrmMDDictory(); + frmmdd.ShowDialog(); + } + /// + /// 数据库备份 + /// + /// + /// + private void buttonItemSJGL9_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL9.Text); + + //新 + FrmBACKORACLE backOracle = new FrmBACKORACLE(); + backOracle.Show(); + } + /// + /// 创建管段 + /// + /// + /// + private void buttonItemBJ1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ1.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; + } + } + /// + /// 创建附属物 + /// + /// + /// + private void buttonItemBJ2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ2.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); + } + } + /// + /// 创建特征管点 + /// + /// + /// + private void buttonItemBJ3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ3.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); + } + } + /// + /// 绘制城市七线 + /// + /// + /// + private void buttonItemBJ4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ4.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; + } + } + } + /// + /// 选中对象 + /// + /// + /// + private void buttonItemBJ5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ5.Text); + + globeControl1.Globe.Action = EnumAction3D.SelectObject; + } + /// + /// 平移对象 + /// + /// + /// + private void buttonItemBJ6_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ6.Text); + + globeControl1.Globe.Action = EnumAction3D.MoveObject; + } + /// + /// 升降对象 + /// + /// + /// + private void buttonItemBJ7_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ7.Text); + + globeControl1.Globe.Action = EnumAction3D.ElevateObject; + } + /// + /// 旋转对象 + /// + /// + /// + private void buttonItemBJ8_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ8.Text); + + globeControl1.Globe.Action = EnumAction3D.RotateObject; + } + /// + /// 连接管段 + /// + /// + /// + private void buttonItemBJ9_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ9.Text); + + if (globeControl1.Globe.SelObjectCount < 2) + { + MessageBox.Show("对不起,请至少选中2个对象!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + return; + } + globeControl1.Globe.InsertJointPipeline(false); + } + /// + /// 后退 + /// + /// + /// + private void buttonItemBJ11_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemBJ11.Text); + globeControl1.Globe.UnDoEdit(); + } + /// + /// 前进 + /// + /// + /// + private void buttonItemBJ12_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemBJ12.Text); + + globeControl1.Globe.ReDoEdit(); + } + /// + /// 导出CAD + /// + /// + /// + private void buttonItemBJ10_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ10_1.Text); + + #region 导出成dxf格式 + List listVectorNames = new List(); + 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(); + #endregion + } + /// + /// 导出矢量 + /// + /// + /// + private void buttonItemBJ10_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ10_2.Text); + + List listVectorNames = new List(); + 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 buttonItemBJ13_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemBJ13.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(); + } + } + MessageBox.Show("删除成功!", "提示"); + } + else + { + MessageBox.Show("请选中要删除的模型!", "提示"); + } + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + } + + private void buttonItemHX1_1_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]; + string filePath = dlg.FileName; + string lastname = Path.GetFileName(filePath); + + 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(); + } + + } + } + } + + public struct LineStruct + { + public string layerName; + public string layerCode; + public string lineLength; + public string hxName; + } + + List lineStruct = new List(); + List featsList = new List(); + + /// + /// 红线审核 + /// + /// + /// + private void buttonItemHX2_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemHX2.Text); + redSH = true; + featsList.Clear(); + lineStruct.Clear(); + List listPipelineLayers = new List(); + + GSOLayer layer = null; + for (int i = 0; i < m_PipelineLayerNames.Count; i++) + { + layer = globeControl1.Globe.Layers.GetLayerByCaption(m_PipelineLayerNames[i]); + if (layer != null) + { + listPipelineLayers.Add(layer); + } + } + //yanxiaowei 重构 + GSOFeatures selectFeatures=new GSOFeatures(); + for (int i = 0; i < globeControl1.Globe.SelObjectCount; i++) + { + GSOFeature feature = null; + globeControl1.Globe.GetSelectObject(i, out feature, out layer); + selectFeatures.Add(feature); + } + DataTable table=new DataTable(); + + ClassGSOTool.CalculateRedLineResult(out table, redSH, selectFeatures, globeControl1, + listPipelineLayers,out lineStruct, out featsList); + + if (table.Rows.Count != 0) + AddDatagridView(table); + else + { + MessageBox.Show("没有侵入地块红线的管线数据!", "提示"); + dataGridViewX1.DataSource = null; + panelOfTable.Visible = false; + return; + } + } + + private void AddDatagridView(DataTable table) + { + dataGridViewX1.DataSource = table; + panelOfTable.Visible = true; + panelOfTable.Height = 200; + toolStripNumbers.Text = "红线审核 |共有:" + table.Rows.Count + "条"; + toolStripDropDownButton3.Visible = true; + } + /// + /// 主窗体 下方的工具条中的 导出.xls文件 按钮事件处理 + /// + /// + /// + private void toolStripDropDownButton3_Click(object sender, EventArgs e) + { + if (dataGridViewX1.Rows.Count == 0) + { + MessageBox.Show("表格内容为空!", "提示"); + return; + } + + string strSaveFile = string.Empty; + SaveFileDialog savefiledialog = new SaveFileDialog(); + savefiledialog.Filter = "Excel文件|*.xls,*.xlsx"; + savefiledialog.AddExtension = true; + savefiledialog.FileName = "红线审核"; + if (savefiledialog.ShowDialog() == DialogResult.OK) + strSaveFile = savefiledialog.FileName; + else return; + + ExpEXCEL.ExpToExcel(dataGridViewX1, strSaveFile, "红线审核", lineStruct, featsList); + MessageBox.Show("导出成功!"); + } + /// + /// 去除集合中重复的管线 + /// + /// + /// + /// + private GSOFeatures getFeaturesByFilter(GSOFeatures features, string fieldName) + { + if (features == null) + { + return null; + } + GSOFeatures featuresGet = new GSOFeatures(); + for (int i = 0; i < features.Length; i++) + { + GSOFeature featureFromFS = features[i]; + string fieldValueFromFS = featureFromFS.GetValue(fieldName).ToString().Trim(); + bool isHas = false; + for (int j = featuresGet.Length - 1; j >= 0; j--) + { + GSOFeature featureFromFSGet = featuresGet[j]; + string fieldValueFromFSGet = featureFromFSGet.GetValue(fieldName).ToString().Trim(); + if (fieldValueFromFS.Equals(fieldValueFromFSGet)) + { + isHas = true; + break; + } + } + if (isHas == false) + { + featuresGet.Add(featureFromFS.Clone()); + } + } + return featuresGet; + } + + private void sliderItem2_ValueChanged(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.sliderItem2.Text); + + globeControl1.Globe.GroundOpaque = 100 - sliderItem2.Value; + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(roadLayerName);//("180fd"); + if (layer != null) + { + layer.Opaque = 100 - sliderItem2.Value; + } + layer = globeControl2.Globe.Layers.GetLayerByCaption("180fd");//("180fd"); + if (layer != null) + { + layer.Opaque = 100 - sliderItem2.Value; + } + globeControl2.Globe.GroundOpaque = 100 - sliderItem2.Value; + + optiValue = sliderItem2.Value; + } + /// + /// 数据管理导入文件 + /// + /// + /// + private void buttonItemSJGL1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL1.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.Multiselect = true; + if (dlg.ShowDialog() == DialogResult.OK) + { + //自定义lprj文件名,从程序中复制一lprj文件。 + string filePath = dlg.FileName; + string lastname = Path.GetFileName(filePath); + + 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, 100); + + globeControl1.Refresh(); + } + } + } + + private void buttonItemHX1_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemHX1.Text); + + GSODataSource dataSpace = globeControl1.Globe.DataManager.OpenOracleDataSource(Utility.DBServer.Trim() + "/" + Utility.dbdatabase.Trim(), "", "", Utility.userID, Utility.DBPassword); + string filepath = ""; + //日志记录 + OpenFileDialog dlg = new OpenFileDialog(); + dlg.Filter = "矢量数据(*.shp)|*.shp|矢量数据(*.lgd)|*.lgd|CAD数据(*.dxf)|*.dxf|全部支持格式(*.lgd,*.shp,*.dxf)|*.lgd;*.shp;*.dxf;"; + dlg.Multiselect = true; + + #region 临时图层显示 + if (dlg.ShowDialog() == DialogResult.OK) + { + string filePath = dlg.FileName; + string lastname = Path.GetFileName(filePath); + + #region + for (int i = 0; i < dlg.FileNames.Length; i++) + { + string strDataPath = dlg.FileNames[i]; + filepath = strDataPath; + + GSOLayer layer = globeControl1.Globe.Layers.Add(strDataPath); + GSOFeatures RedFeatures = layer.GetAllFeatures(); + + 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(); + RedFeatures = features; + 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; + } + + /////////////////////////////////////////////////////////////////////////////////////////// + globeControl1.Globe.Layers.MoveTo(0, globeControl1.Globe.Layers.Count - 1); + globeControl1.Refresh(); + } + + IModelBuilder modelBuilder = new RedLineBuilder(); + + modelBuilder.batchInsert(dataSpace, redDt, RedFeatures); + + } + #endregion + + } + #endregion + } + /// + /// 定位 + /// + /// + /// + private void buttonItemLocation_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemLocation.Text); + + FrmFlyToPosition fly = new FrmFlyToPosition(globeControl1,globeControl2); + fly.Show(this); + } + /// + /// 2015-10-17演示代码 红线审核 + /// + /// + /// + private void ribbonTabItem6_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.FlyToPosition(new GSOPoint3d(120.610963, 31.188121, 50), EnumAltitudeMode.Absolute, -4, 50, 800); + globeControl1.Globe.FlyToPointSpeed = 10000000; + globeControl1.Globe.Action = EnumAction3D.SelectObject; + globeControl1.Refresh(); + + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + + //zhanshi = false; + redSH = true; + splitContainer1.Panel2Collapsed = true; + legendSG.Visible = false; + legendSC.Visible = false; + ClearGZData(); + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = true; + } + + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 基础工具 + /// + /// + /// + private void ribbonTabItem1_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + //zhanshi = false; + redSH = false; + splitContainer1.Panel2Collapsed = true; + panelOfTable.Visible = false; + legendSC.Visible = false; + legendSG.Visible = false; + ClearGZData(); + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + + + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 一键审核 + /// + /// + /// + private void ribbonTabItem11_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + //zhanshi = false; + redSH = false; + splitContainer1.Panel2Collapsed = true; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + panelOfTable.Visible = false; + legendSC.Visible = false; + legendSG.Visible = false; + ClearGZData(); + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + + + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 右屏添加冰箱数据 + /// + void AddDataToGlobeControl2() + { + + bool modelDataBool = false; + for (int i = globeControl2.Globe.Layers.Count - 1; i >= 0; i--) + { + GSOLayer layer = globeControl2.Globe.Layers[i]; + if (layer.Name.Contains("fttp:")) + { + modelDataBool = true; + break; + } + } + + if (modelDataBool == false) + { + GSOLayer ly = globeControl1.Globe.Layers.GetLayerByCaption("天地图地图"); + globeControl2.Globe.Layers.Add(ly); + } + else + { + return; + } + } + /// + /// 双屏对比 + /// + /// + /// + private void ribbonTabItem9_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent += new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent += new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + panelOfTable.Visible = false; + + splitContainer1.Panel2Collapsed = false; + //zhanshi = true; + redSH = false; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + sliderItem2.Value = 100 - globeControl1.Globe.GroundOpaque; + globeControl2.Globe.GroundOpaque = globeControl1.Globe.GroundOpaque; + legendSC.Visible = true; + legendSG.Visible = true; + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + AddDataToGlobeControl2(); + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 文档管理 + /// + /// + /// + private void ribbonTabItem4_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + panelOfTable.Visible = false; + //zhanshi = false; + redSH = false; + splitContainer1.Panel2Collapsed = true; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + legendSC.Visible = false; + legendSG.Visible = false; + ClearGZData(); + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 基础管理 + /// + /// + /// + private void ribbonTabItem14_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + panelOfTable.Visible = false; + //zhanshi = false; + redSH = false; + splitContainer1.Panel2Collapsed = true; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + legendSC.Visible = false; + legendSG.Visible = false; + ClearGZData(); + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 权限管理 + /// + /// + /// + private void ribbonTabItem2_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + panelOfTable.Visible = false; + //zhanshi = false; + redSH = false; + splitContainer1.Panel2Collapsed = true; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + legendSC.Visible = false; + legendSG.Visible = false; + ClearGZData(); + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + GSOFeature dpFeatuer = null; + /// + /// 双屏分析,点击管段分析 + /// + /// + /// + private void buttonItem8_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItem8.Text); + + //FrmCompareFeature frmCompareFeature = new FrmCompareFeature(globeControl1, globeControl2, layerTemp, layerTemp2,m_PipelineLayerNames,sgPipeLayersNames); + int width = this.Width; + FrmCompareFeature.ShowForm(globeControl1, globeControl2, layerTemp, layerTemp2, m_PipelineLayerNames, sgPipeLayersNames,width); + //frmCompareFeature.Location = new Point((this.Width - frmCompareFeature.Width)/2,50); + //frmCompareFeature.Show(this); + + } + /// + /// 红线审核导出图片 + /// + /// + /// + private void buttonItemDCTP_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemDCTP.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))); + */ + int mapWidth = 0; + int mapHeight = 0; + Point pt = getUpperLeftPoint(pt1, pt2, out mapWidth, out mapHeight); + int rightBottomX = pt.X + mapWidth; + int rightBottomY = pt.Y + mapHeight; + Image myImg = new Bitmap(mapWidth, mapHeight); + Graphics g = Graphics.FromImage(myImg); + g.CopyFromScreen(pt, new Point(0, 0), new Size(rightBottomX, rightBottomY)); + + 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; + } + } + } + /// + /// 标识器全区域统计 + /// + /// + /// + private void 标识器分类统计ToolStripMenuItem_Click(object sender, EventArgs e) + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + FrmBSQStatis bsqStatis = new FrmBSQStatis(); + bsqStatis.Show(this); + } + /// + /// 标识器绘制区域统计 + /// + /// + /// + private void 标识器分类统计ToolStripMenuItem1_Click(object sender, EventArgs e) + { + trackflag = "BSQDuoBianXiangStatis"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + } + + #region 保存和加载审核库加载的图层 + /* + private void saveLayerList(TreeNodeCollection treeNodeList) + { + string configPath = Application.StartupPath + "\\configLayerList.xml"; + try + { + XmlDocument doc = new XmlDocument(); + doc.Load(configPath); + XmlNode dbParams = doc.SelectSingleNode("Params/dbparams"); + XmlNode dbLayers = doc.SelectSingleNode("Params/dblayers"); + XmlNode layers = doc.SelectSingleNode("Params/layers"); + dbParams.RemoveAll(); + dbLayers.RemoveAll(); + layers.RemoveAll(); + + List listDS = new List(); + String shDatasourceName = Utility.sgdbip + "/" + Utility.sgdbname + "_" + Utility.sgdbuser; + bool flag = false; + + for (int i = 0; i < globeControl1.Globe.DataManager.DataSourceCount; i++) + { + GSODataSource ds = globeControl1.Globe.DataManager.GetDataSourceAt(i); + if (ds != null && ds.Type == EnumDataSourceType.SqlServer || ds.Type == EnumDataSourceType.Oracle) + { + if (ds.Name == shDatasourceName) + { + //防止因为多次连接同一个数据库 + if (flag == true) + { + break; + } + flag = true; + listDS.Add(ds); + GSODataSourceCnn conn = ds.GetConnectionInfo(); + + XmlElement dbparam = doc.CreateElement("shdbparam"); + XmlElement ip = doc.CreateElement("ship"); + ip.InnerText = conn.Server; + + XmlElement dbname = doc.CreateElement("shdbname"); + dbname.InnerText = conn.Database; + + XmlElement username = doc.CreateElement("shusername"); + username.InnerText = conn.User; + + XmlElement password = doc.CreateElement("shpassword"); + password.InnerText = conn.Password; + + XmlElement type = doc.CreateElement("shtype"); + if (ds.Type == EnumDataSourceType.SqlServer) + { + type.InnerText = "sqlserver"; + } + else + { + type.InnerText = "oracle"; + } + + dbparam.AppendChild(ip); + dbparam.AppendChild(dbname); + dbparam.AppendChild(username); + dbparam.AppendChild(password); + dbparam.AppendChild(type); + dbParams.AppendChild(dbparam); + } + + } + } + + for (int i = 0; i < treeNodeList.Count; i++) + { + GSOLayer layer = treeNodeList[i].Tag as GSOLayer; + if (Path.GetExtension(layer.Name) == "") + { + XmlElement dbLayer = doc.CreateElement("dblayer"); + XmlAttribute attri = doc.CreateAttribute("dbindex"); + for (int j = 0; j < listDS.Count; j++) + { + if (layer.Dataset.DataSource.Name == listDS[j].Name) + { + attri.Value = j.ToString(); + break; + } + } + dbLayer.Attributes.Append(attri); + dbLayer.InnerText = layer.Name; + + dbLayers.AppendChild(dbLayer); + } + else + { + XmlElement dbLayer = doc.CreateElement("layer"); + dbLayer.InnerText = layer.Name; + layers.AppendChild(dbLayer); + } + } + + doc.Save(configPath); + } + catch (Exception e) + { + + } + } + + private void openLayerList() + { + layerManagerNode.Nodes.Clear(); + + string configPath = Application.StartupPath + "\\configLayerList.xml"; + try + { + XmlDocument doc = new XmlDocument(); + doc.Load(configPath); + XmlNode dbParams = doc.SelectSingleNode("Params/dbparams"); + XmlNode dbLayers = doc.SelectSingleNode("Params/dblayers"); + XmlNode layers = doc.SelectSingleNode("Params/layers"); + + List listDS = new List(); + for (int i = 0; i < dbParams.ChildNodes.Count; i++) + { + string ip = ""; + string dbname = ""; + string username = ""; + string password = ""; + string type = ""; + XmlNode node = dbParams.ChildNodes.Item(i); + for (int j = 0; j < node.ChildNodes.Count; j++) + { + XmlNode nodeChild = node.ChildNodes.Item(j); + + if (nodeChild != null && nodeChild.Name == "ship") + { + ip = nodeChild.InnerText; + } + else if (nodeChild != null && nodeChild.Name == "shdbname") + { + dbname = nodeChild.InnerText; + } + else if (nodeChild != null && nodeChild.Name == "shusername") + { + username = nodeChild.InnerText; + } + else if (nodeChild != null && nodeChild.Name == "shpassword") + { + password = nodeChild.InnerText; + } + else if (nodeChild != null && nodeChild.Name == "shtype") + { + type = nodeChild.InnerText; + } + } + + if (type == "sqlserver") + { + GSODataSource ds = globeControl1.Globe.DataManager.OpenSqlServerDataSource(ip, "", dbname, username, password); + listDS.Add(ds); + } + else if (type == "oracle") + { + GSODataSource ds = globeControl1.Globe.DataManager.OpenOracleDataSource(ip + "/" + dbname, "", "", username, password); + listDS.Add(ds); + } + } + + for (int i = 0; i < dbLayers.ChildNodes.Count; i++) + { + XmlNode node = dbLayers.ChildNodes.Item(i); + if (node != null) + { + string layerName = node.InnerText; + XmlAttribute attri = node.Attributes["dbindex"]; + if (attri != null) + { + int dbIndex = -1; + if (int.TryParse(attri.Value, out dbIndex)) + { + GSODataset dataset = listDS[dbIndex].GetDatasetByName(layerName); + globeControl1.Globe.Layers.Add(dataset); + //更新树节点 + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + TreeNode layerNode = new TreeNode(); + layerNode.Tag = layer; + layerNode.Text = layer.Dataset.Caption; + layerNode.ImageIndex = 0; + layerNode.SelectedImageIndex = 0; + layerNode.Checked = layer.Visible; + layerManagerNode.Nodes.Insert(0, layerNode); + // layerManagerNode.Expand(); + + + } + } + } + } + for (int i = 0; i < layers.ChildNodes.Count; i++) + { + XmlNode node = layers.ChildNodes.Item(i); + if (node != null) + { + string layerName = node.InnerText; + globeControl1.Globe.Layers.Add(layerName); + + //更新树节点 + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + TreeNode layerNode = new TreeNode(); + layerNode.Tag = layer; + layerNode.Text = layer.Dataset.Caption; + layerNode.ImageIndex = 0; + layerNode.SelectedImageIndex = 0; + layerNode.Checked = layer.Visible; + layerManagerNode.Nodes.Insert(0, layerNode); + } + } + layerManagerNode.Expand(); + } + catch (Exception e) + { + + } + } + * */ + #endregion + + private void btn_check_history_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_check_history.Text); + + if (FrmCheckHistory.isOpen == true) + { + return; + } + FrmCheckHistory frm = new FrmCheckHistory(globeControl1, globeControl2); + frm.addNode += new AddNodeToLayerManagerNode(addNodeToLayerManagerNode); + frm.Show(); + + } + + private void buttonItem查看数据_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItem查看数据.Text); + + FrmThreeOracle tr = new FrmThreeOracle(globeControl1); + + if (tr.ShowDialog() == DialogResult.OK) + { + addNodeToLayerManagerNode(tr.rukuLayer); + globeControl1.Refresh(); + } + } + /// + /// 规划数据入库 + /// + /// + /// + private void buttonItemGHRK_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemGHRK.Text); + + FrmGHRK ghrk = new FrmGHRK(globeControl1, layerManagerNode); + ghrk.Show(this); + } + + private void btn_user_info_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_user_info.Text); + + if (!FrmSysUserInfoManger.IS_OPEN) + { + FrmSysUserInfoManger frm = new FrmSysUserInfoManger(); + frm.ShowDialog(); + } + } + + private void btn_role_info_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_role_info.Text); + + if (FrmRoleInfoManager.IS_OPEN) + { + return; + } + FrmRoleInfoManager frm = new FrmRoleInfoManager(); + frm.ShowDialog(); + } + + private void btn_resc_info_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_resc_info.Text); + + if (!SysRescInfoManager.IS_OPEN) + { + SysRescInfoManager frm = new SysRescInfoManager(); + frm.ShowDialog(); + } + } + + private void btn_role_resc_Click(object sender, EventArgs e) + { + + LogManager.saveLog(Utility.userName, this.btn_role_resc.Text); + + if (!FrmRoleRescManager.IS_OPEN) + { + FrmRoleRescManager frm = new FrmRoleRescManager(); + frm.ShowDialog(); + } + } + + private void btn_user_role_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_user_role.Text); + + if (FrmUserRole.IS_OPEN) + { + return; + } + FrmUserRole frm = new FrmUserRole(); + frm.ShowDialog(); + } + + private void btn_document_info_Click(object sender, EventArgs e) + { + + LogManager.saveLog(Utility.userName, this.btn_document_info.Text); + + //if (FormDocumentManager.IS_OPEN) + //{ + // return; + //} + //FormDocumentManager frm = new FormDocumentManager(); + //frm.ShowDialog(); + + //if (FormDocumentManager.IS_OPEN) + //{ + // return; + //} + //new FormDocumentManager().ShowDialog(); + if (FormDocumentManager.IS_OPEN) + { + return; + } + this.Cursor = Cursors.WaitCursor; + FormDocumentManager frm = new FormDocumentManager(); + frm.changeCursor += new ChangeCursor(changeCursorToDefault); + frm.ShowDialog(); + + } + + private void changeCursorToDefault() + { + this.Cursor = Cursors.Default; + } + + /// + /// 判断CAD文件是否有投影信息 + /// + /// + /// + Boolean CheckDatasetGeoReference(GSODataset dataset) + { + Boolean bSuccess = false; + if (dataset.GeoReferenceType == EnumGeoReferenceType.Flat) + { + if (MessageBox.Show("数据没有空间参考信息,请设置空间参考信息!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation) == DialogResult.OK) + { + String strPath = Path.GetDirectoryName(Application.ExecutablePath) + "\\Coordinate Systems"; + OpenFileDialog dlg = new OpenFileDialog(); + + dlg.InitialDirectory = strPath; + dlg.RestoreDirectory = true; + + dlg.Filter = "投影文件|*.prj||"; + if (dlg.ShowDialog() == DialogResult.OK) + { + bSuccess = dataset.LoadProjectionFromESRIFile(dlg.FileName); + } + } + } + else + { + return true; + } + return bSuccess; + } + + private void buttonItemexp_CAD_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemexp_CAD.Text); + + OpenFileDialog dlg = new OpenFileDialog(); + dlg.Filter = "支持格式(*.dwg)|*.dwg"; + dlg.Multiselect = true; + if (dlg.ShowDialog() == DialogResult.OK) + { + for (int i = 0; i < dlg.FileNames.Length; i++) + { + //this.Cursor = Cursors.WaitCursor; + string strDataPath = dlg.FileNames[i]; + + #region + //string strDataPathPrj = strDataPath.ToLower().Replace(".dwg", ".lprj"); + + //if (File.Exists(strDataPathPrj) == false) + //{ + // if (MessageBox.Show("数据没有空间参考信息,请设置空间参考信息!", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation) == DialogResult.OK) + // { + // String strPath = Application.StartupPath + "\\Coordinate Systems"; + // OpenFileDialog dlgPrj = new OpenFileDialog(); + // dlgPrj.InitialDirectory = strPath; + // dlgPrj.RestoreDirectory = true; + // dlgPrj.Multiselect = false; + // dlg.Filter = "投影文件|*.prj"; + // if (dlg.ShowDialog() == DialogResult.OK) + // { + // this.Cursor = Cursors.WaitCursor; + // string proj4 = GSODataEngineUtility.ConvertEsriPrjFileToProj4(dlg.FileName); + // using (StreamWriter stream = new StreamWriter(strDataPathPrj, false)) + // { + // stream.WriteLine("0prj4" + proj4 + ""); + // } + // AddLayerData(strDataPath); + // //globeControl1.Globe.Layers.Add(strDataPath); + + // this.Cursor = Cursors.Default; + // } + // else + // { + // AddLayerData(strDataPath); + // //globeControl1.Globe.Layers.Add(strDataPath); + // } + // } + // else + // { + // AddLayerData(strDataPath); + // //globeControl1.Globe.Layers.Add(strDataPath); + // } + + //} + //else + //{ + // //globeControl1.Globe.Layers.Add(strDataPath); + // AddLayerData(strDataPath); + //} + #endregion + AddLayerData(strDataPath); + //this.Cursor = Cursors.Default; + } + } + + 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, 100); + + globeControl1.Refresh(); + } + } + + private void btn_password_edit_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_password_edit.Text); + + if (FrmChangePassword.IS_OPEN) + { + return; + } + FrmChangePassword frm = new FrmChangePassword(); + frm.ShowDialog(); + } + /// + /// 多孔管线入库 + /// + /// + /// + private void buttonItem9_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL4_2.Text); + + if (ds == null) + { + MessageBox.Show("请先连接数据库", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + ConnectDB(null, null); + } + if (ds == null) + return; + + FrmMultiPipelineModelDB frm = new FrmMultiPipelineModelDB(globeControl1, ds); + if (frm.ShowDialog() == DialogResult.OK) + { + addNodeToLayerManagerNode(frm.rukuLayer); + } + //frm.Show(); + } + private void 导出CADToolStripMenuItem1_Click(object sender, EventArgs e) + { + TreeNode node = layerNodeContexMenu.Tag as TreeNode; + if (node == null) + { + MessageBox.Show("请在左侧节点集中选择要导出的图层", "提示"); + return; + } + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(node.Text.Trim()); + if (layer == null || layer.GetAllFeatures().Length <= 0) + { + MessageBox.Show("要导出的图层为空", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + return; + } + string strProjectName = Utility.projectStr; + if (strProjectName != "") + { + SaveFileDialog dlg = new SaveFileDialog(); + dlg.Filter = "*.dwg|*.dwg|*.dxf|*.dxf"; + dlg.FileName = layer.Caption; + if (dlg.ShowDialog(this) == DialogResult.OK) + { + globeControl1.Globe.MemoryLayer.SaveAs(dlg.FileName); + GSOLayer newlayer = globeControl1.Globe.Layers.Add(dlg.FileName); + newlayer.RemoveAllFeature(); + int featureCount = layer.GetAllFeatures().Length; + for (int i = 0; i < featureCount; i++) + { + GSOFeature feature = layer.GetAt(i); + if (feature != null && feature.Geometry != null) + { + if (feature.Geometry.Type == EnumGeometryType.GeoPolyline3D) + { + feature.Geometry.Style = new GSOSimpleLineStyle3D(); + } + else if (feature.Geometry.Type == EnumGeometryType.GeoPolygon3D) + { + feature.Geometry.Style = new GSOSimplePolygonStyle3D(); + } + newlayer.AddFeature(feature); + } + } + newlayer.Save(); + newlayer.Dataset.DataSource.RemoveDataset(newlayer.Dataset); + globeControl1.Globe.Layers.Remove(newlayer); + MessageBox.Show("导出CAD完成!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + } + } + } + + private void buttonItemGBJC_Click(object sender, EventArgs e) + { + FrmGBJC gb = new FrmGBJC(globeControl1, globeControl2, layerTemp, layerTemp2); + gb.Show(this); + } + + #region 右屏管纵数据控制 + private void 五十米主干道ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = true; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + + private void 三十六米次干道ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = true; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + + private void 四十二米次干道ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = true; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + + private void 二十四米一块板ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = true; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + + private void 二十四米三块板ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = true; + } + + private void 二十四米停车带ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = true; + lendendGZ24_3.Visible = false; + } + + private void 二十六米大堤路ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = true; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + + private void 清除管纵数据ToolStripMenuItem_Click(object sender, EventArgs e) + { + ClearGZData(); + } + + private void ClearGZData() + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + #endregion + + private void buttonItemPasswordReset_Click(object sender, EventArgs e) + { + Frm_password_reset reset = new Frm_password_reset(); + reset.Show(); + } + + private void pictureBox1_Paint(object sender, PaintEventArgs e) + { + int Width = this.Width; + string welcomeUser = "欢迎您:" + Utility.userName; + Graphics g = e.Graphics; + g.DrawString(welcomeUser, new Font("宋体", 12), new SolidBrush(Color.Black), Width - 180, 50); + } + + } +} \ No newline at end of file diff --git a/MainFrm.cs.LOCAL.9016.cs b/MainFrm.cs.LOCAL.9016.cs new file mode 100644 index 0000000..0b7e393 --- /dev/null +++ b/MainFrm.cs.LOCAL.9016.cs @@ -0,0 +1,13060 @@ +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; + + GSOBalloon featureTooltip2; + GSOBalloonEx balloonEx2; + + GSOLayer layerTemp; + GSOLayer layerTemp2; + FrmShResult frmShResult = null; + FrmRedlineResult frmredResult = null; + FrmMnModify frmModify = null; + public bool frmRedlineResult = false; + public bool boolfrmShResult = false; + public bool boolfrmModify = false; + + List m_PipelineLayerNames = new List();//线图层名称 + List workwellLayerNames = new List();//工井图层名称 + List valueLayerNames = new List();//阀门图层名称 + List instrumenLayerNames = new List();//附属物图层名称 + List pipefittingLayerNames = new List();//管件图层名称 + List sgPipeLayersNames = new List();//施工管线图层名称 + 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 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; + public string redLayer = null; + //GSOLayer redLayer1 = null; + bool redSH = false; + string redDt = "红线"; + //双屏对比 + //bool zhanshi=false; + Thread t = null; + private GSOHudButton legendSC;//定义图例 + private GSOHudButton legendSG;//定义图例 + //管纵图 + private GSOHudButton lendendGZ50; + private GSOHudButton lendendGZ36; + private GSOHudButton lendendGZ42; + private GSOHudButton lendendGZ24_1; + private GSOHudButton lendendGZ24_2; + private GSOHudButton lendendGZ24_3; + private GSOHudButton lendendGZ26; + + GSOGeoPoint3D bsqPT; + + FrmYJSHTC frmSh = null;//一键审核窗口全局变量wxl + FrmWait frmWait = null;//一键审核等待窗口 + //FrmWait frmWait2 = null;//文档操作等待窗口 + + float mouseDownX1,mouseDownY1; + float mouseDownX2,mouseDownY2; + /// + /// + /// + 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; + + featureTooltip2 = new GSOBalloon(globeControl2.Handle); + balloonEx2 = new GSOBalloonEx(globeControl2.Handle); + Utility.SetBallons(featureTooltip, balloonEx); + + panelOfTable.Height = 200; + + RigthMenuSet(); + + MenuSet(); + + } + /// + /// 右屏中添加管纵图片 + /// + private void AddGZ() + { + + lendendGZ50 = new GSOHudButton(); + lendendGZ50.SetImage(Application.StartupPath + "/Resource/管纵/50.png"); + lendendGZ50.SetOffset(0, 0); + lendendGZ50.MinOpaque = 1; + lendendGZ50.MaxOpaque = 1; + lendendGZ50.FadeOut = false; + lendendGZ50.Name = "lendendGZ50"; + lendendGZ50.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ50); + lendendGZ50.Visible = false; + + lendendGZ36 = new GSOHudButton(); + lendendGZ36.SetImage(Application.StartupPath + "/Resource/管纵/36.png"); + lendendGZ36.SetOffset(0, 0); + lendendGZ36.MinOpaque = 1; + lendendGZ36.MaxOpaque = 1; + lendendGZ36.FadeOut = false; + lendendGZ36.Name = "lendendGZ36"; + lendendGZ36.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ36); + lendendGZ36.Visible = false; + + lendendGZ42 = new GSOHudButton(); + lendendGZ42.SetImage(Application.StartupPath + "/Resource/管纵/42.png"); + lendendGZ42.SetOffset(0, 0); + lendendGZ42.MinOpaque = 1; + lendendGZ42.MaxOpaque = 1; + lendendGZ42.FadeOut = false; + lendendGZ42.Name = "lendendGZ42"; + lendendGZ42.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ42); + lendendGZ42.Visible = false; + + lendendGZ24_1 = new GSOHudButton(); + lendendGZ24_1.SetImage(Application.StartupPath + "/Resource/管纵/24_1.png"); + lendendGZ24_1.SetOffset(0, 0); + lendendGZ24_1.MinOpaque = 1; + lendendGZ24_1.MaxOpaque = 1; + lendendGZ24_1.FadeOut = false; + lendendGZ24_1.Name = "lendendGZ24_1"; + lendendGZ24_1.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ24_1); + lendendGZ24_1.Visible = false; + + lendendGZ24_2 = new GSOHudButton(); + lendendGZ24_2.SetImage(Application.StartupPath + "/Resource/管纵/24_2.png"); + lendendGZ24_2.SetOffset(0, 0); + lendendGZ24_2.MinOpaque = 1; + lendendGZ24_2.MaxOpaque = 1; + lendendGZ24_2.FadeOut = false; + lendendGZ24_2.Name = "lendendGZ24_2"; + lendendGZ24_2.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ24_2); + lendendGZ24_2.Visible = false; + + lendendGZ24_3 = new GSOHudButton(); + lendendGZ24_3.SetImage(Application.StartupPath + "/Resource/管纵/24_3.png"); + lendendGZ24_3.SetOffset(0, 0); + lendendGZ24_3.MinOpaque = 1; + lendendGZ24_3.MaxOpaque = 1; + lendendGZ24_3.FadeOut = false; + lendendGZ24_3.Name = "lendendGZ24_3"; + lendendGZ24_3.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ24_3); + lendendGZ24_3.Visible = false; + + lendendGZ26 = new GSOHudButton(); + lendendGZ26.SetImage(Application.StartupPath + "/Resource/管纵/26.png"); + lendendGZ26.SetOffset(0, 0); + lendendGZ26.MinOpaque = 1; + lendendGZ26.MaxOpaque = 1; + lendendGZ26.FadeOut = false; + lendendGZ26.Name = "lendendGZ26"; + lendendGZ26.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ26); + lendendGZ26.Visible = false; + + } + + public void RigthMenuSet() + { + if (Utility.userRole.IndexOf("清除分析") < 0) + { + toolRightMenu.Items.Remove(清除分析ToolStripMenuItem); + } + + #region 区域分析 + if (Utility.userRole.IndexOf("区域分析") < 0) + { + toolRightMenu.Items.Remove(区域分析ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("缓冲区分析") < 0) + { + 区域分析ToolStripMenuItem.DropDownItems.Remove(缓冲区分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("附属物分析") < 0) + { + 区域分析ToolStripMenuItem.DropDownItems.Remove(附属物分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("无源淹没分析") < 0) + { + 区域分析ToolStripMenuItem.DropDownItems.Remove(无源淹没分析ToolStripMenuItem); + } + } + #endregion + + #region 视域分析 + if (Utility.userRole.IndexOf("视域分析") < 0) + { + toolRightMenu.Items.Remove(视域分析ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("通视分析") < 0) + { + 视域分析ToolStripMenuItem.DropDownItems.Remove(通视分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("可视域分析") < 0) + { + 视域分析ToolStripMenuItem.DropDownItems.Remove(可视域分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("可视包络分析") < 0) + { + 视域分析ToolStripMenuItem.DropDownItems.Remove(可视包络分析ToolStripMenuItem); + } + } + #endregion + + #region 开发分析 + if (Utility.userRole.IndexOf("开挖分析") < 0) + { + toolRightMenu.Items.Remove(开挖分析ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("多边形开挖") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(多边形开挖ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("挖方量分析") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(挖方量分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("沿线开挖") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(沿线开挖ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("创建隧道") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(创建隧道ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("隐藏隧道") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(隐藏隧道ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("删除隧道") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(删除隧道ToolStripMenuItem); + } + } + #endregion + + #region 拓扑分析 + if (Utility.userRole.IndexOf("拓扑分析") < 0) + { + toolRightMenu.Items.Remove(拓扑分析ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("创建拓扑") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(创建拓扑ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("上游分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(上游分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("下游分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(下游分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("流向分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(流向分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("关阀分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(关阀分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("连通分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(连通分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("爆管分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(爆管分析ToolStripMenuItem); + } + } + #endregion + + #region 断面分析 + if (Utility.userRole.IndexOf("断面分析") < 0) + { + toolRightMenu.Items.Remove(断面分析ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("横断面分析") < 0) + { + 断面分析ToolStripMenuItem.DropDownItems.Remove(横断面分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("纵断面分析") < 0) + { + 断面分析ToolStripMenuItem.DropDownItems.Remove(纵断面分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("道路断面分析") < 0) + { + 断面分析ToolStripMenuItem.DropDownItems.Remove(道路断面分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("基线剖面分析") < 0) + { + 断面分析ToolStripMenuItem.DropDownItems.Remove(基线剖面分析ToolStripMenuItem); + } + } + #endregion + + #region 绘制区域统计 + if (Utility.userRole.IndexOf("绘制区域统计") < 0) + { + toolRightMenu.Items.Remove(绘制区域统计ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("绘制区域管线长度统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管线长度统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域阀门数量统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(阀门数量统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域井盖数量统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(井盖数量统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域管径分段统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管径分段统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域埋深分段统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(埋深分段统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域管径分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管径分类统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域材质分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(材质分类统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域附属物分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(附属物分类统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域标识器分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(标识器分类统计ToolStripMenuItem1); + } + + } + #endregion + + #region 全区域统计 + if (Utility.userRole.IndexOf("全区域统计") < 0) + { + toolRightMenu.Items.Remove(全区域统计ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("全区域管线长度统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管线长度统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域阀门数量统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(阀门数量统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域井盖数量统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(井盖数量统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域管径分段统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管径分段统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域埋深分段统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(埋深分段统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域管径分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管径分类统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域材质分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(材质分类统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域附属物分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(附属物分类统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域标识器分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(标识器分类统计ToolStripMenuItem); + } + + } + #endregion + + #region 查询 + if (Utility.userRole.IndexOf("查询") < 0) + { + toolRightMenu.Items.Remove(查询ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("空间查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(空间查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("编号查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(编号查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("坐标查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(坐标查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("管径查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(管径查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("材质查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(材质查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("基本查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(基本查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("复合查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(复合查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("关联查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(关联查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("关键字查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(关键字查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("附属物查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(附属物查询ToolStripMenuItem); + } + } + #endregion + + #region 标注 + if (Utility.userRole.IndexOf("标注") < 0) + { + toolRightMenu.Items.Remove(标注ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("标高标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(标高标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("管径标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(管径标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("埋深标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(埋深标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("坐标标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(坐标标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("距离标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(距离标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("自定义标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(自定义标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("扯旗标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(扯旗标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("坡度标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(坡度标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("属性标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(属性标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("标注管理") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(标注管理ToolStripMenuItem); + } + } + #endregion + + #region 飞行 + if (Utility.userRole.IndexOf("飞行") < 0) + { + toolRightMenu.Items.Remove(飞行ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("自定义飞行") < 0) + { + 飞行ToolStripMenuItem.DropDownItems.Remove(自定义飞行ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("飞行到目标点") < 0) + { + 飞行ToolStripMenuItem.DropDownItems.Remove(飞行到目标点ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("绕中心点飞行") < 0) + { + 飞行ToolStripMenuItem.DropDownItems.Remove(绕中心点飞行ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("绕眼睛飞行") < 0) + { + 飞行ToolStripMenuItem.DropDownItems.Remove(绕眼睛飞行ToolStripMenuItem); + } + } + #endregion + + #region 编辑 + if (Utility.userRole.IndexOf("编辑") < 0) + { + toolRightMenu.Items.Remove(编辑ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("平移对象") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(平移对象ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("升降对象") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(升降对象ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("旋转对象") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(旋转对象ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("连接管段") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(连接管段ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("导出文件") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(导出文件ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("前进") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(前进ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("后退") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(删除模型ToolStripMenuItem); + } + } + #endregion + + #region 量算 + if (Utility.userRole.IndexOf("量算") < 0) + { + toolRightMenu.Items.Remove(量算ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("水平距离") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(水平距离ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("垂直距离") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(垂直距离ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("空间距离") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(空间距离ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("地表距离") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(地表距离ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("高度量算") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(高度量算ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("水平面积") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(水平面积ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("地表面积") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(地表面积ToolStripMenuItem1); + } + } + #endregion + } + + public void MenuSet() + { + + #region 权限管理 + if (Utility.userRole.IndexOf("权限管理") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem2); + } + else + { + + if (Utility.userRole.IndexOf("用户管理") < 0) + { + btn_user_info.Visible = false; + } + if (Utility.userRole.IndexOf("角色管理") < 0) + { + btn_role_info.Visible = false; + } + if (Utility.userRole.IndexOf("资源管理") < 0) + { + btn_resc_info.Visible = false; + } + if (Utility.userRole.IndexOf("角色授权") < 0) + { + btn_role_resc.Visible = false; + } + if (Utility.userRole.IndexOf("用户授权") < 0) + { + btn_user_role.Visible = false; + } + if (Utility.userRole.IndexOf("密码修改") < 0) + { + btn_password_edit.Visible = false; + } + + } + #endregion + + #region 基础工具 + if (Utility.userRole.IndexOf("基础工具") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem1); + } + else + { + if (Utility.userRole.IndexOf("地上模式") < 0) + { + buttonItem87.Visible = false; + } + if (Utility.userRole.IndexOf("地下模式") < 0) + { + buttonItem88.Visible = false; + } + if (Utility.userRole.IndexOf("行走模式") < 0) + { + buttonItem27.Visible = false; + } + if (Utility.userRole.IndexOf("透明度设置") < 0) + { + sliderGroundTransSet1.Visible = false; + } + if (Utility.userRole.IndexOf("快速定位") < 0) + { + buttonItem91.Visible = false; + } + if (Utility.userRole.IndexOf("图层管理") < 0) + { + buttonItem1.Visible = false; + } + if (Utility.userRole.IndexOf("图例管理") < 0) + { + btnlegendSet.Visible = false; + } + if (Utility.userRole.IndexOf("全屏显示") < 0) + { + buttonItem89.Visible = false; + } + if (Utility.userRole.IndexOf("导出图片") < 0) + { + btnOutputJPG.Visible = false; + } + + } + #endregion + + #region 一键审核 + if (Utility.userRole.IndexOf("一键审核") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem11); + } + #endregion + + #region 红线审核 + if (Utility.userRole.IndexOf("红线审核") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem6); + } + #endregion + + #region 双屏对比 + if (Utility.userRole.IndexOf("双屏对比") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem9); + } + #endregion + + #region 文档管理 + if (Utility.userRole.IndexOf("文档管理") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem4); + } + #endregion + + #region 基础管理 + if (Utility.userRole.IndexOf("基础管理") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem14); + } + else + { + if (Utility.userRole.IndexOf("专题图审批") < 0) + { + buttonItemZTT3_2.Visible = false; + } + if (Utility.userRole.IndexOf("打印审批") < 0) + { + buttonItemZTT4_2.Visible = false; + } + if (Utility.userRole.IndexOf("拷贝审批") < 0) + { + buttonItemZTT5_2.Visible = false; + } + } + + #endregion + + if (ribbonControl1.Items.Count <= 0) + { + ribbonControl1.Visible = false; + } + } + + #region Fan Zhang 重构现有代码 + //初始化控件布局 + private void initLayout() + { + 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.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.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.labelX21.Width = (int)(this.labelX21.Width * myScreen); + this.labelX22.Width = (int)(this.labelX22.Width * myScreen); + this.labelX24.Width = (int)(this.labelX24.Width * myScreen); + } + sideBar1.Visible = false; + 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]); + } + + splitContainer1.Panel2Collapsed = true; + + buttonItem87.Checked = true;//默认地上模式 + ribbonTabItem1.Select(); //初始化状态为浏览 + + sideBarPanelItem3.Visible = false; + layerTree.Visible = false; + controlContainerItem3.Visible = false; + if (sideBarPanelItem4.Visible == true) + { + sideBar1.Visible = true; + controlContainerItem5.Visible = true; + } + else + { + sideBar1.Visible = false; + } + Refresh(); + sliderGroundTransSet1.Value = optiValue; + sliderItem1.Value = optiValue; + sliderItem2.Value = optiValue; + sliderItem3.Value = optiValue; + + } + + //初始化地球控件 + private void initGlobalControl() + { + //选择 + btnToolSelect = new GSOHudButton(); + btnToolSelect.SetImage(Application.StartupPath + "\\Resource\\image\\select1.png"); + btnToolSelect.FadeOut = false; + btnToolSelect.Align = EnumAlign.TopLeft; + btnToolSelect.SetOffset(20, 50); + btnToolSelect.Name = "1"; + btnToolSelect.HeightFixed = true; + btnToolSelect.WidthFixed = true; + globeControl1.Globe.AddHudControl(btnToolSelect); + globeControl2.Globe.AddHudControl(btnToolSelect); + + //浏览 + 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); + + //图例 + legend = new GSOHudButton(); + legend.SetImage(Application.StartupPath + "/Resource/图例P.jpg");//图例P + legend.SetOffset(0, 15); + legend.MinOpaque = 1; + legend.MaxOpaque = 1; + legend.FadeOut = false; + legend.Name = "legend"; + legend.Align = EnumAlign.BottomRight; + legend.Visible = false; + globeControl1.Globe.AddHudControl(legend); + + //实测 + legendSC = new GSOHudButton(); + legendSC.SetImage(Application.StartupPath + "/Resource/sc.jpg"); + legendSC.SetOffset(0, 15); + legendSC.MinOpaque = 1; + legendSC.MaxOpaque = 1; + legendSC.FadeOut = false; + legendSC.Name = "legendSC"; + legendSC.Align = EnumAlign.BottomRight; + globeControl1.Globe.AddHudControl(legendSC); + legendSC.Visible = false; + + //施工 + legendSG = new GSOHudButton(); + legendSG.SetImage(Application.StartupPath + "/Resource/sg.jpg"); + legendSG.SetOffset(0, 15); + legendSG.MinOpaque = 1; + legendSG.MaxOpaque = 1; + legendSG.FadeOut = false; + legendSG.Name = "legendSG"; + legendSG.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(legendSG); + legendSG.Visible = false; + + //管纵 + AddGZ(); + + 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; + globeControl1.Globe.IsReleaseMemOutOfView = true; + globeControl1.Globe.ControlPanel.Visible = true; + + globeControl2.Globe.UnderGroundFloor.Visible = false; + globeControl2.Globe.OverviewControl.Visible = false; + globeControl2.Globe.ScalerControl.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; + globeControl2.Globe.IsReleaseMemOutOfView = true; + globeControl2.Globe.ControlPanel.Visible = false; + + 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); + + //添加临时图层 + layerTemp = globeControl1.Globe.Layers.Add(Application.StartupPath + "\\tempLgdData.lgd"); + layerTemp2 = globeControl2.Globe.Layers.Add(Application.StartupPath + "\\tempLgdData2.lgd"); + if (layerTemp != null) + { + layerTemp.MaxVisibleAltitude = 1000; + } + + //添加城市7线图层 + 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"); + + //注册对应事件 + this.registerEvent(); + } + + //注册地球事件 + private bool registerEvent() + { + if (globeControl1 == null || globeControl2 == null) + { + return false; + } + 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); + + globeControl2.FeatureMouseClickEvent += new FeatureMouseClickEventHandler(globeControl2_FeatureMouseClickEvent); + globeControl2.CameraBeginMoveEvent += new CameraBeginMoveEventHandler(globeControl2_CameraBeginMoveEvent); + + globeControl1.MouseDoubleClick += new MouseEventHandler(globeControl1_MouseDoubleClick); + globeControl1.MouseClick += new MouseEventHandler(globeControl1_MouseClick); + globeControl1.MouseDown += new MouseEventHandler(globeControl1_MouseDown); + + globeControl2.MouseClick += new MouseEventHandler(globeControl2_MouseClick); + globeControl2.MouseDown += new MouseEventHandler(globeControl2_MouseDown); + + 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); + + return true; + } + + //加载两个地球数据 + private void loadData() + { + Thread t1 = new Thread(new ThreadStart(doLoadDataForGlobalControl1)); + t1.IsBackground = true; + t1.Start(); + + + } + + delegate void LoadDataForGlobalControl(); + + private void connectServer() + { + globeControl1.Globe.ConnectServer(Utility.serverip, Utility.serverport, "", ""); //加载locaServer中的数据 + globeControl2.Globe.ConnectServer(Utility.serverip, Utility.serverport, "", ""); //加载locaServer中的数据 + //初始化TreeView + // 勾选实测图层 + foreach (TreeNode tn in layerTree.Nodes) + { + if (tn.Nodes.Count > 0) + { + if (tn.Text == "实测数据") + { + tn.Checked = true; + foreach (TreeNode tnChild in tn.Nodes) + { + tnChild.Checked = true; + foreach (TreeNode tnGrandChild in tnChild.Nodes) + { + tnGrandChild.Checked = true; + } + } + } + } + } + } + + private void doLoadDataForGlobalControl1() + { + try + { + + globeControl1.Globe.Layers.MoveDown(10000); + //加载实测管线数据 + Utility.dataSource = globeControl1.Globe.DataManager.OpenOracleDataSource(Utility.DBServer.Trim() + "/" + Utility.dbdatabase.Trim(), "", "", Utility.userID, Utility.DBPassword); + + if (Utility.dataSource != null) + { + for (int j = 0; j < Utility.dataSource.DatasetCount; j++) + { + GSODataset dataset = Utility.dataSource.GetDatasetAt(j); + if (dataset != null && dictionaryNetLayerNameAndCaption.ContainsKey(dataset.Caption)) + { + dataset.Caption = dataset.Name; + globeControl1.Globe.Layers.Add(dataset); + } + } + } + //隐藏红线图层 + globeControl1.Globe.Layers.GetLayerByCaption("红线").Visible = false; + + //globleControl1中加载规划数据 + GSODataSource ghDS = globeControl1.Globe.DataManager.OpenOracleDataSource(Utility.ghdbip + "/" + Utility.ghdbname, "", "", Utility.ghdbuser, Utility.ghdbpwd); + if (ghDS != null) + { + for (int j = 0; j < ghDS.DatasetCount; j++) + { + GSODataset dataset = ghDS.GetDatasetAt(j); + if (dataset != null && dictionaryNetLayerNameAndCaption.ContainsKey(dataset.Caption)) + { + dataset.Caption = dataset.Name; + globeControl1.Globe.Layers.Add(dataset); + globeControl1.Globe.Layers[0].Visible = false; + } + } + } + + //globeControl1,globeControl2中加载施工数据 + GSODataSource sgDS = globeControl1.Globe.DataManager.OpenOracleDataSource(Utility.sgdbip + "/" + Utility.sgdbname, "", "", Utility.sgdbuser, Utility.sgdbpwd); + if (sgDS != null) + { + for (int m = 0; m < sgDS.DatasetCount; m++) + { + GSODataset dataset = sgDS.GetDatasetAt(m); + if (dataset != null && !dataset.Caption.Contains("SH") && dictionaryNetLayerNameAndCaption.ContainsKey(dataset.Caption)) + { + dataset.Caption = dataset.Name; + globeControl1.Globe.Layers.Add(dataset); + globeControl1.Globe.Layers[0].Visible = false; + + globeControl2.Globe.Layers.Add(dataset); + globeControl2.Globe.Layers[0].Visible = true; + } + } + } + + LoadDataForGlobalControl ss = new LoadDataForGlobalControl(connectServer); + ss(); + + } + catch (Exception ex) + { + MessageBox.Show(ex.Message); + } + } + + private void initLayerTree() + { + //加载临时图层节点 + layerManagerNode = new TreeNode(); + layerManagerNode.ImageIndex = 0; + layerManagerNode.SelectedImageIndex = 0; + layerManagerNode.Checked = true; + layerManagerNode.Text = "临时图层"; + layerTree.Nodes.Add(layerManagerNode); + + XmlDocument doc = new XmlDocument(); + doc.Load(filename); + XmlNodeList xmlLayerNodes = doc.SelectNodes("//layer"); + + foreach (XmlNode xmlLayerNode in xmlLayerNodes) + { + + //TODO LIST:创建一级TreeNode(实测、规划、施工) + TreeNode nodelayer = new TreeNode(); + string layerName = xmlLayerNode.Attributes["label"].Value; + nodelayer.Text = layerName; + nodelayer.Checked = false; + layerTree.Nodes.Add(nodelayer); + + XmlNodeList xmlChildLayerNodes = xmlLayerNode.ChildNodes; + foreach (XmlNode xmlChildLayerNode in xmlChildLayerNodes) + { + //TODO LIST:创建二级TreeNode节点 + TreeNode secondLevelNode = new TreeNode(); + string layerType = xmlChildLayerNode.Attributes["label"].Value; + secondLevelNode.Text = layerType; + + if (xmlChildLayerNode.Attributes["type"] != null) + { //道路图层特殊处理 + string type = xmlChildLayerNode.Attributes["type"].Value; + secondLevelNode.Tag = type + "|" + layerType; + } + else + { + secondLevelNode.Tag = layerType; + } + secondLevelNode.Checked = false; + nodelayer.Nodes.Add(secondLevelNode); + + XmlNodeList xmlActitualLayerNodes = xmlChildLayerNode.ChildNodes; + + foreach (XmlNode xmlActitualLayerNode in xmlActitualLayerNodes) + { + //TODO LIST:创建三级图层节点 + TreeNode layerNode = new TreeNode(); + string actutallylayerType = xmlActitualLayerNode.Attributes["type"].Value; + string actutallylayerName = xmlActitualLayerNode.Attributes["layer"].Value; + string actutallyLabelName = xmlActitualLayerNode.Attributes["label"].Value; + + layerNode.Text = actutallyLabelName; + layerNode.Tag = layerType + "|" + actutallyLabelName; + layerNode.Checked = false; + secondLevelNode.Nodes.Add(layerNode); + } + + } + + } + + } + + /** + * 读取Config.xml文件,初始化以下全局Map + * m_PipelineLayerNames:管线 + * workwellLayerNames:工井 + * valueLayerNames:阀门 + * instrumenLayerNames:附属物 + * pipefittingLayerNames:特征管点 + * sgPipeLayersNames:施工管线 + **/ + private void initGlobalMap() + { + XmlDocument doc = new XmlDocument(); + doc.Load(filename); + XmlNodeList xmlLayerNodes = doc.SelectNodes("//layerchild"); + + foreach (XmlNode xmlLayerNode in xmlLayerNodes) + { + string layerType = xmlLayerNode.Attributes["type"].Value; + string layerName1 = xmlLayerNode.Attributes["layer"].Value; + string layerchildName = xmlLayerNode.Attributes["label"].Value; + + dictionaryNetLayerNameAndCaption.Add(layerName1, layerchildName); + + if (layerType != "db") + { + if (xmlLayerNode.Attributes["isRoad"] != null) + { + roadLayerName = layerchildName; + } + } + else if (xmlLayerNode.Attributes["isPipeLine"] != null) + { + m_PipelineLayerNames.Add(layerchildName); + g1layername.Add(layerName1); + } + else if (xmlLayerNode.Attributes["isWorkWell"] != null) + { + workwellLayerNames.Add(layerchildName); + g1layername.Add(layerName1); + } + else if (xmlLayerNode.Attributes["isValve"] != null) + { + valueLayerNames.Add(layerchildName); + g1layername.Add(layerName1); + } + else if (xmlLayerNode.Attributes["isAccess"] != null) + { + instrumenLayerNames.Add(layerchildName); + g1layername.Add(layerName1); + } + else if (xmlLayerNode.Attributes["isCharacter"] != null) + { + pipefittingLayerNames.Add(layerchildName); + g1layername.Add(layerName1); + } + else if (xmlLayerNode.Attributes["isSgData"] != null) + { + sgPipeLayersNames.Add(layerchildName); + g1layername.Add(layerName1); + } + + } + } + + private void initMarkerTree() + { + 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); + } + } + } + } + + private void MainFrm_Load(object sender, EventArgs e) + { + + this.initGlobalControl(); + this.initGlobalMap(); + this.initLayerTree(); + this.initMarkerTree(); + this.initLayout(); + this.loadData(); + + + double x = Convert.ToDouble(Utility.Query_Roads["绿岛"].ToString().Split(',')[0]); + double y = Convert.ToDouble(Utility.Query_Roads["绿岛"].ToString().Split(',')[1]); + double z = Convert.ToDouble(Utility.Query_Roads["绿岛"].ToString().Split(',')[2]); + jumpToCameraState(x, y, z); + + + } + + #endregion + + /// + /// 每次gis服务加载时都会触发的 + /// + /// + /// + 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 dictionaryNetLayerNameAndCaption = new Dictionary(); + 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 配置用户权限 + /// + /// 向数据库插入功能列表 + /// + private void insertControlToDatabase() + { + ArrayList listItem = new ArrayList(); + List subListItem = new List(); + 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) + { + GSOCameraState camera = globeControl2.Globe.CameraState; + globeControl1.Globe.JumpToCameraState(camera); + } + } + + void globeControl1_BeforeSceneRenderEvent(object sender, BeforeSceneRenderEventArgs e) + { + if (globeControl1.Focused) + { + 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); + } + } + } + + /// + /// 检查数据集是否有坐标系信息 + /// + /// + /// + 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 = "0prj4" + lprjStr + ""; + + bSuccess = dataset.LoadProjectionFromESRIFile(dlg.FileName); + + string lprjFileName = strDataPath.Substring(0, strDataPath.LastIndexOf(".")) + ".lprj"; + StreamWriter writer = new StreamWriter(lprjFileName, false); + writer.Write(lprjFileContent); + writer.Close(); + + } + } + } + else + { + return true; + } + return bSuccess; + } + + /// + /// 矩形拉框结束事件处理函数 + /// + /// + /// + 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))); + */ + + int mapWidth = 0; + int mapHeight = 0; + Point pt = getUpperLeftPoint(pt1, pt2, out mapWidth, out mapHeight); + int rightBottomX = pt.X + mapWidth; + int rightBottomY = pt.Y + mapHeight; + Image myImg = new Bitmap(mapWidth, mapHeight); + Graphics g = Graphics.FromImage(myImg); + g.CopyFromScreen(pt, new Point(0, 0), new Size(rightBottomX, rightBottomY)); + + 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; + } + } + /// + /// 定位正北正90度俯视 + /// + /// + /// + /// + 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; + } + } + /// + /// layerTree选中后事件处理 + /// + /// + /// + 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); + } + /// + /// 树节点选中方法 + /// + /// + 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); + } + } + } + + } + /// + /// 改变所有子节点的状态 + /// + /// + /// + 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; + LayerFlyMenuItem.Visible = true; + } + + LayerSelectableMenuItem.Visible = true; + LayerEditableMenuItem.Visible = true; + SaveLayerMenuItem.Visible = true; + LayerFlyMenuItem.Visible = true; + 导出CADToolStripMenuItem1.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]); + if (layer != null) + { + LayerSelectableMenuItem.Checked = layer.Selectable; + LayerEditableMenuItem.Checked = layer.Editable; + } + else + { + return; + } + } + 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; + } + } + } + } + } + + /// + /// 删除临时添加的本地数据图层 + /// + /// + /// + 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); + for (int i = globeControl1.Globe.Layers.Count-1; i >=0; i--) + { + if (globeControl1.Globe.Layers[i].Caption == layer.Caption) + { + globeControl1.Globe.Layers.Remove(globeControl1.Globe.Layers[i]); + } + } + + 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 定位ToolStripMenuItem_Click(object sender, EventArgs e) + { + TreeNode node = layerTree.SelectedNode; + + if (node != null) + { + if (node.Parent.Text.Trim() == "临时图层") + { + GSOLayer lsLayer = globeControl1.Globe.Layers.GetLayerByCaption(node.Text.ToString()); + double x = lsLayer.LatLonBounds.Center.X; + double y = lsLayer.LatLonBounds.Center.Y; + if (x == 0 && y == 0) + { + x = lsLayer.Bounds.Center.X; + y = lsLayer.Bounds.Center.Y; + } + + globeControl1.Globe.FlyToPosition(new GSOPoint3d(x, y, 10), EnumAltitudeMode.Absolute); + } + else + { + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(node.Tag.ToString().Split('|')[1]); + + if (layer != null) + { + if (layer.Caption == "红线") + { + globeControl1.Globe.FlyToPosition(new GSOPoint3d(120.610963, 31.188121, 50), EnumAltitudeMode.Absolute, -4, 50, 1000); + globeControl1.Globe.FlyToPointSpeed = 10000000; + globeControl1.Globe.Action = EnumAction3D.SelectObject; + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = true; + } + globeControl1.Refresh(); + } + else + { + double x = layer.LatLonBounds.Center.X; + double y = layer.LatLonBounds.Center.Y; + globeControl1.Globe.FlyToPosition(new GSOPoint3d(x, y, 100), EnumAltitudeMode.Absolute); + } + } + } + } + else + { + return; + } + + } + + private void layerTree_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e) + { + if(this.layerTree.SelectedNode!=null) + { + if (this.layerTree.SelectedNode.Tag.ToString().Contains("|")) + { + string nodeTag = this.layerTree.SelectedNode.Tag.ToString().Split('|')[1]; + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(nodeTag); + if (layer != null) + { + if (layer.Caption == "红线") + { + globeControl1.Globe.FlyToPosition(new GSOPoint3d(120.610963, 31.188121, 50), EnumAltitudeMode.Absolute, -4, 50, 1000); + globeControl1.Globe.FlyToPointSpeed = 10000000; + globeControl1.Globe.Action = EnumAction3D.SelectObject; + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = true; + } + globeControl1.Refresh(); + } + else { + double x = layer.LatLonBounds.Center.X; + double y = layer.LatLonBounds.Center.Y; + globeControl1.Globe.FlyToPosition(new GSOPoint3d(x, y, 0), EnumAltitudeMode.Absolute); + } + } + } + if (this.layerTree.SelectedNode.Tag is GSOLayer) + { + GSOLayer layer = this.layerTree.SelectedNode.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 (this.layerTree.SelectedNode.Tag is GSOFeature) + { + GSOFeature feature = this.layerTree.SelectedNode.Tag as GSOFeature; + if (feature.Geometry != null) + { + globeControl1.Globe.FlyToPosition(feature.Geometry.GeoCenterPoint, EnumAltitudeMode.Absolute, 0, 0, 10); + } + else + { + globeControl1.Globe.FlyToFeature(feature); + } + } + } + } + + /// + /// 在三维场景移动时,隐藏气泡globeControl1 + /// + /// + /// + void globeControl1_CameraBeginMoveEvent(object sender, CameraBeginMoveEventArgs e) + { + if (featureTooltip.IsVisible()) + { + featureTooltip.HideBalloon(); + } + if (balloonEx.IsVisible()) + { + balloonEx.HideBalloon(); + } + } + + /// + /// 在三维场景移动时,隐藏气泡globeControl2 + /// + /// + /// + void globeControl2_CameraBeginMoveEvent(object sender, CameraBeginMoveEventArgs e) + { + if (featureTooltip2.IsVisible()) + { + featureTooltip2.HideBalloon(); + } + if (balloonEx2.IsVisible()) + { + balloonEx2.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(); + } + } + + #region Fan 横断面 + /// + /// 横断面分析、基线剖面分析、道路断面分析等 + /// + /// + /// + private static EnumTrackPolylineEndMode trackPolylineEndMode; + + void globeControl1_TrackPolylineEndEvent(object sender, TrackPolylineEndEventArgs e) + { + //横断面分析、道路横断面分析 + if (trackPolylineEndMode == EnumTrackPolylineEndMode.HDM_Analysis|| + trackPolylineEndMode == EnumTrackPolylineEndMode.DLDM_Analysis) + { + Dictionary hdmDic = SectionAnalysisTool.HDMAnalysis(this.globeControl1, + e.Polyline, this.m_PipelineLayerNames); + FrmHDMAnalysis3 frm = new FrmHDMAnalysis3(hdmDic, this.globeControl1, + trackPolylineEndMode); + frm.Show(this); + } + //基线剖面分析 + else if (trackPolylineEndMode == EnumTrackPolylineEndMode.JXPM_Analysis) + { + FrmBaseLineProfillAnalysis dlg = new FrmBaseLineProfillAnalysis(globeControl1.Globe, e.Polyline); + dlg.Show(this); + globeControl1.Globe.ClearLastTrackPolyline(); + } + else + { + + } + trackPolylineEndMode = EnumTrackPolylineEndMode.Default_Analysis; + } + #endregion + + private GSOFeatures PolygonIntersectAnalysis(GSOGeoPolygon3D polygon, string pipelinetype) + { + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(pipelinetype); + 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(pipelinetype, feats.Length); + return feats; + } + /// + /// 根据范围统计阀门、管线、工井等, 开挖分析, 挖方量分析 + /// + /// + /// + void globeControl1_TrackPolygonEndEvent(object sender, TrackPolygonEndEventArgs e) + { + if (globeControl1.Globe.Action == EnumAction3D.TrackPolygon && e.Polygon != null) + { + GSOGeoPolygon3D polygon = e.Polygon; + + switch (trackflag) + { + case "valvequery": + FrmValveStatistics frm = new FrmValveStatistics(globeControl1,polygon, new DataGridViewDelegate(InitDataGridViewX1)); + frm.Show(this); + globeControl1.Globe.Action = EnumAction3D.ActionNull; + break; + + case "PipelineDistanceStatistics": + FrmAllPipelineStatis frm1 = new FrmAllPipelineStatis(globeControl1, polygon, new DataGridViewDelegate(InitDataGridViewX1), m_PipelineLayerNames); + frm1.Show(this); + globeControl1.Globe.Action = EnumAction3D.ActionNull; + + break; + case "PipelineSpatialQuery": + FrmAllPipelineStatis.ShowForm(globeControl1,polygon,new DataGridViewDelegate(InitDataGridViewX1),m_PipelineLayerNames); + globeControl1.Globe.ClearAnalysis(); + globeControl1.Globe.Action = EnumAction3D.ActionNull; + + break; + case "workwellquery": + FrmAllWorkWellStatis frmWell = new FrmAllWorkWellStatis(globeControl1, polygon, new DataGridViewDelegate(InitDataGridViewX1)); + 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 "BSQDuoBianXiangStatis": + + GSOFeature f2 = new GSOFeature(); + f2.Geometry = e.Polygon; + f2.Geometry.AltitudeMode = EnumAltitudeMode.Absolute; + globeControl1.Globe.MemoryLayer.AddFeature(f2); + f2.Geometry.MoveZ(3); + workWellLen.Clear(); + List listBSQ = new List(); + + GSOFeatures bsqFeatures = PolygonIntersectAnalysis(e.Polygon, "标识器"); + listBSQ.Add(bsqFeatures); + + FrmBSQDuoBianXingStatis bsqFrm = new FrmBSQDuoBianXingStatis(workWellLen, globeControl1, listBSQ); + bsqFrm.Show(this); + globeControl1.Globe.Action = EnumAction3D.ActionNull; + break; + + case "": + break; + default: + break; + } + } + } + + #region 验证端口 + /* + /// + /// 验证端口 + /// + /// + 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 + + /// + /// 鼠标悬浮提示 + /// + /// + /// + 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); + } + } + + /// + /// 添加管线绘制完成事件, 红线工具绘制完成 + /// + /// + /// + 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; + + + } + } + + /// + /// 获取globeControl1中鼠标按下的坐标供区别鼠标右键和滚轮按下事件 + /// + /// + /// + void globeControl1_MouseDown(object sender, MouseEventArgs e) + { + mouseDownX1 = e.X; + mouseDownY1 = e.Y; + } + /// + /// 获取globeControl2中鼠标按下的坐标供区别鼠标右键和滚轮按下事件 + /// + /// + /// + void globeControl2_MouseDown(object sender, MouseEventArgs e) + { + mouseDownX2 = e.X; + mouseDownY2 = e.Y; + } + /// + /// + /// + /// + /// + void globeControl2_MouseClick(object sender, MouseEventArgs e) + { + if (e.Button == MouseButtons.Right) + { + if (e.X == mouseDownX2 && e.Y == mouseDownY2) + { + RightScreenToolMenu.Show(globeControl2, e.X, e.Y); + } + else + { + return; + } + } + } + /// + /// + /// + /// + /// + void globeControl1_MouseClick(object sender, MouseEventArgs e) + { + if (e.Button == MouseButtons.Left) + { + if (globeControl1.Globe.Action == EnumAction3D.VisibilityAnalysis) + { + buttonItemFX5_1.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; + + bsqPT = pt; + + if (buttonItemLS5.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 (e.X == mouseDownX1 && e.Y == mouseDownY1) + { + toolRightMenu.Show(globeControl1, e.X, e.Y); + if (buttonItemLS5.Checked) + { + buttonItemLS5.Checked = false; + } + } + else + { + return; + } + } + globeControl1.Refresh(); + } + + /// + /// 判断网络图片是否存在 + /// + /// + /// + 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; + } + + /// + /// 鼠标点击, 弹出气泡功能globeControl1 + /// + /// + /// + void globeControl1_FeatureMouseClickEvent(object sender, FeatureMouseClickEventArgs e) + { + GSOFeature feature = e.Feature; + + string str1 = ""; + if (feature != null) + { + if (feature.GetFieldDefn("图片编码") != null)// + { + str1 = GetBubbleInfo(feature, globeControl1); + if (RemoteFileExists(Utility.PicRootURL + feature.GetValue("图片编码").ToString())) + { + str1 += ""; + } + else if (RemoteFileExists(Utility.PicDefaultURL)) + { + str1 += ""; + } + } + else if (isFeatureContainsBianhao(feature)) //管线模型图层 + { + str1 = GetBubbleInfo(feature, globeControl1); + } + + 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; + } + } + } + + /// + /// 鼠标点击, 弹出气泡功能globeControl2 + /// + /// + /// + void globeControl2_FeatureMouseClickEvent(object sender, FeatureMouseClickEventArgs e) + { + GSOFeature feature = e.Feature; + + string str1 = ""; + if (feature != null) + { + if (feature.GetFieldDefn("图片编码") != null) // + { + str1 = GetBubbleInfo(feature, globeControl2); + if (RemoteFileExists(Utility.PicRootURL + feature.GetValue("图片编码").ToString())) + { + str1 += ""; + } + else if (RemoteFileExists(Utility.PicDefaultURL)) + { + str1 += ""; + } + } + else if (isFeatureContainsBianhao(feature)) //管线模型图层 + { + str1 = GetBubbleInfo(feature, globeControl2); + } + + if (str1 != "") + { + + featureTooltip2.HideBalloon(); + balloonEx2.HideBalloon(); + balloonEx2.SetSize(EnumSizeIndexEx.CONTENT_CX, 480); + balloonEx2.SetSize(EnumSizeIndexEx.CONTENT_CY, 420); + balloonEx2.ShowBalloon((int)e.MousePos.X, (int)e.MousePos.Y, str1); + + return; + } + } + } + + /// + /// 拼接气泡表格字符串 + /// + /// + /// + private string GetBubbleInfo(GSOFeature feature,GSOGlobeControl globeControl) + { + if (feature == null) + { + return ""; + } + string str = ""; + str = ""; + 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 += ""; + + 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.get_Fields(layerName, globeControl); + } + if (queryFields != null) + { + string[] param = { "," }; + string[] fieldNames = queryFields.Split(param, StringSplitOptions.RemoveEmptyEntries); + for (int j = 0; j < fieldNames.Length; 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 (name1 == "模型路径") + { + continue; + } + 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 (field1.Type == EnumFieldType.Double) + { + double dl1 = feature.GetFieldAsDouble(j); + if (!name1.Contains("管径") && !name1.Contains("电压") && !name1.Contains("角度")) + { + name1 += "_米"; + } + value1 = dl1.ToString("0.00"); + } + 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 (name2 == "模型路径") + { + continue; + } + + 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 (field2.Type == EnumFieldType.Double) + { + double dl2 = feature.GetFieldAsDouble(j + 1); + if (!name2.Contains("管径") && !name2.Contains("电压") && !name2.Contains("角度")) + { + name2 += "_米"; + } + value2 = dl2.ToString("0.00"); + } + else + { + if (!feature.IsFieldValueNull(j + 1)) + { + value2 = feature.GetValue(j + 1).ToString(); + } + } + } + } + + j++; + } + str += ""; + } + } + str += "
" + title + " " + feature.GetFieldAsString(featureIDFieldName) + "
" + + name1 + + "
" + + value1 + + "
" + + name2 + + "
" + + value2 + "
"; + return str; + } + + string filename = Utility.filename; + List g1layername = new List(); + + /// + /// 获取目标图层 + /// + /// + 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; + } + /// + /// 添加图层 + /// + /// + /// + /// + 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 = 5000; + return templayer.Visible; + } + catch (Exception ex) + { + return false; + } + } + /// + /// 菜单上的 三维导航 工具按钮 + /// + /// + /// + private void buttonItem86_Click(object sender, EventArgs e) + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + } + + /// + /// 地上模式 菜单按钮 + /// + /// + /// + 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(); + + } + } + /// + /// 地下模式 菜单按钮 + /// + /// + /// + 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(); + } + } + /// + /// 行走模式 菜单按钮 + /// + /// + /// + 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; + } + } + /// + /// 地面透明度设置 菜单 + /// + /// + /// + private void sliderGroundTransSet1_ValueChanged(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.sliderGroundTransSet1.Text); + + globeControl1.Globe.GroundOpaque = 100 - sliderGroundTransSet1.Value; + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(roadLayerName);//("180fd"); + if (layer != null) + { + layer.Opaque = 100 - sliderGroundTransSet1.Value; + } + //if (buttonItemSPDB.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; + } + /// + /// 图例 菜单按钮 + /// + /// + /// + 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(); + } + /// + /// 快速定位 菜单按钮 + /// + /// + /// + private void buttonItem91_Click(object sender, EventArgs e) // + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItem91.Text); + FrmFlyToPosition fly = new FrmFlyToPosition(globeControl1); + fly.Show(this); + } + /// + /// 图层管理 菜单按钮 + /// + /// + /// + 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; + + //修改图层管理与标注管理、覆土审查、水平净距分析、垂直净距分析和碰撞分析控件之间的逻辑关系 + controlContainerItem5.Visible = false; + sideBar1.Visible = false; + sideBarPanelItem4.Visible = false; + panel3.Visible = false; + sideBar1.ExpandedPanel = sideBarPanelItem3; + buttonItemBZ11.Checked = false; + + //20160624 + /* + if (sideBarPanelItem4.Visible == true) + { + sideBar1.Visible = true; + controlContainerItem5.Visible = true; + } + else + { + sideBar1.Visible = false; + } + */ + Refresh(); + + } + } + /// + /// 全屏显示 菜单按钮 + /// + /// + /// + 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; + /// + /// 全屏显示功能实现 + /// + 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(); + } + } + + /// + /// 设置窗体宽、高 + /// + /// + /// + private void SetFullScreen(int width, int height) + { + this.Width = width; + this.Height = height; + } + + /// + /// 全屏功能的快捷键F5 + /// + /// + /// + 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); + } + } + /* + /// + /// 输出地图 + /// + /// + /// + /// + 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; + } + * */ + + private Point getUpperLeftPoint(Point p1, Point p2, out int mapWidth, out int mapHeight) // + { + Rectangle rc = new Rectangle(); + + p1 = this.globeControl1.PointToScreen(p1); + p2 = this.globeControl1.PointToScreen(p2); + + int x = Screen.PrimaryScreen.Bounds.X; + int y = Screen.PrimaryScreen.Bounds.Y; + int screenWidth = SystemInformation.WorkingArea.Width; + int screenHeight = SystemInformation.WorkingArea.Height; + + if (p1.X < x) + rc.X = x; + else + rc.X = p1.X; + + if (p1.Y < y) + rc.Y = y; + else + rc.Y = p1.Y; + + p1.X = rc.Left; + p1.Y = rc.Top; + + if (p2.X > screenWidth) + p2.X = screenWidth; + else + p2.X = p2.X; + + if (p2.Y > screenHeight) + p2.Y = screenHeight; + else + p2.Y = p2.Y; + + rc.Width = p2.X - rc.X; + rc.Height = p2.Y - rc.Y; + + mapWidth = rc.Width; + mapHeight = rc.Height; + Point pt = new Point(rc.Left, rc.Top); + return pt; + } + + Image printImage; + /// + /// 打印 菜单 + /// + /// + /// + 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))); + */ + int mapWidth = 0; + int mapHeight = 0; + Point pt = getUpperLeftPoint(pt1, pt2, out mapWidth, out mapHeight); + int rightBottomX = pt.X + mapWidth; + int rightBottomY = pt.Y + mapHeight; + Image myImg = new Bitmap(mapWidth, mapHeight); + Graphics g = Graphics.FromImage(myImg); + g.CopyFromScreen(pt, new Point(0, 0), new Size(rightBottomX, rightBottomY)); + + + 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); + } + /// + /// 输出地图 菜单 + /// + /// + /// + private void btnOutputJPG_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btnOutputJPG.Text); + + //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))); + */ + int mapWidth = 0; + int mapHeight = 0; + Point pt = getUpperLeftPoint(pt1, pt2, out mapWidth, out mapHeight); + int rightBottomX = pt.X + mapWidth; + int rightBottomY = pt.Y + mapHeight; + Image myImg = new Bitmap(mapWidth, mapHeight); + Graphics g = Graphics.FromImage(myImg); + g.CopyFromScreen(pt, new Point(0, 0), new Size(rightBottomX, rightBottomY)); + + 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; + } + } + } + + /// + /// 统计管线的里程数 + /// + /// + /// + /// + 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; + } + + /// + /// 窗体下方属性表格 右键菜单中的 “定位”菜单 + /// + /// + /// + 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); + + } + + /// + /// 表格中右键 “单个闪烁” 菜单 + /// + /// + /// + private void LightMenu_Click(object sender, EventArgs e) + { + flashflag = "single"; + timer1.Start(); + } + /// + /// 表格中右键 “全部闪烁” 菜单 + /// + /// + /// + private void AllLightMenuItem_Click(object sender, EventArgs e) + { + flashflag = "all"; + timer1.Start(); + } + + /// + /// 使用timer实现管线的闪烁效果 + /// + /// + /// + 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; + } + } + + /// + /// 绘制线 菜单 + /// + /// + /// + private void btnAddLine_Click(object sender, EventArgs e) + { + globeControl1.Globe.DestLayerFeatureAdd = globeControl1.Globe.MemoryLayer; + globeControl1.Globe.Action = EnumAction3D.DrawPolyline; + } + /// + /// 绘制面 菜单 + /// + /// + /// + private void btnAddPolygon_Click(object sender, EventArgs e) + { + globeControl1.Globe.DestLayerFeatureAdd = globeControl1.Globe.MemoryLayer; + globeControl1.Globe.Action = EnumAction3D.DrawPolygon; + } + /// + /// 图层目录树 右键菜单中的 目标图层 菜单 + /// + /// + /// + 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; + } + } + /// + /// 图层目录树 右键菜单中的 可选择 菜单 + /// + /// + /// + 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; + } + /// + /// 图层目录树 右键菜单中的 可编辑 菜单 + /// + /// + /// + 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; + } + /// + /// 图层目录树 右键菜单中的 保存 菜单 + /// + /// + /// + 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(); + } + + /// + /// 根据多边形范围统计管线的里程 + /// + /// + /// + /// 返回查询到的管线要素集合 + 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 pipeLineDis = new Dictionary(); + Dictionary workWellLen = new Dictionary(); + + + + + /// + /// 查找指定图层中在 指定范围内的feature对象集合 + /// + /// + /// + /// + 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; + } + /// + /// 清除结果 菜单 + /// + /// + /// + private void buttonItem47_Click(object sender, EventArgs e) + { + globeControl1.Globe.ClearAnalysis(); + dataGridViewX1.DataSource = null; + panelOfTable.Visible = false; + clearFeatureHighLight(); + } + /// + /// 设置菜单的选中状态 + /// + private void ActionToolMenuChecked() + { + if (globeControl1.Globe.Action != EnumAction3D.TrackPolyline) + { + buttonItemFX2_1.Checked = false; + buttonItemFX2_4.Checked = false; + buttonItemFX2_3.Checked = false; + buttonItemFX4_3.Checked = false; + } + if (globeControl1.Globe.Action != EnumAction3D.NormalHit) + { + buttonItemFX3_6.Checked = false; + // ClearConnexityAnalysis(); + + buttonItemFX3_5.Checked = false; + // ClearCloseValvesAnalysis(); + } + if (globeControl1.Globe.Action != EnumAction3D.TrackPolygon) + { + buttonItemFX4_2.Checked = false; + buttonItemFX4_1.Checked = false; + } + } + + /// + /// 主窗体关闭事件处理 + /// + /// + /// + private void MainFrm_FormClosing(object sender, FormClosingEventArgs e) + { + + if (MessageBox.Show("是否退出系统?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) + { + e.Cancel = true; + } + else { + globeControl1.Globe.MemoryLayer.SaveAs(Application.StartupPath + "/MyPlace.kml"); + } + + //saveLayerList(layerManagerNode.Nodes); + //注销id号为103的热键设定 + // UnregisterHotKey(Handle, 103); + } + + /// + /// 显示流向 功能 + /// + /// + /// + /// + 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(); + } + + FrmCloseValves frm; + + FrmBoosterValvers frmbooster = null; + + /// + /// 垂直净距分析 功能界面中的 选择图层复选框 选中状态改变事件处理 + /// + /// + /// + 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(); + } + /// + /// 水平净距分析 功能界面中的 选择图层复选框 选中状态改变事件处理 + /// + /// + /// + 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(); + } + /// + /// 垂直净距分析 功能界面中的 选择管线复选框 选中状态改变事件处理 + /// + /// + /// + private void checkBoxX1_CheckedChanged(object sender, EventArgs e) + { + clearFeatureHighLight(); + if (checkBoxX1.Checked) + { + comboBoxEx1.SelectedItem = null; + 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; + } + } + /// + /// 水平净距分析 功能界面中的 选择管线复选框 选中状态改变事件处理 + /// + /// + /// + private void checkBoxX1_CheckedChanged_shuiping(object sender, EventArgs e) + { + clearFeatureHighLight();//清除高亮 + if (checkBoxX7.Checked) + { + comboBoxEx4.SelectedItem = null; + 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(); + /// + /// 垂直净距分析 功能界面中的 选择图层下拉框 选中项改变 事件处理 + /// + /// + /// + 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; + } + } + } + /// + /// 水平净距分析 功能界面中的 选择图层下拉框 选中项改变 事件处理 + /// + /// + /// + 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 featCount = new Dictionary(); + Dictionary featLenth = new Dictionary(); + Dictionary m_FeaturesWithBianhao = new Dictionary();//记录编号和对应的标注点的位置 + GSOFeatures polygonJingJuAnalysises = new GSOFeatures(); + + /// + /// 垂直净距分析 功能界面中的 开始分析按钮 事件处理 + /// + /// + /// + 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; + } + + /// + /// 在指定的两点组成的线的中间添加一个marker对象,并将marker对象添加到指定的图层中 + /// + /// + /// + /// + /// + /// + 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; + } + + /// + /// 计算指定feature对象与除了该feature所在图层之外的 所有管线图层中的所有feature对象 的垂直距离 并在表格中记录符合要求的管线 + /// + /// + /// + /// + /// + private void VerticalDistanceAnalysis(string type, GSOFeature selectedFeature, List _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(); + } + /// + /// 垂直净距分析中 表格行的 双击定位 功能。 与覆土分析的实现方法不同,主要原因是需要标注垂距 + /// + /// + /// + 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); + } + } + } + } + + /// + /// 水平净距分析 功能界面中 开始分析按钮 的事件处理 + /// + /// + /// + 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; + } + + + /// + /// 计算指定feature对象与除了该feature所在图层之外的 所有管线图层中的所有feature对象 的水平距离 并记录符合要求的管线 功能 + /// + /// + /// + /// + /// + private void HorizontalDistanceAnalysis(GSOFeature selectedFeature, List _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)); + } + } + } + } + } + /// + /// 水平净距分析 功能界面中 表格的 双击定位 功能 + /// + /// + /// + 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); + } + } + } + } + } + /// + /// 碰撞分析 功能界面中 开始分析按钮 事件处理 + /// + /// + /// + 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; + } + /// + /// 碰撞分析功能界面中 表格的 双击定位 功能 + /// + /// + /// + 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); + } + } + } + } + + + + /// + /// 覆土分析功能操作界面中的 选择管线 复选框选中状态改变事件处理 + /// + /// + /// + private void checkBoxX5_CheckedChanged(object sender, EventArgs e) + { + clearFeatureHighLight(); + if (checkBoxX5.Checked) + { + comboBoxEx3.SelectedItem = null; + 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; + } + } + /// + /// 覆土分析功能操作界面中的 选择图层 复选框选中状态改变事件处理 + /// + /// + /// + 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(); + } + /// + /// 覆土分析功能操作界面中的 图层下拉框选中项改变事件处理 + /// + /// + /// + 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; + } + } + } + /// + /// 覆土分析功能操作界面中的 开始分析 按钮事件处理 + /// + /// + /// + 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; + + + GSOPoint3d markerPosition = new GSOPoint3d(); + 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]; + GSOPoint3d pt = new GSOPoint3d(); + + 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"); + + pt.X = pts[m].X; + pt.Y = pts[m].Y; + pt.Z = 0; + markerPosition = LabelVerticalDistance(layerTemp, pts[m], pt, Convert.ToDouble(dataGridViewX7.Rows[idx].Cells[2].Value), true); + 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]; + GSOPoint3d pt = new GSOPoint3d(); + 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"); + + pt.X = pts[m].X; + pt.Y = pts[m].Y; + pt.Z = 0; + markerPosition = LabelVerticalDistance(layerTemp, pts[m], pt, Convert.ToDouble(dataGridViewX7.Rows[idx].Cells[2].Value), true); + + 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; + } + + /// + /// 覆土分析中 表格的 双击定位 功能 + /// + /// + /// + 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); + } + } + } + } + } + /// + /// 覆土分析功能操作界面中的 导出Excel按钮 事件处理 + /// + /// + /// + private void buttonX10_Click(object sender, EventArgs e) + { + if (dataGridViewX7.Rows.Count > 0) + { + ExportExcel("覆土分析", dataGridViewX7, null); + } + else + { + MessageBox.Show("表格内容为空!", "提示"); + } + } + /// + /// 覆土分析功能操作界面底部的 关闭 按钮事件处理 + /// + /// + /// + 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(); + layerTemp.RemoveAllFeature(); + + if (buttonItem1.Checked) + { + sideBar1.ExpandedPanel = sideBarPanelItem3; + } + else + { + sideBar1.Visible = false; + } + globeControl1.Refresh(); + + //Refresh(); + } + + + /// + /// 垂直净距分析 功能界面中 清除分析结果按钮 事件处理 + /// + /// + /// + 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(); + } + /// + /// 水平净距分析 功能界面中 清除分析结果按钮 事件处理 + /// + /// + /// + 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(); + } + + /// + /// 垂直净距分析功能界面中 关闭按钮 事件处理 + /// + /// + /// + 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(); + } + /// + /// 水平净距分析功能界面中 删除缓冲区按钮 事件处理 + /// + /// + /// + private void buttonX14_Click(object sender, EventArgs e) + { + 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(); + } + + /// + /// 导出指定DataGridView控件中的内容 + /// + /// + /// + 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(); + } + } + } + } + + /// + /// 垂直净距分析功能界面中 导出Excel按钮 事件处理 + /// + /// + /// + private void buttonX4_Click(object sender, EventArgs e) + { + if (dataGridViewX3.Rows.Count > 0) + { + ExportExcel("垂直净距分析", dataGridViewX3, listBox1); + } + else + { + MessageBox.Show("表格内容为空!", "提示"); + } + } + /// + /// 水平净距分析功能界面中 导出Excel按钮 事件处理 + /// + /// + /// + private void buttonX4_Click_shuiping(object sender, EventArgs e) + { + if (dataGridViewX9.Rows.Count > 0) + { + ExportExcel("水平净距分析", dataGridViewX9, listBox3); + } + else + { + MessageBox.Show("表格内容为空!", "提示"); + } + } + + + /// + /// 清除所有坑 菜单 + /// + /// + /// + private void buttonItem3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItem3.Text); + + globeControl1.Globe.RemoveAllPits(); + } + + //} + /// + /// 大气层 菜单 + /// + /// + /// + private void buttonItem17_Click_1(object sender, EventArgs e) + { + globeControl1.Globe.Atmosphere.Visible = !globeControl1.Globe.Atmosphere.Visible; + buttonItemSH1.Checked = globeControl1.Globe.Atmosphere.Visible; + globeControl1.Refresh(); + } + /// + /// 经纬网 菜单 + /// + /// + /// + private void buttonItem20_Click(object sender, EventArgs e) + { + globeControl1.Globe.LatLonGrid.Visible = !globeControl1.Globe.LatLonGrid.Visible; + buttonItemSH3.Checked = globeControl1.Globe.LatLonGrid.Visible; + globeControl1.Globe.Refresh(); + } + /// + /// 状态条 菜单 + /// + /// + /// + private void buttonItem21_Click_1(object sender, EventArgs e) + { + globeControl1.Globe.StatusBar.Visible = !globeControl1.Globe.StatusBar.Visible; + buttonItemSH4.Checked = globeControl1.Globe.StatusBar.Visible; + globeControl1.Globe.Refresh(); + } + + + + /// + /// 添加指定路径下的数据 功能 + /// + /// + /// + 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); + //CheckDatasetGeoReference(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; + } + return objRes; + } + /// + /// 刷新目录树 功能 + /// + 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); + } + } + /// + /// 判断图层是否包含字段列表 + /// + /// + /// + 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; + } + + /// + /// 统计指定图层在指定范围内的所有feature对象 + /// + /// + /// + /// + 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; + } + /// + /// 碰撞分析功能界面中 选择管线复选框 选中状态改变事件处理 + /// + /// + /// + private void checkBoxX3_CheckedChanged(object sender, EventArgs e) + { + clearFeatureHighLight(); + if (checkBoxX3.Checked) + { + comboBoxEx2.SelectedItem = null; + 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; + } + } + /// + /// 碰撞分析功能界面中 选择图层复选框 选中状态改变事件处理 + /// + /// + /// + 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(); + } + /// + /// 碰撞分析功能界面中 选择图层下拉框 选中项改变事件处理 + /// + /// + /// + 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; + } + } + } + /// + /// 清除所有图层中的所有feature对象的高亮状态 功能 + /// + 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); + } + } + } + } + for (int i = 0; i < globeControl2.Globe.Layers.Count; i++) + { + GSOLayer layer = globeControl2.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; + } + } + } + + if (globeControl1.Globe.Action == EnumAction3D.SelectObject) + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + //globeControl1.Globe.Action = EnumAction3D.SelectObject; + } + } + + /// + /// 碰撞分析功能界面中 清除分析结果按钮 事件处理 + /// + /// + /// + 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(); + } + /// + /// 碰撞分析功能界面中 导出Excel按钮 事件处理 + /// + /// + /// + private void buttonX6_Click(object sender, EventArgs e) + { + if (dataGridViewX5.Rows.Count > 0) + { + ExportExcel("碰撞分析", dataGridViewX5, listBox2); + } + else + { + MessageBox.Show("表格内容为空!", "提示"); + } + } + /// + /// 导出CAD 菜单 + /// + /// + /// + private void btnExportCAD_Click(object sender, EventArgs e) + { + FrmExportCADS frm = new FrmExportCADS(globeControl1, m_PipelineLayerNames); + frm.ShowDialog(); + } + + ///// + ///// 区域分析 菜单 + ///// + ///// + ///// + //private void buttonItem50_Click(object sender, EventArgs e) + //{ + // buttonItem50.Checked = !buttonItem50.Checked; + // ribbonBarQY.Visible = buttonItem50.Checked; + // ribbonBarQY.Location = new Point(0, 0); + //} + + + /// + /// 连接数据库 菜单事件处理 + /// + /// + /// + 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; + } + } + } + /// + /// 数据验证 菜单 + /// + /// + /// + private void buttonItem80_Click(object sender, EventArgs e) + { + FrmValiData frm = new FrmValiData(globeControl1); + frm.ShowDialog(); + } + /// + /// 根据指定图层创建图层节点并将节点添加到图层管理节点的子节点集合中 + /// + /// + 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; + + if (!layerManagerNode.Nodes.Contains(node)) + { + layerManagerNode.Nodes.Insert(0, node); + layerManagerNode.Expand(); + } + } + } + /// + /// 数据库备份 菜单 + /// + /// + /// + 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(); + } + } + } + + + + #region Fan 去掉 + //GSOFeature emitterFeature; // 粒子要素 + /// + /// 添加火苗 功能 + /// + /// + /// + /// + 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); + + } + /// + /// 添加喷泉 功能 + /// + /// + /// + /// + 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); + } + #endregion + + /// + /// 获取指定图层中最后一个feature对象的名称对应的整数 + /// + /// + /// + 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; + } + /// + /// 设置除指定标注图层之外的所有标注图层不可见 + /// + /// + 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; + } + } + } + } + } + + /// + /// 判断选中的对象是否为管线 + /// + /// 被选中管线 + /// 返回一根线 + 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; + } + + /// + /// 获取指定两点组成的线的长度 功能 + /// + /// + /// + /// + 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; + } + + /// + /// 图层节点树中 节点 右键单击事件处理 + /// + /// + /// + 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; + } + } + } + } + } + + /// + /// 标注管理、传感器管理 图层目录树的右键菜单中的 刷新列表 菜单 + /// + /// + /// + 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); + } + } + /// + /// 给指定的图层节点添加代表feature对象的子节点 + /// + /// + private void RefreshTreeNodeLayerFeatureList(TreeNode layerTreeNode) + { + layerTreeNode.Nodes.Clear(); + GSOLayer layer = (GSOLayer)layerTreeNode.Tag; + // 只将类型为内存数据集的图层列出,如果是其它类型的数据集可能数据量太大,没发显示在树控件中 + if (layer.Dataset is GSOFeatureDataset) + { + VisitFeature3Ds(layer.GetAllFeatures(), layerTreeNode); + } + } + + /// + /// 标注管理、传感器管理 图层目录树的右键菜单中的 移除所有 菜单 + /// + /// + /// + 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(); + } + } + + /// + /// 图层目录树的 节点对应的复选框选中状态改变事件处理 + /// + /// + /// + private void layerMarkerTree_AfterCheck(object sender, TreeViewEventArgs e) + { + if (e.Action != TreeViewAction.Unknown) + { + CheckTreeNode(e.Node, e.Node.Checked); + } + } + /// + /// 改变指定节点对应的复选框的选中状态 + /// + /// + /// + private void CheckTreeNode(TreeNode node, Boolean bChecked) + { + CheckChildTreeNode(node, bChecked); + globeControl1.Globe.Refresh(); + } + /// + /// 改变指定节点的子节点对应的复选框的选中状态 + /// + /// + /// + 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); + } + } + /// + /// 标注管理、传感器管理 目录树中的feature节点的右键菜单中的 删除 菜单 + /// + /// + /// + 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(); + } + } + + /// + /// 双屏对比 菜单 + /// + /// + /// + //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(); + // } + //} + /// + /// 模拟分析 菜单 + /// + /// + /// + //private void buttonItem51_Click(object sender, EventArgs e) + //{ + // buttonItem51.Checked = !buttonItem51.Checked; + // ribbonBarMN.Visible = buttonItem51.Checked; + // ribbonBarMN.Location = new Point(0, 0); + //} + + /// + /// 双屏设置 菜单 + /// + /// + /// + //private void buttonItem96_Click(object sender, EventArgs e) + //{ + // FrmLayerControl frm = new FrmLayerControl(layerTree,globeControl1,globeControl2); + // frm.Show(this); + //} + /// + /// 双屏联动 菜单 + /// + /// + /// + //private void buttonItem95_Click(object sender, EventArgs e) + //{ + // buttonItem95.Checked = !buttonItem95.Checked; + //} + ///// + /// 添加用户仓库 菜单 + /// + /// + /// + private void buttonItem108_Click(object sender, EventArgs e) + { + FrmUserRepo frm = new FrmUserRepo(-1); + frm.ShowDialog(); + } + /// + /// 用户仓库管理 菜单 + /// + /// + /// + private void buttonItem111_Click(object sender, EventArgs e) + { + FrmUserRepoMgr frm = new FrmUserRepoMgr(); + frm.ShowDialog(); + } + /// + /// 添加分系统 菜单 + /// + /// + /// + private void buttonItem112_Click(object sender, EventArgs e) + { + //FrmAPP frm = new FrmAPP(-1); + //frm.ShowDialog(); + } + /// + /// 分系统管理 菜单 + /// + /// + /// + private void buttonItem113_Click(object sender, EventArgs e) + { + //FrmAPPMgr frm = new FrmAPPMgr(); + //frm.ShowDialog(); + } + /// + /// 添加操作 菜单 + /// + /// + /// + private void buttonItem114_Click(object sender, EventArgs e) + { + FrmOper frm = new FrmOper(-1); + frm.ShowDialog(); + } + /// + /// 操作管理 菜单 + /// + /// + /// + private void buttonItem115_Click(object sender, EventArgs e) + { + FrmOperMgr frm = new FrmOperMgr(); + frm.ShowDialog(); + } + /// + /// 添加资源 菜单 + /// + /// + /// + private void buttonItem116_Click(object sender, EventArgs e) + { + FrmRESC frm = new FrmRESC(-1); + frm.ShowDialog(); + } + /// + /// 资源管理 菜单 + /// + /// + /// + private void buttonItem117_Click(object sender, EventArgs e) + { + FrmRESCMgr frm = new FrmRESCMgr(); + frm.ShowDialog(); + } + /// + /// 添加权限 菜单 + /// + /// + /// + private void buttonItem118_Click(object sender, EventArgs e) + { + FrmPerm frm = new FrmPerm(-1); + frm.ShowDialog(); + } + /// + /// 权限管理 菜单 + /// + /// + /// + private void buttonItem119_Click(object sender, EventArgs e) + { + FrmPermMgr frm = new FrmPermMgr(); + frm.ShowDialog(); + } + /// + /// 添加访问控制 菜单 + /// + /// + /// + private void buttonItem120_Click(object sender, EventArgs e) + { + FrmAccess frm = new FrmAccess(-1); + frm.ShowDialog(); + } + /// + /// 访问控制管理 菜单 + /// + /// + /// + private void buttonItem121_Click(object sender, EventArgs e) + { + FrmAccessMgr frm = new FrmAccessMgr(); + frm.ShowDialog(); + } + /// + /// 部门类型管理 菜单 + /// + /// + /// + private void buttonItem122_Click(object sender, EventArgs e) + { + FrmRegionTypeMgr frm = new FrmRegionTypeMgr(); + frm.ShowDialog(); + } + /// + /// 添加用户 菜单 + /// + /// + /// + private void buttonItem127_Click(object sender, EventArgs e) + { + FrmUserAdd frm = new FrmUserAdd(-1); + frm.ShowDialog(); + } + /// + /// 用户信息管理 菜单 + /// + /// + /// + private void buttonItem128_Click_1(object sender, EventArgs e) + { + FrmUserManager frm = new FrmUserManager(); + frm.ShowDialog(); + } + /// + /// 添加角色 菜单 + /// + /// + /// + private void 添加角色_Click(object sender, EventArgs e) + { + FrmRole frm = new FrmRole(-1); + frm.ShowDialog(); + } + /// + /// 所有角色管理 菜单 + /// + /// + /// + private void 角色管理_Click(object sender, EventArgs e) + { + FrmRoleMgr frm = new FrmRoleMgr(); + frm.ShowDialog(); + } + + /// + /// 部门角色管理 菜单 + /// + /// + /// + private void buttonItem133_Click(object sender, EventArgs e) + { + FrmRegionRoleMgr frm = new FrmRegionRoleMgr(); + frm.ShowDialog(); + } + /// + /// 部门管理 菜单 + /// + /// + /// + private void buttonItem130_Click(object sender, EventArgs e) + { + FrmRegionMgr frm = new FrmRegionMgr(); + frm.ShowDialog(); + } + + /// + /// 日志管理 菜单 + /// + /// + /// + private void buttonItem135_Click(object sender, EventArgs e) + { + FrmLogManager frm = new FrmLogManager(); + frm.ShowDialog(); + } + /// + /// 传感器信息查询 菜单 + /// + /// + /// + 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); + } + } + } + /// + /// 根据指定的图层的caption属性的值在配置文件中查找对应的数据库中的表的名称 + /// + /// 图层的caption属性的值 + /// 对应的数据库中的表的名称 + 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; + } + /// + /// 根据数据库中的表的名称 查找对应的表中的字段名称的集合 + /// + /// 数据库中的表的名称 + /// 对应的表中的字段名称的集合 + 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; + } + + /// + /// 历史曲线查询 菜单 + /// + /// + /// + 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; + /// + /// 传感器在线报警 菜单 + /// + /// + /// + 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); + } + /// + /// 传感器报警 功能中的 定时器 的触发事件处理 + /// + /// + /// + 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; + } + } + } + } + } + } + } + + + /// + /// 沿线运动 菜单 + /// + /// + /// + private void buttonItem138_Click(object sender, EventArgs e) + { + if (globeControl1.Globe.SelectedObject == null) + { + MessageBox.Show("请先选择一条线!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + return; + } + + GSOFeature lineFeature = globeControl1.Globe.SelectedObject; + if (lineFeature.Geometry == null || lineFeature.Geometry.Type != EnumGeometryType.GeoPolyline3D) + { + MessageBox.Show("请先选择一条线!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + return; + } + + OpenFileDialog dlg = new OpenFileDialog(); + dlg.Filter = "*.gcm;*.3ds|*.gcm;*.3ds|*.3ds|*.3ds|*.gcm|*.gcm"; + if (dlg.ShowDialog() == DialogResult.OK) + { + GSOGeoModel model = new GSOGeoModel(); + model.FilePath = dlg.FileName; + + GSOGeoDynamicRoute dynamicRoute = new GSOGeoDynamicRoute(); + dynamicRoute.ActorGeometry = model; + + GSORoute route = new GSORoute(); + GSOGeoPolyline3D geoline = (GSOGeoPolyline3D)lineFeature.Geometry; + for (int i = 0; i < geoline[0].Count; i++) + { + route.Add(geoline[0][i]); + } + route.CircleRoute = false; + route.Speed = 30; + route.RotateSpeed = 50; + route.AltitudeMode = geoline.AltitudeMode; + dynamicRoute.Route = route; + + GSOFeature feature = new GSOFeature(); + + dynamicRoute.Play(); + feature.Geometry = dynamicRoute; + + //GSOLabel gsoLabel = new GSOLabel(); + //gsoLabel.Text = "模型测试"; + //feature.Label = gsoLabel; + globeControl1.Globe.MinModelVisibleSize = 0; + + globeControl1.Globe.MemoryLayer.AddFeature(feature); + globeControl1.Globe.Refresh(); + } + } + /// + /// 回退 菜单 + /// + /// + /// + private void buttonItem99_Click(object sender, EventArgs e) + { + globeControl1.Globe.UnDoEdit(); + } + /// + /// 前进 菜单 + /// + /// + /// + private void buttonItem100_Click(object sender, EventArgs e) + { + globeControl1.Globe.ReDoEdit(); + } + /// + /// 水平净距 功能界面中的 标签内容改变事件处理 + /// + /// + /// + 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() + "米的管线有:"; + } + } + } + /// + /// 垂直净距 功能界面中的 标签内容改变事件处理 + /// + /// + /// + 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() + "米的管线有:"; + } + } + } + /// + /// 覆土分析 功能界面中的 标签内容改变事件处理 + /// + /// + /// + 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() + "米的管线有:"; + } + } + } + + /// + /// 传感器分类查询 全区域 菜单 + /// + /// + /// + private void buttonItemSensor全区域查询_Click(object sender, EventArgs e) + { + FrmAccessoriesSensor.ShowForm(globeControl1, instrumenLayerNames, 0); + } + /// + /// 传感器分类查询 绘制区域 菜单 + /// + /// + /// + private void buttonItemSensor绘制区域查询_Click(object sender, EventArgs e) + { + FrmAccessoriesSensor.ShowForm(globeControl1, instrumenLayerNames, 1); + } + + + /// + /// 碰撞分析 功能界面中 关闭按钮 事件处理 + /// + /// + /// + 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(); + } + /// + /// 覆土分析 功能界面中的 清除分析结果 按钮事件处理 + /// + /// + /// + 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(); + } + /// + /// 数字预处理 功能 + /// + /// + /// + private void 数字预处理buttonItem140_Click(object sender, EventArgs e) + { + FrmEditShapeFile frm = new FrmEditShapeFile(globeControl1); + frm.ShowDialog(this); + } + + + /// + /// 导出矢量 功能 将图层导出为kml和shp格式数据 + /// + /// + /// + private void 导出矢量buttonItem140_Click(object sender, EventArgs e) + { + List listVectorNames = new List(); + for (int i = 0; i < m_PipelineLayerNames.Count; i++) + { + 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 = ""; + /// + /// 绘制城市七线 功能按钮 + /// + /// + /// + 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; + } + } + } + /// + /// 七线审核 功能按钮 + /// + /// + /// + private void 七线审核buttonItem141_Click(object sender, EventArgs e) + { + FrmCityServerLineAnalysis frm = new FrmCityServerLineAnalysis(globeControl1, m_PipelineLayerNames); + frm.ShowDialog(this); + } + + /// + /// 间距分析 开始分析按钮 分析绘制的七线和管线的距离是否符合标准 + /// + /// + /// + 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; + } + /// + /// 间距分析 清除分析结果 + /// + /// + /// + 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(); + } + /// + /// 间距分析 导出Excel按钮 将间距分析的结果以Excel表格的形式导出 + /// + /// + /// + private void buttonExportExcel_Click(object sender, EventArgs e) + { + if (dataGridViewAnalysisResult.Rows.Count > 0) + { + ExportExcel("间距分析", dataGridViewAnalysisResult, listBoxStasticsResult); + } + else + { + MessageBox.Show("表格内容为空!", "提示"); + } + } + /// + /// 间距分析 关闭按钮 + /// + /// + /// + 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(); + } + /// + /// 间距分析 分析结果表格双击定位 + /// + /// + /// + 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); + } + } + } + } + /// + /// 间距分析 选择管线复选框 + /// + /// + /// + private void checkBoxSelectPipeline_CheckedChanged(object sender, EventArgs e) + { + clearFeatureHighLight();//清除高亮 + if (checkBoxSelectPipeline.Checked) + { + comboBoxLayer.SelectedItem = null; + 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; + } + } + /// + /// 间距分析 选择图层复选框 + /// + /// + /// + 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(); + } + /// + /// 间距分析 选择图层下拉框 + /// + /// + /// + 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; + } + } + } + + + + /// + /// 管线自动缩进 菜单 + /// + /// + /// + private void 管线自动缩进buttonItem140_Click(object sender, EventArgs e) + { + FrmPipelineIndented frm = new FrmPipelineIndented(globeControl1, m_PipelineLayerNames, workwellLayerNames); + 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 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); + // } + //} + + /// + /// 统计指定图层在指定范围内的所有feature对象 + /// + /// + /// + /// + 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) + { + 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 setLayerVisible(string layerName) + { + GSOLayer templayer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + if (templayer != null) + { + templayer.Visible = false; + } + globeControl1.Globe.Refresh(); + } + + /// + /// 连接数据库 + /// + /// + /// + private void buttonItem129_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL4_1.Text); + + FrmDatabaseParaSetting2 frm = new FrmDatabaseParaSetting2(globeControl1); + if (frm.ShowDialog() == DialogResult.OK) + { + ds = FrmDatabaseParaSetting2.ds; + if (ds != null) + { + ds.IsCloseSaved = false; + } + } + } + + /// + /// 一键审核---导入数据 + /// + /// + /// + private void buttonItem127_Click_2(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, "打开数据"); + + try + { + //if (shds == null) + //{ + //没连的话,直接连接审核库; //审核库配置读配置文件 + string dbIp = Utility.sgdbip; + string database = Utility.sgdbname; + string user = Utility.sgdbuser; + string pass = Utility.sgdbpwd; + /* + 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; + //} + } + catch (Exception ex) + { + LogError.PublishError(ex); + MessageBox.Show("内存过载请清理内存,并重新启动规划分析!", "提示"); + return; + } + + } + + /// + ///自动导出图片 + /// + /// + /// + private void buttonItem130_Click_1(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, "导出审核图"); + + 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))); + */ + + int mapWidth = 0; + int mapHeight = 0; + Point pt = getUpperLeftPoint(pt1, pt2, out mapWidth, out mapHeight); + int rightBottomX = pt.X + mapWidth; + int rightBottomY = pt.Y + mapHeight; + Image myImg = new Bitmap(mapWidth, mapHeight); + Graphics g = Graphics.FromImage(myImg); + g.CopyFromScreen(pt, new Point(0, 0), new Size(rightBottomX, rightBottomY)); + + 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; + } + } + } + /// + /// 一键审核功能 + ///
+ /// + /// + private void buttonItem128_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItem128.Text); + //垂直净距标准 + + frmSh = new FrmYJSHTC(globeControl1, globeControl2,layerTree); + + if (frmSh.ShowDialog() == DialogResult.OK) + { + frmWait = new FrmWait("一键审核……"); + frmWait.Location = new Point(this.Width - frmWait.Width - 10, this.Height - frmWait.Height - 50); + frmWait.Owner = this; + frmWait.Show(); + Thread thread = new Thread(new ThreadStart(doWork)); + thread.IsBackground = true; + thread.Start(); + } + } + + void doWork() + { + FrmShResult frmShResult = null; + + double dVerticalJingJuBiaoZhun = 1, dHorizontalJingJuBiaoZhun = 1; + if (frmSh.rukuLayer != null) + { + #region + this.Invoke((EventHandler)delegate + { + try + { + List managerLayerList = new List(); + for (int i = 0; i < layerManagerNode.Nodes.Count; i++) + { + managerLayerList.Add(layerManagerNode.Nodes[i].Text); + } + if (!managerLayerList.Contains(frmSh.rukuLayer.Caption)) + { + TreeNode node = new TreeNode(); + node.Tag = frmSh.rukuLayer; + node.Text = frmSh.rukuLayer.Dataset.Caption; + node.ImageIndex = 0; + node.SelectedImageIndex = 0; + node.Checked = frmSh.rukuLayer.Visible; + layerManagerNode.Nodes.Insert(0, node); + layerManagerNode.Expand(); + } + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "提示"); + } + }); + #endregion + + shlayername = frmSh.rukuLayer.Name; + globeControl1.Refresh(); + } + + if (frmShResult != null && !frmShResult.IsDisposed) + { + try + { + clearFeatureHighLight(); + ClearRedlineAnalyseResult(); + frmShResult.Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message); + } + } + + 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.analysis(); + + //MainFrm窗体显示控制,回到一键审核Tab + this.Invoke((EventHandler)delegate + { + frmShResult.Show(); + frmWait.Close(); + //将tab页恢复到一键审核 + ribbonTabItem11.Checked = true; + try + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + //zhanshi = false; + splitContainer1.Panel2Collapsed = true; + + panelOfTable.Visible = false; + legendSC.Visible = false; + legendSG.Visible = false; + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + } + catch (Exception ex) + { + MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + + }); + + boolfrmShResult = true; + } + else + { + + } + } + + + /// + /// 清除渲染结果 + /// + 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(); + } + /// + /// 已审核的图层 + /// + /// + /// + private void buttonItem132_Click_1(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItem132.Text); + + if (shds == null) + { + //没连的话,直接连接审核库; //审核库配置读配置文件 + string dbIp = Utility.sgdbip; + string database = Utility.sgdbname; + string user = Utility.sgdbuser; + string pass = Utility.sgdbpwd; + + /* + 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; + //} + + } + /// + /// 审核入库 + /// + /// + /// + private void buttonItem133_Click_1(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, "审核入库"); + FrmShRK frmShrk = new FrmShRK(globeControl1); + frmShrk.Show(); + } + /// + /// 模拟设计修改 + /// + /// + /// + private void buttonItem134_Click_1(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, "模拟设计修改"); + + 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 + { + + } + + } + + + /// + /// 绘制垂线 + /// + /// + /// + 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); + } + /// + /// 比较两个点是否是同一个点 + /// + /// + /// + /// + 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; + } + /// + /// 获得点到线的垂线距离及垂点 + /// + /// + /// + /// + /// + 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); + 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]; + } + /// + /// 获得斜率 + /// + /// + /// + /// + /// + /// + /// + 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); + } + } + /// + /// 根据默认投影参数,经纬度转xyz + /// + /// + /// + /// + 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; + } + /// + /// 根据投影参数,经纬度转xyz + /// + /// + /// + /// + /// + 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; + } + /// + /// 根据默认投影参数,xyz转经纬度 + /// + /// + /// + /// + 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; + } + /// + /// 根据投影参数,Xyz转经纬度 + /// + /// + /// + /// + /// + 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; + } + /// + /// 获得inpolygon的管线长度 + /// + /// + 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; + } + + + /// + /// 一键审核中调节透明度 + /// + /// + /// + private void sliderItem1_ValueChanged(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.sliderItem1.Text); + + globeControl1.Globe.GroundOpaque = 100 - sliderItem1.Value; + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(roadLayerName);//("180fd"); + if (layer != null) + { + layer.Opaque = 100 - sliderItem1.Value; + } + + optiValue = sliderItem1.Value; + } + /// + /// 红线审核中的透明度分析 + /// + /// + /// + private void sliderItem3_ValueChanged(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.sliderItem3.Text); + + globeControl1.Globe.GroundOpaque = 100 - sliderItem3.Value; + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(roadLayerName);//("180fd"); + if (layer != null) + { + layer.Opaque = 100 - sliderItem3.Value; + } + optiValue = sliderItem3.Value; + } + + #region yanxiaowei + //初始化DataGridViewX1控件 + public delegate void DataGridViewDelegate(DataTable dt, string strLable, string strLayer, bool initDataGrid); + /// + /// 代理函数,操作DatgridViewX1 + /// + /// + /// + public void InitDataGridViewX1(DataTable dt, string strLable, string strLayer, bool initDataGrid) + { + if (initDataGrid == true) + { + dataGridViewX1.DataSource = dt; + panelOfTable.Visible = true; + toolStripNumbers.Text = strLable; + dataGridViewX1.Tag = strLayer; + } + else + { + dataGridViewX1.DataSource = null; + dataGridViewX1.Refresh(); + panelOfTable.Visible = false; + toolStripNumbers.Text = ""; + dataGridViewX1.Tag = ""; + globeControl1.Globe.MemoryLayer.RemoveAllFeature();//清除双击产生的标注 + } + } + FrmAnalysisGuiHuaResult from; + /// + /// 主窗体下方属性表格 双击定位 功能 + /// + /// + /// + private void dataGridViewX1_MouseDoubleClick(object sender, MouseEventArgs e) + { + if (redSH == false) + { + 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 if (dataGridViewX1.Columns.Contains("标识器编号")) + { + featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["标识器编号"].Value.ToString(); + } + featureName = featureName.Trim(); + + GSOLayer layer = null; + layer = globeControl1.Globe.Layers.GetLayerByCaption(dataGridViewX1.Tag.ToString()); + + if (layer == null) return; + + GSOFeatures features = layer.GetFeatureByName(featureName, false); + if (features.Length == 0) return; + GSOFeature rowFeature = features[0]; + + ClassSearchAnalysis.AddMakerToLineFeature(globeControl1, rowFeature); + + } + } + } + else + { + if (e.Button == MouseButtons.Left) + { + if (from != null && !from.IsDisposed) + { + try + { + from.Close(); + } + catch (Exception ex) + { + LogError.PublishError(ex); + } + } + try + { + DataGridView.HitTestInfo hittestinfo = dataGridViewX1.HitTest(e.X, e.Y); + if (hittestinfo.RowIndex >= 0) + { + string layer = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["管线类型"].Value.ToString(); + string hxName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["红线编号"].Value.ToString(); + FrmAnalysisGuiHuaResult frm = new FrmAnalysisGuiHuaResult(globeControl1, lineStruct, featsList, + panelOfTable, dataGridViewX1, layer, hxName); + frm.Location = new Point(this.Width - frm.Width - 10, this.Height - frm.Height - 20); + frm.Show(this); + + from = frm; + } + } + catch (Exception ex) + { + LogError.PublishError(ex); + } + } + } + } + + /// + /// 空间查询 + /// + /// + /// + private void buttonItemSearch1_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemSearch1.Text); + + trackflag = "PipelineSpatialQuery"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; + + } + /// + /// 关键字查询 + /// + /// + /// + private void buttonItemSearch9_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch9.Text); + + FrmKeywordQuery.ShowForm(globeControl1, m_PipelineLayerNames, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 编号查询 + /// + /// + /// + private void buttonItemSearch2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch2.Text); + + FrmCodingQuery.ShowForm(globeControl1, m_PipelineLayerNames, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 坐标查询 + /// + /// + /// + private void buttonItemSearch3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch3.Text); + + FrmSetLatLonPos.ShowForm(globeControl1); + } + /// + /// 附属物查询 + /// + /// + /// + private void buttonItemSearch10_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch10.Text); + + FrmFittingQuery.ShowForm(globeControl1, instrumenLayerNames, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 管径查询 + /// + /// + /// + private void buttonItemSearch4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch4.Text); + + FrmDiameterQuery.ShowForm(globeControl1, m_PipelineLayerNames, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 材质查询 + /// + /// + /// + private void buttonItemSearch5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch5.Text); + + FrmMaterialSel.ShowForm(globeControl1, m_PipelineLayerNames, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 基本查询 + /// + /// + /// + private void buttonItemSearch6_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch6.Text); + + FrmBasicQuery.ShowForm(globeControl1, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 复合查询 + /// + /// + /// + private void buttonItemSearch7_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch7.Text); + + FrmQuerySQL.ShowForm(globeControl1, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 关联查询 + /// + /// + /// + private void buttonItemSearch8_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch8.Text); + + if (globeControl1.Globe.SelObjectCount != 1) + { + MessageBox.Show("请选中一个对象!", "提示"); + return; + } + + 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 || (feature.Geometry.Type == EnumGeometryType.GeoPolygon3D + || feature.Geometry.Type == EnumGeometryType.GeoWater)) + return; + else + { + ClassSearchAnalysis.ResultRelationAnalysis(globeControl1, feature, valueLayerNames, workwellLayerNames, + instrumenLayerNames, pipefittingLayerNames, m_PipelineLayerNames, valueAllowance); + } + } + } + #endregion + /// + /// 清除分析 + /// + /// + /// + private void buttonItemClear_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemClear.Text); + + globeControl1.Globe.ClearMeasure(); + layerTemp.RemoveAllFeature(); + layerTemp2.RemoveAllFeature(); + buttonItemLS5.Checked = false; + + dataGridViewX1.DataSource = null; + panelOfTable.Visible = false; + + 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); + + NetworkAnalysisTool.ClearAllTopAnalysis(this.globeControl1); + // 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();//清除所有坑 + + 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(); + } + } + + clearFeatureHighLight();//取消管线高亮 + + GSOLayer layerGround = globeControl1.Globe.Layers.GetLayerByCaption(roadLayerName);//("180fd"); + if (layerGround != null) + { + layerGround.Visible = true; + } + globeControl1.Refresh(); + globeControl2.Refresh(); + ClearRedlineAnalyseResult(); + globeControl1.Globe.Action = EnumAction3D.ActionNull; + } + /// + /// 管线长度全区域统计 + /// + /// + /// + private void buttonItemTJ1_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管线长度统计"); + + FrmAllPipelineStatis frm = new FrmAllPipelineStatis(globeControl1,null, new DataGridViewDelegate(InitDataGridViewX1), m_PipelineLayerNames); + frm.Show(this); + } + /// + /// 管线长度绘制区域统计 + /// + /// + /// + private void buttonItemTJ1_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管线长度统计"); + + trackflag = "PipelineDistanceStatistics"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; + } + /// + /// 阀门数量全区域统计 + /// + /// + /// + private void buttonItemTJ2_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "阀门数量统计"); + + FrmValveStatistics frm = new FrmValveStatistics(globeControl1, null, new DataGridViewDelegate(InitDataGridViewX1)); + frm.Show(this); + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + } + /// + /// 阀门数量绘制区域统计 + /// + /// + /// + private void buttonItemTJ2_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "阀门数量统计"); + + trackflag = "valvequery"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; + } + /// + /// 井盖数量全区域统计 + /// + /// + /// + private void buttonItemTJ3_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "井盖数量统计"); + FrmAllWorkWellStatis frm = new FrmAllWorkWellStatis(globeControl1, null, new DataGridViewDelegate(InitDataGridViewX1)); + frm.Show(this); + } + /// + /// 井盖数量绘制区域统计 + /// + /// + /// + private void buttonItemTJ3_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "井盖数量统计"); + + trackflag = "workwellquery"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; + } + /// + /// 管径分段统计全区域统计 + /// + /// + /// + private void buttonItemTJ4_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管径分段统计"); + + Frmpipediameterstatis.ShowForm(globeControl1, m_PipelineLayerNames, 0); + } + /// + /// 管径分段统计绘制区域统计 + /// + /// + /// + private void buttonItemTJ4_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管径分段统计"); + + trackflag = null; + Frmpipediameterstatis.ShowForm(globeControl1, m_PipelineLayerNames, 1); + } + /// + /// 埋深分段统计全区域统计 + /// + /// + /// + private void buttonItemTJ5_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "埋深分段统计"); + FrmpipeDeepstatis.ShowForm(globeControl1, m_PipelineLayerNames, 0); + } + /// + /// 埋深分段统计绘制区域统计 + /// + /// + /// + private void buttonItemTJ5_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "埋深分段统计"); + trackflag = null; + FrmpipeDeepstatis.ShowForm(globeControl1, m_PipelineLayerNames, 1); + } + /// + /// 管径分类统计全区域统计 + /// + /// + /// + private void buttonItemTJ6_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管径分类汇总"); + + FrmpipeDiametergather.ShowForm(globeControl1, m_PipelineLayerNames, 0); + } + /// + /// 管径分类统计绘制区域统计 + /// + /// + /// + private void buttonItemTJ6_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管径分类汇总"); + + trackflag = null; + FrmpipeDiametergather.ShowForm(globeControl1, m_PipelineLayerNames, 1); + } + /// + /// 材质分类统计全区域统计 + /// + /// + /// + private void buttonItemTJ7_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "材质分类汇总"); + + FrmpipeMaterialGather.ShowForm(globeControl1, m_PipelineLayerNames, 0); + } + /// + /// 材质分类统计绘制区域统计 + /// + /// + /// + private void buttonItemTJ7_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "材质分类汇总"); + + trackflag = null; + FrmpipeMaterialGather.ShowForm(globeControl1, m_PipelineLayerNames, 1); + } + /// + /// 附属物分类统计全区域统计 + /// + /// + /// + private void buttonItemTJ8_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "附属物分类汇总"); + + FrmAccessoriesgather.ShowForm(globeControl1, instrumenLayerNames, 0); + } + /// + /// 附属物分类统计绘制区域统计 + /// + /// + /// + private void buttonItemTJ8_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "附属物分类汇总"); + + trackflag = null; + FrmAccessoriesgather.ShowForm(globeControl1, instrumenLayerNames, 1); + } + /// + /// 碰撞分析 + /// + /// + /// + private void buttonItemFX1_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_4.Text); + + this.dataGridViewX4.Size = new System.Drawing.Size(195, 120); + 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(); + } + /// + /// 覆土分析 + /// + /// + /// + private void buttonItemFX1_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX5_1.Text); + this.dataGridViewX6.Size = new System.Drawing.Size(195, 120); + 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(); + } + /// + /// 间距分析 + /// + /// + /// + private void buttonItemFX1_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX1_3.Text); + + this.dataGridViewLineList.Size = new System.Drawing.Size(185, 120); + 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(); + } + /// + /// 垂直净距分析 + /// + /// + /// + private void buttonItemFX1_4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX1_4.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(); + } + /// + /// 水平净距分析 + /// + /// + /// + private void buttonItemFX1_5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_6.Text); + this.dataGridViewX8.Size = new System.Drawing.Size(185, 120); + 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(); + } + + #region Predaotr,断面分析 + /// + /// 横断面分析 + /// + /// + /// + private void buttonItemFX2_1_Click(object sender, EventArgs e) + { + globeControl1.Globe.Action = EnumAction3D.TrackPolyline; + globeControl1.Globe.TrackPolylineTool.VerticalLineVisible = true; + globeControl1.Globe.TrackPolylineTool.TrackMode = EnumTrackMode.SpaceTrack; + trackPolylineEndMode = EnumTrackPolylineEndMode.HDM_Analysis; + + } + /// + /// 纵断面分析 + /// + /// + /// + private void buttonItemFX2_2_Click(object sender, EventArgs e) + { + if (globeControl1.Globe.SelObjectCount<1) + { + MessageBox.Show("请选择一条或者多条管线!", "提示", MessageBoxButtons.OK, + MessageBoxIcon.Information); + return; + } + 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); + } + } + List feats = SectionAnalysisTool.ZDMAnalysis(selectFeatures); + if (feats != null && feats.Count >= 1) + { + FrmProfileAnalysis frm = new FrmProfileAnalysis(globeControl1, feats); + frm.Show(this); + } + } + /// + /// 道路断面分析 + /// + /// + /// + private void buttonItemFX2_3_Click(object sender, EventArgs e) + { + globeControl1.Globe.Action = EnumAction3D.TrackPolyline; + globeControl1.Globe.TrackPolylineTool.VerticalLineVisible = true; + globeControl1.Globe.TrackPolylineTool.TrackMode = EnumTrackMode.SpaceTrack; + trackPolylineEndMode = EnumTrackPolylineEndMode.DLDM_Analysis; + + } + /// + /// 基线剖面分析 + /// + /// + /// + private void buttonItemFX2_4_Click(object sender, EventArgs e) + { + globeControl1.Globe.Action = EnumAction3D.TrackPolyline; + globeControl1.Globe.TrackPolylineTool.VerticalLineVisible = true; + globeControl1.Globe.TrackPolylineTool.TrackMode = EnumTrackMode.SpaceTrack; + trackPolylineEndMode = EnumTrackPolylineEndMode.JXPM_Analysis; + + } + + #endregion + /// + /// 创建拓扑 + /// + /// + /// + private void buttonItemFX3_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX3_1.Text); + + FrmGenAndFaMenTopu frm = new FrmGenAndFaMenTopu(globeControl1, m_PipelineLayerNames, valueLayerNames); + frm.Show(this); + } + #region Predator :拓扑分析 + /// + /// 上游分析 + /// + /// + /// + private void buttonItemFX3_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX3_2.Text); + NetworkTraceUpDown(true); + } + /// + /// 下游分析 + /// + /// + /// + private void buttonItemFX3_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX3_3.Text); + NetworkTraceUpDown(false); + } + + /// + /// 上下游追踪 功能 + /// + /// + private void NetworkTraceUpDown(Boolean bTraceUp) + { + GSOFeature selLineFeature = globeControl1.Globe.SelectedObject; + if (selLineFeature == null || selLineFeature.Geometry == null || selLineFeature.Geometry.Type != EnumGeometryType.GeoPolyline3D) + { + MessageBox.Show("请点击“编辑”—“选中对象”选择一条线!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); + return; + } + GSOLayer selLayer = globeControl1.Globe.SelectedObjectLayer; + + NetworkAnalysisTool.TraceUpDownAnalysis(bTraceUp, + selLineFeature, selLayer); + } + + /// + /// 流向分析 + /// + /// + /// + private void buttonItemFX3_4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX3_4.Text); + + FrmFlow frm = new FrmFlow(globeControl1, m_PipelineLayerNames); + frm.Show(this); + } + /// + /// 关阀分析 + /// + /// + /// + private void buttonItemFX3_5_Click(object sender, EventArgs e) + { + if (globeControl1.Globe.SelObjectCount < 1) + { + MessageBox.Show("请选中至少一根管线!!"); + buttonItemFX3_5.Checked = false; + return; + } + GSOLayer resLayer = null; + GSOFeature resFeature = null; + globeControl1.Globe.GetSelectObject(0, out resFeature, out resLayer); + + String pipeLayerName = resLayer.Caption; + String pipeLayerNamePrefix = pipeLayerName.Substring(0, pipeLayerName.IndexOf("管线")); + GSOLayer valveLayer = globeControl1.Globe.Layers[pipeLayerNamePrefix + "阀门"]; + if (valveLayer == null) + { + MessageBox.Show("无" + pipeLayerNamePrefix+"阀门图层", "提示"); + return; + } + + GSOFeatures valveFeats = NetworkAnalysisTool.CloseValvesAnalysis(resFeature, + resLayer, valveLayer); + + if (valveFeats != null) + { + FrmCloseValves frm = new FrmCloseValves(this.globeControl1, valveFeats); + frm.Show(this); + } + else + { + MessageBox.Show("未找到关闭阀门"); + } + } + + /// + /// 连通分析 + /// + /// + /// + private void buttonItemFX3_6_Click(object sender, EventArgs e) + { + if (globeControl1.Globe.SelObjectCount < 2) + { + MessageBox.Show("请选中至少两个管线!!"); + buttonItemFX3_6.Checked = false; + return; + } + GSOFeature selFeat0, selFeat1; + GSOLayer layer0,layer1; + globeControl1.Globe.GetSelectObject(0, out selFeat0, out layer0); + globeControl1.Globe.GetSelectObject(1, out selFeat1, out layer1); + + if (!layer0.IsSameInnerObject(layer1)) + { + MessageBox.Show("不在同一个图层!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); + buttonItemFX3_6.Checked = false; + return; + } + NetworkAnalysisTool.ConnexityAnalysis(selFeat0, selFeat1, layer0); + } + /// + /// 爆管分析 + /// + /// + /// + private void buttonItemFX3_7_Click(object sender, EventArgs e) + { + NetworkTraceUpDown(true); //上游追踪: + + GSOFeature selLineFeature = globeControl1.Globe.SelectedObject; + if (selLineFeature == null || selLineFeature.Geometry == null || selLineFeature.Geometry.Type != EnumGeometryType.GeoPolyline3D) + { + MessageBox.Show("请点击“编辑”—“选中对象”选择一条线!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); + return; + } + GSOLayer selLayer = globeControl1.Globe.SelectedObjectLayer; + + NetworkAnalysisTool.ExplodeAnalysis(this.globeControl1,selLineFeature,selLayer); + + this.buttonItemFX3_5_Click(sender, e); //关阀分析: + + } + + #endregion + /// + /// 多边形开挖 + /// + /// + /// + private void buttonItemFX4_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_1.Text); + + trackflag = "pit"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; //是这个么?是的,在模型上 + } + /// + /// 挖方量分析 + /// + /// + /// + private void buttonItemFX4_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_2.Text); + + trackflag = "digFillAnalysis"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; + ActionToolMenuChecked(); + } + /// + /// 沿线开挖 + /// + /// + /// + private void buttonItemFX4_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_3.Text); + + if (!buttonItemFX4_3.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; + buttonItemFX4_3.Checked = true; + } + } + else + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + buttonItemFX4_3.Checked = false; + globeControl1.Globe.TrackPolylineTool.VerticalLineVisible = false; + } + ActionToolMenuChecked(); + } + /// + /// 创建隧道 + /// + /// + /// + private void buttonItemFX4_4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_4.Text); + + 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("场景中未加载隧道图层!", "提示"); + } + } + /// + /// 隐藏隧道 + /// + /// + /// + private void buttonItemFX4_5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_5.Text); + + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption("隧道"); + if (layer != null) + { + layer.Visible = !layer.Visible; + } + } + /// + /// 删除隧道 + /// + /// + /// + private void buttonItemFX4_6_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_6.Text); + + 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("请选中要删除的隧道!", "提示"); + } + } + /// + /// 通视分析 + /// + /// + /// + private void buttonItemFX5_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX5_1.Text); + + if (globeControl1.Globe.Action != EnumAction3D.VisibilityAnalysis) + { + //btnSpaceVisibilityAnalysis.Checked = true; + globeControl1.Globe.Action = EnumAction3D.VisibilityAnalysis; + } + else + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + // SetButtonChecked(); + } + } + /// + /// 可视域分析 + /// + /// + /// + private void buttonItemFX5_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX5_2.Text); + + globeControl1.Globe.Action = EnumAction3D.ViewshedAnalysis; + } + /// + /// 可视包络分析 + /// + /// + /// + private void buttonItemFX5_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX5_3.Text); + + globeControl1.Globe.Action = EnumAction3D.ViewEnvelopeAnalysis; + } + /// + /// 缓冲区分析 + /// + /// + /// + private void buttonItemFX6_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX6_1.Text); + + GSOFeature feat = globeControl1.Globe.SelectedObject; + if (feat == null) + { + MessageBox.Show("请选择要分析的要素!"); + return; + } + if (feat.Geometry.Type == EnumGeometryType.GeoPolyline3D) + { + GSOGeoPolyline3D line1 = feat.Geometry as GSOGeoPolyline3D; + if (line1 == null) + { + MessageBox.Show("请选择一条管线!"); + return; + } + + FrmBufferAnalysis frm = new FrmBufferAnalysis(globeControl1, line1, layerTemp); + frm.Show(this); + } + else + { + FrmBufferAnalysisBSQ frm = new FrmBufferAnalysisBSQ(globeControl1, layerTemp, bsqPT); + frm.Show(this); + } + + } + /// + /// 附属物分析 + /// + /// + /// + private void buttonItemFX6_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX6_2.Text); + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + FrmAccessoryAnalysis dlg = new FrmAccessoryAnalysis(globeControl1, layerTemp); + dlg.Show(this); + } + /// + /// 无源淹没分析 + /// + /// + /// + private void buttonItemFX6_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX6_3.Text); + + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + trackflag = "FloodAnalysis"; + } + /// + /// 水平距离 + /// + /// + /// + private void buttonItemLS1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS1.Text); + + globeControl1.Globe.Action = EnumAction3D.MeasureDistance; + globeControl1.Globe.DistanceRuler.SpaceMeasure = false; + buttonItemLS5.Checked = false; + } + /// + /// 垂直距离 + /// + /// + /// + private void buttonItemLS2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS2.Text); + + buttonItemLS5.Checked = false; + globeControl1.Globe.Action = EnumAction3D.MeasureHeight; + globeControl1.Globe.DistanceRuler.SpaceMeasure = false; + } + /// + /// 空间距离 + /// + /// + /// + private void buttonItemLS3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS3.Text); + + buttonItemLS5.Checked = false; + globeControl1.Globe.Action = EnumAction3D.MeasureDistance; + globeControl1.Globe.DistanceRuler.SpaceMeasure = true; + } + /// + /// 地表距离 + /// + /// + /// + private void buttonItemLS4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS4.Text); + + buttonItemLS5.Checked = false; + globeControl1.Globe.Action = EnumAction3D.MeasureDistance; + globeControl1.Globe.DistanceRuler.SpaceMeasure = false; + } + /// + /// 高度量算 + /// + /// + /// + private void buttonItemLS5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS5.Text); + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + buttonItemLS5.Checked = !buttonItemLS5.Checked; + if (buttonItemLS5.Checked) + { + globeControl1.Globe.Action = EnumAction3D.SelectObject; + } + } + /// + /// 水平面积 + /// + /// + /// + private void buttonItemLS6_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS6.Text); + + buttonItemLS5.Checked = false; + globeControl1.Globe.Action = EnumAction3D.MeasureArea; + globeControl1.Globe.AreaRuler.SpaceMeasure = true; + } + /// + /// 地表面积 + /// + /// + /// + private void buttonItemLS7_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS7.Text); + + buttonItemLS5.Checked = false; + globeControl1.Globe.Action = EnumAction3D.MeasureArea; + globeControl1.Globe.AreaRuler.SpaceMeasure = false; + + } + + # region Fan 重构标注代码 + /// + /// 标高标注 + /// + /// + /// + private void buttonItemSZ1_Click(object sender, EventArgs e) + { + GSOFeature resFeature = IsPipeLineOfSelectedObj(); + if (resFeature == null) + { + MessageBox.Show("请选中一根管线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + GSOGeoPolyline3D selLine = resFeature.Geometry as GSOGeoPolyline3D; + if (selLine[0].Count <= 1) + { + return; + } + + MarkTools.getInstance().showMarker(resFeature, + globeControl1, EnumMarkLayer.Mark_Altitude, ""); + } + /// + /// 管径标注 + /// + GSOFeature radiusMarkerFeature; + private void buttonItemBZ2_Click(object sender, EventArgs e) + { + GSOFeature resFeature = IsPipeLineOfSelectedObj(); + if (resFeature == null) + { + MessageBox.Show("请选中一根管线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + GSOGeoPolyline3D selLine = resFeature.Geometry as GSOGeoPolyline3D; + if (selLine[0].Count <= 1) + { + return; + } + + MarkTools.getInstance().showMarker(resFeature, + globeControl1, EnumMarkLayer.Mark_Diameter, ""); + } + /// + /// 埋深标注 + /// + /// + /// + private void buttonItemBZ3_Click(object sender, EventArgs e) + { + GSOFeature resFeature = IsPipeLineOfSelectedObj(); + if (resFeature == null) + { + MessageBox.Show("请选中一根管线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + GSOGeoPolyline3D selLine = resFeature.Geometry as GSOGeoPolyline3D; + if (selLine[0].Count <=1) + { + return; + } + + MarkTools.getInstance().showMarker(resFeature, + globeControl1, EnumMarkLayer.Mark_Depth, ""); + + } + /// + /// 坐标标注 + /// + /// + /// + private void buttonItemBZ4_Click(object sender, EventArgs e) + { + GSOFeature resFeature = IsPipeLineOfSelectedObj(); + if (resFeature == null) + { + MessageBox.Show("请选中一根管线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + GSOGeoPolyline3D selLine = resFeature.Geometry as GSOGeoPolyline3D; + if (selLine[0].Count <= 1) + { + return; + } + MarkTools.getInstance().showMarker(resFeature, + globeControl1, EnumMarkLayer.Mark_Location, ""); + } + /// + /// 距离标注 + /// + bool distanceMarker = false; + private void buttonItemBZ5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBZ5.Text); + + globeControl1.Globe.Action = EnumAction3D.TrackPolyline; + //globeControl1.Globe.DistanceRuler.MeasureMode = EnumDistanceMeasureMode.HVSLineMeasure; + distanceMarker = true; + } + /// + /// 自定义标注 + /// + /// + /// + private void buttonItemBZ6_Click(object sender, EventArgs e) + { + GSOFeature f = globeControl1.Globe.SelectedObject; + GSOLayer l = globeControl1.Globe.SelectedObjectLayer; + FrmCustomLabel frm = new FrmCustomLabel(globeControl1, l, f); + if (frm.ShowDialog() == DialogResult.OK) + { + MarkTools.getInstance().showMarker(f, globeControl1, EnumMarkLayer.Mark_Custom, frm.labelText); + } + } + /// + /// 扯旗标注 + /// + /// + /// + private void buttonItemBZ7_Click(object sender, EventArgs e) + { + GSOFeature f = globeControl1.Globe.SelectedObject; + GSOLayer l = globeControl1.Globe.SelectedObjectLayer; + FrmMarker frm = new FrmMarker(); + if (frm.ShowDialog() == DialogResult.OK) + { + MarkTools.getInstance().showMarker(f, globeControl1, EnumMarkLayer.Mark_Custom, frm.markerContent); + } + } + /// + /// 坡度标注 + /// + /// + /// + private void buttonItemBZ8_Click(object sender, EventArgs e) + { + GSOFeature resFeature = IsPipeLineOfSelectedObj(); + if (resFeature == null) + { + MessageBox.Show("请选中一根管线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + GSOGeoPolyline3D selLine = resFeature.Geometry as GSOGeoPolyline3D; + if (selLine[0].Count <= 1) + { + return; + } + + MarkTools.getInstance().showMarker(resFeature, + globeControl1, EnumMarkLayer.Mark_Slope, ""); + } + /// + /// 属性标注 + /// + /// + /// + private void buttonItemBZ9_Click(object sender, EventArgs e) + { + GSOFeature f = globeControl1.Globe.SelectedObject; + GSOLayer l = globeControl1.Globe.SelectedObjectLayer; + FrmPropertiesMarker frm = new FrmPropertiesMarker(globeControl1, l, f); + if (frm.ShowDialog() == DialogResult.OK) + { + MarkTools.getInstance().showMarker(f, globeControl1, EnumMarkLayer.Mark_Property, frm.labelText); + } + } + /// + /// 红线工具 + /// + /// + /// + private void buttonItemBZ10_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBZ10.Text); + 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; + } + } + /// + /// 标注管理 + /// + /// + /// + private void buttonItemBZ11_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBZ11.Text); + + buttonItemBZ11.Checked = !buttonItemBZ11.Checked; + 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 (buttonItemBZ11.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(); + } + } + + #endregion + /// + /// 飞行到目标点 + /// + /// + /// + private void buttonItemFXGJ1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFXGJ1.Text); + + FrmSetFlytoPos.ShowForm(globeControl1); + + } + /// + /// 自定义飞行 + /// + /// + /// + private void buttonItemFXGJ2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFXGJ2.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); + } + } + /// + /// 绕中心点飞行 + /// + /// + /// + private void buttonItemFXGJ3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFXGJ3.Text); + + globeControl1.Globe.FlyAroundCenter(10000, EnumFlyRepeatValueType.MiliSeconds); + globeControl1.Globe.CurFlyID = 1; + } + /// + /// 绕眼睛飞行 + /// + /// + /// + private void buttonItemFXGJ4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFXGJ4.Text); + + globeControl1.Globe.FlyAroundEye(720, EnumFlyRepeatValueType.Degrees); + globeControl1.Globe.CurFlyID = 2; + } + + /// + /// 权限管理 + /// + /// + /// + private void buttonItemXT1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT1.Text); + + FrmUserRoleMgr frm = new FrmUserRoleMgr(); + frm.ShowDialog(); + } + /// + /// 数据库管理 + /// + /// + /// + private void buttonItemXT2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT2.Text); + + //查看数据库列表 + FrmDbManager frm = new FrmDbManager(); + frm.ShowDialog(); + } + /// + /// 用户列表 + /// + /// + /// + private void buttonItemXT3_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT3_1.Text); + + FrmUserManager frm = new FrmUserManager(); + frm.ShowDialog(); + } + /// + /// 创建新用户 + /// + /// + /// + private void buttonItemXT3_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT3_2.Text); + + FrmUserAdd frm = new FrmUserAdd(-1); + frm.ShowDialog(); + } + /// + /// 人员修改 + /// + /// + /// + private void buttonItemXT4_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT4_2.Text); + + FrmAppUSER appUSER = new FrmAppUSER(); + appUSER.ShowDialog(); + } + /// + /// 增加人员 + /// + /// + /// + private void buttonItemXT4_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT4_1.Text); + + FrmAppUSERRESET appUSERRESET = new FrmAppUSERRESET(); + appUSERRESET.ShowDialog(); + } + /// + /// 统计数据 + /// + /// + /// + private void buttonItemZTT1_Click(object sender, EventArgs e) + { + ////日志记录 + //LogManager.saveLog(Utility.userName, this.buttonItemZTT1.Text); + + //PATM patm = new PATM(); + //patm.operation = "Statistic"; + //patm.Text = "统计专题图管理"; + //patm.ShowDialog(); + } + /// + /// 热点功能统计 + /// + /// + /// + private void buttonItemZTT2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT2.Text); + + FrmHotFuncStat frmhfs = new FrmHotFuncStat(); + frmhfs.ShowDialog(); + } + + private void buttonItemZTT3_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT3_1.Text); + + FrmAPP appfrm = new FrmAPP("专题图申请"); + appfrm.ShowDialog(); + } + + private void buttonItemZTT3_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT3_2.Text); + + FrmAPPFORASK appForask = new FrmAPPFORASK("专题图审核"); + appForask.ShowDialog(); + } + + private void buttonItemZTT3_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT3_3.Text); + + FrmAPPregion appregion = new FrmAPPregion("专题图审核"); + appregion.ShowDialog(); + } + + private void buttonItemZTT4_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT4_1.Text); + + FrmAPP appfrm = new FrmAPP("打印申请"); + appfrm.ShowDialog(); + } + + private void buttonItemZTT4_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT4_2.Text); + + FrmAPPFORASK appForask = new FrmAPPFORASK("打印审核"); + appForask.ShowDialog(); + } + + private void buttonItemZTT4_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT4_3.Text); + + FrmAPPregion appregion = new FrmAPPregion("打印审核"); + appregion.ShowDialog(); + } + + private void buttonItemZTT5_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT5_1.Text); + + FrmAPP appfrm = new FrmAPP("拷贝申请"); + appfrm.ShowDialog(); + } + + private void buttonItemZTT5_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT5_2.Text); + + FrmAPPFORASK appForask = new FrmAPPFORASK("拷贝审核"); + appForask.ShowDialog(); + } + + private void buttonItemZTT5_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT5_3.Text); + + FrmAPPregion appregion = new FrmAPPregion("拷贝审核"); + appregion.Show(); + } + + private int connectServerCount = 0; + + /// + /// 还原球到实测库 + /// + 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); + } + + if (layerManagerNode.Nodes.Count > 0) + { + for (int i = layerManagerNode.Nodes.Count - 1; i >= 0; i--) + { + layerManagerNode.Nodes[i].Remove(); + + } + } + + globeControl1.Refresh(); + + } + + private void buttonItemSPSZ_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSPSZ.Text); + + FrmLayerControl frm = new FrmLayerControl(layerTree, globeControl1, globeControl2); + frm.Show(this); + } + + /// + /// 碰撞审查 + /// + /// + /// + private void buttonItemSH1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSH1.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 buttonItemSH2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSH2.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 buttonItemSH3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSH3.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 buttonItemSH4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSH4.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 buttonItemSH5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSH5.Text); + FrmCityServerLineAnalysis frm = new FrmCityServerLineAnalysis(globeControl1, m_PipelineLayerNames); + frm.Show(this); + } + #region 数据管理-导入文件 + ///// + ///// 数据管理-导入本地坐标系文件 + ///// + ///// + ///// + //private void buttonItemSJGL1_1_Click(object sender, EventArgs e) + //{ + // //日志记录 + // LogManager.saveLog(Utility.userName, this.buttonItemSJGL1_1.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(); + // } + // } + //} + + ///// + ///// 数据管理-导入其他坐标系文件 + ///// + ///// + ///// + //private void buttonItemSJGL1_2_Click(object sender, EventArgs e) + //{ + // //日志记录 + // LogManager.saveLog(Utility.userName, this.buttonItemSJGL1_2.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(); + // } + // } + //} + #endregion + /// + /// 数据质量检查 + /// + /// + /// + private void buttonItemSJGL2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL2.Text); + FrmValiData frm = new FrmValiData(globeControl1); + frm.ShowDialog(); + } + /// + /// 数据预处理 + /// + /// + /// + private void buttonItemSJGL3_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL3.Text); + + FrmEditShapeFile frm = new FrmEditShapeFile(globeControl1); + frm.ShowDialog(this); + } + /// + /// 连接数据库 + /// + /// + /// + private void buttonItemSJGL4_1_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL4_1.Text); + + FrmDatabaseParaSetting frm = new FrmDatabaseParaSetting(globeControl1); + if (frm.ShowDialog() == DialogResult.OK) + { + ds = FrmDatabaseParaSetting.ds; + if (ds != null) + { + ds.IsCloseSaved = false; + } + } + } + /// + /// 管线入库 + /// + /// + /// + private void buttonItemSJGL4_2_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL4_2.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 buttonItemSJGL4_3_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL4_3.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 buttonItemSJGL5_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL5.Text); + + Cyberpipe.Forms.FrmProject frm = new Cyberpipe.Forms.FrmProject(); + frm.ShowDialog(); + } + /// + /// 元数据基本管理 + /// + /// + /// + private void buttonItemSJGL6_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL6_1.Text); + + FrmMetadata frmmd = new FrmMetadata(); + frmmd.ShowDialog(); + } + /// + /// 元数据查询管理 + /// + /// + /// + private void buttonItemSJGL6_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL6_2.Text); + + FrmMetadataStat frmmds = new FrmMetadataStat(); + //frmmds.Show(); + frmmds.ShowDialog(); + } + /// + /// 操作日志管理 + /// + /// + /// + private void buttonItemSJGL7_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL7.Text); + + FrmLogOper frmlo = new FrmLogOper(); + frmlo.ShowDialog(); + } + /// + /// 数据字典管理 + /// + /// + /// + private void buttonItemSJGL8_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL8.Text); + + FrmMDDictory frmmdd = new FrmMDDictory(); + frmmdd.ShowDialog(); + } + /// + /// 数据库备份 + /// + /// + /// + private void buttonItemSJGL9_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL9.Text); + + //新 + FrmBACKORACLE backOracle = new FrmBACKORACLE(); + backOracle.Show(); + } + /// + /// 创建管段 + /// + /// + /// + private void buttonItemBJ1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ1.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; + } + } + /// + /// 创建附属物 + /// + /// + /// + private void buttonItemBJ2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ2.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); + } + } + /// + /// 创建特征管点 + /// + /// + /// + private void buttonItemBJ3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ3.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); + } + } + /// + /// 绘制城市七线 + /// + /// + /// + private void buttonItemBJ4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ4.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; + } + } + } + /// + /// 选中对象 + /// + /// + /// + private void buttonItemBJ5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ5.Text); + + globeControl1.Globe.Action = EnumAction3D.SelectObject; + } + /// + /// 平移对象 + /// + /// + /// + private void buttonItemBJ6_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ6.Text); + + globeControl1.Globe.Action = EnumAction3D.MoveObject; + } + /// + /// 升降对象 + /// + /// + /// + private void buttonItemBJ7_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ7.Text); + + globeControl1.Globe.Action = EnumAction3D.ElevateObject; + } + /// + /// 旋转对象 + /// + /// + /// + private void buttonItemBJ8_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ8.Text); + + globeControl1.Globe.Action = EnumAction3D.RotateObject; + } + /// + /// 连接管段 + /// + /// + /// + private void buttonItemBJ9_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ9.Text); + + if (globeControl1.Globe.SelObjectCount < 2) + { + MessageBox.Show("对不起,请至少选中2个对象!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + return; + } + globeControl1.Globe.InsertJointPipeline(false); + } + /// + /// 后退 + /// + /// + /// + private void buttonItemBJ11_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemBJ11.Text); + globeControl1.Globe.UnDoEdit(); + } + /// + /// 前进 + /// + /// + /// + private void buttonItemBJ12_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemBJ12.Text); + + globeControl1.Globe.ReDoEdit(); + } + /// + /// 导出CAD + /// + /// + /// + private void buttonItemBJ10_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ10_1.Text); + + #region 导出成dxf格式 + List listVectorNames = new List(); + 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(); + #endregion + } + /// + /// 导出矢量 + /// + /// + /// + private void buttonItemBJ10_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ10_2.Text); + + List listVectorNames = new List(); + 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 buttonItemBJ13_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemBJ13.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(); + } + } + MessageBox.Show("删除成功!", "提示"); + } + else + { + MessageBox.Show("请选中要删除的模型!", "提示"); + } + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + } + + private void buttonItemHX1_1_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]; + string filePath = dlg.FileName; + string lastname = Path.GetFileName(filePath); + + 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(); + } + + } + } + } + + public struct LineStruct + { + public string layerName; + public string layerCode; + public string lineLength; + public string hxName; + } + + List lineStruct = new List(); + List featsList = new List(); + + /// + /// 红线审核 + /// + /// + /// + private void buttonItemHX2_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemHX2.Text); + redSH = true; + featsList.Clear(); + lineStruct.Clear(); + List listPipelineLayers = new List(); + + GSOLayer layer = null; + for (int i = 0; i < m_PipelineLayerNames.Count; i++) + { + layer = globeControl1.Globe.Layers.GetLayerByCaption(m_PipelineLayerNames[i]); + if (layer != null) + { + listPipelineLayers.Add(layer); + } + } + //yanxiaowei 重构 + GSOFeatures selectFeatures=new GSOFeatures(); + for (int i = 0; i < globeControl1.Globe.SelObjectCount; i++) + { + GSOFeature feature = null; + globeControl1.Globe.GetSelectObject(i, out feature, out layer); + selectFeatures.Add(feature); + } + DataTable table=new DataTable(); + + ClassGSOTool.CalculateRedLineResult(out table, redSH, selectFeatures, globeControl1, + listPipelineLayers,out lineStruct, out featsList); + + if (table.Rows.Count != 0) + AddDatagridView(table); + else + { + MessageBox.Show("没有侵入地块红线的管线数据!", "提示"); + dataGridViewX1.DataSource = null; + panelOfTable.Visible = false; + return; + } + } + + private void AddDatagridView(DataTable table) + { + dataGridViewX1.DataSource = table; + panelOfTable.Visible = true; + panelOfTable.Height = 200; + toolStripNumbers.Text = "红线审核 |共有:" + table.Rows.Count + "条"; + toolStripDropDownButton3.Visible = true; + } + /// + /// 主窗体 下方的工具条中的 导出.xls文件 按钮事件处理 + /// + /// + /// + private void toolStripDropDownButton3_Click(object sender, EventArgs e) + { + if (dataGridViewX1.Rows.Count == 0) + { + MessageBox.Show("表格内容为空!", "提示"); + return; + } + + string strSaveFile = string.Empty; + SaveFileDialog savefiledialog = new SaveFileDialog(); + savefiledialog.Filter = "Excel文件|*.xls,*.xlsx"; + savefiledialog.AddExtension = true; + savefiledialog.FileName = "红线审核"; + if (savefiledialog.ShowDialog() == DialogResult.OK) + strSaveFile = savefiledialog.FileName; + else return; + + ExpEXCEL.ExpToExcel(dataGridViewX1, strSaveFile, "红线审核", lineStruct, featsList); + MessageBox.Show("导出成功!"); + } + /// + /// 去除集合中重复的管线 + /// + /// + /// + /// + private GSOFeatures getFeaturesByFilter(GSOFeatures features, string fieldName) + { + if (features == null) + { + return null; + } + GSOFeatures featuresGet = new GSOFeatures(); + for (int i = 0; i < features.Length; i++) + { + GSOFeature featureFromFS = features[i]; + string fieldValueFromFS = featureFromFS.GetValue(fieldName).ToString().Trim(); + bool isHas = false; + for (int j = featuresGet.Length - 1; j >= 0; j--) + { + GSOFeature featureFromFSGet = featuresGet[j]; + string fieldValueFromFSGet = featureFromFSGet.GetValue(fieldName).ToString().Trim(); + if (fieldValueFromFS.Equals(fieldValueFromFSGet)) + { + isHas = true; + break; + } + } + if (isHas == false) + { + featuresGet.Add(featureFromFS.Clone()); + } + } + return featuresGet; + } + + private void sliderItem2_ValueChanged(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.sliderItem2.Text); + + globeControl1.Globe.GroundOpaque = 100 - sliderItem2.Value; + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(roadLayerName);//("180fd"); + if (layer != null) + { + layer.Opaque = 100 - sliderItem2.Value; + } + layer = globeControl2.Globe.Layers.GetLayerByCaption("180fd");//("180fd"); + if (layer != null) + { + layer.Opaque = 100 - sliderItem2.Value; + } + globeControl2.Globe.GroundOpaque = 100 - sliderItem2.Value; + + optiValue = sliderItem2.Value; + } + /// + /// 数据管理导入文件 + /// + /// + /// + private void buttonItemSJGL1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL1.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.Multiselect = true; + if (dlg.ShowDialog() == DialogResult.OK) + { + //自定义lprj文件名,从程序中复制一lprj文件。 + string filePath = dlg.FileName; + string lastname = Path.GetFileName(filePath); + + 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, 100); + + globeControl1.Refresh(); + } + } + } + + private void buttonItemHX1_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemHX1.Text); + + GSODataSource dataSpace = globeControl1.Globe.DataManager.OpenOracleDataSource(Utility.DBServer.Trim() + "/" + Utility.dbdatabase.Trim(), "", "", Utility.userID, Utility.DBPassword); + string filepath = ""; + //日志记录 + OpenFileDialog dlg = new OpenFileDialog(); + dlg.Filter = "矢量数据(*.shp)|*.shp|矢量数据(*.lgd)|*.lgd|CAD数据(*.dxf)|*.dxf|全部支持格式(*.lgd,*.shp,*.dxf)|*.lgd;*.shp;*.dxf;"; + dlg.Multiselect = true; + + #region 临时图层显示 + if (dlg.ShowDialog() == DialogResult.OK) + { + string filePath = dlg.FileName; + string lastname = Path.GetFileName(filePath); + + #region + for (int i = 0; i < dlg.FileNames.Length; i++) + { + string strDataPath = dlg.FileNames[i]; + filepath = strDataPath; + + GSOLayer layer = globeControl1.Globe.Layers.Add(strDataPath); + GSOFeatures RedFeatures = layer.GetAllFeatures(); + + 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(); + RedFeatures = features; + 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; + } + + /////////////////////////////////////////////////////////////////////////////////////////// + globeControl1.Globe.Layers.MoveTo(0, globeControl1.Globe.Layers.Count - 1); + globeControl1.Refresh(); + } + + IModelBuilder modelBuilder = new RedLineBuilder(); + + modelBuilder.batchInsert(dataSpace, redDt, RedFeatures); + + } + #endregion + + } + #endregion + } + /// + /// 定位 + /// + /// + /// + private void buttonItemLocation_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemLocation.Text); + + FrmFlyToPosition fly = new FrmFlyToPosition(globeControl1,globeControl2); + fly.Show(this); + } + /// + /// 2015-10-17演示代码 红线审核 + /// + /// + /// + private void ribbonTabItem6_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.FlyToPosition(new GSOPoint3d(120.610963, 31.188121, 50), EnumAltitudeMode.Absolute, -4, 50, 800); + globeControl1.Globe.FlyToPointSpeed = 10000000; + globeControl1.Globe.Action = EnumAction3D.SelectObject; + globeControl1.Refresh(); + + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + + //zhanshi = false; + redSH = true; + splitContainer1.Panel2Collapsed = true; + legendSG.Visible = false; + legendSC.Visible = false; + ClearGZData(); + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = true; + } + + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 基础工具 + /// + /// + /// + private void ribbonTabItem1_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + //zhanshi = false; + redSH = false; + splitContainer1.Panel2Collapsed = true; + panelOfTable.Visible = false; + legendSC.Visible = false; + legendSG.Visible = false; + ClearGZData(); + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + + + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 一键审核 + /// + /// + /// + private void ribbonTabItem11_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + //zhanshi = false; + redSH = false; + splitContainer1.Panel2Collapsed = true; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + panelOfTable.Visible = false; + legendSC.Visible = false; + legendSG.Visible = false; + ClearGZData(); + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + + + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 右屏添加冰箱数据 + /// + void AddDataToGlobeControl2() + { + + bool modelDataBool = false; + for (int i = globeControl2.Globe.Layers.Count - 1; i >= 0; i--) + { + GSOLayer layer = globeControl2.Globe.Layers[i]; + if (layer.Name.Contains("fttp:")) + { + modelDataBool = true; + break; + } + } + + if (modelDataBool == false) + { + GSOLayer ly = globeControl1.Globe.Layers.GetLayerByCaption("天地图地图"); + globeControl2.Globe.Layers.Add(ly); + } + else + { + return; + } + } + /// + /// 双屏对比 + /// + /// + /// + private void ribbonTabItem9_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent += new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent += new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + panelOfTable.Visible = false; + + splitContainer1.Panel2Collapsed = false; + //zhanshi = true; + redSH = false; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + sliderItem2.Value = 100 - globeControl1.Globe.GroundOpaque; + globeControl2.Globe.GroundOpaque = globeControl1.Globe.GroundOpaque; + legendSC.Visible = true; + legendSG.Visible = true; + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + AddDataToGlobeControl2(); + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 文档管理 + /// + /// + /// + private void ribbonTabItem4_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + panelOfTable.Visible = false; + //zhanshi = false; + redSH = false; + splitContainer1.Panel2Collapsed = true; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + legendSC.Visible = false; + legendSG.Visible = false; + ClearGZData(); + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 基础管理 + /// + /// + /// + private void ribbonTabItem14_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + panelOfTable.Visible = false; + //zhanshi = false; + redSH = false; + splitContainer1.Panel2Collapsed = true; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + legendSC.Visible = false; + legendSG.Visible = false; + ClearGZData(); + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 权限管理 + /// + /// + /// + private void ribbonTabItem2_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + panelOfTable.Visible = false; + //zhanshi = false; + redSH = false; + splitContainer1.Panel2Collapsed = true; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + legendSC.Visible = false; + legendSG.Visible = false; + ClearGZData(); + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + GSOFeature dpFeatuer = null; + /// + /// 双屏分析,点击管段分析 + /// + /// + /// + private void buttonItem8_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItem8.Text); + + //FrmCompareFeature frmCompareFeature = new FrmCompareFeature(globeControl1, globeControl2, layerTemp, layerTemp2,m_PipelineLayerNames,sgPipeLayersNames); + int width = this.Width; + FrmCompareFeature.ShowForm(globeControl1, globeControl2, layerTemp, layerTemp2, m_PipelineLayerNames, sgPipeLayersNames,width); + //frmCompareFeature.Location = new Point((this.Width - frmCompareFeature.Width)/2,50); + //frmCompareFeature.Show(this); + + } + /// + /// 红线审核导出图片 + /// + /// + /// + private void buttonItemDCTP_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemDCTP.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))); + */ + int mapWidth = 0; + int mapHeight = 0; + Point pt = getUpperLeftPoint(pt1, pt2, out mapWidth, out mapHeight); + int rightBottomX = pt.X + mapWidth; + int rightBottomY = pt.Y + mapHeight; + Image myImg = new Bitmap(mapWidth, mapHeight); + Graphics g = Graphics.FromImage(myImg); + g.CopyFromScreen(pt, new Point(0, 0), new Size(rightBottomX, rightBottomY)); + + 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; + } + } + } + /// + /// 标识器全区域统计 + /// + /// + /// + private void 标识器分类统计ToolStripMenuItem_Click(object sender, EventArgs e) + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + FrmBSQStatis bsqStatis = new FrmBSQStatis(); + bsqStatis.Show(this); + } + /// + /// 标识器绘制区域统计 + /// + /// + /// + private void 标识器分类统计ToolStripMenuItem1_Click(object sender, EventArgs e) + { + trackflag = "BSQDuoBianXiangStatis"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + } + + #region 保存和加载审核库加载的图层 + /* + private void saveLayerList(TreeNodeCollection treeNodeList) + { + string configPath = Application.StartupPath + "\\configLayerList.xml"; + try + { + XmlDocument doc = new XmlDocument(); + doc.Load(configPath); + XmlNode dbParams = doc.SelectSingleNode("Params/dbparams"); + XmlNode dbLayers = doc.SelectSingleNode("Params/dblayers"); + XmlNode layers = doc.SelectSingleNode("Params/layers"); + dbParams.RemoveAll(); + dbLayers.RemoveAll(); + layers.RemoveAll(); + + List listDS = new List(); + String shDatasourceName = Utility.sgdbip + "/" + Utility.sgdbname + "_" + Utility.sgdbuser; + bool flag = false; + + for (int i = 0; i < globeControl1.Globe.DataManager.DataSourceCount; i++) + { + GSODataSource ds = globeControl1.Globe.DataManager.GetDataSourceAt(i); + if (ds != null && ds.Type == EnumDataSourceType.SqlServer || ds.Type == EnumDataSourceType.Oracle) + { + if (ds.Name == shDatasourceName) + { + //防止因为多次连接同一个数据库 + if (flag == true) + { + break; + } + flag = true; + listDS.Add(ds); + GSODataSourceCnn conn = ds.GetConnectionInfo(); + + XmlElement dbparam = doc.CreateElement("shdbparam"); + XmlElement ip = doc.CreateElement("ship"); + ip.InnerText = conn.Server; + + XmlElement dbname = doc.CreateElement("shdbname"); + dbname.InnerText = conn.Database; + + XmlElement username = doc.CreateElement("shusername"); + username.InnerText = conn.User; + + XmlElement password = doc.CreateElement("shpassword"); + password.InnerText = conn.Password; + + XmlElement type = doc.CreateElement("shtype"); + if (ds.Type == EnumDataSourceType.SqlServer) + { + type.InnerText = "sqlserver"; + } + else + { + type.InnerText = "oracle"; + } + + dbparam.AppendChild(ip); + dbparam.AppendChild(dbname); + dbparam.AppendChild(username); + dbparam.AppendChild(password); + dbparam.AppendChild(type); + dbParams.AppendChild(dbparam); + } + + } + } + + for (int i = 0; i < treeNodeList.Count; i++) + { + GSOLayer layer = treeNodeList[i].Tag as GSOLayer; + if (Path.GetExtension(layer.Name) == "") + { + XmlElement dbLayer = doc.CreateElement("dblayer"); + XmlAttribute attri = doc.CreateAttribute("dbindex"); + for (int j = 0; j < listDS.Count; j++) + { + if (layer.Dataset.DataSource.Name == listDS[j].Name) + { + attri.Value = j.ToString(); + break; + } + } + dbLayer.Attributes.Append(attri); + dbLayer.InnerText = layer.Name; + + dbLayers.AppendChild(dbLayer); + } + else + { + XmlElement dbLayer = doc.CreateElement("layer"); + dbLayer.InnerText = layer.Name; + layers.AppendChild(dbLayer); + } + } + + doc.Save(configPath); + } + catch (Exception e) + { + + } + } + + private void openLayerList() + { + layerManagerNode.Nodes.Clear(); + + string configPath = Application.StartupPath + "\\configLayerList.xml"; + try + { + XmlDocument doc = new XmlDocument(); + doc.Load(configPath); + XmlNode dbParams = doc.SelectSingleNode("Params/dbparams"); + XmlNode dbLayers = doc.SelectSingleNode("Params/dblayers"); + XmlNode layers = doc.SelectSingleNode("Params/layers"); + + List listDS = new List(); + for (int i = 0; i < dbParams.ChildNodes.Count; i++) + { + string ip = ""; + string dbname = ""; + string username = ""; + string password = ""; + string type = ""; + XmlNode node = dbParams.ChildNodes.Item(i); + for (int j = 0; j < node.ChildNodes.Count; j++) + { + XmlNode nodeChild = node.ChildNodes.Item(j); + + if (nodeChild != null && nodeChild.Name == "ship") + { + ip = nodeChild.InnerText; + } + else if (nodeChild != null && nodeChild.Name == "shdbname") + { + dbname = nodeChild.InnerText; + } + else if (nodeChild != null && nodeChild.Name == "shusername") + { + username = nodeChild.InnerText; + } + else if (nodeChild != null && nodeChild.Name == "shpassword") + { + password = nodeChild.InnerText; + } + else if (nodeChild != null && nodeChild.Name == "shtype") + { + type = nodeChild.InnerText; + } + } + + if (type == "sqlserver") + { + GSODataSource ds = globeControl1.Globe.DataManager.OpenSqlServerDataSource(ip, "", dbname, username, password); + listDS.Add(ds); + } + else if (type == "oracle") + { + GSODataSource ds = globeControl1.Globe.DataManager.OpenOracleDataSource(ip + "/" + dbname, "", "", username, password); + listDS.Add(ds); + } + } + + for (int i = 0; i < dbLayers.ChildNodes.Count; i++) + { + XmlNode node = dbLayers.ChildNodes.Item(i); + if (node != null) + { + string layerName = node.InnerText; + XmlAttribute attri = node.Attributes["dbindex"]; + if (attri != null) + { + int dbIndex = -1; + if (int.TryParse(attri.Value, out dbIndex)) + { + GSODataset dataset = listDS[dbIndex].GetDatasetByName(layerName); + globeControl1.Globe.Layers.Add(dataset); + //更新树节点 + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + TreeNode layerNode = new TreeNode(); + layerNode.Tag = layer; + layerNode.Text = layer.Dataset.Caption; + layerNode.ImageIndex = 0; + layerNode.SelectedImageIndex = 0; + layerNode.Checked = layer.Visible; + layerManagerNode.Nodes.Insert(0, layerNode); + // layerManagerNode.Expand(); + + + } + } + } + } + for (int i = 0; i < layers.ChildNodes.Count; i++) + { + XmlNode node = layers.ChildNodes.Item(i); + if (node != null) + { + string layerName = node.InnerText; + globeControl1.Globe.Layers.Add(layerName); + + //更新树节点 + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + TreeNode layerNode = new TreeNode(); + layerNode.Tag = layer; + layerNode.Text = layer.Dataset.Caption; + layerNode.ImageIndex = 0; + layerNode.SelectedImageIndex = 0; + layerNode.Checked = layer.Visible; + layerManagerNode.Nodes.Insert(0, layerNode); + } + } + layerManagerNode.Expand(); + } + catch (Exception e) + { + + } + } + * */ + #endregion + + private void btn_check_history_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_check_history.Text); + + if (FrmCheckHistory.isOpen == true) + { + return; + } + FrmCheckHistory frm = new FrmCheckHistory(globeControl1, globeControl2); + frm.addNode += new AddNodeToLayerManagerNode(addNodeToLayerManagerNode); + frm.Show(); + + } + + private void buttonItem查看数据_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItem查看数据.Text); + + FrmThreeOracle tr = new FrmThreeOracle(globeControl1); + + if (tr.ShowDialog() == DialogResult.OK) + { + addNodeToLayerManagerNode(tr.rukuLayer); + globeControl1.Refresh(); + } + } + /// + /// 规划数据入库 + /// + /// + /// + private void buttonItemGHRK_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemGHRK.Text); + + FrmGHRK ghrk = new FrmGHRK(globeControl1, layerManagerNode); + ghrk.Show(this); + } + + private void btn_user_info_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_user_info.Text); + + if (!FrmSysUserInfoManger.IS_OPEN) + { + FrmSysUserInfoManger frm = new FrmSysUserInfoManger(); + frm.ShowDialog(); + } + } + + private void btn_role_info_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_role_info.Text); + + if (FrmRoleInfoManager.IS_OPEN) + { + return; + } + FrmRoleInfoManager frm = new FrmRoleInfoManager(); + frm.ShowDialog(); + } + + private void btn_resc_info_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_resc_info.Text); + + if (!SysRescInfoManager.IS_OPEN) + { + SysRescInfoManager frm = new SysRescInfoManager(); + frm.ShowDialog(); + } + } + + private void btn_role_resc_Click(object sender, EventArgs e) + { + + LogManager.saveLog(Utility.userName, this.btn_role_resc.Text); + + if (!FrmRoleRescManager.IS_OPEN) + { + FrmRoleRescManager frm = new FrmRoleRescManager(); + frm.ShowDialog(); + } + } + + private void btn_user_role_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_user_role.Text); + + if (FrmUserRole.IS_OPEN) + { + return; + } + FrmUserRole frm = new FrmUserRole(); + frm.ShowDialog(); + } + + private void btn_document_info_Click(object sender, EventArgs e) + { + + LogManager.saveLog(Utility.userName, this.btn_document_info.Text); + + //if (FormDocumentManager.IS_OPEN) + //{ + // return; + //} + //FormDocumentManager frm = new FormDocumentManager(); + //frm.ShowDialog(); + + //if (FormDocumentManager.IS_OPEN) + //{ + // return; + //} + //new FormDocumentManager().ShowDialog(); + if (FormDocumentManager.IS_OPEN) + { + return; + } + this.Cursor = Cursors.WaitCursor; + FormDocumentManager frm = new FormDocumentManager(); + frm.changeCursor += new ChangeCursor(changeCursorToDefault); + frm.ShowDialog(); + + } + + private void changeCursorToDefault() + { + this.Cursor = Cursors.Default; + } + + /// + /// 判断CAD文件是否有投影信息 + /// + /// + /// + Boolean CheckDatasetGeoReference(GSODataset dataset) + { + Boolean bSuccess = false; + if (dataset.GeoReferenceType == EnumGeoReferenceType.Flat) + { + if (MessageBox.Show("数据没有空间参考信息,请设置空间参考信息!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation) == DialogResult.OK) + { + String strPath = Path.GetDirectoryName(Application.ExecutablePath) + "\\Coordinate Systems"; + OpenFileDialog dlg = new OpenFileDialog(); + + dlg.InitialDirectory = strPath; + dlg.RestoreDirectory = true; + + dlg.Filter = "投影文件|*.prj||"; + if (dlg.ShowDialog() == DialogResult.OK) + { + bSuccess = dataset.LoadProjectionFromESRIFile(dlg.FileName); + } + } + } + else + { + return true; + } + return bSuccess; + } + + private void buttonItemexp_CAD_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemexp_CAD.Text); + + OpenFileDialog dlg = new OpenFileDialog(); + dlg.Filter = "支持格式(*.dwg)|*.dwg"; + dlg.Multiselect = true; + if (dlg.ShowDialog() == DialogResult.OK) + { + for (int i = 0; i < dlg.FileNames.Length; i++) + { + //this.Cursor = Cursors.WaitCursor; + string strDataPath = dlg.FileNames[i]; + + #region + //string strDataPathPrj = strDataPath.ToLower().Replace(".dwg", ".lprj"); + + //if (File.Exists(strDataPathPrj) == false) + //{ + // if (MessageBox.Show("数据没有空间参考信息,请设置空间参考信息!", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation) == DialogResult.OK) + // { + // String strPath = Application.StartupPath + "\\Coordinate Systems"; + // OpenFileDialog dlgPrj = new OpenFileDialog(); + // dlgPrj.InitialDirectory = strPath; + // dlgPrj.RestoreDirectory = true; + // dlgPrj.Multiselect = false; + // dlg.Filter = "投影文件|*.prj"; + // if (dlg.ShowDialog() == DialogResult.OK) + // { + // this.Cursor = Cursors.WaitCursor; + // string proj4 = GSODataEngineUtility.ConvertEsriPrjFileToProj4(dlg.FileName); + // using (StreamWriter stream = new StreamWriter(strDataPathPrj, false)) + // { + // stream.WriteLine("0prj4" + proj4 + ""); + // } + // AddLayerData(strDataPath); + // //globeControl1.Globe.Layers.Add(strDataPath); + + // this.Cursor = Cursors.Default; + // } + // else + // { + // AddLayerData(strDataPath); + // //globeControl1.Globe.Layers.Add(strDataPath); + // } + // } + // else + // { + // AddLayerData(strDataPath); + // //globeControl1.Globe.Layers.Add(strDataPath); + // } + + //} + //else + //{ + // //globeControl1.Globe.Layers.Add(strDataPath); + // AddLayerData(strDataPath); + //} + #endregion + AddLayerData(strDataPath); + //this.Cursor = Cursors.Default; + } + } + + 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, 100); + + globeControl1.Refresh(); + } + } + + private void btn_password_edit_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_password_edit.Text); + + if (FrmChangePassword.IS_OPEN) + { + return; + } + FrmChangePassword frm = new FrmChangePassword(); + frm.ShowDialog(); + } + /// + /// 多孔管线入库 + /// + /// + /// + private void buttonItem9_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL4_2.Text); + + if (ds == null) + { + MessageBox.Show("请先连接数据库", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + ConnectDB(null, null); + } + if (ds == null) + return; + + FrmMultiPipelineModelDB frm = new FrmMultiPipelineModelDB(globeControl1, ds); + if (frm.ShowDialog() == DialogResult.OK) + { + addNodeToLayerManagerNode(frm.rukuLayer); + } + //frm.Show(); + } + private void 导出CADToolStripMenuItem1_Click(object sender, EventArgs e) + { + TreeNode node = layerNodeContexMenu.Tag as TreeNode; + if (node == null) + { + MessageBox.Show("请在左侧节点集中选择要导出的图层", "提示"); + return; + } + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(node.Text.Trim()); + if (layer == null || layer.GetAllFeatures().Length <= 0) + { + MessageBox.Show("要导出的图层为空", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + return; + } + string strProjectName = Utility.projectStr; + if (strProjectName != "") + { + SaveFileDialog dlg = new SaveFileDialog(); + dlg.Filter = "*.dwg|*.dwg|*.dxf|*.dxf"; + dlg.FileName = layer.Caption; + if (dlg.ShowDialog(this) == DialogResult.OK) + { + globeControl1.Globe.MemoryLayer.SaveAs(dlg.FileName); + GSOLayer newlayer = globeControl1.Globe.Layers.Add(dlg.FileName); + newlayer.RemoveAllFeature(); + int featureCount = layer.GetAllFeatures().Length; + for (int i = 0; i < featureCount; i++) + { + GSOFeature feature = layer.GetAt(i); + if (feature != null && feature.Geometry != null) + { + if (feature.Geometry.Type == EnumGeometryType.GeoPolyline3D) + { + feature.Geometry.Style = new GSOSimpleLineStyle3D(); + } + else if (feature.Geometry.Type == EnumGeometryType.GeoPolygon3D) + { + feature.Geometry.Style = new GSOSimplePolygonStyle3D(); + } + newlayer.AddFeature(feature); + } + } + newlayer.Save(); + newlayer.Dataset.DataSource.RemoveDataset(newlayer.Dataset); + globeControl1.Globe.Layers.Remove(newlayer); + MessageBox.Show("导出CAD完成!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + } + } + } + + private void buttonItemGBJC_Click(object sender, EventArgs e) + { + FrmGBJC gb = new FrmGBJC(globeControl1, globeControl2, layerTemp, layerTemp2); + gb.Show(this); + } + + #region 右屏管纵数据控制 + private void 五十米主干道ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = true; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + + private void 三十六米次干道ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = true; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + + private void 四十二米次干道ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = true; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + + private void 二十四米一块板ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = true; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + + private void 二十四米三块板ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = true; + } + + private void 二十四米停车带ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = true; + lendendGZ24_3.Visible = false; + } + + private void 二十六米大堤路ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = true; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + + private void 清除管纵数据ToolStripMenuItem_Click(object sender, EventArgs e) + { + ClearGZData(); + } + + private void ClearGZData() + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + #endregion + + private void buttonItemPasswordReset_Click(object sender, EventArgs e) + { + Frm_password_reset reset = new Frm_password_reset(); + reset.Show(); + } + + private void pictureBox1_Paint(object sender, PaintEventArgs e) + { + int Width = this.Width; + string welcomeUser = "欢迎您:" + Utility.userName; + Graphics g = e.Graphics; + g.DrawString(welcomeUser, new Font("宋体", 12), new SolidBrush(Color.Black), Width - 180, 50); + } + + } +} \ No newline at end of file diff --git a/MainFrm.cs.REMOTE.9016.cs b/MainFrm.cs.REMOTE.9016.cs new file mode 100644 index 0000000..9bfb70e --- /dev/null +++ b/MainFrm.cs.REMOTE.9016.cs @@ -0,0 +1,13345 @@ +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; + + GSOBalloon featureTooltip2; + GSOBalloonEx balloonEx2; + + GSOLayer layerTemp; + GSOLayer layerTemp2; + FrmShResult frmShResult = null; + FrmRedlineResult frmredResult = null; + FrmMnModify frmModify = null; + public bool frmRedlineResult = false; + public bool boolfrmShResult = false; + public bool boolfrmModify = false; + + List m_PipelineLayerNames = new List();//线图层名称 + List workwellLayerNames = new List();//工井图层名称 + List valueLayerNames = new List();//阀门图层名称 + List instrumenLayerNames = new List();//附属物图层名称 + List pipefittingLayerNames = new List();//管件图层名称 + List sgPipeLayersNames = new List();//施工管线图层名称 + 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 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; + public string redLayer = null; + //GSOLayer redLayer1 = null; + bool redSH = false; + string redDt = "红线"; + //双屏对比 + //bool zhanshi=false; + Thread t = null; + private GSOHudButton legendSC;//定义图例 + private GSOHudButton legendSG;//定义图例 + //管纵图 + private GSOHudButton lendendGZ50; + private GSOHudButton lendendGZ36; + private GSOHudButton lendendGZ42; + private GSOHudButton lendendGZ24_1; + private GSOHudButton lendendGZ24_2; + private GSOHudButton lendendGZ24_3; + private GSOHudButton lendendGZ26; + + GSOGeoPoint3D bsqPT; + + FrmYJSHTC frmSh = null;//一键审核窗口全局变量wxl + FrmWait frmWait = null;//一键审核等待窗口 + //FrmWait frmWait2 = null;//文档操作等待窗口 + + float mouseDownX1,mouseDownY1; + float mouseDownX2,mouseDownY2; + /// + /// + /// + 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; + + featureTooltip2 = new GSOBalloon(globeControl2.Handle); + balloonEx2 = new GSOBalloonEx(globeControl2.Handle); + Utility.SetBallons(featureTooltip, balloonEx); + + panelOfTable.Height = 200; + + RigthMenuSet(); + + MenuSet(); + + } + /// + /// 右屏中添加管纵图片 + /// + private void AddGZ() + { + + lendendGZ50 = new GSOHudButton(); + lendendGZ50.SetImage(Application.StartupPath + "/Resource/管纵/50.png"); + lendendGZ50.SetOffset(0, 0); + lendendGZ50.MinOpaque = 1; + lendendGZ50.MaxOpaque = 1; + lendendGZ50.FadeOut = false; + lendendGZ50.Name = "lendendGZ50"; + lendendGZ50.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ50); + lendendGZ50.Visible = false; + + lendendGZ36 = new GSOHudButton(); + lendendGZ36.SetImage(Application.StartupPath + "/Resource/管纵/36.png"); + lendendGZ36.SetOffset(0, 0); + lendendGZ36.MinOpaque = 1; + lendendGZ36.MaxOpaque = 1; + lendendGZ36.FadeOut = false; + lendendGZ36.Name = "lendendGZ36"; + lendendGZ36.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ36); + lendendGZ36.Visible = false; + + lendendGZ42 = new GSOHudButton(); + lendendGZ42.SetImage(Application.StartupPath + "/Resource/管纵/42.png"); + lendendGZ42.SetOffset(0, 0); + lendendGZ42.MinOpaque = 1; + lendendGZ42.MaxOpaque = 1; + lendendGZ42.FadeOut = false; + lendendGZ42.Name = "lendendGZ42"; + lendendGZ42.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ42); + lendendGZ42.Visible = false; + + lendendGZ24_1 = new GSOHudButton(); + lendendGZ24_1.SetImage(Application.StartupPath + "/Resource/管纵/24_1.png"); + lendendGZ24_1.SetOffset(0, 0); + lendendGZ24_1.MinOpaque = 1; + lendendGZ24_1.MaxOpaque = 1; + lendendGZ24_1.FadeOut = false; + lendendGZ24_1.Name = "lendendGZ24_1"; + lendendGZ24_1.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ24_1); + lendendGZ24_1.Visible = false; + + lendendGZ24_2 = new GSOHudButton(); + lendendGZ24_2.SetImage(Application.StartupPath + "/Resource/管纵/24_2.png"); + lendendGZ24_2.SetOffset(0, 0); + lendendGZ24_2.MinOpaque = 1; + lendendGZ24_2.MaxOpaque = 1; + lendendGZ24_2.FadeOut = false; + lendendGZ24_2.Name = "lendendGZ24_2"; + lendendGZ24_2.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ24_2); + lendendGZ24_2.Visible = false; + + lendendGZ24_3 = new GSOHudButton(); + lendendGZ24_3.SetImage(Application.StartupPath + "/Resource/管纵/24_3.png"); + lendendGZ24_3.SetOffset(0, 0); + lendendGZ24_3.MinOpaque = 1; + lendendGZ24_3.MaxOpaque = 1; + lendendGZ24_3.FadeOut = false; + lendendGZ24_3.Name = "lendendGZ24_3"; + lendendGZ24_3.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ24_3); + lendendGZ24_3.Visible = false; + + lendendGZ26 = new GSOHudButton(); + lendendGZ26.SetImage(Application.StartupPath + "/Resource/管纵/26.png"); + lendendGZ26.SetOffset(0, 0); + lendendGZ26.MinOpaque = 1; + lendendGZ26.MaxOpaque = 1; + lendendGZ26.FadeOut = false; + lendendGZ26.Name = "lendendGZ26"; + lendendGZ26.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ26); + lendendGZ26.Visible = false; + + } + + public void RigthMenuSet() + { + if (Utility.userRole.IndexOf("清除分析") < 0) + { + toolRightMenu.Items.Remove(清除分析ToolStripMenuItem); + } + + #region 区域分析 + if (Utility.userRole.IndexOf("区域分析") < 0) + { + toolRightMenu.Items.Remove(区域分析ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("缓冲区分析") < 0) + { + 区域分析ToolStripMenuItem.DropDownItems.Remove(缓冲区分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("附属物分析") < 0) + { + 区域分析ToolStripMenuItem.DropDownItems.Remove(附属物分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("无源淹没分析") < 0) + { + 区域分析ToolStripMenuItem.DropDownItems.Remove(无源淹没分析ToolStripMenuItem); + } + } + #endregion + + #region 视域分析 + if (Utility.userRole.IndexOf("视域分析") < 0) + { + toolRightMenu.Items.Remove(视域分析ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("通视分析") < 0) + { + 视域分析ToolStripMenuItem.DropDownItems.Remove(通视分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("可视域分析") < 0) + { + 视域分析ToolStripMenuItem.DropDownItems.Remove(可视域分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("可视包络分析") < 0) + { + 视域分析ToolStripMenuItem.DropDownItems.Remove(可视包络分析ToolStripMenuItem); + } + } + #endregion + + #region 开发分析 + if (Utility.userRole.IndexOf("开挖分析") < 0) + { + toolRightMenu.Items.Remove(开挖分析ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("多边形开挖") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(多边形开挖ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("挖方量分析") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(挖方量分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("沿线开挖") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(沿线开挖ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("创建隧道") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(创建隧道ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("隐藏隧道") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(隐藏隧道ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("删除隧道") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(删除隧道ToolStripMenuItem); + } + } + #endregion + + #region 拓扑分析 + if (Utility.userRole.IndexOf("拓扑分析") < 0) + { + toolRightMenu.Items.Remove(拓扑分析ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("创建拓扑") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(创建拓扑ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("上游分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(上游分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("下游分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(下游分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("流向分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(流向分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("关阀分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(关阀分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("连通分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(连通分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("爆管分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(爆管分析ToolStripMenuItem); + } + } + #endregion + + #region 断面分析 + if (Utility.userRole.IndexOf("断面分析") < 0) + { + toolRightMenu.Items.Remove(断面分析ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("横断面分析") < 0) + { + 断面分析ToolStripMenuItem.DropDownItems.Remove(横断面分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("纵断面分析") < 0) + { + 断面分析ToolStripMenuItem.DropDownItems.Remove(纵断面分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("道路断面分析") < 0) + { + 断面分析ToolStripMenuItem.DropDownItems.Remove(道路断面分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("基线剖面分析") < 0) + { + 断面分析ToolStripMenuItem.DropDownItems.Remove(基线剖面分析ToolStripMenuItem); + } + } + #endregion + + #region 绘制区域统计 + if (Utility.userRole.IndexOf("绘制区域统计") < 0) + { + toolRightMenu.Items.Remove(绘制区域统计ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("绘制区域管线长度统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管线长度统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域阀门数量统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(阀门数量统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域井盖数量统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(井盖数量统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域管径分段统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管径分段统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域埋深分段统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(埋深分段统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域管径分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管径分类统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域材质分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(材质分类统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域附属物分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(附属物分类统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域标识器分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(标识器分类统计ToolStripMenuItem1); + } + + } + #endregion + + #region 全区域统计 + if (Utility.userRole.IndexOf("全区域统计") < 0) + { + toolRightMenu.Items.Remove(全区域统计ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("全区域管线长度统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管线长度统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域阀门数量统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(阀门数量统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域井盖数量统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(井盖数量统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域管径分段统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管径分段统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域埋深分段统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(埋深分段统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域管径分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管径分类统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域材质分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(材质分类统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域附属物分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(附属物分类统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域标识器分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(标识器分类统计ToolStripMenuItem); + } + + } + #endregion + + #region 查询 + if (Utility.userRole.IndexOf("查询") < 0) + { + toolRightMenu.Items.Remove(查询ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("空间查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(空间查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("编号查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(编号查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("坐标查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(坐标查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("管径查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(管径查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("材质查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(材质查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("基本查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(基本查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("复合查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(复合查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("关联查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(关联查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("关键字查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(关键字查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("附属物查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(附属物查询ToolStripMenuItem); + } + } + #endregion + + #region 标注 + if (Utility.userRole.IndexOf("标注") < 0) + { + toolRightMenu.Items.Remove(标注ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("标高标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(标高标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("管径标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(管径标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("埋深标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(埋深标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("坐标标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(坐标标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("距离标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(距离标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("自定义标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(自定义标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("扯旗标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(扯旗标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("坡度标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(坡度标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("属性标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(属性标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("标注管理") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(标注管理ToolStripMenuItem); + } + } + #endregion + + #region 飞行 + if (Utility.userRole.IndexOf("飞行") < 0) + { + toolRightMenu.Items.Remove(飞行ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("自定义飞行") < 0) + { + 飞行ToolStripMenuItem.DropDownItems.Remove(自定义飞行ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("飞行到目标点") < 0) + { + 飞行ToolStripMenuItem.DropDownItems.Remove(飞行到目标点ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("绕中心点飞行") < 0) + { + 飞行ToolStripMenuItem.DropDownItems.Remove(绕中心点飞行ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("绕眼睛飞行") < 0) + { + 飞行ToolStripMenuItem.DropDownItems.Remove(绕眼睛飞行ToolStripMenuItem); + } + } + #endregion + + #region 编辑 + if (Utility.userRole.IndexOf("编辑") < 0) + { + toolRightMenu.Items.Remove(编辑ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("平移对象") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(平移对象ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("升降对象") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(升降对象ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("旋转对象") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(旋转对象ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("连接管段") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(连接管段ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("导出文件") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(导出文件ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("前进") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(前进ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("后退") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(删除模型ToolStripMenuItem); + } + } + #endregion + + #region 量算 + if (Utility.userRole.IndexOf("量算") < 0) + { + toolRightMenu.Items.Remove(量算ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("水平距离") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(水平距离ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("垂直距离") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(垂直距离ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("空间距离") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(空间距离ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("地表距离") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(地表距离ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("高度量算") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(高度量算ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("水平面积") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(水平面积ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("地表面积") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(地表面积ToolStripMenuItem1); + } + } + #endregion + } + + public void MenuSet() + { + + #region 权限管理 + if (Utility.userRole.IndexOf("权限管理") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem2); + } + else + { + + if (Utility.userRole.IndexOf("用户管理") < 0) + { + btn_user_info.Visible = false; + } + if (Utility.userRole.IndexOf("角色管理") < 0) + { + btn_role_info.Visible = false; + } + if (Utility.userRole.IndexOf("资源管理") < 0) + { + btn_resc_info.Visible = false; + } + if (Utility.userRole.IndexOf("角色授权") < 0) + { + btn_role_resc.Visible = false; + } + if (Utility.userRole.IndexOf("用户授权") < 0) + { + btn_user_role.Visible = false; + } + if (Utility.userRole.IndexOf("密码修改") < 0) + { + btn_password_edit.Visible = false; + } + + } + #endregion + + #region 基础工具 + if (Utility.userRole.IndexOf("基础工具") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem1); + } + else + { + if (Utility.userRole.IndexOf("地上模式") < 0) + { + buttonItem87.Visible = false; + } + if (Utility.userRole.IndexOf("地下模式") < 0) + { + buttonItem88.Visible = false; + } + if (Utility.userRole.IndexOf("行走模式") < 0) + { + buttonItem27.Visible = false; + } + if (Utility.userRole.IndexOf("透明度设置") < 0) + { + sliderGroundTransSet1.Visible = false; + } + if (Utility.userRole.IndexOf("快速定位") < 0) + { + buttonItem91.Visible = false; + } + if (Utility.userRole.IndexOf("图层管理") < 0) + { + buttonItem1.Visible = false; + } + if (Utility.userRole.IndexOf("图例管理") < 0) + { + btnlegendSet.Visible = false; + } + if (Utility.userRole.IndexOf("全屏显示") < 0) + { + buttonItem89.Visible = false; + } + if (Utility.userRole.IndexOf("导出图片") < 0) + { + btnOutputJPG.Visible = false; + } + + } + #endregion + + #region 一键审核 + if (Utility.userRole.IndexOf("一键审核") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem11); + } + #endregion + + #region 红线审核 + if (Utility.userRole.IndexOf("红线审核") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem6); + } + #endregion + + #region 双屏对比 + if (Utility.userRole.IndexOf("双屏对比") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem9); + } + #endregion + + #region 文档管理 + if (Utility.userRole.IndexOf("文档管理") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem4); + } + #endregion + + #region 基础管理 + if (Utility.userRole.IndexOf("基础管理") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem14); + } + else + { + if (Utility.userRole.IndexOf("专题图审批") < 0) + { + buttonItemZTT3_2.Visible = false; + } + if (Utility.userRole.IndexOf("打印审批") < 0) + { + buttonItemZTT4_2.Visible = false; + } + if (Utility.userRole.IndexOf("拷贝审批") < 0) + { + buttonItemZTT5_2.Visible = false; + } + } + + #endregion + + if (ribbonControl1.Items.Count <= 0) + { + ribbonControl1.Visible = false; + } + } + + #region Fan Zhang 重构现有代码 + //初始化控件布局 + private void initLayout() + { + 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.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.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.labelX21.Width = (int)(this.labelX21.Width * myScreen); + this.labelX22.Width = (int)(this.labelX22.Width * myScreen); + this.labelX24.Width = (int)(this.labelX24.Width * myScreen); + } + sideBar1.Visible = false; + 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]); + } + + splitContainer1.Panel2Collapsed = true; + + buttonItem87.Checked = true;//默认地上模式 + ribbonTabItem1.Select(); //初始化状态为浏览 + + sideBarPanelItem3.Visible = false; + layerTree.Visible = false; + controlContainerItem3.Visible = false; + if (sideBarPanelItem4.Visible == true) + { + sideBar1.Visible = true; + controlContainerItem5.Visible = true; + } + else + { + sideBar1.Visible = false; + } + Refresh(); + sliderGroundTransSet1.Value = optiValue; + sliderItem1.Value = optiValue; + sliderItem2.Value = optiValue; + sliderItem3.Value = optiValue; + + } + + //初始化地球控件 + private void initGlobalControl() + { + //选择 + btnToolSelect = new GSOHudButton(); + btnToolSelect.SetImage(Application.StartupPath + "\\Resource\\image\\select1.png"); + btnToolSelect.FadeOut = false; + btnToolSelect.Align = EnumAlign.TopLeft; + btnToolSelect.SetOffset(20, 50); + btnToolSelect.Name = "1"; + btnToolSelect.HeightFixed = true; + btnToolSelect.WidthFixed = true; + globeControl1.Globe.AddHudControl(btnToolSelect); + globeControl2.Globe.AddHudControl(btnToolSelect); + + //浏览 + 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); + + //图例 + legend = new GSOHudButton(); + legend.SetImage(Application.StartupPath + "/Resource/图例P.jpg");//图例P + legend.SetOffset(0, 15); + legend.MinOpaque = 1; + legend.MaxOpaque = 1; + legend.FadeOut = false; + legend.Name = "legend"; + legend.Align = EnumAlign.BottomRight; + legend.Visible = false; + globeControl1.Globe.AddHudControl(legend); + + //实测 + legendSC = new GSOHudButton(); + legendSC.SetImage(Application.StartupPath + "/Resource/sc.jpg"); + legendSC.SetOffset(0, 15); + legendSC.MinOpaque = 1; + legendSC.MaxOpaque = 1; + legendSC.FadeOut = false; + legendSC.Name = "legendSC"; + legendSC.Align = EnumAlign.BottomRight; + globeControl1.Globe.AddHudControl(legendSC); + legendSC.Visible = false; + + //施工 + legendSG = new GSOHudButton(); + legendSG.SetImage(Application.StartupPath + "/Resource/sg.jpg"); + legendSG.SetOffset(0, 15); + legendSG.MinOpaque = 1; + legendSG.MaxOpaque = 1; + legendSG.FadeOut = false; + legendSG.Name = "legendSG"; + legendSG.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(legendSG); + legendSG.Visible = false; + + //管纵 + AddGZ(); + + 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; + globeControl1.Globe.IsReleaseMemOutOfView = true; + globeControl1.Globe.ControlPanel.Visible = true; + + globeControl2.Globe.UnderGroundFloor.Visible = false; + globeControl2.Globe.OverviewControl.Visible = false; + globeControl2.Globe.ScalerControl.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; + globeControl2.Globe.IsReleaseMemOutOfView = true; + globeControl2.Globe.ControlPanel.Visible = false; + + 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); + + //添加临时图层 + layerTemp = globeControl1.Globe.Layers.Add(Application.StartupPath + "\\tempLgdData.lgd"); + layerTemp2 = globeControl2.Globe.Layers.Add(Application.StartupPath + "\\tempLgdData2.lgd"); + if (layerTemp != null) + { + layerTemp.MaxVisibleAltitude = 1000; + } + + //添加城市7线图层 + 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"); + + //注册对应事件 + this.registerEvent(); + } + + //注册地球事件 + private bool registerEvent() + { + if (globeControl1 == null || globeControl2 == null) + { + return false; + } + 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); + + globeControl2.FeatureMouseClickEvent += new FeatureMouseClickEventHandler(globeControl2_FeatureMouseClickEvent); + globeControl2.CameraBeginMoveEvent += new CameraBeginMoveEventHandler(globeControl2_CameraBeginMoveEvent); + + globeControl1.MouseDoubleClick += new MouseEventHandler(globeControl1_MouseDoubleClick); + globeControl1.MouseClick += new MouseEventHandler(globeControl1_MouseClick); + globeControl1.MouseDown += new MouseEventHandler(globeControl1_MouseDown); + + globeControl2.MouseClick += new MouseEventHandler(globeControl2_MouseClick); + globeControl2.MouseDown += new MouseEventHandler(globeControl2_MouseDown); + + 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); + + return true; + } + + //加载两个地球数据 + private void loadData() + { + Thread t1 = new Thread(new ThreadStart(doLoadDataForGlobalControl1)); + t1.IsBackground = true; + t1.Start(); + + + } + + delegate void LoadDataForGlobalControl(); + + private void connectServer() + { + globeControl1.Globe.ConnectServer(Utility.serverip, Utility.serverport, "", ""); //加载locaServer中的数据 + globeControl2.Globe.ConnectServer(Utility.serverip, Utility.serverport, "", ""); //加载locaServer中的数据 + //初始化TreeView + // 勾选实测图层 + foreach (TreeNode tn in layerTree.Nodes) + { + if (tn.Nodes.Count > 0) + { + if (tn.Text == "实测数据") + { + tn.Checked = true; + foreach (TreeNode tnChild in tn.Nodes) + { + tnChild.Checked = true; + foreach (TreeNode tnGrandChild in tnChild.Nodes) + { + tnGrandChild.Checked = true; + } + } + } + } + } + } + + private void doLoadDataForGlobalControl1() + { + try + { + + globeControl1.Globe.Layers.MoveDown(10000); + //加载实测管线数据 + Utility.dataSource = globeControl1.Globe.DataManager.OpenOracleDataSource(Utility.DBServer.Trim() + "/" + Utility.dbdatabase.Trim(), "", "", Utility.userID, Utility.DBPassword); + + if (Utility.dataSource != null) + { + for (int j = 0; j < Utility.dataSource.DatasetCount; j++) + { + GSODataset dataset = Utility.dataSource.GetDatasetAt(j); + if (dataset != null && dictionaryNetLayerNameAndCaption.ContainsKey(dataset.Caption)) + { + dataset.Caption = dataset.Name; + globeControl1.Globe.Layers.Add(dataset); + } + } + } + //隐藏红线图层 + globeControl1.Globe.Layers.GetLayerByCaption("红线").Visible = false; + + //globleControl1中加载规划数据 + GSODataSource ghDS = globeControl1.Globe.DataManager.OpenOracleDataSource(Utility.ghdbip + "/" + Utility.ghdbname, "", "", Utility.ghdbuser, Utility.ghdbpwd); + if (ghDS != null) + { + for (int j = 0; j < ghDS.DatasetCount; j++) + { + GSODataset dataset = ghDS.GetDatasetAt(j); + if (dataset != null && dictionaryNetLayerNameAndCaption.ContainsKey(dataset.Caption)) + { + dataset.Caption = dataset.Name; + globeControl1.Globe.Layers.Add(dataset); + globeControl1.Globe.Layers[0].Visible = false; + } + } + } + + //globeControl1,globeControl2中加载施工数据 + GSODataSource sgDS = globeControl1.Globe.DataManager.OpenOracleDataSource(Utility.sgdbip + "/" + Utility.sgdbname, "", "", Utility.sgdbuser, Utility.sgdbpwd); + if (sgDS != null) + { + for (int m = 0; m < sgDS.DatasetCount; m++) + { + GSODataset dataset = sgDS.GetDatasetAt(m); + if (dataset != null && !dataset.Caption.Contains("SH") && dictionaryNetLayerNameAndCaption.ContainsKey(dataset.Caption)) + { + dataset.Caption = dataset.Name; + globeControl1.Globe.Layers.Add(dataset); + globeControl1.Globe.Layers[0].Visible = false; + + globeControl2.Globe.Layers.Add(dataset); + globeControl2.Globe.Layers[0].Visible = true; + } + } + } + + LoadDataForGlobalControl ss = new LoadDataForGlobalControl(connectServer); + ss(); + + } + catch (Exception ex) + { + MessageBox.Show(ex.Message); + } + } + + private void initLayerTree() + { + //加载临时图层节点 + layerManagerNode = new TreeNode(); + layerManagerNode.ImageIndex = 0; + layerManagerNode.SelectedImageIndex = 0; + layerManagerNode.Checked = true; + layerManagerNode.Text = "临时图层"; + layerTree.Nodes.Add(layerManagerNode); + + XmlDocument doc = new XmlDocument(); + doc.Load(filename); + XmlNodeList xmlLayerNodes = doc.SelectNodes("//layer"); + + foreach (XmlNode xmlLayerNode in xmlLayerNodes) + { + + //TODO LIST:创建一级TreeNode(实测、规划、施工) + TreeNode nodelayer = new TreeNode(); + string layerName = xmlLayerNode.Attributes["label"].Value; + nodelayer.Text = layerName; + nodelayer.Checked = false; + layerTree.Nodes.Add(nodelayer); + + XmlNodeList xmlChildLayerNodes = xmlLayerNode.ChildNodes; + foreach (XmlNode xmlChildLayerNode in xmlChildLayerNodes) + { + //TODO LIST:创建二级TreeNode节点 + TreeNode secondLevelNode = new TreeNode(); + string layerType = xmlChildLayerNode.Attributes["label"].Value; + secondLevelNode.Text = layerType; + + if (xmlChildLayerNode.Attributes["type"] != null) + { //道路图层特殊处理 + string type = xmlChildLayerNode.Attributes["type"].Value; + secondLevelNode.Tag = type + "|" + layerType; + } + else + { + secondLevelNode.Tag = layerType; + } + secondLevelNode.Checked = false; + nodelayer.Nodes.Add(secondLevelNode); + + XmlNodeList xmlActitualLayerNodes = xmlChildLayerNode.ChildNodes; + + foreach (XmlNode xmlActitualLayerNode in xmlActitualLayerNodes) + { + //TODO LIST:创建三级图层节点 + TreeNode layerNode = new TreeNode(); + string actutallylayerType = xmlActitualLayerNode.Attributes["type"].Value; + string actutallylayerName = xmlActitualLayerNode.Attributes["layer"].Value; + string actutallyLabelName = xmlActitualLayerNode.Attributes["label"].Value; + + layerNode.Text = actutallyLabelName; + layerNode.Tag = layerType + "|" + actutallyLabelName; + layerNode.Checked = false; + secondLevelNode.Nodes.Add(layerNode); + } + + } + + } + + } + + /** + * 读取Config.xml文件,初始化以下全局Map + * m_PipelineLayerNames:管线 + * workwellLayerNames:工井 + * valueLayerNames:阀门 + * instrumenLayerNames:附属物 + * pipefittingLayerNames:特征管点 + * sgPipeLayersNames:施工管线 + **/ + private void initGlobalMap() + { + XmlDocument doc = new XmlDocument(); + doc.Load(filename); + XmlNodeList xmlLayerNodes = doc.SelectNodes("//layerchild"); + + foreach (XmlNode xmlLayerNode in xmlLayerNodes) + { + string layerType = xmlLayerNode.Attributes["type"].Value; + string layerName1 = xmlLayerNode.Attributes["layer"].Value; + string layerchildName = xmlLayerNode.Attributes["label"].Value; + + dictionaryNetLayerNameAndCaption.Add(layerName1, layerchildName); + + if (layerType != "db") + { + if (xmlLayerNode.Attributes["isRoad"] != null) + { + roadLayerName = layerchildName; + } + } + else if (xmlLayerNode.Attributes["isPipeLine"] != null) + { + m_PipelineLayerNames.Add(layerchildName); + g1layername.Add(layerName1); + } + else if (xmlLayerNode.Attributes["isWorkWell"] != null) + { + workwellLayerNames.Add(layerchildName); + g1layername.Add(layerName1); + } + else if (xmlLayerNode.Attributes["isValve"] != null) + { + valueLayerNames.Add(layerchildName); + g1layername.Add(layerName1); + } + else if (xmlLayerNode.Attributes["isAccess"] != null) + { + instrumenLayerNames.Add(layerchildName); + g1layername.Add(layerName1); + } + else if (xmlLayerNode.Attributes["isCharacter"] != null) + { + pipefittingLayerNames.Add(layerchildName); + g1layername.Add(layerName1); + } + else if (xmlLayerNode.Attributes["isSgData"] != null) + { + sgPipeLayersNames.Add(layerchildName); + g1layername.Add(layerName1); + } + + } + } + + private void initMarkerTree() + { + 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); + } + } + } + } + + private void MainFrm_Load(object sender, EventArgs e) + { + + this.initGlobalControl(); + this.initGlobalMap(); + this.initLayerTree(); + this.initMarkerTree(); + this.initLayout(); + this.loadData(); + + + double x = Convert.ToDouble(Utility.Query_Roads["绿岛"].ToString().Split(',')[0]); + double y = Convert.ToDouble(Utility.Query_Roads["绿岛"].ToString().Split(',')[1]); + double z = Convert.ToDouble(Utility.Query_Roads["绿岛"].ToString().Split(',')[2]); + jumpToCameraState(x, y, z); + + + } + + #endregion + + /// + /// 每次gis服务加载时都会触发的 + /// + /// + /// + 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 dictionaryNetLayerNameAndCaption = new Dictionary(); + 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 配置用户权限 + /// + /// 向数据库插入功能列表 + /// + private void insertControlToDatabase() + { + ArrayList listItem = new ArrayList(); + List subListItem = new List(); + 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) + { + GSOCameraState camera = globeControl2.Globe.CameraState; + globeControl1.Globe.JumpToCameraState(camera); + } + } + + void globeControl1_BeforeSceneRenderEvent(object sender, BeforeSceneRenderEventArgs e) + { + if (globeControl1.Focused) + { + 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); + } + } + } + + /// + /// 检查数据集是否有坐标系信息 + /// + /// + /// + 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 = "0prj4" + lprjStr + ""; + + bSuccess = dataset.LoadProjectionFromESRIFile(dlg.FileName); + + string lprjFileName = strDataPath.Substring(0, strDataPath.LastIndexOf(".")) + ".lprj"; + StreamWriter writer = new StreamWriter(lprjFileName, false); + writer.Write(lprjFileContent); + writer.Close(); + + } + } + } + else + { + return true; + } + return bSuccess; + } + + /// + /// 矩形拉框结束事件处理函数 + /// + /// + /// + 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))); + */ + + int mapWidth = 0; + int mapHeight = 0; + Point pt = getUpperLeftPoint(pt1, pt2, out mapWidth, out mapHeight); + int rightBottomX = pt.X + mapWidth; + int rightBottomY = pt.Y + mapHeight; + Image myImg = new Bitmap(mapWidth, mapHeight); + Graphics g = Graphics.FromImage(myImg); + g.CopyFromScreen(pt, new Point(0, 0), new Size(rightBottomX, rightBottomY)); + + 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; + } + } + /// + /// 定位正北正90度俯视 + /// + /// + /// + /// + 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; + } + } + /// + /// layerTree选中后事件处理 + /// + /// + /// + 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); + } + /// + /// 树节点选中方法 + /// + /// + 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); + } + } + } + + } + /// + /// 改变所有子节点的状态 + /// + /// + /// + 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; + LayerFlyMenuItem.Visible = true; + } + + LayerSelectableMenuItem.Visible = true; + LayerEditableMenuItem.Visible = true; + SaveLayerMenuItem.Visible = true; + LayerFlyMenuItem.Visible = true; + 导出CADToolStripMenuItem1.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]); + if (layer != null) + { + LayerSelectableMenuItem.Checked = layer.Selectable; + LayerEditableMenuItem.Checked = layer.Editable; + } + else + { + return; + } + } + 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; + } + } + } + } + } + + /// + /// 删除临时添加的本地数据图层 + /// + /// + /// + 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); + for (int i = globeControl1.Globe.Layers.Count-1; i >=0; i--) + { + if (globeControl1.Globe.Layers[i].Caption == layer.Caption) + { + globeControl1.Globe.Layers.Remove(globeControl1.Globe.Layers[i]); + } + } + + 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 定位ToolStripMenuItem_Click(object sender, EventArgs e) + { + TreeNode node = layerTree.SelectedNode; + + if (node != null) + { + if (node.Parent.Text.Trim() == "临时图层") + { + GSOLayer lsLayer = globeControl1.Globe.Layers.GetLayerByCaption(node.Text.ToString()); + double x = lsLayer.LatLonBounds.Center.X; + double y = lsLayer.LatLonBounds.Center.Y; + if (x == 0 && y == 0) + { + x = lsLayer.Bounds.Center.X; + y = lsLayer.Bounds.Center.Y; + } + + globeControl1.Globe.FlyToPosition(new GSOPoint3d(x, y, 10), EnumAltitudeMode.Absolute); + } + else + { + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(node.Tag.ToString().Split('|')[1]); + + if (layer != null) + { + if (layer.Caption == "红线") + { + globeControl1.Globe.FlyToPosition(new GSOPoint3d(120.610963, 31.188121, 50), EnumAltitudeMode.Absolute, -4, 50, 1000); + globeControl1.Globe.FlyToPointSpeed = 10000000; + globeControl1.Globe.Action = EnumAction3D.SelectObject; + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = true; + } + globeControl1.Refresh(); + } + else + { + double x = layer.LatLonBounds.Center.X; + double y = layer.LatLonBounds.Center.Y; + globeControl1.Globe.FlyToPosition(new GSOPoint3d(x, y, 100), EnumAltitudeMode.Absolute); + } + } + } + } + else + { + return; + } + + } + + private void layerTree_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e) + { + if(this.layerTree.SelectedNode!=null) + { + if (this.layerTree.SelectedNode.Tag.ToString().Contains("|")) + { + string nodeTag = this.layerTree.SelectedNode.Tag.ToString().Split('|')[1]; + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(nodeTag); + if (layer != null) + { + if (layer.Caption == "红线") + { + globeControl1.Globe.FlyToPosition(new GSOPoint3d(120.610963, 31.188121, 50), EnumAltitudeMode.Absolute, -4, 50, 1000); + globeControl1.Globe.FlyToPointSpeed = 10000000; + globeControl1.Globe.Action = EnumAction3D.SelectObject; + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = true; + } + globeControl1.Refresh(); + } + else { + double x = layer.LatLonBounds.Center.X; + double y = layer.LatLonBounds.Center.Y; + globeControl1.Globe.FlyToPosition(new GSOPoint3d(x, y, 0), EnumAltitudeMode.Absolute); + } + } + } + if (this.layerTree.SelectedNode.Tag is GSOLayer) + { + GSOLayer layer = this.layerTree.SelectedNode.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 (this.layerTree.SelectedNode.Tag is GSOFeature) + { + GSOFeature feature = this.layerTree.SelectedNode.Tag as GSOFeature; + if (feature.Geometry != null) + { + globeControl1.Globe.FlyToPosition(feature.Geometry.GeoCenterPoint, EnumAltitudeMode.Absolute, 0, 0, 10); + } + else + { + globeControl1.Globe.FlyToFeature(feature); + } + } + } + } + + /// + /// 在三维场景移动时,隐藏气泡globeControl1 + /// + /// + /// + void globeControl1_CameraBeginMoveEvent(object sender, CameraBeginMoveEventArgs e) + { + if (featureTooltip.IsVisible()) + { + featureTooltip.HideBalloon(); + } + if (balloonEx.IsVisible()) + { + balloonEx.HideBalloon(); + } + } + + /// + /// 在三维场景移动时,隐藏气泡globeControl2 + /// + /// + /// + void globeControl2_CameraBeginMoveEvent(object sender, CameraBeginMoveEventArgs e) + { + if (featureTooltip2.IsVisible()) + { + featureTooltip2.HideBalloon(); + } + if (balloonEx2.IsVisible()) + { + balloonEx2.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(); + } + } + + #region Fan 横断面 + /// + /// 横断面分析、基线剖面分析、道路断面分析等 + /// + /// + /// + private static EnumTrackPolylineEndMode trackPolylineEndMode; + + void globeControl1_TrackPolylineEndEvent(object sender, TrackPolylineEndEventArgs e) + { + //横断面分析、道路横断面分析 + if (trackPolylineEndMode == EnumTrackPolylineEndMode.HDM_Analysis|| + trackPolylineEndMode == EnumTrackPolylineEndMode.DLDM_Analysis) + { + Dictionary hdmDic = SectionAnalysisTool.HDMAnalysis(this.globeControl1, + e.Polyline, this.m_PipelineLayerNames); + FrmHDMAnalysis3 frm = new FrmHDMAnalysis3(hdmDic, this.globeControl1, + trackPolylineEndMode); + frm.Show(this); + } + //基线剖面分析 + else if (trackPolylineEndMode == EnumTrackPolylineEndMode.JXPM_Analysis) + { + FrmBaseLineProfillAnalysis dlg = new FrmBaseLineProfillAnalysis(globeControl1.Globe, e.Polyline); + dlg.Show(this); + globeControl1.Globe.ClearLastTrackPolyline(); + /* + FrmRoadHDM f = new FrmRoadHDM(); + f.Show() + * **/ + } + else + { + + } + trackPolylineEndMode = EnumTrackPolylineEndMode.Default_Analysis; + /* + ArrayList arraylistPoint = new ArrayList(); + ArrayList arraylistLine = new ArrayList(); + + // globeControl1.Globe.ClearLastTrackPolyline(); + + if (e.Polyline != null) + { + //横断面分析 + if (buttonItemFX2_1.Checked || buttonItemFX2_3.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 (buttonItemFX2_1.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 (buttonItemFX2_4.Checked) + { + FrmBaseLineProfillAnalysis dlg = new FrmBaseLineProfillAnalysis(globeControl1.Globe, e.Polyline); + dlg.Show(this); + globeControl1.Globe.ClearLastTrackPolyline(); + } + else if (buttonItemFX4_3.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(); + * **/ + } + #endregion + + private GSOFeatures PolygonIntersectAnalysis(GSOGeoPolygon3D polygon, string pipelinetype) + { + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(pipelinetype); + 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(pipelinetype, feats.Length); + return feats; + } + /// + /// 根据范围统计阀门、管线、工井等, 开挖分析, 挖方量分析 + /// + /// + /// + void globeControl1_TrackPolygonEndEvent(object sender, TrackPolygonEndEventArgs e) + { + if (globeControl1.Globe.Action == EnumAction3D.TrackPolygon && e.Polygon != null) + { + GSOGeoPolygon3D polygon = e.Polygon; + + switch (trackflag) + { + case "valvequery": + FrmValveStatistics frm = new FrmValveStatistics(globeControl1,polygon, new DataGridViewDelegate(InitDataGridViewX1)); + frm.Show(this); + //panelEx6.Visible = true; + toolStripFeatureLength.Text = ""; + globeControl1.Globe.Action = EnumAction3D.ActionNull; + break; + + case "PipelineDistanceStatistics": + + FrmAllPipelineStatis frm1 = new FrmAllPipelineStatis(globeControl1, polygon, new DataGridViewDelegate(InitDataGridViewX1), m_PipelineLayerNames); + frm1.Show(this); + globeControl1.Globe.Action = EnumAction3D.ActionNull; + + break; + case "PipelineSpatialQuery": + + FrmAllPipelineStatis.ShowForm(globeControl1,polygon,new DataGridViewDelegate(InitDataGridViewX1),m_PipelineLayerNames); + globeControl1.Globe.ClearAnalysis(); + globeControl1.Globe.Action = EnumAction3D.ActionNull; + + break; + case "workwellquery": + FrmAllWorkWellStatis frmWell = new FrmAllWorkWellStatis(globeControl1, polygon, new DataGridViewDelegate(InitDataGridViewX1)); + 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 "BSQDuoBianXiangStatis": + + //GSOFeature f2 = new GSOFeature(); + //f2.Geometry = e.Polygon; + //f2.Geometry.AltitudeMode = EnumAltitudeMode.Absolute; + //globeControl1.Globe.MemoryLayer.AddFeature(f2); + //f2.Geometry.MoveZ(3); + //workWellLen.Clear(); + //List listBSQ = new List(); + + //GSOFeatures bsqFeatures = PolygonIntersectAnalysis(e.Polygon, "标识器"); + //listBSQ.Add(bsqFeatures); + + //FrmBSQDuoBianXingStatis bsqFrm = new FrmBSQDuoBianXingStatis(workWellLen, globeControl1, listBSQ); + FrmBSQStatis bsqFrm = new FrmBSQStatis(globeControl1,e.Polygon); + bsqFrm.Show(this); + globeControl1.Globe.Action = EnumAction3D.ActionNull; + break; + + case "": + break; + default: + break; + } + } + } + + #region 验证端口 + /* + /// + /// 验证端口 + /// + /// + 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 + + /// + /// 鼠标悬浮提示 + /// + /// + /// + 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); + } + } + + /// + /// 添加管线绘制完成事件, 红线工具绘制完成 + /// + /// + /// + 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; + + + } + } + + /// + /// 获取globeControl1中鼠标按下的坐标供区别鼠标右键和滚轮按下事件 + /// + /// + /// + void globeControl1_MouseDown(object sender, MouseEventArgs e) + { + mouseDownX1 = e.X; + mouseDownY1 = e.Y; + } + /// + /// 获取globeControl2中鼠标按下的坐标供区别鼠标右键和滚轮按下事件 + /// + /// + /// + void globeControl2_MouseDown(object sender, MouseEventArgs e) + { + mouseDownX2 = e.X; + mouseDownY2 = e.Y; + } + /// + /// + /// + /// + /// + void globeControl2_MouseClick(object sender, MouseEventArgs e) + { + if (e.Button == MouseButtons.Right) + { + if (e.X == mouseDownX2 && e.Y == mouseDownY2) + { + RightScreenToolMenu.Show(globeControl2, e.X, e.Y); + } + else + { + return; + } + } + } + /// + /// + /// + /// + /// + void globeControl1_MouseClick(object sender, MouseEventArgs e) + { + if (e.Button == MouseButtons.Left) + { + if (globeControl1.Globe.Action == EnumAction3D.VisibilityAnalysis) + { + buttonItemFX5_1.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; + + bsqPT = pt; + + if (buttonItemLS5.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 (e.X == mouseDownX1 && e.Y == mouseDownY1) + { + toolRightMenu.Show(globeControl1, e.X, e.Y); + if (buttonItemLS5.Checked) + { + buttonItemLS5.Checked = false; + } + } + else + { + return; + } + } + globeControl1.Refresh(); + } + + /// + /// 判断网络图片是否存在 + /// + /// + /// + 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; + } + + /// + /// 鼠标点击, 弹出气泡功能globeControl1 + /// + /// + /// + void globeControl1_FeatureMouseClickEvent(object sender, FeatureMouseClickEventArgs e) + { + GSOFeature feature = e.Feature; + + string str1 = ""; + if (feature != null) + { + if (feature.GetFieldDefn("图片编码") != null)// + { + str1 = GetBubbleInfo(feature, globeControl1); + if (RemoteFileExists(Utility.PicRootURL + feature.GetValue("图片编码").ToString())) + { + str1 += ""; + } + else if (RemoteFileExists(Utility.PicDefaultURL)) + { + str1 += ""; + } + } + else if (isFeatureContainsBianhao(feature)) //管线模型图层 + { + str1 = GetBubbleInfo(feature, globeControl1); + } + + 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; + } + } + } + + /// + /// 鼠标点击, 弹出气泡功能globeControl2 + /// + /// + /// + void globeControl2_FeatureMouseClickEvent(object sender, FeatureMouseClickEventArgs e) + { + GSOFeature feature = e.Feature; + + string str1 = ""; + if (feature != null) + { + if (feature.GetFieldDefn("图片编码") != null) // + { + str1 = GetBubbleInfo(feature, globeControl2); + if (RemoteFileExists(Utility.PicRootURL + feature.GetValue("图片编码").ToString())) + { + str1 += ""; + } + else if (RemoteFileExists(Utility.PicDefaultURL)) + { + str1 += ""; + } + } + else if (isFeatureContainsBianhao(feature)) //管线模型图层 + { + str1 = GetBubbleInfo(feature, globeControl2); + } + + if (str1 != "") + { + + featureTooltip2.HideBalloon(); + balloonEx2.HideBalloon(); + balloonEx2.SetSize(EnumSizeIndexEx.CONTENT_CX, 480); + balloonEx2.SetSize(EnumSizeIndexEx.CONTENT_CY, 420); + balloonEx2.ShowBalloon((int)e.MousePos.X, (int)e.MousePos.Y, str1); + + return; + } + } + } + + /// + /// 拼接气泡表格字符串 + /// + /// + /// + private string GetBubbleInfo(GSOFeature feature,GSOGlobeControl globeControl) + { + if (feature == null) + { + return ""; + } + string str = ""; + str = ""; + 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 += ""; + + 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.get_Fields(layerName, globeControl); + } + if (queryFields != null) + { + string[] param = { "," }; + string[] fieldNames = queryFields.Split(param, StringSplitOptions.RemoveEmptyEntries); + for (int j = 0; j < fieldNames.Length; 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 (name1 == "模型路径") + { + continue; + } + 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 (field1.Type == EnumFieldType.Double) + { + double dl1 = feature.GetFieldAsDouble(j); + if (!name1.Contains("管径") && !name1.Contains("电压") && !name1.Contains("角度")) + { + name1 += "_米"; + } + value1 = dl1.ToString("0.00"); + } + 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 (name2 == "模型路径") + { + continue; + } + + 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 (field2.Type == EnumFieldType.Double) + { + double dl2 = feature.GetFieldAsDouble(j + 1); + if (!name2.Contains("管径") && !name2.Contains("电压") && !name2.Contains("角度")) + { + name2 += "_米"; + } + value2 = dl2.ToString("0.00"); + } + else + { + if (!feature.IsFieldValueNull(j + 1)) + { + value2 = feature.GetValue(j + 1).ToString(); + } + } + } + } + + j++; + } + str += ""; + } + } + str += "
" + title + " " + feature.GetFieldAsString(featureIDFieldName) + "
" + + name1 + + "
" + + value1 + + "
" + + name2 + + "
" + + value2 + "
"; + return str; + } + + string filename = Utility.filename; + List g1layername = new List(); + + /// + /// 获取目标图层 + /// + /// + 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; + } + /// + /// 添加图层 + /// + /// + /// + /// + 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 = 5000; + return templayer.Visible; + } + catch (Exception ex) + { + return false; + } + } + /// + /// 菜单上的 三维导航 工具按钮 + /// + /// + /// + private void buttonItem86_Click(object sender, EventArgs e) + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + } + + /// + /// 地上模式 菜单按钮 + /// + /// + /// + 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(); + + } + } + /// + /// 地下模式 菜单按钮 + /// + /// + /// + 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(); + } + } + /// + /// 行走模式 菜单按钮 + /// + /// + /// + 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; + } + } + /// + /// 地面透明度设置 菜单 + /// + /// + /// + private void sliderGroundTransSet1_ValueChanged(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.sliderGroundTransSet1.Text); + + globeControl1.Globe.GroundOpaque = 100 - sliderGroundTransSet1.Value; + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(roadLayerName);//("180fd"); + if (layer != null) + { + layer.Opaque = 100 - sliderGroundTransSet1.Value; + } + //if (buttonItemSPDB.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; + } + /// + /// 图例 菜单按钮 + /// + /// + /// + 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(); + } + /// + /// 快速定位 菜单按钮 + /// + /// + /// + private void buttonItem91_Click(object sender, EventArgs e) // + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItem91.Text); + FrmFlyToPosition fly = new FrmFlyToPosition(globeControl1); + fly.Show(this); + } + /// + /// 图层管理 菜单按钮 + /// + /// + /// + 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; + + //修改图层管理与标注管理、覆土审查、水平净距分析、垂直净距分析和碰撞分析控件之间的逻辑关系 + controlContainerItem5.Visible = false; + sideBar1.Visible = false; + sideBarPanelItem4.Visible = false; + panel3.Visible = false; + sideBar1.ExpandedPanel = sideBarPanelItem3; + buttonItemBZ11.Checked = false; + + //20160624 + /* + if (sideBarPanelItem4.Visible == true) + { + sideBar1.Visible = true; + controlContainerItem5.Visible = true; + } + else + { + sideBar1.Visible = false; + } + */ + Refresh(); + + } + } + /// + /// 全屏显示 菜单按钮 + /// + /// + /// + 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; + /// + /// 全屏显示功能实现 + /// + 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(); + } + } + + /// + /// 设置窗体宽、高 + /// + /// + /// + private void SetFullScreen(int width, int height) + { + this.Width = width; + this.Height = height; + } + + /// + /// 全屏功能的快捷键F5 + /// + /// + /// + 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); + } + } + /* + /// + /// 输出地图 + /// + /// + /// + /// + 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; + } + * */ + + private Point getUpperLeftPoint(Point p1, Point p2, out int mapWidth, out int mapHeight) // + { + Rectangle rc = new Rectangle(); + + p1 = this.globeControl1.PointToScreen(p1); + p2 = this.globeControl1.PointToScreen(p2); + + int x = Screen.PrimaryScreen.Bounds.X; + int y = Screen.PrimaryScreen.Bounds.Y; + int screenWidth = SystemInformation.WorkingArea.Width; + int screenHeight = SystemInformation.WorkingArea.Height; + + if (p1.X < x) + rc.X = x; + else + rc.X = p1.X; + + if (p1.Y < y) + rc.Y = y; + else + rc.Y = p1.Y; + + p1.X = rc.Left; + p1.Y = rc.Top; + + if (p2.X > screenWidth) + p2.X = screenWidth; + else + p2.X = p2.X; + + if (p2.Y > screenHeight) + p2.Y = screenHeight; + else + p2.Y = p2.Y; + + rc.Width = p2.X - rc.X; + rc.Height = p2.Y - rc.Y; + + mapWidth = rc.Width; + mapHeight = rc.Height; + Point pt = new Point(rc.Left, rc.Top); + return pt; + } + + Image printImage; + /// + /// 打印 菜单 + /// + /// + /// + 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))); + */ + int mapWidth = 0; + int mapHeight = 0; + Point pt = getUpperLeftPoint(pt1, pt2, out mapWidth, out mapHeight); + int rightBottomX = pt.X + mapWidth; + int rightBottomY = pt.Y + mapHeight; + Image myImg = new Bitmap(mapWidth, mapHeight); + Graphics g = Graphics.FromImage(myImg); + g.CopyFromScreen(pt, new Point(0, 0), new Size(rightBottomX, rightBottomY)); + + + 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); + } + /// + /// 输出地图 菜单 + /// + /// + /// + private void btnOutputJPG_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btnOutputJPG.Text); + + //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))); + */ + int mapWidth = 0; + int mapHeight = 0; + Point pt = getUpperLeftPoint(pt1, pt2, out mapWidth, out mapHeight); + int rightBottomX = pt.X + mapWidth; + int rightBottomY = pt.Y + mapHeight; + Image myImg = new Bitmap(mapWidth, mapHeight); + Graphics g = Graphics.FromImage(myImg); + g.CopyFromScreen(pt, new Point(0, 0), new Size(rightBottomX, rightBottomY)); + + 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; + } + } + } + + /// + /// 在窗体的底部状态栏上显示 综合管线条件查询结果 + /// + /// + /// + 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 + " 条记录 | "; + } + } + + /// + /// 统计管线的里程数 + /// + /// + /// + /// + 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; + } + + /// + /// 窗体下方属性表格 右键菜单中的 “定位”菜单 + /// + /// + /// + 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); + + } + + /// + /// 表格中右键 “单个闪烁” 菜单 + /// + /// + /// + private void LightMenu_Click(object sender, EventArgs e) + { + flashflag = "single"; + timer1.Start(); + } + /// + /// 表格中右键 “全部闪烁” 菜单 + /// + /// + /// + private void AllLightMenuItem_Click(object sender, EventArgs e) + { + flashflag = "all"; + timer1.Start(); + } + + /// + /// 使用timer实现管线的闪烁效果 + /// + /// + /// + 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; + } + } + + /// + /// 绘制线 菜单 + /// + /// + /// + private void btnAddLine_Click(object sender, EventArgs e) + { + globeControl1.Globe.DestLayerFeatureAdd = globeControl1.Globe.MemoryLayer; + globeControl1.Globe.Action = EnumAction3D.DrawPolyline; + } + /// + /// 绘制面 菜单 + /// + /// + /// + private void btnAddPolygon_Click(object sender, EventArgs e) + { + globeControl1.Globe.DestLayerFeatureAdd = globeControl1.Globe.MemoryLayer; + globeControl1.Globe.Action = EnumAction3D.DrawPolygon; + } + /// + /// 图层目录树 右键菜单中的 目标图层 菜单 + /// + /// + /// + 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; + } + } + /// + /// 图层目录树 右键菜单中的 可选择 菜单 + /// + /// + /// + 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; + } + /// + /// 图层目录树 右键菜单中的 可编辑 菜单 + /// + /// + /// + 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; + } + /// + /// 图层目录树 右键菜单中的 保存 菜单 + /// + /// + /// + 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(); + } + + /// + /// 根据多边形范围统计管线的里程 + /// + /// + /// + /// 返回查询到的管线要素集合 + 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 pipeLineDis = new Dictionary(); + Dictionary workWellLen = new Dictionary(); + + + + + /// + /// 查找指定图层中在 指定范围内的feature对象集合 + /// + /// + /// + /// + 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; + } + /// + /// 清除结果 菜单 + /// + /// + /// + private void buttonItem47_Click(object sender, EventArgs e) + { + globeControl1.Globe.ClearAnalysis(); + dataGridViewX1.DataSource = null; + panelOfTable.Visible = false; + clearFeatureHighLight(); + } + /// + /// 设置菜单的选中状态 + /// + private void ActionToolMenuChecked() + { + if (globeControl1.Globe.Action != EnumAction3D.TrackPolyline) + { + buttonItemFX2_1.Checked = false; + buttonItemFX2_4.Checked = false; + buttonItemFX2_3.Checked = false; + buttonItemFX4_3.Checked = false; + } + if (globeControl1.Globe.Action != EnumAction3D.NormalHit) + { + buttonItemFX3_6.Checked = false; + // ClearConnexityAnalysis(); + + buttonItemFX3_5.Checked = false; + // ClearCloseValvesAnalysis(); + } + if (globeControl1.Globe.Action != EnumAction3D.TrackPolygon) + { + buttonItemFX4_2.Checked = false; + buttonItemFX4_1.Checked = false; + } + } + + /// + /// 主窗体关闭事件处理 + /// + /// + /// + private void MainFrm_FormClosing(object sender, FormClosingEventArgs e) + { + + if (MessageBox.Show("是否退出系统?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) + { + e.Cancel = true; + } + else { + globeControl1.Globe.MemoryLayer.SaveAs(Application.StartupPath + "/MyPlace.kml"); + } + + //saveLayerList(layerManagerNode.Nodes); + //注销id号为103的热键设定 + // UnregisterHotKey(Handle, 103); + } + + /// + /// 显示流向 功能 + /// + /// + /// + /// + 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(); + } + + FrmCloseValves frm; + + FrmBoosterValvers frmbooster = null; + + /// + /// 垂直净距分析 功能界面中的 选择图层复选框 选中状态改变事件处理 + /// + /// + /// + 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(); + } + /// + /// 水平净距分析 功能界面中的 选择图层复选框 选中状态改变事件处理 + /// + /// + /// + 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(); + } + /// + /// 垂直净距分析 功能界面中的 选择管线复选框 选中状态改变事件处理 + /// + /// + /// + private void checkBoxX1_CheckedChanged(object sender, EventArgs e) + { + clearFeatureHighLight(); + if (checkBoxX1.Checked) + { + comboBoxEx1.SelectedItem = null; + 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; + } + } + /// + /// 水平净距分析 功能界面中的 选择管线复选框 选中状态改变事件处理 + /// + /// + /// + private void checkBoxX1_CheckedChanged_shuiping(object sender, EventArgs e) + { + clearFeatureHighLight();//清除高亮 + if (checkBoxX7.Checked) + { + comboBoxEx4.SelectedItem = null; + 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(); + /// + /// 垂直净距分析 功能界面中的 选择图层下拉框 选中项改变 事件处理 + /// + /// + /// + 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; + } + } + } + /// + /// 水平净距分析 功能界面中的 选择图层下拉框 选中项改变 事件处理 + /// + /// + /// + 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 featCount = new Dictionary(); + Dictionary featLenth = new Dictionary(); + Dictionary m_FeaturesWithBianhao = new Dictionary();//记录编号和对应的标注点的位置 + GSOFeatures polygonJingJuAnalysises = new GSOFeatures(); + + /// + /// 垂直净距分析 功能界面中的 开始分析按钮 事件处理 + /// + /// + /// + 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; + } + + /// + /// 在指定的两点组成的线的中间添加一个marker对象,并将marker对象添加到指定的图层中 + /// + /// + /// + /// + /// + /// + 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; + } + + /// + /// 计算指定feature对象与除了该feature所在图层之外的 所有管线图层中的所有feature对象 的垂直距离 并在表格中记录符合要求的管线 + /// + /// + /// + /// + /// + private void VerticalDistanceAnalysis(string type, GSOFeature selectedFeature, List _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(); + } + /// + /// 垂直净距分析中 表格行的 双击定位 功能。 与覆土分析的实现方法不同,主要原因是需要标注垂距 + /// + /// + /// + 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); + } + } + } + } + + /// + /// 水平净距分析 功能界面中 开始分析按钮 的事件处理 + /// + /// + /// + 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; + } + + + /// + /// 计算指定feature对象与除了该feature所在图层之外的 所有管线图层中的所有feature对象 的水平距离 并记录符合要求的管线 功能 + /// + /// + /// + /// + /// + private void HorizontalDistanceAnalysis(GSOFeature selectedFeature, List _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)); + } + } + } + } + } + /// + /// 水平净距分析 功能界面中 表格的 双击定位 功能 + /// + /// + /// + 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); + } + } + } + } + } + /// + /// 碰撞分析 功能界面中 开始分析按钮 事件处理 + /// + /// + /// + 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; + } + /// + /// 碰撞分析功能界面中 表格的 双击定位 功能 + /// + /// + /// + 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); + } + } + } + } + + + + /// + /// 覆土分析功能操作界面中的 选择管线 复选框选中状态改变事件处理 + /// + /// + /// + private void checkBoxX5_CheckedChanged(object sender, EventArgs e) + { + clearFeatureHighLight(); + if (checkBoxX5.Checked) + { + comboBoxEx3.SelectedItem = null; + 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; + } + } + /// + /// 覆土分析功能操作界面中的 选择图层 复选框选中状态改变事件处理 + /// + /// + /// + 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(); + } + /// + /// 覆土分析功能操作界面中的 图层下拉框选中项改变事件处理 + /// + /// + /// + 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; + } + } + } + /// + /// 覆土分析功能操作界面中的 开始分析 按钮事件处理 + /// + /// + /// + 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; + + + GSOPoint3d markerPosition = new GSOPoint3d(); + 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]; + GSOPoint3d pt = new GSOPoint3d(); + + 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"); + + pt.X = pts[m].X; + pt.Y = pts[m].Y; + pt.Z = 0; + markerPosition = LabelVerticalDistance(layerTemp, pts[m], pt, Convert.ToDouble(dataGridViewX7.Rows[idx].Cells[2].Value), true); + 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]; + GSOPoint3d pt = new GSOPoint3d(); + 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"); + + pt.X = pts[m].X; + pt.Y = pts[m].Y; + pt.Z = 0; + markerPosition = LabelVerticalDistance(layerTemp, pts[m], pt, Convert.ToDouble(dataGridViewX7.Rows[idx].Cells[2].Value), true); + + 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; + } + + /// + /// 覆土分析中 表格的 双击定位 功能 + /// + /// + /// + 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); + } + } + } + } + } + /// + /// 覆土分析功能操作界面中的 导出Excel按钮 事件处理 + /// + /// + /// + private void buttonX10_Click(object sender, EventArgs e) + { + if (dataGridViewX7.Rows.Count > 0) + { + ExportExcel("覆土分析", dataGridViewX7, null); + } + else + { + MessageBox.Show("表格内容为空!", "提示"); + } + } + /// + /// 覆土分析功能操作界面底部的 关闭 按钮事件处理 + /// + /// + /// + 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(); + layerTemp.RemoveAllFeature(); + + if (buttonItem1.Checked) + { + sideBar1.ExpandedPanel = sideBarPanelItem3; + } + else + { + sideBar1.Visible = false; + } + globeControl1.Refresh(); + + //Refresh(); + } + + + /// + /// 垂直净距分析 功能界面中 清除分析结果按钮 事件处理 + /// + /// + /// + 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(); + } + /// + /// 水平净距分析 功能界面中 清除分析结果按钮 事件处理 + /// + /// + /// + 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(); + } + + /// + /// 垂直净距分析功能界面中 关闭按钮 事件处理 + /// + /// + /// + 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(); + } + /// + /// 水平净距分析功能界面中 删除缓冲区按钮 事件处理 + /// + /// + /// + private void buttonX14_Click(object sender, EventArgs e) + { + 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(); + } + + /// + /// 导出指定DataGridView控件中的内容 + /// + /// + /// + 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(); + } + } + } + } + + /// + /// 垂直净距分析功能界面中 导出Excel按钮 事件处理 + /// + /// + /// + private void buttonX4_Click(object sender, EventArgs e) + { + if (dataGridViewX3.Rows.Count > 0) + { + ExportExcel("垂直净距分析", dataGridViewX3, listBox1); + } + else + { + MessageBox.Show("表格内容为空!", "提示"); + } + } + /// + /// 水平净距分析功能界面中 导出Excel按钮 事件处理 + /// + /// + /// + private void buttonX4_Click_shuiping(object sender, EventArgs e) + { + if (dataGridViewX9.Rows.Count > 0) + { + ExportExcel("水平净距分析", dataGridViewX9, listBox3); + } + else + { + MessageBox.Show("表格内容为空!", "提示"); + } + } + + + /// + /// 清除所有坑 菜单 + /// + /// + /// + private void buttonItem3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItem3.Text); + + globeControl1.Globe.RemoveAllPits(); + } + + //} + /// + /// 大气层 菜单 + /// + /// + /// + private void buttonItem17_Click_1(object sender, EventArgs e) + { + globeControl1.Globe.Atmosphere.Visible = !globeControl1.Globe.Atmosphere.Visible; + buttonItemSH1.Checked = globeControl1.Globe.Atmosphere.Visible; + globeControl1.Refresh(); + } + /// + /// 经纬网 菜单 + /// + /// + /// + private void buttonItem20_Click(object sender, EventArgs e) + { + globeControl1.Globe.LatLonGrid.Visible = !globeControl1.Globe.LatLonGrid.Visible; + buttonItemSH3.Checked = globeControl1.Globe.LatLonGrid.Visible; + globeControl1.Globe.Refresh(); + } + /// + /// 状态条 菜单 + /// + /// + /// + private void buttonItem21_Click_1(object sender, EventArgs e) + { + globeControl1.Globe.StatusBar.Visible = !globeControl1.Globe.StatusBar.Visible; + buttonItemSH4.Checked = globeControl1.Globe.StatusBar.Visible; + globeControl1.Globe.Refresh(); + } + + + + /// + /// 添加指定路径下的数据 功能 + /// + /// + /// + 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); + //CheckDatasetGeoReference(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; + } + return objRes; + } + /// + /// 刷新目录树 功能 + /// + 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); + } + } + /// + /// 判断图层是否包含字段列表 + /// + /// + /// + 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; + } + + /// + /// 统计指定图层在指定范围内的所有feature对象 + /// + /// + /// + /// + 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; + } + /// + /// 碰撞分析功能界面中 选择管线复选框 选中状态改变事件处理 + /// + /// + /// + private void checkBoxX3_CheckedChanged(object sender, EventArgs e) + { + clearFeatureHighLight(); + if (checkBoxX3.Checked) + { + comboBoxEx2.SelectedItem = null; + 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; + } + } + /// + /// 碰撞分析功能界面中 选择图层复选框 选中状态改变事件处理 + /// + /// + /// + 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(); + } + /// + /// 碰撞分析功能界面中 选择图层下拉框 选中项改变事件处理 + /// + /// + /// + 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; + } + } + } + /// + /// 清除所有图层中的所有feature对象的高亮状态 功能 + /// + 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); + } + } + } + } + for (int i = 0; i < globeControl2.Globe.Layers.Count; i++) + { + GSOLayer layer = globeControl2.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; + } + } + } + + if (globeControl1.Globe.Action == EnumAction3D.SelectObject) + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + //globeControl1.Globe.Action = EnumAction3D.SelectObject; + } + } + + /// + /// 碰撞分析功能界面中 清除分析结果按钮 事件处理 + /// + /// + /// + 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(); + } + /// + /// 碰撞分析功能界面中 导出Excel按钮 事件处理 + /// + /// + /// + private void buttonX6_Click(object sender, EventArgs e) + { + if (dataGridViewX5.Rows.Count > 0) + { + ExportExcel("碰撞分析", dataGridViewX5, listBox2); + } + else + { + MessageBox.Show("表格内容为空!", "提示"); + } + } + /// + /// 导出CAD 菜单 + /// + /// + /// + private void btnExportCAD_Click(object sender, EventArgs e) + { + FrmExportCADS frm = new FrmExportCADS(globeControl1, m_PipelineLayerNames); + frm.ShowDialog(); + } + + ///// + ///// 区域分析 菜单 + ///// + ///// + ///// + //private void buttonItem50_Click(object sender, EventArgs e) + //{ + // buttonItem50.Checked = !buttonItem50.Checked; + // ribbonBarQY.Visible = buttonItem50.Checked; + // ribbonBarQY.Location = new Point(0, 0); + //} + + + /// + /// 连接数据库 菜单事件处理 + /// + /// + /// + 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; + } + } + } + /// + /// 数据验证 菜单 + /// + /// + /// + private void buttonItem80_Click(object sender, EventArgs e) + { + FrmValiData frm = new FrmValiData(globeControl1); + frm.ShowDialog(); + } + /// + /// 根据指定图层创建图层节点并将节点添加到图层管理节点的子节点集合中 + /// + /// + 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; + + if (!layerManagerNode.Nodes.Contains(node)) + { + layerManagerNode.Nodes.Insert(0, node); + layerManagerNode.Expand(); + } + } + } + /// + /// 数据库备份 菜单 + /// + /// + /// + 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(); + } + } + } + + + + #region Fan 去掉 + //GSOFeature emitterFeature; // 粒子要素 + /// + /// 添加火苗 功能 + /// + /// + /// + /// + 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); + + } + /// + /// 添加喷泉 功能 + /// + /// + /// + /// + 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); + } + #endregion + + /// + /// 获取指定图层中最后一个feature对象的名称对应的整数 + /// + /// + /// + 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; + } + /// + /// 设置除指定标注图层之外的所有标注图层不可见 + /// + /// + 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; + } + } + } + } + } + + /// + /// 判断选中的对象是否为管线 + /// + /// 被选中管线 + /// 返回一根线 + 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; + } + + /// + /// 创建label要素 功能 + /// + /// 添加label要素的feature + /// feature的位置 + /// label要素名字 + /// feature名字 + /// label要素距离点的位置 + /// + 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; + } + + + + /// + /// 获取指定两点组成的线的长度 功能 + /// + /// + /// + /// + 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; + } + + /// + /// 图层节点树中 节点 右键单击事件处理 + /// + /// + /// + 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; + } + } + } + } + } + + /// + /// 标注管理、传感器管理 图层目录树的右键菜单中的 刷新列表 菜单 + /// + /// + /// + 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); + } + } + /// + /// 给指定的图层节点添加代表feature对象的子节点 + /// + /// + private void RefreshTreeNodeLayerFeatureList(TreeNode layerTreeNode) + { + layerTreeNode.Nodes.Clear(); + GSOLayer layer = (GSOLayer)layerTreeNode.Tag; + // 只将类型为内存数据集的图层列出,如果是其它类型的数据集可能数据量太大,没发显示在树控件中 + if (layer.Dataset is GSOFeatureDataset) + { + VisitFeature3Ds(layer.GetAllFeatures(), layerTreeNode); + } + } + + /// + /// 标注管理、传感器管理 图层目录树的右键菜单中的 移除所有 菜单 + /// + /// + /// + 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(); + } + } + + /// + /// 图层目录树的 节点对应的复选框选中状态改变事件处理 + /// + /// + /// + private void layerMarkerTree_AfterCheck(object sender, TreeViewEventArgs e) + { + if (e.Action != TreeViewAction.Unknown) + { + CheckTreeNode(e.Node, e.Node.Checked); + } + } + /// + /// 改变指定节点对应的复选框的选中状态 + /// + /// + /// + private void CheckTreeNode(TreeNode node, Boolean bChecked) + { + CheckChildTreeNode(node, bChecked); + globeControl1.Globe.Refresh(); + } + /// + /// 改变指定节点的子节点对应的复选框的选中状态 + /// + /// + /// + 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); + } + } + /// + /// 标注管理、传感器管理 目录树中的feature节点的右键菜单中的 删除 菜单 + /// + /// + /// + 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(); + } + } + + /// + /// 双屏对比 菜单 + /// + /// + /// + //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(); + // } + //} + /// + /// 模拟分析 菜单 + /// + /// + /// + //private void buttonItem51_Click(object sender, EventArgs e) + //{ + // buttonItem51.Checked = !buttonItem51.Checked; + // ribbonBarMN.Visible = buttonItem51.Checked; + // ribbonBarMN.Location = new Point(0, 0); + //} + + /// + /// 双屏设置 菜单 + /// + /// + /// + //private void buttonItem96_Click(object sender, EventArgs e) + //{ + // FrmLayerControl frm = new FrmLayerControl(layerTree,globeControl1,globeControl2); + // frm.Show(this); + //} + /// + /// 双屏联动 菜单 + /// + /// + /// + //private void buttonItem95_Click(object sender, EventArgs e) + //{ + // buttonItem95.Checked = !buttonItem95.Checked; + //} + ///// + /// 添加用户仓库 菜单 + /// + /// + /// + private void buttonItem108_Click(object sender, EventArgs e) + { + FrmUserRepo frm = new FrmUserRepo(-1); + frm.ShowDialog(); + } + /// + /// 用户仓库管理 菜单 + /// + /// + /// + private void buttonItem111_Click(object sender, EventArgs e) + { + FrmUserRepoMgr frm = new FrmUserRepoMgr(); + frm.ShowDialog(); + } + /// + /// 添加分系统 菜单 + /// + /// + /// + private void buttonItem112_Click(object sender, EventArgs e) + { + //FrmAPP frm = new FrmAPP(-1); + //frm.ShowDialog(); + } + /// + /// 分系统管理 菜单 + /// + /// + /// + private void buttonItem113_Click(object sender, EventArgs e) + { + //FrmAPPMgr frm = new FrmAPPMgr(); + //frm.ShowDialog(); + } + /// + /// 添加操作 菜单 + /// + /// + /// + private void buttonItem114_Click(object sender, EventArgs e) + { + FrmOper frm = new FrmOper(-1); + frm.ShowDialog(); + } + /// + /// 操作管理 菜单 + /// + /// + /// + private void buttonItem115_Click(object sender, EventArgs e) + { + FrmOperMgr frm = new FrmOperMgr(); + frm.ShowDialog(); + } + /// + /// 添加资源 菜单 + /// + /// + /// + private void buttonItem116_Click(object sender, EventArgs e) + { + FrmRESC frm = new FrmRESC(-1); + frm.ShowDialog(); + } + /// + /// 资源管理 菜单 + /// + /// + /// + private void buttonItem117_Click(object sender, EventArgs e) + { + FrmRESCMgr frm = new FrmRESCMgr(); + frm.ShowDialog(); + } + /// + /// 添加权限 菜单 + /// + /// + /// + private void buttonItem118_Click(object sender, EventArgs e) + { + FrmPerm frm = new FrmPerm(-1); + frm.ShowDialog(); + } + /// + /// 权限管理 菜单 + /// + /// + /// + private void buttonItem119_Click(object sender, EventArgs e) + { + FrmPermMgr frm = new FrmPermMgr(); + frm.ShowDialog(); + } + /// + /// 添加访问控制 菜单 + /// + /// + /// + private void buttonItem120_Click(object sender, EventArgs e) + { + FrmAccess frm = new FrmAccess(-1); + frm.ShowDialog(); + } + /// + /// 访问控制管理 菜单 + /// + /// + /// + private void buttonItem121_Click(object sender, EventArgs e) + { + FrmAccessMgr frm = new FrmAccessMgr(); + frm.ShowDialog(); + } + /// + /// 部门类型管理 菜单 + /// + /// + /// + private void buttonItem122_Click(object sender, EventArgs e) + { + FrmRegionTypeMgr frm = new FrmRegionTypeMgr(); + frm.ShowDialog(); + } + /// + /// 添加用户 菜单 + /// + /// + /// + private void buttonItem127_Click(object sender, EventArgs e) + { + FrmUserAdd frm = new FrmUserAdd(-1); + frm.ShowDialog(); + } + /// + /// 用户信息管理 菜单 + /// + /// + /// + private void buttonItem128_Click_1(object sender, EventArgs e) + { + FrmUserManager frm = new FrmUserManager(); + frm.ShowDialog(); + } + /// + /// 添加角色 菜单 + /// + /// + /// + private void 添加角色_Click(object sender, EventArgs e) + { + FrmRole frm = new FrmRole(-1); + frm.ShowDialog(); + } + /// + /// 所有角色管理 菜单 + /// + /// + /// + private void 角色管理_Click(object sender, EventArgs e) + { + FrmRoleMgr frm = new FrmRoleMgr(); + frm.ShowDialog(); + } + + /// + /// 部门角色管理 菜单 + /// + /// + /// + private void buttonItem133_Click(object sender, EventArgs e) + { + FrmRegionRoleMgr frm = new FrmRegionRoleMgr(); + frm.ShowDialog(); + } + /// + /// 部门管理 菜单 + /// + /// + /// + private void buttonItem130_Click(object sender, EventArgs e) + { + FrmRegionMgr frm = new FrmRegionMgr(); + frm.ShowDialog(); + } + + /// + /// 日志管理 菜单 + /// + /// + /// + private void buttonItem135_Click(object sender, EventArgs e) + { + FrmLogManager frm = new FrmLogManager(); + frm.ShowDialog(); + } + /// + /// 传感器信息查询 菜单 + /// + /// + /// + 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); + } + } + } + /// + /// 根据指定的图层的caption属性的值在配置文件中查找对应的数据库中的表的名称 + /// + /// 图层的caption属性的值 + /// 对应的数据库中的表的名称 + 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; + } + /// + /// 根据数据库中的表的名称 查找对应的表中的字段名称的集合 + /// + /// 数据库中的表的名称 + /// 对应的表中的字段名称的集合 + 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; + } + + /// + /// 历史曲线查询 菜单 + /// + /// + /// + 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; + /// + /// 传感器在线报警 菜单 + /// + /// + /// + 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); + } + /// + /// 传感器报警 功能中的 定时器 的触发事件处理 + /// + /// + /// + 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; + } + } + } + } + } + } + } + + + /// + /// 沿线运动 菜单 + /// + /// + /// + private void buttonItem138_Click(object sender, EventArgs e) + { + if (globeControl1.Globe.SelectedObject == null) + { + MessageBox.Show("请先选择一条线!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + return; + } + + GSOFeature lineFeature = globeControl1.Globe.SelectedObject; + if (lineFeature.Geometry == null || lineFeature.Geometry.Type != EnumGeometryType.GeoPolyline3D) + { + MessageBox.Show("请先选择一条线!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + return; + } + + OpenFileDialog dlg = new OpenFileDialog(); + dlg.Filter = "*.gcm;*.3ds|*.gcm;*.3ds|*.3ds|*.3ds|*.gcm|*.gcm"; + if (dlg.ShowDialog() == DialogResult.OK) + { + GSOGeoModel model = new GSOGeoModel(); + model.FilePath = dlg.FileName; + + GSOGeoDynamicRoute dynamicRoute = new GSOGeoDynamicRoute(); + dynamicRoute.ActorGeometry = model; + + GSORoute route = new GSORoute(); + GSOGeoPolyline3D geoline = (GSOGeoPolyline3D)lineFeature.Geometry; + for (int i = 0; i < geoline[0].Count; i++) + { + route.Add(geoline[0][i]); + } + route.CircleRoute = false; + route.Speed = 30; + route.RotateSpeed = 50; + route.AltitudeMode = geoline.AltitudeMode; + dynamicRoute.Route = route; + + GSOFeature feature = new GSOFeature(); + + dynamicRoute.Play(); + feature.Geometry = dynamicRoute; + + //GSOLabel gsoLabel = new GSOLabel(); + //gsoLabel.Text = "模型测试"; + //feature.Label = gsoLabel; + globeControl1.Globe.MinModelVisibleSize = 0; + + globeControl1.Globe.MemoryLayer.AddFeature(feature); + globeControl1.Globe.Refresh(); + } + } + /// + /// 回退 菜单 + /// + /// + /// + private void buttonItem99_Click(object sender, EventArgs e) + { + globeControl1.Globe.UnDoEdit(); + } + /// + /// 前进 菜单 + /// + /// + /// + private void buttonItem100_Click(object sender, EventArgs e) + { + globeControl1.Globe.ReDoEdit(); + } + /// + /// 水平净距 功能界面中的 标签内容改变事件处理 + /// + /// + /// + 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() + "米的管线有:"; + } + } + } + /// + /// 垂直净距 功能界面中的 标签内容改变事件处理 + /// + /// + /// + 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() + "米的管线有:"; + } + } + } + /// + /// 覆土分析 功能界面中的 标签内容改变事件处理 + /// + /// + /// + 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() + "米的管线有:"; + } + } + } + + /// + /// 传感器分类查询 全区域 菜单 + /// + /// + /// + private void buttonItemSensor全区域查询_Click(object sender, EventArgs e) + { + FrmAccessoriesSensor.ShowForm(globeControl1, instrumenLayerNames, 0); + } + /// + /// 传感器分类查询 绘制区域 菜单 + /// + /// + /// + private void buttonItemSensor绘制区域查询_Click(object sender, EventArgs e) + { + FrmAccessoriesSensor.ShowForm(globeControl1, instrumenLayerNames, 1); + } + + + /// + /// 碰撞分析 功能界面中 关闭按钮 事件处理 + /// + /// + /// + 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(); + } + /// + /// 覆土分析 功能界面中的 清除分析结果 按钮事件处理 + /// + /// + /// + 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(); + } + /// + /// 数字预处理 功能 + /// + /// + /// + private void 数字预处理buttonItem140_Click(object sender, EventArgs e) + { + FrmEditShapeFile frm = new FrmEditShapeFile(globeControl1); + frm.ShowDialog(this); + } + + + /// + /// 导出矢量 功能 将图层导出为kml和shp格式数据 + /// + /// + /// + private void 导出矢量buttonItem140_Click(object sender, EventArgs e) + { + List listVectorNames = new List(); + for (int i = 0; i < m_PipelineLayerNames.Count; i++) + { + 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 = ""; + /// + /// 绘制城市七线 功能按钮 + /// + /// + /// + 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; + } + } + } + /// + /// 七线审核 功能按钮 + /// + /// + /// + private void 七线审核buttonItem141_Click(object sender, EventArgs e) + { + FrmCityServerLineAnalysis frm = new FrmCityServerLineAnalysis(globeControl1, m_PipelineLayerNames); + frm.ShowDialog(this); + } + + /// + /// 间距分析 开始分析按钮 分析绘制的七线和管线的距离是否符合标准 + /// + /// + /// + 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; + } + /// + /// 间距分析 清除分析结果 + /// + /// + /// + 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(); + } + /// + /// 间距分析 导出Excel按钮 将间距分析的结果以Excel表格的形式导出 + /// + /// + /// + private void buttonExportExcel_Click(object sender, EventArgs e) + { + if (dataGridViewAnalysisResult.Rows.Count > 0) + { + ExportExcel("间距分析", dataGridViewAnalysisResult, listBoxStasticsResult); + } + else + { + MessageBox.Show("表格内容为空!", "提示"); + } + } + /// + /// 间距分析 关闭按钮 + /// + /// + /// + 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(); + } + /// + /// 间距分析 分析结果表格双击定位 + /// + /// + /// + 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); + } + } + } + } + /// + /// 间距分析 选择管线复选框 + /// + /// + /// + private void checkBoxSelectPipeline_CheckedChanged(object sender, EventArgs e) + { + clearFeatureHighLight();//清除高亮 + if (checkBoxSelectPipeline.Checked) + { + comboBoxLayer.SelectedItem = null; + 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; + } + } + /// + /// 间距分析 选择图层复选框 + /// + /// + /// + 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(); + } + /// + /// 间距分析 选择图层下拉框 + /// + /// + /// + 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; + } + } + } + + + + /// + /// 管线自动缩进 菜单 + /// + /// + /// + private void 管线自动缩进buttonItem140_Click(object sender, EventArgs e) + { + FrmPipelineIndented frm = new FrmPipelineIndented(globeControl1, m_PipelineLayerNames, workwellLayerNames); + 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 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); + // } + //} + + /// + /// 统计指定图层在指定范围内的所有feature对象 + /// + /// + /// + /// + 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) + { + 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 setLayerVisible(string layerName) + { + GSOLayer templayer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + if (templayer != null) + { + templayer.Visible = false; + } + globeControl1.Globe.Refresh(); + } + + /// + /// 连接数据库 + /// + /// + /// + private void buttonItem129_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL4_1.Text); + + FrmDatabaseParaSetting2 frm = new FrmDatabaseParaSetting2(globeControl1); + if (frm.ShowDialog() == DialogResult.OK) + { + ds = FrmDatabaseParaSetting2.ds; + if (ds != null) + { + ds.IsCloseSaved = false; + } + } + } + + /// + /// 一键审核---导入数据 + /// + /// + /// + private void buttonItem127_Click_2(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, "打开数据"); + + try + { + //if (shds == null) + //{ + //没连的话,直接连接审核库; //审核库配置读配置文件 + string dbIp = Utility.sgdbip; + string database = Utility.sgdbname; + string user = Utility.sgdbuser; + string pass = Utility.sgdbpwd; + /* + 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; + //} + } + catch (Exception ex) + { + LogError.PublishError(ex); + MessageBox.Show("内存过载请清理内存,并重新启动规划分析!", "提示"); + return; + } + + } + + /// + ///自动导出图片 + /// + /// + /// + private void buttonItem130_Click_1(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, "导出审核图"); + + 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))); + */ + + int mapWidth = 0; + int mapHeight = 0; + Point pt = getUpperLeftPoint(pt1, pt2, out mapWidth, out mapHeight); + int rightBottomX = pt.X + mapWidth; + int rightBottomY = pt.Y + mapHeight; + Image myImg = new Bitmap(mapWidth, mapHeight); + Graphics g = Graphics.FromImage(myImg); + g.CopyFromScreen(pt, new Point(0, 0), new Size(rightBottomX, rightBottomY)); + + 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; + } + } + } + /// + /// 一键审核功能 + ///
+ /// + /// + private void buttonItem128_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItem128.Text); + //垂直净距标准 + + frmSh = new FrmYJSHTC(globeControl1, globeControl2,layerTree); + + if (frmSh.ShowDialog() == DialogResult.OK) + { + frmWait = new FrmWait("一键审核……"); + frmWait.Location = new Point(this.Width - frmWait.Width - 10, this.Height - frmWait.Height - 50); + frmWait.Owner = this; + frmWait.Show(); + Thread thread = new Thread(new ThreadStart(doWork)); + thread.IsBackground = true; + thread.Start(); + } + } + + void doWork() + { + FrmShResult frmShResult = null; + + double dVerticalJingJuBiaoZhun = 1, dHorizontalJingJuBiaoZhun = 1; + if (frmSh.rukuLayer != null) + { + #region + this.Invoke((EventHandler)delegate + { + try + { + List managerLayerList = new List(); + for (int i = 0; i < layerManagerNode.Nodes.Count; i++) + { + managerLayerList.Add(layerManagerNode.Nodes[i].Text); + } + if (!managerLayerList.Contains(frmSh.rukuLayer.Caption)) + { + TreeNode node = new TreeNode(); + node.Tag = frmSh.rukuLayer; + node.Text = frmSh.rukuLayer.Dataset.Caption; + node.ImageIndex = 0; + node.SelectedImageIndex = 0; + node.Checked = frmSh.rukuLayer.Visible; + layerManagerNode.Nodes.Insert(0, node); + layerManagerNode.Expand(); + } + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "提示"); + } + }); + #endregion + + shlayername = frmSh.rukuLayer.Name; + globeControl1.Refresh(); + } + + if (frmShResult != null && !frmShResult.IsDisposed) + { + try + { + clearFeatureHighLight(); + ClearRedlineAnalyseResult(); + frmShResult.Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message); + } + } + + 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.analysis(); + + //MainFrm窗体显示控制,回到一键审核Tab + this.Invoke((EventHandler)delegate + { + frmShResult.Show(); + frmWait.Close(); + //将tab页恢复到一键审核 + ribbonTabItem11.Checked = true; + try + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + //zhanshi = false; + splitContainer1.Panel2Collapsed = true; + + panelOfTable.Visible = false; + legendSC.Visible = false; + legendSG.Visible = false; + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + } + catch (Exception ex) + { + MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + + }); + + boolfrmShResult = true; + } + else + { + + } + } + + + /// + /// 清除渲染结果 + /// + 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(); + } + /// + /// 已审核的图层 + /// + /// + /// + private void buttonItem132_Click_1(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItem132.Text); + + if (shds == null) + { + //没连的话,直接连接审核库; //审核库配置读配置文件 + string dbIp = Utility.sgdbip; + string database = Utility.sgdbname; + string user = Utility.sgdbuser; + string pass = Utility.sgdbpwd; + + /* + 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; + //} + + } + /// + /// 审核入库 + /// + /// + /// + private void buttonItem133_Click_1(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, "审核入库"); + FrmShRK frmShrk = new FrmShRK(globeControl1); + frmShrk.Show(); + } + /// + /// 模拟设计修改 + /// + /// + /// + private void buttonItem134_Click_1(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, "模拟设计修改"); + + 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 + { + + } + + } + + + /// + /// 绘制垂线 + /// + /// + /// + 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); + } + /// + /// 比较两个点是否是同一个点 + /// + /// + /// + /// + 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; + } + /// + /// 获得点到线的垂线距离及垂点 + /// + /// + /// + /// + /// + 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); + 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]; + } + /// + /// 获得斜率 + /// + /// + /// + /// + /// + /// + /// + 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); + } + } + /// + /// 根据默认投影参数,经纬度转xyz + /// + /// + /// + /// + 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; + } + /// + /// 根据投影参数,经纬度转xyz + /// + /// + /// + /// + /// + 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; + } + /// + /// 根据默认投影参数,xyz转经纬度 + /// + /// + /// + /// + 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; + } + /// + /// 根据投影参数,Xyz转经纬度 + /// + /// + /// + /// + /// + 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; + } + /// + /// 获得inpolygon的管线长度 + /// + /// + 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; + } + + + /// + /// 一键审核中调节透明度 + /// + /// + /// + private void sliderItem1_ValueChanged(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.sliderItem1.Text); + + globeControl1.Globe.GroundOpaque = 100 - sliderItem1.Value; + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(roadLayerName);//("180fd"); + if (layer != null) + { + layer.Opaque = 100 - sliderItem1.Value; + } + + optiValue = sliderItem1.Value; + } + /// + /// 红线审核中的透明度分析 + /// + /// + /// + private void sliderItem3_ValueChanged(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.sliderItem3.Text); + + globeControl1.Globe.GroundOpaque = 100 - sliderItem3.Value; + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(roadLayerName);//("180fd"); + if (layer != null) + { + layer.Opaque = 100 - sliderItem3.Value; + } + optiValue = sliderItem3.Value; + } + + #region yanxiaowei + //初始化DataGridViewX1控件 + public delegate void DataGridViewDelegate(DataTable dt, string strLable, string strLayer, bool initDataGrid); + /// + /// 代理函数,操作DatgridViewX1 + /// + /// + /// + public void InitDataGridViewX1(DataTable dt, string strLable, string strLayer, bool initDataGrid) + { + if (initDataGrid == true) + { + dataGridViewX1.DataSource = dt; + panelOfTable.Visible = true; + toolStripNumbers.Text = strLable; + dataGridViewX1.Tag = strLayer; + } + else + { + dataGridViewX1.DataSource = null; + dataGridViewX1.Refresh(); + panelOfTable.Visible = false; + toolStripNumbers.Text = ""; + dataGridViewX1.Tag = ""; + globeControl1.Globe.MemoryLayer.RemoveAllFeature();//清除双击产生的标注 + } + } + FrmAnalysisGuiHuaResult from; + /// + /// 主窗体下方属性表格 双击定位 功能 + /// + /// + /// + private void dataGridViewX1_MouseDoubleClick(object sender, MouseEventArgs e) + { + if (redSH == false) + { + 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 if (dataGridViewX1.Columns.Contains("标识器编号")) + { + featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["标识器编号"].Value.ToString(); + } + featureName = featureName.Trim(); + + GSOLayer layer = null; + layer = globeControl1.Globe.Layers.GetLayerByCaption(dataGridViewX1.Tag.ToString()); + + if (layer == null) return; + + GSOFeatures features = layer.GetFeatureByName(featureName, false); + if (features.Length == 0) return; + GSOFeature rowFeature = features[0]; + + ClassSearchAnalysis.AddMakerToLineFeature(globeControl1, rowFeature); + + } + } + } + else + { + if (e.Button == MouseButtons.Left) + { + if (from != null && !from.IsDisposed) + { + try + { + from.Close(); + } + catch (Exception ex) + { + LogError.PublishError(ex); + } + } + try + { + DataGridView.HitTestInfo hittestinfo = dataGridViewX1.HitTest(e.X, e.Y); + if (hittestinfo.RowIndex >= 0) + { + string layer = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["管线类型"].Value.ToString(); + string hxName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["红线编号"].Value.ToString(); + FrmAnalysisGuiHuaResult frm = new FrmAnalysisGuiHuaResult(globeControl1, lineStruct, featsList, + panelOfTable, dataGridViewX1, layer, hxName); + frm.Location = new Point(this.Width - frm.Width - 10, this.Height - frm.Height - 20); + frm.Show(this); + + from = frm; + } + } + catch (Exception ex) + { + LogError.PublishError(ex); + } + } + } + } + + /// + /// 空间查询 + /// + /// + /// + private void buttonItemSearch1_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemSearch1.Text); + + trackflag = "PipelineSpatialQuery"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; + + } + /// + /// 关键字查询 + /// + /// + /// + private void buttonItemSearch9_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch9.Text); + + FrmKeywordQuery.ShowForm(globeControl1, m_PipelineLayerNames, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 编号查询 + /// + /// + /// + private void buttonItemSearch2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch2.Text); + + FrmCodingQuery.ShowForm(globeControl1, m_PipelineLayerNames, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 坐标查询 + /// + /// + /// + private void buttonItemSearch3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch3.Text); + + FrmSetLatLonPos.ShowForm(globeControl1); + } + /// + /// 附属物查询 + /// + /// + /// + private void buttonItemSearch10_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch10.Text); + + FrmFittingQuery.ShowForm(globeControl1, instrumenLayerNames, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 管径查询 + /// + /// + /// + private void buttonItemSearch4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch4.Text); + + FrmDiameterQuery.ShowForm(globeControl1, m_PipelineLayerNames, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 材质查询 + /// + /// + /// + private void buttonItemSearch5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch5.Text); + + FrmMaterialSel.ShowForm(globeControl1, m_PipelineLayerNames, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 基本查询 + /// + /// + /// + private void buttonItemSearch6_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch6.Text); + + FrmBasicQuery.ShowForm(globeControl1, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 复合查询 + /// + /// + /// + private void buttonItemSearch7_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch7.Text); + + FrmQuerySQL.ShowForm(globeControl1, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 关联查询 + /// + /// + /// + private void buttonItemSearch8_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch8.Text); + + if (globeControl1.Globe.SelObjectCount != 1) + { + MessageBox.Show("请选中一个对象!", "提示"); + return; + } + + 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 || (feature.Geometry.Type == EnumGeometryType.GeoPolygon3D + || feature.Geometry.Type == EnumGeometryType.GeoWater)) + return; + else + { + ClassSearchAnalysis.ResultRelationAnalysis(globeControl1, feature, valueLayerNames, workwellLayerNames, + instrumenLayerNames, pipefittingLayerNames, m_PipelineLayerNames, valueAllowance); + } + } + } + #endregion + /// + /// 清除分析 + /// + /// + /// + private void buttonItemClear_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemClear.Text); + + globeControl1.Globe.ClearMeasure(); + layerTemp.RemoveAllFeature(); + layerTemp2.RemoveAllFeature(); + buttonItemLS5.Checked = false; + + dataGridViewX1.DataSource = null; + panelOfTable.Visible = false; + + 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); + + NetworkAnalysisTool.ClearAllTopAnalysis(this.globeControl1); + // 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();//清除所有坑 + + 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(); + } + } + + clearFeatureHighLight();//取消管线高亮 + + GSOLayer layerGround = globeControl1.Globe.Layers.GetLayerByCaption(roadLayerName);//("180fd"); + if (layerGround != null) + { + layerGround.Visible = true; + } + globeControl1.Refresh(); + globeControl2.Refresh(); + ClearRedlineAnalyseResult(); + globeControl1.Globe.Action = EnumAction3D.ActionNull; + } + /// + /// 管线长度全区域统计 + /// + /// + /// + private void buttonItemTJ1_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管线长度统计"); + + //pipeLineDis.Clear(); + //List list = new List(); + //for (int i = 0; i < m_PipelineLayerNames.Count; i++) + //{ + // GSOFeatures fs = Intersects_Pipeline(null, m_PipelineLayerNames[i]); + // if (fs!=null) + // list.Add(fs); + //} + + //FrmAllPipelineStatis frm = new FrmAllPipelineStatis(0, pipeLineDis, list, globeControl1, new DataGridViewDelegate(InitDataGridViewX1)); + FrmAllPipelineStatis frm = new FrmAllPipelineStatis(globeControl1,null, new DataGridViewDelegate(InitDataGridViewX1), m_PipelineLayerNames); + frm.Show(this); + + } + /// + /// 管线长度绘制区域统计 + /// + /// + /// + private void buttonItemTJ1_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管线长度统计"); + + trackflag = "PipelineDistanceStatistics"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; + } + /// + /// 阀门数量全区域统计 + /// + /// + /// + private void buttonItemTJ2_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "阀门数量统计"); + + //workWellLen.Clear(); + //List list = new List(); + ////找到所有阀门 + //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, globeControl1, new DataGridViewDelegate(InitDataGridViewX1)); + FrmValveStatistics frm = new FrmValveStatistics(globeControl1, null, new DataGridViewDelegate(InitDataGridViewX1)); + frm.Show(this); + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + } + /// + /// 阀门数量绘制区域统计 + /// + /// + /// + private void buttonItemTJ2_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "阀门数量统计"); + + trackflag = "valvequery"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; + } + /// + /// 井盖数量全区域统计 + /// + /// + /// + private void buttonItemTJ3_ALL_Click(object sender, EventArgs e) + { + FrmAllWorkWellStatis frm = new FrmAllWorkWellStatis(globeControl1, null, new DataGridViewDelegate(InitDataGridViewX1)); + frm.Show(this); + } + /// + /// 井盖数量绘制区域统计 + /// + /// + /// + private void buttonItemTJ3_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "井盖数量统计"); + + trackflag = "workwellquery"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; + } + /// + /// 管径分段统计全区域统计 + /// + /// + /// + private void buttonItemTJ4_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管径分段统计"); + + Frmpipediameterstatis.ShowForm(globeControl1, m_PipelineLayerNames, 0); + } + /// + /// 管径分段统计绘制区域统计 + /// + /// + /// + private void buttonItemTJ4_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管径分段统计"); + + trackflag = null; + Frmpipediameterstatis.ShowForm(globeControl1, m_PipelineLayerNames, 1); + } + /// + /// 埋深分段统计全区域统计 + /// + /// + /// + private void buttonItemTJ5_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "埋深分段统计"); + FrmpipeDeepstatis.ShowForm(globeControl1, m_PipelineLayerNames, 0); + } + /// + /// 埋深分段统计绘制区域统计 + /// + /// + /// + private void buttonItemTJ5_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "埋深分段统计"); + trackflag = null; + FrmpipeDeepstatis.ShowForm(globeControl1, m_PipelineLayerNames, 1); + } + /// + /// 管径分类统计全区域统计 + /// + /// + /// + private void buttonItemTJ6_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管径分类汇总"); + + FrmpipeDiametergather.ShowForm(globeControl1, m_PipelineLayerNames, 0); + } + /// + /// 管径分类统计绘制区域统计 + /// + /// + /// + private void buttonItemTJ6_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管径分类汇总"); + + trackflag = null; + FrmpipeDiametergather.ShowForm(globeControl1, m_PipelineLayerNames, 1); + } + /// + /// 材质分类统计全区域统计 + /// + /// + /// + private void buttonItemTJ7_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "材质分类汇总"); + + FrmpipeMaterialGather.ShowForm(globeControl1, m_PipelineLayerNames, 0); + } + /// + /// 材质分类统计绘制区域统计 + /// + /// + /// + private void buttonItemTJ7_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "材质分类汇总"); + + trackflag = null; + FrmpipeMaterialGather.ShowForm(globeControl1, m_PipelineLayerNames, 1); + } + /// + /// 附属物分类统计全区域统计 + /// + /// + /// + private void buttonItemTJ8_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "附属物分类汇总"); + + FrmAccessoriesgather.ShowForm(globeControl1, instrumenLayerNames, 0); + } + /// + /// 附属物分类统计绘制区域统计 + /// + /// + /// + private void buttonItemTJ8_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "附属物分类汇总"); + + trackflag = null; + FrmAccessoriesgather.ShowForm(globeControl1, instrumenLayerNames, 1); + } + /// + /// 碰撞分析 + /// + /// + /// + private void buttonItemFX1_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_4.Text); + + this.dataGridViewX4.Size = new System.Drawing.Size(195, 120); + 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(); + } + /// + /// 覆土分析 + /// + /// + /// + private void buttonItemFX1_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX5_1.Text); + this.dataGridViewX6.Size = new System.Drawing.Size(195, 120); + 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(); + } + /// + /// 间距分析 + /// + /// + /// + private void buttonItemFX1_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX1_3.Text); + + this.dataGridViewLineList.Size = new System.Drawing.Size(185, 120); + 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(); + } + /// + /// 垂直净距分析 + /// + /// + /// + private void buttonItemFX1_4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX1_4.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(); + } + /// + /// 水平净距分析 + /// + /// + /// + private void buttonItemFX1_5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_6.Text); + this.dataGridViewX8.Size = new System.Drawing.Size(185, 120); + 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(); + } + + #region Predaotr,断面分析 + /// + /// 横断面分析 + /// + /// + /// + private void buttonItemFX2_1_Click(object sender, EventArgs e) + { + globeControl1.Globe.Action = EnumAction3D.TrackPolyline; + globeControl1.Globe.TrackPolylineTool.VerticalLineVisible = true; + globeControl1.Globe.TrackPolylineTool.TrackMode = EnumTrackMode.SpaceTrack; + trackPolylineEndMode = EnumTrackPolylineEndMode.HDM_Analysis; + + } + /// + /// 纵断面分析 + /// + /// + /// + private void buttonItemFX2_2_Click(object sender, EventArgs e) + { + if (globeControl1.Globe.SelObjectCount<1) + { + MessageBox.Show("请选择一条或者多条管线!", "提示", MessageBoxButtons.OK, + MessageBoxIcon.Information); + return; + } + 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); + } + } + List feats = SectionAnalysisTool.ZDMAnalysis(selectFeatures); + if (feats != null && feats.Count >= 1) + { + FrmProfileAnalysis frm = new FrmProfileAnalysis(globeControl1, feats); + frm.Show(this); + } + } + /// + /// 道路断面分析 + /// + /// + /// + private void buttonItemFX2_3_Click(object sender, EventArgs e) + { + globeControl1.Globe.Action = EnumAction3D.TrackPolyline; + globeControl1.Globe.TrackPolylineTool.VerticalLineVisible = true; + globeControl1.Globe.TrackPolylineTool.TrackMode = EnumTrackMode.SpaceTrack; + trackPolylineEndMode = EnumTrackPolylineEndMode.DLDM_Analysis; + + } + /// + /// 基线剖面分析 + /// + /// + /// + private void buttonItemFX2_4_Click(object sender, EventArgs e) + { + globeControl1.Globe.Action = EnumAction3D.TrackPolyline; + globeControl1.Globe.TrackPolylineTool.VerticalLineVisible = true; + globeControl1.Globe.TrackPolylineTool.TrackMode = EnumTrackMode.SpaceTrack; + trackPolylineEndMode = EnumTrackPolylineEndMode.JXPM_Analysis; + + } + + #endregion + /// + /// 创建拓扑 + /// + /// + /// + private void buttonItemFX3_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX3_1.Text); + + FrmGenAndFaMenTopu frm = new FrmGenAndFaMenTopu(globeControl1, m_PipelineLayerNames, valueLayerNames); + frm.Show(this); + } + #region Predator :拓扑分析 + /// + /// 上游分析 + /// + /// + /// + private void buttonItemFX3_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX3_2.Text); + NetworkTraceUpDown(true); + } + /// + /// 下游分析 + /// + /// + /// + private void buttonItemFX3_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX3_3.Text); + NetworkTraceUpDown(false); + } + + /// + /// 上下游追踪 功能 + /// + /// + private void NetworkTraceUpDown(Boolean bTraceUp) + { + GSOFeature selLineFeature = globeControl1.Globe.SelectedObject; + if (selLineFeature == null || selLineFeature.Geometry == null || selLineFeature.Geometry.Type != EnumGeometryType.GeoPolyline3D) + { + MessageBox.Show("请点击“编辑”—“选中对象”选择一条线!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); + return; + } + GSOLayer selLayer = globeControl1.Globe.SelectedObjectLayer; + + NetworkAnalysisTool.TraceUpDownAnalysis(bTraceUp, + selLineFeature, selLayer); + } + + /// + /// 流向分析 + /// + /// + /// + private void buttonItemFX3_4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX3_4.Text); + + FrmFlow frm = new FrmFlow(globeControl1, m_PipelineLayerNames); + frm.Show(this); + } + /// + /// 关阀分析 + /// + /// + /// + private void buttonItemFX3_5_Click(object sender, EventArgs e) + { + if (globeControl1.Globe.SelObjectCount < 1) + { + MessageBox.Show("请选中至少一根管线!!"); + buttonItemFX3_5.Checked = false; + return; + } + GSOLayer resLayer = null; + GSOFeature resFeature = null; + globeControl1.Globe.GetSelectObject(0, out resFeature, out resLayer); + + String pipeLayerName = resLayer.Caption; + String pipeLayerNamePrefix = pipeLayerName.Substring(0, pipeLayerName.IndexOf("管线")); + GSOLayer valveLayer = globeControl1.Globe.Layers[pipeLayerNamePrefix + "阀门"]; + if (valveLayer == null) + { + MessageBox.Show("无" + pipeLayerNamePrefix+"阀门图层", "提示"); + return; + } + + GSOFeatures valveFeats = NetworkAnalysisTool.CloseValvesAnalysis(resFeature, + resLayer, valveLayer); + + if (valveFeats != null) + { + FrmCloseValves frm = new FrmCloseValves(this.globeControl1, valveFeats); + frm.Show(this); + } + else + { + MessageBox.Show("未找到关闭阀门"); + } + } + + /// + /// 连通分析 + /// + /// + /// + private void buttonItemFX3_6_Click(object sender, EventArgs e) + { + if (globeControl1.Globe.SelObjectCount < 2) + { + MessageBox.Show("请选中至少两个管线!!"); + buttonItemFX3_6.Checked = false; + return; + } + GSOFeature selFeat0, selFeat1; + GSOLayer layer0,layer1; + globeControl1.Globe.GetSelectObject(0, out selFeat0, out layer0); + globeControl1.Globe.GetSelectObject(1, out selFeat1, out layer1); + + if (!layer0.IsSameInnerObject(layer1)) + { + MessageBox.Show("不在同一个图层!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); + buttonItemFX3_6.Checked = false; + return; + } + NetworkAnalysisTool.ConnexityAnalysis(selFeat0, selFeat1, layer0); + } + /// + /// 爆管分析 + /// + /// + /// + private void buttonItemFX3_7_Click(object sender, EventArgs e) + { + NetworkTraceUpDown(true); //上游追踪: + + GSOFeature selLineFeature = globeControl1.Globe.SelectedObject; + if (selLineFeature == null || selLineFeature.Geometry == null || selLineFeature.Geometry.Type != EnumGeometryType.GeoPolyline3D) + { + MessageBox.Show("请点击“编辑”—“选中对象”选择一条线!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); + return; + } + GSOLayer selLayer = globeControl1.Globe.SelectedObjectLayer; + + NetworkAnalysisTool.ExplodeAnalysis(this.globeControl1,selLineFeature,selLayer); + + this.buttonItemFX3_5_Click(sender, e); //关阀分析: + + } + + #endregion + /// + /// 多边形开挖 + /// + /// + /// + private void buttonItemFX4_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_1.Text); + + trackflag = "pit"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; //是这个么?是的,在模型上 + } + /// + /// 挖方量分析 + /// + /// + /// + private void buttonItemFX4_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_2.Text); + + trackflag = "digFillAnalysis"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; + ActionToolMenuChecked(); + } + /// + /// 沿线开挖 + /// + /// + /// + private void buttonItemFX4_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_3.Text); + + if (!buttonItemFX4_3.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; + buttonItemFX4_3.Checked = true; + } + } + else + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + buttonItemFX4_3.Checked = false; + globeControl1.Globe.TrackPolylineTool.VerticalLineVisible = false; + } + ActionToolMenuChecked(); + } + /// + /// 创建隧道 + /// + /// + /// + private void buttonItemFX4_4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_4.Text); + + 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("场景中未加载隧道图层!", "提示"); + } + } + /// + /// 隐藏隧道 + /// + /// + /// + private void buttonItemFX4_5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_5.Text); + + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption("隧道"); + if (layer != null) + { + layer.Visible = !layer.Visible; + } + } + /// + /// 删除隧道 + /// + /// + /// + private void buttonItemFX4_6_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_6.Text); + + 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("请选中要删除的隧道!", "提示"); + } + } + /// + /// 通视分析 + /// + /// + /// + private void buttonItemFX5_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX5_1.Text); + + if (globeControl1.Globe.Action != EnumAction3D.VisibilityAnalysis) + { + //btnSpaceVisibilityAnalysis.Checked = true; + globeControl1.Globe.Action = EnumAction3D.VisibilityAnalysis; + } + else + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + // SetButtonChecked(); + } + } + /// + /// 可视域分析 + /// + /// + /// + private void buttonItemFX5_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX5_2.Text); + + globeControl1.Globe.Action = EnumAction3D.ViewshedAnalysis; + } + /// + /// 可视包络分析 + /// + /// + /// + private void buttonItemFX5_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX5_3.Text); + + globeControl1.Globe.Action = EnumAction3D.ViewEnvelopeAnalysis; + } + /// + /// 缓冲区分析 + /// + /// + /// + private void buttonItemFX6_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX6_1.Text); + + GSOFeature feat = globeControl1.Globe.SelectedObject; + if (feat == null) + { + MessageBox.Show("请选择要分析的要素!"); + return; + } + if (feat.Geometry.Type == EnumGeometryType.GeoPolyline3D) + { + GSOGeoPolyline3D line1 = feat.Geometry as GSOGeoPolyline3D; + if (line1 == null) + { + MessageBox.Show("请选择一条管线!"); + return; + } + + FrmBufferAnalysis frm = new FrmBufferAnalysis(globeControl1, line1, layerTemp); + frm.Show(this); + } + else + { + FrmBufferAnalysisBSQ frm = new FrmBufferAnalysisBSQ(globeControl1, layerTemp, bsqPT); + frm.Show(this); + } + + } + /// + /// 附属物分析 + /// + /// + /// + private void buttonItemFX6_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX6_2.Text); + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + FrmAccessoryAnalysis dlg = new FrmAccessoryAnalysis(globeControl1, layerTemp); + dlg.Show(this); + } + /// + /// 无源淹没分析 + /// + /// + /// + private void buttonItemFX6_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX6_3.Text); + + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + trackflag = "FloodAnalysis"; + } + /// + /// 水平距离 + /// + /// + /// + private void buttonItemLS1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS1.Text); + + globeControl1.Globe.Action = EnumAction3D.MeasureDistance; + globeControl1.Globe.DistanceRuler.SpaceMeasure = false; + buttonItemLS5.Checked = false; + } + /// + /// 垂直距离 + /// + /// + /// + private void buttonItemLS2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS2.Text); + + buttonItemLS5.Checked = false; + globeControl1.Globe.Action = EnumAction3D.MeasureHeight; + globeControl1.Globe.DistanceRuler.SpaceMeasure = false; + } + /// + /// 空间距离 + /// + /// + /// + private void buttonItemLS3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS3.Text); + + buttonItemLS5.Checked = false; + globeControl1.Globe.Action = EnumAction3D.MeasureDistance; + globeControl1.Globe.DistanceRuler.SpaceMeasure = true; + } + /// + /// 地表距离 + /// + /// + /// + private void buttonItemLS4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS4.Text); + + buttonItemLS5.Checked = false; + globeControl1.Globe.Action = EnumAction3D.MeasureDistance; + globeControl1.Globe.DistanceRuler.SpaceMeasure = false; + } + /// + /// 高度量算 + /// + /// + /// + private void buttonItemLS5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS5.Text); + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + buttonItemLS5.Checked = !buttonItemLS5.Checked; + if (buttonItemLS5.Checked) + { + globeControl1.Globe.Action = EnumAction3D.SelectObject; + } + } + /// + /// 水平面积 + /// + /// + /// + private void buttonItemLS6_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS6.Text); + + buttonItemLS5.Checked = false; + globeControl1.Globe.Action = EnumAction3D.MeasureArea; + globeControl1.Globe.AreaRuler.SpaceMeasure = true; + } + /// + /// 地表面积 + /// + /// + /// + private void buttonItemLS7_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS7.Text); + + buttonItemLS5.Checked = false; + globeControl1.Globe.Action = EnumAction3D.MeasureArea; + globeControl1.Globe.AreaRuler.SpaceMeasure = false; + + } + + # region Fan 重构标注代码 + /// + /// 标高标注 + /// + /// + /// + private void buttonItemSZ1_Click(object sender, EventArgs e) + { + GSOFeature resFeature = IsPipeLineOfSelectedObj(); + if (resFeature == null) + { + MessageBox.Show("请选中一根管线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + GSOGeoPolyline3D selLine = resFeature.Geometry as GSOGeoPolyline3D; + if (selLine[0].Count <= 1) + { + return; + } + + MarkTools.getInstance().showMarker(resFeature, + globeControl1, EnumMarkLayer.Mark_Altitude, ""); + } + /// + /// 管径标注 + /// + GSOFeature radiusMarkerFeature; + private void buttonItemBZ2_Click(object sender, EventArgs e) + { + GSOFeature resFeature = IsPipeLineOfSelectedObj(); + if (resFeature == null) + { + MessageBox.Show("请选中一根管线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + GSOGeoPolyline3D selLine = resFeature.Geometry as GSOGeoPolyline3D; + if (selLine[0].Count <= 1) + { + return; + } + + MarkTools.getInstance().showMarker(resFeature, + globeControl1, EnumMarkLayer.Mark_Diameter, ""); + } + /// + /// 埋深标注 + /// + /// + /// + private void buttonItemBZ3_Click(object sender, EventArgs e) + { + GSOFeature resFeature = IsPipeLineOfSelectedObj(); + if (resFeature == null) + { + MessageBox.Show("请选中一根管线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + GSOGeoPolyline3D selLine = resFeature.Geometry as GSOGeoPolyline3D; + if (selLine[0].Count <=1) + { + return; + } + + MarkTools.getInstance().showMarker(resFeature, + globeControl1, EnumMarkLayer.Mark_Depth, ""); + + } + /// + /// 坐标标注 + /// + /// + /// + private void buttonItemBZ4_Click(object sender, EventArgs e) + { + GSOFeature resFeature = IsPipeLineOfSelectedObj(); + if (resFeature == null) + { + MessageBox.Show("请选中一根管线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + GSOGeoPolyline3D selLine = resFeature.Geometry as GSOGeoPolyline3D; + if (selLine[0].Count <= 1) + { + return; + } + MarkTools.getInstance().showMarker(resFeature, + globeControl1, EnumMarkLayer.Mark_Location, ""); + } + /// + /// 距离标注 + /// + bool distanceMarker = false; + private void buttonItemBZ5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBZ5.Text); + + globeControl1.Globe.Action = EnumAction3D.TrackPolyline; + //globeControl1.Globe.DistanceRuler.MeasureMode = EnumDistanceMeasureMode.HVSLineMeasure; + distanceMarker = true; + } + /// + /// 自定义标注 + /// + /// + /// + private void buttonItemBZ6_Click(object sender, EventArgs e) + { + GSOFeature f = globeControl1.Globe.SelectedObject; + GSOLayer l = globeControl1.Globe.SelectedObjectLayer; + FrmCustomLabel frm = new FrmCustomLabel(globeControl1, l, f); + if (frm.ShowDialog() == DialogResult.OK) + { + MarkTools.getInstance().showMarker(f, globeControl1, EnumMarkLayer.Mark_Custom, frm.labelText); + } + } + /// + /// 扯旗标注 + /// + /// + /// + private void buttonItemBZ7_Click(object sender, EventArgs e) + { + GSOFeature f = globeControl1.Globe.SelectedObject; + GSOLayer l = globeControl1.Globe.SelectedObjectLayer; + FrmMarker frm = new FrmMarker(); + if (frm.ShowDialog() == DialogResult.OK) + { + MarkTools.getInstance().showMarker(f, globeControl1, EnumMarkLayer.Mark_Custom, frm.markerContent); + } + } + /// + /// 坡度标注 + /// + /// + /// + private void buttonItemBZ8_Click(object sender, EventArgs e) + { + GSOFeature resFeature = IsPipeLineOfSelectedObj(); + if (resFeature == null) + { + MessageBox.Show("请选中一根管线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + GSOGeoPolyline3D selLine = resFeature.Geometry as GSOGeoPolyline3D; + if (selLine[0].Count <= 1) + { + return; + } + + MarkTools.getInstance().showMarker(resFeature, + globeControl1, EnumMarkLayer.Mark_Slope, ""); + } + /// + /// 属性标注 + /// + /// + /// + private void buttonItemBZ9_Click(object sender, EventArgs e) + { + GSOFeature f = globeControl1.Globe.SelectedObject; + GSOLayer l = globeControl1.Globe.SelectedObjectLayer; + FrmPropertiesMarker frm = new FrmPropertiesMarker(globeControl1, l, f); + if (frm.ShowDialog() == DialogResult.OK) + { + MarkTools.getInstance().showMarker(f, globeControl1, EnumMarkLayer.Mark_Property, frm.labelText); + } + } + /// + /// 红线工具 + /// + /// + /// + private void buttonItemBZ10_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBZ10.Text); + 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; + } + } + /// + /// 标注管理 + /// + /// + /// + private void buttonItemBZ11_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBZ11.Text); + + buttonItemBZ11.Checked = !buttonItemBZ11.Checked; + 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 (buttonItemBZ11.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(); + } + } + + #endregion + /// + /// 飞行到目标点 + /// + /// + /// + private void buttonItemFXGJ1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFXGJ1.Text); + + FrmSetFlytoPos.ShowForm(globeControl1); + + } + /// + /// 自定义飞行 + /// + /// + /// + private void buttonItemFXGJ2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFXGJ2.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); + } + } + /// + /// 绕中心点飞行 + /// + /// + /// + private void buttonItemFXGJ3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFXGJ3.Text); + + globeControl1.Globe.FlyAroundCenter(10000, EnumFlyRepeatValueType.MiliSeconds); + globeControl1.Globe.CurFlyID = 1; + } + /// + /// 绕眼睛飞行 + /// + /// + /// + private void buttonItemFXGJ4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFXGJ4.Text); + + globeControl1.Globe.FlyAroundEye(720, EnumFlyRepeatValueType.Degrees); + globeControl1.Globe.CurFlyID = 2; + } + + /// + /// 权限管理 + /// + /// + /// + private void buttonItemXT1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT1.Text); + + FrmUserRoleMgr frm = new FrmUserRoleMgr(); + frm.ShowDialog(); + } + /// + /// 数据库管理 + /// + /// + /// + private void buttonItemXT2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT2.Text); + + //查看数据库列表 + FrmDbManager frm = new FrmDbManager(); + frm.ShowDialog(); + } + /// + /// 用户列表 + /// + /// + /// + private void buttonItemXT3_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT3_1.Text); + + FrmUserManager frm = new FrmUserManager(); + frm.ShowDialog(); + } + /// + /// 创建新用户 + /// + /// + /// + private void buttonItemXT3_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT3_2.Text); + + FrmUserAdd frm = new FrmUserAdd(-1); + frm.ShowDialog(); + } + /// + /// 人员修改 + /// + /// + /// + private void buttonItemXT4_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT4_2.Text); + + FrmAppUSER appUSER = new FrmAppUSER(); + appUSER.ShowDialog(); + } + /// + /// 增加人员 + /// + /// + /// + private void buttonItemXT4_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT4_1.Text); + + FrmAppUSERRESET appUSERRESET = new FrmAppUSERRESET(); + appUSERRESET.ShowDialog(); + } + /// + /// 统计数据 + /// + /// + /// + private void buttonItemZTT1_Click(object sender, EventArgs e) + { + ////日志记录 + //LogManager.saveLog(Utility.userName, this.buttonItemZTT1.Text); + + //PATM patm = new PATM(); + //patm.operation = "Statistic"; + //patm.Text = "统计专题图管理"; + //patm.ShowDialog(); + } + /// + /// 热点功能统计 + /// + /// + /// + private void buttonItemZTT2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT2.Text); + + FrmHotFuncStat frmhfs = new FrmHotFuncStat(); + frmhfs.ShowDialog(); + } + + private void buttonItemZTT3_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT3_1.Text); + + FrmAPP appfrm = new FrmAPP("专题图申请"); + appfrm.ShowDialog(); + } + + private void buttonItemZTT3_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT3_2.Text); + + FrmAPPFORASK appForask = new FrmAPPFORASK("专题图审核"); + appForask.ShowDialog(); + } + + private void buttonItemZTT3_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT3_3.Text); + + FrmAPPregion appregion = new FrmAPPregion("专题图审核"); + appregion.ShowDialog(); + } + + private void buttonItemZTT4_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT4_1.Text); + + FrmAPP appfrm = new FrmAPP("打印申请"); + appfrm.ShowDialog(); + } + + private void buttonItemZTT4_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT4_2.Text); + + FrmAPPFORASK appForask = new FrmAPPFORASK("打印审核"); + appForask.ShowDialog(); + } + + private void buttonItemZTT4_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT4_3.Text); + + FrmAPPregion appregion = new FrmAPPregion("打印审核"); + appregion.ShowDialog(); + } + + private void buttonItemZTT5_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT5_1.Text); + + FrmAPP appfrm = new FrmAPP("拷贝申请"); + appfrm.ShowDialog(); + } + + private void buttonItemZTT5_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT5_2.Text); + + FrmAPPFORASK appForask = new FrmAPPFORASK("拷贝审核"); + appForask.ShowDialog(); + } + + private void buttonItemZTT5_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT5_3.Text); + + FrmAPPregion appregion = new FrmAPPregion("拷贝审核"); + appregion.Show(); + } + + private int connectServerCount = 0; + + /// + /// 还原球到实测库 + /// + 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); + } + + if (layerManagerNode.Nodes.Count > 0) + { + for (int i = layerManagerNode.Nodes.Count - 1; i >= 0; i--) + { + layerManagerNode.Nodes[i].Remove(); + + } + } + + globeControl1.Refresh(); + + } + + private void buttonItemSPSZ_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSPSZ.Text); + + FrmLayerControl frm = new FrmLayerControl(layerTree, globeControl1, globeControl2); + frm.Show(this); + } + + /// + /// 碰撞审查 + /// + /// + /// + private void buttonItemSH1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSH1.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 buttonItemSH2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSH2.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 buttonItemSH3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSH3.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 buttonItemSH4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSH4.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 buttonItemSH5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSH5.Text); + FrmCityServerLineAnalysis frm = new FrmCityServerLineAnalysis(globeControl1, m_PipelineLayerNames); + frm.Show(this); + } + #region 数据管理-导入文件 + ///// + ///// 数据管理-导入本地坐标系文件 + ///// + ///// + ///// + //private void buttonItemSJGL1_1_Click(object sender, EventArgs e) + //{ + // //日志记录 + // LogManager.saveLog(Utility.userName, this.buttonItemSJGL1_1.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(); + // } + // } + //} + + ///// + ///// 数据管理-导入其他坐标系文件 + ///// + ///// + ///// + //private void buttonItemSJGL1_2_Click(object sender, EventArgs e) + //{ + // //日志记录 + // LogManager.saveLog(Utility.userName, this.buttonItemSJGL1_2.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(); + // } + // } + //} + #endregion + /// + /// 数据质量检查 + /// + /// + /// + private void buttonItemSJGL2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL2.Text); + FrmValiData frm = new FrmValiData(globeControl1); + frm.ShowDialog(); + } + /// + /// 数据预处理 + /// + /// + /// + private void buttonItemSJGL3_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL3.Text); + + FrmEditShapeFile frm = new FrmEditShapeFile(globeControl1); + frm.ShowDialog(this); + } + /// + /// 连接数据库 + /// + /// + /// + private void buttonItemSJGL4_1_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL4_1.Text); + + FrmDatabaseParaSetting frm = new FrmDatabaseParaSetting(globeControl1); + if (frm.ShowDialog() == DialogResult.OK) + { + ds = FrmDatabaseParaSetting.ds; + if (ds != null) + { + ds.IsCloseSaved = false; + } + } + } + /// + /// 管线入库 + /// + /// + /// + private void buttonItemSJGL4_2_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL4_2.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 buttonItemSJGL4_3_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL4_3.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 buttonItemSJGL5_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL5.Text); + + Cyberpipe.Forms.FrmProject frm = new Cyberpipe.Forms.FrmProject(); + frm.ShowDialog(); + } + /// + /// 元数据基本管理 + /// + /// + /// + private void buttonItemSJGL6_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL6_1.Text); + + FrmMetadata frmmd = new FrmMetadata(); + frmmd.ShowDialog(); + } + /// + /// 元数据查询管理 + /// + /// + /// + private void buttonItemSJGL6_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL6_2.Text); + + FrmMetadataStat frmmds = new FrmMetadataStat(); + //frmmds.Show(); + frmmds.ShowDialog(); + } + /// + /// 操作日志管理 + /// + /// + /// + private void buttonItemSJGL7_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL7.Text); + + FrmLogOper frmlo = new FrmLogOper(); + frmlo.ShowDialog(); + } + /// + /// 数据字典管理 + /// + /// + /// + private void buttonItemSJGL8_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL8.Text); + + FrmMDDictory frmmdd = new FrmMDDictory(); + frmmdd.ShowDialog(); + } + /// + /// 数据库备份 + /// + /// + /// + private void buttonItemSJGL9_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL9.Text); + + //新 + FrmBACKORACLE backOracle = new FrmBACKORACLE(); + backOracle.Show(); + } + /// + /// 创建管段 + /// + /// + /// + private void buttonItemBJ1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ1.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; + } + } + /// + /// 创建附属物 + /// + /// + /// + private void buttonItemBJ2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ2.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); + } + } + /// + /// 创建特征管点 + /// + /// + /// + private void buttonItemBJ3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ3.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); + } + } + /// + /// 绘制城市七线 + /// + /// + /// + private void buttonItemBJ4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ4.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; + } + } + } + /// + /// 选中对象 + /// + /// + /// + private void buttonItemBJ5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ5.Text); + + globeControl1.Globe.Action = EnumAction3D.SelectObject; + } + /// + /// 平移对象 + /// + /// + /// + private void buttonItemBJ6_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ6.Text); + + globeControl1.Globe.Action = EnumAction3D.MoveObject; + } + /// + /// 升降对象 + /// + /// + /// + private void buttonItemBJ7_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ7.Text); + + globeControl1.Globe.Action = EnumAction3D.ElevateObject; + } + /// + /// 旋转对象 + /// + /// + /// + private void buttonItemBJ8_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ8.Text); + + globeControl1.Globe.Action = EnumAction3D.RotateObject; + } + /// + /// 连接管段 + /// + /// + /// + private void buttonItemBJ9_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ9.Text); + + if (globeControl1.Globe.SelObjectCount < 2) + { + MessageBox.Show("对不起,请至少选中2个对象!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + return; + } + globeControl1.Globe.InsertJointPipeline(false); + } + /// + /// 后退 + /// + /// + /// + private void buttonItemBJ11_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemBJ11.Text); + globeControl1.Globe.UnDoEdit(); + } + /// + /// 前进 + /// + /// + /// + private void buttonItemBJ12_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemBJ12.Text); + + globeControl1.Globe.ReDoEdit(); + } + /// + /// 导出CAD + /// + /// + /// + private void buttonItemBJ10_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ10_1.Text); + + #region 导出成dxf格式 + List listVectorNames = new List(); + 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(); + #endregion + } + /// + /// 导出矢量 + /// + /// + /// + private void buttonItemBJ10_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ10_2.Text); + + List listVectorNames = new List(); + 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 buttonItemBJ13_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemBJ13.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(); + } + } + MessageBox.Show("删除成功!", "提示"); + } + else + { + MessageBox.Show("请选中要删除的模型!", "提示"); + } + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + } + + private void buttonItemHX1_1_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]; + string filePath = dlg.FileName; + string lastname = Path.GetFileName(filePath); + + 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(); + } + + } + } + } + + public struct LineStruct + { + public string layerName; + public string layerCode; + public string lineLength; + public string hxName; + } + + List lineStruct = new List(); + List featsList = new List(); + + /// + /// 红线审核 + /// + /// + /// + private void buttonItemHX2_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemHX2.Text); + redSH = true; + featsList.Clear(); + lineStruct.Clear(); + List listPipelineLayers = new List(); + + GSOLayer layer = null; + for (int i = 0; i < m_PipelineLayerNames.Count; i++) + { + layer = globeControl1.Globe.Layers.GetLayerByCaption(m_PipelineLayerNames[i]); + if (layer != null) + { + listPipelineLayers.Add(layer); + } + } + //yanxiaowei 重构 + GSOFeatures selectFeatures=new GSOFeatures(); + for (int i = 0; i < globeControl1.Globe.SelObjectCount; i++) + { + GSOFeature feature = null; + globeControl1.Globe.GetSelectObject(i, out feature, out layer); + selectFeatures.Add(feature); + } + DataTable table=new DataTable(); + + ClassGSOTool.CalculateRedLineResult(out table, redSH, selectFeatures, globeControl1, + listPipelineLayers,out lineStruct, out featsList); + + if (table.Rows.Count != 0) + AddDatagridView(table); + else + { + MessageBox.Show("没有侵入地块红线的管线数据!", "提示"); + dataGridViewX1.DataSource = null; + panelOfTable.Visible = false; + return; + } + } + + private void AddDatagridView(DataTable table) + { + dataGridViewX1.DataSource = table; + panelOfTable.Visible = true; + panelOfTable.Height = 200; + toolStripNumbers.Text = "红线审核 |共有:" + table.Rows.Count + "条"; + toolStripDropDownButton3.Visible = true; + } + /// + /// 主窗体 下方的工具条中的 导出.xls文件 按钮事件处理 + /// + /// + /// + private void toolStripDropDownButton3_Click(object sender, EventArgs e) + { + if (dataGridViewX1.Rows.Count == 0) + { + MessageBox.Show("表格内容为空!", "提示"); + return; + } + + string strSaveFile = string.Empty; + SaveFileDialog savefiledialog = new SaveFileDialog(); + savefiledialog.Filter = "Excel文件|*.xls,*.xlsx"; + savefiledialog.AddExtension = true; + savefiledialog.FileName = "红线审核"; + if (savefiledialog.ShowDialog() == DialogResult.OK) + strSaveFile = savefiledialog.FileName; + else return; + + ExpEXCEL.ExpToExcel(dataGridViewX1, strSaveFile, "红线审核", lineStruct, featsList); + MessageBox.Show("导出成功!"); + } + /// + /// 去除集合中重复的管线 + /// + /// + /// + /// + private GSOFeatures getFeaturesByFilter(GSOFeatures features, string fieldName) + { + if (features == null) + { + return null; + } + GSOFeatures featuresGet = new GSOFeatures(); + for (int i = 0; i < features.Length; i++) + { + GSOFeature featureFromFS = features[i]; + string fieldValueFromFS = featureFromFS.GetValue(fieldName).ToString().Trim(); + bool isHas = false; + for (int j = featuresGet.Length - 1; j >= 0; j--) + { + GSOFeature featureFromFSGet = featuresGet[j]; + string fieldValueFromFSGet = featureFromFSGet.GetValue(fieldName).ToString().Trim(); + if (fieldValueFromFS.Equals(fieldValueFromFSGet)) + { + isHas = true; + break; + } + } + if (isHas == false) + { + featuresGet.Add(featureFromFS.Clone()); + } + } + return featuresGet; + } + + private void sliderItem2_ValueChanged(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.sliderItem2.Text); + + globeControl1.Globe.GroundOpaque = 100 - sliderItem2.Value; + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(roadLayerName);//("180fd"); + if (layer != null) + { + layer.Opaque = 100 - sliderItem2.Value; + } + layer = globeControl2.Globe.Layers.GetLayerByCaption("180fd");//("180fd"); + if (layer != null) + { + layer.Opaque = 100 - sliderItem2.Value; + } + globeControl2.Globe.GroundOpaque = 100 - sliderItem2.Value; + + optiValue = sliderItem2.Value; + } + /// + /// 数据管理导入文件 + /// + /// + /// + private void buttonItemSJGL1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL1.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.Multiselect = true; + if (dlg.ShowDialog() == DialogResult.OK) + { + //自定义lprj文件名,从程序中复制一lprj文件。 + string filePath = dlg.FileName; + string lastname = Path.GetFileName(filePath); + + 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, 100); + + globeControl1.Refresh(); + } + } + } + + private void buttonItemHX1_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemHX1.Text); + + GSODataSource dataSpace = globeControl1.Globe.DataManager.OpenOracleDataSource(Utility.DBServer.Trim() + "/" + Utility.dbdatabase.Trim(), "", "", Utility.userID, Utility.DBPassword); + string filepath = ""; + //日志记录 + OpenFileDialog dlg = new OpenFileDialog(); + dlg.Filter = "矢量数据(*.shp)|*.shp|矢量数据(*.lgd)|*.lgd|CAD数据(*.dxf)|*.dxf|全部支持格式(*.lgd,*.shp,*.dxf)|*.lgd;*.shp;*.dxf;"; + dlg.Multiselect = true; + + #region 临时图层显示 + if (dlg.ShowDialog() == DialogResult.OK) + { + string filePath = dlg.FileName; + string lastname = Path.GetFileName(filePath); + + #region + for (int i = 0; i < dlg.FileNames.Length; i++) + { + string strDataPath = dlg.FileNames[i]; + filepath = strDataPath; + + GSOLayer layer = globeControl1.Globe.Layers.Add(strDataPath); + GSOFeatures RedFeatures = layer.GetAllFeatures(); + + 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(); + RedFeatures = features; + 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; + } + + /////////////////////////////////////////////////////////////////////////////////////////// + globeControl1.Globe.Layers.MoveTo(0, globeControl1.Globe.Layers.Count - 1); + globeControl1.Refresh(); + } + + IModelBuilder modelBuilder = new RedLineBuilder(); + + modelBuilder.batchInsert(dataSpace, redDt, RedFeatures); + + } + #endregion + + } + #endregion + } + /// + /// 定位 + /// + /// + /// + private void buttonItemLocation_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemLocation.Text); + + FrmFlyToPosition fly = new FrmFlyToPosition(globeControl1,globeControl2); + fly.Show(this); + } + /// + /// 2015-10-17演示代码 红线审核 + /// + /// + /// + private void ribbonTabItem6_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.FlyToPosition(new GSOPoint3d(120.610963, 31.188121, 50), EnumAltitudeMode.Absolute, -4, 50, 800); + globeControl1.Globe.FlyToPointSpeed = 10000000; + globeControl1.Globe.Action = EnumAction3D.SelectObject; + globeControl1.Refresh(); + + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + + //zhanshi = false; + redSH = true; + splitContainer1.Panel2Collapsed = true; + legendSG.Visible = false; + legendSC.Visible = false; + ClearGZData(); + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = true; + } + + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 基础工具 + /// + /// + /// + private void ribbonTabItem1_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + //zhanshi = false; + redSH = false; + splitContainer1.Panel2Collapsed = true; + panelOfTable.Visible = false; + legendSC.Visible = false; + legendSG.Visible = false; + ClearGZData(); + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + + + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 一键审核 + /// + /// + /// + private void ribbonTabItem11_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + //zhanshi = false; + redSH = false; + splitContainer1.Panel2Collapsed = true; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + panelOfTable.Visible = false; + legendSC.Visible = false; + legendSG.Visible = false; + ClearGZData(); + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + + + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 右屏添加冰箱数据 + /// + void AddDataToGlobeControl2() + { + + bool modelDataBool = false; + for (int i = globeControl2.Globe.Layers.Count - 1; i >= 0; i--) + { + GSOLayer layer = globeControl2.Globe.Layers[i]; + if (layer.Name.Contains("fttp:")) + { + modelDataBool = true; + break; + } + } + + if (modelDataBool == false) + { + GSOLayer ly = globeControl1.Globe.Layers.GetLayerByCaption("天地图地图"); + globeControl2.Globe.Layers.Add(ly); + } + else + { + return; + } + } + /// + /// 双屏对比 + /// + /// + /// + private void ribbonTabItem9_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent += new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent += new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + panelOfTable.Visible = false; + + splitContainer1.Panel2Collapsed = false; + //zhanshi = true; + redSH = false; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + sliderItem2.Value = 100 - globeControl1.Globe.GroundOpaque; + globeControl2.Globe.GroundOpaque = globeControl1.Globe.GroundOpaque; + legendSC.Visible = true; + legendSG.Visible = true; + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + AddDataToGlobeControl2(); + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 文档管理 + /// + /// + /// + private void ribbonTabItem4_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + panelOfTable.Visible = false; + //zhanshi = false; + redSH = false; + splitContainer1.Panel2Collapsed = true; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + legendSC.Visible = false; + legendSG.Visible = false; + ClearGZData(); + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 基础管理 + /// + /// + /// + private void ribbonTabItem14_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + panelOfTable.Visible = false; + //zhanshi = false; + redSH = false; + splitContainer1.Panel2Collapsed = true; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + legendSC.Visible = false; + legendSG.Visible = false; + ClearGZData(); + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 权限管理 + /// + /// + /// + private void ribbonTabItem2_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + panelOfTable.Visible = false; + //zhanshi = false; + redSH = false; + splitContainer1.Panel2Collapsed = true; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + legendSC.Visible = false; + legendSG.Visible = false; + ClearGZData(); + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + GSOFeature dpFeatuer = null; + /// + /// 双屏分析,点击管段分析 + /// + /// + /// + private void buttonItem8_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItem8.Text); + + //FrmCompareFeature frmCompareFeature = new FrmCompareFeature(globeControl1, globeControl2, layerTemp, layerTemp2,m_PipelineLayerNames,sgPipeLayersNames); + int width = this.Width; + FrmCompareFeature.ShowForm(globeControl1, globeControl2, layerTemp, layerTemp2, m_PipelineLayerNames, sgPipeLayersNames,width); + //frmCompareFeature.Location = new Point((this.Width - frmCompareFeature.Width)/2,50); + //frmCompareFeature.Show(this); + + } + /// + /// 红线审核导出图片 + /// + /// + /// + private void buttonItemDCTP_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemDCTP.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))); + */ + int mapWidth = 0; + int mapHeight = 0; + Point pt = getUpperLeftPoint(pt1, pt2, out mapWidth, out mapHeight); + int rightBottomX = pt.X + mapWidth; + int rightBottomY = pt.Y + mapHeight; + Image myImg = new Bitmap(mapWidth, mapHeight); + Graphics g = Graphics.FromImage(myImg); + g.CopyFromScreen(pt, new Point(0, 0), new Size(rightBottomX, rightBottomY)); + + 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; + } + } + } + /// + /// 标识器全区域统计 + /// + /// + /// + private void 标识器分类统计ToolStripMenuItem_Click(object sender, EventArgs e) + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + FrmBSQStatis bsqStatis = new FrmBSQStatis(globeControl1,null); + //FrmBSQStatis bsqStatis = new FrmBSQStatis(); + bsqStatis.Show(this); + } + /// + /// 标识器绘制区域统计 + /// + /// + /// + private void 标识器分类统计ToolStripMenuItem1_Click(object sender, EventArgs e) + { + trackflag = "BSQDuoBianXiangStatis"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + } + + #region 保存和加载审核库加载的图层 + /* + private void saveLayerList(TreeNodeCollection treeNodeList) + { + string configPath = Application.StartupPath + "\\configLayerList.xml"; + try + { + XmlDocument doc = new XmlDocument(); + doc.Load(configPath); + XmlNode dbParams = doc.SelectSingleNode("Params/dbparams"); + XmlNode dbLayers = doc.SelectSingleNode("Params/dblayers"); + XmlNode layers = doc.SelectSingleNode("Params/layers"); + dbParams.RemoveAll(); + dbLayers.RemoveAll(); + layers.RemoveAll(); + + List listDS = new List(); + String shDatasourceName = Utility.sgdbip + "/" + Utility.sgdbname + "_" + Utility.sgdbuser; + bool flag = false; + + for (int i = 0; i < globeControl1.Globe.DataManager.DataSourceCount; i++) + { + GSODataSource ds = globeControl1.Globe.DataManager.GetDataSourceAt(i); + if (ds != null && ds.Type == EnumDataSourceType.SqlServer || ds.Type == EnumDataSourceType.Oracle) + { + if (ds.Name == shDatasourceName) + { + //防止因为多次连接同一个数据库 + if (flag == true) + { + break; + } + flag = true; + listDS.Add(ds); + GSODataSourceCnn conn = ds.GetConnectionInfo(); + + XmlElement dbparam = doc.CreateElement("shdbparam"); + XmlElement ip = doc.CreateElement("ship"); + ip.InnerText = conn.Server; + + XmlElement dbname = doc.CreateElement("shdbname"); + dbname.InnerText = conn.Database; + + XmlElement username = doc.CreateElement("shusername"); + username.InnerText = conn.User; + + XmlElement password = doc.CreateElement("shpassword"); + password.InnerText = conn.Password; + + XmlElement type = doc.CreateElement("shtype"); + if (ds.Type == EnumDataSourceType.SqlServer) + { + type.InnerText = "sqlserver"; + } + else + { + type.InnerText = "oracle"; + } + + dbparam.AppendChild(ip); + dbparam.AppendChild(dbname); + dbparam.AppendChild(username); + dbparam.AppendChild(password); + dbparam.AppendChild(type); + dbParams.AppendChild(dbparam); + } + + } + } + + for (int i = 0; i < treeNodeList.Count; i++) + { + GSOLayer layer = treeNodeList[i].Tag as GSOLayer; + if (Path.GetExtension(layer.Name) == "") + { + XmlElement dbLayer = doc.CreateElement("dblayer"); + XmlAttribute attri = doc.CreateAttribute("dbindex"); + for (int j = 0; j < listDS.Count; j++) + { + if (layer.Dataset.DataSource.Name == listDS[j].Name) + { + attri.Value = j.ToString(); + break; + } + } + dbLayer.Attributes.Append(attri); + dbLayer.InnerText = layer.Name; + + dbLayers.AppendChild(dbLayer); + } + else + { + XmlElement dbLayer = doc.CreateElement("layer"); + dbLayer.InnerText = layer.Name; + layers.AppendChild(dbLayer); + } + } + + doc.Save(configPath); + } + catch (Exception e) + { + + } + } + + private void openLayerList() + { + layerManagerNode.Nodes.Clear(); + + string configPath = Application.StartupPath + "\\configLayerList.xml"; + try + { + XmlDocument doc = new XmlDocument(); + doc.Load(configPath); + XmlNode dbParams = doc.SelectSingleNode("Params/dbparams"); + XmlNode dbLayers = doc.SelectSingleNode("Params/dblayers"); + XmlNode layers = doc.SelectSingleNode("Params/layers"); + + List listDS = new List(); + for (int i = 0; i < dbParams.ChildNodes.Count; i++) + { + string ip = ""; + string dbname = ""; + string username = ""; + string password = ""; + string type = ""; + XmlNode node = dbParams.ChildNodes.Item(i); + for (int j = 0; j < node.ChildNodes.Count; j++) + { + XmlNode nodeChild = node.ChildNodes.Item(j); + + if (nodeChild != null && nodeChild.Name == "ship") + { + ip = nodeChild.InnerText; + } + else if (nodeChild != null && nodeChild.Name == "shdbname") + { + dbname = nodeChild.InnerText; + } + else if (nodeChild != null && nodeChild.Name == "shusername") + { + username = nodeChild.InnerText; + } + else if (nodeChild != null && nodeChild.Name == "shpassword") + { + password = nodeChild.InnerText; + } + else if (nodeChild != null && nodeChild.Name == "shtype") + { + type = nodeChild.InnerText; + } + } + + if (type == "sqlserver") + { + GSODataSource ds = globeControl1.Globe.DataManager.OpenSqlServerDataSource(ip, "", dbname, username, password); + listDS.Add(ds); + } + else if (type == "oracle") + { + GSODataSource ds = globeControl1.Globe.DataManager.OpenOracleDataSource(ip + "/" + dbname, "", "", username, password); + listDS.Add(ds); + } + } + + for (int i = 0; i < dbLayers.ChildNodes.Count; i++) + { + XmlNode node = dbLayers.ChildNodes.Item(i); + if (node != null) + { + string layerName = node.InnerText; + XmlAttribute attri = node.Attributes["dbindex"]; + if (attri != null) + { + int dbIndex = -1; + if (int.TryParse(attri.Value, out dbIndex)) + { + GSODataset dataset = listDS[dbIndex].GetDatasetByName(layerName); + globeControl1.Globe.Layers.Add(dataset); + //更新树节点 + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + TreeNode layerNode = new TreeNode(); + layerNode.Tag = layer; + layerNode.Text = layer.Dataset.Caption; + layerNode.ImageIndex = 0; + layerNode.SelectedImageIndex = 0; + layerNode.Checked = layer.Visible; + layerManagerNode.Nodes.Insert(0, layerNode); + // layerManagerNode.Expand(); + + + } + } + } + } + for (int i = 0; i < layers.ChildNodes.Count; i++) + { + XmlNode node = layers.ChildNodes.Item(i); + if (node != null) + { + string layerName = node.InnerText; + globeControl1.Globe.Layers.Add(layerName); + + //更新树节点 + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + TreeNode layerNode = new TreeNode(); + layerNode.Tag = layer; + layerNode.Text = layer.Dataset.Caption; + layerNode.ImageIndex = 0; + layerNode.SelectedImageIndex = 0; + layerNode.Checked = layer.Visible; + layerManagerNode.Nodes.Insert(0, layerNode); + } + } + layerManagerNode.Expand(); + } + catch (Exception e) + { + + } + } + * */ + #endregion + + private void btn_check_history_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_check_history.Text); + + if (FrmCheckHistory.isOpen == true) + { + return; + } + FrmCheckHistory frm = new FrmCheckHistory(globeControl1, globeControl2); + frm.addNode += new AddNodeToLayerManagerNode(addNodeToLayerManagerNode); + frm.Show(); + + } + + private void buttonItem查看数据_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItem查看数据.Text); + + FrmThreeOracle tr = new FrmThreeOracle(globeControl1); + + if (tr.ShowDialog() == DialogResult.OK) + { + addNodeToLayerManagerNode(tr.rukuLayer); + globeControl1.Refresh(); + } + } + /// + /// 规划数据入库 + /// + /// + /// + private void buttonItemGHRK_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemGHRK.Text); + + FrmGHRK ghrk = new FrmGHRK(globeControl1, layerManagerNode); + ghrk.Show(this); + } + + private void btn_user_info_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_user_info.Text); + + if (!FrmSysUserInfoManger.IS_OPEN) + { + FrmSysUserInfoManger frm = new FrmSysUserInfoManger(); + frm.ShowDialog(); + } + } + + private void btn_role_info_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_role_info.Text); + + if (FrmRoleInfoManager.IS_OPEN) + { + return; + } + FrmRoleInfoManager frm = new FrmRoleInfoManager(); + frm.ShowDialog(); + } + + private void btn_resc_info_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_resc_info.Text); + + if (!SysRescInfoManager.IS_OPEN) + { + SysRescInfoManager frm = new SysRescInfoManager(); + frm.ShowDialog(); + } + } + + private void btn_role_resc_Click(object sender, EventArgs e) + { + + LogManager.saveLog(Utility.userName, this.btn_role_resc.Text); + + if (!FrmRoleRescManager.IS_OPEN) + { + FrmRoleRescManager frm = new FrmRoleRescManager(); + frm.ShowDialog(); + } + } + + private void btn_user_role_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_user_role.Text); + + if (FrmUserRole.IS_OPEN) + { + return; + } + FrmUserRole frm = new FrmUserRole(); + frm.ShowDialog(); + } + + private void btn_document_info_Click(object sender, EventArgs e) + { + + LogManager.saveLog(Utility.userName, this.btn_document_info.Text); + + //if (FormDocumentManager.IS_OPEN) + //{ + // return; + //} + //FormDocumentManager frm = new FormDocumentManager(); + //frm.ShowDialog(); + + //if (FormDocumentManager.IS_OPEN) + //{ + // return; + //} + //new FormDocumentManager().ShowDialog(); + if (FormDocumentManager.IS_OPEN) + { + return; + } + this.Cursor = Cursors.WaitCursor; + FormDocumentManager frm = new FormDocumentManager(); + frm.changeCursor += new ChangeCursor(changeCursorToDefault); + frm.ShowDialog(); + + } + + private void changeCursorToDefault() + { + this.Cursor = Cursors.Default; + } + + /// + /// 判断CAD文件是否有投影信息 + /// + /// + /// + Boolean CheckDatasetGeoReference(GSODataset dataset) + { + Boolean bSuccess = false; + if (dataset.GeoReferenceType == EnumGeoReferenceType.Flat) + { + if (MessageBox.Show("数据没有空间参考信息,请设置空间参考信息!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation) == DialogResult.OK) + { + String strPath = Path.GetDirectoryName(Application.ExecutablePath) + "\\Coordinate Systems"; + OpenFileDialog dlg = new OpenFileDialog(); + + dlg.InitialDirectory = strPath; + dlg.RestoreDirectory = true; + + dlg.Filter = "投影文件|*.prj||"; + if (dlg.ShowDialog() == DialogResult.OK) + { + bSuccess = dataset.LoadProjectionFromESRIFile(dlg.FileName); + } + } + } + else + { + return true; + } + return bSuccess; + } + + private void buttonItemexp_CAD_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemexp_CAD.Text); + + OpenFileDialog dlg = new OpenFileDialog(); + dlg.Filter = "支持格式(*.dwg)|*.dwg"; + dlg.Multiselect = true; + if (dlg.ShowDialog() == DialogResult.OK) + { + for (int i = 0; i < dlg.FileNames.Length; i++) + { + //this.Cursor = Cursors.WaitCursor; + string strDataPath = dlg.FileNames[i]; + + #region + //string strDataPathPrj = strDataPath.ToLower().Replace(".dwg", ".lprj"); + + //if (File.Exists(strDataPathPrj) == false) + //{ + // if (MessageBox.Show("数据没有空间参考信息,请设置空间参考信息!", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation) == DialogResult.OK) + // { + // String strPath = Application.StartupPath + "\\Coordinate Systems"; + // OpenFileDialog dlgPrj = new OpenFileDialog(); + // dlgPrj.InitialDirectory = strPath; + // dlgPrj.RestoreDirectory = true; + // dlgPrj.Multiselect = false; + // dlg.Filter = "投影文件|*.prj"; + // if (dlg.ShowDialog() == DialogResult.OK) + // { + // this.Cursor = Cursors.WaitCursor; + // string proj4 = GSODataEngineUtility.ConvertEsriPrjFileToProj4(dlg.FileName); + // using (StreamWriter stream = new StreamWriter(strDataPathPrj, false)) + // { + // stream.WriteLine("0prj4" + proj4 + ""); + // } + // AddLayerData(strDataPath); + // //globeControl1.Globe.Layers.Add(strDataPath); + + // this.Cursor = Cursors.Default; + // } + // else + // { + // AddLayerData(strDataPath); + // //globeControl1.Globe.Layers.Add(strDataPath); + // } + // } + // else + // { + // AddLayerData(strDataPath); + // //globeControl1.Globe.Layers.Add(strDataPath); + // } + + //} + //else + //{ + // //globeControl1.Globe.Layers.Add(strDataPath); + // AddLayerData(strDataPath); + //} + #endregion + AddLayerData(strDataPath); + //this.Cursor = Cursors.Default; + } + } + + 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, 100); + + globeControl1.Refresh(); + } + } + + private void btn_password_edit_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_password_edit.Text); + + if (FrmChangePassword.IS_OPEN) + { + return; + } + FrmChangePassword frm = new FrmChangePassword(); + frm.ShowDialog(); + } + /// + /// 多孔管线入库 + /// + /// + /// + private void buttonItem9_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL4_2.Text); + + if (ds == null) + { + MessageBox.Show("请先连接数据库", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + ConnectDB(null, null); + } + if (ds == null) + return; + + FrmMultiPipelineModelDB frm = new FrmMultiPipelineModelDB(globeControl1, ds); + if (frm.ShowDialog() == DialogResult.OK) + { + addNodeToLayerManagerNode(frm.rukuLayer); + } + //frm.Show(); + } + private void 导出CADToolStripMenuItem1_Click(object sender, EventArgs e) + { + TreeNode node = layerNodeContexMenu.Tag as TreeNode; + if (node == null) + { + MessageBox.Show("请在左侧节点集中选择要导出的图层", "提示"); + return; + } + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(node.Text.Trim()); + if (layer == null || layer.GetAllFeatures().Length <= 0) + { + MessageBox.Show("要导出的图层为空", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + return; + } + string strProjectName = Utility.projectStr; + if (strProjectName != "") + { + SaveFileDialog dlg = new SaveFileDialog(); + dlg.Filter = "*.dwg|*.dwg|*.dxf|*.dxf"; + dlg.FileName = layer.Caption; + if (dlg.ShowDialog(this) == DialogResult.OK) + { + globeControl1.Globe.MemoryLayer.SaveAs(dlg.FileName); + GSOLayer newlayer = globeControl1.Globe.Layers.Add(dlg.FileName); + newlayer.RemoveAllFeature(); + int featureCount = layer.GetAllFeatures().Length; + for (int i = 0; i < featureCount; i++) + { + GSOFeature feature = layer.GetAt(i); + if (feature != null && feature.Geometry != null) + { + if (feature.Geometry.Type == EnumGeometryType.GeoPolyline3D) + { + feature.Geometry.Style = new GSOSimpleLineStyle3D(); + } + else if (feature.Geometry.Type == EnumGeometryType.GeoPolygon3D) + { + feature.Geometry.Style = new GSOSimplePolygonStyle3D(); + } + newlayer.AddFeature(feature); + } + } + newlayer.Save(); + newlayer.Dataset.DataSource.RemoveDataset(newlayer.Dataset); + globeControl1.Globe.Layers.Remove(newlayer); + MessageBox.Show("导出CAD完成!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + } + } + } + + private void buttonItemGBJC_Click(object sender, EventArgs e) + { + FrmGBJC gb = new FrmGBJC(globeControl1, globeControl2, layerTemp, layerTemp2); + gb.Show(this); + } + + #region 右屏管纵数据控制 + private void 五十米主干道ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = true; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + + private void 三十六米次干道ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = true; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + + private void 四十二米次干道ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = true; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + + private void 二十四米一块板ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = true; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + + private void 二十四米三块板ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = true; + } + + private void 二十四米停车带ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = true; + lendendGZ24_3.Visible = false; + } + + private void 二十六米大堤路ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = true; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + + private void 清除管纵数据ToolStripMenuItem_Click(object sender, EventArgs e) + { + ClearGZData(); + } + + private void ClearGZData() + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + #endregion + + private void buttonItemPasswordReset_Click(object sender, EventArgs e) + { + Frm_password_reset reset = new Frm_password_reset(); + reset.Show(); + } + + private void pictureBox1_Paint(object sender, PaintEventArgs e) + { + int Width = this.Width; + string welcomeUser = "欢迎您:" + Utility.userName; + Graphics g = e.Graphics; + g.DrawString(welcomeUser, new Font("宋体", 12), new SolidBrush(Color.Black), Width - 180, 50); + } + + } +} \ No newline at end of file diff --git a/bin/x86/Debug/Cyberpipe.vshost.exe.manifest b/bin/x86/Debug/Cyberpipe.vshost.exe.manifest deleted file mode 100644 index 061c9ca..0000000 --- a/bin/x86/Debug/Cyberpipe.vshost.exe.manifest +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - diff --git a/Cyberpipe.csproj b/Cyberpipe.csproj index 3a45ad8..d22f590 100644 --- a/Cyberpipe.csproj +++ b/Cyberpipe.csproj @@ -402,12 +402,6 @@ FrmBACKORACLE.cs - - Form - - - FrmBSQDuoBianXingStatis.cs - Form @@ -1271,9 +1265,6 @@ FrmBACKORACLE.cs - - FrmBSQDuoBianXingStatis.cs - FrmBSQStatis.cs diff --git a/FeatureStatisticsService.cs b/FeatureStatisticsService.cs index e833e5f..c7de210 100644 --- a/FeatureStatisticsService.cs +++ b/FeatureStatisticsService.cs @@ -273,19 +273,15 @@ /// 获取特定区域图层的管线列表,并将其总长度统计出来 ///
TODOLIST:将Intersects_Pipeline在MainFrm中去除 /// - /// + /// + /// 要统计的长度 /// public static GSOFeatures getLayerPipes(GSOGeoPolygon3D polygon, GSOLayer layer, out double length) { length = 0; if (layer == null) return null; - GSOFeatureLayer flayer = layer as GSOFeatureLayer; - GSOFeatureDataset fdataset = flayer.Dataset as GSOFeatureDataset; - GSOFeatures feats = null; - - feats = polygon == null?flayer.GetAllFeatures():flayer.FindFeaturesInPolygon(polygon, false); - + GSOFeatures feats = getLayerFeatures(polygon, layer); double totallength = 0.00; for (int i = 0; i < feats.Length; i++) { @@ -301,5 +297,17 @@ return feats; } + /// + /// 获取区域图层内的feature列表,MainFrm.PolygonIntersectAnalysis和此方法重复,需要整理删除 + /// + /// + /// + /// + public static GSOFeatures getLayerFeatures(GSOGeoPolygon3D polygon, GSOLayer layer) + { + if (layer == null) return null; + GSOFeatureLayer flayer = layer as GSOFeatureLayer; + return polygon == null ? flayer.GetAllFeatures() : flayer.FindFeaturesInPolygon(polygon, false); + } } } diff --git a/FrmAllWorkWellStatis.cs b/FrmAllWorkWellStatis.cs index 7bf65dc..bd0f81b 100644 --- a/FrmAllWorkWellStatis.cs +++ b/FrmAllWorkWellStatis.cs @@ -19,17 +19,7 @@ private Dictionary map = null; private GSOGlobeControl globeControl1; private GSOGeoPolygon3D polygon; - //TODOLIST:用晓伟的代理进行操作,功能拆分细化 - //public FrmAllWorkWellStatis(GSOGeoPolygon3D polygon, DataGridView dataGridViewX11, ToolStripStatusLabel toolStripNumbers1, GSOGlobeControl ctl, PanelEx p) - //{ - // InitializeComponent(); - // panel = p; - // dataGridViewX1 = dataGridViewX11; - // toolStripNumbers = toolStripNumbers1; - // globeControl1 = ctl; - // map = getAccsMap(polygon); - //} public FrmAllWorkWellStatis(GSOGlobeControl ctl,GSOGeoPolygon3D polygon, MainFrm.DataGridViewDelegate InitDataGridViewX1) { InitializeComponent(); @@ -117,8 +107,9 @@ sql = "select " + getpipeLineFields.getFields(layername, globeControl1) + " from " + layer.Name; sql += " where 1>2 "; - for (int i = 0; i < fs.Length && fs[i].GetFieldDefn("编号") != null; i++) + for (int i = 0; i < fs.Length; i++) { + if (fs[i].GetFieldDefn("编号") == null) continue; sql += " or 编号 = '" + fs[i].GetValue("编号").ToString() + "'"; } diff --git a/FrmBSQDuoBianXingStatis.Designer.cs b/FrmBSQDuoBianXingStatis.Designer.cs deleted file mode 100644 index bda6842..0000000 --- a/FrmBSQDuoBianXingStatis.Designer.cs +++ /dev/null @@ -1,87 +0,0 @@ -namespace Cyberpipe -{ - partial class FrmBSQDuoBianXingStatis - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea1 = new System.Windows.Forms.DataVisualization.Charting.ChartArea(); - this.groupBox1 = new System.Windows.Forms.GroupBox(); - this.chart1 = new System.Windows.Forms.DataVisualization.Charting.Chart(); - this.groupBox1.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.chart1)).BeginInit(); - this.SuspendLayout(); - // - // groupBox1 - // - this.groupBox1.Controls.Add(this.chart1); - this.groupBox1.Dock = System.Windows.Forms.DockStyle.Fill; - this.groupBox1.Location = new System.Drawing.Point(0, 0); - this.groupBox1.Name = "groupBox1"; - this.groupBox1.Size = new System.Drawing.Size(592, 384); - this.groupBox1.TabIndex = 0; - this.groupBox1.TabStop = false; - this.groupBox1.Text = "统计结果信息"; - // - // chart1 - // - chartArea1.AxisX.MajorGrid.Enabled = false; - chartArea1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(191)))), ((int)(((byte)(219)))), ((int)(((byte)(255))))); - chartArea1.BackGradientStyle = System.Windows.Forms.DataVisualization.Charting.GradientStyle.TopBottom; - chartArea1.Name = "ChartArea1"; - this.chart1.ChartAreas.Add(chartArea1); - this.chart1.Dock = System.Windows.Forms.DockStyle.Fill; - this.chart1.Location = new System.Drawing.Point(3, 17); - this.chart1.Name = "chart1"; - this.chart1.Size = new System.Drawing.Size(586, 364); - this.chart1.TabIndex = 0; - this.chart1.Text = "chart1"; - // - // FrmBSQDuoBianXingStatis - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(592, 384); - this.Controls.Add(this.groupBox1); - this.DoubleBuffered = true; - this.Name = "FrmBSQDuoBianXingStatis"; - this.ShowIcon = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; - this.Text = "多边形区域统计"; - this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FrmBSQDuoBianXingStatis_FormClosing); - this.Load += new System.EventHandler(this.FrmBSQDuoBianXingStatis_Load); - this.groupBox1.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)(this.chart1)).EndInit(); - this.ResumeLayout(false); - - } - - #endregion - - private System.Windows.Forms.GroupBox groupBox1; - private System.Windows.Forms.DataVisualization.Charting.Chart chart1; - } -} \ No newline at end of file diff --git a/FrmBSQDuoBianXingStatis.cs b/FrmBSQDuoBianXingStatis.cs deleted file mode 100644 index 80b567e..0000000 --- a/FrmBSQDuoBianXingStatis.cs +++ /dev/null @@ -1,179 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Windows.Forms; -using DevComponents.DotNetBar; -using System.Data.SqlClient; -using System.Windows.Forms.DataVisualization.Charting; -using GeoScene.Data; -using GeoScene.Engine; -using GeoScene.Globe; -using System.Data.OracleClient; - -namespace Cyberpipe -{ - public partial class FrmBSQDuoBianXingStatis : Office2007Form - { - Dictionary bsq = new Dictionary(); - Dictionary bsq1 = new Dictionary(); - static FrmBSQDuoBianXingStatis frm; - GSOGlobeControl globeControl1; - List list = new List(); - public static List pipeLists = new List(); - - string[] codeStr = new string[50]; - string[] nameStr = new string[30]; - public static List typeLists; - - public FrmBSQDuoBianXingStatis(Dictionary workWellLen, GSOGlobeControl glb,List _list) - { - InitializeComponent(); - bsq = workWellLen; - globeControl1 = glb; - list = _list; - } - - private void FrmBSQDuoBianXingStatis_Load(object sender, EventArgs e) - { - FrmBSQDuoBianXingStatisFenLei(); - try - { - chart1.Series.Add("标识器"); - chart1.ChartAreas["ChartArea1"].AxisX.Title = "标识器类型"; - chart1.ChartAreas["ChartArea1"].AxisY.Title = "标识器数量"; - chart1.ChartAreas["ChartArea1"].AxisX.Interval = 1; - chart1.Series["标识器"].ChartType = SeriesChartType.Column; - chart1.Series["标识器"]["DrawingStyle"] = "Cylinder"; - - chart1.Series["标识器"].Points.DataBindXY(bsq1.Keys, bsq1.Values); - if (bsq1.Values.Count == 0) - { - MessageBox.Show("该区域没有标识器信息", "提示"); - this.Close(); - return; - } - else - { - for (int m = 0; m < bsq1.Values.Count; m++) - { - if (chart1.Series["标识器"].Points[m].YValues[0].ToString() != "0") - { - chart1.Series["标识器"].Points[m].Label = chart1.Series[0].Points[m].YValues[0].ToString(); - } - } - } - } - catch (Exception ex) - { - //ErrorLog.PublishError(ex); - } - } - - private void FrmBSQDuoBianXingStatis_FormClosing(object sender, FormClosingEventArgs e) - { - frm = null; - globeControl1.Globe.ClearAnalysis(); - globeControl1.Globe.MemoryLayer.RemoveAllFeature(); - } - - - private void FrmBSQDuoBianXingStatisFenLei() - { - try - { - bool flag2 = false; - for (int i = 0; i < Utility.listPipelineType.Count; i++) - { - - for (int j = 0; j < pipeLists.Count; j++) - { - if (pipeLists[j] == Utility.listPipelineType[i].type) - { - flag2 = true; - break; - } - } - if (!flag2 && Utility.listPipelineType[i].type != "标识器") - { - pipeLists.Add(Utility.listPipelineType[i].type); - } - flag2 = false; - } - - typeLists = new List(); - for (int num = 0; num < pipeLists.Count; num++) - { - typeList ls = new typeList(0, pipeLists[num]); - typeLists.Add(ls); - } - - GSOFeatures fs = list[0]; - string pipetype = "标识器"; - foreach (string key in bsq.Keys) - { - if (key.StartsWith(pipetype)) - { - pipetype = key; - break; - } - } - if (fs.Length > 0) - { - for (int i = 0; i < fs.Length; i++) - { - string str = fs[i].GetValue("对象名称").ToString(); - codeStr = str.Split(','); - for (int n = 0; n < codeStr.Length; n++) - { - for (int ii = 0; ii < Utility.listPipelineType.Count; ii++) - { - if (Utility.listPipelineType[ii].code == codeStr[n]) - { - for (int m = 0; m < typeLists.Count; m++) - { - if (Utility.listPipelineType[ii].type == typeLists[m].type) - { - typeLists[m].num++; - break; - } - } - break; - } - } - } - } - } - - for (int i = 0; i < typeLists.Count; i++) - { - if (typeLists[i].num > 0) - bsq1.Add(typeLists[i].type, typeLists[i].num); - } - - } - catch (Exception ex) - { - //ErrorLog.PublishError(ex); - //MessageBox.Show(ex.Message); - } - - } - public class typeList - { - public int num; - public string type; - - public typeList(int _num, string _type) - { - num = _num; - type = _type; - } - } - - - } -} diff --git a/FrmBSQDuoBianXingStatis.resx b/FrmBSQDuoBianXingStatis.resx deleted file mode 100644 index 1af7de1..0000000 --- a/FrmBSQDuoBianXingStatis.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/FrmBSQStatis.Designer.cs b/FrmBSQStatis.Designer.cs index 2509c7d..ee9b1e7 100644 --- a/FrmBSQStatis.Designer.cs +++ b/FrmBSQStatis.Designer.cs @@ -57,6 +57,7 @@ this.ShowIcon = false; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "标识器全区域统计"; + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FrmBSQStatis_FormClosing); this.Load += new System.EventHandler(this.FrmBSQStatis_Load); ((System.ComponentModel.ISupportInitialize)(this.chartStatis)).EndInit(); this.ResumeLayout(false); diff --git a/FrmBSQStatis.cs b/FrmBSQStatis.cs index 4b25eda..e7c4926 100644 --- a/FrmBSQStatis.cs +++ b/FrmBSQStatis.cs @@ -18,94 +18,18 @@ { public partial class FrmBSQStatis : Office2007Form { - public Dictionary bsq = new Dictionary(); - //SqlConnection conn; - public static List typeLists; - OracleConnection conn; - string connectString; + private Dictionary bsq = new Dictionary(); + private GSOGlobeControl globeControl1; + private GSOGeoPolygon3D polygon; - public FrmBSQStatis() + public FrmBSQStatis(GSOGlobeControl globeControl1,GSOGeoPolygon3D polygon) { + this.globeControl1 = globeControl1; + this.polygon = polygon; InitializeComponent(); - BSQNumStatis(); + bsq = getBSQNameAndNumMap(polygon); } - string[] codeStr = new string[50]; - string[] nameStr = new string[30]; - public static List pipeLists = new List(); - - private void BSQNumStatis() - { - bool flag2 = false; - for (int i = 0; i < Utility.listPipelineType.Count; i++) - { - for (int j = 0; j < pipeLists.Count; j++) - { - if (pipeLists[j] == Utility.listPipelineType[i].type) - { - flag2 = true; - break; - } - } - if (!flag2 && Utility.listPipelineType[i].type != "标识器") - { - pipeLists.Add(Utility.listPipelineType[i].type); - } - flag2 = false; - } - - typeLists = new List(); - for (int num = 0; num 0) - bsq.Add(typeLists[i].type, typeLists[i].num); - } - - } - catch (Exception ex) - { - - } - } private void FrmBSQStatis_Load(object sender, EventArgs e) { @@ -136,17 +60,88 @@ } } - public class typeList + private Dictionary getBSQNameAndNumMap(GSOGeoPolygon3D polygon) { - public int num; - public string type; - public typeList(int _num, string _type) + Dictionary result = new Dictionary(); + Dictionary codeAndType = new Dictionary(); + //得到type的种类 + for (int i = 0; i < Utility.listPipelineType.Count; i++) { - num = _num; - type = _type; + if (!result.ContainsKey(Utility.listPipelineType[i].type) && Utility.listPipelineType[i].type != "标识器") + { + result.Add(Utility.listPipelineType[i].type, 0); + codeAndType.Add(Utility.listPipelineType[i].code, Utility.listPipelineType[i].type); + } + } + + return polygon == null ? getAllAreaMap(result, codeAndType) : getBSQMapByPolygon(polygon, result, codeAndType); + } + public Dictionary getAllAreaMap(Dictionary typeAndCount,Dictionary codeAndType) + { + try + { + OracleConnection conn = OledbHelper.sqlConnection(); + conn.Open(); + OracleCommand cmd; + cmd = new OracleCommand("select 对象类型 from 标识器", conn); + OracleDataReader dr = cmd.ExecuteReader(); + + while (dr.Read()) + { + string str = Convert.ToString(dr["对象类型"]); + if (str == null) continue; + foreach (string key in codeAndType.Keys) + { + if (str.Contains(key)) + { + typeAndCount[codeAndType[key]] += 1; + } + } + } + conn.Close(); + } + catch (Exception ex) + { + LogHelper.WriteLog(typeof(FrmBSQStatis),ex.Message.ToString()); + } + return typeAndCount; + } + + + public Dictionary getBSQMapByPolygon(GSOGeoPolygon3D polygon,Dictionary typeAndCount, Dictionary codeAndType) + { + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption("标识器"); + GSOFeatures bsqFs = FeatureStatisticsService.getLayerFeatures(polygon, layer); + if (bsqFs == null || bsqFs.Length <= 0) { + LogHelper.WriteLog(typeof(FrmBSQStatis),"标识器图层下的Feature为空"); + return null; + } + + for (int i = 0; i < bsqFs.Length; i++) + { + string str = bsqFs[i].GetValue("对象类型").ToString(); + + foreach (string key in codeAndType.Keys) + { + if (str.Contains(key)) + { + typeAndCount[codeAndType[key]] += 1; + } + } + } + + return typeAndCount; + } + + private void FrmBSQStatis_FormClosing(object sender, FormClosingEventArgs e) + { + globeControl1.Globe.ClearAnalysis(); + } + + } } diff --git a/FrmValveStatistics.cs b/FrmValveStatistics.cs index 672f97a..17dad6c 100644 --- a/FrmValveStatistics.cs +++ b/FrmValveStatistics.cs @@ -120,6 +120,7 @@ sql += " where 1>2 "; for (int i = 0; i < fs.Length; i++) { + if (fs[i].GetValue("编号") == null) continue; sql += " or 编号 = '" + fs[i].GetValue("编号").ToString() + "'"; } diff --git a/FrmpipeDeepstatis.cs b/FrmpipeDeepstatis.cs index 879801a..c7edbc3 100644 --- a/FrmpipeDeepstatis.cs +++ b/FrmpipeDeepstatis.cs @@ -164,88 +164,6 @@ } } - //if (clbPipeLine.CheckedItems.Count > 0) - //{ - // if (dataGridViewX2.Rows.Count > 0) - // { - // for (int i = 0; i < clbPipeLine.CheckedItems.Count; i++) - // { - // GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(clbPipeLine.CheckedItems[i].ToString()); - // GSOFeatureLayer flayer = layer as GSOFeatureLayer; - // GSOFeatures feats = new GSOFeatures(); - // if (polygon == null) - // feats = flayer.GetAllFeatures(); - // else - // feats = flayer.FindFeaturesInPolygon(polygon, false); - // for (int j = 0; j < dataGridViewX2.Rows.Count; j++) - // { - // double totalLength = 0.00; - // int ncount = 0; - // for (int m = 0; m < feats.Length; m++) - // { - // GSOFeature feat = feats[m]; - // float radius = feat.GetFieldAsFloat("起始埋深"); - // bool upCompare = true; - // bool downCompare = true; - // if (dataGridViewX2.Rows[j].Cells["下限"].Value != null || dataGridViewX2.Rows[j].Cells["上限"].Value != null) - // { - // if (dataGridViewX2.Rows[j].Cells["下限"].Value != null) - // { - // if (dataGridViewX2.Rows[j].Cells["下限"].Value.ToString() != "") - // { - // if (radius >= Convert.ToDouble(dataGridViewX2.Rows[j].Cells["下限"].Value)) - // { - // downCompare = true; - // } - // else - // downCompare = false; - // } - // } - // if (dataGridViewX2.Rows[j].Cells["上限"].Value != null) - // { - // if (dataGridViewX2.Rows[j].Cells["上限"].Value.ToString() != "") - // { - // if (radius <= Convert.ToDouble(dataGridViewX2.Rows[j].Cells["上限"].Value)) - // { - // upCompare = true; - // } - // else - // upCompare = false; - // } - // } - // if (upCompare && downCompare) - // { - // GSOGeoPolyline3D line = feat.Geometry as GSOGeoPolyline3D; - // double length = line.GetSpaceLength(true, 6378137); - // totalLength += length; - // ncount += 1; - // } - // } - // } - // if (dataGridViewX2.Rows[j].Cells["下限"].Value != null || dataGridViewX2.Rows[j].Cells["上限"].Value != null) - // { - // DataGridViewRow row = new DataGridViewRow(); - // int index = dataGridViewX1.Rows.Add(row); - // row = dataGridViewX1.Rows[index]; - // row.Cells["图层名称"].Value = layer.Caption; - // row.Cells["埋深范围"].Value = dataGridViewX2.Rows[j].Cells["下限"].Value + "-" + dataGridViewX2.Rows[j].Cells["上限"].Value; - // row.Cells["条数"].Value = ncount; - // row.Cells["总长度"].Value =Math.Round(totalLength,2); - - // dic.Add(layer.Caption + "," + row.Cells["埋深范围"].Value.ToString()+","+row.Cells["总长度"].Value.ToString(), ncount); - // } - // } - // } - // } - // else - // { - // MessageBox.Show("请添加分段!"); - // } - //} - //else - //{ - // MessageBox.Show("请选择图层!"); - //} showPipeWidget(); } catch (Exception ex) diff --git a/FrmpipeMaterialGather.cs b/FrmpipeMaterialGather.cs index b7ab1d2..3e9f45d 100644 --- a/FrmpipeMaterialGather.cs +++ b/FrmpipeMaterialGather.cs @@ -180,79 +180,6 @@ } - //if (clbPipeLine.CheckedItems.Count > 0) - //{ - // for (int i = 0; i < clbPipeLine.CheckedItems.Count; i++) - // { - // GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(clbPipeLine.CheckedItems[i].ToString()); - // GSOFeatureLayer flayer = layer as GSOFeatureLayer; - // GSOFeatures feats = new GSOFeatures(); - // if (polygon == null) - // feats = flayer.GetAllFeatures(); - // else - // feats = flayer.FindFeaturesInPolygon(polygon, false); - // List lstDiameter = new List(); - - // for (int j = 0; j < clbmaterials.CheckedItems.Count; j++) - // { - // if (!lstDiameter.Contains(clbmaterials.CheckedItems[j].ToString())) - // { - // lstDiameter.Add(clbmaterials.CheckedItems[j].ToString()); - // } - // } - // //lstDiameter.Sort(); - // if (lstDiameter.Count > 0) - // { - // for (int m = 0; m < lstDiameter.Count; m++) - // { - // double totalLength = 0.00; - // int ncount = 0; - // for (int j = 0; j < feats.Length; j++) - // { - // if (lstDiameter[m] != "无") - // { - // if (feats[j].GetFieldAsString("材质") == lstDiameter[m]) - // { - // GSOGeoPolyline3D line = feats[j].Geometry as GSOGeoPolyline3D; - // if (line != null) - // { - // double length = line.GetSpaceLength(true, 6378137); - // totalLength += length; - // ncount += 1; - // } - // } - // } - // else - // { - // if (feats[j].GetFieldAsString("材质") == "") - // { - // GSOGeoPolyline3D line = feats[j].Geometry as GSOGeoPolyline3D; - // if (line != null) - // { - // double length = line.GetSpaceLength(true, 6378137); - // totalLength += length; - // ncount += 1; - // } - // } - // } - // } - // DataGridViewRow row = new DataGridViewRow(); - // int index = dataGridViewX1.Rows.Add(row); - // row = dataGridViewX1.Rows[index]; - // row.Cells["图层名称"].Value = layer.Caption; - // row.Cells["材质"].Value = lstDiameter[m]; - // row.Cells["条数"].Value = ncount; - // row.Cells["总长度"].Value = Math.Round(totalLength); - - // dic.Add(layer.Caption + "," + row.Cells["材质"].Value.ToString(), ncount); - // } - // } - // } - //} - //else - //{ - // MessageBox.Show("请选择图层!"); - //} showPipeWidget(); } catch (Exception ex) diff --git a/Frmpipediameterstatis.cs b/Frmpipediameterstatis.cs index 9953ac0..aa482d8 100644 --- a/Frmpipediameterstatis.cs +++ b/Frmpipediameterstatis.cs @@ -27,12 +27,9 @@ frm = new Frmpipediameterstatis(_globeControl1, pipeLayers, visibleId); frm.Show(_globeControl1.Parent); } - else + else if (frm.WindowState == FormWindowState.Minimized) { - if (frm.WindowState == FormWindowState.Minimized) - { - frm.WindowState = FormWindowState.Normal; - } + frm.WindowState = FormWindowState.Normal; } } @@ -208,7 +205,8 @@ } catch (Exception ex) { - MessageBox.Show(ex.Message); + LogHelper.WriteLog(typeof(Frmpipediameterstatis), ex.Message); + //MessageBox.Show(ex.Message); LogError.PublishError(ex); } } @@ -290,76 +288,77 @@ /// private void btnExport_Click(object sender, EventArgs e) { - if (dataGridViewX1.Rows.Count > 0) + if (dataGridViewX1.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 = DateTime.Now.ToString("yyyyMMdd") + ".xls"; - if (dlg.ShowDialog() == DialogResult.OK) + MessageBox.Show("统计结果为空,请重新统计之后再导出Excel!", "提示"); + return; + } + + SaveFileDialog dlg = new SaveFileDialog(); + dlg.Filter = "Excel files (*.xls)|*.xls"; + dlg.FilterIndex = 0; + dlg.RestoreDirectory = true; + //dlg.CreatePrompt = true; + dlg.Title = "保存为Excel文件"; + dlg.FileName = 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 { - Stream myStream; - myStream = dlg.OpenFile(); - StreamWriter sw = new StreamWriter(myStream, System.Text.Encoding.GetEncoding(-0)); - string columnTitle = ""; - try + sw.WriteLine("日期:" + DateTime.Now.ToString("yyyy-MM-dd")); + + //写入列标题 + for (int i = 0; i < dataGridViewX1.ColumnCount; i++) { - sw.WriteLine("日期:" + DateTime.Now.ToString("yyyy-MM-dd")); - - //写入列标题 - for (int i = 0; i < dataGridViewX1.ColumnCount; i++) + if (i > 0) { - if (i > 0) - { - columnTitle += "\t"; - } - columnTitle += dataGridViewX1.Columns[i].HeaderText; + columnTitle += "\t"; } - sw.WriteLine(columnTitle); - - //写入列内容 - for (int j = 0; j < dataGridViewX1.Rows.Count; j++) - { - string columnValue = ""; - for (int k = 0; k < dataGridViewX1.Columns.Count; k++) - { - if (k > 0) - { - columnValue += "\t"; - } - if (dataGridViewX1.Rows[j].Cells[k].Value == null) - columnValue += ""; - else - columnValue += dataGridViewX1.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); - } + columnTitle += dataGridViewX1.Columns[i].HeaderText; } - catch (Exception ex) + sw.WriteLine(columnTitle); + + //写入列内容 + for (int j = 0; j < dataGridViewX1.Rows.Count; j++) { - MessageBox.Show(ex.ToString()); + string columnValue = ""; + for (int k = 0; k < dataGridViewX1.Columns.Count; k++) + { + if (k > 0) + { + columnValue += "\t"; + } + if (dataGridViewX1.Rows[j].Cells[k].Value == null) + columnValue += ""; + else + columnValue += dataGridViewX1.Rows[j].Cells[k].Value.ToString().Trim(); + } + + sw.WriteLine(columnValue); } - finally + sw.Close(); + myStream.Close(); + if (MessageBox.Show("导出Excel文件成功!是否打开?", "提示", MessageBoxButtons.YesNo) == DialogResult.Yes) { - sw.Close(); - myStream.Close(); + System.Diagnostics.Process.Start(dlg.FileName); } } + catch (Exception ex) + { + MessageBox.Show(ex.ToString()); + } + finally + { + sw.Close(); + myStream.Close(); + } } - else - { - MessageBox.Show("统计结果为空,请重新统计之后再导出Excel!","提示"); - } + + } /// /// 绘制区域分段统计 diff --git a/MainFrm.cs b/MainFrm.cs index 0b7e393..9bfb70e 100644 --- a/MainFrm.cs +++ b/MainFrm.cs @@ -2667,12 +2667,195 @@ FrmBaseLineProfillAnalysis dlg = new FrmBaseLineProfillAnalysis(globeControl1.Globe, e.Polyline); dlg.Show(this); globeControl1.Globe.ClearLastTrackPolyline(); + /* + FrmRoadHDM f = new FrmRoadHDM(); + f.Show() + * **/ } else { } trackPolylineEndMode = EnumTrackPolylineEndMode.Default_Analysis; + /* + ArrayList arraylistPoint = new ArrayList(); + ArrayList arraylistLine = new ArrayList(); + + // globeControl1.Globe.ClearLastTrackPolyline(); + + if (e.Polyline != null) + { + //横断面分析 + if (buttonItemFX2_1.Checked || buttonItemFX2_3.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 (buttonItemFX2_1.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 (buttonItemFX2_4.Checked) + { + FrmBaseLineProfillAnalysis dlg = new FrmBaseLineProfillAnalysis(globeControl1.Globe, e.Polyline); + dlg.Show(this); + globeControl1.Globe.ClearLastTrackPolyline(); + } + else if (buttonItemFX4_3.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(); + * **/ } #endregion @@ -2713,16 +2896,20 @@ case "valvequery": FrmValveStatistics frm = new FrmValveStatistics(globeControl1,polygon, new DataGridViewDelegate(InitDataGridViewX1)); frm.Show(this); + //panelEx6.Visible = true; + toolStripFeatureLength.Text = ""; globeControl1.Globe.Action = EnumAction3D.ActionNull; break; case "PipelineDistanceStatistics": + FrmAllPipelineStatis frm1 = new FrmAllPipelineStatis(globeControl1, polygon, new DataGridViewDelegate(InitDataGridViewX1), m_PipelineLayerNames); frm1.Show(this); globeControl1.Globe.Action = EnumAction3D.ActionNull; break; case "PipelineSpatialQuery": + FrmAllPipelineStatis.ShowForm(globeControl1,polygon,new DataGridViewDelegate(InitDataGridViewX1),m_PipelineLayerNames); globeControl1.Globe.ClearAnalysis(); globeControl1.Globe.Action = EnumAction3D.ActionNull; @@ -2771,18 +2958,19 @@ break; case "BSQDuoBianXiangStatis": - GSOFeature f2 = new GSOFeature(); - f2.Geometry = e.Polygon; - f2.Geometry.AltitudeMode = EnumAltitudeMode.Absolute; - globeControl1.Globe.MemoryLayer.AddFeature(f2); - f2.Geometry.MoveZ(3); - workWellLen.Clear(); - List listBSQ = new List(); + //GSOFeature f2 = new GSOFeature(); + //f2.Geometry = e.Polygon; + //f2.Geometry.AltitudeMode = EnumAltitudeMode.Absolute; + //globeControl1.Globe.MemoryLayer.AddFeature(f2); + //f2.Geometry.MoveZ(3); + //workWellLen.Clear(); + //List listBSQ = new List(); - GSOFeatures bsqFeatures = PolygonIntersectAnalysis(e.Polygon, "标识器"); - listBSQ.Add(bsqFeatures); + //GSOFeatures bsqFeatures = PolygonIntersectAnalysis(e.Polygon, "标识器"); + //listBSQ.Add(bsqFeatures); - FrmBSQDuoBianXingStatis bsqFrm = new FrmBSQDuoBianXingStatis(workWellLen, globeControl1, listBSQ); + //FrmBSQDuoBianXingStatis bsqFrm = new FrmBSQDuoBianXingStatis(workWellLen, globeControl1, listBSQ); + FrmBSQStatis bsqFrm = new FrmBSQStatis(globeControl1,e.Polygon); bsqFrm.Show(this); globeControl1.Globe.Action = EnumAction3D.ActionNull; break; @@ -4351,6 +4539,26 @@ } /// + /// 在窗体的底部状态栏上显示 综合管线条件查询结果 + /// + /// + /// + 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 + " 条记录 | "; + } + } + + /// /// 统计管线的里程数 /// /// @@ -6824,6 +7032,54 @@ } /// + /// 创建label要素 功能 + /// + /// 添加label要素的feature + /// feature的位置 + /// label要素名字 + /// feature名字 + /// label要素距离点的位置 + /// + 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; + } + + + + /// /// 获取指定两点组成的线的长度 功能 /// /// @@ -9266,8 +9522,19 @@ //日志记录 LogManager.saveLog(Utility.userName, "管线长度统计"); + //pipeLineDis.Clear(); + //List list = new List(); + //for (int i = 0; i < m_PipelineLayerNames.Count; i++) + //{ + // GSOFeatures fs = Intersects_Pipeline(null, m_PipelineLayerNames[i]); + // if (fs!=null) + // list.Add(fs); + //} + + //FrmAllPipelineStatis frm = new FrmAllPipelineStatis(0, pipeLineDis, list, globeControl1, new DataGridViewDelegate(InitDataGridViewX1)); FrmAllPipelineStatis frm = new FrmAllPipelineStatis(globeControl1,null, new DataGridViewDelegate(InitDataGridViewX1), m_PipelineLayerNames); frm.Show(this); + } /// /// 管线长度绘制区域统计 @@ -9293,6 +9560,25 @@ //日志记录 LogManager.saveLog(Utility.userName, "阀门数量统计"); + //workWellLen.Clear(); + //List list = new List(); + ////找到所有阀门 + //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, globeControl1, new DataGridViewDelegate(InitDataGridViewX1)); FrmValveStatistics frm = new FrmValveStatistics(globeControl1, null, new DataGridViewDelegate(InitDataGridViewX1)); frm.Show(this); @@ -9318,9 +9604,7 @@ /// /// private void buttonItemTJ3_ALL_Click(object sender, EventArgs e) - { - //日志记录 - LogManager.saveLog(Utility.userName, "井盖数量统计"); + { FrmAllWorkWellStatis frm = new FrmAllWorkWellStatis(globeControl1, null, new DataGridViewDelegate(InitDataGridViewX1)); frm.Show(this); } @@ -9333,7 +9617,7 @@ { //日志记录 LogManager.saveLog(Utility.userName, "井盖数量统计"); - + trackflag = "workwellquery"; globeControl1.Globe.Action = EnumAction3D.TrackPolygon; globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; @@ -11142,7 +11426,7 @@ Cyberpipe.Forms.FrmPipelineModelDB frm = new Cyberpipe.Forms.FrmPipelineModelDB(globeControl1, ds); if (frm.ShowDialog() == DialogResult.OK) { - //addNodeToLayerManagerNode(frm.rukuLayer); + addNodeToLayerManagerNode(frm.rukuLayer); } } /// @@ -12377,7 +12661,8 @@ private void 标识器分类统计ToolStripMenuItem_Click(object sender, EventArgs e) { globeControl1.Globe.Action = EnumAction3D.ActionNull; - FrmBSQStatis bsqStatis = new FrmBSQStatis(); + FrmBSQStatis bsqStatis = new FrmBSQStatis(globeControl1,null); + //FrmBSQStatis bsqStatis = new FrmBSQStatis(); bsqStatis.Show(this); } /// diff --git a/MainFrm.cs.BACKUP.9016.cs b/MainFrm.cs.BACKUP.9016.cs new file mode 100644 index 0000000..28cb7fa --- /dev/null +++ b/MainFrm.cs.BACKUP.9016.cs @@ -0,0 +1,13074 @@ +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; + + GSOBalloon featureTooltip2; + GSOBalloonEx balloonEx2; + + GSOLayer layerTemp; + GSOLayer layerTemp2; + FrmShResult frmShResult = null; + FrmRedlineResult frmredResult = null; + FrmMnModify frmModify = null; + public bool frmRedlineResult = false; + public bool boolfrmShResult = false; + public bool boolfrmModify = false; + + List m_PipelineLayerNames = new List();//线图层名称 + List workwellLayerNames = new List();//工井图层名称 + List valueLayerNames = new List();//阀门图层名称 + List instrumenLayerNames = new List();//附属物图层名称 + List pipefittingLayerNames = new List();//管件图层名称 + List sgPipeLayersNames = new List();//施工管线图层名称 + 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 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; + public string redLayer = null; + //GSOLayer redLayer1 = null; + bool redSH = false; + string redDt = "红线"; + //双屏对比 + //bool zhanshi=false; + Thread t = null; + private GSOHudButton legendSC;//定义图例 + private GSOHudButton legendSG;//定义图例 + //管纵图 + private GSOHudButton lendendGZ50; + private GSOHudButton lendendGZ36; + private GSOHudButton lendendGZ42; + private GSOHudButton lendendGZ24_1; + private GSOHudButton lendendGZ24_2; + private GSOHudButton lendendGZ24_3; + private GSOHudButton lendendGZ26; + + GSOGeoPoint3D bsqPT; + + FrmYJSHTC frmSh = null;//一键审核窗口全局变量wxl + FrmWait frmWait = null;//一键审核等待窗口 + //FrmWait frmWait2 = null;//文档操作等待窗口 + + float mouseDownX1,mouseDownY1; + float mouseDownX2,mouseDownY2; + /// + /// + /// + 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; + + featureTooltip2 = new GSOBalloon(globeControl2.Handle); + balloonEx2 = new GSOBalloonEx(globeControl2.Handle); + Utility.SetBallons(featureTooltip, balloonEx); + + panelOfTable.Height = 200; + + RigthMenuSet(); + + MenuSet(); + + } + /// + /// 右屏中添加管纵图片 + /// + private void AddGZ() + { + + lendendGZ50 = new GSOHudButton(); + lendendGZ50.SetImage(Application.StartupPath + "/Resource/管纵/50.png"); + lendendGZ50.SetOffset(0, 0); + lendendGZ50.MinOpaque = 1; + lendendGZ50.MaxOpaque = 1; + lendendGZ50.FadeOut = false; + lendendGZ50.Name = "lendendGZ50"; + lendendGZ50.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ50); + lendendGZ50.Visible = false; + + lendendGZ36 = new GSOHudButton(); + lendendGZ36.SetImage(Application.StartupPath + "/Resource/管纵/36.png"); + lendendGZ36.SetOffset(0, 0); + lendendGZ36.MinOpaque = 1; + lendendGZ36.MaxOpaque = 1; + lendendGZ36.FadeOut = false; + lendendGZ36.Name = "lendendGZ36"; + lendendGZ36.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ36); + lendendGZ36.Visible = false; + + lendendGZ42 = new GSOHudButton(); + lendendGZ42.SetImage(Application.StartupPath + "/Resource/管纵/42.png"); + lendendGZ42.SetOffset(0, 0); + lendendGZ42.MinOpaque = 1; + lendendGZ42.MaxOpaque = 1; + lendendGZ42.FadeOut = false; + lendendGZ42.Name = "lendendGZ42"; + lendendGZ42.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ42); + lendendGZ42.Visible = false; + + lendendGZ24_1 = new GSOHudButton(); + lendendGZ24_1.SetImage(Application.StartupPath + "/Resource/管纵/24_1.png"); + lendendGZ24_1.SetOffset(0, 0); + lendendGZ24_1.MinOpaque = 1; + lendendGZ24_1.MaxOpaque = 1; + lendendGZ24_1.FadeOut = false; + lendendGZ24_1.Name = "lendendGZ24_1"; + lendendGZ24_1.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ24_1); + lendendGZ24_1.Visible = false; + + lendendGZ24_2 = new GSOHudButton(); + lendendGZ24_2.SetImage(Application.StartupPath + "/Resource/管纵/24_2.png"); + lendendGZ24_2.SetOffset(0, 0); + lendendGZ24_2.MinOpaque = 1; + lendendGZ24_2.MaxOpaque = 1; + lendendGZ24_2.FadeOut = false; + lendendGZ24_2.Name = "lendendGZ24_2"; + lendendGZ24_2.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ24_2); + lendendGZ24_2.Visible = false; + + lendendGZ24_3 = new GSOHudButton(); + lendendGZ24_3.SetImage(Application.StartupPath + "/Resource/管纵/24_3.png"); + lendendGZ24_3.SetOffset(0, 0); + lendendGZ24_3.MinOpaque = 1; + lendendGZ24_3.MaxOpaque = 1; + lendendGZ24_3.FadeOut = false; + lendendGZ24_3.Name = "lendendGZ24_3"; + lendendGZ24_3.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ24_3); + lendendGZ24_3.Visible = false; + + lendendGZ26 = new GSOHudButton(); + lendendGZ26.SetImage(Application.StartupPath + "/Resource/管纵/26.png"); + lendendGZ26.SetOffset(0, 0); + lendendGZ26.MinOpaque = 1; + lendendGZ26.MaxOpaque = 1; + lendendGZ26.FadeOut = false; + lendendGZ26.Name = "lendendGZ26"; + lendendGZ26.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ26); + lendendGZ26.Visible = false; + + } + + public void RigthMenuSet() + { + if (Utility.userRole.IndexOf("清除分析") < 0) + { + toolRightMenu.Items.Remove(清除分析ToolStripMenuItem); + } + + #region 区域分析 + if (Utility.userRole.IndexOf("区域分析") < 0) + { + toolRightMenu.Items.Remove(区域分析ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("缓冲区分析") < 0) + { + 区域分析ToolStripMenuItem.DropDownItems.Remove(缓冲区分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("附属物分析") < 0) + { + 区域分析ToolStripMenuItem.DropDownItems.Remove(附属物分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("无源淹没分析") < 0) + { + 区域分析ToolStripMenuItem.DropDownItems.Remove(无源淹没分析ToolStripMenuItem); + } + } + #endregion + + #region 视域分析 + if (Utility.userRole.IndexOf("视域分析") < 0) + { + toolRightMenu.Items.Remove(视域分析ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("通视分析") < 0) + { + 视域分析ToolStripMenuItem.DropDownItems.Remove(通视分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("可视域分析") < 0) + { + 视域分析ToolStripMenuItem.DropDownItems.Remove(可视域分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("可视包络分析") < 0) + { + 视域分析ToolStripMenuItem.DropDownItems.Remove(可视包络分析ToolStripMenuItem); + } + } + #endregion + + #region 开发分析 + if (Utility.userRole.IndexOf("开挖分析") < 0) + { + toolRightMenu.Items.Remove(开挖分析ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("多边形开挖") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(多边形开挖ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("挖方量分析") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(挖方量分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("沿线开挖") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(沿线开挖ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("创建隧道") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(创建隧道ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("隐藏隧道") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(隐藏隧道ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("删除隧道") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(删除隧道ToolStripMenuItem); + } + } + #endregion + + #region 拓扑分析 + if (Utility.userRole.IndexOf("拓扑分析") < 0) + { + toolRightMenu.Items.Remove(拓扑分析ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("创建拓扑") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(创建拓扑ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("上游分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(上游分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("下游分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(下游分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("流向分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(流向分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("关阀分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(关阀分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("连通分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(连通分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("爆管分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(爆管分析ToolStripMenuItem); + } + } + #endregion + + #region 断面分析 + if (Utility.userRole.IndexOf("断面分析") < 0) + { + toolRightMenu.Items.Remove(断面分析ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("横断面分析") < 0) + { + 断面分析ToolStripMenuItem.DropDownItems.Remove(横断面分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("纵断面分析") < 0) + { + 断面分析ToolStripMenuItem.DropDownItems.Remove(纵断面分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("道路断面分析") < 0) + { + 断面分析ToolStripMenuItem.DropDownItems.Remove(道路断面分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("基线剖面分析") < 0) + { + 断面分析ToolStripMenuItem.DropDownItems.Remove(基线剖面分析ToolStripMenuItem); + } + } + #endregion + + #region 绘制区域统计 + if (Utility.userRole.IndexOf("绘制区域统计") < 0) + { + toolRightMenu.Items.Remove(绘制区域统计ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("绘制区域管线长度统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管线长度统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域阀门数量统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(阀门数量统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域井盖数量统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(井盖数量统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域管径分段统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管径分段统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域埋深分段统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(埋深分段统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域管径分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管径分类统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域材质分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(材质分类统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域附属物分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(附属物分类统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域标识器分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(标识器分类统计ToolStripMenuItem1); + } + + } + #endregion + + #region 全区域统计 + if (Utility.userRole.IndexOf("全区域统计") < 0) + { + toolRightMenu.Items.Remove(全区域统计ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("全区域管线长度统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管线长度统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域阀门数量统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(阀门数量统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域井盖数量统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(井盖数量统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域管径分段统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管径分段统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域埋深分段统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(埋深分段统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域管径分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管径分类统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域材质分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(材质分类统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域附属物分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(附属物分类统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域标识器分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(标识器分类统计ToolStripMenuItem); + } + + } + #endregion + + #region 查询 + if (Utility.userRole.IndexOf("查询") < 0) + { + toolRightMenu.Items.Remove(查询ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("空间查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(空间查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("编号查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(编号查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("坐标查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(坐标查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("管径查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(管径查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("材质查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(材质查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("基本查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(基本查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("复合查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(复合查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("关联查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(关联查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("关键字查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(关键字查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("附属物查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(附属物查询ToolStripMenuItem); + } + } + #endregion + + #region 标注 + if (Utility.userRole.IndexOf("标注") < 0) + { + toolRightMenu.Items.Remove(标注ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("标高标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(标高标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("管径标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(管径标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("埋深标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(埋深标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("坐标标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(坐标标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("距离标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(距离标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("自定义标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(自定义标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("扯旗标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(扯旗标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("坡度标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(坡度标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("属性标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(属性标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("标注管理") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(标注管理ToolStripMenuItem); + } + } + #endregion + + #region 飞行 + if (Utility.userRole.IndexOf("飞行") < 0) + { + toolRightMenu.Items.Remove(飞行ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("自定义飞行") < 0) + { + 飞行ToolStripMenuItem.DropDownItems.Remove(自定义飞行ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("飞行到目标点") < 0) + { + 飞行ToolStripMenuItem.DropDownItems.Remove(飞行到目标点ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("绕中心点飞行") < 0) + { + 飞行ToolStripMenuItem.DropDownItems.Remove(绕中心点飞行ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("绕眼睛飞行") < 0) + { + 飞行ToolStripMenuItem.DropDownItems.Remove(绕眼睛飞行ToolStripMenuItem); + } + } + #endregion + + #region 编辑 + if (Utility.userRole.IndexOf("编辑") < 0) + { + toolRightMenu.Items.Remove(编辑ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("平移对象") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(平移对象ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("升降对象") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(升降对象ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("旋转对象") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(旋转对象ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("连接管段") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(连接管段ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("导出文件") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(导出文件ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("前进") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(前进ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("后退") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(删除模型ToolStripMenuItem); + } + } + #endregion + + #region 量算 + if (Utility.userRole.IndexOf("量算") < 0) + { + toolRightMenu.Items.Remove(量算ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("水平距离") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(水平距离ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("垂直距离") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(垂直距离ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("空间距离") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(空间距离ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("地表距离") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(地表距离ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("高度量算") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(高度量算ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("水平面积") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(水平面积ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("地表面积") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(地表面积ToolStripMenuItem1); + } + } + #endregion + } + + public void MenuSet() + { + + #region 权限管理 + if (Utility.userRole.IndexOf("权限管理") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem2); + } + else + { + + if (Utility.userRole.IndexOf("用户管理") < 0) + { + btn_user_info.Visible = false; + } + if (Utility.userRole.IndexOf("角色管理") < 0) + { + btn_role_info.Visible = false; + } + if (Utility.userRole.IndexOf("资源管理") < 0) + { + btn_resc_info.Visible = false; + } + if (Utility.userRole.IndexOf("角色授权") < 0) + { + btn_role_resc.Visible = false; + } + if (Utility.userRole.IndexOf("用户授权") < 0) + { + btn_user_role.Visible = false; + } + if (Utility.userRole.IndexOf("密码修改") < 0) + { + btn_password_edit.Visible = false; + } + + } + #endregion + + #region 基础工具 + if (Utility.userRole.IndexOf("基础工具") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem1); + } + else + { + if (Utility.userRole.IndexOf("地上模式") < 0) + { + buttonItem87.Visible = false; + } + if (Utility.userRole.IndexOf("地下模式") < 0) + { + buttonItem88.Visible = false; + } + if (Utility.userRole.IndexOf("行走模式") < 0) + { + buttonItem27.Visible = false; + } + if (Utility.userRole.IndexOf("透明度设置") < 0) + { + sliderGroundTransSet1.Visible = false; + } + if (Utility.userRole.IndexOf("快速定位") < 0) + { + buttonItem91.Visible = false; + } + if (Utility.userRole.IndexOf("图层管理") < 0) + { + buttonItem1.Visible = false; + } + if (Utility.userRole.IndexOf("图例管理") < 0) + { + btnlegendSet.Visible = false; + } + if (Utility.userRole.IndexOf("全屏显示") < 0) + { + buttonItem89.Visible = false; + } + if (Utility.userRole.IndexOf("导出图片") < 0) + { + btnOutputJPG.Visible = false; + } + + } + #endregion + + #region 一键审核 + if (Utility.userRole.IndexOf("一键审核") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem11); + } + #endregion + + #region 红线审核 + if (Utility.userRole.IndexOf("红线审核") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem6); + } + #endregion + + #region 双屏对比 + if (Utility.userRole.IndexOf("双屏对比") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem9); + } + #endregion + + #region 文档管理 + if (Utility.userRole.IndexOf("文档管理") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem4); + } + #endregion + + #region 基础管理 + if (Utility.userRole.IndexOf("基础管理") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem14); + } + else + { + if (Utility.userRole.IndexOf("专题图审批") < 0) + { + buttonItemZTT3_2.Visible = false; + } + if (Utility.userRole.IndexOf("打印审批") < 0) + { + buttonItemZTT4_2.Visible = false; + } + if (Utility.userRole.IndexOf("拷贝审批") < 0) + { + buttonItemZTT5_2.Visible = false; + } + } + + #endregion + + if (ribbonControl1.Items.Count <= 0) + { + ribbonControl1.Visible = false; + } + } + + #region Fan Zhang 重构现有代码 + //初始化控件布局 + private void initLayout() + { + 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.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.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.labelX21.Width = (int)(this.labelX21.Width * myScreen); + this.labelX22.Width = (int)(this.labelX22.Width * myScreen); + this.labelX24.Width = (int)(this.labelX24.Width * myScreen); + } + sideBar1.Visible = false; + 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]); + } + + splitContainer1.Panel2Collapsed = true; + + buttonItem87.Checked = true;//默认地上模式 + ribbonTabItem1.Select(); //初始化状态为浏览 + + sideBarPanelItem3.Visible = false; + layerTree.Visible = false; + controlContainerItem3.Visible = false; + if (sideBarPanelItem4.Visible == true) + { + sideBar1.Visible = true; + controlContainerItem5.Visible = true; + } + else + { + sideBar1.Visible = false; + } + Refresh(); + sliderGroundTransSet1.Value = optiValue; + sliderItem1.Value = optiValue; + sliderItem2.Value = optiValue; + sliderItem3.Value = optiValue; + + } + + //初始化地球控件 + private void initGlobalControl() + { + //选择 + btnToolSelect = new GSOHudButton(); + btnToolSelect.SetImage(Application.StartupPath + "\\Resource\\image\\select1.png"); + btnToolSelect.FadeOut = false; + btnToolSelect.Align = EnumAlign.TopLeft; + btnToolSelect.SetOffset(20, 50); + btnToolSelect.Name = "1"; + btnToolSelect.HeightFixed = true; + btnToolSelect.WidthFixed = true; + globeControl1.Globe.AddHudControl(btnToolSelect); + globeControl2.Globe.AddHudControl(btnToolSelect); + + //浏览 + 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); + + //图例 + legend = new GSOHudButton(); + legend.SetImage(Application.StartupPath + "/Resource/图例P.jpg");//图例P + legend.SetOffset(0, 15); + legend.MinOpaque = 1; + legend.MaxOpaque = 1; + legend.FadeOut = false; + legend.Name = "legend"; + legend.Align = EnumAlign.BottomRight; + legend.Visible = false; + globeControl1.Globe.AddHudControl(legend); + + //实测 + legendSC = new GSOHudButton(); + legendSC.SetImage(Application.StartupPath + "/Resource/sc.jpg"); + legendSC.SetOffset(0, 15); + legendSC.MinOpaque = 1; + legendSC.MaxOpaque = 1; + legendSC.FadeOut = false; + legendSC.Name = "legendSC"; + legendSC.Align = EnumAlign.BottomRight; + globeControl1.Globe.AddHudControl(legendSC); + legendSC.Visible = false; + + //施工 + legendSG = new GSOHudButton(); + legendSG.SetImage(Application.StartupPath + "/Resource/sg.jpg"); + legendSG.SetOffset(0, 15); + legendSG.MinOpaque = 1; + legendSG.MaxOpaque = 1; + legendSG.FadeOut = false; + legendSG.Name = "legendSG"; + legendSG.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(legendSG); + legendSG.Visible = false; + + //管纵 + AddGZ(); + + 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; + globeControl1.Globe.IsReleaseMemOutOfView = true; + globeControl1.Globe.ControlPanel.Visible = true; + + globeControl2.Globe.UnderGroundFloor.Visible = false; + globeControl2.Globe.OverviewControl.Visible = false; + globeControl2.Globe.ScalerControl.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; + globeControl2.Globe.IsReleaseMemOutOfView = true; + globeControl2.Globe.ControlPanel.Visible = false; + + 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); + + //添加临时图层 + layerTemp = globeControl1.Globe.Layers.Add(Application.StartupPath + "\\tempLgdData.lgd"); + layerTemp2 = globeControl2.Globe.Layers.Add(Application.StartupPath + "\\tempLgdData2.lgd"); + if (layerTemp != null) + { + layerTemp.MaxVisibleAltitude = 1000; + } + + //添加城市7线图层 + 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"); + + //注册对应事件 + this.registerEvent(); + } + + //注册地球事件 + private bool registerEvent() + { + if (globeControl1 == null || globeControl2 == null) + { + return false; + } + 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); + + globeControl2.FeatureMouseClickEvent += new FeatureMouseClickEventHandler(globeControl2_FeatureMouseClickEvent); + globeControl2.CameraBeginMoveEvent += new CameraBeginMoveEventHandler(globeControl2_CameraBeginMoveEvent); + + globeControl1.MouseDoubleClick += new MouseEventHandler(globeControl1_MouseDoubleClick); + globeControl1.MouseClick += new MouseEventHandler(globeControl1_MouseClick); + globeControl1.MouseDown += new MouseEventHandler(globeControl1_MouseDown); + + globeControl2.MouseClick += new MouseEventHandler(globeControl2_MouseClick); + globeControl2.MouseDown += new MouseEventHandler(globeControl2_MouseDown); + + 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); + + return true; + } + + //加载两个地球数据 + private void loadData() + { + Thread t1 = new Thread(new ThreadStart(doLoadDataForGlobalControl1)); + t1.IsBackground = true; + t1.Start(); + + + } + + delegate void LoadDataForGlobalControl(); + + private void connectServer() + { + globeControl1.Globe.ConnectServer(Utility.serverip, Utility.serverport, "", ""); //加载locaServer中的数据 + globeControl2.Globe.ConnectServer(Utility.serverip, Utility.serverport, "", ""); //加载locaServer中的数据 + //初始化TreeView + // 勾选实测图层 + foreach (TreeNode tn in layerTree.Nodes) + { + if (tn.Nodes.Count > 0) + { + if (tn.Text == "实测数据") + { + tn.Checked = true; + foreach (TreeNode tnChild in tn.Nodes) + { + tnChild.Checked = true; + foreach (TreeNode tnGrandChild in tnChild.Nodes) + { + tnGrandChild.Checked = true; + } + } + } + } + } + } + + private void doLoadDataForGlobalControl1() + { + try + { + + globeControl1.Globe.Layers.MoveDown(10000); + //加载实测管线数据 + Utility.dataSource = globeControl1.Globe.DataManager.OpenOracleDataSource(Utility.DBServer.Trim() + "/" + Utility.dbdatabase.Trim(), "", "", Utility.userID, Utility.DBPassword); + + if (Utility.dataSource != null) + { + for (int j = 0; j < Utility.dataSource.DatasetCount; j++) + { + GSODataset dataset = Utility.dataSource.GetDatasetAt(j); + if (dataset != null && dictionaryNetLayerNameAndCaption.ContainsKey(dataset.Caption)) + { + dataset.Caption = dataset.Name; + globeControl1.Globe.Layers.Add(dataset); + } + } + } + //隐藏红线图层 + globeControl1.Globe.Layers.GetLayerByCaption("红线").Visible = false; + + //globleControl1中加载规划数据 + GSODataSource ghDS = globeControl1.Globe.DataManager.OpenOracleDataSource(Utility.ghdbip + "/" + Utility.ghdbname, "", "", Utility.ghdbuser, Utility.ghdbpwd); + if (ghDS != null) + { + for (int j = 0; j < ghDS.DatasetCount; j++) + { + GSODataset dataset = ghDS.GetDatasetAt(j); + if (dataset != null && dictionaryNetLayerNameAndCaption.ContainsKey(dataset.Caption)) + { + dataset.Caption = dataset.Name; + globeControl1.Globe.Layers.Add(dataset); + globeControl1.Globe.Layers[0].Visible = false; + } + } + } + + //globeControl1,globeControl2中加载施工数据 + GSODataSource sgDS = globeControl1.Globe.DataManager.OpenOracleDataSource(Utility.sgdbip + "/" + Utility.sgdbname, "", "", Utility.sgdbuser, Utility.sgdbpwd); + if (sgDS != null) + { + for (int m = 0; m < sgDS.DatasetCount; m++) + { + GSODataset dataset = sgDS.GetDatasetAt(m); + if (dataset != null && !dataset.Caption.Contains("SH") && dictionaryNetLayerNameAndCaption.ContainsKey(dataset.Caption)) + { + dataset.Caption = dataset.Name; + globeControl1.Globe.Layers.Add(dataset); + globeControl1.Globe.Layers[0].Visible = false; + + globeControl2.Globe.Layers.Add(dataset); + globeControl2.Globe.Layers[0].Visible = true; + } + } + } + + LoadDataForGlobalControl ss = new LoadDataForGlobalControl(connectServer); + ss(); + + } + catch (Exception ex) + { + MessageBox.Show(ex.Message); + } + } + + private void initLayerTree() + { + //加载临时图层节点 + layerManagerNode = new TreeNode(); + layerManagerNode.ImageIndex = 0; + layerManagerNode.SelectedImageIndex = 0; + layerManagerNode.Checked = true; + layerManagerNode.Text = "临时图层"; + layerTree.Nodes.Add(layerManagerNode); + + XmlDocument doc = new XmlDocument(); + doc.Load(filename); + XmlNodeList xmlLayerNodes = doc.SelectNodes("//layer"); + + foreach (XmlNode xmlLayerNode in xmlLayerNodes) + { + + //TODO LIST:创建一级TreeNode(实测、规划、施工) + TreeNode nodelayer = new TreeNode(); + string layerName = xmlLayerNode.Attributes["label"].Value; + nodelayer.Text = layerName; + nodelayer.Checked = false; + layerTree.Nodes.Add(nodelayer); + + XmlNodeList xmlChildLayerNodes = xmlLayerNode.ChildNodes; + foreach (XmlNode xmlChildLayerNode in xmlChildLayerNodes) + { + //TODO LIST:创建二级TreeNode节点 + TreeNode secondLevelNode = new TreeNode(); + string layerType = xmlChildLayerNode.Attributes["label"].Value; + secondLevelNode.Text = layerType; + + if (xmlChildLayerNode.Attributes["type"] != null) + { //道路图层特殊处理 + string type = xmlChildLayerNode.Attributes["type"].Value; + secondLevelNode.Tag = type + "|" + layerType; + } + else + { + secondLevelNode.Tag = layerType; + } + secondLevelNode.Checked = false; + nodelayer.Nodes.Add(secondLevelNode); + + XmlNodeList xmlActitualLayerNodes = xmlChildLayerNode.ChildNodes; + + foreach (XmlNode xmlActitualLayerNode in xmlActitualLayerNodes) + { + //TODO LIST:创建三级图层节点 + TreeNode layerNode = new TreeNode(); + string actutallylayerType = xmlActitualLayerNode.Attributes["type"].Value; + string actutallylayerName = xmlActitualLayerNode.Attributes["layer"].Value; + string actutallyLabelName = xmlActitualLayerNode.Attributes["label"].Value; + + layerNode.Text = actutallyLabelName; + layerNode.Tag = layerType + "|" + actutallyLabelName; + layerNode.Checked = false; + secondLevelNode.Nodes.Add(layerNode); + } + + } + + } + + } + + /** + * 读取Config.xml文件,初始化以下全局Map + * m_PipelineLayerNames:管线 + * workwellLayerNames:工井 + * valueLayerNames:阀门 + * instrumenLayerNames:附属物 + * pipefittingLayerNames:特征管点 + * sgPipeLayersNames:施工管线 + **/ + private void initGlobalMap() + { + XmlDocument doc = new XmlDocument(); + doc.Load(filename); + XmlNodeList xmlLayerNodes = doc.SelectNodes("//layerchild"); + + foreach (XmlNode xmlLayerNode in xmlLayerNodes) + { + string layerType = xmlLayerNode.Attributes["type"].Value; + string layerName1 = xmlLayerNode.Attributes["layer"].Value; + string layerchildName = xmlLayerNode.Attributes["label"].Value; + + dictionaryNetLayerNameAndCaption.Add(layerName1, layerchildName); + + if (layerType != "db") + { + if (xmlLayerNode.Attributes["isRoad"] != null) + { + roadLayerName = layerchildName; + } + } + else if (xmlLayerNode.Attributes["isPipeLine"] != null) + { + m_PipelineLayerNames.Add(layerchildName); + g1layername.Add(layerName1); + } + else if (xmlLayerNode.Attributes["isWorkWell"] != null) + { + workwellLayerNames.Add(layerchildName); + g1layername.Add(layerName1); + } + else if (xmlLayerNode.Attributes["isValve"] != null) + { + valueLayerNames.Add(layerchildName); + g1layername.Add(layerName1); + } + else if (xmlLayerNode.Attributes["isAccess"] != null) + { + instrumenLayerNames.Add(layerchildName); + g1layername.Add(layerName1); + } + else if (xmlLayerNode.Attributes["isCharacter"] != null) + { + pipefittingLayerNames.Add(layerchildName); + g1layername.Add(layerName1); + } + else if (xmlLayerNode.Attributes["isSgData"] != null) + { + sgPipeLayersNames.Add(layerchildName); + g1layername.Add(layerName1); + } + + } + } + + private void initMarkerTree() + { + 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); + } + } + } + } + + private void MainFrm_Load(object sender, EventArgs e) + { + + this.initGlobalControl(); + this.initGlobalMap(); + this.initLayerTree(); + this.initMarkerTree(); + this.initLayout(); + this.loadData(); + + + double x = Convert.ToDouble(Utility.Query_Roads["绿岛"].ToString().Split(',')[0]); + double y = Convert.ToDouble(Utility.Query_Roads["绿岛"].ToString().Split(',')[1]); + double z = Convert.ToDouble(Utility.Query_Roads["绿岛"].ToString().Split(',')[2]); + jumpToCameraState(x, y, z); + + + } + + #endregion + + /// + /// 每次gis服务加载时都会触发的 + /// + /// + /// + 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 dictionaryNetLayerNameAndCaption = new Dictionary(); + 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 配置用户权限 + /// + /// 向数据库插入功能列表 + /// + private void insertControlToDatabase() + { + ArrayList listItem = new ArrayList(); + List subListItem = new List(); + 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) + { + GSOCameraState camera = globeControl2.Globe.CameraState; + globeControl1.Globe.JumpToCameraState(camera); + } + } + + void globeControl1_BeforeSceneRenderEvent(object sender, BeforeSceneRenderEventArgs e) + { + if (globeControl1.Focused) + { + 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); + } + } + } + + /// + /// 检查数据集是否有坐标系信息 + /// + /// + /// + 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 = "0prj4" + lprjStr + ""; + + bSuccess = dataset.LoadProjectionFromESRIFile(dlg.FileName); + + string lprjFileName = strDataPath.Substring(0, strDataPath.LastIndexOf(".")) + ".lprj"; + StreamWriter writer = new StreamWriter(lprjFileName, false); + writer.Write(lprjFileContent); + writer.Close(); + + } + } + } + else + { + return true; + } + return bSuccess; + } + + /// + /// 矩形拉框结束事件处理函数 + /// + /// + /// + 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))); + */ + + int mapWidth = 0; + int mapHeight = 0; + Point pt = getUpperLeftPoint(pt1, pt2, out mapWidth, out mapHeight); + int rightBottomX = pt.X + mapWidth; + int rightBottomY = pt.Y + mapHeight; + Image myImg = new Bitmap(mapWidth, mapHeight); + Graphics g = Graphics.FromImage(myImg); + g.CopyFromScreen(pt, new Point(0, 0), new Size(rightBottomX, rightBottomY)); + + 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; + } + } + /// + /// 定位正北正90度俯视 + /// + /// + /// + /// + 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; + } + } + /// + /// layerTree选中后事件处理 + /// + /// + /// + 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); + } + /// + /// 树节点选中方法 + /// + /// + 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); + } + } + } + + } + /// + /// 改变所有子节点的状态 + /// + /// + /// + 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; + LayerFlyMenuItem.Visible = true; + } + + LayerSelectableMenuItem.Visible = true; + LayerEditableMenuItem.Visible = true; + SaveLayerMenuItem.Visible = true; + LayerFlyMenuItem.Visible = true; + 导出CADToolStripMenuItem1.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]); + if (layer != null) + { + LayerSelectableMenuItem.Checked = layer.Selectable; + LayerEditableMenuItem.Checked = layer.Editable; + } + else + { + return; + } + } + 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; + } + } + } + } + } + + /// + /// 删除临时添加的本地数据图层 + /// + /// + /// + 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); + for (int i = globeControl1.Globe.Layers.Count-1; i >=0; i--) + { + if (globeControl1.Globe.Layers[i].Caption == layer.Caption) + { + globeControl1.Globe.Layers.Remove(globeControl1.Globe.Layers[i]); + } + } + + 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 定位ToolStripMenuItem_Click(object sender, EventArgs e) + { + TreeNode node = layerTree.SelectedNode; + + if (node != null) + { + if (node.Parent.Text.Trim() == "临时图层") + { + GSOLayer lsLayer = globeControl1.Globe.Layers.GetLayerByCaption(node.Text.ToString()); + double x = lsLayer.LatLonBounds.Center.X; + double y = lsLayer.LatLonBounds.Center.Y; + if (x == 0 && y == 0) + { + x = lsLayer.Bounds.Center.X; + y = lsLayer.Bounds.Center.Y; + } + + globeControl1.Globe.FlyToPosition(new GSOPoint3d(x, y, 10), EnumAltitudeMode.Absolute); + } + else + { + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(node.Tag.ToString().Split('|')[1]); + + if (layer != null) + { + if (layer.Caption == "红线") + { + globeControl1.Globe.FlyToPosition(new GSOPoint3d(120.610963, 31.188121, 50), EnumAltitudeMode.Absolute, -4, 50, 1000); + globeControl1.Globe.FlyToPointSpeed = 10000000; + globeControl1.Globe.Action = EnumAction3D.SelectObject; + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = true; + } + globeControl1.Refresh(); + } + else + { + double x = layer.LatLonBounds.Center.X; + double y = layer.LatLonBounds.Center.Y; + globeControl1.Globe.FlyToPosition(new GSOPoint3d(x, y, 100), EnumAltitudeMode.Absolute); + } + } + } + } + else + { + return; + } + + } + + private void layerTree_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e) + { + if(this.layerTree.SelectedNode!=null) + { + if (this.layerTree.SelectedNode.Tag.ToString().Contains("|")) + { + string nodeTag = this.layerTree.SelectedNode.Tag.ToString().Split('|')[1]; + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(nodeTag); + if (layer != null) + { + if (layer.Caption == "红线") + { + globeControl1.Globe.FlyToPosition(new GSOPoint3d(120.610963, 31.188121, 50), EnumAltitudeMode.Absolute, -4, 50, 1000); + globeControl1.Globe.FlyToPointSpeed = 10000000; + globeControl1.Globe.Action = EnumAction3D.SelectObject; + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = true; + } + globeControl1.Refresh(); + } + else { + double x = layer.LatLonBounds.Center.X; + double y = layer.LatLonBounds.Center.Y; + globeControl1.Globe.FlyToPosition(new GSOPoint3d(x, y, 0), EnumAltitudeMode.Absolute); + } + } + } + if (this.layerTree.SelectedNode.Tag is GSOLayer) + { + GSOLayer layer = this.layerTree.SelectedNode.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 (this.layerTree.SelectedNode.Tag is GSOFeature) + { + GSOFeature feature = this.layerTree.SelectedNode.Tag as GSOFeature; + if (feature.Geometry != null) + { + globeControl1.Globe.FlyToPosition(feature.Geometry.GeoCenterPoint, EnumAltitudeMode.Absolute, 0, 0, 10); + } + else + { + globeControl1.Globe.FlyToFeature(feature); + } + } + } + } + + /// + /// 在三维场景移动时,隐藏气泡globeControl1 + /// + /// + /// + void globeControl1_CameraBeginMoveEvent(object sender, CameraBeginMoveEventArgs e) + { + if (featureTooltip.IsVisible()) + { + featureTooltip.HideBalloon(); + } + if (balloonEx.IsVisible()) + { + balloonEx.HideBalloon(); + } + } + + /// + /// 在三维场景移动时,隐藏气泡globeControl2 + /// + /// + /// + void globeControl2_CameraBeginMoveEvent(object sender, CameraBeginMoveEventArgs e) + { + if (featureTooltip2.IsVisible()) + { + featureTooltip2.HideBalloon(); + } + if (balloonEx2.IsVisible()) + { + balloonEx2.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(); + } + } + + #region Fan 横断面 + /// + /// 横断面分析、基线剖面分析、道路断面分析等 + /// + /// + /// + private static EnumTrackPolylineEndMode trackPolylineEndMode; + + void globeControl1_TrackPolylineEndEvent(object sender, TrackPolylineEndEventArgs e) + { + //横断面分析、道路横断面分析 + if (trackPolylineEndMode == EnumTrackPolylineEndMode.HDM_Analysis|| + trackPolylineEndMode == EnumTrackPolylineEndMode.DLDM_Analysis) + { + Dictionary hdmDic = SectionAnalysisTool.HDMAnalysis(this.globeControl1, + e.Polyline, this.m_PipelineLayerNames); + FrmHDMAnalysis3 frm = new FrmHDMAnalysis3(hdmDic, this.globeControl1, + trackPolylineEndMode); + frm.Show(this); + } + //基线剖面分析 + else if (trackPolylineEndMode == EnumTrackPolylineEndMode.JXPM_Analysis) + { + FrmBaseLineProfillAnalysis dlg = new FrmBaseLineProfillAnalysis(globeControl1.Globe, e.Polyline); + dlg.Show(this); + globeControl1.Globe.ClearLastTrackPolyline(); + } + else + { + + } + trackPolylineEndMode = EnumTrackPolylineEndMode.Default_Analysis; + } + #endregion + + private GSOFeatures PolygonIntersectAnalysis(GSOGeoPolygon3D polygon, string pipelinetype) + { + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(pipelinetype); + 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(pipelinetype, feats.Length); + return feats; + } + /// + /// 根据范围统计阀门、管线、工井等, 开挖分析, 挖方量分析 + /// + /// + /// + void globeControl1_TrackPolygonEndEvent(object sender, TrackPolygonEndEventArgs e) + { + if (globeControl1.Globe.Action == EnumAction3D.TrackPolygon && e.Polygon != null) + { + GSOGeoPolygon3D polygon = e.Polygon; + + switch (trackflag) + { + case "valvequery": + FrmValveStatistics frm = new FrmValveStatistics(globeControl1,polygon, new DataGridViewDelegate(InitDataGridViewX1)); + frm.Show(this); + globeControl1.Globe.Action = EnumAction3D.ActionNull; + break; + + case "PipelineDistanceStatistics": +<<<<<<< HEAD +======= + +>>>>>>> d2d0088a6b3c53c1a96b7f1997f4d3443c0ee8c0 + FrmAllPipelineStatis frm1 = new FrmAllPipelineStatis(globeControl1, polygon, new DataGridViewDelegate(InitDataGridViewX1), m_PipelineLayerNames); + frm1.Show(this); + globeControl1.Globe.Action = EnumAction3D.ActionNull; + + break; + case "PipelineSpatialQuery": +<<<<<<< HEAD +======= + +>>>>>>> d2d0088a6b3c53c1a96b7f1997f4d3443c0ee8c0 + FrmAllPipelineStatis.ShowForm(globeControl1,polygon,new DataGridViewDelegate(InitDataGridViewX1),m_PipelineLayerNames); + globeControl1.Globe.ClearAnalysis(); + globeControl1.Globe.Action = EnumAction3D.ActionNull; + + break; + case "workwellquery": + FrmAllWorkWellStatis frmWell = new FrmAllWorkWellStatis(globeControl1, polygon, new DataGridViewDelegate(InitDataGridViewX1)); + 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 "BSQDuoBianXiangStatis": + + //GSOFeature f2 = new GSOFeature(); + //f2.Geometry = e.Polygon; + //f2.Geometry.AltitudeMode = EnumAltitudeMode.Absolute; + //globeControl1.Globe.MemoryLayer.AddFeature(f2); + //f2.Geometry.MoveZ(3); + //workWellLen.Clear(); + //List listBSQ = new List(); + + //GSOFeatures bsqFeatures = PolygonIntersectAnalysis(e.Polygon, "标识器"); + //listBSQ.Add(bsqFeatures); + + //FrmBSQDuoBianXingStatis bsqFrm = new FrmBSQDuoBianXingStatis(workWellLen, globeControl1, listBSQ); + FrmBSQStatis bsqFrm = new FrmBSQStatis(globeControl1,e.Polygon); + bsqFrm.Show(this); + globeControl1.Globe.Action = EnumAction3D.ActionNull; + break; + + case "": + break; + default: + break; + } + } + } + + #region 验证端口 + /* + /// + /// 验证端口 + /// + /// + 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 + + /// + /// 鼠标悬浮提示 + /// + /// + /// + 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); + } + } + + /// + /// 添加管线绘制完成事件, 红线工具绘制完成 + /// + /// + /// + 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; + + + } + } + + /// + /// 获取globeControl1中鼠标按下的坐标供区别鼠标右键和滚轮按下事件 + /// + /// + /// + void globeControl1_MouseDown(object sender, MouseEventArgs e) + { + mouseDownX1 = e.X; + mouseDownY1 = e.Y; + } + /// + /// 获取globeControl2中鼠标按下的坐标供区别鼠标右键和滚轮按下事件 + /// + /// + /// + void globeControl2_MouseDown(object sender, MouseEventArgs e) + { + mouseDownX2 = e.X; + mouseDownY2 = e.Y; + } + /// + /// + /// + /// + /// + void globeControl2_MouseClick(object sender, MouseEventArgs e) + { + if (e.Button == MouseButtons.Right) + { + if (e.X == mouseDownX2 && e.Y == mouseDownY2) + { + RightScreenToolMenu.Show(globeControl2, e.X, e.Y); + } + else + { + return; + } + } + } + /// + /// + /// + /// + /// + void globeControl1_MouseClick(object sender, MouseEventArgs e) + { + if (e.Button == MouseButtons.Left) + { + if (globeControl1.Globe.Action == EnumAction3D.VisibilityAnalysis) + { + buttonItemFX5_1.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; + + bsqPT = pt; + + if (buttonItemLS5.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 (e.X == mouseDownX1 && e.Y == mouseDownY1) + { + toolRightMenu.Show(globeControl1, e.X, e.Y); + if (buttonItemLS5.Checked) + { + buttonItemLS5.Checked = false; + } + } + else + { + return; + } + } + globeControl1.Refresh(); + } + + /// + /// 判断网络图片是否存在 + /// + /// + /// + 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; + } + + /// + /// 鼠标点击, 弹出气泡功能globeControl1 + /// + /// + /// + void globeControl1_FeatureMouseClickEvent(object sender, FeatureMouseClickEventArgs e) + { + GSOFeature feature = e.Feature; + + string str1 = ""; + if (feature != null) + { + if (feature.GetFieldDefn("图片编码") != null)// + { + str1 = GetBubbleInfo(feature, globeControl1); + if (RemoteFileExists(Utility.PicRootURL + feature.GetValue("图片编码").ToString())) + { + str1 += ""; + } + else if (RemoteFileExists(Utility.PicDefaultURL)) + { + str1 += ""; + } + } + else if (isFeatureContainsBianhao(feature)) //管线模型图层 + { + str1 = GetBubbleInfo(feature, globeControl1); + } + + 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; + } + } + } + + /// + /// 鼠标点击, 弹出气泡功能globeControl2 + /// + /// + /// + void globeControl2_FeatureMouseClickEvent(object sender, FeatureMouseClickEventArgs e) + { + GSOFeature feature = e.Feature; + + string str1 = ""; + if (feature != null) + { + if (feature.GetFieldDefn("图片编码") != null) // + { + str1 = GetBubbleInfo(feature, globeControl2); + if (RemoteFileExists(Utility.PicRootURL + feature.GetValue("图片编码").ToString())) + { + str1 += ""; + } + else if (RemoteFileExists(Utility.PicDefaultURL)) + { + str1 += ""; + } + } + else if (isFeatureContainsBianhao(feature)) //管线模型图层 + { + str1 = GetBubbleInfo(feature, globeControl2); + } + + if (str1 != "") + { + + featureTooltip2.HideBalloon(); + balloonEx2.HideBalloon(); + balloonEx2.SetSize(EnumSizeIndexEx.CONTENT_CX, 480); + balloonEx2.SetSize(EnumSizeIndexEx.CONTENT_CY, 420); + balloonEx2.ShowBalloon((int)e.MousePos.X, (int)e.MousePos.Y, str1); + + return; + } + } + } + + /// + /// 拼接气泡表格字符串 + /// + /// + /// + private string GetBubbleInfo(GSOFeature feature,GSOGlobeControl globeControl) + { + if (feature == null) + { + return ""; + } + string str = ""; + str = ""; + 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 += ""; + + 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.get_Fields(layerName, globeControl); + } + if (queryFields != null) + { + string[] param = { "," }; + string[] fieldNames = queryFields.Split(param, StringSplitOptions.RemoveEmptyEntries); + for (int j = 0; j < fieldNames.Length; 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 (name1 == "模型路径") + { + continue; + } + 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 (field1.Type == EnumFieldType.Double) + { + double dl1 = feature.GetFieldAsDouble(j); + if (!name1.Contains("管径") && !name1.Contains("电压") && !name1.Contains("角度")) + { + name1 += "_米"; + } + value1 = dl1.ToString("0.00"); + } + 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 (name2 == "模型路径") + { + continue; + } + + 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 (field2.Type == EnumFieldType.Double) + { + double dl2 = feature.GetFieldAsDouble(j + 1); + if (!name2.Contains("管径") && !name2.Contains("电压") && !name2.Contains("角度")) + { + name2 += "_米"; + } + value2 = dl2.ToString("0.00"); + } + else + { + if (!feature.IsFieldValueNull(j + 1)) + { + value2 = feature.GetValue(j + 1).ToString(); + } + } + } + } + + j++; + } + str += ""; + } + } + str += "
" + title + " " + feature.GetFieldAsString(featureIDFieldName) + "
" + + name1 + + "
" + + value1 + + "
" + + name2 + + "
" + + value2 + "
"; + return str; + } + + string filename = Utility.filename; + List g1layername = new List(); + + /// + /// 获取目标图层 + /// + /// + 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; + } + /// + /// 添加图层 + /// + /// + /// + /// + 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 = 5000; + return templayer.Visible; + } + catch (Exception ex) + { + return false; + } + } + /// + /// 菜单上的 三维导航 工具按钮 + /// + /// + /// + private void buttonItem86_Click(object sender, EventArgs e) + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + } + + /// + /// 地上模式 菜单按钮 + /// + /// + /// + 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(); + + } + } + /// + /// 地下模式 菜单按钮 + /// + /// + /// + 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(); + } + } + /// + /// 行走模式 菜单按钮 + /// + /// + /// + 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; + } + } + /// + /// 地面透明度设置 菜单 + /// + /// + /// + private void sliderGroundTransSet1_ValueChanged(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.sliderGroundTransSet1.Text); + + globeControl1.Globe.GroundOpaque = 100 - sliderGroundTransSet1.Value; + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(roadLayerName);//("180fd"); + if (layer != null) + { + layer.Opaque = 100 - sliderGroundTransSet1.Value; + } + //if (buttonItemSPDB.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; + } + /// + /// 图例 菜单按钮 + /// + /// + /// + 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(); + } + /// + /// 快速定位 菜单按钮 + /// + /// + /// + private void buttonItem91_Click(object sender, EventArgs e) // + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItem91.Text); + FrmFlyToPosition fly = new FrmFlyToPosition(globeControl1); + fly.Show(this); + } + /// + /// 图层管理 菜单按钮 + /// + /// + /// + 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; + + //修改图层管理与标注管理、覆土审查、水平净距分析、垂直净距分析和碰撞分析控件之间的逻辑关系 + controlContainerItem5.Visible = false; + sideBar1.Visible = false; + sideBarPanelItem4.Visible = false; + panel3.Visible = false; + sideBar1.ExpandedPanel = sideBarPanelItem3; + buttonItemBZ11.Checked = false; + + //20160624 + /* + if (sideBarPanelItem4.Visible == true) + { + sideBar1.Visible = true; + controlContainerItem5.Visible = true; + } + else + { + sideBar1.Visible = false; + } + */ + Refresh(); + + } + } + /// + /// 全屏显示 菜单按钮 + /// + /// + /// + 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; + /// + /// 全屏显示功能实现 + /// + 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(); + } + } + + /// + /// 设置窗体宽、高 + /// + /// + /// + private void SetFullScreen(int width, int height) + { + this.Width = width; + this.Height = height; + } + + /// + /// 全屏功能的快捷键F5 + /// + /// + /// + 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); + } + } + /* + /// + /// 输出地图 + /// + /// + /// + /// + 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; + } + * */ + + private Point getUpperLeftPoint(Point p1, Point p2, out int mapWidth, out int mapHeight) // + { + Rectangle rc = new Rectangle(); + + p1 = this.globeControl1.PointToScreen(p1); + p2 = this.globeControl1.PointToScreen(p2); + + int x = Screen.PrimaryScreen.Bounds.X; + int y = Screen.PrimaryScreen.Bounds.Y; + int screenWidth = SystemInformation.WorkingArea.Width; + int screenHeight = SystemInformation.WorkingArea.Height; + + if (p1.X < x) + rc.X = x; + else + rc.X = p1.X; + + if (p1.Y < y) + rc.Y = y; + else + rc.Y = p1.Y; + + p1.X = rc.Left; + p1.Y = rc.Top; + + if (p2.X > screenWidth) + p2.X = screenWidth; + else + p2.X = p2.X; + + if (p2.Y > screenHeight) + p2.Y = screenHeight; + else + p2.Y = p2.Y; + + rc.Width = p2.X - rc.X; + rc.Height = p2.Y - rc.Y; + + mapWidth = rc.Width; + mapHeight = rc.Height; + Point pt = new Point(rc.Left, rc.Top); + return pt; + } + + Image printImage; + /// + /// 打印 菜单 + /// + /// + /// + 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))); + */ + int mapWidth = 0; + int mapHeight = 0; + Point pt = getUpperLeftPoint(pt1, pt2, out mapWidth, out mapHeight); + int rightBottomX = pt.X + mapWidth; + int rightBottomY = pt.Y + mapHeight; + Image myImg = new Bitmap(mapWidth, mapHeight); + Graphics g = Graphics.FromImage(myImg); + g.CopyFromScreen(pt, new Point(0, 0), new Size(rightBottomX, rightBottomY)); + + + 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); + } + /// + /// 输出地图 菜单 + /// + /// + /// + private void btnOutputJPG_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btnOutputJPG.Text); + + //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))); + */ + int mapWidth = 0; + int mapHeight = 0; + Point pt = getUpperLeftPoint(pt1, pt2, out mapWidth, out mapHeight); + int rightBottomX = pt.X + mapWidth; + int rightBottomY = pt.Y + mapHeight; + Image myImg = new Bitmap(mapWidth, mapHeight); + Graphics g = Graphics.FromImage(myImg); + g.CopyFromScreen(pt, new Point(0, 0), new Size(rightBottomX, rightBottomY)); + + 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; + } + } + } + + /// + /// 统计管线的里程数 + /// + /// + /// + /// + 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; + } + + /// + /// 窗体下方属性表格 右键菜单中的 “定位”菜单 + /// + /// + /// + 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); + + } + + /// + /// 表格中右键 “单个闪烁” 菜单 + /// + /// + /// + private void LightMenu_Click(object sender, EventArgs e) + { + flashflag = "single"; + timer1.Start(); + } + /// + /// 表格中右键 “全部闪烁” 菜单 + /// + /// + /// + private void AllLightMenuItem_Click(object sender, EventArgs e) + { + flashflag = "all"; + timer1.Start(); + } + + /// + /// 使用timer实现管线的闪烁效果 + /// + /// + /// + 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; + } + } + + /// + /// 绘制线 菜单 + /// + /// + /// + private void btnAddLine_Click(object sender, EventArgs e) + { + globeControl1.Globe.DestLayerFeatureAdd = globeControl1.Globe.MemoryLayer; + globeControl1.Globe.Action = EnumAction3D.DrawPolyline; + } + /// + /// 绘制面 菜单 + /// + /// + /// + private void btnAddPolygon_Click(object sender, EventArgs e) + { + globeControl1.Globe.DestLayerFeatureAdd = globeControl1.Globe.MemoryLayer; + globeControl1.Globe.Action = EnumAction3D.DrawPolygon; + } + /// + /// 图层目录树 右键菜单中的 目标图层 菜单 + /// + /// + /// + 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; + } + } + /// + /// 图层目录树 右键菜单中的 可选择 菜单 + /// + /// + /// + 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; + } + /// + /// 图层目录树 右键菜单中的 可编辑 菜单 + /// + /// + /// + 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; + } + /// + /// 图层目录树 右键菜单中的 保存 菜单 + /// + /// + /// + 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(); + } + + /// + /// 根据多边形范围统计管线的里程 + /// + /// + /// + /// 返回查询到的管线要素集合 + 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 pipeLineDis = new Dictionary(); + Dictionary workWellLen = new Dictionary(); + + + + + /// + /// 查找指定图层中在 指定范围内的feature对象集合 + /// + /// + /// + /// + 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; + } + /// + /// 清除结果 菜单 + /// + /// + /// + private void buttonItem47_Click(object sender, EventArgs e) + { + globeControl1.Globe.ClearAnalysis(); + dataGridViewX1.DataSource = null; + panelOfTable.Visible = false; + clearFeatureHighLight(); + } + /// + /// 设置菜单的选中状态 + /// + private void ActionToolMenuChecked() + { + if (globeControl1.Globe.Action != EnumAction3D.TrackPolyline) + { + buttonItemFX2_1.Checked = false; + buttonItemFX2_4.Checked = false; + buttonItemFX2_3.Checked = false; + buttonItemFX4_3.Checked = false; + } + if (globeControl1.Globe.Action != EnumAction3D.NormalHit) + { + buttonItemFX3_6.Checked = false; + // ClearConnexityAnalysis(); + + buttonItemFX3_5.Checked = false; + // ClearCloseValvesAnalysis(); + } + if (globeControl1.Globe.Action != EnumAction3D.TrackPolygon) + { + buttonItemFX4_2.Checked = false; + buttonItemFX4_1.Checked = false; + } + } + + /// + /// 主窗体关闭事件处理 + /// + /// + /// + private void MainFrm_FormClosing(object sender, FormClosingEventArgs e) + { + + if (MessageBox.Show("是否退出系统?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) + { + e.Cancel = true; + } + else { + globeControl1.Globe.MemoryLayer.SaveAs(Application.StartupPath + "/MyPlace.kml"); + } + + //saveLayerList(layerManagerNode.Nodes); + //注销id号为103的热键设定 + // UnregisterHotKey(Handle, 103); + } + + /// + /// 显示流向 功能 + /// + /// + /// + /// + 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(); + } + + FrmCloseValves frm; + + FrmBoosterValvers frmbooster = null; + + /// + /// 垂直净距分析 功能界面中的 选择图层复选框 选中状态改变事件处理 + /// + /// + /// + 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(); + } + /// + /// 水平净距分析 功能界面中的 选择图层复选框 选中状态改变事件处理 + /// + /// + /// + 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(); + } + /// + /// 垂直净距分析 功能界面中的 选择管线复选框 选中状态改变事件处理 + /// + /// + /// + private void checkBoxX1_CheckedChanged(object sender, EventArgs e) + { + clearFeatureHighLight(); + if (checkBoxX1.Checked) + { + comboBoxEx1.SelectedItem = null; + 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; + } + } + /// + /// 水平净距分析 功能界面中的 选择管线复选框 选中状态改变事件处理 + /// + /// + /// + private void checkBoxX1_CheckedChanged_shuiping(object sender, EventArgs e) + { + clearFeatureHighLight();//清除高亮 + if (checkBoxX7.Checked) + { + comboBoxEx4.SelectedItem = null; + 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(); + /// + /// 垂直净距分析 功能界面中的 选择图层下拉框 选中项改变 事件处理 + /// + /// + /// + 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; + } + } + } + /// + /// 水平净距分析 功能界面中的 选择图层下拉框 选中项改变 事件处理 + /// + /// + /// + 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 featCount = new Dictionary(); + Dictionary featLenth = new Dictionary(); + Dictionary m_FeaturesWithBianhao = new Dictionary();//记录编号和对应的标注点的位置 + GSOFeatures polygonJingJuAnalysises = new GSOFeatures(); + + /// + /// 垂直净距分析 功能界面中的 开始分析按钮 事件处理 + /// + /// + /// + 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; + } + + /// + /// 在指定的两点组成的线的中间添加一个marker对象,并将marker对象添加到指定的图层中 + /// + /// + /// + /// + /// + /// + 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; + } + + /// + /// 计算指定feature对象与除了该feature所在图层之外的 所有管线图层中的所有feature对象 的垂直距离 并在表格中记录符合要求的管线 + /// + /// + /// + /// + /// + private void VerticalDistanceAnalysis(string type, GSOFeature selectedFeature, List _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(); + } + /// + /// 垂直净距分析中 表格行的 双击定位 功能。 与覆土分析的实现方法不同,主要原因是需要标注垂距 + /// + /// + /// + 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); + } + } + } + } + + /// + /// 水平净距分析 功能界面中 开始分析按钮 的事件处理 + /// + /// + /// + 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; + } + + + /// + /// 计算指定feature对象与除了该feature所在图层之外的 所有管线图层中的所有feature对象 的水平距离 并记录符合要求的管线 功能 + /// + /// + /// + /// + /// + private void HorizontalDistanceAnalysis(GSOFeature selectedFeature, List _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)); + } + } + } + } + } + /// + /// 水平净距分析 功能界面中 表格的 双击定位 功能 + /// + /// + /// + 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); + } + } + } + } + } + /// + /// 碰撞分析 功能界面中 开始分析按钮 事件处理 + /// + /// + /// + 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; + } + /// + /// 碰撞分析功能界面中 表格的 双击定位 功能 + /// + /// + /// + 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); + } + } + } + } + + + + /// + /// 覆土分析功能操作界面中的 选择管线 复选框选中状态改变事件处理 + /// + /// + /// + private void checkBoxX5_CheckedChanged(object sender, EventArgs e) + { + clearFeatureHighLight(); + if (checkBoxX5.Checked) + { + comboBoxEx3.SelectedItem = null; + 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; + } + } + /// + /// 覆土分析功能操作界面中的 选择图层 复选框选中状态改变事件处理 + /// + /// + /// + 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(); + } + /// + /// 覆土分析功能操作界面中的 图层下拉框选中项改变事件处理 + /// + /// + /// + 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; + } + } + } + /// + /// 覆土分析功能操作界面中的 开始分析 按钮事件处理 + /// + /// + /// + 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; + + + GSOPoint3d markerPosition = new GSOPoint3d(); + 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]; + GSOPoint3d pt = new GSOPoint3d(); + + 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"); + + pt.X = pts[m].X; + pt.Y = pts[m].Y; + pt.Z = 0; + markerPosition = LabelVerticalDistance(layerTemp, pts[m], pt, Convert.ToDouble(dataGridViewX7.Rows[idx].Cells[2].Value), true); + 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]; + GSOPoint3d pt = new GSOPoint3d(); + 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"); + + pt.X = pts[m].X; + pt.Y = pts[m].Y; + pt.Z = 0; + markerPosition = LabelVerticalDistance(layerTemp, pts[m], pt, Convert.ToDouble(dataGridViewX7.Rows[idx].Cells[2].Value), true); + + 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; + } + + /// + /// 覆土分析中 表格的 双击定位 功能 + /// + /// + /// + 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); + } + } + } + } + } + /// + /// 覆土分析功能操作界面中的 导出Excel按钮 事件处理 + /// + /// + /// + private void buttonX10_Click(object sender, EventArgs e) + { + if (dataGridViewX7.Rows.Count > 0) + { + ExportExcel("覆土分析", dataGridViewX7, null); + } + else + { + MessageBox.Show("表格内容为空!", "提示"); + } + } + /// + /// 覆土分析功能操作界面底部的 关闭 按钮事件处理 + /// + /// + /// + 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(); + layerTemp.RemoveAllFeature(); + + if (buttonItem1.Checked) + { + sideBar1.ExpandedPanel = sideBarPanelItem3; + } + else + { + sideBar1.Visible = false; + } + globeControl1.Refresh(); + + //Refresh(); + } + + + /// + /// 垂直净距分析 功能界面中 清除分析结果按钮 事件处理 + /// + /// + /// + 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(); + } + /// + /// 水平净距分析 功能界面中 清除分析结果按钮 事件处理 + /// + /// + /// + 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(); + } + + /// + /// 垂直净距分析功能界面中 关闭按钮 事件处理 + /// + /// + /// + 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(); + } + /// + /// 水平净距分析功能界面中 删除缓冲区按钮 事件处理 + /// + /// + /// + private void buttonX14_Click(object sender, EventArgs e) + { + 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(); + } + + /// + /// 导出指定DataGridView控件中的内容 + /// + /// + /// + 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(); + } + } + } + } + + /// + /// 垂直净距分析功能界面中 导出Excel按钮 事件处理 + /// + /// + /// + private void buttonX4_Click(object sender, EventArgs e) + { + if (dataGridViewX3.Rows.Count > 0) + { + ExportExcel("垂直净距分析", dataGridViewX3, listBox1); + } + else + { + MessageBox.Show("表格内容为空!", "提示"); + } + } + /// + /// 水平净距分析功能界面中 导出Excel按钮 事件处理 + /// + /// + /// + private void buttonX4_Click_shuiping(object sender, EventArgs e) + { + if (dataGridViewX9.Rows.Count > 0) + { + ExportExcel("水平净距分析", dataGridViewX9, listBox3); + } + else + { + MessageBox.Show("表格内容为空!", "提示"); + } + } + + + /// + /// 清除所有坑 菜单 + /// + /// + /// + private void buttonItem3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItem3.Text); + + globeControl1.Globe.RemoveAllPits(); + } + + //} + /// + /// 大气层 菜单 + /// + /// + /// + private void buttonItem17_Click_1(object sender, EventArgs e) + { + globeControl1.Globe.Atmosphere.Visible = !globeControl1.Globe.Atmosphere.Visible; + buttonItemSH1.Checked = globeControl1.Globe.Atmosphere.Visible; + globeControl1.Refresh(); + } + /// + /// 经纬网 菜单 + /// + /// + /// + private void buttonItem20_Click(object sender, EventArgs e) + { + globeControl1.Globe.LatLonGrid.Visible = !globeControl1.Globe.LatLonGrid.Visible; + buttonItemSH3.Checked = globeControl1.Globe.LatLonGrid.Visible; + globeControl1.Globe.Refresh(); + } + /// + /// 状态条 菜单 + /// + /// + /// + private void buttonItem21_Click_1(object sender, EventArgs e) + { + globeControl1.Globe.StatusBar.Visible = !globeControl1.Globe.StatusBar.Visible; + buttonItemSH4.Checked = globeControl1.Globe.StatusBar.Visible; + globeControl1.Globe.Refresh(); + } + + + + /// + /// 添加指定路径下的数据 功能 + /// + /// + /// + 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); + //CheckDatasetGeoReference(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; + } + return objRes; + } + /// + /// 刷新目录树 功能 + /// + 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); + } + } + /// + /// 判断图层是否包含字段列表 + /// + /// + /// + 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; + } + + /// + /// 统计指定图层在指定范围内的所有feature对象 + /// + /// + /// + /// + 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; + } + /// + /// 碰撞分析功能界面中 选择管线复选框 选中状态改变事件处理 + /// + /// + /// + private void checkBoxX3_CheckedChanged(object sender, EventArgs e) + { + clearFeatureHighLight(); + if (checkBoxX3.Checked) + { + comboBoxEx2.SelectedItem = null; + 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; + } + } + /// + /// 碰撞分析功能界面中 选择图层复选框 选中状态改变事件处理 + /// + /// + /// + 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(); + } + /// + /// 碰撞分析功能界面中 选择图层下拉框 选中项改变事件处理 + /// + /// + /// + 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; + } + } + } + /// + /// 清除所有图层中的所有feature对象的高亮状态 功能 + /// + 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); + } + } + } + } + for (int i = 0; i < globeControl2.Globe.Layers.Count; i++) + { + GSOLayer layer = globeControl2.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; + } + } + } + + if (globeControl1.Globe.Action == EnumAction3D.SelectObject) + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + //globeControl1.Globe.Action = EnumAction3D.SelectObject; + } + } + + /// + /// 碰撞分析功能界面中 清除分析结果按钮 事件处理 + /// + /// + /// + 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(); + } + /// + /// 碰撞分析功能界面中 导出Excel按钮 事件处理 + /// + /// + /// + private void buttonX6_Click(object sender, EventArgs e) + { + if (dataGridViewX5.Rows.Count > 0) + { + ExportExcel("碰撞分析", dataGridViewX5, listBox2); + } + else + { + MessageBox.Show("表格内容为空!", "提示"); + } + } + /// + /// 导出CAD 菜单 + /// + /// + /// + private void btnExportCAD_Click(object sender, EventArgs e) + { + FrmExportCADS frm = new FrmExportCADS(globeControl1, m_PipelineLayerNames); + frm.ShowDialog(); + } + + ///// + ///// 区域分析 菜单 + ///// + ///// + ///// + //private void buttonItem50_Click(object sender, EventArgs e) + //{ + // buttonItem50.Checked = !buttonItem50.Checked; + // ribbonBarQY.Visible = buttonItem50.Checked; + // ribbonBarQY.Location = new Point(0, 0); + //} + + + /// + /// 连接数据库 菜单事件处理 + /// + /// + /// + 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; + } + } + } + /// + /// 数据验证 菜单 + /// + /// + /// + private void buttonItem80_Click(object sender, EventArgs e) + { + FrmValiData frm = new FrmValiData(globeControl1); + frm.ShowDialog(); + } + /// + /// 根据指定图层创建图层节点并将节点添加到图层管理节点的子节点集合中 + /// + /// + 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; + + if (!layerManagerNode.Nodes.Contains(node)) + { + layerManagerNode.Nodes.Insert(0, node); + layerManagerNode.Expand(); + } + } + } + /// + /// 数据库备份 菜单 + /// + /// + /// + 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(); + } + } + } + + + + #region Fan 去掉 + //GSOFeature emitterFeature; // 粒子要素 + /// + /// 添加火苗 功能 + /// + /// + /// + /// + 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); + + } + /// + /// 添加喷泉 功能 + /// + /// + /// + /// + 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); + } + #endregion + + /// + /// 获取指定图层中最后一个feature对象的名称对应的整数 + /// + /// + /// + 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; + } + /// + /// 设置除指定标注图层之外的所有标注图层不可见 + /// + /// + 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; + } + } + } + } + } + + /// + /// 判断选中的对象是否为管线 + /// + /// 被选中管线 + /// 返回一根线 + 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; + } + + /// + /// 获取指定两点组成的线的长度 功能 + /// + /// + /// + /// + 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; + } + + /// + /// 图层节点树中 节点 右键单击事件处理 + /// + /// + /// + 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; + } + } + } + } + } + + /// + /// 标注管理、传感器管理 图层目录树的右键菜单中的 刷新列表 菜单 + /// + /// + /// + 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); + } + } + /// + /// 给指定的图层节点添加代表feature对象的子节点 + /// + /// + private void RefreshTreeNodeLayerFeatureList(TreeNode layerTreeNode) + { + layerTreeNode.Nodes.Clear(); + GSOLayer layer = (GSOLayer)layerTreeNode.Tag; + // 只将类型为内存数据集的图层列出,如果是其它类型的数据集可能数据量太大,没发显示在树控件中 + if (layer.Dataset is GSOFeatureDataset) + { + VisitFeature3Ds(layer.GetAllFeatures(), layerTreeNode); + } + } + + /// + /// 标注管理、传感器管理 图层目录树的右键菜单中的 移除所有 菜单 + /// + /// + /// + 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(); + } + } + + /// + /// 图层目录树的 节点对应的复选框选中状态改变事件处理 + /// + /// + /// + private void layerMarkerTree_AfterCheck(object sender, TreeViewEventArgs e) + { + if (e.Action != TreeViewAction.Unknown) + { + CheckTreeNode(e.Node, e.Node.Checked); + } + } + /// + /// 改变指定节点对应的复选框的选中状态 + /// + /// + /// + private void CheckTreeNode(TreeNode node, Boolean bChecked) + { + CheckChildTreeNode(node, bChecked); + globeControl1.Globe.Refresh(); + } + /// + /// 改变指定节点的子节点对应的复选框的选中状态 + /// + /// + /// + 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); + } + } + /// + /// 标注管理、传感器管理 目录树中的feature节点的右键菜单中的 删除 菜单 + /// + /// + /// + 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(); + } + } + + /// + /// 双屏对比 菜单 + /// + /// + /// + //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(); + // } + //} + /// + /// 模拟分析 菜单 + /// + /// + /// + //private void buttonItem51_Click(object sender, EventArgs e) + //{ + // buttonItem51.Checked = !buttonItem51.Checked; + // ribbonBarMN.Visible = buttonItem51.Checked; + // ribbonBarMN.Location = new Point(0, 0); + //} + + /// + /// 双屏设置 菜单 + /// + /// + /// + //private void buttonItem96_Click(object sender, EventArgs e) + //{ + // FrmLayerControl frm = new FrmLayerControl(layerTree,globeControl1,globeControl2); + // frm.Show(this); + //} + /// + /// 双屏联动 菜单 + /// + /// + /// + //private void buttonItem95_Click(object sender, EventArgs e) + //{ + // buttonItem95.Checked = !buttonItem95.Checked; + //} + ///// + /// 添加用户仓库 菜单 + /// + /// + /// + private void buttonItem108_Click(object sender, EventArgs e) + { + FrmUserRepo frm = new FrmUserRepo(-1); + frm.ShowDialog(); + } + /// + /// 用户仓库管理 菜单 + /// + /// + /// + private void buttonItem111_Click(object sender, EventArgs e) + { + FrmUserRepoMgr frm = new FrmUserRepoMgr(); + frm.ShowDialog(); + } + /// + /// 添加分系统 菜单 + /// + /// + /// + private void buttonItem112_Click(object sender, EventArgs e) + { + //FrmAPP frm = new FrmAPP(-1); + //frm.ShowDialog(); + } + /// + /// 分系统管理 菜单 + /// + /// + /// + private void buttonItem113_Click(object sender, EventArgs e) + { + //FrmAPPMgr frm = new FrmAPPMgr(); + //frm.ShowDialog(); + } + /// + /// 添加操作 菜单 + /// + /// + /// + private void buttonItem114_Click(object sender, EventArgs e) + { + FrmOper frm = new FrmOper(-1); + frm.ShowDialog(); + } + /// + /// 操作管理 菜单 + /// + /// + /// + private void buttonItem115_Click(object sender, EventArgs e) + { + FrmOperMgr frm = new FrmOperMgr(); + frm.ShowDialog(); + } + /// + /// 添加资源 菜单 + /// + /// + /// + private void buttonItem116_Click(object sender, EventArgs e) + { + FrmRESC frm = new FrmRESC(-1); + frm.ShowDialog(); + } + /// + /// 资源管理 菜单 + /// + /// + /// + private void buttonItem117_Click(object sender, EventArgs e) + { + FrmRESCMgr frm = new FrmRESCMgr(); + frm.ShowDialog(); + } + /// + /// 添加权限 菜单 + /// + /// + /// + private void buttonItem118_Click(object sender, EventArgs e) + { + FrmPerm frm = new FrmPerm(-1); + frm.ShowDialog(); + } + /// + /// 权限管理 菜单 + /// + /// + /// + private void buttonItem119_Click(object sender, EventArgs e) + { + FrmPermMgr frm = new FrmPermMgr(); + frm.ShowDialog(); + } + /// + /// 添加访问控制 菜单 + /// + /// + /// + private void buttonItem120_Click(object sender, EventArgs e) + { + FrmAccess frm = new FrmAccess(-1); + frm.ShowDialog(); + } + /// + /// 访问控制管理 菜单 + /// + /// + /// + private void buttonItem121_Click(object sender, EventArgs e) + { + FrmAccessMgr frm = new FrmAccessMgr(); + frm.ShowDialog(); + } + /// + /// 部门类型管理 菜单 + /// + /// + /// + private void buttonItem122_Click(object sender, EventArgs e) + { + FrmRegionTypeMgr frm = new FrmRegionTypeMgr(); + frm.ShowDialog(); + } + /// + /// 添加用户 菜单 + /// + /// + /// + private void buttonItem127_Click(object sender, EventArgs e) + { + FrmUserAdd frm = new FrmUserAdd(-1); + frm.ShowDialog(); + } + /// + /// 用户信息管理 菜单 + /// + /// + /// + private void buttonItem128_Click_1(object sender, EventArgs e) + { + FrmUserManager frm = new FrmUserManager(); + frm.ShowDialog(); + } + /// + /// 添加角色 菜单 + /// + /// + /// + private void 添加角色_Click(object sender, EventArgs e) + { + FrmRole frm = new FrmRole(-1); + frm.ShowDialog(); + } + /// + /// 所有角色管理 菜单 + /// + /// + /// + private void 角色管理_Click(object sender, EventArgs e) + { + FrmRoleMgr frm = new FrmRoleMgr(); + frm.ShowDialog(); + } + + /// + /// 部门角色管理 菜单 + /// + /// + /// + private void buttonItem133_Click(object sender, EventArgs e) + { + FrmRegionRoleMgr frm = new FrmRegionRoleMgr(); + frm.ShowDialog(); + } + /// + /// 部门管理 菜单 + /// + /// + /// + private void buttonItem130_Click(object sender, EventArgs e) + { + FrmRegionMgr frm = new FrmRegionMgr(); + frm.ShowDialog(); + } + + /// + /// 日志管理 菜单 + /// + /// + /// + private void buttonItem135_Click(object sender, EventArgs e) + { + FrmLogManager frm = new FrmLogManager(); + frm.ShowDialog(); + } + /// + /// 传感器信息查询 菜单 + /// + /// + /// + 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); + } + } + } + /// + /// 根据指定的图层的caption属性的值在配置文件中查找对应的数据库中的表的名称 + /// + /// 图层的caption属性的值 + /// 对应的数据库中的表的名称 + 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; + } + /// + /// 根据数据库中的表的名称 查找对应的表中的字段名称的集合 + /// + /// 数据库中的表的名称 + /// 对应的表中的字段名称的集合 + 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; + } + + /// + /// 历史曲线查询 菜单 + /// + /// + /// + 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; + /// + /// 传感器在线报警 菜单 + /// + /// + /// + 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); + } + /// + /// 传感器报警 功能中的 定时器 的触发事件处理 + /// + /// + /// + 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; + } + } + } + } + } + } + } + + + /// + /// 沿线运动 菜单 + /// + /// + /// + private void buttonItem138_Click(object sender, EventArgs e) + { + if (globeControl1.Globe.SelectedObject == null) + { + MessageBox.Show("请先选择一条线!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + return; + } + + GSOFeature lineFeature = globeControl1.Globe.SelectedObject; + if (lineFeature.Geometry == null || lineFeature.Geometry.Type != EnumGeometryType.GeoPolyline3D) + { + MessageBox.Show("请先选择一条线!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + return; + } + + OpenFileDialog dlg = new OpenFileDialog(); + dlg.Filter = "*.gcm;*.3ds|*.gcm;*.3ds|*.3ds|*.3ds|*.gcm|*.gcm"; + if (dlg.ShowDialog() == DialogResult.OK) + { + GSOGeoModel model = new GSOGeoModel(); + model.FilePath = dlg.FileName; + + GSOGeoDynamicRoute dynamicRoute = new GSOGeoDynamicRoute(); + dynamicRoute.ActorGeometry = model; + + GSORoute route = new GSORoute(); + GSOGeoPolyline3D geoline = (GSOGeoPolyline3D)lineFeature.Geometry; + for (int i = 0; i < geoline[0].Count; i++) + { + route.Add(geoline[0][i]); + } + route.CircleRoute = false; + route.Speed = 30; + route.RotateSpeed = 50; + route.AltitudeMode = geoline.AltitudeMode; + dynamicRoute.Route = route; + + GSOFeature feature = new GSOFeature(); + + dynamicRoute.Play(); + feature.Geometry = dynamicRoute; + + //GSOLabel gsoLabel = new GSOLabel(); + //gsoLabel.Text = "模型测试"; + //feature.Label = gsoLabel; + globeControl1.Globe.MinModelVisibleSize = 0; + + globeControl1.Globe.MemoryLayer.AddFeature(feature); + globeControl1.Globe.Refresh(); + } + } + /// + /// 回退 菜单 + /// + /// + /// + private void buttonItem99_Click(object sender, EventArgs e) + { + globeControl1.Globe.UnDoEdit(); + } + /// + /// 前进 菜单 + /// + /// + /// + private void buttonItem100_Click(object sender, EventArgs e) + { + globeControl1.Globe.ReDoEdit(); + } + /// + /// 水平净距 功能界面中的 标签内容改变事件处理 + /// + /// + /// + 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() + "米的管线有:"; + } + } + } + /// + /// 垂直净距 功能界面中的 标签内容改变事件处理 + /// + /// + /// + 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() + "米的管线有:"; + } + } + } + /// + /// 覆土分析 功能界面中的 标签内容改变事件处理 + /// + /// + /// + 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() + "米的管线有:"; + } + } + } + + /// + /// 传感器分类查询 全区域 菜单 + /// + /// + /// + private void buttonItemSensor全区域查询_Click(object sender, EventArgs e) + { + FrmAccessoriesSensor.ShowForm(globeControl1, instrumenLayerNames, 0); + } + /// + /// 传感器分类查询 绘制区域 菜单 + /// + /// + /// + private void buttonItemSensor绘制区域查询_Click(object sender, EventArgs e) + { + FrmAccessoriesSensor.ShowForm(globeControl1, instrumenLayerNames, 1); + } + + + /// + /// 碰撞分析 功能界面中 关闭按钮 事件处理 + /// + /// + /// + 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(); + } + /// + /// 覆土分析 功能界面中的 清除分析结果 按钮事件处理 + /// + /// + /// + 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(); + } + /// + /// 数字预处理 功能 + /// + /// + /// + private void 数字预处理buttonItem140_Click(object sender, EventArgs e) + { + FrmEditShapeFile frm = new FrmEditShapeFile(globeControl1); + frm.ShowDialog(this); + } + + + /// + /// 导出矢量 功能 将图层导出为kml和shp格式数据 + /// + /// + /// + private void 导出矢量buttonItem140_Click(object sender, EventArgs e) + { + List listVectorNames = new List(); + for (int i = 0; i < m_PipelineLayerNames.Count; i++) + { + 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 = ""; + /// + /// 绘制城市七线 功能按钮 + /// + /// + /// + 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; + } + } + } + /// + /// 七线审核 功能按钮 + /// + /// + /// + private void 七线审核buttonItem141_Click(object sender, EventArgs e) + { + FrmCityServerLineAnalysis frm = new FrmCityServerLineAnalysis(globeControl1, m_PipelineLayerNames); + frm.ShowDialog(this); + } + + /// + /// 间距分析 开始分析按钮 分析绘制的七线和管线的距离是否符合标准 + /// + /// + /// + 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; + } + /// + /// 间距分析 清除分析结果 + /// + /// + /// + 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(); + } + /// + /// 间距分析 导出Excel按钮 将间距分析的结果以Excel表格的形式导出 + /// + /// + /// + private void buttonExportExcel_Click(object sender, EventArgs e) + { + if (dataGridViewAnalysisResult.Rows.Count > 0) + { + ExportExcel("间距分析", dataGridViewAnalysisResult, listBoxStasticsResult); + } + else + { + MessageBox.Show("表格内容为空!", "提示"); + } + } + /// + /// 间距分析 关闭按钮 + /// + /// + /// + 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(); + } + /// + /// 间距分析 分析结果表格双击定位 + /// + /// + /// + 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); + } + } + } + } + /// + /// 间距分析 选择管线复选框 + /// + /// + /// + private void checkBoxSelectPipeline_CheckedChanged(object sender, EventArgs e) + { + clearFeatureHighLight();//清除高亮 + if (checkBoxSelectPipeline.Checked) + { + comboBoxLayer.SelectedItem = null; + 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; + } + } + /// + /// 间距分析 选择图层复选框 + /// + /// + /// + 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(); + } + /// + /// 间距分析 选择图层下拉框 + /// + /// + /// + 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; + } + } + } + + + + /// + /// 管线自动缩进 菜单 + /// + /// + /// + private void 管线自动缩进buttonItem140_Click(object sender, EventArgs e) + { + FrmPipelineIndented frm = new FrmPipelineIndented(globeControl1, m_PipelineLayerNames, workwellLayerNames); + 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 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); + // } + //} + + /// + /// 统计指定图层在指定范围内的所有feature对象 + /// + /// + /// + /// + 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) + { + 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 setLayerVisible(string layerName) + { + GSOLayer templayer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + if (templayer != null) + { + templayer.Visible = false; + } + globeControl1.Globe.Refresh(); + } + + /// + /// 连接数据库 + /// + /// + /// + private void buttonItem129_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL4_1.Text); + + FrmDatabaseParaSetting2 frm = new FrmDatabaseParaSetting2(globeControl1); + if (frm.ShowDialog() == DialogResult.OK) + { + ds = FrmDatabaseParaSetting2.ds; + if (ds != null) + { + ds.IsCloseSaved = false; + } + } + } + + /// + /// 一键审核---导入数据 + /// + /// + /// + private void buttonItem127_Click_2(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, "打开数据"); + + try + { + //if (shds == null) + //{ + //没连的话,直接连接审核库; //审核库配置读配置文件 + string dbIp = Utility.sgdbip; + string database = Utility.sgdbname; + string user = Utility.sgdbuser; + string pass = Utility.sgdbpwd; + /* + 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; + //} + } + catch (Exception ex) + { + LogError.PublishError(ex); + MessageBox.Show("内存过载请清理内存,并重新启动规划分析!", "提示"); + return; + } + + } + + /// + ///自动导出图片 + /// + /// + /// + private void buttonItem130_Click_1(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, "导出审核图"); + + 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))); + */ + + int mapWidth = 0; + int mapHeight = 0; + Point pt = getUpperLeftPoint(pt1, pt2, out mapWidth, out mapHeight); + int rightBottomX = pt.X + mapWidth; + int rightBottomY = pt.Y + mapHeight; + Image myImg = new Bitmap(mapWidth, mapHeight); + Graphics g = Graphics.FromImage(myImg); + g.CopyFromScreen(pt, new Point(0, 0), new Size(rightBottomX, rightBottomY)); + + 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; + } + } + } + /// + /// 一键审核功能 + ///
+ /// + /// + private void buttonItem128_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItem128.Text); + //垂直净距标准 + + frmSh = new FrmYJSHTC(globeControl1, globeControl2,layerTree); + + if (frmSh.ShowDialog() == DialogResult.OK) + { + frmWait = new FrmWait("一键审核……"); + frmWait.Location = new Point(this.Width - frmWait.Width - 10, this.Height - frmWait.Height - 50); + frmWait.Owner = this; + frmWait.Show(); + Thread thread = new Thread(new ThreadStart(doWork)); + thread.IsBackground = true; + thread.Start(); + } + } + + void doWork() + { + FrmShResult frmShResult = null; + + double dVerticalJingJuBiaoZhun = 1, dHorizontalJingJuBiaoZhun = 1; + if (frmSh.rukuLayer != null) + { + #region + this.Invoke((EventHandler)delegate + { + try + { + List managerLayerList = new List(); + for (int i = 0; i < layerManagerNode.Nodes.Count; i++) + { + managerLayerList.Add(layerManagerNode.Nodes[i].Text); + } + if (!managerLayerList.Contains(frmSh.rukuLayer.Caption)) + { + TreeNode node = new TreeNode(); + node.Tag = frmSh.rukuLayer; + node.Text = frmSh.rukuLayer.Dataset.Caption; + node.ImageIndex = 0; + node.SelectedImageIndex = 0; + node.Checked = frmSh.rukuLayer.Visible; + layerManagerNode.Nodes.Insert(0, node); + layerManagerNode.Expand(); + } + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "提示"); + } + }); + #endregion + + shlayername = frmSh.rukuLayer.Name; + globeControl1.Refresh(); + } + + if (frmShResult != null && !frmShResult.IsDisposed) + { + try + { + clearFeatureHighLight(); + ClearRedlineAnalyseResult(); + frmShResult.Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message); + } + } + + 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.analysis(); + + //MainFrm窗体显示控制,回到一键审核Tab + this.Invoke((EventHandler)delegate + { + frmShResult.Show(); + frmWait.Close(); + //将tab页恢复到一键审核 + ribbonTabItem11.Checked = true; + try + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + //zhanshi = false; + splitContainer1.Panel2Collapsed = true; + + panelOfTable.Visible = false; + legendSC.Visible = false; + legendSG.Visible = false; + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + } + catch (Exception ex) + { + MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + + }); + + boolfrmShResult = true; + } + else + { + + } + } + + + /// + /// 清除渲染结果 + /// + 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(); + } + /// + /// 已审核的图层 + /// + /// + /// + private void buttonItem132_Click_1(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItem132.Text); + + if (shds == null) + { + //没连的话,直接连接审核库; //审核库配置读配置文件 + string dbIp = Utility.sgdbip; + string database = Utility.sgdbname; + string user = Utility.sgdbuser; + string pass = Utility.sgdbpwd; + + /* + 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; + //} + + } + /// + /// 审核入库 + /// + /// + /// + private void buttonItem133_Click_1(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, "审核入库"); + FrmShRK frmShrk = new FrmShRK(globeControl1); + frmShrk.Show(); + } + /// + /// 模拟设计修改 + /// + /// + /// + private void buttonItem134_Click_1(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, "模拟设计修改"); + + 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 + { + + } + + } + + + /// + /// 绘制垂线 + /// + /// + /// + 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); + } + /// + /// 比较两个点是否是同一个点 + /// + /// + /// + /// + 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; + } + /// + /// 获得点到线的垂线距离及垂点 + /// + /// + /// + /// + /// + 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); + 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]; + } + /// + /// 获得斜率 + /// + /// + /// + /// + /// + /// + /// + 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); + } + } + /// + /// 根据默认投影参数,经纬度转xyz + /// + /// + /// + /// + 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; + } + /// + /// 根据投影参数,经纬度转xyz + /// + /// + /// + /// + /// + 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; + } + /// + /// 根据默认投影参数,xyz转经纬度 + /// + /// + /// + /// + 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; + } + /// + /// 根据投影参数,Xyz转经纬度 + /// + /// + /// + /// + /// + 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; + } + /// + /// 获得inpolygon的管线长度 + /// + /// + 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; + } + + + /// + /// 一键审核中调节透明度 + /// + /// + /// + private void sliderItem1_ValueChanged(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.sliderItem1.Text); + + globeControl1.Globe.GroundOpaque = 100 - sliderItem1.Value; + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(roadLayerName);//("180fd"); + if (layer != null) + { + layer.Opaque = 100 - sliderItem1.Value; + } + + optiValue = sliderItem1.Value; + } + /// + /// 红线审核中的透明度分析 + /// + /// + /// + private void sliderItem3_ValueChanged(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.sliderItem3.Text); + + globeControl1.Globe.GroundOpaque = 100 - sliderItem3.Value; + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(roadLayerName);//("180fd"); + if (layer != null) + { + layer.Opaque = 100 - sliderItem3.Value; + } + optiValue = sliderItem3.Value; + } + + #region yanxiaowei + //初始化DataGridViewX1控件 + public delegate void DataGridViewDelegate(DataTable dt, string strLable, string strLayer, bool initDataGrid); + /// + /// 代理函数,操作DatgridViewX1 + /// + /// + /// + public void InitDataGridViewX1(DataTable dt, string strLable, string strLayer, bool initDataGrid) + { + if (initDataGrid == true) + { + dataGridViewX1.DataSource = dt; + panelOfTable.Visible = true; + toolStripNumbers.Text = strLable; + dataGridViewX1.Tag = strLayer; + } + else + { + dataGridViewX1.DataSource = null; + dataGridViewX1.Refresh(); + panelOfTable.Visible = false; + toolStripNumbers.Text = ""; + dataGridViewX1.Tag = ""; + globeControl1.Globe.MemoryLayer.RemoveAllFeature();//清除双击产生的标注 + } + } + FrmAnalysisGuiHuaResult from; + /// + /// 主窗体下方属性表格 双击定位 功能 + /// + /// + /// + private void dataGridViewX1_MouseDoubleClick(object sender, MouseEventArgs e) + { + if (redSH == false) + { + 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 if (dataGridViewX1.Columns.Contains("标识器编号")) + { + featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["标识器编号"].Value.ToString(); + } + featureName = featureName.Trim(); + + GSOLayer layer = null; + layer = globeControl1.Globe.Layers.GetLayerByCaption(dataGridViewX1.Tag.ToString()); + + if (layer == null) return; + + GSOFeatures features = layer.GetFeatureByName(featureName, false); + if (features.Length == 0) return; + GSOFeature rowFeature = features[0]; + + ClassSearchAnalysis.AddMakerToLineFeature(globeControl1, rowFeature); + + } + } + } + else + { + if (e.Button == MouseButtons.Left) + { + if (from != null && !from.IsDisposed) + { + try + { + from.Close(); + } + catch (Exception ex) + { + LogError.PublishError(ex); + } + } + try + { + DataGridView.HitTestInfo hittestinfo = dataGridViewX1.HitTest(e.X, e.Y); + if (hittestinfo.RowIndex >= 0) + { + string layer = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["管线类型"].Value.ToString(); + string hxName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["红线编号"].Value.ToString(); + FrmAnalysisGuiHuaResult frm = new FrmAnalysisGuiHuaResult(globeControl1, lineStruct, featsList, + panelOfTable, dataGridViewX1, layer, hxName); + frm.Location = new Point(this.Width - frm.Width - 10, this.Height - frm.Height - 20); + frm.Show(this); + + from = frm; + } + } + catch (Exception ex) + { + LogError.PublishError(ex); + } + } + } + } + + /// + /// 空间查询 + /// + /// + /// + private void buttonItemSearch1_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemSearch1.Text); + + trackflag = "PipelineSpatialQuery"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; + + } + /// + /// 关键字查询 + /// + /// + /// + private void buttonItemSearch9_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch9.Text); + + FrmKeywordQuery.ShowForm(globeControl1, m_PipelineLayerNames, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 编号查询 + /// + /// + /// + private void buttonItemSearch2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch2.Text); + + FrmCodingQuery.ShowForm(globeControl1, m_PipelineLayerNames, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 坐标查询 + /// + /// + /// + private void buttonItemSearch3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch3.Text); + + FrmSetLatLonPos.ShowForm(globeControl1); + } + /// + /// 附属物查询 + /// + /// + /// + private void buttonItemSearch10_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch10.Text); + + FrmFittingQuery.ShowForm(globeControl1, instrumenLayerNames, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 管径查询 + /// + /// + /// + private void buttonItemSearch4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch4.Text); + + FrmDiameterQuery.ShowForm(globeControl1, m_PipelineLayerNames, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 材质查询 + /// + /// + /// + private void buttonItemSearch5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch5.Text); + + FrmMaterialSel.ShowForm(globeControl1, m_PipelineLayerNames, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 基本查询 + /// + /// + /// + private void buttonItemSearch6_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch6.Text); + + FrmBasicQuery.ShowForm(globeControl1, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 复合查询 + /// + /// + /// + private void buttonItemSearch7_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch7.Text); + + FrmQuerySQL.ShowForm(globeControl1, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 关联查询 + /// + /// + /// + private void buttonItemSearch8_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch8.Text); + + if (globeControl1.Globe.SelObjectCount != 1) + { + MessageBox.Show("请选中一个对象!", "提示"); + return; + } + + 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 || (feature.Geometry.Type == EnumGeometryType.GeoPolygon3D + || feature.Geometry.Type == EnumGeometryType.GeoWater)) + return; + else + { + ClassSearchAnalysis.ResultRelationAnalysis(globeControl1, feature, valueLayerNames, workwellLayerNames, + instrumenLayerNames, pipefittingLayerNames, m_PipelineLayerNames, valueAllowance); + } + } + } + #endregion + /// + /// 清除分析 + /// + /// + /// + private void buttonItemClear_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemClear.Text); + + globeControl1.Globe.ClearMeasure(); + layerTemp.RemoveAllFeature(); + layerTemp2.RemoveAllFeature(); + buttonItemLS5.Checked = false; + + dataGridViewX1.DataSource = null; + panelOfTable.Visible = false; + + 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); + + NetworkAnalysisTool.ClearAllTopAnalysis(this.globeControl1); + // 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();//清除所有坑 + + 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(); + } + } + + clearFeatureHighLight();//取消管线高亮 + + GSOLayer layerGround = globeControl1.Globe.Layers.GetLayerByCaption(roadLayerName);//("180fd"); + if (layerGround != null) + { + layerGround.Visible = true; + } + globeControl1.Refresh(); + globeControl2.Refresh(); + ClearRedlineAnalyseResult(); + globeControl1.Globe.Action = EnumAction3D.ActionNull; + } + /// + /// 管线长度全区域统计 + /// + /// + /// + private void buttonItemTJ1_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管线长度统计"); + + FrmAllPipelineStatis frm = new FrmAllPipelineStatis(globeControl1,null, new DataGridViewDelegate(InitDataGridViewX1), m_PipelineLayerNames); + frm.Show(this); + } + /// + /// 管线长度绘制区域统计 + /// + /// + /// + private void buttonItemTJ1_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管线长度统计"); + + trackflag = "PipelineDistanceStatistics"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; + } + /// + /// 阀门数量全区域统计 + /// + /// + /// + private void buttonItemTJ2_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "阀门数量统计"); + + FrmValveStatistics frm = new FrmValveStatistics(globeControl1, null, new DataGridViewDelegate(InitDataGridViewX1)); + frm.Show(this); + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + } + /// + /// 阀门数量绘制区域统计 + /// + /// + /// + private void buttonItemTJ2_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "阀门数量统计"); + + trackflag = "valvequery"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; + } + /// + /// 井盖数量全区域统计 + /// + /// + /// + private void buttonItemTJ3_ALL_Click(object sender, EventArgs e) +<<<<<<< HEAD + { + //日志记录 + LogManager.saveLog(Utility.userName, "井盖数量统计"); +======= + { +>>>>>>> d2d0088a6b3c53c1a96b7f1997f4d3443c0ee8c0 + FrmAllWorkWellStatis frm = new FrmAllWorkWellStatis(globeControl1, null, new DataGridViewDelegate(InitDataGridViewX1)); + frm.Show(this); + } + /// + /// 井盖数量绘制区域统计 + /// + /// + /// + private void buttonItemTJ3_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "井盖数量统计"); + + trackflag = "workwellquery"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; + } + /// + /// 管径分段统计全区域统计 + /// + /// + /// + private void buttonItemTJ4_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管径分段统计"); + + Frmpipediameterstatis.ShowForm(globeControl1, m_PipelineLayerNames, 0); + } + /// + /// 管径分段统计绘制区域统计 + /// + /// + /// + private void buttonItemTJ4_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管径分段统计"); + + trackflag = null; + Frmpipediameterstatis.ShowForm(globeControl1, m_PipelineLayerNames, 1); + } + /// + /// 埋深分段统计全区域统计 + /// + /// + /// + private void buttonItemTJ5_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "埋深分段统计"); + FrmpipeDeepstatis.ShowForm(globeControl1, m_PipelineLayerNames, 0); + } + /// + /// 埋深分段统计绘制区域统计 + /// + /// + /// + private void buttonItemTJ5_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "埋深分段统计"); + trackflag = null; + FrmpipeDeepstatis.ShowForm(globeControl1, m_PipelineLayerNames, 1); + } + /// + /// 管径分类统计全区域统计 + /// + /// + /// + private void buttonItemTJ6_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管径分类汇总"); + + FrmpipeDiametergather.ShowForm(globeControl1, m_PipelineLayerNames, 0); + } + /// + /// 管径分类统计绘制区域统计 + /// + /// + /// + private void buttonItemTJ6_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管径分类汇总"); + + trackflag = null; + FrmpipeDiametergather.ShowForm(globeControl1, m_PipelineLayerNames, 1); + } + /// + /// 材质分类统计全区域统计 + /// + /// + /// + private void buttonItemTJ7_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "材质分类汇总"); + + FrmpipeMaterialGather.ShowForm(globeControl1, m_PipelineLayerNames, 0); + } + /// + /// 材质分类统计绘制区域统计 + /// + /// + /// + private void buttonItemTJ7_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "材质分类汇总"); + + trackflag = null; + FrmpipeMaterialGather.ShowForm(globeControl1, m_PipelineLayerNames, 1); + } + /// + /// 附属物分类统计全区域统计 + /// + /// + /// + private void buttonItemTJ8_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "附属物分类汇总"); + + FrmAccessoriesgather.ShowForm(globeControl1, instrumenLayerNames, 0); + } + /// + /// 附属物分类统计绘制区域统计 + /// + /// + /// + private void buttonItemTJ8_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "附属物分类汇总"); + + trackflag = null; + FrmAccessoriesgather.ShowForm(globeControl1, instrumenLayerNames, 1); + } + /// + /// 碰撞分析 + /// + /// + /// + private void buttonItemFX1_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_4.Text); + + this.dataGridViewX4.Size = new System.Drawing.Size(195, 120); + 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(); + } + /// + /// 覆土分析 + /// + /// + /// + private void buttonItemFX1_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX5_1.Text); + this.dataGridViewX6.Size = new System.Drawing.Size(195, 120); + 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(); + } + /// + /// 间距分析 + /// + /// + /// + private void buttonItemFX1_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX1_3.Text); + + this.dataGridViewLineList.Size = new System.Drawing.Size(185, 120); + 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(); + } + /// + /// 垂直净距分析 + /// + /// + /// + private void buttonItemFX1_4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX1_4.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(); + } + /// + /// 水平净距分析 + /// + /// + /// + private void buttonItemFX1_5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_6.Text); + this.dataGridViewX8.Size = new System.Drawing.Size(185, 120); + 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(); + } + + #region Predaotr,断面分析 + /// + /// 横断面分析 + /// + /// + /// + private void buttonItemFX2_1_Click(object sender, EventArgs e) + { + globeControl1.Globe.Action = EnumAction3D.TrackPolyline; + globeControl1.Globe.TrackPolylineTool.VerticalLineVisible = true; + globeControl1.Globe.TrackPolylineTool.TrackMode = EnumTrackMode.SpaceTrack; + trackPolylineEndMode = EnumTrackPolylineEndMode.HDM_Analysis; + + } + /// + /// 纵断面分析 + /// + /// + /// + private void buttonItemFX2_2_Click(object sender, EventArgs e) + { + if (globeControl1.Globe.SelObjectCount<1) + { + MessageBox.Show("请选择一条或者多条管线!", "提示", MessageBoxButtons.OK, + MessageBoxIcon.Information); + return; + } + 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); + } + } + List feats = SectionAnalysisTool.ZDMAnalysis(selectFeatures); + if (feats != null && feats.Count >= 1) + { + FrmProfileAnalysis frm = new FrmProfileAnalysis(globeControl1, feats); + frm.Show(this); + } + } + /// + /// 道路断面分析 + /// + /// + /// + private void buttonItemFX2_3_Click(object sender, EventArgs e) + { + globeControl1.Globe.Action = EnumAction3D.TrackPolyline; + globeControl1.Globe.TrackPolylineTool.VerticalLineVisible = true; + globeControl1.Globe.TrackPolylineTool.TrackMode = EnumTrackMode.SpaceTrack; + trackPolylineEndMode = EnumTrackPolylineEndMode.DLDM_Analysis; + + } + /// + /// 基线剖面分析 + /// + /// + /// + private void buttonItemFX2_4_Click(object sender, EventArgs e) + { + globeControl1.Globe.Action = EnumAction3D.TrackPolyline; + globeControl1.Globe.TrackPolylineTool.VerticalLineVisible = true; + globeControl1.Globe.TrackPolylineTool.TrackMode = EnumTrackMode.SpaceTrack; + trackPolylineEndMode = EnumTrackPolylineEndMode.JXPM_Analysis; + + } + + #endregion + /// + /// 创建拓扑 + /// + /// + /// + private void buttonItemFX3_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX3_1.Text); + + FrmGenAndFaMenTopu frm = new FrmGenAndFaMenTopu(globeControl1, m_PipelineLayerNames, valueLayerNames); + frm.Show(this); + } + #region Predator :拓扑分析 + /// + /// 上游分析 + /// + /// + /// + private void buttonItemFX3_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX3_2.Text); + NetworkTraceUpDown(true); + } + /// + /// 下游分析 + /// + /// + /// + private void buttonItemFX3_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX3_3.Text); + NetworkTraceUpDown(false); + } + + /// + /// 上下游追踪 功能 + /// + /// + private void NetworkTraceUpDown(Boolean bTraceUp) + { + GSOFeature selLineFeature = globeControl1.Globe.SelectedObject; + if (selLineFeature == null || selLineFeature.Geometry == null || selLineFeature.Geometry.Type != EnumGeometryType.GeoPolyline3D) + { + MessageBox.Show("请点击“编辑”—“选中对象”选择一条线!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); + return; + } + GSOLayer selLayer = globeControl1.Globe.SelectedObjectLayer; + + NetworkAnalysisTool.TraceUpDownAnalysis(bTraceUp, + selLineFeature, selLayer); + } + + /// + /// 流向分析 + /// + /// + /// + private void buttonItemFX3_4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX3_4.Text); + + FrmFlow frm = new FrmFlow(globeControl1, m_PipelineLayerNames); + frm.Show(this); + } + /// + /// 关阀分析 + /// + /// + /// + private void buttonItemFX3_5_Click(object sender, EventArgs e) + { + if (globeControl1.Globe.SelObjectCount < 1) + { + MessageBox.Show("请选中至少一根管线!!"); + buttonItemFX3_5.Checked = false; + return; + } + GSOLayer resLayer = null; + GSOFeature resFeature = null; + globeControl1.Globe.GetSelectObject(0, out resFeature, out resLayer); + + String pipeLayerName = resLayer.Caption; + String pipeLayerNamePrefix = pipeLayerName.Substring(0, pipeLayerName.IndexOf("管线")); + GSOLayer valveLayer = globeControl1.Globe.Layers[pipeLayerNamePrefix + "阀门"]; + if (valveLayer == null) + { + MessageBox.Show("无" + pipeLayerNamePrefix+"阀门图层", "提示"); + return; + } + + GSOFeatures valveFeats = NetworkAnalysisTool.CloseValvesAnalysis(resFeature, + resLayer, valveLayer); + + if (valveFeats != null) + { + FrmCloseValves frm = new FrmCloseValves(this.globeControl1, valveFeats); + frm.Show(this); + } + else + { + MessageBox.Show("未找到关闭阀门"); + } + } + + /// + /// 连通分析 + /// + /// + /// + private void buttonItemFX3_6_Click(object sender, EventArgs e) + { + if (globeControl1.Globe.SelObjectCount < 2) + { + MessageBox.Show("请选中至少两个管线!!"); + buttonItemFX3_6.Checked = false; + return; + } + GSOFeature selFeat0, selFeat1; + GSOLayer layer0,layer1; + globeControl1.Globe.GetSelectObject(0, out selFeat0, out layer0); + globeControl1.Globe.GetSelectObject(1, out selFeat1, out layer1); + + if (!layer0.IsSameInnerObject(layer1)) + { + MessageBox.Show("不在同一个图层!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); + buttonItemFX3_6.Checked = false; + return; + } + NetworkAnalysisTool.ConnexityAnalysis(selFeat0, selFeat1, layer0); + } + /// + /// 爆管分析 + /// + /// + /// + private void buttonItemFX3_7_Click(object sender, EventArgs e) + { + NetworkTraceUpDown(true); //上游追踪: + + GSOFeature selLineFeature = globeControl1.Globe.SelectedObject; + if (selLineFeature == null || selLineFeature.Geometry == null || selLineFeature.Geometry.Type != EnumGeometryType.GeoPolyline3D) + { + MessageBox.Show("请点击“编辑”—“选中对象”选择一条线!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); + return; + } + GSOLayer selLayer = globeControl1.Globe.SelectedObjectLayer; + + NetworkAnalysisTool.ExplodeAnalysis(this.globeControl1,selLineFeature,selLayer); + + this.buttonItemFX3_5_Click(sender, e); //关阀分析: + + } + + #endregion + /// + /// 多边形开挖 + /// + /// + /// + private void buttonItemFX4_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_1.Text); + + trackflag = "pit"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; //是这个么?是的,在模型上 + } + /// + /// 挖方量分析 + /// + /// + /// + private void buttonItemFX4_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_2.Text); + + trackflag = "digFillAnalysis"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; + ActionToolMenuChecked(); + } + /// + /// 沿线开挖 + /// + /// + /// + private void buttonItemFX4_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_3.Text); + + if (!buttonItemFX4_3.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; + buttonItemFX4_3.Checked = true; + } + } + else + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + buttonItemFX4_3.Checked = false; + globeControl1.Globe.TrackPolylineTool.VerticalLineVisible = false; + } + ActionToolMenuChecked(); + } + /// + /// 创建隧道 + /// + /// + /// + private void buttonItemFX4_4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_4.Text); + + 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("场景中未加载隧道图层!", "提示"); + } + } + /// + /// 隐藏隧道 + /// + /// + /// + private void buttonItemFX4_5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_5.Text); + + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption("隧道"); + if (layer != null) + { + layer.Visible = !layer.Visible; + } + } + /// + /// 删除隧道 + /// + /// + /// + private void buttonItemFX4_6_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_6.Text); + + 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("请选中要删除的隧道!", "提示"); + } + } + /// + /// 通视分析 + /// + /// + /// + private void buttonItemFX5_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX5_1.Text); + + if (globeControl1.Globe.Action != EnumAction3D.VisibilityAnalysis) + { + //btnSpaceVisibilityAnalysis.Checked = true; + globeControl1.Globe.Action = EnumAction3D.VisibilityAnalysis; + } + else + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + // SetButtonChecked(); + } + } + /// + /// 可视域分析 + /// + /// + /// + private void buttonItemFX5_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX5_2.Text); + + globeControl1.Globe.Action = EnumAction3D.ViewshedAnalysis; + } + /// + /// 可视包络分析 + /// + /// + /// + private void buttonItemFX5_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX5_3.Text); + + globeControl1.Globe.Action = EnumAction3D.ViewEnvelopeAnalysis; + } + /// + /// 缓冲区分析 + /// + /// + /// + private void buttonItemFX6_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX6_1.Text); + + GSOFeature feat = globeControl1.Globe.SelectedObject; + if (feat == null) + { + MessageBox.Show("请选择要分析的要素!"); + return; + } + if (feat.Geometry.Type == EnumGeometryType.GeoPolyline3D) + { + GSOGeoPolyline3D line1 = feat.Geometry as GSOGeoPolyline3D; + if (line1 == null) + { + MessageBox.Show("请选择一条管线!"); + return; + } + + FrmBufferAnalysis frm = new FrmBufferAnalysis(globeControl1, line1, layerTemp); + frm.Show(this); + } + else + { + FrmBufferAnalysisBSQ frm = new FrmBufferAnalysisBSQ(globeControl1, layerTemp, bsqPT); + frm.Show(this); + } + + } + /// + /// 附属物分析 + /// + /// + /// + private void buttonItemFX6_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX6_2.Text); + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + FrmAccessoryAnalysis dlg = new FrmAccessoryAnalysis(globeControl1, layerTemp); + dlg.Show(this); + } + /// + /// 无源淹没分析 + /// + /// + /// + private void buttonItemFX6_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX6_3.Text); + + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + trackflag = "FloodAnalysis"; + } + /// + /// 水平距离 + /// + /// + /// + private void buttonItemLS1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS1.Text); + + globeControl1.Globe.Action = EnumAction3D.MeasureDistance; + globeControl1.Globe.DistanceRuler.SpaceMeasure = false; + buttonItemLS5.Checked = false; + } + /// + /// 垂直距离 + /// + /// + /// + private void buttonItemLS2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS2.Text); + + buttonItemLS5.Checked = false; + globeControl1.Globe.Action = EnumAction3D.MeasureHeight; + globeControl1.Globe.DistanceRuler.SpaceMeasure = false; + } + /// + /// 空间距离 + /// + /// + /// + private void buttonItemLS3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS3.Text); + + buttonItemLS5.Checked = false; + globeControl1.Globe.Action = EnumAction3D.MeasureDistance; + globeControl1.Globe.DistanceRuler.SpaceMeasure = true; + } + /// + /// 地表距离 + /// + /// + /// + private void buttonItemLS4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS4.Text); + + buttonItemLS5.Checked = false; + globeControl1.Globe.Action = EnumAction3D.MeasureDistance; + globeControl1.Globe.DistanceRuler.SpaceMeasure = false; + } + /// + /// 高度量算 + /// + /// + /// + private void buttonItemLS5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS5.Text); + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + buttonItemLS5.Checked = !buttonItemLS5.Checked; + if (buttonItemLS5.Checked) + { + globeControl1.Globe.Action = EnumAction3D.SelectObject; + } + } + /// + /// 水平面积 + /// + /// + /// + private void buttonItemLS6_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS6.Text); + + buttonItemLS5.Checked = false; + globeControl1.Globe.Action = EnumAction3D.MeasureArea; + globeControl1.Globe.AreaRuler.SpaceMeasure = true; + } + /// + /// 地表面积 + /// + /// + /// + private void buttonItemLS7_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS7.Text); + + buttonItemLS5.Checked = false; + globeControl1.Globe.Action = EnumAction3D.MeasureArea; + globeControl1.Globe.AreaRuler.SpaceMeasure = false; + + } + + # region Fan 重构标注代码 + /// + /// 标高标注 + /// + /// + /// + private void buttonItemSZ1_Click(object sender, EventArgs e) + { + GSOFeature resFeature = IsPipeLineOfSelectedObj(); + if (resFeature == null) + { + MessageBox.Show("请选中一根管线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + GSOGeoPolyline3D selLine = resFeature.Geometry as GSOGeoPolyline3D; + if (selLine[0].Count <= 1) + { + return; + } + + MarkTools.getInstance().showMarker(resFeature, + globeControl1, EnumMarkLayer.Mark_Altitude, ""); + } + /// + /// 管径标注 + /// + GSOFeature radiusMarkerFeature; + private void buttonItemBZ2_Click(object sender, EventArgs e) + { + GSOFeature resFeature = IsPipeLineOfSelectedObj(); + if (resFeature == null) + { + MessageBox.Show("请选中一根管线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + GSOGeoPolyline3D selLine = resFeature.Geometry as GSOGeoPolyline3D; + if (selLine[0].Count <= 1) + { + return; + } + + MarkTools.getInstance().showMarker(resFeature, + globeControl1, EnumMarkLayer.Mark_Diameter, ""); + } + /// + /// 埋深标注 + /// + /// + /// + private void buttonItemBZ3_Click(object sender, EventArgs e) + { + GSOFeature resFeature = IsPipeLineOfSelectedObj(); + if (resFeature == null) + { + MessageBox.Show("请选中一根管线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + GSOGeoPolyline3D selLine = resFeature.Geometry as GSOGeoPolyline3D; + if (selLine[0].Count <=1) + { + return; + } + + MarkTools.getInstance().showMarker(resFeature, + globeControl1, EnumMarkLayer.Mark_Depth, ""); + + } + /// + /// 坐标标注 + /// + /// + /// + private void buttonItemBZ4_Click(object sender, EventArgs e) + { + GSOFeature resFeature = IsPipeLineOfSelectedObj(); + if (resFeature == null) + { + MessageBox.Show("请选中一根管线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + GSOGeoPolyline3D selLine = resFeature.Geometry as GSOGeoPolyline3D; + if (selLine[0].Count <= 1) + { + return; + } + MarkTools.getInstance().showMarker(resFeature, + globeControl1, EnumMarkLayer.Mark_Location, ""); + } + /// + /// 距离标注 + /// + bool distanceMarker = false; + private void buttonItemBZ5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBZ5.Text); + + globeControl1.Globe.Action = EnumAction3D.TrackPolyline; + //globeControl1.Globe.DistanceRuler.MeasureMode = EnumDistanceMeasureMode.HVSLineMeasure; + distanceMarker = true; + } + /// + /// 自定义标注 + /// + /// + /// + private void buttonItemBZ6_Click(object sender, EventArgs e) + { + GSOFeature f = globeControl1.Globe.SelectedObject; + GSOLayer l = globeControl1.Globe.SelectedObjectLayer; + FrmCustomLabel frm = new FrmCustomLabel(globeControl1, l, f); + if (frm.ShowDialog() == DialogResult.OK) + { + MarkTools.getInstance().showMarker(f, globeControl1, EnumMarkLayer.Mark_Custom, frm.labelText); + } + } + /// + /// 扯旗标注 + /// + /// + /// + private void buttonItemBZ7_Click(object sender, EventArgs e) + { + GSOFeature f = globeControl1.Globe.SelectedObject; + GSOLayer l = globeControl1.Globe.SelectedObjectLayer; + FrmMarker frm = new FrmMarker(); + if (frm.ShowDialog() == DialogResult.OK) + { + MarkTools.getInstance().showMarker(f, globeControl1, EnumMarkLayer.Mark_Custom, frm.markerContent); + } + } + /// + /// 坡度标注 + /// + /// + /// + private void buttonItemBZ8_Click(object sender, EventArgs e) + { + GSOFeature resFeature = IsPipeLineOfSelectedObj(); + if (resFeature == null) + { + MessageBox.Show("请选中一根管线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + GSOGeoPolyline3D selLine = resFeature.Geometry as GSOGeoPolyline3D; + if (selLine[0].Count <= 1) + { + return; + } + + MarkTools.getInstance().showMarker(resFeature, + globeControl1, EnumMarkLayer.Mark_Slope, ""); + } + /// + /// 属性标注 + /// + /// + /// + private void buttonItemBZ9_Click(object sender, EventArgs e) + { + GSOFeature f = globeControl1.Globe.SelectedObject; + GSOLayer l = globeControl1.Globe.SelectedObjectLayer; + FrmPropertiesMarker frm = new FrmPropertiesMarker(globeControl1, l, f); + if (frm.ShowDialog() == DialogResult.OK) + { + MarkTools.getInstance().showMarker(f, globeControl1, EnumMarkLayer.Mark_Property, frm.labelText); + } + } + /// + /// 红线工具 + /// + /// + /// + private void buttonItemBZ10_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBZ10.Text); + 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; + } + } + /// + /// 标注管理 + /// + /// + /// + private void buttonItemBZ11_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBZ11.Text); + + buttonItemBZ11.Checked = !buttonItemBZ11.Checked; + 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 (buttonItemBZ11.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(); + } + } + + #endregion + /// + /// 飞行到目标点 + /// + /// + /// + private void buttonItemFXGJ1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFXGJ1.Text); + + FrmSetFlytoPos.ShowForm(globeControl1); + + } + /// + /// 自定义飞行 + /// + /// + /// + private void buttonItemFXGJ2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFXGJ2.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); + } + } + /// + /// 绕中心点飞行 + /// + /// + /// + private void buttonItemFXGJ3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFXGJ3.Text); + + globeControl1.Globe.FlyAroundCenter(10000, EnumFlyRepeatValueType.MiliSeconds); + globeControl1.Globe.CurFlyID = 1; + } + /// + /// 绕眼睛飞行 + /// + /// + /// + private void buttonItemFXGJ4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFXGJ4.Text); + + globeControl1.Globe.FlyAroundEye(720, EnumFlyRepeatValueType.Degrees); + globeControl1.Globe.CurFlyID = 2; + } + + /// + /// 权限管理 + /// + /// + /// + private void buttonItemXT1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT1.Text); + + FrmUserRoleMgr frm = new FrmUserRoleMgr(); + frm.ShowDialog(); + } + /// + /// 数据库管理 + /// + /// + /// + private void buttonItemXT2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT2.Text); + + //查看数据库列表 + FrmDbManager frm = new FrmDbManager(); + frm.ShowDialog(); + } + /// + /// 用户列表 + /// + /// + /// + private void buttonItemXT3_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT3_1.Text); + + FrmUserManager frm = new FrmUserManager(); + frm.ShowDialog(); + } + /// + /// 创建新用户 + /// + /// + /// + private void buttonItemXT3_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT3_2.Text); + + FrmUserAdd frm = new FrmUserAdd(-1); + frm.ShowDialog(); + } + /// + /// 人员修改 + /// + /// + /// + private void buttonItemXT4_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT4_2.Text); + + FrmAppUSER appUSER = new FrmAppUSER(); + appUSER.ShowDialog(); + } + /// + /// 增加人员 + /// + /// + /// + private void buttonItemXT4_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT4_1.Text); + + FrmAppUSERRESET appUSERRESET = new FrmAppUSERRESET(); + appUSERRESET.ShowDialog(); + } + /// + /// 统计数据 + /// + /// + /// + private void buttonItemZTT1_Click(object sender, EventArgs e) + { + ////日志记录 + //LogManager.saveLog(Utility.userName, this.buttonItemZTT1.Text); + + //PATM patm = new PATM(); + //patm.operation = "Statistic"; + //patm.Text = "统计专题图管理"; + //patm.ShowDialog(); + } + /// + /// 热点功能统计 + /// + /// + /// + private void buttonItemZTT2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT2.Text); + + FrmHotFuncStat frmhfs = new FrmHotFuncStat(); + frmhfs.ShowDialog(); + } + + private void buttonItemZTT3_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT3_1.Text); + + FrmAPP appfrm = new FrmAPP("专题图申请"); + appfrm.ShowDialog(); + } + + private void buttonItemZTT3_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT3_2.Text); + + FrmAPPFORASK appForask = new FrmAPPFORASK("专题图审核"); + appForask.ShowDialog(); + } + + private void buttonItemZTT3_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT3_3.Text); + + FrmAPPregion appregion = new FrmAPPregion("专题图审核"); + appregion.ShowDialog(); + } + + private void buttonItemZTT4_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT4_1.Text); + + FrmAPP appfrm = new FrmAPP("打印申请"); + appfrm.ShowDialog(); + } + + private void buttonItemZTT4_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT4_2.Text); + + FrmAPPFORASK appForask = new FrmAPPFORASK("打印审核"); + appForask.ShowDialog(); + } + + private void buttonItemZTT4_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT4_3.Text); + + FrmAPPregion appregion = new FrmAPPregion("打印审核"); + appregion.ShowDialog(); + } + + private void buttonItemZTT5_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT5_1.Text); + + FrmAPP appfrm = new FrmAPP("拷贝申请"); + appfrm.ShowDialog(); + } + + private void buttonItemZTT5_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT5_2.Text); + + FrmAPPFORASK appForask = new FrmAPPFORASK("拷贝审核"); + appForask.ShowDialog(); + } + + private void buttonItemZTT5_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT5_3.Text); + + FrmAPPregion appregion = new FrmAPPregion("拷贝审核"); + appregion.Show(); + } + + private int connectServerCount = 0; + + /// + /// 还原球到实测库 + /// + 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); + } + + if (layerManagerNode.Nodes.Count > 0) + { + for (int i = layerManagerNode.Nodes.Count - 1; i >= 0; i--) + { + layerManagerNode.Nodes[i].Remove(); + + } + } + + globeControl1.Refresh(); + + } + + private void buttonItemSPSZ_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSPSZ.Text); + + FrmLayerControl frm = new FrmLayerControl(layerTree, globeControl1, globeControl2); + frm.Show(this); + } + + /// + /// 碰撞审查 + /// + /// + /// + private void buttonItemSH1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSH1.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 buttonItemSH2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSH2.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 buttonItemSH3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSH3.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 buttonItemSH4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSH4.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 buttonItemSH5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSH5.Text); + FrmCityServerLineAnalysis frm = new FrmCityServerLineAnalysis(globeControl1, m_PipelineLayerNames); + frm.Show(this); + } + #region 数据管理-导入文件 + ///// + ///// 数据管理-导入本地坐标系文件 + ///// + ///// + ///// + //private void buttonItemSJGL1_1_Click(object sender, EventArgs e) + //{ + // //日志记录 + // LogManager.saveLog(Utility.userName, this.buttonItemSJGL1_1.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(); + // } + // } + //} + + ///// + ///// 数据管理-导入其他坐标系文件 + ///// + ///// + ///// + //private void buttonItemSJGL1_2_Click(object sender, EventArgs e) + //{ + // //日志记录 + // LogManager.saveLog(Utility.userName, this.buttonItemSJGL1_2.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(); + // } + // } + //} + #endregion + /// + /// 数据质量检查 + /// + /// + /// + private void buttonItemSJGL2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL2.Text); + FrmValiData frm = new FrmValiData(globeControl1); + frm.ShowDialog(); + } + /// + /// 数据预处理 + /// + /// + /// + private void buttonItemSJGL3_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL3.Text); + + FrmEditShapeFile frm = new FrmEditShapeFile(globeControl1); + frm.ShowDialog(this); + } + /// + /// 连接数据库 + /// + /// + /// + private void buttonItemSJGL4_1_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL4_1.Text); + + FrmDatabaseParaSetting frm = new FrmDatabaseParaSetting(globeControl1); + if (frm.ShowDialog() == DialogResult.OK) + { + ds = FrmDatabaseParaSetting.ds; + if (ds != null) + { + ds.IsCloseSaved = false; + } + } + } + /// + /// 管线入库 + /// + /// + /// + private void buttonItemSJGL4_2_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL4_2.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 buttonItemSJGL4_3_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL4_3.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 buttonItemSJGL5_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL5.Text); + + Cyberpipe.Forms.FrmProject frm = new Cyberpipe.Forms.FrmProject(); + frm.ShowDialog(); + } + /// + /// 元数据基本管理 + /// + /// + /// + private void buttonItemSJGL6_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL6_1.Text); + + FrmMetadata frmmd = new FrmMetadata(); + frmmd.ShowDialog(); + } + /// + /// 元数据查询管理 + /// + /// + /// + private void buttonItemSJGL6_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL6_2.Text); + + FrmMetadataStat frmmds = new FrmMetadataStat(); + //frmmds.Show(); + frmmds.ShowDialog(); + } + /// + /// 操作日志管理 + /// + /// + /// + private void buttonItemSJGL7_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL7.Text); + + FrmLogOper frmlo = new FrmLogOper(); + frmlo.ShowDialog(); + } + /// + /// 数据字典管理 + /// + /// + /// + private void buttonItemSJGL8_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL8.Text); + + FrmMDDictory frmmdd = new FrmMDDictory(); + frmmdd.ShowDialog(); + } + /// + /// 数据库备份 + /// + /// + /// + private void buttonItemSJGL9_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL9.Text); + + //新 + FrmBACKORACLE backOracle = new FrmBACKORACLE(); + backOracle.Show(); + } + /// + /// 创建管段 + /// + /// + /// + private void buttonItemBJ1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ1.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; + } + } + /// + /// 创建附属物 + /// + /// + /// + private void buttonItemBJ2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ2.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); + } + } + /// + /// 创建特征管点 + /// + /// + /// + private void buttonItemBJ3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ3.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); + } + } + /// + /// 绘制城市七线 + /// + /// + /// + private void buttonItemBJ4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ4.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; + } + } + } + /// + /// 选中对象 + /// + /// + /// + private void buttonItemBJ5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ5.Text); + + globeControl1.Globe.Action = EnumAction3D.SelectObject; + } + /// + /// 平移对象 + /// + /// + /// + private void buttonItemBJ6_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ6.Text); + + globeControl1.Globe.Action = EnumAction3D.MoveObject; + } + /// + /// 升降对象 + /// + /// + /// + private void buttonItemBJ7_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ7.Text); + + globeControl1.Globe.Action = EnumAction3D.ElevateObject; + } + /// + /// 旋转对象 + /// + /// + /// + private void buttonItemBJ8_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ8.Text); + + globeControl1.Globe.Action = EnumAction3D.RotateObject; + } + /// + /// 连接管段 + /// + /// + /// + private void buttonItemBJ9_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ9.Text); + + if (globeControl1.Globe.SelObjectCount < 2) + { + MessageBox.Show("对不起,请至少选中2个对象!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + return; + } + globeControl1.Globe.InsertJointPipeline(false); + } + /// + /// 后退 + /// + /// + /// + private void buttonItemBJ11_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemBJ11.Text); + globeControl1.Globe.UnDoEdit(); + } + /// + /// 前进 + /// + /// + /// + private void buttonItemBJ12_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemBJ12.Text); + + globeControl1.Globe.ReDoEdit(); + } + /// + /// 导出CAD + /// + /// + /// + private void buttonItemBJ10_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ10_1.Text); + + #region 导出成dxf格式 + List listVectorNames = new List(); + 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(); + #endregion + } + /// + /// 导出矢量 + /// + /// + /// + private void buttonItemBJ10_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ10_2.Text); + + List listVectorNames = new List(); + 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 buttonItemBJ13_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemBJ13.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(); + } + } + MessageBox.Show("删除成功!", "提示"); + } + else + { + MessageBox.Show("请选中要删除的模型!", "提示"); + } + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + } + + private void buttonItemHX1_1_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]; + string filePath = dlg.FileName; + string lastname = Path.GetFileName(filePath); + + 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(); + } + + } + } + } + + public struct LineStruct + { + public string layerName; + public string layerCode; + public string lineLength; + public string hxName; + } + + List lineStruct = new List(); + List featsList = new List(); + + /// + /// 红线审核 + /// + /// + /// + private void buttonItemHX2_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemHX2.Text); + redSH = true; + featsList.Clear(); + lineStruct.Clear(); + List listPipelineLayers = new List(); + + GSOLayer layer = null; + for (int i = 0; i < m_PipelineLayerNames.Count; i++) + { + layer = globeControl1.Globe.Layers.GetLayerByCaption(m_PipelineLayerNames[i]); + if (layer != null) + { + listPipelineLayers.Add(layer); + } + } + //yanxiaowei 重构 + GSOFeatures selectFeatures=new GSOFeatures(); + for (int i = 0; i < globeControl1.Globe.SelObjectCount; i++) + { + GSOFeature feature = null; + globeControl1.Globe.GetSelectObject(i, out feature, out layer); + selectFeatures.Add(feature); + } + DataTable table=new DataTable(); + + ClassGSOTool.CalculateRedLineResult(out table, redSH, selectFeatures, globeControl1, + listPipelineLayers,out lineStruct, out featsList); + + if (table.Rows.Count != 0) + AddDatagridView(table); + else + { + MessageBox.Show("没有侵入地块红线的管线数据!", "提示"); + dataGridViewX1.DataSource = null; + panelOfTable.Visible = false; + return; + } + } + + private void AddDatagridView(DataTable table) + { + dataGridViewX1.DataSource = table; + panelOfTable.Visible = true; + panelOfTable.Height = 200; + toolStripNumbers.Text = "红线审核 |共有:" + table.Rows.Count + "条"; + toolStripDropDownButton3.Visible = true; + } + /// + /// 主窗体 下方的工具条中的 导出.xls文件 按钮事件处理 + /// + /// + /// + private void toolStripDropDownButton3_Click(object sender, EventArgs e) + { + if (dataGridViewX1.Rows.Count == 0) + { + MessageBox.Show("表格内容为空!", "提示"); + return; + } + + string strSaveFile = string.Empty; + SaveFileDialog savefiledialog = new SaveFileDialog(); + savefiledialog.Filter = "Excel文件|*.xls,*.xlsx"; + savefiledialog.AddExtension = true; + savefiledialog.FileName = "红线审核"; + if (savefiledialog.ShowDialog() == DialogResult.OK) + strSaveFile = savefiledialog.FileName; + else return; + + ExpEXCEL.ExpToExcel(dataGridViewX1, strSaveFile, "红线审核", lineStruct, featsList); + MessageBox.Show("导出成功!"); + } + /// + /// 去除集合中重复的管线 + /// + /// + /// + /// + private GSOFeatures getFeaturesByFilter(GSOFeatures features, string fieldName) + { + if (features == null) + { + return null; + } + GSOFeatures featuresGet = new GSOFeatures(); + for (int i = 0; i < features.Length; i++) + { + GSOFeature featureFromFS = features[i]; + string fieldValueFromFS = featureFromFS.GetValue(fieldName).ToString().Trim(); + bool isHas = false; + for (int j = featuresGet.Length - 1; j >= 0; j--) + { + GSOFeature featureFromFSGet = featuresGet[j]; + string fieldValueFromFSGet = featureFromFSGet.GetValue(fieldName).ToString().Trim(); + if (fieldValueFromFS.Equals(fieldValueFromFSGet)) + { + isHas = true; + break; + } + } + if (isHas == false) + { + featuresGet.Add(featureFromFS.Clone()); + } + } + return featuresGet; + } + + private void sliderItem2_ValueChanged(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.sliderItem2.Text); + + globeControl1.Globe.GroundOpaque = 100 - sliderItem2.Value; + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(roadLayerName);//("180fd"); + if (layer != null) + { + layer.Opaque = 100 - sliderItem2.Value; + } + layer = globeControl2.Globe.Layers.GetLayerByCaption("180fd");//("180fd"); + if (layer != null) + { + layer.Opaque = 100 - sliderItem2.Value; + } + globeControl2.Globe.GroundOpaque = 100 - sliderItem2.Value; + + optiValue = sliderItem2.Value; + } + /// + /// 数据管理导入文件 + /// + /// + /// + private void buttonItemSJGL1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL1.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.Multiselect = true; + if (dlg.ShowDialog() == DialogResult.OK) + { + //自定义lprj文件名,从程序中复制一lprj文件。 + string filePath = dlg.FileName; + string lastname = Path.GetFileName(filePath); + + 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, 100); + + globeControl1.Refresh(); + } + } + } + + private void buttonItemHX1_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemHX1.Text); + + GSODataSource dataSpace = globeControl1.Globe.DataManager.OpenOracleDataSource(Utility.DBServer.Trim() + "/" + Utility.dbdatabase.Trim(), "", "", Utility.userID, Utility.DBPassword); + string filepath = ""; + //日志记录 + OpenFileDialog dlg = new OpenFileDialog(); + dlg.Filter = "矢量数据(*.shp)|*.shp|矢量数据(*.lgd)|*.lgd|CAD数据(*.dxf)|*.dxf|全部支持格式(*.lgd,*.shp,*.dxf)|*.lgd;*.shp;*.dxf;"; + dlg.Multiselect = true; + + #region 临时图层显示 + if (dlg.ShowDialog() == DialogResult.OK) + { + string filePath = dlg.FileName; + string lastname = Path.GetFileName(filePath); + + #region + for (int i = 0; i < dlg.FileNames.Length; i++) + { + string strDataPath = dlg.FileNames[i]; + filepath = strDataPath; + + GSOLayer layer = globeControl1.Globe.Layers.Add(strDataPath); + GSOFeatures RedFeatures = layer.GetAllFeatures(); + + 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(); + RedFeatures = features; + 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; + } + + /////////////////////////////////////////////////////////////////////////////////////////// + globeControl1.Globe.Layers.MoveTo(0, globeControl1.Globe.Layers.Count - 1); + globeControl1.Refresh(); + } + + IModelBuilder modelBuilder = new RedLineBuilder(); + + modelBuilder.batchInsert(dataSpace, redDt, RedFeatures); + + } + #endregion + + } + #endregion + } + /// + /// 定位 + /// + /// + /// + private void buttonItemLocation_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemLocation.Text); + + FrmFlyToPosition fly = new FrmFlyToPosition(globeControl1,globeControl2); + fly.Show(this); + } + /// + /// 2015-10-17演示代码 红线审核 + /// + /// + /// + private void ribbonTabItem6_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.FlyToPosition(new GSOPoint3d(120.610963, 31.188121, 50), EnumAltitudeMode.Absolute, -4, 50, 800); + globeControl1.Globe.FlyToPointSpeed = 10000000; + globeControl1.Globe.Action = EnumAction3D.SelectObject; + globeControl1.Refresh(); + + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + + //zhanshi = false; + redSH = true; + splitContainer1.Panel2Collapsed = true; + legendSG.Visible = false; + legendSC.Visible = false; + ClearGZData(); + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = true; + } + + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 基础工具 + /// + /// + /// + private void ribbonTabItem1_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + //zhanshi = false; + redSH = false; + splitContainer1.Panel2Collapsed = true; + panelOfTable.Visible = false; + legendSC.Visible = false; + legendSG.Visible = false; + ClearGZData(); + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + + + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 一键审核 + /// + /// + /// + private void ribbonTabItem11_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + //zhanshi = false; + redSH = false; + splitContainer1.Panel2Collapsed = true; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + panelOfTable.Visible = false; + legendSC.Visible = false; + legendSG.Visible = false; + ClearGZData(); + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + + + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 右屏添加冰箱数据 + /// + void AddDataToGlobeControl2() + { + + bool modelDataBool = false; + for (int i = globeControl2.Globe.Layers.Count - 1; i >= 0; i--) + { + GSOLayer layer = globeControl2.Globe.Layers[i]; + if (layer.Name.Contains("fttp:")) + { + modelDataBool = true; + break; + } + } + + if (modelDataBool == false) + { + GSOLayer ly = globeControl1.Globe.Layers.GetLayerByCaption("天地图地图"); + globeControl2.Globe.Layers.Add(ly); + } + else + { + return; + } + } + /// + /// 双屏对比 + /// + /// + /// + private void ribbonTabItem9_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent += new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent += new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + panelOfTable.Visible = false; + + splitContainer1.Panel2Collapsed = false; + //zhanshi = true; + redSH = false; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + sliderItem2.Value = 100 - globeControl1.Globe.GroundOpaque; + globeControl2.Globe.GroundOpaque = globeControl1.Globe.GroundOpaque; + legendSC.Visible = true; + legendSG.Visible = true; + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + AddDataToGlobeControl2(); + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 文档管理 + /// + /// + /// + private void ribbonTabItem4_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + panelOfTable.Visible = false; + //zhanshi = false; + redSH = false; + splitContainer1.Panel2Collapsed = true; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + legendSC.Visible = false; + legendSG.Visible = false; + ClearGZData(); + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 基础管理 + /// + /// + /// + private void ribbonTabItem14_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + panelOfTable.Visible = false; + //zhanshi = false; + redSH = false; + splitContainer1.Panel2Collapsed = true; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + legendSC.Visible = false; + legendSG.Visible = false; + ClearGZData(); + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 权限管理 + /// + /// + /// + private void ribbonTabItem2_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + panelOfTable.Visible = false; + //zhanshi = false; + redSH = false; + splitContainer1.Panel2Collapsed = true; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + legendSC.Visible = false; + legendSG.Visible = false; + ClearGZData(); + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + GSOFeature dpFeatuer = null; + /// + /// 双屏分析,点击管段分析 + /// + /// + /// + private void buttonItem8_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItem8.Text); + + //FrmCompareFeature frmCompareFeature = new FrmCompareFeature(globeControl1, globeControl2, layerTemp, layerTemp2,m_PipelineLayerNames,sgPipeLayersNames); + int width = this.Width; + FrmCompareFeature.ShowForm(globeControl1, globeControl2, layerTemp, layerTemp2, m_PipelineLayerNames, sgPipeLayersNames,width); + //frmCompareFeature.Location = new Point((this.Width - frmCompareFeature.Width)/2,50); + //frmCompareFeature.Show(this); + + } + /// + /// 红线审核导出图片 + /// + /// + /// + private void buttonItemDCTP_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemDCTP.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))); + */ + int mapWidth = 0; + int mapHeight = 0; + Point pt = getUpperLeftPoint(pt1, pt2, out mapWidth, out mapHeight); + int rightBottomX = pt.X + mapWidth; + int rightBottomY = pt.Y + mapHeight; + Image myImg = new Bitmap(mapWidth, mapHeight); + Graphics g = Graphics.FromImage(myImg); + g.CopyFromScreen(pt, new Point(0, 0), new Size(rightBottomX, rightBottomY)); + + 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; + } + } + } + /// + /// 标识器全区域统计 + /// + /// + /// + private void 标识器分类统计ToolStripMenuItem_Click(object sender, EventArgs e) + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + FrmBSQStatis bsqStatis = new FrmBSQStatis(globeControl1,null); + //FrmBSQStatis bsqStatis = new FrmBSQStatis(); + bsqStatis.Show(this); + } + /// + /// 标识器绘制区域统计 + /// + /// + /// + private void 标识器分类统计ToolStripMenuItem1_Click(object sender, EventArgs e) + { + trackflag = "BSQDuoBianXiangStatis"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + } + + #region 保存和加载审核库加载的图层 + /* + private void saveLayerList(TreeNodeCollection treeNodeList) + { + string configPath = Application.StartupPath + "\\configLayerList.xml"; + try + { + XmlDocument doc = new XmlDocument(); + doc.Load(configPath); + XmlNode dbParams = doc.SelectSingleNode("Params/dbparams"); + XmlNode dbLayers = doc.SelectSingleNode("Params/dblayers"); + XmlNode layers = doc.SelectSingleNode("Params/layers"); + dbParams.RemoveAll(); + dbLayers.RemoveAll(); + layers.RemoveAll(); + + List listDS = new List(); + String shDatasourceName = Utility.sgdbip + "/" + Utility.sgdbname + "_" + Utility.sgdbuser; + bool flag = false; + + for (int i = 0; i < globeControl1.Globe.DataManager.DataSourceCount; i++) + { + GSODataSource ds = globeControl1.Globe.DataManager.GetDataSourceAt(i); + if (ds != null && ds.Type == EnumDataSourceType.SqlServer || ds.Type == EnumDataSourceType.Oracle) + { + if (ds.Name == shDatasourceName) + { + //防止因为多次连接同一个数据库 + if (flag == true) + { + break; + } + flag = true; + listDS.Add(ds); + GSODataSourceCnn conn = ds.GetConnectionInfo(); + + XmlElement dbparam = doc.CreateElement("shdbparam"); + XmlElement ip = doc.CreateElement("ship"); + ip.InnerText = conn.Server; + + XmlElement dbname = doc.CreateElement("shdbname"); + dbname.InnerText = conn.Database; + + XmlElement username = doc.CreateElement("shusername"); + username.InnerText = conn.User; + + XmlElement password = doc.CreateElement("shpassword"); + password.InnerText = conn.Password; + + XmlElement type = doc.CreateElement("shtype"); + if (ds.Type == EnumDataSourceType.SqlServer) + { + type.InnerText = "sqlserver"; + } + else + { + type.InnerText = "oracle"; + } + + dbparam.AppendChild(ip); + dbparam.AppendChild(dbname); + dbparam.AppendChild(username); + dbparam.AppendChild(password); + dbparam.AppendChild(type); + dbParams.AppendChild(dbparam); + } + + } + } + + for (int i = 0; i < treeNodeList.Count; i++) + { + GSOLayer layer = treeNodeList[i].Tag as GSOLayer; + if (Path.GetExtension(layer.Name) == "") + { + XmlElement dbLayer = doc.CreateElement("dblayer"); + XmlAttribute attri = doc.CreateAttribute("dbindex"); + for (int j = 0; j < listDS.Count; j++) + { + if (layer.Dataset.DataSource.Name == listDS[j].Name) + { + attri.Value = j.ToString(); + break; + } + } + dbLayer.Attributes.Append(attri); + dbLayer.InnerText = layer.Name; + + dbLayers.AppendChild(dbLayer); + } + else + { + XmlElement dbLayer = doc.CreateElement("layer"); + dbLayer.InnerText = layer.Name; + layers.AppendChild(dbLayer); + } + } + + doc.Save(configPath); + } + catch (Exception e) + { + + } + } + + private void openLayerList() + { + layerManagerNode.Nodes.Clear(); + + string configPath = Application.StartupPath + "\\configLayerList.xml"; + try + { + XmlDocument doc = new XmlDocument(); + doc.Load(configPath); + XmlNode dbParams = doc.SelectSingleNode("Params/dbparams"); + XmlNode dbLayers = doc.SelectSingleNode("Params/dblayers"); + XmlNode layers = doc.SelectSingleNode("Params/layers"); + + List listDS = new List(); + for (int i = 0; i < dbParams.ChildNodes.Count; i++) + { + string ip = ""; + string dbname = ""; + string username = ""; + string password = ""; + string type = ""; + XmlNode node = dbParams.ChildNodes.Item(i); + for (int j = 0; j < node.ChildNodes.Count; j++) + { + XmlNode nodeChild = node.ChildNodes.Item(j); + + if (nodeChild != null && nodeChild.Name == "ship") + { + ip = nodeChild.InnerText; + } + else if (nodeChild != null && nodeChild.Name == "shdbname") + { + dbname = nodeChild.InnerText; + } + else if (nodeChild != null && nodeChild.Name == "shusername") + { + username = nodeChild.InnerText; + } + else if (nodeChild != null && nodeChild.Name == "shpassword") + { + password = nodeChild.InnerText; + } + else if (nodeChild != null && nodeChild.Name == "shtype") + { + type = nodeChild.InnerText; + } + } + + if (type == "sqlserver") + { + GSODataSource ds = globeControl1.Globe.DataManager.OpenSqlServerDataSource(ip, "", dbname, username, password); + listDS.Add(ds); + } + else if (type == "oracle") + { + GSODataSource ds = globeControl1.Globe.DataManager.OpenOracleDataSource(ip + "/" + dbname, "", "", username, password); + listDS.Add(ds); + } + } + + for (int i = 0; i < dbLayers.ChildNodes.Count; i++) + { + XmlNode node = dbLayers.ChildNodes.Item(i); + if (node != null) + { + string layerName = node.InnerText; + XmlAttribute attri = node.Attributes["dbindex"]; + if (attri != null) + { + int dbIndex = -1; + if (int.TryParse(attri.Value, out dbIndex)) + { + GSODataset dataset = listDS[dbIndex].GetDatasetByName(layerName); + globeControl1.Globe.Layers.Add(dataset); + //更新树节点 + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + TreeNode layerNode = new TreeNode(); + layerNode.Tag = layer; + layerNode.Text = layer.Dataset.Caption; + layerNode.ImageIndex = 0; + layerNode.SelectedImageIndex = 0; + layerNode.Checked = layer.Visible; + layerManagerNode.Nodes.Insert(0, layerNode); + // layerManagerNode.Expand(); + + + } + } + } + } + for (int i = 0; i < layers.ChildNodes.Count; i++) + { + XmlNode node = layers.ChildNodes.Item(i); + if (node != null) + { + string layerName = node.InnerText; + globeControl1.Globe.Layers.Add(layerName); + + //更新树节点 + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + TreeNode layerNode = new TreeNode(); + layerNode.Tag = layer; + layerNode.Text = layer.Dataset.Caption; + layerNode.ImageIndex = 0; + layerNode.SelectedImageIndex = 0; + layerNode.Checked = layer.Visible; + layerManagerNode.Nodes.Insert(0, layerNode); + } + } + layerManagerNode.Expand(); + } + catch (Exception e) + { + + } + } + * */ + #endregion + + private void btn_check_history_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_check_history.Text); + + if (FrmCheckHistory.isOpen == true) + { + return; + } + FrmCheckHistory frm = new FrmCheckHistory(globeControl1, globeControl2); + frm.addNode += new AddNodeToLayerManagerNode(addNodeToLayerManagerNode); + frm.Show(); + + } + + private void buttonItem查看数据_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItem查看数据.Text); + + FrmThreeOracle tr = new FrmThreeOracle(globeControl1); + + if (tr.ShowDialog() == DialogResult.OK) + { + addNodeToLayerManagerNode(tr.rukuLayer); + globeControl1.Refresh(); + } + } + /// + /// 规划数据入库 + /// + /// + /// + private void buttonItemGHRK_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemGHRK.Text); + + FrmGHRK ghrk = new FrmGHRK(globeControl1, layerManagerNode); + ghrk.Show(this); + } + + private void btn_user_info_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_user_info.Text); + + if (!FrmSysUserInfoManger.IS_OPEN) + { + FrmSysUserInfoManger frm = new FrmSysUserInfoManger(); + frm.ShowDialog(); + } + } + + private void btn_role_info_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_role_info.Text); + + if (FrmRoleInfoManager.IS_OPEN) + { + return; + } + FrmRoleInfoManager frm = new FrmRoleInfoManager(); + frm.ShowDialog(); + } + + private void btn_resc_info_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_resc_info.Text); + + if (!SysRescInfoManager.IS_OPEN) + { + SysRescInfoManager frm = new SysRescInfoManager(); + frm.ShowDialog(); + } + } + + private void btn_role_resc_Click(object sender, EventArgs e) + { + + LogManager.saveLog(Utility.userName, this.btn_role_resc.Text); + + if (!FrmRoleRescManager.IS_OPEN) + { + FrmRoleRescManager frm = new FrmRoleRescManager(); + frm.ShowDialog(); + } + } + + private void btn_user_role_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_user_role.Text); + + if (FrmUserRole.IS_OPEN) + { + return; + } + FrmUserRole frm = new FrmUserRole(); + frm.ShowDialog(); + } + + private void btn_document_info_Click(object sender, EventArgs e) + { + + LogManager.saveLog(Utility.userName, this.btn_document_info.Text); + + //if (FormDocumentManager.IS_OPEN) + //{ + // return; + //} + //FormDocumentManager frm = new FormDocumentManager(); + //frm.ShowDialog(); + + //if (FormDocumentManager.IS_OPEN) + //{ + // return; + //} + //new FormDocumentManager().ShowDialog(); + if (FormDocumentManager.IS_OPEN) + { + return; + } + this.Cursor = Cursors.WaitCursor; + FormDocumentManager frm = new FormDocumentManager(); + frm.changeCursor += new ChangeCursor(changeCursorToDefault); + frm.ShowDialog(); + + } + + private void changeCursorToDefault() + { + this.Cursor = Cursors.Default; + } + + /// + /// 判断CAD文件是否有投影信息 + /// + /// + /// + Boolean CheckDatasetGeoReference(GSODataset dataset) + { + Boolean bSuccess = false; + if (dataset.GeoReferenceType == EnumGeoReferenceType.Flat) + { + if (MessageBox.Show("数据没有空间参考信息,请设置空间参考信息!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation) == DialogResult.OK) + { + String strPath = Path.GetDirectoryName(Application.ExecutablePath) + "\\Coordinate Systems"; + OpenFileDialog dlg = new OpenFileDialog(); + + dlg.InitialDirectory = strPath; + dlg.RestoreDirectory = true; + + dlg.Filter = "投影文件|*.prj||"; + if (dlg.ShowDialog() == DialogResult.OK) + { + bSuccess = dataset.LoadProjectionFromESRIFile(dlg.FileName); + } + } + } + else + { + return true; + } + return bSuccess; + } + + private void buttonItemexp_CAD_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemexp_CAD.Text); + + OpenFileDialog dlg = new OpenFileDialog(); + dlg.Filter = "支持格式(*.dwg)|*.dwg"; + dlg.Multiselect = true; + if (dlg.ShowDialog() == DialogResult.OK) + { + for (int i = 0; i < dlg.FileNames.Length; i++) + { + //this.Cursor = Cursors.WaitCursor; + string strDataPath = dlg.FileNames[i]; + + #region + //string strDataPathPrj = strDataPath.ToLower().Replace(".dwg", ".lprj"); + + //if (File.Exists(strDataPathPrj) == false) + //{ + // if (MessageBox.Show("数据没有空间参考信息,请设置空间参考信息!", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation) == DialogResult.OK) + // { + // String strPath = Application.StartupPath + "\\Coordinate Systems"; + // OpenFileDialog dlgPrj = new OpenFileDialog(); + // dlgPrj.InitialDirectory = strPath; + // dlgPrj.RestoreDirectory = true; + // dlgPrj.Multiselect = false; + // dlg.Filter = "投影文件|*.prj"; + // if (dlg.ShowDialog() == DialogResult.OK) + // { + // this.Cursor = Cursors.WaitCursor; + // string proj4 = GSODataEngineUtility.ConvertEsriPrjFileToProj4(dlg.FileName); + // using (StreamWriter stream = new StreamWriter(strDataPathPrj, false)) + // { + // stream.WriteLine("0prj4" + proj4 + ""); + // } + // AddLayerData(strDataPath); + // //globeControl1.Globe.Layers.Add(strDataPath); + + // this.Cursor = Cursors.Default; + // } + // else + // { + // AddLayerData(strDataPath); + // //globeControl1.Globe.Layers.Add(strDataPath); + // } + // } + // else + // { + // AddLayerData(strDataPath); + // //globeControl1.Globe.Layers.Add(strDataPath); + // } + + //} + //else + //{ + // //globeControl1.Globe.Layers.Add(strDataPath); + // AddLayerData(strDataPath); + //} + #endregion + AddLayerData(strDataPath); + //this.Cursor = Cursors.Default; + } + } + + 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, 100); + + globeControl1.Refresh(); + } + } + + private void btn_password_edit_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_password_edit.Text); + + if (FrmChangePassword.IS_OPEN) + { + return; + } + FrmChangePassword frm = new FrmChangePassword(); + frm.ShowDialog(); + } + /// + /// 多孔管线入库 + /// + /// + /// + private void buttonItem9_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL4_2.Text); + + if (ds == null) + { + MessageBox.Show("请先连接数据库", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + ConnectDB(null, null); + } + if (ds == null) + return; + + FrmMultiPipelineModelDB frm = new FrmMultiPipelineModelDB(globeControl1, ds); + if (frm.ShowDialog() == DialogResult.OK) + { + addNodeToLayerManagerNode(frm.rukuLayer); + } + //frm.Show(); + } + private void 导出CADToolStripMenuItem1_Click(object sender, EventArgs e) + { + TreeNode node = layerNodeContexMenu.Tag as TreeNode; + if (node == null) + { + MessageBox.Show("请在左侧节点集中选择要导出的图层", "提示"); + return; + } + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(node.Text.Trim()); + if (layer == null || layer.GetAllFeatures().Length <= 0) + { + MessageBox.Show("要导出的图层为空", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + return; + } + string strProjectName = Utility.projectStr; + if (strProjectName != "") + { + SaveFileDialog dlg = new SaveFileDialog(); + dlg.Filter = "*.dwg|*.dwg|*.dxf|*.dxf"; + dlg.FileName = layer.Caption; + if (dlg.ShowDialog(this) == DialogResult.OK) + { + globeControl1.Globe.MemoryLayer.SaveAs(dlg.FileName); + GSOLayer newlayer = globeControl1.Globe.Layers.Add(dlg.FileName); + newlayer.RemoveAllFeature(); + int featureCount = layer.GetAllFeatures().Length; + for (int i = 0; i < featureCount; i++) + { + GSOFeature feature = layer.GetAt(i); + if (feature != null && feature.Geometry != null) + { + if (feature.Geometry.Type == EnumGeometryType.GeoPolyline3D) + { + feature.Geometry.Style = new GSOSimpleLineStyle3D(); + } + else if (feature.Geometry.Type == EnumGeometryType.GeoPolygon3D) + { + feature.Geometry.Style = new GSOSimplePolygonStyle3D(); + } + newlayer.AddFeature(feature); + } + } + newlayer.Save(); + newlayer.Dataset.DataSource.RemoveDataset(newlayer.Dataset); + globeControl1.Globe.Layers.Remove(newlayer); + MessageBox.Show("导出CAD完成!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + } + } + } + + private void buttonItemGBJC_Click(object sender, EventArgs e) + { + FrmGBJC gb = new FrmGBJC(globeControl1, globeControl2, layerTemp, layerTemp2); + gb.Show(this); + } + + #region 右屏管纵数据控制 + private void 五十米主干道ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = true; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + + private void 三十六米次干道ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = true; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + + private void 四十二米次干道ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = true; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + + private void 二十四米一块板ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = true; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + + private void 二十四米三块板ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = true; + } + + private void 二十四米停车带ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = true; + lendendGZ24_3.Visible = false; + } + + private void 二十六米大堤路ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = true; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + + private void 清除管纵数据ToolStripMenuItem_Click(object sender, EventArgs e) + { + ClearGZData(); + } + + private void ClearGZData() + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + #endregion + + private void buttonItemPasswordReset_Click(object sender, EventArgs e) + { + Frm_password_reset reset = new Frm_password_reset(); + reset.Show(); + } + + private void pictureBox1_Paint(object sender, PaintEventArgs e) + { + int Width = this.Width; + string welcomeUser = "欢迎您:" + Utility.userName; + Graphics g = e.Graphics; + g.DrawString(welcomeUser, new Font("宋体", 12), new SolidBrush(Color.Black), Width - 180, 50); + } + + } +} \ No newline at end of file diff --git a/MainFrm.cs.BASE.9016.cs b/MainFrm.cs.BASE.9016.cs new file mode 100644 index 0000000..e530fbd --- /dev/null +++ b/MainFrm.cs.BASE.9016.cs @@ -0,0 +1,13442 @@ +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; + + GSOBalloon featureTooltip2; + GSOBalloonEx balloonEx2; + + GSOLayer layerTemp; + GSOLayer layerTemp2; + FrmShResult frmShResult = null; + FrmRedlineResult frmredResult = null; + FrmMnModify frmModify = null; + public bool frmRedlineResult = false; + public bool boolfrmShResult = false; + public bool boolfrmModify = false; + + List m_PipelineLayerNames = new List();//线图层名称 + List workwellLayerNames = new List();//工井图层名称 + List valueLayerNames = new List();//阀门图层名称 + List instrumenLayerNames = new List();//附属物图层名称 + List pipefittingLayerNames = new List();//管件图层名称 + List sgPipeLayersNames = new List();//施工管线图层名称 + 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 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; + public string redLayer = null; + //GSOLayer redLayer1 = null; + bool redSH = false; + string redDt = "红线"; + //双屏对比 + //bool zhanshi=false; + Thread t = null; + private GSOHudButton legendSC;//定义图例 + private GSOHudButton legendSG;//定义图例 + //管纵图 + private GSOHudButton lendendGZ50; + private GSOHudButton lendendGZ36; + private GSOHudButton lendendGZ42; + private GSOHudButton lendendGZ24_1; + private GSOHudButton lendendGZ24_2; + private GSOHudButton lendendGZ24_3; + private GSOHudButton lendendGZ26; + + GSOGeoPoint3D bsqPT; + + FrmYJSHTC frmSh = null;//一键审核窗口全局变量wxl + FrmWait frmWait = null;//一键审核等待窗口 + //FrmWait frmWait2 = null;//文档操作等待窗口 + + float mouseDownX1,mouseDownY1; + float mouseDownX2,mouseDownY2; + /// + /// + /// + 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; + + featureTooltip2 = new GSOBalloon(globeControl2.Handle); + balloonEx2 = new GSOBalloonEx(globeControl2.Handle); + Utility.SetBallons(featureTooltip, balloonEx); + + panelOfTable.Height = 200; + + RigthMenuSet(); + + MenuSet(); + + } + /// + /// 右屏中添加管纵图片 + /// + private void AddGZ() + { + + lendendGZ50 = new GSOHudButton(); + lendendGZ50.SetImage(Application.StartupPath + "/Resource/管纵/50.png"); + lendendGZ50.SetOffset(0, 0); + lendendGZ50.MinOpaque = 1; + lendendGZ50.MaxOpaque = 1; + lendendGZ50.FadeOut = false; + lendendGZ50.Name = "lendendGZ50"; + lendendGZ50.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ50); + lendendGZ50.Visible = false; + + lendendGZ36 = new GSOHudButton(); + lendendGZ36.SetImage(Application.StartupPath + "/Resource/管纵/36.png"); + lendendGZ36.SetOffset(0, 0); + lendendGZ36.MinOpaque = 1; + lendendGZ36.MaxOpaque = 1; + lendendGZ36.FadeOut = false; + lendendGZ36.Name = "lendendGZ36"; + lendendGZ36.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ36); + lendendGZ36.Visible = false; + + lendendGZ42 = new GSOHudButton(); + lendendGZ42.SetImage(Application.StartupPath + "/Resource/管纵/42.png"); + lendendGZ42.SetOffset(0, 0); + lendendGZ42.MinOpaque = 1; + lendendGZ42.MaxOpaque = 1; + lendendGZ42.FadeOut = false; + lendendGZ42.Name = "lendendGZ42"; + lendendGZ42.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ42); + lendendGZ42.Visible = false; + + lendendGZ24_1 = new GSOHudButton(); + lendendGZ24_1.SetImage(Application.StartupPath + "/Resource/管纵/24_1.png"); + lendendGZ24_1.SetOffset(0, 0); + lendendGZ24_1.MinOpaque = 1; + lendendGZ24_1.MaxOpaque = 1; + lendendGZ24_1.FadeOut = false; + lendendGZ24_1.Name = "lendendGZ24_1"; + lendendGZ24_1.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ24_1); + lendendGZ24_1.Visible = false; + + lendendGZ24_2 = new GSOHudButton(); + lendendGZ24_2.SetImage(Application.StartupPath + "/Resource/管纵/24_2.png"); + lendendGZ24_2.SetOffset(0, 0); + lendendGZ24_2.MinOpaque = 1; + lendendGZ24_2.MaxOpaque = 1; + lendendGZ24_2.FadeOut = false; + lendendGZ24_2.Name = "lendendGZ24_2"; + lendendGZ24_2.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ24_2); + lendendGZ24_2.Visible = false; + + lendendGZ24_3 = new GSOHudButton(); + lendendGZ24_3.SetImage(Application.StartupPath + "/Resource/管纵/24_3.png"); + lendendGZ24_3.SetOffset(0, 0); + lendendGZ24_3.MinOpaque = 1; + lendendGZ24_3.MaxOpaque = 1; + lendendGZ24_3.FadeOut = false; + lendendGZ24_3.Name = "lendendGZ24_3"; + lendendGZ24_3.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ24_3); + lendendGZ24_3.Visible = false; + + lendendGZ26 = new GSOHudButton(); + lendendGZ26.SetImage(Application.StartupPath + "/Resource/管纵/26.png"); + lendendGZ26.SetOffset(0, 0); + lendendGZ26.MinOpaque = 1; + lendendGZ26.MaxOpaque = 1; + lendendGZ26.FadeOut = false; + lendendGZ26.Name = "lendendGZ26"; + lendendGZ26.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ26); + lendendGZ26.Visible = false; + + } + + public void RigthMenuSet() + { + if (Utility.userRole.IndexOf("清除分析") < 0) + { + toolRightMenu.Items.Remove(清除分析ToolStripMenuItem); + } + + #region 区域分析 + if (Utility.userRole.IndexOf("区域分析") < 0) + { + toolRightMenu.Items.Remove(区域分析ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("缓冲区分析") < 0) + { + 区域分析ToolStripMenuItem.DropDownItems.Remove(缓冲区分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("附属物分析") < 0) + { + 区域分析ToolStripMenuItem.DropDownItems.Remove(附属物分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("无源淹没分析") < 0) + { + 区域分析ToolStripMenuItem.DropDownItems.Remove(无源淹没分析ToolStripMenuItem); + } + } + #endregion + + #region 视域分析 + if (Utility.userRole.IndexOf("视域分析") < 0) + { + toolRightMenu.Items.Remove(视域分析ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("通视分析") < 0) + { + 视域分析ToolStripMenuItem.DropDownItems.Remove(通视分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("可视域分析") < 0) + { + 视域分析ToolStripMenuItem.DropDownItems.Remove(可视域分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("可视包络分析") < 0) + { + 视域分析ToolStripMenuItem.DropDownItems.Remove(可视包络分析ToolStripMenuItem); + } + } + #endregion + + #region 开发分析 + if (Utility.userRole.IndexOf("开挖分析") < 0) + { + toolRightMenu.Items.Remove(开挖分析ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("多边形开挖") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(多边形开挖ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("挖方量分析") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(挖方量分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("沿线开挖") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(沿线开挖ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("创建隧道") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(创建隧道ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("隐藏隧道") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(隐藏隧道ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("删除隧道") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(删除隧道ToolStripMenuItem); + } + } + #endregion + + #region 拓扑分析 + if (Utility.userRole.IndexOf("拓扑分析") < 0) + { + toolRightMenu.Items.Remove(拓扑分析ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("创建拓扑") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(创建拓扑ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("上游分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(上游分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("下游分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(下游分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("流向分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(流向分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("关阀分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(关阀分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("连通分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(连通分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("爆管分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(爆管分析ToolStripMenuItem); + } + } + #endregion + + #region 断面分析 + if (Utility.userRole.IndexOf("断面分析") < 0) + { + toolRightMenu.Items.Remove(断面分析ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("横断面分析") < 0) + { + 断面分析ToolStripMenuItem.DropDownItems.Remove(横断面分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("纵断面分析") < 0) + { + 断面分析ToolStripMenuItem.DropDownItems.Remove(纵断面分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("道路断面分析") < 0) + { + 断面分析ToolStripMenuItem.DropDownItems.Remove(道路断面分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("基线剖面分析") < 0) + { + 断面分析ToolStripMenuItem.DropDownItems.Remove(基线剖面分析ToolStripMenuItem); + } + } + #endregion + + #region 绘制区域统计 + if (Utility.userRole.IndexOf("绘制区域统计") < 0) + { + toolRightMenu.Items.Remove(绘制区域统计ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("绘制区域管线长度统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管线长度统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域阀门数量统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(阀门数量统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域井盖数量统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(井盖数量统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域管径分段统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管径分段统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域埋深分段统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(埋深分段统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域管径分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管径分类统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域材质分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(材质分类统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域附属物分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(附属物分类统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域标识器分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(标识器分类统计ToolStripMenuItem1); + } + + } + #endregion + + #region 全区域统计 + if (Utility.userRole.IndexOf("全区域统计") < 0) + { + toolRightMenu.Items.Remove(全区域统计ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("全区域管线长度统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管线长度统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域阀门数量统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(阀门数量统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域井盖数量统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(井盖数量统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域管径分段统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管径分段统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域埋深分段统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(埋深分段统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域管径分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管径分类统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域材质分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(材质分类统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域附属物分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(附属物分类统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域标识器分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(标识器分类统计ToolStripMenuItem); + } + + } + #endregion + + #region 查询 + if (Utility.userRole.IndexOf("查询") < 0) + { + toolRightMenu.Items.Remove(查询ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("空间查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(空间查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("编号查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(编号查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("坐标查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(坐标查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("管径查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(管径查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("材质查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(材质查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("基本查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(基本查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("复合查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(复合查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("关联查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(关联查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("关键字查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(关键字查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("附属物查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(附属物查询ToolStripMenuItem); + } + } + #endregion + + #region 标注 + if (Utility.userRole.IndexOf("标注") < 0) + { + toolRightMenu.Items.Remove(标注ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("标高标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(标高标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("管径标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(管径标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("埋深标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(埋深标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("坐标标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(坐标标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("距离标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(距离标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("自定义标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(自定义标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("扯旗标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(扯旗标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("坡度标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(坡度标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("属性标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(属性标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("标注管理") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(标注管理ToolStripMenuItem); + } + } + #endregion + + #region 飞行 + if (Utility.userRole.IndexOf("飞行") < 0) + { + toolRightMenu.Items.Remove(飞行ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("自定义飞行") < 0) + { + 飞行ToolStripMenuItem.DropDownItems.Remove(自定义飞行ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("飞行到目标点") < 0) + { + 飞行ToolStripMenuItem.DropDownItems.Remove(飞行到目标点ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("绕中心点飞行") < 0) + { + 飞行ToolStripMenuItem.DropDownItems.Remove(绕中心点飞行ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("绕眼睛飞行") < 0) + { + 飞行ToolStripMenuItem.DropDownItems.Remove(绕眼睛飞行ToolStripMenuItem); + } + } + #endregion + + #region 编辑 + if (Utility.userRole.IndexOf("编辑") < 0) + { + toolRightMenu.Items.Remove(编辑ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("平移对象") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(平移对象ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("升降对象") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(升降对象ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("旋转对象") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(旋转对象ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("连接管段") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(连接管段ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("导出文件") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(导出文件ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("前进") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(前进ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("后退") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(删除模型ToolStripMenuItem); + } + } + #endregion + + #region 量算 + if (Utility.userRole.IndexOf("量算") < 0) + { + toolRightMenu.Items.Remove(量算ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("水平距离") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(水平距离ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("垂直距离") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(垂直距离ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("空间距离") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(空间距离ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("地表距离") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(地表距离ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("高度量算") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(高度量算ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("水平面积") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(水平面积ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("地表面积") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(地表面积ToolStripMenuItem1); + } + } + #endregion + } + + public void MenuSet() + { + + #region 权限管理 + if (Utility.userRole.IndexOf("权限管理") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem2); + } + else + { + + if (Utility.userRole.IndexOf("用户管理") < 0) + { + btn_user_info.Visible = false; + } + if (Utility.userRole.IndexOf("角色管理") < 0) + { + btn_role_info.Visible = false; + } + if (Utility.userRole.IndexOf("资源管理") < 0) + { + btn_resc_info.Visible = false; + } + if (Utility.userRole.IndexOf("角色授权") < 0) + { + btn_role_resc.Visible = false; + } + if (Utility.userRole.IndexOf("用户授权") < 0) + { + btn_user_role.Visible = false; + } + if (Utility.userRole.IndexOf("密码修改") < 0) + { + btn_password_edit.Visible = false; + } + + } + #endregion + + #region 基础工具 + if (Utility.userRole.IndexOf("基础工具") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem1); + } + else + { + if (Utility.userRole.IndexOf("地上模式") < 0) + { + buttonItem87.Visible = false; + } + if (Utility.userRole.IndexOf("地下模式") < 0) + { + buttonItem88.Visible = false; + } + if (Utility.userRole.IndexOf("行走模式") < 0) + { + buttonItem27.Visible = false; + } + if (Utility.userRole.IndexOf("透明度设置") < 0) + { + sliderGroundTransSet1.Visible = false; + } + if (Utility.userRole.IndexOf("快速定位") < 0) + { + buttonItem91.Visible = false; + } + if (Utility.userRole.IndexOf("图层管理") < 0) + { + buttonItem1.Visible = false; + } + if (Utility.userRole.IndexOf("图例管理") < 0) + { + btnlegendSet.Visible = false; + } + if (Utility.userRole.IndexOf("全屏显示") < 0) + { + buttonItem89.Visible = false; + } + if (Utility.userRole.IndexOf("导出图片") < 0) + { + btnOutputJPG.Visible = false; + } + + } + #endregion + + #region 一键审核 + if (Utility.userRole.IndexOf("一键审核") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem11); + } + #endregion + + #region 红线审核 + if (Utility.userRole.IndexOf("红线审核") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem6); + } + #endregion + + #region 双屏对比 + if (Utility.userRole.IndexOf("双屏对比") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem9); + } + #endregion + + #region 文档管理 + if (Utility.userRole.IndexOf("文档管理") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem4); + } + #endregion + + #region 基础管理 + if (Utility.userRole.IndexOf("基础管理") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem14); + } + else + { + if (Utility.userRole.IndexOf("专题图审批") < 0) + { + buttonItemZTT3_2.Visible = false; + } + if (Utility.userRole.IndexOf("打印审批") < 0) + { + buttonItemZTT4_2.Visible = false; + } + if (Utility.userRole.IndexOf("拷贝审批") < 0) + { + buttonItemZTT5_2.Visible = false; + } + } + + #endregion + + if (ribbonControl1.Items.Count <= 0) + { + ribbonControl1.Visible = false; + } + } + + #region Fan Zhang 重构现有代码 + //初始化控件布局 + private void initLayout() + { + 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.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.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.labelX21.Width = (int)(this.labelX21.Width * myScreen); + this.labelX22.Width = (int)(this.labelX22.Width * myScreen); + this.labelX24.Width = (int)(this.labelX24.Width * myScreen); + } + sideBar1.Visible = false; + 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]); + } + + splitContainer1.Panel2Collapsed = true; + + buttonItem87.Checked = true;//默认地上模式 + ribbonTabItem1.Select(); //初始化状态为浏览 + + sideBarPanelItem3.Visible = false; + layerTree.Visible = false; + controlContainerItem3.Visible = false; + if (sideBarPanelItem4.Visible == true) + { + sideBar1.Visible = true; + controlContainerItem5.Visible = true; + } + else + { + sideBar1.Visible = false; + } + Refresh(); + sliderGroundTransSet1.Value = optiValue; + sliderItem1.Value = optiValue; + sliderItem2.Value = optiValue; + sliderItem3.Value = optiValue; + + } + + //初始化地球控件 + private void initGlobalControl() + { + //选择 + btnToolSelect = new GSOHudButton(); + btnToolSelect.SetImage(Application.StartupPath + "\\Resource\\image\\select1.png"); + btnToolSelect.FadeOut = false; + btnToolSelect.Align = EnumAlign.TopLeft; + btnToolSelect.SetOffset(20, 50); + btnToolSelect.Name = "1"; + btnToolSelect.HeightFixed = true; + btnToolSelect.WidthFixed = true; + globeControl1.Globe.AddHudControl(btnToolSelect); + globeControl2.Globe.AddHudControl(btnToolSelect); + + //浏览 + 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); + + //图例 + legend = new GSOHudButton(); + legend.SetImage(Application.StartupPath + "/Resource/图例P.jpg");//图例P + legend.SetOffset(0, 15); + legend.MinOpaque = 1; + legend.MaxOpaque = 1; + legend.FadeOut = false; + legend.Name = "legend"; + legend.Align = EnumAlign.BottomRight; + legend.Visible = false; + globeControl1.Globe.AddHudControl(legend); + + //实测 + legendSC = new GSOHudButton(); + legendSC.SetImage(Application.StartupPath + "/Resource/sc.jpg"); + legendSC.SetOffset(0, 15); + legendSC.MinOpaque = 1; + legendSC.MaxOpaque = 1; + legendSC.FadeOut = false; + legendSC.Name = "legendSC"; + legendSC.Align = EnumAlign.BottomRight; + globeControl1.Globe.AddHudControl(legendSC); + legendSC.Visible = false; + + //施工 + legendSG = new GSOHudButton(); + legendSG.SetImage(Application.StartupPath + "/Resource/sg.jpg"); + legendSG.SetOffset(0, 15); + legendSG.MinOpaque = 1; + legendSG.MaxOpaque = 1; + legendSG.FadeOut = false; + legendSG.Name = "legendSG"; + legendSG.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(legendSG); + legendSG.Visible = false; + + //管纵 + AddGZ(); + + 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; + globeControl1.Globe.IsReleaseMemOutOfView = true; + globeControl1.Globe.ControlPanel.Visible = true; + + globeControl2.Globe.UnderGroundFloor.Visible = false; + globeControl2.Globe.OverviewControl.Visible = false; + globeControl2.Globe.ScalerControl.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; + globeControl2.Globe.IsReleaseMemOutOfView = true; + globeControl2.Globe.ControlPanel.Visible = false; + + 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); + + //添加临时图层 + layerTemp = globeControl1.Globe.Layers.Add(Application.StartupPath + "\\tempLgdData.lgd"); + layerTemp2 = globeControl2.Globe.Layers.Add(Application.StartupPath + "\\tempLgdData2.lgd"); + if (layerTemp != null) + { + layerTemp.MaxVisibleAltitude = 1000; + } + + //添加城市7线图层 + 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"); + + //注册对应事件 + this.registerEvent(); + } + + //注册地球事件 + private bool registerEvent() + { + if (globeControl1 == null || globeControl2 == null) + { + return false; + } + 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); + + globeControl2.FeatureMouseClickEvent += new FeatureMouseClickEventHandler(globeControl2_FeatureMouseClickEvent); + globeControl2.CameraBeginMoveEvent += new CameraBeginMoveEventHandler(globeControl2_CameraBeginMoveEvent); + + globeControl1.MouseDoubleClick += new MouseEventHandler(globeControl1_MouseDoubleClick); + globeControl1.MouseClick += new MouseEventHandler(globeControl1_MouseClick); + globeControl1.MouseDown += new MouseEventHandler(globeControl1_MouseDown); + + globeControl2.MouseClick += new MouseEventHandler(globeControl2_MouseClick); + globeControl2.MouseDown += new MouseEventHandler(globeControl2_MouseDown); + + 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); + + return true; + } + + //加载两个地球数据 + private void loadData() + { + Thread t1 = new Thread(new ThreadStart(doLoadDataForGlobalControl1)); + t1.IsBackground = true; + t1.Start(); + + + } + + delegate void LoadDataForGlobalControl(); + + private void connectServer() + { + globeControl1.Globe.ConnectServer(Utility.serverip, Utility.serverport, "", ""); //加载locaServer中的数据 + globeControl2.Globe.ConnectServer(Utility.serverip, Utility.serverport, "", ""); //加载locaServer中的数据 + //初始化TreeView + // 勾选实测图层 + foreach (TreeNode tn in layerTree.Nodes) + { + if (tn.Nodes.Count > 0) + { + if (tn.Text == "实测数据") + { + tn.Checked = true; + foreach (TreeNode tnChild in tn.Nodes) + { + tnChild.Checked = true; + foreach (TreeNode tnGrandChild in tnChild.Nodes) + { + tnGrandChild.Checked = true; + } + } + } + } + } + } + + private void doLoadDataForGlobalControl1() + { + try + { + + globeControl1.Globe.Layers.MoveDown(10000); + //加载实测管线数据 + Utility.dataSource = globeControl1.Globe.DataManager.OpenOracleDataSource(Utility.DBServer.Trim() + "/" + Utility.dbdatabase.Trim(), "", "", Utility.userID, Utility.DBPassword); + + if (Utility.dataSource != null) + { + for (int j = 0; j < Utility.dataSource.DatasetCount; j++) + { + GSODataset dataset = Utility.dataSource.GetDatasetAt(j); + if (dataset != null && dictionaryNetLayerNameAndCaption.ContainsKey(dataset.Caption)) + { + dataset.Caption = dataset.Name; + globeControl1.Globe.Layers.Add(dataset); + } + } + } + //隐藏红线图层 + globeControl1.Globe.Layers.GetLayerByCaption("红线").Visible = false; + + //globleControl1中加载规划数据 + GSODataSource ghDS = globeControl1.Globe.DataManager.OpenOracleDataSource(Utility.ghdbip + "/" + Utility.ghdbname, "", "", Utility.ghdbuser, Utility.ghdbpwd); + if (ghDS != null) + { + for (int j = 0; j < ghDS.DatasetCount; j++) + { + GSODataset dataset = ghDS.GetDatasetAt(j); + if (dataset != null && dictionaryNetLayerNameAndCaption.ContainsKey(dataset.Caption)) + { + dataset.Caption = dataset.Name; + globeControl1.Globe.Layers.Add(dataset); + globeControl1.Globe.Layers[0].Visible = false; + } + } + } + + //globeControl1,globeControl2中加载施工数据 + GSODataSource sgDS = globeControl1.Globe.DataManager.OpenOracleDataSource(Utility.sgdbip + "/" + Utility.sgdbname, "", "", Utility.sgdbuser, Utility.sgdbpwd); + if (sgDS != null) + { + for (int m = 0; m < sgDS.DatasetCount; m++) + { + GSODataset dataset = sgDS.GetDatasetAt(m); + if (dataset != null && !dataset.Caption.Contains("SH") && dictionaryNetLayerNameAndCaption.ContainsKey(dataset.Caption)) + { + dataset.Caption = dataset.Name; + globeControl1.Globe.Layers.Add(dataset); + globeControl1.Globe.Layers[0].Visible = false; + + globeControl2.Globe.Layers.Add(dataset); + globeControl2.Globe.Layers[0].Visible = true; + } + } + } + + LoadDataForGlobalControl ss = new LoadDataForGlobalControl(connectServer); + ss(); + + } + catch (Exception ex) + { + MessageBox.Show(ex.Message); + } + } + + private void initLayerTree() + { + //加载临时图层节点 + layerManagerNode = new TreeNode(); + layerManagerNode.ImageIndex = 0; + layerManagerNode.SelectedImageIndex = 0; + layerManagerNode.Checked = true; + layerManagerNode.Text = "临时图层"; + layerTree.Nodes.Add(layerManagerNode); + + XmlDocument doc = new XmlDocument(); + doc.Load(filename); + XmlNodeList xmlLayerNodes = doc.SelectNodes("//layer"); + + foreach (XmlNode xmlLayerNode in xmlLayerNodes) + { + + //TODO LIST:创建一级TreeNode(实测、规划、施工) + TreeNode nodelayer = new TreeNode(); + string layerName = xmlLayerNode.Attributes["label"].Value; + nodelayer.Text = layerName; + nodelayer.Checked = false; + layerTree.Nodes.Add(nodelayer); + + XmlNodeList xmlChildLayerNodes = xmlLayerNode.ChildNodes; + foreach (XmlNode xmlChildLayerNode in xmlChildLayerNodes) + { + //TODO LIST:创建二级TreeNode节点 + TreeNode secondLevelNode = new TreeNode(); + string layerType = xmlChildLayerNode.Attributes["label"].Value; + secondLevelNode.Text = layerType; + + if (xmlChildLayerNode.Attributes["type"] != null) + { //道路图层特殊处理 + string type = xmlChildLayerNode.Attributes["type"].Value; + secondLevelNode.Tag = type + "|" + layerType; + } + else + { + secondLevelNode.Tag = layerType; + } + secondLevelNode.Checked = false; + nodelayer.Nodes.Add(secondLevelNode); + + XmlNodeList xmlActitualLayerNodes = xmlChildLayerNode.ChildNodes; + + foreach (XmlNode xmlActitualLayerNode in xmlActitualLayerNodes) + { + //TODO LIST:创建三级图层节点 + TreeNode layerNode = new TreeNode(); + string actutallylayerType = xmlActitualLayerNode.Attributes["type"].Value; + string actutallylayerName = xmlActitualLayerNode.Attributes["layer"].Value; + string actutallyLabelName = xmlActitualLayerNode.Attributes["label"].Value; + + layerNode.Text = actutallyLabelName; + layerNode.Tag = layerType + "|" + actutallyLabelName; + layerNode.Checked = false; + secondLevelNode.Nodes.Add(layerNode); + } + + } + + } + + } + + /** + * 读取Config.xml文件,初始化以下全局Map + * m_PipelineLayerNames:管线 + * workwellLayerNames:工井 + * valueLayerNames:阀门 + * instrumenLayerNames:附属物 + * pipefittingLayerNames:特征管点 + * sgPipeLayersNames:施工管线 + **/ + private void initGlobalMap() + { + XmlDocument doc = new XmlDocument(); + doc.Load(filename); + XmlNodeList xmlLayerNodes = doc.SelectNodes("//layerchild"); + + foreach (XmlNode xmlLayerNode in xmlLayerNodes) + { + string layerType = xmlLayerNode.Attributes["type"].Value; + string layerName1 = xmlLayerNode.Attributes["layer"].Value; + string layerchildName = xmlLayerNode.Attributes["label"].Value; + + dictionaryNetLayerNameAndCaption.Add(layerName1, layerchildName); + + if (layerType != "db") + { + if (xmlLayerNode.Attributes["isRoad"] != null) + { + roadLayerName = layerchildName; + } + } + else if (xmlLayerNode.Attributes["isPipeLine"] != null) + { + m_PipelineLayerNames.Add(layerchildName); + g1layername.Add(layerName1); + } + else if (xmlLayerNode.Attributes["isWorkWell"] != null) + { + workwellLayerNames.Add(layerchildName); + g1layername.Add(layerName1); + } + else if (xmlLayerNode.Attributes["isValve"] != null) + { + valueLayerNames.Add(layerchildName); + g1layername.Add(layerName1); + } + else if (xmlLayerNode.Attributes["isAccess"] != null) + { + instrumenLayerNames.Add(layerchildName); + g1layername.Add(layerName1); + } + else if (xmlLayerNode.Attributes["isCharacter"] != null) + { + pipefittingLayerNames.Add(layerchildName); + g1layername.Add(layerName1); + } + else if (xmlLayerNode.Attributes["isSgData"] != null) + { + sgPipeLayersNames.Add(layerchildName); + g1layername.Add(layerName1); + } + + } + } + + private void initMarkerTree() + { + 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); + } + } + } + } + + private void MainFrm_Load(object sender, EventArgs e) + { + + this.initGlobalControl(); + this.initGlobalMap(); + this.initLayerTree(); + this.initMarkerTree(); + this.initLayout(); + this.loadData(); + + + double x = Convert.ToDouble(Utility.Query_Roads["绿岛"].ToString().Split(',')[0]); + double y = Convert.ToDouble(Utility.Query_Roads["绿岛"].ToString().Split(',')[1]); + double z = Convert.ToDouble(Utility.Query_Roads["绿岛"].ToString().Split(',')[2]); + jumpToCameraState(x, y, z); + + + } + + #endregion + + /// + /// 每次gis服务加载时都会触发的 + /// + /// + /// + 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 dictionaryNetLayerNameAndCaption = new Dictionary(); + 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 配置用户权限 + /// + /// 向数据库插入功能列表 + /// + private void insertControlToDatabase() + { + ArrayList listItem = new ArrayList(); + List subListItem = new List(); + 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) + { + GSOCameraState camera = globeControl2.Globe.CameraState; + globeControl1.Globe.JumpToCameraState(camera); + } + } + + void globeControl1_BeforeSceneRenderEvent(object sender, BeforeSceneRenderEventArgs e) + { + if (globeControl1.Focused) + { + 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); + } + } + } + + /// + /// 检查数据集是否有坐标系信息 + /// + /// + /// + 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 = "0prj4" + lprjStr + ""; + + bSuccess = dataset.LoadProjectionFromESRIFile(dlg.FileName); + + string lprjFileName = strDataPath.Substring(0, strDataPath.LastIndexOf(".")) + ".lprj"; + StreamWriter writer = new StreamWriter(lprjFileName, false); + writer.Write(lprjFileContent); + writer.Close(); + + } + } + } + else + { + return true; + } + return bSuccess; + } + + /// + /// 矩形拉框结束事件处理函数 + /// + /// + /// + 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))); + */ + + int mapWidth = 0; + int mapHeight = 0; + Point pt = getUpperLeftPoint(pt1, pt2, out mapWidth, out mapHeight); + int rightBottomX = pt.X + mapWidth; + int rightBottomY = pt.Y + mapHeight; + Image myImg = new Bitmap(mapWidth, mapHeight); + Graphics g = Graphics.FromImage(myImg); + g.CopyFromScreen(pt, new Point(0, 0), new Size(rightBottomX, rightBottomY)); + + 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; + } + } + /// + /// 定位正北正90度俯视 + /// + /// + /// + /// + 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; + } + } + /// + /// layerTree选中后事件处理 + /// + /// + /// + 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); + } + /// + /// 树节点选中方法 + /// + /// + 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); + } + } + } + + } + /// + /// 改变所有子节点的状态 + /// + /// + /// + 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; + LayerFlyMenuItem.Visible = true; + } + + LayerSelectableMenuItem.Visible = true; + LayerEditableMenuItem.Visible = true; + SaveLayerMenuItem.Visible = true; + LayerFlyMenuItem.Visible = true; + 导出CADToolStripMenuItem1.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]); + if (layer != null) + { + LayerSelectableMenuItem.Checked = layer.Selectable; + LayerEditableMenuItem.Checked = layer.Editable; + } + else + { + return; + } + } + 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; + } + } + } + } + } + + /// + /// 删除临时添加的本地数据图层 + /// + /// + /// + 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); + for (int i = globeControl1.Globe.Layers.Count-1; i >=0; i--) + { + if (globeControl1.Globe.Layers[i].Caption == layer.Caption) + { + globeControl1.Globe.Layers.Remove(globeControl1.Globe.Layers[i]); + } + } + + 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 定位ToolStripMenuItem_Click(object sender, EventArgs e) + { + TreeNode node = layerTree.SelectedNode; + + if (node != null) + { + if (node.Parent.Text.Trim() == "临时图层") + { + GSOLayer lsLayer = globeControl1.Globe.Layers.GetLayerByCaption(node.Text.ToString()); + double x = lsLayer.LatLonBounds.Center.X; + double y = lsLayer.LatLonBounds.Center.Y; + if (x == 0 && y == 0) + { + x = lsLayer.Bounds.Center.X; + y = lsLayer.Bounds.Center.Y; + } + + globeControl1.Globe.FlyToPosition(new GSOPoint3d(x, y, 10), EnumAltitudeMode.Absolute); + } + else + { + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(node.Tag.ToString().Split('|')[1]); + + if (layer != null) + { + if (layer.Caption == "红线") + { + globeControl1.Globe.FlyToPosition(new GSOPoint3d(120.610963, 31.188121, 50), EnumAltitudeMode.Absolute, -4, 50, 1000); + globeControl1.Globe.FlyToPointSpeed = 10000000; + globeControl1.Globe.Action = EnumAction3D.SelectObject; + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = true; + } + globeControl1.Refresh(); + } + else + { + double x = layer.LatLonBounds.Center.X; + double y = layer.LatLonBounds.Center.Y; + globeControl1.Globe.FlyToPosition(new GSOPoint3d(x, y, 100), EnumAltitudeMode.Absolute); + } + } + } + } + else + { + return; + } + + } + + private void layerTree_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e) + { + if(this.layerTree.SelectedNode!=null) + { + if (this.layerTree.SelectedNode.Tag.ToString().Contains("|")) + { + string nodeTag = this.layerTree.SelectedNode.Tag.ToString().Split('|')[1]; + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(nodeTag); + if (layer != null) + { + if (layer.Caption == "红线") + { + globeControl1.Globe.FlyToPosition(new GSOPoint3d(120.610963, 31.188121, 50), EnumAltitudeMode.Absolute, -4, 50, 1000); + globeControl1.Globe.FlyToPointSpeed = 10000000; + globeControl1.Globe.Action = EnumAction3D.SelectObject; + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = true; + } + globeControl1.Refresh(); + } + else { + double x = layer.LatLonBounds.Center.X; + double y = layer.LatLonBounds.Center.Y; + globeControl1.Globe.FlyToPosition(new GSOPoint3d(x, y, 0), EnumAltitudeMode.Absolute); + } + } + } + if (this.layerTree.SelectedNode.Tag is GSOLayer) + { + GSOLayer layer = this.layerTree.SelectedNode.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 (this.layerTree.SelectedNode.Tag is GSOFeature) + { + GSOFeature feature = this.layerTree.SelectedNode.Tag as GSOFeature; + if (feature.Geometry != null) + { + globeControl1.Globe.FlyToPosition(feature.Geometry.GeoCenterPoint, EnumAltitudeMode.Absolute, 0, 0, 10); + } + else + { + globeControl1.Globe.FlyToFeature(feature); + } + } + } + } + + /// + /// 在三维场景移动时,隐藏气泡globeControl1 + /// + /// + /// + void globeControl1_CameraBeginMoveEvent(object sender, CameraBeginMoveEventArgs e) + { + if (featureTooltip.IsVisible()) + { + featureTooltip.HideBalloon(); + } + if (balloonEx.IsVisible()) + { + balloonEx.HideBalloon(); + } + } + + /// + /// 在三维场景移动时,隐藏气泡globeControl2 + /// + /// + /// + void globeControl2_CameraBeginMoveEvent(object sender, CameraBeginMoveEventArgs e) + { + if (featureTooltip2.IsVisible()) + { + featureTooltip2.HideBalloon(); + } + if (balloonEx2.IsVisible()) + { + balloonEx2.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(); + } + } + + #region Fan 横断面 + /// + /// 横断面分析、基线剖面分析、道路断面分析等 + /// + /// + /// + private static EnumTrackPolylineEndMode trackPolylineEndMode; + + void globeControl1_TrackPolylineEndEvent(object sender, TrackPolylineEndEventArgs e) + { + //横断面分析、道路横断面分析 + if (trackPolylineEndMode == EnumTrackPolylineEndMode.HDM_Analysis|| + trackPolylineEndMode == EnumTrackPolylineEndMode.DLDM_Analysis) + { + Dictionary hdmDic = SectionAnalysisTool.HDMAnalysis(this.globeControl1, + e.Polyline, this.m_PipelineLayerNames); + FrmHDMAnalysis3 frm = new FrmHDMAnalysis3(hdmDic, this.globeControl1, + trackPolylineEndMode); + frm.Show(this); + } + //基线剖面分析 + else if (trackPolylineEndMode == EnumTrackPolylineEndMode.JXPM_Analysis) + { + FrmBaseLineProfillAnalysis dlg = new FrmBaseLineProfillAnalysis(globeControl1.Globe, e.Polyline); + dlg.Show(this); + globeControl1.Globe.ClearLastTrackPolyline(); + /* + FrmRoadHDM f = new FrmRoadHDM(); + f.Show() + * **/ + } + else + { + + } + trackPolylineEndMode = EnumTrackPolylineEndMode.Default_Analysis; + /* + ArrayList arraylistPoint = new ArrayList(); + ArrayList arraylistLine = new ArrayList(); + + // globeControl1.Globe.ClearLastTrackPolyline(); + + if (e.Polyline != null) + { + //横断面分析 + if (buttonItemFX2_1.Checked || buttonItemFX2_3.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 (buttonItemFX2_1.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 (buttonItemFX2_4.Checked) + { + FrmBaseLineProfillAnalysis dlg = new FrmBaseLineProfillAnalysis(globeControl1.Globe, e.Polyline); + dlg.Show(this); + globeControl1.Globe.ClearLastTrackPolyline(); + } + else if (buttonItemFX4_3.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(); + * **/ + } + #endregion + + private GSOFeatures PolygonIntersectAnalysis(GSOGeoPolygon3D polygon, string pipelinetype) + { + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(pipelinetype); + 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(pipelinetype, feats.Length); + return feats; + } + /// + /// 根据范围统计阀门、管线、工井等, 开挖分析, 挖方量分析 + /// + /// + /// + void globeControl1_TrackPolygonEndEvent(object sender, TrackPolygonEndEventArgs e) + { + if (globeControl1.Globe.Action == EnumAction3D.TrackPolygon && e.Polygon != null) + { + GSOGeoPolygon3D polygon = e.Polygon; + + switch (trackflag) + { + case "valvequery": + //workWellLen.Clear(); + //List list = new List(); + ////找到所有阀门 + //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, globeControl1, new DataGridViewDelegate(InitDataGridViewX1)); + FrmValveStatistics frm = new FrmValveStatistics(globeControl1,polygon, new DataGridViewDelegate(InitDataGridViewX1)); + frm.Show(this); + //panelEx6.Visible = true; + toolStripFeatureLength.Text = ""; + globeControl1.Globe.Action = EnumAction3D.ActionNull; + break; + + case "PipelineDistanceStatistics": + //pipeLineDis.Clear(); + //List list1 = new List(); + //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, globeControl1, new DataGridViewDelegate(InitDataGridViewX1)); + FrmAllPipelineStatis frm1 = new FrmAllPipelineStatis(globeControl1, polygon, new DataGridViewDelegate(InitDataGridViewX1), m_PipelineLayerNames); + frm1.Show(this); + globeControl1.Globe.Action = EnumAction3D.ActionNull; + + break; + case "PipelineSpatialQuery": + //pipeLineDis.Clear(); + //List list2 = new List(); + //for (int i = 0; i < m_PipelineLayerNames.Count; i++) + //{ + // GSOFeatures fs = Intersects_Pipeline(polygon, m_PipelineLayerNames[i]); + // if (fs != null) + // { + // list2.Add(fs); + // } + //} + + //FrmAllPipelineStatis.ShowForm(1, pipeLineDis, list2, globeControl1, new DataGridViewDelegate(InitDataGridViewX1)); + FrmAllPipelineStatis.ShowForm(globeControl1,polygon,new DataGridViewDelegate(InitDataGridViewX1),m_PipelineLayerNames); + globeControl1.Globe.ClearAnalysis(); + globeControl1.Globe.Action = EnumAction3D.ActionNull; + + break; + case "workwellquery": + //workWellLen.Clear(); + //List listWell = new List(); + ////找到所有井 + //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(polygon, dataGridViewX1, toolStripNumbers, globeControl1, panelOfTable); + FrmAllWorkWellStatis frmWell = new FrmAllWorkWellStatis(globeControl1, polygon, new DataGridViewDelegate(InitDataGridViewX1)); + 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 "BSQDuoBianXiangStatis": + + GSOFeature f2 = new GSOFeature(); + f2.Geometry = e.Polygon; + f2.Geometry.AltitudeMode = EnumAltitudeMode.Absolute; + globeControl1.Globe.MemoryLayer.AddFeature(f2); + f2.Geometry.MoveZ(3); + workWellLen.Clear(); + List listBSQ = new List(); + + GSOFeatures bsqFeatures = PolygonIntersectAnalysis(e.Polygon, "标识器"); + listBSQ.Add(bsqFeatures); + + FrmBSQDuoBianXingStatis bsqFrm = new FrmBSQDuoBianXingStatis(workWellLen, globeControl1, listBSQ); + bsqFrm.Show(this); + globeControl1.Globe.Action = EnumAction3D.ActionNull; + break; + + case "": + break; + default: + break; + } + } + } + + #region 验证端口 + /* + /// + /// 验证端口 + /// + /// + 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 + + /// + /// 鼠标悬浮提示 + /// + /// + /// + 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); + } + } + + /// + /// 添加管线绘制完成事件, 红线工具绘制完成 + /// + /// + /// + 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; + + + } + } + + /// + /// 获取globeControl1中鼠标按下的坐标供区别鼠标右键和滚轮按下事件 + /// + /// + /// + void globeControl1_MouseDown(object sender, MouseEventArgs e) + { + mouseDownX1 = e.X; + mouseDownY1 = e.Y; + } + /// + /// 获取globeControl2中鼠标按下的坐标供区别鼠标右键和滚轮按下事件 + /// + /// + /// + void globeControl2_MouseDown(object sender, MouseEventArgs e) + { + mouseDownX2 = e.X; + mouseDownY2 = e.Y; + } + /// + /// + /// + /// + /// + void globeControl2_MouseClick(object sender, MouseEventArgs e) + { + if (e.Button == MouseButtons.Right) + { + if (e.X == mouseDownX2 && e.Y == mouseDownY2) + { + RightScreenToolMenu.Show(globeControl2, e.X, e.Y); + } + else + { + return; + } + } + } + /// + /// + /// + /// + /// + void globeControl1_MouseClick(object sender, MouseEventArgs e) + { + if (e.Button == MouseButtons.Left) + { + if (globeControl1.Globe.Action == EnumAction3D.VisibilityAnalysis) + { + buttonItemFX5_1.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; + + bsqPT = pt; + + if (buttonItemLS5.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 (e.X == mouseDownX1 && e.Y == mouseDownY1) + { + toolRightMenu.Show(globeControl1, e.X, e.Y); + if (buttonItemLS5.Checked) + { + buttonItemLS5.Checked = false; + } + } + else + { + return; + } + } + globeControl1.Refresh(); + } + + /// + /// 判断网络图片是否存在 + /// + /// + /// + 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; + } + + /// + /// 鼠标点击, 弹出气泡功能globeControl1 + /// + /// + /// + void globeControl1_FeatureMouseClickEvent(object sender, FeatureMouseClickEventArgs e) + { + GSOFeature feature = e.Feature; + + string str1 = ""; + if (feature != null) + { + if (feature.GetFieldDefn("图片编码") != null)// + { + str1 = GetBubbleInfo(feature, globeControl1); + if (RemoteFileExists(Utility.PicRootURL + feature.GetValue("图片编码").ToString())) + { + str1 += ""; + } + else if (RemoteFileExists(Utility.PicDefaultURL)) + { + str1 += ""; + } + } + else if (isFeatureContainsBianhao(feature)) //管线模型图层 + { + str1 = GetBubbleInfo(feature, globeControl1); + } + + 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; + } + } + } + + /// + /// 鼠标点击, 弹出气泡功能globeControl2 + /// + /// + /// + void globeControl2_FeatureMouseClickEvent(object sender, FeatureMouseClickEventArgs e) + { + GSOFeature feature = e.Feature; + + string str1 = ""; + if (feature != null) + { + if (feature.GetFieldDefn("图片编码") != null) // + { + str1 = GetBubbleInfo(feature, globeControl2); + if (RemoteFileExists(Utility.PicRootURL + feature.GetValue("图片编码").ToString())) + { + str1 += ""; + } + else if (RemoteFileExists(Utility.PicDefaultURL)) + { + str1 += ""; + } + } + else if (isFeatureContainsBianhao(feature)) //管线模型图层 + { + str1 = GetBubbleInfo(feature, globeControl2); + } + + if (str1 != "") + { + + featureTooltip2.HideBalloon(); + balloonEx2.HideBalloon(); + balloonEx2.SetSize(EnumSizeIndexEx.CONTENT_CX, 480); + balloonEx2.SetSize(EnumSizeIndexEx.CONTENT_CY, 420); + balloonEx2.ShowBalloon((int)e.MousePos.X, (int)e.MousePos.Y, str1); + + return; + } + } + } + + /// + /// 拼接气泡表格字符串 + /// + /// + /// + private string GetBubbleInfo(GSOFeature feature,GSOGlobeControl globeControl) + { + if (feature == null) + { + return ""; + } + string str = ""; + str = ""; + 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 += ""; + + 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.get_Fields(layerName, globeControl); + } + if (queryFields != null) + { + string[] param = { "," }; + string[] fieldNames = queryFields.Split(param, StringSplitOptions.RemoveEmptyEntries); + for (int j = 0; j < fieldNames.Length; 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 (name1 == "模型路径") + { + continue; + } + 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 (field1.Type == EnumFieldType.Double) + { + double dl1 = feature.GetFieldAsDouble(j); + if (!name1.Contains("管径") && !name1.Contains("电压") && !name1.Contains("角度")) + { + name1 += "_米"; + } + value1 = dl1.ToString("0.00"); + } + 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 (name2 == "模型路径") + { + continue; + } + + 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 (field2.Type == EnumFieldType.Double) + { + double dl2 = feature.GetFieldAsDouble(j + 1); + if (!name2.Contains("管径") && !name2.Contains("电压") && !name2.Contains("角度")) + { + name2 += "_米"; + } + value2 = dl2.ToString("0.00"); + } + else + { + if (!feature.IsFieldValueNull(j + 1)) + { + value2 = feature.GetValue(j + 1).ToString(); + } + } + } + } + + j++; + } + str += ""; + } + } + str += "
" + title + " " + feature.GetFieldAsString(featureIDFieldName) + "
" + + name1 + + "
" + + value1 + + "
" + + name2 + + "
" + + value2 + "
"; + return str; + } + + string filename = Utility.filename; + List g1layername = new List(); + + /// + /// 获取目标图层 + /// + /// + 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; + } + /// + /// 添加图层 + /// + /// + /// + /// + 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 = 5000; + return templayer.Visible; + } + catch (Exception ex) + { + return false; + } + } + /// + /// 菜单上的 三维导航 工具按钮 + /// + /// + /// + private void buttonItem86_Click(object sender, EventArgs e) + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + } + + /// + /// 地上模式 菜单按钮 + /// + /// + /// + 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(); + + } + } + /// + /// 地下模式 菜单按钮 + /// + /// + /// + 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(); + } + } + /// + /// 行走模式 菜单按钮 + /// + /// + /// + 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; + } + } + /// + /// 地面透明度设置 菜单 + /// + /// + /// + private void sliderGroundTransSet1_ValueChanged(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.sliderGroundTransSet1.Text); + + globeControl1.Globe.GroundOpaque = 100 - sliderGroundTransSet1.Value; + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(roadLayerName);//("180fd"); + if (layer != null) + { + layer.Opaque = 100 - sliderGroundTransSet1.Value; + } + //if (buttonItemSPDB.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; + } + /// + /// 图例 菜单按钮 + /// + /// + /// + 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(); + } + /// + /// 快速定位 菜单按钮 + /// + /// + /// + private void buttonItem91_Click(object sender, EventArgs e) // + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItem91.Text); + FrmFlyToPosition fly = new FrmFlyToPosition(globeControl1); + fly.Show(this); + } + /// + /// 图层管理 菜单按钮 + /// + /// + /// + 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; + + //修改图层管理与标注管理、覆土审查、水平净距分析、垂直净距分析和碰撞分析控件之间的逻辑关系 + controlContainerItem5.Visible = false; + sideBar1.Visible = false; + sideBarPanelItem4.Visible = false; + panel3.Visible = false; + sideBar1.ExpandedPanel = sideBarPanelItem3; + buttonItemBZ11.Checked = false; + + //20160624 + /* + if (sideBarPanelItem4.Visible == true) + { + sideBar1.Visible = true; + controlContainerItem5.Visible = true; + } + else + { + sideBar1.Visible = false; + } + */ + Refresh(); + + } + } + /// + /// 全屏显示 菜单按钮 + /// + /// + /// + 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; + /// + /// 全屏显示功能实现 + /// + 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(); + } + } + + /// + /// 设置窗体宽、高 + /// + /// + /// + private void SetFullScreen(int width, int height) + { + this.Width = width; + this.Height = height; + } + + /// + /// 全屏功能的快捷键F5 + /// + /// + /// + 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); + } + } + /* + /// + /// 输出地图 + /// + /// + /// + /// + 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; + } + * */ + + private Point getUpperLeftPoint(Point p1, Point p2, out int mapWidth, out int mapHeight) // + { + Rectangle rc = new Rectangle(); + + p1 = this.globeControl1.PointToScreen(p1); + p2 = this.globeControl1.PointToScreen(p2); + + int x = Screen.PrimaryScreen.Bounds.X; + int y = Screen.PrimaryScreen.Bounds.Y; + int screenWidth = SystemInformation.WorkingArea.Width; + int screenHeight = SystemInformation.WorkingArea.Height; + + if (p1.X < x) + rc.X = x; + else + rc.X = p1.X; + + if (p1.Y < y) + rc.Y = y; + else + rc.Y = p1.Y; + + p1.X = rc.Left; + p1.Y = rc.Top; + + if (p2.X > screenWidth) + p2.X = screenWidth; + else + p2.X = p2.X; + + if (p2.Y > screenHeight) + p2.Y = screenHeight; + else + p2.Y = p2.Y; + + rc.Width = p2.X - rc.X; + rc.Height = p2.Y - rc.Y; + + mapWidth = rc.Width; + mapHeight = rc.Height; + Point pt = new Point(rc.Left, rc.Top); + return pt; + } + + Image printImage; + /// + /// 打印 菜单 + /// + /// + /// + 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))); + */ + int mapWidth = 0; + int mapHeight = 0; + Point pt = getUpperLeftPoint(pt1, pt2, out mapWidth, out mapHeight); + int rightBottomX = pt.X + mapWidth; + int rightBottomY = pt.Y + mapHeight; + Image myImg = new Bitmap(mapWidth, mapHeight); + Graphics g = Graphics.FromImage(myImg); + g.CopyFromScreen(pt, new Point(0, 0), new Size(rightBottomX, rightBottomY)); + + + 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); + } + /// + /// 输出地图 菜单 + /// + /// + /// + private void btnOutputJPG_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btnOutputJPG.Text); + + //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))); + */ + int mapWidth = 0; + int mapHeight = 0; + Point pt = getUpperLeftPoint(pt1, pt2, out mapWidth, out mapHeight); + int rightBottomX = pt.X + mapWidth; + int rightBottomY = pt.Y + mapHeight; + Image myImg = new Bitmap(mapWidth, mapHeight); + Graphics g = Graphics.FromImage(myImg); + g.CopyFromScreen(pt, new Point(0, 0), new Size(rightBottomX, rightBottomY)); + + 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; + } + } + } + + /// + /// 在窗体的底部状态栏上显示 综合管线条件查询结果 + /// + /// + /// + 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 + " 条记录 | "; + } + } + + /// + /// 统计管线的里程数 + /// + /// + /// + /// + 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; + } + + /// + /// 窗体下方属性表格 右键菜单中的 “定位”菜单 + /// + /// + /// + 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); + + } + + /// + /// 表格中右键 “单个闪烁” 菜单 + /// + /// + /// + private void LightMenu_Click(object sender, EventArgs e) + { + flashflag = "single"; + timer1.Start(); + } + /// + /// 表格中右键 “全部闪烁” 菜单 + /// + /// + /// + private void AllLightMenuItem_Click(object sender, EventArgs e) + { + flashflag = "all"; + timer1.Start(); + } + + /// + /// 使用timer实现管线的闪烁效果 + /// + /// + /// + 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; + } + } + + /// + /// 绘制线 菜单 + /// + /// + /// + private void btnAddLine_Click(object sender, EventArgs e) + { + globeControl1.Globe.DestLayerFeatureAdd = globeControl1.Globe.MemoryLayer; + globeControl1.Globe.Action = EnumAction3D.DrawPolyline; + } + /// + /// 绘制面 菜单 + /// + /// + /// + private void btnAddPolygon_Click(object sender, EventArgs e) + { + globeControl1.Globe.DestLayerFeatureAdd = globeControl1.Globe.MemoryLayer; + globeControl1.Globe.Action = EnumAction3D.DrawPolygon; + } + /// + /// 图层目录树 右键菜单中的 目标图层 菜单 + /// + /// + /// + 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; + } + } + /// + /// 图层目录树 右键菜单中的 可选择 菜单 + /// + /// + /// + 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; + } + /// + /// 图层目录树 右键菜单中的 可编辑 菜单 + /// + /// + /// + 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; + } + /// + /// 图层目录树 右键菜单中的 保存 菜单 + /// + /// + /// + 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(); + } + + /// + /// 根据多边形范围统计管线的里程 + /// + /// + /// + /// 返回查询到的管线要素集合 + 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 pipeLineDis = new Dictionary(); + Dictionary workWellLen = new Dictionary(); + + + + + /// + /// 查找指定图层中在 指定范围内的feature对象集合 + /// + /// + /// + /// + 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; + } + /// + /// 清除结果 菜单 + /// + /// + /// + private void buttonItem47_Click(object sender, EventArgs e) + { + globeControl1.Globe.ClearAnalysis(); + dataGridViewX1.DataSource = null; + panelOfTable.Visible = false; + clearFeatureHighLight(); + } + /// + /// 设置菜单的选中状态 + /// + private void ActionToolMenuChecked() + { + if (globeControl1.Globe.Action != EnumAction3D.TrackPolyline) + { + buttonItemFX2_1.Checked = false; + buttonItemFX2_4.Checked = false; + buttonItemFX2_3.Checked = false; + buttonItemFX4_3.Checked = false; + } + if (globeControl1.Globe.Action != EnumAction3D.NormalHit) + { + buttonItemFX3_6.Checked = false; + // ClearConnexityAnalysis(); + + buttonItemFX3_5.Checked = false; + // ClearCloseValvesAnalysis(); + } + if (globeControl1.Globe.Action != EnumAction3D.TrackPolygon) + { + buttonItemFX4_2.Checked = false; + buttonItemFX4_1.Checked = false; + } + } + + /// + /// 主窗体关闭事件处理 + /// + /// + /// + private void MainFrm_FormClosing(object sender, FormClosingEventArgs e) + { + + if (MessageBox.Show("是否退出系统?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) + { + e.Cancel = true; + } + else { + globeControl1.Globe.MemoryLayer.SaveAs(Application.StartupPath + "/MyPlace.kml"); + } + + //saveLayerList(layerManagerNode.Nodes); + //注销id号为103的热键设定 + // UnregisterHotKey(Handle, 103); + } + + /// + /// 显示流向 功能 + /// + /// + /// + /// + 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(); + } + + FrmCloseValves frm; + + FrmBoosterValvers frmbooster = null; + + /// + /// 垂直净距分析 功能界面中的 选择图层复选框 选中状态改变事件处理 + /// + /// + /// + 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(); + } + /// + /// 水平净距分析 功能界面中的 选择图层复选框 选中状态改变事件处理 + /// + /// + /// + 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(); + } + /// + /// 垂直净距分析 功能界面中的 选择管线复选框 选中状态改变事件处理 + /// + /// + /// + private void checkBoxX1_CheckedChanged(object sender, EventArgs e) + { + clearFeatureHighLight(); + if (checkBoxX1.Checked) + { + comboBoxEx1.SelectedItem = null; + 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; + } + } + /// + /// 水平净距分析 功能界面中的 选择管线复选框 选中状态改变事件处理 + /// + /// + /// + private void checkBoxX1_CheckedChanged_shuiping(object sender, EventArgs e) + { + clearFeatureHighLight();//清除高亮 + if (checkBoxX7.Checked) + { + comboBoxEx4.SelectedItem = null; + 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(); + /// + /// 垂直净距分析 功能界面中的 选择图层下拉框 选中项改变 事件处理 + /// + /// + /// + 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; + } + } + } + /// + /// 水平净距分析 功能界面中的 选择图层下拉框 选中项改变 事件处理 + /// + /// + /// + 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 featCount = new Dictionary(); + Dictionary featLenth = new Dictionary(); + Dictionary m_FeaturesWithBianhao = new Dictionary();//记录编号和对应的标注点的位置 + GSOFeatures polygonJingJuAnalysises = new GSOFeatures(); + + /// + /// 垂直净距分析 功能界面中的 开始分析按钮 事件处理 + /// + /// + /// + 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; + } + + /// + /// 在指定的两点组成的线的中间添加一个marker对象,并将marker对象添加到指定的图层中 + /// + /// + /// + /// + /// + /// + 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; + } + + /// + /// 计算指定feature对象与除了该feature所在图层之外的 所有管线图层中的所有feature对象 的垂直距离 并在表格中记录符合要求的管线 + /// + /// + /// + /// + /// + private void VerticalDistanceAnalysis(string type, GSOFeature selectedFeature, List _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(); + } + /// + /// 垂直净距分析中 表格行的 双击定位 功能。 与覆土分析的实现方法不同,主要原因是需要标注垂距 + /// + /// + /// + 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); + } + } + } + } + + /// + /// 水平净距分析 功能界面中 开始分析按钮 的事件处理 + /// + /// + /// + 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; + } + + + /// + /// 计算指定feature对象与除了该feature所在图层之外的 所有管线图层中的所有feature对象 的水平距离 并记录符合要求的管线 功能 + /// + /// + /// + /// + /// + private void HorizontalDistanceAnalysis(GSOFeature selectedFeature, List _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)); + } + } + } + } + } + /// + /// 水平净距分析 功能界面中 表格的 双击定位 功能 + /// + /// + /// + 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); + } + } + } + } + } + /// + /// 碰撞分析 功能界面中 开始分析按钮 事件处理 + /// + /// + /// + 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; + } + /// + /// 碰撞分析功能界面中 表格的 双击定位 功能 + /// + /// + /// + 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); + } + } + } + } + + + + /// + /// 覆土分析功能操作界面中的 选择管线 复选框选中状态改变事件处理 + /// + /// + /// + private void checkBoxX5_CheckedChanged(object sender, EventArgs e) + { + clearFeatureHighLight(); + if (checkBoxX5.Checked) + { + comboBoxEx3.SelectedItem = null; + 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; + } + } + /// + /// 覆土分析功能操作界面中的 选择图层 复选框选中状态改变事件处理 + /// + /// + /// + 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(); + } + /// + /// 覆土分析功能操作界面中的 图层下拉框选中项改变事件处理 + /// + /// + /// + 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; + } + } + } + /// + /// 覆土分析功能操作界面中的 开始分析 按钮事件处理 + /// + /// + /// + 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; + + + GSOPoint3d markerPosition = new GSOPoint3d(); + 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]; + GSOPoint3d pt = new GSOPoint3d(); + + 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"); + + pt.X = pts[m].X; + pt.Y = pts[m].Y; + pt.Z = 0; + markerPosition = LabelVerticalDistance(layerTemp, pts[m], pt, Convert.ToDouble(dataGridViewX7.Rows[idx].Cells[2].Value), true); + 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]; + GSOPoint3d pt = new GSOPoint3d(); + 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"); + + pt.X = pts[m].X; + pt.Y = pts[m].Y; + pt.Z = 0; + markerPosition = LabelVerticalDistance(layerTemp, pts[m], pt, Convert.ToDouble(dataGridViewX7.Rows[idx].Cells[2].Value), true); + + 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; + } + + /// + /// 覆土分析中 表格的 双击定位 功能 + /// + /// + /// + 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); + } + } + } + } + } + /// + /// 覆土分析功能操作界面中的 导出Excel按钮 事件处理 + /// + /// + /// + private void buttonX10_Click(object sender, EventArgs e) + { + if (dataGridViewX7.Rows.Count > 0) + { + ExportExcel("覆土分析", dataGridViewX7, null); + } + else + { + MessageBox.Show("表格内容为空!", "提示"); + } + } + /// + /// 覆土分析功能操作界面底部的 关闭 按钮事件处理 + /// + /// + /// + 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(); + layerTemp.RemoveAllFeature(); + + if (buttonItem1.Checked) + { + sideBar1.ExpandedPanel = sideBarPanelItem3; + } + else + { + sideBar1.Visible = false; + } + globeControl1.Refresh(); + + //Refresh(); + } + + + /// + /// 垂直净距分析 功能界面中 清除分析结果按钮 事件处理 + /// + /// + /// + 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(); + } + /// + /// 水平净距分析 功能界面中 清除分析结果按钮 事件处理 + /// + /// + /// + 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(); + } + + /// + /// 垂直净距分析功能界面中 关闭按钮 事件处理 + /// + /// + /// + 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(); + } + /// + /// 水平净距分析功能界面中 删除缓冲区按钮 事件处理 + /// + /// + /// + private void buttonX14_Click(object sender, EventArgs e) + { + 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(); + } + + /// + /// 导出指定DataGridView控件中的内容 + /// + /// + /// + 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(); + } + } + } + } + + /// + /// 垂直净距分析功能界面中 导出Excel按钮 事件处理 + /// + /// + /// + private void buttonX4_Click(object sender, EventArgs e) + { + if (dataGridViewX3.Rows.Count > 0) + { + ExportExcel("垂直净距分析", dataGridViewX3, listBox1); + } + else + { + MessageBox.Show("表格内容为空!", "提示"); + } + } + /// + /// 水平净距分析功能界面中 导出Excel按钮 事件处理 + /// + /// + /// + private void buttonX4_Click_shuiping(object sender, EventArgs e) + { + if (dataGridViewX9.Rows.Count > 0) + { + ExportExcel("水平净距分析", dataGridViewX9, listBox3); + } + else + { + MessageBox.Show("表格内容为空!", "提示"); + } + } + + + /// + /// 清除所有坑 菜单 + /// + /// + /// + private void buttonItem3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItem3.Text); + + globeControl1.Globe.RemoveAllPits(); + } + + //} + /// + /// 大气层 菜单 + /// + /// + /// + private void buttonItem17_Click_1(object sender, EventArgs e) + { + globeControl1.Globe.Atmosphere.Visible = !globeControl1.Globe.Atmosphere.Visible; + buttonItemSH1.Checked = globeControl1.Globe.Atmosphere.Visible; + globeControl1.Refresh(); + } + /// + /// 经纬网 菜单 + /// + /// + /// + private void buttonItem20_Click(object sender, EventArgs e) + { + globeControl1.Globe.LatLonGrid.Visible = !globeControl1.Globe.LatLonGrid.Visible; + buttonItemSH3.Checked = globeControl1.Globe.LatLonGrid.Visible; + globeControl1.Globe.Refresh(); + } + /// + /// 状态条 菜单 + /// + /// + /// + private void buttonItem21_Click_1(object sender, EventArgs e) + { + globeControl1.Globe.StatusBar.Visible = !globeControl1.Globe.StatusBar.Visible; + buttonItemSH4.Checked = globeControl1.Globe.StatusBar.Visible; + globeControl1.Globe.Refresh(); + } + + + + /// + /// 添加指定路径下的数据 功能 + /// + /// + /// + 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); + //CheckDatasetGeoReference(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; + } + return objRes; + } + /// + /// 刷新目录树 功能 + /// + 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); + } + } + /// + /// 判断图层是否包含字段列表 + /// + /// + /// + 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; + } + + /// + /// 统计指定图层在指定范围内的所有feature对象 + /// + /// + /// + /// + 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; + } + /// + /// 碰撞分析功能界面中 选择管线复选框 选中状态改变事件处理 + /// + /// + /// + private void checkBoxX3_CheckedChanged(object sender, EventArgs e) + { + clearFeatureHighLight(); + if (checkBoxX3.Checked) + { + comboBoxEx2.SelectedItem = null; + 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; + } + } + /// + /// 碰撞分析功能界面中 选择图层复选框 选中状态改变事件处理 + /// + /// + /// + 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(); + } + /// + /// 碰撞分析功能界面中 选择图层下拉框 选中项改变事件处理 + /// + /// + /// + 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; + } + } + } + /// + /// 清除所有图层中的所有feature对象的高亮状态 功能 + /// + 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); + } + } + } + } + for (int i = 0; i < globeControl2.Globe.Layers.Count; i++) + { + GSOLayer layer = globeControl2.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; + } + } + } + + if (globeControl1.Globe.Action == EnumAction3D.SelectObject) + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + //globeControl1.Globe.Action = EnumAction3D.SelectObject; + } + } + + /// + /// 碰撞分析功能界面中 清除分析结果按钮 事件处理 + /// + /// + /// + 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(); + } + /// + /// 碰撞分析功能界面中 导出Excel按钮 事件处理 + /// + /// + /// + private void buttonX6_Click(object sender, EventArgs e) + { + if (dataGridViewX5.Rows.Count > 0) + { + ExportExcel("碰撞分析", dataGridViewX5, listBox2); + } + else + { + MessageBox.Show("表格内容为空!", "提示"); + } + } + /// + /// 导出CAD 菜单 + /// + /// + /// + private void btnExportCAD_Click(object sender, EventArgs e) + { + FrmExportCADS frm = new FrmExportCADS(globeControl1, m_PipelineLayerNames); + frm.ShowDialog(); + } + + ///// + ///// 区域分析 菜单 + ///// + ///// + ///// + //private void buttonItem50_Click(object sender, EventArgs e) + //{ + // buttonItem50.Checked = !buttonItem50.Checked; + // ribbonBarQY.Visible = buttonItem50.Checked; + // ribbonBarQY.Location = new Point(0, 0); + //} + + + /// + /// 连接数据库 菜单事件处理 + /// + /// + /// + 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; + } + } + } + /// + /// 数据验证 菜单 + /// + /// + /// + private void buttonItem80_Click(object sender, EventArgs e) + { + FrmValiData frm = new FrmValiData(globeControl1); + frm.ShowDialog(); + } + /// + /// 根据指定图层创建图层节点并将节点添加到图层管理节点的子节点集合中 + /// + /// + 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; + + if (!layerManagerNode.Nodes.Contains(node)) + { + layerManagerNode.Nodes.Insert(0, node); + layerManagerNode.Expand(); + } + } + } + /// + /// 数据库备份 菜单 + /// + /// + /// + 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(); + } + } + } + + + + #region Fan 去掉 + //GSOFeature emitterFeature; // 粒子要素 + /// + /// 添加火苗 功能 + /// + /// + /// + /// + 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); + + } + /// + /// 添加喷泉 功能 + /// + /// + /// + /// + 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); + } + #endregion + + /// + /// 获取指定图层中最后一个feature对象的名称对应的整数 + /// + /// + /// + 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; + } + /// + /// 设置除指定标注图层之外的所有标注图层不可见 + /// + /// + 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; + } + } + } + } + } + + /// + /// 判断选中的对象是否为管线 + /// + /// 被选中管线 + /// 返回一根线 + 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; + } + + /// + /// 创建label要素 功能 + /// + /// 添加label要素的feature + /// feature的位置 + /// label要素名字 + /// feature名字 + /// label要素距离点的位置 + /// + 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; + } + + + + /// + /// 获取指定两点组成的线的长度 功能 + /// + /// + /// + /// + 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; + } + + /// + /// 图层节点树中 节点 右键单击事件处理 + /// + /// + /// + 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; + } + } + } + } + } + + /// + /// 标注管理、传感器管理 图层目录树的右键菜单中的 刷新列表 菜单 + /// + /// + /// + 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); + } + } + /// + /// 给指定的图层节点添加代表feature对象的子节点 + /// + /// + private void RefreshTreeNodeLayerFeatureList(TreeNode layerTreeNode) + { + layerTreeNode.Nodes.Clear(); + GSOLayer layer = (GSOLayer)layerTreeNode.Tag; + // 只将类型为内存数据集的图层列出,如果是其它类型的数据集可能数据量太大,没发显示在树控件中 + if (layer.Dataset is GSOFeatureDataset) + { + VisitFeature3Ds(layer.GetAllFeatures(), layerTreeNode); + } + } + + /// + /// 标注管理、传感器管理 图层目录树的右键菜单中的 移除所有 菜单 + /// + /// + /// + 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(); + } + } + + /// + /// 图层目录树的 节点对应的复选框选中状态改变事件处理 + /// + /// + /// + private void layerMarkerTree_AfterCheck(object sender, TreeViewEventArgs e) + { + if (e.Action != TreeViewAction.Unknown) + { + CheckTreeNode(e.Node, e.Node.Checked); + } + } + /// + /// 改变指定节点对应的复选框的选中状态 + /// + /// + /// + private void CheckTreeNode(TreeNode node, Boolean bChecked) + { + CheckChildTreeNode(node, bChecked); + globeControl1.Globe.Refresh(); + } + /// + /// 改变指定节点的子节点对应的复选框的选中状态 + /// + /// + /// + 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); + } + } + /// + /// 标注管理、传感器管理 目录树中的feature节点的右键菜单中的 删除 菜单 + /// + /// + /// + 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(); + } + } + + /// + /// 双屏对比 菜单 + /// + /// + /// + //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(); + // } + //} + /// + /// 模拟分析 菜单 + /// + /// + /// + //private void buttonItem51_Click(object sender, EventArgs e) + //{ + // buttonItem51.Checked = !buttonItem51.Checked; + // ribbonBarMN.Visible = buttonItem51.Checked; + // ribbonBarMN.Location = new Point(0, 0); + //} + + /// + /// 双屏设置 菜单 + /// + /// + /// + //private void buttonItem96_Click(object sender, EventArgs e) + //{ + // FrmLayerControl frm = new FrmLayerControl(layerTree,globeControl1,globeControl2); + // frm.Show(this); + //} + /// + /// 双屏联动 菜单 + /// + /// + /// + //private void buttonItem95_Click(object sender, EventArgs e) + //{ + // buttonItem95.Checked = !buttonItem95.Checked; + //} + ///// + /// 添加用户仓库 菜单 + /// + /// + /// + private void buttonItem108_Click(object sender, EventArgs e) + { + FrmUserRepo frm = new FrmUserRepo(-1); + frm.ShowDialog(); + } + /// + /// 用户仓库管理 菜单 + /// + /// + /// + private void buttonItem111_Click(object sender, EventArgs e) + { + FrmUserRepoMgr frm = new FrmUserRepoMgr(); + frm.ShowDialog(); + } + /// + /// 添加分系统 菜单 + /// + /// + /// + private void buttonItem112_Click(object sender, EventArgs e) + { + //FrmAPP frm = new FrmAPP(-1); + //frm.ShowDialog(); + } + /// + /// 分系统管理 菜单 + /// + /// + /// + private void buttonItem113_Click(object sender, EventArgs e) + { + //FrmAPPMgr frm = new FrmAPPMgr(); + //frm.ShowDialog(); + } + /// + /// 添加操作 菜单 + /// + /// + /// + private void buttonItem114_Click(object sender, EventArgs e) + { + FrmOper frm = new FrmOper(-1); + frm.ShowDialog(); + } + /// + /// 操作管理 菜单 + /// + /// + /// + private void buttonItem115_Click(object sender, EventArgs e) + { + FrmOperMgr frm = new FrmOperMgr(); + frm.ShowDialog(); + } + /// + /// 添加资源 菜单 + /// + /// + /// + private void buttonItem116_Click(object sender, EventArgs e) + { + FrmRESC frm = new FrmRESC(-1); + frm.ShowDialog(); + } + /// + /// 资源管理 菜单 + /// + /// + /// + private void buttonItem117_Click(object sender, EventArgs e) + { + FrmRESCMgr frm = new FrmRESCMgr(); + frm.ShowDialog(); + } + /// + /// 添加权限 菜单 + /// + /// + /// + private void buttonItem118_Click(object sender, EventArgs e) + { + FrmPerm frm = new FrmPerm(-1); + frm.ShowDialog(); + } + /// + /// 权限管理 菜单 + /// + /// + /// + private void buttonItem119_Click(object sender, EventArgs e) + { + FrmPermMgr frm = new FrmPermMgr(); + frm.ShowDialog(); + } + /// + /// 添加访问控制 菜单 + /// + /// + /// + private void buttonItem120_Click(object sender, EventArgs e) + { + FrmAccess frm = new FrmAccess(-1); + frm.ShowDialog(); + } + /// + /// 访问控制管理 菜单 + /// + /// + /// + private void buttonItem121_Click(object sender, EventArgs e) + { + FrmAccessMgr frm = new FrmAccessMgr(); + frm.ShowDialog(); + } + /// + /// 部门类型管理 菜单 + /// + /// + /// + private void buttonItem122_Click(object sender, EventArgs e) + { + FrmRegionTypeMgr frm = new FrmRegionTypeMgr(); + frm.ShowDialog(); + } + /// + /// 添加用户 菜单 + /// + /// + /// + private void buttonItem127_Click(object sender, EventArgs e) + { + FrmUserAdd frm = new FrmUserAdd(-1); + frm.ShowDialog(); + } + /// + /// 用户信息管理 菜单 + /// + /// + /// + private void buttonItem128_Click_1(object sender, EventArgs e) + { + FrmUserManager frm = new FrmUserManager(); + frm.ShowDialog(); + } + /// + /// 添加角色 菜单 + /// + /// + /// + private void 添加角色_Click(object sender, EventArgs e) + { + FrmRole frm = new FrmRole(-1); + frm.ShowDialog(); + } + /// + /// 所有角色管理 菜单 + /// + /// + /// + private void 角色管理_Click(object sender, EventArgs e) + { + FrmRoleMgr frm = new FrmRoleMgr(); + frm.ShowDialog(); + } + + /// + /// 部门角色管理 菜单 + /// + /// + /// + private void buttonItem133_Click(object sender, EventArgs e) + { + FrmRegionRoleMgr frm = new FrmRegionRoleMgr(); + frm.ShowDialog(); + } + /// + /// 部门管理 菜单 + /// + /// + /// + private void buttonItem130_Click(object sender, EventArgs e) + { + FrmRegionMgr frm = new FrmRegionMgr(); + frm.ShowDialog(); + } + + /// + /// 日志管理 菜单 + /// + /// + /// + private void buttonItem135_Click(object sender, EventArgs e) + { + FrmLogManager frm = new FrmLogManager(); + frm.ShowDialog(); + } + /// + /// 传感器信息查询 菜单 + /// + /// + /// + 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); + } + } + } + /// + /// 根据指定的图层的caption属性的值在配置文件中查找对应的数据库中的表的名称 + /// + /// 图层的caption属性的值 + /// 对应的数据库中的表的名称 + 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; + } + /// + /// 根据数据库中的表的名称 查找对应的表中的字段名称的集合 + /// + /// 数据库中的表的名称 + /// 对应的表中的字段名称的集合 + 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; + } + + /// + /// 历史曲线查询 菜单 + /// + /// + /// + 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; + /// + /// 传感器在线报警 菜单 + /// + /// + /// + 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); + } + /// + /// 传感器报警 功能中的 定时器 的触发事件处理 + /// + /// + /// + 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; + } + } + } + } + } + } + } + + + /// + /// 沿线运动 菜单 + /// + /// + /// + private void buttonItem138_Click(object sender, EventArgs e) + { + if (globeControl1.Globe.SelectedObject == null) + { + MessageBox.Show("请先选择一条线!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + return; + } + + GSOFeature lineFeature = globeControl1.Globe.SelectedObject; + if (lineFeature.Geometry == null || lineFeature.Geometry.Type != EnumGeometryType.GeoPolyline3D) + { + MessageBox.Show("请先选择一条线!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + return; + } + + OpenFileDialog dlg = new OpenFileDialog(); + dlg.Filter = "*.gcm;*.3ds|*.gcm;*.3ds|*.3ds|*.3ds|*.gcm|*.gcm"; + if (dlg.ShowDialog() == DialogResult.OK) + { + GSOGeoModel model = new GSOGeoModel(); + model.FilePath = dlg.FileName; + + GSOGeoDynamicRoute dynamicRoute = new GSOGeoDynamicRoute(); + dynamicRoute.ActorGeometry = model; + + GSORoute route = new GSORoute(); + GSOGeoPolyline3D geoline = (GSOGeoPolyline3D)lineFeature.Geometry; + for (int i = 0; i < geoline[0].Count; i++) + { + route.Add(geoline[0][i]); + } + route.CircleRoute = false; + route.Speed = 30; + route.RotateSpeed = 50; + route.AltitudeMode = geoline.AltitudeMode; + dynamicRoute.Route = route; + + GSOFeature feature = new GSOFeature(); + + dynamicRoute.Play(); + feature.Geometry = dynamicRoute; + + //GSOLabel gsoLabel = new GSOLabel(); + //gsoLabel.Text = "模型测试"; + //feature.Label = gsoLabel; + globeControl1.Globe.MinModelVisibleSize = 0; + + globeControl1.Globe.MemoryLayer.AddFeature(feature); + globeControl1.Globe.Refresh(); + } + } + /// + /// 回退 菜单 + /// + /// + /// + private void buttonItem99_Click(object sender, EventArgs e) + { + globeControl1.Globe.UnDoEdit(); + } + /// + /// 前进 菜单 + /// + /// + /// + private void buttonItem100_Click(object sender, EventArgs e) + { + globeControl1.Globe.ReDoEdit(); + } + /// + /// 水平净距 功能界面中的 标签内容改变事件处理 + /// + /// + /// + 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() + "米的管线有:"; + } + } + } + /// + /// 垂直净距 功能界面中的 标签内容改变事件处理 + /// + /// + /// + 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() + "米的管线有:"; + } + } + } + /// + /// 覆土分析 功能界面中的 标签内容改变事件处理 + /// + /// + /// + 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() + "米的管线有:"; + } + } + } + + /// + /// 传感器分类查询 全区域 菜单 + /// + /// + /// + private void buttonItemSensor全区域查询_Click(object sender, EventArgs e) + { + FrmAccessoriesSensor.ShowForm(globeControl1, instrumenLayerNames, 0); + } + /// + /// 传感器分类查询 绘制区域 菜单 + /// + /// + /// + private void buttonItemSensor绘制区域查询_Click(object sender, EventArgs e) + { + FrmAccessoriesSensor.ShowForm(globeControl1, instrumenLayerNames, 1); + } + + + /// + /// 碰撞分析 功能界面中 关闭按钮 事件处理 + /// + /// + /// + 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(); + } + /// + /// 覆土分析 功能界面中的 清除分析结果 按钮事件处理 + /// + /// + /// + 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(); + } + /// + /// 数字预处理 功能 + /// + /// + /// + private void 数字预处理buttonItem140_Click(object sender, EventArgs e) + { + FrmEditShapeFile frm = new FrmEditShapeFile(globeControl1); + frm.ShowDialog(this); + } + + + /// + /// 导出矢量 功能 将图层导出为kml和shp格式数据 + /// + /// + /// + private void 导出矢量buttonItem140_Click(object sender, EventArgs e) + { + List listVectorNames = new List(); + for (int i = 0; i < m_PipelineLayerNames.Count; i++) + { + 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 = ""; + /// + /// 绘制城市七线 功能按钮 + /// + /// + /// + 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; + } + } + } + /// + /// 七线审核 功能按钮 + /// + /// + /// + private void 七线审核buttonItem141_Click(object sender, EventArgs e) + { + FrmCityServerLineAnalysis frm = new FrmCityServerLineAnalysis(globeControl1, m_PipelineLayerNames); + frm.ShowDialog(this); + } + + /// + /// 间距分析 开始分析按钮 分析绘制的七线和管线的距离是否符合标准 + /// + /// + /// + 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; + } + /// + /// 间距分析 清除分析结果 + /// + /// + /// + 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(); + } + /// + /// 间距分析 导出Excel按钮 将间距分析的结果以Excel表格的形式导出 + /// + /// + /// + private void buttonExportExcel_Click(object sender, EventArgs e) + { + if (dataGridViewAnalysisResult.Rows.Count > 0) + { + ExportExcel("间距分析", dataGridViewAnalysisResult, listBoxStasticsResult); + } + else + { + MessageBox.Show("表格内容为空!", "提示"); + } + } + /// + /// 间距分析 关闭按钮 + /// + /// + /// + 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(); + } + /// + /// 间距分析 分析结果表格双击定位 + /// + /// + /// + 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); + } + } + } + } + /// + /// 间距分析 选择管线复选框 + /// + /// + /// + private void checkBoxSelectPipeline_CheckedChanged(object sender, EventArgs e) + { + clearFeatureHighLight();//清除高亮 + if (checkBoxSelectPipeline.Checked) + { + comboBoxLayer.SelectedItem = null; + 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; + } + } + /// + /// 间距分析 选择图层复选框 + /// + /// + /// + 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(); + } + /// + /// 间距分析 选择图层下拉框 + /// + /// + /// + 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; + } + } + } + + + + /// + /// 管线自动缩进 菜单 + /// + /// + /// + private void 管线自动缩进buttonItem140_Click(object sender, EventArgs e) + { + FrmPipelineIndented frm = new FrmPipelineIndented(globeControl1, m_PipelineLayerNames, workwellLayerNames); + 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 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); + // } + //} + + /// + /// 统计指定图层在指定范围内的所有feature对象 + /// + /// + /// + /// + 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) + { + 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 setLayerVisible(string layerName) + { + GSOLayer templayer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + if (templayer != null) + { + templayer.Visible = false; + } + globeControl1.Globe.Refresh(); + } + + /// + /// 连接数据库 + /// + /// + /// + private void buttonItem129_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL4_1.Text); + + FrmDatabaseParaSetting2 frm = new FrmDatabaseParaSetting2(globeControl1); + if (frm.ShowDialog() == DialogResult.OK) + { + ds = FrmDatabaseParaSetting2.ds; + if (ds != null) + { + ds.IsCloseSaved = false; + } + } + } + + /// + /// 一键审核---导入数据 + /// + /// + /// + private void buttonItem127_Click_2(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, "打开数据"); + + try + { + //if (shds == null) + //{ + //没连的话,直接连接审核库; //审核库配置读配置文件 + string dbIp = Utility.sgdbip; + string database = Utility.sgdbname; + string user = Utility.sgdbuser; + string pass = Utility.sgdbpwd; + /* + 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; + //} + } + catch (Exception ex) + { + LogError.PublishError(ex); + MessageBox.Show("内存过载请清理内存,并重新启动规划分析!", "提示"); + return; + } + + } + + /// + ///自动导出图片 + /// + /// + /// + private void buttonItem130_Click_1(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, "导出审核图"); + + 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))); + */ + + int mapWidth = 0; + int mapHeight = 0; + Point pt = getUpperLeftPoint(pt1, pt2, out mapWidth, out mapHeight); + int rightBottomX = pt.X + mapWidth; + int rightBottomY = pt.Y + mapHeight; + Image myImg = new Bitmap(mapWidth, mapHeight); + Graphics g = Graphics.FromImage(myImg); + g.CopyFromScreen(pt, new Point(0, 0), new Size(rightBottomX, rightBottomY)); + + 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; + } + } + } + /// + /// 一键审核功能 + ///
+ /// + /// + private void buttonItem128_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItem128.Text); + //垂直净距标准 + + frmSh = new FrmYJSHTC(globeControl1, globeControl2,layerTree); + + if (frmSh.ShowDialog() == DialogResult.OK) + { + frmWait = new FrmWait("一键审核……"); + frmWait.Location = new Point(this.Width - frmWait.Width - 10, this.Height - frmWait.Height - 50); + frmWait.Owner = this; + frmWait.Show(); + Thread thread = new Thread(new ThreadStart(doWork)); + thread.IsBackground = true; + thread.Start(); + } + } + + void doWork() + { + FrmShResult frmShResult = null; + + double dVerticalJingJuBiaoZhun = 1, dHorizontalJingJuBiaoZhun = 1; + if (frmSh.rukuLayer != null) + { + #region + this.Invoke((EventHandler)delegate + { + try + { + List managerLayerList = new List(); + for (int i = 0; i < layerManagerNode.Nodes.Count; i++) + { + managerLayerList.Add(layerManagerNode.Nodes[i].Text); + } + if (!managerLayerList.Contains(frmSh.rukuLayer.Caption)) + { + TreeNode node = new TreeNode(); + node.Tag = frmSh.rukuLayer; + node.Text = frmSh.rukuLayer.Dataset.Caption; + node.ImageIndex = 0; + node.SelectedImageIndex = 0; + node.Checked = frmSh.rukuLayer.Visible; + layerManagerNode.Nodes.Insert(0, node); + layerManagerNode.Expand(); + } + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "提示"); + } + }); + #endregion + + shlayername = frmSh.rukuLayer.Name; + globeControl1.Refresh(); + } + + if (frmShResult != null && !frmShResult.IsDisposed) + { + try + { + clearFeatureHighLight(); + ClearRedlineAnalyseResult(); + frmShResult.Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message); + } + } + + 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.analysis(); + + //MainFrm窗体显示控制,回到一键审核Tab + this.Invoke((EventHandler)delegate + { + frmShResult.Show(); + frmWait.Close(); + //将tab页恢复到一键审核 + ribbonTabItem11.Checked = true; + try + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + //zhanshi = false; + splitContainer1.Panel2Collapsed = true; + + panelOfTable.Visible = false; + legendSC.Visible = false; + legendSG.Visible = false; + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + } + catch (Exception ex) + { + MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + + }); + + boolfrmShResult = true; + } + else + { + + } + } + + + /// + /// 清除渲染结果 + /// + 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(); + } + /// + /// 已审核的图层 + /// + /// + /// + private void buttonItem132_Click_1(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItem132.Text); + + if (shds == null) + { + //没连的话,直接连接审核库; //审核库配置读配置文件 + string dbIp = Utility.sgdbip; + string database = Utility.sgdbname; + string user = Utility.sgdbuser; + string pass = Utility.sgdbpwd; + + /* + 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; + //} + + } + /// + /// 审核入库 + /// + /// + /// + private void buttonItem133_Click_1(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, "审核入库"); + FrmShRK frmShrk = new FrmShRK(globeControl1); + frmShrk.Show(); + } + /// + /// 模拟设计修改 + /// + /// + /// + private void buttonItem134_Click_1(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, "模拟设计修改"); + + 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 + { + + } + + } + + + /// + /// 绘制垂线 + /// + /// + /// + 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); + } + /// + /// 比较两个点是否是同一个点 + /// + /// + /// + /// + 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; + } + /// + /// 获得点到线的垂线距离及垂点 + /// + /// + /// + /// + /// + 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); + 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]; + } + /// + /// 获得斜率 + /// + /// + /// + /// + /// + /// + /// + 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); + } + } + /// + /// 根据默认投影参数,经纬度转xyz + /// + /// + /// + /// + 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; + } + /// + /// 根据投影参数,经纬度转xyz + /// + /// + /// + /// + /// + 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; + } + /// + /// 根据默认投影参数,xyz转经纬度 + /// + /// + /// + /// + 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; + } + /// + /// 根据投影参数,Xyz转经纬度 + /// + /// + /// + /// + /// + 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; + } + /// + /// 获得inpolygon的管线长度 + /// + /// + 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; + } + + + /// + /// 一键审核中调节透明度 + /// + /// + /// + private void sliderItem1_ValueChanged(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.sliderItem1.Text); + + globeControl1.Globe.GroundOpaque = 100 - sliderItem1.Value; + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(roadLayerName);//("180fd"); + if (layer != null) + { + layer.Opaque = 100 - sliderItem1.Value; + } + + optiValue = sliderItem1.Value; + } + /// + /// 红线审核中的透明度分析 + /// + /// + /// + private void sliderItem3_ValueChanged(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.sliderItem3.Text); + + globeControl1.Globe.GroundOpaque = 100 - sliderItem3.Value; + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(roadLayerName);//("180fd"); + if (layer != null) + { + layer.Opaque = 100 - sliderItem3.Value; + } + optiValue = sliderItem3.Value; + } + + #region yanxiaowei + //初始化DataGridViewX1控件 + public delegate void DataGridViewDelegate(DataTable dt, string strLable, string strLayer, bool initDataGrid); + /// + /// 代理函数,操作DatgridViewX1 + /// + /// + /// + public void InitDataGridViewX1(DataTable dt, string strLable, string strLayer, bool initDataGrid) + { + if (initDataGrid == true) + { + dataGridViewX1.DataSource = dt; + panelOfTable.Visible = true; + toolStripNumbers.Text = strLable; + dataGridViewX1.Tag = strLayer; + } + else + { + dataGridViewX1.DataSource = null; + dataGridViewX1.Refresh(); + panelOfTable.Visible = false; + toolStripNumbers.Text = ""; + dataGridViewX1.Tag = ""; + globeControl1.Globe.MemoryLayer.RemoveAllFeature();//清除双击产生的标注 + } + } + FrmAnalysisGuiHuaResult from; + /// + /// 主窗体下方属性表格 双击定位 功能 + /// + /// + /// + private void dataGridViewX1_MouseDoubleClick(object sender, MouseEventArgs e) + { + if (redSH == false) + { + 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 if (dataGridViewX1.Columns.Contains("标识器编号")) + { + featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["标识器编号"].Value.ToString(); + } + featureName = featureName.Trim(); + + GSOLayer layer = null; + layer = globeControl1.Globe.Layers.GetLayerByCaption(dataGridViewX1.Tag.ToString()); + + if (layer == null) return; + + GSOFeatures features = layer.GetFeatureByName(featureName, false); + if (features.Length == 0) return; + GSOFeature rowFeature = features[0]; + + ClassSearchAnalysis.AddMakerToLineFeature(globeControl1, rowFeature); + + } + } + } + else + { + if (e.Button == MouseButtons.Left) + { + if (from != null && !from.IsDisposed) + { + try + { + from.Close(); + } + catch (Exception ex) + { + LogError.PublishError(ex); + } + } + try + { + DataGridView.HitTestInfo hittestinfo = dataGridViewX1.HitTest(e.X, e.Y); + if (hittestinfo.RowIndex >= 0) + { + string layer = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["管线类型"].Value.ToString(); + string hxName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["红线编号"].Value.ToString(); + FrmAnalysisGuiHuaResult frm = new FrmAnalysisGuiHuaResult(globeControl1, lineStruct, featsList, + panelOfTable, dataGridViewX1, layer, hxName); + frm.Location = new Point(this.Width - frm.Width - 10, this.Height - frm.Height - 20); + frm.Show(this); + + from = frm; + } + } + catch (Exception ex) + { + LogError.PublishError(ex); + } + } + } + } + + /// + /// 空间查询 + /// + /// + /// + private void buttonItemSearch1_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemSearch1.Text); + + trackflag = "PipelineSpatialQuery"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; + + } + /// + /// 关键字查询 + /// + /// + /// + private void buttonItemSearch9_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch9.Text); + + FrmKeywordQuery.ShowForm(globeControl1, m_PipelineLayerNames, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 编号查询 + /// + /// + /// + private void buttonItemSearch2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch2.Text); + + FrmCodingQuery.ShowForm(globeControl1, m_PipelineLayerNames, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 坐标查询 + /// + /// + /// + private void buttonItemSearch3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch3.Text); + + FrmSetLatLonPos.ShowForm(globeControl1); + } + /// + /// 附属物查询 + /// + /// + /// + private void buttonItemSearch10_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch10.Text); + + FrmFittingQuery.ShowForm(globeControl1, instrumenLayerNames, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 管径查询 + /// + /// + /// + private void buttonItemSearch4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch4.Text); + + FrmDiameterQuery.ShowForm(globeControl1, m_PipelineLayerNames, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 材质查询 + /// + /// + /// + private void buttonItemSearch5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch5.Text); + + FrmMaterialSel.ShowForm(globeControl1, m_PipelineLayerNames, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 基本查询 + /// + /// + /// + private void buttonItemSearch6_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch6.Text); + + FrmBasicQuery.ShowForm(globeControl1, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 复合查询 + /// + /// + /// + private void buttonItemSearch7_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch7.Text); + + FrmQuerySQL.ShowForm(globeControl1, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 关联查询 + /// + /// + /// + private void buttonItemSearch8_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch8.Text); + + if (globeControl1.Globe.SelObjectCount != 1) + { + MessageBox.Show("请选中一个对象!", "提示"); + return; + } + + 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 || (feature.Geometry.Type == EnumGeometryType.GeoPolygon3D + || feature.Geometry.Type == EnumGeometryType.GeoWater)) + return; + else + { + ClassSearchAnalysis.ResultRelationAnalysis(globeControl1, feature, valueLayerNames, workwellLayerNames, + instrumenLayerNames, pipefittingLayerNames, m_PipelineLayerNames, valueAllowance); + } + } + } + #endregion + /// + /// 清除分析 + /// + /// + /// + private void buttonItemClear_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemClear.Text); + + globeControl1.Globe.ClearMeasure(); + layerTemp.RemoveAllFeature(); + layerTemp2.RemoveAllFeature(); + buttonItemLS5.Checked = false; + + dataGridViewX1.DataSource = null; + panelOfTable.Visible = false; + + 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); + + NetworkAnalysisTool.ClearAllTopAnalysis(this.globeControl1); + // 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();//清除所有坑 + + 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(); + } + } + + clearFeatureHighLight();//取消管线高亮 + + GSOLayer layerGround = globeControl1.Globe.Layers.GetLayerByCaption(roadLayerName);//("180fd"); + if (layerGround != null) + { + layerGround.Visible = true; + } + globeControl1.Refresh(); + globeControl2.Refresh(); + ClearRedlineAnalyseResult(); + globeControl1.Globe.Action = EnumAction3D.ActionNull; + } + /// + /// 管线长度全区域统计 + /// + /// + /// + private void buttonItemTJ1_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管线长度统计"); + + //pipeLineDis.Clear(); + //List list = new List(); + //for (int i = 0; i < m_PipelineLayerNames.Count; i++) + //{ + // GSOFeatures fs = Intersects_Pipeline(null, m_PipelineLayerNames[i]); + // if (fs!=null) + // list.Add(fs); + //} + + //FrmAllPipelineStatis frm = new FrmAllPipelineStatis(0, pipeLineDis, list, globeControl1, new DataGridViewDelegate(InitDataGridViewX1)); + FrmAllPipelineStatis frm = new FrmAllPipelineStatis(globeControl1,null, new DataGridViewDelegate(InitDataGridViewX1), m_PipelineLayerNames); + frm.Show(this); + + } + /// + /// 管线长度绘制区域统计 + /// + /// + /// + private void buttonItemTJ1_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管线长度统计"); + + trackflag = "PipelineDistanceStatistics"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; + } + /// + /// 阀门数量全区域统计 + /// + /// + /// + private void buttonItemTJ2_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "阀门数量统计"); + + //workWellLen.Clear(); + //List list = new List(); + ////找到所有阀门 + //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, globeControl1, new DataGridViewDelegate(InitDataGridViewX1)); + FrmValveStatistics frm = new FrmValveStatistics(globeControl1, null, new DataGridViewDelegate(InitDataGridViewX1)); + frm.Show(this); + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + } + /// + /// 阀门数量绘制区域统计 + /// + /// + /// + private void buttonItemTJ2_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "阀门数量统计"); + + trackflag = "valvequery"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; + } + /// + /// 井盖数量全区域统计 + /// + /// + /// + private void buttonItemTJ3_ALL_Click(object sender, EventArgs e) + { + //日志记录 + //LogManager.saveLog(Utility.userName, "井盖数量统计"); + + //workWellLen.Clear(); + //List list = new List(); + + //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(null, dataGridViewX1, toolStripNumbers, globeControl1, panelOfTable); + FrmAllWorkWellStatis frm = new FrmAllWorkWellStatis(globeControl1, null, new DataGridViewDelegate(InitDataGridViewX1)); + frm.Show(this); + } + /// + /// 井盖数量绘制区域统计 + /// + /// + /// + private void buttonItemTJ3_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "井盖数量统计"); + + trackflag = "workwellquery"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; + } + /// + /// 管径分段统计全区域统计 + /// + /// + /// + private void buttonItemTJ4_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管径分段统计"); + + Frmpipediameterstatis.ShowForm(globeControl1, m_PipelineLayerNames, 0); + } + /// + /// 管径分段统计绘制区域统计 + /// + /// + /// + private void buttonItemTJ4_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管径分段统计"); + + trackflag = null; + Frmpipediameterstatis.ShowForm(globeControl1, m_PipelineLayerNames, 1); + } + /// + /// 埋深分段统计全区域统计 + /// + /// + /// + private void buttonItemTJ5_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "埋深分段统计"); + FrmpipeDeepstatis.ShowForm(globeControl1, m_PipelineLayerNames, 0); + } + /// + /// 埋深分段统计绘制区域统计 + /// + /// + /// + private void buttonItemTJ5_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "埋深分段统计"); + trackflag = null; + FrmpipeDeepstatis.ShowForm(globeControl1, m_PipelineLayerNames, 1); + } + /// + /// 管径分类统计全区域统计 + /// + /// + /// + private void buttonItemTJ6_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管径分类汇总"); + + FrmpipeDiametergather.ShowForm(globeControl1, m_PipelineLayerNames, 0); + } + /// + /// 管径分类统计绘制区域统计 + /// + /// + /// + private void buttonItemTJ6_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管径分类汇总"); + + trackflag = null; + FrmpipeDiametergather.ShowForm(globeControl1, m_PipelineLayerNames, 1); + } + /// + /// 材质分类统计全区域统计 + /// + /// + /// + private void buttonItemTJ7_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "材质分类汇总"); + + FrmpipeMaterialGather.ShowForm(globeControl1, m_PipelineLayerNames, 0); + } + /// + /// 材质分类统计绘制区域统计 + /// + /// + /// + private void buttonItemTJ7_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "材质分类汇总"); + + trackflag = null; + FrmpipeMaterialGather.ShowForm(globeControl1, m_PipelineLayerNames, 1); + } + /// + /// 附属物分类统计全区域统计 + /// + /// + /// + private void buttonItemTJ8_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "附属物分类汇总"); + + FrmAccessoriesgather.ShowForm(globeControl1, instrumenLayerNames, 0); + } + /// + /// 附属物分类统计绘制区域统计 + /// + /// + /// + private void buttonItemTJ8_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "附属物分类汇总"); + + trackflag = null; + FrmAccessoriesgather.ShowForm(globeControl1, instrumenLayerNames, 1); + } + /// + /// 碰撞分析 + /// + /// + /// + private void buttonItemFX1_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_4.Text); + + this.dataGridViewX4.Size = new System.Drawing.Size(195, 120); + 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(); + } + /// + /// 覆土分析 + /// + /// + /// + private void buttonItemFX1_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX5_1.Text); + this.dataGridViewX6.Size = new System.Drawing.Size(195, 120); + 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(); + } + /// + /// 间距分析 + /// + /// + /// + private void buttonItemFX1_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX1_3.Text); + + this.dataGridViewLineList.Size = new System.Drawing.Size(185, 120); + 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(); + } + /// + /// 垂直净距分析 + /// + /// + /// + private void buttonItemFX1_4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX1_4.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(); + } + /// + /// 水平净距分析 + /// + /// + /// + private void buttonItemFX1_5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_6.Text); + this.dataGridViewX8.Size = new System.Drawing.Size(185, 120); + 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(); + } + + #region Predaotr,断面分析 + /// + /// 横断面分析 + /// + /// + /// + private void buttonItemFX2_1_Click(object sender, EventArgs e) + { + globeControl1.Globe.Action = EnumAction3D.TrackPolyline; + globeControl1.Globe.TrackPolylineTool.VerticalLineVisible = true; + globeControl1.Globe.TrackPolylineTool.TrackMode = EnumTrackMode.SpaceTrack; + trackPolylineEndMode = EnumTrackPolylineEndMode.HDM_Analysis; + + } + /// + /// 纵断面分析 + /// + /// + /// + private void buttonItemFX2_2_Click(object sender, EventArgs e) + { + if (globeControl1.Globe.SelObjectCount<1) + { + MessageBox.Show("请选择一条或者多条管线!", "提示", MessageBoxButtons.OK, + MessageBoxIcon.Information); + return; + } + 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); + } + } + List feats = SectionAnalysisTool.ZDMAnalysis(selectFeatures); + if (feats != null && feats.Count >= 1) + { + FrmProfileAnalysis frm = new FrmProfileAnalysis(globeControl1, feats); + frm.Show(this); + } + } + /// + /// 道路断面分析 + /// + /// + /// + private void buttonItemFX2_3_Click(object sender, EventArgs e) + { + globeControl1.Globe.Action = EnumAction3D.TrackPolyline; + globeControl1.Globe.TrackPolylineTool.VerticalLineVisible = true; + globeControl1.Globe.TrackPolylineTool.TrackMode = EnumTrackMode.SpaceTrack; + trackPolylineEndMode = EnumTrackPolylineEndMode.DLDM_Analysis; + + } + /// + /// 基线剖面分析 + /// + /// + /// + private void buttonItemFX2_4_Click(object sender, EventArgs e) + { + globeControl1.Globe.Action = EnumAction3D.TrackPolyline; + globeControl1.Globe.TrackPolylineTool.VerticalLineVisible = true; + globeControl1.Globe.TrackPolylineTool.TrackMode = EnumTrackMode.SpaceTrack; + trackPolylineEndMode = EnumTrackPolylineEndMode.JXPM_Analysis; + + } + + #endregion + /// + /// 创建拓扑 + /// + /// + /// + private void buttonItemFX3_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX3_1.Text); + + FrmGenAndFaMenTopu frm = new FrmGenAndFaMenTopu(globeControl1, m_PipelineLayerNames, valueLayerNames); + frm.Show(this); + } + #region Predator :拓扑分析 + /// + /// 上游分析 + /// + /// + /// + private void buttonItemFX3_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX3_2.Text); + NetworkTraceUpDown(true); + } + /// + /// 下游分析 + /// + /// + /// + private void buttonItemFX3_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX3_3.Text); + NetworkTraceUpDown(false); + } + + /// + /// 上下游追踪 功能 + /// + /// + private void NetworkTraceUpDown(Boolean bTraceUp) + { + GSOFeature selLineFeature = globeControl1.Globe.SelectedObject; + if (selLineFeature == null || selLineFeature.Geometry == null || selLineFeature.Geometry.Type != EnumGeometryType.GeoPolyline3D) + { + MessageBox.Show("请点击“编辑”—“选中对象”选择一条线!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); + return; + } + GSOLayer selLayer = globeControl1.Globe.SelectedObjectLayer; + + NetworkAnalysisTool.TraceUpDownAnalysis(bTraceUp, + selLineFeature, selLayer); + } + + /// + /// 流向分析 + /// + /// + /// + private void buttonItemFX3_4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX3_4.Text); + + FrmFlow frm = new FrmFlow(globeControl1, m_PipelineLayerNames); + frm.Show(this); + } + /// + /// 关阀分析 + /// + /// + /// + private void buttonItemFX3_5_Click(object sender, EventArgs e) + { + if (globeControl1.Globe.SelObjectCount < 1) + { + MessageBox.Show("请选中至少一根管线!!"); + buttonItemFX3_5.Checked = false; + return; + } + GSOLayer resLayer = null; + GSOFeature resFeature = null; + globeControl1.Globe.GetSelectObject(0, out resFeature, out resLayer); + + String pipeLayerName = resLayer.Caption; + String pipeLayerNamePrefix = pipeLayerName.Substring(0, pipeLayerName.IndexOf("管线")); + GSOLayer valveLayer = globeControl1.Globe.Layers[pipeLayerNamePrefix + "阀门"]; + if (valveLayer == null) + { + MessageBox.Show("无" + pipeLayerNamePrefix+"阀门图层", "提示"); + return; + } + + GSOFeatures valveFeats = NetworkAnalysisTool.CloseValvesAnalysis(resFeature, + resLayer, valveLayer); + + if (valveFeats != null) + { + FrmCloseValves frm = new FrmCloseValves(this.globeControl1, valveFeats); + frm.Show(this); + } + else + { + MessageBox.Show("未找到关闭阀门"); + } + } + + /// + /// 连通分析 + /// + /// + /// + private void buttonItemFX3_6_Click(object sender, EventArgs e) + { + if (globeControl1.Globe.SelObjectCount < 2) + { + MessageBox.Show("请选中至少两个管线!!"); + buttonItemFX3_6.Checked = false; + return; + } + GSOFeature selFeat0, selFeat1; + GSOLayer layer0,layer1; + globeControl1.Globe.GetSelectObject(0, out selFeat0, out layer0); + globeControl1.Globe.GetSelectObject(1, out selFeat1, out layer1); + + if (!layer0.IsSameInnerObject(layer1)) + { + MessageBox.Show("不在同一个图层!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); + buttonItemFX3_6.Checked = false; + return; + } + NetworkAnalysisTool.ConnexityAnalysis(selFeat0, selFeat1, layer0); + } + /// + /// 爆管分析 + /// + /// + /// + private void buttonItemFX3_7_Click(object sender, EventArgs e) + { + NetworkTraceUpDown(true); //上游追踪: + + GSOFeature selLineFeature = globeControl1.Globe.SelectedObject; + if (selLineFeature == null || selLineFeature.Geometry == null || selLineFeature.Geometry.Type != EnumGeometryType.GeoPolyline3D) + { + MessageBox.Show("请点击“编辑”—“选中对象”选择一条线!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); + return; + } + GSOLayer selLayer = globeControl1.Globe.SelectedObjectLayer; + + NetworkAnalysisTool.ExplodeAnalysis(this.globeControl1,selLineFeature,selLayer); + + this.buttonItemFX3_5_Click(sender, e); //关阀分析: + + } + + #endregion + /// + /// 多边形开挖 + /// + /// + /// + private void buttonItemFX4_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_1.Text); + + trackflag = "pit"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; //是这个么?是的,在模型上 + } + /// + /// 挖方量分析 + /// + /// + /// + private void buttonItemFX4_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_2.Text); + + trackflag = "digFillAnalysis"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; + ActionToolMenuChecked(); + } + /// + /// 沿线开挖 + /// + /// + /// + private void buttonItemFX4_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_3.Text); + + if (!buttonItemFX4_3.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; + buttonItemFX4_3.Checked = true; + } + } + else + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + buttonItemFX4_3.Checked = false; + globeControl1.Globe.TrackPolylineTool.VerticalLineVisible = false; + } + ActionToolMenuChecked(); + } + /// + /// 创建隧道 + /// + /// + /// + private void buttonItemFX4_4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_4.Text); + + 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("场景中未加载隧道图层!", "提示"); + } + } + /// + /// 隐藏隧道 + /// + /// + /// + private void buttonItemFX4_5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_5.Text); + + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption("隧道"); + if (layer != null) + { + layer.Visible = !layer.Visible; + } + } + /// + /// 删除隧道 + /// + /// + /// + private void buttonItemFX4_6_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_6.Text); + + 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("请选中要删除的隧道!", "提示"); + } + } + /// + /// 通视分析 + /// + /// + /// + private void buttonItemFX5_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX5_1.Text); + + if (globeControl1.Globe.Action != EnumAction3D.VisibilityAnalysis) + { + //btnSpaceVisibilityAnalysis.Checked = true; + globeControl1.Globe.Action = EnumAction3D.VisibilityAnalysis; + } + else + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + // SetButtonChecked(); + } + } + /// + /// 可视域分析 + /// + /// + /// + private void buttonItemFX5_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX5_2.Text); + + globeControl1.Globe.Action = EnumAction3D.ViewshedAnalysis; + } + /// + /// 可视包络分析 + /// + /// + /// + private void buttonItemFX5_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX5_3.Text); + + globeControl1.Globe.Action = EnumAction3D.ViewEnvelopeAnalysis; + } + /// + /// 缓冲区分析 + /// + /// + /// + private void buttonItemFX6_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX6_1.Text); + + GSOFeature feat = globeControl1.Globe.SelectedObject; + if (feat == null) + { + MessageBox.Show("请选择要分析的要素!"); + return; + } + if (feat.Geometry.Type == EnumGeometryType.GeoPolyline3D) + { + GSOGeoPolyline3D line1 = feat.Geometry as GSOGeoPolyline3D; + if (line1 == null) + { + MessageBox.Show("请选择一条管线!"); + return; + } + + FrmBufferAnalysis frm = new FrmBufferAnalysis(globeControl1, line1, layerTemp); + frm.Show(this); + } + else + { + FrmBufferAnalysisBSQ frm = new FrmBufferAnalysisBSQ(globeControl1, layerTemp, bsqPT); + frm.Show(this); + } + + } + /// + /// 附属物分析 + /// + /// + /// + private void buttonItemFX6_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX6_2.Text); + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + FrmAccessoryAnalysis dlg = new FrmAccessoryAnalysis(globeControl1, layerTemp); + dlg.Show(this); + } + /// + /// 无源淹没分析 + /// + /// + /// + private void buttonItemFX6_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX6_3.Text); + + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + trackflag = "FloodAnalysis"; + } + /// + /// 水平距离 + /// + /// + /// + private void buttonItemLS1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS1.Text); + + globeControl1.Globe.Action = EnumAction3D.MeasureDistance; + globeControl1.Globe.DistanceRuler.SpaceMeasure = false; + buttonItemLS5.Checked = false; + } + /// + /// 垂直距离 + /// + /// + /// + private void buttonItemLS2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS2.Text); + + buttonItemLS5.Checked = false; + globeControl1.Globe.Action = EnumAction3D.MeasureHeight; + globeControl1.Globe.DistanceRuler.SpaceMeasure = false; + } + /// + /// 空间距离 + /// + /// + /// + private void buttonItemLS3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS3.Text); + + buttonItemLS5.Checked = false; + globeControl1.Globe.Action = EnumAction3D.MeasureDistance; + globeControl1.Globe.DistanceRuler.SpaceMeasure = true; + } + /// + /// 地表距离 + /// + /// + /// + private void buttonItemLS4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS4.Text); + + buttonItemLS5.Checked = false; + globeControl1.Globe.Action = EnumAction3D.MeasureDistance; + globeControl1.Globe.DistanceRuler.SpaceMeasure = false; + } + /// + /// 高度量算 + /// + /// + /// + private void buttonItemLS5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS5.Text); + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + buttonItemLS5.Checked = !buttonItemLS5.Checked; + if (buttonItemLS5.Checked) + { + globeControl1.Globe.Action = EnumAction3D.SelectObject; + } + } + /// + /// 水平面积 + /// + /// + /// + private void buttonItemLS6_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS6.Text); + + buttonItemLS5.Checked = false; + globeControl1.Globe.Action = EnumAction3D.MeasureArea; + globeControl1.Globe.AreaRuler.SpaceMeasure = true; + } + /// + /// 地表面积 + /// + /// + /// + private void buttonItemLS7_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS7.Text); + + buttonItemLS5.Checked = false; + globeControl1.Globe.Action = EnumAction3D.MeasureArea; + globeControl1.Globe.AreaRuler.SpaceMeasure = false; + + } + + # region Fan 重构标注代码 + /// + /// 标高标注 + /// + /// + /// + private void buttonItemSZ1_Click(object sender, EventArgs e) + { + GSOFeature resFeature = IsPipeLineOfSelectedObj(); + if (resFeature == null) + { + MessageBox.Show("请选中一根管线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + GSOGeoPolyline3D selLine = resFeature.Geometry as GSOGeoPolyline3D; + if (selLine[0].Count <= 1) + { + return; + } + + MarkTools.getInstance().showMarker(resFeature, + globeControl1, EnumMarkLayer.Mark_Altitude, ""); + } + /// + /// 管径标注 + /// + GSOFeature radiusMarkerFeature; + private void buttonItemBZ2_Click(object sender, EventArgs e) + { + GSOFeature resFeature = IsPipeLineOfSelectedObj(); + if (resFeature == null) + { + MessageBox.Show("请选中一根管线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + GSOGeoPolyline3D selLine = resFeature.Geometry as GSOGeoPolyline3D; + if (selLine[0].Count <= 1) + { + return; + } + + MarkTools.getInstance().showMarker(resFeature, + globeControl1, EnumMarkLayer.Mark_Diameter, ""); + } + /// + /// 埋深标注 + /// + /// + /// + private void buttonItemBZ3_Click(object sender, EventArgs e) + { + GSOFeature resFeature = IsPipeLineOfSelectedObj(); + if (resFeature == null) + { + MessageBox.Show("请选中一根管线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + GSOGeoPolyline3D selLine = resFeature.Geometry as GSOGeoPolyline3D; + if (selLine[0].Count <=1) + { + return; + } + + MarkTools.getInstance().showMarker(resFeature, + globeControl1, EnumMarkLayer.Mark_Depth, ""); + + } + /// + /// 坐标标注 + /// + /// + /// + private void buttonItemBZ4_Click(object sender, EventArgs e) + { + GSOFeature resFeature = IsPipeLineOfSelectedObj(); + if (resFeature == null) + { + MessageBox.Show("请选中一根管线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + GSOGeoPolyline3D selLine = resFeature.Geometry as GSOGeoPolyline3D; + if (selLine[0].Count <= 1) + { + return; + } + MarkTools.getInstance().showMarker(resFeature, + globeControl1, EnumMarkLayer.Mark_Location, ""); + } + /// + /// 距离标注 + /// + bool distanceMarker = false; + private void buttonItemBZ5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBZ5.Text); + + globeControl1.Globe.Action = EnumAction3D.TrackPolyline; + //globeControl1.Globe.DistanceRuler.MeasureMode = EnumDistanceMeasureMode.HVSLineMeasure; + distanceMarker = true; + } + /// + /// 自定义标注 + /// + /// + /// + private void buttonItemBZ6_Click(object sender, EventArgs e) + { + GSOFeature f = globeControl1.Globe.SelectedObject; + GSOLayer l = globeControl1.Globe.SelectedObjectLayer; + FrmCustomLabel frm = new FrmCustomLabel(globeControl1, l, f); + if (frm.ShowDialog() == DialogResult.OK) + { + MarkTools.getInstance().showMarker(f, globeControl1, EnumMarkLayer.Mark_Custom, frm.labelText); + } + } + /// + /// 扯旗标注 + /// + /// + /// + private void buttonItemBZ7_Click(object sender, EventArgs e) + { + GSOFeature f = globeControl1.Globe.SelectedObject; + GSOLayer l = globeControl1.Globe.SelectedObjectLayer; + FrmMarker frm = new FrmMarker(); + if (frm.ShowDialog() == DialogResult.OK) + { + MarkTools.getInstance().showMarker(f, globeControl1, EnumMarkLayer.Mark_Custom, frm.markerContent); + } + } + /// + /// 坡度标注 + /// + /// + /// + private void buttonItemBZ8_Click(object sender, EventArgs e) + { + GSOFeature resFeature = IsPipeLineOfSelectedObj(); + if (resFeature == null) + { + MessageBox.Show("请选中一根管线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + GSOGeoPolyline3D selLine = resFeature.Geometry as GSOGeoPolyline3D; + if (selLine[0].Count <= 1) + { + return; + } + + MarkTools.getInstance().showMarker(resFeature, + globeControl1, EnumMarkLayer.Mark_Slope, ""); + } + /// + /// 属性标注 + /// + /// + /// + private void buttonItemBZ9_Click(object sender, EventArgs e) + { + GSOFeature f = globeControl1.Globe.SelectedObject; + GSOLayer l = globeControl1.Globe.SelectedObjectLayer; + FrmPropertiesMarker frm = new FrmPropertiesMarker(globeControl1, l, f); + if (frm.ShowDialog() == DialogResult.OK) + { + MarkTools.getInstance().showMarker(f, globeControl1, EnumMarkLayer.Mark_Property, frm.labelText); + } + } + /// + /// 红线工具 + /// + /// + /// + private void buttonItemBZ10_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBZ10.Text); + 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; + } + } + /// + /// 标注管理 + /// + /// + /// + private void buttonItemBZ11_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBZ11.Text); + + buttonItemBZ11.Checked = !buttonItemBZ11.Checked; + 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 (buttonItemBZ11.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(); + } + } + + #endregion + /// + /// 飞行到目标点 + /// + /// + /// + private void buttonItemFXGJ1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFXGJ1.Text); + + FrmSetFlytoPos.ShowForm(globeControl1); + + } + /// + /// 自定义飞行 + /// + /// + /// + private void buttonItemFXGJ2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFXGJ2.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); + } + } + /// + /// 绕中心点飞行 + /// + /// + /// + private void buttonItemFXGJ3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFXGJ3.Text); + + globeControl1.Globe.FlyAroundCenter(10000, EnumFlyRepeatValueType.MiliSeconds); + globeControl1.Globe.CurFlyID = 1; + } + /// + /// 绕眼睛飞行 + /// + /// + /// + private void buttonItemFXGJ4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFXGJ4.Text); + + globeControl1.Globe.FlyAroundEye(720, EnumFlyRepeatValueType.Degrees); + globeControl1.Globe.CurFlyID = 2; + } + + /// + /// 权限管理 + /// + /// + /// + private void buttonItemXT1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT1.Text); + + FrmUserRoleMgr frm = new FrmUserRoleMgr(); + frm.ShowDialog(); + } + /// + /// 数据库管理 + /// + /// + /// + private void buttonItemXT2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT2.Text); + + //查看数据库列表 + FrmDbManager frm = new FrmDbManager(); + frm.ShowDialog(); + } + /// + /// 用户列表 + /// + /// + /// + private void buttonItemXT3_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT3_1.Text); + + FrmUserManager frm = new FrmUserManager(); + frm.ShowDialog(); + } + /// + /// 创建新用户 + /// + /// + /// + private void buttonItemXT3_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT3_2.Text); + + FrmUserAdd frm = new FrmUserAdd(-1); + frm.ShowDialog(); + } + /// + /// 人员修改 + /// + /// + /// + private void buttonItemXT4_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT4_2.Text); + + FrmAppUSER appUSER = new FrmAppUSER(); + appUSER.ShowDialog(); + } + /// + /// 增加人员 + /// + /// + /// + private void buttonItemXT4_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT4_1.Text); + + FrmAppUSERRESET appUSERRESET = new FrmAppUSERRESET(); + appUSERRESET.ShowDialog(); + } + /// + /// 统计数据 + /// + /// + /// + private void buttonItemZTT1_Click(object sender, EventArgs e) + { + ////日志记录 + //LogManager.saveLog(Utility.userName, this.buttonItemZTT1.Text); + + //PATM patm = new PATM(); + //patm.operation = "Statistic"; + //patm.Text = "统计专题图管理"; + //patm.ShowDialog(); + } + /// + /// 热点功能统计 + /// + /// + /// + private void buttonItemZTT2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT2.Text); + + FrmHotFuncStat frmhfs = new FrmHotFuncStat(); + frmhfs.ShowDialog(); + } + + private void buttonItemZTT3_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT3_1.Text); + + FrmAPP appfrm = new FrmAPP("专题图申请"); + appfrm.ShowDialog(); + } + + private void buttonItemZTT3_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT3_2.Text); + + FrmAPPFORASK appForask = new FrmAPPFORASK("专题图审核"); + appForask.ShowDialog(); + } + + private void buttonItemZTT3_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT3_3.Text); + + FrmAPPregion appregion = new FrmAPPregion("专题图审核"); + appregion.ShowDialog(); + } + + private void buttonItemZTT4_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT4_1.Text); + + FrmAPP appfrm = new FrmAPP("打印申请"); + appfrm.ShowDialog(); + } + + private void buttonItemZTT4_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT4_2.Text); + + FrmAPPFORASK appForask = new FrmAPPFORASK("打印审核"); + appForask.ShowDialog(); + } + + private void buttonItemZTT4_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT4_3.Text); + + FrmAPPregion appregion = new FrmAPPregion("打印审核"); + appregion.ShowDialog(); + } + + private void buttonItemZTT5_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT5_1.Text); + + FrmAPP appfrm = new FrmAPP("拷贝申请"); + appfrm.ShowDialog(); + } + + private void buttonItemZTT5_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT5_2.Text); + + FrmAPPFORASK appForask = new FrmAPPFORASK("拷贝审核"); + appForask.ShowDialog(); + } + + private void buttonItemZTT5_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT5_3.Text); + + FrmAPPregion appregion = new FrmAPPregion("拷贝审核"); + appregion.Show(); + } + + private int connectServerCount = 0; + + /// + /// 还原球到实测库 + /// + 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); + } + + if (layerManagerNode.Nodes.Count > 0) + { + for (int i = layerManagerNode.Nodes.Count - 1; i >= 0; i--) + { + layerManagerNode.Nodes[i].Remove(); + + } + } + + globeControl1.Refresh(); + + } + + private void buttonItemSPSZ_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSPSZ.Text); + + FrmLayerControl frm = new FrmLayerControl(layerTree, globeControl1, globeControl2); + frm.Show(this); + } + + /// + /// 碰撞审查 + /// + /// + /// + private void buttonItemSH1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSH1.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 buttonItemSH2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSH2.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 buttonItemSH3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSH3.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 buttonItemSH4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSH4.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 buttonItemSH5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSH5.Text); + FrmCityServerLineAnalysis frm = new FrmCityServerLineAnalysis(globeControl1, m_PipelineLayerNames); + frm.Show(this); + } + #region 数据管理-导入文件 + ///// + ///// 数据管理-导入本地坐标系文件 + ///// + ///// + ///// + //private void buttonItemSJGL1_1_Click(object sender, EventArgs e) + //{ + // //日志记录 + // LogManager.saveLog(Utility.userName, this.buttonItemSJGL1_1.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(); + // } + // } + //} + + ///// + ///// 数据管理-导入其他坐标系文件 + ///// + ///// + ///// + //private void buttonItemSJGL1_2_Click(object sender, EventArgs e) + //{ + // //日志记录 + // LogManager.saveLog(Utility.userName, this.buttonItemSJGL1_2.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(); + // } + // } + //} + #endregion + /// + /// 数据质量检查 + /// + /// + /// + private void buttonItemSJGL2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL2.Text); + FrmValiData frm = new FrmValiData(globeControl1); + frm.ShowDialog(); + } + /// + /// 数据预处理 + /// + /// + /// + private void buttonItemSJGL3_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL3.Text); + + FrmEditShapeFile frm = new FrmEditShapeFile(globeControl1); + frm.ShowDialog(this); + } + /// + /// 连接数据库 + /// + /// + /// + private void buttonItemSJGL4_1_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL4_1.Text); + + FrmDatabaseParaSetting frm = new FrmDatabaseParaSetting(globeControl1); + if (frm.ShowDialog() == DialogResult.OK) + { + ds = FrmDatabaseParaSetting.ds; + if (ds != null) + { + ds.IsCloseSaved = false; + } + } + } + /// + /// 管线入库 + /// + /// + /// + private void buttonItemSJGL4_2_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL4_2.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 buttonItemSJGL4_3_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL4_3.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 buttonItemSJGL5_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL5.Text); + + Cyberpipe.Forms.FrmProject frm = new Cyberpipe.Forms.FrmProject(); + frm.ShowDialog(); + } + /// + /// 元数据基本管理 + /// + /// + /// + private void buttonItemSJGL6_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL6_1.Text); + + FrmMetadata frmmd = new FrmMetadata(); + frmmd.ShowDialog(); + } + /// + /// 元数据查询管理 + /// + /// + /// + private void buttonItemSJGL6_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL6_2.Text); + + FrmMetadataStat frmmds = new FrmMetadataStat(); + //frmmds.Show(); + frmmds.ShowDialog(); + } + /// + /// 操作日志管理 + /// + /// + /// + private void buttonItemSJGL7_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL7.Text); + + FrmLogOper frmlo = new FrmLogOper(); + frmlo.ShowDialog(); + } + /// + /// 数据字典管理 + /// + /// + /// + private void buttonItemSJGL8_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL8.Text); + + FrmMDDictory frmmdd = new FrmMDDictory(); + frmmdd.ShowDialog(); + } + /// + /// 数据库备份 + /// + /// + /// + private void buttonItemSJGL9_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL9.Text); + + //新 + FrmBACKORACLE backOracle = new FrmBACKORACLE(); + backOracle.Show(); + } + /// + /// 创建管段 + /// + /// + /// + private void buttonItemBJ1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ1.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; + } + } + /// + /// 创建附属物 + /// + /// + /// + private void buttonItemBJ2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ2.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); + } + } + /// + /// 创建特征管点 + /// + /// + /// + private void buttonItemBJ3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ3.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); + } + } + /// + /// 绘制城市七线 + /// + /// + /// + private void buttonItemBJ4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ4.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; + } + } + } + /// + /// 选中对象 + /// + /// + /// + private void buttonItemBJ5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ5.Text); + + globeControl1.Globe.Action = EnumAction3D.SelectObject; + } + /// + /// 平移对象 + /// + /// + /// + private void buttonItemBJ6_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ6.Text); + + globeControl1.Globe.Action = EnumAction3D.MoveObject; + } + /// + /// 升降对象 + /// + /// + /// + private void buttonItemBJ7_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ7.Text); + + globeControl1.Globe.Action = EnumAction3D.ElevateObject; + } + /// + /// 旋转对象 + /// + /// + /// + private void buttonItemBJ8_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ8.Text); + + globeControl1.Globe.Action = EnumAction3D.RotateObject; + } + /// + /// 连接管段 + /// + /// + /// + private void buttonItemBJ9_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ9.Text); + + if (globeControl1.Globe.SelObjectCount < 2) + { + MessageBox.Show("对不起,请至少选中2个对象!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + return; + } + globeControl1.Globe.InsertJointPipeline(false); + } + /// + /// 后退 + /// + /// + /// + private void buttonItemBJ11_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemBJ11.Text); + globeControl1.Globe.UnDoEdit(); + } + /// + /// 前进 + /// + /// + /// + private void buttonItemBJ12_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemBJ12.Text); + + globeControl1.Globe.ReDoEdit(); + } + /// + /// 导出CAD + /// + /// + /// + private void buttonItemBJ10_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ10_1.Text); + + #region 导出成dxf格式 + List listVectorNames = new List(); + 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(); + #endregion + } + /// + /// 导出矢量 + /// + /// + /// + private void buttonItemBJ10_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ10_2.Text); + + List listVectorNames = new List(); + 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 buttonItemBJ13_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemBJ13.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(); + } + } + MessageBox.Show("删除成功!", "提示"); + } + else + { + MessageBox.Show("请选中要删除的模型!", "提示"); + } + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + } + + private void buttonItemHX1_1_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]; + string filePath = dlg.FileName; + string lastname = Path.GetFileName(filePath); + + 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(); + } + + } + } + } + + public struct LineStruct + { + public string layerName; + public string layerCode; + public string lineLength; + public string hxName; + } + + List lineStruct = new List(); + List featsList = new List(); + + /// + /// 红线审核 + /// + /// + /// + private void buttonItemHX2_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemHX2.Text); + redSH = true; + featsList.Clear(); + lineStruct.Clear(); + List listPipelineLayers = new List(); + + GSOLayer layer = null; + for (int i = 0; i < m_PipelineLayerNames.Count; i++) + { + layer = globeControl1.Globe.Layers.GetLayerByCaption(m_PipelineLayerNames[i]); + if (layer != null) + { + listPipelineLayers.Add(layer); + } + } + //yanxiaowei 重构 + GSOFeatures selectFeatures=new GSOFeatures(); + for (int i = 0; i < globeControl1.Globe.SelObjectCount; i++) + { + GSOFeature feature = null; + globeControl1.Globe.GetSelectObject(i, out feature, out layer); + selectFeatures.Add(feature); + } + DataTable table=new DataTable(); + + ClassGSOTool.CalculateRedLineResult(out table, redSH, selectFeatures, globeControl1, + listPipelineLayers,out lineStruct, out featsList); + + if (table.Rows.Count != 0) + AddDatagridView(table); + else + { + MessageBox.Show("没有侵入地块红线的管线数据!", "提示"); + dataGridViewX1.DataSource = null; + panelOfTable.Visible = false; + return; + } + } + + private void AddDatagridView(DataTable table) + { + dataGridViewX1.DataSource = table; + panelOfTable.Visible = true; + panelOfTable.Height = 200; + toolStripNumbers.Text = "红线审核 |共有:" + table.Rows.Count + "条"; + toolStripDropDownButton3.Visible = true; + } + /// + /// 主窗体 下方的工具条中的 导出.xls文件 按钮事件处理 + /// + /// + /// + private void toolStripDropDownButton3_Click(object sender, EventArgs e) + { + if (dataGridViewX1.Rows.Count == 0) + { + MessageBox.Show("表格内容为空!", "提示"); + return; + } + + string strSaveFile = string.Empty; + SaveFileDialog savefiledialog = new SaveFileDialog(); + savefiledialog.Filter = "Excel文件|*.xls,*.xlsx"; + savefiledialog.AddExtension = true; + savefiledialog.FileName = "红线审核"; + if (savefiledialog.ShowDialog() == DialogResult.OK) + strSaveFile = savefiledialog.FileName; + else return; + + ExpEXCEL.ExpToExcel(dataGridViewX1, strSaveFile, "红线审核", lineStruct, featsList); + MessageBox.Show("导出成功!"); + } + /// + /// 去除集合中重复的管线 + /// + /// + /// + /// + private GSOFeatures getFeaturesByFilter(GSOFeatures features, string fieldName) + { + if (features == null) + { + return null; + } + GSOFeatures featuresGet = new GSOFeatures(); + for (int i = 0; i < features.Length; i++) + { + GSOFeature featureFromFS = features[i]; + string fieldValueFromFS = featureFromFS.GetValue(fieldName).ToString().Trim(); + bool isHas = false; + for (int j = featuresGet.Length - 1; j >= 0; j--) + { + GSOFeature featureFromFSGet = featuresGet[j]; + string fieldValueFromFSGet = featureFromFSGet.GetValue(fieldName).ToString().Trim(); + if (fieldValueFromFS.Equals(fieldValueFromFSGet)) + { + isHas = true; + break; + } + } + if (isHas == false) + { + featuresGet.Add(featureFromFS.Clone()); + } + } + return featuresGet; + } + + private void sliderItem2_ValueChanged(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.sliderItem2.Text); + + globeControl1.Globe.GroundOpaque = 100 - sliderItem2.Value; + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(roadLayerName);//("180fd"); + if (layer != null) + { + layer.Opaque = 100 - sliderItem2.Value; + } + layer = globeControl2.Globe.Layers.GetLayerByCaption("180fd");//("180fd"); + if (layer != null) + { + layer.Opaque = 100 - sliderItem2.Value; + } + globeControl2.Globe.GroundOpaque = 100 - sliderItem2.Value; + + optiValue = sliderItem2.Value; + } + /// + /// 数据管理导入文件 + /// + /// + /// + private void buttonItemSJGL1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL1.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.Multiselect = true; + if (dlg.ShowDialog() == DialogResult.OK) + { + //自定义lprj文件名,从程序中复制一lprj文件。 + string filePath = dlg.FileName; + string lastname = Path.GetFileName(filePath); + + 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, 100); + + globeControl1.Refresh(); + } + } + } + + private void buttonItemHX1_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemHX1.Text); + + GSODataSource dataSpace = globeControl1.Globe.DataManager.OpenOracleDataSource(Utility.DBServer.Trim() + "/" + Utility.dbdatabase.Trim(), "", "", Utility.userID, Utility.DBPassword); + string filepath = ""; + //日志记录 + OpenFileDialog dlg = new OpenFileDialog(); + dlg.Filter = "矢量数据(*.shp)|*.shp|矢量数据(*.lgd)|*.lgd|CAD数据(*.dxf)|*.dxf|全部支持格式(*.lgd,*.shp,*.dxf)|*.lgd;*.shp;*.dxf;"; + dlg.Multiselect = true; + + #region 临时图层显示 + if (dlg.ShowDialog() == DialogResult.OK) + { + string filePath = dlg.FileName; + string lastname = Path.GetFileName(filePath); + + #region + for (int i = 0; i < dlg.FileNames.Length; i++) + { + string strDataPath = dlg.FileNames[i]; + filepath = strDataPath; + + GSOLayer layer = globeControl1.Globe.Layers.Add(strDataPath); + GSOFeatures RedFeatures = layer.GetAllFeatures(); + + 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(); + RedFeatures = features; + 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; + } + + /////////////////////////////////////////////////////////////////////////////////////////// + globeControl1.Globe.Layers.MoveTo(0, globeControl1.Globe.Layers.Count - 1); + globeControl1.Refresh(); + } + + IModelBuilder modelBuilder = new RedLineBuilder(); + + modelBuilder.batchInsert(dataSpace, redDt, RedFeatures); + + } + #endregion + + } + #endregion + } + /// + /// 定位 + /// + /// + /// + private void buttonItemLocation_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemLocation.Text); + + FrmFlyToPosition fly = new FrmFlyToPosition(globeControl1,globeControl2); + fly.Show(this); + } + /// + /// 2015-10-17演示代码 红线审核 + /// + /// + /// + private void ribbonTabItem6_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.FlyToPosition(new GSOPoint3d(120.610963, 31.188121, 50), EnumAltitudeMode.Absolute, -4, 50, 800); + globeControl1.Globe.FlyToPointSpeed = 10000000; + globeControl1.Globe.Action = EnumAction3D.SelectObject; + globeControl1.Refresh(); + + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + + //zhanshi = false; + redSH = true; + splitContainer1.Panel2Collapsed = true; + legendSG.Visible = false; + legendSC.Visible = false; + ClearGZData(); + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = true; + } + + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 基础工具 + /// + /// + /// + private void ribbonTabItem1_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + //zhanshi = false; + redSH = false; + splitContainer1.Panel2Collapsed = true; + panelOfTable.Visible = false; + legendSC.Visible = false; + legendSG.Visible = false; + ClearGZData(); + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + + + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 一键审核 + /// + /// + /// + private void ribbonTabItem11_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + //zhanshi = false; + redSH = false; + splitContainer1.Panel2Collapsed = true; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + panelOfTable.Visible = false; + legendSC.Visible = false; + legendSG.Visible = false; + ClearGZData(); + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + + + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 右屏添加冰箱数据 + /// + void AddDataToGlobeControl2() + { + + bool modelDataBool = false; + for (int i = globeControl2.Globe.Layers.Count - 1; i >= 0; i--) + { + GSOLayer layer = globeControl2.Globe.Layers[i]; + if (layer.Name.Contains("fttp:")) + { + modelDataBool = true; + break; + } + } + + if (modelDataBool == false) + { + GSOLayer ly = globeControl1.Globe.Layers.GetLayerByCaption("天地图地图"); + globeControl2.Globe.Layers.Add(ly); + } + else + { + return; + } + } + /// + /// 双屏对比 + /// + /// + /// + private void ribbonTabItem9_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent += new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent += new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + panelOfTable.Visible = false; + + splitContainer1.Panel2Collapsed = false; + //zhanshi = true; + redSH = false; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + sliderItem2.Value = 100 - globeControl1.Globe.GroundOpaque; + globeControl2.Globe.GroundOpaque = globeControl1.Globe.GroundOpaque; + legendSC.Visible = true; + legendSG.Visible = true; + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + AddDataToGlobeControl2(); + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 文档管理 + /// + /// + /// + private void ribbonTabItem4_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + panelOfTable.Visible = false; + //zhanshi = false; + redSH = false; + splitContainer1.Panel2Collapsed = true; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + legendSC.Visible = false; + legendSG.Visible = false; + ClearGZData(); + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 基础管理 + /// + /// + /// + private void ribbonTabItem14_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + panelOfTable.Visible = false; + //zhanshi = false; + redSH = false; + splitContainer1.Panel2Collapsed = true; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + legendSC.Visible = false; + legendSG.Visible = false; + ClearGZData(); + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 权限管理 + /// + /// + /// + private void ribbonTabItem2_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + panelOfTable.Visible = false; + //zhanshi = false; + redSH = false; + splitContainer1.Panel2Collapsed = true; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + legendSC.Visible = false; + legendSG.Visible = false; + ClearGZData(); + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + GSOFeature dpFeatuer = null; + /// + /// 双屏分析,点击管段分析 + /// + /// + /// + private void buttonItem8_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItem8.Text); + + //FrmCompareFeature frmCompareFeature = new FrmCompareFeature(globeControl1, globeControl2, layerTemp, layerTemp2,m_PipelineLayerNames,sgPipeLayersNames); + int width = this.Width; + FrmCompareFeature.ShowForm(globeControl1, globeControl2, layerTemp, layerTemp2, m_PipelineLayerNames, sgPipeLayersNames,width); + //frmCompareFeature.Location = new Point((this.Width - frmCompareFeature.Width)/2,50); + //frmCompareFeature.Show(this); + + } + /// + /// 红线审核导出图片 + /// + /// + /// + private void buttonItemDCTP_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemDCTP.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))); + */ + int mapWidth = 0; + int mapHeight = 0; + Point pt = getUpperLeftPoint(pt1, pt2, out mapWidth, out mapHeight); + int rightBottomX = pt.X + mapWidth; + int rightBottomY = pt.Y + mapHeight; + Image myImg = new Bitmap(mapWidth, mapHeight); + Graphics g = Graphics.FromImage(myImg); + g.CopyFromScreen(pt, new Point(0, 0), new Size(rightBottomX, rightBottomY)); + + 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; + } + } + } + /// + /// 标识器全区域统计 + /// + /// + /// + private void 标识器分类统计ToolStripMenuItem_Click(object sender, EventArgs e) + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + FrmBSQStatis bsqStatis = new FrmBSQStatis(); + bsqStatis.Show(this); + } + /// + /// 标识器绘制区域统计 + /// + /// + /// + private void 标识器分类统计ToolStripMenuItem1_Click(object sender, EventArgs e) + { + trackflag = "BSQDuoBianXiangStatis"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + } + + #region 保存和加载审核库加载的图层 + /* + private void saveLayerList(TreeNodeCollection treeNodeList) + { + string configPath = Application.StartupPath + "\\configLayerList.xml"; + try + { + XmlDocument doc = new XmlDocument(); + doc.Load(configPath); + XmlNode dbParams = doc.SelectSingleNode("Params/dbparams"); + XmlNode dbLayers = doc.SelectSingleNode("Params/dblayers"); + XmlNode layers = doc.SelectSingleNode("Params/layers"); + dbParams.RemoveAll(); + dbLayers.RemoveAll(); + layers.RemoveAll(); + + List listDS = new List(); + String shDatasourceName = Utility.sgdbip + "/" + Utility.sgdbname + "_" + Utility.sgdbuser; + bool flag = false; + + for (int i = 0; i < globeControl1.Globe.DataManager.DataSourceCount; i++) + { + GSODataSource ds = globeControl1.Globe.DataManager.GetDataSourceAt(i); + if (ds != null && ds.Type == EnumDataSourceType.SqlServer || ds.Type == EnumDataSourceType.Oracle) + { + if (ds.Name == shDatasourceName) + { + //防止因为多次连接同一个数据库 + if (flag == true) + { + break; + } + flag = true; + listDS.Add(ds); + GSODataSourceCnn conn = ds.GetConnectionInfo(); + + XmlElement dbparam = doc.CreateElement("shdbparam"); + XmlElement ip = doc.CreateElement("ship"); + ip.InnerText = conn.Server; + + XmlElement dbname = doc.CreateElement("shdbname"); + dbname.InnerText = conn.Database; + + XmlElement username = doc.CreateElement("shusername"); + username.InnerText = conn.User; + + XmlElement password = doc.CreateElement("shpassword"); + password.InnerText = conn.Password; + + XmlElement type = doc.CreateElement("shtype"); + if (ds.Type == EnumDataSourceType.SqlServer) + { + type.InnerText = "sqlserver"; + } + else + { + type.InnerText = "oracle"; + } + + dbparam.AppendChild(ip); + dbparam.AppendChild(dbname); + dbparam.AppendChild(username); + dbparam.AppendChild(password); + dbparam.AppendChild(type); + dbParams.AppendChild(dbparam); + } + + } + } + + for (int i = 0; i < treeNodeList.Count; i++) + { + GSOLayer layer = treeNodeList[i].Tag as GSOLayer; + if (Path.GetExtension(layer.Name) == "") + { + XmlElement dbLayer = doc.CreateElement("dblayer"); + XmlAttribute attri = doc.CreateAttribute("dbindex"); + for (int j = 0; j < listDS.Count; j++) + { + if (layer.Dataset.DataSource.Name == listDS[j].Name) + { + attri.Value = j.ToString(); + break; + } + } + dbLayer.Attributes.Append(attri); + dbLayer.InnerText = layer.Name; + + dbLayers.AppendChild(dbLayer); + } + else + { + XmlElement dbLayer = doc.CreateElement("layer"); + dbLayer.InnerText = layer.Name; + layers.AppendChild(dbLayer); + } + } + + doc.Save(configPath); + } + catch (Exception e) + { + + } + } + + private void openLayerList() + { + layerManagerNode.Nodes.Clear(); + + string configPath = Application.StartupPath + "\\configLayerList.xml"; + try + { + XmlDocument doc = new XmlDocument(); + doc.Load(configPath); + XmlNode dbParams = doc.SelectSingleNode("Params/dbparams"); + XmlNode dbLayers = doc.SelectSingleNode("Params/dblayers"); + XmlNode layers = doc.SelectSingleNode("Params/layers"); + + List listDS = new List(); + for (int i = 0; i < dbParams.ChildNodes.Count; i++) + { + string ip = ""; + string dbname = ""; + string username = ""; + string password = ""; + string type = ""; + XmlNode node = dbParams.ChildNodes.Item(i); + for (int j = 0; j < node.ChildNodes.Count; j++) + { + XmlNode nodeChild = node.ChildNodes.Item(j); + + if (nodeChild != null && nodeChild.Name == "ship") + { + ip = nodeChild.InnerText; + } + else if (nodeChild != null && nodeChild.Name == "shdbname") + { + dbname = nodeChild.InnerText; + } + else if (nodeChild != null && nodeChild.Name == "shusername") + { + username = nodeChild.InnerText; + } + else if (nodeChild != null && nodeChild.Name == "shpassword") + { + password = nodeChild.InnerText; + } + else if (nodeChild != null && nodeChild.Name == "shtype") + { + type = nodeChild.InnerText; + } + } + + if (type == "sqlserver") + { + GSODataSource ds = globeControl1.Globe.DataManager.OpenSqlServerDataSource(ip, "", dbname, username, password); + listDS.Add(ds); + } + else if (type == "oracle") + { + GSODataSource ds = globeControl1.Globe.DataManager.OpenOracleDataSource(ip + "/" + dbname, "", "", username, password); + listDS.Add(ds); + } + } + + for (int i = 0; i < dbLayers.ChildNodes.Count; i++) + { + XmlNode node = dbLayers.ChildNodes.Item(i); + if (node != null) + { + string layerName = node.InnerText; + XmlAttribute attri = node.Attributes["dbindex"]; + if (attri != null) + { + int dbIndex = -1; + if (int.TryParse(attri.Value, out dbIndex)) + { + GSODataset dataset = listDS[dbIndex].GetDatasetByName(layerName); + globeControl1.Globe.Layers.Add(dataset); + //更新树节点 + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + TreeNode layerNode = new TreeNode(); + layerNode.Tag = layer; + layerNode.Text = layer.Dataset.Caption; + layerNode.ImageIndex = 0; + layerNode.SelectedImageIndex = 0; + layerNode.Checked = layer.Visible; + layerManagerNode.Nodes.Insert(0, layerNode); + // layerManagerNode.Expand(); + + + } + } + } + } + for (int i = 0; i < layers.ChildNodes.Count; i++) + { + XmlNode node = layers.ChildNodes.Item(i); + if (node != null) + { + string layerName = node.InnerText; + globeControl1.Globe.Layers.Add(layerName); + + //更新树节点 + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + TreeNode layerNode = new TreeNode(); + layerNode.Tag = layer; + layerNode.Text = layer.Dataset.Caption; + layerNode.ImageIndex = 0; + layerNode.SelectedImageIndex = 0; + layerNode.Checked = layer.Visible; + layerManagerNode.Nodes.Insert(0, layerNode); + } + } + layerManagerNode.Expand(); + } + catch (Exception e) + { + + } + } + * */ + #endregion + + private void btn_check_history_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_check_history.Text); + + if (FrmCheckHistory.isOpen == true) + { + return; + } + FrmCheckHistory frm = new FrmCheckHistory(globeControl1, globeControl2); + frm.addNode += new AddNodeToLayerManagerNode(addNodeToLayerManagerNode); + frm.Show(); + + } + + private void buttonItem查看数据_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItem查看数据.Text); + + FrmThreeOracle tr = new FrmThreeOracle(globeControl1); + + if (tr.ShowDialog() == DialogResult.OK) + { + addNodeToLayerManagerNode(tr.rukuLayer); + globeControl1.Refresh(); + } + } + /// + /// 规划数据入库 + /// + /// + /// + private void buttonItemGHRK_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemGHRK.Text); + + FrmGHRK ghrk = new FrmGHRK(globeControl1, layerManagerNode); + ghrk.Show(this); + } + + private void btn_user_info_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_user_info.Text); + + if (!FrmSysUserInfoManger.IS_OPEN) + { + FrmSysUserInfoManger frm = new FrmSysUserInfoManger(); + frm.ShowDialog(); + } + } + + private void btn_role_info_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_role_info.Text); + + if (FrmRoleInfoManager.IS_OPEN) + { + return; + } + FrmRoleInfoManager frm = new FrmRoleInfoManager(); + frm.ShowDialog(); + } + + private void btn_resc_info_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_resc_info.Text); + + if (!SysRescInfoManager.IS_OPEN) + { + SysRescInfoManager frm = new SysRescInfoManager(); + frm.ShowDialog(); + } + } + + private void btn_role_resc_Click(object sender, EventArgs e) + { + + LogManager.saveLog(Utility.userName, this.btn_role_resc.Text); + + if (!FrmRoleRescManager.IS_OPEN) + { + FrmRoleRescManager frm = new FrmRoleRescManager(); + frm.ShowDialog(); + } + } + + private void btn_user_role_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_user_role.Text); + + if (FrmUserRole.IS_OPEN) + { + return; + } + FrmUserRole frm = new FrmUserRole(); + frm.ShowDialog(); + } + + private void btn_document_info_Click(object sender, EventArgs e) + { + + LogManager.saveLog(Utility.userName, this.btn_document_info.Text); + + //if (FormDocumentManager.IS_OPEN) + //{ + // return; + //} + //FormDocumentManager frm = new FormDocumentManager(); + //frm.ShowDialog(); + + //if (FormDocumentManager.IS_OPEN) + //{ + // return; + //} + //new FormDocumentManager().ShowDialog(); + if (FormDocumentManager.IS_OPEN) + { + return; + } + this.Cursor = Cursors.WaitCursor; + FormDocumentManager frm = new FormDocumentManager(); + frm.changeCursor += new ChangeCursor(changeCursorToDefault); + frm.ShowDialog(); + + } + + private void changeCursorToDefault() + { + this.Cursor = Cursors.Default; + } + + /// + /// 判断CAD文件是否有投影信息 + /// + /// + /// + Boolean CheckDatasetGeoReference(GSODataset dataset) + { + Boolean bSuccess = false; + if (dataset.GeoReferenceType == EnumGeoReferenceType.Flat) + { + if (MessageBox.Show("数据没有空间参考信息,请设置空间参考信息!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation) == DialogResult.OK) + { + String strPath = Path.GetDirectoryName(Application.ExecutablePath) + "\\Coordinate Systems"; + OpenFileDialog dlg = new OpenFileDialog(); + + dlg.InitialDirectory = strPath; + dlg.RestoreDirectory = true; + + dlg.Filter = "投影文件|*.prj||"; + if (dlg.ShowDialog() == DialogResult.OK) + { + bSuccess = dataset.LoadProjectionFromESRIFile(dlg.FileName); + } + } + } + else + { + return true; + } + return bSuccess; + } + + private void buttonItemexp_CAD_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemexp_CAD.Text); + + OpenFileDialog dlg = new OpenFileDialog(); + dlg.Filter = "支持格式(*.dwg)|*.dwg"; + dlg.Multiselect = true; + if (dlg.ShowDialog() == DialogResult.OK) + { + for (int i = 0; i < dlg.FileNames.Length; i++) + { + //this.Cursor = Cursors.WaitCursor; + string strDataPath = dlg.FileNames[i]; + + #region + //string strDataPathPrj = strDataPath.ToLower().Replace(".dwg", ".lprj"); + + //if (File.Exists(strDataPathPrj) == false) + //{ + // if (MessageBox.Show("数据没有空间参考信息,请设置空间参考信息!", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation) == DialogResult.OK) + // { + // String strPath = Application.StartupPath + "\\Coordinate Systems"; + // OpenFileDialog dlgPrj = new OpenFileDialog(); + // dlgPrj.InitialDirectory = strPath; + // dlgPrj.RestoreDirectory = true; + // dlgPrj.Multiselect = false; + // dlg.Filter = "投影文件|*.prj"; + // if (dlg.ShowDialog() == DialogResult.OK) + // { + // this.Cursor = Cursors.WaitCursor; + // string proj4 = GSODataEngineUtility.ConvertEsriPrjFileToProj4(dlg.FileName); + // using (StreamWriter stream = new StreamWriter(strDataPathPrj, false)) + // { + // stream.WriteLine("0prj4" + proj4 + ""); + // } + // AddLayerData(strDataPath); + // //globeControl1.Globe.Layers.Add(strDataPath); + + // this.Cursor = Cursors.Default; + // } + // else + // { + // AddLayerData(strDataPath); + // //globeControl1.Globe.Layers.Add(strDataPath); + // } + // } + // else + // { + // AddLayerData(strDataPath); + // //globeControl1.Globe.Layers.Add(strDataPath); + // } + + //} + //else + //{ + // //globeControl1.Globe.Layers.Add(strDataPath); + // AddLayerData(strDataPath); + //} + #endregion + AddLayerData(strDataPath); + //this.Cursor = Cursors.Default; + } + } + + 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, 100); + + globeControl1.Refresh(); + } + } + + private void btn_password_edit_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_password_edit.Text); + + if (FrmChangePassword.IS_OPEN) + { + return; + } + FrmChangePassword frm = new FrmChangePassword(); + frm.ShowDialog(); + } + /// + /// 多孔管线入库 + /// + /// + /// + private void buttonItem9_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL4_2.Text); + + if (ds == null) + { + MessageBox.Show("请先连接数据库", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + ConnectDB(null, null); + } + if (ds == null) + return; + + FrmMultiPipelineModelDB frm = new FrmMultiPipelineModelDB(globeControl1, ds); + if (frm.ShowDialog() == DialogResult.OK) + { + addNodeToLayerManagerNode(frm.rukuLayer); + } + //frm.Show(); + } + private void 导出CADToolStripMenuItem1_Click(object sender, EventArgs e) + { + TreeNode node = layerNodeContexMenu.Tag as TreeNode; + if (node == null) + { + MessageBox.Show("请在左侧节点集中选择要导出的图层", "提示"); + return; + } + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(node.Text.Trim()); + if (layer == null || layer.GetAllFeatures().Length <= 0) + { + MessageBox.Show("要导出的图层为空", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + return; + } + string strProjectName = Utility.projectStr; + if (strProjectName != "") + { + SaveFileDialog dlg = new SaveFileDialog(); + dlg.Filter = "*.dwg|*.dwg|*.dxf|*.dxf"; + dlg.FileName = layer.Caption; + if (dlg.ShowDialog(this) == DialogResult.OK) + { + globeControl1.Globe.MemoryLayer.SaveAs(dlg.FileName); + GSOLayer newlayer = globeControl1.Globe.Layers.Add(dlg.FileName); + newlayer.RemoveAllFeature(); + int featureCount = layer.GetAllFeatures().Length; + for (int i = 0; i < featureCount; i++) + { + GSOFeature feature = layer.GetAt(i); + if (feature != null && feature.Geometry != null) + { + if (feature.Geometry.Type == EnumGeometryType.GeoPolyline3D) + { + feature.Geometry.Style = new GSOSimpleLineStyle3D(); + } + else if (feature.Geometry.Type == EnumGeometryType.GeoPolygon3D) + { + feature.Geometry.Style = new GSOSimplePolygonStyle3D(); + } + newlayer.AddFeature(feature); + } + } + newlayer.Save(); + newlayer.Dataset.DataSource.RemoveDataset(newlayer.Dataset); + globeControl1.Globe.Layers.Remove(newlayer); + MessageBox.Show("导出CAD完成!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + } + } + } + + private void buttonItemGBJC_Click(object sender, EventArgs e) + { + FrmGBJC gb = new FrmGBJC(globeControl1, globeControl2, layerTemp, layerTemp2); + gb.Show(this); + } + + #region 右屏管纵数据控制 + private void 五十米主干道ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = true; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + + private void 三十六米次干道ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = true; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + + private void 四十二米次干道ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = true; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + + private void 二十四米一块板ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = true; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + + private void 二十四米三块板ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = true; + } + + private void 二十四米停车带ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = true; + lendendGZ24_3.Visible = false; + } + + private void 二十六米大堤路ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = true; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + + private void 清除管纵数据ToolStripMenuItem_Click(object sender, EventArgs e) + { + ClearGZData(); + } + + private void ClearGZData() + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + #endregion + + private void buttonItemPasswordReset_Click(object sender, EventArgs e) + { + Frm_password_reset reset = new Frm_password_reset(); + reset.Show(); + } + + private void pictureBox1_Paint(object sender, PaintEventArgs e) + { + int Width = this.Width; + string welcomeUser = "欢迎您:" + Utility.userName; + Graphics g = e.Graphics; + g.DrawString(welcomeUser, new Font("宋体", 12), new SolidBrush(Color.Black), Width - 180, 50); + } + + } +} \ No newline at end of file diff --git a/MainFrm.cs.LOCAL.9016.cs b/MainFrm.cs.LOCAL.9016.cs new file mode 100644 index 0000000..0b7e393 --- /dev/null +++ b/MainFrm.cs.LOCAL.9016.cs @@ -0,0 +1,13060 @@ +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; + + GSOBalloon featureTooltip2; + GSOBalloonEx balloonEx2; + + GSOLayer layerTemp; + GSOLayer layerTemp2; + FrmShResult frmShResult = null; + FrmRedlineResult frmredResult = null; + FrmMnModify frmModify = null; + public bool frmRedlineResult = false; + public bool boolfrmShResult = false; + public bool boolfrmModify = false; + + List m_PipelineLayerNames = new List();//线图层名称 + List workwellLayerNames = new List();//工井图层名称 + List valueLayerNames = new List();//阀门图层名称 + List instrumenLayerNames = new List();//附属物图层名称 + List pipefittingLayerNames = new List();//管件图层名称 + List sgPipeLayersNames = new List();//施工管线图层名称 + 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 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; + public string redLayer = null; + //GSOLayer redLayer1 = null; + bool redSH = false; + string redDt = "红线"; + //双屏对比 + //bool zhanshi=false; + Thread t = null; + private GSOHudButton legendSC;//定义图例 + private GSOHudButton legendSG;//定义图例 + //管纵图 + private GSOHudButton lendendGZ50; + private GSOHudButton lendendGZ36; + private GSOHudButton lendendGZ42; + private GSOHudButton lendendGZ24_1; + private GSOHudButton lendendGZ24_2; + private GSOHudButton lendendGZ24_3; + private GSOHudButton lendendGZ26; + + GSOGeoPoint3D bsqPT; + + FrmYJSHTC frmSh = null;//一键审核窗口全局变量wxl + FrmWait frmWait = null;//一键审核等待窗口 + //FrmWait frmWait2 = null;//文档操作等待窗口 + + float mouseDownX1,mouseDownY1; + float mouseDownX2,mouseDownY2; + /// + /// + /// + 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; + + featureTooltip2 = new GSOBalloon(globeControl2.Handle); + balloonEx2 = new GSOBalloonEx(globeControl2.Handle); + Utility.SetBallons(featureTooltip, balloonEx); + + panelOfTable.Height = 200; + + RigthMenuSet(); + + MenuSet(); + + } + /// + /// 右屏中添加管纵图片 + /// + private void AddGZ() + { + + lendendGZ50 = new GSOHudButton(); + lendendGZ50.SetImage(Application.StartupPath + "/Resource/管纵/50.png"); + lendendGZ50.SetOffset(0, 0); + lendendGZ50.MinOpaque = 1; + lendendGZ50.MaxOpaque = 1; + lendendGZ50.FadeOut = false; + lendendGZ50.Name = "lendendGZ50"; + lendendGZ50.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ50); + lendendGZ50.Visible = false; + + lendendGZ36 = new GSOHudButton(); + lendendGZ36.SetImage(Application.StartupPath + "/Resource/管纵/36.png"); + lendendGZ36.SetOffset(0, 0); + lendendGZ36.MinOpaque = 1; + lendendGZ36.MaxOpaque = 1; + lendendGZ36.FadeOut = false; + lendendGZ36.Name = "lendendGZ36"; + lendendGZ36.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ36); + lendendGZ36.Visible = false; + + lendendGZ42 = new GSOHudButton(); + lendendGZ42.SetImage(Application.StartupPath + "/Resource/管纵/42.png"); + lendendGZ42.SetOffset(0, 0); + lendendGZ42.MinOpaque = 1; + lendendGZ42.MaxOpaque = 1; + lendendGZ42.FadeOut = false; + lendendGZ42.Name = "lendendGZ42"; + lendendGZ42.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ42); + lendendGZ42.Visible = false; + + lendendGZ24_1 = new GSOHudButton(); + lendendGZ24_1.SetImage(Application.StartupPath + "/Resource/管纵/24_1.png"); + lendendGZ24_1.SetOffset(0, 0); + lendendGZ24_1.MinOpaque = 1; + lendendGZ24_1.MaxOpaque = 1; + lendendGZ24_1.FadeOut = false; + lendendGZ24_1.Name = "lendendGZ24_1"; + lendendGZ24_1.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ24_1); + lendendGZ24_1.Visible = false; + + lendendGZ24_2 = new GSOHudButton(); + lendendGZ24_2.SetImage(Application.StartupPath + "/Resource/管纵/24_2.png"); + lendendGZ24_2.SetOffset(0, 0); + lendendGZ24_2.MinOpaque = 1; + lendendGZ24_2.MaxOpaque = 1; + lendendGZ24_2.FadeOut = false; + lendendGZ24_2.Name = "lendendGZ24_2"; + lendendGZ24_2.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ24_2); + lendendGZ24_2.Visible = false; + + lendendGZ24_3 = new GSOHudButton(); + lendendGZ24_3.SetImage(Application.StartupPath + "/Resource/管纵/24_3.png"); + lendendGZ24_3.SetOffset(0, 0); + lendendGZ24_3.MinOpaque = 1; + lendendGZ24_3.MaxOpaque = 1; + lendendGZ24_3.FadeOut = false; + lendendGZ24_3.Name = "lendendGZ24_3"; + lendendGZ24_3.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ24_3); + lendendGZ24_3.Visible = false; + + lendendGZ26 = new GSOHudButton(); + lendendGZ26.SetImage(Application.StartupPath + "/Resource/管纵/26.png"); + lendendGZ26.SetOffset(0, 0); + lendendGZ26.MinOpaque = 1; + lendendGZ26.MaxOpaque = 1; + lendendGZ26.FadeOut = false; + lendendGZ26.Name = "lendendGZ26"; + lendendGZ26.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ26); + lendendGZ26.Visible = false; + + } + + public void RigthMenuSet() + { + if (Utility.userRole.IndexOf("清除分析") < 0) + { + toolRightMenu.Items.Remove(清除分析ToolStripMenuItem); + } + + #region 区域分析 + if (Utility.userRole.IndexOf("区域分析") < 0) + { + toolRightMenu.Items.Remove(区域分析ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("缓冲区分析") < 0) + { + 区域分析ToolStripMenuItem.DropDownItems.Remove(缓冲区分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("附属物分析") < 0) + { + 区域分析ToolStripMenuItem.DropDownItems.Remove(附属物分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("无源淹没分析") < 0) + { + 区域分析ToolStripMenuItem.DropDownItems.Remove(无源淹没分析ToolStripMenuItem); + } + } + #endregion + + #region 视域分析 + if (Utility.userRole.IndexOf("视域分析") < 0) + { + toolRightMenu.Items.Remove(视域分析ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("通视分析") < 0) + { + 视域分析ToolStripMenuItem.DropDownItems.Remove(通视分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("可视域分析") < 0) + { + 视域分析ToolStripMenuItem.DropDownItems.Remove(可视域分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("可视包络分析") < 0) + { + 视域分析ToolStripMenuItem.DropDownItems.Remove(可视包络分析ToolStripMenuItem); + } + } + #endregion + + #region 开发分析 + if (Utility.userRole.IndexOf("开挖分析") < 0) + { + toolRightMenu.Items.Remove(开挖分析ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("多边形开挖") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(多边形开挖ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("挖方量分析") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(挖方量分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("沿线开挖") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(沿线开挖ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("创建隧道") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(创建隧道ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("隐藏隧道") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(隐藏隧道ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("删除隧道") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(删除隧道ToolStripMenuItem); + } + } + #endregion + + #region 拓扑分析 + if (Utility.userRole.IndexOf("拓扑分析") < 0) + { + toolRightMenu.Items.Remove(拓扑分析ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("创建拓扑") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(创建拓扑ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("上游分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(上游分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("下游分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(下游分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("流向分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(流向分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("关阀分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(关阀分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("连通分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(连通分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("爆管分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(爆管分析ToolStripMenuItem); + } + } + #endregion + + #region 断面分析 + if (Utility.userRole.IndexOf("断面分析") < 0) + { + toolRightMenu.Items.Remove(断面分析ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("横断面分析") < 0) + { + 断面分析ToolStripMenuItem.DropDownItems.Remove(横断面分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("纵断面分析") < 0) + { + 断面分析ToolStripMenuItem.DropDownItems.Remove(纵断面分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("道路断面分析") < 0) + { + 断面分析ToolStripMenuItem.DropDownItems.Remove(道路断面分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("基线剖面分析") < 0) + { + 断面分析ToolStripMenuItem.DropDownItems.Remove(基线剖面分析ToolStripMenuItem); + } + } + #endregion + + #region 绘制区域统计 + if (Utility.userRole.IndexOf("绘制区域统计") < 0) + { + toolRightMenu.Items.Remove(绘制区域统计ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("绘制区域管线长度统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管线长度统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域阀门数量统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(阀门数量统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域井盖数量统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(井盖数量统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域管径分段统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管径分段统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域埋深分段统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(埋深分段统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域管径分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管径分类统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域材质分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(材质分类统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域附属物分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(附属物分类统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域标识器分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(标识器分类统计ToolStripMenuItem1); + } + + } + #endregion + + #region 全区域统计 + if (Utility.userRole.IndexOf("全区域统计") < 0) + { + toolRightMenu.Items.Remove(全区域统计ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("全区域管线长度统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管线长度统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域阀门数量统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(阀门数量统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域井盖数量统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(井盖数量统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域管径分段统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管径分段统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域埋深分段统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(埋深分段统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域管径分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管径分类统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域材质分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(材质分类统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域附属物分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(附属物分类统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域标识器分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(标识器分类统计ToolStripMenuItem); + } + + } + #endregion + + #region 查询 + if (Utility.userRole.IndexOf("查询") < 0) + { + toolRightMenu.Items.Remove(查询ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("空间查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(空间查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("编号查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(编号查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("坐标查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(坐标查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("管径查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(管径查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("材质查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(材质查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("基本查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(基本查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("复合查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(复合查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("关联查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(关联查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("关键字查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(关键字查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("附属物查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(附属物查询ToolStripMenuItem); + } + } + #endregion + + #region 标注 + if (Utility.userRole.IndexOf("标注") < 0) + { + toolRightMenu.Items.Remove(标注ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("标高标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(标高标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("管径标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(管径标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("埋深标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(埋深标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("坐标标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(坐标标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("距离标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(距离标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("自定义标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(自定义标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("扯旗标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(扯旗标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("坡度标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(坡度标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("属性标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(属性标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("标注管理") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(标注管理ToolStripMenuItem); + } + } + #endregion + + #region 飞行 + if (Utility.userRole.IndexOf("飞行") < 0) + { + toolRightMenu.Items.Remove(飞行ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("自定义飞行") < 0) + { + 飞行ToolStripMenuItem.DropDownItems.Remove(自定义飞行ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("飞行到目标点") < 0) + { + 飞行ToolStripMenuItem.DropDownItems.Remove(飞行到目标点ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("绕中心点飞行") < 0) + { + 飞行ToolStripMenuItem.DropDownItems.Remove(绕中心点飞行ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("绕眼睛飞行") < 0) + { + 飞行ToolStripMenuItem.DropDownItems.Remove(绕眼睛飞行ToolStripMenuItem); + } + } + #endregion + + #region 编辑 + if (Utility.userRole.IndexOf("编辑") < 0) + { + toolRightMenu.Items.Remove(编辑ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("平移对象") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(平移对象ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("升降对象") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(升降对象ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("旋转对象") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(旋转对象ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("连接管段") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(连接管段ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("导出文件") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(导出文件ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("前进") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(前进ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("后退") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(删除模型ToolStripMenuItem); + } + } + #endregion + + #region 量算 + if (Utility.userRole.IndexOf("量算") < 0) + { + toolRightMenu.Items.Remove(量算ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("水平距离") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(水平距离ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("垂直距离") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(垂直距离ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("空间距离") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(空间距离ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("地表距离") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(地表距离ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("高度量算") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(高度量算ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("水平面积") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(水平面积ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("地表面积") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(地表面积ToolStripMenuItem1); + } + } + #endregion + } + + public void MenuSet() + { + + #region 权限管理 + if (Utility.userRole.IndexOf("权限管理") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem2); + } + else + { + + if (Utility.userRole.IndexOf("用户管理") < 0) + { + btn_user_info.Visible = false; + } + if (Utility.userRole.IndexOf("角色管理") < 0) + { + btn_role_info.Visible = false; + } + if (Utility.userRole.IndexOf("资源管理") < 0) + { + btn_resc_info.Visible = false; + } + if (Utility.userRole.IndexOf("角色授权") < 0) + { + btn_role_resc.Visible = false; + } + if (Utility.userRole.IndexOf("用户授权") < 0) + { + btn_user_role.Visible = false; + } + if (Utility.userRole.IndexOf("密码修改") < 0) + { + btn_password_edit.Visible = false; + } + + } + #endregion + + #region 基础工具 + if (Utility.userRole.IndexOf("基础工具") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem1); + } + else + { + if (Utility.userRole.IndexOf("地上模式") < 0) + { + buttonItem87.Visible = false; + } + if (Utility.userRole.IndexOf("地下模式") < 0) + { + buttonItem88.Visible = false; + } + if (Utility.userRole.IndexOf("行走模式") < 0) + { + buttonItem27.Visible = false; + } + if (Utility.userRole.IndexOf("透明度设置") < 0) + { + sliderGroundTransSet1.Visible = false; + } + if (Utility.userRole.IndexOf("快速定位") < 0) + { + buttonItem91.Visible = false; + } + if (Utility.userRole.IndexOf("图层管理") < 0) + { + buttonItem1.Visible = false; + } + if (Utility.userRole.IndexOf("图例管理") < 0) + { + btnlegendSet.Visible = false; + } + if (Utility.userRole.IndexOf("全屏显示") < 0) + { + buttonItem89.Visible = false; + } + if (Utility.userRole.IndexOf("导出图片") < 0) + { + btnOutputJPG.Visible = false; + } + + } + #endregion + + #region 一键审核 + if (Utility.userRole.IndexOf("一键审核") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem11); + } + #endregion + + #region 红线审核 + if (Utility.userRole.IndexOf("红线审核") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem6); + } + #endregion + + #region 双屏对比 + if (Utility.userRole.IndexOf("双屏对比") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem9); + } + #endregion + + #region 文档管理 + if (Utility.userRole.IndexOf("文档管理") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem4); + } + #endregion + + #region 基础管理 + if (Utility.userRole.IndexOf("基础管理") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem14); + } + else + { + if (Utility.userRole.IndexOf("专题图审批") < 0) + { + buttonItemZTT3_2.Visible = false; + } + if (Utility.userRole.IndexOf("打印审批") < 0) + { + buttonItemZTT4_2.Visible = false; + } + if (Utility.userRole.IndexOf("拷贝审批") < 0) + { + buttonItemZTT5_2.Visible = false; + } + } + + #endregion + + if (ribbonControl1.Items.Count <= 0) + { + ribbonControl1.Visible = false; + } + } + + #region Fan Zhang 重构现有代码 + //初始化控件布局 + private void initLayout() + { + 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.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.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.labelX21.Width = (int)(this.labelX21.Width * myScreen); + this.labelX22.Width = (int)(this.labelX22.Width * myScreen); + this.labelX24.Width = (int)(this.labelX24.Width * myScreen); + } + sideBar1.Visible = false; + 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]); + } + + splitContainer1.Panel2Collapsed = true; + + buttonItem87.Checked = true;//默认地上模式 + ribbonTabItem1.Select(); //初始化状态为浏览 + + sideBarPanelItem3.Visible = false; + layerTree.Visible = false; + controlContainerItem3.Visible = false; + if (sideBarPanelItem4.Visible == true) + { + sideBar1.Visible = true; + controlContainerItem5.Visible = true; + } + else + { + sideBar1.Visible = false; + } + Refresh(); + sliderGroundTransSet1.Value = optiValue; + sliderItem1.Value = optiValue; + sliderItem2.Value = optiValue; + sliderItem3.Value = optiValue; + + } + + //初始化地球控件 + private void initGlobalControl() + { + //选择 + btnToolSelect = new GSOHudButton(); + btnToolSelect.SetImage(Application.StartupPath + "\\Resource\\image\\select1.png"); + btnToolSelect.FadeOut = false; + btnToolSelect.Align = EnumAlign.TopLeft; + btnToolSelect.SetOffset(20, 50); + btnToolSelect.Name = "1"; + btnToolSelect.HeightFixed = true; + btnToolSelect.WidthFixed = true; + globeControl1.Globe.AddHudControl(btnToolSelect); + globeControl2.Globe.AddHudControl(btnToolSelect); + + //浏览 + 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); + + //图例 + legend = new GSOHudButton(); + legend.SetImage(Application.StartupPath + "/Resource/图例P.jpg");//图例P + legend.SetOffset(0, 15); + legend.MinOpaque = 1; + legend.MaxOpaque = 1; + legend.FadeOut = false; + legend.Name = "legend"; + legend.Align = EnumAlign.BottomRight; + legend.Visible = false; + globeControl1.Globe.AddHudControl(legend); + + //实测 + legendSC = new GSOHudButton(); + legendSC.SetImage(Application.StartupPath + "/Resource/sc.jpg"); + legendSC.SetOffset(0, 15); + legendSC.MinOpaque = 1; + legendSC.MaxOpaque = 1; + legendSC.FadeOut = false; + legendSC.Name = "legendSC"; + legendSC.Align = EnumAlign.BottomRight; + globeControl1.Globe.AddHudControl(legendSC); + legendSC.Visible = false; + + //施工 + legendSG = new GSOHudButton(); + legendSG.SetImage(Application.StartupPath + "/Resource/sg.jpg"); + legendSG.SetOffset(0, 15); + legendSG.MinOpaque = 1; + legendSG.MaxOpaque = 1; + legendSG.FadeOut = false; + legendSG.Name = "legendSG"; + legendSG.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(legendSG); + legendSG.Visible = false; + + //管纵 + AddGZ(); + + 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; + globeControl1.Globe.IsReleaseMemOutOfView = true; + globeControl1.Globe.ControlPanel.Visible = true; + + globeControl2.Globe.UnderGroundFloor.Visible = false; + globeControl2.Globe.OverviewControl.Visible = false; + globeControl2.Globe.ScalerControl.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; + globeControl2.Globe.IsReleaseMemOutOfView = true; + globeControl2.Globe.ControlPanel.Visible = false; + + 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); + + //添加临时图层 + layerTemp = globeControl1.Globe.Layers.Add(Application.StartupPath + "\\tempLgdData.lgd"); + layerTemp2 = globeControl2.Globe.Layers.Add(Application.StartupPath + "\\tempLgdData2.lgd"); + if (layerTemp != null) + { + layerTemp.MaxVisibleAltitude = 1000; + } + + //添加城市7线图层 + 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"); + + //注册对应事件 + this.registerEvent(); + } + + //注册地球事件 + private bool registerEvent() + { + if (globeControl1 == null || globeControl2 == null) + { + return false; + } + 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); + + globeControl2.FeatureMouseClickEvent += new FeatureMouseClickEventHandler(globeControl2_FeatureMouseClickEvent); + globeControl2.CameraBeginMoveEvent += new CameraBeginMoveEventHandler(globeControl2_CameraBeginMoveEvent); + + globeControl1.MouseDoubleClick += new MouseEventHandler(globeControl1_MouseDoubleClick); + globeControl1.MouseClick += new MouseEventHandler(globeControl1_MouseClick); + globeControl1.MouseDown += new MouseEventHandler(globeControl1_MouseDown); + + globeControl2.MouseClick += new MouseEventHandler(globeControl2_MouseClick); + globeControl2.MouseDown += new MouseEventHandler(globeControl2_MouseDown); + + 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); + + return true; + } + + //加载两个地球数据 + private void loadData() + { + Thread t1 = new Thread(new ThreadStart(doLoadDataForGlobalControl1)); + t1.IsBackground = true; + t1.Start(); + + + } + + delegate void LoadDataForGlobalControl(); + + private void connectServer() + { + globeControl1.Globe.ConnectServer(Utility.serverip, Utility.serverport, "", ""); //加载locaServer中的数据 + globeControl2.Globe.ConnectServer(Utility.serverip, Utility.serverport, "", ""); //加载locaServer中的数据 + //初始化TreeView + // 勾选实测图层 + foreach (TreeNode tn in layerTree.Nodes) + { + if (tn.Nodes.Count > 0) + { + if (tn.Text == "实测数据") + { + tn.Checked = true; + foreach (TreeNode tnChild in tn.Nodes) + { + tnChild.Checked = true; + foreach (TreeNode tnGrandChild in tnChild.Nodes) + { + tnGrandChild.Checked = true; + } + } + } + } + } + } + + private void doLoadDataForGlobalControl1() + { + try + { + + globeControl1.Globe.Layers.MoveDown(10000); + //加载实测管线数据 + Utility.dataSource = globeControl1.Globe.DataManager.OpenOracleDataSource(Utility.DBServer.Trim() + "/" + Utility.dbdatabase.Trim(), "", "", Utility.userID, Utility.DBPassword); + + if (Utility.dataSource != null) + { + for (int j = 0; j < Utility.dataSource.DatasetCount; j++) + { + GSODataset dataset = Utility.dataSource.GetDatasetAt(j); + if (dataset != null && dictionaryNetLayerNameAndCaption.ContainsKey(dataset.Caption)) + { + dataset.Caption = dataset.Name; + globeControl1.Globe.Layers.Add(dataset); + } + } + } + //隐藏红线图层 + globeControl1.Globe.Layers.GetLayerByCaption("红线").Visible = false; + + //globleControl1中加载规划数据 + GSODataSource ghDS = globeControl1.Globe.DataManager.OpenOracleDataSource(Utility.ghdbip + "/" + Utility.ghdbname, "", "", Utility.ghdbuser, Utility.ghdbpwd); + if (ghDS != null) + { + for (int j = 0; j < ghDS.DatasetCount; j++) + { + GSODataset dataset = ghDS.GetDatasetAt(j); + if (dataset != null && dictionaryNetLayerNameAndCaption.ContainsKey(dataset.Caption)) + { + dataset.Caption = dataset.Name; + globeControl1.Globe.Layers.Add(dataset); + globeControl1.Globe.Layers[0].Visible = false; + } + } + } + + //globeControl1,globeControl2中加载施工数据 + GSODataSource sgDS = globeControl1.Globe.DataManager.OpenOracleDataSource(Utility.sgdbip + "/" + Utility.sgdbname, "", "", Utility.sgdbuser, Utility.sgdbpwd); + if (sgDS != null) + { + for (int m = 0; m < sgDS.DatasetCount; m++) + { + GSODataset dataset = sgDS.GetDatasetAt(m); + if (dataset != null && !dataset.Caption.Contains("SH") && dictionaryNetLayerNameAndCaption.ContainsKey(dataset.Caption)) + { + dataset.Caption = dataset.Name; + globeControl1.Globe.Layers.Add(dataset); + globeControl1.Globe.Layers[0].Visible = false; + + globeControl2.Globe.Layers.Add(dataset); + globeControl2.Globe.Layers[0].Visible = true; + } + } + } + + LoadDataForGlobalControl ss = new LoadDataForGlobalControl(connectServer); + ss(); + + } + catch (Exception ex) + { + MessageBox.Show(ex.Message); + } + } + + private void initLayerTree() + { + //加载临时图层节点 + layerManagerNode = new TreeNode(); + layerManagerNode.ImageIndex = 0; + layerManagerNode.SelectedImageIndex = 0; + layerManagerNode.Checked = true; + layerManagerNode.Text = "临时图层"; + layerTree.Nodes.Add(layerManagerNode); + + XmlDocument doc = new XmlDocument(); + doc.Load(filename); + XmlNodeList xmlLayerNodes = doc.SelectNodes("//layer"); + + foreach (XmlNode xmlLayerNode in xmlLayerNodes) + { + + //TODO LIST:创建一级TreeNode(实测、规划、施工) + TreeNode nodelayer = new TreeNode(); + string layerName = xmlLayerNode.Attributes["label"].Value; + nodelayer.Text = layerName; + nodelayer.Checked = false; + layerTree.Nodes.Add(nodelayer); + + XmlNodeList xmlChildLayerNodes = xmlLayerNode.ChildNodes; + foreach (XmlNode xmlChildLayerNode in xmlChildLayerNodes) + { + //TODO LIST:创建二级TreeNode节点 + TreeNode secondLevelNode = new TreeNode(); + string layerType = xmlChildLayerNode.Attributes["label"].Value; + secondLevelNode.Text = layerType; + + if (xmlChildLayerNode.Attributes["type"] != null) + { //道路图层特殊处理 + string type = xmlChildLayerNode.Attributes["type"].Value; + secondLevelNode.Tag = type + "|" + layerType; + } + else + { + secondLevelNode.Tag = layerType; + } + secondLevelNode.Checked = false; + nodelayer.Nodes.Add(secondLevelNode); + + XmlNodeList xmlActitualLayerNodes = xmlChildLayerNode.ChildNodes; + + foreach (XmlNode xmlActitualLayerNode in xmlActitualLayerNodes) + { + //TODO LIST:创建三级图层节点 + TreeNode layerNode = new TreeNode(); + string actutallylayerType = xmlActitualLayerNode.Attributes["type"].Value; + string actutallylayerName = xmlActitualLayerNode.Attributes["layer"].Value; + string actutallyLabelName = xmlActitualLayerNode.Attributes["label"].Value; + + layerNode.Text = actutallyLabelName; + layerNode.Tag = layerType + "|" + actutallyLabelName; + layerNode.Checked = false; + secondLevelNode.Nodes.Add(layerNode); + } + + } + + } + + } + + /** + * 读取Config.xml文件,初始化以下全局Map + * m_PipelineLayerNames:管线 + * workwellLayerNames:工井 + * valueLayerNames:阀门 + * instrumenLayerNames:附属物 + * pipefittingLayerNames:特征管点 + * sgPipeLayersNames:施工管线 + **/ + private void initGlobalMap() + { + XmlDocument doc = new XmlDocument(); + doc.Load(filename); + XmlNodeList xmlLayerNodes = doc.SelectNodes("//layerchild"); + + foreach (XmlNode xmlLayerNode in xmlLayerNodes) + { + string layerType = xmlLayerNode.Attributes["type"].Value; + string layerName1 = xmlLayerNode.Attributes["layer"].Value; + string layerchildName = xmlLayerNode.Attributes["label"].Value; + + dictionaryNetLayerNameAndCaption.Add(layerName1, layerchildName); + + if (layerType != "db") + { + if (xmlLayerNode.Attributes["isRoad"] != null) + { + roadLayerName = layerchildName; + } + } + else if (xmlLayerNode.Attributes["isPipeLine"] != null) + { + m_PipelineLayerNames.Add(layerchildName); + g1layername.Add(layerName1); + } + else if (xmlLayerNode.Attributes["isWorkWell"] != null) + { + workwellLayerNames.Add(layerchildName); + g1layername.Add(layerName1); + } + else if (xmlLayerNode.Attributes["isValve"] != null) + { + valueLayerNames.Add(layerchildName); + g1layername.Add(layerName1); + } + else if (xmlLayerNode.Attributes["isAccess"] != null) + { + instrumenLayerNames.Add(layerchildName); + g1layername.Add(layerName1); + } + else if (xmlLayerNode.Attributes["isCharacter"] != null) + { + pipefittingLayerNames.Add(layerchildName); + g1layername.Add(layerName1); + } + else if (xmlLayerNode.Attributes["isSgData"] != null) + { + sgPipeLayersNames.Add(layerchildName); + g1layername.Add(layerName1); + } + + } + } + + private void initMarkerTree() + { + 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); + } + } + } + } + + private void MainFrm_Load(object sender, EventArgs e) + { + + this.initGlobalControl(); + this.initGlobalMap(); + this.initLayerTree(); + this.initMarkerTree(); + this.initLayout(); + this.loadData(); + + + double x = Convert.ToDouble(Utility.Query_Roads["绿岛"].ToString().Split(',')[0]); + double y = Convert.ToDouble(Utility.Query_Roads["绿岛"].ToString().Split(',')[1]); + double z = Convert.ToDouble(Utility.Query_Roads["绿岛"].ToString().Split(',')[2]); + jumpToCameraState(x, y, z); + + + } + + #endregion + + /// + /// 每次gis服务加载时都会触发的 + /// + /// + /// + 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 dictionaryNetLayerNameAndCaption = new Dictionary(); + 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 配置用户权限 + /// + /// 向数据库插入功能列表 + /// + private void insertControlToDatabase() + { + ArrayList listItem = new ArrayList(); + List subListItem = new List(); + 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) + { + GSOCameraState camera = globeControl2.Globe.CameraState; + globeControl1.Globe.JumpToCameraState(camera); + } + } + + void globeControl1_BeforeSceneRenderEvent(object sender, BeforeSceneRenderEventArgs e) + { + if (globeControl1.Focused) + { + 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); + } + } + } + + /// + /// 检查数据集是否有坐标系信息 + /// + /// + /// + 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 = "0prj4" + lprjStr + ""; + + bSuccess = dataset.LoadProjectionFromESRIFile(dlg.FileName); + + string lprjFileName = strDataPath.Substring(0, strDataPath.LastIndexOf(".")) + ".lprj"; + StreamWriter writer = new StreamWriter(lprjFileName, false); + writer.Write(lprjFileContent); + writer.Close(); + + } + } + } + else + { + return true; + } + return bSuccess; + } + + /// + /// 矩形拉框结束事件处理函数 + /// + /// + /// + 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))); + */ + + int mapWidth = 0; + int mapHeight = 0; + Point pt = getUpperLeftPoint(pt1, pt2, out mapWidth, out mapHeight); + int rightBottomX = pt.X + mapWidth; + int rightBottomY = pt.Y + mapHeight; + Image myImg = new Bitmap(mapWidth, mapHeight); + Graphics g = Graphics.FromImage(myImg); + g.CopyFromScreen(pt, new Point(0, 0), new Size(rightBottomX, rightBottomY)); + + 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; + } + } + /// + /// 定位正北正90度俯视 + /// + /// + /// + /// + 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; + } + } + /// + /// layerTree选中后事件处理 + /// + /// + /// + 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); + } + /// + /// 树节点选中方法 + /// + /// + 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); + } + } + } + + } + /// + /// 改变所有子节点的状态 + /// + /// + /// + 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; + LayerFlyMenuItem.Visible = true; + } + + LayerSelectableMenuItem.Visible = true; + LayerEditableMenuItem.Visible = true; + SaveLayerMenuItem.Visible = true; + LayerFlyMenuItem.Visible = true; + 导出CADToolStripMenuItem1.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]); + if (layer != null) + { + LayerSelectableMenuItem.Checked = layer.Selectable; + LayerEditableMenuItem.Checked = layer.Editable; + } + else + { + return; + } + } + 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; + } + } + } + } + } + + /// + /// 删除临时添加的本地数据图层 + /// + /// + /// + 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); + for (int i = globeControl1.Globe.Layers.Count-1; i >=0; i--) + { + if (globeControl1.Globe.Layers[i].Caption == layer.Caption) + { + globeControl1.Globe.Layers.Remove(globeControl1.Globe.Layers[i]); + } + } + + 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 定位ToolStripMenuItem_Click(object sender, EventArgs e) + { + TreeNode node = layerTree.SelectedNode; + + if (node != null) + { + if (node.Parent.Text.Trim() == "临时图层") + { + GSOLayer lsLayer = globeControl1.Globe.Layers.GetLayerByCaption(node.Text.ToString()); + double x = lsLayer.LatLonBounds.Center.X; + double y = lsLayer.LatLonBounds.Center.Y; + if (x == 0 && y == 0) + { + x = lsLayer.Bounds.Center.X; + y = lsLayer.Bounds.Center.Y; + } + + globeControl1.Globe.FlyToPosition(new GSOPoint3d(x, y, 10), EnumAltitudeMode.Absolute); + } + else + { + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(node.Tag.ToString().Split('|')[1]); + + if (layer != null) + { + if (layer.Caption == "红线") + { + globeControl1.Globe.FlyToPosition(new GSOPoint3d(120.610963, 31.188121, 50), EnumAltitudeMode.Absolute, -4, 50, 1000); + globeControl1.Globe.FlyToPointSpeed = 10000000; + globeControl1.Globe.Action = EnumAction3D.SelectObject; + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = true; + } + globeControl1.Refresh(); + } + else + { + double x = layer.LatLonBounds.Center.X; + double y = layer.LatLonBounds.Center.Y; + globeControl1.Globe.FlyToPosition(new GSOPoint3d(x, y, 100), EnumAltitudeMode.Absolute); + } + } + } + } + else + { + return; + } + + } + + private void layerTree_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e) + { + if(this.layerTree.SelectedNode!=null) + { + if (this.layerTree.SelectedNode.Tag.ToString().Contains("|")) + { + string nodeTag = this.layerTree.SelectedNode.Tag.ToString().Split('|')[1]; + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(nodeTag); + if (layer != null) + { + if (layer.Caption == "红线") + { + globeControl1.Globe.FlyToPosition(new GSOPoint3d(120.610963, 31.188121, 50), EnumAltitudeMode.Absolute, -4, 50, 1000); + globeControl1.Globe.FlyToPointSpeed = 10000000; + globeControl1.Globe.Action = EnumAction3D.SelectObject; + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = true; + } + globeControl1.Refresh(); + } + else { + double x = layer.LatLonBounds.Center.X; + double y = layer.LatLonBounds.Center.Y; + globeControl1.Globe.FlyToPosition(new GSOPoint3d(x, y, 0), EnumAltitudeMode.Absolute); + } + } + } + if (this.layerTree.SelectedNode.Tag is GSOLayer) + { + GSOLayer layer = this.layerTree.SelectedNode.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 (this.layerTree.SelectedNode.Tag is GSOFeature) + { + GSOFeature feature = this.layerTree.SelectedNode.Tag as GSOFeature; + if (feature.Geometry != null) + { + globeControl1.Globe.FlyToPosition(feature.Geometry.GeoCenterPoint, EnumAltitudeMode.Absolute, 0, 0, 10); + } + else + { + globeControl1.Globe.FlyToFeature(feature); + } + } + } + } + + /// + /// 在三维场景移动时,隐藏气泡globeControl1 + /// + /// + /// + void globeControl1_CameraBeginMoveEvent(object sender, CameraBeginMoveEventArgs e) + { + if (featureTooltip.IsVisible()) + { + featureTooltip.HideBalloon(); + } + if (balloonEx.IsVisible()) + { + balloonEx.HideBalloon(); + } + } + + /// + /// 在三维场景移动时,隐藏气泡globeControl2 + /// + /// + /// + void globeControl2_CameraBeginMoveEvent(object sender, CameraBeginMoveEventArgs e) + { + if (featureTooltip2.IsVisible()) + { + featureTooltip2.HideBalloon(); + } + if (balloonEx2.IsVisible()) + { + balloonEx2.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(); + } + } + + #region Fan 横断面 + /// + /// 横断面分析、基线剖面分析、道路断面分析等 + /// + /// + /// + private static EnumTrackPolylineEndMode trackPolylineEndMode; + + void globeControl1_TrackPolylineEndEvent(object sender, TrackPolylineEndEventArgs e) + { + //横断面分析、道路横断面分析 + if (trackPolylineEndMode == EnumTrackPolylineEndMode.HDM_Analysis|| + trackPolylineEndMode == EnumTrackPolylineEndMode.DLDM_Analysis) + { + Dictionary hdmDic = SectionAnalysisTool.HDMAnalysis(this.globeControl1, + e.Polyline, this.m_PipelineLayerNames); + FrmHDMAnalysis3 frm = new FrmHDMAnalysis3(hdmDic, this.globeControl1, + trackPolylineEndMode); + frm.Show(this); + } + //基线剖面分析 + else if (trackPolylineEndMode == EnumTrackPolylineEndMode.JXPM_Analysis) + { + FrmBaseLineProfillAnalysis dlg = new FrmBaseLineProfillAnalysis(globeControl1.Globe, e.Polyline); + dlg.Show(this); + globeControl1.Globe.ClearLastTrackPolyline(); + } + else + { + + } + trackPolylineEndMode = EnumTrackPolylineEndMode.Default_Analysis; + } + #endregion + + private GSOFeatures PolygonIntersectAnalysis(GSOGeoPolygon3D polygon, string pipelinetype) + { + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(pipelinetype); + 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(pipelinetype, feats.Length); + return feats; + } + /// + /// 根据范围统计阀门、管线、工井等, 开挖分析, 挖方量分析 + /// + /// + /// + void globeControl1_TrackPolygonEndEvent(object sender, TrackPolygonEndEventArgs e) + { + if (globeControl1.Globe.Action == EnumAction3D.TrackPolygon && e.Polygon != null) + { + GSOGeoPolygon3D polygon = e.Polygon; + + switch (trackflag) + { + case "valvequery": + FrmValveStatistics frm = new FrmValveStatistics(globeControl1,polygon, new DataGridViewDelegate(InitDataGridViewX1)); + frm.Show(this); + globeControl1.Globe.Action = EnumAction3D.ActionNull; + break; + + case "PipelineDistanceStatistics": + FrmAllPipelineStatis frm1 = new FrmAllPipelineStatis(globeControl1, polygon, new DataGridViewDelegate(InitDataGridViewX1), m_PipelineLayerNames); + frm1.Show(this); + globeControl1.Globe.Action = EnumAction3D.ActionNull; + + break; + case "PipelineSpatialQuery": + FrmAllPipelineStatis.ShowForm(globeControl1,polygon,new DataGridViewDelegate(InitDataGridViewX1),m_PipelineLayerNames); + globeControl1.Globe.ClearAnalysis(); + globeControl1.Globe.Action = EnumAction3D.ActionNull; + + break; + case "workwellquery": + FrmAllWorkWellStatis frmWell = new FrmAllWorkWellStatis(globeControl1, polygon, new DataGridViewDelegate(InitDataGridViewX1)); + 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 "BSQDuoBianXiangStatis": + + GSOFeature f2 = new GSOFeature(); + f2.Geometry = e.Polygon; + f2.Geometry.AltitudeMode = EnumAltitudeMode.Absolute; + globeControl1.Globe.MemoryLayer.AddFeature(f2); + f2.Geometry.MoveZ(3); + workWellLen.Clear(); + List listBSQ = new List(); + + GSOFeatures bsqFeatures = PolygonIntersectAnalysis(e.Polygon, "标识器"); + listBSQ.Add(bsqFeatures); + + FrmBSQDuoBianXingStatis bsqFrm = new FrmBSQDuoBianXingStatis(workWellLen, globeControl1, listBSQ); + bsqFrm.Show(this); + globeControl1.Globe.Action = EnumAction3D.ActionNull; + break; + + case "": + break; + default: + break; + } + } + } + + #region 验证端口 + /* + /// + /// 验证端口 + /// + /// + 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 + + /// + /// 鼠标悬浮提示 + /// + /// + /// + 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); + } + } + + /// + /// 添加管线绘制完成事件, 红线工具绘制完成 + /// + /// + /// + 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; + + + } + } + + /// + /// 获取globeControl1中鼠标按下的坐标供区别鼠标右键和滚轮按下事件 + /// + /// + /// + void globeControl1_MouseDown(object sender, MouseEventArgs e) + { + mouseDownX1 = e.X; + mouseDownY1 = e.Y; + } + /// + /// 获取globeControl2中鼠标按下的坐标供区别鼠标右键和滚轮按下事件 + /// + /// + /// + void globeControl2_MouseDown(object sender, MouseEventArgs e) + { + mouseDownX2 = e.X; + mouseDownY2 = e.Y; + } + /// + /// + /// + /// + /// + void globeControl2_MouseClick(object sender, MouseEventArgs e) + { + if (e.Button == MouseButtons.Right) + { + if (e.X == mouseDownX2 && e.Y == mouseDownY2) + { + RightScreenToolMenu.Show(globeControl2, e.X, e.Y); + } + else + { + return; + } + } + } + /// + /// + /// + /// + /// + void globeControl1_MouseClick(object sender, MouseEventArgs e) + { + if (e.Button == MouseButtons.Left) + { + if (globeControl1.Globe.Action == EnumAction3D.VisibilityAnalysis) + { + buttonItemFX5_1.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; + + bsqPT = pt; + + if (buttonItemLS5.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 (e.X == mouseDownX1 && e.Y == mouseDownY1) + { + toolRightMenu.Show(globeControl1, e.X, e.Y); + if (buttonItemLS5.Checked) + { + buttonItemLS5.Checked = false; + } + } + else + { + return; + } + } + globeControl1.Refresh(); + } + + /// + /// 判断网络图片是否存在 + /// + /// + /// + 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; + } + + /// + /// 鼠标点击, 弹出气泡功能globeControl1 + /// + /// + /// + void globeControl1_FeatureMouseClickEvent(object sender, FeatureMouseClickEventArgs e) + { + GSOFeature feature = e.Feature; + + string str1 = ""; + if (feature != null) + { + if (feature.GetFieldDefn("图片编码") != null)// + { + str1 = GetBubbleInfo(feature, globeControl1); + if (RemoteFileExists(Utility.PicRootURL + feature.GetValue("图片编码").ToString())) + { + str1 += ""; + } + else if (RemoteFileExists(Utility.PicDefaultURL)) + { + str1 += ""; + } + } + else if (isFeatureContainsBianhao(feature)) //管线模型图层 + { + str1 = GetBubbleInfo(feature, globeControl1); + } + + 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; + } + } + } + + /// + /// 鼠标点击, 弹出气泡功能globeControl2 + /// + /// + /// + void globeControl2_FeatureMouseClickEvent(object sender, FeatureMouseClickEventArgs e) + { + GSOFeature feature = e.Feature; + + string str1 = ""; + if (feature != null) + { + if (feature.GetFieldDefn("图片编码") != null) // + { + str1 = GetBubbleInfo(feature, globeControl2); + if (RemoteFileExists(Utility.PicRootURL + feature.GetValue("图片编码").ToString())) + { + str1 += ""; + } + else if (RemoteFileExists(Utility.PicDefaultURL)) + { + str1 += ""; + } + } + else if (isFeatureContainsBianhao(feature)) //管线模型图层 + { + str1 = GetBubbleInfo(feature, globeControl2); + } + + if (str1 != "") + { + + featureTooltip2.HideBalloon(); + balloonEx2.HideBalloon(); + balloonEx2.SetSize(EnumSizeIndexEx.CONTENT_CX, 480); + balloonEx2.SetSize(EnumSizeIndexEx.CONTENT_CY, 420); + balloonEx2.ShowBalloon((int)e.MousePos.X, (int)e.MousePos.Y, str1); + + return; + } + } + } + + /// + /// 拼接气泡表格字符串 + /// + /// + /// + private string GetBubbleInfo(GSOFeature feature,GSOGlobeControl globeControl) + { + if (feature == null) + { + return ""; + } + string str = ""; + str = ""; + 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 += ""; + + 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.get_Fields(layerName, globeControl); + } + if (queryFields != null) + { + string[] param = { "," }; + string[] fieldNames = queryFields.Split(param, StringSplitOptions.RemoveEmptyEntries); + for (int j = 0; j < fieldNames.Length; 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 (name1 == "模型路径") + { + continue; + } + 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 (field1.Type == EnumFieldType.Double) + { + double dl1 = feature.GetFieldAsDouble(j); + if (!name1.Contains("管径") && !name1.Contains("电压") && !name1.Contains("角度")) + { + name1 += "_米"; + } + value1 = dl1.ToString("0.00"); + } + 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 (name2 == "模型路径") + { + continue; + } + + 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 (field2.Type == EnumFieldType.Double) + { + double dl2 = feature.GetFieldAsDouble(j + 1); + if (!name2.Contains("管径") && !name2.Contains("电压") && !name2.Contains("角度")) + { + name2 += "_米"; + } + value2 = dl2.ToString("0.00"); + } + else + { + if (!feature.IsFieldValueNull(j + 1)) + { + value2 = feature.GetValue(j + 1).ToString(); + } + } + } + } + + j++; + } + str += ""; + } + } + str += "
" + title + " " + feature.GetFieldAsString(featureIDFieldName) + "
" + + name1 + + "
" + + value1 + + "
" + + name2 + + "
" + + value2 + "
"; + return str; + } + + string filename = Utility.filename; + List g1layername = new List(); + + /// + /// 获取目标图层 + /// + /// + 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; + } + /// + /// 添加图层 + /// + /// + /// + /// + 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 = 5000; + return templayer.Visible; + } + catch (Exception ex) + { + return false; + } + } + /// + /// 菜单上的 三维导航 工具按钮 + /// + /// + /// + private void buttonItem86_Click(object sender, EventArgs e) + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + } + + /// + /// 地上模式 菜单按钮 + /// + /// + /// + 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(); + + } + } + /// + /// 地下模式 菜单按钮 + /// + /// + /// + 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(); + } + } + /// + /// 行走模式 菜单按钮 + /// + /// + /// + 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; + } + } + /// + /// 地面透明度设置 菜单 + /// + /// + /// + private void sliderGroundTransSet1_ValueChanged(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.sliderGroundTransSet1.Text); + + globeControl1.Globe.GroundOpaque = 100 - sliderGroundTransSet1.Value; + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(roadLayerName);//("180fd"); + if (layer != null) + { + layer.Opaque = 100 - sliderGroundTransSet1.Value; + } + //if (buttonItemSPDB.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; + } + /// + /// 图例 菜单按钮 + /// + /// + /// + 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(); + } + /// + /// 快速定位 菜单按钮 + /// + /// + /// + private void buttonItem91_Click(object sender, EventArgs e) // + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItem91.Text); + FrmFlyToPosition fly = new FrmFlyToPosition(globeControl1); + fly.Show(this); + } + /// + /// 图层管理 菜单按钮 + /// + /// + /// + 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; + + //修改图层管理与标注管理、覆土审查、水平净距分析、垂直净距分析和碰撞分析控件之间的逻辑关系 + controlContainerItem5.Visible = false; + sideBar1.Visible = false; + sideBarPanelItem4.Visible = false; + panel3.Visible = false; + sideBar1.ExpandedPanel = sideBarPanelItem3; + buttonItemBZ11.Checked = false; + + //20160624 + /* + if (sideBarPanelItem4.Visible == true) + { + sideBar1.Visible = true; + controlContainerItem5.Visible = true; + } + else + { + sideBar1.Visible = false; + } + */ + Refresh(); + + } + } + /// + /// 全屏显示 菜单按钮 + /// + /// + /// + 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; + /// + /// 全屏显示功能实现 + /// + 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(); + } + } + + /// + /// 设置窗体宽、高 + /// + /// + /// + private void SetFullScreen(int width, int height) + { + this.Width = width; + this.Height = height; + } + + /// + /// 全屏功能的快捷键F5 + /// + /// + /// + 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); + } + } + /* + /// + /// 输出地图 + /// + /// + /// + /// + 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; + } + * */ + + private Point getUpperLeftPoint(Point p1, Point p2, out int mapWidth, out int mapHeight) // + { + Rectangle rc = new Rectangle(); + + p1 = this.globeControl1.PointToScreen(p1); + p2 = this.globeControl1.PointToScreen(p2); + + int x = Screen.PrimaryScreen.Bounds.X; + int y = Screen.PrimaryScreen.Bounds.Y; + int screenWidth = SystemInformation.WorkingArea.Width; + int screenHeight = SystemInformation.WorkingArea.Height; + + if (p1.X < x) + rc.X = x; + else + rc.X = p1.X; + + if (p1.Y < y) + rc.Y = y; + else + rc.Y = p1.Y; + + p1.X = rc.Left; + p1.Y = rc.Top; + + if (p2.X > screenWidth) + p2.X = screenWidth; + else + p2.X = p2.X; + + if (p2.Y > screenHeight) + p2.Y = screenHeight; + else + p2.Y = p2.Y; + + rc.Width = p2.X - rc.X; + rc.Height = p2.Y - rc.Y; + + mapWidth = rc.Width; + mapHeight = rc.Height; + Point pt = new Point(rc.Left, rc.Top); + return pt; + } + + Image printImage; + /// + /// 打印 菜单 + /// + /// + /// + 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))); + */ + int mapWidth = 0; + int mapHeight = 0; + Point pt = getUpperLeftPoint(pt1, pt2, out mapWidth, out mapHeight); + int rightBottomX = pt.X + mapWidth; + int rightBottomY = pt.Y + mapHeight; + Image myImg = new Bitmap(mapWidth, mapHeight); + Graphics g = Graphics.FromImage(myImg); + g.CopyFromScreen(pt, new Point(0, 0), new Size(rightBottomX, rightBottomY)); + + + 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); + } + /// + /// 输出地图 菜单 + /// + /// + /// + private void btnOutputJPG_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btnOutputJPG.Text); + + //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))); + */ + int mapWidth = 0; + int mapHeight = 0; + Point pt = getUpperLeftPoint(pt1, pt2, out mapWidth, out mapHeight); + int rightBottomX = pt.X + mapWidth; + int rightBottomY = pt.Y + mapHeight; + Image myImg = new Bitmap(mapWidth, mapHeight); + Graphics g = Graphics.FromImage(myImg); + g.CopyFromScreen(pt, new Point(0, 0), new Size(rightBottomX, rightBottomY)); + + 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; + } + } + } + + /// + /// 统计管线的里程数 + /// + /// + /// + /// + 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; + } + + /// + /// 窗体下方属性表格 右键菜单中的 “定位”菜单 + /// + /// + /// + 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); + + } + + /// + /// 表格中右键 “单个闪烁” 菜单 + /// + /// + /// + private void LightMenu_Click(object sender, EventArgs e) + { + flashflag = "single"; + timer1.Start(); + } + /// + /// 表格中右键 “全部闪烁” 菜单 + /// + /// + /// + private void AllLightMenuItem_Click(object sender, EventArgs e) + { + flashflag = "all"; + timer1.Start(); + } + + /// + /// 使用timer实现管线的闪烁效果 + /// + /// + /// + 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; + } + } + + /// + /// 绘制线 菜单 + /// + /// + /// + private void btnAddLine_Click(object sender, EventArgs e) + { + globeControl1.Globe.DestLayerFeatureAdd = globeControl1.Globe.MemoryLayer; + globeControl1.Globe.Action = EnumAction3D.DrawPolyline; + } + /// + /// 绘制面 菜单 + /// + /// + /// + private void btnAddPolygon_Click(object sender, EventArgs e) + { + globeControl1.Globe.DestLayerFeatureAdd = globeControl1.Globe.MemoryLayer; + globeControl1.Globe.Action = EnumAction3D.DrawPolygon; + } + /// + /// 图层目录树 右键菜单中的 目标图层 菜单 + /// + /// + /// + 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; + } + } + /// + /// 图层目录树 右键菜单中的 可选择 菜单 + /// + /// + /// + 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; + } + /// + /// 图层目录树 右键菜单中的 可编辑 菜单 + /// + /// + /// + 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; + } + /// + /// 图层目录树 右键菜单中的 保存 菜单 + /// + /// + /// + 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(); + } + + /// + /// 根据多边形范围统计管线的里程 + /// + /// + /// + /// 返回查询到的管线要素集合 + 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 pipeLineDis = new Dictionary(); + Dictionary workWellLen = new Dictionary(); + + + + + /// + /// 查找指定图层中在 指定范围内的feature对象集合 + /// + /// + /// + /// + 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; + } + /// + /// 清除结果 菜单 + /// + /// + /// + private void buttonItem47_Click(object sender, EventArgs e) + { + globeControl1.Globe.ClearAnalysis(); + dataGridViewX1.DataSource = null; + panelOfTable.Visible = false; + clearFeatureHighLight(); + } + /// + /// 设置菜单的选中状态 + /// + private void ActionToolMenuChecked() + { + if (globeControl1.Globe.Action != EnumAction3D.TrackPolyline) + { + buttonItemFX2_1.Checked = false; + buttonItemFX2_4.Checked = false; + buttonItemFX2_3.Checked = false; + buttonItemFX4_3.Checked = false; + } + if (globeControl1.Globe.Action != EnumAction3D.NormalHit) + { + buttonItemFX3_6.Checked = false; + // ClearConnexityAnalysis(); + + buttonItemFX3_5.Checked = false; + // ClearCloseValvesAnalysis(); + } + if (globeControl1.Globe.Action != EnumAction3D.TrackPolygon) + { + buttonItemFX4_2.Checked = false; + buttonItemFX4_1.Checked = false; + } + } + + /// + /// 主窗体关闭事件处理 + /// + /// + /// + private void MainFrm_FormClosing(object sender, FormClosingEventArgs e) + { + + if (MessageBox.Show("是否退出系统?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) + { + e.Cancel = true; + } + else { + globeControl1.Globe.MemoryLayer.SaveAs(Application.StartupPath + "/MyPlace.kml"); + } + + //saveLayerList(layerManagerNode.Nodes); + //注销id号为103的热键设定 + // UnregisterHotKey(Handle, 103); + } + + /// + /// 显示流向 功能 + /// + /// + /// + /// + 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(); + } + + FrmCloseValves frm; + + FrmBoosterValvers frmbooster = null; + + /// + /// 垂直净距分析 功能界面中的 选择图层复选框 选中状态改变事件处理 + /// + /// + /// + 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(); + } + /// + /// 水平净距分析 功能界面中的 选择图层复选框 选中状态改变事件处理 + /// + /// + /// + 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(); + } + /// + /// 垂直净距分析 功能界面中的 选择管线复选框 选中状态改变事件处理 + /// + /// + /// + private void checkBoxX1_CheckedChanged(object sender, EventArgs e) + { + clearFeatureHighLight(); + if (checkBoxX1.Checked) + { + comboBoxEx1.SelectedItem = null; + 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; + } + } + /// + /// 水平净距分析 功能界面中的 选择管线复选框 选中状态改变事件处理 + /// + /// + /// + private void checkBoxX1_CheckedChanged_shuiping(object sender, EventArgs e) + { + clearFeatureHighLight();//清除高亮 + if (checkBoxX7.Checked) + { + comboBoxEx4.SelectedItem = null; + 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(); + /// + /// 垂直净距分析 功能界面中的 选择图层下拉框 选中项改变 事件处理 + /// + /// + /// + 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; + } + } + } + /// + /// 水平净距分析 功能界面中的 选择图层下拉框 选中项改变 事件处理 + /// + /// + /// + 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 featCount = new Dictionary(); + Dictionary featLenth = new Dictionary(); + Dictionary m_FeaturesWithBianhao = new Dictionary();//记录编号和对应的标注点的位置 + GSOFeatures polygonJingJuAnalysises = new GSOFeatures(); + + /// + /// 垂直净距分析 功能界面中的 开始分析按钮 事件处理 + /// + /// + /// + 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; + } + + /// + /// 在指定的两点组成的线的中间添加一个marker对象,并将marker对象添加到指定的图层中 + /// + /// + /// + /// + /// + /// + 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; + } + + /// + /// 计算指定feature对象与除了该feature所在图层之外的 所有管线图层中的所有feature对象 的垂直距离 并在表格中记录符合要求的管线 + /// + /// + /// + /// + /// + private void VerticalDistanceAnalysis(string type, GSOFeature selectedFeature, List _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(); + } + /// + /// 垂直净距分析中 表格行的 双击定位 功能。 与覆土分析的实现方法不同,主要原因是需要标注垂距 + /// + /// + /// + 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); + } + } + } + } + + /// + /// 水平净距分析 功能界面中 开始分析按钮 的事件处理 + /// + /// + /// + 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; + } + + + /// + /// 计算指定feature对象与除了该feature所在图层之外的 所有管线图层中的所有feature对象 的水平距离 并记录符合要求的管线 功能 + /// + /// + /// + /// + /// + private void HorizontalDistanceAnalysis(GSOFeature selectedFeature, List _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)); + } + } + } + } + } + /// + /// 水平净距分析 功能界面中 表格的 双击定位 功能 + /// + /// + /// + 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); + } + } + } + } + } + /// + /// 碰撞分析 功能界面中 开始分析按钮 事件处理 + /// + /// + /// + 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; + } + /// + /// 碰撞分析功能界面中 表格的 双击定位 功能 + /// + /// + /// + 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); + } + } + } + } + + + + /// + /// 覆土分析功能操作界面中的 选择管线 复选框选中状态改变事件处理 + /// + /// + /// + private void checkBoxX5_CheckedChanged(object sender, EventArgs e) + { + clearFeatureHighLight(); + if (checkBoxX5.Checked) + { + comboBoxEx3.SelectedItem = null; + 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; + } + } + /// + /// 覆土分析功能操作界面中的 选择图层 复选框选中状态改变事件处理 + /// + /// + /// + 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(); + } + /// + /// 覆土分析功能操作界面中的 图层下拉框选中项改变事件处理 + /// + /// + /// + 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; + } + } + } + /// + /// 覆土分析功能操作界面中的 开始分析 按钮事件处理 + /// + /// + /// + 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; + + + GSOPoint3d markerPosition = new GSOPoint3d(); + 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]; + GSOPoint3d pt = new GSOPoint3d(); + + 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"); + + pt.X = pts[m].X; + pt.Y = pts[m].Y; + pt.Z = 0; + markerPosition = LabelVerticalDistance(layerTemp, pts[m], pt, Convert.ToDouble(dataGridViewX7.Rows[idx].Cells[2].Value), true); + 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]; + GSOPoint3d pt = new GSOPoint3d(); + 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"); + + pt.X = pts[m].X; + pt.Y = pts[m].Y; + pt.Z = 0; + markerPosition = LabelVerticalDistance(layerTemp, pts[m], pt, Convert.ToDouble(dataGridViewX7.Rows[idx].Cells[2].Value), true); + + 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; + } + + /// + /// 覆土分析中 表格的 双击定位 功能 + /// + /// + /// + 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); + } + } + } + } + } + /// + /// 覆土分析功能操作界面中的 导出Excel按钮 事件处理 + /// + /// + /// + private void buttonX10_Click(object sender, EventArgs e) + { + if (dataGridViewX7.Rows.Count > 0) + { + ExportExcel("覆土分析", dataGridViewX7, null); + } + else + { + MessageBox.Show("表格内容为空!", "提示"); + } + } + /// + /// 覆土分析功能操作界面底部的 关闭 按钮事件处理 + /// + /// + /// + 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(); + layerTemp.RemoveAllFeature(); + + if (buttonItem1.Checked) + { + sideBar1.ExpandedPanel = sideBarPanelItem3; + } + else + { + sideBar1.Visible = false; + } + globeControl1.Refresh(); + + //Refresh(); + } + + + /// + /// 垂直净距分析 功能界面中 清除分析结果按钮 事件处理 + /// + /// + /// + 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(); + } + /// + /// 水平净距分析 功能界面中 清除分析结果按钮 事件处理 + /// + /// + /// + 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(); + } + + /// + /// 垂直净距分析功能界面中 关闭按钮 事件处理 + /// + /// + /// + 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(); + } + /// + /// 水平净距分析功能界面中 删除缓冲区按钮 事件处理 + /// + /// + /// + private void buttonX14_Click(object sender, EventArgs e) + { + 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(); + } + + /// + /// 导出指定DataGridView控件中的内容 + /// + /// + /// + 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(); + } + } + } + } + + /// + /// 垂直净距分析功能界面中 导出Excel按钮 事件处理 + /// + /// + /// + private void buttonX4_Click(object sender, EventArgs e) + { + if (dataGridViewX3.Rows.Count > 0) + { + ExportExcel("垂直净距分析", dataGridViewX3, listBox1); + } + else + { + MessageBox.Show("表格内容为空!", "提示"); + } + } + /// + /// 水平净距分析功能界面中 导出Excel按钮 事件处理 + /// + /// + /// + private void buttonX4_Click_shuiping(object sender, EventArgs e) + { + if (dataGridViewX9.Rows.Count > 0) + { + ExportExcel("水平净距分析", dataGridViewX9, listBox3); + } + else + { + MessageBox.Show("表格内容为空!", "提示"); + } + } + + + /// + /// 清除所有坑 菜单 + /// + /// + /// + private void buttonItem3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItem3.Text); + + globeControl1.Globe.RemoveAllPits(); + } + + //} + /// + /// 大气层 菜单 + /// + /// + /// + private void buttonItem17_Click_1(object sender, EventArgs e) + { + globeControl1.Globe.Atmosphere.Visible = !globeControl1.Globe.Atmosphere.Visible; + buttonItemSH1.Checked = globeControl1.Globe.Atmosphere.Visible; + globeControl1.Refresh(); + } + /// + /// 经纬网 菜单 + /// + /// + /// + private void buttonItem20_Click(object sender, EventArgs e) + { + globeControl1.Globe.LatLonGrid.Visible = !globeControl1.Globe.LatLonGrid.Visible; + buttonItemSH3.Checked = globeControl1.Globe.LatLonGrid.Visible; + globeControl1.Globe.Refresh(); + } + /// + /// 状态条 菜单 + /// + /// + /// + private void buttonItem21_Click_1(object sender, EventArgs e) + { + globeControl1.Globe.StatusBar.Visible = !globeControl1.Globe.StatusBar.Visible; + buttonItemSH4.Checked = globeControl1.Globe.StatusBar.Visible; + globeControl1.Globe.Refresh(); + } + + + + /// + /// 添加指定路径下的数据 功能 + /// + /// + /// + 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); + //CheckDatasetGeoReference(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; + } + return objRes; + } + /// + /// 刷新目录树 功能 + /// + 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); + } + } + /// + /// 判断图层是否包含字段列表 + /// + /// + /// + 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; + } + + /// + /// 统计指定图层在指定范围内的所有feature对象 + /// + /// + /// + /// + 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; + } + /// + /// 碰撞分析功能界面中 选择管线复选框 选中状态改变事件处理 + /// + /// + /// + private void checkBoxX3_CheckedChanged(object sender, EventArgs e) + { + clearFeatureHighLight(); + if (checkBoxX3.Checked) + { + comboBoxEx2.SelectedItem = null; + 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; + } + } + /// + /// 碰撞分析功能界面中 选择图层复选框 选中状态改变事件处理 + /// + /// + /// + 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(); + } + /// + /// 碰撞分析功能界面中 选择图层下拉框 选中项改变事件处理 + /// + /// + /// + 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; + } + } + } + /// + /// 清除所有图层中的所有feature对象的高亮状态 功能 + /// + 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); + } + } + } + } + for (int i = 0; i < globeControl2.Globe.Layers.Count; i++) + { + GSOLayer layer = globeControl2.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; + } + } + } + + if (globeControl1.Globe.Action == EnumAction3D.SelectObject) + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + //globeControl1.Globe.Action = EnumAction3D.SelectObject; + } + } + + /// + /// 碰撞分析功能界面中 清除分析结果按钮 事件处理 + /// + /// + /// + 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(); + } + /// + /// 碰撞分析功能界面中 导出Excel按钮 事件处理 + /// + /// + /// + private void buttonX6_Click(object sender, EventArgs e) + { + if (dataGridViewX5.Rows.Count > 0) + { + ExportExcel("碰撞分析", dataGridViewX5, listBox2); + } + else + { + MessageBox.Show("表格内容为空!", "提示"); + } + } + /// + /// 导出CAD 菜单 + /// + /// + /// + private void btnExportCAD_Click(object sender, EventArgs e) + { + FrmExportCADS frm = new FrmExportCADS(globeControl1, m_PipelineLayerNames); + frm.ShowDialog(); + } + + ///// + ///// 区域分析 菜单 + ///// + ///// + ///// + //private void buttonItem50_Click(object sender, EventArgs e) + //{ + // buttonItem50.Checked = !buttonItem50.Checked; + // ribbonBarQY.Visible = buttonItem50.Checked; + // ribbonBarQY.Location = new Point(0, 0); + //} + + + /// + /// 连接数据库 菜单事件处理 + /// + /// + /// + 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; + } + } + } + /// + /// 数据验证 菜单 + /// + /// + /// + private void buttonItem80_Click(object sender, EventArgs e) + { + FrmValiData frm = new FrmValiData(globeControl1); + frm.ShowDialog(); + } + /// + /// 根据指定图层创建图层节点并将节点添加到图层管理节点的子节点集合中 + /// + /// + 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; + + if (!layerManagerNode.Nodes.Contains(node)) + { + layerManagerNode.Nodes.Insert(0, node); + layerManagerNode.Expand(); + } + } + } + /// + /// 数据库备份 菜单 + /// + /// + /// + 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(); + } + } + } + + + + #region Fan 去掉 + //GSOFeature emitterFeature; // 粒子要素 + /// + /// 添加火苗 功能 + /// + /// + /// + /// + 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); + + } + /// + /// 添加喷泉 功能 + /// + /// + /// + /// + 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); + } + #endregion + + /// + /// 获取指定图层中最后一个feature对象的名称对应的整数 + /// + /// + /// + 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; + } + /// + /// 设置除指定标注图层之外的所有标注图层不可见 + /// + /// + 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; + } + } + } + } + } + + /// + /// 判断选中的对象是否为管线 + /// + /// 被选中管线 + /// 返回一根线 + 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; + } + + /// + /// 获取指定两点组成的线的长度 功能 + /// + /// + /// + /// + 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; + } + + /// + /// 图层节点树中 节点 右键单击事件处理 + /// + /// + /// + 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; + } + } + } + } + } + + /// + /// 标注管理、传感器管理 图层目录树的右键菜单中的 刷新列表 菜单 + /// + /// + /// + 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); + } + } + /// + /// 给指定的图层节点添加代表feature对象的子节点 + /// + /// + private void RefreshTreeNodeLayerFeatureList(TreeNode layerTreeNode) + { + layerTreeNode.Nodes.Clear(); + GSOLayer layer = (GSOLayer)layerTreeNode.Tag; + // 只将类型为内存数据集的图层列出,如果是其它类型的数据集可能数据量太大,没发显示在树控件中 + if (layer.Dataset is GSOFeatureDataset) + { + VisitFeature3Ds(layer.GetAllFeatures(), layerTreeNode); + } + } + + /// + /// 标注管理、传感器管理 图层目录树的右键菜单中的 移除所有 菜单 + /// + /// + /// + 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(); + } + } + + /// + /// 图层目录树的 节点对应的复选框选中状态改变事件处理 + /// + /// + /// + private void layerMarkerTree_AfterCheck(object sender, TreeViewEventArgs e) + { + if (e.Action != TreeViewAction.Unknown) + { + CheckTreeNode(e.Node, e.Node.Checked); + } + } + /// + /// 改变指定节点对应的复选框的选中状态 + /// + /// + /// + private void CheckTreeNode(TreeNode node, Boolean bChecked) + { + CheckChildTreeNode(node, bChecked); + globeControl1.Globe.Refresh(); + } + /// + /// 改变指定节点的子节点对应的复选框的选中状态 + /// + /// + /// + 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); + } + } + /// + /// 标注管理、传感器管理 目录树中的feature节点的右键菜单中的 删除 菜单 + /// + /// + /// + 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(); + } + } + + /// + /// 双屏对比 菜单 + /// + /// + /// + //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(); + // } + //} + /// + /// 模拟分析 菜单 + /// + /// + /// + //private void buttonItem51_Click(object sender, EventArgs e) + //{ + // buttonItem51.Checked = !buttonItem51.Checked; + // ribbonBarMN.Visible = buttonItem51.Checked; + // ribbonBarMN.Location = new Point(0, 0); + //} + + /// + /// 双屏设置 菜单 + /// + /// + /// + //private void buttonItem96_Click(object sender, EventArgs e) + //{ + // FrmLayerControl frm = new FrmLayerControl(layerTree,globeControl1,globeControl2); + // frm.Show(this); + //} + /// + /// 双屏联动 菜单 + /// + /// + /// + //private void buttonItem95_Click(object sender, EventArgs e) + //{ + // buttonItem95.Checked = !buttonItem95.Checked; + //} + ///// + /// 添加用户仓库 菜单 + /// + /// + /// + private void buttonItem108_Click(object sender, EventArgs e) + { + FrmUserRepo frm = new FrmUserRepo(-1); + frm.ShowDialog(); + } + /// + /// 用户仓库管理 菜单 + /// + /// + /// + private void buttonItem111_Click(object sender, EventArgs e) + { + FrmUserRepoMgr frm = new FrmUserRepoMgr(); + frm.ShowDialog(); + } + /// + /// 添加分系统 菜单 + /// + /// + /// + private void buttonItem112_Click(object sender, EventArgs e) + { + //FrmAPP frm = new FrmAPP(-1); + //frm.ShowDialog(); + } + /// + /// 分系统管理 菜单 + /// + /// + /// + private void buttonItem113_Click(object sender, EventArgs e) + { + //FrmAPPMgr frm = new FrmAPPMgr(); + //frm.ShowDialog(); + } + /// + /// 添加操作 菜单 + /// + /// + /// + private void buttonItem114_Click(object sender, EventArgs e) + { + FrmOper frm = new FrmOper(-1); + frm.ShowDialog(); + } + /// + /// 操作管理 菜单 + /// + /// + /// + private void buttonItem115_Click(object sender, EventArgs e) + { + FrmOperMgr frm = new FrmOperMgr(); + frm.ShowDialog(); + } + /// + /// 添加资源 菜单 + /// + /// + /// + private void buttonItem116_Click(object sender, EventArgs e) + { + FrmRESC frm = new FrmRESC(-1); + frm.ShowDialog(); + } + /// + /// 资源管理 菜单 + /// + /// + /// + private void buttonItem117_Click(object sender, EventArgs e) + { + FrmRESCMgr frm = new FrmRESCMgr(); + frm.ShowDialog(); + } + /// + /// 添加权限 菜单 + /// + /// + /// + private void buttonItem118_Click(object sender, EventArgs e) + { + FrmPerm frm = new FrmPerm(-1); + frm.ShowDialog(); + } + /// + /// 权限管理 菜单 + /// + /// + /// + private void buttonItem119_Click(object sender, EventArgs e) + { + FrmPermMgr frm = new FrmPermMgr(); + frm.ShowDialog(); + } + /// + /// 添加访问控制 菜单 + /// + /// + /// + private void buttonItem120_Click(object sender, EventArgs e) + { + FrmAccess frm = new FrmAccess(-1); + frm.ShowDialog(); + } + /// + /// 访问控制管理 菜单 + /// + /// + /// + private void buttonItem121_Click(object sender, EventArgs e) + { + FrmAccessMgr frm = new FrmAccessMgr(); + frm.ShowDialog(); + } + /// + /// 部门类型管理 菜单 + /// + /// + /// + private void buttonItem122_Click(object sender, EventArgs e) + { + FrmRegionTypeMgr frm = new FrmRegionTypeMgr(); + frm.ShowDialog(); + } + /// + /// 添加用户 菜单 + /// + /// + /// + private void buttonItem127_Click(object sender, EventArgs e) + { + FrmUserAdd frm = new FrmUserAdd(-1); + frm.ShowDialog(); + } + /// + /// 用户信息管理 菜单 + /// + /// + /// + private void buttonItem128_Click_1(object sender, EventArgs e) + { + FrmUserManager frm = new FrmUserManager(); + frm.ShowDialog(); + } + /// + /// 添加角色 菜单 + /// + /// + /// + private void 添加角色_Click(object sender, EventArgs e) + { + FrmRole frm = new FrmRole(-1); + frm.ShowDialog(); + } + /// + /// 所有角色管理 菜单 + /// + /// + /// + private void 角色管理_Click(object sender, EventArgs e) + { + FrmRoleMgr frm = new FrmRoleMgr(); + frm.ShowDialog(); + } + + /// + /// 部门角色管理 菜单 + /// + /// + /// + private void buttonItem133_Click(object sender, EventArgs e) + { + FrmRegionRoleMgr frm = new FrmRegionRoleMgr(); + frm.ShowDialog(); + } + /// + /// 部门管理 菜单 + /// + /// + /// + private void buttonItem130_Click(object sender, EventArgs e) + { + FrmRegionMgr frm = new FrmRegionMgr(); + frm.ShowDialog(); + } + + /// + /// 日志管理 菜单 + /// + /// + /// + private void buttonItem135_Click(object sender, EventArgs e) + { + FrmLogManager frm = new FrmLogManager(); + frm.ShowDialog(); + } + /// + /// 传感器信息查询 菜单 + /// + /// + /// + 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); + } + } + } + /// + /// 根据指定的图层的caption属性的值在配置文件中查找对应的数据库中的表的名称 + /// + /// 图层的caption属性的值 + /// 对应的数据库中的表的名称 + 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; + } + /// + /// 根据数据库中的表的名称 查找对应的表中的字段名称的集合 + /// + /// 数据库中的表的名称 + /// 对应的表中的字段名称的集合 + 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; + } + + /// + /// 历史曲线查询 菜单 + /// + /// + /// + 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; + /// + /// 传感器在线报警 菜单 + /// + /// + /// + 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); + } + /// + /// 传感器报警 功能中的 定时器 的触发事件处理 + /// + /// + /// + 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; + } + } + } + } + } + } + } + + + /// + /// 沿线运动 菜单 + /// + /// + /// + private void buttonItem138_Click(object sender, EventArgs e) + { + if (globeControl1.Globe.SelectedObject == null) + { + MessageBox.Show("请先选择一条线!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + return; + } + + GSOFeature lineFeature = globeControl1.Globe.SelectedObject; + if (lineFeature.Geometry == null || lineFeature.Geometry.Type != EnumGeometryType.GeoPolyline3D) + { + MessageBox.Show("请先选择一条线!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + return; + } + + OpenFileDialog dlg = new OpenFileDialog(); + dlg.Filter = "*.gcm;*.3ds|*.gcm;*.3ds|*.3ds|*.3ds|*.gcm|*.gcm"; + if (dlg.ShowDialog() == DialogResult.OK) + { + GSOGeoModel model = new GSOGeoModel(); + model.FilePath = dlg.FileName; + + GSOGeoDynamicRoute dynamicRoute = new GSOGeoDynamicRoute(); + dynamicRoute.ActorGeometry = model; + + GSORoute route = new GSORoute(); + GSOGeoPolyline3D geoline = (GSOGeoPolyline3D)lineFeature.Geometry; + for (int i = 0; i < geoline[0].Count; i++) + { + route.Add(geoline[0][i]); + } + route.CircleRoute = false; + route.Speed = 30; + route.RotateSpeed = 50; + route.AltitudeMode = geoline.AltitudeMode; + dynamicRoute.Route = route; + + GSOFeature feature = new GSOFeature(); + + dynamicRoute.Play(); + feature.Geometry = dynamicRoute; + + //GSOLabel gsoLabel = new GSOLabel(); + //gsoLabel.Text = "模型测试"; + //feature.Label = gsoLabel; + globeControl1.Globe.MinModelVisibleSize = 0; + + globeControl1.Globe.MemoryLayer.AddFeature(feature); + globeControl1.Globe.Refresh(); + } + } + /// + /// 回退 菜单 + /// + /// + /// + private void buttonItem99_Click(object sender, EventArgs e) + { + globeControl1.Globe.UnDoEdit(); + } + /// + /// 前进 菜单 + /// + /// + /// + private void buttonItem100_Click(object sender, EventArgs e) + { + globeControl1.Globe.ReDoEdit(); + } + /// + /// 水平净距 功能界面中的 标签内容改变事件处理 + /// + /// + /// + 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() + "米的管线有:"; + } + } + } + /// + /// 垂直净距 功能界面中的 标签内容改变事件处理 + /// + /// + /// + 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() + "米的管线有:"; + } + } + } + /// + /// 覆土分析 功能界面中的 标签内容改变事件处理 + /// + /// + /// + 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() + "米的管线有:"; + } + } + } + + /// + /// 传感器分类查询 全区域 菜单 + /// + /// + /// + private void buttonItemSensor全区域查询_Click(object sender, EventArgs e) + { + FrmAccessoriesSensor.ShowForm(globeControl1, instrumenLayerNames, 0); + } + /// + /// 传感器分类查询 绘制区域 菜单 + /// + /// + /// + private void buttonItemSensor绘制区域查询_Click(object sender, EventArgs e) + { + FrmAccessoriesSensor.ShowForm(globeControl1, instrumenLayerNames, 1); + } + + + /// + /// 碰撞分析 功能界面中 关闭按钮 事件处理 + /// + /// + /// + 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(); + } + /// + /// 覆土分析 功能界面中的 清除分析结果 按钮事件处理 + /// + /// + /// + 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(); + } + /// + /// 数字预处理 功能 + /// + /// + /// + private void 数字预处理buttonItem140_Click(object sender, EventArgs e) + { + FrmEditShapeFile frm = new FrmEditShapeFile(globeControl1); + frm.ShowDialog(this); + } + + + /// + /// 导出矢量 功能 将图层导出为kml和shp格式数据 + /// + /// + /// + private void 导出矢量buttonItem140_Click(object sender, EventArgs e) + { + List listVectorNames = new List(); + for (int i = 0; i < m_PipelineLayerNames.Count; i++) + { + 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 = ""; + /// + /// 绘制城市七线 功能按钮 + /// + /// + /// + 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; + } + } + } + /// + /// 七线审核 功能按钮 + /// + /// + /// + private void 七线审核buttonItem141_Click(object sender, EventArgs e) + { + FrmCityServerLineAnalysis frm = new FrmCityServerLineAnalysis(globeControl1, m_PipelineLayerNames); + frm.ShowDialog(this); + } + + /// + /// 间距分析 开始分析按钮 分析绘制的七线和管线的距离是否符合标准 + /// + /// + /// + 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; + } + /// + /// 间距分析 清除分析结果 + /// + /// + /// + 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(); + } + /// + /// 间距分析 导出Excel按钮 将间距分析的结果以Excel表格的形式导出 + /// + /// + /// + private void buttonExportExcel_Click(object sender, EventArgs e) + { + if (dataGridViewAnalysisResult.Rows.Count > 0) + { + ExportExcel("间距分析", dataGridViewAnalysisResult, listBoxStasticsResult); + } + else + { + MessageBox.Show("表格内容为空!", "提示"); + } + } + /// + /// 间距分析 关闭按钮 + /// + /// + /// + 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(); + } + /// + /// 间距分析 分析结果表格双击定位 + /// + /// + /// + 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); + } + } + } + } + /// + /// 间距分析 选择管线复选框 + /// + /// + /// + private void checkBoxSelectPipeline_CheckedChanged(object sender, EventArgs e) + { + clearFeatureHighLight();//清除高亮 + if (checkBoxSelectPipeline.Checked) + { + comboBoxLayer.SelectedItem = null; + 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; + } + } + /// + /// 间距分析 选择图层复选框 + /// + /// + /// + 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(); + } + /// + /// 间距分析 选择图层下拉框 + /// + /// + /// + 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; + } + } + } + + + + /// + /// 管线自动缩进 菜单 + /// + /// + /// + private void 管线自动缩进buttonItem140_Click(object sender, EventArgs e) + { + FrmPipelineIndented frm = new FrmPipelineIndented(globeControl1, m_PipelineLayerNames, workwellLayerNames); + 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 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); + // } + //} + + /// + /// 统计指定图层在指定范围内的所有feature对象 + /// + /// + /// + /// + 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) + { + 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 setLayerVisible(string layerName) + { + GSOLayer templayer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + if (templayer != null) + { + templayer.Visible = false; + } + globeControl1.Globe.Refresh(); + } + + /// + /// 连接数据库 + /// + /// + /// + private void buttonItem129_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL4_1.Text); + + FrmDatabaseParaSetting2 frm = new FrmDatabaseParaSetting2(globeControl1); + if (frm.ShowDialog() == DialogResult.OK) + { + ds = FrmDatabaseParaSetting2.ds; + if (ds != null) + { + ds.IsCloseSaved = false; + } + } + } + + /// + /// 一键审核---导入数据 + /// + /// + /// + private void buttonItem127_Click_2(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, "打开数据"); + + try + { + //if (shds == null) + //{ + //没连的话,直接连接审核库; //审核库配置读配置文件 + string dbIp = Utility.sgdbip; + string database = Utility.sgdbname; + string user = Utility.sgdbuser; + string pass = Utility.sgdbpwd; + /* + 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; + //} + } + catch (Exception ex) + { + LogError.PublishError(ex); + MessageBox.Show("内存过载请清理内存,并重新启动规划分析!", "提示"); + return; + } + + } + + /// + ///自动导出图片 + /// + /// + /// + private void buttonItem130_Click_1(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, "导出审核图"); + + 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))); + */ + + int mapWidth = 0; + int mapHeight = 0; + Point pt = getUpperLeftPoint(pt1, pt2, out mapWidth, out mapHeight); + int rightBottomX = pt.X + mapWidth; + int rightBottomY = pt.Y + mapHeight; + Image myImg = new Bitmap(mapWidth, mapHeight); + Graphics g = Graphics.FromImage(myImg); + g.CopyFromScreen(pt, new Point(0, 0), new Size(rightBottomX, rightBottomY)); + + 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; + } + } + } + /// + /// 一键审核功能 + ///
+ /// + /// + private void buttonItem128_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItem128.Text); + //垂直净距标准 + + frmSh = new FrmYJSHTC(globeControl1, globeControl2,layerTree); + + if (frmSh.ShowDialog() == DialogResult.OK) + { + frmWait = new FrmWait("一键审核……"); + frmWait.Location = new Point(this.Width - frmWait.Width - 10, this.Height - frmWait.Height - 50); + frmWait.Owner = this; + frmWait.Show(); + Thread thread = new Thread(new ThreadStart(doWork)); + thread.IsBackground = true; + thread.Start(); + } + } + + void doWork() + { + FrmShResult frmShResult = null; + + double dVerticalJingJuBiaoZhun = 1, dHorizontalJingJuBiaoZhun = 1; + if (frmSh.rukuLayer != null) + { + #region + this.Invoke((EventHandler)delegate + { + try + { + List managerLayerList = new List(); + for (int i = 0; i < layerManagerNode.Nodes.Count; i++) + { + managerLayerList.Add(layerManagerNode.Nodes[i].Text); + } + if (!managerLayerList.Contains(frmSh.rukuLayer.Caption)) + { + TreeNode node = new TreeNode(); + node.Tag = frmSh.rukuLayer; + node.Text = frmSh.rukuLayer.Dataset.Caption; + node.ImageIndex = 0; + node.SelectedImageIndex = 0; + node.Checked = frmSh.rukuLayer.Visible; + layerManagerNode.Nodes.Insert(0, node); + layerManagerNode.Expand(); + } + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "提示"); + } + }); + #endregion + + shlayername = frmSh.rukuLayer.Name; + globeControl1.Refresh(); + } + + if (frmShResult != null && !frmShResult.IsDisposed) + { + try + { + clearFeatureHighLight(); + ClearRedlineAnalyseResult(); + frmShResult.Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message); + } + } + + 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.analysis(); + + //MainFrm窗体显示控制,回到一键审核Tab + this.Invoke((EventHandler)delegate + { + frmShResult.Show(); + frmWait.Close(); + //将tab页恢复到一键审核 + ribbonTabItem11.Checked = true; + try + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + //zhanshi = false; + splitContainer1.Panel2Collapsed = true; + + panelOfTable.Visible = false; + legendSC.Visible = false; + legendSG.Visible = false; + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + } + catch (Exception ex) + { + MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + + }); + + boolfrmShResult = true; + } + else + { + + } + } + + + /// + /// 清除渲染结果 + /// + 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(); + } + /// + /// 已审核的图层 + /// + /// + /// + private void buttonItem132_Click_1(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItem132.Text); + + if (shds == null) + { + //没连的话,直接连接审核库; //审核库配置读配置文件 + string dbIp = Utility.sgdbip; + string database = Utility.sgdbname; + string user = Utility.sgdbuser; + string pass = Utility.sgdbpwd; + + /* + 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; + //} + + } + /// + /// 审核入库 + /// + /// + /// + private void buttonItem133_Click_1(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, "审核入库"); + FrmShRK frmShrk = new FrmShRK(globeControl1); + frmShrk.Show(); + } + /// + /// 模拟设计修改 + /// + /// + /// + private void buttonItem134_Click_1(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, "模拟设计修改"); + + 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 + { + + } + + } + + + /// + /// 绘制垂线 + /// + /// + /// + 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); + } + /// + /// 比较两个点是否是同一个点 + /// + /// + /// + /// + 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; + } + /// + /// 获得点到线的垂线距离及垂点 + /// + /// + /// + /// + /// + 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); + 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]; + } + /// + /// 获得斜率 + /// + /// + /// + /// + /// + /// + /// + 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); + } + } + /// + /// 根据默认投影参数,经纬度转xyz + /// + /// + /// + /// + 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; + } + /// + /// 根据投影参数,经纬度转xyz + /// + /// + /// + /// + /// + 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; + } + /// + /// 根据默认投影参数,xyz转经纬度 + /// + /// + /// + /// + 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; + } + /// + /// 根据投影参数,Xyz转经纬度 + /// + /// + /// + /// + /// + 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; + } + /// + /// 获得inpolygon的管线长度 + /// + /// + 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; + } + + + /// + /// 一键审核中调节透明度 + /// + /// + /// + private void sliderItem1_ValueChanged(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.sliderItem1.Text); + + globeControl1.Globe.GroundOpaque = 100 - sliderItem1.Value; + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(roadLayerName);//("180fd"); + if (layer != null) + { + layer.Opaque = 100 - sliderItem1.Value; + } + + optiValue = sliderItem1.Value; + } + /// + /// 红线审核中的透明度分析 + /// + /// + /// + private void sliderItem3_ValueChanged(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.sliderItem3.Text); + + globeControl1.Globe.GroundOpaque = 100 - sliderItem3.Value; + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(roadLayerName);//("180fd"); + if (layer != null) + { + layer.Opaque = 100 - sliderItem3.Value; + } + optiValue = sliderItem3.Value; + } + + #region yanxiaowei + //初始化DataGridViewX1控件 + public delegate void DataGridViewDelegate(DataTable dt, string strLable, string strLayer, bool initDataGrid); + /// + /// 代理函数,操作DatgridViewX1 + /// + /// + /// + public void InitDataGridViewX1(DataTable dt, string strLable, string strLayer, bool initDataGrid) + { + if (initDataGrid == true) + { + dataGridViewX1.DataSource = dt; + panelOfTable.Visible = true; + toolStripNumbers.Text = strLable; + dataGridViewX1.Tag = strLayer; + } + else + { + dataGridViewX1.DataSource = null; + dataGridViewX1.Refresh(); + panelOfTable.Visible = false; + toolStripNumbers.Text = ""; + dataGridViewX1.Tag = ""; + globeControl1.Globe.MemoryLayer.RemoveAllFeature();//清除双击产生的标注 + } + } + FrmAnalysisGuiHuaResult from; + /// + /// 主窗体下方属性表格 双击定位 功能 + /// + /// + /// + private void dataGridViewX1_MouseDoubleClick(object sender, MouseEventArgs e) + { + if (redSH == false) + { + 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 if (dataGridViewX1.Columns.Contains("标识器编号")) + { + featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["标识器编号"].Value.ToString(); + } + featureName = featureName.Trim(); + + GSOLayer layer = null; + layer = globeControl1.Globe.Layers.GetLayerByCaption(dataGridViewX1.Tag.ToString()); + + if (layer == null) return; + + GSOFeatures features = layer.GetFeatureByName(featureName, false); + if (features.Length == 0) return; + GSOFeature rowFeature = features[0]; + + ClassSearchAnalysis.AddMakerToLineFeature(globeControl1, rowFeature); + + } + } + } + else + { + if (e.Button == MouseButtons.Left) + { + if (from != null && !from.IsDisposed) + { + try + { + from.Close(); + } + catch (Exception ex) + { + LogError.PublishError(ex); + } + } + try + { + DataGridView.HitTestInfo hittestinfo = dataGridViewX1.HitTest(e.X, e.Y); + if (hittestinfo.RowIndex >= 0) + { + string layer = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["管线类型"].Value.ToString(); + string hxName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["红线编号"].Value.ToString(); + FrmAnalysisGuiHuaResult frm = new FrmAnalysisGuiHuaResult(globeControl1, lineStruct, featsList, + panelOfTable, dataGridViewX1, layer, hxName); + frm.Location = new Point(this.Width - frm.Width - 10, this.Height - frm.Height - 20); + frm.Show(this); + + from = frm; + } + } + catch (Exception ex) + { + LogError.PublishError(ex); + } + } + } + } + + /// + /// 空间查询 + /// + /// + /// + private void buttonItemSearch1_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemSearch1.Text); + + trackflag = "PipelineSpatialQuery"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; + + } + /// + /// 关键字查询 + /// + /// + /// + private void buttonItemSearch9_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch9.Text); + + FrmKeywordQuery.ShowForm(globeControl1, m_PipelineLayerNames, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 编号查询 + /// + /// + /// + private void buttonItemSearch2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch2.Text); + + FrmCodingQuery.ShowForm(globeControl1, m_PipelineLayerNames, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 坐标查询 + /// + /// + /// + private void buttonItemSearch3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch3.Text); + + FrmSetLatLonPos.ShowForm(globeControl1); + } + /// + /// 附属物查询 + /// + /// + /// + private void buttonItemSearch10_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch10.Text); + + FrmFittingQuery.ShowForm(globeControl1, instrumenLayerNames, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 管径查询 + /// + /// + /// + private void buttonItemSearch4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch4.Text); + + FrmDiameterQuery.ShowForm(globeControl1, m_PipelineLayerNames, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 材质查询 + /// + /// + /// + private void buttonItemSearch5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch5.Text); + + FrmMaterialSel.ShowForm(globeControl1, m_PipelineLayerNames, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 基本查询 + /// + /// + /// + private void buttonItemSearch6_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch6.Text); + + FrmBasicQuery.ShowForm(globeControl1, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 复合查询 + /// + /// + /// + private void buttonItemSearch7_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch7.Text); + + FrmQuerySQL.ShowForm(globeControl1, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 关联查询 + /// + /// + /// + private void buttonItemSearch8_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch8.Text); + + if (globeControl1.Globe.SelObjectCount != 1) + { + MessageBox.Show("请选中一个对象!", "提示"); + return; + } + + 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 || (feature.Geometry.Type == EnumGeometryType.GeoPolygon3D + || feature.Geometry.Type == EnumGeometryType.GeoWater)) + return; + else + { + ClassSearchAnalysis.ResultRelationAnalysis(globeControl1, feature, valueLayerNames, workwellLayerNames, + instrumenLayerNames, pipefittingLayerNames, m_PipelineLayerNames, valueAllowance); + } + } + } + #endregion + /// + /// 清除分析 + /// + /// + /// + private void buttonItemClear_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemClear.Text); + + globeControl1.Globe.ClearMeasure(); + layerTemp.RemoveAllFeature(); + layerTemp2.RemoveAllFeature(); + buttonItemLS5.Checked = false; + + dataGridViewX1.DataSource = null; + panelOfTable.Visible = false; + + 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); + + NetworkAnalysisTool.ClearAllTopAnalysis(this.globeControl1); + // 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();//清除所有坑 + + 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(); + } + } + + clearFeatureHighLight();//取消管线高亮 + + GSOLayer layerGround = globeControl1.Globe.Layers.GetLayerByCaption(roadLayerName);//("180fd"); + if (layerGround != null) + { + layerGround.Visible = true; + } + globeControl1.Refresh(); + globeControl2.Refresh(); + ClearRedlineAnalyseResult(); + globeControl1.Globe.Action = EnumAction3D.ActionNull; + } + /// + /// 管线长度全区域统计 + /// + /// + /// + private void buttonItemTJ1_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管线长度统计"); + + FrmAllPipelineStatis frm = new FrmAllPipelineStatis(globeControl1,null, new DataGridViewDelegate(InitDataGridViewX1), m_PipelineLayerNames); + frm.Show(this); + } + /// + /// 管线长度绘制区域统计 + /// + /// + /// + private void buttonItemTJ1_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管线长度统计"); + + trackflag = "PipelineDistanceStatistics"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; + } + /// + /// 阀门数量全区域统计 + /// + /// + /// + private void buttonItemTJ2_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "阀门数量统计"); + + FrmValveStatistics frm = new FrmValveStatistics(globeControl1, null, new DataGridViewDelegate(InitDataGridViewX1)); + frm.Show(this); + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + } + /// + /// 阀门数量绘制区域统计 + /// + /// + /// + private void buttonItemTJ2_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "阀门数量统计"); + + trackflag = "valvequery"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; + } + /// + /// 井盖数量全区域统计 + /// + /// + /// + private void buttonItemTJ3_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "井盖数量统计"); + FrmAllWorkWellStatis frm = new FrmAllWorkWellStatis(globeControl1, null, new DataGridViewDelegate(InitDataGridViewX1)); + frm.Show(this); + } + /// + /// 井盖数量绘制区域统计 + /// + /// + /// + private void buttonItemTJ3_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "井盖数量统计"); + + trackflag = "workwellquery"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; + } + /// + /// 管径分段统计全区域统计 + /// + /// + /// + private void buttonItemTJ4_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管径分段统计"); + + Frmpipediameterstatis.ShowForm(globeControl1, m_PipelineLayerNames, 0); + } + /// + /// 管径分段统计绘制区域统计 + /// + /// + /// + private void buttonItemTJ4_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管径分段统计"); + + trackflag = null; + Frmpipediameterstatis.ShowForm(globeControl1, m_PipelineLayerNames, 1); + } + /// + /// 埋深分段统计全区域统计 + /// + /// + /// + private void buttonItemTJ5_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "埋深分段统计"); + FrmpipeDeepstatis.ShowForm(globeControl1, m_PipelineLayerNames, 0); + } + /// + /// 埋深分段统计绘制区域统计 + /// + /// + /// + private void buttonItemTJ5_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "埋深分段统计"); + trackflag = null; + FrmpipeDeepstatis.ShowForm(globeControl1, m_PipelineLayerNames, 1); + } + /// + /// 管径分类统计全区域统计 + /// + /// + /// + private void buttonItemTJ6_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管径分类汇总"); + + FrmpipeDiametergather.ShowForm(globeControl1, m_PipelineLayerNames, 0); + } + /// + /// 管径分类统计绘制区域统计 + /// + /// + /// + private void buttonItemTJ6_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管径分类汇总"); + + trackflag = null; + FrmpipeDiametergather.ShowForm(globeControl1, m_PipelineLayerNames, 1); + } + /// + /// 材质分类统计全区域统计 + /// + /// + /// + private void buttonItemTJ7_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "材质分类汇总"); + + FrmpipeMaterialGather.ShowForm(globeControl1, m_PipelineLayerNames, 0); + } + /// + /// 材质分类统计绘制区域统计 + /// + /// + /// + private void buttonItemTJ7_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "材质分类汇总"); + + trackflag = null; + FrmpipeMaterialGather.ShowForm(globeControl1, m_PipelineLayerNames, 1); + } + /// + /// 附属物分类统计全区域统计 + /// + /// + /// + private void buttonItemTJ8_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "附属物分类汇总"); + + FrmAccessoriesgather.ShowForm(globeControl1, instrumenLayerNames, 0); + } + /// + /// 附属物分类统计绘制区域统计 + /// + /// + /// + private void buttonItemTJ8_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "附属物分类汇总"); + + trackflag = null; + FrmAccessoriesgather.ShowForm(globeControl1, instrumenLayerNames, 1); + } + /// + /// 碰撞分析 + /// + /// + /// + private void buttonItemFX1_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_4.Text); + + this.dataGridViewX4.Size = new System.Drawing.Size(195, 120); + 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(); + } + /// + /// 覆土分析 + /// + /// + /// + private void buttonItemFX1_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX5_1.Text); + this.dataGridViewX6.Size = new System.Drawing.Size(195, 120); + 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(); + } + /// + /// 间距分析 + /// + /// + /// + private void buttonItemFX1_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX1_3.Text); + + this.dataGridViewLineList.Size = new System.Drawing.Size(185, 120); + 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(); + } + /// + /// 垂直净距分析 + /// + /// + /// + private void buttonItemFX1_4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX1_4.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(); + } + /// + /// 水平净距分析 + /// + /// + /// + private void buttonItemFX1_5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_6.Text); + this.dataGridViewX8.Size = new System.Drawing.Size(185, 120); + 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(); + } + + #region Predaotr,断面分析 + /// + /// 横断面分析 + /// + /// + /// + private void buttonItemFX2_1_Click(object sender, EventArgs e) + { + globeControl1.Globe.Action = EnumAction3D.TrackPolyline; + globeControl1.Globe.TrackPolylineTool.VerticalLineVisible = true; + globeControl1.Globe.TrackPolylineTool.TrackMode = EnumTrackMode.SpaceTrack; + trackPolylineEndMode = EnumTrackPolylineEndMode.HDM_Analysis; + + } + /// + /// 纵断面分析 + /// + /// + /// + private void buttonItemFX2_2_Click(object sender, EventArgs e) + { + if (globeControl1.Globe.SelObjectCount<1) + { + MessageBox.Show("请选择一条或者多条管线!", "提示", MessageBoxButtons.OK, + MessageBoxIcon.Information); + return; + } + 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); + } + } + List feats = SectionAnalysisTool.ZDMAnalysis(selectFeatures); + if (feats != null && feats.Count >= 1) + { + FrmProfileAnalysis frm = new FrmProfileAnalysis(globeControl1, feats); + frm.Show(this); + } + } + /// + /// 道路断面分析 + /// + /// + /// + private void buttonItemFX2_3_Click(object sender, EventArgs e) + { + globeControl1.Globe.Action = EnumAction3D.TrackPolyline; + globeControl1.Globe.TrackPolylineTool.VerticalLineVisible = true; + globeControl1.Globe.TrackPolylineTool.TrackMode = EnumTrackMode.SpaceTrack; + trackPolylineEndMode = EnumTrackPolylineEndMode.DLDM_Analysis; + + } + /// + /// 基线剖面分析 + /// + /// + /// + private void buttonItemFX2_4_Click(object sender, EventArgs e) + { + globeControl1.Globe.Action = EnumAction3D.TrackPolyline; + globeControl1.Globe.TrackPolylineTool.VerticalLineVisible = true; + globeControl1.Globe.TrackPolylineTool.TrackMode = EnumTrackMode.SpaceTrack; + trackPolylineEndMode = EnumTrackPolylineEndMode.JXPM_Analysis; + + } + + #endregion + /// + /// 创建拓扑 + /// + /// + /// + private void buttonItemFX3_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX3_1.Text); + + FrmGenAndFaMenTopu frm = new FrmGenAndFaMenTopu(globeControl1, m_PipelineLayerNames, valueLayerNames); + frm.Show(this); + } + #region Predator :拓扑分析 + /// + /// 上游分析 + /// + /// + /// + private void buttonItemFX3_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX3_2.Text); + NetworkTraceUpDown(true); + } + /// + /// 下游分析 + /// + /// + /// + private void buttonItemFX3_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX3_3.Text); + NetworkTraceUpDown(false); + } + + /// + /// 上下游追踪 功能 + /// + /// + private void NetworkTraceUpDown(Boolean bTraceUp) + { + GSOFeature selLineFeature = globeControl1.Globe.SelectedObject; + if (selLineFeature == null || selLineFeature.Geometry == null || selLineFeature.Geometry.Type != EnumGeometryType.GeoPolyline3D) + { + MessageBox.Show("请点击“编辑”—“选中对象”选择一条线!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); + return; + } + GSOLayer selLayer = globeControl1.Globe.SelectedObjectLayer; + + NetworkAnalysisTool.TraceUpDownAnalysis(bTraceUp, + selLineFeature, selLayer); + } + + /// + /// 流向分析 + /// + /// + /// + private void buttonItemFX3_4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX3_4.Text); + + FrmFlow frm = new FrmFlow(globeControl1, m_PipelineLayerNames); + frm.Show(this); + } + /// + /// 关阀分析 + /// + /// + /// + private void buttonItemFX3_5_Click(object sender, EventArgs e) + { + if (globeControl1.Globe.SelObjectCount < 1) + { + MessageBox.Show("请选中至少一根管线!!"); + buttonItemFX3_5.Checked = false; + return; + } + GSOLayer resLayer = null; + GSOFeature resFeature = null; + globeControl1.Globe.GetSelectObject(0, out resFeature, out resLayer); + + String pipeLayerName = resLayer.Caption; + String pipeLayerNamePrefix = pipeLayerName.Substring(0, pipeLayerName.IndexOf("管线")); + GSOLayer valveLayer = globeControl1.Globe.Layers[pipeLayerNamePrefix + "阀门"]; + if (valveLayer == null) + { + MessageBox.Show("无" + pipeLayerNamePrefix+"阀门图层", "提示"); + return; + } + + GSOFeatures valveFeats = NetworkAnalysisTool.CloseValvesAnalysis(resFeature, + resLayer, valveLayer); + + if (valveFeats != null) + { + FrmCloseValves frm = new FrmCloseValves(this.globeControl1, valveFeats); + frm.Show(this); + } + else + { + MessageBox.Show("未找到关闭阀门"); + } + } + + /// + /// 连通分析 + /// + /// + /// + private void buttonItemFX3_6_Click(object sender, EventArgs e) + { + if (globeControl1.Globe.SelObjectCount < 2) + { + MessageBox.Show("请选中至少两个管线!!"); + buttonItemFX3_6.Checked = false; + return; + } + GSOFeature selFeat0, selFeat1; + GSOLayer layer0,layer1; + globeControl1.Globe.GetSelectObject(0, out selFeat0, out layer0); + globeControl1.Globe.GetSelectObject(1, out selFeat1, out layer1); + + if (!layer0.IsSameInnerObject(layer1)) + { + MessageBox.Show("不在同一个图层!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); + buttonItemFX3_6.Checked = false; + return; + } + NetworkAnalysisTool.ConnexityAnalysis(selFeat0, selFeat1, layer0); + } + /// + /// 爆管分析 + /// + /// + /// + private void buttonItemFX3_7_Click(object sender, EventArgs e) + { + NetworkTraceUpDown(true); //上游追踪: + + GSOFeature selLineFeature = globeControl1.Globe.SelectedObject; + if (selLineFeature == null || selLineFeature.Geometry == null || selLineFeature.Geometry.Type != EnumGeometryType.GeoPolyline3D) + { + MessageBox.Show("请点击“编辑”—“选中对象”选择一条线!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); + return; + } + GSOLayer selLayer = globeControl1.Globe.SelectedObjectLayer; + + NetworkAnalysisTool.ExplodeAnalysis(this.globeControl1,selLineFeature,selLayer); + + this.buttonItemFX3_5_Click(sender, e); //关阀分析: + + } + + #endregion + /// + /// 多边形开挖 + /// + /// + /// + private void buttonItemFX4_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_1.Text); + + trackflag = "pit"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; //是这个么?是的,在模型上 + } + /// + /// 挖方量分析 + /// + /// + /// + private void buttonItemFX4_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_2.Text); + + trackflag = "digFillAnalysis"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; + ActionToolMenuChecked(); + } + /// + /// 沿线开挖 + /// + /// + /// + private void buttonItemFX4_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_3.Text); + + if (!buttonItemFX4_3.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; + buttonItemFX4_3.Checked = true; + } + } + else + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + buttonItemFX4_3.Checked = false; + globeControl1.Globe.TrackPolylineTool.VerticalLineVisible = false; + } + ActionToolMenuChecked(); + } + /// + /// 创建隧道 + /// + /// + /// + private void buttonItemFX4_4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_4.Text); + + 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("场景中未加载隧道图层!", "提示"); + } + } + /// + /// 隐藏隧道 + /// + /// + /// + private void buttonItemFX4_5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_5.Text); + + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption("隧道"); + if (layer != null) + { + layer.Visible = !layer.Visible; + } + } + /// + /// 删除隧道 + /// + /// + /// + private void buttonItemFX4_6_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_6.Text); + + 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("请选中要删除的隧道!", "提示"); + } + } + /// + /// 通视分析 + /// + /// + /// + private void buttonItemFX5_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX5_1.Text); + + if (globeControl1.Globe.Action != EnumAction3D.VisibilityAnalysis) + { + //btnSpaceVisibilityAnalysis.Checked = true; + globeControl1.Globe.Action = EnumAction3D.VisibilityAnalysis; + } + else + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + // SetButtonChecked(); + } + } + /// + /// 可视域分析 + /// + /// + /// + private void buttonItemFX5_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX5_2.Text); + + globeControl1.Globe.Action = EnumAction3D.ViewshedAnalysis; + } + /// + /// 可视包络分析 + /// + /// + /// + private void buttonItemFX5_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX5_3.Text); + + globeControl1.Globe.Action = EnumAction3D.ViewEnvelopeAnalysis; + } + /// + /// 缓冲区分析 + /// + /// + /// + private void buttonItemFX6_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX6_1.Text); + + GSOFeature feat = globeControl1.Globe.SelectedObject; + if (feat == null) + { + MessageBox.Show("请选择要分析的要素!"); + return; + } + if (feat.Geometry.Type == EnumGeometryType.GeoPolyline3D) + { + GSOGeoPolyline3D line1 = feat.Geometry as GSOGeoPolyline3D; + if (line1 == null) + { + MessageBox.Show("请选择一条管线!"); + return; + } + + FrmBufferAnalysis frm = new FrmBufferAnalysis(globeControl1, line1, layerTemp); + frm.Show(this); + } + else + { + FrmBufferAnalysisBSQ frm = new FrmBufferAnalysisBSQ(globeControl1, layerTemp, bsqPT); + frm.Show(this); + } + + } + /// + /// 附属物分析 + /// + /// + /// + private void buttonItemFX6_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX6_2.Text); + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + FrmAccessoryAnalysis dlg = new FrmAccessoryAnalysis(globeControl1, layerTemp); + dlg.Show(this); + } + /// + /// 无源淹没分析 + /// + /// + /// + private void buttonItemFX6_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX6_3.Text); + + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + trackflag = "FloodAnalysis"; + } + /// + /// 水平距离 + /// + /// + /// + private void buttonItemLS1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS1.Text); + + globeControl1.Globe.Action = EnumAction3D.MeasureDistance; + globeControl1.Globe.DistanceRuler.SpaceMeasure = false; + buttonItemLS5.Checked = false; + } + /// + /// 垂直距离 + /// + /// + /// + private void buttonItemLS2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS2.Text); + + buttonItemLS5.Checked = false; + globeControl1.Globe.Action = EnumAction3D.MeasureHeight; + globeControl1.Globe.DistanceRuler.SpaceMeasure = false; + } + /// + /// 空间距离 + /// + /// + /// + private void buttonItemLS3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS3.Text); + + buttonItemLS5.Checked = false; + globeControl1.Globe.Action = EnumAction3D.MeasureDistance; + globeControl1.Globe.DistanceRuler.SpaceMeasure = true; + } + /// + /// 地表距离 + /// + /// + /// + private void buttonItemLS4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS4.Text); + + buttonItemLS5.Checked = false; + globeControl1.Globe.Action = EnumAction3D.MeasureDistance; + globeControl1.Globe.DistanceRuler.SpaceMeasure = false; + } + /// + /// 高度量算 + /// + /// + /// + private void buttonItemLS5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS5.Text); + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + buttonItemLS5.Checked = !buttonItemLS5.Checked; + if (buttonItemLS5.Checked) + { + globeControl1.Globe.Action = EnumAction3D.SelectObject; + } + } + /// + /// 水平面积 + /// + /// + /// + private void buttonItemLS6_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS6.Text); + + buttonItemLS5.Checked = false; + globeControl1.Globe.Action = EnumAction3D.MeasureArea; + globeControl1.Globe.AreaRuler.SpaceMeasure = true; + } + /// + /// 地表面积 + /// + /// + /// + private void buttonItemLS7_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS7.Text); + + buttonItemLS5.Checked = false; + globeControl1.Globe.Action = EnumAction3D.MeasureArea; + globeControl1.Globe.AreaRuler.SpaceMeasure = false; + + } + + # region Fan 重构标注代码 + /// + /// 标高标注 + /// + /// + /// + private void buttonItemSZ1_Click(object sender, EventArgs e) + { + GSOFeature resFeature = IsPipeLineOfSelectedObj(); + if (resFeature == null) + { + MessageBox.Show("请选中一根管线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + GSOGeoPolyline3D selLine = resFeature.Geometry as GSOGeoPolyline3D; + if (selLine[0].Count <= 1) + { + return; + } + + MarkTools.getInstance().showMarker(resFeature, + globeControl1, EnumMarkLayer.Mark_Altitude, ""); + } + /// + /// 管径标注 + /// + GSOFeature radiusMarkerFeature; + private void buttonItemBZ2_Click(object sender, EventArgs e) + { + GSOFeature resFeature = IsPipeLineOfSelectedObj(); + if (resFeature == null) + { + MessageBox.Show("请选中一根管线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + GSOGeoPolyline3D selLine = resFeature.Geometry as GSOGeoPolyline3D; + if (selLine[0].Count <= 1) + { + return; + } + + MarkTools.getInstance().showMarker(resFeature, + globeControl1, EnumMarkLayer.Mark_Diameter, ""); + } + /// + /// 埋深标注 + /// + /// + /// + private void buttonItemBZ3_Click(object sender, EventArgs e) + { + GSOFeature resFeature = IsPipeLineOfSelectedObj(); + if (resFeature == null) + { + MessageBox.Show("请选中一根管线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + GSOGeoPolyline3D selLine = resFeature.Geometry as GSOGeoPolyline3D; + if (selLine[0].Count <=1) + { + return; + } + + MarkTools.getInstance().showMarker(resFeature, + globeControl1, EnumMarkLayer.Mark_Depth, ""); + + } + /// + /// 坐标标注 + /// + /// + /// + private void buttonItemBZ4_Click(object sender, EventArgs e) + { + GSOFeature resFeature = IsPipeLineOfSelectedObj(); + if (resFeature == null) + { + MessageBox.Show("请选中一根管线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + GSOGeoPolyline3D selLine = resFeature.Geometry as GSOGeoPolyline3D; + if (selLine[0].Count <= 1) + { + return; + } + MarkTools.getInstance().showMarker(resFeature, + globeControl1, EnumMarkLayer.Mark_Location, ""); + } + /// + /// 距离标注 + /// + bool distanceMarker = false; + private void buttonItemBZ5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBZ5.Text); + + globeControl1.Globe.Action = EnumAction3D.TrackPolyline; + //globeControl1.Globe.DistanceRuler.MeasureMode = EnumDistanceMeasureMode.HVSLineMeasure; + distanceMarker = true; + } + /// + /// 自定义标注 + /// + /// + /// + private void buttonItemBZ6_Click(object sender, EventArgs e) + { + GSOFeature f = globeControl1.Globe.SelectedObject; + GSOLayer l = globeControl1.Globe.SelectedObjectLayer; + FrmCustomLabel frm = new FrmCustomLabel(globeControl1, l, f); + if (frm.ShowDialog() == DialogResult.OK) + { + MarkTools.getInstance().showMarker(f, globeControl1, EnumMarkLayer.Mark_Custom, frm.labelText); + } + } + /// + /// 扯旗标注 + /// + /// + /// + private void buttonItemBZ7_Click(object sender, EventArgs e) + { + GSOFeature f = globeControl1.Globe.SelectedObject; + GSOLayer l = globeControl1.Globe.SelectedObjectLayer; + FrmMarker frm = new FrmMarker(); + if (frm.ShowDialog() == DialogResult.OK) + { + MarkTools.getInstance().showMarker(f, globeControl1, EnumMarkLayer.Mark_Custom, frm.markerContent); + } + } + /// + /// 坡度标注 + /// + /// + /// + private void buttonItemBZ8_Click(object sender, EventArgs e) + { + GSOFeature resFeature = IsPipeLineOfSelectedObj(); + if (resFeature == null) + { + MessageBox.Show("请选中一根管线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + GSOGeoPolyline3D selLine = resFeature.Geometry as GSOGeoPolyline3D; + if (selLine[0].Count <= 1) + { + return; + } + + MarkTools.getInstance().showMarker(resFeature, + globeControl1, EnumMarkLayer.Mark_Slope, ""); + } + /// + /// 属性标注 + /// + /// + /// + private void buttonItemBZ9_Click(object sender, EventArgs e) + { + GSOFeature f = globeControl1.Globe.SelectedObject; + GSOLayer l = globeControl1.Globe.SelectedObjectLayer; + FrmPropertiesMarker frm = new FrmPropertiesMarker(globeControl1, l, f); + if (frm.ShowDialog() == DialogResult.OK) + { + MarkTools.getInstance().showMarker(f, globeControl1, EnumMarkLayer.Mark_Property, frm.labelText); + } + } + /// + /// 红线工具 + /// + /// + /// + private void buttonItemBZ10_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBZ10.Text); + 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; + } + } + /// + /// 标注管理 + /// + /// + /// + private void buttonItemBZ11_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBZ11.Text); + + buttonItemBZ11.Checked = !buttonItemBZ11.Checked; + 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 (buttonItemBZ11.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(); + } + } + + #endregion + /// + /// 飞行到目标点 + /// + /// + /// + private void buttonItemFXGJ1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFXGJ1.Text); + + FrmSetFlytoPos.ShowForm(globeControl1); + + } + /// + /// 自定义飞行 + /// + /// + /// + private void buttonItemFXGJ2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFXGJ2.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); + } + } + /// + /// 绕中心点飞行 + /// + /// + /// + private void buttonItemFXGJ3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFXGJ3.Text); + + globeControl1.Globe.FlyAroundCenter(10000, EnumFlyRepeatValueType.MiliSeconds); + globeControl1.Globe.CurFlyID = 1; + } + /// + /// 绕眼睛飞行 + /// + /// + /// + private void buttonItemFXGJ4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFXGJ4.Text); + + globeControl1.Globe.FlyAroundEye(720, EnumFlyRepeatValueType.Degrees); + globeControl1.Globe.CurFlyID = 2; + } + + /// + /// 权限管理 + /// + /// + /// + private void buttonItemXT1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT1.Text); + + FrmUserRoleMgr frm = new FrmUserRoleMgr(); + frm.ShowDialog(); + } + /// + /// 数据库管理 + /// + /// + /// + private void buttonItemXT2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT2.Text); + + //查看数据库列表 + FrmDbManager frm = new FrmDbManager(); + frm.ShowDialog(); + } + /// + /// 用户列表 + /// + /// + /// + private void buttonItemXT3_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT3_1.Text); + + FrmUserManager frm = new FrmUserManager(); + frm.ShowDialog(); + } + /// + /// 创建新用户 + /// + /// + /// + private void buttonItemXT3_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT3_2.Text); + + FrmUserAdd frm = new FrmUserAdd(-1); + frm.ShowDialog(); + } + /// + /// 人员修改 + /// + /// + /// + private void buttonItemXT4_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT4_2.Text); + + FrmAppUSER appUSER = new FrmAppUSER(); + appUSER.ShowDialog(); + } + /// + /// 增加人员 + /// + /// + /// + private void buttonItemXT4_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT4_1.Text); + + FrmAppUSERRESET appUSERRESET = new FrmAppUSERRESET(); + appUSERRESET.ShowDialog(); + } + /// + /// 统计数据 + /// + /// + /// + private void buttonItemZTT1_Click(object sender, EventArgs e) + { + ////日志记录 + //LogManager.saveLog(Utility.userName, this.buttonItemZTT1.Text); + + //PATM patm = new PATM(); + //patm.operation = "Statistic"; + //patm.Text = "统计专题图管理"; + //patm.ShowDialog(); + } + /// + /// 热点功能统计 + /// + /// + /// + private void buttonItemZTT2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT2.Text); + + FrmHotFuncStat frmhfs = new FrmHotFuncStat(); + frmhfs.ShowDialog(); + } + + private void buttonItemZTT3_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT3_1.Text); + + FrmAPP appfrm = new FrmAPP("专题图申请"); + appfrm.ShowDialog(); + } + + private void buttonItemZTT3_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT3_2.Text); + + FrmAPPFORASK appForask = new FrmAPPFORASK("专题图审核"); + appForask.ShowDialog(); + } + + private void buttonItemZTT3_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT3_3.Text); + + FrmAPPregion appregion = new FrmAPPregion("专题图审核"); + appregion.ShowDialog(); + } + + private void buttonItemZTT4_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT4_1.Text); + + FrmAPP appfrm = new FrmAPP("打印申请"); + appfrm.ShowDialog(); + } + + private void buttonItemZTT4_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT4_2.Text); + + FrmAPPFORASK appForask = new FrmAPPFORASK("打印审核"); + appForask.ShowDialog(); + } + + private void buttonItemZTT4_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT4_3.Text); + + FrmAPPregion appregion = new FrmAPPregion("打印审核"); + appregion.ShowDialog(); + } + + private void buttonItemZTT5_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT5_1.Text); + + FrmAPP appfrm = new FrmAPP("拷贝申请"); + appfrm.ShowDialog(); + } + + private void buttonItemZTT5_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT5_2.Text); + + FrmAPPFORASK appForask = new FrmAPPFORASK("拷贝审核"); + appForask.ShowDialog(); + } + + private void buttonItemZTT5_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT5_3.Text); + + FrmAPPregion appregion = new FrmAPPregion("拷贝审核"); + appregion.Show(); + } + + private int connectServerCount = 0; + + /// + /// 还原球到实测库 + /// + 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); + } + + if (layerManagerNode.Nodes.Count > 0) + { + for (int i = layerManagerNode.Nodes.Count - 1; i >= 0; i--) + { + layerManagerNode.Nodes[i].Remove(); + + } + } + + globeControl1.Refresh(); + + } + + private void buttonItemSPSZ_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSPSZ.Text); + + FrmLayerControl frm = new FrmLayerControl(layerTree, globeControl1, globeControl2); + frm.Show(this); + } + + /// + /// 碰撞审查 + /// + /// + /// + private void buttonItemSH1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSH1.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 buttonItemSH2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSH2.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 buttonItemSH3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSH3.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 buttonItemSH4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSH4.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 buttonItemSH5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSH5.Text); + FrmCityServerLineAnalysis frm = new FrmCityServerLineAnalysis(globeControl1, m_PipelineLayerNames); + frm.Show(this); + } + #region 数据管理-导入文件 + ///// + ///// 数据管理-导入本地坐标系文件 + ///// + ///// + ///// + //private void buttonItemSJGL1_1_Click(object sender, EventArgs e) + //{ + // //日志记录 + // LogManager.saveLog(Utility.userName, this.buttonItemSJGL1_1.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(); + // } + // } + //} + + ///// + ///// 数据管理-导入其他坐标系文件 + ///// + ///// + ///// + //private void buttonItemSJGL1_2_Click(object sender, EventArgs e) + //{ + // //日志记录 + // LogManager.saveLog(Utility.userName, this.buttonItemSJGL1_2.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(); + // } + // } + //} + #endregion + /// + /// 数据质量检查 + /// + /// + /// + private void buttonItemSJGL2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL2.Text); + FrmValiData frm = new FrmValiData(globeControl1); + frm.ShowDialog(); + } + /// + /// 数据预处理 + /// + /// + /// + private void buttonItemSJGL3_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL3.Text); + + FrmEditShapeFile frm = new FrmEditShapeFile(globeControl1); + frm.ShowDialog(this); + } + /// + /// 连接数据库 + /// + /// + /// + private void buttonItemSJGL4_1_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL4_1.Text); + + FrmDatabaseParaSetting frm = new FrmDatabaseParaSetting(globeControl1); + if (frm.ShowDialog() == DialogResult.OK) + { + ds = FrmDatabaseParaSetting.ds; + if (ds != null) + { + ds.IsCloseSaved = false; + } + } + } + /// + /// 管线入库 + /// + /// + /// + private void buttonItemSJGL4_2_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL4_2.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 buttonItemSJGL4_3_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL4_3.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 buttonItemSJGL5_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL5.Text); + + Cyberpipe.Forms.FrmProject frm = new Cyberpipe.Forms.FrmProject(); + frm.ShowDialog(); + } + /// + /// 元数据基本管理 + /// + /// + /// + private void buttonItemSJGL6_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL6_1.Text); + + FrmMetadata frmmd = new FrmMetadata(); + frmmd.ShowDialog(); + } + /// + /// 元数据查询管理 + /// + /// + /// + private void buttonItemSJGL6_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL6_2.Text); + + FrmMetadataStat frmmds = new FrmMetadataStat(); + //frmmds.Show(); + frmmds.ShowDialog(); + } + /// + /// 操作日志管理 + /// + /// + /// + private void buttonItemSJGL7_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL7.Text); + + FrmLogOper frmlo = new FrmLogOper(); + frmlo.ShowDialog(); + } + /// + /// 数据字典管理 + /// + /// + /// + private void buttonItemSJGL8_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL8.Text); + + FrmMDDictory frmmdd = new FrmMDDictory(); + frmmdd.ShowDialog(); + } + /// + /// 数据库备份 + /// + /// + /// + private void buttonItemSJGL9_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL9.Text); + + //新 + FrmBACKORACLE backOracle = new FrmBACKORACLE(); + backOracle.Show(); + } + /// + /// 创建管段 + /// + /// + /// + private void buttonItemBJ1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ1.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; + } + } + /// + /// 创建附属物 + /// + /// + /// + private void buttonItemBJ2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ2.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); + } + } + /// + /// 创建特征管点 + /// + /// + /// + private void buttonItemBJ3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ3.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); + } + } + /// + /// 绘制城市七线 + /// + /// + /// + private void buttonItemBJ4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ4.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; + } + } + } + /// + /// 选中对象 + /// + /// + /// + private void buttonItemBJ5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ5.Text); + + globeControl1.Globe.Action = EnumAction3D.SelectObject; + } + /// + /// 平移对象 + /// + /// + /// + private void buttonItemBJ6_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ6.Text); + + globeControl1.Globe.Action = EnumAction3D.MoveObject; + } + /// + /// 升降对象 + /// + /// + /// + private void buttonItemBJ7_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ7.Text); + + globeControl1.Globe.Action = EnumAction3D.ElevateObject; + } + /// + /// 旋转对象 + /// + /// + /// + private void buttonItemBJ8_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ8.Text); + + globeControl1.Globe.Action = EnumAction3D.RotateObject; + } + /// + /// 连接管段 + /// + /// + /// + private void buttonItemBJ9_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ9.Text); + + if (globeControl1.Globe.SelObjectCount < 2) + { + MessageBox.Show("对不起,请至少选中2个对象!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + return; + } + globeControl1.Globe.InsertJointPipeline(false); + } + /// + /// 后退 + /// + /// + /// + private void buttonItemBJ11_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemBJ11.Text); + globeControl1.Globe.UnDoEdit(); + } + /// + /// 前进 + /// + /// + /// + private void buttonItemBJ12_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemBJ12.Text); + + globeControl1.Globe.ReDoEdit(); + } + /// + /// 导出CAD + /// + /// + /// + private void buttonItemBJ10_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ10_1.Text); + + #region 导出成dxf格式 + List listVectorNames = new List(); + 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(); + #endregion + } + /// + /// 导出矢量 + /// + /// + /// + private void buttonItemBJ10_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ10_2.Text); + + List listVectorNames = new List(); + 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 buttonItemBJ13_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemBJ13.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(); + } + } + MessageBox.Show("删除成功!", "提示"); + } + else + { + MessageBox.Show("请选中要删除的模型!", "提示"); + } + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + } + + private void buttonItemHX1_1_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]; + string filePath = dlg.FileName; + string lastname = Path.GetFileName(filePath); + + 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(); + } + + } + } + } + + public struct LineStruct + { + public string layerName; + public string layerCode; + public string lineLength; + public string hxName; + } + + List lineStruct = new List(); + List featsList = new List(); + + /// + /// 红线审核 + /// + /// + /// + private void buttonItemHX2_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemHX2.Text); + redSH = true; + featsList.Clear(); + lineStruct.Clear(); + List listPipelineLayers = new List(); + + GSOLayer layer = null; + for (int i = 0; i < m_PipelineLayerNames.Count; i++) + { + layer = globeControl1.Globe.Layers.GetLayerByCaption(m_PipelineLayerNames[i]); + if (layer != null) + { + listPipelineLayers.Add(layer); + } + } + //yanxiaowei 重构 + GSOFeatures selectFeatures=new GSOFeatures(); + for (int i = 0; i < globeControl1.Globe.SelObjectCount; i++) + { + GSOFeature feature = null; + globeControl1.Globe.GetSelectObject(i, out feature, out layer); + selectFeatures.Add(feature); + } + DataTable table=new DataTable(); + + ClassGSOTool.CalculateRedLineResult(out table, redSH, selectFeatures, globeControl1, + listPipelineLayers,out lineStruct, out featsList); + + if (table.Rows.Count != 0) + AddDatagridView(table); + else + { + MessageBox.Show("没有侵入地块红线的管线数据!", "提示"); + dataGridViewX1.DataSource = null; + panelOfTable.Visible = false; + return; + } + } + + private void AddDatagridView(DataTable table) + { + dataGridViewX1.DataSource = table; + panelOfTable.Visible = true; + panelOfTable.Height = 200; + toolStripNumbers.Text = "红线审核 |共有:" + table.Rows.Count + "条"; + toolStripDropDownButton3.Visible = true; + } + /// + /// 主窗体 下方的工具条中的 导出.xls文件 按钮事件处理 + /// + /// + /// + private void toolStripDropDownButton3_Click(object sender, EventArgs e) + { + if (dataGridViewX1.Rows.Count == 0) + { + MessageBox.Show("表格内容为空!", "提示"); + return; + } + + string strSaveFile = string.Empty; + SaveFileDialog savefiledialog = new SaveFileDialog(); + savefiledialog.Filter = "Excel文件|*.xls,*.xlsx"; + savefiledialog.AddExtension = true; + savefiledialog.FileName = "红线审核"; + if (savefiledialog.ShowDialog() == DialogResult.OK) + strSaveFile = savefiledialog.FileName; + else return; + + ExpEXCEL.ExpToExcel(dataGridViewX1, strSaveFile, "红线审核", lineStruct, featsList); + MessageBox.Show("导出成功!"); + } + /// + /// 去除集合中重复的管线 + /// + /// + /// + /// + private GSOFeatures getFeaturesByFilter(GSOFeatures features, string fieldName) + { + if (features == null) + { + return null; + } + GSOFeatures featuresGet = new GSOFeatures(); + for (int i = 0; i < features.Length; i++) + { + GSOFeature featureFromFS = features[i]; + string fieldValueFromFS = featureFromFS.GetValue(fieldName).ToString().Trim(); + bool isHas = false; + for (int j = featuresGet.Length - 1; j >= 0; j--) + { + GSOFeature featureFromFSGet = featuresGet[j]; + string fieldValueFromFSGet = featureFromFSGet.GetValue(fieldName).ToString().Trim(); + if (fieldValueFromFS.Equals(fieldValueFromFSGet)) + { + isHas = true; + break; + } + } + if (isHas == false) + { + featuresGet.Add(featureFromFS.Clone()); + } + } + return featuresGet; + } + + private void sliderItem2_ValueChanged(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.sliderItem2.Text); + + globeControl1.Globe.GroundOpaque = 100 - sliderItem2.Value; + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(roadLayerName);//("180fd"); + if (layer != null) + { + layer.Opaque = 100 - sliderItem2.Value; + } + layer = globeControl2.Globe.Layers.GetLayerByCaption("180fd");//("180fd"); + if (layer != null) + { + layer.Opaque = 100 - sliderItem2.Value; + } + globeControl2.Globe.GroundOpaque = 100 - sliderItem2.Value; + + optiValue = sliderItem2.Value; + } + /// + /// 数据管理导入文件 + /// + /// + /// + private void buttonItemSJGL1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL1.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.Multiselect = true; + if (dlg.ShowDialog() == DialogResult.OK) + { + //自定义lprj文件名,从程序中复制一lprj文件。 + string filePath = dlg.FileName; + string lastname = Path.GetFileName(filePath); + + 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, 100); + + globeControl1.Refresh(); + } + } + } + + private void buttonItemHX1_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemHX1.Text); + + GSODataSource dataSpace = globeControl1.Globe.DataManager.OpenOracleDataSource(Utility.DBServer.Trim() + "/" + Utility.dbdatabase.Trim(), "", "", Utility.userID, Utility.DBPassword); + string filepath = ""; + //日志记录 + OpenFileDialog dlg = new OpenFileDialog(); + dlg.Filter = "矢量数据(*.shp)|*.shp|矢量数据(*.lgd)|*.lgd|CAD数据(*.dxf)|*.dxf|全部支持格式(*.lgd,*.shp,*.dxf)|*.lgd;*.shp;*.dxf;"; + dlg.Multiselect = true; + + #region 临时图层显示 + if (dlg.ShowDialog() == DialogResult.OK) + { + string filePath = dlg.FileName; + string lastname = Path.GetFileName(filePath); + + #region + for (int i = 0; i < dlg.FileNames.Length; i++) + { + string strDataPath = dlg.FileNames[i]; + filepath = strDataPath; + + GSOLayer layer = globeControl1.Globe.Layers.Add(strDataPath); + GSOFeatures RedFeatures = layer.GetAllFeatures(); + + 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(); + RedFeatures = features; + 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; + } + + /////////////////////////////////////////////////////////////////////////////////////////// + globeControl1.Globe.Layers.MoveTo(0, globeControl1.Globe.Layers.Count - 1); + globeControl1.Refresh(); + } + + IModelBuilder modelBuilder = new RedLineBuilder(); + + modelBuilder.batchInsert(dataSpace, redDt, RedFeatures); + + } + #endregion + + } + #endregion + } + /// + /// 定位 + /// + /// + /// + private void buttonItemLocation_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemLocation.Text); + + FrmFlyToPosition fly = new FrmFlyToPosition(globeControl1,globeControl2); + fly.Show(this); + } + /// + /// 2015-10-17演示代码 红线审核 + /// + /// + /// + private void ribbonTabItem6_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.FlyToPosition(new GSOPoint3d(120.610963, 31.188121, 50), EnumAltitudeMode.Absolute, -4, 50, 800); + globeControl1.Globe.FlyToPointSpeed = 10000000; + globeControl1.Globe.Action = EnumAction3D.SelectObject; + globeControl1.Refresh(); + + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + + //zhanshi = false; + redSH = true; + splitContainer1.Panel2Collapsed = true; + legendSG.Visible = false; + legendSC.Visible = false; + ClearGZData(); + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = true; + } + + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 基础工具 + /// + /// + /// + private void ribbonTabItem1_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + //zhanshi = false; + redSH = false; + splitContainer1.Panel2Collapsed = true; + panelOfTable.Visible = false; + legendSC.Visible = false; + legendSG.Visible = false; + ClearGZData(); + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + + + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 一键审核 + /// + /// + /// + private void ribbonTabItem11_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + //zhanshi = false; + redSH = false; + splitContainer1.Panel2Collapsed = true; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + panelOfTable.Visible = false; + legendSC.Visible = false; + legendSG.Visible = false; + ClearGZData(); + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + + + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 右屏添加冰箱数据 + /// + void AddDataToGlobeControl2() + { + + bool modelDataBool = false; + for (int i = globeControl2.Globe.Layers.Count - 1; i >= 0; i--) + { + GSOLayer layer = globeControl2.Globe.Layers[i]; + if (layer.Name.Contains("fttp:")) + { + modelDataBool = true; + break; + } + } + + if (modelDataBool == false) + { + GSOLayer ly = globeControl1.Globe.Layers.GetLayerByCaption("天地图地图"); + globeControl2.Globe.Layers.Add(ly); + } + else + { + return; + } + } + /// + /// 双屏对比 + /// + /// + /// + private void ribbonTabItem9_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent += new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent += new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + panelOfTable.Visible = false; + + splitContainer1.Panel2Collapsed = false; + //zhanshi = true; + redSH = false; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + sliderItem2.Value = 100 - globeControl1.Globe.GroundOpaque; + globeControl2.Globe.GroundOpaque = globeControl1.Globe.GroundOpaque; + legendSC.Visible = true; + legendSG.Visible = true; + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + AddDataToGlobeControl2(); + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 文档管理 + /// + /// + /// + private void ribbonTabItem4_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + panelOfTable.Visible = false; + //zhanshi = false; + redSH = false; + splitContainer1.Panel2Collapsed = true; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + legendSC.Visible = false; + legendSG.Visible = false; + ClearGZData(); + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 基础管理 + /// + /// + /// + private void ribbonTabItem14_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + panelOfTable.Visible = false; + //zhanshi = false; + redSH = false; + splitContainer1.Panel2Collapsed = true; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + legendSC.Visible = false; + legendSG.Visible = false; + ClearGZData(); + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 权限管理 + /// + /// + /// + private void ribbonTabItem2_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + panelOfTable.Visible = false; + //zhanshi = false; + redSH = false; + splitContainer1.Panel2Collapsed = true; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + legendSC.Visible = false; + legendSG.Visible = false; + ClearGZData(); + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + GSOFeature dpFeatuer = null; + /// + /// 双屏分析,点击管段分析 + /// + /// + /// + private void buttonItem8_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItem8.Text); + + //FrmCompareFeature frmCompareFeature = new FrmCompareFeature(globeControl1, globeControl2, layerTemp, layerTemp2,m_PipelineLayerNames,sgPipeLayersNames); + int width = this.Width; + FrmCompareFeature.ShowForm(globeControl1, globeControl2, layerTemp, layerTemp2, m_PipelineLayerNames, sgPipeLayersNames,width); + //frmCompareFeature.Location = new Point((this.Width - frmCompareFeature.Width)/2,50); + //frmCompareFeature.Show(this); + + } + /// + /// 红线审核导出图片 + /// + /// + /// + private void buttonItemDCTP_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemDCTP.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))); + */ + int mapWidth = 0; + int mapHeight = 0; + Point pt = getUpperLeftPoint(pt1, pt2, out mapWidth, out mapHeight); + int rightBottomX = pt.X + mapWidth; + int rightBottomY = pt.Y + mapHeight; + Image myImg = new Bitmap(mapWidth, mapHeight); + Graphics g = Graphics.FromImage(myImg); + g.CopyFromScreen(pt, new Point(0, 0), new Size(rightBottomX, rightBottomY)); + + 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; + } + } + } + /// + /// 标识器全区域统计 + /// + /// + /// + private void 标识器分类统计ToolStripMenuItem_Click(object sender, EventArgs e) + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + FrmBSQStatis bsqStatis = new FrmBSQStatis(); + bsqStatis.Show(this); + } + /// + /// 标识器绘制区域统计 + /// + /// + /// + private void 标识器分类统计ToolStripMenuItem1_Click(object sender, EventArgs e) + { + trackflag = "BSQDuoBianXiangStatis"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + } + + #region 保存和加载审核库加载的图层 + /* + private void saveLayerList(TreeNodeCollection treeNodeList) + { + string configPath = Application.StartupPath + "\\configLayerList.xml"; + try + { + XmlDocument doc = new XmlDocument(); + doc.Load(configPath); + XmlNode dbParams = doc.SelectSingleNode("Params/dbparams"); + XmlNode dbLayers = doc.SelectSingleNode("Params/dblayers"); + XmlNode layers = doc.SelectSingleNode("Params/layers"); + dbParams.RemoveAll(); + dbLayers.RemoveAll(); + layers.RemoveAll(); + + List listDS = new List(); + String shDatasourceName = Utility.sgdbip + "/" + Utility.sgdbname + "_" + Utility.sgdbuser; + bool flag = false; + + for (int i = 0; i < globeControl1.Globe.DataManager.DataSourceCount; i++) + { + GSODataSource ds = globeControl1.Globe.DataManager.GetDataSourceAt(i); + if (ds != null && ds.Type == EnumDataSourceType.SqlServer || ds.Type == EnumDataSourceType.Oracle) + { + if (ds.Name == shDatasourceName) + { + //防止因为多次连接同一个数据库 + if (flag == true) + { + break; + } + flag = true; + listDS.Add(ds); + GSODataSourceCnn conn = ds.GetConnectionInfo(); + + XmlElement dbparam = doc.CreateElement("shdbparam"); + XmlElement ip = doc.CreateElement("ship"); + ip.InnerText = conn.Server; + + XmlElement dbname = doc.CreateElement("shdbname"); + dbname.InnerText = conn.Database; + + XmlElement username = doc.CreateElement("shusername"); + username.InnerText = conn.User; + + XmlElement password = doc.CreateElement("shpassword"); + password.InnerText = conn.Password; + + XmlElement type = doc.CreateElement("shtype"); + if (ds.Type == EnumDataSourceType.SqlServer) + { + type.InnerText = "sqlserver"; + } + else + { + type.InnerText = "oracle"; + } + + dbparam.AppendChild(ip); + dbparam.AppendChild(dbname); + dbparam.AppendChild(username); + dbparam.AppendChild(password); + dbparam.AppendChild(type); + dbParams.AppendChild(dbparam); + } + + } + } + + for (int i = 0; i < treeNodeList.Count; i++) + { + GSOLayer layer = treeNodeList[i].Tag as GSOLayer; + if (Path.GetExtension(layer.Name) == "") + { + XmlElement dbLayer = doc.CreateElement("dblayer"); + XmlAttribute attri = doc.CreateAttribute("dbindex"); + for (int j = 0; j < listDS.Count; j++) + { + if (layer.Dataset.DataSource.Name == listDS[j].Name) + { + attri.Value = j.ToString(); + break; + } + } + dbLayer.Attributes.Append(attri); + dbLayer.InnerText = layer.Name; + + dbLayers.AppendChild(dbLayer); + } + else + { + XmlElement dbLayer = doc.CreateElement("layer"); + dbLayer.InnerText = layer.Name; + layers.AppendChild(dbLayer); + } + } + + doc.Save(configPath); + } + catch (Exception e) + { + + } + } + + private void openLayerList() + { + layerManagerNode.Nodes.Clear(); + + string configPath = Application.StartupPath + "\\configLayerList.xml"; + try + { + XmlDocument doc = new XmlDocument(); + doc.Load(configPath); + XmlNode dbParams = doc.SelectSingleNode("Params/dbparams"); + XmlNode dbLayers = doc.SelectSingleNode("Params/dblayers"); + XmlNode layers = doc.SelectSingleNode("Params/layers"); + + List listDS = new List(); + for (int i = 0; i < dbParams.ChildNodes.Count; i++) + { + string ip = ""; + string dbname = ""; + string username = ""; + string password = ""; + string type = ""; + XmlNode node = dbParams.ChildNodes.Item(i); + for (int j = 0; j < node.ChildNodes.Count; j++) + { + XmlNode nodeChild = node.ChildNodes.Item(j); + + if (nodeChild != null && nodeChild.Name == "ship") + { + ip = nodeChild.InnerText; + } + else if (nodeChild != null && nodeChild.Name == "shdbname") + { + dbname = nodeChild.InnerText; + } + else if (nodeChild != null && nodeChild.Name == "shusername") + { + username = nodeChild.InnerText; + } + else if (nodeChild != null && nodeChild.Name == "shpassword") + { + password = nodeChild.InnerText; + } + else if (nodeChild != null && nodeChild.Name == "shtype") + { + type = nodeChild.InnerText; + } + } + + if (type == "sqlserver") + { + GSODataSource ds = globeControl1.Globe.DataManager.OpenSqlServerDataSource(ip, "", dbname, username, password); + listDS.Add(ds); + } + else if (type == "oracle") + { + GSODataSource ds = globeControl1.Globe.DataManager.OpenOracleDataSource(ip + "/" + dbname, "", "", username, password); + listDS.Add(ds); + } + } + + for (int i = 0; i < dbLayers.ChildNodes.Count; i++) + { + XmlNode node = dbLayers.ChildNodes.Item(i); + if (node != null) + { + string layerName = node.InnerText; + XmlAttribute attri = node.Attributes["dbindex"]; + if (attri != null) + { + int dbIndex = -1; + if (int.TryParse(attri.Value, out dbIndex)) + { + GSODataset dataset = listDS[dbIndex].GetDatasetByName(layerName); + globeControl1.Globe.Layers.Add(dataset); + //更新树节点 + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + TreeNode layerNode = new TreeNode(); + layerNode.Tag = layer; + layerNode.Text = layer.Dataset.Caption; + layerNode.ImageIndex = 0; + layerNode.SelectedImageIndex = 0; + layerNode.Checked = layer.Visible; + layerManagerNode.Nodes.Insert(0, layerNode); + // layerManagerNode.Expand(); + + + } + } + } + } + for (int i = 0; i < layers.ChildNodes.Count; i++) + { + XmlNode node = layers.ChildNodes.Item(i); + if (node != null) + { + string layerName = node.InnerText; + globeControl1.Globe.Layers.Add(layerName); + + //更新树节点 + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + TreeNode layerNode = new TreeNode(); + layerNode.Tag = layer; + layerNode.Text = layer.Dataset.Caption; + layerNode.ImageIndex = 0; + layerNode.SelectedImageIndex = 0; + layerNode.Checked = layer.Visible; + layerManagerNode.Nodes.Insert(0, layerNode); + } + } + layerManagerNode.Expand(); + } + catch (Exception e) + { + + } + } + * */ + #endregion + + private void btn_check_history_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_check_history.Text); + + if (FrmCheckHistory.isOpen == true) + { + return; + } + FrmCheckHistory frm = new FrmCheckHistory(globeControl1, globeControl2); + frm.addNode += new AddNodeToLayerManagerNode(addNodeToLayerManagerNode); + frm.Show(); + + } + + private void buttonItem查看数据_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItem查看数据.Text); + + FrmThreeOracle tr = new FrmThreeOracle(globeControl1); + + if (tr.ShowDialog() == DialogResult.OK) + { + addNodeToLayerManagerNode(tr.rukuLayer); + globeControl1.Refresh(); + } + } + /// + /// 规划数据入库 + /// + /// + /// + private void buttonItemGHRK_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemGHRK.Text); + + FrmGHRK ghrk = new FrmGHRK(globeControl1, layerManagerNode); + ghrk.Show(this); + } + + private void btn_user_info_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_user_info.Text); + + if (!FrmSysUserInfoManger.IS_OPEN) + { + FrmSysUserInfoManger frm = new FrmSysUserInfoManger(); + frm.ShowDialog(); + } + } + + private void btn_role_info_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_role_info.Text); + + if (FrmRoleInfoManager.IS_OPEN) + { + return; + } + FrmRoleInfoManager frm = new FrmRoleInfoManager(); + frm.ShowDialog(); + } + + private void btn_resc_info_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_resc_info.Text); + + if (!SysRescInfoManager.IS_OPEN) + { + SysRescInfoManager frm = new SysRescInfoManager(); + frm.ShowDialog(); + } + } + + private void btn_role_resc_Click(object sender, EventArgs e) + { + + LogManager.saveLog(Utility.userName, this.btn_role_resc.Text); + + if (!FrmRoleRescManager.IS_OPEN) + { + FrmRoleRescManager frm = new FrmRoleRescManager(); + frm.ShowDialog(); + } + } + + private void btn_user_role_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_user_role.Text); + + if (FrmUserRole.IS_OPEN) + { + return; + } + FrmUserRole frm = new FrmUserRole(); + frm.ShowDialog(); + } + + private void btn_document_info_Click(object sender, EventArgs e) + { + + LogManager.saveLog(Utility.userName, this.btn_document_info.Text); + + //if (FormDocumentManager.IS_OPEN) + //{ + // return; + //} + //FormDocumentManager frm = new FormDocumentManager(); + //frm.ShowDialog(); + + //if (FormDocumentManager.IS_OPEN) + //{ + // return; + //} + //new FormDocumentManager().ShowDialog(); + if (FormDocumentManager.IS_OPEN) + { + return; + } + this.Cursor = Cursors.WaitCursor; + FormDocumentManager frm = new FormDocumentManager(); + frm.changeCursor += new ChangeCursor(changeCursorToDefault); + frm.ShowDialog(); + + } + + private void changeCursorToDefault() + { + this.Cursor = Cursors.Default; + } + + /// + /// 判断CAD文件是否有投影信息 + /// + /// + /// + Boolean CheckDatasetGeoReference(GSODataset dataset) + { + Boolean bSuccess = false; + if (dataset.GeoReferenceType == EnumGeoReferenceType.Flat) + { + if (MessageBox.Show("数据没有空间参考信息,请设置空间参考信息!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation) == DialogResult.OK) + { + String strPath = Path.GetDirectoryName(Application.ExecutablePath) + "\\Coordinate Systems"; + OpenFileDialog dlg = new OpenFileDialog(); + + dlg.InitialDirectory = strPath; + dlg.RestoreDirectory = true; + + dlg.Filter = "投影文件|*.prj||"; + if (dlg.ShowDialog() == DialogResult.OK) + { + bSuccess = dataset.LoadProjectionFromESRIFile(dlg.FileName); + } + } + } + else + { + return true; + } + return bSuccess; + } + + private void buttonItemexp_CAD_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemexp_CAD.Text); + + OpenFileDialog dlg = new OpenFileDialog(); + dlg.Filter = "支持格式(*.dwg)|*.dwg"; + dlg.Multiselect = true; + if (dlg.ShowDialog() == DialogResult.OK) + { + for (int i = 0; i < dlg.FileNames.Length; i++) + { + //this.Cursor = Cursors.WaitCursor; + string strDataPath = dlg.FileNames[i]; + + #region + //string strDataPathPrj = strDataPath.ToLower().Replace(".dwg", ".lprj"); + + //if (File.Exists(strDataPathPrj) == false) + //{ + // if (MessageBox.Show("数据没有空间参考信息,请设置空间参考信息!", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation) == DialogResult.OK) + // { + // String strPath = Application.StartupPath + "\\Coordinate Systems"; + // OpenFileDialog dlgPrj = new OpenFileDialog(); + // dlgPrj.InitialDirectory = strPath; + // dlgPrj.RestoreDirectory = true; + // dlgPrj.Multiselect = false; + // dlg.Filter = "投影文件|*.prj"; + // if (dlg.ShowDialog() == DialogResult.OK) + // { + // this.Cursor = Cursors.WaitCursor; + // string proj4 = GSODataEngineUtility.ConvertEsriPrjFileToProj4(dlg.FileName); + // using (StreamWriter stream = new StreamWriter(strDataPathPrj, false)) + // { + // stream.WriteLine("0prj4" + proj4 + ""); + // } + // AddLayerData(strDataPath); + // //globeControl1.Globe.Layers.Add(strDataPath); + + // this.Cursor = Cursors.Default; + // } + // else + // { + // AddLayerData(strDataPath); + // //globeControl1.Globe.Layers.Add(strDataPath); + // } + // } + // else + // { + // AddLayerData(strDataPath); + // //globeControl1.Globe.Layers.Add(strDataPath); + // } + + //} + //else + //{ + // //globeControl1.Globe.Layers.Add(strDataPath); + // AddLayerData(strDataPath); + //} + #endregion + AddLayerData(strDataPath); + //this.Cursor = Cursors.Default; + } + } + + 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, 100); + + globeControl1.Refresh(); + } + } + + private void btn_password_edit_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_password_edit.Text); + + if (FrmChangePassword.IS_OPEN) + { + return; + } + FrmChangePassword frm = new FrmChangePassword(); + frm.ShowDialog(); + } + /// + /// 多孔管线入库 + /// + /// + /// + private void buttonItem9_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL4_2.Text); + + if (ds == null) + { + MessageBox.Show("请先连接数据库", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + ConnectDB(null, null); + } + if (ds == null) + return; + + FrmMultiPipelineModelDB frm = new FrmMultiPipelineModelDB(globeControl1, ds); + if (frm.ShowDialog() == DialogResult.OK) + { + addNodeToLayerManagerNode(frm.rukuLayer); + } + //frm.Show(); + } + private void 导出CADToolStripMenuItem1_Click(object sender, EventArgs e) + { + TreeNode node = layerNodeContexMenu.Tag as TreeNode; + if (node == null) + { + MessageBox.Show("请在左侧节点集中选择要导出的图层", "提示"); + return; + } + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(node.Text.Trim()); + if (layer == null || layer.GetAllFeatures().Length <= 0) + { + MessageBox.Show("要导出的图层为空", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + return; + } + string strProjectName = Utility.projectStr; + if (strProjectName != "") + { + SaveFileDialog dlg = new SaveFileDialog(); + dlg.Filter = "*.dwg|*.dwg|*.dxf|*.dxf"; + dlg.FileName = layer.Caption; + if (dlg.ShowDialog(this) == DialogResult.OK) + { + globeControl1.Globe.MemoryLayer.SaveAs(dlg.FileName); + GSOLayer newlayer = globeControl1.Globe.Layers.Add(dlg.FileName); + newlayer.RemoveAllFeature(); + int featureCount = layer.GetAllFeatures().Length; + for (int i = 0; i < featureCount; i++) + { + GSOFeature feature = layer.GetAt(i); + if (feature != null && feature.Geometry != null) + { + if (feature.Geometry.Type == EnumGeometryType.GeoPolyline3D) + { + feature.Geometry.Style = new GSOSimpleLineStyle3D(); + } + else if (feature.Geometry.Type == EnumGeometryType.GeoPolygon3D) + { + feature.Geometry.Style = new GSOSimplePolygonStyle3D(); + } + newlayer.AddFeature(feature); + } + } + newlayer.Save(); + newlayer.Dataset.DataSource.RemoveDataset(newlayer.Dataset); + globeControl1.Globe.Layers.Remove(newlayer); + MessageBox.Show("导出CAD完成!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + } + } + } + + private void buttonItemGBJC_Click(object sender, EventArgs e) + { + FrmGBJC gb = new FrmGBJC(globeControl1, globeControl2, layerTemp, layerTemp2); + gb.Show(this); + } + + #region 右屏管纵数据控制 + private void 五十米主干道ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = true; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + + private void 三十六米次干道ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = true; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + + private void 四十二米次干道ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = true; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + + private void 二十四米一块板ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = true; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + + private void 二十四米三块板ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = true; + } + + private void 二十四米停车带ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = true; + lendendGZ24_3.Visible = false; + } + + private void 二十六米大堤路ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = true; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + + private void 清除管纵数据ToolStripMenuItem_Click(object sender, EventArgs e) + { + ClearGZData(); + } + + private void ClearGZData() + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + #endregion + + private void buttonItemPasswordReset_Click(object sender, EventArgs e) + { + Frm_password_reset reset = new Frm_password_reset(); + reset.Show(); + } + + private void pictureBox1_Paint(object sender, PaintEventArgs e) + { + int Width = this.Width; + string welcomeUser = "欢迎您:" + Utility.userName; + Graphics g = e.Graphics; + g.DrawString(welcomeUser, new Font("宋体", 12), new SolidBrush(Color.Black), Width - 180, 50); + } + + } +} \ No newline at end of file diff --git a/MainFrm.cs.REMOTE.9016.cs b/MainFrm.cs.REMOTE.9016.cs new file mode 100644 index 0000000..9bfb70e --- /dev/null +++ b/MainFrm.cs.REMOTE.9016.cs @@ -0,0 +1,13345 @@ +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; + + GSOBalloon featureTooltip2; + GSOBalloonEx balloonEx2; + + GSOLayer layerTemp; + GSOLayer layerTemp2; + FrmShResult frmShResult = null; + FrmRedlineResult frmredResult = null; + FrmMnModify frmModify = null; + public bool frmRedlineResult = false; + public bool boolfrmShResult = false; + public bool boolfrmModify = false; + + List m_PipelineLayerNames = new List();//线图层名称 + List workwellLayerNames = new List();//工井图层名称 + List valueLayerNames = new List();//阀门图层名称 + List instrumenLayerNames = new List();//附属物图层名称 + List pipefittingLayerNames = new List();//管件图层名称 + List sgPipeLayersNames = new List();//施工管线图层名称 + 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 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; + public string redLayer = null; + //GSOLayer redLayer1 = null; + bool redSH = false; + string redDt = "红线"; + //双屏对比 + //bool zhanshi=false; + Thread t = null; + private GSOHudButton legendSC;//定义图例 + private GSOHudButton legendSG;//定义图例 + //管纵图 + private GSOHudButton lendendGZ50; + private GSOHudButton lendendGZ36; + private GSOHudButton lendendGZ42; + private GSOHudButton lendendGZ24_1; + private GSOHudButton lendendGZ24_2; + private GSOHudButton lendendGZ24_3; + private GSOHudButton lendendGZ26; + + GSOGeoPoint3D bsqPT; + + FrmYJSHTC frmSh = null;//一键审核窗口全局变量wxl + FrmWait frmWait = null;//一键审核等待窗口 + //FrmWait frmWait2 = null;//文档操作等待窗口 + + float mouseDownX1,mouseDownY1; + float mouseDownX2,mouseDownY2; + /// + /// + /// + 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; + + featureTooltip2 = new GSOBalloon(globeControl2.Handle); + balloonEx2 = new GSOBalloonEx(globeControl2.Handle); + Utility.SetBallons(featureTooltip, balloonEx); + + panelOfTable.Height = 200; + + RigthMenuSet(); + + MenuSet(); + + } + /// + /// 右屏中添加管纵图片 + /// + private void AddGZ() + { + + lendendGZ50 = new GSOHudButton(); + lendendGZ50.SetImage(Application.StartupPath + "/Resource/管纵/50.png"); + lendendGZ50.SetOffset(0, 0); + lendendGZ50.MinOpaque = 1; + lendendGZ50.MaxOpaque = 1; + lendendGZ50.FadeOut = false; + lendendGZ50.Name = "lendendGZ50"; + lendendGZ50.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ50); + lendendGZ50.Visible = false; + + lendendGZ36 = new GSOHudButton(); + lendendGZ36.SetImage(Application.StartupPath + "/Resource/管纵/36.png"); + lendendGZ36.SetOffset(0, 0); + lendendGZ36.MinOpaque = 1; + lendendGZ36.MaxOpaque = 1; + lendendGZ36.FadeOut = false; + lendendGZ36.Name = "lendendGZ36"; + lendendGZ36.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ36); + lendendGZ36.Visible = false; + + lendendGZ42 = new GSOHudButton(); + lendendGZ42.SetImage(Application.StartupPath + "/Resource/管纵/42.png"); + lendendGZ42.SetOffset(0, 0); + lendendGZ42.MinOpaque = 1; + lendendGZ42.MaxOpaque = 1; + lendendGZ42.FadeOut = false; + lendendGZ42.Name = "lendendGZ42"; + lendendGZ42.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ42); + lendendGZ42.Visible = false; + + lendendGZ24_1 = new GSOHudButton(); + lendendGZ24_1.SetImage(Application.StartupPath + "/Resource/管纵/24_1.png"); + lendendGZ24_1.SetOffset(0, 0); + lendendGZ24_1.MinOpaque = 1; + lendendGZ24_1.MaxOpaque = 1; + lendendGZ24_1.FadeOut = false; + lendendGZ24_1.Name = "lendendGZ24_1"; + lendendGZ24_1.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ24_1); + lendendGZ24_1.Visible = false; + + lendendGZ24_2 = new GSOHudButton(); + lendendGZ24_2.SetImage(Application.StartupPath + "/Resource/管纵/24_2.png"); + lendendGZ24_2.SetOffset(0, 0); + lendendGZ24_2.MinOpaque = 1; + lendendGZ24_2.MaxOpaque = 1; + lendendGZ24_2.FadeOut = false; + lendendGZ24_2.Name = "lendendGZ24_2"; + lendendGZ24_2.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ24_2); + lendendGZ24_2.Visible = false; + + lendendGZ24_3 = new GSOHudButton(); + lendendGZ24_3.SetImage(Application.StartupPath + "/Resource/管纵/24_3.png"); + lendendGZ24_3.SetOffset(0, 0); + lendendGZ24_3.MinOpaque = 1; + lendendGZ24_3.MaxOpaque = 1; + lendendGZ24_3.FadeOut = false; + lendendGZ24_3.Name = "lendendGZ24_3"; + lendendGZ24_3.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ24_3); + lendendGZ24_3.Visible = false; + + lendendGZ26 = new GSOHudButton(); + lendendGZ26.SetImage(Application.StartupPath + "/Resource/管纵/26.png"); + lendendGZ26.SetOffset(0, 0); + lendendGZ26.MinOpaque = 1; + lendendGZ26.MaxOpaque = 1; + lendendGZ26.FadeOut = false; + lendendGZ26.Name = "lendendGZ26"; + lendendGZ26.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ26); + lendendGZ26.Visible = false; + + } + + public void RigthMenuSet() + { + if (Utility.userRole.IndexOf("清除分析") < 0) + { + toolRightMenu.Items.Remove(清除分析ToolStripMenuItem); + } + + #region 区域分析 + if (Utility.userRole.IndexOf("区域分析") < 0) + { + toolRightMenu.Items.Remove(区域分析ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("缓冲区分析") < 0) + { + 区域分析ToolStripMenuItem.DropDownItems.Remove(缓冲区分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("附属物分析") < 0) + { + 区域分析ToolStripMenuItem.DropDownItems.Remove(附属物分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("无源淹没分析") < 0) + { + 区域分析ToolStripMenuItem.DropDownItems.Remove(无源淹没分析ToolStripMenuItem); + } + } + #endregion + + #region 视域分析 + if (Utility.userRole.IndexOf("视域分析") < 0) + { + toolRightMenu.Items.Remove(视域分析ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("通视分析") < 0) + { + 视域分析ToolStripMenuItem.DropDownItems.Remove(通视分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("可视域分析") < 0) + { + 视域分析ToolStripMenuItem.DropDownItems.Remove(可视域分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("可视包络分析") < 0) + { + 视域分析ToolStripMenuItem.DropDownItems.Remove(可视包络分析ToolStripMenuItem); + } + } + #endregion + + #region 开发分析 + if (Utility.userRole.IndexOf("开挖分析") < 0) + { + toolRightMenu.Items.Remove(开挖分析ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("多边形开挖") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(多边形开挖ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("挖方量分析") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(挖方量分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("沿线开挖") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(沿线开挖ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("创建隧道") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(创建隧道ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("隐藏隧道") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(隐藏隧道ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("删除隧道") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(删除隧道ToolStripMenuItem); + } + } + #endregion + + #region 拓扑分析 + if (Utility.userRole.IndexOf("拓扑分析") < 0) + { + toolRightMenu.Items.Remove(拓扑分析ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("创建拓扑") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(创建拓扑ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("上游分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(上游分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("下游分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(下游分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("流向分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(流向分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("关阀分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(关阀分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("连通分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(连通分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("爆管分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(爆管分析ToolStripMenuItem); + } + } + #endregion + + #region 断面分析 + if (Utility.userRole.IndexOf("断面分析") < 0) + { + toolRightMenu.Items.Remove(断面分析ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("横断面分析") < 0) + { + 断面分析ToolStripMenuItem.DropDownItems.Remove(横断面分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("纵断面分析") < 0) + { + 断面分析ToolStripMenuItem.DropDownItems.Remove(纵断面分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("道路断面分析") < 0) + { + 断面分析ToolStripMenuItem.DropDownItems.Remove(道路断面分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("基线剖面分析") < 0) + { + 断面分析ToolStripMenuItem.DropDownItems.Remove(基线剖面分析ToolStripMenuItem); + } + } + #endregion + + #region 绘制区域统计 + if (Utility.userRole.IndexOf("绘制区域统计") < 0) + { + toolRightMenu.Items.Remove(绘制区域统计ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("绘制区域管线长度统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管线长度统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域阀门数量统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(阀门数量统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域井盖数量统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(井盖数量统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域管径分段统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管径分段统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域埋深分段统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(埋深分段统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域管径分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管径分类统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域材质分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(材质分类统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域附属物分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(附属物分类统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域标识器分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(标识器分类统计ToolStripMenuItem1); + } + + } + #endregion + + #region 全区域统计 + if (Utility.userRole.IndexOf("全区域统计") < 0) + { + toolRightMenu.Items.Remove(全区域统计ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("全区域管线长度统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管线长度统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域阀门数量统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(阀门数量统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域井盖数量统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(井盖数量统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域管径分段统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管径分段统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域埋深分段统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(埋深分段统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域管径分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管径分类统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域材质分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(材质分类统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域附属物分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(附属物分类统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域标识器分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(标识器分类统计ToolStripMenuItem); + } + + } + #endregion + + #region 查询 + if (Utility.userRole.IndexOf("查询") < 0) + { + toolRightMenu.Items.Remove(查询ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("空间查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(空间查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("编号查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(编号查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("坐标查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(坐标查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("管径查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(管径查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("材质查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(材质查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("基本查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(基本查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("复合查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(复合查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("关联查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(关联查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("关键字查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(关键字查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("附属物查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(附属物查询ToolStripMenuItem); + } + } + #endregion + + #region 标注 + if (Utility.userRole.IndexOf("标注") < 0) + { + toolRightMenu.Items.Remove(标注ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("标高标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(标高标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("管径标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(管径标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("埋深标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(埋深标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("坐标标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(坐标标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("距离标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(距离标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("自定义标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(自定义标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("扯旗标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(扯旗标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("坡度标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(坡度标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("属性标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(属性标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("标注管理") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(标注管理ToolStripMenuItem); + } + } + #endregion + + #region 飞行 + if (Utility.userRole.IndexOf("飞行") < 0) + { + toolRightMenu.Items.Remove(飞行ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("自定义飞行") < 0) + { + 飞行ToolStripMenuItem.DropDownItems.Remove(自定义飞行ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("飞行到目标点") < 0) + { + 飞行ToolStripMenuItem.DropDownItems.Remove(飞行到目标点ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("绕中心点飞行") < 0) + { + 飞行ToolStripMenuItem.DropDownItems.Remove(绕中心点飞行ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("绕眼睛飞行") < 0) + { + 飞行ToolStripMenuItem.DropDownItems.Remove(绕眼睛飞行ToolStripMenuItem); + } + } + #endregion + + #region 编辑 + if (Utility.userRole.IndexOf("编辑") < 0) + { + toolRightMenu.Items.Remove(编辑ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("平移对象") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(平移对象ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("升降对象") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(升降对象ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("旋转对象") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(旋转对象ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("连接管段") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(连接管段ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("导出文件") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(导出文件ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("前进") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(前进ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("后退") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(删除模型ToolStripMenuItem); + } + } + #endregion + + #region 量算 + if (Utility.userRole.IndexOf("量算") < 0) + { + toolRightMenu.Items.Remove(量算ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("水平距离") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(水平距离ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("垂直距离") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(垂直距离ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("空间距离") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(空间距离ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("地表距离") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(地表距离ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("高度量算") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(高度量算ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("水平面积") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(水平面积ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("地表面积") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(地表面积ToolStripMenuItem1); + } + } + #endregion + } + + public void MenuSet() + { + + #region 权限管理 + if (Utility.userRole.IndexOf("权限管理") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem2); + } + else + { + + if (Utility.userRole.IndexOf("用户管理") < 0) + { + btn_user_info.Visible = false; + } + if (Utility.userRole.IndexOf("角色管理") < 0) + { + btn_role_info.Visible = false; + } + if (Utility.userRole.IndexOf("资源管理") < 0) + { + btn_resc_info.Visible = false; + } + if (Utility.userRole.IndexOf("角色授权") < 0) + { + btn_role_resc.Visible = false; + } + if (Utility.userRole.IndexOf("用户授权") < 0) + { + btn_user_role.Visible = false; + } + if (Utility.userRole.IndexOf("密码修改") < 0) + { + btn_password_edit.Visible = false; + } + + } + #endregion + + #region 基础工具 + if (Utility.userRole.IndexOf("基础工具") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem1); + } + else + { + if (Utility.userRole.IndexOf("地上模式") < 0) + { + buttonItem87.Visible = false; + } + if (Utility.userRole.IndexOf("地下模式") < 0) + { + buttonItem88.Visible = false; + } + if (Utility.userRole.IndexOf("行走模式") < 0) + { + buttonItem27.Visible = false; + } + if (Utility.userRole.IndexOf("透明度设置") < 0) + { + sliderGroundTransSet1.Visible = false; + } + if (Utility.userRole.IndexOf("快速定位") < 0) + { + buttonItem91.Visible = false; + } + if (Utility.userRole.IndexOf("图层管理") < 0) + { + buttonItem1.Visible = false; + } + if (Utility.userRole.IndexOf("图例管理") < 0) + { + btnlegendSet.Visible = false; + } + if (Utility.userRole.IndexOf("全屏显示") < 0) + { + buttonItem89.Visible = false; + } + if (Utility.userRole.IndexOf("导出图片") < 0) + { + btnOutputJPG.Visible = false; + } + + } + #endregion + + #region 一键审核 + if (Utility.userRole.IndexOf("一键审核") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem11); + } + #endregion + + #region 红线审核 + if (Utility.userRole.IndexOf("红线审核") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem6); + } + #endregion + + #region 双屏对比 + if (Utility.userRole.IndexOf("双屏对比") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem9); + } + #endregion + + #region 文档管理 + if (Utility.userRole.IndexOf("文档管理") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem4); + } + #endregion + + #region 基础管理 + if (Utility.userRole.IndexOf("基础管理") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem14); + } + else + { + if (Utility.userRole.IndexOf("专题图审批") < 0) + { + buttonItemZTT3_2.Visible = false; + } + if (Utility.userRole.IndexOf("打印审批") < 0) + { + buttonItemZTT4_2.Visible = false; + } + if (Utility.userRole.IndexOf("拷贝审批") < 0) + { + buttonItemZTT5_2.Visible = false; + } + } + + #endregion + + if (ribbonControl1.Items.Count <= 0) + { + ribbonControl1.Visible = false; + } + } + + #region Fan Zhang 重构现有代码 + //初始化控件布局 + private void initLayout() + { + 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.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.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.labelX21.Width = (int)(this.labelX21.Width * myScreen); + this.labelX22.Width = (int)(this.labelX22.Width * myScreen); + this.labelX24.Width = (int)(this.labelX24.Width * myScreen); + } + sideBar1.Visible = false; + 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]); + } + + splitContainer1.Panel2Collapsed = true; + + buttonItem87.Checked = true;//默认地上模式 + ribbonTabItem1.Select(); //初始化状态为浏览 + + sideBarPanelItem3.Visible = false; + layerTree.Visible = false; + controlContainerItem3.Visible = false; + if (sideBarPanelItem4.Visible == true) + { + sideBar1.Visible = true; + controlContainerItem5.Visible = true; + } + else + { + sideBar1.Visible = false; + } + Refresh(); + sliderGroundTransSet1.Value = optiValue; + sliderItem1.Value = optiValue; + sliderItem2.Value = optiValue; + sliderItem3.Value = optiValue; + + } + + //初始化地球控件 + private void initGlobalControl() + { + //选择 + btnToolSelect = new GSOHudButton(); + btnToolSelect.SetImage(Application.StartupPath + "\\Resource\\image\\select1.png"); + btnToolSelect.FadeOut = false; + btnToolSelect.Align = EnumAlign.TopLeft; + btnToolSelect.SetOffset(20, 50); + btnToolSelect.Name = "1"; + btnToolSelect.HeightFixed = true; + btnToolSelect.WidthFixed = true; + globeControl1.Globe.AddHudControl(btnToolSelect); + globeControl2.Globe.AddHudControl(btnToolSelect); + + //浏览 + 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); + + //图例 + legend = new GSOHudButton(); + legend.SetImage(Application.StartupPath + "/Resource/图例P.jpg");//图例P + legend.SetOffset(0, 15); + legend.MinOpaque = 1; + legend.MaxOpaque = 1; + legend.FadeOut = false; + legend.Name = "legend"; + legend.Align = EnumAlign.BottomRight; + legend.Visible = false; + globeControl1.Globe.AddHudControl(legend); + + //实测 + legendSC = new GSOHudButton(); + legendSC.SetImage(Application.StartupPath + "/Resource/sc.jpg"); + legendSC.SetOffset(0, 15); + legendSC.MinOpaque = 1; + legendSC.MaxOpaque = 1; + legendSC.FadeOut = false; + legendSC.Name = "legendSC"; + legendSC.Align = EnumAlign.BottomRight; + globeControl1.Globe.AddHudControl(legendSC); + legendSC.Visible = false; + + //施工 + legendSG = new GSOHudButton(); + legendSG.SetImage(Application.StartupPath + "/Resource/sg.jpg"); + legendSG.SetOffset(0, 15); + legendSG.MinOpaque = 1; + legendSG.MaxOpaque = 1; + legendSG.FadeOut = false; + legendSG.Name = "legendSG"; + legendSG.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(legendSG); + legendSG.Visible = false; + + //管纵 + AddGZ(); + + 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; + globeControl1.Globe.IsReleaseMemOutOfView = true; + globeControl1.Globe.ControlPanel.Visible = true; + + globeControl2.Globe.UnderGroundFloor.Visible = false; + globeControl2.Globe.OverviewControl.Visible = false; + globeControl2.Globe.ScalerControl.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; + globeControl2.Globe.IsReleaseMemOutOfView = true; + globeControl2.Globe.ControlPanel.Visible = false; + + 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); + + //添加临时图层 + layerTemp = globeControl1.Globe.Layers.Add(Application.StartupPath + "\\tempLgdData.lgd"); + layerTemp2 = globeControl2.Globe.Layers.Add(Application.StartupPath + "\\tempLgdData2.lgd"); + if (layerTemp != null) + { + layerTemp.MaxVisibleAltitude = 1000; + } + + //添加城市7线图层 + 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"); + + //注册对应事件 + this.registerEvent(); + } + + //注册地球事件 + private bool registerEvent() + { + if (globeControl1 == null || globeControl2 == null) + { + return false; + } + 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); + + globeControl2.FeatureMouseClickEvent += new FeatureMouseClickEventHandler(globeControl2_FeatureMouseClickEvent); + globeControl2.CameraBeginMoveEvent += new CameraBeginMoveEventHandler(globeControl2_CameraBeginMoveEvent); + + globeControl1.MouseDoubleClick += new MouseEventHandler(globeControl1_MouseDoubleClick); + globeControl1.MouseClick += new MouseEventHandler(globeControl1_MouseClick); + globeControl1.MouseDown += new MouseEventHandler(globeControl1_MouseDown); + + globeControl2.MouseClick += new MouseEventHandler(globeControl2_MouseClick); + globeControl2.MouseDown += new MouseEventHandler(globeControl2_MouseDown); + + 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); + + return true; + } + + //加载两个地球数据 + private void loadData() + { + Thread t1 = new Thread(new ThreadStart(doLoadDataForGlobalControl1)); + t1.IsBackground = true; + t1.Start(); + + + } + + delegate void LoadDataForGlobalControl(); + + private void connectServer() + { + globeControl1.Globe.ConnectServer(Utility.serverip, Utility.serverport, "", ""); //加载locaServer中的数据 + globeControl2.Globe.ConnectServer(Utility.serverip, Utility.serverport, "", ""); //加载locaServer中的数据 + //初始化TreeView + // 勾选实测图层 + foreach (TreeNode tn in layerTree.Nodes) + { + if (tn.Nodes.Count > 0) + { + if (tn.Text == "实测数据") + { + tn.Checked = true; + foreach (TreeNode tnChild in tn.Nodes) + { + tnChild.Checked = true; + foreach (TreeNode tnGrandChild in tnChild.Nodes) + { + tnGrandChild.Checked = true; + } + } + } + } + } + } + + private void doLoadDataForGlobalControl1() + { + try + { + + globeControl1.Globe.Layers.MoveDown(10000); + //加载实测管线数据 + Utility.dataSource = globeControl1.Globe.DataManager.OpenOracleDataSource(Utility.DBServer.Trim() + "/" + Utility.dbdatabase.Trim(), "", "", Utility.userID, Utility.DBPassword); + + if (Utility.dataSource != null) + { + for (int j = 0; j < Utility.dataSource.DatasetCount; j++) + { + GSODataset dataset = Utility.dataSource.GetDatasetAt(j); + if (dataset != null && dictionaryNetLayerNameAndCaption.ContainsKey(dataset.Caption)) + { + dataset.Caption = dataset.Name; + globeControl1.Globe.Layers.Add(dataset); + } + } + } + //隐藏红线图层 + globeControl1.Globe.Layers.GetLayerByCaption("红线").Visible = false; + + //globleControl1中加载规划数据 + GSODataSource ghDS = globeControl1.Globe.DataManager.OpenOracleDataSource(Utility.ghdbip + "/" + Utility.ghdbname, "", "", Utility.ghdbuser, Utility.ghdbpwd); + if (ghDS != null) + { + for (int j = 0; j < ghDS.DatasetCount; j++) + { + GSODataset dataset = ghDS.GetDatasetAt(j); + if (dataset != null && dictionaryNetLayerNameAndCaption.ContainsKey(dataset.Caption)) + { + dataset.Caption = dataset.Name; + globeControl1.Globe.Layers.Add(dataset); + globeControl1.Globe.Layers[0].Visible = false; + } + } + } + + //globeControl1,globeControl2中加载施工数据 + GSODataSource sgDS = globeControl1.Globe.DataManager.OpenOracleDataSource(Utility.sgdbip + "/" + Utility.sgdbname, "", "", Utility.sgdbuser, Utility.sgdbpwd); + if (sgDS != null) + { + for (int m = 0; m < sgDS.DatasetCount; m++) + { + GSODataset dataset = sgDS.GetDatasetAt(m); + if (dataset != null && !dataset.Caption.Contains("SH") && dictionaryNetLayerNameAndCaption.ContainsKey(dataset.Caption)) + { + dataset.Caption = dataset.Name; + globeControl1.Globe.Layers.Add(dataset); + globeControl1.Globe.Layers[0].Visible = false; + + globeControl2.Globe.Layers.Add(dataset); + globeControl2.Globe.Layers[0].Visible = true; + } + } + } + + LoadDataForGlobalControl ss = new LoadDataForGlobalControl(connectServer); + ss(); + + } + catch (Exception ex) + { + MessageBox.Show(ex.Message); + } + } + + private void initLayerTree() + { + //加载临时图层节点 + layerManagerNode = new TreeNode(); + layerManagerNode.ImageIndex = 0; + layerManagerNode.SelectedImageIndex = 0; + layerManagerNode.Checked = true; + layerManagerNode.Text = "临时图层"; + layerTree.Nodes.Add(layerManagerNode); + + XmlDocument doc = new XmlDocument(); + doc.Load(filename); + XmlNodeList xmlLayerNodes = doc.SelectNodes("//layer"); + + foreach (XmlNode xmlLayerNode in xmlLayerNodes) + { + + //TODO LIST:创建一级TreeNode(实测、规划、施工) + TreeNode nodelayer = new TreeNode(); + string layerName = xmlLayerNode.Attributes["label"].Value; + nodelayer.Text = layerName; + nodelayer.Checked = false; + layerTree.Nodes.Add(nodelayer); + + XmlNodeList xmlChildLayerNodes = xmlLayerNode.ChildNodes; + foreach (XmlNode xmlChildLayerNode in xmlChildLayerNodes) + { + //TODO LIST:创建二级TreeNode节点 + TreeNode secondLevelNode = new TreeNode(); + string layerType = xmlChildLayerNode.Attributes["label"].Value; + secondLevelNode.Text = layerType; + + if (xmlChildLayerNode.Attributes["type"] != null) + { //道路图层特殊处理 + string type = xmlChildLayerNode.Attributes["type"].Value; + secondLevelNode.Tag = type + "|" + layerType; + } + else + { + secondLevelNode.Tag = layerType; + } + secondLevelNode.Checked = false; + nodelayer.Nodes.Add(secondLevelNode); + + XmlNodeList xmlActitualLayerNodes = xmlChildLayerNode.ChildNodes; + + foreach (XmlNode xmlActitualLayerNode in xmlActitualLayerNodes) + { + //TODO LIST:创建三级图层节点 + TreeNode layerNode = new TreeNode(); + string actutallylayerType = xmlActitualLayerNode.Attributes["type"].Value; + string actutallylayerName = xmlActitualLayerNode.Attributes["layer"].Value; + string actutallyLabelName = xmlActitualLayerNode.Attributes["label"].Value; + + layerNode.Text = actutallyLabelName; + layerNode.Tag = layerType + "|" + actutallyLabelName; + layerNode.Checked = false; + secondLevelNode.Nodes.Add(layerNode); + } + + } + + } + + } + + /** + * 读取Config.xml文件,初始化以下全局Map + * m_PipelineLayerNames:管线 + * workwellLayerNames:工井 + * valueLayerNames:阀门 + * instrumenLayerNames:附属物 + * pipefittingLayerNames:特征管点 + * sgPipeLayersNames:施工管线 + **/ + private void initGlobalMap() + { + XmlDocument doc = new XmlDocument(); + doc.Load(filename); + XmlNodeList xmlLayerNodes = doc.SelectNodes("//layerchild"); + + foreach (XmlNode xmlLayerNode in xmlLayerNodes) + { + string layerType = xmlLayerNode.Attributes["type"].Value; + string layerName1 = xmlLayerNode.Attributes["layer"].Value; + string layerchildName = xmlLayerNode.Attributes["label"].Value; + + dictionaryNetLayerNameAndCaption.Add(layerName1, layerchildName); + + if (layerType != "db") + { + if (xmlLayerNode.Attributes["isRoad"] != null) + { + roadLayerName = layerchildName; + } + } + else if (xmlLayerNode.Attributes["isPipeLine"] != null) + { + m_PipelineLayerNames.Add(layerchildName); + g1layername.Add(layerName1); + } + else if (xmlLayerNode.Attributes["isWorkWell"] != null) + { + workwellLayerNames.Add(layerchildName); + g1layername.Add(layerName1); + } + else if (xmlLayerNode.Attributes["isValve"] != null) + { + valueLayerNames.Add(layerchildName); + g1layername.Add(layerName1); + } + else if (xmlLayerNode.Attributes["isAccess"] != null) + { + instrumenLayerNames.Add(layerchildName); + g1layername.Add(layerName1); + } + else if (xmlLayerNode.Attributes["isCharacter"] != null) + { + pipefittingLayerNames.Add(layerchildName); + g1layername.Add(layerName1); + } + else if (xmlLayerNode.Attributes["isSgData"] != null) + { + sgPipeLayersNames.Add(layerchildName); + g1layername.Add(layerName1); + } + + } + } + + private void initMarkerTree() + { + 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); + } + } + } + } + + private void MainFrm_Load(object sender, EventArgs e) + { + + this.initGlobalControl(); + this.initGlobalMap(); + this.initLayerTree(); + this.initMarkerTree(); + this.initLayout(); + this.loadData(); + + + double x = Convert.ToDouble(Utility.Query_Roads["绿岛"].ToString().Split(',')[0]); + double y = Convert.ToDouble(Utility.Query_Roads["绿岛"].ToString().Split(',')[1]); + double z = Convert.ToDouble(Utility.Query_Roads["绿岛"].ToString().Split(',')[2]); + jumpToCameraState(x, y, z); + + + } + + #endregion + + /// + /// 每次gis服务加载时都会触发的 + /// + /// + /// + 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 dictionaryNetLayerNameAndCaption = new Dictionary(); + 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 配置用户权限 + /// + /// 向数据库插入功能列表 + /// + private void insertControlToDatabase() + { + ArrayList listItem = new ArrayList(); + List subListItem = new List(); + 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) + { + GSOCameraState camera = globeControl2.Globe.CameraState; + globeControl1.Globe.JumpToCameraState(camera); + } + } + + void globeControl1_BeforeSceneRenderEvent(object sender, BeforeSceneRenderEventArgs e) + { + if (globeControl1.Focused) + { + 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); + } + } + } + + /// + /// 检查数据集是否有坐标系信息 + /// + /// + /// + 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 = "0prj4" + lprjStr + ""; + + bSuccess = dataset.LoadProjectionFromESRIFile(dlg.FileName); + + string lprjFileName = strDataPath.Substring(0, strDataPath.LastIndexOf(".")) + ".lprj"; + StreamWriter writer = new StreamWriter(lprjFileName, false); + writer.Write(lprjFileContent); + writer.Close(); + + } + } + } + else + { + return true; + } + return bSuccess; + } + + /// + /// 矩形拉框结束事件处理函数 + /// + /// + /// + 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))); + */ + + int mapWidth = 0; + int mapHeight = 0; + Point pt = getUpperLeftPoint(pt1, pt2, out mapWidth, out mapHeight); + int rightBottomX = pt.X + mapWidth; + int rightBottomY = pt.Y + mapHeight; + Image myImg = new Bitmap(mapWidth, mapHeight); + Graphics g = Graphics.FromImage(myImg); + g.CopyFromScreen(pt, new Point(0, 0), new Size(rightBottomX, rightBottomY)); + + 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; + } + } + /// + /// 定位正北正90度俯视 + /// + /// + /// + /// + 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; + } + } + /// + /// layerTree选中后事件处理 + /// + /// + /// + 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); + } + /// + /// 树节点选中方法 + /// + /// + 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); + } + } + } + + } + /// + /// 改变所有子节点的状态 + /// + /// + /// + 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; + LayerFlyMenuItem.Visible = true; + } + + LayerSelectableMenuItem.Visible = true; + LayerEditableMenuItem.Visible = true; + SaveLayerMenuItem.Visible = true; + LayerFlyMenuItem.Visible = true; + 导出CADToolStripMenuItem1.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]); + if (layer != null) + { + LayerSelectableMenuItem.Checked = layer.Selectable; + LayerEditableMenuItem.Checked = layer.Editable; + } + else + { + return; + } + } + 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; + } + } + } + } + } + + /// + /// 删除临时添加的本地数据图层 + /// + /// + /// + 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); + for (int i = globeControl1.Globe.Layers.Count-1; i >=0; i--) + { + if (globeControl1.Globe.Layers[i].Caption == layer.Caption) + { + globeControl1.Globe.Layers.Remove(globeControl1.Globe.Layers[i]); + } + } + + 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 定位ToolStripMenuItem_Click(object sender, EventArgs e) + { + TreeNode node = layerTree.SelectedNode; + + if (node != null) + { + if (node.Parent.Text.Trim() == "临时图层") + { + GSOLayer lsLayer = globeControl1.Globe.Layers.GetLayerByCaption(node.Text.ToString()); + double x = lsLayer.LatLonBounds.Center.X; + double y = lsLayer.LatLonBounds.Center.Y; + if (x == 0 && y == 0) + { + x = lsLayer.Bounds.Center.X; + y = lsLayer.Bounds.Center.Y; + } + + globeControl1.Globe.FlyToPosition(new GSOPoint3d(x, y, 10), EnumAltitudeMode.Absolute); + } + else + { + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(node.Tag.ToString().Split('|')[1]); + + if (layer != null) + { + if (layer.Caption == "红线") + { + globeControl1.Globe.FlyToPosition(new GSOPoint3d(120.610963, 31.188121, 50), EnumAltitudeMode.Absolute, -4, 50, 1000); + globeControl1.Globe.FlyToPointSpeed = 10000000; + globeControl1.Globe.Action = EnumAction3D.SelectObject; + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = true; + } + globeControl1.Refresh(); + } + else + { + double x = layer.LatLonBounds.Center.X; + double y = layer.LatLonBounds.Center.Y; + globeControl1.Globe.FlyToPosition(new GSOPoint3d(x, y, 100), EnumAltitudeMode.Absolute); + } + } + } + } + else + { + return; + } + + } + + private void layerTree_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e) + { + if(this.layerTree.SelectedNode!=null) + { + if (this.layerTree.SelectedNode.Tag.ToString().Contains("|")) + { + string nodeTag = this.layerTree.SelectedNode.Tag.ToString().Split('|')[1]; + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(nodeTag); + if (layer != null) + { + if (layer.Caption == "红线") + { + globeControl1.Globe.FlyToPosition(new GSOPoint3d(120.610963, 31.188121, 50), EnumAltitudeMode.Absolute, -4, 50, 1000); + globeControl1.Globe.FlyToPointSpeed = 10000000; + globeControl1.Globe.Action = EnumAction3D.SelectObject; + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = true; + } + globeControl1.Refresh(); + } + else { + double x = layer.LatLonBounds.Center.X; + double y = layer.LatLonBounds.Center.Y; + globeControl1.Globe.FlyToPosition(new GSOPoint3d(x, y, 0), EnumAltitudeMode.Absolute); + } + } + } + if (this.layerTree.SelectedNode.Tag is GSOLayer) + { + GSOLayer layer = this.layerTree.SelectedNode.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 (this.layerTree.SelectedNode.Tag is GSOFeature) + { + GSOFeature feature = this.layerTree.SelectedNode.Tag as GSOFeature; + if (feature.Geometry != null) + { + globeControl1.Globe.FlyToPosition(feature.Geometry.GeoCenterPoint, EnumAltitudeMode.Absolute, 0, 0, 10); + } + else + { + globeControl1.Globe.FlyToFeature(feature); + } + } + } + } + + /// + /// 在三维场景移动时,隐藏气泡globeControl1 + /// + /// + /// + void globeControl1_CameraBeginMoveEvent(object sender, CameraBeginMoveEventArgs e) + { + if (featureTooltip.IsVisible()) + { + featureTooltip.HideBalloon(); + } + if (balloonEx.IsVisible()) + { + balloonEx.HideBalloon(); + } + } + + /// + /// 在三维场景移动时,隐藏气泡globeControl2 + /// + /// + /// + void globeControl2_CameraBeginMoveEvent(object sender, CameraBeginMoveEventArgs e) + { + if (featureTooltip2.IsVisible()) + { + featureTooltip2.HideBalloon(); + } + if (balloonEx2.IsVisible()) + { + balloonEx2.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(); + } + } + + #region Fan 横断面 + /// + /// 横断面分析、基线剖面分析、道路断面分析等 + /// + /// + /// + private static EnumTrackPolylineEndMode trackPolylineEndMode; + + void globeControl1_TrackPolylineEndEvent(object sender, TrackPolylineEndEventArgs e) + { + //横断面分析、道路横断面分析 + if (trackPolylineEndMode == EnumTrackPolylineEndMode.HDM_Analysis|| + trackPolylineEndMode == EnumTrackPolylineEndMode.DLDM_Analysis) + { + Dictionary hdmDic = SectionAnalysisTool.HDMAnalysis(this.globeControl1, + e.Polyline, this.m_PipelineLayerNames); + FrmHDMAnalysis3 frm = new FrmHDMAnalysis3(hdmDic, this.globeControl1, + trackPolylineEndMode); + frm.Show(this); + } + //基线剖面分析 + else if (trackPolylineEndMode == EnumTrackPolylineEndMode.JXPM_Analysis) + { + FrmBaseLineProfillAnalysis dlg = new FrmBaseLineProfillAnalysis(globeControl1.Globe, e.Polyline); + dlg.Show(this); + globeControl1.Globe.ClearLastTrackPolyline(); + /* + FrmRoadHDM f = new FrmRoadHDM(); + f.Show() + * **/ + } + else + { + + } + trackPolylineEndMode = EnumTrackPolylineEndMode.Default_Analysis; + /* + ArrayList arraylistPoint = new ArrayList(); + ArrayList arraylistLine = new ArrayList(); + + // globeControl1.Globe.ClearLastTrackPolyline(); + + if (e.Polyline != null) + { + //横断面分析 + if (buttonItemFX2_1.Checked || buttonItemFX2_3.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 (buttonItemFX2_1.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 (buttonItemFX2_4.Checked) + { + FrmBaseLineProfillAnalysis dlg = new FrmBaseLineProfillAnalysis(globeControl1.Globe, e.Polyline); + dlg.Show(this); + globeControl1.Globe.ClearLastTrackPolyline(); + } + else if (buttonItemFX4_3.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(); + * **/ + } + #endregion + + private GSOFeatures PolygonIntersectAnalysis(GSOGeoPolygon3D polygon, string pipelinetype) + { + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(pipelinetype); + 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(pipelinetype, feats.Length); + return feats; + } + /// + /// 根据范围统计阀门、管线、工井等, 开挖分析, 挖方量分析 + /// + /// + /// + void globeControl1_TrackPolygonEndEvent(object sender, TrackPolygonEndEventArgs e) + { + if (globeControl1.Globe.Action == EnumAction3D.TrackPolygon && e.Polygon != null) + { + GSOGeoPolygon3D polygon = e.Polygon; + + switch (trackflag) + { + case "valvequery": + FrmValveStatistics frm = new FrmValveStatistics(globeControl1,polygon, new DataGridViewDelegate(InitDataGridViewX1)); + frm.Show(this); + //panelEx6.Visible = true; + toolStripFeatureLength.Text = ""; + globeControl1.Globe.Action = EnumAction3D.ActionNull; + break; + + case "PipelineDistanceStatistics": + + FrmAllPipelineStatis frm1 = new FrmAllPipelineStatis(globeControl1, polygon, new DataGridViewDelegate(InitDataGridViewX1), m_PipelineLayerNames); + frm1.Show(this); + globeControl1.Globe.Action = EnumAction3D.ActionNull; + + break; + case "PipelineSpatialQuery": + + FrmAllPipelineStatis.ShowForm(globeControl1,polygon,new DataGridViewDelegate(InitDataGridViewX1),m_PipelineLayerNames); + globeControl1.Globe.ClearAnalysis(); + globeControl1.Globe.Action = EnumAction3D.ActionNull; + + break; + case "workwellquery": + FrmAllWorkWellStatis frmWell = new FrmAllWorkWellStatis(globeControl1, polygon, new DataGridViewDelegate(InitDataGridViewX1)); + 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 "BSQDuoBianXiangStatis": + + //GSOFeature f2 = new GSOFeature(); + //f2.Geometry = e.Polygon; + //f2.Geometry.AltitudeMode = EnumAltitudeMode.Absolute; + //globeControl1.Globe.MemoryLayer.AddFeature(f2); + //f2.Geometry.MoveZ(3); + //workWellLen.Clear(); + //List listBSQ = new List(); + + //GSOFeatures bsqFeatures = PolygonIntersectAnalysis(e.Polygon, "标识器"); + //listBSQ.Add(bsqFeatures); + + //FrmBSQDuoBianXingStatis bsqFrm = new FrmBSQDuoBianXingStatis(workWellLen, globeControl1, listBSQ); + FrmBSQStatis bsqFrm = new FrmBSQStatis(globeControl1,e.Polygon); + bsqFrm.Show(this); + globeControl1.Globe.Action = EnumAction3D.ActionNull; + break; + + case "": + break; + default: + break; + } + } + } + + #region 验证端口 + /* + /// + /// 验证端口 + /// + /// + 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 + + /// + /// 鼠标悬浮提示 + /// + /// + /// + 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); + } + } + + /// + /// 添加管线绘制完成事件, 红线工具绘制完成 + /// + /// + /// + 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; + + + } + } + + /// + /// 获取globeControl1中鼠标按下的坐标供区别鼠标右键和滚轮按下事件 + /// + /// + /// + void globeControl1_MouseDown(object sender, MouseEventArgs e) + { + mouseDownX1 = e.X; + mouseDownY1 = e.Y; + } + /// + /// 获取globeControl2中鼠标按下的坐标供区别鼠标右键和滚轮按下事件 + /// + /// + /// + void globeControl2_MouseDown(object sender, MouseEventArgs e) + { + mouseDownX2 = e.X; + mouseDownY2 = e.Y; + } + /// + /// + /// + /// + /// + void globeControl2_MouseClick(object sender, MouseEventArgs e) + { + if (e.Button == MouseButtons.Right) + { + if (e.X == mouseDownX2 && e.Y == mouseDownY2) + { + RightScreenToolMenu.Show(globeControl2, e.X, e.Y); + } + else + { + return; + } + } + } + /// + /// + /// + /// + /// + void globeControl1_MouseClick(object sender, MouseEventArgs e) + { + if (e.Button == MouseButtons.Left) + { + if (globeControl1.Globe.Action == EnumAction3D.VisibilityAnalysis) + { + buttonItemFX5_1.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; + + bsqPT = pt; + + if (buttonItemLS5.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 (e.X == mouseDownX1 && e.Y == mouseDownY1) + { + toolRightMenu.Show(globeControl1, e.X, e.Y); + if (buttonItemLS5.Checked) + { + buttonItemLS5.Checked = false; + } + } + else + { + return; + } + } + globeControl1.Refresh(); + } + + /// + /// 判断网络图片是否存在 + /// + /// + /// + 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; + } + + /// + /// 鼠标点击, 弹出气泡功能globeControl1 + /// + /// + /// + void globeControl1_FeatureMouseClickEvent(object sender, FeatureMouseClickEventArgs e) + { + GSOFeature feature = e.Feature; + + string str1 = ""; + if (feature != null) + { + if (feature.GetFieldDefn("图片编码") != null)// + { + str1 = GetBubbleInfo(feature, globeControl1); + if (RemoteFileExists(Utility.PicRootURL + feature.GetValue("图片编码").ToString())) + { + str1 += ""; + } + else if (RemoteFileExists(Utility.PicDefaultURL)) + { + str1 += ""; + } + } + else if (isFeatureContainsBianhao(feature)) //管线模型图层 + { + str1 = GetBubbleInfo(feature, globeControl1); + } + + 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; + } + } + } + + /// + /// 鼠标点击, 弹出气泡功能globeControl2 + /// + /// + /// + void globeControl2_FeatureMouseClickEvent(object sender, FeatureMouseClickEventArgs e) + { + GSOFeature feature = e.Feature; + + string str1 = ""; + if (feature != null) + { + if (feature.GetFieldDefn("图片编码") != null) // + { + str1 = GetBubbleInfo(feature, globeControl2); + if (RemoteFileExists(Utility.PicRootURL + feature.GetValue("图片编码").ToString())) + { + str1 += ""; + } + else if (RemoteFileExists(Utility.PicDefaultURL)) + { + str1 += ""; + } + } + else if (isFeatureContainsBianhao(feature)) //管线模型图层 + { + str1 = GetBubbleInfo(feature, globeControl2); + } + + if (str1 != "") + { + + featureTooltip2.HideBalloon(); + balloonEx2.HideBalloon(); + balloonEx2.SetSize(EnumSizeIndexEx.CONTENT_CX, 480); + balloonEx2.SetSize(EnumSizeIndexEx.CONTENT_CY, 420); + balloonEx2.ShowBalloon((int)e.MousePos.X, (int)e.MousePos.Y, str1); + + return; + } + } + } + + /// + /// 拼接气泡表格字符串 + /// + /// + /// + private string GetBubbleInfo(GSOFeature feature,GSOGlobeControl globeControl) + { + if (feature == null) + { + return ""; + } + string str = ""; + str = ""; + 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 += ""; + + 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.get_Fields(layerName, globeControl); + } + if (queryFields != null) + { + string[] param = { "," }; + string[] fieldNames = queryFields.Split(param, StringSplitOptions.RemoveEmptyEntries); + for (int j = 0; j < fieldNames.Length; 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 (name1 == "模型路径") + { + continue; + } + 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 (field1.Type == EnumFieldType.Double) + { + double dl1 = feature.GetFieldAsDouble(j); + if (!name1.Contains("管径") && !name1.Contains("电压") && !name1.Contains("角度")) + { + name1 += "_米"; + } + value1 = dl1.ToString("0.00"); + } + 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 (name2 == "模型路径") + { + continue; + } + + 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 (field2.Type == EnumFieldType.Double) + { + double dl2 = feature.GetFieldAsDouble(j + 1); + if (!name2.Contains("管径") && !name2.Contains("电压") && !name2.Contains("角度")) + { + name2 += "_米"; + } + value2 = dl2.ToString("0.00"); + } + else + { + if (!feature.IsFieldValueNull(j + 1)) + { + value2 = feature.GetValue(j + 1).ToString(); + } + } + } + } + + j++; + } + str += ""; + } + } + str += "
" + title + " " + feature.GetFieldAsString(featureIDFieldName) + "
" + + name1 + + "
" + + value1 + + "
" + + name2 + + "
" + + value2 + "
"; + return str; + } + + string filename = Utility.filename; + List g1layername = new List(); + + /// + /// 获取目标图层 + /// + /// + 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; + } + /// + /// 添加图层 + /// + /// + /// + /// + 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 = 5000; + return templayer.Visible; + } + catch (Exception ex) + { + return false; + } + } + /// + /// 菜单上的 三维导航 工具按钮 + /// + /// + /// + private void buttonItem86_Click(object sender, EventArgs e) + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + } + + /// + /// 地上模式 菜单按钮 + /// + /// + /// + 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(); + + } + } + /// + /// 地下模式 菜单按钮 + /// + /// + /// + 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(); + } + } + /// + /// 行走模式 菜单按钮 + /// + /// + /// + 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; + } + } + /// + /// 地面透明度设置 菜单 + /// + /// + /// + private void sliderGroundTransSet1_ValueChanged(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.sliderGroundTransSet1.Text); + + globeControl1.Globe.GroundOpaque = 100 - sliderGroundTransSet1.Value; + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(roadLayerName);//("180fd"); + if (layer != null) + { + layer.Opaque = 100 - sliderGroundTransSet1.Value; + } + //if (buttonItemSPDB.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; + } + /// + /// 图例 菜单按钮 + /// + /// + /// + 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(); + } + /// + /// 快速定位 菜单按钮 + /// + /// + /// + private void buttonItem91_Click(object sender, EventArgs e) // + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItem91.Text); + FrmFlyToPosition fly = new FrmFlyToPosition(globeControl1); + fly.Show(this); + } + /// + /// 图层管理 菜单按钮 + /// + /// + /// + 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; + + //修改图层管理与标注管理、覆土审查、水平净距分析、垂直净距分析和碰撞分析控件之间的逻辑关系 + controlContainerItem5.Visible = false; + sideBar1.Visible = false; + sideBarPanelItem4.Visible = false; + panel3.Visible = false; + sideBar1.ExpandedPanel = sideBarPanelItem3; + buttonItemBZ11.Checked = false; + + //20160624 + /* + if (sideBarPanelItem4.Visible == true) + { + sideBar1.Visible = true; + controlContainerItem5.Visible = true; + } + else + { + sideBar1.Visible = false; + } + */ + Refresh(); + + } + } + /// + /// 全屏显示 菜单按钮 + /// + /// + /// + 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; + /// + /// 全屏显示功能实现 + /// + 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(); + } + } + + /// + /// 设置窗体宽、高 + /// + /// + /// + private void SetFullScreen(int width, int height) + { + this.Width = width; + this.Height = height; + } + + /// + /// 全屏功能的快捷键F5 + /// + /// + /// + 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); + } + } + /* + /// + /// 输出地图 + /// + /// + /// + /// + 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; + } + * */ + + private Point getUpperLeftPoint(Point p1, Point p2, out int mapWidth, out int mapHeight) // + { + Rectangle rc = new Rectangle(); + + p1 = this.globeControl1.PointToScreen(p1); + p2 = this.globeControl1.PointToScreen(p2); + + int x = Screen.PrimaryScreen.Bounds.X; + int y = Screen.PrimaryScreen.Bounds.Y; + int screenWidth = SystemInformation.WorkingArea.Width; + int screenHeight = SystemInformation.WorkingArea.Height; + + if (p1.X < x) + rc.X = x; + else + rc.X = p1.X; + + if (p1.Y < y) + rc.Y = y; + else + rc.Y = p1.Y; + + p1.X = rc.Left; + p1.Y = rc.Top; + + if (p2.X > screenWidth) + p2.X = screenWidth; + else + p2.X = p2.X; + + if (p2.Y > screenHeight) + p2.Y = screenHeight; + else + p2.Y = p2.Y; + + rc.Width = p2.X - rc.X; + rc.Height = p2.Y - rc.Y; + + mapWidth = rc.Width; + mapHeight = rc.Height; + Point pt = new Point(rc.Left, rc.Top); + return pt; + } + + Image printImage; + /// + /// 打印 菜单 + /// + /// + /// + 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))); + */ + int mapWidth = 0; + int mapHeight = 0; + Point pt = getUpperLeftPoint(pt1, pt2, out mapWidth, out mapHeight); + int rightBottomX = pt.X + mapWidth; + int rightBottomY = pt.Y + mapHeight; + Image myImg = new Bitmap(mapWidth, mapHeight); + Graphics g = Graphics.FromImage(myImg); + g.CopyFromScreen(pt, new Point(0, 0), new Size(rightBottomX, rightBottomY)); + + + 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); + } + /// + /// 输出地图 菜单 + /// + /// + /// + private void btnOutputJPG_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btnOutputJPG.Text); + + //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))); + */ + int mapWidth = 0; + int mapHeight = 0; + Point pt = getUpperLeftPoint(pt1, pt2, out mapWidth, out mapHeight); + int rightBottomX = pt.X + mapWidth; + int rightBottomY = pt.Y + mapHeight; + Image myImg = new Bitmap(mapWidth, mapHeight); + Graphics g = Graphics.FromImage(myImg); + g.CopyFromScreen(pt, new Point(0, 0), new Size(rightBottomX, rightBottomY)); + + 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; + } + } + } + + /// + /// 在窗体的底部状态栏上显示 综合管线条件查询结果 + /// + /// + /// + 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 + " 条记录 | "; + } + } + + /// + /// 统计管线的里程数 + /// + /// + /// + /// + 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; + } + + /// + /// 窗体下方属性表格 右键菜单中的 “定位”菜单 + /// + /// + /// + 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); + + } + + /// + /// 表格中右键 “单个闪烁” 菜单 + /// + /// + /// + private void LightMenu_Click(object sender, EventArgs e) + { + flashflag = "single"; + timer1.Start(); + } + /// + /// 表格中右键 “全部闪烁” 菜单 + /// + /// + /// + private void AllLightMenuItem_Click(object sender, EventArgs e) + { + flashflag = "all"; + timer1.Start(); + } + + /// + /// 使用timer实现管线的闪烁效果 + /// + /// + /// + 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; + } + } + + /// + /// 绘制线 菜单 + /// + /// + /// + private void btnAddLine_Click(object sender, EventArgs e) + { + globeControl1.Globe.DestLayerFeatureAdd = globeControl1.Globe.MemoryLayer; + globeControl1.Globe.Action = EnumAction3D.DrawPolyline; + } + /// + /// 绘制面 菜单 + /// + /// + /// + private void btnAddPolygon_Click(object sender, EventArgs e) + { + globeControl1.Globe.DestLayerFeatureAdd = globeControl1.Globe.MemoryLayer; + globeControl1.Globe.Action = EnumAction3D.DrawPolygon; + } + /// + /// 图层目录树 右键菜单中的 目标图层 菜单 + /// + /// + /// + 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; + } + } + /// + /// 图层目录树 右键菜单中的 可选择 菜单 + /// + /// + /// + 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; + } + /// + /// 图层目录树 右键菜单中的 可编辑 菜单 + /// + /// + /// + 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; + } + /// + /// 图层目录树 右键菜单中的 保存 菜单 + /// + /// + /// + 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(); + } + + /// + /// 根据多边形范围统计管线的里程 + /// + /// + /// + /// 返回查询到的管线要素集合 + 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 pipeLineDis = new Dictionary(); + Dictionary workWellLen = new Dictionary(); + + + + + /// + /// 查找指定图层中在 指定范围内的feature对象集合 + /// + /// + /// + /// + 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; + } + /// + /// 清除结果 菜单 + /// + /// + /// + private void buttonItem47_Click(object sender, EventArgs e) + { + globeControl1.Globe.ClearAnalysis(); + dataGridViewX1.DataSource = null; + panelOfTable.Visible = false; + clearFeatureHighLight(); + } + /// + /// 设置菜单的选中状态 + /// + private void ActionToolMenuChecked() + { + if (globeControl1.Globe.Action != EnumAction3D.TrackPolyline) + { + buttonItemFX2_1.Checked = false; + buttonItemFX2_4.Checked = false; + buttonItemFX2_3.Checked = false; + buttonItemFX4_3.Checked = false; + } + if (globeControl1.Globe.Action != EnumAction3D.NormalHit) + { + buttonItemFX3_6.Checked = false; + // ClearConnexityAnalysis(); + + buttonItemFX3_5.Checked = false; + // ClearCloseValvesAnalysis(); + } + if (globeControl1.Globe.Action != EnumAction3D.TrackPolygon) + { + buttonItemFX4_2.Checked = false; + buttonItemFX4_1.Checked = false; + } + } + + /// + /// 主窗体关闭事件处理 + /// + /// + /// + private void MainFrm_FormClosing(object sender, FormClosingEventArgs e) + { + + if (MessageBox.Show("是否退出系统?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) + { + e.Cancel = true; + } + else { + globeControl1.Globe.MemoryLayer.SaveAs(Application.StartupPath + "/MyPlace.kml"); + } + + //saveLayerList(layerManagerNode.Nodes); + //注销id号为103的热键设定 + // UnregisterHotKey(Handle, 103); + } + + /// + /// 显示流向 功能 + /// + /// + /// + /// + 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(); + } + + FrmCloseValves frm; + + FrmBoosterValvers frmbooster = null; + + /// + /// 垂直净距分析 功能界面中的 选择图层复选框 选中状态改变事件处理 + /// + /// + /// + 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(); + } + /// + /// 水平净距分析 功能界面中的 选择图层复选框 选中状态改变事件处理 + /// + /// + /// + 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(); + } + /// + /// 垂直净距分析 功能界面中的 选择管线复选框 选中状态改变事件处理 + /// + /// + /// + private void checkBoxX1_CheckedChanged(object sender, EventArgs e) + { + clearFeatureHighLight(); + if (checkBoxX1.Checked) + { + comboBoxEx1.SelectedItem = null; + 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; + } + } + /// + /// 水平净距分析 功能界面中的 选择管线复选框 选中状态改变事件处理 + /// + /// + /// + private void checkBoxX1_CheckedChanged_shuiping(object sender, EventArgs e) + { + clearFeatureHighLight();//清除高亮 + if (checkBoxX7.Checked) + { + comboBoxEx4.SelectedItem = null; + 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(); + /// + /// 垂直净距分析 功能界面中的 选择图层下拉框 选中项改变 事件处理 + /// + /// + /// + 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; + } + } + } + /// + /// 水平净距分析 功能界面中的 选择图层下拉框 选中项改变 事件处理 + /// + /// + /// + 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 featCount = new Dictionary(); + Dictionary featLenth = new Dictionary(); + Dictionary m_FeaturesWithBianhao = new Dictionary();//记录编号和对应的标注点的位置 + GSOFeatures polygonJingJuAnalysises = new GSOFeatures(); + + /// + /// 垂直净距分析 功能界面中的 开始分析按钮 事件处理 + /// + /// + /// + 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; + } + + /// + /// 在指定的两点组成的线的中间添加一个marker对象,并将marker对象添加到指定的图层中 + /// + /// + /// + /// + /// + /// + 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; + } + + /// + /// 计算指定feature对象与除了该feature所在图层之外的 所有管线图层中的所有feature对象 的垂直距离 并在表格中记录符合要求的管线 + /// + /// + /// + /// + /// + private void VerticalDistanceAnalysis(string type, GSOFeature selectedFeature, List _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(); + } + /// + /// 垂直净距分析中 表格行的 双击定位 功能。 与覆土分析的实现方法不同,主要原因是需要标注垂距 + /// + /// + /// + 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); + } + } + } + } + + /// + /// 水平净距分析 功能界面中 开始分析按钮 的事件处理 + /// + /// + /// + 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; + } + + + /// + /// 计算指定feature对象与除了该feature所在图层之外的 所有管线图层中的所有feature对象 的水平距离 并记录符合要求的管线 功能 + /// + /// + /// + /// + /// + private void HorizontalDistanceAnalysis(GSOFeature selectedFeature, List _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)); + } + } + } + } + } + /// + /// 水平净距分析 功能界面中 表格的 双击定位 功能 + /// + /// + /// + 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); + } + } + } + } + } + /// + /// 碰撞分析 功能界面中 开始分析按钮 事件处理 + /// + /// + /// + 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; + } + /// + /// 碰撞分析功能界面中 表格的 双击定位 功能 + /// + /// + /// + 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); + } + } + } + } + + + + /// + /// 覆土分析功能操作界面中的 选择管线 复选框选中状态改变事件处理 + /// + /// + /// + private void checkBoxX5_CheckedChanged(object sender, EventArgs e) + { + clearFeatureHighLight(); + if (checkBoxX5.Checked) + { + comboBoxEx3.SelectedItem = null; + 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; + } + } + /// + /// 覆土分析功能操作界面中的 选择图层 复选框选中状态改变事件处理 + /// + /// + /// + 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(); + } + /// + /// 覆土分析功能操作界面中的 图层下拉框选中项改变事件处理 + /// + /// + /// + 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; + } + } + } + /// + /// 覆土分析功能操作界面中的 开始分析 按钮事件处理 + /// + /// + /// + 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; + + + GSOPoint3d markerPosition = new GSOPoint3d(); + 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]; + GSOPoint3d pt = new GSOPoint3d(); + + 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"); + + pt.X = pts[m].X; + pt.Y = pts[m].Y; + pt.Z = 0; + markerPosition = LabelVerticalDistance(layerTemp, pts[m], pt, Convert.ToDouble(dataGridViewX7.Rows[idx].Cells[2].Value), true); + 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]; + GSOPoint3d pt = new GSOPoint3d(); + 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"); + + pt.X = pts[m].X; + pt.Y = pts[m].Y; + pt.Z = 0; + markerPosition = LabelVerticalDistance(layerTemp, pts[m], pt, Convert.ToDouble(dataGridViewX7.Rows[idx].Cells[2].Value), true); + + 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; + } + + /// + /// 覆土分析中 表格的 双击定位 功能 + /// + /// + /// + 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); + } + } + } + } + } + /// + /// 覆土分析功能操作界面中的 导出Excel按钮 事件处理 + /// + /// + /// + private void buttonX10_Click(object sender, EventArgs e) + { + if (dataGridViewX7.Rows.Count > 0) + { + ExportExcel("覆土分析", dataGridViewX7, null); + } + else + { + MessageBox.Show("表格内容为空!", "提示"); + } + } + /// + /// 覆土分析功能操作界面底部的 关闭 按钮事件处理 + /// + /// + /// + 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(); + layerTemp.RemoveAllFeature(); + + if (buttonItem1.Checked) + { + sideBar1.ExpandedPanel = sideBarPanelItem3; + } + else + { + sideBar1.Visible = false; + } + globeControl1.Refresh(); + + //Refresh(); + } + + + /// + /// 垂直净距分析 功能界面中 清除分析结果按钮 事件处理 + /// + /// + /// + 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(); + } + /// + /// 水平净距分析 功能界面中 清除分析结果按钮 事件处理 + /// + /// + /// + 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(); + } + + /// + /// 垂直净距分析功能界面中 关闭按钮 事件处理 + /// + /// + /// + 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(); + } + /// + /// 水平净距分析功能界面中 删除缓冲区按钮 事件处理 + /// + /// + /// + private void buttonX14_Click(object sender, EventArgs e) + { + 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(); + } + + /// + /// 导出指定DataGridView控件中的内容 + /// + /// + /// + 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(); + } + } + } + } + + /// + /// 垂直净距分析功能界面中 导出Excel按钮 事件处理 + /// + /// + /// + private void buttonX4_Click(object sender, EventArgs e) + { + if (dataGridViewX3.Rows.Count > 0) + { + ExportExcel("垂直净距分析", dataGridViewX3, listBox1); + } + else + { + MessageBox.Show("表格内容为空!", "提示"); + } + } + /// + /// 水平净距分析功能界面中 导出Excel按钮 事件处理 + /// + /// + /// + private void buttonX4_Click_shuiping(object sender, EventArgs e) + { + if (dataGridViewX9.Rows.Count > 0) + { + ExportExcel("水平净距分析", dataGridViewX9, listBox3); + } + else + { + MessageBox.Show("表格内容为空!", "提示"); + } + } + + + /// + /// 清除所有坑 菜单 + /// + /// + /// + private void buttonItem3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItem3.Text); + + globeControl1.Globe.RemoveAllPits(); + } + + //} + /// + /// 大气层 菜单 + /// + /// + /// + private void buttonItem17_Click_1(object sender, EventArgs e) + { + globeControl1.Globe.Atmosphere.Visible = !globeControl1.Globe.Atmosphere.Visible; + buttonItemSH1.Checked = globeControl1.Globe.Atmosphere.Visible; + globeControl1.Refresh(); + } + /// + /// 经纬网 菜单 + /// + /// + /// + private void buttonItem20_Click(object sender, EventArgs e) + { + globeControl1.Globe.LatLonGrid.Visible = !globeControl1.Globe.LatLonGrid.Visible; + buttonItemSH3.Checked = globeControl1.Globe.LatLonGrid.Visible; + globeControl1.Globe.Refresh(); + } + /// + /// 状态条 菜单 + /// + /// + /// + private void buttonItem21_Click_1(object sender, EventArgs e) + { + globeControl1.Globe.StatusBar.Visible = !globeControl1.Globe.StatusBar.Visible; + buttonItemSH4.Checked = globeControl1.Globe.StatusBar.Visible; + globeControl1.Globe.Refresh(); + } + + + + /// + /// 添加指定路径下的数据 功能 + /// + /// + /// + 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); + //CheckDatasetGeoReference(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; + } + return objRes; + } + /// + /// 刷新目录树 功能 + /// + 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); + } + } + /// + /// 判断图层是否包含字段列表 + /// + /// + /// + 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; + } + + /// + /// 统计指定图层在指定范围内的所有feature对象 + /// + /// + /// + /// + 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; + } + /// + /// 碰撞分析功能界面中 选择管线复选框 选中状态改变事件处理 + /// + /// + /// + private void checkBoxX3_CheckedChanged(object sender, EventArgs e) + { + clearFeatureHighLight(); + if (checkBoxX3.Checked) + { + comboBoxEx2.SelectedItem = null; + 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; + } + } + /// + /// 碰撞分析功能界面中 选择图层复选框 选中状态改变事件处理 + /// + /// + /// + 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(); + } + /// + /// 碰撞分析功能界面中 选择图层下拉框 选中项改变事件处理 + /// + /// + /// + 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; + } + } + } + /// + /// 清除所有图层中的所有feature对象的高亮状态 功能 + /// + 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); + } + } + } + } + for (int i = 0; i < globeControl2.Globe.Layers.Count; i++) + { + GSOLayer layer = globeControl2.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; + } + } + } + + if (globeControl1.Globe.Action == EnumAction3D.SelectObject) + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + //globeControl1.Globe.Action = EnumAction3D.SelectObject; + } + } + + /// + /// 碰撞分析功能界面中 清除分析结果按钮 事件处理 + /// + /// + /// + 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(); + } + /// + /// 碰撞分析功能界面中 导出Excel按钮 事件处理 + /// + /// + /// + private void buttonX6_Click(object sender, EventArgs e) + { + if (dataGridViewX5.Rows.Count > 0) + { + ExportExcel("碰撞分析", dataGridViewX5, listBox2); + } + else + { + MessageBox.Show("表格内容为空!", "提示"); + } + } + /// + /// 导出CAD 菜单 + /// + /// + /// + private void btnExportCAD_Click(object sender, EventArgs e) + { + FrmExportCADS frm = new FrmExportCADS(globeControl1, m_PipelineLayerNames); + frm.ShowDialog(); + } + + ///// + ///// 区域分析 菜单 + ///// + ///// + ///// + //private void buttonItem50_Click(object sender, EventArgs e) + //{ + // buttonItem50.Checked = !buttonItem50.Checked; + // ribbonBarQY.Visible = buttonItem50.Checked; + // ribbonBarQY.Location = new Point(0, 0); + //} + + + /// + /// 连接数据库 菜单事件处理 + /// + /// + /// + 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; + } + } + } + /// + /// 数据验证 菜单 + /// + /// + /// + private void buttonItem80_Click(object sender, EventArgs e) + { + FrmValiData frm = new FrmValiData(globeControl1); + frm.ShowDialog(); + } + /// + /// 根据指定图层创建图层节点并将节点添加到图层管理节点的子节点集合中 + /// + /// + 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; + + if (!layerManagerNode.Nodes.Contains(node)) + { + layerManagerNode.Nodes.Insert(0, node); + layerManagerNode.Expand(); + } + } + } + /// + /// 数据库备份 菜单 + /// + /// + /// + 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(); + } + } + } + + + + #region Fan 去掉 + //GSOFeature emitterFeature; // 粒子要素 + /// + /// 添加火苗 功能 + /// + /// + /// + /// + 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); + + } + /// + /// 添加喷泉 功能 + /// + /// + /// + /// + 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); + } + #endregion + + /// + /// 获取指定图层中最后一个feature对象的名称对应的整数 + /// + /// + /// + 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; + } + /// + /// 设置除指定标注图层之外的所有标注图层不可见 + /// + /// + 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; + } + } + } + } + } + + /// + /// 判断选中的对象是否为管线 + /// + /// 被选中管线 + /// 返回一根线 + 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; + } + + /// + /// 创建label要素 功能 + /// + /// 添加label要素的feature + /// feature的位置 + /// label要素名字 + /// feature名字 + /// label要素距离点的位置 + /// + 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; + } + + + + /// + /// 获取指定两点组成的线的长度 功能 + /// + /// + /// + /// + 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; + } + + /// + /// 图层节点树中 节点 右键单击事件处理 + /// + /// + /// + 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; + } + } + } + } + } + + /// + /// 标注管理、传感器管理 图层目录树的右键菜单中的 刷新列表 菜单 + /// + /// + /// + 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); + } + } + /// + /// 给指定的图层节点添加代表feature对象的子节点 + /// + /// + private void RefreshTreeNodeLayerFeatureList(TreeNode layerTreeNode) + { + layerTreeNode.Nodes.Clear(); + GSOLayer layer = (GSOLayer)layerTreeNode.Tag; + // 只将类型为内存数据集的图层列出,如果是其它类型的数据集可能数据量太大,没发显示在树控件中 + if (layer.Dataset is GSOFeatureDataset) + { + VisitFeature3Ds(layer.GetAllFeatures(), layerTreeNode); + } + } + + /// + /// 标注管理、传感器管理 图层目录树的右键菜单中的 移除所有 菜单 + /// + /// + /// + 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(); + } + } + + /// + /// 图层目录树的 节点对应的复选框选中状态改变事件处理 + /// + /// + /// + private void layerMarkerTree_AfterCheck(object sender, TreeViewEventArgs e) + { + if (e.Action != TreeViewAction.Unknown) + { + CheckTreeNode(e.Node, e.Node.Checked); + } + } + /// + /// 改变指定节点对应的复选框的选中状态 + /// + /// + /// + private void CheckTreeNode(TreeNode node, Boolean bChecked) + { + CheckChildTreeNode(node, bChecked); + globeControl1.Globe.Refresh(); + } + /// + /// 改变指定节点的子节点对应的复选框的选中状态 + /// + /// + /// + 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); + } + } + /// + /// 标注管理、传感器管理 目录树中的feature节点的右键菜单中的 删除 菜单 + /// + /// + /// + 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(); + } + } + + /// + /// 双屏对比 菜单 + /// + /// + /// + //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(); + // } + //} + /// + /// 模拟分析 菜单 + /// + /// + /// + //private void buttonItem51_Click(object sender, EventArgs e) + //{ + // buttonItem51.Checked = !buttonItem51.Checked; + // ribbonBarMN.Visible = buttonItem51.Checked; + // ribbonBarMN.Location = new Point(0, 0); + //} + + /// + /// 双屏设置 菜单 + /// + /// + /// + //private void buttonItem96_Click(object sender, EventArgs e) + //{ + // FrmLayerControl frm = new FrmLayerControl(layerTree,globeControl1,globeControl2); + // frm.Show(this); + //} + /// + /// 双屏联动 菜单 + /// + /// + /// + //private void buttonItem95_Click(object sender, EventArgs e) + //{ + // buttonItem95.Checked = !buttonItem95.Checked; + //} + ///// + /// 添加用户仓库 菜单 + /// + /// + /// + private void buttonItem108_Click(object sender, EventArgs e) + { + FrmUserRepo frm = new FrmUserRepo(-1); + frm.ShowDialog(); + } + /// + /// 用户仓库管理 菜单 + /// + /// + /// + private void buttonItem111_Click(object sender, EventArgs e) + { + FrmUserRepoMgr frm = new FrmUserRepoMgr(); + frm.ShowDialog(); + } + /// + /// 添加分系统 菜单 + /// + /// + /// + private void buttonItem112_Click(object sender, EventArgs e) + { + //FrmAPP frm = new FrmAPP(-1); + //frm.ShowDialog(); + } + /// + /// 分系统管理 菜单 + /// + /// + /// + private void buttonItem113_Click(object sender, EventArgs e) + { + //FrmAPPMgr frm = new FrmAPPMgr(); + //frm.ShowDialog(); + } + /// + /// 添加操作 菜单 + /// + /// + /// + private void buttonItem114_Click(object sender, EventArgs e) + { + FrmOper frm = new FrmOper(-1); + frm.ShowDialog(); + } + /// + /// 操作管理 菜单 + /// + /// + /// + private void buttonItem115_Click(object sender, EventArgs e) + { + FrmOperMgr frm = new FrmOperMgr(); + frm.ShowDialog(); + } + /// + /// 添加资源 菜单 + /// + /// + /// + private void buttonItem116_Click(object sender, EventArgs e) + { + FrmRESC frm = new FrmRESC(-1); + frm.ShowDialog(); + } + /// + /// 资源管理 菜单 + /// + /// + /// + private void buttonItem117_Click(object sender, EventArgs e) + { + FrmRESCMgr frm = new FrmRESCMgr(); + frm.ShowDialog(); + } + /// + /// 添加权限 菜单 + /// + /// + /// + private void buttonItem118_Click(object sender, EventArgs e) + { + FrmPerm frm = new FrmPerm(-1); + frm.ShowDialog(); + } + /// + /// 权限管理 菜单 + /// + /// + /// + private void buttonItem119_Click(object sender, EventArgs e) + { + FrmPermMgr frm = new FrmPermMgr(); + frm.ShowDialog(); + } + /// + /// 添加访问控制 菜单 + /// + /// + /// + private void buttonItem120_Click(object sender, EventArgs e) + { + FrmAccess frm = new FrmAccess(-1); + frm.ShowDialog(); + } + /// + /// 访问控制管理 菜单 + /// + /// + /// + private void buttonItem121_Click(object sender, EventArgs e) + { + FrmAccessMgr frm = new FrmAccessMgr(); + frm.ShowDialog(); + } + /// + /// 部门类型管理 菜单 + /// + /// + /// + private void buttonItem122_Click(object sender, EventArgs e) + { + FrmRegionTypeMgr frm = new FrmRegionTypeMgr(); + frm.ShowDialog(); + } + /// + /// 添加用户 菜单 + /// + /// + /// + private void buttonItem127_Click(object sender, EventArgs e) + { + FrmUserAdd frm = new FrmUserAdd(-1); + frm.ShowDialog(); + } + /// + /// 用户信息管理 菜单 + /// + /// + /// + private void buttonItem128_Click_1(object sender, EventArgs e) + { + FrmUserManager frm = new FrmUserManager(); + frm.ShowDialog(); + } + /// + /// 添加角色 菜单 + /// + /// + /// + private void 添加角色_Click(object sender, EventArgs e) + { + FrmRole frm = new FrmRole(-1); + frm.ShowDialog(); + } + /// + /// 所有角色管理 菜单 + /// + /// + /// + private void 角色管理_Click(object sender, EventArgs e) + { + FrmRoleMgr frm = new FrmRoleMgr(); + frm.ShowDialog(); + } + + /// + /// 部门角色管理 菜单 + /// + /// + /// + private void buttonItem133_Click(object sender, EventArgs e) + { + FrmRegionRoleMgr frm = new FrmRegionRoleMgr(); + frm.ShowDialog(); + } + /// + /// 部门管理 菜单 + /// + /// + /// + private void buttonItem130_Click(object sender, EventArgs e) + { + FrmRegionMgr frm = new FrmRegionMgr(); + frm.ShowDialog(); + } + + /// + /// 日志管理 菜单 + /// + /// + /// + private void buttonItem135_Click(object sender, EventArgs e) + { + FrmLogManager frm = new FrmLogManager(); + frm.ShowDialog(); + } + /// + /// 传感器信息查询 菜单 + /// + /// + /// + 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); + } + } + } + /// + /// 根据指定的图层的caption属性的值在配置文件中查找对应的数据库中的表的名称 + /// + /// 图层的caption属性的值 + /// 对应的数据库中的表的名称 + 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; + } + /// + /// 根据数据库中的表的名称 查找对应的表中的字段名称的集合 + /// + /// 数据库中的表的名称 + /// 对应的表中的字段名称的集合 + 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; + } + + /// + /// 历史曲线查询 菜单 + /// + /// + /// + 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; + /// + /// 传感器在线报警 菜单 + /// + /// + /// + 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); + } + /// + /// 传感器报警 功能中的 定时器 的触发事件处理 + /// + /// + /// + 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; + } + } + } + } + } + } + } + + + /// + /// 沿线运动 菜单 + /// + /// + /// + private void buttonItem138_Click(object sender, EventArgs e) + { + if (globeControl1.Globe.SelectedObject == null) + { + MessageBox.Show("请先选择一条线!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + return; + } + + GSOFeature lineFeature = globeControl1.Globe.SelectedObject; + if (lineFeature.Geometry == null || lineFeature.Geometry.Type != EnumGeometryType.GeoPolyline3D) + { + MessageBox.Show("请先选择一条线!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + return; + } + + OpenFileDialog dlg = new OpenFileDialog(); + dlg.Filter = "*.gcm;*.3ds|*.gcm;*.3ds|*.3ds|*.3ds|*.gcm|*.gcm"; + if (dlg.ShowDialog() == DialogResult.OK) + { + GSOGeoModel model = new GSOGeoModel(); + model.FilePath = dlg.FileName; + + GSOGeoDynamicRoute dynamicRoute = new GSOGeoDynamicRoute(); + dynamicRoute.ActorGeometry = model; + + GSORoute route = new GSORoute(); + GSOGeoPolyline3D geoline = (GSOGeoPolyline3D)lineFeature.Geometry; + for (int i = 0; i < geoline[0].Count; i++) + { + route.Add(geoline[0][i]); + } + route.CircleRoute = false; + route.Speed = 30; + route.RotateSpeed = 50; + route.AltitudeMode = geoline.AltitudeMode; + dynamicRoute.Route = route; + + GSOFeature feature = new GSOFeature(); + + dynamicRoute.Play(); + feature.Geometry = dynamicRoute; + + //GSOLabel gsoLabel = new GSOLabel(); + //gsoLabel.Text = "模型测试"; + //feature.Label = gsoLabel; + globeControl1.Globe.MinModelVisibleSize = 0; + + globeControl1.Globe.MemoryLayer.AddFeature(feature); + globeControl1.Globe.Refresh(); + } + } + /// + /// 回退 菜单 + /// + /// + /// + private void buttonItem99_Click(object sender, EventArgs e) + { + globeControl1.Globe.UnDoEdit(); + } + /// + /// 前进 菜单 + /// + /// + /// + private void buttonItem100_Click(object sender, EventArgs e) + { + globeControl1.Globe.ReDoEdit(); + } + /// + /// 水平净距 功能界面中的 标签内容改变事件处理 + /// + /// + /// + 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() + "米的管线有:"; + } + } + } + /// + /// 垂直净距 功能界面中的 标签内容改变事件处理 + /// + /// + /// + 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() + "米的管线有:"; + } + } + } + /// + /// 覆土分析 功能界面中的 标签内容改变事件处理 + /// + /// + /// + 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() + "米的管线有:"; + } + } + } + + /// + /// 传感器分类查询 全区域 菜单 + /// + /// + /// + private void buttonItemSensor全区域查询_Click(object sender, EventArgs e) + { + FrmAccessoriesSensor.ShowForm(globeControl1, instrumenLayerNames, 0); + } + /// + /// 传感器分类查询 绘制区域 菜单 + /// + /// + /// + private void buttonItemSensor绘制区域查询_Click(object sender, EventArgs e) + { + FrmAccessoriesSensor.ShowForm(globeControl1, instrumenLayerNames, 1); + } + + + /// + /// 碰撞分析 功能界面中 关闭按钮 事件处理 + /// + /// + /// + 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(); + } + /// + /// 覆土分析 功能界面中的 清除分析结果 按钮事件处理 + /// + /// + /// + 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(); + } + /// + /// 数字预处理 功能 + /// + /// + /// + private void 数字预处理buttonItem140_Click(object sender, EventArgs e) + { + FrmEditShapeFile frm = new FrmEditShapeFile(globeControl1); + frm.ShowDialog(this); + } + + + /// + /// 导出矢量 功能 将图层导出为kml和shp格式数据 + /// + /// + /// + private void 导出矢量buttonItem140_Click(object sender, EventArgs e) + { + List listVectorNames = new List(); + for (int i = 0; i < m_PipelineLayerNames.Count; i++) + { + 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 = ""; + /// + /// 绘制城市七线 功能按钮 + /// + /// + /// + 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; + } + } + } + /// + /// 七线审核 功能按钮 + /// + /// + /// + private void 七线审核buttonItem141_Click(object sender, EventArgs e) + { + FrmCityServerLineAnalysis frm = new FrmCityServerLineAnalysis(globeControl1, m_PipelineLayerNames); + frm.ShowDialog(this); + } + + /// + /// 间距分析 开始分析按钮 分析绘制的七线和管线的距离是否符合标准 + /// + /// + /// + 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; + } + /// + /// 间距分析 清除分析结果 + /// + /// + /// + 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(); + } + /// + /// 间距分析 导出Excel按钮 将间距分析的结果以Excel表格的形式导出 + /// + /// + /// + private void buttonExportExcel_Click(object sender, EventArgs e) + { + if (dataGridViewAnalysisResult.Rows.Count > 0) + { + ExportExcel("间距分析", dataGridViewAnalysisResult, listBoxStasticsResult); + } + else + { + MessageBox.Show("表格内容为空!", "提示"); + } + } + /// + /// 间距分析 关闭按钮 + /// + /// + /// + 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(); + } + /// + /// 间距分析 分析结果表格双击定位 + /// + /// + /// + 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); + } + } + } + } + /// + /// 间距分析 选择管线复选框 + /// + /// + /// + private void checkBoxSelectPipeline_CheckedChanged(object sender, EventArgs e) + { + clearFeatureHighLight();//清除高亮 + if (checkBoxSelectPipeline.Checked) + { + comboBoxLayer.SelectedItem = null; + 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; + } + } + /// + /// 间距分析 选择图层复选框 + /// + /// + /// + 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(); + } + /// + /// 间距分析 选择图层下拉框 + /// + /// + /// + 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; + } + } + } + + + + /// + /// 管线自动缩进 菜单 + /// + /// + /// + private void 管线自动缩进buttonItem140_Click(object sender, EventArgs e) + { + FrmPipelineIndented frm = new FrmPipelineIndented(globeControl1, m_PipelineLayerNames, workwellLayerNames); + 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 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); + // } + //} + + /// + /// 统计指定图层在指定范围内的所有feature对象 + /// + /// + /// + /// + 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) + { + 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 setLayerVisible(string layerName) + { + GSOLayer templayer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + if (templayer != null) + { + templayer.Visible = false; + } + globeControl1.Globe.Refresh(); + } + + /// + /// 连接数据库 + /// + /// + /// + private void buttonItem129_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL4_1.Text); + + FrmDatabaseParaSetting2 frm = new FrmDatabaseParaSetting2(globeControl1); + if (frm.ShowDialog() == DialogResult.OK) + { + ds = FrmDatabaseParaSetting2.ds; + if (ds != null) + { + ds.IsCloseSaved = false; + } + } + } + + /// + /// 一键审核---导入数据 + /// + /// + /// + private void buttonItem127_Click_2(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, "打开数据"); + + try + { + //if (shds == null) + //{ + //没连的话,直接连接审核库; //审核库配置读配置文件 + string dbIp = Utility.sgdbip; + string database = Utility.sgdbname; + string user = Utility.sgdbuser; + string pass = Utility.sgdbpwd; + /* + 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; + //} + } + catch (Exception ex) + { + LogError.PublishError(ex); + MessageBox.Show("内存过载请清理内存,并重新启动规划分析!", "提示"); + return; + } + + } + + /// + ///自动导出图片 + /// + /// + /// + private void buttonItem130_Click_1(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, "导出审核图"); + + 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))); + */ + + int mapWidth = 0; + int mapHeight = 0; + Point pt = getUpperLeftPoint(pt1, pt2, out mapWidth, out mapHeight); + int rightBottomX = pt.X + mapWidth; + int rightBottomY = pt.Y + mapHeight; + Image myImg = new Bitmap(mapWidth, mapHeight); + Graphics g = Graphics.FromImage(myImg); + g.CopyFromScreen(pt, new Point(0, 0), new Size(rightBottomX, rightBottomY)); + + 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; + } + } + } + /// + /// 一键审核功能 + ///
+ /// + /// + private void buttonItem128_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItem128.Text); + //垂直净距标准 + + frmSh = new FrmYJSHTC(globeControl1, globeControl2,layerTree); + + if (frmSh.ShowDialog() == DialogResult.OK) + { + frmWait = new FrmWait("一键审核……"); + frmWait.Location = new Point(this.Width - frmWait.Width - 10, this.Height - frmWait.Height - 50); + frmWait.Owner = this; + frmWait.Show(); + Thread thread = new Thread(new ThreadStart(doWork)); + thread.IsBackground = true; + thread.Start(); + } + } + + void doWork() + { + FrmShResult frmShResult = null; + + double dVerticalJingJuBiaoZhun = 1, dHorizontalJingJuBiaoZhun = 1; + if (frmSh.rukuLayer != null) + { + #region + this.Invoke((EventHandler)delegate + { + try + { + List managerLayerList = new List(); + for (int i = 0; i < layerManagerNode.Nodes.Count; i++) + { + managerLayerList.Add(layerManagerNode.Nodes[i].Text); + } + if (!managerLayerList.Contains(frmSh.rukuLayer.Caption)) + { + TreeNode node = new TreeNode(); + node.Tag = frmSh.rukuLayer; + node.Text = frmSh.rukuLayer.Dataset.Caption; + node.ImageIndex = 0; + node.SelectedImageIndex = 0; + node.Checked = frmSh.rukuLayer.Visible; + layerManagerNode.Nodes.Insert(0, node); + layerManagerNode.Expand(); + } + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "提示"); + } + }); + #endregion + + shlayername = frmSh.rukuLayer.Name; + globeControl1.Refresh(); + } + + if (frmShResult != null && !frmShResult.IsDisposed) + { + try + { + clearFeatureHighLight(); + ClearRedlineAnalyseResult(); + frmShResult.Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message); + } + } + + 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.analysis(); + + //MainFrm窗体显示控制,回到一键审核Tab + this.Invoke((EventHandler)delegate + { + frmShResult.Show(); + frmWait.Close(); + //将tab页恢复到一键审核 + ribbonTabItem11.Checked = true; + try + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + //zhanshi = false; + splitContainer1.Panel2Collapsed = true; + + panelOfTable.Visible = false; + legendSC.Visible = false; + legendSG.Visible = false; + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + } + catch (Exception ex) + { + MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + + }); + + boolfrmShResult = true; + } + else + { + + } + } + + + /// + /// 清除渲染结果 + /// + 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(); + } + /// + /// 已审核的图层 + /// + /// + /// + private void buttonItem132_Click_1(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItem132.Text); + + if (shds == null) + { + //没连的话,直接连接审核库; //审核库配置读配置文件 + string dbIp = Utility.sgdbip; + string database = Utility.sgdbname; + string user = Utility.sgdbuser; + string pass = Utility.sgdbpwd; + + /* + 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; + //} + + } + /// + /// 审核入库 + /// + /// + /// + private void buttonItem133_Click_1(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, "审核入库"); + FrmShRK frmShrk = new FrmShRK(globeControl1); + frmShrk.Show(); + } + /// + /// 模拟设计修改 + /// + /// + /// + private void buttonItem134_Click_1(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, "模拟设计修改"); + + 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 + { + + } + + } + + + /// + /// 绘制垂线 + /// + /// + /// + 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); + } + /// + /// 比较两个点是否是同一个点 + /// + /// + /// + /// + 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; + } + /// + /// 获得点到线的垂线距离及垂点 + /// + /// + /// + /// + /// + 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); + 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]; + } + /// + /// 获得斜率 + /// + /// + /// + /// + /// + /// + /// + 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); + } + } + /// + /// 根据默认投影参数,经纬度转xyz + /// + /// + /// + /// + 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; + } + /// + /// 根据投影参数,经纬度转xyz + /// + /// + /// + /// + /// + 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; + } + /// + /// 根据默认投影参数,xyz转经纬度 + /// + /// + /// + /// + 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; + } + /// + /// 根据投影参数,Xyz转经纬度 + /// + /// + /// + /// + /// + 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; + } + /// + /// 获得inpolygon的管线长度 + /// + /// + 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; + } + + + /// + /// 一键审核中调节透明度 + /// + /// + /// + private void sliderItem1_ValueChanged(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.sliderItem1.Text); + + globeControl1.Globe.GroundOpaque = 100 - sliderItem1.Value; + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(roadLayerName);//("180fd"); + if (layer != null) + { + layer.Opaque = 100 - sliderItem1.Value; + } + + optiValue = sliderItem1.Value; + } + /// + /// 红线审核中的透明度分析 + /// + /// + /// + private void sliderItem3_ValueChanged(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.sliderItem3.Text); + + globeControl1.Globe.GroundOpaque = 100 - sliderItem3.Value; + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(roadLayerName);//("180fd"); + if (layer != null) + { + layer.Opaque = 100 - sliderItem3.Value; + } + optiValue = sliderItem3.Value; + } + + #region yanxiaowei + //初始化DataGridViewX1控件 + public delegate void DataGridViewDelegate(DataTable dt, string strLable, string strLayer, bool initDataGrid); + /// + /// 代理函数,操作DatgridViewX1 + /// + /// + /// + public void InitDataGridViewX1(DataTable dt, string strLable, string strLayer, bool initDataGrid) + { + if (initDataGrid == true) + { + dataGridViewX1.DataSource = dt; + panelOfTable.Visible = true; + toolStripNumbers.Text = strLable; + dataGridViewX1.Tag = strLayer; + } + else + { + dataGridViewX1.DataSource = null; + dataGridViewX1.Refresh(); + panelOfTable.Visible = false; + toolStripNumbers.Text = ""; + dataGridViewX1.Tag = ""; + globeControl1.Globe.MemoryLayer.RemoveAllFeature();//清除双击产生的标注 + } + } + FrmAnalysisGuiHuaResult from; + /// + /// 主窗体下方属性表格 双击定位 功能 + /// + /// + /// + private void dataGridViewX1_MouseDoubleClick(object sender, MouseEventArgs e) + { + if (redSH == false) + { + 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 if (dataGridViewX1.Columns.Contains("标识器编号")) + { + featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["标识器编号"].Value.ToString(); + } + featureName = featureName.Trim(); + + GSOLayer layer = null; + layer = globeControl1.Globe.Layers.GetLayerByCaption(dataGridViewX1.Tag.ToString()); + + if (layer == null) return; + + GSOFeatures features = layer.GetFeatureByName(featureName, false); + if (features.Length == 0) return; + GSOFeature rowFeature = features[0]; + + ClassSearchAnalysis.AddMakerToLineFeature(globeControl1, rowFeature); + + } + } + } + else + { + if (e.Button == MouseButtons.Left) + { + if (from != null && !from.IsDisposed) + { + try + { + from.Close(); + } + catch (Exception ex) + { + LogError.PublishError(ex); + } + } + try + { + DataGridView.HitTestInfo hittestinfo = dataGridViewX1.HitTest(e.X, e.Y); + if (hittestinfo.RowIndex >= 0) + { + string layer = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["管线类型"].Value.ToString(); + string hxName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["红线编号"].Value.ToString(); + FrmAnalysisGuiHuaResult frm = new FrmAnalysisGuiHuaResult(globeControl1, lineStruct, featsList, + panelOfTable, dataGridViewX1, layer, hxName); + frm.Location = new Point(this.Width - frm.Width - 10, this.Height - frm.Height - 20); + frm.Show(this); + + from = frm; + } + } + catch (Exception ex) + { + LogError.PublishError(ex); + } + } + } + } + + /// + /// 空间查询 + /// + /// + /// + private void buttonItemSearch1_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemSearch1.Text); + + trackflag = "PipelineSpatialQuery"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; + + } + /// + /// 关键字查询 + /// + /// + /// + private void buttonItemSearch9_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch9.Text); + + FrmKeywordQuery.ShowForm(globeControl1, m_PipelineLayerNames, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 编号查询 + /// + /// + /// + private void buttonItemSearch2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch2.Text); + + FrmCodingQuery.ShowForm(globeControl1, m_PipelineLayerNames, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 坐标查询 + /// + /// + /// + private void buttonItemSearch3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch3.Text); + + FrmSetLatLonPos.ShowForm(globeControl1); + } + /// + /// 附属物查询 + /// + /// + /// + private void buttonItemSearch10_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch10.Text); + + FrmFittingQuery.ShowForm(globeControl1, instrumenLayerNames, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 管径查询 + /// + /// + /// + private void buttonItemSearch4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch4.Text); + + FrmDiameterQuery.ShowForm(globeControl1, m_PipelineLayerNames, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 材质查询 + /// + /// + /// + private void buttonItemSearch5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch5.Text); + + FrmMaterialSel.ShowForm(globeControl1, m_PipelineLayerNames, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 基本查询 + /// + /// + /// + private void buttonItemSearch6_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch6.Text); + + FrmBasicQuery.ShowForm(globeControl1, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 复合查询 + /// + /// + /// + private void buttonItemSearch7_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch7.Text); + + FrmQuerySQL.ShowForm(globeControl1, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 关联查询 + /// + /// + /// + private void buttonItemSearch8_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch8.Text); + + if (globeControl1.Globe.SelObjectCount != 1) + { + MessageBox.Show("请选中一个对象!", "提示"); + return; + } + + 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 || (feature.Geometry.Type == EnumGeometryType.GeoPolygon3D + || feature.Geometry.Type == EnumGeometryType.GeoWater)) + return; + else + { + ClassSearchAnalysis.ResultRelationAnalysis(globeControl1, feature, valueLayerNames, workwellLayerNames, + instrumenLayerNames, pipefittingLayerNames, m_PipelineLayerNames, valueAllowance); + } + } + } + #endregion + /// + /// 清除分析 + /// + /// + /// + private void buttonItemClear_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemClear.Text); + + globeControl1.Globe.ClearMeasure(); + layerTemp.RemoveAllFeature(); + layerTemp2.RemoveAllFeature(); + buttonItemLS5.Checked = false; + + dataGridViewX1.DataSource = null; + panelOfTable.Visible = false; + + 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); + + NetworkAnalysisTool.ClearAllTopAnalysis(this.globeControl1); + // 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();//清除所有坑 + + 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(); + } + } + + clearFeatureHighLight();//取消管线高亮 + + GSOLayer layerGround = globeControl1.Globe.Layers.GetLayerByCaption(roadLayerName);//("180fd"); + if (layerGround != null) + { + layerGround.Visible = true; + } + globeControl1.Refresh(); + globeControl2.Refresh(); + ClearRedlineAnalyseResult(); + globeControl1.Globe.Action = EnumAction3D.ActionNull; + } + /// + /// 管线长度全区域统计 + /// + /// + /// + private void buttonItemTJ1_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管线长度统计"); + + //pipeLineDis.Clear(); + //List list = new List(); + //for (int i = 0; i < m_PipelineLayerNames.Count; i++) + //{ + // GSOFeatures fs = Intersects_Pipeline(null, m_PipelineLayerNames[i]); + // if (fs!=null) + // list.Add(fs); + //} + + //FrmAllPipelineStatis frm = new FrmAllPipelineStatis(0, pipeLineDis, list, globeControl1, new DataGridViewDelegate(InitDataGridViewX1)); + FrmAllPipelineStatis frm = new FrmAllPipelineStatis(globeControl1,null, new DataGridViewDelegate(InitDataGridViewX1), m_PipelineLayerNames); + frm.Show(this); + + } + /// + /// 管线长度绘制区域统计 + /// + /// + /// + private void buttonItemTJ1_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管线长度统计"); + + trackflag = "PipelineDistanceStatistics"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; + } + /// + /// 阀门数量全区域统计 + /// + /// + /// + private void buttonItemTJ2_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "阀门数量统计"); + + //workWellLen.Clear(); + //List list = new List(); + ////找到所有阀门 + //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, globeControl1, new DataGridViewDelegate(InitDataGridViewX1)); + FrmValveStatistics frm = new FrmValveStatistics(globeControl1, null, new DataGridViewDelegate(InitDataGridViewX1)); + frm.Show(this); + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + } + /// + /// 阀门数量绘制区域统计 + /// + /// + /// + private void buttonItemTJ2_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "阀门数量统计"); + + trackflag = "valvequery"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; + } + /// + /// 井盖数量全区域统计 + /// + /// + /// + private void buttonItemTJ3_ALL_Click(object sender, EventArgs e) + { + FrmAllWorkWellStatis frm = new FrmAllWorkWellStatis(globeControl1, null, new DataGridViewDelegate(InitDataGridViewX1)); + frm.Show(this); + } + /// + /// 井盖数量绘制区域统计 + /// + /// + /// + private void buttonItemTJ3_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "井盖数量统计"); + + trackflag = "workwellquery"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; + } + /// + /// 管径分段统计全区域统计 + /// + /// + /// + private void buttonItemTJ4_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管径分段统计"); + + Frmpipediameterstatis.ShowForm(globeControl1, m_PipelineLayerNames, 0); + } + /// + /// 管径分段统计绘制区域统计 + /// + /// + /// + private void buttonItemTJ4_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管径分段统计"); + + trackflag = null; + Frmpipediameterstatis.ShowForm(globeControl1, m_PipelineLayerNames, 1); + } + /// + /// 埋深分段统计全区域统计 + /// + /// + /// + private void buttonItemTJ5_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "埋深分段统计"); + FrmpipeDeepstatis.ShowForm(globeControl1, m_PipelineLayerNames, 0); + } + /// + /// 埋深分段统计绘制区域统计 + /// + /// + /// + private void buttonItemTJ5_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "埋深分段统计"); + trackflag = null; + FrmpipeDeepstatis.ShowForm(globeControl1, m_PipelineLayerNames, 1); + } + /// + /// 管径分类统计全区域统计 + /// + /// + /// + private void buttonItemTJ6_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管径分类汇总"); + + FrmpipeDiametergather.ShowForm(globeControl1, m_PipelineLayerNames, 0); + } + /// + /// 管径分类统计绘制区域统计 + /// + /// + /// + private void buttonItemTJ6_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管径分类汇总"); + + trackflag = null; + FrmpipeDiametergather.ShowForm(globeControl1, m_PipelineLayerNames, 1); + } + /// + /// 材质分类统计全区域统计 + /// + /// + /// + private void buttonItemTJ7_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "材质分类汇总"); + + FrmpipeMaterialGather.ShowForm(globeControl1, m_PipelineLayerNames, 0); + } + /// + /// 材质分类统计绘制区域统计 + /// + /// + /// + private void buttonItemTJ7_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "材质分类汇总"); + + trackflag = null; + FrmpipeMaterialGather.ShowForm(globeControl1, m_PipelineLayerNames, 1); + } + /// + /// 附属物分类统计全区域统计 + /// + /// + /// + private void buttonItemTJ8_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "附属物分类汇总"); + + FrmAccessoriesgather.ShowForm(globeControl1, instrumenLayerNames, 0); + } + /// + /// 附属物分类统计绘制区域统计 + /// + /// + /// + private void buttonItemTJ8_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "附属物分类汇总"); + + trackflag = null; + FrmAccessoriesgather.ShowForm(globeControl1, instrumenLayerNames, 1); + } + /// + /// 碰撞分析 + /// + /// + /// + private void buttonItemFX1_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_4.Text); + + this.dataGridViewX4.Size = new System.Drawing.Size(195, 120); + 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(); + } + /// + /// 覆土分析 + /// + /// + /// + private void buttonItemFX1_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX5_1.Text); + this.dataGridViewX6.Size = new System.Drawing.Size(195, 120); + 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(); + } + /// + /// 间距分析 + /// + /// + /// + private void buttonItemFX1_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX1_3.Text); + + this.dataGridViewLineList.Size = new System.Drawing.Size(185, 120); + 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(); + } + /// + /// 垂直净距分析 + /// + /// + /// + private void buttonItemFX1_4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX1_4.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(); + } + /// + /// 水平净距分析 + /// + /// + /// + private void buttonItemFX1_5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_6.Text); + this.dataGridViewX8.Size = new System.Drawing.Size(185, 120); + 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(); + } + + #region Predaotr,断面分析 + /// + /// 横断面分析 + /// + /// + /// + private void buttonItemFX2_1_Click(object sender, EventArgs e) + { + globeControl1.Globe.Action = EnumAction3D.TrackPolyline; + globeControl1.Globe.TrackPolylineTool.VerticalLineVisible = true; + globeControl1.Globe.TrackPolylineTool.TrackMode = EnumTrackMode.SpaceTrack; + trackPolylineEndMode = EnumTrackPolylineEndMode.HDM_Analysis; + + } + /// + /// 纵断面分析 + /// + /// + /// + private void buttonItemFX2_2_Click(object sender, EventArgs e) + { + if (globeControl1.Globe.SelObjectCount<1) + { + MessageBox.Show("请选择一条或者多条管线!", "提示", MessageBoxButtons.OK, + MessageBoxIcon.Information); + return; + } + 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); + } + } + List feats = SectionAnalysisTool.ZDMAnalysis(selectFeatures); + if (feats != null && feats.Count >= 1) + { + FrmProfileAnalysis frm = new FrmProfileAnalysis(globeControl1, feats); + frm.Show(this); + } + } + /// + /// 道路断面分析 + /// + /// + /// + private void buttonItemFX2_3_Click(object sender, EventArgs e) + { + globeControl1.Globe.Action = EnumAction3D.TrackPolyline; + globeControl1.Globe.TrackPolylineTool.VerticalLineVisible = true; + globeControl1.Globe.TrackPolylineTool.TrackMode = EnumTrackMode.SpaceTrack; + trackPolylineEndMode = EnumTrackPolylineEndMode.DLDM_Analysis; + + } + /// + /// 基线剖面分析 + /// + /// + /// + private void buttonItemFX2_4_Click(object sender, EventArgs e) + { + globeControl1.Globe.Action = EnumAction3D.TrackPolyline; + globeControl1.Globe.TrackPolylineTool.VerticalLineVisible = true; + globeControl1.Globe.TrackPolylineTool.TrackMode = EnumTrackMode.SpaceTrack; + trackPolylineEndMode = EnumTrackPolylineEndMode.JXPM_Analysis; + + } + + #endregion + /// + /// 创建拓扑 + /// + /// + /// + private void buttonItemFX3_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX3_1.Text); + + FrmGenAndFaMenTopu frm = new FrmGenAndFaMenTopu(globeControl1, m_PipelineLayerNames, valueLayerNames); + frm.Show(this); + } + #region Predator :拓扑分析 + /// + /// 上游分析 + /// + /// + /// + private void buttonItemFX3_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX3_2.Text); + NetworkTraceUpDown(true); + } + /// + /// 下游分析 + /// + /// + /// + private void buttonItemFX3_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX3_3.Text); + NetworkTraceUpDown(false); + } + + /// + /// 上下游追踪 功能 + /// + /// + private void NetworkTraceUpDown(Boolean bTraceUp) + { + GSOFeature selLineFeature = globeControl1.Globe.SelectedObject; + if (selLineFeature == null || selLineFeature.Geometry == null || selLineFeature.Geometry.Type != EnumGeometryType.GeoPolyline3D) + { + MessageBox.Show("请点击“编辑”—“选中对象”选择一条线!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); + return; + } + GSOLayer selLayer = globeControl1.Globe.SelectedObjectLayer; + + NetworkAnalysisTool.TraceUpDownAnalysis(bTraceUp, + selLineFeature, selLayer); + } + + /// + /// 流向分析 + /// + /// + /// + private void buttonItemFX3_4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX3_4.Text); + + FrmFlow frm = new FrmFlow(globeControl1, m_PipelineLayerNames); + frm.Show(this); + } + /// + /// 关阀分析 + /// + /// + /// + private void buttonItemFX3_5_Click(object sender, EventArgs e) + { + if (globeControl1.Globe.SelObjectCount < 1) + { + MessageBox.Show("请选中至少一根管线!!"); + buttonItemFX3_5.Checked = false; + return; + } + GSOLayer resLayer = null; + GSOFeature resFeature = null; + globeControl1.Globe.GetSelectObject(0, out resFeature, out resLayer); + + String pipeLayerName = resLayer.Caption; + String pipeLayerNamePrefix = pipeLayerName.Substring(0, pipeLayerName.IndexOf("管线")); + GSOLayer valveLayer = globeControl1.Globe.Layers[pipeLayerNamePrefix + "阀门"]; + if (valveLayer == null) + { + MessageBox.Show("无" + pipeLayerNamePrefix+"阀门图层", "提示"); + return; + } + + GSOFeatures valveFeats = NetworkAnalysisTool.CloseValvesAnalysis(resFeature, + resLayer, valveLayer); + + if (valveFeats != null) + { + FrmCloseValves frm = new FrmCloseValves(this.globeControl1, valveFeats); + frm.Show(this); + } + else + { + MessageBox.Show("未找到关闭阀门"); + } + } + + /// + /// 连通分析 + /// + /// + /// + private void buttonItemFX3_6_Click(object sender, EventArgs e) + { + if (globeControl1.Globe.SelObjectCount < 2) + { + MessageBox.Show("请选中至少两个管线!!"); + buttonItemFX3_6.Checked = false; + return; + } + GSOFeature selFeat0, selFeat1; + GSOLayer layer0,layer1; + globeControl1.Globe.GetSelectObject(0, out selFeat0, out layer0); + globeControl1.Globe.GetSelectObject(1, out selFeat1, out layer1); + + if (!layer0.IsSameInnerObject(layer1)) + { + MessageBox.Show("不在同一个图层!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); + buttonItemFX3_6.Checked = false; + return; + } + NetworkAnalysisTool.ConnexityAnalysis(selFeat0, selFeat1, layer0); + } + /// + /// 爆管分析 + /// + /// + /// + private void buttonItemFX3_7_Click(object sender, EventArgs e) + { + NetworkTraceUpDown(true); //上游追踪: + + GSOFeature selLineFeature = globeControl1.Globe.SelectedObject; + if (selLineFeature == null || selLineFeature.Geometry == null || selLineFeature.Geometry.Type != EnumGeometryType.GeoPolyline3D) + { + MessageBox.Show("请点击“编辑”—“选中对象”选择一条线!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); + return; + } + GSOLayer selLayer = globeControl1.Globe.SelectedObjectLayer; + + NetworkAnalysisTool.ExplodeAnalysis(this.globeControl1,selLineFeature,selLayer); + + this.buttonItemFX3_5_Click(sender, e); //关阀分析: + + } + + #endregion + /// + /// 多边形开挖 + /// + /// + /// + private void buttonItemFX4_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_1.Text); + + trackflag = "pit"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; //是这个么?是的,在模型上 + } + /// + /// 挖方量分析 + /// + /// + /// + private void buttonItemFX4_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_2.Text); + + trackflag = "digFillAnalysis"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; + ActionToolMenuChecked(); + } + /// + /// 沿线开挖 + /// + /// + /// + private void buttonItemFX4_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_3.Text); + + if (!buttonItemFX4_3.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; + buttonItemFX4_3.Checked = true; + } + } + else + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + buttonItemFX4_3.Checked = false; + globeControl1.Globe.TrackPolylineTool.VerticalLineVisible = false; + } + ActionToolMenuChecked(); + } + /// + /// 创建隧道 + /// + /// + /// + private void buttonItemFX4_4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_4.Text); + + 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("场景中未加载隧道图层!", "提示"); + } + } + /// + /// 隐藏隧道 + /// + /// + /// + private void buttonItemFX4_5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_5.Text); + + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption("隧道"); + if (layer != null) + { + layer.Visible = !layer.Visible; + } + } + /// + /// 删除隧道 + /// + /// + /// + private void buttonItemFX4_6_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_6.Text); + + 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("请选中要删除的隧道!", "提示"); + } + } + /// + /// 通视分析 + /// + /// + /// + private void buttonItemFX5_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX5_1.Text); + + if (globeControl1.Globe.Action != EnumAction3D.VisibilityAnalysis) + { + //btnSpaceVisibilityAnalysis.Checked = true; + globeControl1.Globe.Action = EnumAction3D.VisibilityAnalysis; + } + else + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + // SetButtonChecked(); + } + } + /// + /// 可视域分析 + /// + /// + /// + private void buttonItemFX5_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX5_2.Text); + + globeControl1.Globe.Action = EnumAction3D.ViewshedAnalysis; + } + /// + /// 可视包络分析 + /// + /// + /// + private void buttonItemFX5_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX5_3.Text); + + globeControl1.Globe.Action = EnumAction3D.ViewEnvelopeAnalysis; + } + /// + /// 缓冲区分析 + /// + /// + /// + private void buttonItemFX6_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX6_1.Text); + + GSOFeature feat = globeControl1.Globe.SelectedObject; + if (feat == null) + { + MessageBox.Show("请选择要分析的要素!"); + return; + } + if (feat.Geometry.Type == EnumGeometryType.GeoPolyline3D) + { + GSOGeoPolyline3D line1 = feat.Geometry as GSOGeoPolyline3D; + if (line1 == null) + { + MessageBox.Show("请选择一条管线!"); + return; + } + + FrmBufferAnalysis frm = new FrmBufferAnalysis(globeControl1, line1, layerTemp); + frm.Show(this); + } + else + { + FrmBufferAnalysisBSQ frm = new FrmBufferAnalysisBSQ(globeControl1, layerTemp, bsqPT); + frm.Show(this); + } + + } + /// + /// 附属物分析 + /// + /// + /// + private void buttonItemFX6_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX6_2.Text); + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + FrmAccessoryAnalysis dlg = new FrmAccessoryAnalysis(globeControl1, layerTemp); + dlg.Show(this); + } + /// + /// 无源淹没分析 + /// + /// + /// + private void buttonItemFX6_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX6_3.Text); + + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + trackflag = "FloodAnalysis"; + } + /// + /// 水平距离 + /// + /// + /// + private void buttonItemLS1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS1.Text); + + globeControl1.Globe.Action = EnumAction3D.MeasureDistance; + globeControl1.Globe.DistanceRuler.SpaceMeasure = false; + buttonItemLS5.Checked = false; + } + /// + /// 垂直距离 + /// + /// + /// + private void buttonItemLS2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS2.Text); + + buttonItemLS5.Checked = false; + globeControl1.Globe.Action = EnumAction3D.MeasureHeight; + globeControl1.Globe.DistanceRuler.SpaceMeasure = false; + } + /// + /// 空间距离 + /// + /// + /// + private void buttonItemLS3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS3.Text); + + buttonItemLS5.Checked = false; + globeControl1.Globe.Action = EnumAction3D.MeasureDistance; + globeControl1.Globe.DistanceRuler.SpaceMeasure = true; + } + /// + /// 地表距离 + /// + /// + /// + private void buttonItemLS4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS4.Text); + + buttonItemLS5.Checked = false; + globeControl1.Globe.Action = EnumAction3D.MeasureDistance; + globeControl1.Globe.DistanceRuler.SpaceMeasure = false; + } + /// + /// 高度量算 + /// + /// + /// + private void buttonItemLS5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS5.Text); + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + buttonItemLS5.Checked = !buttonItemLS5.Checked; + if (buttonItemLS5.Checked) + { + globeControl1.Globe.Action = EnumAction3D.SelectObject; + } + } + /// + /// 水平面积 + /// + /// + /// + private void buttonItemLS6_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS6.Text); + + buttonItemLS5.Checked = false; + globeControl1.Globe.Action = EnumAction3D.MeasureArea; + globeControl1.Globe.AreaRuler.SpaceMeasure = true; + } + /// + /// 地表面积 + /// + /// + /// + private void buttonItemLS7_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS7.Text); + + buttonItemLS5.Checked = false; + globeControl1.Globe.Action = EnumAction3D.MeasureArea; + globeControl1.Globe.AreaRuler.SpaceMeasure = false; + + } + + # region Fan 重构标注代码 + /// + /// 标高标注 + /// + /// + /// + private void buttonItemSZ1_Click(object sender, EventArgs e) + { + GSOFeature resFeature = IsPipeLineOfSelectedObj(); + if (resFeature == null) + { + MessageBox.Show("请选中一根管线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + GSOGeoPolyline3D selLine = resFeature.Geometry as GSOGeoPolyline3D; + if (selLine[0].Count <= 1) + { + return; + } + + MarkTools.getInstance().showMarker(resFeature, + globeControl1, EnumMarkLayer.Mark_Altitude, ""); + } + /// + /// 管径标注 + /// + GSOFeature radiusMarkerFeature; + private void buttonItemBZ2_Click(object sender, EventArgs e) + { + GSOFeature resFeature = IsPipeLineOfSelectedObj(); + if (resFeature == null) + { + MessageBox.Show("请选中一根管线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + GSOGeoPolyline3D selLine = resFeature.Geometry as GSOGeoPolyline3D; + if (selLine[0].Count <= 1) + { + return; + } + + MarkTools.getInstance().showMarker(resFeature, + globeControl1, EnumMarkLayer.Mark_Diameter, ""); + } + /// + /// 埋深标注 + /// + /// + /// + private void buttonItemBZ3_Click(object sender, EventArgs e) + { + GSOFeature resFeature = IsPipeLineOfSelectedObj(); + if (resFeature == null) + { + MessageBox.Show("请选中一根管线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + GSOGeoPolyline3D selLine = resFeature.Geometry as GSOGeoPolyline3D; + if (selLine[0].Count <=1) + { + return; + } + + MarkTools.getInstance().showMarker(resFeature, + globeControl1, EnumMarkLayer.Mark_Depth, ""); + + } + /// + /// 坐标标注 + /// + /// + /// + private void buttonItemBZ4_Click(object sender, EventArgs e) + { + GSOFeature resFeature = IsPipeLineOfSelectedObj(); + if (resFeature == null) + { + MessageBox.Show("请选中一根管线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + GSOGeoPolyline3D selLine = resFeature.Geometry as GSOGeoPolyline3D; + if (selLine[0].Count <= 1) + { + return; + } + MarkTools.getInstance().showMarker(resFeature, + globeControl1, EnumMarkLayer.Mark_Location, ""); + } + /// + /// 距离标注 + /// + bool distanceMarker = false; + private void buttonItemBZ5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBZ5.Text); + + globeControl1.Globe.Action = EnumAction3D.TrackPolyline; + //globeControl1.Globe.DistanceRuler.MeasureMode = EnumDistanceMeasureMode.HVSLineMeasure; + distanceMarker = true; + } + /// + /// 自定义标注 + /// + /// + /// + private void buttonItemBZ6_Click(object sender, EventArgs e) + { + GSOFeature f = globeControl1.Globe.SelectedObject; + GSOLayer l = globeControl1.Globe.SelectedObjectLayer; + FrmCustomLabel frm = new FrmCustomLabel(globeControl1, l, f); + if (frm.ShowDialog() == DialogResult.OK) + { + MarkTools.getInstance().showMarker(f, globeControl1, EnumMarkLayer.Mark_Custom, frm.labelText); + } + } + /// + /// 扯旗标注 + /// + /// + /// + private void buttonItemBZ7_Click(object sender, EventArgs e) + { + GSOFeature f = globeControl1.Globe.SelectedObject; + GSOLayer l = globeControl1.Globe.SelectedObjectLayer; + FrmMarker frm = new FrmMarker(); + if (frm.ShowDialog() == DialogResult.OK) + { + MarkTools.getInstance().showMarker(f, globeControl1, EnumMarkLayer.Mark_Custom, frm.markerContent); + } + } + /// + /// 坡度标注 + /// + /// + /// + private void buttonItemBZ8_Click(object sender, EventArgs e) + { + GSOFeature resFeature = IsPipeLineOfSelectedObj(); + if (resFeature == null) + { + MessageBox.Show("请选中一根管线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + GSOGeoPolyline3D selLine = resFeature.Geometry as GSOGeoPolyline3D; + if (selLine[0].Count <= 1) + { + return; + } + + MarkTools.getInstance().showMarker(resFeature, + globeControl1, EnumMarkLayer.Mark_Slope, ""); + } + /// + /// 属性标注 + /// + /// + /// + private void buttonItemBZ9_Click(object sender, EventArgs e) + { + GSOFeature f = globeControl1.Globe.SelectedObject; + GSOLayer l = globeControl1.Globe.SelectedObjectLayer; + FrmPropertiesMarker frm = new FrmPropertiesMarker(globeControl1, l, f); + if (frm.ShowDialog() == DialogResult.OK) + { + MarkTools.getInstance().showMarker(f, globeControl1, EnumMarkLayer.Mark_Property, frm.labelText); + } + } + /// + /// 红线工具 + /// + /// + /// + private void buttonItemBZ10_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBZ10.Text); + 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; + } + } + /// + /// 标注管理 + /// + /// + /// + private void buttonItemBZ11_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBZ11.Text); + + buttonItemBZ11.Checked = !buttonItemBZ11.Checked; + 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 (buttonItemBZ11.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(); + } + } + + #endregion + /// + /// 飞行到目标点 + /// + /// + /// + private void buttonItemFXGJ1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFXGJ1.Text); + + FrmSetFlytoPos.ShowForm(globeControl1); + + } + /// + /// 自定义飞行 + /// + /// + /// + private void buttonItemFXGJ2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFXGJ2.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); + } + } + /// + /// 绕中心点飞行 + /// + /// + /// + private void buttonItemFXGJ3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFXGJ3.Text); + + globeControl1.Globe.FlyAroundCenter(10000, EnumFlyRepeatValueType.MiliSeconds); + globeControl1.Globe.CurFlyID = 1; + } + /// + /// 绕眼睛飞行 + /// + /// + /// + private void buttonItemFXGJ4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFXGJ4.Text); + + globeControl1.Globe.FlyAroundEye(720, EnumFlyRepeatValueType.Degrees); + globeControl1.Globe.CurFlyID = 2; + } + + /// + /// 权限管理 + /// + /// + /// + private void buttonItemXT1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT1.Text); + + FrmUserRoleMgr frm = new FrmUserRoleMgr(); + frm.ShowDialog(); + } + /// + /// 数据库管理 + /// + /// + /// + private void buttonItemXT2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT2.Text); + + //查看数据库列表 + FrmDbManager frm = new FrmDbManager(); + frm.ShowDialog(); + } + /// + /// 用户列表 + /// + /// + /// + private void buttonItemXT3_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT3_1.Text); + + FrmUserManager frm = new FrmUserManager(); + frm.ShowDialog(); + } + /// + /// 创建新用户 + /// + /// + /// + private void buttonItemXT3_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT3_2.Text); + + FrmUserAdd frm = new FrmUserAdd(-1); + frm.ShowDialog(); + } + /// + /// 人员修改 + /// + /// + /// + private void buttonItemXT4_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT4_2.Text); + + FrmAppUSER appUSER = new FrmAppUSER(); + appUSER.ShowDialog(); + } + /// + /// 增加人员 + /// + /// + /// + private void buttonItemXT4_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT4_1.Text); + + FrmAppUSERRESET appUSERRESET = new FrmAppUSERRESET(); + appUSERRESET.ShowDialog(); + } + /// + /// 统计数据 + /// + /// + /// + private void buttonItemZTT1_Click(object sender, EventArgs e) + { + ////日志记录 + //LogManager.saveLog(Utility.userName, this.buttonItemZTT1.Text); + + //PATM patm = new PATM(); + //patm.operation = "Statistic"; + //patm.Text = "统计专题图管理"; + //patm.ShowDialog(); + } + /// + /// 热点功能统计 + /// + /// + /// + private void buttonItemZTT2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT2.Text); + + FrmHotFuncStat frmhfs = new FrmHotFuncStat(); + frmhfs.ShowDialog(); + } + + private void buttonItemZTT3_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT3_1.Text); + + FrmAPP appfrm = new FrmAPP("专题图申请"); + appfrm.ShowDialog(); + } + + private void buttonItemZTT3_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT3_2.Text); + + FrmAPPFORASK appForask = new FrmAPPFORASK("专题图审核"); + appForask.ShowDialog(); + } + + private void buttonItemZTT3_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT3_3.Text); + + FrmAPPregion appregion = new FrmAPPregion("专题图审核"); + appregion.ShowDialog(); + } + + private void buttonItemZTT4_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT4_1.Text); + + FrmAPP appfrm = new FrmAPP("打印申请"); + appfrm.ShowDialog(); + } + + private void buttonItemZTT4_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT4_2.Text); + + FrmAPPFORASK appForask = new FrmAPPFORASK("打印审核"); + appForask.ShowDialog(); + } + + private void buttonItemZTT4_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT4_3.Text); + + FrmAPPregion appregion = new FrmAPPregion("打印审核"); + appregion.ShowDialog(); + } + + private void buttonItemZTT5_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT5_1.Text); + + FrmAPP appfrm = new FrmAPP("拷贝申请"); + appfrm.ShowDialog(); + } + + private void buttonItemZTT5_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT5_2.Text); + + FrmAPPFORASK appForask = new FrmAPPFORASK("拷贝审核"); + appForask.ShowDialog(); + } + + private void buttonItemZTT5_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT5_3.Text); + + FrmAPPregion appregion = new FrmAPPregion("拷贝审核"); + appregion.Show(); + } + + private int connectServerCount = 0; + + /// + /// 还原球到实测库 + /// + 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); + } + + if (layerManagerNode.Nodes.Count > 0) + { + for (int i = layerManagerNode.Nodes.Count - 1; i >= 0; i--) + { + layerManagerNode.Nodes[i].Remove(); + + } + } + + globeControl1.Refresh(); + + } + + private void buttonItemSPSZ_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSPSZ.Text); + + FrmLayerControl frm = new FrmLayerControl(layerTree, globeControl1, globeControl2); + frm.Show(this); + } + + /// + /// 碰撞审查 + /// + /// + /// + private void buttonItemSH1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSH1.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 buttonItemSH2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSH2.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 buttonItemSH3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSH3.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 buttonItemSH4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSH4.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 buttonItemSH5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSH5.Text); + FrmCityServerLineAnalysis frm = new FrmCityServerLineAnalysis(globeControl1, m_PipelineLayerNames); + frm.Show(this); + } + #region 数据管理-导入文件 + ///// + ///// 数据管理-导入本地坐标系文件 + ///// + ///// + ///// + //private void buttonItemSJGL1_1_Click(object sender, EventArgs e) + //{ + // //日志记录 + // LogManager.saveLog(Utility.userName, this.buttonItemSJGL1_1.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(); + // } + // } + //} + + ///// + ///// 数据管理-导入其他坐标系文件 + ///// + ///// + ///// + //private void buttonItemSJGL1_2_Click(object sender, EventArgs e) + //{ + // //日志记录 + // LogManager.saveLog(Utility.userName, this.buttonItemSJGL1_2.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(); + // } + // } + //} + #endregion + /// + /// 数据质量检查 + /// + /// + /// + private void buttonItemSJGL2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL2.Text); + FrmValiData frm = new FrmValiData(globeControl1); + frm.ShowDialog(); + } + /// + /// 数据预处理 + /// + /// + /// + private void buttonItemSJGL3_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL3.Text); + + FrmEditShapeFile frm = new FrmEditShapeFile(globeControl1); + frm.ShowDialog(this); + } + /// + /// 连接数据库 + /// + /// + /// + private void buttonItemSJGL4_1_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL4_1.Text); + + FrmDatabaseParaSetting frm = new FrmDatabaseParaSetting(globeControl1); + if (frm.ShowDialog() == DialogResult.OK) + { + ds = FrmDatabaseParaSetting.ds; + if (ds != null) + { + ds.IsCloseSaved = false; + } + } + } + /// + /// 管线入库 + /// + /// + /// + private void buttonItemSJGL4_2_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL4_2.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 buttonItemSJGL4_3_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL4_3.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 buttonItemSJGL5_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL5.Text); + + Cyberpipe.Forms.FrmProject frm = new Cyberpipe.Forms.FrmProject(); + frm.ShowDialog(); + } + /// + /// 元数据基本管理 + /// + /// + /// + private void buttonItemSJGL6_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL6_1.Text); + + FrmMetadata frmmd = new FrmMetadata(); + frmmd.ShowDialog(); + } + /// + /// 元数据查询管理 + /// + /// + /// + private void buttonItemSJGL6_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL6_2.Text); + + FrmMetadataStat frmmds = new FrmMetadataStat(); + //frmmds.Show(); + frmmds.ShowDialog(); + } + /// + /// 操作日志管理 + /// + /// + /// + private void buttonItemSJGL7_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL7.Text); + + FrmLogOper frmlo = new FrmLogOper(); + frmlo.ShowDialog(); + } + /// + /// 数据字典管理 + /// + /// + /// + private void buttonItemSJGL8_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL8.Text); + + FrmMDDictory frmmdd = new FrmMDDictory(); + frmmdd.ShowDialog(); + } + /// + /// 数据库备份 + /// + /// + /// + private void buttonItemSJGL9_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL9.Text); + + //新 + FrmBACKORACLE backOracle = new FrmBACKORACLE(); + backOracle.Show(); + } + /// + /// 创建管段 + /// + /// + /// + private void buttonItemBJ1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ1.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; + } + } + /// + /// 创建附属物 + /// + /// + /// + private void buttonItemBJ2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ2.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); + } + } + /// + /// 创建特征管点 + /// + /// + /// + private void buttonItemBJ3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ3.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); + } + } + /// + /// 绘制城市七线 + /// + /// + /// + private void buttonItemBJ4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ4.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; + } + } + } + /// + /// 选中对象 + /// + /// + /// + private void buttonItemBJ5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ5.Text); + + globeControl1.Globe.Action = EnumAction3D.SelectObject; + } + /// + /// 平移对象 + /// + /// + /// + private void buttonItemBJ6_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ6.Text); + + globeControl1.Globe.Action = EnumAction3D.MoveObject; + } + /// + /// 升降对象 + /// + /// + /// + private void buttonItemBJ7_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ7.Text); + + globeControl1.Globe.Action = EnumAction3D.ElevateObject; + } + /// + /// 旋转对象 + /// + /// + /// + private void buttonItemBJ8_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ8.Text); + + globeControl1.Globe.Action = EnumAction3D.RotateObject; + } + /// + /// 连接管段 + /// + /// + /// + private void buttonItemBJ9_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ9.Text); + + if (globeControl1.Globe.SelObjectCount < 2) + { + MessageBox.Show("对不起,请至少选中2个对象!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + return; + } + globeControl1.Globe.InsertJointPipeline(false); + } + /// + /// 后退 + /// + /// + /// + private void buttonItemBJ11_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemBJ11.Text); + globeControl1.Globe.UnDoEdit(); + } + /// + /// 前进 + /// + /// + /// + private void buttonItemBJ12_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemBJ12.Text); + + globeControl1.Globe.ReDoEdit(); + } + /// + /// 导出CAD + /// + /// + /// + private void buttonItemBJ10_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ10_1.Text); + + #region 导出成dxf格式 + List listVectorNames = new List(); + 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(); + #endregion + } + /// + /// 导出矢量 + /// + /// + /// + private void buttonItemBJ10_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ10_2.Text); + + List listVectorNames = new List(); + 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 buttonItemBJ13_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemBJ13.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(); + } + } + MessageBox.Show("删除成功!", "提示"); + } + else + { + MessageBox.Show("请选中要删除的模型!", "提示"); + } + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + } + + private void buttonItemHX1_1_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]; + string filePath = dlg.FileName; + string lastname = Path.GetFileName(filePath); + + 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(); + } + + } + } + } + + public struct LineStruct + { + public string layerName; + public string layerCode; + public string lineLength; + public string hxName; + } + + List lineStruct = new List(); + List featsList = new List(); + + /// + /// 红线审核 + /// + /// + /// + private void buttonItemHX2_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemHX2.Text); + redSH = true; + featsList.Clear(); + lineStruct.Clear(); + List listPipelineLayers = new List(); + + GSOLayer layer = null; + for (int i = 0; i < m_PipelineLayerNames.Count; i++) + { + layer = globeControl1.Globe.Layers.GetLayerByCaption(m_PipelineLayerNames[i]); + if (layer != null) + { + listPipelineLayers.Add(layer); + } + } + //yanxiaowei 重构 + GSOFeatures selectFeatures=new GSOFeatures(); + for (int i = 0; i < globeControl1.Globe.SelObjectCount; i++) + { + GSOFeature feature = null; + globeControl1.Globe.GetSelectObject(i, out feature, out layer); + selectFeatures.Add(feature); + } + DataTable table=new DataTable(); + + ClassGSOTool.CalculateRedLineResult(out table, redSH, selectFeatures, globeControl1, + listPipelineLayers,out lineStruct, out featsList); + + if (table.Rows.Count != 0) + AddDatagridView(table); + else + { + MessageBox.Show("没有侵入地块红线的管线数据!", "提示"); + dataGridViewX1.DataSource = null; + panelOfTable.Visible = false; + return; + } + } + + private void AddDatagridView(DataTable table) + { + dataGridViewX1.DataSource = table; + panelOfTable.Visible = true; + panelOfTable.Height = 200; + toolStripNumbers.Text = "红线审核 |共有:" + table.Rows.Count + "条"; + toolStripDropDownButton3.Visible = true; + } + /// + /// 主窗体 下方的工具条中的 导出.xls文件 按钮事件处理 + /// + /// + /// + private void toolStripDropDownButton3_Click(object sender, EventArgs e) + { + if (dataGridViewX1.Rows.Count == 0) + { + MessageBox.Show("表格内容为空!", "提示"); + return; + } + + string strSaveFile = string.Empty; + SaveFileDialog savefiledialog = new SaveFileDialog(); + savefiledialog.Filter = "Excel文件|*.xls,*.xlsx"; + savefiledialog.AddExtension = true; + savefiledialog.FileName = "红线审核"; + if (savefiledialog.ShowDialog() == DialogResult.OK) + strSaveFile = savefiledialog.FileName; + else return; + + ExpEXCEL.ExpToExcel(dataGridViewX1, strSaveFile, "红线审核", lineStruct, featsList); + MessageBox.Show("导出成功!"); + } + /// + /// 去除集合中重复的管线 + /// + /// + /// + /// + private GSOFeatures getFeaturesByFilter(GSOFeatures features, string fieldName) + { + if (features == null) + { + return null; + } + GSOFeatures featuresGet = new GSOFeatures(); + for (int i = 0; i < features.Length; i++) + { + GSOFeature featureFromFS = features[i]; + string fieldValueFromFS = featureFromFS.GetValue(fieldName).ToString().Trim(); + bool isHas = false; + for (int j = featuresGet.Length - 1; j >= 0; j--) + { + GSOFeature featureFromFSGet = featuresGet[j]; + string fieldValueFromFSGet = featureFromFSGet.GetValue(fieldName).ToString().Trim(); + if (fieldValueFromFS.Equals(fieldValueFromFSGet)) + { + isHas = true; + break; + } + } + if (isHas == false) + { + featuresGet.Add(featureFromFS.Clone()); + } + } + return featuresGet; + } + + private void sliderItem2_ValueChanged(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.sliderItem2.Text); + + globeControl1.Globe.GroundOpaque = 100 - sliderItem2.Value; + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(roadLayerName);//("180fd"); + if (layer != null) + { + layer.Opaque = 100 - sliderItem2.Value; + } + layer = globeControl2.Globe.Layers.GetLayerByCaption("180fd");//("180fd"); + if (layer != null) + { + layer.Opaque = 100 - sliderItem2.Value; + } + globeControl2.Globe.GroundOpaque = 100 - sliderItem2.Value; + + optiValue = sliderItem2.Value; + } + /// + /// 数据管理导入文件 + /// + /// + /// + private void buttonItemSJGL1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL1.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.Multiselect = true; + if (dlg.ShowDialog() == DialogResult.OK) + { + //自定义lprj文件名,从程序中复制一lprj文件。 + string filePath = dlg.FileName; + string lastname = Path.GetFileName(filePath); + + 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, 100); + + globeControl1.Refresh(); + } + } + } + + private void buttonItemHX1_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemHX1.Text); + + GSODataSource dataSpace = globeControl1.Globe.DataManager.OpenOracleDataSource(Utility.DBServer.Trim() + "/" + Utility.dbdatabase.Trim(), "", "", Utility.userID, Utility.DBPassword); + string filepath = ""; + //日志记录 + OpenFileDialog dlg = new OpenFileDialog(); + dlg.Filter = "矢量数据(*.shp)|*.shp|矢量数据(*.lgd)|*.lgd|CAD数据(*.dxf)|*.dxf|全部支持格式(*.lgd,*.shp,*.dxf)|*.lgd;*.shp;*.dxf;"; + dlg.Multiselect = true; + + #region 临时图层显示 + if (dlg.ShowDialog() == DialogResult.OK) + { + string filePath = dlg.FileName; + string lastname = Path.GetFileName(filePath); + + #region + for (int i = 0; i < dlg.FileNames.Length; i++) + { + string strDataPath = dlg.FileNames[i]; + filepath = strDataPath; + + GSOLayer layer = globeControl1.Globe.Layers.Add(strDataPath); + GSOFeatures RedFeatures = layer.GetAllFeatures(); + + 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(); + RedFeatures = features; + 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; + } + + /////////////////////////////////////////////////////////////////////////////////////////// + globeControl1.Globe.Layers.MoveTo(0, globeControl1.Globe.Layers.Count - 1); + globeControl1.Refresh(); + } + + IModelBuilder modelBuilder = new RedLineBuilder(); + + modelBuilder.batchInsert(dataSpace, redDt, RedFeatures); + + } + #endregion + + } + #endregion + } + /// + /// 定位 + /// + /// + /// + private void buttonItemLocation_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemLocation.Text); + + FrmFlyToPosition fly = new FrmFlyToPosition(globeControl1,globeControl2); + fly.Show(this); + } + /// + /// 2015-10-17演示代码 红线审核 + /// + /// + /// + private void ribbonTabItem6_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.FlyToPosition(new GSOPoint3d(120.610963, 31.188121, 50), EnumAltitudeMode.Absolute, -4, 50, 800); + globeControl1.Globe.FlyToPointSpeed = 10000000; + globeControl1.Globe.Action = EnumAction3D.SelectObject; + globeControl1.Refresh(); + + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + + //zhanshi = false; + redSH = true; + splitContainer1.Panel2Collapsed = true; + legendSG.Visible = false; + legendSC.Visible = false; + ClearGZData(); + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = true; + } + + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 基础工具 + /// + /// + /// + private void ribbonTabItem1_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + //zhanshi = false; + redSH = false; + splitContainer1.Panel2Collapsed = true; + panelOfTable.Visible = false; + legendSC.Visible = false; + legendSG.Visible = false; + ClearGZData(); + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + + + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 一键审核 + /// + /// + /// + private void ribbonTabItem11_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + //zhanshi = false; + redSH = false; + splitContainer1.Panel2Collapsed = true; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + panelOfTable.Visible = false; + legendSC.Visible = false; + legendSG.Visible = false; + ClearGZData(); + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + + + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 右屏添加冰箱数据 + /// + void AddDataToGlobeControl2() + { + + bool modelDataBool = false; + for (int i = globeControl2.Globe.Layers.Count - 1; i >= 0; i--) + { + GSOLayer layer = globeControl2.Globe.Layers[i]; + if (layer.Name.Contains("fttp:")) + { + modelDataBool = true; + break; + } + } + + if (modelDataBool == false) + { + GSOLayer ly = globeControl1.Globe.Layers.GetLayerByCaption("天地图地图"); + globeControl2.Globe.Layers.Add(ly); + } + else + { + return; + } + } + /// + /// 双屏对比 + /// + /// + /// + private void ribbonTabItem9_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent += new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent += new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + panelOfTable.Visible = false; + + splitContainer1.Panel2Collapsed = false; + //zhanshi = true; + redSH = false; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + sliderItem2.Value = 100 - globeControl1.Globe.GroundOpaque; + globeControl2.Globe.GroundOpaque = globeControl1.Globe.GroundOpaque; + legendSC.Visible = true; + legendSG.Visible = true; + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + AddDataToGlobeControl2(); + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 文档管理 + /// + /// + /// + private void ribbonTabItem4_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + panelOfTable.Visible = false; + //zhanshi = false; + redSH = false; + splitContainer1.Panel2Collapsed = true; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + legendSC.Visible = false; + legendSG.Visible = false; + ClearGZData(); + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 基础管理 + /// + /// + /// + private void ribbonTabItem14_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + panelOfTable.Visible = false; + //zhanshi = false; + redSH = false; + splitContainer1.Panel2Collapsed = true; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + legendSC.Visible = false; + legendSG.Visible = false; + ClearGZData(); + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 权限管理 + /// + /// + /// + private void ribbonTabItem2_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + panelOfTable.Visible = false; + //zhanshi = false; + redSH = false; + splitContainer1.Panel2Collapsed = true; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + legendSC.Visible = false; + legendSG.Visible = false; + ClearGZData(); + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + GSOFeature dpFeatuer = null; + /// + /// 双屏分析,点击管段分析 + /// + /// + /// + private void buttonItem8_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItem8.Text); + + //FrmCompareFeature frmCompareFeature = new FrmCompareFeature(globeControl1, globeControl2, layerTemp, layerTemp2,m_PipelineLayerNames,sgPipeLayersNames); + int width = this.Width; + FrmCompareFeature.ShowForm(globeControl1, globeControl2, layerTemp, layerTemp2, m_PipelineLayerNames, sgPipeLayersNames,width); + //frmCompareFeature.Location = new Point((this.Width - frmCompareFeature.Width)/2,50); + //frmCompareFeature.Show(this); + + } + /// + /// 红线审核导出图片 + /// + /// + /// + private void buttonItemDCTP_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemDCTP.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))); + */ + int mapWidth = 0; + int mapHeight = 0; + Point pt = getUpperLeftPoint(pt1, pt2, out mapWidth, out mapHeight); + int rightBottomX = pt.X + mapWidth; + int rightBottomY = pt.Y + mapHeight; + Image myImg = new Bitmap(mapWidth, mapHeight); + Graphics g = Graphics.FromImage(myImg); + g.CopyFromScreen(pt, new Point(0, 0), new Size(rightBottomX, rightBottomY)); + + 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; + } + } + } + /// + /// 标识器全区域统计 + /// + /// + /// + private void 标识器分类统计ToolStripMenuItem_Click(object sender, EventArgs e) + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + FrmBSQStatis bsqStatis = new FrmBSQStatis(globeControl1,null); + //FrmBSQStatis bsqStatis = new FrmBSQStatis(); + bsqStatis.Show(this); + } + /// + /// 标识器绘制区域统计 + /// + /// + /// + private void 标识器分类统计ToolStripMenuItem1_Click(object sender, EventArgs e) + { + trackflag = "BSQDuoBianXiangStatis"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + } + + #region 保存和加载审核库加载的图层 + /* + private void saveLayerList(TreeNodeCollection treeNodeList) + { + string configPath = Application.StartupPath + "\\configLayerList.xml"; + try + { + XmlDocument doc = new XmlDocument(); + doc.Load(configPath); + XmlNode dbParams = doc.SelectSingleNode("Params/dbparams"); + XmlNode dbLayers = doc.SelectSingleNode("Params/dblayers"); + XmlNode layers = doc.SelectSingleNode("Params/layers"); + dbParams.RemoveAll(); + dbLayers.RemoveAll(); + layers.RemoveAll(); + + List listDS = new List(); + String shDatasourceName = Utility.sgdbip + "/" + Utility.sgdbname + "_" + Utility.sgdbuser; + bool flag = false; + + for (int i = 0; i < globeControl1.Globe.DataManager.DataSourceCount; i++) + { + GSODataSource ds = globeControl1.Globe.DataManager.GetDataSourceAt(i); + if (ds != null && ds.Type == EnumDataSourceType.SqlServer || ds.Type == EnumDataSourceType.Oracle) + { + if (ds.Name == shDatasourceName) + { + //防止因为多次连接同一个数据库 + if (flag == true) + { + break; + } + flag = true; + listDS.Add(ds); + GSODataSourceCnn conn = ds.GetConnectionInfo(); + + XmlElement dbparam = doc.CreateElement("shdbparam"); + XmlElement ip = doc.CreateElement("ship"); + ip.InnerText = conn.Server; + + XmlElement dbname = doc.CreateElement("shdbname"); + dbname.InnerText = conn.Database; + + XmlElement username = doc.CreateElement("shusername"); + username.InnerText = conn.User; + + XmlElement password = doc.CreateElement("shpassword"); + password.InnerText = conn.Password; + + XmlElement type = doc.CreateElement("shtype"); + if (ds.Type == EnumDataSourceType.SqlServer) + { + type.InnerText = "sqlserver"; + } + else + { + type.InnerText = "oracle"; + } + + dbparam.AppendChild(ip); + dbparam.AppendChild(dbname); + dbparam.AppendChild(username); + dbparam.AppendChild(password); + dbparam.AppendChild(type); + dbParams.AppendChild(dbparam); + } + + } + } + + for (int i = 0; i < treeNodeList.Count; i++) + { + GSOLayer layer = treeNodeList[i].Tag as GSOLayer; + if (Path.GetExtension(layer.Name) == "") + { + XmlElement dbLayer = doc.CreateElement("dblayer"); + XmlAttribute attri = doc.CreateAttribute("dbindex"); + for (int j = 0; j < listDS.Count; j++) + { + if (layer.Dataset.DataSource.Name == listDS[j].Name) + { + attri.Value = j.ToString(); + break; + } + } + dbLayer.Attributes.Append(attri); + dbLayer.InnerText = layer.Name; + + dbLayers.AppendChild(dbLayer); + } + else + { + XmlElement dbLayer = doc.CreateElement("layer"); + dbLayer.InnerText = layer.Name; + layers.AppendChild(dbLayer); + } + } + + doc.Save(configPath); + } + catch (Exception e) + { + + } + } + + private void openLayerList() + { + layerManagerNode.Nodes.Clear(); + + string configPath = Application.StartupPath + "\\configLayerList.xml"; + try + { + XmlDocument doc = new XmlDocument(); + doc.Load(configPath); + XmlNode dbParams = doc.SelectSingleNode("Params/dbparams"); + XmlNode dbLayers = doc.SelectSingleNode("Params/dblayers"); + XmlNode layers = doc.SelectSingleNode("Params/layers"); + + List listDS = new List(); + for (int i = 0; i < dbParams.ChildNodes.Count; i++) + { + string ip = ""; + string dbname = ""; + string username = ""; + string password = ""; + string type = ""; + XmlNode node = dbParams.ChildNodes.Item(i); + for (int j = 0; j < node.ChildNodes.Count; j++) + { + XmlNode nodeChild = node.ChildNodes.Item(j); + + if (nodeChild != null && nodeChild.Name == "ship") + { + ip = nodeChild.InnerText; + } + else if (nodeChild != null && nodeChild.Name == "shdbname") + { + dbname = nodeChild.InnerText; + } + else if (nodeChild != null && nodeChild.Name == "shusername") + { + username = nodeChild.InnerText; + } + else if (nodeChild != null && nodeChild.Name == "shpassword") + { + password = nodeChild.InnerText; + } + else if (nodeChild != null && nodeChild.Name == "shtype") + { + type = nodeChild.InnerText; + } + } + + if (type == "sqlserver") + { + GSODataSource ds = globeControl1.Globe.DataManager.OpenSqlServerDataSource(ip, "", dbname, username, password); + listDS.Add(ds); + } + else if (type == "oracle") + { + GSODataSource ds = globeControl1.Globe.DataManager.OpenOracleDataSource(ip + "/" + dbname, "", "", username, password); + listDS.Add(ds); + } + } + + for (int i = 0; i < dbLayers.ChildNodes.Count; i++) + { + XmlNode node = dbLayers.ChildNodes.Item(i); + if (node != null) + { + string layerName = node.InnerText; + XmlAttribute attri = node.Attributes["dbindex"]; + if (attri != null) + { + int dbIndex = -1; + if (int.TryParse(attri.Value, out dbIndex)) + { + GSODataset dataset = listDS[dbIndex].GetDatasetByName(layerName); + globeControl1.Globe.Layers.Add(dataset); + //更新树节点 + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + TreeNode layerNode = new TreeNode(); + layerNode.Tag = layer; + layerNode.Text = layer.Dataset.Caption; + layerNode.ImageIndex = 0; + layerNode.SelectedImageIndex = 0; + layerNode.Checked = layer.Visible; + layerManagerNode.Nodes.Insert(0, layerNode); + // layerManagerNode.Expand(); + + + } + } + } + } + for (int i = 0; i < layers.ChildNodes.Count; i++) + { + XmlNode node = layers.ChildNodes.Item(i); + if (node != null) + { + string layerName = node.InnerText; + globeControl1.Globe.Layers.Add(layerName); + + //更新树节点 + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + TreeNode layerNode = new TreeNode(); + layerNode.Tag = layer; + layerNode.Text = layer.Dataset.Caption; + layerNode.ImageIndex = 0; + layerNode.SelectedImageIndex = 0; + layerNode.Checked = layer.Visible; + layerManagerNode.Nodes.Insert(0, layerNode); + } + } + layerManagerNode.Expand(); + } + catch (Exception e) + { + + } + } + * */ + #endregion + + private void btn_check_history_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_check_history.Text); + + if (FrmCheckHistory.isOpen == true) + { + return; + } + FrmCheckHistory frm = new FrmCheckHistory(globeControl1, globeControl2); + frm.addNode += new AddNodeToLayerManagerNode(addNodeToLayerManagerNode); + frm.Show(); + + } + + private void buttonItem查看数据_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItem查看数据.Text); + + FrmThreeOracle tr = new FrmThreeOracle(globeControl1); + + if (tr.ShowDialog() == DialogResult.OK) + { + addNodeToLayerManagerNode(tr.rukuLayer); + globeControl1.Refresh(); + } + } + /// + /// 规划数据入库 + /// + /// + /// + private void buttonItemGHRK_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemGHRK.Text); + + FrmGHRK ghrk = new FrmGHRK(globeControl1, layerManagerNode); + ghrk.Show(this); + } + + private void btn_user_info_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_user_info.Text); + + if (!FrmSysUserInfoManger.IS_OPEN) + { + FrmSysUserInfoManger frm = new FrmSysUserInfoManger(); + frm.ShowDialog(); + } + } + + private void btn_role_info_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_role_info.Text); + + if (FrmRoleInfoManager.IS_OPEN) + { + return; + } + FrmRoleInfoManager frm = new FrmRoleInfoManager(); + frm.ShowDialog(); + } + + private void btn_resc_info_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_resc_info.Text); + + if (!SysRescInfoManager.IS_OPEN) + { + SysRescInfoManager frm = new SysRescInfoManager(); + frm.ShowDialog(); + } + } + + private void btn_role_resc_Click(object sender, EventArgs e) + { + + LogManager.saveLog(Utility.userName, this.btn_role_resc.Text); + + if (!FrmRoleRescManager.IS_OPEN) + { + FrmRoleRescManager frm = new FrmRoleRescManager(); + frm.ShowDialog(); + } + } + + private void btn_user_role_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_user_role.Text); + + if (FrmUserRole.IS_OPEN) + { + return; + } + FrmUserRole frm = new FrmUserRole(); + frm.ShowDialog(); + } + + private void btn_document_info_Click(object sender, EventArgs e) + { + + LogManager.saveLog(Utility.userName, this.btn_document_info.Text); + + //if (FormDocumentManager.IS_OPEN) + //{ + // return; + //} + //FormDocumentManager frm = new FormDocumentManager(); + //frm.ShowDialog(); + + //if (FormDocumentManager.IS_OPEN) + //{ + // return; + //} + //new FormDocumentManager().ShowDialog(); + if (FormDocumentManager.IS_OPEN) + { + return; + } + this.Cursor = Cursors.WaitCursor; + FormDocumentManager frm = new FormDocumentManager(); + frm.changeCursor += new ChangeCursor(changeCursorToDefault); + frm.ShowDialog(); + + } + + private void changeCursorToDefault() + { + this.Cursor = Cursors.Default; + } + + /// + /// 判断CAD文件是否有投影信息 + /// + /// + /// + Boolean CheckDatasetGeoReference(GSODataset dataset) + { + Boolean bSuccess = false; + if (dataset.GeoReferenceType == EnumGeoReferenceType.Flat) + { + if (MessageBox.Show("数据没有空间参考信息,请设置空间参考信息!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation) == DialogResult.OK) + { + String strPath = Path.GetDirectoryName(Application.ExecutablePath) + "\\Coordinate Systems"; + OpenFileDialog dlg = new OpenFileDialog(); + + dlg.InitialDirectory = strPath; + dlg.RestoreDirectory = true; + + dlg.Filter = "投影文件|*.prj||"; + if (dlg.ShowDialog() == DialogResult.OK) + { + bSuccess = dataset.LoadProjectionFromESRIFile(dlg.FileName); + } + } + } + else + { + return true; + } + return bSuccess; + } + + private void buttonItemexp_CAD_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemexp_CAD.Text); + + OpenFileDialog dlg = new OpenFileDialog(); + dlg.Filter = "支持格式(*.dwg)|*.dwg"; + dlg.Multiselect = true; + if (dlg.ShowDialog() == DialogResult.OK) + { + for (int i = 0; i < dlg.FileNames.Length; i++) + { + //this.Cursor = Cursors.WaitCursor; + string strDataPath = dlg.FileNames[i]; + + #region + //string strDataPathPrj = strDataPath.ToLower().Replace(".dwg", ".lprj"); + + //if (File.Exists(strDataPathPrj) == false) + //{ + // if (MessageBox.Show("数据没有空间参考信息,请设置空间参考信息!", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation) == DialogResult.OK) + // { + // String strPath = Application.StartupPath + "\\Coordinate Systems"; + // OpenFileDialog dlgPrj = new OpenFileDialog(); + // dlgPrj.InitialDirectory = strPath; + // dlgPrj.RestoreDirectory = true; + // dlgPrj.Multiselect = false; + // dlg.Filter = "投影文件|*.prj"; + // if (dlg.ShowDialog() == DialogResult.OK) + // { + // this.Cursor = Cursors.WaitCursor; + // string proj4 = GSODataEngineUtility.ConvertEsriPrjFileToProj4(dlg.FileName); + // using (StreamWriter stream = new StreamWriter(strDataPathPrj, false)) + // { + // stream.WriteLine("0prj4" + proj4 + ""); + // } + // AddLayerData(strDataPath); + // //globeControl1.Globe.Layers.Add(strDataPath); + + // this.Cursor = Cursors.Default; + // } + // else + // { + // AddLayerData(strDataPath); + // //globeControl1.Globe.Layers.Add(strDataPath); + // } + // } + // else + // { + // AddLayerData(strDataPath); + // //globeControl1.Globe.Layers.Add(strDataPath); + // } + + //} + //else + //{ + // //globeControl1.Globe.Layers.Add(strDataPath); + // AddLayerData(strDataPath); + //} + #endregion + AddLayerData(strDataPath); + //this.Cursor = Cursors.Default; + } + } + + 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, 100); + + globeControl1.Refresh(); + } + } + + private void btn_password_edit_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_password_edit.Text); + + if (FrmChangePassword.IS_OPEN) + { + return; + } + FrmChangePassword frm = new FrmChangePassword(); + frm.ShowDialog(); + } + /// + /// 多孔管线入库 + /// + /// + /// + private void buttonItem9_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL4_2.Text); + + if (ds == null) + { + MessageBox.Show("请先连接数据库", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + ConnectDB(null, null); + } + if (ds == null) + return; + + FrmMultiPipelineModelDB frm = new FrmMultiPipelineModelDB(globeControl1, ds); + if (frm.ShowDialog() == DialogResult.OK) + { + addNodeToLayerManagerNode(frm.rukuLayer); + } + //frm.Show(); + } + private void 导出CADToolStripMenuItem1_Click(object sender, EventArgs e) + { + TreeNode node = layerNodeContexMenu.Tag as TreeNode; + if (node == null) + { + MessageBox.Show("请在左侧节点集中选择要导出的图层", "提示"); + return; + } + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(node.Text.Trim()); + if (layer == null || layer.GetAllFeatures().Length <= 0) + { + MessageBox.Show("要导出的图层为空", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + return; + } + string strProjectName = Utility.projectStr; + if (strProjectName != "") + { + SaveFileDialog dlg = new SaveFileDialog(); + dlg.Filter = "*.dwg|*.dwg|*.dxf|*.dxf"; + dlg.FileName = layer.Caption; + if (dlg.ShowDialog(this) == DialogResult.OK) + { + globeControl1.Globe.MemoryLayer.SaveAs(dlg.FileName); + GSOLayer newlayer = globeControl1.Globe.Layers.Add(dlg.FileName); + newlayer.RemoveAllFeature(); + int featureCount = layer.GetAllFeatures().Length; + for (int i = 0; i < featureCount; i++) + { + GSOFeature feature = layer.GetAt(i); + if (feature != null && feature.Geometry != null) + { + if (feature.Geometry.Type == EnumGeometryType.GeoPolyline3D) + { + feature.Geometry.Style = new GSOSimpleLineStyle3D(); + } + else if (feature.Geometry.Type == EnumGeometryType.GeoPolygon3D) + { + feature.Geometry.Style = new GSOSimplePolygonStyle3D(); + } + newlayer.AddFeature(feature); + } + } + newlayer.Save(); + newlayer.Dataset.DataSource.RemoveDataset(newlayer.Dataset); + globeControl1.Globe.Layers.Remove(newlayer); + MessageBox.Show("导出CAD完成!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + } + } + } + + private void buttonItemGBJC_Click(object sender, EventArgs e) + { + FrmGBJC gb = new FrmGBJC(globeControl1, globeControl2, layerTemp, layerTemp2); + gb.Show(this); + } + + #region 右屏管纵数据控制 + private void 五十米主干道ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = true; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + + private void 三十六米次干道ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = true; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + + private void 四十二米次干道ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = true; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + + private void 二十四米一块板ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = true; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + + private void 二十四米三块板ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = true; + } + + private void 二十四米停车带ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = true; + lendendGZ24_3.Visible = false; + } + + private void 二十六米大堤路ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = true; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + + private void 清除管纵数据ToolStripMenuItem_Click(object sender, EventArgs e) + { + ClearGZData(); + } + + private void ClearGZData() + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + #endregion + + private void buttonItemPasswordReset_Click(object sender, EventArgs e) + { + Frm_password_reset reset = new Frm_password_reset(); + reset.Show(); + } + + private void pictureBox1_Paint(object sender, PaintEventArgs e) + { + int Width = this.Width; + string welcomeUser = "欢迎您:" + Utility.userName; + Graphics g = e.Graphics; + g.DrawString(welcomeUser, new Font("宋体", 12), new SolidBrush(Color.Black), Width - 180, 50); + } + + } +} \ No newline at end of file diff --git a/bin/x86/Debug/Cyberpipe.vshost.exe.manifest b/bin/x86/Debug/Cyberpipe.vshost.exe.manifest deleted file mode 100644 index 061c9ca..0000000 --- a/bin/x86/Debug/Cyberpipe.vshost.exe.manifest +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - diff --git a/bin/x86/Debug/glVersion.txt b/bin/x86/Debug/glVersion.txt index 06a7613..1fc46d0 100644 --- a/bin/x86/Debug/glVersion.txt +++ b/bin/x86/Debug/glVersion.txt Binary files differ diff --git a/Cyberpipe.csproj b/Cyberpipe.csproj index 3a45ad8..d22f590 100644 --- a/Cyberpipe.csproj +++ b/Cyberpipe.csproj @@ -402,12 +402,6 @@ FrmBACKORACLE.cs - - Form - - - FrmBSQDuoBianXingStatis.cs - Form @@ -1271,9 +1265,6 @@ FrmBACKORACLE.cs - - FrmBSQDuoBianXingStatis.cs - FrmBSQStatis.cs diff --git a/FeatureStatisticsService.cs b/FeatureStatisticsService.cs index e833e5f..c7de210 100644 --- a/FeatureStatisticsService.cs +++ b/FeatureStatisticsService.cs @@ -273,19 +273,15 @@ /// 获取特定区域图层的管线列表,并将其总长度统计出来 ///
TODOLIST:将Intersects_Pipeline在MainFrm中去除 /// - /// + /// + /// 要统计的长度 /// public static GSOFeatures getLayerPipes(GSOGeoPolygon3D polygon, GSOLayer layer, out double length) { length = 0; if (layer == null) return null; - GSOFeatureLayer flayer = layer as GSOFeatureLayer; - GSOFeatureDataset fdataset = flayer.Dataset as GSOFeatureDataset; - GSOFeatures feats = null; - - feats = polygon == null?flayer.GetAllFeatures():flayer.FindFeaturesInPolygon(polygon, false); - + GSOFeatures feats = getLayerFeatures(polygon, layer); double totallength = 0.00; for (int i = 0; i < feats.Length; i++) { @@ -301,5 +297,17 @@ return feats; } + /// + /// 获取区域图层内的feature列表,MainFrm.PolygonIntersectAnalysis和此方法重复,需要整理删除 + /// + /// + /// + /// + public static GSOFeatures getLayerFeatures(GSOGeoPolygon3D polygon, GSOLayer layer) + { + if (layer == null) return null; + GSOFeatureLayer flayer = layer as GSOFeatureLayer; + return polygon == null ? flayer.GetAllFeatures() : flayer.FindFeaturesInPolygon(polygon, false); + } } } diff --git a/FrmAllWorkWellStatis.cs b/FrmAllWorkWellStatis.cs index 7bf65dc..bd0f81b 100644 --- a/FrmAllWorkWellStatis.cs +++ b/FrmAllWorkWellStatis.cs @@ -19,17 +19,7 @@ private Dictionary map = null; private GSOGlobeControl globeControl1; private GSOGeoPolygon3D polygon; - //TODOLIST:用晓伟的代理进行操作,功能拆分细化 - //public FrmAllWorkWellStatis(GSOGeoPolygon3D polygon, DataGridView dataGridViewX11, ToolStripStatusLabel toolStripNumbers1, GSOGlobeControl ctl, PanelEx p) - //{ - // InitializeComponent(); - // panel = p; - // dataGridViewX1 = dataGridViewX11; - // toolStripNumbers = toolStripNumbers1; - // globeControl1 = ctl; - // map = getAccsMap(polygon); - //} public FrmAllWorkWellStatis(GSOGlobeControl ctl,GSOGeoPolygon3D polygon, MainFrm.DataGridViewDelegate InitDataGridViewX1) { InitializeComponent(); @@ -117,8 +107,9 @@ sql = "select " + getpipeLineFields.getFields(layername, globeControl1) + " from " + layer.Name; sql += " where 1>2 "; - for (int i = 0; i < fs.Length && fs[i].GetFieldDefn("编号") != null; i++) + for (int i = 0; i < fs.Length; i++) { + if (fs[i].GetFieldDefn("编号") == null) continue; sql += " or 编号 = '" + fs[i].GetValue("编号").ToString() + "'"; } diff --git a/FrmBSQDuoBianXingStatis.Designer.cs b/FrmBSQDuoBianXingStatis.Designer.cs deleted file mode 100644 index bda6842..0000000 --- a/FrmBSQDuoBianXingStatis.Designer.cs +++ /dev/null @@ -1,87 +0,0 @@ -namespace Cyberpipe -{ - partial class FrmBSQDuoBianXingStatis - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea1 = new System.Windows.Forms.DataVisualization.Charting.ChartArea(); - this.groupBox1 = new System.Windows.Forms.GroupBox(); - this.chart1 = new System.Windows.Forms.DataVisualization.Charting.Chart(); - this.groupBox1.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.chart1)).BeginInit(); - this.SuspendLayout(); - // - // groupBox1 - // - this.groupBox1.Controls.Add(this.chart1); - this.groupBox1.Dock = System.Windows.Forms.DockStyle.Fill; - this.groupBox1.Location = new System.Drawing.Point(0, 0); - this.groupBox1.Name = "groupBox1"; - this.groupBox1.Size = new System.Drawing.Size(592, 384); - this.groupBox1.TabIndex = 0; - this.groupBox1.TabStop = false; - this.groupBox1.Text = "统计结果信息"; - // - // chart1 - // - chartArea1.AxisX.MajorGrid.Enabled = false; - chartArea1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(191)))), ((int)(((byte)(219)))), ((int)(((byte)(255))))); - chartArea1.BackGradientStyle = System.Windows.Forms.DataVisualization.Charting.GradientStyle.TopBottom; - chartArea1.Name = "ChartArea1"; - this.chart1.ChartAreas.Add(chartArea1); - this.chart1.Dock = System.Windows.Forms.DockStyle.Fill; - this.chart1.Location = new System.Drawing.Point(3, 17); - this.chart1.Name = "chart1"; - this.chart1.Size = new System.Drawing.Size(586, 364); - this.chart1.TabIndex = 0; - this.chart1.Text = "chart1"; - // - // FrmBSQDuoBianXingStatis - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(592, 384); - this.Controls.Add(this.groupBox1); - this.DoubleBuffered = true; - this.Name = "FrmBSQDuoBianXingStatis"; - this.ShowIcon = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; - this.Text = "多边形区域统计"; - this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FrmBSQDuoBianXingStatis_FormClosing); - this.Load += new System.EventHandler(this.FrmBSQDuoBianXingStatis_Load); - this.groupBox1.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)(this.chart1)).EndInit(); - this.ResumeLayout(false); - - } - - #endregion - - private System.Windows.Forms.GroupBox groupBox1; - private System.Windows.Forms.DataVisualization.Charting.Chart chart1; - } -} \ No newline at end of file diff --git a/FrmBSQDuoBianXingStatis.cs b/FrmBSQDuoBianXingStatis.cs deleted file mode 100644 index 80b567e..0000000 --- a/FrmBSQDuoBianXingStatis.cs +++ /dev/null @@ -1,179 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Windows.Forms; -using DevComponents.DotNetBar; -using System.Data.SqlClient; -using System.Windows.Forms.DataVisualization.Charting; -using GeoScene.Data; -using GeoScene.Engine; -using GeoScene.Globe; -using System.Data.OracleClient; - -namespace Cyberpipe -{ - public partial class FrmBSQDuoBianXingStatis : Office2007Form - { - Dictionary bsq = new Dictionary(); - Dictionary bsq1 = new Dictionary(); - static FrmBSQDuoBianXingStatis frm; - GSOGlobeControl globeControl1; - List list = new List(); - public static List pipeLists = new List(); - - string[] codeStr = new string[50]; - string[] nameStr = new string[30]; - public static List typeLists; - - public FrmBSQDuoBianXingStatis(Dictionary workWellLen, GSOGlobeControl glb,List _list) - { - InitializeComponent(); - bsq = workWellLen; - globeControl1 = glb; - list = _list; - } - - private void FrmBSQDuoBianXingStatis_Load(object sender, EventArgs e) - { - FrmBSQDuoBianXingStatisFenLei(); - try - { - chart1.Series.Add("标识器"); - chart1.ChartAreas["ChartArea1"].AxisX.Title = "标识器类型"; - chart1.ChartAreas["ChartArea1"].AxisY.Title = "标识器数量"; - chart1.ChartAreas["ChartArea1"].AxisX.Interval = 1; - chart1.Series["标识器"].ChartType = SeriesChartType.Column; - chart1.Series["标识器"]["DrawingStyle"] = "Cylinder"; - - chart1.Series["标识器"].Points.DataBindXY(bsq1.Keys, bsq1.Values); - if (bsq1.Values.Count == 0) - { - MessageBox.Show("该区域没有标识器信息", "提示"); - this.Close(); - return; - } - else - { - for (int m = 0; m < bsq1.Values.Count; m++) - { - if (chart1.Series["标识器"].Points[m].YValues[0].ToString() != "0") - { - chart1.Series["标识器"].Points[m].Label = chart1.Series[0].Points[m].YValues[0].ToString(); - } - } - } - } - catch (Exception ex) - { - //ErrorLog.PublishError(ex); - } - } - - private void FrmBSQDuoBianXingStatis_FormClosing(object sender, FormClosingEventArgs e) - { - frm = null; - globeControl1.Globe.ClearAnalysis(); - globeControl1.Globe.MemoryLayer.RemoveAllFeature(); - } - - - private void FrmBSQDuoBianXingStatisFenLei() - { - try - { - bool flag2 = false; - for (int i = 0; i < Utility.listPipelineType.Count; i++) - { - - for (int j = 0; j < pipeLists.Count; j++) - { - if (pipeLists[j] == Utility.listPipelineType[i].type) - { - flag2 = true; - break; - } - } - if (!flag2 && Utility.listPipelineType[i].type != "标识器") - { - pipeLists.Add(Utility.listPipelineType[i].type); - } - flag2 = false; - } - - typeLists = new List(); - for (int num = 0; num < pipeLists.Count; num++) - { - typeList ls = new typeList(0, pipeLists[num]); - typeLists.Add(ls); - } - - GSOFeatures fs = list[0]; - string pipetype = "标识器"; - foreach (string key in bsq.Keys) - { - if (key.StartsWith(pipetype)) - { - pipetype = key; - break; - } - } - if (fs.Length > 0) - { - for (int i = 0; i < fs.Length; i++) - { - string str = fs[i].GetValue("对象名称").ToString(); - codeStr = str.Split(','); - for (int n = 0; n < codeStr.Length; n++) - { - for (int ii = 0; ii < Utility.listPipelineType.Count; ii++) - { - if (Utility.listPipelineType[ii].code == codeStr[n]) - { - for (int m = 0; m < typeLists.Count; m++) - { - if (Utility.listPipelineType[ii].type == typeLists[m].type) - { - typeLists[m].num++; - break; - } - } - break; - } - } - } - } - } - - for (int i = 0; i < typeLists.Count; i++) - { - if (typeLists[i].num > 0) - bsq1.Add(typeLists[i].type, typeLists[i].num); - } - - } - catch (Exception ex) - { - //ErrorLog.PublishError(ex); - //MessageBox.Show(ex.Message); - } - - } - public class typeList - { - public int num; - public string type; - - public typeList(int _num, string _type) - { - num = _num; - type = _type; - } - } - - - } -} diff --git a/FrmBSQDuoBianXingStatis.resx b/FrmBSQDuoBianXingStatis.resx deleted file mode 100644 index 1af7de1..0000000 --- a/FrmBSQDuoBianXingStatis.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/FrmBSQStatis.Designer.cs b/FrmBSQStatis.Designer.cs index 2509c7d..ee9b1e7 100644 --- a/FrmBSQStatis.Designer.cs +++ b/FrmBSQStatis.Designer.cs @@ -57,6 +57,7 @@ this.ShowIcon = false; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "标识器全区域统计"; + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FrmBSQStatis_FormClosing); this.Load += new System.EventHandler(this.FrmBSQStatis_Load); ((System.ComponentModel.ISupportInitialize)(this.chartStatis)).EndInit(); this.ResumeLayout(false); diff --git a/FrmBSQStatis.cs b/FrmBSQStatis.cs index 4b25eda..e7c4926 100644 --- a/FrmBSQStatis.cs +++ b/FrmBSQStatis.cs @@ -18,94 +18,18 @@ { public partial class FrmBSQStatis : Office2007Form { - public Dictionary bsq = new Dictionary(); - //SqlConnection conn; - public static List typeLists; - OracleConnection conn; - string connectString; + private Dictionary bsq = new Dictionary(); + private GSOGlobeControl globeControl1; + private GSOGeoPolygon3D polygon; - public FrmBSQStatis() + public FrmBSQStatis(GSOGlobeControl globeControl1,GSOGeoPolygon3D polygon) { + this.globeControl1 = globeControl1; + this.polygon = polygon; InitializeComponent(); - BSQNumStatis(); + bsq = getBSQNameAndNumMap(polygon); } - string[] codeStr = new string[50]; - string[] nameStr = new string[30]; - public static List pipeLists = new List(); - - private void BSQNumStatis() - { - bool flag2 = false; - for (int i = 0; i < Utility.listPipelineType.Count; i++) - { - for (int j = 0; j < pipeLists.Count; j++) - { - if (pipeLists[j] == Utility.listPipelineType[i].type) - { - flag2 = true; - break; - } - } - if (!flag2 && Utility.listPipelineType[i].type != "标识器") - { - pipeLists.Add(Utility.listPipelineType[i].type); - } - flag2 = false; - } - - typeLists = new List(); - for (int num = 0; num 0) - bsq.Add(typeLists[i].type, typeLists[i].num); - } - - } - catch (Exception ex) - { - - } - } private void FrmBSQStatis_Load(object sender, EventArgs e) { @@ -136,17 +60,88 @@ } } - public class typeList + private Dictionary getBSQNameAndNumMap(GSOGeoPolygon3D polygon) { - public int num; - public string type; - public typeList(int _num, string _type) + Dictionary result = new Dictionary(); + Dictionary codeAndType = new Dictionary(); + //得到type的种类 + for (int i = 0; i < Utility.listPipelineType.Count; i++) { - num = _num; - type = _type; + if (!result.ContainsKey(Utility.listPipelineType[i].type) && Utility.listPipelineType[i].type != "标识器") + { + result.Add(Utility.listPipelineType[i].type, 0); + codeAndType.Add(Utility.listPipelineType[i].code, Utility.listPipelineType[i].type); + } + } + + return polygon == null ? getAllAreaMap(result, codeAndType) : getBSQMapByPolygon(polygon, result, codeAndType); + } + public Dictionary getAllAreaMap(Dictionary typeAndCount,Dictionary codeAndType) + { + try + { + OracleConnection conn = OledbHelper.sqlConnection(); + conn.Open(); + OracleCommand cmd; + cmd = new OracleCommand("select 对象类型 from 标识器", conn); + OracleDataReader dr = cmd.ExecuteReader(); + + while (dr.Read()) + { + string str = Convert.ToString(dr["对象类型"]); + if (str == null) continue; + foreach (string key in codeAndType.Keys) + { + if (str.Contains(key)) + { + typeAndCount[codeAndType[key]] += 1; + } + } + } + conn.Close(); + } + catch (Exception ex) + { + LogHelper.WriteLog(typeof(FrmBSQStatis),ex.Message.ToString()); + } + return typeAndCount; + } + + + public Dictionary getBSQMapByPolygon(GSOGeoPolygon3D polygon,Dictionary typeAndCount, Dictionary codeAndType) + { + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption("标识器"); + GSOFeatures bsqFs = FeatureStatisticsService.getLayerFeatures(polygon, layer); + if (bsqFs == null || bsqFs.Length <= 0) { + LogHelper.WriteLog(typeof(FrmBSQStatis),"标识器图层下的Feature为空"); + return null; + } + + for (int i = 0; i < bsqFs.Length; i++) + { + string str = bsqFs[i].GetValue("对象类型").ToString(); + + foreach (string key in codeAndType.Keys) + { + if (str.Contains(key)) + { + typeAndCount[codeAndType[key]] += 1; + } + } + } + + return typeAndCount; + } + + private void FrmBSQStatis_FormClosing(object sender, FormClosingEventArgs e) + { + globeControl1.Globe.ClearAnalysis(); + } + + } } diff --git a/FrmValveStatistics.cs b/FrmValveStatistics.cs index 672f97a..17dad6c 100644 --- a/FrmValveStatistics.cs +++ b/FrmValveStatistics.cs @@ -120,6 +120,7 @@ sql += " where 1>2 "; for (int i = 0; i < fs.Length; i++) { + if (fs[i].GetValue("编号") == null) continue; sql += " or 编号 = '" + fs[i].GetValue("编号").ToString() + "'"; } diff --git a/FrmpipeDeepstatis.cs b/FrmpipeDeepstatis.cs index 879801a..c7edbc3 100644 --- a/FrmpipeDeepstatis.cs +++ b/FrmpipeDeepstatis.cs @@ -164,88 +164,6 @@ } } - //if (clbPipeLine.CheckedItems.Count > 0) - //{ - // if (dataGridViewX2.Rows.Count > 0) - // { - // for (int i = 0; i < clbPipeLine.CheckedItems.Count; i++) - // { - // GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(clbPipeLine.CheckedItems[i].ToString()); - // GSOFeatureLayer flayer = layer as GSOFeatureLayer; - // GSOFeatures feats = new GSOFeatures(); - // if (polygon == null) - // feats = flayer.GetAllFeatures(); - // else - // feats = flayer.FindFeaturesInPolygon(polygon, false); - // for (int j = 0; j < dataGridViewX2.Rows.Count; j++) - // { - // double totalLength = 0.00; - // int ncount = 0; - // for (int m = 0; m < feats.Length; m++) - // { - // GSOFeature feat = feats[m]; - // float radius = feat.GetFieldAsFloat("起始埋深"); - // bool upCompare = true; - // bool downCompare = true; - // if (dataGridViewX2.Rows[j].Cells["下限"].Value != null || dataGridViewX2.Rows[j].Cells["上限"].Value != null) - // { - // if (dataGridViewX2.Rows[j].Cells["下限"].Value != null) - // { - // if (dataGridViewX2.Rows[j].Cells["下限"].Value.ToString() != "") - // { - // if (radius >= Convert.ToDouble(dataGridViewX2.Rows[j].Cells["下限"].Value)) - // { - // downCompare = true; - // } - // else - // downCompare = false; - // } - // } - // if (dataGridViewX2.Rows[j].Cells["上限"].Value != null) - // { - // if (dataGridViewX2.Rows[j].Cells["上限"].Value.ToString() != "") - // { - // if (radius <= Convert.ToDouble(dataGridViewX2.Rows[j].Cells["上限"].Value)) - // { - // upCompare = true; - // } - // else - // upCompare = false; - // } - // } - // if (upCompare && downCompare) - // { - // GSOGeoPolyline3D line = feat.Geometry as GSOGeoPolyline3D; - // double length = line.GetSpaceLength(true, 6378137); - // totalLength += length; - // ncount += 1; - // } - // } - // } - // if (dataGridViewX2.Rows[j].Cells["下限"].Value != null || dataGridViewX2.Rows[j].Cells["上限"].Value != null) - // { - // DataGridViewRow row = new DataGridViewRow(); - // int index = dataGridViewX1.Rows.Add(row); - // row = dataGridViewX1.Rows[index]; - // row.Cells["图层名称"].Value = layer.Caption; - // row.Cells["埋深范围"].Value = dataGridViewX2.Rows[j].Cells["下限"].Value + "-" + dataGridViewX2.Rows[j].Cells["上限"].Value; - // row.Cells["条数"].Value = ncount; - // row.Cells["总长度"].Value =Math.Round(totalLength,2); - - // dic.Add(layer.Caption + "," + row.Cells["埋深范围"].Value.ToString()+","+row.Cells["总长度"].Value.ToString(), ncount); - // } - // } - // } - // } - // else - // { - // MessageBox.Show("请添加分段!"); - // } - //} - //else - //{ - // MessageBox.Show("请选择图层!"); - //} showPipeWidget(); } catch (Exception ex) diff --git a/FrmpipeMaterialGather.cs b/FrmpipeMaterialGather.cs index b7ab1d2..3e9f45d 100644 --- a/FrmpipeMaterialGather.cs +++ b/FrmpipeMaterialGather.cs @@ -180,79 +180,6 @@ } - //if (clbPipeLine.CheckedItems.Count > 0) - //{ - // for (int i = 0; i < clbPipeLine.CheckedItems.Count; i++) - // { - // GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(clbPipeLine.CheckedItems[i].ToString()); - // GSOFeatureLayer flayer = layer as GSOFeatureLayer; - // GSOFeatures feats = new GSOFeatures(); - // if (polygon == null) - // feats = flayer.GetAllFeatures(); - // else - // feats = flayer.FindFeaturesInPolygon(polygon, false); - // List lstDiameter = new List(); - - // for (int j = 0; j < clbmaterials.CheckedItems.Count; j++) - // { - // if (!lstDiameter.Contains(clbmaterials.CheckedItems[j].ToString())) - // { - // lstDiameter.Add(clbmaterials.CheckedItems[j].ToString()); - // } - // } - // //lstDiameter.Sort(); - // if (lstDiameter.Count > 0) - // { - // for (int m = 0; m < lstDiameter.Count; m++) - // { - // double totalLength = 0.00; - // int ncount = 0; - // for (int j = 0; j < feats.Length; j++) - // { - // if (lstDiameter[m] != "无") - // { - // if (feats[j].GetFieldAsString("材质") == lstDiameter[m]) - // { - // GSOGeoPolyline3D line = feats[j].Geometry as GSOGeoPolyline3D; - // if (line != null) - // { - // double length = line.GetSpaceLength(true, 6378137); - // totalLength += length; - // ncount += 1; - // } - // } - // } - // else - // { - // if (feats[j].GetFieldAsString("材质") == "") - // { - // GSOGeoPolyline3D line = feats[j].Geometry as GSOGeoPolyline3D; - // if (line != null) - // { - // double length = line.GetSpaceLength(true, 6378137); - // totalLength += length; - // ncount += 1; - // } - // } - // } - // } - // DataGridViewRow row = new DataGridViewRow(); - // int index = dataGridViewX1.Rows.Add(row); - // row = dataGridViewX1.Rows[index]; - // row.Cells["图层名称"].Value = layer.Caption; - // row.Cells["材质"].Value = lstDiameter[m]; - // row.Cells["条数"].Value = ncount; - // row.Cells["总长度"].Value = Math.Round(totalLength); - - // dic.Add(layer.Caption + "," + row.Cells["材质"].Value.ToString(), ncount); - // } - // } - // } - //} - //else - //{ - // MessageBox.Show("请选择图层!"); - //} showPipeWidget(); } catch (Exception ex) diff --git a/Frmpipediameterstatis.cs b/Frmpipediameterstatis.cs index 9953ac0..aa482d8 100644 --- a/Frmpipediameterstatis.cs +++ b/Frmpipediameterstatis.cs @@ -27,12 +27,9 @@ frm = new Frmpipediameterstatis(_globeControl1, pipeLayers, visibleId); frm.Show(_globeControl1.Parent); } - else + else if (frm.WindowState == FormWindowState.Minimized) { - if (frm.WindowState == FormWindowState.Minimized) - { - frm.WindowState = FormWindowState.Normal; - } + frm.WindowState = FormWindowState.Normal; } } @@ -208,7 +205,8 @@ } catch (Exception ex) { - MessageBox.Show(ex.Message); + LogHelper.WriteLog(typeof(Frmpipediameterstatis), ex.Message); + //MessageBox.Show(ex.Message); LogError.PublishError(ex); } } @@ -290,76 +288,77 @@ /// private void btnExport_Click(object sender, EventArgs e) { - if (dataGridViewX1.Rows.Count > 0) + if (dataGridViewX1.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 = DateTime.Now.ToString("yyyyMMdd") + ".xls"; - if (dlg.ShowDialog() == DialogResult.OK) + MessageBox.Show("统计结果为空,请重新统计之后再导出Excel!", "提示"); + return; + } + + SaveFileDialog dlg = new SaveFileDialog(); + dlg.Filter = "Excel files (*.xls)|*.xls"; + dlg.FilterIndex = 0; + dlg.RestoreDirectory = true; + //dlg.CreatePrompt = true; + dlg.Title = "保存为Excel文件"; + dlg.FileName = 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 { - Stream myStream; - myStream = dlg.OpenFile(); - StreamWriter sw = new StreamWriter(myStream, System.Text.Encoding.GetEncoding(-0)); - string columnTitle = ""; - try + sw.WriteLine("日期:" + DateTime.Now.ToString("yyyy-MM-dd")); + + //写入列标题 + for (int i = 0; i < dataGridViewX1.ColumnCount; i++) { - sw.WriteLine("日期:" + DateTime.Now.ToString("yyyy-MM-dd")); - - //写入列标题 - for (int i = 0; i < dataGridViewX1.ColumnCount; i++) + if (i > 0) { - if (i > 0) - { - columnTitle += "\t"; - } - columnTitle += dataGridViewX1.Columns[i].HeaderText; + columnTitle += "\t"; } - sw.WriteLine(columnTitle); - - //写入列内容 - for (int j = 0; j < dataGridViewX1.Rows.Count; j++) - { - string columnValue = ""; - for (int k = 0; k < dataGridViewX1.Columns.Count; k++) - { - if (k > 0) - { - columnValue += "\t"; - } - if (dataGridViewX1.Rows[j].Cells[k].Value == null) - columnValue += ""; - else - columnValue += dataGridViewX1.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); - } + columnTitle += dataGridViewX1.Columns[i].HeaderText; } - catch (Exception ex) + sw.WriteLine(columnTitle); + + //写入列内容 + for (int j = 0; j < dataGridViewX1.Rows.Count; j++) { - MessageBox.Show(ex.ToString()); + string columnValue = ""; + for (int k = 0; k < dataGridViewX1.Columns.Count; k++) + { + if (k > 0) + { + columnValue += "\t"; + } + if (dataGridViewX1.Rows[j].Cells[k].Value == null) + columnValue += ""; + else + columnValue += dataGridViewX1.Rows[j].Cells[k].Value.ToString().Trim(); + } + + sw.WriteLine(columnValue); } - finally + sw.Close(); + myStream.Close(); + if (MessageBox.Show("导出Excel文件成功!是否打开?", "提示", MessageBoxButtons.YesNo) == DialogResult.Yes) { - sw.Close(); - myStream.Close(); + System.Diagnostics.Process.Start(dlg.FileName); } } + catch (Exception ex) + { + MessageBox.Show(ex.ToString()); + } + finally + { + sw.Close(); + myStream.Close(); + } } - else - { - MessageBox.Show("统计结果为空,请重新统计之后再导出Excel!","提示"); - } + + } /// /// 绘制区域分段统计 diff --git a/MainFrm.cs b/MainFrm.cs index 0b7e393..9bfb70e 100644 --- a/MainFrm.cs +++ b/MainFrm.cs @@ -2667,12 +2667,195 @@ FrmBaseLineProfillAnalysis dlg = new FrmBaseLineProfillAnalysis(globeControl1.Globe, e.Polyline); dlg.Show(this); globeControl1.Globe.ClearLastTrackPolyline(); + /* + FrmRoadHDM f = new FrmRoadHDM(); + f.Show() + * **/ } else { } trackPolylineEndMode = EnumTrackPolylineEndMode.Default_Analysis; + /* + ArrayList arraylistPoint = new ArrayList(); + ArrayList arraylistLine = new ArrayList(); + + // globeControl1.Globe.ClearLastTrackPolyline(); + + if (e.Polyline != null) + { + //横断面分析 + if (buttonItemFX2_1.Checked || buttonItemFX2_3.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 (buttonItemFX2_1.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 (buttonItemFX2_4.Checked) + { + FrmBaseLineProfillAnalysis dlg = new FrmBaseLineProfillAnalysis(globeControl1.Globe, e.Polyline); + dlg.Show(this); + globeControl1.Globe.ClearLastTrackPolyline(); + } + else if (buttonItemFX4_3.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(); + * **/ } #endregion @@ -2713,16 +2896,20 @@ case "valvequery": FrmValveStatistics frm = new FrmValveStatistics(globeControl1,polygon, new DataGridViewDelegate(InitDataGridViewX1)); frm.Show(this); + //panelEx6.Visible = true; + toolStripFeatureLength.Text = ""; globeControl1.Globe.Action = EnumAction3D.ActionNull; break; case "PipelineDistanceStatistics": + FrmAllPipelineStatis frm1 = new FrmAllPipelineStatis(globeControl1, polygon, new DataGridViewDelegate(InitDataGridViewX1), m_PipelineLayerNames); frm1.Show(this); globeControl1.Globe.Action = EnumAction3D.ActionNull; break; case "PipelineSpatialQuery": + FrmAllPipelineStatis.ShowForm(globeControl1,polygon,new DataGridViewDelegate(InitDataGridViewX1),m_PipelineLayerNames); globeControl1.Globe.ClearAnalysis(); globeControl1.Globe.Action = EnumAction3D.ActionNull; @@ -2771,18 +2958,19 @@ break; case "BSQDuoBianXiangStatis": - GSOFeature f2 = new GSOFeature(); - f2.Geometry = e.Polygon; - f2.Geometry.AltitudeMode = EnumAltitudeMode.Absolute; - globeControl1.Globe.MemoryLayer.AddFeature(f2); - f2.Geometry.MoveZ(3); - workWellLen.Clear(); - List listBSQ = new List(); + //GSOFeature f2 = new GSOFeature(); + //f2.Geometry = e.Polygon; + //f2.Geometry.AltitudeMode = EnumAltitudeMode.Absolute; + //globeControl1.Globe.MemoryLayer.AddFeature(f2); + //f2.Geometry.MoveZ(3); + //workWellLen.Clear(); + //List listBSQ = new List(); - GSOFeatures bsqFeatures = PolygonIntersectAnalysis(e.Polygon, "标识器"); - listBSQ.Add(bsqFeatures); + //GSOFeatures bsqFeatures = PolygonIntersectAnalysis(e.Polygon, "标识器"); + //listBSQ.Add(bsqFeatures); - FrmBSQDuoBianXingStatis bsqFrm = new FrmBSQDuoBianXingStatis(workWellLen, globeControl1, listBSQ); + //FrmBSQDuoBianXingStatis bsqFrm = new FrmBSQDuoBianXingStatis(workWellLen, globeControl1, listBSQ); + FrmBSQStatis bsqFrm = new FrmBSQStatis(globeControl1,e.Polygon); bsqFrm.Show(this); globeControl1.Globe.Action = EnumAction3D.ActionNull; break; @@ -4351,6 +4539,26 @@ } /// + /// 在窗体的底部状态栏上显示 综合管线条件查询结果 + /// + /// + /// + 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 + " 条记录 | "; + } + } + + /// /// 统计管线的里程数 /// /// @@ -6824,6 +7032,54 @@ } /// + /// 创建label要素 功能 + /// + /// 添加label要素的feature + /// feature的位置 + /// label要素名字 + /// feature名字 + /// label要素距离点的位置 + /// + 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; + } + + + + /// /// 获取指定两点组成的线的长度 功能 /// /// @@ -9266,8 +9522,19 @@ //日志记录 LogManager.saveLog(Utility.userName, "管线长度统计"); + //pipeLineDis.Clear(); + //List list = new List(); + //for (int i = 0; i < m_PipelineLayerNames.Count; i++) + //{ + // GSOFeatures fs = Intersects_Pipeline(null, m_PipelineLayerNames[i]); + // if (fs!=null) + // list.Add(fs); + //} + + //FrmAllPipelineStatis frm = new FrmAllPipelineStatis(0, pipeLineDis, list, globeControl1, new DataGridViewDelegate(InitDataGridViewX1)); FrmAllPipelineStatis frm = new FrmAllPipelineStatis(globeControl1,null, new DataGridViewDelegate(InitDataGridViewX1), m_PipelineLayerNames); frm.Show(this); + } /// /// 管线长度绘制区域统计 @@ -9293,6 +9560,25 @@ //日志记录 LogManager.saveLog(Utility.userName, "阀门数量统计"); + //workWellLen.Clear(); + //List list = new List(); + ////找到所有阀门 + //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, globeControl1, new DataGridViewDelegate(InitDataGridViewX1)); FrmValveStatistics frm = new FrmValveStatistics(globeControl1, null, new DataGridViewDelegate(InitDataGridViewX1)); frm.Show(this); @@ -9318,9 +9604,7 @@ /// /// private void buttonItemTJ3_ALL_Click(object sender, EventArgs e) - { - //日志记录 - LogManager.saveLog(Utility.userName, "井盖数量统计"); + { FrmAllWorkWellStatis frm = new FrmAllWorkWellStatis(globeControl1, null, new DataGridViewDelegate(InitDataGridViewX1)); frm.Show(this); } @@ -9333,7 +9617,7 @@ { //日志记录 LogManager.saveLog(Utility.userName, "井盖数量统计"); - + trackflag = "workwellquery"; globeControl1.Globe.Action = EnumAction3D.TrackPolygon; globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; @@ -11142,7 +11426,7 @@ Cyberpipe.Forms.FrmPipelineModelDB frm = new Cyberpipe.Forms.FrmPipelineModelDB(globeControl1, ds); if (frm.ShowDialog() == DialogResult.OK) { - //addNodeToLayerManagerNode(frm.rukuLayer); + addNodeToLayerManagerNode(frm.rukuLayer); } } /// @@ -12377,7 +12661,8 @@ private void 标识器分类统计ToolStripMenuItem_Click(object sender, EventArgs e) { globeControl1.Globe.Action = EnumAction3D.ActionNull; - FrmBSQStatis bsqStatis = new FrmBSQStatis(); + FrmBSQStatis bsqStatis = new FrmBSQStatis(globeControl1,null); + //FrmBSQStatis bsqStatis = new FrmBSQStatis(); bsqStatis.Show(this); } /// diff --git a/MainFrm.cs.BACKUP.9016.cs b/MainFrm.cs.BACKUP.9016.cs new file mode 100644 index 0000000..28cb7fa --- /dev/null +++ b/MainFrm.cs.BACKUP.9016.cs @@ -0,0 +1,13074 @@ +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; + + GSOBalloon featureTooltip2; + GSOBalloonEx balloonEx2; + + GSOLayer layerTemp; + GSOLayer layerTemp2; + FrmShResult frmShResult = null; + FrmRedlineResult frmredResult = null; + FrmMnModify frmModify = null; + public bool frmRedlineResult = false; + public bool boolfrmShResult = false; + public bool boolfrmModify = false; + + List m_PipelineLayerNames = new List();//线图层名称 + List workwellLayerNames = new List();//工井图层名称 + List valueLayerNames = new List();//阀门图层名称 + List instrumenLayerNames = new List();//附属物图层名称 + List pipefittingLayerNames = new List();//管件图层名称 + List sgPipeLayersNames = new List();//施工管线图层名称 + 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 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; + public string redLayer = null; + //GSOLayer redLayer1 = null; + bool redSH = false; + string redDt = "红线"; + //双屏对比 + //bool zhanshi=false; + Thread t = null; + private GSOHudButton legendSC;//定义图例 + private GSOHudButton legendSG;//定义图例 + //管纵图 + private GSOHudButton lendendGZ50; + private GSOHudButton lendendGZ36; + private GSOHudButton lendendGZ42; + private GSOHudButton lendendGZ24_1; + private GSOHudButton lendendGZ24_2; + private GSOHudButton lendendGZ24_3; + private GSOHudButton lendendGZ26; + + GSOGeoPoint3D bsqPT; + + FrmYJSHTC frmSh = null;//一键审核窗口全局变量wxl + FrmWait frmWait = null;//一键审核等待窗口 + //FrmWait frmWait2 = null;//文档操作等待窗口 + + float mouseDownX1,mouseDownY1; + float mouseDownX2,mouseDownY2; + /// + /// + /// + 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; + + featureTooltip2 = new GSOBalloon(globeControl2.Handle); + balloonEx2 = new GSOBalloonEx(globeControl2.Handle); + Utility.SetBallons(featureTooltip, balloonEx); + + panelOfTable.Height = 200; + + RigthMenuSet(); + + MenuSet(); + + } + /// + /// 右屏中添加管纵图片 + /// + private void AddGZ() + { + + lendendGZ50 = new GSOHudButton(); + lendendGZ50.SetImage(Application.StartupPath + "/Resource/管纵/50.png"); + lendendGZ50.SetOffset(0, 0); + lendendGZ50.MinOpaque = 1; + lendendGZ50.MaxOpaque = 1; + lendendGZ50.FadeOut = false; + lendendGZ50.Name = "lendendGZ50"; + lendendGZ50.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ50); + lendendGZ50.Visible = false; + + lendendGZ36 = new GSOHudButton(); + lendendGZ36.SetImage(Application.StartupPath + "/Resource/管纵/36.png"); + lendendGZ36.SetOffset(0, 0); + lendendGZ36.MinOpaque = 1; + lendendGZ36.MaxOpaque = 1; + lendendGZ36.FadeOut = false; + lendendGZ36.Name = "lendendGZ36"; + lendendGZ36.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ36); + lendendGZ36.Visible = false; + + lendendGZ42 = new GSOHudButton(); + lendendGZ42.SetImage(Application.StartupPath + "/Resource/管纵/42.png"); + lendendGZ42.SetOffset(0, 0); + lendendGZ42.MinOpaque = 1; + lendendGZ42.MaxOpaque = 1; + lendendGZ42.FadeOut = false; + lendendGZ42.Name = "lendendGZ42"; + lendendGZ42.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ42); + lendendGZ42.Visible = false; + + lendendGZ24_1 = new GSOHudButton(); + lendendGZ24_1.SetImage(Application.StartupPath + "/Resource/管纵/24_1.png"); + lendendGZ24_1.SetOffset(0, 0); + lendendGZ24_1.MinOpaque = 1; + lendendGZ24_1.MaxOpaque = 1; + lendendGZ24_1.FadeOut = false; + lendendGZ24_1.Name = "lendendGZ24_1"; + lendendGZ24_1.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ24_1); + lendendGZ24_1.Visible = false; + + lendendGZ24_2 = new GSOHudButton(); + lendendGZ24_2.SetImage(Application.StartupPath + "/Resource/管纵/24_2.png"); + lendendGZ24_2.SetOffset(0, 0); + lendendGZ24_2.MinOpaque = 1; + lendendGZ24_2.MaxOpaque = 1; + lendendGZ24_2.FadeOut = false; + lendendGZ24_2.Name = "lendendGZ24_2"; + lendendGZ24_2.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ24_2); + lendendGZ24_2.Visible = false; + + lendendGZ24_3 = new GSOHudButton(); + lendendGZ24_3.SetImage(Application.StartupPath + "/Resource/管纵/24_3.png"); + lendendGZ24_3.SetOffset(0, 0); + lendendGZ24_3.MinOpaque = 1; + lendendGZ24_3.MaxOpaque = 1; + lendendGZ24_3.FadeOut = false; + lendendGZ24_3.Name = "lendendGZ24_3"; + lendendGZ24_3.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ24_3); + lendendGZ24_3.Visible = false; + + lendendGZ26 = new GSOHudButton(); + lendendGZ26.SetImage(Application.StartupPath + "/Resource/管纵/26.png"); + lendendGZ26.SetOffset(0, 0); + lendendGZ26.MinOpaque = 1; + lendendGZ26.MaxOpaque = 1; + lendendGZ26.FadeOut = false; + lendendGZ26.Name = "lendendGZ26"; + lendendGZ26.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ26); + lendendGZ26.Visible = false; + + } + + public void RigthMenuSet() + { + if (Utility.userRole.IndexOf("清除分析") < 0) + { + toolRightMenu.Items.Remove(清除分析ToolStripMenuItem); + } + + #region 区域分析 + if (Utility.userRole.IndexOf("区域分析") < 0) + { + toolRightMenu.Items.Remove(区域分析ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("缓冲区分析") < 0) + { + 区域分析ToolStripMenuItem.DropDownItems.Remove(缓冲区分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("附属物分析") < 0) + { + 区域分析ToolStripMenuItem.DropDownItems.Remove(附属物分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("无源淹没分析") < 0) + { + 区域分析ToolStripMenuItem.DropDownItems.Remove(无源淹没分析ToolStripMenuItem); + } + } + #endregion + + #region 视域分析 + if (Utility.userRole.IndexOf("视域分析") < 0) + { + toolRightMenu.Items.Remove(视域分析ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("通视分析") < 0) + { + 视域分析ToolStripMenuItem.DropDownItems.Remove(通视分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("可视域分析") < 0) + { + 视域分析ToolStripMenuItem.DropDownItems.Remove(可视域分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("可视包络分析") < 0) + { + 视域分析ToolStripMenuItem.DropDownItems.Remove(可视包络分析ToolStripMenuItem); + } + } + #endregion + + #region 开发分析 + if (Utility.userRole.IndexOf("开挖分析") < 0) + { + toolRightMenu.Items.Remove(开挖分析ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("多边形开挖") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(多边形开挖ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("挖方量分析") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(挖方量分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("沿线开挖") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(沿线开挖ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("创建隧道") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(创建隧道ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("隐藏隧道") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(隐藏隧道ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("删除隧道") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(删除隧道ToolStripMenuItem); + } + } + #endregion + + #region 拓扑分析 + if (Utility.userRole.IndexOf("拓扑分析") < 0) + { + toolRightMenu.Items.Remove(拓扑分析ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("创建拓扑") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(创建拓扑ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("上游分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(上游分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("下游分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(下游分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("流向分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(流向分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("关阀分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(关阀分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("连通分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(连通分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("爆管分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(爆管分析ToolStripMenuItem); + } + } + #endregion + + #region 断面分析 + if (Utility.userRole.IndexOf("断面分析") < 0) + { + toolRightMenu.Items.Remove(断面分析ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("横断面分析") < 0) + { + 断面分析ToolStripMenuItem.DropDownItems.Remove(横断面分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("纵断面分析") < 0) + { + 断面分析ToolStripMenuItem.DropDownItems.Remove(纵断面分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("道路断面分析") < 0) + { + 断面分析ToolStripMenuItem.DropDownItems.Remove(道路断面分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("基线剖面分析") < 0) + { + 断面分析ToolStripMenuItem.DropDownItems.Remove(基线剖面分析ToolStripMenuItem); + } + } + #endregion + + #region 绘制区域统计 + if (Utility.userRole.IndexOf("绘制区域统计") < 0) + { + toolRightMenu.Items.Remove(绘制区域统计ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("绘制区域管线长度统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管线长度统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域阀门数量统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(阀门数量统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域井盖数量统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(井盖数量统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域管径分段统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管径分段统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域埋深分段统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(埋深分段统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域管径分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管径分类统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域材质分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(材质分类统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域附属物分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(附属物分类统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域标识器分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(标识器分类统计ToolStripMenuItem1); + } + + } + #endregion + + #region 全区域统计 + if (Utility.userRole.IndexOf("全区域统计") < 0) + { + toolRightMenu.Items.Remove(全区域统计ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("全区域管线长度统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管线长度统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域阀门数量统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(阀门数量统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域井盖数量统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(井盖数量统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域管径分段统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管径分段统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域埋深分段统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(埋深分段统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域管径分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管径分类统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域材质分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(材质分类统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域附属物分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(附属物分类统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域标识器分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(标识器分类统计ToolStripMenuItem); + } + + } + #endregion + + #region 查询 + if (Utility.userRole.IndexOf("查询") < 0) + { + toolRightMenu.Items.Remove(查询ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("空间查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(空间查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("编号查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(编号查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("坐标查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(坐标查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("管径查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(管径查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("材质查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(材质查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("基本查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(基本查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("复合查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(复合查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("关联查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(关联查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("关键字查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(关键字查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("附属物查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(附属物查询ToolStripMenuItem); + } + } + #endregion + + #region 标注 + if (Utility.userRole.IndexOf("标注") < 0) + { + toolRightMenu.Items.Remove(标注ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("标高标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(标高标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("管径标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(管径标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("埋深标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(埋深标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("坐标标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(坐标标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("距离标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(距离标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("自定义标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(自定义标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("扯旗标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(扯旗标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("坡度标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(坡度标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("属性标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(属性标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("标注管理") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(标注管理ToolStripMenuItem); + } + } + #endregion + + #region 飞行 + if (Utility.userRole.IndexOf("飞行") < 0) + { + toolRightMenu.Items.Remove(飞行ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("自定义飞行") < 0) + { + 飞行ToolStripMenuItem.DropDownItems.Remove(自定义飞行ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("飞行到目标点") < 0) + { + 飞行ToolStripMenuItem.DropDownItems.Remove(飞行到目标点ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("绕中心点飞行") < 0) + { + 飞行ToolStripMenuItem.DropDownItems.Remove(绕中心点飞行ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("绕眼睛飞行") < 0) + { + 飞行ToolStripMenuItem.DropDownItems.Remove(绕眼睛飞行ToolStripMenuItem); + } + } + #endregion + + #region 编辑 + if (Utility.userRole.IndexOf("编辑") < 0) + { + toolRightMenu.Items.Remove(编辑ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("平移对象") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(平移对象ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("升降对象") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(升降对象ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("旋转对象") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(旋转对象ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("连接管段") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(连接管段ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("导出文件") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(导出文件ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("前进") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(前进ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("后退") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(删除模型ToolStripMenuItem); + } + } + #endregion + + #region 量算 + if (Utility.userRole.IndexOf("量算") < 0) + { + toolRightMenu.Items.Remove(量算ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("水平距离") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(水平距离ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("垂直距离") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(垂直距离ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("空间距离") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(空间距离ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("地表距离") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(地表距离ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("高度量算") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(高度量算ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("水平面积") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(水平面积ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("地表面积") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(地表面积ToolStripMenuItem1); + } + } + #endregion + } + + public void MenuSet() + { + + #region 权限管理 + if (Utility.userRole.IndexOf("权限管理") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem2); + } + else + { + + if (Utility.userRole.IndexOf("用户管理") < 0) + { + btn_user_info.Visible = false; + } + if (Utility.userRole.IndexOf("角色管理") < 0) + { + btn_role_info.Visible = false; + } + if (Utility.userRole.IndexOf("资源管理") < 0) + { + btn_resc_info.Visible = false; + } + if (Utility.userRole.IndexOf("角色授权") < 0) + { + btn_role_resc.Visible = false; + } + if (Utility.userRole.IndexOf("用户授权") < 0) + { + btn_user_role.Visible = false; + } + if (Utility.userRole.IndexOf("密码修改") < 0) + { + btn_password_edit.Visible = false; + } + + } + #endregion + + #region 基础工具 + if (Utility.userRole.IndexOf("基础工具") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem1); + } + else + { + if (Utility.userRole.IndexOf("地上模式") < 0) + { + buttonItem87.Visible = false; + } + if (Utility.userRole.IndexOf("地下模式") < 0) + { + buttonItem88.Visible = false; + } + if (Utility.userRole.IndexOf("行走模式") < 0) + { + buttonItem27.Visible = false; + } + if (Utility.userRole.IndexOf("透明度设置") < 0) + { + sliderGroundTransSet1.Visible = false; + } + if (Utility.userRole.IndexOf("快速定位") < 0) + { + buttonItem91.Visible = false; + } + if (Utility.userRole.IndexOf("图层管理") < 0) + { + buttonItem1.Visible = false; + } + if (Utility.userRole.IndexOf("图例管理") < 0) + { + btnlegendSet.Visible = false; + } + if (Utility.userRole.IndexOf("全屏显示") < 0) + { + buttonItem89.Visible = false; + } + if (Utility.userRole.IndexOf("导出图片") < 0) + { + btnOutputJPG.Visible = false; + } + + } + #endregion + + #region 一键审核 + if (Utility.userRole.IndexOf("一键审核") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem11); + } + #endregion + + #region 红线审核 + if (Utility.userRole.IndexOf("红线审核") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem6); + } + #endregion + + #region 双屏对比 + if (Utility.userRole.IndexOf("双屏对比") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem9); + } + #endregion + + #region 文档管理 + if (Utility.userRole.IndexOf("文档管理") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem4); + } + #endregion + + #region 基础管理 + if (Utility.userRole.IndexOf("基础管理") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem14); + } + else + { + if (Utility.userRole.IndexOf("专题图审批") < 0) + { + buttonItemZTT3_2.Visible = false; + } + if (Utility.userRole.IndexOf("打印审批") < 0) + { + buttonItemZTT4_2.Visible = false; + } + if (Utility.userRole.IndexOf("拷贝审批") < 0) + { + buttonItemZTT5_2.Visible = false; + } + } + + #endregion + + if (ribbonControl1.Items.Count <= 0) + { + ribbonControl1.Visible = false; + } + } + + #region Fan Zhang 重构现有代码 + //初始化控件布局 + private void initLayout() + { + 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.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.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.labelX21.Width = (int)(this.labelX21.Width * myScreen); + this.labelX22.Width = (int)(this.labelX22.Width * myScreen); + this.labelX24.Width = (int)(this.labelX24.Width * myScreen); + } + sideBar1.Visible = false; + 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]); + } + + splitContainer1.Panel2Collapsed = true; + + buttonItem87.Checked = true;//默认地上模式 + ribbonTabItem1.Select(); //初始化状态为浏览 + + sideBarPanelItem3.Visible = false; + layerTree.Visible = false; + controlContainerItem3.Visible = false; + if (sideBarPanelItem4.Visible == true) + { + sideBar1.Visible = true; + controlContainerItem5.Visible = true; + } + else + { + sideBar1.Visible = false; + } + Refresh(); + sliderGroundTransSet1.Value = optiValue; + sliderItem1.Value = optiValue; + sliderItem2.Value = optiValue; + sliderItem3.Value = optiValue; + + } + + //初始化地球控件 + private void initGlobalControl() + { + //选择 + btnToolSelect = new GSOHudButton(); + btnToolSelect.SetImage(Application.StartupPath + "\\Resource\\image\\select1.png"); + btnToolSelect.FadeOut = false; + btnToolSelect.Align = EnumAlign.TopLeft; + btnToolSelect.SetOffset(20, 50); + btnToolSelect.Name = "1"; + btnToolSelect.HeightFixed = true; + btnToolSelect.WidthFixed = true; + globeControl1.Globe.AddHudControl(btnToolSelect); + globeControl2.Globe.AddHudControl(btnToolSelect); + + //浏览 + 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); + + //图例 + legend = new GSOHudButton(); + legend.SetImage(Application.StartupPath + "/Resource/图例P.jpg");//图例P + legend.SetOffset(0, 15); + legend.MinOpaque = 1; + legend.MaxOpaque = 1; + legend.FadeOut = false; + legend.Name = "legend"; + legend.Align = EnumAlign.BottomRight; + legend.Visible = false; + globeControl1.Globe.AddHudControl(legend); + + //实测 + legendSC = new GSOHudButton(); + legendSC.SetImage(Application.StartupPath + "/Resource/sc.jpg"); + legendSC.SetOffset(0, 15); + legendSC.MinOpaque = 1; + legendSC.MaxOpaque = 1; + legendSC.FadeOut = false; + legendSC.Name = "legendSC"; + legendSC.Align = EnumAlign.BottomRight; + globeControl1.Globe.AddHudControl(legendSC); + legendSC.Visible = false; + + //施工 + legendSG = new GSOHudButton(); + legendSG.SetImage(Application.StartupPath + "/Resource/sg.jpg"); + legendSG.SetOffset(0, 15); + legendSG.MinOpaque = 1; + legendSG.MaxOpaque = 1; + legendSG.FadeOut = false; + legendSG.Name = "legendSG"; + legendSG.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(legendSG); + legendSG.Visible = false; + + //管纵 + AddGZ(); + + 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; + globeControl1.Globe.IsReleaseMemOutOfView = true; + globeControl1.Globe.ControlPanel.Visible = true; + + globeControl2.Globe.UnderGroundFloor.Visible = false; + globeControl2.Globe.OverviewControl.Visible = false; + globeControl2.Globe.ScalerControl.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; + globeControl2.Globe.IsReleaseMemOutOfView = true; + globeControl2.Globe.ControlPanel.Visible = false; + + 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); + + //添加临时图层 + layerTemp = globeControl1.Globe.Layers.Add(Application.StartupPath + "\\tempLgdData.lgd"); + layerTemp2 = globeControl2.Globe.Layers.Add(Application.StartupPath + "\\tempLgdData2.lgd"); + if (layerTemp != null) + { + layerTemp.MaxVisibleAltitude = 1000; + } + + //添加城市7线图层 + 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"); + + //注册对应事件 + this.registerEvent(); + } + + //注册地球事件 + private bool registerEvent() + { + if (globeControl1 == null || globeControl2 == null) + { + return false; + } + 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); + + globeControl2.FeatureMouseClickEvent += new FeatureMouseClickEventHandler(globeControl2_FeatureMouseClickEvent); + globeControl2.CameraBeginMoveEvent += new CameraBeginMoveEventHandler(globeControl2_CameraBeginMoveEvent); + + globeControl1.MouseDoubleClick += new MouseEventHandler(globeControl1_MouseDoubleClick); + globeControl1.MouseClick += new MouseEventHandler(globeControl1_MouseClick); + globeControl1.MouseDown += new MouseEventHandler(globeControl1_MouseDown); + + globeControl2.MouseClick += new MouseEventHandler(globeControl2_MouseClick); + globeControl2.MouseDown += new MouseEventHandler(globeControl2_MouseDown); + + 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); + + return true; + } + + //加载两个地球数据 + private void loadData() + { + Thread t1 = new Thread(new ThreadStart(doLoadDataForGlobalControl1)); + t1.IsBackground = true; + t1.Start(); + + + } + + delegate void LoadDataForGlobalControl(); + + private void connectServer() + { + globeControl1.Globe.ConnectServer(Utility.serverip, Utility.serverport, "", ""); //加载locaServer中的数据 + globeControl2.Globe.ConnectServer(Utility.serverip, Utility.serverport, "", ""); //加载locaServer中的数据 + //初始化TreeView + // 勾选实测图层 + foreach (TreeNode tn in layerTree.Nodes) + { + if (tn.Nodes.Count > 0) + { + if (tn.Text == "实测数据") + { + tn.Checked = true; + foreach (TreeNode tnChild in tn.Nodes) + { + tnChild.Checked = true; + foreach (TreeNode tnGrandChild in tnChild.Nodes) + { + tnGrandChild.Checked = true; + } + } + } + } + } + } + + private void doLoadDataForGlobalControl1() + { + try + { + + globeControl1.Globe.Layers.MoveDown(10000); + //加载实测管线数据 + Utility.dataSource = globeControl1.Globe.DataManager.OpenOracleDataSource(Utility.DBServer.Trim() + "/" + Utility.dbdatabase.Trim(), "", "", Utility.userID, Utility.DBPassword); + + if (Utility.dataSource != null) + { + for (int j = 0; j < Utility.dataSource.DatasetCount; j++) + { + GSODataset dataset = Utility.dataSource.GetDatasetAt(j); + if (dataset != null && dictionaryNetLayerNameAndCaption.ContainsKey(dataset.Caption)) + { + dataset.Caption = dataset.Name; + globeControl1.Globe.Layers.Add(dataset); + } + } + } + //隐藏红线图层 + globeControl1.Globe.Layers.GetLayerByCaption("红线").Visible = false; + + //globleControl1中加载规划数据 + GSODataSource ghDS = globeControl1.Globe.DataManager.OpenOracleDataSource(Utility.ghdbip + "/" + Utility.ghdbname, "", "", Utility.ghdbuser, Utility.ghdbpwd); + if (ghDS != null) + { + for (int j = 0; j < ghDS.DatasetCount; j++) + { + GSODataset dataset = ghDS.GetDatasetAt(j); + if (dataset != null && dictionaryNetLayerNameAndCaption.ContainsKey(dataset.Caption)) + { + dataset.Caption = dataset.Name; + globeControl1.Globe.Layers.Add(dataset); + globeControl1.Globe.Layers[0].Visible = false; + } + } + } + + //globeControl1,globeControl2中加载施工数据 + GSODataSource sgDS = globeControl1.Globe.DataManager.OpenOracleDataSource(Utility.sgdbip + "/" + Utility.sgdbname, "", "", Utility.sgdbuser, Utility.sgdbpwd); + if (sgDS != null) + { + for (int m = 0; m < sgDS.DatasetCount; m++) + { + GSODataset dataset = sgDS.GetDatasetAt(m); + if (dataset != null && !dataset.Caption.Contains("SH") && dictionaryNetLayerNameAndCaption.ContainsKey(dataset.Caption)) + { + dataset.Caption = dataset.Name; + globeControl1.Globe.Layers.Add(dataset); + globeControl1.Globe.Layers[0].Visible = false; + + globeControl2.Globe.Layers.Add(dataset); + globeControl2.Globe.Layers[0].Visible = true; + } + } + } + + LoadDataForGlobalControl ss = new LoadDataForGlobalControl(connectServer); + ss(); + + } + catch (Exception ex) + { + MessageBox.Show(ex.Message); + } + } + + private void initLayerTree() + { + //加载临时图层节点 + layerManagerNode = new TreeNode(); + layerManagerNode.ImageIndex = 0; + layerManagerNode.SelectedImageIndex = 0; + layerManagerNode.Checked = true; + layerManagerNode.Text = "临时图层"; + layerTree.Nodes.Add(layerManagerNode); + + XmlDocument doc = new XmlDocument(); + doc.Load(filename); + XmlNodeList xmlLayerNodes = doc.SelectNodes("//layer"); + + foreach (XmlNode xmlLayerNode in xmlLayerNodes) + { + + //TODO LIST:创建一级TreeNode(实测、规划、施工) + TreeNode nodelayer = new TreeNode(); + string layerName = xmlLayerNode.Attributes["label"].Value; + nodelayer.Text = layerName; + nodelayer.Checked = false; + layerTree.Nodes.Add(nodelayer); + + XmlNodeList xmlChildLayerNodes = xmlLayerNode.ChildNodes; + foreach (XmlNode xmlChildLayerNode in xmlChildLayerNodes) + { + //TODO LIST:创建二级TreeNode节点 + TreeNode secondLevelNode = new TreeNode(); + string layerType = xmlChildLayerNode.Attributes["label"].Value; + secondLevelNode.Text = layerType; + + if (xmlChildLayerNode.Attributes["type"] != null) + { //道路图层特殊处理 + string type = xmlChildLayerNode.Attributes["type"].Value; + secondLevelNode.Tag = type + "|" + layerType; + } + else + { + secondLevelNode.Tag = layerType; + } + secondLevelNode.Checked = false; + nodelayer.Nodes.Add(secondLevelNode); + + XmlNodeList xmlActitualLayerNodes = xmlChildLayerNode.ChildNodes; + + foreach (XmlNode xmlActitualLayerNode in xmlActitualLayerNodes) + { + //TODO LIST:创建三级图层节点 + TreeNode layerNode = new TreeNode(); + string actutallylayerType = xmlActitualLayerNode.Attributes["type"].Value; + string actutallylayerName = xmlActitualLayerNode.Attributes["layer"].Value; + string actutallyLabelName = xmlActitualLayerNode.Attributes["label"].Value; + + layerNode.Text = actutallyLabelName; + layerNode.Tag = layerType + "|" + actutallyLabelName; + layerNode.Checked = false; + secondLevelNode.Nodes.Add(layerNode); + } + + } + + } + + } + + /** + * 读取Config.xml文件,初始化以下全局Map + * m_PipelineLayerNames:管线 + * workwellLayerNames:工井 + * valueLayerNames:阀门 + * instrumenLayerNames:附属物 + * pipefittingLayerNames:特征管点 + * sgPipeLayersNames:施工管线 + **/ + private void initGlobalMap() + { + XmlDocument doc = new XmlDocument(); + doc.Load(filename); + XmlNodeList xmlLayerNodes = doc.SelectNodes("//layerchild"); + + foreach (XmlNode xmlLayerNode in xmlLayerNodes) + { + string layerType = xmlLayerNode.Attributes["type"].Value; + string layerName1 = xmlLayerNode.Attributes["layer"].Value; + string layerchildName = xmlLayerNode.Attributes["label"].Value; + + dictionaryNetLayerNameAndCaption.Add(layerName1, layerchildName); + + if (layerType != "db") + { + if (xmlLayerNode.Attributes["isRoad"] != null) + { + roadLayerName = layerchildName; + } + } + else if (xmlLayerNode.Attributes["isPipeLine"] != null) + { + m_PipelineLayerNames.Add(layerchildName); + g1layername.Add(layerName1); + } + else if (xmlLayerNode.Attributes["isWorkWell"] != null) + { + workwellLayerNames.Add(layerchildName); + g1layername.Add(layerName1); + } + else if (xmlLayerNode.Attributes["isValve"] != null) + { + valueLayerNames.Add(layerchildName); + g1layername.Add(layerName1); + } + else if (xmlLayerNode.Attributes["isAccess"] != null) + { + instrumenLayerNames.Add(layerchildName); + g1layername.Add(layerName1); + } + else if (xmlLayerNode.Attributes["isCharacter"] != null) + { + pipefittingLayerNames.Add(layerchildName); + g1layername.Add(layerName1); + } + else if (xmlLayerNode.Attributes["isSgData"] != null) + { + sgPipeLayersNames.Add(layerchildName); + g1layername.Add(layerName1); + } + + } + } + + private void initMarkerTree() + { + 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); + } + } + } + } + + private void MainFrm_Load(object sender, EventArgs e) + { + + this.initGlobalControl(); + this.initGlobalMap(); + this.initLayerTree(); + this.initMarkerTree(); + this.initLayout(); + this.loadData(); + + + double x = Convert.ToDouble(Utility.Query_Roads["绿岛"].ToString().Split(',')[0]); + double y = Convert.ToDouble(Utility.Query_Roads["绿岛"].ToString().Split(',')[1]); + double z = Convert.ToDouble(Utility.Query_Roads["绿岛"].ToString().Split(',')[2]); + jumpToCameraState(x, y, z); + + + } + + #endregion + + /// + /// 每次gis服务加载时都会触发的 + /// + /// + /// + 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 dictionaryNetLayerNameAndCaption = new Dictionary(); + 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 配置用户权限 + /// + /// 向数据库插入功能列表 + /// + private void insertControlToDatabase() + { + ArrayList listItem = new ArrayList(); + List subListItem = new List(); + 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) + { + GSOCameraState camera = globeControl2.Globe.CameraState; + globeControl1.Globe.JumpToCameraState(camera); + } + } + + void globeControl1_BeforeSceneRenderEvent(object sender, BeforeSceneRenderEventArgs e) + { + if (globeControl1.Focused) + { + 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); + } + } + } + + /// + /// 检查数据集是否有坐标系信息 + /// + /// + /// + 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 = "0prj4" + lprjStr + ""; + + bSuccess = dataset.LoadProjectionFromESRIFile(dlg.FileName); + + string lprjFileName = strDataPath.Substring(0, strDataPath.LastIndexOf(".")) + ".lprj"; + StreamWriter writer = new StreamWriter(lprjFileName, false); + writer.Write(lprjFileContent); + writer.Close(); + + } + } + } + else + { + return true; + } + return bSuccess; + } + + /// + /// 矩形拉框结束事件处理函数 + /// + /// + /// + 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))); + */ + + int mapWidth = 0; + int mapHeight = 0; + Point pt = getUpperLeftPoint(pt1, pt2, out mapWidth, out mapHeight); + int rightBottomX = pt.X + mapWidth; + int rightBottomY = pt.Y + mapHeight; + Image myImg = new Bitmap(mapWidth, mapHeight); + Graphics g = Graphics.FromImage(myImg); + g.CopyFromScreen(pt, new Point(0, 0), new Size(rightBottomX, rightBottomY)); + + 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; + } + } + /// + /// 定位正北正90度俯视 + /// + /// + /// + /// + 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; + } + } + /// + /// layerTree选中后事件处理 + /// + /// + /// + 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); + } + /// + /// 树节点选中方法 + /// + /// + 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); + } + } + } + + } + /// + /// 改变所有子节点的状态 + /// + /// + /// + 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; + LayerFlyMenuItem.Visible = true; + } + + LayerSelectableMenuItem.Visible = true; + LayerEditableMenuItem.Visible = true; + SaveLayerMenuItem.Visible = true; + LayerFlyMenuItem.Visible = true; + 导出CADToolStripMenuItem1.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]); + if (layer != null) + { + LayerSelectableMenuItem.Checked = layer.Selectable; + LayerEditableMenuItem.Checked = layer.Editable; + } + else + { + return; + } + } + 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; + } + } + } + } + } + + /// + /// 删除临时添加的本地数据图层 + /// + /// + /// + 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); + for (int i = globeControl1.Globe.Layers.Count-1; i >=0; i--) + { + if (globeControl1.Globe.Layers[i].Caption == layer.Caption) + { + globeControl1.Globe.Layers.Remove(globeControl1.Globe.Layers[i]); + } + } + + 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 定位ToolStripMenuItem_Click(object sender, EventArgs e) + { + TreeNode node = layerTree.SelectedNode; + + if (node != null) + { + if (node.Parent.Text.Trim() == "临时图层") + { + GSOLayer lsLayer = globeControl1.Globe.Layers.GetLayerByCaption(node.Text.ToString()); + double x = lsLayer.LatLonBounds.Center.X; + double y = lsLayer.LatLonBounds.Center.Y; + if (x == 0 && y == 0) + { + x = lsLayer.Bounds.Center.X; + y = lsLayer.Bounds.Center.Y; + } + + globeControl1.Globe.FlyToPosition(new GSOPoint3d(x, y, 10), EnumAltitudeMode.Absolute); + } + else + { + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(node.Tag.ToString().Split('|')[1]); + + if (layer != null) + { + if (layer.Caption == "红线") + { + globeControl1.Globe.FlyToPosition(new GSOPoint3d(120.610963, 31.188121, 50), EnumAltitudeMode.Absolute, -4, 50, 1000); + globeControl1.Globe.FlyToPointSpeed = 10000000; + globeControl1.Globe.Action = EnumAction3D.SelectObject; + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = true; + } + globeControl1.Refresh(); + } + else + { + double x = layer.LatLonBounds.Center.X; + double y = layer.LatLonBounds.Center.Y; + globeControl1.Globe.FlyToPosition(new GSOPoint3d(x, y, 100), EnumAltitudeMode.Absolute); + } + } + } + } + else + { + return; + } + + } + + private void layerTree_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e) + { + if(this.layerTree.SelectedNode!=null) + { + if (this.layerTree.SelectedNode.Tag.ToString().Contains("|")) + { + string nodeTag = this.layerTree.SelectedNode.Tag.ToString().Split('|')[1]; + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(nodeTag); + if (layer != null) + { + if (layer.Caption == "红线") + { + globeControl1.Globe.FlyToPosition(new GSOPoint3d(120.610963, 31.188121, 50), EnumAltitudeMode.Absolute, -4, 50, 1000); + globeControl1.Globe.FlyToPointSpeed = 10000000; + globeControl1.Globe.Action = EnumAction3D.SelectObject; + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = true; + } + globeControl1.Refresh(); + } + else { + double x = layer.LatLonBounds.Center.X; + double y = layer.LatLonBounds.Center.Y; + globeControl1.Globe.FlyToPosition(new GSOPoint3d(x, y, 0), EnumAltitudeMode.Absolute); + } + } + } + if (this.layerTree.SelectedNode.Tag is GSOLayer) + { + GSOLayer layer = this.layerTree.SelectedNode.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 (this.layerTree.SelectedNode.Tag is GSOFeature) + { + GSOFeature feature = this.layerTree.SelectedNode.Tag as GSOFeature; + if (feature.Geometry != null) + { + globeControl1.Globe.FlyToPosition(feature.Geometry.GeoCenterPoint, EnumAltitudeMode.Absolute, 0, 0, 10); + } + else + { + globeControl1.Globe.FlyToFeature(feature); + } + } + } + } + + /// + /// 在三维场景移动时,隐藏气泡globeControl1 + /// + /// + /// + void globeControl1_CameraBeginMoveEvent(object sender, CameraBeginMoveEventArgs e) + { + if (featureTooltip.IsVisible()) + { + featureTooltip.HideBalloon(); + } + if (balloonEx.IsVisible()) + { + balloonEx.HideBalloon(); + } + } + + /// + /// 在三维场景移动时,隐藏气泡globeControl2 + /// + /// + /// + void globeControl2_CameraBeginMoveEvent(object sender, CameraBeginMoveEventArgs e) + { + if (featureTooltip2.IsVisible()) + { + featureTooltip2.HideBalloon(); + } + if (balloonEx2.IsVisible()) + { + balloonEx2.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(); + } + } + + #region Fan 横断面 + /// + /// 横断面分析、基线剖面分析、道路断面分析等 + /// + /// + /// + private static EnumTrackPolylineEndMode trackPolylineEndMode; + + void globeControl1_TrackPolylineEndEvent(object sender, TrackPolylineEndEventArgs e) + { + //横断面分析、道路横断面分析 + if (trackPolylineEndMode == EnumTrackPolylineEndMode.HDM_Analysis|| + trackPolylineEndMode == EnumTrackPolylineEndMode.DLDM_Analysis) + { + Dictionary hdmDic = SectionAnalysisTool.HDMAnalysis(this.globeControl1, + e.Polyline, this.m_PipelineLayerNames); + FrmHDMAnalysis3 frm = new FrmHDMAnalysis3(hdmDic, this.globeControl1, + trackPolylineEndMode); + frm.Show(this); + } + //基线剖面分析 + else if (trackPolylineEndMode == EnumTrackPolylineEndMode.JXPM_Analysis) + { + FrmBaseLineProfillAnalysis dlg = new FrmBaseLineProfillAnalysis(globeControl1.Globe, e.Polyline); + dlg.Show(this); + globeControl1.Globe.ClearLastTrackPolyline(); + } + else + { + + } + trackPolylineEndMode = EnumTrackPolylineEndMode.Default_Analysis; + } + #endregion + + private GSOFeatures PolygonIntersectAnalysis(GSOGeoPolygon3D polygon, string pipelinetype) + { + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(pipelinetype); + 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(pipelinetype, feats.Length); + return feats; + } + /// + /// 根据范围统计阀门、管线、工井等, 开挖分析, 挖方量分析 + /// + /// + /// + void globeControl1_TrackPolygonEndEvent(object sender, TrackPolygonEndEventArgs e) + { + if (globeControl1.Globe.Action == EnumAction3D.TrackPolygon && e.Polygon != null) + { + GSOGeoPolygon3D polygon = e.Polygon; + + switch (trackflag) + { + case "valvequery": + FrmValveStatistics frm = new FrmValveStatistics(globeControl1,polygon, new DataGridViewDelegate(InitDataGridViewX1)); + frm.Show(this); + globeControl1.Globe.Action = EnumAction3D.ActionNull; + break; + + case "PipelineDistanceStatistics": +<<<<<<< HEAD +======= + +>>>>>>> d2d0088a6b3c53c1a96b7f1997f4d3443c0ee8c0 + FrmAllPipelineStatis frm1 = new FrmAllPipelineStatis(globeControl1, polygon, new DataGridViewDelegate(InitDataGridViewX1), m_PipelineLayerNames); + frm1.Show(this); + globeControl1.Globe.Action = EnumAction3D.ActionNull; + + break; + case "PipelineSpatialQuery": +<<<<<<< HEAD +======= + +>>>>>>> d2d0088a6b3c53c1a96b7f1997f4d3443c0ee8c0 + FrmAllPipelineStatis.ShowForm(globeControl1,polygon,new DataGridViewDelegate(InitDataGridViewX1),m_PipelineLayerNames); + globeControl1.Globe.ClearAnalysis(); + globeControl1.Globe.Action = EnumAction3D.ActionNull; + + break; + case "workwellquery": + FrmAllWorkWellStatis frmWell = new FrmAllWorkWellStatis(globeControl1, polygon, new DataGridViewDelegate(InitDataGridViewX1)); + 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 "BSQDuoBianXiangStatis": + + //GSOFeature f2 = new GSOFeature(); + //f2.Geometry = e.Polygon; + //f2.Geometry.AltitudeMode = EnumAltitudeMode.Absolute; + //globeControl1.Globe.MemoryLayer.AddFeature(f2); + //f2.Geometry.MoveZ(3); + //workWellLen.Clear(); + //List listBSQ = new List(); + + //GSOFeatures bsqFeatures = PolygonIntersectAnalysis(e.Polygon, "标识器"); + //listBSQ.Add(bsqFeatures); + + //FrmBSQDuoBianXingStatis bsqFrm = new FrmBSQDuoBianXingStatis(workWellLen, globeControl1, listBSQ); + FrmBSQStatis bsqFrm = new FrmBSQStatis(globeControl1,e.Polygon); + bsqFrm.Show(this); + globeControl1.Globe.Action = EnumAction3D.ActionNull; + break; + + case "": + break; + default: + break; + } + } + } + + #region 验证端口 + /* + /// + /// 验证端口 + /// + /// + 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 + + /// + /// 鼠标悬浮提示 + /// + /// + /// + 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); + } + } + + /// + /// 添加管线绘制完成事件, 红线工具绘制完成 + /// + /// + /// + 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; + + + } + } + + /// + /// 获取globeControl1中鼠标按下的坐标供区别鼠标右键和滚轮按下事件 + /// + /// + /// + void globeControl1_MouseDown(object sender, MouseEventArgs e) + { + mouseDownX1 = e.X; + mouseDownY1 = e.Y; + } + /// + /// 获取globeControl2中鼠标按下的坐标供区别鼠标右键和滚轮按下事件 + /// + /// + /// + void globeControl2_MouseDown(object sender, MouseEventArgs e) + { + mouseDownX2 = e.X; + mouseDownY2 = e.Y; + } + /// + /// + /// + /// + /// + void globeControl2_MouseClick(object sender, MouseEventArgs e) + { + if (e.Button == MouseButtons.Right) + { + if (e.X == mouseDownX2 && e.Y == mouseDownY2) + { + RightScreenToolMenu.Show(globeControl2, e.X, e.Y); + } + else + { + return; + } + } + } + /// + /// + /// + /// + /// + void globeControl1_MouseClick(object sender, MouseEventArgs e) + { + if (e.Button == MouseButtons.Left) + { + if (globeControl1.Globe.Action == EnumAction3D.VisibilityAnalysis) + { + buttonItemFX5_1.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; + + bsqPT = pt; + + if (buttonItemLS5.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 (e.X == mouseDownX1 && e.Y == mouseDownY1) + { + toolRightMenu.Show(globeControl1, e.X, e.Y); + if (buttonItemLS5.Checked) + { + buttonItemLS5.Checked = false; + } + } + else + { + return; + } + } + globeControl1.Refresh(); + } + + /// + /// 判断网络图片是否存在 + /// + /// + /// + 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; + } + + /// + /// 鼠标点击, 弹出气泡功能globeControl1 + /// + /// + /// + void globeControl1_FeatureMouseClickEvent(object sender, FeatureMouseClickEventArgs e) + { + GSOFeature feature = e.Feature; + + string str1 = ""; + if (feature != null) + { + if (feature.GetFieldDefn("图片编码") != null)// + { + str1 = GetBubbleInfo(feature, globeControl1); + if (RemoteFileExists(Utility.PicRootURL + feature.GetValue("图片编码").ToString())) + { + str1 += ""; + } + else if (RemoteFileExists(Utility.PicDefaultURL)) + { + str1 += ""; + } + } + else if (isFeatureContainsBianhao(feature)) //管线模型图层 + { + str1 = GetBubbleInfo(feature, globeControl1); + } + + 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; + } + } + } + + /// + /// 鼠标点击, 弹出气泡功能globeControl2 + /// + /// + /// + void globeControl2_FeatureMouseClickEvent(object sender, FeatureMouseClickEventArgs e) + { + GSOFeature feature = e.Feature; + + string str1 = ""; + if (feature != null) + { + if (feature.GetFieldDefn("图片编码") != null) // + { + str1 = GetBubbleInfo(feature, globeControl2); + if (RemoteFileExists(Utility.PicRootURL + feature.GetValue("图片编码").ToString())) + { + str1 += ""; + } + else if (RemoteFileExists(Utility.PicDefaultURL)) + { + str1 += ""; + } + } + else if (isFeatureContainsBianhao(feature)) //管线模型图层 + { + str1 = GetBubbleInfo(feature, globeControl2); + } + + if (str1 != "") + { + + featureTooltip2.HideBalloon(); + balloonEx2.HideBalloon(); + balloonEx2.SetSize(EnumSizeIndexEx.CONTENT_CX, 480); + balloonEx2.SetSize(EnumSizeIndexEx.CONTENT_CY, 420); + balloonEx2.ShowBalloon((int)e.MousePos.X, (int)e.MousePos.Y, str1); + + return; + } + } + } + + /// + /// 拼接气泡表格字符串 + /// + /// + /// + private string GetBubbleInfo(GSOFeature feature,GSOGlobeControl globeControl) + { + if (feature == null) + { + return ""; + } + string str = ""; + str = ""; + 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 += ""; + + 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.get_Fields(layerName, globeControl); + } + if (queryFields != null) + { + string[] param = { "," }; + string[] fieldNames = queryFields.Split(param, StringSplitOptions.RemoveEmptyEntries); + for (int j = 0; j < fieldNames.Length; 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 (name1 == "模型路径") + { + continue; + } + 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 (field1.Type == EnumFieldType.Double) + { + double dl1 = feature.GetFieldAsDouble(j); + if (!name1.Contains("管径") && !name1.Contains("电压") && !name1.Contains("角度")) + { + name1 += "_米"; + } + value1 = dl1.ToString("0.00"); + } + 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 (name2 == "模型路径") + { + continue; + } + + 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 (field2.Type == EnumFieldType.Double) + { + double dl2 = feature.GetFieldAsDouble(j + 1); + if (!name2.Contains("管径") && !name2.Contains("电压") && !name2.Contains("角度")) + { + name2 += "_米"; + } + value2 = dl2.ToString("0.00"); + } + else + { + if (!feature.IsFieldValueNull(j + 1)) + { + value2 = feature.GetValue(j + 1).ToString(); + } + } + } + } + + j++; + } + str += ""; + } + } + str += "
" + title + " " + feature.GetFieldAsString(featureIDFieldName) + "
" + + name1 + + "
" + + value1 + + "
" + + name2 + + "
" + + value2 + "
"; + return str; + } + + string filename = Utility.filename; + List g1layername = new List(); + + /// + /// 获取目标图层 + /// + /// + 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; + } + /// + /// 添加图层 + /// + /// + /// + /// + 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 = 5000; + return templayer.Visible; + } + catch (Exception ex) + { + return false; + } + } + /// + /// 菜单上的 三维导航 工具按钮 + /// + /// + /// + private void buttonItem86_Click(object sender, EventArgs e) + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + } + + /// + /// 地上模式 菜单按钮 + /// + /// + /// + 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(); + + } + } + /// + /// 地下模式 菜单按钮 + /// + /// + /// + 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(); + } + } + /// + /// 行走模式 菜单按钮 + /// + /// + /// + 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; + } + } + /// + /// 地面透明度设置 菜单 + /// + /// + /// + private void sliderGroundTransSet1_ValueChanged(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.sliderGroundTransSet1.Text); + + globeControl1.Globe.GroundOpaque = 100 - sliderGroundTransSet1.Value; + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(roadLayerName);//("180fd"); + if (layer != null) + { + layer.Opaque = 100 - sliderGroundTransSet1.Value; + } + //if (buttonItemSPDB.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; + } + /// + /// 图例 菜单按钮 + /// + /// + /// + 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(); + } + /// + /// 快速定位 菜单按钮 + /// + /// + /// + private void buttonItem91_Click(object sender, EventArgs e) // + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItem91.Text); + FrmFlyToPosition fly = new FrmFlyToPosition(globeControl1); + fly.Show(this); + } + /// + /// 图层管理 菜单按钮 + /// + /// + /// + 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; + + //修改图层管理与标注管理、覆土审查、水平净距分析、垂直净距分析和碰撞分析控件之间的逻辑关系 + controlContainerItem5.Visible = false; + sideBar1.Visible = false; + sideBarPanelItem4.Visible = false; + panel3.Visible = false; + sideBar1.ExpandedPanel = sideBarPanelItem3; + buttonItemBZ11.Checked = false; + + //20160624 + /* + if (sideBarPanelItem4.Visible == true) + { + sideBar1.Visible = true; + controlContainerItem5.Visible = true; + } + else + { + sideBar1.Visible = false; + } + */ + Refresh(); + + } + } + /// + /// 全屏显示 菜单按钮 + /// + /// + /// + 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; + /// + /// 全屏显示功能实现 + /// + 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(); + } + } + + /// + /// 设置窗体宽、高 + /// + /// + /// + private void SetFullScreen(int width, int height) + { + this.Width = width; + this.Height = height; + } + + /// + /// 全屏功能的快捷键F5 + /// + /// + /// + 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); + } + } + /* + /// + /// 输出地图 + /// + /// + /// + /// + 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; + } + * */ + + private Point getUpperLeftPoint(Point p1, Point p2, out int mapWidth, out int mapHeight) // + { + Rectangle rc = new Rectangle(); + + p1 = this.globeControl1.PointToScreen(p1); + p2 = this.globeControl1.PointToScreen(p2); + + int x = Screen.PrimaryScreen.Bounds.X; + int y = Screen.PrimaryScreen.Bounds.Y; + int screenWidth = SystemInformation.WorkingArea.Width; + int screenHeight = SystemInformation.WorkingArea.Height; + + if (p1.X < x) + rc.X = x; + else + rc.X = p1.X; + + if (p1.Y < y) + rc.Y = y; + else + rc.Y = p1.Y; + + p1.X = rc.Left; + p1.Y = rc.Top; + + if (p2.X > screenWidth) + p2.X = screenWidth; + else + p2.X = p2.X; + + if (p2.Y > screenHeight) + p2.Y = screenHeight; + else + p2.Y = p2.Y; + + rc.Width = p2.X - rc.X; + rc.Height = p2.Y - rc.Y; + + mapWidth = rc.Width; + mapHeight = rc.Height; + Point pt = new Point(rc.Left, rc.Top); + return pt; + } + + Image printImage; + /// + /// 打印 菜单 + /// + /// + /// + 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))); + */ + int mapWidth = 0; + int mapHeight = 0; + Point pt = getUpperLeftPoint(pt1, pt2, out mapWidth, out mapHeight); + int rightBottomX = pt.X + mapWidth; + int rightBottomY = pt.Y + mapHeight; + Image myImg = new Bitmap(mapWidth, mapHeight); + Graphics g = Graphics.FromImage(myImg); + g.CopyFromScreen(pt, new Point(0, 0), new Size(rightBottomX, rightBottomY)); + + + 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); + } + /// + /// 输出地图 菜单 + /// + /// + /// + private void btnOutputJPG_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btnOutputJPG.Text); + + //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))); + */ + int mapWidth = 0; + int mapHeight = 0; + Point pt = getUpperLeftPoint(pt1, pt2, out mapWidth, out mapHeight); + int rightBottomX = pt.X + mapWidth; + int rightBottomY = pt.Y + mapHeight; + Image myImg = new Bitmap(mapWidth, mapHeight); + Graphics g = Graphics.FromImage(myImg); + g.CopyFromScreen(pt, new Point(0, 0), new Size(rightBottomX, rightBottomY)); + + 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; + } + } + } + + /// + /// 统计管线的里程数 + /// + /// + /// + /// + 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; + } + + /// + /// 窗体下方属性表格 右键菜单中的 “定位”菜单 + /// + /// + /// + 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); + + } + + /// + /// 表格中右键 “单个闪烁” 菜单 + /// + /// + /// + private void LightMenu_Click(object sender, EventArgs e) + { + flashflag = "single"; + timer1.Start(); + } + /// + /// 表格中右键 “全部闪烁” 菜单 + /// + /// + /// + private void AllLightMenuItem_Click(object sender, EventArgs e) + { + flashflag = "all"; + timer1.Start(); + } + + /// + /// 使用timer实现管线的闪烁效果 + /// + /// + /// + 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; + } + } + + /// + /// 绘制线 菜单 + /// + /// + /// + private void btnAddLine_Click(object sender, EventArgs e) + { + globeControl1.Globe.DestLayerFeatureAdd = globeControl1.Globe.MemoryLayer; + globeControl1.Globe.Action = EnumAction3D.DrawPolyline; + } + /// + /// 绘制面 菜单 + /// + /// + /// + private void btnAddPolygon_Click(object sender, EventArgs e) + { + globeControl1.Globe.DestLayerFeatureAdd = globeControl1.Globe.MemoryLayer; + globeControl1.Globe.Action = EnumAction3D.DrawPolygon; + } + /// + /// 图层目录树 右键菜单中的 目标图层 菜单 + /// + /// + /// + 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; + } + } + /// + /// 图层目录树 右键菜单中的 可选择 菜单 + /// + /// + /// + 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; + } + /// + /// 图层目录树 右键菜单中的 可编辑 菜单 + /// + /// + /// + 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; + } + /// + /// 图层目录树 右键菜单中的 保存 菜单 + /// + /// + /// + 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(); + } + + /// + /// 根据多边形范围统计管线的里程 + /// + /// + /// + /// 返回查询到的管线要素集合 + 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 pipeLineDis = new Dictionary(); + Dictionary workWellLen = new Dictionary(); + + + + + /// + /// 查找指定图层中在 指定范围内的feature对象集合 + /// + /// + /// + /// + 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; + } + /// + /// 清除结果 菜单 + /// + /// + /// + private void buttonItem47_Click(object sender, EventArgs e) + { + globeControl1.Globe.ClearAnalysis(); + dataGridViewX1.DataSource = null; + panelOfTable.Visible = false; + clearFeatureHighLight(); + } + /// + /// 设置菜单的选中状态 + /// + private void ActionToolMenuChecked() + { + if (globeControl1.Globe.Action != EnumAction3D.TrackPolyline) + { + buttonItemFX2_1.Checked = false; + buttonItemFX2_4.Checked = false; + buttonItemFX2_3.Checked = false; + buttonItemFX4_3.Checked = false; + } + if (globeControl1.Globe.Action != EnumAction3D.NormalHit) + { + buttonItemFX3_6.Checked = false; + // ClearConnexityAnalysis(); + + buttonItemFX3_5.Checked = false; + // ClearCloseValvesAnalysis(); + } + if (globeControl1.Globe.Action != EnumAction3D.TrackPolygon) + { + buttonItemFX4_2.Checked = false; + buttonItemFX4_1.Checked = false; + } + } + + /// + /// 主窗体关闭事件处理 + /// + /// + /// + private void MainFrm_FormClosing(object sender, FormClosingEventArgs e) + { + + if (MessageBox.Show("是否退出系统?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) + { + e.Cancel = true; + } + else { + globeControl1.Globe.MemoryLayer.SaveAs(Application.StartupPath + "/MyPlace.kml"); + } + + //saveLayerList(layerManagerNode.Nodes); + //注销id号为103的热键设定 + // UnregisterHotKey(Handle, 103); + } + + /// + /// 显示流向 功能 + /// + /// + /// + /// + 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(); + } + + FrmCloseValves frm; + + FrmBoosterValvers frmbooster = null; + + /// + /// 垂直净距分析 功能界面中的 选择图层复选框 选中状态改变事件处理 + /// + /// + /// + 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(); + } + /// + /// 水平净距分析 功能界面中的 选择图层复选框 选中状态改变事件处理 + /// + /// + /// + 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(); + } + /// + /// 垂直净距分析 功能界面中的 选择管线复选框 选中状态改变事件处理 + /// + /// + /// + private void checkBoxX1_CheckedChanged(object sender, EventArgs e) + { + clearFeatureHighLight(); + if (checkBoxX1.Checked) + { + comboBoxEx1.SelectedItem = null; + 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; + } + } + /// + /// 水平净距分析 功能界面中的 选择管线复选框 选中状态改变事件处理 + /// + /// + /// + private void checkBoxX1_CheckedChanged_shuiping(object sender, EventArgs e) + { + clearFeatureHighLight();//清除高亮 + if (checkBoxX7.Checked) + { + comboBoxEx4.SelectedItem = null; + 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(); + /// + /// 垂直净距分析 功能界面中的 选择图层下拉框 选中项改变 事件处理 + /// + /// + /// + 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; + } + } + } + /// + /// 水平净距分析 功能界面中的 选择图层下拉框 选中项改变 事件处理 + /// + /// + /// + 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 featCount = new Dictionary(); + Dictionary featLenth = new Dictionary(); + Dictionary m_FeaturesWithBianhao = new Dictionary();//记录编号和对应的标注点的位置 + GSOFeatures polygonJingJuAnalysises = new GSOFeatures(); + + /// + /// 垂直净距分析 功能界面中的 开始分析按钮 事件处理 + /// + /// + /// + 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; + } + + /// + /// 在指定的两点组成的线的中间添加一个marker对象,并将marker对象添加到指定的图层中 + /// + /// + /// + /// + /// + /// + 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; + } + + /// + /// 计算指定feature对象与除了该feature所在图层之外的 所有管线图层中的所有feature对象 的垂直距离 并在表格中记录符合要求的管线 + /// + /// + /// + /// + /// + private void VerticalDistanceAnalysis(string type, GSOFeature selectedFeature, List _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(); + } + /// + /// 垂直净距分析中 表格行的 双击定位 功能。 与覆土分析的实现方法不同,主要原因是需要标注垂距 + /// + /// + /// + 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); + } + } + } + } + + /// + /// 水平净距分析 功能界面中 开始分析按钮 的事件处理 + /// + /// + /// + 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; + } + + + /// + /// 计算指定feature对象与除了该feature所在图层之外的 所有管线图层中的所有feature对象 的水平距离 并记录符合要求的管线 功能 + /// + /// + /// + /// + /// + private void HorizontalDistanceAnalysis(GSOFeature selectedFeature, List _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)); + } + } + } + } + } + /// + /// 水平净距分析 功能界面中 表格的 双击定位 功能 + /// + /// + /// + 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); + } + } + } + } + } + /// + /// 碰撞分析 功能界面中 开始分析按钮 事件处理 + /// + /// + /// + 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; + } + /// + /// 碰撞分析功能界面中 表格的 双击定位 功能 + /// + /// + /// + 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); + } + } + } + } + + + + /// + /// 覆土分析功能操作界面中的 选择管线 复选框选中状态改变事件处理 + /// + /// + /// + private void checkBoxX5_CheckedChanged(object sender, EventArgs e) + { + clearFeatureHighLight(); + if (checkBoxX5.Checked) + { + comboBoxEx3.SelectedItem = null; + 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; + } + } + /// + /// 覆土分析功能操作界面中的 选择图层 复选框选中状态改变事件处理 + /// + /// + /// + 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(); + } + /// + /// 覆土分析功能操作界面中的 图层下拉框选中项改变事件处理 + /// + /// + /// + 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; + } + } + } + /// + /// 覆土分析功能操作界面中的 开始分析 按钮事件处理 + /// + /// + /// + 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; + + + GSOPoint3d markerPosition = new GSOPoint3d(); + 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]; + GSOPoint3d pt = new GSOPoint3d(); + + 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"); + + pt.X = pts[m].X; + pt.Y = pts[m].Y; + pt.Z = 0; + markerPosition = LabelVerticalDistance(layerTemp, pts[m], pt, Convert.ToDouble(dataGridViewX7.Rows[idx].Cells[2].Value), true); + 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]; + GSOPoint3d pt = new GSOPoint3d(); + 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"); + + pt.X = pts[m].X; + pt.Y = pts[m].Y; + pt.Z = 0; + markerPosition = LabelVerticalDistance(layerTemp, pts[m], pt, Convert.ToDouble(dataGridViewX7.Rows[idx].Cells[2].Value), true); + + 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; + } + + /// + /// 覆土分析中 表格的 双击定位 功能 + /// + /// + /// + 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); + } + } + } + } + } + /// + /// 覆土分析功能操作界面中的 导出Excel按钮 事件处理 + /// + /// + /// + private void buttonX10_Click(object sender, EventArgs e) + { + if (dataGridViewX7.Rows.Count > 0) + { + ExportExcel("覆土分析", dataGridViewX7, null); + } + else + { + MessageBox.Show("表格内容为空!", "提示"); + } + } + /// + /// 覆土分析功能操作界面底部的 关闭 按钮事件处理 + /// + /// + /// + 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(); + layerTemp.RemoveAllFeature(); + + if (buttonItem1.Checked) + { + sideBar1.ExpandedPanel = sideBarPanelItem3; + } + else + { + sideBar1.Visible = false; + } + globeControl1.Refresh(); + + //Refresh(); + } + + + /// + /// 垂直净距分析 功能界面中 清除分析结果按钮 事件处理 + /// + /// + /// + 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(); + } + /// + /// 水平净距分析 功能界面中 清除分析结果按钮 事件处理 + /// + /// + /// + 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(); + } + + /// + /// 垂直净距分析功能界面中 关闭按钮 事件处理 + /// + /// + /// + 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(); + } + /// + /// 水平净距分析功能界面中 删除缓冲区按钮 事件处理 + /// + /// + /// + private void buttonX14_Click(object sender, EventArgs e) + { + 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(); + } + + /// + /// 导出指定DataGridView控件中的内容 + /// + /// + /// + 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(); + } + } + } + } + + /// + /// 垂直净距分析功能界面中 导出Excel按钮 事件处理 + /// + /// + /// + private void buttonX4_Click(object sender, EventArgs e) + { + if (dataGridViewX3.Rows.Count > 0) + { + ExportExcel("垂直净距分析", dataGridViewX3, listBox1); + } + else + { + MessageBox.Show("表格内容为空!", "提示"); + } + } + /// + /// 水平净距分析功能界面中 导出Excel按钮 事件处理 + /// + /// + /// + private void buttonX4_Click_shuiping(object sender, EventArgs e) + { + if (dataGridViewX9.Rows.Count > 0) + { + ExportExcel("水平净距分析", dataGridViewX9, listBox3); + } + else + { + MessageBox.Show("表格内容为空!", "提示"); + } + } + + + /// + /// 清除所有坑 菜单 + /// + /// + /// + private void buttonItem3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItem3.Text); + + globeControl1.Globe.RemoveAllPits(); + } + + //} + /// + /// 大气层 菜单 + /// + /// + /// + private void buttonItem17_Click_1(object sender, EventArgs e) + { + globeControl1.Globe.Atmosphere.Visible = !globeControl1.Globe.Atmosphere.Visible; + buttonItemSH1.Checked = globeControl1.Globe.Atmosphere.Visible; + globeControl1.Refresh(); + } + /// + /// 经纬网 菜单 + /// + /// + /// + private void buttonItem20_Click(object sender, EventArgs e) + { + globeControl1.Globe.LatLonGrid.Visible = !globeControl1.Globe.LatLonGrid.Visible; + buttonItemSH3.Checked = globeControl1.Globe.LatLonGrid.Visible; + globeControl1.Globe.Refresh(); + } + /// + /// 状态条 菜单 + /// + /// + /// + private void buttonItem21_Click_1(object sender, EventArgs e) + { + globeControl1.Globe.StatusBar.Visible = !globeControl1.Globe.StatusBar.Visible; + buttonItemSH4.Checked = globeControl1.Globe.StatusBar.Visible; + globeControl1.Globe.Refresh(); + } + + + + /// + /// 添加指定路径下的数据 功能 + /// + /// + /// + 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); + //CheckDatasetGeoReference(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; + } + return objRes; + } + /// + /// 刷新目录树 功能 + /// + 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); + } + } + /// + /// 判断图层是否包含字段列表 + /// + /// + /// + 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; + } + + /// + /// 统计指定图层在指定范围内的所有feature对象 + /// + /// + /// + /// + 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; + } + /// + /// 碰撞分析功能界面中 选择管线复选框 选中状态改变事件处理 + /// + /// + /// + private void checkBoxX3_CheckedChanged(object sender, EventArgs e) + { + clearFeatureHighLight(); + if (checkBoxX3.Checked) + { + comboBoxEx2.SelectedItem = null; + 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; + } + } + /// + /// 碰撞分析功能界面中 选择图层复选框 选中状态改变事件处理 + /// + /// + /// + 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(); + } + /// + /// 碰撞分析功能界面中 选择图层下拉框 选中项改变事件处理 + /// + /// + /// + 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; + } + } + } + /// + /// 清除所有图层中的所有feature对象的高亮状态 功能 + /// + 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); + } + } + } + } + for (int i = 0; i < globeControl2.Globe.Layers.Count; i++) + { + GSOLayer layer = globeControl2.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; + } + } + } + + if (globeControl1.Globe.Action == EnumAction3D.SelectObject) + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + //globeControl1.Globe.Action = EnumAction3D.SelectObject; + } + } + + /// + /// 碰撞分析功能界面中 清除分析结果按钮 事件处理 + /// + /// + /// + 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(); + } + /// + /// 碰撞分析功能界面中 导出Excel按钮 事件处理 + /// + /// + /// + private void buttonX6_Click(object sender, EventArgs e) + { + if (dataGridViewX5.Rows.Count > 0) + { + ExportExcel("碰撞分析", dataGridViewX5, listBox2); + } + else + { + MessageBox.Show("表格内容为空!", "提示"); + } + } + /// + /// 导出CAD 菜单 + /// + /// + /// + private void btnExportCAD_Click(object sender, EventArgs e) + { + FrmExportCADS frm = new FrmExportCADS(globeControl1, m_PipelineLayerNames); + frm.ShowDialog(); + } + + ///// + ///// 区域分析 菜单 + ///// + ///// + ///// + //private void buttonItem50_Click(object sender, EventArgs e) + //{ + // buttonItem50.Checked = !buttonItem50.Checked; + // ribbonBarQY.Visible = buttonItem50.Checked; + // ribbonBarQY.Location = new Point(0, 0); + //} + + + /// + /// 连接数据库 菜单事件处理 + /// + /// + /// + 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; + } + } + } + /// + /// 数据验证 菜单 + /// + /// + /// + private void buttonItem80_Click(object sender, EventArgs e) + { + FrmValiData frm = new FrmValiData(globeControl1); + frm.ShowDialog(); + } + /// + /// 根据指定图层创建图层节点并将节点添加到图层管理节点的子节点集合中 + /// + /// + 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; + + if (!layerManagerNode.Nodes.Contains(node)) + { + layerManagerNode.Nodes.Insert(0, node); + layerManagerNode.Expand(); + } + } + } + /// + /// 数据库备份 菜单 + /// + /// + /// + 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(); + } + } + } + + + + #region Fan 去掉 + //GSOFeature emitterFeature; // 粒子要素 + /// + /// 添加火苗 功能 + /// + /// + /// + /// + 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); + + } + /// + /// 添加喷泉 功能 + /// + /// + /// + /// + 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); + } + #endregion + + /// + /// 获取指定图层中最后一个feature对象的名称对应的整数 + /// + /// + /// + 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; + } + /// + /// 设置除指定标注图层之外的所有标注图层不可见 + /// + /// + 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; + } + } + } + } + } + + /// + /// 判断选中的对象是否为管线 + /// + /// 被选中管线 + /// 返回一根线 + 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; + } + + /// + /// 获取指定两点组成的线的长度 功能 + /// + /// + /// + /// + 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; + } + + /// + /// 图层节点树中 节点 右键单击事件处理 + /// + /// + /// + 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; + } + } + } + } + } + + /// + /// 标注管理、传感器管理 图层目录树的右键菜单中的 刷新列表 菜单 + /// + /// + /// + 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); + } + } + /// + /// 给指定的图层节点添加代表feature对象的子节点 + /// + /// + private void RefreshTreeNodeLayerFeatureList(TreeNode layerTreeNode) + { + layerTreeNode.Nodes.Clear(); + GSOLayer layer = (GSOLayer)layerTreeNode.Tag; + // 只将类型为内存数据集的图层列出,如果是其它类型的数据集可能数据量太大,没发显示在树控件中 + if (layer.Dataset is GSOFeatureDataset) + { + VisitFeature3Ds(layer.GetAllFeatures(), layerTreeNode); + } + } + + /// + /// 标注管理、传感器管理 图层目录树的右键菜单中的 移除所有 菜单 + /// + /// + /// + 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(); + } + } + + /// + /// 图层目录树的 节点对应的复选框选中状态改变事件处理 + /// + /// + /// + private void layerMarkerTree_AfterCheck(object sender, TreeViewEventArgs e) + { + if (e.Action != TreeViewAction.Unknown) + { + CheckTreeNode(e.Node, e.Node.Checked); + } + } + /// + /// 改变指定节点对应的复选框的选中状态 + /// + /// + /// + private void CheckTreeNode(TreeNode node, Boolean bChecked) + { + CheckChildTreeNode(node, bChecked); + globeControl1.Globe.Refresh(); + } + /// + /// 改变指定节点的子节点对应的复选框的选中状态 + /// + /// + /// + 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); + } + } + /// + /// 标注管理、传感器管理 目录树中的feature节点的右键菜单中的 删除 菜单 + /// + /// + /// + 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(); + } + } + + /// + /// 双屏对比 菜单 + /// + /// + /// + //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(); + // } + //} + /// + /// 模拟分析 菜单 + /// + /// + /// + //private void buttonItem51_Click(object sender, EventArgs e) + //{ + // buttonItem51.Checked = !buttonItem51.Checked; + // ribbonBarMN.Visible = buttonItem51.Checked; + // ribbonBarMN.Location = new Point(0, 0); + //} + + /// + /// 双屏设置 菜单 + /// + /// + /// + //private void buttonItem96_Click(object sender, EventArgs e) + //{ + // FrmLayerControl frm = new FrmLayerControl(layerTree,globeControl1,globeControl2); + // frm.Show(this); + //} + /// + /// 双屏联动 菜单 + /// + /// + /// + //private void buttonItem95_Click(object sender, EventArgs e) + //{ + // buttonItem95.Checked = !buttonItem95.Checked; + //} + ///// + /// 添加用户仓库 菜单 + /// + /// + /// + private void buttonItem108_Click(object sender, EventArgs e) + { + FrmUserRepo frm = new FrmUserRepo(-1); + frm.ShowDialog(); + } + /// + /// 用户仓库管理 菜单 + /// + /// + /// + private void buttonItem111_Click(object sender, EventArgs e) + { + FrmUserRepoMgr frm = new FrmUserRepoMgr(); + frm.ShowDialog(); + } + /// + /// 添加分系统 菜单 + /// + /// + /// + private void buttonItem112_Click(object sender, EventArgs e) + { + //FrmAPP frm = new FrmAPP(-1); + //frm.ShowDialog(); + } + /// + /// 分系统管理 菜单 + /// + /// + /// + private void buttonItem113_Click(object sender, EventArgs e) + { + //FrmAPPMgr frm = new FrmAPPMgr(); + //frm.ShowDialog(); + } + /// + /// 添加操作 菜单 + /// + /// + /// + private void buttonItem114_Click(object sender, EventArgs e) + { + FrmOper frm = new FrmOper(-1); + frm.ShowDialog(); + } + /// + /// 操作管理 菜单 + /// + /// + /// + private void buttonItem115_Click(object sender, EventArgs e) + { + FrmOperMgr frm = new FrmOperMgr(); + frm.ShowDialog(); + } + /// + /// 添加资源 菜单 + /// + /// + /// + private void buttonItem116_Click(object sender, EventArgs e) + { + FrmRESC frm = new FrmRESC(-1); + frm.ShowDialog(); + } + /// + /// 资源管理 菜单 + /// + /// + /// + private void buttonItem117_Click(object sender, EventArgs e) + { + FrmRESCMgr frm = new FrmRESCMgr(); + frm.ShowDialog(); + } + /// + /// 添加权限 菜单 + /// + /// + /// + private void buttonItem118_Click(object sender, EventArgs e) + { + FrmPerm frm = new FrmPerm(-1); + frm.ShowDialog(); + } + /// + /// 权限管理 菜单 + /// + /// + /// + private void buttonItem119_Click(object sender, EventArgs e) + { + FrmPermMgr frm = new FrmPermMgr(); + frm.ShowDialog(); + } + /// + /// 添加访问控制 菜单 + /// + /// + /// + private void buttonItem120_Click(object sender, EventArgs e) + { + FrmAccess frm = new FrmAccess(-1); + frm.ShowDialog(); + } + /// + /// 访问控制管理 菜单 + /// + /// + /// + private void buttonItem121_Click(object sender, EventArgs e) + { + FrmAccessMgr frm = new FrmAccessMgr(); + frm.ShowDialog(); + } + /// + /// 部门类型管理 菜单 + /// + /// + /// + private void buttonItem122_Click(object sender, EventArgs e) + { + FrmRegionTypeMgr frm = new FrmRegionTypeMgr(); + frm.ShowDialog(); + } + /// + /// 添加用户 菜单 + /// + /// + /// + private void buttonItem127_Click(object sender, EventArgs e) + { + FrmUserAdd frm = new FrmUserAdd(-1); + frm.ShowDialog(); + } + /// + /// 用户信息管理 菜单 + /// + /// + /// + private void buttonItem128_Click_1(object sender, EventArgs e) + { + FrmUserManager frm = new FrmUserManager(); + frm.ShowDialog(); + } + /// + /// 添加角色 菜单 + /// + /// + /// + private void 添加角色_Click(object sender, EventArgs e) + { + FrmRole frm = new FrmRole(-1); + frm.ShowDialog(); + } + /// + /// 所有角色管理 菜单 + /// + /// + /// + private void 角色管理_Click(object sender, EventArgs e) + { + FrmRoleMgr frm = new FrmRoleMgr(); + frm.ShowDialog(); + } + + /// + /// 部门角色管理 菜单 + /// + /// + /// + private void buttonItem133_Click(object sender, EventArgs e) + { + FrmRegionRoleMgr frm = new FrmRegionRoleMgr(); + frm.ShowDialog(); + } + /// + /// 部门管理 菜单 + /// + /// + /// + private void buttonItem130_Click(object sender, EventArgs e) + { + FrmRegionMgr frm = new FrmRegionMgr(); + frm.ShowDialog(); + } + + /// + /// 日志管理 菜单 + /// + /// + /// + private void buttonItem135_Click(object sender, EventArgs e) + { + FrmLogManager frm = new FrmLogManager(); + frm.ShowDialog(); + } + /// + /// 传感器信息查询 菜单 + /// + /// + /// + 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); + } + } + } + /// + /// 根据指定的图层的caption属性的值在配置文件中查找对应的数据库中的表的名称 + /// + /// 图层的caption属性的值 + /// 对应的数据库中的表的名称 + 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; + } + /// + /// 根据数据库中的表的名称 查找对应的表中的字段名称的集合 + /// + /// 数据库中的表的名称 + /// 对应的表中的字段名称的集合 + 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; + } + + /// + /// 历史曲线查询 菜单 + /// + /// + /// + 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; + /// + /// 传感器在线报警 菜单 + /// + /// + /// + 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); + } + /// + /// 传感器报警 功能中的 定时器 的触发事件处理 + /// + /// + /// + 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; + } + } + } + } + } + } + } + + + /// + /// 沿线运动 菜单 + /// + /// + /// + private void buttonItem138_Click(object sender, EventArgs e) + { + if (globeControl1.Globe.SelectedObject == null) + { + MessageBox.Show("请先选择一条线!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + return; + } + + GSOFeature lineFeature = globeControl1.Globe.SelectedObject; + if (lineFeature.Geometry == null || lineFeature.Geometry.Type != EnumGeometryType.GeoPolyline3D) + { + MessageBox.Show("请先选择一条线!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + return; + } + + OpenFileDialog dlg = new OpenFileDialog(); + dlg.Filter = "*.gcm;*.3ds|*.gcm;*.3ds|*.3ds|*.3ds|*.gcm|*.gcm"; + if (dlg.ShowDialog() == DialogResult.OK) + { + GSOGeoModel model = new GSOGeoModel(); + model.FilePath = dlg.FileName; + + GSOGeoDynamicRoute dynamicRoute = new GSOGeoDynamicRoute(); + dynamicRoute.ActorGeometry = model; + + GSORoute route = new GSORoute(); + GSOGeoPolyline3D geoline = (GSOGeoPolyline3D)lineFeature.Geometry; + for (int i = 0; i < geoline[0].Count; i++) + { + route.Add(geoline[0][i]); + } + route.CircleRoute = false; + route.Speed = 30; + route.RotateSpeed = 50; + route.AltitudeMode = geoline.AltitudeMode; + dynamicRoute.Route = route; + + GSOFeature feature = new GSOFeature(); + + dynamicRoute.Play(); + feature.Geometry = dynamicRoute; + + //GSOLabel gsoLabel = new GSOLabel(); + //gsoLabel.Text = "模型测试"; + //feature.Label = gsoLabel; + globeControl1.Globe.MinModelVisibleSize = 0; + + globeControl1.Globe.MemoryLayer.AddFeature(feature); + globeControl1.Globe.Refresh(); + } + } + /// + /// 回退 菜单 + /// + /// + /// + private void buttonItem99_Click(object sender, EventArgs e) + { + globeControl1.Globe.UnDoEdit(); + } + /// + /// 前进 菜单 + /// + /// + /// + private void buttonItem100_Click(object sender, EventArgs e) + { + globeControl1.Globe.ReDoEdit(); + } + /// + /// 水平净距 功能界面中的 标签内容改变事件处理 + /// + /// + /// + 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() + "米的管线有:"; + } + } + } + /// + /// 垂直净距 功能界面中的 标签内容改变事件处理 + /// + /// + /// + 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() + "米的管线有:"; + } + } + } + /// + /// 覆土分析 功能界面中的 标签内容改变事件处理 + /// + /// + /// + 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() + "米的管线有:"; + } + } + } + + /// + /// 传感器分类查询 全区域 菜单 + /// + /// + /// + private void buttonItemSensor全区域查询_Click(object sender, EventArgs e) + { + FrmAccessoriesSensor.ShowForm(globeControl1, instrumenLayerNames, 0); + } + /// + /// 传感器分类查询 绘制区域 菜单 + /// + /// + /// + private void buttonItemSensor绘制区域查询_Click(object sender, EventArgs e) + { + FrmAccessoriesSensor.ShowForm(globeControl1, instrumenLayerNames, 1); + } + + + /// + /// 碰撞分析 功能界面中 关闭按钮 事件处理 + /// + /// + /// + 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(); + } + /// + /// 覆土分析 功能界面中的 清除分析结果 按钮事件处理 + /// + /// + /// + 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(); + } + /// + /// 数字预处理 功能 + /// + /// + /// + private void 数字预处理buttonItem140_Click(object sender, EventArgs e) + { + FrmEditShapeFile frm = new FrmEditShapeFile(globeControl1); + frm.ShowDialog(this); + } + + + /// + /// 导出矢量 功能 将图层导出为kml和shp格式数据 + /// + /// + /// + private void 导出矢量buttonItem140_Click(object sender, EventArgs e) + { + List listVectorNames = new List(); + for (int i = 0; i < m_PipelineLayerNames.Count; i++) + { + 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 = ""; + /// + /// 绘制城市七线 功能按钮 + /// + /// + /// + 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; + } + } + } + /// + /// 七线审核 功能按钮 + /// + /// + /// + private void 七线审核buttonItem141_Click(object sender, EventArgs e) + { + FrmCityServerLineAnalysis frm = new FrmCityServerLineAnalysis(globeControl1, m_PipelineLayerNames); + frm.ShowDialog(this); + } + + /// + /// 间距分析 开始分析按钮 分析绘制的七线和管线的距离是否符合标准 + /// + /// + /// + 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; + } + /// + /// 间距分析 清除分析结果 + /// + /// + /// + 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(); + } + /// + /// 间距分析 导出Excel按钮 将间距分析的结果以Excel表格的形式导出 + /// + /// + /// + private void buttonExportExcel_Click(object sender, EventArgs e) + { + if (dataGridViewAnalysisResult.Rows.Count > 0) + { + ExportExcel("间距分析", dataGridViewAnalysisResult, listBoxStasticsResult); + } + else + { + MessageBox.Show("表格内容为空!", "提示"); + } + } + /// + /// 间距分析 关闭按钮 + /// + /// + /// + 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(); + } + /// + /// 间距分析 分析结果表格双击定位 + /// + /// + /// + 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); + } + } + } + } + /// + /// 间距分析 选择管线复选框 + /// + /// + /// + private void checkBoxSelectPipeline_CheckedChanged(object sender, EventArgs e) + { + clearFeatureHighLight();//清除高亮 + if (checkBoxSelectPipeline.Checked) + { + comboBoxLayer.SelectedItem = null; + 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; + } + } + /// + /// 间距分析 选择图层复选框 + /// + /// + /// + 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(); + } + /// + /// 间距分析 选择图层下拉框 + /// + /// + /// + 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; + } + } + } + + + + /// + /// 管线自动缩进 菜单 + /// + /// + /// + private void 管线自动缩进buttonItem140_Click(object sender, EventArgs e) + { + FrmPipelineIndented frm = new FrmPipelineIndented(globeControl1, m_PipelineLayerNames, workwellLayerNames); + 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 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); + // } + //} + + /// + /// 统计指定图层在指定范围内的所有feature对象 + /// + /// + /// + /// + 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) + { + 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 setLayerVisible(string layerName) + { + GSOLayer templayer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + if (templayer != null) + { + templayer.Visible = false; + } + globeControl1.Globe.Refresh(); + } + + /// + /// 连接数据库 + /// + /// + /// + private void buttonItem129_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL4_1.Text); + + FrmDatabaseParaSetting2 frm = new FrmDatabaseParaSetting2(globeControl1); + if (frm.ShowDialog() == DialogResult.OK) + { + ds = FrmDatabaseParaSetting2.ds; + if (ds != null) + { + ds.IsCloseSaved = false; + } + } + } + + /// + /// 一键审核---导入数据 + /// + /// + /// + private void buttonItem127_Click_2(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, "打开数据"); + + try + { + //if (shds == null) + //{ + //没连的话,直接连接审核库; //审核库配置读配置文件 + string dbIp = Utility.sgdbip; + string database = Utility.sgdbname; + string user = Utility.sgdbuser; + string pass = Utility.sgdbpwd; + /* + 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; + //} + } + catch (Exception ex) + { + LogError.PublishError(ex); + MessageBox.Show("内存过载请清理内存,并重新启动规划分析!", "提示"); + return; + } + + } + + /// + ///自动导出图片 + /// + /// + /// + private void buttonItem130_Click_1(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, "导出审核图"); + + 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))); + */ + + int mapWidth = 0; + int mapHeight = 0; + Point pt = getUpperLeftPoint(pt1, pt2, out mapWidth, out mapHeight); + int rightBottomX = pt.X + mapWidth; + int rightBottomY = pt.Y + mapHeight; + Image myImg = new Bitmap(mapWidth, mapHeight); + Graphics g = Graphics.FromImage(myImg); + g.CopyFromScreen(pt, new Point(0, 0), new Size(rightBottomX, rightBottomY)); + + 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; + } + } + } + /// + /// 一键审核功能 + ///
+ /// + /// + private void buttonItem128_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItem128.Text); + //垂直净距标准 + + frmSh = new FrmYJSHTC(globeControl1, globeControl2,layerTree); + + if (frmSh.ShowDialog() == DialogResult.OK) + { + frmWait = new FrmWait("一键审核……"); + frmWait.Location = new Point(this.Width - frmWait.Width - 10, this.Height - frmWait.Height - 50); + frmWait.Owner = this; + frmWait.Show(); + Thread thread = new Thread(new ThreadStart(doWork)); + thread.IsBackground = true; + thread.Start(); + } + } + + void doWork() + { + FrmShResult frmShResult = null; + + double dVerticalJingJuBiaoZhun = 1, dHorizontalJingJuBiaoZhun = 1; + if (frmSh.rukuLayer != null) + { + #region + this.Invoke((EventHandler)delegate + { + try + { + List managerLayerList = new List(); + for (int i = 0; i < layerManagerNode.Nodes.Count; i++) + { + managerLayerList.Add(layerManagerNode.Nodes[i].Text); + } + if (!managerLayerList.Contains(frmSh.rukuLayer.Caption)) + { + TreeNode node = new TreeNode(); + node.Tag = frmSh.rukuLayer; + node.Text = frmSh.rukuLayer.Dataset.Caption; + node.ImageIndex = 0; + node.SelectedImageIndex = 0; + node.Checked = frmSh.rukuLayer.Visible; + layerManagerNode.Nodes.Insert(0, node); + layerManagerNode.Expand(); + } + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "提示"); + } + }); + #endregion + + shlayername = frmSh.rukuLayer.Name; + globeControl1.Refresh(); + } + + if (frmShResult != null && !frmShResult.IsDisposed) + { + try + { + clearFeatureHighLight(); + ClearRedlineAnalyseResult(); + frmShResult.Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message); + } + } + + 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.analysis(); + + //MainFrm窗体显示控制,回到一键审核Tab + this.Invoke((EventHandler)delegate + { + frmShResult.Show(); + frmWait.Close(); + //将tab页恢复到一键审核 + ribbonTabItem11.Checked = true; + try + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + //zhanshi = false; + splitContainer1.Panel2Collapsed = true; + + panelOfTable.Visible = false; + legendSC.Visible = false; + legendSG.Visible = false; + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + } + catch (Exception ex) + { + MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + + }); + + boolfrmShResult = true; + } + else + { + + } + } + + + /// + /// 清除渲染结果 + /// + 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(); + } + /// + /// 已审核的图层 + /// + /// + /// + private void buttonItem132_Click_1(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItem132.Text); + + if (shds == null) + { + //没连的话,直接连接审核库; //审核库配置读配置文件 + string dbIp = Utility.sgdbip; + string database = Utility.sgdbname; + string user = Utility.sgdbuser; + string pass = Utility.sgdbpwd; + + /* + 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; + //} + + } + /// + /// 审核入库 + /// + /// + /// + private void buttonItem133_Click_1(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, "审核入库"); + FrmShRK frmShrk = new FrmShRK(globeControl1); + frmShrk.Show(); + } + /// + /// 模拟设计修改 + /// + /// + /// + private void buttonItem134_Click_1(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, "模拟设计修改"); + + 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 + { + + } + + } + + + /// + /// 绘制垂线 + /// + /// + /// + 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); + } + /// + /// 比较两个点是否是同一个点 + /// + /// + /// + /// + 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; + } + /// + /// 获得点到线的垂线距离及垂点 + /// + /// + /// + /// + /// + 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); + 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]; + } + /// + /// 获得斜率 + /// + /// + /// + /// + /// + /// + /// + 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); + } + } + /// + /// 根据默认投影参数,经纬度转xyz + /// + /// + /// + /// + 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; + } + /// + /// 根据投影参数,经纬度转xyz + /// + /// + /// + /// + /// + 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; + } + /// + /// 根据默认投影参数,xyz转经纬度 + /// + /// + /// + /// + 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; + } + /// + /// 根据投影参数,Xyz转经纬度 + /// + /// + /// + /// + /// + 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; + } + /// + /// 获得inpolygon的管线长度 + /// + /// + 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; + } + + + /// + /// 一键审核中调节透明度 + /// + /// + /// + private void sliderItem1_ValueChanged(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.sliderItem1.Text); + + globeControl1.Globe.GroundOpaque = 100 - sliderItem1.Value; + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(roadLayerName);//("180fd"); + if (layer != null) + { + layer.Opaque = 100 - sliderItem1.Value; + } + + optiValue = sliderItem1.Value; + } + /// + /// 红线审核中的透明度分析 + /// + /// + /// + private void sliderItem3_ValueChanged(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.sliderItem3.Text); + + globeControl1.Globe.GroundOpaque = 100 - sliderItem3.Value; + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(roadLayerName);//("180fd"); + if (layer != null) + { + layer.Opaque = 100 - sliderItem3.Value; + } + optiValue = sliderItem3.Value; + } + + #region yanxiaowei + //初始化DataGridViewX1控件 + public delegate void DataGridViewDelegate(DataTable dt, string strLable, string strLayer, bool initDataGrid); + /// + /// 代理函数,操作DatgridViewX1 + /// + /// + /// + public void InitDataGridViewX1(DataTable dt, string strLable, string strLayer, bool initDataGrid) + { + if (initDataGrid == true) + { + dataGridViewX1.DataSource = dt; + panelOfTable.Visible = true; + toolStripNumbers.Text = strLable; + dataGridViewX1.Tag = strLayer; + } + else + { + dataGridViewX1.DataSource = null; + dataGridViewX1.Refresh(); + panelOfTable.Visible = false; + toolStripNumbers.Text = ""; + dataGridViewX1.Tag = ""; + globeControl1.Globe.MemoryLayer.RemoveAllFeature();//清除双击产生的标注 + } + } + FrmAnalysisGuiHuaResult from; + /// + /// 主窗体下方属性表格 双击定位 功能 + /// + /// + /// + private void dataGridViewX1_MouseDoubleClick(object sender, MouseEventArgs e) + { + if (redSH == false) + { + 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 if (dataGridViewX1.Columns.Contains("标识器编号")) + { + featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["标识器编号"].Value.ToString(); + } + featureName = featureName.Trim(); + + GSOLayer layer = null; + layer = globeControl1.Globe.Layers.GetLayerByCaption(dataGridViewX1.Tag.ToString()); + + if (layer == null) return; + + GSOFeatures features = layer.GetFeatureByName(featureName, false); + if (features.Length == 0) return; + GSOFeature rowFeature = features[0]; + + ClassSearchAnalysis.AddMakerToLineFeature(globeControl1, rowFeature); + + } + } + } + else + { + if (e.Button == MouseButtons.Left) + { + if (from != null && !from.IsDisposed) + { + try + { + from.Close(); + } + catch (Exception ex) + { + LogError.PublishError(ex); + } + } + try + { + DataGridView.HitTestInfo hittestinfo = dataGridViewX1.HitTest(e.X, e.Y); + if (hittestinfo.RowIndex >= 0) + { + string layer = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["管线类型"].Value.ToString(); + string hxName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["红线编号"].Value.ToString(); + FrmAnalysisGuiHuaResult frm = new FrmAnalysisGuiHuaResult(globeControl1, lineStruct, featsList, + panelOfTable, dataGridViewX1, layer, hxName); + frm.Location = new Point(this.Width - frm.Width - 10, this.Height - frm.Height - 20); + frm.Show(this); + + from = frm; + } + } + catch (Exception ex) + { + LogError.PublishError(ex); + } + } + } + } + + /// + /// 空间查询 + /// + /// + /// + private void buttonItemSearch1_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemSearch1.Text); + + trackflag = "PipelineSpatialQuery"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; + + } + /// + /// 关键字查询 + /// + /// + /// + private void buttonItemSearch9_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch9.Text); + + FrmKeywordQuery.ShowForm(globeControl1, m_PipelineLayerNames, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 编号查询 + /// + /// + /// + private void buttonItemSearch2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch2.Text); + + FrmCodingQuery.ShowForm(globeControl1, m_PipelineLayerNames, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 坐标查询 + /// + /// + /// + private void buttonItemSearch3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch3.Text); + + FrmSetLatLonPos.ShowForm(globeControl1); + } + /// + /// 附属物查询 + /// + /// + /// + private void buttonItemSearch10_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch10.Text); + + FrmFittingQuery.ShowForm(globeControl1, instrumenLayerNames, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 管径查询 + /// + /// + /// + private void buttonItemSearch4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch4.Text); + + FrmDiameterQuery.ShowForm(globeControl1, m_PipelineLayerNames, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 材质查询 + /// + /// + /// + private void buttonItemSearch5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch5.Text); + + FrmMaterialSel.ShowForm(globeControl1, m_PipelineLayerNames, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 基本查询 + /// + /// + /// + private void buttonItemSearch6_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch6.Text); + + FrmBasicQuery.ShowForm(globeControl1, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 复合查询 + /// + /// + /// + private void buttonItemSearch7_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch7.Text); + + FrmQuerySQL.ShowForm(globeControl1, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 关联查询 + /// + /// + /// + private void buttonItemSearch8_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch8.Text); + + if (globeControl1.Globe.SelObjectCount != 1) + { + MessageBox.Show("请选中一个对象!", "提示"); + return; + } + + 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 || (feature.Geometry.Type == EnumGeometryType.GeoPolygon3D + || feature.Geometry.Type == EnumGeometryType.GeoWater)) + return; + else + { + ClassSearchAnalysis.ResultRelationAnalysis(globeControl1, feature, valueLayerNames, workwellLayerNames, + instrumenLayerNames, pipefittingLayerNames, m_PipelineLayerNames, valueAllowance); + } + } + } + #endregion + /// + /// 清除分析 + /// + /// + /// + private void buttonItemClear_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemClear.Text); + + globeControl1.Globe.ClearMeasure(); + layerTemp.RemoveAllFeature(); + layerTemp2.RemoveAllFeature(); + buttonItemLS5.Checked = false; + + dataGridViewX1.DataSource = null; + panelOfTable.Visible = false; + + 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); + + NetworkAnalysisTool.ClearAllTopAnalysis(this.globeControl1); + // 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();//清除所有坑 + + 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(); + } + } + + clearFeatureHighLight();//取消管线高亮 + + GSOLayer layerGround = globeControl1.Globe.Layers.GetLayerByCaption(roadLayerName);//("180fd"); + if (layerGround != null) + { + layerGround.Visible = true; + } + globeControl1.Refresh(); + globeControl2.Refresh(); + ClearRedlineAnalyseResult(); + globeControl1.Globe.Action = EnumAction3D.ActionNull; + } + /// + /// 管线长度全区域统计 + /// + /// + /// + private void buttonItemTJ1_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管线长度统计"); + + FrmAllPipelineStatis frm = new FrmAllPipelineStatis(globeControl1,null, new DataGridViewDelegate(InitDataGridViewX1), m_PipelineLayerNames); + frm.Show(this); + } + /// + /// 管线长度绘制区域统计 + /// + /// + /// + private void buttonItemTJ1_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管线长度统计"); + + trackflag = "PipelineDistanceStatistics"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; + } + /// + /// 阀门数量全区域统计 + /// + /// + /// + private void buttonItemTJ2_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "阀门数量统计"); + + FrmValveStatistics frm = new FrmValveStatistics(globeControl1, null, new DataGridViewDelegate(InitDataGridViewX1)); + frm.Show(this); + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + } + /// + /// 阀门数量绘制区域统计 + /// + /// + /// + private void buttonItemTJ2_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "阀门数量统计"); + + trackflag = "valvequery"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; + } + /// + /// 井盖数量全区域统计 + /// + /// + /// + private void buttonItemTJ3_ALL_Click(object sender, EventArgs e) +<<<<<<< HEAD + { + //日志记录 + LogManager.saveLog(Utility.userName, "井盖数量统计"); +======= + { +>>>>>>> d2d0088a6b3c53c1a96b7f1997f4d3443c0ee8c0 + FrmAllWorkWellStatis frm = new FrmAllWorkWellStatis(globeControl1, null, new DataGridViewDelegate(InitDataGridViewX1)); + frm.Show(this); + } + /// + /// 井盖数量绘制区域统计 + /// + /// + /// + private void buttonItemTJ3_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "井盖数量统计"); + + trackflag = "workwellquery"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; + } + /// + /// 管径分段统计全区域统计 + /// + /// + /// + private void buttonItemTJ4_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管径分段统计"); + + Frmpipediameterstatis.ShowForm(globeControl1, m_PipelineLayerNames, 0); + } + /// + /// 管径分段统计绘制区域统计 + /// + /// + /// + private void buttonItemTJ4_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管径分段统计"); + + trackflag = null; + Frmpipediameterstatis.ShowForm(globeControl1, m_PipelineLayerNames, 1); + } + /// + /// 埋深分段统计全区域统计 + /// + /// + /// + private void buttonItemTJ5_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "埋深分段统计"); + FrmpipeDeepstatis.ShowForm(globeControl1, m_PipelineLayerNames, 0); + } + /// + /// 埋深分段统计绘制区域统计 + /// + /// + /// + private void buttonItemTJ5_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "埋深分段统计"); + trackflag = null; + FrmpipeDeepstatis.ShowForm(globeControl1, m_PipelineLayerNames, 1); + } + /// + /// 管径分类统计全区域统计 + /// + /// + /// + private void buttonItemTJ6_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管径分类汇总"); + + FrmpipeDiametergather.ShowForm(globeControl1, m_PipelineLayerNames, 0); + } + /// + /// 管径分类统计绘制区域统计 + /// + /// + /// + private void buttonItemTJ6_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管径分类汇总"); + + trackflag = null; + FrmpipeDiametergather.ShowForm(globeControl1, m_PipelineLayerNames, 1); + } + /// + /// 材质分类统计全区域统计 + /// + /// + /// + private void buttonItemTJ7_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "材质分类汇总"); + + FrmpipeMaterialGather.ShowForm(globeControl1, m_PipelineLayerNames, 0); + } + /// + /// 材质分类统计绘制区域统计 + /// + /// + /// + private void buttonItemTJ7_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "材质分类汇总"); + + trackflag = null; + FrmpipeMaterialGather.ShowForm(globeControl1, m_PipelineLayerNames, 1); + } + /// + /// 附属物分类统计全区域统计 + /// + /// + /// + private void buttonItemTJ8_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "附属物分类汇总"); + + FrmAccessoriesgather.ShowForm(globeControl1, instrumenLayerNames, 0); + } + /// + /// 附属物分类统计绘制区域统计 + /// + /// + /// + private void buttonItemTJ8_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "附属物分类汇总"); + + trackflag = null; + FrmAccessoriesgather.ShowForm(globeControl1, instrumenLayerNames, 1); + } + /// + /// 碰撞分析 + /// + /// + /// + private void buttonItemFX1_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_4.Text); + + this.dataGridViewX4.Size = new System.Drawing.Size(195, 120); + 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(); + } + /// + /// 覆土分析 + /// + /// + /// + private void buttonItemFX1_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX5_1.Text); + this.dataGridViewX6.Size = new System.Drawing.Size(195, 120); + 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(); + } + /// + /// 间距分析 + /// + /// + /// + private void buttonItemFX1_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX1_3.Text); + + this.dataGridViewLineList.Size = new System.Drawing.Size(185, 120); + 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(); + } + /// + /// 垂直净距分析 + /// + /// + /// + private void buttonItemFX1_4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX1_4.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(); + } + /// + /// 水平净距分析 + /// + /// + /// + private void buttonItemFX1_5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_6.Text); + this.dataGridViewX8.Size = new System.Drawing.Size(185, 120); + 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(); + } + + #region Predaotr,断面分析 + /// + /// 横断面分析 + /// + /// + /// + private void buttonItemFX2_1_Click(object sender, EventArgs e) + { + globeControl1.Globe.Action = EnumAction3D.TrackPolyline; + globeControl1.Globe.TrackPolylineTool.VerticalLineVisible = true; + globeControl1.Globe.TrackPolylineTool.TrackMode = EnumTrackMode.SpaceTrack; + trackPolylineEndMode = EnumTrackPolylineEndMode.HDM_Analysis; + + } + /// + /// 纵断面分析 + /// + /// + /// + private void buttonItemFX2_2_Click(object sender, EventArgs e) + { + if (globeControl1.Globe.SelObjectCount<1) + { + MessageBox.Show("请选择一条或者多条管线!", "提示", MessageBoxButtons.OK, + MessageBoxIcon.Information); + return; + } + 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); + } + } + List feats = SectionAnalysisTool.ZDMAnalysis(selectFeatures); + if (feats != null && feats.Count >= 1) + { + FrmProfileAnalysis frm = new FrmProfileAnalysis(globeControl1, feats); + frm.Show(this); + } + } + /// + /// 道路断面分析 + /// + /// + /// + private void buttonItemFX2_3_Click(object sender, EventArgs e) + { + globeControl1.Globe.Action = EnumAction3D.TrackPolyline; + globeControl1.Globe.TrackPolylineTool.VerticalLineVisible = true; + globeControl1.Globe.TrackPolylineTool.TrackMode = EnumTrackMode.SpaceTrack; + trackPolylineEndMode = EnumTrackPolylineEndMode.DLDM_Analysis; + + } + /// + /// 基线剖面分析 + /// + /// + /// + private void buttonItemFX2_4_Click(object sender, EventArgs e) + { + globeControl1.Globe.Action = EnumAction3D.TrackPolyline; + globeControl1.Globe.TrackPolylineTool.VerticalLineVisible = true; + globeControl1.Globe.TrackPolylineTool.TrackMode = EnumTrackMode.SpaceTrack; + trackPolylineEndMode = EnumTrackPolylineEndMode.JXPM_Analysis; + + } + + #endregion + /// + /// 创建拓扑 + /// + /// + /// + private void buttonItemFX3_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX3_1.Text); + + FrmGenAndFaMenTopu frm = new FrmGenAndFaMenTopu(globeControl1, m_PipelineLayerNames, valueLayerNames); + frm.Show(this); + } + #region Predator :拓扑分析 + /// + /// 上游分析 + /// + /// + /// + private void buttonItemFX3_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX3_2.Text); + NetworkTraceUpDown(true); + } + /// + /// 下游分析 + /// + /// + /// + private void buttonItemFX3_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX3_3.Text); + NetworkTraceUpDown(false); + } + + /// + /// 上下游追踪 功能 + /// + /// + private void NetworkTraceUpDown(Boolean bTraceUp) + { + GSOFeature selLineFeature = globeControl1.Globe.SelectedObject; + if (selLineFeature == null || selLineFeature.Geometry == null || selLineFeature.Geometry.Type != EnumGeometryType.GeoPolyline3D) + { + MessageBox.Show("请点击“编辑”—“选中对象”选择一条线!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); + return; + } + GSOLayer selLayer = globeControl1.Globe.SelectedObjectLayer; + + NetworkAnalysisTool.TraceUpDownAnalysis(bTraceUp, + selLineFeature, selLayer); + } + + /// + /// 流向分析 + /// + /// + /// + private void buttonItemFX3_4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX3_4.Text); + + FrmFlow frm = new FrmFlow(globeControl1, m_PipelineLayerNames); + frm.Show(this); + } + /// + /// 关阀分析 + /// + /// + /// + private void buttonItemFX3_5_Click(object sender, EventArgs e) + { + if (globeControl1.Globe.SelObjectCount < 1) + { + MessageBox.Show("请选中至少一根管线!!"); + buttonItemFX3_5.Checked = false; + return; + } + GSOLayer resLayer = null; + GSOFeature resFeature = null; + globeControl1.Globe.GetSelectObject(0, out resFeature, out resLayer); + + String pipeLayerName = resLayer.Caption; + String pipeLayerNamePrefix = pipeLayerName.Substring(0, pipeLayerName.IndexOf("管线")); + GSOLayer valveLayer = globeControl1.Globe.Layers[pipeLayerNamePrefix + "阀门"]; + if (valveLayer == null) + { + MessageBox.Show("无" + pipeLayerNamePrefix+"阀门图层", "提示"); + return; + } + + GSOFeatures valveFeats = NetworkAnalysisTool.CloseValvesAnalysis(resFeature, + resLayer, valveLayer); + + if (valveFeats != null) + { + FrmCloseValves frm = new FrmCloseValves(this.globeControl1, valveFeats); + frm.Show(this); + } + else + { + MessageBox.Show("未找到关闭阀门"); + } + } + + /// + /// 连通分析 + /// + /// + /// + private void buttonItemFX3_6_Click(object sender, EventArgs e) + { + if (globeControl1.Globe.SelObjectCount < 2) + { + MessageBox.Show("请选中至少两个管线!!"); + buttonItemFX3_6.Checked = false; + return; + } + GSOFeature selFeat0, selFeat1; + GSOLayer layer0,layer1; + globeControl1.Globe.GetSelectObject(0, out selFeat0, out layer0); + globeControl1.Globe.GetSelectObject(1, out selFeat1, out layer1); + + if (!layer0.IsSameInnerObject(layer1)) + { + MessageBox.Show("不在同一个图层!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); + buttonItemFX3_6.Checked = false; + return; + } + NetworkAnalysisTool.ConnexityAnalysis(selFeat0, selFeat1, layer0); + } + /// + /// 爆管分析 + /// + /// + /// + private void buttonItemFX3_7_Click(object sender, EventArgs e) + { + NetworkTraceUpDown(true); //上游追踪: + + GSOFeature selLineFeature = globeControl1.Globe.SelectedObject; + if (selLineFeature == null || selLineFeature.Geometry == null || selLineFeature.Geometry.Type != EnumGeometryType.GeoPolyline3D) + { + MessageBox.Show("请点击“编辑”—“选中对象”选择一条线!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); + return; + } + GSOLayer selLayer = globeControl1.Globe.SelectedObjectLayer; + + NetworkAnalysisTool.ExplodeAnalysis(this.globeControl1,selLineFeature,selLayer); + + this.buttonItemFX3_5_Click(sender, e); //关阀分析: + + } + + #endregion + /// + /// 多边形开挖 + /// + /// + /// + private void buttonItemFX4_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_1.Text); + + trackflag = "pit"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; //是这个么?是的,在模型上 + } + /// + /// 挖方量分析 + /// + /// + /// + private void buttonItemFX4_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_2.Text); + + trackflag = "digFillAnalysis"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; + ActionToolMenuChecked(); + } + /// + /// 沿线开挖 + /// + /// + /// + private void buttonItemFX4_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_3.Text); + + if (!buttonItemFX4_3.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; + buttonItemFX4_3.Checked = true; + } + } + else + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + buttonItemFX4_3.Checked = false; + globeControl1.Globe.TrackPolylineTool.VerticalLineVisible = false; + } + ActionToolMenuChecked(); + } + /// + /// 创建隧道 + /// + /// + /// + private void buttonItemFX4_4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_4.Text); + + 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("场景中未加载隧道图层!", "提示"); + } + } + /// + /// 隐藏隧道 + /// + /// + /// + private void buttonItemFX4_5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_5.Text); + + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption("隧道"); + if (layer != null) + { + layer.Visible = !layer.Visible; + } + } + /// + /// 删除隧道 + /// + /// + /// + private void buttonItemFX4_6_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_6.Text); + + 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("请选中要删除的隧道!", "提示"); + } + } + /// + /// 通视分析 + /// + /// + /// + private void buttonItemFX5_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX5_1.Text); + + if (globeControl1.Globe.Action != EnumAction3D.VisibilityAnalysis) + { + //btnSpaceVisibilityAnalysis.Checked = true; + globeControl1.Globe.Action = EnumAction3D.VisibilityAnalysis; + } + else + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + // SetButtonChecked(); + } + } + /// + /// 可视域分析 + /// + /// + /// + private void buttonItemFX5_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX5_2.Text); + + globeControl1.Globe.Action = EnumAction3D.ViewshedAnalysis; + } + /// + /// 可视包络分析 + /// + /// + /// + private void buttonItemFX5_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX5_3.Text); + + globeControl1.Globe.Action = EnumAction3D.ViewEnvelopeAnalysis; + } + /// + /// 缓冲区分析 + /// + /// + /// + private void buttonItemFX6_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX6_1.Text); + + GSOFeature feat = globeControl1.Globe.SelectedObject; + if (feat == null) + { + MessageBox.Show("请选择要分析的要素!"); + return; + } + if (feat.Geometry.Type == EnumGeometryType.GeoPolyline3D) + { + GSOGeoPolyline3D line1 = feat.Geometry as GSOGeoPolyline3D; + if (line1 == null) + { + MessageBox.Show("请选择一条管线!"); + return; + } + + FrmBufferAnalysis frm = new FrmBufferAnalysis(globeControl1, line1, layerTemp); + frm.Show(this); + } + else + { + FrmBufferAnalysisBSQ frm = new FrmBufferAnalysisBSQ(globeControl1, layerTemp, bsqPT); + frm.Show(this); + } + + } + /// + /// 附属物分析 + /// + /// + /// + private void buttonItemFX6_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX6_2.Text); + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + FrmAccessoryAnalysis dlg = new FrmAccessoryAnalysis(globeControl1, layerTemp); + dlg.Show(this); + } + /// + /// 无源淹没分析 + /// + /// + /// + private void buttonItemFX6_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX6_3.Text); + + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + trackflag = "FloodAnalysis"; + } + /// + /// 水平距离 + /// + /// + /// + private void buttonItemLS1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS1.Text); + + globeControl1.Globe.Action = EnumAction3D.MeasureDistance; + globeControl1.Globe.DistanceRuler.SpaceMeasure = false; + buttonItemLS5.Checked = false; + } + /// + /// 垂直距离 + /// + /// + /// + private void buttonItemLS2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS2.Text); + + buttonItemLS5.Checked = false; + globeControl1.Globe.Action = EnumAction3D.MeasureHeight; + globeControl1.Globe.DistanceRuler.SpaceMeasure = false; + } + /// + /// 空间距离 + /// + /// + /// + private void buttonItemLS3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS3.Text); + + buttonItemLS5.Checked = false; + globeControl1.Globe.Action = EnumAction3D.MeasureDistance; + globeControl1.Globe.DistanceRuler.SpaceMeasure = true; + } + /// + /// 地表距离 + /// + /// + /// + private void buttonItemLS4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS4.Text); + + buttonItemLS5.Checked = false; + globeControl1.Globe.Action = EnumAction3D.MeasureDistance; + globeControl1.Globe.DistanceRuler.SpaceMeasure = false; + } + /// + /// 高度量算 + /// + /// + /// + private void buttonItemLS5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS5.Text); + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + buttonItemLS5.Checked = !buttonItemLS5.Checked; + if (buttonItemLS5.Checked) + { + globeControl1.Globe.Action = EnumAction3D.SelectObject; + } + } + /// + /// 水平面积 + /// + /// + /// + private void buttonItemLS6_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS6.Text); + + buttonItemLS5.Checked = false; + globeControl1.Globe.Action = EnumAction3D.MeasureArea; + globeControl1.Globe.AreaRuler.SpaceMeasure = true; + } + /// + /// 地表面积 + /// + /// + /// + private void buttonItemLS7_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS7.Text); + + buttonItemLS5.Checked = false; + globeControl1.Globe.Action = EnumAction3D.MeasureArea; + globeControl1.Globe.AreaRuler.SpaceMeasure = false; + + } + + # region Fan 重构标注代码 + /// + /// 标高标注 + /// + /// + /// + private void buttonItemSZ1_Click(object sender, EventArgs e) + { + GSOFeature resFeature = IsPipeLineOfSelectedObj(); + if (resFeature == null) + { + MessageBox.Show("请选中一根管线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + GSOGeoPolyline3D selLine = resFeature.Geometry as GSOGeoPolyline3D; + if (selLine[0].Count <= 1) + { + return; + } + + MarkTools.getInstance().showMarker(resFeature, + globeControl1, EnumMarkLayer.Mark_Altitude, ""); + } + /// + /// 管径标注 + /// + GSOFeature radiusMarkerFeature; + private void buttonItemBZ2_Click(object sender, EventArgs e) + { + GSOFeature resFeature = IsPipeLineOfSelectedObj(); + if (resFeature == null) + { + MessageBox.Show("请选中一根管线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + GSOGeoPolyline3D selLine = resFeature.Geometry as GSOGeoPolyline3D; + if (selLine[0].Count <= 1) + { + return; + } + + MarkTools.getInstance().showMarker(resFeature, + globeControl1, EnumMarkLayer.Mark_Diameter, ""); + } + /// + /// 埋深标注 + /// + /// + /// + private void buttonItemBZ3_Click(object sender, EventArgs e) + { + GSOFeature resFeature = IsPipeLineOfSelectedObj(); + if (resFeature == null) + { + MessageBox.Show("请选中一根管线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + GSOGeoPolyline3D selLine = resFeature.Geometry as GSOGeoPolyline3D; + if (selLine[0].Count <=1) + { + return; + } + + MarkTools.getInstance().showMarker(resFeature, + globeControl1, EnumMarkLayer.Mark_Depth, ""); + + } + /// + /// 坐标标注 + /// + /// + /// + private void buttonItemBZ4_Click(object sender, EventArgs e) + { + GSOFeature resFeature = IsPipeLineOfSelectedObj(); + if (resFeature == null) + { + MessageBox.Show("请选中一根管线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + GSOGeoPolyline3D selLine = resFeature.Geometry as GSOGeoPolyline3D; + if (selLine[0].Count <= 1) + { + return; + } + MarkTools.getInstance().showMarker(resFeature, + globeControl1, EnumMarkLayer.Mark_Location, ""); + } + /// + /// 距离标注 + /// + bool distanceMarker = false; + private void buttonItemBZ5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBZ5.Text); + + globeControl1.Globe.Action = EnumAction3D.TrackPolyline; + //globeControl1.Globe.DistanceRuler.MeasureMode = EnumDistanceMeasureMode.HVSLineMeasure; + distanceMarker = true; + } + /// + /// 自定义标注 + /// + /// + /// + private void buttonItemBZ6_Click(object sender, EventArgs e) + { + GSOFeature f = globeControl1.Globe.SelectedObject; + GSOLayer l = globeControl1.Globe.SelectedObjectLayer; + FrmCustomLabel frm = new FrmCustomLabel(globeControl1, l, f); + if (frm.ShowDialog() == DialogResult.OK) + { + MarkTools.getInstance().showMarker(f, globeControl1, EnumMarkLayer.Mark_Custom, frm.labelText); + } + } + /// + /// 扯旗标注 + /// + /// + /// + private void buttonItemBZ7_Click(object sender, EventArgs e) + { + GSOFeature f = globeControl1.Globe.SelectedObject; + GSOLayer l = globeControl1.Globe.SelectedObjectLayer; + FrmMarker frm = new FrmMarker(); + if (frm.ShowDialog() == DialogResult.OK) + { + MarkTools.getInstance().showMarker(f, globeControl1, EnumMarkLayer.Mark_Custom, frm.markerContent); + } + } + /// + /// 坡度标注 + /// + /// + /// + private void buttonItemBZ8_Click(object sender, EventArgs e) + { + GSOFeature resFeature = IsPipeLineOfSelectedObj(); + if (resFeature == null) + { + MessageBox.Show("请选中一根管线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + GSOGeoPolyline3D selLine = resFeature.Geometry as GSOGeoPolyline3D; + if (selLine[0].Count <= 1) + { + return; + } + + MarkTools.getInstance().showMarker(resFeature, + globeControl1, EnumMarkLayer.Mark_Slope, ""); + } + /// + /// 属性标注 + /// + /// + /// + private void buttonItemBZ9_Click(object sender, EventArgs e) + { + GSOFeature f = globeControl1.Globe.SelectedObject; + GSOLayer l = globeControl1.Globe.SelectedObjectLayer; + FrmPropertiesMarker frm = new FrmPropertiesMarker(globeControl1, l, f); + if (frm.ShowDialog() == DialogResult.OK) + { + MarkTools.getInstance().showMarker(f, globeControl1, EnumMarkLayer.Mark_Property, frm.labelText); + } + } + /// + /// 红线工具 + /// + /// + /// + private void buttonItemBZ10_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBZ10.Text); + 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; + } + } + /// + /// 标注管理 + /// + /// + /// + private void buttonItemBZ11_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBZ11.Text); + + buttonItemBZ11.Checked = !buttonItemBZ11.Checked; + 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 (buttonItemBZ11.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(); + } + } + + #endregion + /// + /// 飞行到目标点 + /// + /// + /// + private void buttonItemFXGJ1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFXGJ1.Text); + + FrmSetFlytoPos.ShowForm(globeControl1); + + } + /// + /// 自定义飞行 + /// + /// + /// + private void buttonItemFXGJ2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFXGJ2.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); + } + } + /// + /// 绕中心点飞行 + /// + /// + /// + private void buttonItemFXGJ3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFXGJ3.Text); + + globeControl1.Globe.FlyAroundCenter(10000, EnumFlyRepeatValueType.MiliSeconds); + globeControl1.Globe.CurFlyID = 1; + } + /// + /// 绕眼睛飞行 + /// + /// + /// + private void buttonItemFXGJ4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFXGJ4.Text); + + globeControl1.Globe.FlyAroundEye(720, EnumFlyRepeatValueType.Degrees); + globeControl1.Globe.CurFlyID = 2; + } + + /// + /// 权限管理 + /// + /// + /// + private void buttonItemXT1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT1.Text); + + FrmUserRoleMgr frm = new FrmUserRoleMgr(); + frm.ShowDialog(); + } + /// + /// 数据库管理 + /// + /// + /// + private void buttonItemXT2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT2.Text); + + //查看数据库列表 + FrmDbManager frm = new FrmDbManager(); + frm.ShowDialog(); + } + /// + /// 用户列表 + /// + /// + /// + private void buttonItemXT3_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT3_1.Text); + + FrmUserManager frm = new FrmUserManager(); + frm.ShowDialog(); + } + /// + /// 创建新用户 + /// + /// + /// + private void buttonItemXT3_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT3_2.Text); + + FrmUserAdd frm = new FrmUserAdd(-1); + frm.ShowDialog(); + } + /// + /// 人员修改 + /// + /// + /// + private void buttonItemXT4_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT4_2.Text); + + FrmAppUSER appUSER = new FrmAppUSER(); + appUSER.ShowDialog(); + } + /// + /// 增加人员 + /// + /// + /// + private void buttonItemXT4_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT4_1.Text); + + FrmAppUSERRESET appUSERRESET = new FrmAppUSERRESET(); + appUSERRESET.ShowDialog(); + } + /// + /// 统计数据 + /// + /// + /// + private void buttonItemZTT1_Click(object sender, EventArgs e) + { + ////日志记录 + //LogManager.saveLog(Utility.userName, this.buttonItemZTT1.Text); + + //PATM patm = new PATM(); + //patm.operation = "Statistic"; + //patm.Text = "统计专题图管理"; + //patm.ShowDialog(); + } + /// + /// 热点功能统计 + /// + /// + /// + private void buttonItemZTT2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT2.Text); + + FrmHotFuncStat frmhfs = new FrmHotFuncStat(); + frmhfs.ShowDialog(); + } + + private void buttonItemZTT3_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT3_1.Text); + + FrmAPP appfrm = new FrmAPP("专题图申请"); + appfrm.ShowDialog(); + } + + private void buttonItemZTT3_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT3_2.Text); + + FrmAPPFORASK appForask = new FrmAPPFORASK("专题图审核"); + appForask.ShowDialog(); + } + + private void buttonItemZTT3_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT3_3.Text); + + FrmAPPregion appregion = new FrmAPPregion("专题图审核"); + appregion.ShowDialog(); + } + + private void buttonItemZTT4_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT4_1.Text); + + FrmAPP appfrm = new FrmAPP("打印申请"); + appfrm.ShowDialog(); + } + + private void buttonItemZTT4_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT4_2.Text); + + FrmAPPFORASK appForask = new FrmAPPFORASK("打印审核"); + appForask.ShowDialog(); + } + + private void buttonItemZTT4_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT4_3.Text); + + FrmAPPregion appregion = new FrmAPPregion("打印审核"); + appregion.ShowDialog(); + } + + private void buttonItemZTT5_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT5_1.Text); + + FrmAPP appfrm = new FrmAPP("拷贝申请"); + appfrm.ShowDialog(); + } + + private void buttonItemZTT5_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT5_2.Text); + + FrmAPPFORASK appForask = new FrmAPPFORASK("拷贝审核"); + appForask.ShowDialog(); + } + + private void buttonItemZTT5_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT5_3.Text); + + FrmAPPregion appregion = new FrmAPPregion("拷贝审核"); + appregion.Show(); + } + + private int connectServerCount = 0; + + /// + /// 还原球到实测库 + /// + 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); + } + + if (layerManagerNode.Nodes.Count > 0) + { + for (int i = layerManagerNode.Nodes.Count - 1; i >= 0; i--) + { + layerManagerNode.Nodes[i].Remove(); + + } + } + + globeControl1.Refresh(); + + } + + private void buttonItemSPSZ_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSPSZ.Text); + + FrmLayerControl frm = new FrmLayerControl(layerTree, globeControl1, globeControl2); + frm.Show(this); + } + + /// + /// 碰撞审查 + /// + /// + /// + private void buttonItemSH1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSH1.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 buttonItemSH2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSH2.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 buttonItemSH3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSH3.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 buttonItemSH4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSH4.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 buttonItemSH5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSH5.Text); + FrmCityServerLineAnalysis frm = new FrmCityServerLineAnalysis(globeControl1, m_PipelineLayerNames); + frm.Show(this); + } + #region 数据管理-导入文件 + ///// + ///// 数据管理-导入本地坐标系文件 + ///// + ///// + ///// + //private void buttonItemSJGL1_1_Click(object sender, EventArgs e) + //{ + // //日志记录 + // LogManager.saveLog(Utility.userName, this.buttonItemSJGL1_1.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(); + // } + // } + //} + + ///// + ///// 数据管理-导入其他坐标系文件 + ///// + ///// + ///// + //private void buttonItemSJGL1_2_Click(object sender, EventArgs e) + //{ + // //日志记录 + // LogManager.saveLog(Utility.userName, this.buttonItemSJGL1_2.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(); + // } + // } + //} + #endregion + /// + /// 数据质量检查 + /// + /// + /// + private void buttonItemSJGL2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL2.Text); + FrmValiData frm = new FrmValiData(globeControl1); + frm.ShowDialog(); + } + /// + /// 数据预处理 + /// + /// + /// + private void buttonItemSJGL3_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL3.Text); + + FrmEditShapeFile frm = new FrmEditShapeFile(globeControl1); + frm.ShowDialog(this); + } + /// + /// 连接数据库 + /// + /// + /// + private void buttonItemSJGL4_1_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL4_1.Text); + + FrmDatabaseParaSetting frm = new FrmDatabaseParaSetting(globeControl1); + if (frm.ShowDialog() == DialogResult.OK) + { + ds = FrmDatabaseParaSetting.ds; + if (ds != null) + { + ds.IsCloseSaved = false; + } + } + } + /// + /// 管线入库 + /// + /// + /// + private void buttonItemSJGL4_2_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL4_2.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 buttonItemSJGL4_3_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL4_3.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 buttonItemSJGL5_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL5.Text); + + Cyberpipe.Forms.FrmProject frm = new Cyberpipe.Forms.FrmProject(); + frm.ShowDialog(); + } + /// + /// 元数据基本管理 + /// + /// + /// + private void buttonItemSJGL6_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL6_1.Text); + + FrmMetadata frmmd = new FrmMetadata(); + frmmd.ShowDialog(); + } + /// + /// 元数据查询管理 + /// + /// + /// + private void buttonItemSJGL6_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL6_2.Text); + + FrmMetadataStat frmmds = new FrmMetadataStat(); + //frmmds.Show(); + frmmds.ShowDialog(); + } + /// + /// 操作日志管理 + /// + /// + /// + private void buttonItemSJGL7_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL7.Text); + + FrmLogOper frmlo = new FrmLogOper(); + frmlo.ShowDialog(); + } + /// + /// 数据字典管理 + /// + /// + /// + private void buttonItemSJGL8_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL8.Text); + + FrmMDDictory frmmdd = new FrmMDDictory(); + frmmdd.ShowDialog(); + } + /// + /// 数据库备份 + /// + /// + /// + private void buttonItemSJGL9_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL9.Text); + + //新 + FrmBACKORACLE backOracle = new FrmBACKORACLE(); + backOracle.Show(); + } + /// + /// 创建管段 + /// + /// + /// + private void buttonItemBJ1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ1.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; + } + } + /// + /// 创建附属物 + /// + /// + /// + private void buttonItemBJ2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ2.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); + } + } + /// + /// 创建特征管点 + /// + /// + /// + private void buttonItemBJ3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ3.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); + } + } + /// + /// 绘制城市七线 + /// + /// + /// + private void buttonItemBJ4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ4.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; + } + } + } + /// + /// 选中对象 + /// + /// + /// + private void buttonItemBJ5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ5.Text); + + globeControl1.Globe.Action = EnumAction3D.SelectObject; + } + /// + /// 平移对象 + /// + /// + /// + private void buttonItemBJ6_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ6.Text); + + globeControl1.Globe.Action = EnumAction3D.MoveObject; + } + /// + /// 升降对象 + /// + /// + /// + private void buttonItemBJ7_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ7.Text); + + globeControl1.Globe.Action = EnumAction3D.ElevateObject; + } + /// + /// 旋转对象 + /// + /// + /// + private void buttonItemBJ8_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ8.Text); + + globeControl1.Globe.Action = EnumAction3D.RotateObject; + } + /// + /// 连接管段 + /// + /// + /// + private void buttonItemBJ9_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ9.Text); + + if (globeControl1.Globe.SelObjectCount < 2) + { + MessageBox.Show("对不起,请至少选中2个对象!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + return; + } + globeControl1.Globe.InsertJointPipeline(false); + } + /// + /// 后退 + /// + /// + /// + private void buttonItemBJ11_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemBJ11.Text); + globeControl1.Globe.UnDoEdit(); + } + /// + /// 前进 + /// + /// + /// + private void buttonItemBJ12_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemBJ12.Text); + + globeControl1.Globe.ReDoEdit(); + } + /// + /// 导出CAD + /// + /// + /// + private void buttonItemBJ10_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ10_1.Text); + + #region 导出成dxf格式 + List listVectorNames = new List(); + 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(); + #endregion + } + /// + /// 导出矢量 + /// + /// + /// + private void buttonItemBJ10_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ10_2.Text); + + List listVectorNames = new List(); + 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 buttonItemBJ13_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemBJ13.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(); + } + } + MessageBox.Show("删除成功!", "提示"); + } + else + { + MessageBox.Show("请选中要删除的模型!", "提示"); + } + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + } + + private void buttonItemHX1_1_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]; + string filePath = dlg.FileName; + string lastname = Path.GetFileName(filePath); + + 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(); + } + + } + } + } + + public struct LineStruct + { + public string layerName; + public string layerCode; + public string lineLength; + public string hxName; + } + + List lineStruct = new List(); + List featsList = new List(); + + /// + /// 红线审核 + /// + /// + /// + private void buttonItemHX2_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemHX2.Text); + redSH = true; + featsList.Clear(); + lineStruct.Clear(); + List listPipelineLayers = new List(); + + GSOLayer layer = null; + for (int i = 0; i < m_PipelineLayerNames.Count; i++) + { + layer = globeControl1.Globe.Layers.GetLayerByCaption(m_PipelineLayerNames[i]); + if (layer != null) + { + listPipelineLayers.Add(layer); + } + } + //yanxiaowei 重构 + GSOFeatures selectFeatures=new GSOFeatures(); + for (int i = 0; i < globeControl1.Globe.SelObjectCount; i++) + { + GSOFeature feature = null; + globeControl1.Globe.GetSelectObject(i, out feature, out layer); + selectFeatures.Add(feature); + } + DataTable table=new DataTable(); + + ClassGSOTool.CalculateRedLineResult(out table, redSH, selectFeatures, globeControl1, + listPipelineLayers,out lineStruct, out featsList); + + if (table.Rows.Count != 0) + AddDatagridView(table); + else + { + MessageBox.Show("没有侵入地块红线的管线数据!", "提示"); + dataGridViewX1.DataSource = null; + panelOfTable.Visible = false; + return; + } + } + + private void AddDatagridView(DataTable table) + { + dataGridViewX1.DataSource = table; + panelOfTable.Visible = true; + panelOfTable.Height = 200; + toolStripNumbers.Text = "红线审核 |共有:" + table.Rows.Count + "条"; + toolStripDropDownButton3.Visible = true; + } + /// + /// 主窗体 下方的工具条中的 导出.xls文件 按钮事件处理 + /// + /// + /// + private void toolStripDropDownButton3_Click(object sender, EventArgs e) + { + if (dataGridViewX1.Rows.Count == 0) + { + MessageBox.Show("表格内容为空!", "提示"); + return; + } + + string strSaveFile = string.Empty; + SaveFileDialog savefiledialog = new SaveFileDialog(); + savefiledialog.Filter = "Excel文件|*.xls,*.xlsx"; + savefiledialog.AddExtension = true; + savefiledialog.FileName = "红线审核"; + if (savefiledialog.ShowDialog() == DialogResult.OK) + strSaveFile = savefiledialog.FileName; + else return; + + ExpEXCEL.ExpToExcel(dataGridViewX1, strSaveFile, "红线审核", lineStruct, featsList); + MessageBox.Show("导出成功!"); + } + /// + /// 去除集合中重复的管线 + /// + /// + /// + /// + private GSOFeatures getFeaturesByFilter(GSOFeatures features, string fieldName) + { + if (features == null) + { + return null; + } + GSOFeatures featuresGet = new GSOFeatures(); + for (int i = 0; i < features.Length; i++) + { + GSOFeature featureFromFS = features[i]; + string fieldValueFromFS = featureFromFS.GetValue(fieldName).ToString().Trim(); + bool isHas = false; + for (int j = featuresGet.Length - 1; j >= 0; j--) + { + GSOFeature featureFromFSGet = featuresGet[j]; + string fieldValueFromFSGet = featureFromFSGet.GetValue(fieldName).ToString().Trim(); + if (fieldValueFromFS.Equals(fieldValueFromFSGet)) + { + isHas = true; + break; + } + } + if (isHas == false) + { + featuresGet.Add(featureFromFS.Clone()); + } + } + return featuresGet; + } + + private void sliderItem2_ValueChanged(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.sliderItem2.Text); + + globeControl1.Globe.GroundOpaque = 100 - sliderItem2.Value; + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(roadLayerName);//("180fd"); + if (layer != null) + { + layer.Opaque = 100 - sliderItem2.Value; + } + layer = globeControl2.Globe.Layers.GetLayerByCaption("180fd");//("180fd"); + if (layer != null) + { + layer.Opaque = 100 - sliderItem2.Value; + } + globeControl2.Globe.GroundOpaque = 100 - sliderItem2.Value; + + optiValue = sliderItem2.Value; + } + /// + /// 数据管理导入文件 + /// + /// + /// + private void buttonItemSJGL1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL1.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.Multiselect = true; + if (dlg.ShowDialog() == DialogResult.OK) + { + //自定义lprj文件名,从程序中复制一lprj文件。 + string filePath = dlg.FileName; + string lastname = Path.GetFileName(filePath); + + 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, 100); + + globeControl1.Refresh(); + } + } + } + + private void buttonItemHX1_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemHX1.Text); + + GSODataSource dataSpace = globeControl1.Globe.DataManager.OpenOracleDataSource(Utility.DBServer.Trim() + "/" + Utility.dbdatabase.Trim(), "", "", Utility.userID, Utility.DBPassword); + string filepath = ""; + //日志记录 + OpenFileDialog dlg = new OpenFileDialog(); + dlg.Filter = "矢量数据(*.shp)|*.shp|矢量数据(*.lgd)|*.lgd|CAD数据(*.dxf)|*.dxf|全部支持格式(*.lgd,*.shp,*.dxf)|*.lgd;*.shp;*.dxf;"; + dlg.Multiselect = true; + + #region 临时图层显示 + if (dlg.ShowDialog() == DialogResult.OK) + { + string filePath = dlg.FileName; + string lastname = Path.GetFileName(filePath); + + #region + for (int i = 0; i < dlg.FileNames.Length; i++) + { + string strDataPath = dlg.FileNames[i]; + filepath = strDataPath; + + GSOLayer layer = globeControl1.Globe.Layers.Add(strDataPath); + GSOFeatures RedFeatures = layer.GetAllFeatures(); + + 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(); + RedFeatures = features; + 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; + } + + /////////////////////////////////////////////////////////////////////////////////////////// + globeControl1.Globe.Layers.MoveTo(0, globeControl1.Globe.Layers.Count - 1); + globeControl1.Refresh(); + } + + IModelBuilder modelBuilder = new RedLineBuilder(); + + modelBuilder.batchInsert(dataSpace, redDt, RedFeatures); + + } + #endregion + + } + #endregion + } + /// + /// 定位 + /// + /// + /// + private void buttonItemLocation_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemLocation.Text); + + FrmFlyToPosition fly = new FrmFlyToPosition(globeControl1,globeControl2); + fly.Show(this); + } + /// + /// 2015-10-17演示代码 红线审核 + /// + /// + /// + private void ribbonTabItem6_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.FlyToPosition(new GSOPoint3d(120.610963, 31.188121, 50), EnumAltitudeMode.Absolute, -4, 50, 800); + globeControl1.Globe.FlyToPointSpeed = 10000000; + globeControl1.Globe.Action = EnumAction3D.SelectObject; + globeControl1.Refresh(); + + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + + //zhanshi = false; + redSH = true; + splitContainer1.Panel2Collapsed = true; + legendSG.Visible = false; + legendSC.Visible = false; + ClearGZData(); + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = true; + } + + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 基础工具 + /// + /// + /// + private void ribbonTabItem1_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + //zhanshi = false; + redSH = false; + splitContainer1.Panel2Collapsed = true; + panelOfTable.Visible = false; + legendSC.Visible = false; + legendSG.Visible = false; + ClearGZData(); + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + + + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 一键审核 + /// + /// + /// + private void ribbonTabItem11_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + //zhanshi = false; + redSH = false; + splitContainer1.Panel2Collapsed = true; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + panelOfTable.Visible = false; + legendSC.Visible = false; + legendSG.Visible = false; + ClearGZData(); + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + + + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 右屏添加冰箱数据 + /// + void AddDataToGlobeControl2() + { + + bool modelDataBool = false; + for (int i = globeControl2.Globe.Layers.Count - 1; i >= 0; i--) + { + GSOLayer layer = globeControl2.Globe.Layers[i]; + if (layer.Name.Contains("fttp:")) + { + modelDataBool = true; + break; + } + } + + if (modelDataBool == false) + { + GSOLayer ly = globeControl1.Globe.Layers.GetLayerByCaption("天地图地图"); + globeControl2.Globe.Layers.Add(ly); + } + else + { + return; + } + } + /// + /// 双屏对比 + /// + /// + /// + private void ribbonTabItem9_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent += new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent += new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + panelOfTable.Visible = false; + + splitContainer1.Panel2Collapsed = false; + //zhanshi = true; + redSH = false; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + sliderItem2.Value = 100 - globeControl1.Globe.GroundOpaque; + globeControl2.Globe.GroundOpaque = globeControl1.Globe.GroundOpaque; + legendSC.Visible = true; + legendSG.Visible = true; + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + AddDataToGlobeControl2(); + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 文档管理 + /// + /// + /// + private void ribbonTabItem4_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + panelOfTable.Visible = false; + //zhanshi = false; + redSH = false; + splitContainer1.Panel2Collapsed = true; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + legendSC.Visible = false; + legendSG.Visible = false; + ClearGZData(); + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 基础管理 + /// + /// + /// + private void ribbonTabItem14_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + panelOfTable.Visible = false; + //zhanshi = false; + redSH = false; + splitContainer1.Panel2Collapsed = true; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + legendSC.Visible = false; + legendSG.Visible = false; + ClearGZData(); + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 权限管理 + /// + /// + /// + private void ribbonTabItem2_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + panelOfTable.Visible = false; + //zhanshi = false; + redSH = false; + splitContainer1.Panel2Collapsed = true; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + legendSC.Visible = false; + legendSG.Visible = false; + ClearGZData(); + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + GSOFeature dpFeatuer = null; + /// + /// 双屏分析,点击管段分析 + /// + /// + /// + private void buttonItem8_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItem8.Text); + + //FrmCompareFeature frmCompareFeature = new FrmCompareFeature(globeControl1, globeControl2, layerTemp, layerTemp2,m_PipelineLayerNames,sgPipeLayersNames); + int width = this.Width; + FrmCompareFeature.ShowForm(globeControl1, globeControl2, layerTemp, layerTemp2, m_PipelineLayerNames, sgPipeLayersNames,width); + //frmCompareFeature.Location = new Point((this.Width - frmCompareFeature.Width)/2,50); + //frmCompareFeature.Show(this); + + } + /// + /// 红线审核导出图片 + /// + /// + /// + private void buttonItemDCTP_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemDCTP.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))); + */ + int mapWidth = 0; + int mapHeight = 0; + Point pt = getUpperLeftPoint(pt1, pt2, out mapWidth, out mapHeight); + int rightBottomX = pt.X + mapWidth; + int rightBottomY = pt.Y + mapHeight; + Image myImg = new Bitmap(mapWidth, mapHeight); + Graphics g = Graphics.FromImage(myImg); + g.CopyFromScreen(pt, new Point(0, 0), new Size(rightBottomX, rightBottomY)); + + 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; + } + } + } + /// + /// 标识器全区域统计 + /// + /// + /// + private void 标识器分类统计ToolStripMenuItem_Click(object sender, EventArgs e) + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + FrmBSQStatis bsqStatis = new FrmBSQStatis(globeControl1,null); + //FrmBSQStatis bsqStatis = new FrmBSQStatis(); + bsqStatis.Show(this); + } + /// + /// 标识器绘制区域统计 + /// + /// + /// + private void 标识器分类统计ToolStripMenuItem1_Click(object sender, EventArgs e) + { + trackflag = "BSQDuoBianXiangStatis"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + } + + #region 保存和加载审核库加载的图层 + /* + private void saveLayerList(TreeNodeCollection treeNodeList) + { + string configPath = Application.StartupPath + "\\configLayerList.xml"; + try + { + XmlDocument doc = new XmlDocument(); + doc.Load(configPath); + XmlNode dbParams = doc.SelectSingleNode("Params/dbparams"); + XmlNode dbLayers = doc.SelectSingleNode("Params/dblayers"); + XmlNode layers = doc.SelectSingleNode("Params/layers"); + dbParams.RemoveAll(); + dbLayers.RemoveAll(); + layers.RemoveAll(); + + List listDS = new List(); + String shDatasourceName = Utility.sgdbip + "/" + Utility.sgdbname + "_" + Utility.sgdbuser; + bool flag = false; + + for (int i = 0; i < globeControl1.Globe.DataManager.DataSourceCount; i++) + { + GSODataSource ds = globeControl1.Globe.DataManager.GetDataSourceAt(i); + if (ds != null && ds.Type == EnumDataSourceType.SqlServer || ds.Type == EnumDataSourceType.Oracle) + { + if (ds.Name == shDatasourceName) + { + //防止因为多次连接同一个数据库 + if (flag == true) + { + break; + } + flag = true; + listDS.Add(ds); + GSODataSourceCnn conn = ds.GetConnectionInfo(); + + XmlElement dbparam = doc.CreateElement("shdbparam"); + XmlElement ip = doc.CreateElement("ship"); + ip.InnerText = conn.Server; + + XmlElement dbname = doc.CreateElement("shdbname"); + dbname.InnerText = conn.Database; + + XmlElement username = doc.CreateElement("shusername"); + username.InnerText = conn.User; + + XmlElement password = doc.CreateElement("shpassword"); + password.InnerText = conn.Password; + + XmlElement type = doc.CreateElement("shtype"); + if (ds.Type == EnumDataSourceType.SqlServer) + { + type.InnerText = "sqlserver"; + } + else + { + type.InnerText = "oracle"; + } + + dbparam.AppendChild(ip); + dbparam.AppendChild(dbname); + dbparam.AppendChild(username); + dbparam.AppendChild(password); + dbparam.AppendChild(type); + dbParams.AppendChild(dbparam); + } + + } + } + + for (int i = 0; i < treeNodeList.Count; i++) + { + GSOLayer layer = treeNodeList[i].Tag as GSOLayer; + if (Path.GetExtension(layer.Name) == "") + { + XmlElement dbLayer = doc.CreateElement("dblayer"); + XmlAttribute attri = doc.CreateAttribute("dbindex"); + for (int j = 0; j < listDS.Count; j++) + { + if (layer.Dataset.DataSource.Name == listDS[j].Name) + { + attri.Value = j.ToString(); + break; + } + } + dbLayer.Attributes.Append(attri); + dbLayer.InnerText = layer.Name; + + dbLayers.AppendChild(dbLayer); + } + else + { + XmlElement dbLayer = doc.CreateElement("layer"); + dbLayer.InnerText = layer.Name; + layers.AppendChild(dbLayer); + } + } + + doc.Save(configPath); + } + catch (Exception e) + { + + } + } + + private void openLayerList() + { + layerManagerNode.Nodes.Clear(); + + string configPath = Application.StartupPath + "\\configLayerList.xml"; + try + { + XmlDocument doc = new XmlDocument(); + doc.Load(configPath); + XmlNode dbParams = doc.SelectSingleNode("Params/dbparams"); + XmlNode dbLayers = doc.SelectSingleNode("Params/dblayers"); + XmlNode layers = doc.SelectSingleNode("Params/layers"); + + List listDS = new List(); + for (int i = 0; i < dbParams.ChildNodes.Count; i++) + { + string ip = ""; + string dbname = ""; + string username = ""; + string password = ""; + string type = ""; + XmlNode node = dbParams.ChildNodes.Item(i); + for (int j = 0; j < node.ChildNodes.Count; j++) + { + XmlNode nodeChild = node.ChildNodes.Item(j); + + if (nodeChild != null && nodeChild.Name == "ship") + { + ip = nodeChild.InnerText; + } + else if (nodeChild != null && nodeChild.Name == "shdbname") + { + dbname = nodeChild.InnerText; + } + else if (nodeChild != null && nodeChild.Name == "shusername") + { + username = nodeChild.InnerText; + } + else if (nodeChild != null && nodeChild.Name == "shpassword") + { + password = nodeChild.InnerText; + } + else if (nodeChild != null && nodeChild.Name == "shtype") + { + type = nodeChild.InnerText; + } + } + + if (type == "sqlserver") + { + GSODataSource ds = globeControl1.Globe.DataManager.OpenSqlServerDataSource(ip, "", dbname, username, password); + listDS.Add(ds); + } + else if (type == "oracle") + { + GSODataSource ds = globeControl1.Globe.DataManager.OpenOracleDataSource(ip + "/" + dbname, "", "", username, password); + listDS.Add(ds); + } + } + + for (int i = 0; i < dbLayers.ChildNodes.Count; i++) + { + XmlNode node = dbLayers.ChildNodes.Item(i); + if (node != null) + { + string layerName = node.InnerText; + XmlAttribute attri = node.Attributes["dbindex"]; + if (attri != null) + { + int dbIndex = -1; + if (int.TryParse(attri.Value, out dbIndex)) + { + GSODataset dataset = listDS[dbIndex].GetDatasetByName(layerName); + globeControl1.Globe.Layers.Add(dataset); + //更新树节点 + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + TreeNode layerNode = new TreeNode(); + layerNode.Tag = layer; + layerNode.Text = layer.Dataset.Caption; + layerNode.ImageIndex = 0; + layerNode.SelectedImageIndex = 0; + layerNode.Checked = layer.Visible; + layerManagerNode.Nodes.Insert(0, layerNode); + // layerManagerNode.Expand(); + + + } + } + } + } + for (int i = 0; i < layers.ChildNodes.Count; i++) + { + XmlNode node = layers.ChildNodes.Item(i); + if (node != null) + { + string layerName = node.InnerText; + globeControl1.Globe.Layers.Add(layerName); + + //更新树节点 + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + TreeNode layerNode = new TreeNode(); + layerNode.Tag = layer; + layerNode.Text = layer.Dataset.Caption; + layerNode.ImageIndex = 0; + layerNode.SelectedImageIndex = 0; + layerNode.Checked = layer.Visible; + layerManagerNode.Nodes.Insert(0, layerNode); + } + } + layerManagerNode.Expand(); + } + catch (Exception e) + { + + } + } + * */ + #endregion + + private void btn_check_history_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_check_history.Text); + + if (FrmCheckHistory.isOpen == true) + { + return; + } + FrmCheckHistory frm = new FrmCheckHistory(globeControl1, globeControl2); + frm.addNode += new AddNodeToLayerManagerNode(addNodeToLayerManagerNode); + frm.Show(); + + } + + private void buttonItem查看数据_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItem查看数据.Text); + + FrmThreeOracle tr = new FrmThreeOracle(globeControl1); + + if (tr.ShowDialog() == DialogResult.OK) + { + addNodeToLayerManagerNode(tr.rukuLayer); + globeControl1.Refresh(); + } + } + /// + /// 规划数据入库 + /// + /// + /// + private void buttonItemGHRK_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemGHRK.Text); + + FrmGHRK ghrk = new FrmGHRK(globeControl1, layerManagerNode); + ghrk.Show(this); + } + + private void btn_user_info_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_user_info.Text); + + if (!FrmSysUserInfoManger.IS_OPEN) + { + FrmSysUserInfoManger frm = new FrmSysUserInfoManger(); + frm.ShowDialog(); + } + } + + private void btn_role_info_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_role_info.Text); + + if (FrmRoleInfoManager.IS_OPEN) + { + return; + } + FrmRoleInfoManager frm = new FrmRoleInfoManager(); + frm.ShowDialog(); + } + + private void btn_resc_info_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_resc_info.Text); + + if (!SysRescInfoManager.IS_OPEN) + { + SysRescInfoManager frm = new SysRescInfoManager(); + frm.ShowDialog(); + } + } + + private void btn_role_resc_Click(object sender, EventArgs e) + { + + LogManager.saveLog(Utility.userName, this.btn_role_resc.Text); + + if (!FrmRoleRescManager.IS_OPEN) + { + FrmRoleRescManager frm = new FrmRoleRescManager(); + frm.ShowDialog(); + } + } + + private void btn_user_role_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_user_role.Text); + + if (FrmUserRole.IS_OPEN) + { + return; + } + FrmUserRole frm = new FrmUserRole(); + frm.ShowDialog(); + } + + private void btn_document_info_Click(object sender, EventArgs e) + { + + LogManager.saveLog(Utility.userName, this.btn_document_info.Text); + + //if (FormDocumentManager.IS_OPEN) + //{ + // return; + //} + //FormDocumentManager frm = new FormDocumentManager(); + //frm.ShowDialog(); + + //if (FormDocumentManager.IS_OPEN) + //{ + // return; + //} + //new FormDocumentManager().ShowDialog(); + if (FormDocumentManager.IS_OPEN) + { + return; + } + this.Cursor = Cursors.WaitCursor; + FormDocumentManager frm = new FormDocumentManager(); + frm.changeCursor += new ChangeCursor(changeCursorToDefault); + frm.ShowDialog(); + + } + + private void changeCursorToDefault() + { + this.Cursor = Cursors.Default; + } + + /// + /// 判断CAD文件是否有投影信息 + /// + /// + /// + Boolean CheckDatasetGeoReference(GSODataset dataset) + { + Boolean bSuccess = false; + if (dataset.GeoReferenceType == EnumGeoReferenceType.Flat) + { + if (MessageBox.Show("数据没有空间参考信息,请设置空间参考信息!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation) == DialogResult.OK) + { + String strPath = Path.GetDirectoryName(Application.ExecutablePath) + "\\Coordinate Systems"; + OpenFileDialog dlg = new OpenFileDialog(); + + dlg.InitialDirectory = strPath; + dlg.RestoreDirectory = true; + + dlg.Filter = "投影文件|*.prj||"; + if (dlg.ShowDialog() == DialogResult.OK) + { + bSuccess = dataset.LoadProjectionFromESRIFile(dlg.FileName); + } + } + } + else + { + return true; + } + return bSuccess; + } + + private void buttonItemexp_CAD_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemexp_CAD.Text); + + OpenFileDialog dlg = new OpenFileDialog(); + dlg.Filter = "支持格式(*.dwg)|*.dwg"; + dlg.Multiselect = true; + if (dlg.ShowDialog() == DialogResult.OK) + { + for (int i = 0; i < dlg.FileNames.Length; i++) + { + //this.Cursor = Cursors.WaitCursor; + string strDataPath = dlg.FileNames[i]; + + #region + //string strDataPathPrj = strDataPath.ToLower().Replace(".dwg", ".lprj"); + + //if (File.Exists(strDataPathPrj) == false) + //{ + // if (MessageBox.Show("数据没有空间参考信息,请设置空间参考信息!", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation) == DialogResult.OK) + // { + // String strPath = Application.StartupPath + "\\Coordinate Systems"; + // OpenFileDialog dlgPrj = new OpenFileDialog(); + // dlgPrj.InitialDirectory = strPath; + // dlgPrj.RestoreDirectory = true; + // dlgPrj.Multiselect = false; + // dlg.Filter = "投影文件|*.prj"; + // if (dlg.ShowDialog() == DialogResult.OK) + // { + // this.Cursor = Cursors.WaitCursor; + // string proj4 = GSODataEngineUtility.ConvertEsriPrjFileToProj4(dlg.FileName); + // using (StreamWriter stream = new StreamWriter(strDataPathPrj, false)) + // { + // stream.WriteLine("0prj4" + proj4 + ""); + // } + // AddLayerData(strDataPath); + // //globeControl1.Globe.Layers.Add(strDataPath); + + // this.Cursor = Cursors.Default; + // } + // else + // { + // AddLayerData(strDataPath); + // //globeControl1.Globe.Layers.Add(strDataPath); + // } + // } + // else + // { + // AddLayerData(strDataPath); + // //globeControl1.Globe.Layers.Add(strDataPath); + // } + + //} + //else + //{ + // //globeControl1.Globe.Layers.Add(strDataPath); + // AddLayerData(strDataPath); + //} + #endregion + AddLayerData(strDataPath); + //this.Cursor = Cursors.Default; + } + } + + 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, 100); + + globeControl1.Refresh(); + } + } + + private void btn_password_edit_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_password_edit.Text); + + if (FrmChangePassword.IS_OPEN) + { + return; + } + FrmChangePassword frm = new FrmChangePassword(); + frm.ShowDialog(); + } + /// + /// 多孔管线入库 + /// + /// + /// + private void buttonItem9_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL4_2.Text); + + if (ds == null) + { + MessageBox.Show("请先连接数据库", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + ConnectDB(null, null); + } + if (ds == null) + return; + + FrmMultiPipelineModelDB frm = new FrmMultiPipelineModelDB(globeControl1, ds); + if (frm.ShowDialog() == DialogResult.OK) + { + addNodeToLayerManagerNode(frm.rukuLayer); + } + //frm.Show(); + } + private void 导出CADToolStripMenuItem1_Click(object sender, EventArgs e) + { + TreeNode node = layerNodeContexMenu.Tag as TreeNode; + if (node == null) + { + MessageBox.Show("请在左侧节点集中选择要导出的图层", "提示"); + return; + } + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(node.Text.Trim()); + if (layer == null || layer.GetAllFeatures().Length <= 0) + { + MessageBox.Show("要导出的图层为空", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + return; + } + string strProjectName = Utility.projectStr; + if (strProjectName != "") + { + SaveFileDialog dlg = new SaveFileDialog(); + dlg.Filter = "*.dwg|*.dwg|*.dxf|*.dxf"; + dlg.FileName = layer.Caption; + if (dlg.ShowDialog(this) == DialogResult.OK) + { + globeControl1.Globe.MemoryLayer.SaveAs(dlg.FileName); + GSOLayer newlayer = globeControl1.Globe.Layers.Add(dlg.FileName); + newlayer.RemoveAllFeature(); + int featureCount = layer.GetAllFeatures().Length; + for (int i = 0; i < featureCount; i++) + { + GSOFeature feature = layer.GetAt(i); + if (feature != null && feature.Geometry != null) + { + if (feature.Geometry.Type == EnumGeometryType.GeoPolyline3D) + { + feature.Geometry.Style = new GSOSimpleLineStyle3D(); + } + else if (feature.Geometry.Type == EnumGeometryType.GeoPolygon3D) + { + feature.Geometry.Style = new GSOSimplePolygonStyle3D(); + } + newlayer.AddFeature(feature); + } + } + newlayer.Save(); + newlayer.Dataset.DataSource.RemoveDataset(newlayer.Dataset); + globeControl1.Globe.Layers.Remove(newlayer); + MessageBox.Show("导出CAD完成!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + } + } + } + + private void buttonItemGBJC_Click(object sender, EventArgs e) + { + FrmGBJC gb = new FrmGBJC(globeControl1, globeControl2, layerTemp, layerTemp2); + gb.Show(this); + } + + #region 右屏管纵数据控制 + private void 五十米主干道ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = true; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + + private void 三十六米次干道ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = true; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + + private void 四十二米次干道ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = true; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + + private void 二十四米一块板ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = true; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + + private void 二十四米三块板ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = true; + } + + private void 二十四米停车带ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = true; + lendendGZ24_3.Visible = false; + } + + private void 二十六米大堤路ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = true; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + + private void 清除管纵数据ToolStripMenuItem_Click(object sender, EventArgs e) + { + ClearGZData(); + } + + private void ClearGZData() + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + #endregion + + private void buttonItemPasswordReset_Click(object sender, EventArgs e) + { + Frm_password_reset reset = new Frm_password_reset(); + reset.Show(); + } + + private void pictureBox1_Paint(object sender, PaintEventArgs e) + { + int Width = this.Width; + string welcomeUser = "欢迎您:" + Utility.userName; + Graphics g = e.Graphics; + g.DrawString(welcomeUser, new Font("宋体", 12), new SolidBrush(Color.Black), Width - 180, 50); + } + + } +} \ No newline at end of file diff --git a/MainFrm.cs.BASE.9016.cs b/MainFrm.cs.BASE.9016.cs new file mode 100644 index 0000000..e530fbd --- /dev/null +++ b/MainFrm.cs.BASE.9016.cs @@ -0,0 +1,13442 @@ +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; + + GSOBalloon featureTooltip2; + GSOBalloonEx balloonEx2; + + GSOLayer layerTemp; + GSOLayer layerTemp2; + FrmShResult frmShResult = null; + FrmRedlineResult frmredResult = null; + FrmMnModify frmModify = null; + public bool frmRedlineResult = false; + public bool boolfrmShResult = false; + public bool boolfrmModify = false; + + List m_PipelineLayerNames = new List();//线图层名称 + List workwellLayerNames = new List();//工井图层名称 + List valueLayerNames = new List();//阀门图层名称 + List instrumenLayerNames = new List();//附属物图层名称 + List pipefittingLayerNames = new List();//管件图层名称 + List sgPipeLayersNames = new List();//施工管线图层名称 + 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 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; + public string redLayer = null; + //GSOLayer redLayer1 = null; + bool redSH = false; + string redDt = "红线"; + //双屏对比 + //bool zhanshi=false; + Thread t = null; + private GSOHudButton legendSC;//定义图例 + private GSOHudButton legendSG;//定义图例 + //管纵图 + private GSOHudButton lendendGZ50; + private GSOHudButton lendendGZ36; + private GSOHudButton lendendGZ42; + private GSOHudButton lendendGZ24_1; + private GSOHudButton lendendGZ24_2; + private GSOHudButton lendendGZ24_3; + private GSOHudButton lendendGZ26; + + GSOGeoPoint3D bsqPT; + + FrmYJSHTC frmSh = null;//一键审核窗口全局变量wxl + FrmWait frmWait = null;//一键审核等待窗口 + //FrmWait frmWait2 = null;//文档操作等待窗口 + + float mouseDownX1,mouseDownY1; + float mouseDownX2,mouseDownY2; + /// + /// + /// + 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; + + featureTooltip2 = new GSOBalloon(globeControl2.Handle); + balloonEx2 = new GSOBalloonEx(globeControl2.Handle); + Utility.SetBallons(featureTooltip, balloonEx); + + panelOfTable.Height = 200; + + RigthMenuSet(); + + MenuSet(); + + } + /// + /// 右屏中添加管纵图片 + /// + private void AddGZ() + { + + lendendGZ50 = new GSOHudButton(); + lendendGZ50.SetImage(Application.StartupPath + "/Resource/管纵/50.png"); + lendendGZ50.SetOffset(0, 0); + lendendGZ50.MinOpaque = 1; + lendendGZ50.MaxOpaque = 1; + lendendGZ50.FadeOut = false; + lendendGZ50.Name = "lendendGZ50"; + lendendGZ50.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ50); + lendendGZ50.Visible = false; + + lendendGZ36 = new GSOHudButton(); + lendendGZ36.SetImage(Application.StartupPath + "/Resource/管纵/36.png"); + lendendGZ36.SetOffset(0, 0); + lendendGZ36.MinOpaque = 1; + lendendGZ36.MaxOpaque = 1; + lendendGZ36.FadeOut = false; + lendendGZ36.Name = "lendendGZ36"; + lendendGZ36.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ36); + lendendGZ36.Visible = false; + + lendendGZ42 = new GSOHudButton(); + lendendGZ42.SetImage(Application.StartupPath + "/Resource/管纵/42.png"); + lendendGZ42.SetOffset(0, 0); + lendendGZ42.MinOpaque = 1; + lendendGZ42.MaxOpaque = 1; + lendendGZ42.FadeOut = false; + lendendGZ42.Name = "lendendGZ42"; + lendendGZ42.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ42); + lendendGZ42.Visible = false; + + lendendGZ24_1 = new GSOHudButton(); + lendendGZ24_1.SetImage(Application.StartupPath + "/Resource/管纵/24_1.png"); + lendendGZ24_1.SetOffset(0, 0); + lendendGZ24_1.MinOpaque = 1; + lendendGZ24_1.MaxOpaque = 1; + lendendGZ24_1.FadeOut = false; + lendendGZ24_1.Name = "lendendGZ24_1"; + lendendGZ24_1.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ24_1); + lendendGZ24_1.Visible = false; + + lendendGZ24_2 = new GSOHudButton(); + lendendGZ24_2.SetImage(Application.StartupPath + "/Resource/管纵/24_2.png"); + lendendGZ24_2.SetOffset(0, 0); + lendendGZ24_2.MinOpaque = 1; + lendendGZ24_2.MaxOpaque = 1; + lendendGZ24_2.FadeOut = false; + lendendGZ24_2.Name = "lendendGZ24_2"; + lendendGZ24_2.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ24_2); + lendendGZ24_2.Visible = false; + + lendendGZ24_3 = new GSOHudButton(); + lendendGZ24_3.SetImage(Application.StartupPath + "/Resource/管纵/24_3.png"); + lendendGZ24_3.SetOffset(0, 0); + lendendGZ24_3.MinOpaque = 1; + lendendGZ24_3.MaxOpaque = 1; + lendendGZ24_3.FadeOut = false; + lendendGZ24_3.Name = "lendendGZ24_3"; + lendendGZ24_3.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ24_3); + lendendGZ24_3.Visible = false; + + lendendGZ26 = new GSOHudButton(); + lendendGZ26.SetImage(Application.StartupPath + "/Resource/管纵/26.png"); + lendendGZ26.SetOffset(0, 0); + lendendGZ26.MinOpaque = 1; + lendendGZ26.MaxOpaque = 1; + lendendGZ26.FadeOut = false; + lendendGZ26.Name = "lendendGZ26"; + lendendGZ26.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ26); + lendendGZ26.Visible = false; + + } + + public void RigthMenuSet() + { + if (Utility.userRole.IndexOf("清除分析") < 0) + { + toolRightMenu.Items.Remove(清除分析ToolStripMenuItem); + } + + #region 区域分析 + if (Utility.userRole.IndexOf("区域分析") < 0) + { + toolRightMenu.Items.Remove(区域分析ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("缓冲区分析") < 0) + { + 区域分析ToolStripMenuItem.DropDownItems.Remove(缓冲区分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("附属物分析") < 0) + { + 区域分析ToolStripMenuItem.DropDownItems.Remove(附属物分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("无源淹没分析") < 0) + { + 区域分析ToolStripMenuItem.DropDownItems.Remove(无源淹没分析ToolStripMenuItem); + } + } + #endregion + + #region 视域分析 + if (Utility.userRole.IndexOf("视域分析") < 0) + { + toolRightMenu.Items.Remove(视域分析ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("通视分析") < 0) + { + 视域分析ToolStripMenuItem.DropDownItems.Remove(通视分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("可视域分析") < 0) + { + 视域分析ToolStripMenuItem.DropDownItems.Remove(可视域分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("可视包络分析") < 0) + { + 视域分析ToolStripMenuItem.DropDownItems.Remove(可视包络分析ToolStripMenuItem); + } + } + #endregion + + #region 开发分析 + if (Utility.userRole.IndexOf("开挖分析") < 0) + { + toolRightMenu.Items.Remove(开挖分析ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("多边形开挖") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(多边形开挖ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("挖方量分析") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(挖方量分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("沿线开挖") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(沿线开挖ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("创建隧道") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(创建隧道ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("隐藏隧道") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(隐藏隧道ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("删除隧道") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(删除隧道ToolStripMenuItem); + } + } + #endregion + + #region 拓扑分析 + if (Utility.userRole.IndexOf("拓扑分析") < 0) + { + toolRightMenu.Items.Remove(拓扑分析ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("创建拓扑") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(创建拓扑ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("上游分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(上游分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("下游分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(下游分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("流向分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(流向分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("关阀分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(关阀分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("连通分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(连通分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("爆管分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(爆管分析ToolStripMenuItem); + } + } + #endregion + + #region 断面分析 + if (Utility.userRole.IndexOf("断面分析") < 0) + { + toolRightMenu.Items.Remove(断面分析ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("横断面分析") < 0) + { + 断面分析ToolStripMenuItem.DropDownItems.Remove(横断面分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("纵断面分析") < 0) + { + 断面分析ToolStripMenuItem.DropDownItems.Remove(纵断面分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("道路断面分析") < 0) + { + 断面分析ToolStripMenuItem.DropDownItems.Remove(道路断面分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("基线剖面分析") < 0) + { + 断面分析ToolStripMenuItem.DropDownItems.Remove(基线剖面分析ToolStripMenuItem); + } + } + #endregion + + #region 绘制区域统计 + if (Utility.userRole.IndexOf("绘制区域统计") < 0) + { + toolRightMenu.Items.Remove(绘制区域统计ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("绘制区域管线长度统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管线长度统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域阀门数量统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(阀门数量统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域井盖数量统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(井盖数量统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域管径分段统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管径分段统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域埋深分段统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(埋深分段统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域管径分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管径分类统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域材质分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(材质分类统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域附属物分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(附属物分类统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域标识器分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(标识器分类统计ToolStripMenuItem1); + } + + } + #endregion + + #region 全区域统计 + if (Utility.userRole.IndexOf("全区域统计") < 0) + { + toolRightMenu.Items.Remove(全区域统计ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("全区域管线长度统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管线长度统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域阀门数量统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(阀门数量统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域井盖数量统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(井盖数量统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域管径分段统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管径分段统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域埋深分段统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(埋深分段统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域管径分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管径分类统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域材质分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(材质分类统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域附属物分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(附属物分类统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域标识器分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(标识器分类统计ToolStripMenuItem); + } + + } + #endregion + + #region 查询 + if (Utility.userRole.IndexOf("查询") < 0) + { + toolRightMenu.Items.Remove(查询ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("空间查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(空间查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("编号查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(编号查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("坐标查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(坐标查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("管径查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(管径查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("材质查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(材质查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("基本查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(基本查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("复合查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(复合查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("关联查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(关联查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("关键字查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(关键字查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("附属物查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(附属物查询ToolStripMenuItem); + } + } + #endregion + + #region 标注 + if (Utility.userRole.IndexOf("标注") < 0) + { + toolRightMenu.Items.Remove(标注ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("标高标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(标高标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("管径标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(管径标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("埋深标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(埋深标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("坐标标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(坐标标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("距离标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(距离标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("自定义标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(自定义标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("扯旗标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(扯旗标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("坡度标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(坡度标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("属性标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(属性标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("标注管理") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(标注管理ToolStripMenuItem); + } + } + #endregion + + #region 飞行 + if (Utility.userRole.IndexOf("飞行") < 0) + { + toolRightMenu.Items.Remove(飞行ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("自定义飞行") < 0) + { + 飞行ToolStripMenuItem.DropDownItems.Remove(自定义飞行ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("飞行到目标点") < 0) + { + 飞行ToolStripMenuItem.DropDownItems.Remove(飞行到目标点ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("绕中心点飞行") < 0) + { + 飞行ToolStripMenuItem.DropDownItems.Remove(绕中心点飞行ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("绕眼睛飞行") < 0) + { + 飞行ToolStripMenuItem.DropDownItems.Remove(绕眼睛飞行ToolStripMenuItem); + } + } + #endregion + + #region 编辑 + if (Utility.userRole.IndexOf("编辑") < 0) + { + toolRightMenu.Items.Remove(编辑ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("平移对象") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(平移对象ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("升降对象") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(升降对象ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("旋转对象") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(旋转对象ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("连接管段") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(连接管段ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("导出文件") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(导出文件ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("前进") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(前进ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("后退") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(删除模型ToolStripMenuItem); + } + } + #endregion + + #region 量算 + if (Utility.userRole.IndexOf("量算") < 0) + { + toolRightMenu.Items.Remove(量算ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("水平距离") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(水平距离ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("垂直距离") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(垂直距离ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("空间距离") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(空间距离ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("地表距离") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(地表距离ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("高度量算") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(高度量算ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("水平面积") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(水平面积ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("地表面积") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(地表面积ToolStripMenuItem1); + } + } + #endregion + } + + public void MenuSet() + { + + #region 权限管理 + if (Utility.userRole.IndexOf("权限管理") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem2); + } + else + { + + if (Utility.userRole.IndexOf("用户管理") < 0) + { + btn_user_info.Visible = false; + } + if (Utility.userRole.IndexOf("角色管理") < 0) + { + btn_role_info.Visible = false; + } + if (Utility.userRole.IndexOf("资源管理") < 0) + { + btn_resc_info.Visible = false; + } + if (Utility.userRole.IndexOf("角色授权") < 0) + { + btn_role_resc.Visible = false; + } + if (Utility.userRole.IndexOf("用户授权") < 0) + { + btn_user_role.Visible = false; + } + if (Utility.userRole.IndexOf("密码修改") < 0) + { + btn_password_edit.Visible = false; + } + + } + #endregion + + #region 基础工具 + if (Utility.userRole.IndexOf("基础工具") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem1); + } + else + { + if (Utility.userRole.IndexOf("地上模式") < 0) + { + buttonItem87.Visible = false; + } + if (Utility.userRole.IndexOf("地下模式") < 0) + { + buttonItem88.Visible = false; + } + if (Utility.userRole.IndexOf("行走模式") < 0) + { + buttonItem27.Visible = false; + } + if (Utility.userRole.IndexOf("透明度设置") < 0) + { + sliderGroundTransSet1.Visible = false; + } + if (Utility.userRole.IndexOf("快速定位") < 0) + { + buttonItem91.Visible = false; + } + if (Utility.userRole.IndexOf("图层管理") < 0) + { + buttonItem1.Visible = false; + } + if (Utility.userRole.IndexOf("图例管理") < 0) + { + btnlegendSet.Visible = false; + } + if (Utility.userRole.IndexOf("全屏显示") < 0) + { + buttonItem89.Visible = false; + } + if (Utility.userRole.IndexOf("导出图片") < 0) + { + btnOutputJPG.Visible = false; + } + + } + #endregion + + #region 一键审核 + if (Utility.userRole.IndexOf("一键审核") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem11); + } + #endregion + + #region 红线审核 + if (Utility.userRole.IndexOf("红线审核") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem6); + } + #endregion + + #region 双屏对比 + if (Utility.userRole.IndexOf("双屏对比") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem9); + } + #endregion + + #region 文档管理 + if (Utility.userRole.IndexOf("文档管理") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem4); + } + #endregion + + #region 基础管理 + if (Utility.userRole.IndexOf("基础管理") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem14); + } + else + { + if (Utility.userRole.IndexOf("专题图审批") < 0) + { + buttonItemZTT3_2.Visible = false; + } + if (Utility.userRole.IndexOf("打印审批") < 0) + { + buttonItemZTT4_2.Visible = false; + } + if (Utility.userRole.IndexOf("拷贝审批") < 0) + { + buttonItemZTT5_2.Visible = false; + } + } + + #endregion + + if (ribbonControl1.Items.Count <= 0) + { + ribbonControl1.Visible = false; + } + } + + #region Fan Zhang 重构现有代码 + //初始化控件布局 + private void initLayout() + { + 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.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.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.labelX21.Width = (int)(this.labelX21.Width * myScreen); + this.labelX22.Width = (int)(this.labelX22.Width * myScreen); + this.labelX24.Width = (int)(this.labelX24.Width * myScreen); + } + sideBar1.Visible = false; + 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]); + } + + splitContainer1.Panel2Collapsed = true; + + buttonItem87.Checked = true;//默认地上模式 + ribbonTabItem1.Select(); //初始化状态为浏览 + + sideBarPanelItem3.Visible = false; + layerTree.Visible = false; + controlContainerItem3.Visible = false; + if (sideBarPanelItem4.Visible == true) + { + sideBar1.Visible = true; + controlContainerItem5.Visible = true; + } + else + { + sideBar1.Visible = false; + } + Refresh(); + sliderGroundTransSet1.Value = optiValue; + sliderItem1.Value = optiValue; + sliderItem2.Value = optiValue; + sliderItem3.Value = optiValue; + + } + + //初始化地球控件 + private void initGlobalControl() + { + //选择 + btnToolSelect = new GSOHudButton(); + btnToolSelect.SetImage(Application.StartupPath + "\\Resource\\image\\select1.png"); + btnToolSelect.FadeOut = false; + btnToolSelect.Align = EnumAlign.TopLeft; + btnToolSelect.SetOffset(20, 50); + btnToolSelect.Name = "1"; + btnToolSelect.HeightFixed = true; + btnToolSelect.WidthFixed = true; + globeControl1.Globe.AddHudControl(btnToolSelect); + globeControl2.Globe.AddHudControl(btnToolSelect); + + //浏览 + 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); + + //图例 + legend = new GSOHudButton(); + legend.SetImage(Application.StartupPath + "/Resource/图例P.jpg");//图例P + legend.SetOffset(0, 15); + legend.MinOpaque = 1; + legend.MaxOpaque = 1; + legend.FadeOut = false; + legend.Name = "legend"; + legend.Align = EnumAlign.BottomRight; + legend.Visible = false; + globeControl1.Globe.AddHudControl(legend); + + //实测 + legendSC = new GSOHudButton(); + legendSC.SetImage(Application.StartupPath + "/Resource/sc.jpg"); + legendSC.SetOffset(0, 15); + legendSC.MinOpaque = 1; + legendSC.MaxOpaque = 1; + legendSC.FadeOut = false; + legendSC.Name = "legendSC"; + legendSC.Align = EnumAlign.BottomRight; + globeControl1.Globe.AddHudControl(legendSC); + legendSC.Visible = false; + + //施工 + legendSG = new GSOHudButton(); + legendSG.SetImage(Application.StartupPath + "/Resource/sg.jpg"); + legendSG.SetOffset(0, 15); + legendSG.MinOpaque = 1; + legendSG.MaxOpaque = 1; + legendSG.FadeOut = false; + legendSG.Name = "legendSG"; + legendSG.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(legendSG); + legendSG.Visible = false; + + //管纵 + AddGZ(); + + 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; + globeControl1.Globe.IsReleaseMemOutOfView = true; + globeControl1.Globe.ControlPanel.Visible = true; + + globeControl2.Globe.UnderGroundFloor.Visible = false; + globeControl2.Globe.OverviewControl.Visible = false; + globeControl2.Globe.ScalerControl.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; + globeControl2.Globe.IsReleaseMemOutOfView = true; + globeControl2.Globe.ControlPanel.Visible = false; + + 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); + + //添加临时图层 + layerTemp = globeControl1.Globe.Layers.Add(Application.StartupPath + "\\tempLgdData.lgd"); + layerTemp2 = globeControl2.Globe.Layers.Add(Application.StartupPath + "\\tempLgdData2.lgd"); + if (layerTemp != null) + { + layerTemp.MaxVisibleAltitude = 1000; + } + + //添加城市7线图层 + 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"); + + //注册对应事件 + this.registerEvent(); + } + + //注册地球事件 + private bool registerEvent() + { + if (globeControl1 == null || globeControl2 == null) + { + return false; + } + 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); + + globeControl2.FeatureMouseClickEvent += new FeatureMouseClickEventHandler(globeControl2_FeatureMouseClickEvent); + globeControl2.CameraBeginMoveEvent += new CameraBeginMoveEventHandler(globeControl2_CameraBeginMoveEvent); + + globeControl1.MouseDoubleClick += new MouseEventHandler(globeControl1_MouseDoubleClick); + globeControl1.MouseClick += new MouseEventHandler(globeControl1_MouseClick); + globeControl1.MouseDown += new MouseEventHandler(globeControl1_MouseDown); + + globeControl2.MouseClick += new MouseEventHandler(globeControl2_MouseClick); + globeControl2.MouseDown += new MouseEventHandler(globeControl2_MouseDown); + + 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); + + return true; + } + + //加载两个地球数据 + private void loadData() + { + Thread t1 = new Thread(new ThreadStart(doLoadDataForGlobalControl1)); + t1.IsBackground = true; + t1.Start(); + + + } + + delegate void LoadDataForGlobalControl(); + + private void connectServer() + { + globeControl1.Globe.ConnectServer(Utility.serverip, Utility.serverport, "", ""); //加载locaServer中的数据 + globeControl2.Globe.ConnectServer(Utility.serverip, Utility.serverport, "", ""); //加载locaServer中的数据 + //初始化TreeView + // 勾选实测图层 + foreach (TreeNode tn in layerTree.Nodes) + { + if (tn.Nodes.Count > 0) + { + if (tn.Text == "实测数据") + { + tn.Checked = true; + foreach (TreeNode tnChild in tn.Nodes) + { + tnChild.Checked = true; + foreach (TreeNode tnGrandChild in tnChild.Nodes) + { + tnGrandChild.Checked = true; + } + } + } + } + } + } + + private void doLoadDataForGlobalControl1() + { + try + { + + globeControl1.Globe.Layers.MoveDown(10000); + //加载实测管线数据 + Utility.dataSource = globeControl1.Globe.DataManager.OpenOracleDataSource(Utility.DBServer.Trim() + "/" + Utility.dbdatabase.Trim(), "", "", Utility.userID, Utility.DBPassword); + + if (Utility.dataSource != null) + { + for (int j = 0; j < Utility.dataSource.DatasetCount; j++) + { + GSODataset dataset = Utility.dataSource.GetDatasetAt(j); + if (dataset != null && dictionaryNetLayerNameAndCaption.ContainsKey(dataset.Caption)) + { + dataset.Caption = dataset.Name; + globeControl1.Globe.Layers.Add(dataset); + } + } + } + //隐藏红线图层 + globeControl1.Globe.Layers.GetLayerByCaption("红线").Visible = false; + + //globleControl1中加载规划数据 + GSODataSource ghDS = globeControl1.Globe.DataManager.OpenOracleDataSource(Utility.ghdbip + "/" + Utility.ghdbname, "", "", Utility.ghdbuser, Utility.ghdbpwd); + if (ghDS != null) + { + for (int j = 0; j < ghDS.DatasetCount; j++) + { + GSODataset dataset = ghDS.GetDatasetAt(j); + if (dataset != null && dictionaryNetLayerNameAndCaption.ContainsKey(dataset.Caption)) + { + dataset.Caption = dataset.Name; + globeControl1.Globe.Layers.Add(dataset); + globeControl1.Globe.Layers[0].Visible = false; + } + } + } + + //globeControl1,globeControl2中加载施工数据 + GSODataSource sgDS = globeControl1.Globe.DataManager.OpenOracleDataSource(Utility.sgdbip + "/" + Utility.sgdbname, "", "", Utility.sgdbuser, Utility.sgdbpwd); + if (sgDS != null) + { + for (int m = 0; m < sgDS.DatasetCount; m++) + { + GSODataset dataset = sgDS.GetDatasetAt(m); + if (dataset != null && !dataset.Caption.Contains("SH") && dictionaryNetLayerNameAndCaption.ContainsKey(dataset.Caption)) + { + dataset.Caption = dataset.Name; + globeControl1.Globe.Layers.Add(dataset); + globeControl1.Globe.Layers[0].Visible = false; + + globeControl2.Globe.Layers.Add(dataset); + globeControl2.Globe.Layers[0].Visible = true; + } + } + } + + LoadDataForGlobalControl ss = new LoadDataForGlobalControl(connectServer); + ss(); + + } + catch (Exception ex) + { + MessageBox.Show(ex.Message); + } + } + + private void initLayerTree() + { + //加载临时图层节点 + layerManagerNode = new TreeNode(); + layerManagerNode.ImageIndex = 0; + layerManagerNode.SelectedImageIndex = 0; + layerManagerNode.Checked = true; + layerManagerNode.Text = "临时图层"; + layerTree.Nodes.Add(layerManagerNode); + + XmlDocument doc = new XmlDocument(); + doc.Load(filename); + XmlNodeList xmlLayerNodes = doc.SelectNodes("//layer"); + + foreach (XmlNode xmlLayerNode in xmlLayerNodes) + { + + //TODO LIST:创建一级TreeNode(实测、规划、施工) + TreeNode nodelayer = new TreeNode(); + string layerName = xmlLayerNode.Attributes["label"].Value; + nodelayer.Text = layerName; + nodelayer.Checked = false; + layerTree.Nodes.Add(nodelayer); + + XmlNodeList xmlChildLayerNodes = xmlLayerNode.ChildNodes; + foreach (XmlNode xmlChildLayerNode in xmlChildLayerNodes) + { + //TODO LIST:创建二级TreeNode节点 + TreeNode secondLevelNode = new TreeNode(); + string layerType = xmlChildLayerNode.Attributes["label"].Value; + secondLevelNode.Text = layerType; + + if (xmlChildLayerNode.Attributes["type"] != null) + { //道路图层特殊处理 + string type = xmlChildLayerNode.Attributes["type"].Value; + secondLevelNode.Tag = type + "|" + layerType; + } + else + { + secondLevelNode.Tag = layerType; + } + secondLevelNode.Checked = false; + nodelayer.Nodes.Add(secondLevelNode); + + XmlNodeList xmlActitualLayerNodes = xmlChildLayerNode.ChildNodes; + + foreach (XmlNode xmlActitualLayerNode in xmlActitualLayerNodes) + { + //TODO LIST:创建三级图层节点 + TreeNode layerNode = new TreeNode(); + string actutallylayerType = xmlActitualLayerNode.Attributes["type"].Value; + string actutallylayerName = xmlActitualLayerNode.Attributes["layer"].Value; + string actutallyLabelName = xmlActitualLayerNode.Attributes["label"].Value; + + layerNode.Text = actutallyLabelName; + layerNode.Tag = layerType + "|" + actutallyLabelName; + layerNode.Checked = false; + secondLevelNode.Nodes.Add(layerNode); + } + + } + + } + + } + + /** + * 读取Config.xml文件,初始化以下全局Map + * m_PipelineLayerNames:管线 + * workwellLayerNames:工井 + * valueLayerNames:阀门 + * instrumenLayerNames:附属物 + * pipefittingLayerNames:特征管点 + * sgPipeLayersNames:施工管线 + **/ + private void initGlobalMap() + { + XmlDocument doc = new XmlDocument(); + doc.Load(filename); + XmlNodeList xmlLayerNodes = doc.SelectNodes("//layerchild"); + + foreach (XmlNode xmlLayerNode in xmlLayerNodes) + { + string layerType = xmlLayerNode.Attributes["type"].Value; + string layerName1 = xmlLayerNode.Attributes["layer"].Value; + string layerchildName = xmlLayerNode.Attributes["label"].Value; + + dictionaryNetLayerNameAndCaption.Add(layerName1, layerchildName); + + if (layerType != "db") + { + if (xmlLayerNode.Attributes["isRoad"] != null) + { + roadLayerName = layerchildName; + } + } + else if (xmlLayerNode.Attributes["isPipeLine"] != null) + { + m_PipelineLayerNames.Add(layerchildName); + g1layername.Add(layerName1); + } + else if (xmlLayerNode.Attributes["isWorkWell"] != null) + { + workwellLayerNames.Add(layerchildName); + g1layername.Add(layerName1); + } + else if (xmlLayerNode.Attributes["isValve"] != null) + { + valueLayerNames.Add(layerchildName); + g1layername.Add(layerName1); + } + else if (xmlLayerNode.Attributes["isAccess"] != null) + { + instrumenLayerNames.Add(layerchildName); + g1layername.Add(layerName1); + } + else if (xmlLayerNode.Attributes["isCharacter"] != null) + { + pipefittingLayerNames.Add(layerchildName); + g1layername.Add(layerName1); + } + else if (xmlLayerNode.Attributes["isSgData"] != null) + { + sgPipeLayersNames.Add(layerchildName); + g1layername.Add(layerName1); + } + + } + } + + private void initMarkerTree() + { + 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); + } + } + } + } + + private void MainFrm_Load(object sender, EventArgs e) + { + + this.initGlobalControl(); + this.initGlobalMap(); + this.initLayerTree(); + this.initMarkerTree(); + this.initLayout(); + this.loadData(); + + + double x = Convert.ToDouble(Utility.Query_Roads["绿岛"].ToString().Split(',')[0]); + double y = Convert.ToDouble(Utility.Query_Roads["绿岛"].ToString().Split(',')[1]); + double z = Convert.ToDouble(Utility.Query_Roads["绿岛"].ToString().Split(',')[2]); + jumpToCameraState(x, y, z); + + + } + + #endregion + + /// + /// 每次gis服务加载时都会触发的 + /// + /// + /// + 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 dictionaryNetLayerNameAndCaption = new Dictionary(); + 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 配置用户权限 + /// + /// 向数据库插入功能列表 + /// + private void insertControlToDatabase() + { + ArrayList listItem = new ArrayList(); + List subListItem = new List(); + 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) + { + GSOCameraState camera = globeControl2.Globe.CameraState; + globeControl1.Globe.JumpToCameraState(camera); + } + } + + void globeControl1_BeforeSceneRenderEvent(object sender, BeforeSceneRenderEventArgs e) + { + if (globeControl1.Focused) + { + 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); + } + } + } + + /// + /// 检查数据集是否有坐标系信息 + /// + /// + /// + 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 = "0prj4" + lprjStr + ""; + + bSuccess = dataset.LoadProjectionFromESRIFile(dlg.FileName); + + string lprjFileName = strDataPath.Substring(0, strDataPath.LastIndexOf(".")) + ".lprj"; + StreamWriter writer = new StreamWriter(lprjFileName, false); + writer.Write(lprjFileContent); + writer.Close(); + + } + } + } + else + { + return true; + } + return bSuccess; + } + + /// + /// 矩形拉框结束事件处理函数 + /// + /// + /// + 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))); + */ + + int mapWidth = 0; + int mapHeight = 0; + Point pt = getUpperLeftPoint(pt1, pt2, out mapWidth, out mapHeight); + int rightBottomX = pt.X + mapWidth; + int rightBottomY = pt.Y + mapHeight; + Image myImg = new Bitmap(mapWidth, mapHeight); + Graphics g = Graphics.FromImage(myImg); + g.CopyFromScreen(pt, new Point(0, 0), new Size(rightBottomX, rightBottomY)); + + 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; + } + } + /// + /// 定位正北正90度俯视 + /// + /// + /// + /// + 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; + } + } + /// + /// layerTree选中后事件处理 + /// + /// + /// + 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); + } + /// + /// 树节点选中方法 + /// + /// + 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); + } + } + } + + } + /// + /// 改变所有子节点的状态 + /// + /// + /// + 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; + LayerFlyMenuItem.Visible = true; + } + + LayerSelectableMenuItem.Visible = true; + LayerEditableMenuItem.Visible = true; + SaveLayerMenuItem.Visible = true; + LayerFlyMenuItem.Visible = true; + 导出CADToolStripMenuItem1.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]); + if (layer != null) + { + LayerSelectableMenuItem.Checked = layer.Selectable; + LayerEditableMenuItem.Checked = layer.Editable; + } + else + { + return; + } + } + 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; + } + } + } + } + } + + /// + /// 删除临时添加的本地数据图层 + /// + /// + /// + 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); + for (int i = globeControl1.Globe.Layers.Count-1; i >=0; i--) + { + if (globeControl1.Globe.Layers[i].Caption == layer.Caption) + { + globeControl1.Globe.Layers.Remove(globeControl1.Globe.Layers[i]); + } + } + + 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 定位ToolStripMenuItem_Click(object sender, EventArgs e) + { + TreeNode node = layerTree.SelectedNode; + + if (node != null) + { + if (node.Parent.Text.Trim() == "临时图层") + { + GSOLayer lsLayer = globeControl1.Globe.Layers.GetLayerByCaption(node.Text.ToString()); + double x = lsLayer.LatLonBounds.Center.X; + double y = lsLayer.LatLonBounds.Center.Y; + if (x == 0 && y == 0) + { + x = lsLayer.Bounds.Center.X; + y = lsLayer.Bounds.Center.Y; + } + + globeControl1.Globe.FlyToPosition(new GSOPoint3d(x, y, 10), EnumAltitudeMode.Absolute); + } + else + { + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(node.Tag.ToString().Split('|')[1]); + + if (layer != null) + { + if (layer.Caption == "红线") + { + globeControl1.Globe.FlyToPosition(new GSOPoint3d(120.610963, 31.188121, 50), EnumAltitudeMode.Absolute, -4, 50, 1000); + globeControl1.Globe.FlyToPointSpeed = 10000000; + globeControl1.Globe.Action = EnumAction3D.SelectObject; + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = true; + } + globeControl1.Refresh(); + } + else + { + double x = layer.LatLonBounds.Center.X; + double y = layer.LatLonBounds.Center.Y; + globeControl1.Globe.FlyToPosition(new GSOPoint3d(x, y, 100), EnumAltitudeMode.Absolute); + } + } + } + } + else + { + return; + } + + } + + private void layerTree_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e) + { + if(this.layerTree.SelectedNode!=null) + { + if (this.layerTree.SelectedNode.Tag.ToString().Contains("|")) + { + string nodeTag = this.layerTree.SelectedNode.Tag.ToString().Split('|')[1]; + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(nodeTag); + if (layer != null) + { + if (layer.Caption == "红线") + { + globeControl1.Globe.FlyToPosition(new GSOPoint3d(120.610963, 31.188121, 50), EnumAltitudeMode.Absolute, -4, 50, 1000); + globeControl1.Globe.FlyToPointSpeed = 10000000; + globeControl1.Globe.Action = EnumAction3D.SelectObject; + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = true; + } + globeControl1.Refresh(); + } + else { + double x = layer.LatLonBounds.Center.X; + double y = layer.LatLonBounds.Center.Y; + globeControl1.Globe.FlyToPosition(new GSOPoint3d(x, y, 0), EnumAltitudeMode.Absolute); + } + } + } + if (this.layerTree.SelectedNode.Tag is GSOLayer) + { + GSOLayer layer = this.layerTree.SelectedNode.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 (this.layerTree.SelectedNode.Tag is GSOFeature) + { + GSOFeature feature = this.layerTree.SelectedNode.Tag as GSOFeature; + if (feature.Geometry != null) + { + globeControl1.Globe.FlyToPosition(feature.Geometry.GeoCenterPoint, EnumAltitudeMode.Absolute, 0, 0, 10); + } + else + { + globeControl1.Globe.FlyToFeature(feature); + } + } + } + } + + /// + /// 在三维场景移动时,隐藏气泡globeControl1 + /// + /// + /// + void globeControl1_CameraBeginMoveEvent(object sender, CameraBeginMoveEventArgs e) + { + if (featureTooltip.IsVisible()) + { + featureTooltip.HideBalloon(); + } + if (balloonEx.IsVisible()) + { + balloonEx.HideBalloon(); + } + } + + /// + /// 在三维场景移动时,隐藏气泡globeControl2 + /// + /// + /// + void globeControl2_CameraBeginMoveEvent(object sender, CameraBeginMoveEventArgs e) + { + if (featureTooltip2.IsVisible()) + { + featureTooltip2.HideBalloon(); + } + if (balloonEx2.IsVisible()) + { + balloonEx2.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(); + } + } + + #region Fan 横断面 + /// + /// 横断面分析、基线剖面分析、道路断面分析等 + /// + /// + /// + private static EnumTrackPolylineEndMode trackPolylineEndMode; + + void globeControl1_TrackPolylineEndEvent(object sender, TrackPolylineEndEventArgs e) + { + //横断面分析、道路横断面分析 + if (trackPolylineEndMode == EnumTrackPolylineEndMode.HDM_Analysis|| + trackPolylineEndMode == EnumTrackPolylineEndMode.DLDM_Analysis) + { + Dictionary hdmDic = SectionAnalysisTool.HDMAnalysis(this.globeControl1, + e.Polyline, this.m_PipelineLayerNames); + FrmHDMAnalysis3 frm = new FrmHDMAnalysis3(hdmDic, this.globeControl1, + trackPolylineEndMode); + frm.Show(this); + } + //基线剖面分析 + else if (trackPolylineEndMode == EnumTrackPolylineEndMode.JXPM_Analysis) + { + FrmBaseLineProfillAnalysis dlg = new FrmBaseLineProfillAnalysis(globeControl1.Globe, e.Polyline); + dlg.Show(this); + globeControl1.Globe.ClearLastTrackPolyline(); + /* + FrmRoadHDM f = new FrmRoadHDM(); + f.Show() + * **/ + } + else + { + + } + trackPolylineEndMode = EnumTrackPolylineEndMode.Default_Analysis; + /* + ArrayList arraylistPoint = new ArrayList(); + ArrayList arraylistLine = new ArrayList(); + + // globeControl1.Globe.ClearLastTrackPolyline(); + + if (e.Polyline != null) + { + //横断面分析 + if (buttonItemFX2_1.Checked || buttonItemFX2_3.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 (buttonItemFX2_1.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 (buttonItemFX2_4.Checked) + { + FrmBaseLineProfillAnalysis dlg = new FrmBaseLineProfillAnalysis(globeControl1.Globe, e.Polyline); + dlg.Show(this); + globeControl1.Globe.ClearLastTrackPolyline(); + } + else if (buttonItemFX4_3.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(); + * **/ + } + #endregion + + private GSOFeatures PolygonIntersectAnalysis(GSOGeoPolygon3D polygon, string pipelinetype) + { + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(pipelinetype); + 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(pipelinetype, feats.Length); + return feats; + } + /// + /// 根据范围统计阀门、管线、工井等, 开挖分析, 挖方量分析 + /// + /// + /// + void globeControl1_TrackPolygonEndEvent(object sender, TrackPolygonEndEventArgs e) + { + if (globeControl1.Globe.Action == EnumAction3D.TrackPolygon && e.Polygon != null) + { + GSOGeoPolygon3D polygon = e.Polygon; + + switch (trackflag) + { + case "valvequery": + //workWellLen.Clear(); + //List list = new List(); + ////找到所有阀门 + //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, globeControl1, new DataGridViewDelegate(InitDataGridViewX1)); + FrmValveStatistics frm = new FrmValveStatistics(globeControl1,polygon, new DataGridViewDelegate(InitDataGridViewX1)); + frm.Show(this); + //panelEx6.Visible = true; + toolStripFeatureLength.Text = ""; + globeControl1.Globe.Action = EnumAction3D.ActionNull; + break; + + case "PipelineDistanceStatistics": + //pipeLineDis.Clear(); + //List list1 = new List(); + //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, globeControl1, new DataGridViewDelegate(InitDataGridViewX1)); + FrmAllPipelineStatis frm1 = new FrmAllPipelineStatis(globeControl1, polygon, new DataGridViewDelegate(InitDataGridViewX1), m_PipelineLayerNames); + frm1.Show(this); + globeControl1.Globe.Action = EnumAction3D.ActionNull; + + break; + case "PipelineSpatialQuery": + //pipeLineDis.Clear(); + //List list2 = new List(); + //for (int i = 0; i < m_PipelineLayerNames.Count; i++) + //{ + // GSOFeatures fs = Intersects_Pipeline(polygon, m_PipelineLayerNames[i]); + // if (fs != null) + // { + // list2.Add(fs); + // } + //} + + //FrmAllPipelineStatis.ShowForm(1, pipeLineDis, list2, globeControl1, new DataGridViewDelegate(InitDataGridViewX1)); + FrmAllPipelineStatis.ShowForm(globeControl1,polygon,new DataGridViewDelegate(InitDataGridViewX1),m_PipelineLayerNames); + globeControl1.Globe.ClearAnalysis(); + globeControl1.Globe.Action = EnumAction3D.ActionNull; + + break; + case "workwellquery": + //workWellLen.Clear(); + //List listWell = new List(); + ////找到所有井 + //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(polygon, dataGridViewX1, toolStripNumbers, globeControl1, panelOfTable); + FrmAllWorkWellStatis frmWell = new FrmAllWorkWellStatis(globeControl1, polygon, new DataGridViewDelegate(InitDataGridViewX1)); + 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 "BSQDuoBianXiangStatis": + + GSOFeature f2 = new GSOFeature(); + f2.Geometry = e.Polygon; + f2.Geometry.AltitudeMode = EnumAltitudeMode.Absolute; + globeControl1.Globe.MemoryLayer.AddFeature(f2); + f2.Geometry.MoveZ(3); + workWellLen.Clear(); + List listBSQ = new List(); + + GSOFeatures bsqFeatures = PolygonIntersectAnalysis(e.Polygon, "标识器"); + listBSQ.Add(bsqFeatures); + + FrmBSQDuoBianXingStatis bsqFrm = new FrmBSQDuoBianXingStatis(workWellLen, globeControl1, listBSQ); + bsqFrm.Show(this); + globeControl1.Globe.Action = EnumAction3D.ActionNull; + break; + + case "": + break; + default: + break; + } + } + } + + #region 验证端口 + /* + /// + /// 验证端口 + /// + /// + 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 + + /// + /// 鼠标悬浮提示 + /// + /// + /// + 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); + } + } + + /// + /// 添加管线绘制完成事件, 红线工具绘制完成 + /// + /// + /// + 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; + + + } + } + + /// + /// 获取globeControl1中鼠标按下的坐标供区别鼠标右键和滚轮按下事件 + /// + /// + /// + void globeControl1_MouseDown(object sender, MouseEventArgs e) + { + mouseDownX1 = e.X; + mouseDownY1 = e.Y; + } + /// + /// 获取globeControl2中鼠标按下的坐标供区别鼠标右键和滚轮按下事件 + /// + /// + /// + void globeControl2_MouseDown(object sender, MouseEventArgs e) + { + mouseDownX2 = e.X; + mouseDownY2 = e.Y; + } + /// + /// + /// + /// + /// + void globeControl2_MouseClick(object sender, MouseEventArgs e) + { + if (e.Button == MouseButtons.Right) + { + if (e.X == mouseDownX2 && e.Y == mouseDownY2) + { + RightScreenToolMenu.Show(globeControl2, e.X, e.Y); + } + else + { + return; + } + } + } + /// + /// + /// + /// + /// + void globeControl1_MouseClick(object sender, MouseEventArgs e) + { + if (e.Button == MouseButtons.Left) + { + if (globeControl1.Globe.Action == EnumAction3D.VisibilityAnalysis) + { + buttonItemFX5_1.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; + + bsqPT = pt; + + if (buttonItemLS5.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 (e.X == mouseDownX1 && e.Y == mouseDownY1) + { + toolRightMenu.Show(globeControl1, e.X, e.Y); + if (buttonItemLS5.Checked) + { + buttonItemLS5.Checked = false; + } + } + else + { + return; + } + } + globeControl1.Refresh(); + } + + /// + /// 判断网络图片是否存在 + /// + /// + /// + 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; + } + + /// + /// 鼠标点击, 弹出气泡功能globeControl1 + /// + /// + /// + void globeControl1_FeatureMouseClickEvent(object sender, FeatureMouseClickEventArgs e) + { + GSOFeature feature = e.Feature; + + string str1 = ""; + if (feature != null) + { + if (feature.GetFieldDefn("图片编码") != null)// + { + str1 = GetBubbleInfo(feature, globeControl1); + if (RemoteFileExists(Utility.PicRootURL + feature.GetValue("图片编码").ToString())) + { + str1 += ""; + } + else if (RemoteFileExists(Utility.PicDefaultURL)) + { + str1 += ""; + } + } + else if (isFeatureContainsBianhao(feature)) //管线模型图层 + { + str1 = GetBubbleInfo(feature, globeControl1); + } + + 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; + } + } + } + + /// + /// 鼠标点击, 弹出气泡功能globeControl2 + /// + /// + /// + void globeControl2_FeatureMouseClickEvent(object sender, FeatureMouseClickEventArgs e) + { + GSOFeature feature = e.Feature; + + string str1 = ""; + if (feature != null) + { + if (feature.GetFieldDefn("图片编码") != null) // + { + str1 = GetBubbleInfo(feature, globeControl2); + if (RemoteFileExists(Utility.PicRootURL + feature.GetValue("图片编码").ToString())) + { + str1 += ""; + } + else if (RemoteFileExists(Utility.PicDefaultURL)) + { + str1 += ""; + } + } + else if (isFeatureContainsBianhao(feature)) //管线模型图层 + { + str1 = GetBubbleInfo(feature, globeControl2); + } + + if (str1 != "") + { + + featureTooltip2.HideBalloon(); + balloonEx2.HideBalloon(); + balloonEx2.SetSize(EnumSizeIndexEx.CONTENT_CX, 480); + balloonEx2.SetSize(EnumSizeIndexEx.CONTENT_CY, 420); + balloonEx2.ShowBalloon((int)e.MousePos.X, (int)e.MousePos.Y, str1); + + return; + } + } + } + + /// + /// 拼接气泡表格字符串 + /// + /// + /// + private string GetBubbleInfo(GSOFeature feature,GSOGlobeControl globeControl) + { + if (feature == null) + { + return ""; + } + string str = ""; + str = ""; + 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 += ""; + + 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.get_Fields(layerName, globeControl); + } + if (queryFields != null) + { + string[] param = { "," }; + string[] fieldNames = queryFields.Split(param, StringSplitOptions.RemoveEmptyEntries); + for (int j = 0; j < fieldNames.Length; 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 (name1 == "模型路径") + { + continue; + } + 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 (field1.Type == EnumFieldType.Double) + { + double dl1 = feature.GetFieldAsDouble(j); + if (!name1.Contains("管径") && !name1.Contains("电压") && !name1.Contains("角度")) + { + name1 += "_米"; + } + value1 = dl1.ToString("0.00"); + } + 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 (name2 == "模型路径") + { + continue; + } + + 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 (field2.Type == EnumFieldType.Double) + { + double dl2 = feature.GetFieldAsDouble(j + 1); + if (!name2.Contains("管径") && !name2.Contains("电压") && !name2.Contains("角度")) + { + name2 += "_米"; + } + value2 = dl2.ToString("0.00"); + } + else + { + if (!feature.IsFieldValueNull(j + 1)) + { + value2 = feature.GetValue(j + 1).ToString(); + } + } + } + } + + j++; + } + str += ""; + } + } + str += "
" + title + " " + feature.GetFieldAsString(featureIDFieldName) + "
" + + name1 + + "
" + + value1 + + "
" + + name2 + + "
" + + value2 + "
"; + return str; + } + + string filename = Utility.filename; + List g1layername = new List(); + + /// + /// 获取目标图层 + /// + /// + 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; + } + /// + /// 添加图层 + /// + /// + /// + /// + 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 = 5000; + return templayer.Visible; + } + catch (Exception ex) + { + return false; + } + } + /// + /// 菜单上的 三维导航 工具按钮 + /// + /// + /// + private void buttonItem86_Click(object sender, EventArgs e) + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + } + + /// + /// 地上模式 菜单按钮 + /// + /// + /// + 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(); + + } + } + /// + /// 地下模式 菜单按钮 + /// + /// + /// + 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(); + } + } + /// + /// 行走模式 菜单按钮 + /// + /// + /// + 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; + } + } + /// + /// 地面透明度设置 菜单 + /// + /// + /// + private void sliderGroundTransSet1_ValueChanged(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.sliderGroundTransSet1.Text); + + globeControl1.Globe.GroundOpaque = 100 - sliderGroundTransSet1.Value; + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(roadLayerName);//("180fd"); + if (layer != null) + { + layer.Opaque = 100 - sliderGroundTransSet1.Value; + } + //if (buttonItemSPDB.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; + } + /// + /// 图例 菜单按钮 + /// + /// + /// + 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(); + } + /// + /// 快速定位 菜单按钮 + /// + /// + /// + private void buttonItem91_Click(object sender, EventArgs e) // + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItem91.Text); + FrmFlyToPosition fly = new FrmFlyToPosition(globeControl1); + fly.Show(this); + } + /// + /// 图层管理 菜单按钮 + /// + /// + /// + 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; + + //修改图层管理与标注管理、覆土审查、水平净距分析、垂直净距分析和碰撞分析控件之间的逻辑关系 + controlContainerItem5.Visible = false; + sideBar1.Visible = false; + sideBarPanelItem4.Visible = false; + panel3.Visible = false; + sideBar1.ExpandedPanel = sideBarPanelItem3; + buttonItemBZ11.Checked = false; + + //20160624 + /* + if (sideBarPanelItem4.Visible == true) + { + sideBar1.Visible = true; + controlContainerItem5.Visible = true; + } + else + { + sideBar1.Visible = false; + } + */ + Refresh(); + + } + } + /// + /// 全屏显示 菜单按钮 + /// + /// + /// + 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; + /// + /// 全屏显示功能实现 + /// + 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(); + } + } + + /// + /// 设置窗体宽、高 + /// + /// + /// + private void SetFullScreen(int width, int height) + { + this.Width = width; + this.Height = height; + } + + /// + /// 全屏功能的快捷键F5 + /// + /// + /// + 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); + } + } + /* + /// + /// 输出地图 + /// + /// + /// + /// + 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; + } + * */ + + private Point getUpperLeftPoint(Point p1, Point p2, out int mapWidth, out int mapHeight) // + { + Rectangle rc = new Rectangle(); + + p1 = this.globeControl1.PointToScreen(p1); + p2 = this.globeControl1.PointToScreen(p2); + + int x = Screen.PrimaryScreen.Bounds.X; + int y = Screen.PrimaryScreen.Bounds.Y; + int screenWidth = SystemInformation.WorkingArea.Width; + int screenHeight = SystemInformation.WorkingArea.Height; + + if (p1.X < x) + rc.X = x; + else + rc.X = p1.X; + + if (p1.Y < y) + rc.Y = y; + else + rc.Y = p1.Y; + + p1.X = rc.Left; + p1.Y = rc.Top; + + if (p2.X > screenWidth) + p2.X = screenWidth; + else + p2.X = p2.X; + + if (p2.Y > screenHeight) + p2.Y = screenHeight; + else + p2.Y = p2.Y; + + rc.Width = p2.X - rc.X; + rc.Height = p2.Y - rc.Y; + + mapWidth = rc.Width; + mapHeight = rc.Height; + Point pt = new Point(rc.Left, rc.Top); + return pt; + } + + Image printImage; + /// + /// 打印 菜单 + /// + /// + /// + 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))); + */ + int mapWidth = 0; + int mapHeight = 0; + Point pt = getUpperLeftPoint(pt1, pt2, out mapWidth, out mapHeight); + int rightBottomX = pt.X + mapWidth; + int rightBottomY = pt.Y + mapHeight; + Image myImg = new Bitmap(mapWidth, mapHeight); + Graphics g = Graphics.FromImage(myImg); + g.CopyFromScreen(pt, new Point(0, 0), new Size(rightBottomX, rightBottomY)); + + + 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); + } + /// + /// 输出地图 菜单 + /// + /// + /// + private void btnOutputJPG_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btnOutputJPG.Text); + + //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))); + */ + int mapWidth = 0; + int mapHeight = 0; + Point pt = getUpperLeftPoint(pt1, pt2, out mapWidth, out mapHeight); + int rightBottomX = pt.X + mapWidth; + int rightBottomY = pt.Y + mapHeight; + Image myImg = new Bitmap(mapWidth, mapHeight); + Graphics g = Graphics.FromImage(myImg); + g.CopyFromScreen(pt, new Point(0, 0), new Size(rightBottomX, rightBottomY)); + + 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; + } + } + } + + /// + /// 在窗体的底部状态栏上显示 综合管线条件查询结果 + /// + /// + /// + 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 + " 条记录 | "; + } + } + + /// + /// 统计管线的里程数 + /// + /// + /// + /// + 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; + } + + /// + /// 窗体下方属性表格 右键菜单中的 “定位”菜单 + /// + /// + /// + 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); + + } + + /// + /// 表格中右键 “单个闪烁” 菜单 + /// + /// + /// + private void LightMenu_Click(object sender, EventArgs e) + { + flashflag = "single"; + timer1.Start(); + } + /// + /// 表格中右键 “全部闪烁” 菜单 + /// + /// + /// + private void AllLightMenuItem_Click(object sender, EventArgs e) + { + flashflag = "all"; + timer1.Start(); + } + + /// + /// 使用timer实现管线的闪烁效果 + /// + /// + /// + 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; + } + } + + /// + /// 绘制线 菜单 + /// + /// + /// + private void btnAddLine_Click(object sender, EventArgs e) + { + globeControl1.Globe.DestLayerFeatureAdd = globeControl1.Globe.MemoryLayer; + globeControl1.Globe.Action = EnumAction3D.DrawPolyline; + } + /// + /// 绘制面 菜单 + /// + /// + /// + private void btnAddPolygon_Click(object sender, EventArgs e) + { + globeControl1.Globe.DestLayerFeatureAdd = globeControl1.Globe.MemoryLayer; + globeControl1.Globe.Action = EnumAction3D.DrawPolygon; + } + /// + /// 图层目录树 右键菜单中的 目标图层 菜单 + /// + /// + /// + 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; + } + } + /// + /// 图层目录树 右键菜单中的 可选择 菜单 + /// + /// + /// + 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; + } + /// + /// 图层目录树 右键菜单中的 可编辑 菜单 + /// + /// + /// + 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; + } + /// + /// 图层目录树 右键菜单中的 保存 菜单 + /// + /// + /// + 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(); + } + + /// + /// 根据多边形范围统计管线的里程 + /// + /// + /// + /// 返回查询到的管线要素集合 + 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 pipeLineDis = new Dictionary(); + Dictionary workWellLen = new Dictionary(); + + + + + /// + /// 查找指定图层中在 指定范围内的feature对象集合 + /// + /// + /// + /// + 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; + } + /// + /// 清除结果 菜单 + /// + /// + /// + private void buttonItem47_Click(object sender, EventArgs e) + { + globeControl1.Globe.ClearAnalysis(); + dataGridViewX1.DataSource = null; + panelOfTable.Visible = false; + clearFeatureHighLight(); + } + /// + /// 设置菜单的选中状态 + /// + private void ActionToolMenuChecked() + { + if (globeControl1.Globe.Action != EnumAction3D.TrackPolyline) + { + buttonItemFX2_1.Checked = false; + buttonItemFX2_4.Checked = false; + buttonItemFX2_3.Checked = false; + buttonItemFX4_3.Checked = false; + } + if (globeControl1.Globe.Action != EnumAction3D.NormalHit) + { + buttonItemFX3_6.Checked = false; + // ClearConnexityAnalysis(); + + buttonItemFX3_5.Checked = false; + // ClearCloseValvesAnalysis(); + } + if (globeControl1.Globe.Action != EnumAction3D.TrackPolygon) + { + buttonItemFX4_2.Checked = false; + buttonItemFX4_1.Checked = false; + } + } + + /// + /// 主窗体关闭事件处理 + /// + /// + /// + private void MainFrm_FormClosing(object sender, FormClosingEventArgs e) + { + + if (MessageBox.Show("是否退出系统?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) + { + e.Cancel = true; + } + else { + globeControl1.Globe.MemoryLayer.SaveAs(Application.StartupPath + "/MyPlace.kml"); + } + + //saveLayerList(layerManagerNode.Nodes); + //注销id号为103的热键设定 + // UnregisterHotKey(Handle, 103); + } + + /// + /// 显示流向 功能 + /// + /// + /// + /// + 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(); + } + + FrmCloseValves frm; + + FrmBoosterValvers frmbooster = null; + + /// + /// 垂直净距分析 功能界面中的 选择图层复选框 选中状态改变事件处理 + /// + /// + /// + 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(); + } + /// + /// 水平净距分析 功能界面中的 选择图层复选框 选中状态改变事件处理 + /// + /// + /// + 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(); + } + /// + /// 垂直净距分析 功能界面中的 选择管线复选框 选中状态改变事件处理 + /// + /// + /// + private void checkBoxX1_CheckedChanged(object sender, EventArgs e) + { + clearFeatureHighLight(); + if (checkBoxX1.Checked) + { + comboBoxEx1.SelectedItem = null; + 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; + } + } + /// + /// 水平净距分析 功能界面中的 选择管线复选框 选中状态改变事件处理 + /// + /// + /// + private void checkBoxX1_CheckedChanged_shuiping(object sender, EventArgs e) + { + clearFeatureHighLight();//清除高亮 + if (checkBoxX7.Checked) + { + comboBoxEx4.SelectedItem = null; + 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(); + /// + /// 垂直净距分析 功能界面中的 选择图层下拉框 选中项改变 事件处理 + /// + /// + /// + 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; + } + } + } + /// + /// 水平净距分析 功能界面中的 选择图层下拉框 选中项改变 事件处理 + /// + /// + /// + 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 featCount = new Dictionary(); + Dictionary featLenth = new Dictionary(); + Dictionary m_FeaturesWithBianhao = new Dictionary();//记录编号和对应的标注点的位置 + GSOFeatures polygonJingJuAnalysises = new GSOFeatures(); + + /// + /// 垂直净距分析 功能界面中的 开始分析按钮 事件处理 + /// + /// + /// + 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; + } + + /// + /// 在指定的两点组成的线的中间添加一个marker对象,并将marker对象添加到指定的图层中 + /// + /// + /// + /// + /// + /// + 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; + } + + /// + /// 计算指定feature对象与除了该feature所在图层之外的 所有管线图层中的所有feature对象 的垂直距离 并在表格中记录符合要求的管线 + /// + /// + /// + /// + /// + private void VerticalDistanceAnalysis(string type, GSOFeature selectedFeature, List _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(); + } + /// + /// 垂直净距分析中 表格行的 双击定位 功能。 与覆土分析的实现方法不同,主要原因是需要标注垂距 + /// + /// + /// + 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); + } + } + } + } + + /// + /// 水平净距分析 功能界面中 开始分析按钮 的事件处理 + /// + /// + /// + 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; + } + + + /// + /// 计算指定feature对象与除了该feature所在图层之外的 所有管线图层中的所有feature对象 的水平距离 并记录符合要求的管线 功能 + /// + /// + /// + /// + /// + private void HorizontalDistanceAnalysis(GSOFeature selectedFeature, List _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)); + } + } + } + } + } + /// + /// 水平净距分析 功能界面中 表格的 双击定位 功能 + /// + /// + /// + 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); + } + } + } + } + } + /// + /// 碰撞分析 功能界面中 开始分析按钮 事件处理 + /// + /// + /// + 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; + } + /// + /// 碰撞分析功能界面中 表格的 双击定位 功能 + /// + /// + /// + 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); + } + } + } + } + + + + /// + /// 覆土分析功能操作界面中的 选择管线 复选框选中状态改变事件处理 + /// + /// + /// + private void checkBoxX5_CheckedChanged(object sender, EventArgs e) + { + clearFeatureHighLight(); + if (checkBoxX5.Checked) + { + comboBoxEx3.SelectedItem = null; + 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; + } + } + /// + /// 覆土分析功能操作界面中的 选择图层 复选框选中状态改变事件处理 + /// + /// + /// + 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(); + } + /// + /// 覆土分析功能操作界面中的 图层下拉框选中项改变事件处理 + /// + /// + /// + 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; + } + } + } + /// + /// 覆土分析功能操作界面中的 开始分析 按钮事件处理 + /// + /// + /// + 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; + + + GSOPoint3d markerPosition = new GSOPoint3d(); + 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]; + GSOPoint3d pt = new GSOPoint3d(); + + 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"); + + pt.X = pts[m].X; + pt.Y = pts[m].Y; + pt.Z = 0; + markerPosition = LabelVerticalDistance(layerTemp, pts[m], pt, Convert.ToDouble(dataGridViewX7.Rows[idx].Cells[2].Value), true); + 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]; + GSOPoint3d pt = new GSOPoint3d(); + 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"); + + pt.X = pts[m].X; + pt.Y = pts[m].Y; + pt.Z = 0; + markerPosition = LabelVerticalDistance(layerTemp, pts[m], pt, Convert.ToDouble(dataGridViewX7.Rows[idx].Cells[2].Value), true); + + 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; + } + + /// + /// 覆土分析中 表格的 双击定位 功能 + /// + /// + /// + 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); + } + } + } + } + } + /// + /// 覆土分析功能操作界面中的 导出Excel按钮 事件处理 + /// + /// + /// + private void buttonX10_Click(object sender, EventArgs e) + { + if (dataGridViewX7.Rows.Count > 0) + { + ExportExcel("覆土分析", dataGridViewX7, null); + } + else + { + MessageBox.Show("表格内容为空!", "提示"); + } + } + /// + /// 覆土分析功能操作界面底部的 关闭 按钮事件处理 + /// + /// + /// + 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(); + layerTemp.RemoveAllFeature(); + + if (buttonItem1.Checked) + { + sideBar1.ExpandedPanel = sideBarPanelItem3; + } + else + { + sideBar1.Visible = false; + } + globeControl1.Refresh(); + + //Refresh(); + } + + + /// + /// 垂直净距分析 功能界面中 清除分析结果按钮 事件处理 + /// + /// + /// + 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(); + } + /// + /// 水平净距分析 功能界面中 清除分析结果按钮 事件处理 + /// + /// + /// + 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(); + } + + /// + /// 垂直净距分析功能界面中 关闭按钮 事件处理 + /// + /// + /// + 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(); + } + /// + /// 水平净距分析功能界面中 删除缓冲区按钮 事件处理 + /// + /// + /// + private void buttonX14_Click(object sender, EventArgs e) + { + 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(); + } + + /// + /// 导出指定DataGridView控件中的内容 + /// + /// + /// + 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(); + } + } + } + } + + /// + /// 垂直净距分析功能界面中 导出Excel按钮 事件处理 + /// + /// + /// + private void buttonX4_Click(object sender, EventArgs e) + { + if (dataGridViewX3.Rows.Count > 0) + { + ExportExcel("垂直净距分析", dataGridViewX3, listBox1); + } + else + { + MessageBox.Show("表格内容为空!", "提示"); + } + } + /// + /// 水平净距分析功能界面中 导出Excel按钮 事件处理 + /// + /// + /// + private void buttonX4_Click_shuiping(object sender, EventArgs e) + { + if (dataGridViewX9.Rows.Count > 0) + { + ExportExcel("水平净距分析", dataGridViewX9, listBox3); + } + else + { + MessageBox.Show("表格内容为空!", "提示"); + } + } + + + /// + /// 清除所有坑 菜单 + /// + /// + /// + private void buttonItem3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItem3.Text); + + globeControl1.Globe.RemoveAllPits(); + } + + //} + /// + /// 大气层 菜单 + /// + /// + /// + private void buttonItem17_Click_1(object sender, EventArgs e) + { + globeControl1.Globe.Atmosphere.Visible = !globeControl1.Globe.Atmosphere.Visible; + buttonItemSH1.Checked = globeControl1.Globe.Atmosphere.Visible; + globeControl1.Refresh(); + } + /// + /// 经纬网 菜单 + /// + /// + /// + private void buttonItem20_Click(object sender, EventArgs e) + { + globeControl1.Globe.LatLonGrid.Visible = !globeControl1.Globe.LatLonGrid.Visible; + buttonItemSH3.Checked = globeControl1.Globe.LatLonGrid.Visible; + globeControl1.Globe.Refresh(); + } + /// + /// 状态条 菜单 + /// + /// + /// + private void buttonItem21_Click_1(object sender, EventArgs e) + { + globeControl1.Globe.StatusBar.Visible = !globeControl1.Globe.StatusBar.Visible; + buttonItemSH4.Checked = globeControl1.Globe.StatusBar.Visible; + globeControl1.Globe.Refresh(); + } + + + + /// + /// 添加指定路径下的数据 功能 + /// + /// + /// + 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); + //CheckDatasetGeoReference(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; + } + return objRes; + } + /// + /// 刷新目录树 功能 + /// + 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); + } + } + /// + /// 判断图层是否包含字段列表 + /// + /// + /// + 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; + } + + /// + /// 统计指定图层在指定范围内的所有feature对象 + /// + /// + /// + /// + 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; + } + /// + /// 碰撞分析功能界面中 选择管线复选框 选中状态改变事件处理 + /// + /// + /// + private void checkBoxX3_CheckedChanged(object sender, EventArgs e) + { + clearFeatureHighLight(); + if (checkBoxX3.Checked) + { + comboBoxEx2.SelectedItem = null; + 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; + } + } + /// + /// 碰撞分析功能界面中 选择图层复选框 选中状态改变事件处理 + /// + /// + /// + 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(); + } + /// + /// 碰撞分析功能界面中 选择图层下拉框 选中项改变事件处理 + /// + /// + /// + 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; + } + } + } + /// + /// 清除所有图层中的所有feature对象的高亮状态 功能 + /// + 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); + } + } + } + } + for (int i = 0; i < globeControl2.Globe.Layers.Count; i++) + { + GSOLayer layer = globeControl2.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; + } + } + } + + if (globeControl1.Globe.Action == EnumAction3D.SelectObject) + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + //globeControl1.Globe.Action = EnumAction3D.SelectObject; + } + } + + /// + /// 碰撞分析功能界面中 清除分析结果按钮 事件处理 + /// + /// + /// + 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(); + } + /// + /// 碰撞分析功能界面中 导出Excel按钮 事件处理 + /// + /// + /// + private void buttonX6_Click(object sender, EventArgs e) + { + if (dataGridViewX5.Rows.Count > 0) + { + ExportExcel("碰撞分析", dataGridViewX5, listBox2); + } + else + { + MessageBox.Show("表格内容为空!", "提示"); + } + } + /// + /// 导出CAD 菜单 + /// + /// + /// + private void btnExportCAD_Click(object sender, EventArgs e) + { + FrmExportCADS frm = new FrmExportCADS(globeControl1, m_PipelineLayerNames); + frm.ShowDialog(); + } + + ///// + ///// 区域分析 菜单 + ///// + ///// + ///// + //private void buttonItem50_Click(object sender, EventArgs e) + //{ + // buttonItem50.Checked = !buttonItem50.Checked; + // ribbonBarQY.Visible = buttonItem50.Checked; + // ribbonBarQY.Location = new Point(0, 0); + //} + + + /// + /// 连接数据库 菜单事件处理 + /// + /// + /// + 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; + } + } + } + /// + /// 数据验证 菜单 + /// + /// + /// + private void buttonItem80_Click(object sender, EventArgs e) + { + FrmValiData frm = new FrmValiData(globeControl1); + frm.ShowDialog(); + } + /// + /// 根据指定图层创建图层节点并将节点添加到图层管理节点的子节点集合中 + /// + /// + 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; + + if (!layerManagerNode.Nodes.Contains(node)) + { + layerManagerNode.Nodes.Insert(0, node); + layerManagerNode.Expand(); + } + } + } + /// + /// 数据库备份 菜单 + /// + /// + /// + 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(); + } + } + } + + + + #region Fan 去掉 + //GSOFeature emitterFeature; // 粒子要素 + /// + /// 添加火苗 功能 + /// + /// + /// + /// + 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); + + } + /// + /// 添加喷泉 功能 + /// + /// + /// + /// + 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); + } + #endregion + + /// + /// 获取指定图层中最后一个feature对象的名称对应的整数 + /// + /// + /// + 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; + } + /// + /// 设置除指定标注图层之外的所有标注图层不可见 + /// + /// + 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; + } + } + } + } + } + + /// + /// 判断选中的对象是否为管线 + /// + /// 被选中管线 + /// 返回一根线 + 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; + } + + /// + /// 创建label要素 功能 + /// + /// 添加label要素的feature + /// feature的位置 + /// label要素名字 + /// feature名字 + /// label要素距离点的位置 + /// + 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; + } + + + + /// + /// 获取指定两点组成的线的长度 功能 + /// + /// + /// + /// + 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; + } + + /// + /// 图层节点树中 节点 右键单击事件处理 + /// + /// + /// + 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; + } + } + } + } + } + + /// + /// 标注管理、传感器管理 图层目录树的右键菜单中的 刷新列表 菜单 + /// + /// + /// + 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); + } + } + /// + /// 给指定的图层节点添加代表feature对象的子节点 + /// + /// + private void RefreshTreeNodeLayerFeatureList(TreeNode layerTreeNode) + { + layerTreeNode.Nodes.Clear(); + GSOLayer layer = (GSOLayer)layerTreeNode.Tag; + // 只将类型为内存数据集的图层列出,如果是其它类型的数据集可能数据量太大,没发显示在树控件中 + if (layer.Dataset is GSOFeatureDataset) + { + VisitFeature3Ds(layer.GetAllFeatures(), layerTreeNode); + } + } + + /// + /// 标注管理、传感器管理 图层目录树的右键菜单中的 移除所有 菜单 + /// + /// + /// + 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(); + } + } + + /// + /// 图层目录树的 节点对应的复选框选中状态改变事件处理 + /// + /// + /// + private void layerMarkerTree_AfterCheck(object sender, TreeViewEventArgs e) + { + if (e.Action != TreeViewAction.Unknown) + { + CheckTreeNode(e.Node, e.Node.Checked); + } + } + /// + /// 改变指定节点对应的复选框的选中状态 + /// + /// + /// + private void CheckTreeNode(TreeNode node, Boolean bChecked) + { + CheckChildTreeNode(node, bChecked); + globeControl1.Globe.Refresh(); + } + /// + /// 改变指定节点的子节点对应的复选框的选中状态 + /// + /// + /// + 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); + } + } + /// + /// 标注管理、传感器管理 目录树中的feature节点的右键菜单中的 删除 菜单 + /// + /// + /// + 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(); + } + } + + /// + /// 双屏对比 菜单 + /// + /// + /// + //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(); + // } + //} + /// + /// 模拟分析 菜单 + /// + /// + /// + //private void buttonItem51_Click(object sender, EventArgs e) + //{ + // buttonItem51.Checked = !buttonItem51.Checked; + // ribbonBarMN.Visible = buttonItem51.Checked; + // ribbonBarMN.Location = new Point(0, 0); + //} + + /// + /// 双屏设置 菜单 + /// + /// + /// + //private void buttonItem96_Click(object sender, EventArgs e) + //{ + // FrmLayerControl frm = new FrmLayerControl(layerTree,globeControl1,globeControl2); + // frm.Show(this); + //} + /// + /// 双屏联动 菜单 + /// + /// + /// + //private void buttonItem95_Click(object sender, EventArgs e) + //{ + // buttonItem95.Checked = !buttonItem95.Checked; + //} + ///// + /// 添加用户仓库 菜单 + /// + /// + /// + private void buttonItem108_Click(object sender, EventArgs e) + { + FrmUserRepo frm = new FrmUserRepo(-1); + frm.ShowDialog(); + } + /// + /// 用户仓库管理 菜单 + /// + /// + /// + private void buttonItem111_Click(object sender, EventArgs e) + { + FrmUserRepoMgr frm = new FrmUserRepoMgr(); + frm.ShowDialog(); + } + /// + /// 添加分系统 菜单 + /// + /// + /// + private void buttonItem112_Click(object sender, EventArgs e) + { + //FrmAPP frm = new FrmAPP(-1); + //frm.ShowDialog(); + } + /// + /// 分系统管理 菜单 + /// + /// + /// + private void buttonItem113_Click(object sender, EventArgs e) + { + //FrmAPPMgr frm = new FrmAPPMgr(); + //frm.ShowDialog(); + } + /// + /// 添加操作 菜单 + /// + /// + /// + private void buttonItem114_Click(object sender, EventArgs e) + { + FrmOper frm = new FrmOper(-1); + frm.ShowDialog(); + } + /// + /// 操作管理 菜单 + /// + /// + /// + private void buttonItem115_Click(object sender, EventArgs e) + { + FrmOperMgr frm = new FrmOperMgr(); + frm.ShowDialog(); + } + /// + /// 添加资源 菜单 + /// + /// + /// + private void buttonItem116_Click(object sender, EventArgs e) + { + FrmRESC frm = new FrmRESC(-1); + frm.ShowDialog(); + } + /// + /// 资源管理 菜单 + /// + /// + /// + private void buttonItem117_Click(object sender, EventArgs e) + { + FrmRESCMgr frm = new FrmRESCMgr(); + frm.ShowDialog(); + } + /// + /// 添加权限 菜单 + /// + /// + /// + private void buttonItem118_Click(object sender, EventArgs e) + { + FrmPerm frm = new FrmPerm(-1); + frm.ShowDialog(); + } + /// + /// 权限管理 菜单 + /// + /// + /// + private void buttonItem119_Click(object sender, EventArgs e) + { + FrmPermMgr frm = new FrmPermMgr(); + frm.ShowDialog(); + } + /// + /// 添加访问控制 菜单 + /// + /// + /// + private void buttonItem120_Click(object sender, EventArgs e) + { + FrmAccess frm = new FrmAccess(-1); + frm.ShowDialog(); + } + /// + /// 访问控制管理 菜单 + /// + /// + /// + private void buttonItem121_Click(object sender, EventArgs e) + { + FrmAccessMgr frm = new FrmAccessMgr(); + frm.ShowDialog(); + } + /// + /// 部门类型管理 菜单 + /// + /// + /// + private void buttonItem122_Click(object sender, EventArgs e) + { + FrmRegionTypeMgr frm = new FrmRegionTypeMgr(); + frm.ShowDialog(); + } + /// + /// 添加用户 菜单 + /// + /// + /// + private void buttonItem127_Click(object sender, EventArgs e) + { + FrmUserAdd frm = new FrmUserAdd(-1); + frm.ShowDialog(); + } + /// + /// 用户信息管理 菜单 + /// + /// + /// + private void buttonItem128_Click_1(object sender, EventArgs e) + { + FrmUserManager frm = new FrmUserManager(); + frm.ShowDialog(); + } + /// + /// 添加角色 菜单 + /// + /// + /// + private void 添加角色_Click(object sender, EventArgs e) + { + FrmRole frm = new FrmRole(-1); + frm.ShowDialog(); + } + /// + /// 所有角色管理 菜单 + /// + /// + /// + private void 角色管理_Click(object sender, EventArgs e) + { + FrmRoleMgr frm = new FrmRoleMgr(); + frm.ShowDialog(); + } + + /// + /// 部门角色管理 菜单 + /// + /// + /// + private void buttonItem133_Click(object sender, EventArgs e) + { + FrmRegionRoleMgr frm = new FrmRegionRoleMgr(); + frm.ShowDialog(); + } + /// + /// 部门管理 菜单 + /// + /// + /// + private void buttonItem130_Click(object sender, EventArgs e) + { + FrmRegionMgr frm = new FrmRegionMgr(); + frm.ShowDialog(); + } + + /// + /// 日志管理 菜单 + /// + /// + /// + private void buttonItem135_Click(object sender, EventArgs e) + { + FrmLogManager frm = new FrmLogManager(); + frm.ShowDialog(); + } + /// + /// 传感器信息查询 菜单 + /// + /// + /// + 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); + } + } + } + /// + /// 根据指定的图层的caption属性的值在配置文件中查找对应的数据库中的表的名称 + /// + /// 图层的caption属性的值 + /// 对应的数据库中的表的名称 + 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; + } + /// + /// 根据数据库中的表的名称 查找对应的表中的字段名称的集合 + /// + /// 数据库中的表的名称 + /// 对应的表中的字段名称的集合 + 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; + } + + /// + /// 历史曲线查询 菜单 + /// + /// + /// + 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; + /// + /// 传感器在线报警 菜单 + /// + /// + /// + 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); + } + /// + /// 传感器报警 功能中的 定时器 的触发事件处理 + /// + /// + /// + 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; + } + } + } + } + } + } + } + + + /// + /// 沿线运动 菜单 + /// + /// + /// + private void buttonItem138_Click(object sender, EventArgs e) + { + if (globeControl1.Globe.SelectedObject == null) + { + MessageBox.Show("请先选择一条线!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + return; + } + + GSOFeature lineFeature = globeControl1.Globe.SelectedObject; + if (lineFeature.Geometry == null || lineFeature.Geometry.Type != EnumGeometryType.GeoPolyline3D) + { + MessageBox.Show("请先选择一条线!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + return; + } + + OpenFileDialog dlg = new OpenFileDialog(); + dlg.Filter = "*.gcm;*.3ds|*.gcm;*.3ds|*.3ds|*.3ds|*.gcm|*.gcm"; + if (dlg.ShowDialog() == DialogResult.OK) + { + GSOGeoModel model = new GSOGeoModel(); + model.FilePath = dlg.FileName; + + GSOGeoDynamicRoute dynamicRoute = new GSOGeoDynamicRoute(); + dynamicRoute.ActorGeometry = model; + + GSORoute route = new GSORoute(); + GSOGeoPolyline3D geoline = (GSOGeoPolyline3D)lineFeature.Geometry; + for (int i = 0; i < geoline[0].Count; i++) + { + route.Add(geoline[0][i]); + } + route.CircleRoute = false; + route.Speed = 30; + route.RotateSpeed = 50; + route.AltitudeMode = geoline.AltitudeMode; + dynamicRoute.Route = route; + + GSOFeature feature = new GSOFeature(); + + dynamicRoute.Play(); + feature.Geometry = dynamicRoute; + + //GSOLabel gsoLabel = new GSOLabel(); + //gsoLabel.Text = "模型测试"; + //feature.Label = gsoLabel; + globeControl1.Globe.MinModelVisibleSize = 0; + + globeControl1.Globe.MemoryLayer.AddFeature(feature); + globeControl1.Globe.Refresh(); + } + } + /// + /// 回退 菜单 + /// + /// + /// + private void buttonItem99_Click(object sender, EventArgs e) + { + globeControl1.Globe.UnDoEdit(); + } + /// + /// 前进 菜单 + /// + /// + /// + private void buttonItem100_Click(object sender, EventArgs e) + { + globeControl1.Globe.ReDoEdit(); + } + /// + /// 水平净距 功能界面中的 标签内容改变事件处理 + /// + /// + /// + 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() + "米的管线有:"; + } + } + } + /// + /// 垂直净距 功能界面中的 标签内容改变事件处理 + /// + /// + /// + 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() + "米的管线有:"; + } + } + } + /// + /// 覆土分析 功能界面中的 标签内容改变事件处理 + /// + /// + /// + 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() + "米的管线有:"; + } + } + } + + /// + /// 传感器分类查询 全区域 菜单 + /// + /// + /// + private void buttonItemSensor全区域查询_Click(object sender, EventArgs e) + { + FrmAccessoriesSensor.ShowForm(globeControl1, instrumenLayerNames, 0); + } + /// + /// 传感器分类查询 绘制区域 菜单 + /// + /// + /// + private void buttonItemSensor绘制区域查询_Click(object sender, EventArgs e) + { + FrmAccessoriesSensor.ShowForm(globeControl1, instrumenLayerNames, 1); + } + + + /// + /// 碰撞分析 功能界面中 关闭按钮 事件处理 + /// + /// + /// + 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(); + } + /// + /// 覆土分析 功能界面中的 清除分析结果 按钮事件处理 + /// + /// + /// + 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(); + } + /// + /// 数字预处理 功能 + /// + /// + /// + private void 数字预处理buttonItem140_Click(object sender, EventArgs e) + { + FrmEditShapeFile frm = new FrmEditShapeFile(globeControl1); + frm.ShowDialog(this); + } + + + /// + /// 导出矢量 功能 将图层导出为kml和shp格式数据 + /// + /// + /// + private void 导出矢量buttonItem140_Click(object sender, EventArgs e) + { + List listVectorNames = new List(); + for (int i = 0; i < m_PipelineLayerNames.Count; i++) + { + 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 = ""; + /// + /// 绘制城市七线 功能按钮 + /// + /// + /// + 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; + } + } + } + /// + /// 七线审核 功能按钮 + /// + /// + /// + private void 七线审核buttonItem141_Click(object sender, EventArgs e) + { + FrmCityServerLineAnalysis frm = new FrmCityServerLineAnalysis(globeControl1, m_PipelineLayerNames); + frm.ShowDialog(this); + } + + /// + /// 间距分析 开始分析按钮 分析绘制的七线和管线的距离是否符合标准 + /// + /// + /// + 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; + } + /// + /// 间距分析 清除分析结果 + /// + /// + /// + 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(); + } + /// + /// 间距分析 导出Excel按钮 将间距分析的结果以Excel表格的形式导出 + /// + /// + /// + private void buttonExportExcel_Click(object sender, EventArgs e) + { + if (dataGridViewAnalysisResult.Rows.Count > 0) + { + ExportExcel("间距分析", dataGridViewAnalysisResult, listBoxStasticsResult); + } + else + { + MessageBox.Show("表格内容为空!", "提示"); + } + } + /// + /// 间距分析 关闭按钮 + /// + /// + /// + 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(); + } + /// + /// 间距分析 分析结果表格双击定位 + /// + /// + /// + 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); + } + } + } + } + /// + /// 间距分析 选择管线复选框 + /// + /// + /// + private void checkBoxSelectPipeline_CheckedChanged(object sender, EventArgs e) + { + clearFeatureHighLight();//清除高亮 + if (checkBoxSelectPipeline.Checked) + { + comboBoxLayer.SelectedItem = null; + 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; + } + } + /// + /// 间距分析 选择图层复选框 + /// + /// + /// + 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(); + } + /// + /// 间距分析 选择图层下拉框 + /// + /// + /// + 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; + } + } + } + + + + /// + /// 管线自动缩进 菜单 + /// + /// + /// + private void 管线自动缩进buttonItem140_Click(object sender, EventArgs e) + { + FrmPipelineIndented frm = new FrmPipelineIndented(globeControl1, m_PipelineLayerNames, workwellLayerNames); + 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 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); + // } + //} + + /// + /// 统计指定图层在指定范围内的所有feature对象 + /// + /// + /// + /// + 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) + { + 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 setLayerVisible(string layerName) + { + GSOLayer templayer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + if (templayer != null) + { + templayer.Visible = false; + } + globeControl1.Globe.Refresh(); + } + + /// + /// 连接数据库 + /// + /// + /// + private void buttonItem129_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL4_1.Text); + + FrmDatabaseParaSetting2 frm = new FrmDatabaseParaSetting2(globeControl1); + if (frm.ShowDialog() == DialogResult.OK) + { + ds = FrmDatabaseParaSetting2.ds; + if (ds != null) + { + ds.IsCloseSaved = false; + } + } + } + + /// + /// 一键审核---导入数据 + /// + /// + /// + private void buttonItem127_Click_2(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, "打开数据"); + + try + { + //if (shds == null) + //{ + //没连的话,直接连接审核库; //审核库配置读配置文件 + string dbIp = Utility.sgdbip; + string database = Utility.sgdbname; + string user = Utility.sgdbuser; + string pass = Utility.sgdbpwd; + /* + 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; + //} + } + catch (Exception ex) + { + LogError.PublishError(ex); + MessageBox.Show("内存过载请清理内存,并重新启动规划分析!", "提示"); + return; + } + + } + + /// + ///自动导出图片 + /// + /// + /// + private void buttonItem130_Click_1(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, "导出审核图"); + + 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))); + */ + + int mapWidth = 0; + int mapHeight = 0; + Point pt = getUpperLeftPoint(pt1, pt2, out mapWidth, out mapHeight); + int rightBottomX = pt.X + mapWidth; + int rightBottomY = pt.Y + mapHeight; + Image myImg = new Bitmap(mapWidth, mapHeight); + Graphics g = Graphics.FromImage(myImg); + g.CopyFromScreen(pt, new Point(0, 0), new Size(rightBottomX, rightBottomY)); + + 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; + } + } + } + /// + /// 一键审核功能 + ///
+ /// + /// + private void buttonItem128_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItem128.Text); + //垂直净距标准 + + frmSh = new FrmYJSHTC(globeControl1, globeControl2,layerTree); + + if (frmSh.ShowDialog() == DialogResult.OK) + { + frmWait = new FrmWait("一键审核……"); + frmWait.Location = new Point(this.Width - frmWait.Width - 10, this.Height - frmWait.Height - 50); + frmWait.Owner = this; + frmWait.Show(); + Thread thread = new Thread(new ThreadStart(doWork)); + thread.IsBackground = true; + thread.Start(); + } + } + + void doWork() + { + FrmShResult frmShResult = null; + + double dVerticalJingJuBiaoZhun = 1, dHorizontalJingJuBiaoZhun = 1; + if (frmSh.rukuLayer != null) + { + #region + this.Invoke((EventHandler)delegate + { + try + { + List managerLayerList = new List(); + for (int i = 0; i < layerManagerNode.Nodes.Count; i++) + { + managerLayerList.Add(layerManagerNode.Nodes[i].Text); + } + if (!managerLayerList.Contains(frmSh.rukuLayer.Caption)) + { + TreeNode node = new TreeNode(); + node.Tag = frmSh.rukuLayer; + node.Text = frmSh.rukuLayer.Dataset.Caption; + node.ImageIndex = 0; + node.SelectedImageIndex = 0; + node.Checked = frmSh.rukuLayer.Visible; + layerManagerNode.Nodes.Insert(0, node); + layerManagerNode.Expand(); + } + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "提示"); + } + }); + #endregion + + shlayername = frmSh.rukuLayer.Name; + globeControl1.Refresh(); + } + + if (frmShResult != null && !frmShResult.IsDisposed) + { + try + { + clearFeatureHighLight(); + ClearRedlineAnalyseResult(); + frmShResult.Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message); + } + } + + 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.analysis(); + + //MainFrm窗体显示控制,回到一键审核Tab + this.Invoke((EventHandler)delegate + { + frmShResult.Show(); + frmWait.Close(); + //将tab页恢复到一键审核 + ribbonTabItem11.Checked = true; + try + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + //zhanshi = false; + splitContainer1.Panel2Collapsed = true; + + panelOfTable.Visible = false; + legendSC.Visible = false; + legendSG.Visible = false; + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + } + catch (Exception ex) + { + MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + + }); + + boolfrmShResult = true; + } + else + { + + } + } + + + /// + /// 清除渲染结果 + /// + 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(); + } + /// + /// 已审核的图层 + /// + /// + /// + private void buttonItem132_Click_1(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItem132.Text); + + if (shds == null) + { + //没连的话,直接连接审核库; //审核库配置读配置文件 + string dbIp = Utility.sgdbip; + string database = Utility.sgdbname; + string user = Utility.sgdbuser; + string pass = Utility.sgdbpwd; + + /* + 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; + //} + + } + /// + /// 审核入库 + /// + /// + /// + private void buttonItem133_Click_1(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, "审核入库"); + FrmShRK frmShrk = new FrmShRK(globeControl1); + frmShrk.Show(); + } + /// + /// 模拟设计修改 + /// + /// + /// + private void buttonItem134_Click_1(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, "模拟设计修改"); + + 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 + { + + } + + } + + + /// + /// 绘制垂线 + /// + /// + /// + 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); + } + /// + /// 比较两个点是否是同一个点 + /// + /// + /// + /// + 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; + } + /// + /// 获得点到线的垂线距离及垂点 + /// + /// + /// + /// + /// + 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); + 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]; + } + /// + /// 获得斜率 + /// + /// + /// + /// + /// + /// + /// + 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); + } + } + /// + /// 根据默认投影参数,经纬度转xyz + /// + /// + /// + /// + 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; + } + /// + /// 根据投影参数,经纬度转xyz + /// + /// + /// + /// + /// + 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; + } + /// + /// 根据默认投影参数,xyz转经纬度 + /// + /// + /// + /// + 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; + } + /// + /// 根据投影参数,Xyz转经纬度 + /// + /// + /// + /// + /// + 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; + } + /// + /// 获得inpolygon的管线长度 + /// + /// + 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; + } + + + /// + /// 一键审核中调节透明度 + /// + /// + /// + private void sliderItem1_ValueChanged(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.sliderItem1.Text); + + globeControl1.Globe.GroundOpaque = 100 - sliderItem1.Value; + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(roadLayerName);//("180fd"); + if (layer != null) + { + layer.Opaque = 100 - sliderItem1.Value; + } + + optiValue = sliderItem1.Value; + } + /// + /// 红线审核中的透明度分析 + /// + /// + /// + private void sliderItem3_ValueChanged(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.sliderItem3.Text); + + globeControl1.Globe.GroundOpaque = 100 - sliderItem3.Value; + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(roadLayerName);//("180fd"); + if (layer != null) + { + layer.Opaque = 100 - sliderItem3.Value; + } + optiValue = sliderItem3.Value; + } + + #region yanxiaowei + //初始化DataGridViewX1控件 + public delegate void DataGridViewDelegate(DataTable dt, string strLable, string strLayer, bool initDataGrid); + /// + /// 代理函数,操作DatgridViewX1 + /// + /// + /// + public void InitDataGridViewX1(DataTable dt, string strLable, string strLayer, bool initDataGrid) + { + if (initDataGrid == true) + { + dataGridViewX1.DataSource = dt; + panelOfTable.Visible = true; + toolStripNumbers.Text = strLable; + dataGridViewX1.Tag = strLayer; + } + else + { + dataGridViewX1.DataSource = null; + dataGridViewX1.Refresh(); + panelOfTable.Visible = false; + toolStripNumbers.Text = ""; + dataGridViewX1.Tag = ""; + globeControl1.Globe.MemoryLayer.RemoveAllFeature();//清除双击产生的标注 + } + } + FrmAnalysisGuiHuaResult from; + /// + /// 主窗体下方属性表格 双击定位 功能 + /// + /// + /// + private void dataGridViewX1_MouseDoubleClick(object sender, MouseEventArgs e) + { + if (redSH == false) + { + 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 if (dataGridViewX1.Columns.Contains("标识器编号")) + { + featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["标识器编号"].Value.ToString(); + } + featureName = featureName.Trim(); + + GSOLayer layer = null; + layer = globeControl1.Globe.Layers.GetLayerByCaption(dataGridViewX1.Tag.ToString()); + + if (layer == null) return; + + GSOFeatures features = layer.GetFeatureByName(featureName, false); + if (features.Length == 0) return; + GSOFeature rowFeature = features[0]; + + ClassSearchAnalysis.AddMakerToLineFeature(globeControl1, rowFeature); + + } + } + } + else + { + if (e.Button == MouseButtons.Left) + { + if (from != null && !from.IsDisposed) + { + try + { + from.Close(); + } + catch (Exception ex) + { + LogError.PublishError(ex); + } + } + try + { + DataGridView.HitTestInfo hittestinfo = dataGridViewX1.HitTest(e.X, e.Y); + if (hittestinfo.RowIndex >= 0) + { + string layer = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["管线类型"].Value.ToString(); + string hxName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["红线编号"].Value.ToString(); + FrmAnalysisGuiHuaResult frm = new FrmAnalysisGuiHuaResult(globeControl1, lineStruct, featsList, + panelOfTable, dataGridViewX1, layer, hxName); + frm.Location = new Point(this.Width - frm.Width - 10, this.Height - frm.Height - 20); + frm.Show(this); + + from = frm; + } + } + catch (Exception ex) + { + LogError.PublishError(ex); + } + } + } + } + + /// + /// 空间查询 + /// + /// + /// + private void buttonItemSearch1_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemSearch1.Text); + + trackflag = "PipelineSpatialQuery"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; + + } + /// + /// 关键字查询 + /// + /// + /// + private void buttonItemSearch9_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch9.Text); + + FrmKeywordQuery.ShowForm(globeControl1, m_PipelineLayerNames, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 编号查询 + /// + /// + /// + private void buttonItemSearch2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch2.Text); + + FrmCodingQuery.ShowForm(globeControl1, m_PipelineLayerNames, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 坐标查询 + /// + /// + /// + private void buttonItemSearch3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch3.Text); + + FrmSetLatLonPos.ShowForm(globeControl1); + } + /// + /// 附属物查询 + /// + /// + /// + private void buttonItemSearch10_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch10.Text); + + FrmFittingQuery.ShowForm(globeControl1, instrumenLayerNames, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 管径查询 + /// + /// + /// + private void buttonItemSearch4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch4.Text); + + FrmDiameterQuery.ShowForm(globeControl1, m_PipelineLayerNames, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 材质查询 + /// + /// + /// + private void buttonItemSearch5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch5.Text); + + FrmMaterialSel.ShowForm(globeControl1, m_PipelineLayerNames, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 基本查询 + /// + /// + /// + private void buttonItemSearch6_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch6.Text); + + FrmBasicQuery.ShowForm(globeControl1, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 复合查询 + /// + /// + /// + private void buttonItemSearch7_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch7.Text); + + FrmQuerySQL.ShowForm(globeControl1, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 关联查询 + /// + /// + /// + private void buttonItemSearch8_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch8.Text); + + if (globeControl1.Globe.SelObjectCount != 1) + { + MessageBox.Show("请选中一个对象!", "提示"); + return; + } + + 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 || (feature.Geometry.Type == EnumGeometryType.GeoPolygon3D + || feature.Geometry.Type == EnumGeometryType.GeoWater)) + return; + else + { + ClassSearchAnalysis.ResultRelationAnalysis(globeControl1, feature, valueLayerNames, workwellLayerNames, + instrumenLayerNames, pipefittingLayerNames, m_PipelineLayerNames, valueAllowance); + } + } + } + #endregion + /// + /// 清除分析 + /// + /// + /// + private void buttonItemClear_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemClear.Text); + + globeControl1.Globe.ClearMeasure(); + layerTemp.RemoveAllFeature(); + layerTemp2.RemoveAllFeature(); + buttonItemLS5.Checked = false; + + dataGridViewX1.DataSource = null; + panelOfTable.Visible = false; + + 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); + + NetworkAnalysisTool.ClearAllTopAnalysis(this.globeControl1); + // 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();//清除所有坑 + + 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(); + } + } + + clearFeatureHighLight();//取消管线高亮 + + GSOLayer layerGround = globeControl1.Globe.Layers.GetLayerByCaption(roadLayerName);//("180fd"); + if (layerGround != null) + { + layerGround.Visible = true; + } + globeControl1.Refresh(); + globeControl2.Refresh(); + ClearRedlineAnalyseResult(); + globeControl1.Globe.Action = EnumAction3D.ActionNull; + } + /// + /// 管线长度全区域统计 + /// + /// + /// + private void buttonItemTJ1_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管线长度统计"); + + //pipeLineDis.Clear(); + //List list = new List(); + //for (int i = 0; i < m_PipelineLayerNames.Count; i++) + //{ + // GSOFeatures fs = Intersects_Pipeline(null, m_PipelineLayerNames[i]); + // if (fs!=null) + // list.Add(fs); + //} + + //FrmAllPipelineStatis frm = new FrmAllPipelineStatis(0, pipeLineDis, list, globeControl1, new DataGridViewDelegate(InitDataGridViewX1)); + FrmAllPipelineStatis frm = new FrmAllPipelineStatis(globeControl1,null, new DataGridViewDelegate(InitDataGridViewX1), m_PipelineLayerNames); + frm.Show(this); + + } + /// + /// 管线长度绘制区域统计 + /// + /// + /// + private void buttonItemTJ1_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管线长度统计"); + + trackflag = "PipelineDistanceStatistics"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; + } + /// + /// 阀门数量全区域统计 + /// + /// + /// + private void buttonItemTJ2_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "阀门数量统计"); + + //workWellLen.Clear(); + //List list = new List(); + ////找到所有阀门 + //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, globeControl1, new DataGridViewDelegate(InitDataGridViewX1)); + FrmValveStatistics frm = new FrmValveStatistics(globeControl1, null, new DataGridViewDelegate(InitDataGridViewX1)); + frm.Show(this); + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + } + /// + /// 阀门数量绘制区域统计 + /// + /// + /// + private void buttonItemTJ2_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "阀门数量统计"); + + trackflag = "valvequery"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; + } + /// + /// 井盖数量全区域统计 + /// + /// + /// + private void buttonItemTJ3_ALL_Click(object sender, EventArgs e) + { + //日志记录 + //LogManager.saveLog(Utility.userName, "井盖数量统计"); + + //workWellLen.Clear(); + //List list = new List(); + + //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(null, dataGridViewX1, toolStripNumbers, globeControl1, panelOfTable); + FrmAllWorkWellStatis frm = new FrmAllWorkWellStatis(globeControl1, null, new DataGridViewDelegate(InitDataGridViewX1)); + frm.Show(this); + } + /// + /// 井盖数量绘制区域统计 + /// + /// + /// + private void buttonItemTJ3_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "井盖数量统计"); + + trackflag = "workwellquery"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; + } + /// + /// 管径分段统计全区域统计 + /// + /// + /// + private void buttonItemTJ4_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管径分段统计"); + + Frmpipediameterstatis.ShowForm(globeControl1, m_PipelineLayerNames, 0); + } + /// + /// 管径分段统计绘制区域统计 + /// + /// + /// + private void buttonItemTJ4_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管径分段统计"); + + trackflag = null; + Frmpipediameterstatis.ShowForm(globeControl1, m_PipelineLayerNames, 1); + } + /// + /// 埋深分段统计全区域统计 + /// + /// + /// + private void buttonItemTJ5_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "埋深分段统计"); + FrmpipeDeepstatis.ShowForm(globeControl1, m_PipelineLayerNames, 0); + } + /// + /// 埋深分段统计绘制区域统计 + /// + /// + /// + private void buttonItemTJ5_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "埋深分段统计"); + trackflag = null; + FrmpipeDeepstatis.ShowForm(globeControl1, m_PipelineLayerNames, 1); + } + /// + /// 管径分类统计全区域统计 + /// + /// + /// + private void buttonItemTJ6_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管径分类汇总"); + + FrmpipeDiametergather.ShowForm(globeControl1, m_PipelineLayerNames, 0); + } + /// + /// 管径分类统计绘制区域统计 + /// + /// + /// + private void buttonItemTJ6_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管径分类汇总"); + + trackflag = null; + FrmpipeDiametergather.ShowForm(globeControl1, m_PipelineLayerNames, 1); + } + /// + /// 材质分类统计全区域统计 + /// + /// + /// + private void buttonItemTJ7_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "材质分类汇总"); + + FrmpipeMaterialGather.ShowForm(globeControl1, m_PipelineLayerNames, 0); + } + /// + /// 材质分类统计绘制区域统计 + /// + /// + /// + private void buttonItemTJ7_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "材质分类汇总"); + + trackflag = null; + FrmpipeMaterialGather.ShowForm(globeControl1, m_PipelineLayerNames, 1); + } + /// + /// 附属物分类统计全区域统计 + /// + /// + /// + private void buttonItemTJ8_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "附属物分类汇总"); + + FrmAccessoriesgather.ShowForm(globeControl1, instrumenLayerNames, 0); + } + /// + /// 附属物分类统计绘制区域统计 + /// + /// + /// + private void buttonItemTJ8_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "附属物分类汇总"); + + trackflag = null; + FrmAccessoriesgather.ShowForm(globeControl1, instrumenLayerNames, 1); + } + /// + /// 碰撞分析 + /// + /// + /// + private void buttonItemFX1_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_4.Text); + + this.dataGridViewX4.Size = new System.Drawing.Size(195, 120); + 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(); + } + /// + /// 覆土分析 + /// + /// + /// + private void buttonItemFX1_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX5_1.Text); + this.dataGridViewX6.Size = new System.Drawing.Size(195, 120); + 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(); + } + /// + /// 间距分析 + /// + /// + /// + private void buttonItemFX1_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX1_3.Text); + + this.dataGridViewLineList.Size = new System.Drawing.Size(185, 120); + 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(); + } + /// + /// 垂直净距分析 + /// + /// + /// + private void buttonItemFX1_4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX1_4.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(); + } + /// + /// 水平净距分析 + /// + /// + /// + private void buttonItemFX1_5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_6.Text); + this.dataGridViewX8.Size = new System.Drawing.Size(185, 120); + 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(); + } + + #region Predaotr,断面分析 + /// + /// 横断面分析 + /// + /// + /// + private void buttonItemFX2_1_Click(object sender, EventArgs e) + { + globeControl1.Globe.Action = EnumAction3D.TrackPolyline; + globeControl1.Globe.TrackPolylineTool.VerticalLineVisible = true; + globeControl1.Globe.TrackPolylineTool.TrackMode = EnumTrackMode.SpaceTrack; + trackPolylineEndMode = EnumTrackPolylineEndMode.HDM_Analysis; + + } + /// + /// 纵断面分析 + /// + /// + /// + private void buttonItemFX2_2_Click(object sender, EventArgs e) + { + if (globeControl1.Globe.SelObjectCount<1) + { + MessageBox.Show("请选择一条或者多条管线!", "提示", MessageBoxButtons.OK, + MessageBoxIcon.Information); + return; + } + 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); + } + } + List feats = SectionAnalysisTool.ZDMAnalysis(selectFeatures); + if (feats != null && feats.Count >= 1) + { + FrmProfileAnalysis frm = new FrmProfileAnalysis(globeControl1, feats); + frm.Show(this); + } + } + /// + /// 道路断面分析 + /// + /// + /// + private void buttonItemFX2_3_Click(object sender, EventArgs e) + { + globeControl1.Globe.Action = EnumAction3D.TrackPolyline; + globeControl1.Globe.TrackPolylineTool.VerticalLineVisible = true; + globeControl1.Globe.TrackPolylineTool.TrackMode = EnumTrackMode.SpaceTrack; + trackPolylineEndMode = EnumTrackPolylineEndMode.DLDM_Analysis; + + } + /// + /// 基线剖面分析 + /// + /// + /// + private void buttonItemFX2_4_Click(object sender, EventArgs e) + { + globeControl1.Globe.Action = EnumAction3D.TrackPolyline; + globeControl1.Globe.TrackPolylineTool.VerticalLineVisible = true; + globeControl1.Globe.TrackPolylineTool.TrackMode = EnumTrackMode.SpaceTrack; + trackPolylineEndMode = EnumTrackPolylineEndMode.JXPM_Analysis; + + } + + #endregion + /// + /// 创建拓扑 + /// + /// + /// + private void buttonItemFX3_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX3_1.Text); + + FrmGenAndFaMenTopu frm = new FrmGenAndFaMenTopu(globeControl1, m_PipelineLayerNames, valueLayerNames); + frm.Show(this); + } + #region Predator :拓扑分析 + /// + /// 上游分析 + /// + /// + /// + private void buttonItemFX3_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX3_2.Text); + NetworkTraceUpDown(true); + } + /// + /// 下游分析 + /// + /// + /// + private void buttonItemFX3_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX3_3.Text); + NetworkTraceUpDown(false); + } + + /// + /// 上下游追踪 功能 + /// + /// + private void NetworkTraceUpDown(Boolean bTraceUp) + { + GSOFeature selLineFeature = globeControl1.Globe.SelectedObject; + if (selLineFeature == null || selLineFeature.Geometry == null || selLineFeature.Geometry.Type != EnumGeometryType.GeoPolyline3D) + { + MessageBox.Show("请点击“编辑”—“选中对象”选择一条线!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); + return; + } + GSOLayer selLayer = globeControl1.Globe.SelectedObjectLayer; + + NetworkAnalysisTool.TraceUpDownAnalysis(bTraceUp, + selLineFeature, selLayer); + } + + /// + /// 流向分析 + /// + /// + /// + private void buttonItemFX3_4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX3_4.Text); + + FrmFlow frm = new FrmFlow(globeControl1, m_PipelineLayerNames); + frm.Show(this); + } + /// + /// 关阀分析 + /// + /// + /// + private void buttonItemFX3_5_Click(object sender, EventArgs e) + { + if (globeControl1.Globe.SelObjectCount < 1) + { + MessageBox.Show("请选中至少一根管线!!"); + buttonItemFX3_5.Checked = false; + return; + } + GSOLayer resLayer = null; + GSOFeature resFeature = null; + globeControl1.Globe.GetSelectObject(0, out resFeature, out resLayer); + + String pipeLayerName = resLayer.Caption; + String pipeLayerNamePrefix = pipeLayerName.Substring(0, pipeLayerName.IndexOf("管线")); + GSOLayer valveLayer = globeControl1.Globe.Layers[pipeLayerNamePrefix + "阀门"]; + if (valveLayer == null) + { + MessageBox.Show("无" + pipeLayerNamePrefix+"阀门图层", "提示"); + return; + } + + GSOFeatures valveFeats = NetworkAnalysisTool.CloseValvesAnalysis(resFeature, + resLayer, valveLayer); + + if (valveFeats != null) + { + FrmCloseValves frm = new FrmCloseValves(this.globeControl1, valveFeats); + frm.Show(this); + } + else + { + MessageBox.Show("未找到关闭阀门"); + } + } + + /// + /// 连通分析 + /// + /// + /// + private void buttonItemFX3_6_Click(object sender, EventArgs e) + { + if (globeControl1.Globe.SelObjectCount < 2) + { + MessageBox.Show("请选中至少两个管线!!"); + buttonItemFX3_6.Checked = false; + return; + } + GSOFeature selFeat0, selFeat1; + GSOLayer layer0,layer1; + globeControl1.Globe.GetSelectObject(0, out selFeat0, out layer0); + globeControl1.Globe.GetSelectObject(1, out selFeat1, out layer1); + + if (!layer0.IsSameInnerObject(layer1)) + { + MessageBox.Show("不在同一个图层!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); + buttonItemFX3_6.Checked = false; + return; + } + NetworkAnalysisTool.ConnexityAnalysis(selFeat0, selFeat1, layer0); + } + /// + /// 爆管分析 + /// + /// + /// + private void buttonItemFX3_7_Click(object sender, EventArgs e) + { + NetworkTraceUpDown(true); //上游追踪: + + GSOFeature selLineFeature = globeControl1.Globe.SelectedObject; + if (selLineFeature == null || selLineFeature.Geometry == null || selLineFeature.Geometry.Type != EnumGeometryType.GeoPolyline3D) + { + MessageBox.Show("请点击“编辑”—“选中对象”选择一条线!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); + return; + } + GSOLayer selLayer = globeControl1.Globe.SelectedObjectLayer; + + NetworkAnalysisTool.ExplodeAnalysis(this.globeControl1,selLineFeature,selLayer); + + this.buttonItemFX3_5_Click(sender, e); //关阀分析: + + } + + #endregion + /// + /// 多边形开挖 + /// + /// + /// + private void buttonItemFX4_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_1.Text); + + trackflag = "pit"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; //是这个么?是的,在模型上 + } + /// + /// 挖方量分析 + /// + /// + /// + private void buttonItemFX4_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_2.Text); + + trackflag = "digFillAnalysis"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; + ActionToolMenuChecked(); + } + /// + /// 沿线开挖 + /// + /// + /// + private void buttonItemFX4_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_3.Text); + + if (!buttonItemFX4_3.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; + buttonItemFX4_3.Checked = true; + } + } + else + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + buttonItemFX4_3.Checked = false; + globeControl1.Globe.TrackPolylineTool.VerticalLineVisible = false; + } + ActionToolMenuChecked(); + } + /// + /// 创建隧道 + /// + /// + /// + private void buttonItemFX4_4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_4.Text); + + 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("场景中未加载隧道图层!", "提示"); + } + } + /// + /// 隐藏隧道 + /// + /// + /// + private void buttonItemFX4_5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_5.Text); + + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption("隧道"); + if (layer != null) + { + layer.Visible = !layer.Visible; + } + } + /// + /// 删除隧道 + /// + /// + /// + private void buttonItemFX4_6_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_6.Text); + + 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("请选中要删除的隧道!", "提示"); + } + } + /// + /// 通视分析 + /// + /// + /// + private void buttonItemFX5_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX5_1.Text); + + if (globeControl1.Globe.Action != EnumAction3D.VisibilityAnalysis) + { + //btnSpaceVisibilityAnalysis.Checked = true; + globeControl1.Globe.Action = EnumAction3D.VisibilityAnalysis; + } + else + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + // SetButtonChecked(); + } + } + /// + /// 可视域分析 + /// + /// + /// + private void buttonItemFX5_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX5_2.Text); + + globeControl1.Globe.Action = EnumAction3D.ViewshedAnalysis; + } + /// + /// 可视包络分析 + /// + /// + /// + private void buttonItemFX5_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX5_3.Text); + + globeControl1.Globe.Action = EnumAction3D.ViewEnvelopeAnalysis; + } + /// + /// 缓冲区分析 + /// + /// + /// + private void buttonItemFX6_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX6_1.Text); + + GSOFeature feat = globeControl1.Globe.SelectedObject; + if (feat == null) + { + MessageBox.Show("请选择要分析的要素!"); + return; + } + if (feat.Geometry.Type == EnumGeometryType.GeoPolyline3D) + { + GSOGeoPolyline3D line1 = feat.Geometry as GSOGeoPolyline3D; + if (line1 == null) + { + MessageBox.Show("请选择一条管线!"); + return; + } + + FrmBufferAnalysis frm = new FrmBufferAnalysis(globeControl1, line1, layerTemp); + frm.Show(this); + } + else + { + FrmBufferAnalysisBSQ frm = new FrmBufferAnalysisBSQ(globeControl1, layerTemp, bsqPT); + frm.Show(this); + } + + } + /// + /// 附属物分析 + /// + /// + /// + private void buttonItemFX6_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX6_2.Text); + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + FrmAccessoryAnalysis dlg = new FrmAccessoryAnalysis(globeControl1, layerTemp); + dlg.Show(this); + } + /// + /// 无源淹没分析 + /// + /// + /// + private void buttonItemFX6_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX6_3.Text); + + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + trackflag = "FloodAnalysis"; + } + /// + /// 水平距离 + /// + /// + /// + private void buttonItemLS1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS1.Text); + + globeControl1.Globe.Action = EnumAction3D.MeasureDistance; + globeControl1.Globe.DistanceRuler.SpaceMeasure = false; + buttonItemLS5.Checked = false; + } + /// + /// 垂直距离 + /// + /// + /// + private void buttonItemLS2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS2.Text); + + buttonItemLS5.Checked = false; + globeControl1.Globe.Action = EnumAction3D.MeasureHeight; + globeControl1.Globe.DistanceRuler.SpaceMeasure = false; + } + /// + /// 空间距离 + /// + /// + /// + private void buttonItemLS3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS3.Text); + + buttonItemLS5.Checked = false; + globeControl1.Globe.Action = EnumAction3D.MeasureDistance; + globeControl1.Globe.DistanceRuler.SpaceMeasure = true; + } + /// + /// 地表距离 + /// + /// + /// + private void buttonItemLS4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS4.Text); + + buttonItemLS5.Checked = false; + globeControl1.Globe.Action = EnumAction3D.MeasureDistance; + globeControl1.Globe.DistanceRuler.SpaceMeasure = false; + } + /// + /// 高度量算 + /// + /// + /// + private void buttonItemLS5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS5.Text); + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + buttonItemLS5.Checked = !buttonItemLS5.Checked; + if (buttonItemLS5.Checked) + { + globeControl1.Globe.Action = EnumAction3D.SelectObject; + } + } + /// + /// 水平面积 + /// + /// + /// + private void buttonItemLS6_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS6.Text); + + buttonItemLS5.Checked = false; + globeControl1.Globe.Action = EnumAction3D.MeasureArea; + globeControl1.Globe.AreaRuler.SpaceMeasure = true; + } + /// + /// 地表面积 + /// + /// + /// + private void buttonItemLS7_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS7.Text); + + buttonItemLS5.Checked = false; + globeControl1.Globe.Action = EnumAction3D.MeasureArea; + globeControl1.Globe.AreaRuler.SpaceMeasure = false; + + } + + # region Fan 重构标注代码 + /// + /// 标高标注 + /// + /// + /// + private void buttonItemSZ1_Click(object sender, EventArgs e) + { + GSOFeature resFeature = IsPipeLineOfSelectedObj(); + if (resFeature == null) + { + MessageBox.Show("请选中一根管线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + GSOGeoPolyline3D selLine = resFeature.Geometry as GSOGeoPolyline3D; + if (selLine[0].Count <= 1) + { + return; + } + + MarkTools.getInstance().showMarker(resFeature, + globeControl1, EnumMarkLayer.Mark_Altitude, ""); + } + /// + /// 管径标注 + /// + GSOFeature radiusMarkerFeature; + private void buttonItemBZ2_Click(object sender, EventArgs e) + { + GSOFeature resFeature = IsPipeLineOfSelectedObj(); + if (resFeature == null) + { + MessageBox.Show("请选中一根管线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + GSOGeoPolyline3D selLine = resFeature.Geometry as GSOGeoPolyline3D; + if (selLine[0].Count <= 1) + { + return; + } + + MarkTools.getInstance().showMarker(resFeature, + globeControl1, EnumMarkLayer.Mark_Diameter, ""); + } + /// + /// 埋深标注 + /// + /// + /// + private void buttonItemBZ3_Click(object sender, EventArgs e) + { + GSOFeature resFeature = IsPipeLineOfSelectedObj(); + if (resFeature == null) + { + MessageBox.Show("请选中一根管线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + GSOGeoPolyline3D selLine = resFeature.Geometry as GSOGeoPolyline3D; + if (selLine[0].Count <=1) + { + return; + } + + MarkTools.getInstance().showMarker(resFeature, + globeControl1, EnumMarkLayer.Mark_Depth, ""); + + } + /// + /// 坐标标注 + /// + /// + /// + private void buttonItemBZ4_Click(object sender, EventArgs e) + { + GSOFeature resFeature = IsPipeLineOfSelectedObj(); + if (resFeature == null) + { + MessageBox.Show("请选中一根管线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + GSOGeoPolyline3D selLine = resFeature.Geometry as GSOGeoPolyline3D; + if (selLine[0].Count <= 1) + { + return; + } + MarkTools.getInstance().showMarker(resFeature, + globeControl1, EnumMarkLayer.Mark_Location, ""); + } + /// + /// 距离标注 + /// + bool distanceMarker = false; + private void buttonItemBZ5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBZ5.Text); + + globeControl1.Globe.Action = EnumAction3D.TrackPolyline; + //globeControl1.Globe.DistanceRuler.MeasureMode = EnumDistanceMeasureMode.HVSLineMeasure; + distanceMarker = true; + } + /// + /// 自定义标注 + /// + /// + /// + private void buttonItemBZ6_Click(object sender, EventArgs e) + { + GSOFeature f = globeControl1.Globe.SelectedObject; + GSOLayer l = globeControl1.Globe.SelectedObjectLayer; + FrmCustomLabel frm = new FrmCustomLabel(globeControl1, l, f); + if (frm.ShowDialog() == DialogResult.OK) + { + MarkTools.getInstance().showMarker(f, globeControl1, EnumMarkLayer.Mark_Custom, frm.labelText); + } + } + /// + /// 扯旗标注 + /// + /// + /// + private void buttonItemBZ7_Click(object sender, EventArgs e) + { + GSOFeature f = globeControl1.Globe.SelectedObject; + GSOLayer l = globeControl1.Globe.SelectedObjectLayer; + FrmMarker frm = new FrmMarker(); + if (frm.ShowDialog() == DialogResult.OK) + { + MarkTools.getInstance().showMarker(f, globeControl1, EnumMarkLayer.Mark_Custom, frm.markerContent); + } + } + /// + /// 坡度标注 + /// + /// + /// + private void buttonItemBZ8_Click(object sender, EventArgs e) + { + GSOFeature resFeature = IsPipeLineOfSelectedObj(); + if (resFeature == null) + { + MessageBox.Show("请选中一根管线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + GSOGeoPolyline3D selLine = resFeature.Geometry as GSOGeoPolyline3D; + if (selLine[0].Count <= 1) + { + return; + } + + MarkTools.getInstance().showMarker(resFeature, + globeControl1, EnumMarkLayer.Mark_Slope, ""); + } + /// + /// 属性标注 + /// + /// + /// + private void buttonItemBZ9_Click(object sender, EventArgs e) + { + GSOFeature f = globeControl1.Globe.SelectedObject; + GSOLayer l = globeControl1.Globe.SelectedObjectLayer; + FrmPropertiesMarker frm = new FrmPropertiesMarker(globeControl1, l, f); + if (frm.ShowDialog() == DialogResult.OK) + { + MarkTools.getInstance().showMarker(f, globeControl1, EnumMarkLayer.Mark_Property, frm.labelText); + } + } + /// + /// 红线工具 + /// + /// + /// + private void buttonItemBZ10_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBZ10.Text); + 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; + } + } + /// + /// 标注管理 + /// + /// + /// + private void buttonItemBZ11_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBZ11.Text); + + buttonItemBZ11.Checked = !buttonItemBZ11.Checked; + 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 (buttonItemBZ11.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(); + } + } + + #endregion + /// + /// 飞行到目标点 + /// + /// + /// + private void buttonItemFXGJ1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFXGJ1.Text); + + FrmSetFlytoPos.ShowForm(globeControl1); + + } + /// + /// 自定义飞行 + /// + /// + /// + private void buttonItemFXGJ2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFXGJ2.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); + } + } + /// + /// 绕中心点飞行 + /// + /// + /// + private void buttonItemFXGJ3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFXGJ3.Text); + + globeControl1.Globe.FlyAroundCenter(10000, EnumFlyRepeatValueType.MiliSeconds); + globeControl1.Globe.CurFlyID = 1; + } + /// + /// 绕眼睛飞行 + /// + /// + /// + private void buttonItemFXGJ4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFXGJ4.Text); + + globeControl1.Globe.FlyAroundEye(720, EnumFlyRepeatValueType.Degrees); + globeControl1.Globe.CurFlyID = 2; + } + + /// + /// 权限管理 + /// + /// + /// + private void buttonItemXT1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT1.Text); + + FrmUserRoleMgr frm = new FrmUserRoleMgr(); + frm.ShowDialog(); + } + /// + /// 数据库管理 + /// + /// + /// + private void buttonItemXT2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT2.Text); + + //查看数据库列表 + FrmDbManager frm = new FrmDbManager(); + frm.ShowDialog(); + } + /// + /// 用户列表 + /// + /// + /// + private void buttonItemXT3_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT3_1.Text); + + FrmUserManager frm = new FrmUserManager(); + frm.ShowDialog(); + } + /// + /// 创建新用户 + /// + /// + /// + private void buttonItemXT3_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT3_2.Text); + + FrmUserAdd frm = new FrmUserAdd(-1); + frm.ShowDialog(); + } + /// + /// 人员修改 + /// + /// + /// + private void buttonItemXT4_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT4_2.Text); + + FrmAppUSER appUSER = new FrmAppUSER(); + appUSER.ShowDialog(); + } + /// + /// 增加人员 + /// + /// + /// + private void buttonItemXT4_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT4_1.Text); + + FrmAppUSERRESET appUSERRESET = new FrmAppUSERRESET(); + appUSERRESET.ShowDialog(); + } + /// + /// 统计数据 + /// + /// + /// + private void buttonItemZTT1_Click(object sender, EventArgs e) + { + ////日志记录 + //LogManager.saveLog(Utility.userName, this.buttonItemZTT1.Text); + + //PATM patm = new PATM(); + //patm.operation = "Statistic"; + //patm.Text = "统计专题图管理"; + //patm.ShowDialog(); + } + /// + /// 热点功能统计 + /// + /// + /// + private void buttonItemZTT2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT2.Text); + + FrmHotFuncStat frmhfs = new FrmHotFuncStat(); + frmhfs.ShowDialog(); + } + + private void buttonItemZTT3_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT3_1.Text); + + FrmAPP appfrm = new FrmAPP("专题图申请"); + appfrm.ShowDialog(); + } + + private void buttonItemZTT3_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT3_2.Text); + + FrmAPPFORASK appForask = new FrmAPPFORASK("专题图审核"); + appForask.ShowDialog(); + } + + private void buttonItemZTT3_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT3_3.Text); + + FrmAPPregion appregion = new FrmAPPregion("专题图审核"); + appregion.ShowDialog(); + } + + private void buttonItemZTT4_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT4_1.Text); + + FrmAPP appfrm = new FrmAPP("打印申请"); + appfrm.ShowDialog(); + } + + private void buttonItemZTT4_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT4_2.Text); + + FrmAPPFORASK appForask = new FrmAPPFORASK("打印审核"); + appForask.ShowDialog(); + } + + private void buttonItemZTT4_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT4_3.Text); + + FrmAPPregion appregion = new FrmAPPregion("打印审核"); + appregion.ShowDialog(); + } + + private void buttonItemZTT5_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT5_1.Text); + + FrmAPP appfrm = new FrmAPP("拷贝申请"); + appfrm.ShowDialog(); + } + + private void buttonItemZTT5_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT5_2.Text); + + FrmAPPFORASK appForask = new FrmAPPFORASK("拷贝审核"); + appForask.ShowDialog(); + } + + private void buttonItemZTT5_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT5_3.Text); + + FrmAPPregion appregion = new FrmAPPregion("拷贝审核"); + appregion.Show(); + } + + private int connectServerCount = 0; + + /// + /// 还原球到实测库 + /// + 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); + } + + if (layerManagerNode.Nodes.Count > 0) + { + for (int i = layerManagerNode.Nodes.Count - 1; i >= 0; i--) + { + layerManagerNode.Nodes[i].Remove(); + + } + } + + globeControl1.Refresh(); + + } + + private void buttonItemSPSZ_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSPSZ.Text); + + FrmLayerControl frm = new FrmLayerControl(layerTree, globeControl1, globeControl2); + frm.Show(this); + } + + /// + /// 碰撞审查 + /// + /// + /// + private void buttonItemSH1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSH1.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 buttonItemSH2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSH2.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 buttonItemSH3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSH3.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 buttonItemSH4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSH4.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 buttonItemSH5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSH5.Text); + FrmCityServerLineAnalysis frm = new FrmCityServerLineAnalysis(globeControl1, m_PipelineLayerNames); + frm.Show(this); + } + #region 数据管理-导入文件 + ///// + ///// 数据管理-导入本地坐标系文件 + ///// + ///// + ///// + //private void buttonItemSJGL1_1_Click(object sender, EventArgs e) + //{ + // //日志记录 + // LogManager.saveLog(Utility.userName, this.buttonItemSJGL1_1.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(); + // } + // } + //} + + ///// + ///// 数据管理-导入其他坐标系文件 + ///// + ///// + ///// + //private void buttonItemSJGL1_2_Click(object sender, EventArgs e) + //{ + // //日志记录 + // LogManager.saveLog(Utility.userName, this.buttonItemSJGL1_2.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(); + // } + // } + //} + #endregion + /// + /// 数据质量检查 + /// + /// + /// + private void buttonItemSJGL2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL2.Text); + FrmValiData frm = new FrmValiData(globeControl1); + frm.ShowDialog(); + } + /// + /// 数据预处理 + /// + /// + /// + private void buttonItemSJGL3_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL3.Text); + + FrmEditShapeFile frm = new FrmEditShapeFile(globeControl1); + frm.ShowDialog(this); + } + /// + /// 连接数据库 + /// + /// + /// + private void buttonItemSJGL4_1_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL4_1.Text); + + FrmDatabaseParaSetting frm = new FrmDatabaseParaSetting(globeControl1); + if (frm.ShowDialog() == DialogResult.OK) + { + ds = FrmDatabaseParaSetting.ds; + if (ds != null) + { + ds.IsCloseSaved = false; + } + } + } + /// + /// 管线入库 + /// + /// + /// + private void buttonItemSJGL4_2_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL4_2.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 buttonItemSJGL4_3_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL4_3.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 buttonItemSJGL5_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL5.Text); + + Cyberpipe.Forms.FrmProject frm = new Cyberpipe.Forms.FrmProject(); + frm.ShowDialog(); + } + /// + /// 元数据基本管理 + /// + /// + /// + private void buttonItemSJGL6_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL6_1.Text); + + FrmMetadata frmmd = new FrmMetadata(); + frmmd.ShowDialog(); + } + /// + /// 元数据查询管理 + /// + /// + /// + private void buttonItemSJGL6_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL6_2.Text); + + FrmMetadataStat frmmds = new FrmMetadataStat(); + //frmmds.Show(); + frmmds.ShowDialog(); + } + /// + /// 操作日志管理 + /// + /// + /// + private void buttonItemSJGL7_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL7.Text); + + FrmLogOper frmlo = new FrmLogOper(); + frmlo.ShowDialog(); + } + /// + /// 数据字典管理 + /// + /// + /// + private void buttonItemSJGL8_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL8.Text); + + FrmMDDictory frmmdd = new FrmMDDictory(); + frmmdd.ShowDialog(); + } + /// + /// 数据库备份 + /// + /// + /// + private void buttonItemSJGL9_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL9.Text); + + //新 + FrmBACKORACLE backOracle = new FrmBACKORACLE(); + backOracle.Show(); + } + /// + /// 创建管段 + /// + /// + /// + private void buttonItemBJ1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ1.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; + } + } + /// + /// 创建附属物 + /// + /// + /// + private void buttonItemBJ2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ2.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); + } + } + /// + /// 创建特征管点 + /// + /// + /// + private void buttonItemBJ3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ3.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); + } + } + /// + /// 绘制城市七线 + /// + /// + /// + private void buttonItemBJ4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ4.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; + } + } + } + /// + /// 选中对象 + /// + /// + /// + private void buttonItemBJ5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ5.Text); + + globeControl1.Globe.Action = EnumAction3D.SelectObject; + } + /// + /// 平移对象 + /// + /// + /// + private void buttonItemBJ6_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ6.Text); + + globeControl1.Globe.Action = EnumAction3D.MoveObject; + } + /// + /// 升降对象 + /// + /// + /// + private void buttonItemBJ7_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ7.Text); + + globeControl1.Globe.Action = EnumAction3D.ElevateObject; + } + /// + /// 旋转对象 + /// + /// + /// + private void buttonItemBJ8_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ8.Text); + + globeControl1.Globe.Action = EnumAction3D.RotateObject; + } + /// + /// 连接管段 + /// + /// + /// + private void buttonItemBJ9_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ9.Text); + + if (globeControl1.Globe.SelObjectCount < 2) + { + MessageBox.Show("对不起,请至少选中2个对象!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + return; + } + globeControl1.Globe.InsertJointPipeline(false); + } + /// + /// 后退 + /// + /// + /// + private void buttonItemBJ11_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemBJ11.Text); + globeControl1.Globe.UnDoEdit(); + } + /// + /// 前进 + /// + /// + /// + private void buttonItemBJ12_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemBJ12.Text); + + globeControl1.Globe.ReDoEdit(); + } + /// + /// 导出CAD + /// + /// + /// + private void buttonItemBJ10_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ10_1.Text); + + #region 导出成dxf格式 + List listVectorNames = new List(); + 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(); + #endregion + } + /// + /// 导出矢量 + /// + /// + /// + private void buttonItemBJ10_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ10_2.Text); + + List listVectorNames = new List(); + 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 buttonItemBJ13_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemBJ13.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(); + } + } + MessageBox.Show("删除成功!", "提示"); + } + else + { + MessageBox.Show("请选中要删除的模型!", "提示"); + } + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + } + + private void buttonItemHX1_1_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]; + string filePath = dlg.FileName; + string lastname = Path.GetFileName(filePath); + + 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(); + } + + } + } + } + + public struct LineStruct + { + public string layerName; + public string layerCode; + public string lineLength; + public string hxName; + } + + List lineStruct = new List(); + List featsList = new List(); + + /// + /// 红线审核 + /// + /// + /// + private void buttonItemHX2_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemHX2.Text); + redSH = true; + featsList.Clear(); + lineStruct.Clear(); + List listPipelineLayers = new List(); + + GSOLayer layer = null; + for (int i = 0; i < m_PipelineLayerNames.Count; i++) + { + layer = globeControl1.Globe.Layers.GetLayerByCaption(m_PipelineLayerNames[i]); + if (layer != null) + { + listPipelineLayers.Add(layer); + } + } + //yanxiaowei 重构 + GSOFeatures selectFeatures=new GSOFeatures(); + for (int i = 0; i < globeControl1.Globe.SelObjectCount; i++) + { + GSOFeature feature = null; + globeControl1.Globe.GetSelectObject(i, out feature, out layer); + selectFeatures.Add(feature); + } + DataTable table=new DataTable(); + + ClassGSOTool.CalculateRedLineResult(out table, redSH, selectFeatures, globeControl1, + listPipelineLayers,out lineStruct, out featsList); + + if (table.Rows.Count != 0) + AddDatagridView(table); + else + { + MessageBox.Show("没有侵入地块红线的管线数据!", "提示"); + dataGridViewX1.DataSource = null; + panelOfTable.Visible = false; + return; + } + } + + private void AddDatagridView(DataTable table) + { + dataGridViewX1.DataSource = table; + panelOfTable.Visible = true; + panelOfTable.Height = 200; + toolStripNumbers.Text = "红线审核 |共有:" + table.Rows.Count + "条"; + toolStripDropDownButton3.Visible = true; + } + /// + /// 主窗体 下方的工具条中的 导出.xls文件 按钮事件处理 + /// + /// + /// + private void toolStripDropDownButton3_Click(object sender, EventArgs e) + { + if (dataGridViewX1.Rows.Count == 0) + { + MessageBox.Show("表格内容为空!", "提示"); + return; + } + + string strSaveFile = string.Empty; + SaveFileDialog savefiledialog = new SaveFileDialog(); + savefiledialog.Filter = "Excel文件|*.xls,*.xlsx"; + savefiledialog.AddExtension = true; + savefiledialog.FileName = "红线审核"; + if (savefiledialog.ShowDialog() == DialogResult.OK) + strSaveFile = savefiledialog.FileName; + else return; + + ExpEXCEL.ExpToExcel(dataGridViewX1, strSaveFile, "红线审核", lineStruct, featsList); + MessageBox.Show("导出成功!"); + } + /// + /// 去除集合中重复的管线 + /// + /// + /// + /// + private GSOFeatures getFeaturesByFilter(GSOFeatures features, string fieldName) + { + if (features == null) + { + return null; + } + GSOFeatures featuresGet = new GSOFeatures(); + for (int i = 0; i < features.Length; i++) + { + GSOFeature featureFromFS = features[i]; + string fieldValueFromFS = featureFromFS.GetValue(fieldName).ToString().Trim(); + bool isHas = false; + for (int j = featuresGet.Length - 1; j >= 0; j--) + { + GSOFeature featureFromFSGet = featuresGet[j]; + string fieldValueFromFSGet = featureFromFSGet.GetValue(fieldName).ToString().Trim(); + if (fieldValueFromFS.Equals(fieldValueFromFSGet)) + { + isHas = true; + break; + } + } + if (isHas == false) + { + featuresGet.Add(featureFromFS.Clone()); + } + } + return featuresGet; + } + + private void sliderItem2_ValueChanged(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.sliderItem2.Text); + + globeControl1.Globe.GroundOpaque = 100 - sliderItem2.Value; + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(roadLayerName);//("180fd"); + if (layer != null) + { + layer.Opaque = 100 - sliderItem2.Value; + } + layer = globeControl2.Globe.Layers.GetLayerByCaption("180fd");//("180fd"); + if (layer != null) + { + layer.Opaque = 100 - sliderItem2.Value; + } + globeControl2.Globe.GroundOpaque = 100 - sliderItem2.Value; + + optiValue = sliderItem2.Value; + } + /// + /// 数据管理导入文件 + /// + /// + /// + private void buttonItemSJGL1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL1.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.Multiselect = true; + if (dlg.ShowDialog() == DialogResult.OK) + { + //自定义lprj文件名,从程序中复制一lprj文件。 + string filePath = dlg.FileName; + string lastname = Path.GetFileName(filePath); + + 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, 100); + + globeControl1.Refresh(); + } + } + } + + private void buttonItemHX1_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemHX1.Text); + + GSODataSource dataSpace = globeControl1.Globe.DataManager.OpenOracleDataSource(Utility.DBServer.Trim() + "/" + Utility.dbdatabase.Trim(), "", "", Utility.userID, Utility.DBPassword); + string filepath = ""; + //日志记录 + OpenFileDialog dlg = new OpenFileDialog(); + dlg.Filter = "矢量数据(*.shp)|*.shp|矢量数据(*.lgd)|*.lgd|CAD数据(*.dxf)|*.dxf|全部支持格式(*.lgd,*.shp,*.dxf)|*.lgd;*.shp;*.dxf;"; + dlg.Multiselect = true; + + #region 临时图层显示 + if (dlg.ShowDialog() == DialogResult.OK) + { + string filePath = dlg.FileName; + string lastname = Path.GetFileName(filePath); + + #region + for (int i = 0; i < dlg.FileNames.Length; i++) + { + string strDataPath = dlg.FileNames[i]; + filepath = strDataPath; + + GSOLayer layer = globeControl1.Globe.Layers.Add(strDataPath); + GSOFeatures RedFeatures = layer.GetAllFeatures(); + + 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(); + RedFeatures = features; + 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; + } + + /////////////////////////////////////////////////////////////////////////////////////////// + globeControl1.Globe.Layers.MoveTo(0, globeControl1.Globe.Layers.Count - 1); + globeControl1.Refresh(); + } + + IModelBuilder modelBuilder = new RedLineBuilder(); + + modelBuilder.batchInsert(dataSpace, redDt, RedFeatures); + + } + #endregion + + } + #endregion + } + /// + /// 定位 + /// + /// + /// + private void buttonItemLocation_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemLocation.Text); + + FrmFlyToPosition fly = new FrmFlyToPosition(globeControl1,globeControl2); + fly.Show(this); + } + /// + /// 2015-10-17演示代码 红线审核 + /// + /// + /// + private void ribbonTabItem6_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.FlyToPosition(new GSOPoint3d(120.610963, 31.188121, 50), EnumAltitudeMode.Absolute, -4, 50, 800); + globeControl1.Globe.FlyToPointSpeed = 10000000; + globeControl1.Globe.Action = EnumAction3D.SelectObject; + globeControl1.Refresh(); + + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + + //zhanshi = false; + redSH = true; + splitContainer1.Panel2Collapsed = true; + legendSG.Visible = false; + legendSC.Visible = false; + ClearGZData(); + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = true; + } + + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 基础工具 + /// + /// + /// + private void ribbonTabItem1_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + //zhanshi = false; + redSH = false; + splitContainer1.Panel2Collapsed = true; + panelOfTable.Visible = false; + legendSC.Visible = false; + legendSG.Visible = false; + ClearGZData(); + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + + + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 一键审核 + /// + /// + /// + private void ribbonTabItem11_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + //zhanshi = false; + redSH = false; + splitContainer1.Panel2Collapsed = true; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + panelOfTable.Visible = false; + legendSC.Visible = false; + legendSG.Visible = false; + ClearGZData(); + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + + + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 右屏添加冰箱数据 + /// + void AddDataToGlobeControl2() + { + + bool modelDataBool = false; + for (int i = globeControl2.Globe.Layers.Count - 1; i >= 0; i--) + { + GSOLayer layer = globeControl2.Globe.Layers[i]; + if (layer.Name.Contains("fttp:")) + { + modelDataBool = true; + break; + } + } + + if (modelDataBool == false) + { + GSOLayer ly = globeControl1.Globe.Layers.GetLayerByCaption("天地图地图"); + globeControl2.Globe.Layers.Add(ly); + } + else + { + return; + } + } + /// + /// 双屏对比 + /// + /// + /// + private void ribbonTabItem9_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent += new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent += new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + panelOfTable.Visible = false; + + splitContainer1.Panel2Collapsed = false; + //zhanshi = true; + redSH = false; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + sliderItem2.Value = 100 - globeControl1.Globe.GroundOpaque; + globeControl2.Globe.GroundOpaque = globeControl1.Globe.GroundOpaque; + legendSC.Visible = true; + legendSG.Visible = true; + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + AddDataToGlobeControl2(); + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 文档管理 + /// + /// + /// + private void ribbonTabItem4_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + panelOfTable.Visible = false; + //zhanshi = false; + redSH = false; + splitContainer1.Panel2Collapsed = true; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + legendSC.Visible = false; + legendSG.Visible = false; + ClearGZData(); + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 基础管理 + /// + /// + /// + private void ribbonTabItem14_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + panelOfTable.Visible = false; + //zhanshi = false; + redSH = false; + splitContainer1.Panel2Collapsed = true; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + legendSC.Visible = false; + legendSG.Visible = false; + ClearGZData(); + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 权限管理 + /// + /// + /// + private void ribbonTabItem2_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + panelOfTable.Visible = false; + //zhanshi = false; + redSH = false; + splitContainer1.Panel2Collapsed = true; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + legendSC.Visible = false; + legendSG.Visible = false; + ClearGZData(); + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + GSOFeature dpFeatuer = null; + /// + /// 双屏分析,点击管段分析 + /// + /// + /// + private void buttonItem8_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItem8.Text); + + //FrmCompareFeature frmCompareFeature = new FrmCompareFeature(globeControl1, globeControl2, layerTemp, layerTemp2,m_PipelineLayerNames,sgPipeLayersNames); + int width = this.Width; + FrmCompareFeature.ShowForm(globeControl1, globeControl2, layerTemp, layerTemp2, m_PipelineLayerNames, sgPipeLayersNames,width); + //frmCompareFeature.Location = new Point((this.Width - frmCompareFeature.Width)/2,50); + //frmCompareFeature.Show(this); + + } + /// + /// 红线审核导出图片 + /// + /// + /// + private void buttonItemDCTP_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemDCTP.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))); + */ + int mapWidth = 0; + int mapHeight = 0; + Point pt = getUpperLeftPoint(pt1, pt2, out mapWidth, out mapHeight); + int rightBottomX = pt.X + mapWidth; + int rightBottomY = pt.Y + mapHeight; + Image myImg = new Bitmap(mapWidth, mapHeight); + Graphics g = Graphics.FromImage(myImg); + g.CopyFromScreen(pt, new Point(0, 0), new Size(rightBottomX, rightBottomY)); + + 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; + } + } + } + /// + /// 标识器全区域统计 + /// + /// + /// + private void 标识器分类统计ToolStripMenuItem_Click(object sender, EventArgs e) + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + FrmBSQStatis bsqStatis = new FrmBSQStatis(); + bsqStatis.Show(this); + } + /// + /// 标识器绘制区域统计 + /// + /// + /// + private void 标识器分类统计ToolStripMenuItem1_Click(object sender, EventArgs e) + { + trackflag = "BSQDuoBianXiangStatis"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + } + + #region 保存和加载审核库加载的图层 + /* + private void saveLayerList(TreeNodeCollection treeNodeList) + { + string configPath = Application.StartupPath + "\\configLayerList.xml"; + try + { + XmlDocument doc = new XmlDocument(); + doc.Load(configPath); + XmlNode dbParams = doc.SelectSingleNode("Params/dbparams"); + XmlNode dbLayers = doc.SelectSingleNode("Params/dblayers"); + XmlNode layers = doc.SelectSingleNode("Params/layers"); + dbParams.RemoveAll(); + dbLayers.RemoveAll(); + layers.RemoveAll(); + + List listDS = new List(); + String shDatasourceName = Utility.sgdbip + "/" + Utility.sgdbname + "_" + Utility.sgdbuser; + bool flag = false; + + for (int i = 0; i < globeControl1.Globe.DataManager.DataSourceCount; i++) + { + GSODataSource ds = globeControl1.Globe.DataManager.GetDataSourceAt(i); + if (ds != null && ds.Type == EnumDataSourceType.SqlServer || ds.Type == EnumDataSourceType.Oracle) + { + if (ds.Name == shDatasourceName) + { + //防止因为多次连接同一个数据库 + if (flag == true) + { + break; + } + flag = true; + listDS.Add(ds); + GSODataSourceCnn conn = ds.GetConnectionInfo(); + + XmlElement dbparam = doc.CreateElement("shdbparam"); + XmlElement ip = doc.CreateElement("ship"); + ip.InnerText = conn.Server; + + XmlElement dbname = doc.CreateElement("shdbname"); + dbname.InnerText = conn.Database; + + XmlElement username = doc.CreateElement("shusername"); + username.InnerText = conn.User; + + XmlElement password = doc.CreateElement("shpassword"); + password.InnerText = conn.Password; + + XmlElement type = doc.CreateElement("shtype"); + if (ds.Type == EnumDataSourceType.SqlServer) + { + type.InnerText = "sqlserver"; + } + else + { + type.InnerText = "oracle"; + } + + dbparam.AppendChild(ip); + dbparam.AppendChild(dbname); + dbparam.AppendChild(username); + dbparam.AppendChild(password); + dbparam.AppendChild(type); + dbParams.AppendChild(dbparam); + } + + } + } + + for (int i = 0; i < treeNodeList.Count; i++) + { + GSOLayer layer = treeNodeList[i].Tag as GSOLayer; + if (Path.GetExtension(layer.Name) == "") + { + XmlElement dbLayer = doc.CreateElement("dblayer"); + XmlAttribute attri = doc.CreateAttribute("dbindex"); + for (int j = 0; j < listDS.Count; j++) + { + if (layer.Dataset.DataSource.Name == listDS[j].Name) + { + attri.Value = j.ToString(); + break; + } + } + dbLayer.Attributes.Append(attri); + dbLayer.InnerText = layer.Name; + + dbLayers.AppendChild(dbLayer); + } + else + { + XmlElement dbLayer = doc.CreateElement("layer"); + dbLayer.InnerText = layer.Name; + layers.AppendChild(dbLayer); + } + } + + doc.Save(configPath); + } + catch (Exception e) + { + + } + } + + private void openLayerList() + { + layerManagerNode.Nodes.Clear(); + + string configPath = Application.StartupPath + "\\configLayerList.xml"; + try + { + XmlDocument doc = new XmlDocument(); + doc.Load(configPath); + XmlNode dbParams = doc.SelectSingleNode("Params/dbparams"); + XmlNode dbLayers = doc.SelectSingleNode("Params/dblayers"); + XmlNode layers = doc.SelectSingleNode("Params/layers"); + + List listDS = new List(); + for (int i = 0; i < dbParams.ChildNodes.Count; i++) + { + string ip = ""; + string dbname = ""; + string username = ""; + string password = ""; + string type = ""; + XmlNode node = dbParams.ChildNodes.Item(i); + for (int j = 0; j < node.ChildNodes.Count; j++) + { + XmlNode nodeChild = node.ChildNodes.Item(j); + + if (nodeChild != null && nodeChild.Name == "ship") + { + ip = nodeChild.InnerText; + } + else if (nodeChild != null && nodeChild.Name == "shdbname") + { + dbname = nodeChild.InnerText; + } + else if (nodeChild != null && nodeChild.Name == "shusername") + { + username = nodeChild.InnerText; + } + else if (nodeChild != null && nodeChild.Name == "shpassword") + { + password = nodeChild.InnerText; + } + else if (nodeChild != null && nodeChild.Name == "shtype") + { + type = nodeChild.InnerText; + } + } + + if (type == "sqlserver") + { + GSODataSource ds = globeControl1.Globe.DataManager.OpenSqlServerDataSource(ip, "", dbname, username, password); + listDS.Add(ds); + } + else if (type == "oracle") + { + GSODataSource ds = globeControl1.Globe.DataManager.OpenOracleDataSource(ip + "/" + dbname, "", "", username, password); + listDS.Add(ds); + } + } + + for (int i = 0; i < dbLayers.ChildNodes.Count; i++) + { + XmlNode node = dbLayers.ChildNodes.Item(i); + if (node != null) + { + string layerName = node.InnerText; + XmlAttribute attri = node.Attributes["dbindex"]; + if (attri != null) + { + int dbIndex = -1; + if (int.TryParse(attri.Value, out dbIndex)) + { + GSODataset dataset = listDS[dbIndex].GetDatasetByName(layerName); + globeControl1.Globe.Layers.Add(dataset); + //更新树节点 + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + TreeNode layerNode = new TreeNode(); + layerNode.Tag = layer; + layerNode.Text = layer.Dataset.Caption; + layerNode.ImageIndex = 0; + layerNode.SelectedImageIndex = 0; + layerNode.Checked = layer.Visible; + layerManagerNode.Nodes.Insert(0, layerNode); + // layerManagerNode.Expand(); + + + } + } + } + } + for (int i = 0; i < layers.ChildNodes.Count; i++) + { + XmlNode node = layers.ChildNodes.Item(i); + if (node != null) + { + string layerName = node.InnerText; + globeControl1.Globe.Layers.Add(layerName); + + //更新树节点 + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + TreeNode layerNode = new TreeNode(); + layerNode.Tag = layer; + layerNode.Text = layer.Dataset.Caption; + layerNode.ImageIndex = 0; + layerNode.SelectedImageIndex = 0; + layerNode.Checked = layer.Visible; + layerManagerNode.Nodes.Insert(0, layerNode); + } + } + layerManagerNode.Expand(); + } + catch (Exception e) + { + + } + } + * */ + #endregion + + private void btn_check_history_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_check_history.Text); + + if (FrmCheckHistory.isOpen == true) + { + return; + } + FrmCheckHistory frm = new FrmCheckHistory(globeControl1, globeControl2); + frm.addNode += new AddNodeToLayerManagerNode(addNodeToLayerManagerNode); + frm.Show(); + + } + + private void buttonItem查看数据_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItem查看数据.Text); + + FrmThreeOracle tr = new FrmThreeOracle(globeControl1); + + if (tr.ShowDialog() == DialogResult.OK) + { + addNodeToLayerManagerNode(tr.rukuLayer); + globeControl1.Refresh(); + } + } + /// + /// 规划数据入库 + /// + /// + /// + private void buttonItemGHRK_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemGHRK.Text); + + FrmGHRK ghrk = new FrmGHRK(globeControl1, layerManagerNode); + ghrk.Show(this); + } + + private void btn_user_info_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_user_info.Text); + + if (!FrmSysUserInfoManger.IS_OPEN) + { + FrmSysUserInfoManger frm = new FrmSysUserInfoManger(); + frm.ShowDialog(); + } + } + + private void btn_role_info_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_role_info.Text); + + if (FrmRoleInfoManager.IS_OPEN) + { + return; + } + FrmRoleInfoManager frm = new FrmRoleInfoManager(); + frm.ShowDialog(); + } + + private void btn_resc_info_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_resc_info.Text); + + if (!SysRescInfoManager.IS_OPEN) + { + SysRescInfoManager frm = new SysRescInfoManager(); + frm.ShowDialog(); + } + } + + private void btn_role_resc_Click(object sender, EventArgs e) + { + + LogManager.saveLog(Utility.userName, this.btn_role_resc.Text); + + if (!FrmRoleRescManager.IS_OPEN) + { + FrmRoleRescManager frm = new FrmRoleRescManager(); + frm.ShowDialog(); + } + } + + private void btn_user_role_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_user_role.Text); + + if (FrmUserRole.IS_OPEN) + { + return; + } + FrmUserRole frm = new FrmUserRole(); + frm.ShowDialog(); + } + + private void btn_document_info_Click(object sender, EventArgs e) + { + + LogManager.saveLog(Utility.userName, this.btn_document_info.Text); + + //if (FormDocumentManager.IS_OPEN) + //{ + // return; + //} + //FormDocumentManager frm = new FormDocumentManager(); + //frm.ShowDialog(); + + //if (FormDocumentManager.IS_OPEN) + //{ + // return; + //} + //new FormDocumentManager().ShowDialog(); + if (FormDocumentManager.IS_OPEN) + { + return; + } + this.Cursor = Cursors.WaitCursor; + FormDocumentManager frm = new FormDocumentManager(); + frm.changeCursor += new ChangeCursor(changeCursorToDefault); + frm.ShowDialog(); + + } + + private void changeCursorToDefault() + { + this.Cursor = Cursors.Default; + } + + /// + /// 判断CAD文件是否有投影信息 + /// + /// + /// + Boolean CheckDatasetGeoReference(GSODataset dataset) + { + Boolean bSuccess = false; + if (dataset.GeoReferenceType == EnumGeoReferenceType.Flat) + { + if (MessageBox.Show("数据没有空间参考信息,请设置空间参考信息!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation) == DialogResult.OK) + { + String strPath = Path.GetDirectoryName(Application.ExecutablePath) + "\\Coordinate Systems"; + OpenFileDialog dlg = new OpenFileDialog(); + + dlg.InitialDirectory = strPath; + dlg.RestoreDirectory = true; + + dlg.Filter = "投影文件|*.prj||"; + if (dlg.ShowDialog() == DialogResult.OK) + { + bSuccess = dataset.LoadProjectionFromESRIFile(dlg.FileName); + } + } + } + else + { + return true; + } + return bSuccess; + } + + private void buttonItemexp_CAD_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemexp_CAD.Text); + + OpenFileDialog dlg = new OpenFileDialog(); + dlg.Filter = "支持格式(*.dwg)|*.dwg"; + dlg.Multiselect = true; + if (dlg.ShowDialog() == DialogResult.OK) + { + for (int i = 0; i < dlg.FileNames.Length; i++) + { + //this.Cursor = Cursors.WaitCursor; + string strDataPath = dlg.FileNames[i]; + + #region + //string strDataPathPrj = strDataPath.ToLower().Replace(".dwg", ".lprj"); + + //if (File.Exists(strDataPathPrj) == false) + //{ + // if (MessageBox.Show("数据没有空间参考信息,请设置空间参考信息!", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation) == DialogResult.OK) + // { + // String strPath = Application.StartupPath + "\\Coordinate Systems"; + // OpenFileDialog dlgPrj = new OpenFileDialog(); + // dlgPrj.InitialDirectory = strPath; + // dlgPrj.RestoreDirectory = true; + // dlgPrj.Multiselect = false; + // dlg.Filter = "投影文件|*.prj"; + // if (dlg.ShowDialog() == DialogResult.OK) + // { + // this.Cursor = Cursors.WaitCursor; + // string proj4 = GSODataEngineUtility.ConvertEsriPrjFileToProj4(dlg.FileName); + // using (StreamWriter stream = new StreamWriter(strDataPathPrj, false)) + // { + // stream.WriteLine("0prj4" + proj4 + ""); + // } + // AddLayerData(strDataPath); + // //globeControl1.Globe.Layers.Add(strDataPath); + + // this.Cursor = Cursors.Default; + // } + // else + // { + // AddLayerData(strDataPath); + // //globeControl1.Globe.Layers.Add(strDataPath); + // } + // } + // else + // { + // AddLayerData(strDataPath); + // //globeControl1.Globe.Layers.Add(strDataPath); + // } + + //} + //else + //{ + // //globeControl1.Globe.Layers.Add(strDataPath); + // AddLayerData(strDataPath); + //} + #endregion + AddLayerData(strDataPath); + //this.Cursor = Cursors.Default; + } + } + + 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, 100); + + globeControl1.Refresh(); + } + } + + private void btn_password_edit_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_password_edit.Text); + + if (FrmChangePassword.IS_OPEN) + { + return; + } + FrmChangePassword frm = new FrmChangePassword(); + frm.ShowDialog(); + } + /// + /// 多孔管线入库 + /// + /// + /// + private void buttonItem9_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL4_2.Text); + + if (ds == null) + { + MessageBox.Show("请先连接数据库", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + ConnectDB(null, null); + } + if (ds == null) + return; + + FrmMultiPipelineModelDB frm = new FrmMultiPipelineModelDB(globeControl1, ds); + if (frm.ShowDialog() == DialogResult.OK) + { + addNodeToLayerManagerNode(frm.rukuLayer); + } + //frm.Show(); + } + private void 导出CADToolStripMenuItem1_Click(object sender, EventArgs e) + { + TreeNode node = layerNodeContexMenu.Tag as TreeNode; + if (node == null) + { + MessageBox.Show("请在左侧节点集中选择要导出的图层", "提示"); + return; + } + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(node.Text.Trim()); + if (layer == null || layer.GetAllFeatures().Length <= 0) + { + MessageBox.Show("要导出的图层为空", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + return; + } + string strProjectName = Utility.projectStr; + if (strProjectName != "") + { + SaveFileDialog dlg = new SaveFileDialog(); + dlg.Filter = "*.dwg|*.dwg|*.dxf|*.dxf"; + dlg.FileName = layer.Caption; + if (dlg.ShowDialog(this) == DialogResult.OK) + { + globeControl1.Globe.MemoryLayer.SaveAs(dlg.FileName); + GSOLayer newlayer = globeControl1.Globe.Layers.Add(dlg.FileName); + newlayer.RemoveAllFeature(); + int featureCount = layer.GetAllFeatures().Length; + for (int i = 0; i < featureCount; i++) + { + GSOFeature feature = layer.GetAt(i); + if (feature != null && feature.Geometry != null) + { + if (feature.Geometry.Type == EnumGeometryType.GeoPolyline3D) + { + feature.Geometry.Style = new GSOSimpleLineStyle3D(); + } + else if (feature.Geometry.Type == EnumGeometryType.GeoPolygon3D) + { + feature.Geometry.Style = new GSOSimplePolygonStyle3D(); + } + newlayer.AddFeature(feature); + } + } + newlayer.Save(); + newlayer.Dataset.DataSource.RemoveDataset(newlayer.Dataset); + globeControl1.Globe.Layers.Remove(newlayer); + MessageBox.Show("导出CAD完成!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + } + } + } + + private void buttonItemGBJC_Click(object sender, EventArgs e) + { + FrmGBJC gb = new FrmGBJC(globeControl1, globeControl2, layerTemp, layerTemp2); + gb.Show(this); + } + + #region 右屏管纵数据控制 + private void 五十米主干道ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = true; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + + private void 三十六米次干道ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = true; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + + private void 四十二米次干道ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = true; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + + private void 二十四米一块板ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = true; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + + private void 二十四米三块板ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = true; + } + + private void 二十四米停车带ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = true; + lendendGZ24_3.Visible = false; + } + + private void 二十六米大堤路ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = true; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + + private void 清除管纵数据ToolStripMenuItem_Click(object sender, EventArgs e) + { + ClearGZData(); + } + + private void ClearGZData() + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + #endregion + + private void buttonItemPasswordReset_Click(object sender, EventArgs e) + { + Frm_password_reset reset = new Frm_password_reset(); + reset.Show(); + } + + private void pictureBox1_Paint(object sender, PaintEventArgs e) + { + int Width = this.Width; + string welcomeUser = "欢迎您:" + Utility.userName; + Graphics g = e.Graphics; + g.DrawString(welcomeUser, new Font("宋体", 12), new SolidBrush(Color.Black), Width - 180, 50); + } + + } +} \ No newline at end of file diff --git a/MainFrm.cs.LOCAL.9016.cs b/MainFrm.cs.LOCAL.9016.cs new file mode 100644 index 0000000..0b7e393 --- /dev/null +++ b/MainFrm.cs.LOCAL.9016.cs @@ -0,0 +1,13060 @@ +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; + + GSOBalloon featureTooltip2; + GSOBalloonEx balloonEx2; + + GSOLayer layerTemp; + GSOLayer layerTemp2; + FrmShResult frmShResult = null; + FrmRedlineResult frmredResult = null; + FrmMnModify frmModify = null; + public bool frmRedlineResult = false; + public bool boolfrmShResult = false; + public bool boolfrmModify = false; + + List m_PipelineLayerNames = new List();//线图层名称 + List workwellLayerNames = new List();//工井图层名称 + List valueLayerNames = new List();//阀门图层名称 + List instrumenLayerNames = new List();//附属物图层名称 + List pipefittingLayerNames = new List();//管件图层名称 + List sgPipeLayersNames = new List();//施工管线图层名称 + 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 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; + public string redLayer = null; + //GSOLayer redLayer1 = null; + bool redSH = false; + string redDt = "红线"; + //双屏对比 + //bool zhanshi=false; + Thread t = null; + private GSOHudButton legendSC;//定义图例 + private GSOHudButton legendSG;//定义图例 + //管纵图 + private GSOHudButton lendendGZ50; + private GSOHudButton lendendGZ36; + private GSOHudButton lendendGZ42; + private GSOHudButton lendendGZ24_1; + private GSOHudButton lendendGZ24_2; + private GSOHudButton lendendGZ24_3; + private GSOHudButton lendendGZ26; + + GSOGeoPoint3D bsqPT; + + FrmYJSHTC frmSh = null;//一键审核窗口全局变量wxl + FrmWait frmWait = null;//一键审核等待窗口 + //FrmWait frmWait2 = null;//文档操作等待窗口 + + float mouseDownX1,mouseDownY1; + float mouseDownX2,mouseDownY2; + /// + /// + /// + 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; + + featureTooltip2 = new GSOBalloon(globeControl2.Handle); + balloonEx2 = new GSOBalloonEx(globeControl2.Handle); + Utility.SetBallons(featureTooltip, balloonEx); + + panelOfTable.Height = 200; + + RigthMenuSet(); + + MenuSet(); + + } + /// + /// 右屏中添加管纵图片 + /// + private void AddGZ() + { + + lendendGZ50 = new GSOHudButton(); + lendendGZ50.SetImage(Application.StartupPath + "/Resource/管纵/50.png"); + lendendGZ50.SetOffset(0, 0); + lendendGZ50.MinOpaque = 1; + lendendGZ50.MaxOpaque = 1; + lendendGZ50.FadeOut = false; + lendendGZ50.Name = "lendendGZ50"; + lendendGZ50.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ50); + lendendGZ50.Visible = false; + + lendendGZ36 = new GSOHudButton(); + lendendGZ36.SetImage(Application.StartupPath + "/Resource/管纵/36.png"); + lendendGZ36.SetOffset(0, 0); + lendendGZ36.MinOpaque = 1; + lendendGZ36.MaxOpaque = 1; + lendendGZ36.FadeOut = false; + lendendGZ36.Name = "lendendGZ36"; + lendendGZ36.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ36); + lendendGZ36.Visible = false; + + lendendGZ42 = new GSOHudButton(); + lendendGZ42.SetImage(Application.StartupPath + "/Resource/管纵/42.png"); + lendendGZ42.SetOffset(0, 0); + lendendGZ42.MinOpaque = 1; + lendendGZ42.MaxOpaque = 1; + lendendGZ42.FadeOut = false; + lendendGZ42.Name = "lendendGZ42"; + lendendGZ42.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ42); + lendendGZ42.Visible = false; + + lendendGZ24_1 = new GSOHudButton(); + lendendGZ24_1.SetImage(Application.StartupPath + "/Resource/管纵/24_1.png"); + lendendGZ24_1.SetOffset(0, 0); + lendendGZ24_1.MinOpaque = 1; + lendendGZ24_1.MaxOpaque = 1; + lendendGZ24_1.FadeOut = false; + lendendGZ24_1.Name = "lendendGZ24_1"; + lendendGZ24_1.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ24_1); + lendendGZ24_1.Visible = false; + + lendendGZ24_2 = new GSOHudButton(); + lendendGZ24_2.SetImage(Application.StartupPath + "/Resource/管纵/24_2.png"); + lendendGZ24_2.SetOffset(0, 0); + lendendGZ24_2.MinOpaque = 1; + lendendGZ24_2.MaxOpaque = 1; + lendendGZ24_2.FadeOut = false; + lendendGZ24_2.Name = "lendendGZ24_2"; + lendendGZ24_2.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ24_2); + lendendGZ24_2.Visible = false; + + lendendGZ24_3 = new GSOHudButton(); + lendendGZ24_3.SetImage(Application.StartupPath + "/Resource/管纵/24_3.png"); + lendendGZ24_3.SetOffset(0, 0); + lendendGZ24_3.MinOpaque = 1; + lendendGZ24_3.MaxOpaque = 1; + lendendGZ24_3.FadeOut = false; + lendendGZ24_3.Name = "lendendGZ24_3"; + lendendGZ24_3.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ24_3); + lendendGZ24_3.Visible = false; + + lendendGZ26 = new GSOHudButton(); + lendendGZ26.SetImage(Application.StartupPath + "/Resource/管纵/26.png"); + lendendGZ26.SetOffset(0, 0); + lendendGZ26.MinOpaque = 1; + lendendGZ26.MaxOpaque = 1; + lendendGZ26.FadeOut = false; + lendendGZ26.Name = "lendendGZ26"; + lendendGZ26.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ26); + lendendGZ26.Visible = false; + + } + + public void RigthMenuSet() + { + if (Utility.userRole.IndexOf("清除分析") < 0) + { + toolRightMenu.Items.Remove(清除分析ToolStripMenuItem); + } + + #region 区域分析 + if (Utility.userRole.IndexOf("区域分析") < 0) + { + toolRightMenu.Items.Remove(区域分析ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("缓冲区分析") < 0) + { + 区域分析ToolStripMenuItem.DropDownItems.Remove(缓冲区分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("附属物分析") < 0) + { + 区域分析ToolStripMenuItem.DropDownItems.Remove(附属物分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("无源淹没分析") < 0) + { + 区域分析ToolStripMenuItem.DropDownItems.Remove(无源淹没分析ToolStripMenuItem); + } + } + #endregion + + #region 视域分析 + if (Utility.userRole.IndexOf("视域分析") < 0) + { + toolRightMenu.Items.Remove(视域分析ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("通视分析") < 0) + { + 视域分析ToolStripMenuItem.DropDownItems.Remove(通视分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("可视域分析") < 0) + { + 视域分析ToolStripMenuItem.DropDownItems.Remove(可视域分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("可视包络分析") < 0) + { + 视域分析ToolStripMenuItem.DropDownItems.Remove(可视包络分析ToolStripMenuItem); + } + } + #endregion + + #region 开发分析 + if (Utility.userRole.IndexOf("开挖分析") < 0) + { + toolRightMenu.Items.Remove(开挖分析ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("多边形开挖") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(多边形开挖ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("挖方量分析") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(挖方量分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("沿线开挖") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(沿线开挖ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("创建隧道") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(创建隧道ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("隐藏隧道") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(隐藏隧道ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("删除隧道") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(删除隧道ToolStripMenuItem); + } + } + #endregion + + #region 拓扑分析 + if (Utility.userRole.IndexOf("拓扑分析") < 0) + { + toolRightMenu.Items.Remove(拓扑分析ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("创建拓扑") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(创建拓扑ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("上游分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(上游分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("下游分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(下游分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("流向分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(流向分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("关阀分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(关阀分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("连通分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(连通分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("爆管分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(爆管分析ToolStripMenuItem); + } + } + #endregion + + #region 断面分析 + if (Utility.userRole.IndexOf("断面分析") < 0) + { + toolRightMenu.Items.Remove(断面分析ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("横断面分析") < 0) + { + 断面分析ToolStripMenuItem.DropDownItems.Remove(横断面分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("纵断面分析") < 0) + { + 断面分析ToolStripMenuItem.DropDownItems.Remove(纵断面分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("道路断面分析") < 0) + { + 断面分析ToolStripMenuItem.DropDownItems.Remove(道路断面分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("基线剖面分析") < 0) + { + 断面分析ToolStripMenuItem.DropDownItems.Remove(基线剖面分析ToolStripMenuItem); + } + } + #endregion + + #region 绘制区域统计 + if (Utility.userRole.IndexOf("绘制区域统计") < 0) + { + toolRightMenu.Items.Remove(绘制区域统计ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("绘制区域管线长度统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管线长度统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域阀门数量统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(阀门数量统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域井盖数量统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(井盖数量统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域管径分段统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管径分段统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域埋深分段统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(埋深分段统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域管径分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管径分类统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域材质分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(材质分类统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域附属物分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(附属物分类统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域标识器分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(标识器分类统计ToolStripMenuItem1); + } + + } + #endregion + + #region 全区域统计 + if (Utility.userRole.IndexOf("全区域统计") < 0) + { + toolRightMenu.Items.Remove(全区域统计ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("全区域管线长度统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管线长度统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域阀门数量统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(阀门数量统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域井盖数量统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(井盖数量统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域管径分段统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管径分段统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域埋深分段统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(埋深分段统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域管径分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管径分类统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域材质分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(材质分类统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域附属物分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(附属物分类统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域标识器分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(标识器分类统计ToolStripMenuItem); + } + + } + #endregion + + #region 查询 + if (Utility.userRole.IndexOf("查询") < 0) + { + toolRightMenu.Items.Remove(查询ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("空间查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(空间查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("编号查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(编号查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("坐标查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(坐标查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("管径查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(管径查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("材质查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(材质查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("基本查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(基本查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("复合查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(复合查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("关联查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(关联查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("关键字查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(关键字查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("附属物查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(附属物查询ToolStripMenuItem); + } + } + #endregion + + #region 标注 + if (Utility.userRole.IndexOf("标注") < 0) + { + toolRightMenu.Items.Remove(标注ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("标高标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(标高标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("管径标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(管径标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("埋深标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(埋深标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("坐标标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(坐标标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("距离标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(距离标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("自定义标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(自定义标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("扯旗标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(扯旗标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("坡度标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(坡度标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("属性标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(属性标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("标注管理") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(标注管理ToolStripMenuItem); + } + } + #endregion + + #region 飞行 + if (Utility.userRole.IndexOf("飞行") < 0) + { + toolRightMenu.Items.Remove(飞行ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("自定义飞行") < 0) + { + 飞行ToolStripMenuItem.DropDownItems.Remove(自定义飞行ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("飞行到目标点") < 0) + { + 飞行ToolStripMenuItem.DropDownItems.Remove(飞行到目标点ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("绕中心点飞行") < 0) + { + 飞行ToolStripMenuItem.DropDownItems.Remove(绕中心点飞行ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("绕眼睛飞行") < 0) + { + 飞行ToolStripMenuItem.DropDownItems.Remove(绕眼睛飞行ToolStripMenuItem); + } + } + #endregion + + #region 编辑 + if (Utility.userRole.IndexOf("编辑") < 0) + { + toolRightMenu.Items.Remove(编辑ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("平移对象") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(平移对象ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("升降对象") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(升降对象ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("旋转对象") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(旋转对象ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("连接管段") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(连接管段ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("导出文件") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(导出文件ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("前进") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(前进ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("后退") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(删除模型ToolStripMenuItem); + } + } + #endregion + + #region 量算 + if (Utility.userRole.IndexOf("量算") < 0) + { + toolRightMenu.Items.Remove(量算ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("水平距离") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(水平距离ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("垂直距离") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(垂直距离ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("空间距离") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(空间距离ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("地表距离") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(地表距离ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("高度量算") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(高度量算ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("水平面积") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(水平面积ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("地表面积") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(地表面积ToolStripMenuItem1); + } + } + #endregion + } + + public void MenuSet() + { + + #region 权限管理 + if (Utility.userRole.IndexOf("权限管理") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem2); + } + else + { + + if (Utility.userRole.IndexOf("用户管理") < 0) + { + btn_user_info.Visible = false; + } + if (Utility.userRole.IndexOf("角色管理") < 0) + { + btn_role_info.Visible = false; + } + if (Utility.userRole.IndexOf("资源管理") < 0) + { + btn_resc_info.Visible = false; + } + if (Utility.userRole.IndexOf("角色授权") < 0) + { + btn_role_resc.Visible = false; + } + if (Utility.userRole.IndexOf("用户授权") < 0) + { + btn_user_role.Visible = false; + } + if (Utility.userRole.IndexOf("密码修改") < 0) + { + btn_password_edit.Visible = false; + } + + } + #endregion + + #region 基础工具 + if (Utility.userRole.IndexOf("基础工具") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem1); + } + else + { + if (Utility.userRole.IndexOf("地上模式") < 0) + { + buttonItem87.Visible = false; + } + if (Utility.userRole.IndexOf("地下模式") < 0) + { + buttonItem88.Visible = false; + } + if (Utility.userRole.IndexOf("行走模式") < 0) + { + buttonItem27.Visible = false; + } + if (Utility.userRole.IndexOf("透明度设置") < 0) + { + sliderGroundTransSet1.Visible = false; + } + if (Utility.userRole.IndexOf("快速定位") < 0) + { + buttonItem91.Visible = false; + } + if (Utility.userRole.IndexOf("图层管理") < 0) + { + buttonItem1.Visible = false; + } + if (Utility.userRole.IndexOf("图例管理") < 0) + { + btnlegendSet.Visible = false; + } + if (Utility.userRole.IndexOf("全屏显示") < 0) + { + buttonItem89.Visible = false; + } + if (Utility.userRole.IndexOf("导出图片") < 0) + { + btnOutputJPG.Visible = false; + } + + } + #endregion + + #region 一键审核 + if (Utility.userRole.IndexOf("一键审核") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem11); + } + #endregion + + #region 红线审核 + if (Utility.userRole.IndexOf("红线审核") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem6); + } + #endregion + + #region 双屏对比 + if (Utility.userRole.IndexOf("双屏对比") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem9); + } + #endregion + + #region 文档管理 + if (Utility.userRole.IndexOf("文档管理") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem4); + } + #endregion + + #region 基础管理 + if (Utility.userRole.IndexOf("基础管理") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem14); + } + else + { + if (Utility.userRole.IndexOf("专题图审批") < 0) + { + buttonItemZTT3_2.Visible = false; + } + if (Utility.userRole.IndexOf("打印审批") < 0) + { + buttonItemZTT4_2.Visible = false; + } + if (Utility.userRole.IndexOf("拷贝审批") < 0) + { + buttonItemZTT5_2.Visible = false; + } + } + + #endregion + + if (ribbonControl1.Items.Count <= 0) + { + ribbonControl1.Visible = false; + } + } + + #region Fan Zhang 重构现有代码 + //初始化控件布局 + private void initLayout() + { + 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.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.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.labelX21.Width = (int)(this.labelX21.Width * myScreen); + this.labelX22.Width = (int)(this.labelX22.Width * myScreen); + this.labelX24.Width = (int)(this.labelX24.Width * myScreen); + } + sideBar1.Visible = false; + 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]); + } + + splitContainer1.Panel2Collapsed = true; + + buttonItem87.Checked = true;//默认地上模式 + ribbonTabItem1.Select(); //初始化状态为浏览 + + sideBarPanelItem3.Visible = false; + layerTree.Visible = false; + controlContainerItem3.Visible = false; + if (sideBarPanelItem4.Visible == true) + { + sideBar1.Visible = true; + controlContainerItem5.Visible = true; + } + else + { + sideBar1.Visible = false; + } + Refresh(); + sliderGroundTransSet1.Value = optiValue; + sliderItem1.Value = optiValue; + sliderItem2.Value = optiValue; + sliderItem3.Value = optiValue; + + } + + //初始化地球控件 + private void initGlobalControl() + { + //选择 + btnToolSelect = new GSOHudButton(); + btnToolSelect.SetImage(Application.StartupPath + "\\Resource\\image\\select1.png"); + btnToolSelect.FadeOut = false; + btnToolSelect.Align = EnumAlign.TopLeft; + btnToolSelect.SetOffset(20, 50); + btnToolSelect.Name = "1"; + btnToolSelect.HeightFixed = true; + btnToolSelect.WidthFixed = true; + globeControl1.Globe.AddHudControl(btnToolSelect); + globeControl2.Globe.AddHudControl(btnToolSelect); + + //浏览 + 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); + + //图例 + legend = new GSOHudButton(); + legend.SetImage(Application.StartupPath + "/Resource/图例P.jpg");//图例P + legend.SetOffset(0, 15); + legend.MinOpaque = 1; + legend.MaxOpaque = 1; + legend.FadeOut = false; + legend.Name = "legend"; + legend.Align = EnumAlign.BottomRight; + legend.Visible = false; + globeControl1.Globe.AddHudControl(legend); + + //实测 + legendSC = new GSOHudButton(); + legendSC.SetImage(Application.StartupPath + "/Resource/sc.jpg"); + legendSC.SetOffset(0, 15); + legendSC.MinOpaque = 1; + legendSC.MaxOpaque = 1; + legendSC.FadeOut = false; + legendSC.Name = "legendSC"; + legendSC.Align = EnumAlign.BottomRight; + globeControl1.Globe.AddHudControl(legendSC); + legendSC.Visible = false; + + //施工 + legendSG = new GSOHudButton(); + legendSG.SetImage(Application.StartupPath + "/Resource/sg.jpg"); + legendSG.SetOffset(0, 15); + legendSG.MinOpaque = 1; + legendSG.MaxOpaque = 1; + legendSG.FadeOut = false; + legendSG.Name = "legendSG"; + legendSG.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(legendSG); + legendSG.Visible = false; + + //管纵 + AddGZ(); + + 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; + globeControl1.Globe.IsReleaseMemOutOfView = true; + globeControl1.Globe.ControlPanel.Visible = true; + + globeControl2.Globe.UnderGroundFloor.Visible = false; + globeControl2.Globe.OverviewControl.Visible = false; + globeControl2.Globe.ScalerControl.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; + globeControl2.Globe.IsReleaseMemOutOfView = true; + globeControl2.Globe.ControlPanel.Visible = false; + + 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); + + //添加临时图层 + layerTemp = globeControl1.Globe.Layers.Add(Application.StartupPath + "\\tempLgdData.lgd"); + layerTemp2 = globeControl2.Globe.Layers.Add(Application.StartupPath + "\\tempLgdData2.lgd"); + if (layerTemp != null) + { + layerTemp.MaxVisibleAltitude = 1000; + } + + //添加城市7线图层 + 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"); + + //注册对应事件 + this.registerEvent(); + } + + //注册地球事件 + private bool registerEvent() + { + if (globeControl1 == null || globeControl2 == null) + { + return false; + } + 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); + + globeControl2.FeatureMouseClickEvent += new FeatureMouseClickEventHandler(globeControl2_FeatureMouseClickEvent); + globeControl2.CameraBeginMoveEvent += new CameraBeginMoveEventHandler(globeControl2_CameraBeginMoveEvent); + + globeControl1.MouseDoubleClick += new MouseEventHandler(globeControl1_MouseDoubleClick); + globeControl1.MouseClick += new MouseEventHandler(globeControl1_MouseClick); + globeControl1.MouseDown += new MouseEventHandler(globeControl1_MouseDown); + + globeControl2.MouseClick += new MouseEventHandler(globeControl2_MouseClick); + globeControl2.MouseDown += new MouseEventHandler(globeControl2_MouseDown); + + 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); + + return true; + } + + //加载两个地球数据 + private void loadData() + { + Thread t1 = new Thread(new ThreadStart(doLoadDataForGlobalControl1)); + t1.IsBackground = true; + t1.Start(); + + + } + + delegate void LoadDataForGlobalControl(); + + private void connectServer() + { + globeControl1.Globe.ConnectServer(Utility.serverip, Utility.serverport, "", ""); //加载locaServer中的数据 + globeControl2.Globe.ConnectServer(Utility.serverip, Utility.serverport, "", ""); //加载locaServer中的数据 + //初始化TreeView + // 勾选实测图层 + foreach (TreeNode tn in layerTree.Nodes) + { + if (tn.Nodes.Count > 0) + { + if (tn.Text == "实测数据") + { + tn.Checked = true; + foreach (TreeNode tnChild in tn.Nodes) + { + tnChild.Checked = true; + foreach (TreeNode tnGrandChild in tnChild.Nodes) + { + tnGrandChild.Checked = true; + } + } + } + } + } + } + + private void doLoadDataForGlobalControl1() + { + try + { + + globeControl1.Globe.Layers.MoveDown(10000); + //加载实测管线数据 + Utility.dataSource = globeControl1.Globe.DataManager.OpenOracleDataSource(Utility.DBServer.Trim() + "/" + Utility.dbdatabase.Trim(), "", "", Utility.userID, Utility.DBPassword); + + if (Utility.dataSource != null) + { + for (int j = 0; j < Utility.dataSource.DatasetCount; j++) + { + GSODataset dataset = Utility.dataSource.GetDatasetAt(j); + if (dataset != null && dictionaryNetLayerNameAndCaption.ContainsKey(dataset.Caption)) + { + dataset.Caption = dataset.Name; + globeControl1.Globe.Layers.Add(dataset); + } + } + } + //隐藏红线图层 + globeControl1.Globe.Layers.GetLayerByCaption("红线").Visible = false; + + //globleControl1中加载规划数据 + GSODataSource ghDS = globeControl1.Globe.DataManager.OpenOracleDataSource(Utility.ghdbip + "/" + Utility.ghdbname, "", "", Utility.ghdbuser, Utility.ghdbpwd); + if (ghDS != null) + { + for (int j = 0; j < ghDS.DatasetCount; j++) + { + GSODataset dataset = ghDS.GetDatasetAt(j); + if (dataset != null && dictionaryNetLayerNameAndCaption.ContainsKey(dataset.Caption)) + { + dataset.Caption = dataset.Name; + globeControl1.Globe.Layers.Add(dataset); + globeControl1.Globe.Layers[0].Visible = false; + } + } + } + + //globeControl1,globeControl2中加载施工数据 + GSODataSource sgDS = globeControl1.Globe.DataManager.OpenOracleDataSource(Utility.sgdbip + "/" + Utility.sgdbname, "", "", Utility.sgdbuser, Utility.sgdbpwd); + if (sgDS != null) + { + for (int m = 0; m < sgDS.DatasetCount; m++) + { + GSODataset dataset = sgDS.GetDatasetAt(m); + if (dataset != null && !dataset.Caption.Contains("SH") && dictionaryNetLayerNameAndCaption.ContainsKey(dataset.Caption)) + { + dataset.Caption = dataset.Name; + globeControl1.Globe.Layers.Add(dataset); + globeControl1.Globe.Layers[0].Visible = false; + + globeControl2.Globe.Layers.Add(dataset); + globeControl2.Globe.Layers[0].Visible = true; + } + } + } + + LoadDataForGlobalControl ss = new LoadDataForGlobalControl(connectServer); + ss(); + + } + catch (Exception ex) + { + MessageBox.Show(ex.Message); + } + } + + private void initLayerTree() + { + //加载临时图层节点 + layerManagerNode = new TreeNode(); + layerManagerNode.ImageIndex = 0; + layerManagerNode.SelectedImageIndex = 0; + layerManagerNode.Checked = true; + layerManagerNode.Text = "临时图层"; + layerTree.Nodes.Add(layerManagerNode); + + XmlDocument doc = new XmlDocument(); + doc.Load(filename); + XmlNodeList xmlLayerNodes = doc.SelectNodes("//layer"); + + foreach (XmlNode xmlLayerNode in xmlLayerNodes) + { + + //TODO LIST:创建一级TreeNode(实测、规划、施工) + TreeNode nodelayer = new TreeNode(); + string layerName = xmlLayerNode.Attributes["label"].Value; + nodelayer.Text = layerName; + nodelayer.Checked = false; + layerTree.Nodes.Add(nodelayer); + + XmlNodeList xmlChildLayerNodes = xmlLayerNode.ChildNodes; + foreach (XmlNode xmlChildLayerNode in xmlChildLayerNodes) + { + //TODO LIST:创建二级TreeNode节点 + TreeNode secondLevelNode = new TreeNode(); + string layerType = xmlChildLayerNode.Attributes["label"].Value; + secondLevelNode.Text = layerType; + + if (xmlChildLayerNode.Attributes["type"] != null) + { //道路图层特殊处理 + string type = xmlChildLayerNode.Attributes["type"].Value; + secondLevelNode.Tag = type + "|" + layerType; + } + else + { + secondLevelNode.Tag = layerType; + } + secondLevelNode.Checked = false; + nodelayer.Nodes.Add(secondLevelNode); + + XmlNodeList xmlActitualLayerNodes = xmlChildLayerNode.ChildNodes; + + foreach (XmlNode xmlActitualLayerNode in xmlActitualLayerNodes) + { + //TODO LIST:创建三级图层节点 + TreeNode layerNode = new TreeNode(); + string actutallylayerType = xmlActitualLayerNode.Attributes["type"].Value; + string actutallylayerName = xmlActitualLayerNode.Attributes["layer"].Value; + string actutallyLabelName = xmlActitualLayerNode.Attributes["label"].Value; + + layerNode.Text = actutallyLabelName; + layerNode.Tag = layerType + "|" + actutallyLabelName; + layerNode.Checked = false; + secondLevelNode.Nodes.Add(layerNode); + } + + } + + } + + } + + /** + * 读取Config.xml文件,初始化以下全局Map + * m_PipelineLayerNames:管线 + * workwellLayerNames:工井 + * valueLayerNames:阀门 + * instrumenLayerNames:附属物 + * pipefittingLayerNames:特征管点 + * sgPipeLayersNames:施工管线 + **/ + private void initGlobalMap() + { + XmlDocument doc = new XmlDocument(); + doc.Load(filename); + XmlNodeList xmlLayerNodes = doc.SelectNodes("//layerchild"); + + foreach (XmlNode xmlLayerNode in xmlLayerNodes) + { + string layerType = xmlLayerNode.Attributes["type"].Value; + string layerName1 = xmlLayerNode.Attributes["layer"].Value; + string layerchildName = xmlLayerNode.Attributes["label"].Value; + + dictionaryNetLayerNameAndCaption.Add(layerName1, layerchildName); + + if (layerType != "db") + { + if (xmlLayerNode.Attributes["isRoad"] != null) + { + roadLayerName = layerchildName; + } + } + else if (xmlLayerNode.Attributes["isPipeLine"] != null) + { + m_PipelineLayerNames.Add(layerchildName); + g1layername.Add(layerName1); + } + else if (xmlLayerNode.Attributes["isWorkWell"] != null) + { + workwellLayerNames.Add(layerchildName); + g1layername.Add(layerName1); + } + else if (xmlLayerNode.Attributes["isValve"] != null) + { + valueLayerNames.Add(layerchildName); + g1layername.Add(layerName1); + } + else if (xmlLayerNode.Attributes["isAccess"] != null) + { + instrumenLayerNames.Add(layerchildName); + g1layername.Add(layerName1); + } + else if (xmlLayerNode.Attributes["isCharacter"] != null) + { + pipefittingLayerNames.Add(layerchildName); + g1layername.Add(layerName1); + } + else if (xmlLayerNode.Attributes["isSgData"] != null) + { + sgPipeLayersNames.Add(layerchildName); + g1layername.Add(layerName1); + } + + } + } + + private void initMarkerTree() + { + 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); + } + } + } + } + + private void MainFrm_Load(object sender, EventArgs e) + { + + this.initGlobalControl(); + this.initGlobalMap(); + this.initLayerTree(); + this.initMarkerTree(); + this.initLayout(); + this.loadData(); + + + double x = Convert.ToDouble(Utility.Query_Roads["绿岛"].ToString().Split(',')[0]); + double y = Convert.ToDouble(Utility.Query_Roads["绿岛"].ToString().Split(',')[1]); + double z = Convert.ToDouble(Utility.Query_Roads["绿岛"].ToString().Split(',')[2]); + jumpToCameraState(x, y, z); + + + } + + #endregion + + /// + /// 每次gis服务加载时都会触发的 + /// + /// + /// + 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 dictionaryNetLayerNameAndCaption = new Dictionary(); + 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 配置用户权限 + /// + /// 向数据库插入功能列表 + /// + private void insertControlToDatabase() + { + ArrayList listItem = new ArrayList(); + List subListItem = new List(); + 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) + { + GSOCameraState camera = globeControl2.Globe.CameraState; + globeControl1.Globe.JumpToCameraState(camera); + } + } + + void globeControl1_BeforeSceneRenderEvent(object sender, BeforeSceneRenderEventArgs e) + { + if (globeControl1.Focused) + { + 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); + } + } + } + + /// + /// 检查数据集是否有坐标系信息 + /// + /// + /// + 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 = "0prj4" + lprjStr + ""; + + bSuccess = dataset.LoadProjectionFromESRIFile(dlg.FileName); + + string lprjFileName = strDataPath.Substring(0, strDataPath.LastIndexOf(".")) + ".lprj"; + StreamWriter writer = new StreamWriter(lprjFileName, false); + writer.Write(lprjFileContent); + writer.Close(); + + } + } + } + else + { + return true; + } + return bSuccess; + } + + /// + /// 矩形拉框结束事件处理函数 + /// + /// + /// + 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))); + */ + + int mapWidth = 0; + int mapHeight = 0; + Point pt = getUpperLeftPoint(pt1, pt2, out mapWidth, out mapHeight); + int rightBottomX = pt.X + mapWidth; + int rightBottomY = pt.Y + mapHeight; + Image myImg = new Bitmap(mapWidth, mapHeight); + Graphics g = Graphics.FromImage(myImg); + g.CopyFromScreen(pt, new Point(0, 0), new Size(rightBottomX, rightBottomY)); + + 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; + } + } + /// + /// 定位正北正90度俯视 + /// + /// + /// + /// + 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; + } + } + /// + /// layerTree选中后事件处理 + /// + /// + /// + 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); + } + /// + /// 树节点选中方法 + /// + /// + 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); + } + } + } + + } + /// + /// 改变所有子节点的状态 + /// + /// + /// + 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; + LayerFlyMenuItem.Visible = true; + } + + LayerSelectableMenuItem.Visible = true; + LayerEditableMenuItem.Visible = true; + SaveLayerMenuItem.Visible = true; + LayerFlyMenuItem.Visible = true; + 导出CADToolStripMenuItem1.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]); + if (layer != null) + { + LayerSelectableMenuItem.Checked = layer.Selectable; + LayerEditableMenuItem.Checked = layer.Editable; + } + else + { + return; + } + } + 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; + } + } + } + } + } + + /// + /// 删除临时添加的本地数据图层 + /// + /// + /// + 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); + for (int i = globeControl1.Globe.Layers.Count-1; i >=0; i--) + { + if (globeControl1.Globe.Layers[i].Caption == layer.Caption) + { + globeControl1.Globe.Layers.Remove(globeControl1.Globe.Layers[i]); + } + } + + 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 定位ToolStripMenuItem_Click(object sender, EventArgs e) + { + TreeNode node = layerTree.SelectedNode; + + if (node != null) + { + if (node.Parent.Text.Trim() == "临时图层") + { + GSOLayer lsLayer = globeControl1.Globe.Layers.GetLayerByCaption(node.Text.ToString()); + double x = lsLayer.LatLonBounds.Center.X; + double y = lsLayer.LatLonBounds.Center.Y; + if (x == 0 && y == 0) + { + x = lsLayer.Bounds.Center.X; + y = lsLayer.Bounds.Center.Y; + } + + globeControl1.Globe.FlyToPosition(new GSOPoint3d(x, y, 10), EnumAltitudeMode.Absolute); + } + else + { + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(node.Tag.ToString().Split('|')[1]); + + if (layer != null) + { + if (layer.Caption == "红线") + { + globeControl1.Globe.FlyToPosition(new GSOPoint3d(120.610963, 31.188121, 50), EnumAltitudeMode.Absolute, -4, 50, 1000); + globeControl1.Globe.FlyToPointSpeed = 10000000; + globeControl1.Globe.Action = EnumAction3D.SelectObject; + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = true; + } + globeControl1.Refresh(); + } + else + { + double x = layer.LatLonBounds.Center.X; + double y = layer.LatLonBounds.Center.Y; + globeControl1.Globe.FlyToPosition(new GSOPoint3d(x, y, 100), EnumAltitudeMode.Absolute); + } + } + } + } + else + { + return; + } + + } + + private void layerTree_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e) + { + if(this.layerTree.SelectedNode!=null) + { + if (this.layerTree.SelectedNode.Tag.ToString().Contains("|")) + { + string nodeTag = this.layerTree.SelectedNode.Tag.ToString().Split('|')[1]; + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(nodeTag); + if (layer != null) + { + if (layer.Caption == "红线") + { + globeControl1.Globe.FlyToPosition(new GSOPoint3d(120.610963, 31.188121, 50), EnumAltitudeMode.Absolute, -4, 50, 1000); + globeControl1.Globe.FlyToPointSpeed = 10000000; + globeControl1.Globe.Action = EnumAction3D.SelectObject; + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = true; + } + globeControl1.Refresh(); + } + else { + double x = layer.LatLonBounds.Center.X; + double y = layer.LatLonBounds.Center.Y; + globeControl1.Globe.FlyToPosition(new GSOPoint3d(x, y, 0), EnumAltitudeMode.Absolute); + } + } + } + if (this.layerTree.SelectedNode.Tag is GSOLayer) + { + GSOLayer layer = this.layerTree.SelectedNode.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 (this.layerTree.SelectedNode.Tag is GSOFeature) + { + GSOFeature feature = this.layerTree.SelectedNode.Tag as GSOFeature; + if (feature.Geometry != null) + { + globeControl1.Globe.FlyToPosition(feature.Geometry.GeoCenterPoint, EnumAltitudeMode.Absolute, 0, 0, 10); + } + else + { + globeControl1.Globe.FlyToFeature(feature); + } + } + } + } + + /// + /// 在三维场景移动时,隐藏气泡globeControl1 + /// + /// + /// + void globeControl1_CameraBeginMoveEvent(object sender, CameraBeginMoveEventArgs e) + { + if (featureTooltip.IsVisible()) + { + featureTooltip.HideBalloon(); + } + if (balloonEx.IsVisible()) + { + balloonEx.HideBalloon(); + } + } + + /// + /// 在三维场景移动时,隐藏气泡globeControl2 + /// + /// + /// + void globeControl2_CameraBeginMoveEvent(object sender, CameraBeginMoveEventArgs e) + { + if (featureTooltip2.IsVisible()) + { + featureTooltip2.HideBalloon(); + } + if (balloonEx2.IsVisible()) + { + balloonEx2.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(); + } + } + + #region Fan 横断面 + /// + /// 横断面分析、基线剖面分析、道路断面分析等 + /// + /// + /// + private static EnumTrackPolylineEndMode trackPolylineEndMode; + + void globeControl1_TrackPolylineEndEvent(object sender, TrackPolylineEndEventArgs e) + { + //横断面分析、道路横断面分析 + if (trackPolylineEndMode == EnumTrackPolylineEndMode.HDM_Analysis|| + trackPolylineEndMode == EnumTrackPolylineEndMode.DLDM_Analysis) + { + Dictionary hdmDic = SectionAnalysisTool.HDMAnalysis(this.globeControl1, + e.Polyline, this.m_PipelineLayerNames); + FrmHDMAnalysis3 frm = new FrmHDMAnalysis3(hdmDic, this.globeControl1, + trackPolylineEndMode); + frm.Show(this); + } + //基线剖面分析 + else if (trackPolylineEndMode == EnumTrackPolylineEndMode.JXPM_Analysis) + { + FrmBaseLineProfillAnalysis dlg = new FrmBaseLineProfillAnalysis(globeControl1.Globe, e.Polyline); + dlg.Show(this); + globeControl1.Globe.ClearLastTrackPolyline(); + } + else + { + + } + trackPolylineEndMode = EnumTrackPolylineEndMode.Default_Analysis; + } + #endregion + + private GSOFeatures PolygonIntersectAnalysis(GSOGeoPolygon3D polygon, string pipelinetype) + { + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(pipelinetype); + 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(pipelinetype, feats.Length); + return feats; + } + /// + /// 根据范围统计阀门、管线、工井等, 开挖分析, 挖方量分析 + /// + /// + /// + void globeControl1_TrackPolygonEndEvent(object sender, TrackPolygonEndEventArgs e) + { + if (globeControl1.Globe.Action == EnumAction3D.TrackPolygon && e.Polygon != null) + { + GSOGeoPolygon3D polygon = e.Polygon; + + switch (trackflag) + { + case "valvequery": + FrmValveStatistics frm = new FrmValveStatistics(globeControl1,polygon, new DataGridViewDelegate(InitDataGridViewX1)); + frm.Show(this); + globeControl1.Globe.Action = EnumAction3D.ActionNull; + break; + + case "PipelineDistanceStatistics": + FrmAllPipelineStatis frm1 = new FrmAllPipelineStatis(globeControl1, polygon, new DataGridViewDelegate(InitDataGridViewX1), m_PipelineLayerNames); + frm1.Show(this); + globeControl1.Globe.Action = EnumAction3D.ActionNull; + + break; + case "PipelineSpatialQuery": + FrmAllPipelineStatis.ShowForm(globeControl1,polygon,new DataGridViewDelegate(InitDataGridViewX1),m_PipelineLayerNames); + globeControl1.Globe.ClearAnalysis(); + globeControl1.Globe.Action = EnumAction3D.ActionNull; + + break; + case "workwellquery": + FrmAllWorkWellStatis frmWell = new FrmAllWorkWellStatis(globeControl1, polygon, new DataGridViewDelegate(InitDataGridViewX1)); + 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 "BSQDuoBianXiangStatis": + + GSOFeature f2 = new GSOFeature(); + f2.Geometry = e.Polygon; + f2.Geometry.AltitudeMode = EnumAltitudeMode.Absolute; + globeControl1.Globe.MemoryLayer.AddFeature(f2); + f2.Geometry.MoveZ(3); + workWellLen.Clear(); + List listBSQ = new List(); + + GSOFeatures bsqFeatures = PolygonIntersectAnalysis(e.Polygon, "标识器"); + listBSQ.Add(bsqFeatures); + + FrmBSQDuoBianXingStatis bsqFrm = new FrmBSQDuoBianXingStatis(workWellLen, globeControl1, listBSQ); + bsqFrm.Show(this); + globeControl1.Globe.Action = EnumAction3D.ActionNull; + break; + + case "": + break; + default: + break; + } + } + } + + #region 验证端口 + /* + /// + /// 验证端口 + /// + /// + 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 + + /// + /// 鼠标悬浮提示 + /// + /// + /// + 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); + } + } + + /// + /// 添加管线绘制完成事件, 红线工具绘制完成 + /// + /// + /// + 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; + + + } + } + + /// + /// 获取globeControl1中鼠标按下的坐标供区别鼠标右键和滚轮按下事件 + /// + /// + /// + void globeControl1_MouseDown(object sender, MouseEventArgs e) + { + mouseDownX1 = e.X; + mouseDownY1 = e.Y; + } + /// + /// 获取globeControl2中鼠标按下的坐标供区别鼠标右键和滚轮按下事件 + /// + /// + /// + void globeControl2_MouseDown(object sender, MouseEventArgs e) + { + mouseDownX2 = e.X; + mouseDownY2 = e.Y; + } + /// + /// + /// + /// + /// + void globeControl2_MouseClick(object sender, MouseEventArgs e) + { + if (e.Button == MouseButtons.Right) + { + if (e.X == mouseDownX2 && e.Y == mouseDownY2) + { + RightScreenToolMenu.Show(globeControl2, e.X, e.Y); + } + else + { + return; + } + } + } + /// + /// + /// + /// + /// + void globeControl1_MouseClick(object sender, MouseEventArgs e) + { + if (e.Button == MouseButtons.Left) + { + if (globeControl1.Globe.Action == EnumAction3D.VisibilityAnalysis) + { + buttonItemFX5_1.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; + + bsqPT = pt; + + if (buttonItemLS5.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 (e.X == mouseDownX1 && e.Y == mouseDownY1) + { + toolRightMenu.Show(globeControl1, e.X, e.Y); + if (buttonItemLS5.Checked) + { + buttonItemLS5.Checked = false; + } + } + else + { + return; + } + } + globeControl1.Refresh(); + } + + /// + /// 判断网络图片是否存在 + /// + /// + /// + 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; + } + + /// + /// 鼠标点击, 弹出气泡功能globeControl1 + /// + /// + /// + void globeControl1_FeatureMouseClickEvent(object sender, FeatureMouseClickEventArgs e) + { + GSOFeature feature = e.Feature; + + string str1 = ""; + if (feature != null) + { + if (feature.GetFieldDefn("图片编码") != null)// + { + str1 = GetBubbleInfo(feature, globeControl1); + if (RemoteFileExists(Utility.PicRootURL + feature.GetValue("图片编码").ToString())) + { + str1 += ""; + } + else if (RemoteFileExists(Utility.PicDefaultURL)) + { + str1 += ""; + } + } + else if (isFeatureContainsBianhao(feature)) //管线模型图层 + { + str1 = GetBubbleInfo(feature, globeControl1); + } + + 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; + } + } + } + + /// + /// 鼠标点击, 弹出气泡功能globeControl2 + /// + /// + /// + void globeControl2_FeatureMouseClickEvent(object sender, FeatureMouseClickEventArgs e) + { + GSOFeature feature = e.Feature; + + string str1 = ""; + if (feature != null) + { + if (feature.GetFieldDefn("图片编码") != null) // + { + str1 = GetBubbleInfo(feature, globeControl2); + if (RemoteFileExists(Utility.PicRootURL + feature.GetValue("图片编码").ToString())) + { + str1 += ""; + } + else if (RemoteFileExists(Utility.PicDefaultURL)) + { + str1 += ""; + } + } + else if (isFeatureContainsBianhao(feature)) //管线模型图层 + { + str1 = GetBubbleInfo(feature, globeControl2); + } + + if (str1 != "") + { + + featureTooltip2.HideBalloon(); + balloonEx2.HideBalloon(); + balloonEx2.SetSize(EnumSizeIndexEx.CONTENT_CX, 480); + balloonEx2.SetSize(EnumSizeIndexEx.CONTENT_CY, 420); + balloonEx2.ShowBalloon((int)e.MousePos.X, (int)e.MousePos.Y, str1); + + return; + } + } + } + + /// + /// 拼接气泡表格字符串 + /// + /// + /// + private string GetBubbleInfo(GSOFeature feature,GSOGlobeControl globeControl) + { + if (feature == null) + { + return ""; + } + string str = ""; + str = ""; + 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 += ""; + + 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.get_Fields(layerName, globeControl); + } + if (queryFields != null) + { + string[] param = { "," }; + string[] fieldNames = queryFields.Split(param, StringSplitOptions.RemoveEmptyEntries); + for (int j = 0; j < fieldNames.Length; 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 (name1 == "模型路径") + { + continue; + } + 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 (field1.Type == EnumFieldType.Double) + { + double dl1 = feature.GetFieldAsDouble(j); + if (!name1.Contains("管径") && !name1.Contains("电压") && !name1.Contains("角度")) + { + name1 += "_米"; + } + value1 = dl1.ToString("0.00"); + } + 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 (name2 == "模型路径") + { + continue; + } + + 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 (field2.Type == EnumFieldType.Double) + { + double dl2 = feature.GetFieldAsDouble(j + 1); + if (!name2.Contains("管径") && !name2.Contains("电压") && !name2.Contains("角度")) + { + name2 += "_米"; + } + value2 = dl2.ToString("0.00"); + } + else + { + if (!feature.IsFieldValueNull(j + 1)) + { + value2 = feature.GetValue(j + 1).ToString(); + } + } + } + } + + j++; + } + str += ""; + } + } + str += "
" + title + " " + feature.GetFieldAsString(featureIDFieldName) + "
" + + name1 + + "
" + + value1 + + "
" + + name2 + + "
" + + value2 + "
"; + return str; + } + + string filename = Utility.filename; + List g1layername = new List(); + + /// + /// 获取目标图层 + /// + /// + 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; + } + /// + /// 添加图层 + /// + /// + /// + /// + 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 = 5000; + return templayer.Visible; + } + catch (Exception ex) + { + return false; + } + } + /// + /// 菜单上的 三维导航 工具按钮 + /// + /// + /// + private void buttonItem86_Click(object sender, EventArgs e) + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + } + + /// + /// 地上模式 菜单按钮 + /// + /// + /// + 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(); + + } + } + /// + /// 地下模式 菜单按钮 + /// + /// + /// + 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(); + } + } + /// + /// 行走模式 菜单按钮 + /// + /// + /// + 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; + } + } + /// + /// 地面透明度设置 菜单 + /// + /// + /// + private void sliderGroundTransSet1_ValueChanged(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.sliderGroundTransSet1.Text); + + globeControl1.Globe.GroundOpaque = 100 - sliderGroundTransSet1.Value; + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(roadLayerName);//("180fd"); + if (layer != null) + { + layer.Opaque = 100 - sliderGroundTransSet1.Value; + } + //if (buttonItemSPDB.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; + } + /// + /// 图例 菜单按钮 + /// + /// + /// + 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(); + } + /// + /// 快速定位 菜单按钮 + /// + /// + /// + private void buttonItem91_Click(object sender, EventArgs e) // + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItem91.Text); + FrmFlyToPosition fly = new FrmFlyToPosition(globeControl1); + fly.Show(this); + } + /// + /// 图层管理 菜单按钮 + /// + /// + /// + 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; + + //修改图层管理与标注管理、覆土审查、水平净距分析、垂直净距分析和碰撞分析控件之间的逻辑关系 + controlContainerItem5.Visible = false; + sideBar1.Visible = false; + sideBarPanelItem4.Visible = false; + panel3.Visible = false; + sideBar1.ExpandedPanel = sideBarPanelItem3; + buttonItemBZ11.Checked = false; + + //20160624 + /* + if (sideBarPanelItem4.Visible == true) + { + sideBar1.Visible = true; + controlContainerItem5.Visible = true; + } + else + { + sideBar1.Visible = false; + } + */ + Refresh(); + + } + } + /// + /// 全屏显示 菜单按钮 + /// + /// + /// + 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; + /// + /// 全屏显示功能实现 + /// + 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(); + } + } + + /// + /// 设置窗体宽、高 + /// + /// + /// + private void SetFullScreen(int width, int height) + { + this.Width = width; + this.Height = height; + } + + /// + /// 全屏功能的快捷键F5 + /// + /// + /// + 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); + } + } + /* + /// + /// 输出地图 + /// + /// + /// + /// + 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; + } + * */ + + private Point getUpperLeftPoint(Point p1, Point p2, out int mapWidth, out int mapHeight) // + { + Rectangle rc = new Rectangle(); + + p1 = this.globeControl1.PointToScreen(p1); + p2 = this.globeControl1.PointToScreen(p2); + + int x = Screen.PrimaryScreen.Bounds.X; + int y = Screen.PrimaryScreen.Bounds.Y; + int screenWidth = SystemInformation.WorkingArea.Width; + int screenHeight = SystemInformation.WorkingArea.Height; + + if (p1.X < x) + rc.X = x; + else + rc.X = p1.X; + + if (p1.Y < y) + rc.Y = y; + else + rc.Y = p1.Y; + + p1.X = rc.Left; + p1.Y = rc.Top; + + if (p2.X > screenWidth) + p2.X = screenWidth; + else + p2.X = p2.X; + + if (p2.Y > screenHeight) + p2.Y = screenHeight; + else + p2.Y = p2.Y; + + rc.Width = p2.X - rc.X; + rc.Height = p2.Y - rc.Y; + + mapWidth = rc.Width; + mapHeight = rc.Height; + Point pt = new Point(rc.Left, rc.Top); + return pt; + } + + Image printImage; + /// + /// 打印 菜单 + /// + /// + /// + 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))); + */ + int mapWidth = 0; + int mapHeight = 0; + Point pt = getUpperLeftPoint(pt1, pt2, out mapWidth, out mapHeight); + int rightBottomX = pt.X + mapWidth; + int rightBottomY = pt.Y + mapHeight; + Image myImg = new Bitmap(mapWidth, mapHeight); + Graphics g = Graphics.FromImage(myImg); + g.CopyFromScreen(pt, new Point(0, 0), new Size(rightBottomX, rightBottomY)); + + + 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); + } + /// + /// 输出地图 菜单 + /// + /// + /// + private void btnOutputJPG_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btnOutputJPG.Text); + + //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))); + */ + int mapWidth = 0; + int mapHeight = 0; + Point pt = getUpperLeftPoint(pt1, pt2, out mapWidth, out mapHeight); + int rightBottomX = pt.X + mapWidth; + int rightBottomY = pt.Y + mapHeight; + Image myImg = new Bitmap(mapWidth, mapHeight); + Graphics g = Graphics.FromImage(myImg); + g.CopyFromScreen(pt, new Point(0, 0), new Size(rightBottomX, rightBottomY)); + + 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; + } + } + } + + /// + /// 统计管线的里程数 + /// + /// + /// + /// + 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; + } + + /// + /// 窗体下方属性表格 右键菜单中的 “定位”菜单 + /// + /// + /// + 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); + + } + + /// + /// 表格中右键 “单个闪烁” 菜单 + /// + /// + /// + private void LightMenu_Click(object sender, EventArgs e) + { + flashflag = "single"; + timer1.Start(); + } + /// + /// 表格中右键 “全部闪烁” 菜单 + /// + /// + /// + private void AllLightMenuItem_Click(object sender, EventArgs e) + { + flashflag = "all"; + timer1.Start(); + } + + /// + /// 使用timer实现管线的闪烁效果 + /// + /// + /// + 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; + } + } + + /// + /// 绘制线 菜单 + /// + /// + /// + private void btnAddLine_Click(object sender, EventArgs e) + { + globeControl1.Globe.DestLayerFeatureAdd = globeControl1.Globe.MemoryLayer; + globeControl1.Globe.Action = EnumAction3D.DrawPolyline; + } + /// + /// 绘制面 菜单 + /// + /// + /// + private void btnAddPolygon_Click(object sender, EventArgs e) + { + globeControl1.Globe.DestLayerFeatureAdd = globeControl1.Globe.MemoryLayer; + globeControl1.Globe.Action = EnumAction3D.DrawPolygon; + } + /// + /// 图层目录树 右键菜单中的 目标图层 菜单 + /// + /// + /// + 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; + } + } + /// + /// 图层目录树 右键菜单中的 可选择 菜单 + /// + /// + /// + 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; + } + /// + /// 图层目录树 右键菜单中的 可编辑 菜单 + /// + /// + /// + 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; + } + /// + /// 图层目录树 右键菜单中的 保存 菜单 + /// + /// + /// + 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(); + } + + /// + /// 根据多边形范围统计管线的里程 + /// + /// + /// + /// 返回查询到的管线要素集合 + 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 pipeLineDis = new Dictionary(); + Dictionary workWellLen = new Dictionary(); + + + + + /// + /// 查找指定图层中在 指定范围内的feature对象集合 + /// + /// + /// + /// + 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; + } + /// + /// 清除结果 菜单 + /// + /// + /// + private void buttonItem47_Click(object sender, EventArgs e) + { + globeControl1.Globe.ClearAnalysis(); + dataGridViewX1.DataSource = null; + panelOfTable.Visible = false; + clearFeatureHighLight(); + } + /// + /// 设置菜单的选中状态 + /// + private void ActionToolMenuChecked() + { + if (globeControl1.Globe.Action != EnumAction3D.TrackPolyline) + { + buttonItemFX2_1.Checked = false; + buttonItemFX2_4.Checked = false; + buttonItemFX2_3.Checked = false; + buttonItemFX4_3.Checked = false; + } + if (globeControl1.Globe.Action != EnumAction3D.NormalHit) + { + buttonItemFX3_6.Checked = false; + // ClearConnexityAnalysis(); + + buttonItemFX3_5.Checked = false; + // ClearCloseValvesAnalysis(); + } + if (globeControl1.Globe.Action != EnumAction3D.TrackPolygon) + { + buttonItemFX4_2.Checked = false; + buttonItemFX4_1.Checked = false; + } + } + + /// + /// 主窗体关闭事件处理 + /// + /// + /// + private void MainFrm_FormClosing(object sender, FormClosingEventArgs e) + { + + if (MessageBox.Show("是否退出系统?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) + { + e.Cancel = true; + } + else { + globeControl1.Globe.MemoryLayer.SaveAs(Application.StartupPath + "/MyPlace.kml"); + } + + //saveLayerList(layerManagerNode.Nodes); + //注销id号为103的热键设定 + // UnregisterHotKey(Handle, 103); + } + + /// + /// 显示流向 功能 + /// + /// + /// + /// + 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(); + } + + FrmCloseValves frm; + + FrmBoosterValvers frmbooster = null; + + /// + /// 垂直净距分析 功能界面中的 选择图层复选框 选中状态改变事件处理 + /// + /// + /// + 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(); + } + /// + /// 水平净距分析 功能界面中的 选择图层复选框 选中状态改变事件处理 + /// + /// + /// + 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(); + } + /// + /// 垂直净距分析 功能界面中的 选择管线复选框 选中状态改变事件处理 + /// + /// + /// + private void checkBoxX1_CheckedChanged(object sender, EventArgs e) + { + clearFeatureHighLight(); + if (checkBoxX1.Checked) + { + comboBoxEx1.SelectedItem = null; + 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; + } + } + /// + /// 水平净距分析 功能界面中的 选择管线复选框 选中状态改变事件处理 + /// + /// + /// + private void checkBoxX1_CheckedChanged_shuiping(object sender, EventArgs e) + { + clearFeatureHighLight();//清除高亮 + if (checkBoxX7.Checked) + { + comboBoxEx4.SelectedItem = null; + 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(); + /// + /// 垂直净距分析 功能界面中的 选择图层下拉框 选中项改变 事件处理 + /// + /// + /// + 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; + } + } + } + /// + /// 水平净距分析 功能界面中的 选择图层下拉框 选中项改变 事件处理 + /// + /// + /// + 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 featCount = new Dictionary(); + Dictionary featLenth = new Dictionary(); + Dictionary m_FeaturesWithBianhao = new Dictionary();//记录编号和对应的标注点的位置 + GSOFeatures polygonJingJuAnalysises = new GSOFeatures(); + + /// + /// 垂直净距分析 功能界面中的 开始分析按钮 事件处理 + /// + /// + /// + 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; + } + + /// + /// 在指定的两点组成的线的中间添加一个marker对象,并将marker对象添加到指定的图层中 + /// + /// + /// + /// + /// + /// + 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; + } + + /// + /// 计算指定feature对象与除了该feature所在图层之外的 所有管线图层中的所有feature对象 的垂直距离 并在表格中记录符合要求的管线 + /// + /// + /// + /// + /// + private void VerticalDistanceAnalysis(string type, GSOFeature selectedFeature, List _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(); + } + /// + /// 垂直净距分析中 表格行的 双击定位 功能。 与覆土分析的实现方法不同,主要原因是需要标注垂距 + /// + /// + /// + 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); + } + } + } + } + + /// + /// 水平净距分析 功能界面中 开始分析按钮 的事件处理 + /// + /// + /// + 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; + } + + + /// + /// 计算指定feature对象与除了该feature所在图层之外的 所有管线图层中的所有feature对象 的水平距离 并记录符合要求的管线 功能 + /// + /// + /// + /// + /// + private void HorizontalDistanceAnalysis(GSOFeature selectedFeature, List _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)); + } + } + } + } + } + /// + /// 水平净距分析 功能界面中 表格的 双击定位 功能 + /// + /// + /// + 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); + } + } + } + } + } + /// + /// 碰撞分析 功能界面中 开始分析按钮 事件处理 + /// + /// + /// + 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; + } + /// + /// 碰撞分析功能界面中 表格的 双击定位 功能 + /// + /// + /// + 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); + } + } + } + } + + + + /// + /// 覆土分析功能操作界面中的 选择管线 复选框选中状态改变事件处理 + /// + /// + /// + private void checkBoxX5_CheckedChanged(object sender, EventArgs e) + { + clearFeatureHighLight(); + if (checkBoxX5.Checked) + { + comboBoxEx3.SelectedItem = null; + 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; + } + } + /// + /// 覆土分析功能操作界面中的 选择图层 复选框选中状态改变事件处理 + /// + /// + /// + 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(); + } + /// + /// 覆土分析功能操作界面中的 图层下拉框选中项改变事件处理 + /// + /// + /// + 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; + } + } + } + /// + /// 覆土分析功能操作界面中的 开始分析 按钮事件处理 + /// + /// + /// + 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; + + + GSOPoint3d markerPosition = new GSOPoint3d(); + 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]; + GSOPoint3d pt = new GSOPoint3d(); + + 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"); + + pt.X = pts[m].X; + pt.Y = pts[m].Y; + pt.Z = 0; + markerPosition = LabelVerticalDistance(layerTemp, pts[m], pt, Convert.ToDouble(dataGridViewX7.Rows[idx].Cells[2].Value), true); + 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]; + GSOPoint3d pt = new GSOPoint3d(); + 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"); + + pt.X = pts[m].X; + pt.Y = pts[m].Y; + pt.Z = 0; + markerPosition = LabelVerticalDistance(layerTemp, pts[m], pt, Convert.ToDouble(dataGridViewX7.Rows[idx].Cells[2].Value), true); + + 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; + } + + /// + /// 覆土分析中 表格的 双击定位 功能 + /// + /// + /// + 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); + } + } + } + } + } + /// + /// 覆土分析功能操作界面中的 导出Excel按钮 事件处理 + /// + /// + /// + private void buttonX10_Click(object sender, EventArgs e) + { + if (dataGridViewX7.Rows.Count > 0) + { + ExportExcel("覆土分析", dataGridViewX7, null); + } + else + { + MessageBox.Show("表格内容为空!", "提示"); + } + } + /// + /// 覆土分析功能操作界面底部的 关闭 按钮事件处理 + /// + /// + /// + 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(); + layerTemp.RemoveAllFeature(); + + if (buttonItem1.Checked) + { + sideBar1.ExpandedPanel = sideBarPanelItem3; + } + else + { + sideBar1.Visible = false; + } + globeControl1.Refresh(); + + //Refresh(); + } + + + /// + /// 垂直净距分析 功能界面中 清除分析结果按钮 事件处理 + /// + /// + /// + 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(); + } + /// + /// 水平净距分析 功能界面中 清除分析结果按钮 事件处理 + /// + /// + /// + 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(); + } + + /// + /// 垂直净距分析功能界面中 关闭按钮 事件处理 + /// + /// + /// + 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(); + } + /// + /// 水平净距分析功能界面中 删除缓冲区按钮 事件处理 + /// + /// + /// + private void buttonX14_Click(object sender, EventArgs e) + { + 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(); + } + + /// + /// 导出指定DataGridView控件中的内容 + /// + /// + /// + 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(); + } + } + } + } + + /// + /// 垂直净距分析功能界面中 导出Excel按钮 事件处理 + /// + /// + /// + private void buttonX4_Click(object sender, EventArgs e) + { + if (dataGridViewX3.Rows.Count > 0) + { + ExportExcel("垂直净距分析", dataGridViewX3, listBox1); + } + else + { + MessageBox.Show("表格内容为空!", "提示"); + } + } + /// + /// 水平净距分析功能界面中 导出Excel按钮 事件处理 + /// + /// + /// + private void buttonX4_Click_shuiping(object sender, EventArgs e) + { + if (dataGridViewX9.Rows.Count > 0) + { + ExportExcel("水平净距分析", dataGridViewX9, listBox3); + } + else + { + MessageBox.Show("表格内容为空!", "提示"); + } + } + + + /// + /// 清除所有坑 菜单 + /// + /// + /// + private void buttonItem3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItem3.Text); + + globeControl1.Globe.RemoveAllPits(); + } + + //} + /// + /// 大气层 菜单 + /// + /// + /// + private void buttonItem17_Click_1(object sender, EventArgs e) + { + globeControl1.Globe.Atmosphere.Visible = !globeControl1.Globe.Atmosphere.Visible; + buttonItemSH1.Checked = globeControl1.Globe.Atmosphere.Visible; + globeControl1.Refresh(); + } + /// + /// 经纬网 菜单 + /// + /// + /// + private void buttonItem20_Click(object sender, EventArgs e) + { + globeControl1.Globe.LatLonGrid.Visible = !globeControl1.Globe.LatLonGrid.Visible; + buttonItemSH3.Checked = globeControl1.Globe.LatLonGrid.Visible; + globeControl1.Globe.Refresh(); + } + /// + /// 状态条 菜单 + /// + /// + /// + private void buttonItem21_Click_1(object sender, EventArgs e) + { + globeControl1.Globe.StatusBar.Visible = !globeControl1.Globe.StatusBar.Visible; + buttonItemSH4.Checked = globeControl1.Globe.StatusBar.Visible; + globeControl1.Globe.Refresh(); + } + + + + /// + /// 添加指定路径下的数据 功能 + /// + /// + /// + 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); + //CheckDatasetGeoReference(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; + } + return objRes; + } + /// + /// 刷新目录树 功能 + /// + 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); + } + } + /// + /// 判断图层是否包含字段列表 + /// + /// + /// + 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; + } + + /// + /// 统计指定图层在指定范围内的所有feature对象 + /// + /// + /// + /// + 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; + } + /// + /// 碰撞分析功能界面中 选择管线复选框 选中状态改变事件处理 + /// + /// + /// + private void checkBoxX3_CheckedChanged(object sender, EventArgs e) + { + clearFeatureHighLight(); + if (checkBoxX3.Checked) + { + comboBoxEx2.SelectedItem = null; + 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; + } + } + /// + /// 碰撞分析功能界面中 选择图层复选框 选中状态改变事件处理 + /// + /// + /// + 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(); + } + /// + /// 碰撞分析功能界面中 选择图层下拉框 选中项改变事件处理 + /// + /// + /// + 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; + } + } + } + /// + /// 清除所有图层中的所有feature对象的高亮状态 功能 + /// + 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); + } + } + } + } + for (int i = 0; i < globeControl2.Globe.Layers.Count; i++) + { + GSOLayer layer = globeControl2.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; + } + } + } + + if (globeControl1.Globe.Action == EnumAction3D.SelectObject) + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + //globeControl1.Globe.Action = EnumAction3D.SelectObject; + } + } + + /// + /// 碰撞分析功能界面中 清除分析结果按钮 事件处理 + /// + /// + /// + 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(); + } + /// + /// 碰撞分析功能界面中 导出Excel按钮 事件处理 + /// + /// + /// + private void buttonX6_Click(object sender, EventArgs e) + { + if (dataGridViewX5.Rows.Count > 0) + { + ExportExcel("碰撞分析", dataGridViewX5, listBox2); + } + else + { + MessageBox.Show("表格内容为空!", "提示"); + } + } + /// + /// 导出CAD 菜单 + /// + /// + /// + private void btnExportCAD_Click(object sender, EventArgs e) + { + FrmExportCADS frm = new FrmExportCADS(globeControl1, m_PipelineLayerNames); + frm.ShowDialog(); + } + + ///// + ///// 区域分析 菜单 + ///// + ///// + ///// + //private void buttonItem50_Click(object sender, EventArgs e) + //{ + // buttonItem50.Checked = !buttonItem50.Checked; + // ribbonBarQY.Visible = buttonItem50.Checked; + // ribbonBarQY.Location = new Point(0, 0); + //} + + + /// + /// 连接数据库 菜单事件处理 + /// + /// + /// + 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; + } + } + } + /// + /// 数据验证 菜单 + /// + /// + /// + private void buttonItem80_Click(object sender, EventArgs e) + { + FrmValiData frm = new FrmValiData(globeControl1); + frm.ShowDialog(); + } + /// + /// 根据指定图层创建图层节点并将节点添加到图层管理节点的子节点集合中 + /// + /// + 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; + + if (!layerManagerNode.Nodes.Contains(node)) + { + layerManagerNode.Nodes.Insert(0, node); + layerManagerNode.Expand(); + } + } + } + /// + /// 数据库备份 菜单 + /// + /// + /// + 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(); + } + } + } + + + + #region Fan 去掉 + //GSOFeature emitterFeature; // 粒子要素 + /// + /// 添加火苗 功能 + /// + /// + /// + /// + 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); + + } + /// + /// 添加喷泉 功能 + /// + /// + /// + /// + 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); + } + #endregion + + /// + /// 获取指定图层中最后一个feature对象的名称对应的整数 + /// + /// + /// + 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; + } + /// + /// 设置除指定标注图层之外的所有标注图层不可见 + /// + /// + 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; + } + } + } + } + } + + /// + /// 判断选中的对象是否为管线 + /// + /// 被选中管线 + /// 返回一根线 + 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; + } + + /// + /// 获取指定两点组成的线的长度 功能 + /// + /// + /// + /// + 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; + } + + /// + /// 图层节点树中 节点 右键单击事件处理 + /// + /// + /// + 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; + } + } + } + } + } + + /// + /// 标注管理、传感器管理 图层目录树的右键菜单中的 刷新列表 菜单 + /// + /// + /// + 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); + } + } + /// + /// 给指定的图层节点添加代表feature对象的子节点 + /// + /// + private void RefreshTreeNodeLayerFeatureList(TreeNode layerTreeNode) + { + layerTreeNode.Nodes.Clear(); + GSOLayer layer = (GSOLayer)layerTreeNode.Tag; + // 只将类型为内存数据集的图层列出,如果是其它类型的数据集可能数据量太大,没发显示在树控件中 + if (layer.Dataset is GSOFeatureDataset) + { + VisitFeature3Ds(layer.GetAllFeatures(), layerTreeNode); + } + } + + /// + /// 标注管理、传感器管理 图层目录树的右键菜单中的 移除所有 菜单 + /// + /// + /// + 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(); + } + } + + /// + /// 图层目录树的 节点对应的复选框选中状态改变事件处理 + /// + /// + /// + private void layerMarkerTree_AfterCheck(object sender, TreeViewEventArgs e) + { + if (e.Action != TreeViewAction.Unknown) + { + CheckTreeNode(e.Node, e.Node.Checked); + } + } + /// + /// 改变指定节点对应的复选框的选中状态 + /// + /// + /// + private void CheckTreeNode(TreeNode node, Boolean bChecked) + { + CheckChildTreeNode(node, bChecked); + globeControl1.Globe.Refresh(); + } + /// + /// 改变指定节点的子节点对应的复选框的选中状态 + /// + /// + /// + 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); + } + } + /// + /// 标注管理、传感器管理 目录树中的feature节点的右键菜单中的 删除 菜单 + /// + /// + /// + 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(); + } + } + + /// + /// 双屏对比 菜单 + /// + /// + /// + //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(); + // } + //} + /// + /// 模拟分析 菜单 + /// + /// + /// + //private void buttonItem51_Click(object sender, EventArgs e) + //{ + // buttonItem51.Checked = !buttonItem51.Checked; + // ribbonBarMN.Visible = buttonItem51.Checked; + // ribbonBarMN.Location = new Point(0, 0); + //} + + /// + /// 双屏设置 菜单 + /// + /// + /// + //private void buttonItem96_Click(object sender, EventArgs e) + //{ + // FrmLayerControl frm = new FrmLayerControl(layerTree,globeControl1,globeControl2); + // frm.Show(this); + //} + /// + /// 双屏联动 菜单 + /// + /// + /// + //private void buttonItem95_Click(object sender, EventArgs e) + //{ + // buttonItem95.Checked = !buttonItem95.Checked; + //} + ///// + /// 添加用户仓库 菜单 + /// + /// + /// + private void buttonItem108_Click(object sender, EventArgs e) + { + FrmUserRepo frm = new FrmUserRepo(-1); + frm.ShowDialog(); + } + /// + /// 用户仓库管理 菜单 + /// + /// + /// + private void buttonItem111_Click(object sender, EventArgs e) + { + FrmUserRepoMgr frm = new FrmUserRepoMgr(); + frm.ShowDialog(); + } + /// + /// 添加分系统 菜单 + /// + /// + /// + private void buttonItem112_Click(object sender, EventArgs e) + { + //FrmAPP frm = new FrmAPP(-1); + //frm.ShowDialog(); + } + /// + /// 分系统管理 菜单 + /// + /// + /// + private void buttonItem113_Click(object sender, EventArgs e) + { + //FrmAPPMgr frm = new FrmAPPMgr(); + //frm.ShowDialog(); + } + /// + /// 添加操作 菜单 + /// + /// + /// + private void buttonItem114_Click(object sender, EventArgs e) + { + FrmOper frm = new FrmOper(-1); + frm.ShowDialog(); + } + /// + /// 操作管理 菜单 + /// + /// + /// + private void buttonItem115_Click(object sender, EventArgs e) + { + FrmOperMgr frm = new FrmOperMgr(); + frm.ShowDialog(); + } + /// + /// 添加资源 菜单 + /// + /// + /// + private void buttonItem116_Click(object sender, EventArgs e) + { + FrmRESC frm = new FrmRESC(-1); + frm.ShowDialog(); + } + /// + /// 资源管理 菜单 + /// + /// + /// + private void buttonItem117_Click(object sender, EventArgs e) + { + FrmRESCMgr frm = new FrmRESCMgr(); + frm.ShowDialog(); + } + /// + /// 添加权限 菜单 + /// + /// + /// + private void buttonItem118_Click(object sender, EventArgs e) + { + FrmPerm frm = new FrmPerm(-1); + frm.ShowDialog(); + } + /// + /// 权限管理 菜单 + /// + /// + /// + private void buttonItem119_Click(object sender, EventArgs e) + { + FrmPermMgr frm = new FrmPermMgr(); + frm.ShowDialog(); + } + /// + /// 添加访问控制 菜单 + /// + /// + /// + private void buttonItem120_Click(object sender, EventArgs e) + { + FrmAccess frm = new FrmAccess(-1); + frm.ShowDialog(); + } + /// + /// 访问控制管理 菜单 + /// + /// + /// + private void buttonItem121_Click(object sender, EventArgs e) + { + FrmAccessMgr frm = new FrmAccessMgr(); + frm.ShowDialog(); + } + /// + /// 部门类型管理 菜单 + /// + /// + /// + private void buttonItem122_Click(object sender, EventArgs e) + { + FrmRegionTypeMgr frm = new FrmRegionTypeMgr(); + frm.ShowDialog(); + } + /// + /// 添加用户 菜单 + /// + /// + /// + private void buttonItem127_Click(object sender, EventArgs e) + { + FrmUserAdd frm = new FrmUserAdd(-1); + frm.ShowDialog(); + } + /// + /// 用户信息管理 菜单 + /// + /// + /// + private void buttonItem128_Click_1(object sender, EventArgs e) + { + FrmUserManager frm = new FrmUserManager(); + frm.ShowDialog(); + } + /// + /// 添加角色 菜单 + /// + /// + /// + private void 添加角色_Click(object sender, EventArgs e) + { + FrmRole frm = new FrmRole(-1); + frm.ShowDialog(); + } + /// + /// 所有角色管理 菜单 + /// + /// + /// + private void 角色管理_Click(object sender, EventArgs e) + { + FrmRoleMgr frm = new FrmRoleMgr(); + frm.ShowDialog(); + } + + /// + /// 部门角色管理 菜单 + /// + /// + /// + private void buttonItem133_Click(object sender, EventArgs e) + { + FrmRegionRoleMgr frm = new FrmRegionRoleMgr(); + frm.ShowDialog(); + } + /// + /// 部门管理 菜单 + /// + /// + /// + private void buttonItem130_Click(object sender, EventArgs e) + { + FrmRegionMgr frm = new FrmRegionMgr(); + frm.ShowDialog(); + } + + /// + /// 日志管理 菜单 + /// + /// + /// + private void buttonItem135_Click(object sender, EventArgs e) + { + FrmLogManager frm = new FrmLogManager(); + frm.ShowDialog(); + } + /// + /// 传感器信息查询 菜单 + /// + /// + /// + 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); + } + } + } + /// + /// 根据指定的图层的caption属性的值在配置文件中查找对应的数据库中的表的名称 + /// + /// 图层的caption属性的值 + /// 对应的数据库中的表的名称 + 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; + } + /// + /// 根据数据库中的表的名称 查找对应的表中的字段名称的集合 + /// + /// 数据库中的表的名称 + /// 对应的表中的字段名称的集合 + 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; + } + + /// + /// 历史曲线查询 菜单 + /// + /// + /// + 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; + /// + /// 传感器在线报警 菜单 + /// + /// + /// + 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); + } + /// + /// 传感器报警 功能中的 定时器 的触发事件处理 + /// + /// + /// + 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; + } + } + } + } + } + } + } + + + /// + /// 沿线运动 菜单 + /// + /// + /// + private void buttonItem138_Click(object sender, EventArgs e) + { + if (globeControl1.Globe.SelectedObject == null) + { + MessageBox.Show("请先选择一条线!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + return; + } + + GSOFeature lineFeature = globeControl1.Globe.SelectedObject; + if (lineFeature.Geometry == null || lineFeature.Geometry.Type != EnumGeometryType.GeoPolyline3D) + { + MessageBox.Show("请先选择一条线!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + return; + } + + OpenFileDialog dlg = new OpenFileDialog(); + dlg.Filter = "*.gcm;*.3ds|*.gcm;*.3ds|*.3ds|*.3ds|*.gcm|*.gcm"; + if (dlg.ShowDialog() == DialogResult.OK) + { + GSOGeoModel model = new GSOGeoModel(); + model.FilePath = dlg.FileName; + + GSOGeoDynamicRoute dynamicRoute = new GSOGeoDynamicRoute(); + dynamicRoute.ActorGeometry = model; + + GSORoute route = new GSORoute(); + GSOGeoPolyline3D geoline = (GSOGeoPolyline3D)lineFeature.Geometry; + for (int i = 0; i < geoline[0].Count; i++) + { + route.Add(geoline[0][i]); + } + route.CircleRoute = false; + route.Speed = 30; + route.RotateSpeed = 50; + route.AltitudeMode = geoline.AltitudeMode; + dynamicRoute.Route = route; + + GSOFeature feature = new GSOFeature(); + + dynamicRoute.Play(); + feature.Geometry = dynamicRoute; + + //GSOLabel gsoLabel = new GSOLabel(); + //gsoLabel.Text = "模型测试"; + //feature.Label = gsoLabel; + globeControl1.Globe.MinModelVisibleSize = 0; + + globeControl1.Globe.MemoryLayer.AddFeature(feature); + globeControl1.Globe.Refresh(); + } + } + /// + /// 回退 菜单 + /// + /// + /// + private void buttonItem99_Click(object sender, EventArgs e) + { + globeControl1.Globe.UnDoEdit(); + } + /// + /// 前进 菜单 + /// + /// + /// + private void buttonItem100_Click(object sender, EventArgs e) + { + globeControl1.Globe.ReDoEdit(); + } + /// + /// 水平净距 功能界面中的 标签内容改变事件处理 + /// + /// + /// + 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() + "米的管线有:"; + } + } + } + /// + /// 垂直净距 功能界面中的 标签内容改变事件处理 + /// + /// + /// + 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() + "米的管线有:"; + } + } + } + /// + /// 覆土分析 功能界面中的 标签内容改变事件处理 + /// + /// + /// + 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() + "米的管线有:"; + } + } + } + + /// + /// 传感器分类查询 全区域 菜单 + /// + /// + /// + private void buttonItemSensor全区域查询_Click(object sender, EventArgs e) + { + FrmAccessoriesSensor.ShowForm(globeControl1, instrumenLayerNames, 0); + } + /// + /// 传感器分类查询 绘制区域 菜单 + /// + /// + /// + private void buttonItemSensor绘制区域查询_Click(object sender, EventArgs e) + { + FrmAccessoriesSensor.ShowForm(globeControl1, instrumenLayerNames, 1); + } + + + /// + /// 碰撞分析 功能界面中 关闭按钮 事件处理 + /// + /// + /// + 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(); + } + /// + /// 覆土分析 功能界面中的 清除分析结果 按钮事件处理 + /// + /// + /// + 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(); + } + /// + /// 数字预处理 功能 + /// + /// + /// + private void 数字预处理buttonItem140_Click(object sender, EventArgs e) + { + FrmEditShapeFile frm = new FrmEditShapeFile(globeControl1); + frm.ShowDialog(this); + } + + + /// + /// 导出矢量 功能 将图层导出为kml和shp格式数据 + /// + /// + /// + private void 导出矢量buttonItem140_Click(object sender, EventArgs e) + { + List listVectorNames = new List(); + for (int i = 0; i < m_PipelineLayerNames.Count; i++) + { + 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 = ""; + /// + /// 绘制城市七线 功能按钮 + /// + /// + /// + 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; + } + } + } + /// + /// 七线审核 功能按钮 + /// + /// + /// + private void 七线审核buttonItem141_Click(object sender, EventArgs e) + { + FrmCityServerLineAnalysis frm = new FrmCityServerLineAnalysis(globeControl1, m_PipelineLayerNames); + frm.ShowDialog(this); + } + + /// + /// 间距分析 开始分析按钮 分析绘制的七线和管线的距离是否符合标准 + /// + /// + /// + 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; + } + /// + /// 间距分析 清除分析结果 + /// + /// + /// + 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(); + } + /// + /// 间距分析 导出Excel按钮 将间距分析的结果以Excel表格的形式导出 + /// + /// + /// + private void buttonExportExcel_Click(object sender, EventArgs e) + { + if (dataGridViewAnalysisResult.Rows.Count > 0) + { + ExportExcel("间距分析", dataGridViewAnalysisResult, listBoxStasticsResult); + } + else + { + MessageBox.Show("表格内容为空!", "提示"); + } + } + /// + /// 间距分析 关闭按钮 + /// + /// + /// + 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(); + } + /// + /// 间距分析 分析结果表格双击定位 + /// + /// + /// + 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); + } + } + } + } + /// + /// 间距分析 选择管线复选框 + /// + /// + /// + private void checkBoxSelectPipeline_CheckedChanged(object sender, EventArgs e) + { + clearFeatureHighLight();//清除高亮 + if (checkBoxSelectPipeline.Checked) + { + comboBoxLayer.SelectedItem = null; + 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; + } + } + /// + /// 间距分析 选择图层复选框 + /// + /// + /// + 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(); + } + /// + /// 间距分析 选择图层下拉框 + /// + /// + /// + 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; + } + } + } + + + + /// + /// 管线自动缩进 菜单 + /// + /// + /// + private void 管线自动缩进buttonItem140_Click(object sender, EventArgs e) + { + FrmPipelineIndented frm = new FrmPipelineIndented(globeControl1, m_PipelineLayerNames, workwellLayerNames); + 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 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); + // } + //} + + /// + /// 统计指定图层在指定范围内的所有feature对象 + /// + /// + /// + /// + 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) + { + 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 setLayerVisible(string layerName) + { + GSOLayer templayer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + if (templayer != null) + { + templayer.Visible = false; + } + globeControl1.Globe.Refresh(); + } + + /// + /// 连接数据库 + /// + /// + /// + private void buttonItem129_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL4_1.Text); + + FrmDatabaseParaSetting2 frm = new FrmDatabaseParaSetting2(globeControl1); + if (frm.ShowDialog() == DialogResult.OK) + { + ds = FrmDatabaseParaSetting2.ds; + if (ds != null) + { + ds.IsCloseSaved = false; + } + } + } + + /// + /// 一键审核---导入数据 + /// + /// + /// + private void buttonItem127_Click_2(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, "打开数据"); + + try + { + //if (shds == null) + //{ + //没连的话,直接连接审核库; //审核库配置读配置文件 + string dbIp = Utility.sgdbip; + string database = Utility.sgdbname; + string user = Utility.sgdbuser; + string pass = Utility.sgdbpwd; + /* + 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; + //} + } + catch (Exception ex) + { + LogError.PublishError(ex); + MessageBox.Show("内存过载请清理内存,并重新启动规划分析!", "提示"); + return; + } + + } + + /// + ///自动导出图片 + /// + /// + /// + private void buttonItem130_Click_1(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, "导出审核图"); + + 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))); + */ + + int mapWidth = 0; + int mapHeight = 0; + Point pt = getUpperLeftPoint(pt1, pt2, out mapWidth, out mapHeight); + int rightBottomX = pt.X + mapWidth; + int rightBottomY = pt.Y + mapHeight; + Image myImg = new Bitmap(mapWidth, mapHeight); + Graphics g = Graphics.FromImage(myImg); + g.CopyFromScreen(pt, new Point(0, 0), new Size(rightBottomX, rightBottomY)); + + 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; + } + } + } + /// + /// 一键审核功能 + ///
+ /// + /// + private void buttonItem128_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItem128.Text); + //垂直净距标准 + + frmSh = new FrmYJSHTC(globeControl1, globeControl2,layerTree); + + if (frmSh.ShowDialog() == DialogResult.OK) + { + frmWait = new FrmWait("一键审核……"); + frmWait.Location = new Point(this.Width - frmWait.Width - 10, this.Height - frmWait.Height - 50); + frmWait.Owner = this; + frmWait.Show(); + Thread thread = new Thread(new ThreadStart(doWork)); + thread.IsBackground = true; + thread.Start(); + } + } + + void doWork() + { + FrmShResult frmShResult = null; + + double dVerticalJingJuBiaoZhun = 1, dHorizontalJingJuBiaoZhun = 1; + if (frmSh.rukuLayer != null) + { + #region + this.Invoke((EventHandler)delegate + { + try + { + List managerLayerList = new List(); + for (int i = 0; i < layerManagerNode.Nodes.Count; i++) + { + managerLayerList.Add(layerManagerNode.Nodes[i].Text); + } + if (!managerLayerList.Contains(frmSh.rukuLayer.Caption)) + { + TreeNode node = new TreeNode(); + node.Tag = frmSh.rukuLayer; + node.Text = frmSh.rukuLayer.Dataset.Caption; + node.ImageIndex = 0; + node.SelectedImageIndex = 0; + node.Checked = frmSh.rukuLayer.Visible; + layerManagerNode.Nodes.Insert(0, node); + layerManagerNode.Expand(); + } + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "提示"); + } + }); + #endregion + + shlayername = frmSh.rukuLayer.Name; + globeControl1.Refresh(); + } + + if (frmShResult != null && !frmShResult.IsDisposed) + { + try + { + clearFeatureHighLight(); + ClearRedlineAnalyseResult(); + frmShResult.Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message); + } + } + + 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.analysis(); + + //MainFrm窗体显示控制,回到一键审核Tab + this.Invoke((EventHandler)delegate + { + frmShResult.Show(); + frmWait.Close(); + //将tab页恢复到一键审核 + ribbonTabItem11.Checked = true; + try + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + //zhanshi = false; + splitContainer1.Panel2Collapsed = true; + + panelOfTable.Visible = false; + legendSC.Visible = false; + legendSG.Visible = false; + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + } + catch (Exception ex) + { + MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + + }); + + boolfrmShResult = true; + } + else + { + + } + } + + + /// + /// 清除渲染结果 + /// + 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(); + } + /// + /// 已审核的图层 + /// + /// + /// + private void buttonItem132_Click_1(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItem132.Text); + + if (shds == null) + { + //没连的话,直接连接审核库; //审核库配置读配置文件 + string dbIp = Utility.sgdbip; + string database = Utility.sgdbname; + string user = Utility.sgdbuser; + string pass = Utility.sgdbpwd; + + /* + 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; + //} + + } + /// + /// 审核入库 + /// + /// + /// + private void buttonItem133_Click_1(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, "审核入库"); + FrmShRK frmShrk = new FrmShRK(globeControl1); + frmShrk.Show(); + } + /// + /// 模拟设计修改 + /// + /// + /// + private void buttonItem134_Click_1(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, "模拟设计修改"); + + 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 + { + + } + + } + + + /// + /// 绘制垂线 + /// + /// + /// + 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); + } + /// + /// 比较两个点是否是同一个点 + /// + /// + /// + /// + 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; + } + /// + /// 获得点到线的垂线距离及垂点 + /// + /// + /// + /// + /// + 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); + 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]; + } + /// + /// 获得斜率 + /// + /// + /// + /// + /// + /// + /// + 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); + } + } + /// + /// 根据默认投影参数,经纬度转xyz + /// + /// + /// + /// + 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; + } + /// + /// 根据投影参数,经纬度转xyz + /// + /// + /// + /// + /// + 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; + } + /// + /// 根据默认投影参数,xyz转经纬度 + /// + /// + /// + /// + 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; + } + /// + /// 根据投影参数,Xyz转经纬度 + /// + /// + /// + /// + /// + 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; + } + /// + /// 获得inpolygon的管线长度 + /// + /// + 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; + } + + + /// + /// 一键审核中调节透明度 + /// + /// + /// + private void sliderItem1_ValueChanged(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.sliderItem1.Text); + + globeControl1.Globe.GroundOpaque = 100 - sliderItem1.Value; + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(roadLayerName);//("180fd"); + if (layer != null) + { + layer.Opaque = 100 - sliderItem1.Value; + } + + optiValue = sliderItem1.Value; + } + /// + /// 红线审核中的透明度分析 + /// + /// + /// + private void sliderItem3_ValueChanged(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.sliderItem3.Text); + + globeControl1.Globe.GroundOpaque = 100 - sliderItem3.Value; + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(roadLayerName);//("180fd"); + if (layer != null) + { + layer.Opaque = 100 - sliderItem3.Value; + } + optiValue = sliderItem3.Value; + } + + #region yanxiaowei + //初始化DataGridViewX1控件 + public delegate void DataGridViewDelegate(DataTable dt, string strLable, string strLayer, bool initDataGrid); + /// + /// 代理函数,操作DatgridViewX1 + /// + /// + /// + public void InitDataGridViewX1(DataTable dt, string strLable, string strLayer, bool initDataGrid) + { + if (initDataGrid == true) + { + dataGridViewX1.DataSource = dt; + panelOfTable.Visible = true; + toolStripNumbers.Text = strLable; + dataGridViewX1.Tag = strLayer; + } + else + { + dataGridViewX1.DataSource = null; + dataGridViewX1.Refresh(); + panelOfTable.Visible = false; + toolStripNumbers.Text = ""; + dataGridViewX1.Tag = ""; + globeControl1.Globe.MemoryLayer.RemoveAllFeature();//清除双击产生的标注 + } + } + FrmAnalysisGuiHuaResult from; + /// + /// 主窗体下方属性表格 双击定位 功能 + /// + /// + /// + private void dataGridViewX1_MouseDoubleClick(object sender, MouseEventArgs e) + { + if (redSH == false) + { + 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 if (dataGridViewX1.Columns.Contains("标识器编号")) + { + featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["标识器编号"].Value.ToString(); + } + featureName = featureName.Trim(); + + GSOLayer layer = null; + layer = globeControl1.Globe.Layers.GetLayerByCaption(dataGridViewX1.Tag.ToString()); + + if (layer == null) return; + + GSOFeatures features = layer.GetFeatureByName(featureName, false); + if (features.Length == 0) return; + GSOFeature rowFeature = features[0]; + + ClassSearchAnalysis.AddMakerToLineFeature(globeControl1, rowFeature); + + } + } + } + else + { + if (e.Button == MouseButtons.Left) + { + if (from != null && !from.IsDisposed) + { + try + { + from.Close(); + } + catch (Exception ex) + { + LogError.PublishError(ex); + } + } + try + { + DataGridView.HitTestInfo hittestinfo = dataGridViewX1.HitTest(e.X, e.Y); + if (hittestinfo.RowIndex >= 0) + { + string layer = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["管线类型"].Value.ToString(); + string hxName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["红线编号"].Value.ToString(); + FrmAnalysisGuiHuaResult frm = new FrmAnalysisGuiHuaResult(globeControl1, lineStruct, featsList, + panelOfTable, dataGridViewX1, layer, hxName); + frm.Location = new Point(this.Width - frm.Width - 10, this.Height - frm.Height - 20); + frm.Show(this); + + from = frm; + } + } + catch (Exception ex) + { + LogError.PublishError(ex); + } + } + } + } + + /// + /// 空间查询 + /// + /// + /// + private void buttonItemSearch1_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemSearch1.Text); + + trackflag = "PipelineSpatialQuery"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; + + } + /// + /// 关键字查询 + /// + /// + /// + private void buttonItemSearch9_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch9.Text); + + FrmKeywordQuery.ShowForm(globeControl1, m_PipelineLayerNames, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 编号查询 + /// + /// + /// + private void buttonItemSearch2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch2.Text); + + FrmCodingQuery.ShowForm(globeControl1, m_PipelineLayerNames, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 坐标查询 + /// + /// + /// + private void buttonItemSearch3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch3.Text); + + FrmSetLatLonPos.ShowForm(globeControl1); + } + /// + /// 附属物查询 + /// + /// + /// + private void buttonItemSearch10_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch10.Text); + + FrmFittingQuery.ShowForm(globeControl1, instrumenLayerNames, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 管径查询 + /// + /// + /// + private void buttonItemSearch4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch4.Text); + + FrmDiameterQuery.ShowForm(globeControl1, m_PipelineLayerNames, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 材质查询 + /// + /// + /// + private void buttonItemSearch5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch5.Text); + + FrmMaterialSel.ShowForm(globeControl1, m_PipelineLayerNames, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 基本查询 + /// + /// + /// + private void buttonItemSearch6_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch6.Text); + + FrmBasicQuery.ShowForm(globeControl1, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 复合查询 + /// + /// + /// + private void buttonItemSearch7_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch7.Text); + + FrmQuerySQL.ShowForm(globeControl1, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 关联查询 + /// + /// + /// + private void buttonItemSearch8_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch8.Text); + + if (globeControl1.Globe.SelObjectCount != 1) + { + MessageBox.Show("请选中一个对象!", "提示"); + return; + } + + 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 || (feature.Geometry.Type == EnumGeometryType.GeoPolygon3D + || feature.Geometry.Type == EnumGeometryType.GeoWater)) + return; + else + { + ClassSearchAnalysis.ResultRelationAnalysis(globeControl1, feature, valueLayerNames, workwellLayerNames, + instrumenLayerNames, pipefittingLayerNames, m_PipelineLayerNames, valueAllowance); + } + } + } + #endregion + /// + /// 清除分析 + /// + /// + /// + private void buttonItemClear_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemClear.Text); + + globeControl1.Globe.ClearMeasure(); + layerTemp.RemoveAllFeature(); + layerTemp2.RemoveAllFeature(); + buttonItemLS5.Checked = false; + + dataGridViewX1.DataSource = null; + panelOfTable.Visible = false; + + 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); + + NetworkAnalysisTool.ClearAllTopAnalysis(this.globeControl1); + // 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();//清除所有坑 + + 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(); + } + } + + clearFeatureHighLight();//取消管线高亮 + + GSOLayer layerGround = globeControl1.Globe.Layers.GetLayerByCaption(roadLayerName);//("180fd"); + if (layerGround != null) + { + layerGround.Visible = true; + } + globeControl1.Refresh(); + globeControl2.Refresh(); + ClearRedlineAnalyseResult(); + globeControl1.Globe.Action = EnumAction3D.ActionNull; + } + /// + /// 管线长度全区域统计 + /// + /// + /// + private void buttonItemTJ1_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管线长度统计"); + + FrmAllPipelineStatis frm = new FrmAllPipelineStatis(globeControl1,null, new DataGridViewDelegate(InitDataGridViewX1), m_PipelineLayerNames); + frm.Show(this); + } + /// + /// 管线长度绘制区域统计 + /// + /// + /// + private void buttonItemTJ1_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管线长度统计"); + + trackflag = "PipelineDistanceStatistics"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; + } + /// + /// 阀门数量全区域统计 + /// + /// + /// + private void buttonItemTJ2_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "阀门数量统计"); + + FrmValveStatistics frm = new FrmValveStatistics(globeControl1, null, new DataGridViewDelegate(InitDataGridViewX1)); + frm.Show(this); + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + } + /// + /// 阀门数量绘制区域统计 + /// + /// + /// + private void buttonItemTJ2_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "阀门数量统计"); + + trackflag = "valvequery"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; + } + /// + /// 井盖数量全区域统计 + /// + /// + /// + private void buttonItemTJ3_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "井盖数量统计"); + FrmAllWorkWellStatis frm = new FrmAllWorkWellStatis(globeControl1, null, new DataGridViewDelegate(InitDataGridViewX1)); + frm.Show(this); + } + /// + /// 井盖数量绘制区域统计 + /// + /// + /// + private void buttonItemTJ3_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "井盖数量统计"); + + trackflag = "workwellquery"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; + } + /// + /// 管径分段统计全区域统计 + /// + /// + /// + private void buttonItemTJ4_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管径分段统计"); + + Frmpipediameterstatis.ShowForm(globeControl1, m_PipelineLayerNames, 0); + } + /// + /// 管径分段统计绘制区域统计 + /// + /// + /// + private void buttonItemTJ4_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管径分段统计"); + + trackflag = null; + Frmpipediameterstatis.ShowForm(globeControl1, m_PipelineLayerNames, 1); + } + /// + /// 埋深分段统计全区域统计 + /// + /// + /// + private void buttonItemTJ5_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "埋深分段统计"); + FrmpipeDeepstatis.ShowForm(globeControl1, m_PipelineLayerNames, 0); + } + /// + /// 埋深分段统计绘制区域统计 + /// + /// + /// + private void buttonItemTJ5_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "埋深分段统计"); + trackflag = null; + FrmpipeDeepstatis.ShowForm(globeControl1, m_PipelineLayerNames, 1); + } + /// + /// 管径分类统计全区域统计 + /// + /// + /// + private void buttonItemTJ6_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管径分类汇总"); + + FrmpipeDiametergather.ShowForm(globeControl1, m_PipelineLayerNames, 0); + } + /// + /// 管径分类统计绘制区域统计 + /// + /// + /// + private void buttonItemTJ6_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管径分类汇总"); + + trackflag = null; + FrmpipeDiametergather.ShowForm(globeControl1, m_PipelineLayerNames, 1); + } + /// + /// 材质分类统计全区域统计 + /// + /// + /// + private void buttonItemTJ7_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "材质分类汇总"); + + FrmpipeMaterialGather.ShowForm(globeControl1, m_PipelineLayerNames, 0); + } + /// + /// 材质分类统计绘制区域统计 + /// + /// + /// + private void buttonItemTJ7_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "材质分类汇总"); + + trackflag = null; + FrmpipeMaterialGather.ShowForm(globeControl1, m_PipelineLayerNames, 1); + } + /// + /// 附属物分类统计全区域统计 + /// + /// + /// + private void buttonItemTJ8_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "附属物分类汇总"); + + FrmAccessoriesgather.ShowForm(globeControl1, instrumenLayerNames, 0); + } + /// + /// 附属物分类统计绘制区域统计 + /// + /// + /// + private void buttonItemTJ8_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "附属物分类汇总"); + + trackflag = null; + FrmAccessoriesgather.ShowForm(globeControl1, instrumenLayerNames, 1); + } + /// + /// 碰撞分析 + /// + /// + /// + private void buttonItemFX1_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_4.Text); + + this.dataGridViewX4.Size = new System.Drawing.Size(195, 120); + 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(); + } + /// + /// 覆土分析 + /// + /// + /// + private void buttonItemFX1_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX5_1.Text); + this.dataGridViewX6.Size = new System.Drawing.Size(195, 120); + 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(); + } + /// + /// 间距分析 + /// + /// + /// + private void buttonItemFX1_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX1_3.Text); + + this.dataGridViewLineList.Size = new System.Drawing.Size(185, 120); + 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(); + } + /// + /// 垂直净距分析 + /// + /// + /// + private void buttonItemFX1_4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX1_4.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(); + } + /// + /// 水平净距分析 + /// + /// + /// + private void buttonItemFX1_5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_6.Text); + this.dataGridViewX8.Size = new System.Drawing.Size(185, 120); + 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(); + } + + #region Predaotr,断面分析 + /// + /// 横断面分析 + /// + /// + /// + private void buttonItemFX2_1_Click(object sender, EventArgs e) + { + globeControl1.Globe.Action = EnumAction3D.TrackPolyline; + globeControl1.Globe.TrackPolylineTool.VerticalLineVisible = true; + globeControl1.Globe.TrackPolylineTool.TrackMode = EnumTrackMode.SpaceTrack; + trackPolylineEndMode = EnumTrackPolylineEndMode.HDM_Analysis; + + } + /// + /// 纵断面分析 + /// + /// + /// + private void buttonItemFX2_2_Click(object sender, EventArgs e) + { + if (globeControl1.Globe.SelObjectCount<1) + { + MessageBox.Show("请选择一条或者多条管线!", "提示", MessageBoxButtons.OK, + MessageBoxIcon.Information); + return; + } + 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); + } + } + List feats = SectionAnalysisTool.ZDMAnalysis(selectFeatures); + if (feats != null && feats.Count >= 1) + { + FrmProfileAnalysis frm = new FrmProfileAnalysis(globeControl1, feats); + frm.Show(this); + } + } + /// + /// 道路断面分析 + /// + /// + /// + private void buttonItemFX2_3_Click(object sender, EventArgs e) + { + globeControl1.Globe.Action = EnumAction3D.TrackPolyline; + globeControl1.Globe.TrackPolylineTool.VerticalLineVisible = true; + globeControl1.Globe.TrackPolylineTool.TrackMode = EnumTrackMode.SpaceTrack; + trackPolylineEndMode = EnumTrackPolylineEndMode.DLDM_Analysis; + + } + /// + /// 基线剖面分析 + /// + /// + /// + private void buttonItemFX2_4_Click(object sender, EventArgs e) + { + globeControl1.Globe.Action = EnumAction3D.TrackPolyline; + globeControl1.Globe.TrackPolylineTool.VerticalLineVisible = true; + globeControl1.Globe.TrackPolylineTool.TrackMode = EnumTrackMode.SpaceTrack; + trackPolylineEndMode = EnumTrackPolylineEndMode.JXPM_Analysis; + + } + + #endregion + /// + /// 创建拓扑 + /// + /// + /// + private void buttonItemFX3_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX3_1.Text); + + FrmGenAndFaMenTopu frm = new FrmGenAndFaMenTopu(globeControl1, m_PipelineLayerNames, valueLayerNames); + frm.Show(this); + } + #region Predator :拓扑分析 + /// + /// 上游分析 + /// + /// + /// + private void buttonItemFX3_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX3_2.Text); + NetworkTraceUpDown(true); + } + /// + /// 下游分析 + /// + /// + /// + private void buttonItemFX3_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX3_3.Text); + NetworkTraceUpDown(false); + } + + /// + /// 上下游追踪 功能 + /// + /// + private void NetworkTraceUpDown(Boolean bTraceUp) + { + GSOFeature selLineFeature = globeControl1.Globe.SelectedObject; + if (selLineFeature == null || selLineFeature.Geometry == null || selLineFeature.Geometry.Type != EnumGeometryType.GeoPolyline3D) + { + MessageBox.Show("请点击“编辑”—“选中对象”选择一条线!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); + return; + } + GSOLayer selLayer = globeControl1.Globe.SelectedObjectLayer; + + NetworkAnalysisTool.TraceUpDownAnalysis(bTraceUp, + selLineFeature, selLayer); + } + + /// + /// 流向分析 + /// + /// + /// + private void buttonItemFX3_4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX3_4.Text); + + FrmFlow frm = new FrmFlow(globeControl1, m_PipelineLayerNames); + frm.Show(this); + } + /// + /// 关阀分析 + /// + /// + /// + private void buttonItemFX3_5_Click(object sender, EventArgs e) + { + if (globeControl1.Globe.SelObjectCount < 1) + { + MessageBox.Show("请选中至少一根管线!!"); + buttonItemFX3_5.Checked = false; + return; + } + GSOLayer resLayer = null; + GSOFeature resFeature = null; + globeControl1.Globe.GetSelectObject(0, out resFeature, out resLayer); + + String pipeLayerName = resLayer.Caption; + String pipeLayerNamePrefix = pipeLayerName.Substring(0, pipeLayerName.IndexOf("管线")); + GSOLayer valveLayer = globeControl1.Globe.Layers[pipeLayerNamePrefix + "阀门"]; + if (valveLayer == null) + { + MessageBox.Show("无" + pipeLayerNamePrefix+"阀门图层", "提示"); + return; + } + + GSOFeatures valveFeats = NetworkAnalysisTool.CloseValvesAnalysis(resFeature, + resLayer, valveLayer); + + if (valveFeats != null) + { + FrmCloseValves frm = new FrmCloseValves(this.globeControl1, valveFeats); + frm.Show(this); + } + else + { + MessageBox.Show("未找到关闭阀门"); + } + } + + /// + /// 连通分析 + /// + /// + /// + private void buttonItemFX3_6_Click(object sender, EventArgs e) + { + if (globeControl1.Globe.SelObjectCount < 2) + { + MessageBox.Show("请选中至少两个管线!!"); + buttonItemFX3_6.Checked = false; + return; + } + GSOFeature selFeat0, selFeat1; + GSOLayer layer0,layer1; + globeControl1.Globe.GetSelectObject(0, out selFeat0, out layer0); + globeControl1.Globe.GetSelectObject(1, out selFeat1, out layer1); + + if (!layer0.IsSameInnerObject(layer1)) + { + MessageBox.Show("不在同一个图层!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); + buttonItemFX3_6.Checked = false; + return; + } + NetworkAnalysisTool.ConnexityAnalysis(selFeat0, selFeat1, layer0); + } + /// + /// 爆管分析 + /// + /// + /// + private void buttonItemFX3_7_Click(object sender, EventArgs e) + { + NetworkTraceUpDown(true); //上游追踪: + + GSOFeature selLineFeature = globeControl1.Globe.SelectedObject; + if (selLineFeature == null || selLineFeature.Geometry == null || selLineFeature.Geometry.Type != EnumGeometryType.GeoPolyline3D) + { + MessageBox.Show("请点击“编辑”—“选中对象”选择一条线!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); + return; + } + GSOLayer selLayer = globeControl1.Globe.SelectedObjectLayer; + + NetworkAnalysisTool.ExplodeAnalysis(this.globeControl1,selLineFeature,selLayer); + + this.buttonItemFX3_5_Click(sender, e); //关阀分析: + + } + + #endregion + /// + /// 多边形开挖 + /// + /// + /// + private void buttonItemFX4_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_1.Text); + + trackflag = "pit"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; //是这个么?是的,在模型上 + } + /// + /// 挖方量分析 + /// + /// + /// + private void buttonItemFX4_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_2.Text); + + trackflag = "digFillAnalysis"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; + ActionToolMenuChecked(); + } + /// + /// 沿线开挖 + /// + /// + /// + private void buttonItemFX4_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_3.Text); + + if (!buttonItemFX4_3.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; + buttonItemFX4_3.Checked = true; + } + } + else + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + buttonItemFX4_3.Checked = false; + globeControl1.Globe.TrackPolylineTool.VerticalLineVisible = false; + } + ActionToolMenuChecked(); + } + /// + /// 创建隧道 + /// + /// + /// + private void buttonItemFX4_4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_4.Text); + + 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("场景中未加载隧道图层!", "提示"); + } + } + /// + /// 隐藏隧道 + /// + /// + /// + private void buttonItemFX4_5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_5.Text); + + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption("隧道"); + if (layer != null) + { + layer.Visible = !layer.Visible; + } + } + /// + /// 删除隧道 + /// + /// + /// + private void buttonItemFX4_6_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_6.Text); + + 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("请选中要删除的隧道!", "提示"); + } + } + /// + /// 通视分析 + /// + /// + /// + private void buttonItemFX5_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX5_1.Text); + + if (globeControl1.Globe.Action != EnumAction3D.VisibilityAnalysis) + { + //btnSpaceVisibilityAnalysis.Checked = true; + globeControl1.Globe.Action = EnumAction3D.VisibilityAnalysis; + } + else + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + // SetButtonChecked(); + } + } + /// + /// 可视域分析 + /// + /// + /// + private void buttonItemFX5_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX5_2.Text); + + globeControl1.Globe.Action = EnumAction3D.ViewshedAnalysis; + } + /// + /// 可视包络分析 + /// + /// + /// + private void buttonItemFX5_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX5_3.Text); + + globeControl1.Globe.Action = EnumAction3D.ViewEnvelopeAnalysis; + } + /// + /// 缓冲区分析 + /// + /// + /// + private void buttonItemFX6_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX6_1.Text); + + GSOFeature feat = globeControl1.Globe.SelectedObject; + if (feat == null) + { + MessageBox.Show("请选择要分析的要素!"); + return; + } + if (feat.Geometry.Type == EnumGeometryType.GeoPolyline3D) + { + GSOGeoPolyline3D line1 = feat.Geometry as GSOGeoPolyline3D; + if (line1 == null) + { + MessageBox.Show("请选择一条管线!"); + return; + } + + FrmBufferAnalysis frm = new FrmBufferAnalysis(globeControl1, line1, layerTemp); + frm.Show(this); + } + else + { + FrmBufferAnalysisBSQ frm = new FrmBufferAnalysisBSQ(globeControl1, layerTemp, bsqPT); + frm.Show(this); + } + + } + /// + /// 附属物分析 + /// + /// + /// + private void buttonItemFX6_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX6_2.Text); + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + FrmAccessoryAnalysis dlg = new FrmAccessoryAnalysis(globeControl1, layerTemp); + dlg.Show(this); + } + /// + /// 无源淹没分析 + /// + /// + /// + private void buttonItemFX6_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX6_3.Text); + + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + trackflag = "FloodAnalysis"; + } + /// + /// 水平距离 + /// + /// + /// + private void buttonItemLS1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS1.Text); + + globeControl1.Globe.Action = EnumAction3D.MeasureDistance; + globeControl1.Globe.DistanceRuler.SpaceMeasure = false; + buttonItemLS5.Checked = false; + } + /// + /// 垂直距离 + /// + /// + /// + private void buttonItemLS2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS2.Text); + + buttonItemLS5.Checked = false; + globeControl1.Globe.Action = EnumAction3D.MeasureHeight; + globeControl1.Globe.DistanceRuler.SpaceMeasure = false; + } + /// + /// 空间距离 + /// + /// + /// + private void buttonItemLS3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS3.Text); + + buttonItemLS5.Checked = false; + globeControl1.Globe.Action = EnumAction3D.MeasureDistance; + globeControl1.Globe.DistanceRuler.SpaceMeasure = true; + } + /// + /// 地表距离 + /// + /// + /// + private void buttonItemLS4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS4.Text); + + buttonItemLS5.Checked = false; + globeControl1.Globe.Action = EnumAction3D.MeasureDistance; + globeControl1.Globe.DistanceRuler.SpaceMeasure = false; + } + /// + /// 高度量算 + /// + /// + /// + private void buttonItemLS5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS5.Text); + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + buttonItemLS5.Checked = !buttonItemLS5.Checked; + if (buttonItemLS5.Checked) + { + globeControl1.Globe.Action = EnumAction3D.SelectObject; + } + } + /// + /// 水平面积 + /// + /// + /// + private void buttonItemLS6_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS6.Text); + + buttonItemLS5.Checked = false; + globeControl1.Globe.Action = EnumAction3D.MeasureArea; + globeControl1.Globe.AreaRuler.SpaceMeasure = true; + } + /// + /// 地表面积 + /// + /// + /// + private void buttonItemLS7_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS7.Text); + + buttonItemLS5.Checked = false; + globeControl1.Globe.Action = EnumAction3D.MeasureArea; + globeControl1.Globe.AreaRuler.SpaceMeasure = false; + + } + + # region Fan 重构标注代码 + /// + /// 标高标注 + /// + /// + /// + private void buttonItemSZ1_Click(object sender, EventArgs e) + { + GSOFeature resFeature = IsPipeLineOfSelectedObj(); + if (resFeature == null) + { + MessageBox.Show("请选中一根管线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + GSOGeoPolyline3D selLine = resFeature.Geometry as GSOGeoPolyline3D; + if (selLine[0].Count <= 1) + { + return; + } + + MarkTools.getInstance().showMarker(resFeature, + globeControl1, EnumMarkLayer.Mark_Altitude, ""); + } + /// + /// 管径标注 + /// + GSOFeature radiusMarkerFeature; + private void buttonItemBZ2_Click(object sender, EventArgs e) + { + GSOFeature resFeature = IsPipeLineOfSelectedObj(); + if (resFeature == null) + { + MessageBox.Show("请选中一根管线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + GSOGeoPolyline3D selLine = resFeature.Geometry as GSOGeoPolyline3D; + if (selLine[0].Count <= 1) + { + return; + } + + MarkTools.getInstance().showMarker(resFeature, + globeControl1, EnumMarkLayer.Mark_Diameter, ""); + } + /// + /// 埋深标注 + /// + /// + /// + private void buttonItemBZ3_Click(object sender, EventArgs e) + { + GSOFeature resFeature = IsPipeLineOfSelectedObj(); + if (resFeature == null) + { + MessageBox.Show("请选中一根管线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + GSOGeoPolyline3D selLine = resFeature.Geometry as GSOGeoPolyline3D; + if (selLine[0].Count <=1) + { + return; + } + + MarkTools.getInstance().showMarker(resFeature, + globeControl1, EnumMarkLayer.Mark_Depth, ""); + + } + /// + /// 坐标标注 + /// + /// + /// + private void buttonItemBZ4_Click(object sender, EventArgs e) + { + GSOFeature resFeature = IsPipeLineOfSelectedObj(); + if (resFeature == null) + { + MessageBox.Show("请选中一根管线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + GSOGeoPolyline3D selLine = resFeature.Geometry as GSOGeoPolyline3D; + if (selLine[0].Count <= 1) + { + return; + } + MarkTools.getInstance().showMarker(resFeature, + globeControl1, EnumMarkLayer.Mark_Location, ""); + } + /// + /// 距离标注 + /// + bool distanceMarker = false; + private void buttonItemBZ5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBZ5.Text); + + globeControl1.Globe.Action = EnumAction3D.TrackPolyline; + //globeControl1.Globe.DistanceRuler.MeasureMode = EnumDistanceMeasureMode.HVSLineMeasure; + distanceMarker = true; + } + /// + /// 自定义标注 + /// + /// + /// + private void buttonItemBZ6_Click(object sender, EventArgs e) + { + GSOFeature f = globeControl1.Globe.SelectedObject; + GSOLayer l = globeControl1.Globe.SelectedObjectLayer; + FrmCustomLabel frm = new FrmCustomLabel(globeControl1, l, f); + if (frm.ShowDialog() == DialogResult.OK) + { + MarkTools.getInstance().showMarker(f, globeControl1, EnumMarkLayer.Mark_Custom, frm.labelText); + } + } + /// + /// 扯旗标注 + /// + /// + /// + private void buttonItemBZ7_Click(object sender, EventArgs e) + { + GSOFeature f = globeControl1.Globe.SelectedObject; + GSOLayer l = globeControl1.Globe.SelectedObjectLayer; + FrmMarker frm = new FrmMarker(); + if (frm.ShowDialog() == DialogResult.OK) + { + MarkTools.getInstance().showMarker(f, globeControl1, EnumMarkLayer.Mark_Custom, frm.markerContent); + } + } + /// + /// 坡度标注 + /// + /// + /// + private void buttonItemBZ8_Click(object sender, EventArgs e) + { + GSOFeature resFeature = IsPipeLineOfSelectedObj(); + if (resFeature == null) + { + MessageBox.Show("请选中一根管线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + GSOGeoPolyline3D selLine = resFeature.Geometry as GSOGeoPolyline3D; + if (selLine[0].Count <= 1) + { + return; + } + + MarkTools.getInstance().showMarker(resFeature, + globeControl1, EnumMarkLayer.Mark_Slope, ""); + } + /// + /// 属性标注 + /// + /// + /// + private void buttonItemBZ9_Click(object sender, EventArgs e) + { + GSOFeature f = globeControl1.Globe.SelectedObject; + GSOLayer l = globeControl1.Globe.SelectedObjectLayer; + FrmPropertiesMarker frm = new FrmPropertiesMarker(globeControl1, l, f); + if (frm.ShowDialog() == DialogResult.OK) + { + MarkTools.getInstance().showMarker(f, globeControl1, EnumMarkLayer.Mark_Property, frm.labelText); + } + } + /// + /// 红线工具 + /// + /// + /// + private void buttonItemBZ10_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBZ10.Text); + 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; + } + } + /// + /// 标注管理 + /// + /// + /// + private void buttonItemBZ11_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBZ11.Text); + + buttonItemBZ11.Checked = !buttonItemBZ11.Checked; + 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 (buttonItemBZ11.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(); + } + } + + #endregion + /// + /// 飞行到目标点 + /// + /// + /// + private void buttonItemFXGJ1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFXGJ1.Text); + + FrmSetFlytoPos.ShowForm(globeControl1); + + } + /// + /// 自定义飞行 + /// + /// + /// + private void buttonItemFXGJ2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFXGJ2.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); + } + } + /// + /// 绕中心点飞行 + /// + /// + /// + private void buttonItemFXGJ3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFXGJ3.Text); + + globeControl1.Globe.FlyAroundCenter(10000, EnumFlyRepeatValueType.MiliSeconds); + globeControl1.Globe.CurFlyID = 1; + } + /// + /// 绕眼睛飞行 + /// + /// + /// + private void buttonItemFXGJ4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFXGJ4.Text); + + globeControl1.Globe.FlyAroundEye(720, EnumFlyRepeatValueType.Degrees); + globeControl1.Globe.CurFlyID = 2; + } + + /// + /// 权限管理 + /// + /// + /// + private void buttonItemXT1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT1.Text); + + FrmUserRoleMgr frm = new FrmUserRoleMgr(); + frm.ShowDialog(); + } + /// + /// 数据库管理 + /// + /// + /// + private void buttonItemXT2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT2.Text); + + //查看数据库列表 + FrmDbManager frm = new FrmDbManager(); + frm.ShowDialog(); + } + /// + /// 用户列表 + /// + /// + /// + private void buttonItemXT3_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT3_1.Text); + + FrmUserManager frm = new FrmUserManager(); + frm.ShowDialog(); + } + /// + /// 创建新用户 + /// + /// + /// + private void buttonItemXT3_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT3_2.Text); + + FrmUserAdd frm = new FrmUserAdd(-1); + frm.ShowDialog(); + } + /// + /// 人员修改 + /// + /// + /// + private void buttonItemXT4_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT4_2.Text); + + FrmAppUSER appUSER = new FrmAppUSER(); + appUSER.ShowDialog(); + } + /// + /// 增加人员 + /// + /// + /// + private void buttonItemXT4_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT4_1.Text); + + FrmAppUSERRESET appUSERRESET = new FrmAppUSERRESET(); + appUSERRESET.ShowDialog(); + } + /// + /// 统计数据 + /// + /// + /// + private void buttonItemZTT1_Click(object sender, EventArgs e) + { + ////日志记录 + //LogManager.saveLog(Utility.userName, this.buttonItemZTT1.Text); + + //PATM patm = new PATM(); + //patm.operation = "Statistic"; + //patm.Text = "统计专题图管理"; + //patm.ShowDialog(); + } + /// + /// 热点功能统计 + /// + /// + /// + private void buttonItemZTT2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT2.Text); + + FrmHotFuncStat frmhfs = new FrmHotFuncStat(); + frmhfs.ShowDialog(); + } + + private void buttonItemZTT3_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT3_1.Text); + + FrmAPP appfrm = new FrmAPP("专题图申请"); + appfrm.ShowDialog(); + } + + private void buttonItemZTT3_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT3_2.Text); + + FrmAPPFORASK appForask = new FrmAPPFORASK("专题图审核"); + appForask.ShowDialog(); + } + + private void buttonItemZTT3_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT3_3.Text); + + FrmAPPregion appregion = new FrmAPPregion("专题图审核"); + appregion.ShowDialog(); + } + + private void buttonItemZTT4_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT4_1.Text); + + FrmAPP appfrm = new FrmAPP("打印申请"); + appfrm.ShowDialog(); + } + + private void buttonItemZTT4_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT4_2.Text); + + FrmAPPFORASK appForask = new FrmAPPFORASK("打印审核"); + appForask.ShowDialog(); + } + + private void buttonItemZTT4_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT4_3.Text); + + FrmAPPregion appregion = new FrmAPPregion("打印审核"); + appregion.ShowDialog(); + } + + private void buttonItemZTT5_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT5_1.Text); + + FrmAPP appfrm = new FrmAPP("拷贝申请"); + appfrm.ShowDialog(); + } + + private void buttonItemZTT5_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT5_2.Text); + + FrmAPPFORASK appForask = new FrmAPPFORASK("拷贝审核"); + appForask.ShowDialog(); + } + + private void buttonItemZTT5_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT5_3.Text); + + FrmAPPregion appregion = new FrmAPPregion("拷贝审核"); + appregion.Show(); + } + + private int connectServerCount = 0; + + /// + /// 还原球到实测库 + /// + 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); + } + + if (layerManagerNode.Nodes.Count > 0) + { + for (int i = layerManagerNode.Nodes.Count - 1; i >= 0; i--) + { + layerManagerNode.Nodes[i].Remove(); + + } + } + + globeControl1.Refresh(); + + } + + private void buttonItemSPSZ_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSPSZ.Text); + + FrmLayerControl frm = new FrmLayerControl(layerTree, globeControl1, globeControl2); + frm.Show(this); + } + + /// + /// 碰撞审查 + /// + /// + /// + private void buttonItemSH1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSH1.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 buttonItemSH2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSH2.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 buttonItemSH3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSH3.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 buttonItemSH4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSH4.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 buttonItemSH5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSH5.Text); + FrmCityServerLineAnalysis frm = new FrmCityServerLineAnalysis(globeControl1, m_PipelineLayerNames); + frm.Show(this); + } + #region 数据管理-导入文件 + ///// + ///// 数据管理-导入本地坐标系文件 + ///// + ///// + ///// + //private void buttonItemSJGL1_1_Click(object sender, EventArgs e) + //{ + // //日志记录 + // LogManager.saveLog(Utility.userName, this.buttonItemSJGL1_1.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(); + // } + // } + //} + + ///// + ///// 数据管理-导入其他坐标系文件 + ///// + ///// + ///// + //private void buttonItemSJGL1_2_Click(object sender, EventArgs e) + //{ + // //日志记录 + // LogManager.saveLog(Utility.userName, this.buttonItemSJGL1_2.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(); + // } + // } + //} + #endregion + /// + /// 数据质量检查 + /// + /// + /// + private void buttonItemSJGL2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL2.Text); + FrmValiData frm = new FrmValiData(globeControl1); + frm.ShowDialog(); + } + /// + /// 数据预处理 + /// + /// + /// + private void buttonItemSJGL3_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL3.Text); + + FrmEditShapeFile frm = new FrmEditShapeFile(globeControl1); + frm.ShowDialog(this); + } + /// + /// 连接数据库 + /// + /// + /// + private void buttonItemSJGL4_1_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL4_1.Text); + + FrmDatabaseParaSetting frm = new FrmDatabaseParaSetting(globeControl1); + if (frm.ShowDialog() == DialogResult.OK) + { + ds = FrmDatabaseParaSetting.ds; + if (ds != null) + { + ds.IsCloseSaved = false; + } + } + } + /// + /// 管线入库 + /// + /// + /// + private void buttonItemSJGL4_2_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL4_2.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 buttonItemSJGL4_3_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL4_3.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 buttonItemSJGL5_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL5.Text); + + Cyberpipe.Forms.FrmProject frm = new Cyberpipe.Forms.FrmProject(); + frm.ShowDialog(); + } + /// + /// 元数据基本管理 + /// + /// + /// + private void buttonItemSJGL6_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL6_1.Text); + + FrmMetadata frmmd = new FrmMetadata(); + frmmd.ShowDialog(); + } + /// + /// 元数据查询管理 + /// + /// + /// + private void buttonItemSJGL6_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL6_2.Text); + + FrmMetadataStat frmmds = new FrmMetadataStat(); + //frmmds.Show(); + frmmds.ShowDialog(); + } + /// + /// 操作日志管理 + /// + /// + /// + private void buttonItemSJGL7_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL7.Text); + + FrmLogOper frmlo = new FrmLogOper(); + frmlo.ShowDialog(); + } + /// + /// 数据字典管理 + /// + /// + /// + private void buttonItemSJGL8_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL8.Text); + + FrmMDDictory frmmdd = new FrmMDDictory(); + frmmdd.ShowDialog(); + } + /// + /// 数据库备份 + /// + /// + /// + private void buttonItemSJGL9_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL9.Text); + + //新 + FrmBACKORACLE backOracle = new FrmBACKORACLE(); + backOracle.Show(); + } + /// + /// 创建管段 + /// + /// + /// + private void buttonItemBJ1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ1.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; + } + } + /// + /// 创建附属物 + /// + /// + /// + private void buttonItemBJ2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ2.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); + } + } + /// + /// 创建特征管点 + /// + /// + /// + private void buttonItemBJ3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ3.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); + } + } + /// + /// 绘制城市七线 + /// + /// + /// + private void buttonItemBJ4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ4.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; + } + } + } + /// + /// 选中对象 + /// + /// + /// + private void buttonItemBJ5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ5.Text); + + globeControl1.Globe.Action = EnumAction3D.SelectObject; + } + /// + /// 平移对象 + /// + /// + /// + private void buttonItemBJ6_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ6.Text); + + globeControl1.Globe.Action = EnumAction3D.MoveObject; + } + /// + /// 升降对象 + /// + /// + /// + private void buttonItemBJ7_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ7.Text); + + globeControl1.Globe.Action = EnumAction3D.ElevateObject; + } + /// + /// 旋转对象 + /// + /// + /// + private void buttonItemBJ8_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ8.Text); + + globeControl1.Globe.Action = EnumAction3D.RotateObject; + } + /// + /// 连接管段 + /// + /// + /// + private void buttonItemBJ9_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ9.Text); + + if (globeControl1.Globe.SelObjectCount < 2) + { + MessageBox.Show("对不起,请至少选中2个对象!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + return; + } + globeControl1.Globe.InsertJointPipeline(false); + } + /// + /// 后退 + /// + /// + /// + private void buttonItemBJ11_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemBJ11.Text); + globeControl1.Globe.UnDoEdit(); + } + /// + /// 前进 + /// + /// + /// + private void buttonItemBJ12_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemBJ12.Text); + + globeControl1.Globe.ReDoEdit(); + } + /// + /// 导出CAD + /// + /// + /// + private void buttonItemBJ10_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ10_1.Text); + + #region 导出成dxf格式 + List listVectorNames = new List(); + 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(); + #endregion + } + /// + /// 导出矢量 + /// + /// + /// + private void buttonItemBJ10_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ10_2.Text); + + List listVectorNames = new List(); + 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 buttonItemBJ13_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemBJ13.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(); + } + } + MessageBox.Show("删除成功!", "提示"); + } + else + { + MessageBox.Show("请选中要删除的模型!", "提示"); + } + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + } + + private void buttonItemHX1_1_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]; + string filePath = dlg.FileName; + string lastname = Path.GetFileName(filePath); + + 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(); + } + + } + } + } + + public struct LineStruct + { + public string layerName; + public string layerCode; + public string lineLength; + public string hxName; + } + + List lineStruct = new List(); + List featsList = new List(); + + /// + /// 红线审核 + /// + /// + /// + private void buttonItemHX2_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemHX2.Text); + redSH = true; + featsList.Clear(); + lineStruct.Clear(); + List listPipelineLayers = new List(); + + GSOLayer layer = null; + for (int i = 0; i < m_PipelineLayerNames.Count; i++) + { + layer = globeControl1.Globe.Layers.GetLayerByCaption(m_PipelineLayerNames[i]); + if (layer != null) + { + listPipelineLayers.Add(layer); + } + } + //yanxiaowei 重构 + GSOFeatures selectFeatures=new GSOFeatures(); + for (int i = 0; i < globeControl1.Globe.SelObjectCount; i++) + { + GSOFeature feature = null; + globeControl1.Globe.GetSelectObject(i, out feature, out layer); + selectFeatures.Add(feature); + } + DataTable table=new DataTable(); + + ClassGSOTool.CalculateRedLineResult(out table, redSH, selectFeatures, globeControl1, + listPipelineLayers,out lineStruct, out featsList); + + if (table.Rows.Count != 0) + AddDatagridView(table); + else + { + MessageBox.Show("没有侵入地块红线的管线数据!", "提示"); + dataGridViewX1.DataSource = null; + panelOfTable.Visible = false; + return; + } + } + + private void AddDatagridView(DataTable table) + { + dataGridViewX1.DataSource = table; + panelOfTable.Visible = true; + panelOfTable.Height = 200; + toolStripNumbers.Text = "红线审核 |共有:" + table.Rows.Count + "条"; + toolStripDropDownButton3.Visible = true; + } + /// + /// 主窗体 下方的工具条中的 导出.xls文件 按钮事件处理 + /// + /// + /// + private void toolStripDropDownButton3_Click(object sender, EventArgs e) + { + if (dataGridViewX1.Rows.Count == 0) + { + MessageBox.Show("表格内容为空!", "提示"); + return; + } + + string strSaveFile = string.Empty; + SaveFileDialog savefiledialog = new SaveFileDialog(); + savefiledialog.Filter = "Excel文件|*.xls,*.xlsx"; + savefiledialog.AddExtension = true; + savefiledialog.FileName = "红线审核"; + if (savefiledialog.ShowDialog() == DialogResult.OK) + strSaveFile = savefiledialog.FileName; + else return; + + ExpEXCEL.ExpToExcel(dataGridViewX1, strSaveFile, "红线审核", lineStruct, featsList); + MessageBox.Show("导出成功!"); + } + /// + /// 去除集合中重复的管线 + /// + /// + /// + /// + private GSOFeatures getFeaturesByFilter(GSOFeatures features, string fieldName) + { + if (features == null) + { + return null; + } + GSOFeatures featuresGet = new GSOFeatures(); + for (int i = 0; i < features.Length; i++) + { + GSOFeature featureFromFS = features[i]; + string fieldValueFromFS = featureFromFS.GetValue(fieldName).ToString().Trim(); + bool isHas = false; + for (int j = featuresGet.Length - 1; j >= 0; j--) + { + GSOFeature featureFromFSGet = featuresGet[j]; + string fieldValueFromFSGet = featureFromFSGet.GetValue(fieldName).ToString().Trim(); + if (fieldValueFromFS.Equals(fieldValueFromFSGet)) + { + isHas = true; + break; + } + } + if (isHas == false) + { + featuresGet.Add(featureFromFS.Clone()); + } + } + return featuresGet; + } + + private void sliderItem2_ValueChanged(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.sliderItem2.Text); + + globeControl1.Globe.GroundOpaque = 100 - sliderItem2.Value; + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(roadLayerName);//("180fd"); + if (layer != null) + { + layer.Opaque = 100 - sliderItem2.Value; + } + layer = globeControl2.Globe.Layers.GetLayerByCaption("180fd");//("180fd"); + if (layer != null) + { + layer.Opaque = 100 - sliderItem2.Value; + } + globeControl2.Globe.GroundOpaque = 100 - sliderItem2.Value; + + optiValue = sliderItem2.Value; + } + /// + /// 数据管理导入文件 + /// + /// + /// + private void buttonItemSJGL1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL1.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.Multiselect = true; + if (dlg.ShowDialog() == DialogResult.OK) + { + //自定义lprj文件名,从程序中复制一lprj文件。 + string filePath = dlg.FileName; + string lastname = Path.GetFileName(filePath); + + 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, 100); + + globeControl1.Refresh(); + } + } + } + + private void buttonItemHX1_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemHX1.Text); + + GSODataSource dataSpace = globeControl1.Globe.DataManager.OpenOracleDataSource(Utility.DBServer.Trim() + "/" + Utility.dbdatabase.Trim(), "", "", Utility.userID, Utility.DBPassword); + string filepath = ""; + //日志记录 + OpenFileDialog dlg = new OpenFileDialog(); + dlg.Filter = "矢量数据(*.shp)|*.shp|矢量数据(*.lgd)|*.lgd|CAD数据(*.dxf)|*.dxf|全部支持格式(*.lgd,*.shp,*.dxf)|*.lgd;*.shp;*.dxf;"; + dlg.Multiselect = true; + + #region 临时图层显示 + if (dlg.ShowDialog() == DialogResult.OK) + { + string filePath = dlg.FileName; + string lastname = Path.GetFileName(filePath); + + #region + for (int i = 0; i < dlg.FileNames.Length; i++) + { + string strDataPath = dlg.FileNames[i]; + filepath = strDataPath; + + GSOLayer layer = globeControl1.Globe.Layers.Add(strDataPath); + GSOFeatures RedFeatures = layer.GetAllFeatures(); + + 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(); + RedFeatures = features; + 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; + } + + /////////////////////////////////////////////////////////////////////////////////////////// + globeControl1.Globe.Layers.MoveTo(0, globeControl1.Globe.Layers.Count - 1); + globeControl1.Refresh(); + } + + IModelBuilder modelBuilder = new RedLineBuilder(); + + modelBuilder.batchInsert(dataSpace, redDt, RedFeatures); + + } + #endregion + + } + #endregion + } + /// + /// 定位 + /// + /// + /// + private void buttonItemLocation_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemLocation.Text); + + FrmFlyToPosition fly = new FrmFlyToPosition(globeControl1,globeControl2); + fly.Show(this); + } + /// + /// 2015-10-17演示代码 红线审核 + /// + /// + /// + private void ribbonTabItem6_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.FlyToPosition(new GSOPoint3d(120.610963, 31.188121, 50), EnumAltitudeMode.Absolute, -4, 50, 800); + globeControl1.Globe.FlyToPointSpeed = 10000000; + globeControl1.Globe.Action = EnumAction3D.SelectObject; + globeControl1.Refresh(); + + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + + //zhanshi = false; + redSH = true; + splitContainer1.Panel2Collapsed = true; + legendSG.Visible = false; + legendSC.Visible = false; + ClearGZData(); + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = true; + } + + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 基础工具 + /// + /// + /// + private void ribbonTabItem1_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + //zhanshi = false; + redSH = false; + splitContainer1.Panel2Collapsed = true; + panelOfTable.Visible = false; + legendSC.Visible = false; + legendSG.Visible = false; + ClearGZData(); + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + + + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 一键审核 + /// + /// + /// + private void ribbonTabItem11_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + //zhanshi = false; + redSH = false; + splitContainer1.Panel2Collapsed = true; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + panelOfTable.Visible = false; + legendSC.Visible = false; + legendSG.Visible = false; + ClearGZData(); + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + + + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 右屏添加冰箱数据 + /// + void AddDataToGlobeControl2() + { + + bool modelDataBool = false; + for (int i = globeControl2.Globe.Layers.Count - 1; i >= 0; i--) + { + GSOLayer layer = globeControl2.Globe.Layers[i]; + if (layer.Name.Contains("fttp:")) + { + modelDataBool = true; + break; + } + } + + if (modelDataBool == false) + { + GSOLayer ly = globeControl1.Globe.Layers.GetLayerByCaption("天地图地图"); + globeControl2.Globe.Layers.Add(ly); + } + else + { + return; + } + } + /// + /// 双屏对比 + /// + /// + /// + private void ribbonTabItem9_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent += new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent += new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + panelOfTable.Visible = false; + + splitContainer1.Panel2Collapsed = false; + //zhanshi = true; + redSH = false; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + sliderItem2.Value = 100 - globeControl1.Globe.GroundOpaque; + globeControl2.Globe.GroundOpaque = globeControl1.Globe.GroundOpaque; + legendSC.Visible = true; + legendSG.Visible = true; + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + AddDataToGlobeControl2(); + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 文档管理 + /// + /// + /// + private void ribbonTabItem4_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + panelOfTable.Visible = false; + //zhanshi = false; + redSH = false; + splitContainer1.Panel2Collapsed = true; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + legendSC.Visible = false; + legendSG.Visible = false; + ClearGZData(); + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 基础管理 + /// + /// + /// + private void ribbonTabItem14_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + panelOfTable.Visible = false; + //zhanshi = false; + redSH = false; + splitContainer1.Panel2Collapsed = true; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + legendSC.Visible = false; + legendSG.Visible = false; + ClearGZData(); + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 权限管理 + /// + /// + /// + private void ribbonTabItem2_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + panelOfTable.Visible = false; + //zhanshi = false; + redSH = false; + splitContainer1.Panel2Collapsed = true; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + legendSC.Visible = false; + legendSG.Visible = false; + ClearGZData(); + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + GSOFeature dpFeatuer = null; + /// + /// 双屏分析,点击管段分析 + /// + /// + /// + private void buttonItem8_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItem8.Text); + + //FrmCompareFeature frmCompareFeature = new FrmCompareFeature(globeControl1, globeControl2, layerTemp, layerTemp2,m_PipelineLayerNames,sgPipeLayersNames); + int width = this.Width; + FrmCompareFeature.ShowForm(globeControl1, globeControl2, layerTemp, layerTemp2, m_PipelineLayerNames, sgPipeLayersNames,width); + //frmCompareFeature.Location = new Point((this.Width - frmCompareFeature.Width)/2,50); + //frmCompareFeature.Show(this); + + } + /// + /// 红线审核导出图片 + /// + /// + /// + private void buttonItemDCTP_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemDCTP.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))); + */ + int mapWidth = 0; + int mapHeight = 0; + Point pt = getUpperLeftPoint(pt1, pt2, out mapWidth, out mapHeight); + int rightBottomX = pt.X + mapWidth; + int rightBottomY = pt.Y + mapHeight; + Image myImg = new Bitmap(mapWidth, mapHeight); + Graphics g = Graphics.FromImage(myImg); + g.CopyFromScreen(pt, new Point(0, 0), new Size(rightBottomX, rightBottomY)); + + 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; + } + } + } + /// + /// 标识器全区域统计 + /// + /// + /// + private void 标识器分类统计ToolStripMenuItem_Click(object sender, EventArgs e) + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + FrmBSQStatis bsqStatis = new FrmBSQStatis(); + bsqStatis.Show(this); + } + /// + /// 标识器绘制区域统计 + /// + /// + /// + private void 标识器分类统计ToolStripMenuItem1_Click(object sender, EventArgs e) + { + trackflag = "BSQDuoBianXiangStatis"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + } + + #region 保存和加载审核库加载的图层 + /* + private void saveLayerList(TreeNodeCollection treeNodeList) + { + string configPath = Application.StartupPath + "\\configLayerList.xml"; + try + { + XmlDocument doc = new XmlDocument(); + doc.Load(configPath); + XmlNode dbParams = doc.SelectSingleNode("Params/dbparams"); + XmlNode dbLayers = doc.SelectSingleNode("Params/dblayers"); + XmlNode layers = doc.SelectSingleNode("Params/layers"); + dbParams.RemoveAll(); + dbLayers.RemoveAll(); + layers.RemoveAll(); + + List listDS = new List(); + String shDatasourceName = Utility.sgdbip + "/" + Utility.sgdbname + "_" + Utility.sgdbuser; + bool flag = false; + + for (int i = 0; i < globeControl1.Globe.DataManager.DataSourceCount; i++) + { + GSODataSource ds = globeControl1.Globe.DataManager.GetDataSourceAt(i); + if (ds != null && ds.Type == EnumDataSourceType.SqlServer || ds.Type == EnumDataSourceType.Oracle) + { + if (ds.Name == shDatasourceName) + { + //防止因为多次连接同一个数据库 + if (flag == true) + { + break; + } + flag = true; + listDS.Add(ds); + GSODataSourceCnn conn = ds.GetConnectionInfo(); + + XmlElement dbparam = doc.CreateElement("shdbparam"); + XmlElement ip = doc.CreateElement("ship"); + ip.InnerText = conn.Server; + + XmlElement dbname = doc.CreateElement("shdbname"); + dbname.InnerText = conn.Database; + + XmlElement username = doc.CreateElement("shusername"); + username.InnerText = conn.User; + + XmlElement password = doc.CreateElement("shpassword"); + password.InnerText = conn.Password; + + XmlElement type = doc.CreateElement("shtype"); + if (ds.Type == EnumDataSourceType.SqlServer) + { + type.InnerText = "sqlserver"; + } + else + { + type.InnerText = "oracle"; + } + + dbparam.AppendChild(ip); + dbparam.AppendChild(dbname); + dbparam.AppendChild(username); + dbparam.AppendChild(password); + dbparam.AppendChild(type); + dbParams.AppendChild(dbparam); + } + + } + } + + for (int i = 0; i < treeNodeList.Count; i++) + { + GSOLayer layer = treeNodeList[i].Tag as GSOLayer; + if (Path.GetExtension(layer.Name) == "") + { + XmlElement dbLayer = doc.CreateElement("dblayer"); + XmlAttribute attri = doc.CreateAttribute("dbindex"); + for (int j = 0; j < listDS.Count; j++) + { + if (layer.Dataset.DataSource.Name == listDS[j].Name) + { + attri.Value = j.ToString(); + break; + } + } + dbLayer.Attributes.Append(attri); + dbLayer.InnerText = layer.Name; + + dbLayers.AppendChild(dbLayer); + } + else + { + XmlElement dbLayer = doc.CreateElement("layer"); + dbLayer.InnerText = layer.Name; + layers.AppendChild(dbLayer); + } + } + + doc.Save(configPath); + } + catch (Exception e) + { + + } + } + + private void openLayerList() + { + layerManagerNode.Nodes.Clear(); + + string configPath = Application.StartupPath + "\\configLayerList.xml"; + try + { + XmlDocument doc = new XmlDocument(); + doc.Load(configPath); + XmlNode dbParams = doc.SelectSingleNode("Params/dbparams"); + XmlNode dbLayers = doc.SelectSingleNode("Params/dblayers"); + XmlNode layers = doc.SelectSingleNode("Params/layers"); + + List listDS = new List(); + for (int i = 0; i < dbParams.ChildNodes.Count; i++) + { + string ip = ""; + string dbname = ""; + string username = ""; + string password = ""; + string type = ""; + XmlNode node = dbParams.ChildNodes.Item(i); + for (int j = 0; j < node.ChildNodes.Count; j++) + { + XmlNode nodeChild = node.ChildNodes.Item(j); + + if (nodeChild != null && nodeChild.Name == "ship") + { + ip = nodeChild.InnerText; + } + else if (nodeChild != null && nodeChild.Name == "shdbname") + { + dbname = nodeChild.InnerText; + } + else if (nodeChild != null && nodeChild.Name == "shusername") + { + username = nodeChild.InnerText; + } + else if (nodeChild != null && nodeChild.Name == "shpassword") + { + password = nodeChild.InnerText; + } + else if (nodeChild != null && nodeChild.Name == "shtype") + { + type = nodeChild.InnerText; + } + } + + if (type == "sqlserver") + { + GSODataSource ds = globeControl1.Globe.DataManager.OpenSqlServerDataSource(ip, "", dbname, username, password); + listDS.Add(ds); + } + else if (type == "oracle") + { + GSODataSource ds = globeControl1.Globe.DataManager.OpenOracleDataSource(ip + "/" + dbname, "", "", username, password); + listDS.Add(ds); + } + } + + for (int i = 0; i < dbLayers.ChildNodes.Count; i++) + { + XmlNode node = dbLayers.ChildNodes.Item(i); + if (node != null) + { + string layerName = node.InnerText; + XmlAttribute attri = node.Attributes["dbindex"]; + if (attri != null) + { + int dbIndex = -1; + if (int.TryParse(attri.Value, out dbIndex)) + { + GSODataset dataset = listDS[dbIndex].GetDatasetByName(layerName); + globeControl1.Globe.Layers.Add(dataset); + //更新树节点 + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + TreeNode layerNode = new TreeNode(); + layerNode.Tag = layer; + layerNode.Text = layer.Dataset.Caption; + layerNode.ImageIndex = 0; + layerNode.SelectedImageIndex = 0; + layerNode.Checked = layer.Visible; + layerManagerNode.Nodes.Insert(0, layerNode); + // layerManagerNode.Expand(); + + + } + } + } + } + for (int i = 0; i < layers.ChildNodes.Count; i++) + { + XmlNode node = layers.ChildNodes.Item(i); + if (node != null) + { + string layerName = node.InnerText; + globeControl1.Globe.Layers.Add(layerName); + + //更新树节点 + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + TreeNode layerNode = new TreeNode(); + layerNode.Tag = layer; + layerNode.Text = layer.Dataset.Caption; + layerNode.ImageIndex = 0; + layerNode.SelectedImageIndex = 0; + layerNode.Checked = layer.Visible; + layerManagerNode.Nodes.Insert(0, layerNode); + } + } + layerManagerNode.Expand(); + } + catch (Exception e) + { + + } + } + * */ + #endregion + + private void btn_check_history_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_check_history.Text); + + if (FrmCheckHistory.isOpen == true) + { + return; + } + FrmCheckHistory frm = new FrmCheckHistory(globeControl1, globeControl2); + frm.addNode += new AddNodeToLayerManagerNode(addNodeToLayerManagerNode); + frm.Show(); + + } + + private void buttonItem查看数据_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItem查看数据.Text); + + FrmThreeOracle tr = new FrmThreeOracle(globeControl1); + + if (tr.ShowDialog() == DialogResult.OK) + { + addNodeToLayerManagerNode(tr.rukuLayer); + globeControl1.Refresh(); + } + } + /// + /// 规划数据入库 + /// + /// + /// + private void buttonItemGHRK_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemGHRK.Text); + + FrmGHRK ghrk = new FrmGHRK(globeControl1, layerManagerNode); + ghrk.Show(this); + } + + private void btn_user_info_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_user_info.Text); + + if (!FrmSysUserInfoManger.IS_OPEN) + { + FrmSysUserInfoManger frm = new FrmSysUserInfoManger(); + frm.ShowDialog(); + } + } + + private void btn_role_info_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_role_info.Text); + + if (FrmRoleInfoManager.IS_OPEN) + { + return; + } + FrmRoleInfoManager frm = new FrmRoleInfoManager(); + frm.ShowDialog(); + } + + private void btn_resc_info_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_resc_info.Text); + + if (!SysRescInfoManager.IS_OPEN) + { + SysRescInfoManager frm = new SysRescInfoManager(); + frm.ShowDialog(); + } + } + + private void btn_role_resc_Click(object sender, EventArgs e) + { + + LogManager.saveLog(Utility.userName, this.btn_role_resc.Text); + + if (!FrmRoleRescManager.IS_OPEN) + { + FrmRoleRescManager frm = new FrmRoleRescManager(); + frm.ShowDialog(); + } + } + + private void btn_user_role_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_user_role.Text); + + if (FrmUserRole.IS_OPEN) + { + return; + } + FrmUserRole frm = new FrmUserRole(); + frm.ShowDialog(); + } + + private void btn_document_info_Click(object sender, EventArgs e) + { + + LogManager.saveLog(Utility.userName, this.btn_document_info.Text); + + //if (FormDocumentManager.IS_OPEN) + //{ + // return; + //} + //FormDocumentManager frm = new FormDocumentManager(); + //frm.ShowDialog(); + + //if (FormDocumentManager.IS_OPEN) + //{ + // return; + //} + //new FormDocumentManager().ShowDialog(); + if (FormDocumentManager.IS_OPEN) + { + return; + } + this.Cursor = Cursors.WaitCursor; + FormDocumentManager frm = new FormDocumentManager(); + frm.changeCursor += new ChangeCursor(changeCursorToDefault); + frm.ShowDialog(); + + } + + private void changeCursorToDefault() + { + this.Cursor = Cursors.Default; + } + + /// + /// 判断CAD文件是否有投影信息 + /// + /// + /// + Boolean CheckDatasetGeoReference(GSODataset dataset) + { + Boolean bSuccess = false; + if (dataset.GeoReferenceType == EnumGeoReferenceType.Flat) + { + if (MessageBox.Show("数据没有空间参考信息,请设置空间参考信息!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation) == DialogResult.OK) + { + String strPath = Path.GetDirectoryName(Application.ExecutablePath) + "\\Coordinate Systems"; + OpenFileDialog dlg = new OpenFileDialog(); + + dlg.InitialDirectory = strPath; + dlg.RestoreDirectory = true; + + dlg.Filter = "投影文件|*.prj||"; + if (dlg.ShowDialog() == DialogResult.OK) + { + bSuccess = dataset.LoadProjectionFromESRIFile(dlg.FileName); + } + } + } + else + { + return true; + } + return bSuccess; + } + + private void buttonItemexp_CAD_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemexp_CAD.Text); + + OpenFileDialog dlg = new OpenFileDialog(); + dlg.Filter = "支持格式(*.dwg)|*.dwg"; + dlg.Multiselect = true; + if (dlg.ShowDialog() == DialogResult.OK) + { + for (int i = 0; i < dlg.FileNames.Length; i++) + { + //this.Cursor = Cursors.WaitCursor; + string strDataPath = dlg.FileNames[i]; + + #region + //string strDataPathPrj = strDataPath.ToLower().Replace(".dwg", ".lprj"); + + //if (File.Exists(strDataPathPrj) == false) + //{ + // if (MessageBox.Show("数据没有空间参考信息,请设置空间参考信息!", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation) == DialogResult.OK) + // { + // String strPath = Application.StartupPath + "\\Coordinate Systems"; + // OpenFileDialog dlgPrj = new OpenFileDialog(); + // dlgPrj.InitialDirectory = strPath; + // dlgPrj.RestoreDirectory = true; + // dlgPrj.Multiselect = false; + // dlg.Filter = "投影文件|*.prj"; + // if (dlg.ShowDialog() == DialogResult.OK) + // { + // this.Cursor = Cursors.WaitCursor; + // string proj4 = GSODataEngineUtility.ConvertEsriPrjFileToProj4(dlg.FileName); + // using (StreamWriter stream = new StreamWriter(strDataPathPrj, false)) + // { + // stream.WriteLine("0prj4" + proj4 + ""); + // } + // AddLayerData(strDataPath); + // //globeControl1.Globe.Layers.Add(strDataPath); + + // this.Cursor = Cursors.Default; + // } + // else + // { + // AddLayerData(strDataPath); + // //globeControl1.Globe.Layers.Add(strDataPath); + // } + // } + // else + // { + // AddLayerData(strDataPath); + // //globeControl1.Globe.Layers.Add(strDataPath); + // } + + //} + //else + //{ + // //globeControl1.Globe.Layers.Add(strDataPath); + // AddLayerData(strDataPath); + //} + #endregion + AddLayerData(strDataPath); + //this.Cursor = Cursors.Default; + } + } + + 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, 100); + + globeControl1.Refresh(); + } + } + + private void btn_password_edit_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_password_edit.Text); + + if (FrmChangePassword.IS_OPEN) + { + return; + } + FrmChangePassword frm = new FrmChangePassword(); + frm.ShowDialog(); + } + /// + /// 多孔管线入库 + /// + /// + /// + private void buttonItem9_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL4_2.Text); + + if (ds == null) + { + MessageBox.Show("请先连接数据库", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + ConnectDB(null, null); + } + if (ds == null) + return; + + FrmMultiPipelineModelDB frm = new FrmMultiPipelineModelDB(globeControl1, ds); + if (frm.ShowDialog() == DialogResult.OK) + { + addNodeToLayerManagerNode(frm.rukuLayer); + } + //frm.Show(); + } + private void 导出CADToolStripMenuItem1_Click(object sender, EventArgs e) + { + TreeNode node = layerNodeContexMenu.Tag as TreeNode; + if (node == null) + { + MessageBox.Show("请在左侧节点集中选择要导出的图层", "提示"); + return; + } + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(node.Text.Trim()); + if (layer == null || layer.GetAllFeatures().Length <= 0) + { + MessageBox.Show("要导出的图层为空", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + return; + } + string strProjectName = Utility.projectStr; + if (strProjectName != "") + { + SaveFileDialog dlg = new SaveFileDialog(); + dlg.Filter = "*.dwg|*.dwg|*.dxf|*.dxf"; + dlg.FileName = layer.Caption; + if (dlg.ShowDialog(this) == DialogResult.OK) + { + globeControl1.Globe.MemoryLayer.SaveAs(dlg.FileName); + GSOLayer newlayer = globeControl1.Globe.Layers.Add(dlg.FileName); + newlayer.RemoveAllFeature(); + int featureCount = layer.GetAllFeatures().Length; + for (int i = 0; i < featureCount; i++) + { + GSOFeature feature = layer.GetAt(i); + if (feature != null && feature.Geometry != null) + { + if (feature.Geometry.Type == EnumGeometryType.GeoPolyline3D) + { + feature.Geometry.Style = new GSOSimpleLineStyle3D(); + } + else if (feature.Geometry.Type == EnumGeometryType.GeoPolygon3D) + { + feature.Geometry.Style = new GSOSimplePolygonStyle3D(); + } + newlayer.AddFeature(feature); + } + } + newlayer.Save(); + newlayer.Dataset.DataSource.RemoveDataset(newlayer.Dataset); + globeControl1.Globe.Layers.Remove(newlayer); + MessageBox.Show("导出CAD完成!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + } + } + } + + private void buttonItemGBJC_Click(object sender, EventArgs e) + { + FrmGBJC gb = new FrmGBJC(globeControl1, globeControl2, layerTemp, layerTemp2); + gb.Show(this); + } + + #region 右屏管纵数据控制 + private void 五十米主干道ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = true; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + + private void 三十六米次干道ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = true; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + + private void 四十二米次干道ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = true; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + + private void 二十四米一块板ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = true; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + + private void 二十四米三块板ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = true; + } + + private void 二十四米停车带ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = true; + lendendGZ24_3.Visible = false; + } + + private void 二十六米大堤路ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = true; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + + private void 清除管纵数据ToolStripMenuItem_Click(object sender, EventArgs e) + { + ClearGZData(); + } + + private void ClearGZData() + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + #endregion + + private void buttonItemPasswordReset_Click(object sender, EventArgs e) + { + Frm_password_reset reset = new Frm_password_reset(); + reset.Show(); + } + + private void pictureBox1_Paint(object sender, PaintEventArgs e) + { + int Width = this.Width; + string welcomeUser = "欢迎您:" + Utility.userName; + Graphics g = e.Graphics; + g.DrawString(welcomeUser, new Font("宋体", 12), new SolidBrush(Color.Black), Width - 180, 50); + } + + } +} \ No newline at end of file diff --git a/MainFrm.cs.REMOTE.9016.cs b/MainFrm.cs.REMOTE.9016.cs new file mode 100644 index 0000000..9bfb70e --- /dev/null +++ b/MainFrm.cs.REMOTE.9016.cs @@ -0,0 +1,13345 @@ +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; + + GSOBalloon featureTooltip2; + GSOBalloonEx balloonEx2; + + GSOLayer layerTemp; + GSOLayer layerTemp2; + FrmShResult frmShResult = null; + FrmRedlineResult frmredResult = null; + FrmMnModify frmModify = null; + public bool frmRedlineResult = false; + public bool boolfrmShResult = false; + public bool boolfrmModify = false; + + List m_PipelineLayerNames = new List();//线图层名称 + List workwellLayerNames = new List();//工井图层名称 + List valueLayerNames = new List();//阀门图层名称 + List instrumenLayerNames = new List();//附属物图层名称 + List pipefittingLayerNames = new List();//管件图层名称 + List sgPipeLayersNames = new List();//施工管线图层名称 + 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 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; + public string redLayer = null; + //GSOLayer redLayer1 = null; + bool redSH = false; + string redDt = "红线"; + //双屏对比 + //bool zhanshi=false; + Thread t = null; + private GSOHudButton legendSC;//定义图例 + private GSOHudButton legendSG;//定义图例 + //管纵图 + private GSOHudButton lendendGZ50; + private GSOHudButton lendendGZ36; + private GSOHudButton lendendGZ42; + private GSOHudButton lendendGZ24_1; + private GSOHudButton lendendGZ24_2; + private GSOHudButton lendendGZ24_3; + private GSOHudButton lendendGZ26; + + GSOGeoPoint3D bsqPT; + + FrmYJSHTC frmSh = null;//一键审核窗口全局变量wxl + FrmWait frmWait = null;//一键审核等待窗口 + //FrmWait frmWait2 = null;//文档操作等待窗口 + + float mouseDownX1,mouseDownY1; + float mouseDownX2,mouseDownY2; + /// + /// + /// + 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; + + featureTooltip2 = new GSOBalloon(globeControl2.Handle); + balloonEx2 = new GSOBalloonEx(globeControl2.Handle); + Utility.SetBallons(featureTooltip, balloonEx); + + panelOfTable.Height = 200; + + RigthMenuSet(); + + MenuSet(); + + } + /// + /// 右屏中添加管纵图片 + /// + private void AddGZ() + { + + lendendGZ50 = new GSOHudButton(); + lendendGZ50.SetImage(Application.StartupPath + "/Resource/管纵/50.png"); + lendendGZ50.SetOffset(0, 0); + lendendGZ50.MinOpaque = 1; + lendendGZ50.MaxOpaque = 1; + lendendGZ50.FadeOut = false; + lendendGZ50.Name = "lendendGZ50"; + lendendGZ50.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ50); + lendendGZ50.Visible = false; + + lendendGZ36 = new GSOHudButton(); + lendendGZ36.SetImage(Application.StartupPath + "/Resource/管纵/36.png"); + lendendGZ36.SetOffset(0, 0); + lendendGZ36.MinOpaque = 1; + lendendGZ36.MaxOpaque = 1; + lendendGZ36.FadeOut = false; + lendendGZ36.Name = "lendendGZ36"; + lendendGZ36.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ36); + lendendGZ36.Visible = false; + + lendendGZ42 = new GSOHudButton(); + lendendGZ42.SetImage(Application.StartupPath + "/Resource/管纵/42.png"); + lendendGZ42.SetOffset(0, 0); + lendendGZ42.MinOpaque = 1; + lendendGZ42.MaxOpaque = 1; + lendendGZ42.FadeOut = false; + lendendGZ42.Name = "lendendGZ42"; + lendendGZ42.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ42); + lendendGZ42.Visible = false; + + lendendGZ24_1 = new GSOHudButton(); + lendendGZ24_1.SetImage(Application.StartupPath + "/Resource/管纵/24_1.png"); + lendendGZ24_1.SetOffset(0, 0); + lendendGZ24_1.MinOpaque = 1; + lendendGZ24_1.MaxOpaque = 1; + lendendGZ24_1.FadeOut = false; + lendendGZ24_1.Name = "lendendGZ24_1"; + lendendGZ24_1.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ24_1); + lendendGZ24_1.Visible = false; + + lendendGZ24_2 = new GSOHudButton(); + lendendGZ24_2.SetImage(Application.StartupPath + "/Resource/管纵/24_2.png"); + lendendGZ24_2.SetOffset(0, 0); + lendendGZ24_2.MinOpaque = 1; + lendendGZ24_2.MaxOpaque = 1; + lendendGZ24_2.FadeOut = false; + lendendGZ24_2.Name = "lendendGZ24_2"; + lendendGZ24_2.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ24_2); + lendendGZ24_2.Visible = false; + + lendendGZ24_3 = new GSOHudButton(); + lendendGZ24_3.SetImage(Application.StartupPath + "/Resource/管纵/24_3.png"); + lendendGZ24_3.SetOffset(0, 0); + lendendGZ24_3.MinOpaque = 1; + lendendGZ24_3.MaxOpaque = 1; + lendendGZ24_3.FadeOut = false; + lendendGZ24_3.Name = "lendendGZ24_3"; + lendendGZ24_3.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ24_3); + lendendGZ24_3.Visible = false; + + lendendGZ26 = new GSOHudButton(); + lendendGZ26.SetImage(Application.StartupPath + "/Resource/管纵/26.png"); + lendendGZ26.SetOffset(0, 0); + lendendGZ26.MinOpaque = 1; + lendendGZ26.MaxOpaque = 1; + lendendGZ26.FadeOut = false; + lendendGZ26.Name = "lendendGZ26"; + lendendGZ26.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(lendendGZ26); + lendendGZ26.Visible = false; + + } + + public void RigthMenuSet() + { + if (Utility.userRole.IndexOf("清除分析") < 0) + { + toolRightMenu.Items.Remove(清除分析ToolStripMenuItem); + } + + #region 区域分析 + if (Utility.userRole.IndexOf("区域分析") < 0) + { + toolRightMenu.Items.Remove(区域分析ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("缓冲区分析") < 0) + { + 区域分析ToolStripMenuItem.DropDownItems.Remove(缓冲区分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("附属物分析") < 0) + { + 区域分析ToolStripMenuItem.DropDownItems.Remove(附属物分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("无源淹没分析") < 0) + { + 区域分析ToolStripMenuItem.DropDownItems.Remove(无源淹没分析ToolStripMenuItem); + } + } + #endregion + + #region 视域分析 + if (Utility.userRole.IndexOf("视域分析") < 0) + { + toolRightMenu.Items.Remove(视域分析ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("通视分析") < 0) + { + 视域分析ToolStripMenuItem.DropDownItems.Remove(通视分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("可视域分析") < 0) + { + 视域分析ToolStripMenuItem.DropDownItems.Remove(可视域分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("可视包络分析") < 0) + { + 视域分析ToolStripMenuItem.DropDownItems.Remove(可视包络分析ToolStripMenuItem); + } + } + #endregion + + #region 开发分析 + if (Utility.userRole.IndexOf("开挖分析") < 0) + { + toolRightMenu.Items.Remove(开挖分析ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("多边形开挖") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(多边形开挖ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("挖方量分析") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(挖方量分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("沿线开挖") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(沿线开挖ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("创建隧道") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(创建隧道ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("隐藏隧道") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(隐藏隧道ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("删除隧道") < 0) + { + 开挖分析ToolStripMenuItem.DropDownItems.Remove(删除隧道ToolStripMenuItem); + } + } + #endregion + + #region 拓扑分析 + if (Utility.userRole.IndexOf("拓扑分析") < 0) + { + toolRightMenu.Items.Remove(拓扑分析ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("创建拓扑") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(创建拓扑ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("上游分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(上游分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("下游分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(下游分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("流向分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(流向分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("关阀分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(关阀分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("连通分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(连通分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("爆管分析") < 0) + { + 拓扑分析ToolStripMenuItem.DropDownItems.Remove(爆管分析ToolStripMenuItem); + } + } + #endregion + + #region 断面分析 + if (Utility.userRole.IndexOf("断面分析") < 0) + { + toolRightMenu.Items.Remove(断面分析ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("横断面分析") < 0) + { + 断面分析ToolStripMenuItem.DropDownItems.Remove(横断面分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("纵断面分析") < 0) + { + 断面分析ToolStripMenuItem.DropDownItems.Remove(纵断面分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("道路断面分析") < 0) + { + 断面分析ToolStripMenuItem.DropDownItems.Remove(道路断面分析ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("基线剖面分析") < 0) + { + 断面分析ToolStripMenuItem.DropDownItems.Remove(基线剖面分析ToolStripMenuItem); + } + } + #endregion + + #region 绘制区域统计 + if (Utility.userRole.IndexOf("绘制区域统计") < 0) + { + toolRightMenu.Items.Remove(绘制区域统计ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("绘制区域管线长度统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管线长度统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域阀门数量统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(阀门数量统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域井盖数量统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(井盖数量统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域管径分段统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管径分段统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域埋深分段统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(埋深分段统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域管径分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管径分类统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域材质分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(材质分类统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域附属物分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(附属物分类统计ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("绘制区域标识器分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(标识器分类统计ToolStripMenuItem1); + } + + } + #endregion + + #region 全区域统计 + if (Utility.userRole.IndexOf("全区域统计") < 0) + { + toolRightMenu.Items.Remove(全区域统计ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("全区域管线长度统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管线长度统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域阀门数量统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(阀门数量统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域井盖数量统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(井盖数量统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域管径分段统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管径分段统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域埋深分段统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(埋深分段统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域管径分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(管径分类统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域材质分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(材质分类统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域附属物分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(附属物分类统计ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("全区域标识器分类统计") < 0) + { + 绘制区域统计ToolStripMenuItem.DropDownItems.Remove(标识器分类统计ToolStripMenuItem); + } + + } + #endregion + + #region 查询 + if (Utility.userRole.IndexOf("查询") < 0) + { + toolRightMenu.Items.Remove(查询ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("空间查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(空间查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("编号查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(编号查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("坐标查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(坐标查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("管径查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(管径查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("材质查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(材质查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("基本查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(基本查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("复合查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(复合查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("关联查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(关联查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("关键字查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(关键字查询ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("附属物查询") < 0) + { + 查询ToolStripMenuItem.DropDownItems.Remove(附属物查询ToolStripMenuItem); + } + } + #endregion + + #region 标注 + if (Utility.userRole.IndexOf("标注") < 0) + { + toolRightMenu.Items.Remove(标注ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("标高标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(标高标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("管径标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(管径标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("埋深标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(埋深标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("坐标标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(坐标标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("距离标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(距离标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("自定义标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(自定义标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("扯旗标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(扯旗标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("坡度标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(坡度标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("属性标注") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(属性标注ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("标注管理") < 0) + { + 标注ToolStripMenuItem.DropDownItems.Remove(标注管理ToolStripMenuItem); + } + } + #endregion + + #region 飞行 + if (Utility.userRole.IndexOf("飞行") < 0) + { + toolRightMenu.Items.Remove(飞行ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("自定义飞行") < 0) + { + 飞行ToolStripMenuItem.DropDownItems.Remove(自定义飞行ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("飞行到目标点") < 0) + { + 飞行ToolStripMenuItem.DropDownItems.Remove(飞行到目标点ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("绕中心点飞行") < 0) + { + 飞行ToolStripMenuItem.DropDownItems.Remove(绕中心点飞行ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("绕眼睛飞行") < 0) + { + 飞行ToolStripMenuItem.DropDownItems.Remove(绕眼睛飞行ToolStripMenuItem); + } + } + #endregion + + #region 编辑 + if (Utility.userRole.IndexOf("编辑") < 0) + { + toolRightMenu.Items.Remove(编辑ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("平移对象") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(平移对象ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("升降对象") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(升降对象ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("旋转对象") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(旋转对象ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("连接管段") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(连接管段ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("导出文件") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(导出文件ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("前进") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(前进ToolStripMenuItem); + } + if (Utility.userRole.IndexOf("后退") < 0) + { + 编辑ToolStripMenuItem.DropDownItems.Remove(删除模型ToolStripMenuItem); + } + } + #endregion + + #region 量算 + if (Utility.userRole.IndexOf("量算") < 0) + { + toolRightMenu.Items.Remove(量算ToolStripMenuItem); + } + else + { + if (Utility.userRole.IndexOf("水平距离") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(水平距离ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("垂直距离") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(垂直距离ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("空间距离") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(空间距离ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("地表距离") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(地表距离ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("高度量算") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(高度量算ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("水平面积") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(水平面积ToolStripMenuItem1); + } + if (Utility.userRole.IndexOf("地表面积") < 0) + { + 量算ToolStripMenuItem.DropDownItems.Remove(地表面积ToolStripMenuItem1); + } + } + #endregion + } + + public void MenuSet() + { + + #region 权限管理 + if (Utility.userRole.IndexOf("权限管理") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem2); + } + else + { + + if (Utility.userRole.IndexOf("用户管理") < 0) + { + btn_user_info.Visible = false; + } + if (Utility.userRole.IndexOf("角色管理") < 0) + { + btn_role_info.Visible = false; + } + if (Utility.userRole.IndexOf("资源管理") < 0) + { + btn_resc_info.Visible = false; + } + if (Utility.userRole.IndexOf("角色授权") < 0) + { + btn_role_resc.Visible = false; + } + if (Utility.userRole.IndexOf("用户授权") < 0) + { + btn_user_role.Visible = false; + } + if (Utility.userRole.IndexOf("密码修改") < 0) + { + btn_password_edit.Visible = false; + } + + } + #endregion + + #region 基础工具 + if (Utility.userRole.IndexOf("基础工具") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem1); + } + else + { + if (Utility.userRole.IndexOf("地上模式") < 0) + { + buttonItem87.Visible = false; + } + if (Utility.userRole.IndexOf("地下模式") < 0) + { + buttonItem88.Visible = false; + } + if (Utility.userRole.IndexOf("行走模式") < 0) + { + buttonItem27.Visible = false; + } + if (Utility.userRole.IndexOf("透明度设置") < 0) + { + sliderGroundTransSet1.Visible = false; + } + if (Utility.userRole.IndexOf("快速定位") < 0) + { + buttonItem91.Visible = false; + } + if (Utility.userRole.IndexOf("图层管理") < 0) + { + buttonItem1.Visible = false; + } + if (Utility.userRole.IndexOf("图例管理") < 0) + { + btnlegendSet.Visible = false; + } + if (Utility.userRole.IndexOf("全屏显示") < 0) + { + buttonItem89.Visible = false; + } + if (Utility.userRole.IndexOf("导出图片") < 0) + { + btnOutputJPG.Visible = false; + } + + } + #endregion + + #region 一键审核 + if (Utility.userRole.IndexOf("一键审核") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem11); + } + #endregion + + #region 红线审核 + if (Utility.userRole.IndexOf("红线审核") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem6); + } + #endregion + + #region 双屏对比 + if (Utility.userRole.IndexOf("双屏对比") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem9); + } + #endregion + + #region 文档管理 + if (Utility.userRole.IndexOf("文档管理") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem4); + } + #endregion + + #region 基础管理 + if (Utility.userRole.IndexOf("基础管理") < 0) + { + ribbonControl1.Items.Remove(ribbonTabItem14); + } + else + { + if (Utility.userRole.IndexOf("专题图审批") < 0) + { + buttonItemZTT3_2.Visible = false; + } + if (Utility.userRole.IndexOf("打印审批") < 0) + { + buttonItemZTT4_2.Visible = false; + } + if (Utility.userRole.IndexOf("拷贝审批") < 0) + { + buttonItemZTT5_2.Visible = false; + } + } + + #endregion + + if (ribbonControl1.Items.Count <= 0) + { + ribbonControl1.Visible = false; + } + } + + #region Fan Zhang 重构现有代码 + //初始化控件布局 + private void initLayout() + { + 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.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.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.labelX21.Width = (int)(this.labelX21.Width * myScreen); + this.labelX22.Width = (int)(this.labelX22.Width * myScreen); + this.labelX24.Width = (int)(this.labelX24.Width * myScreen); + } + sideBar1.Visible = false; + 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]); + } + + splitContainer1.Panel2Collapsed = true; + + buttonItem87.Checked = true;//默认地上模式 + ribbonTabItem1.Select(); //初始化状态为浏览 + + sideBarPanelItem3.Visible = false; + layerTree.Visible = false; + controlContainerItem3.Visible = false; + if (sideBarPanelItem4.Visible == true) + { + sideBar1.Visible = true; + controlContainerItem5.Visible = true; + } + else + { + sideBar1.Visible = false; + } + Refresh(); + sliderGroundTransSet1.Value = optiValue; + sliderItem1.Value = optiValue; + sliderItem2.Value = optiValue; + sliderItem3.Value = optiValue; + + } + + //初始化地球控件 + private void initGlobalControl() + { + //选择 + btnToolSelect = new GSOHudButton(); + btnToolSelect.SetImage(Application.StartupPath + "\\Resource\\image\\select1.png"); + btnToolSelect.FadeOut = false; + btnToolSelect.Align = EnumAlign.TopLeft; + btnToolSelect.SetOffset(20, 50); + btnToolSelect.Name = "1"; + btnToolSelect.HeightFixed = true; + btnToolSelect.WidthFixed = true; + globeControl1.Globe.AddHudControl(btnToolSelect); + globeControl2.Globe.AddHudControl(btnToolSelect); + + //浏览 + 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); + + //图例 + legend = new GSOHudButton(); + legend.SetImage(Application.StartupPath + "/Resource/图例P.jpg");//图例P + legend.SetOffset(0, 15); + legend.MinOpaque = 1; + legend.MaxOpaque = 1; + legend.FadeOut = false; + legend.Name = "legend"; + legend.Align = EnumAlign.BottomRight; + legend.Visible = false; + globeControl1.Globe.AddHudControl(legend); + + //实测 + legendSC = new GSOHudButton(); + legendSC.SetImage(Application.StartupPath + "/Resource/sc.jpg"); + legendSC.SetOffset(0, 15); + legendSC.MinOpaque = 1; + legendSC.MaxOpaque = 1; + legendSC.FadeOut = false; + legendSC.Name = "legendSC"; + legendSC.Align = EnumAlign.BottomRight; + globeControl1.Globe.AddHudControl(legendSC); + legendSC.Visible = false; + + //施工 + legendSG = new GSOHudButton(); + legendSG.SetImage(Application.StartupPath + "/Resource/sg.jpg"); + legendSG.SetOffset(0, 15); + legendSG.MinOpaque = 1; + legendSG.MaxOpaque = 1; + legendSG.FadeOut = false; + legendSG.Name = "legendSG"; + legendSG.Align = EnumAlign.BottomRight; + globeControl2.Globe.AddHudControl(legendSG); + legendSG.Visible = false; + + //管纵 + AddGZ(); + + 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; + globeControl1.Globe.IsReleaseMemOutOfView = true; + globeControl1.Globe.ControlPanel.Visible = true; + + globeControl2.Globe.UnderGroundFloor.Visible = false; + globeControl2.Globe.OverviewControl.Visible = false; + globeControl2.Globe.ScalerControl.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; + globeControl2.Globe.IsReleaseMemOutOfView = true; + globeControl2.Globe.ControlPanel.Visible = false; + + 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); + + //添加临时图层 + layerTemp = globeControl1.Globe.Layers.Add(Application.StartupPath + "\\tempLgdData.lgd"); + layerTemp2 = globeControl2.Globe.Layers.Add(Application.StartupPath + "\\tempLgdData2.lgd"); + if (layerTemp != null) + { + layerTemp.MaxVisibleAltitude = 1000; + } + + //添加城市7线图层 + 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"); + + //注册对应事件 + this.registerEvent(); + } + + //注册地球事件 + private bool registerEvent() + { + if (globeControl1 == null || globeControl2 == null) + { + return false; + } + 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); + + globeControl2.FeatureMouseClickEvent += new FeatureMouseClickEventHandler(globeControl2_FeatureMouseClickEvent); + globeControl2.CameraBeginMoveEvent += new CameraBeginMoveEventHandler(globeControl2_CameraBeginMoveEvent); + + globeControl1.MouseDoubleClick += new MouseEventHandler(globeControl1_MouseDoubleClick); + globeControl1.MouseClick += new MouseEventHandler(globeControl1_MouseClick); + globeControl1.MouseDown += new MouseEventHandler(globeControl1_MouseDown); + + globeControl2.MouseClick += new MouseEventHandler(globeControl2_MouseClick); + globeControl2.MouseDown += new MouseEventHandler(globeControl2_MouseDown); + + 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); + + return true; + } + + //加载两个地球数据 + private void loadData() + { + Thread t1 = new Thread(new ThreadStart(doLoadDataForGlobalControl1)); + t1.IsBackground = true; + t1.Start(); + + + } + + delegate void LoadDataForGlobalControl(); + + private void connectServer() + { + globeControl1.Globe.ConnectServer(Utility.serverip, Utility.serverport, "", ""); //加载locaServer中的数据 + globeControl2.Globe.ConnectServer(Utility.serverip, Utility.serverport, "", ""); //加载locaServer中的数据 + //初始化TreeView + // 勾选实测图层 + foreach (TreeNode tn in layerTree.Nodes) + { + if (tn.Nodes.Count > 0) + { + if (tn.Text == "实测数据") + { + tn.Checked = true; + foreach (TreeNode tnChild in tn.Nodes) + { + tnChild.Checked = true; + foreach (TreeNode tnGrandChild in tnChild.Nodes) + { + tnGrandChild.Checked = true; + } + } + } + } + } + } + + private void doLoadDataForGlobalControl1() + { + try + { + + globeControl1.Globe.Layers.MoveDown(10000); + //加载实测管线数据 + Utility.dataSource = globeControl1.Globe.DataManager.OpenOracleDataSource(Utility.DBServer.Trim() + "/" + Utility.dbdatabase.Trim(), "", "", Utility.userID, Utility.DBPassword); + + if (Utility.dataSource != null) + { + for (int j = 0; j < Utility.dataSource.DatasetCount; j++) + { + GSODataset dataset = Utility.dataSource.GetDatasetAt(j); + if (dataset != null && dictionaryNetLayerNameAndCaption.ContainsKey(dataset.Caption)) + { + dataset.Caption = dataset.Name; + globeControl1.Globe.Layers.Add(dataset); + } + } + } + //隐藏红线图层 + globeControl1.Globe.Layers.GetLayerByCaption("红线").Visible = false; + + //globleControl1中加载规划数据 + GSODataSource ghDS = globeControl1.Globe.DataManager.OpenOracleDataSource(Utility.ghdbip + "/" + Utility.ghdbname, "", "", Utility.ghdbuser, Utility.ghdbpwd); + if (ghDS != null) + { + for (int j = 0; j < ghDS.DatasetCount; j++) + { + GSODataset dataset = ghDS.GetDatasetAt(j); + if (dataset != null && dictionaryNetLayerNameAndCaption.ContainsKey(dataset.Caption)) + { + dataset.Caption = dataset.Name; + globeControl1.Globe.Layers.Add(dataset); + globeControl1.Globe.Layers[0].Visible = false; + } + } + } + + //globeControl1,globeControl2中加载施工数据 + GSODataSource sgDS = globeControl1.Globe.DataManager.OpenOracleDataSource(Utility.sgdbip + "/" + Utility.sgdbname, "", "", Utility.sgdbuser, Utility.sgdbpwd); + if (sgDS != null) + { + for (int m = 0; m < sgDS.DatasetCount; m++) + { + GSODataset dataset = sgDS.GetDatasetAt(m); + if (dataset != null && !dataset.Caption.Contains("SH") && dictionaryNetLayerNameAndCaption.ContainsKey(dataset.Caption)) + { + dataset.Caption = dataset.Name; + globeControl1.Globe.Layers.Add(dataset); + globeControl1.Globe.Layers[0].Visible = false; + + globeControl2.Globe.Layers.Add(dataset); + globeControl2.Globe.Layers[0].Visible = true; + } + } + } + + LoadDataForGlobalControl ss = new LoadDataForGlobalControl(connectServer); + ss(); + + } + catch (Exception ex) + { + MessageBox.Show(ex.Message); + } + } + + private void initLayerTree() + { + //加载临时图层节点 + layerManagerNode = new TreeNode(); + layerManagerNode.ImageIndex = 0; + layerManagerNode.SelectedImageIndex = 0; + layerManagerNode.Checked = true; + layerManagerNode.Text = "临时图层"; + layerTree.Nodes.Add(layerManagerNode); + + XmlDocument doc = new XmlDocument(); + doc.Load(filename); + XmlNodeList xmlLayerNodes = doc.SelectNodes("//layer"); + + foreach (XmlNode xmlLayerNode in xmlLayerNodes) + { + + //TODO LIST:创建一级TreeNode(实测、规划、施工) + TreeNode nodelayer = new TreeNode(); + string layerName = xmlLayerNode.Attributes["label"].Value; + nodelayer.Text = layerName; + nodelayer.Checked = false; + layerTree.Nodes.Add(nodelayer); + + XmlNodeList xmlChildLayerNodes = xmlLayerNode.ChildNodes; + foreach (XmlNode xmlChildLayerNode in xmlChildLayerNodes) + { + //TODO LIST:创建二级TreeNode节点 + TreeNode secondLevelNode = new TreeNode(); + string layerType = xmlChildLayerNode.Attributes["label"].Value; + secondLevelNode.Text = layerType; + + if (xmlChildLayerNode.Attributes["type"] != null) + { //道路图层特殊处理 + string type = xmlChildLayerNode.Attributes["type"].Value; + secondLevelNode.Tag = type + "|" + layerType; + } + else + { + secondLevelNode.Tag = layerType; + } + secondLevelNode.Checked = false; + nodelayer.Nodes.Add(secondLevelNode); + + XmlNodeList xmlActitualLayerNodes = xmlChildLayerNode.ChildNodes; + + foreach (XmlNode xmlActitualLayerNode in xmlActitualLayerNodes) + { + //TODO LIST:创建三级图层节点 + TreeNode layerNode = new TreeNode(); + string actutallylayerType = xmlActitualLayerNode.Attributes["type"].Value; + string actutallylayerName = xmlActitualLayerNode.Attributes["layer"].Value; + string actutallyLabelName = xmlActitualLayerNode.Attributes["label"].Value; + + layerNode.Text = actutallyLabelName; + layerNode.Tag = layerType + "|" + actutallyLabelName; + layerNode.Checked = false; + secondLevelNode.Nodes.Add(layerNode); + } + + } + + } + + } + + /** + * 读取Config.xml文件,初始化以下全局Map + * m_PipelineLayerNames:管线 + * workwellLayerNames:工井 + * valueLayerNames:阀门 + * instrumenLayerNames:附属物 + * pipefittingLayerNames:特征管点 + * sgPipeLayersNames:施工管线 + **/ + private void initGlobalMap() + { + XmlDocument doc = new XmlDocument(); + doc.Load(filename); + XmlNodeList xmlLayerNodes = doc.SelectNodes("//layerchild"); + + foreach (XmlNode xmlLayerNode in xmlLayerNodes) + { + string layerType = xmlLayerNode.Attributes["type"].Value; + string layerName1 = xmlLayerNode.Attributes["layer"].Value; + string layerchildName = xmlLayerNode.Attributes["label"].Value; + + dictionaryNetLayerNameAndCaption.Add(layerName1, layerchildName); + + if (layerType != "db") + { + if (xmlLayerNode.Attributes["isRoad"] != null) + { + roadLayerName = layerchildName; + } + } + else if (xmlLayerNode.Attributes["isPipeLine"] != null) + { + m_PipelineLayerNames.Add(layerchildName); + g1layername.Add(layerName1); + } + else if (xmlLayerNode.Attributes["isWorkWell"] != null) + { + workwellLayerNames.Add(layerchildName); + g1layername.Add(layerName1); + } + else if (xmlLayerNode.Attributes["isValve"] != null) + { + valueLayerNames.Add(layerchildName); + g1layername.Add(layerName1); + } + else if (xmlLayerNode.Attributes["isAccess"] != null) + { + instrumenLayerNames.Add(layerchildName); + g1layername.Add(layerName1); + } + else if (xmlLayerNode.Attributes["isCharacter"] != null) + { + pipefittingLayerNames.Add(layerchildName); + g1layername.Add(layerName1); + } + else if (xmlLayerNode.Attributes["isSgData"] != null) + { + sgPipeLayersNames.Add(layerchildName); + g1layername.Add(layerName1); + } + + } + } + + private void initMarkerTree() + { + 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); + } + } + } + } + + private void MainFrm_Load(object sender, EventArgs e) + { + + this.initGlobalControl(); + this.initGlobalMap(); + this.initLayerTree(); + this.initMarkerTree(); + this.initLayout(); + this.loadData(); + + + double x = Convert.ToDouble(Utility.Query_Roads["绿岛"].ToString().Split(',')[0]); + double y = Convert.ToDouble(Utility.Query_Roads["绿岛"].ToString().Split(',')[1]); + double z = Convert.ToDouble(Utility.Query_Roads["绿岛"].ToString().Split(',')[2]); + jumpToCameraState(x, y, z); + + + } + + #endregion + + /// + /// 每次gis服务加载时都会触发的 + /// + /// + /// + 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 dictionaryNetLayerNameAndCaption = new Dictionary(); + 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 配置用户权限 + /// + /// 向数据库插入功能列表 + /// + private void insertControlToDatabase() + { + ArrayList listItem = new ArrayList(); + List subListItem = new List(); + 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) + { + GSOCameraState camera = globeControl2.Globe.CameraState; + globeControl1.Globe.JumpToCameraState(camera); + } + } + + void globeControl1_BeforeSceneRenderEvent(object sender, BeforeSceneRenderEventArgs e) + { + if (globeControl1.Focused) + { + 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); + } + } + } + + /// + /// 检查数据集是否有坐标系信息 + /// + /// + /// + 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 = "0prj4" + lprjStr + ""; + + bSuccess = dataset.LoadProjectionFromESRIFile(dlg.FileName); + + string lprjFileName = strDataPath.Substring(0, strDataPath.LastIndexOf(".")) + ".lprj"; + StreamWriter writer = new StreamWriter(lprjFileName, false); + writer.Write(lprjFileContent); + writer.Close(); + + } + } + } + else + { + return true; + } + return bSuccess; + } + + /// + /// 矩形拉框结束事件处理函数 + /// + /// + /// + 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))); + */ + + int mapWidth = 0; + int mapHeight = 0; + Point pt = getUpperLeftPoint(pt1, pt2, out mapWidth, out mapHeight); + int rightBottomX = pt.X + mapWidth; + int rightBottomY = pt.Y + mapHeight; + Image myImg = new Bitmap(mapWidth, mapHeight); + Graphics g = Graphics.FromImage(myImg); + g.CopyFromScreen(pt, new Point(0, 0), new Size(rightBottomX, rightBottomY)); + + 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; + } + } + /// + /// 定位正北正90度俯视 + /// + /// + /// + /// + 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; + } + } + /// + /// layerTree选中后事件处理 + /// + /// + /// + 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); + } + /// + /// 树节点选中方法 + /// + /// + 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); + } + } + } + + } + /// + /// 改变所有子节点的状态 + /// + /// + /// + 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; + LayerFlyMenuItem.Visible = true; + } + + LayerSelectableMenuItem.Visible = true; + LayerEditableMenuItem.Visible = true; + SaveLayerMenuItem.Visible = true; + LayerFlyMenuItem.Visible = true; + 导出CADToolStripMenuItem1.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]); + if (layer != null) + { + LayerSelectableMenuItem.Checked = layer.Selectable; + LayerEditableMenuItem.Checked = layer.Editable; + } + else + { + return; + } + } + 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; + } + } + } + } + } + + /// + /// 删除临时添加的本地数据图层 + /// + /// + /// + 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); + for (int i = globeControl1.Globe.Layers.Count-1; i >=0; i--) + { + if (globeControl1.Globe.Layers[i].Caption == layer.Caption) + { + globeControl1.Globe.Layers.Remove(globeControl1.Globe.Layers[i]); + } + } + + 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 定位ToolStripMenuItem_Click(object sender, EventArgs e) + { + TreeNode node = layerTree.SelectedNode; + + if (node != null) + { + if (node.Parent.Text.Trim() == "临时图层") + { + GSOLayer lsLayer = globeControl1.Globe.Layers.GetLayerByCaption(node.Text.ToString()); + double x = lsLayer.LatLonBounds.Center.X; + double y = lsLayer.LatLonBounds.Center.Y; + if (x == 0 && y == 0) + { + x = lsLayer.Bounds.Center.X; + y = lsLayer.Bounds.Center.Y; + } + + globeControl1.Globe.FlyToPosition(new GSOPoint3d(x, y, 10), EnumAltitudeMode.Absolute); + } + else + { + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(node.Tag.ToString().Split('|')[1]); + + if (layer != null) + { + if (layer.Caption == "红线") + { + globeControl1.Globe.FlyToPosition(new GSOPoint3d(120.610963, 31.188121, 50), EnumAltitudeMode.Absolute, -4, 50, 1000); + globeControl1.Globe.FlyToPointSpeed = 10000000; + globeControl1.Globe.Action = EnumAction3D.SelectObject; + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = true; + } + globeControl1.Refresh(); + } + else + { + double x = layer.LatLonBounds.Center.X; + double y = layer.LatLonBounds.Center.Y; + globeControl1.Globe.FlyToPosition(new GSOPoint3d(x, y, 100), EnumAltitudeMode.Absolute); + } + } + } + } + else + { + return; + } + + } + + private void layerTree_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e) + { + if(this.layerTree.SelectedNode!=null) + { + if (this.layerTree.SelectedNode.Tag.ToString().Contains("|")) + { + string nodeTag = this.layerTree.SelectedNode.Tag.ToString().Split('|')[1]; + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(nodeTag); + if (layer != null) + { + if (layer.Caption == "红线") + { + globeControl1.Globe.FlyToPosition(new GSOPoint3d(120.610963, 31.188121, 50), EnumAltitudeMode.Absolute, -4, 50, 1000); + globeControl1.Globe.FlyToPointSpeed = 10000000; + globeControl1.Globe.Action = EnumAction3D.SelectObject; + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = true; + } + globeControl1.Refresh(); + } + else { + double x = layer.LatLonBounds.Center.X; + double y = layer.LatLonBounds.Center.Y; + globeControl1.Globe.FlyToPosition(new GSOPoint3d(x, y, 0), EnumAltitudeMode.Absolute); + } + } + } + if (this.layerTree.SelectedNode.Tag is GSOLayer) + { + GSOLayer layer = this.layerTree.SelectedNode.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 (this.layerTree.SelectedNode.Tag is GSOFeature) + { + GSOFeature feature = this.layerTree.SelectedNode.Tag as GSOFeature; + if (feature.Geometry != null) + { + globeControl1.Globe.FlyToPosition(feature.Geometry.GeoCenterPoint, EnumAltitudeMode.Absolute, 0, 0, 10); + } + else + { + globeControl1.Globe.FlyToFeature(feature); + } + } + } + } + + /// + /// 在三维场景移动时,隐藏气泡globeControl1 + /// + /// + /// + void globeControl1_CameraBeginMoveEvent(object sender, CameraBeginMoveEventArgs e) + { + if (featureTooltip.IsVisible()) + { + featureTooltip.HideBalloon(); + } + if (balloonEx.IsVisible()) + { + balloonEx.HideBalloon(); + } + } + + /// + /// 在三维场景移动时,隐藏气泡globeControl2 + /// + /// + /// + void globeControl2_CameraBeginMoveEvent(object sender, CameraBeginMoveEventArgs e) + { + if (featureTooltip2.IsVisible()) + { + featureTooltip2.HideBalloon(); + } + if (balloonEx2.IsVisible()) + { + balloonEx2.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(); + } + } + + #region Fan 横断面 + /// + /// 横断面分析、基线剖面分析、道路断面分析等 + /// + /// + /// + private static EnumTrackPolylineEndMode trackPolylineEndMode; + + void globeControl1_TrackPolylineEndEvent(object sender, TrackPolylineEndEventArgs e) + { + //横断面分析、道路横断面分析 + if (trackPolylineEndMode == EnumTrackPolylineEndMode.HDM_Analysis|| + trackPolylineEndMode == EnumTrackPolylineEndMode.DLDM_Analysis) + { + Dictionary hdmDic = SectionAnalysisTool.HDMAnalysis(this.globeControl1, + e.Polyline, this.m_PipelineLayerNames); + FrmHDMAnalysis3 frm = new FrmHDMAnalysis3(hdmDic, this.globeControl1, + trackPolylineEndMode); + frm.Show(this); + } + //基线剖面分析 + else if (trackPolylineEndMode == EnumTrackPolylineEndMode.JXPM_Analysis) + { + FrmBaseLineProfillAnalysis dlg = new FrmBaseLineProfillAnalysis(globeControl1.Globe, e.Polyline); + dlg.Show(this); + globeControl1.Globe.ClearLastTrackPolyline(); + /* + FrmRoadHDM f = new FrmRoadHDM(); + f.Show() + * **/ + } + else + { + + } + trackPolylineEndMode = EnumTrackPolylineEndMode.Default_Analysis; + /* + ArrayList arraylistPoint = new ArrayList(); + ArrayList arraylistLine = new ArrayList(); + + // globeControl1.Globe.ClearLastTrackPolyline(); + + if (e.Polyline != null) + { + //横断面分析 + if (buttonItemFX2_1.Checked || buttonItemFX2_3.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 (buttonItemFX2_1.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 (buttonItemFX2_4.Checked) + { + FrmBaseLineProfillAnalysis dlg = new FrmBaseLineProfillAnalysis(globeControl1.Globe, e.Polyline); + dlg.Show(this); + globeControl1.Globe.ClearLastTrackPolyline(); + } + else if (buttonItemFX4_3.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(); + * **/ + } + #endregion + + private GSOFeatures PolygonIntersectAnalysis(GSOGeoPolygon3D polygon, string pipelinetype) + { + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(pipelinetype); + 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(pipelinetype, feats.Length); + return feats; + } + /// + /// 根据范围统计阀门、管线、工井等, 开挖分析, 挖方量分析 + /// + /// + /// + void globeControl1_TrackPolygonEndEvent(object sender, TrackPolygonEndEventArgs e) + { + if (globeControl1.Globe.Action == EnumAction3D.TrackPolygon && e.Polygon != null) + { + GSOGeoPolygon3D polygon = e.Polygon; + + switch (trackflag) + { + case "valvequery": + FrmValveStatistics frm = new FrmValveStatistics(globeControl1,polygon, new DataGridViewDelegate(InitDataGridViewX1)); + frm.Show(this); + //panelEx6.Visible = true; + toolStripFeatureLength.Text = ""; + globeControl1.Globe.Action = EnumAction3D.ActionNull; + break; + + case "PipelineDistanceStatistics": + + FrmAllPipelineStatis frm1 = new FrmAllPipelineStatis(globeControl1, polygon, new DataGridViewDelegate(InitDataGridViewX1), m_PipelineLayerNames); + frm1.Show(this); + globeControl1.Globe.Action = EnumAction3D.ActionNull; + + break; + case "PipelineSpatialQuery": + + FrmAllPipelineStatis.ShowForm(globeControl1,polygon,new DataGridViewDelegate(InitDataGridViewX1),m_PipelineLayerNames); + globeControl1.Globe.ClearAnalysis(); + globeControl1.Globe.Action = EnumAction3D.ActionNull; + + break; + case "workwellquery": + FrmAllWorkWellStatis frmWell = new FrmAllWorkWellStatis(globeControl1, polygon, new DataGridViewDelegate(InitDataGridViewX1)); + 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 "BSQDuoBianXiangStatis": + + //GSOFeature f2 = new GSOFeature(); + //f2.Geometry = e.Polygon; + //f2.Geometry.AltitudeMode = EnumAltitudeMode.Absolute; + //globeControl1.Globe.MemoryLayer.AddFeature(f2); + //f2.Geometry.MoveZ(3); + //workWellLen.Clear(); + //List listBSQ = new List(); + + //GSOFeatures bsqFeatures = PolygonIntersectAnalysis(e.Polygon, "标识器"); + //listBSQ.Add(bsqFeatures); + + //FrmBSQDuoBianXingStatis bsqFrm = new FrmBSQDuoBianXingStatis(workWellLen, globeControl1, listBSQ); + FrmBSQStatis bsqFrm = new FrmBSQStatis(globeControl1,e.Polygon); + bsqFrm.Show(this); + globeControl1.Globe.Action = EnumAction3D.ActionNull; + break; + + case "": + break; + default: + break; + } + } + } + + #region 验证端口 + /* + /// + /// 验证端口 + /// + /// + 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 + + /// + /// 鼠标悬浮提示 + /// + /// + /// + 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); + } + } + + /// + /// 添加管线绘制完成事件, 红线工具绘制完成 + /// + /// + /// + 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; + + + } + } + + /// + /// 获取globeControl1中鼠标按下的坐标供区别鼠标右键和滚轮按下事件 + /// + /// + /// + void globeControl1_MouseDown(object sender, MouseEventArgs e) + { + mouseDownX1 = e.X; + mouseDownY1 = e.Y; + } + /// + /// 获取globeControl2中鼠标按下的坐标供区别鼠标右键和滚轮按下事件 + /// + /// + /// + void globeControl2_MouseDown(object sender, MouseEventArgs e) + { + mouseDownX2 = e.X; + mouseDownY2 = e.Y; + } + /// + /// + /// + /// + /// + void globeControl2_MouseClick(object sender, MouseEventArgs e) + { + if (e.Button == MouseButtons.Right) + { + if (e.X == mouseDownX2 && e.Y == mouseDownY2) + { + RightScreenToolMenu.Show(globeControl2, e.X, e.Y); + } + else + { + return; + } + } + } + /// + /// + /// + /// + /// + void globeControl1_MouseClick(object sender, MouseEventArgs e) + { + if (e.Button == MouseButtons.Left) + { + if (globeControl1.Globe.Action == EnumAction3D.VisibilityAnalysis) + { + buttonItemFX5_1.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; + + bsqPT = pt; + + if (buttonItemLS5.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 (e.X == mouseDownX1 && e.Y == mouseDownY1) + { + toolRightMenu.Show(globeControl1, e.X, e.Y); + if (buttonItemLS5.Checked) + { + buttonItemLS5.Checked = false; + } + } + else + { + return; + } + } + globeControl1.Refresh(); + } + + /// + /// 判断网络图片是否存在 + /// + /// + /// + 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; + } + + /// + /// 鼠标点击, 弹出气泡功能globeControl1 + /// + /// + /// + void globeControl1_FeatureMouseClickEvent(object sender, FeatureMouseClickEventArgs e) + { + GSOFeature feature = e.Feature; + + string str1 = ""; + if (feature != null) + { + if (feature.GetFieldDefn("图片编码") != null)// + { + str1 = GetBubbleInfo(feature, globeControl1); + if (RemoteFileExists(Utility.PicRootURL + feature.GetValue("图片编码").ToString())) + { + str1 += ""; + } + else if (RemoteFileExists(Utility.PicDefaultURL)) + { + str1 += ""; + } + } + else if (isFeatureContainsBianhao(feature)) //管线模型图层 + { + str1 = GetBubbleInfo(feature, globeControl1); + } + + 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; + } + } + } + + /// + /// 鼠标点击, 弹出气泡功能globeControl2 + /// + /// + /// + void globeControl2_FeatureMouseClickEvent(object sender, FeatureMouseClickEventArgs e) + { + GSOFeature feature = e.Feature; + + string str1 = ""; + if (feature != null) + { + if (feature.GetFieldDefn("图片编码") != null) // + { + str1 = GetBubbleInfo(feature, globeControl2); + if (RemoteFileExists(Utility.PicRootURL + feature.GetValue("图片编码").ToString())) + { + str1 += ""; + } + else if (RemoteFileExists(Utility.PicDefaultURL)) + { + str1 += ""; + } + } + else if (isFeatureContainsBianhao(feature)) //管线模型图层 + { + str1 = GetBubbleInfo(feature, globeControl2); + } + + if (str1 != "") + { + + featureTooltip2.HideBalloon(); + balloonEx2.HideBalloon(); + balloonEx2.SetSize(EnumSizeIndexEx.CONTENT_CX, 480); + balloonEx2.SetSize(EnumSizeIndexEx.CONTENT_CY, 420); + balloonEx2.ShowBalloon((int)e.MousePos.X, (int)e.MousePos.Y, str1); + + return; + } + } + } + + /// + /// 拼接气泡表格字符串 + /// + /// + /// + private string GetBubbleInfo(GSOFeature feature,GSOGlobeControl globeControl) + { + if (feature == null) + { + return ""; + } + string str = ""; + str = ""; + 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 += ""; + + 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.get_Fields(layerName, globeControl); + } + if (queryFields != null) + { + string[] param = { "," }; + string[] fieldNames = queryFields.Split(param, StringSplitOptions.RemoveEmptyEntries); + for (int j = 0; j < fieldNames.Length; 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 (name1 == "模型路径") + { + continue; + } + 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 (field1.Type == EnumFieldType.Double) + { + double dl1 = feature.GetFieldAsDouble(j); + if (!name1.Contains("管径") && !name1.Contains("电压") && !name1.Contains("角度")) + { + name1 += "_米"; + } + value1 = dl1.ToString("0.00"); + } + 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 (name2 == "模型路径") + { + continue; + } + + 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 (field2.Type == EnumFieldType.Double) + { + double dl2 = feature.GetFieldAsDouble(j + 1); + if (!name2.Contains("管径") && !name2.Contains("电压") && !name2.Contains("角度")) + { + name2 += "_米"; + } + value2 = dl2.ToString("0.00"); + } + else + { + if (!feature.IsFieldValueNull(j + 1)) + { + value2 = feature.GetValue(j + 1).ToString(); + } + } + } + } + + j++; + } + str += ""; + } + } + str += "
" + title + " " + feature.GetFieldAsString(featureIDFieldName) + "
" + + name1 + + "
" + + value1 + + "
" + + name2 + + "
" + + value2 + "
"; + return str; + } + + string filename = Utility.filename; + List g1layername = new List(); + + /// + /// 获取目标图层 + /// + /// + 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; + } + /// + /// 添加图层 + /// + /// + /// + /// + 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 = 5000; + return templayer.Visible; + } + catch (Exception ex) + { + return false; + } + } + /// + /// 菜单上的 三维导航 工具按钮 + /// + /// + /// + private void buttonItem86_Click(object sender, EventArgs e) + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + } + + /// + /// 地上模式 菜单按钮 + /// + /// + /// + 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(); + + } + } + /// + /// 地下模式 菜单按钮 + /// + /// + /// + 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(); + } + } + /// + /// 行走模式 菜单按钮 + /// + /// + /// + 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; + } + } + /// + /// 地面透明度设置 菜单 + /// + /// + /// + private void sliderGroundTransSet1_ValueChanged(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.sliderGroundTransSet1.Text); + + globeControl1.Globe.GroundOpaque = 100 - sliderGroundTransSet1.Value; + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(roadLayerName);//("180fd"); + if (layer != null) + { + layer.Opaque = 100 - sliderGroundTransSet1.Value; + } + //if (buttonItemSPDB.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; + } + /// + /// 图例 菜单按钮 + /// + /// + /// + 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(); + } + /// + /// 快速定位 菜单按钮 + /// + /// + /// + private void buttonItem91_Click(object sender, EventArgs e) // + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItem91.Text); + FrmFlyToPosition fly = new FrmFlyToPosition(globeControl1); + fly.Show(this); + } + /// + /// 图层管理 菜单按钮 + /// + /// + /// + 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; + + //修改图层管理与标注管理、覆土审查、水平净距分析、垂直净距分析和碰撞分析控件之间的逻辑关系 + controlContainerItem5.Visible = false; + sideBar1.Visible = false; + sideBarPanelItem4.Visible = false; + panel3.Visible = false; + sideBar1.ExpandedPanel = sideBarPanelItem3; + buttonItemBZ11.Checked = false; + + //20160624 + /* + if (sideBarPanelItem4.Visible == true) + { + sideBar1.Visible = true; + controlContainerItem5.Visible = true; + } + else + { + sideBar1.Visible = false; + } + */ + Refresh(); + + } + } + /// + /// 全屏显示 菜单按钮 + /// + /// + /// + 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; + /// + /// 全屏显示功能实现 + /// + 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(); + } + } + + /// + /// 设置窗体宽、高 + /// + /// + /// + private void SetFullScreen(int width, int height) + { + this.Width = width; + this.Height = height; + } + + /// + /// 全屏功能的快捷键F5 + /// + /// + /// + 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); + } + } + /* + /// + /// 输出地图 + /// + /// + /// + /// + 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; + } + * */ + + private Point getUpperLeftPoint(Point p1, Point p2, out int mapWidth, out int mapHeight) // + { + Rectangle rc = new Rectangle(); + + p1 = this.globeControl1.PointToScreen(p1); + p2 = this.globeControl1.PointToScreen(p2); + + int x = Screen.PrimaryScreen.Bounds.X; + int y = Screen.PrimaryScreen.Bounds.Y; + int screenWidth = SystemInformation.WorkingArea.Width; + int screenHeight = SystemInformation.WorkingArea.Height; + + if (p1.X < x) + rc.X = x; + else + rc.X = p1.X; + + if (p1.Y < y) + rc.Y = y; + else + rc.Y = p1.Y; + + p1.X = rc.Left; + p1.Y = rc.Top; + + if (p2.X > screenWidth) + p2.X = screenWidth; + else + p2.X = p2.X; + + if (p2.Y > screenHeight) + p2.Y = screenHeight; + else + p2.Y = p2.Y; + + rc.Width = p2.X - rc.X; + rc.Height = p2.Y - rc.Y; + + mapWidth = rc.Width; + mapHeight = rc.Height; + Point pt = new Point(rc.Left, rc.Top); + return pt; + } + + Image printImage; + /// + /// 打印 菜单 + /// + /// + /// + 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))); + */ + int mapWidth = 0; + int mapHeight = 0; + Point pt = getUpperLeftPoint(pt1, pt2, out mapWidth, out mapHeight); + int rightBottomX = pt.X + mapWidth; + int rightBottomY = pt.Y + mapHeight; + Image myImg = new Bitmap(mapWidth, mapHeight); + Graphics g = Graphics.FromImage(myImg); + g.CopyFromScreen(pt, new Point(0, 0), new Size(rightBottomX, rightBottomY)); + + + 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); + } + /// + /// 输出地图 菜单 + /// + /// + /// + private void btnOutputJPG_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btnOutputJPG.Text); + + //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))); + */ + int mapWidth = 0; + int mapHeight = 0; + Point pt = getUpperLeftPoint(pt1, pt2, out mapWidth, out mapHeight); + int rightBottomX = pt.X + mapWidth; + int rightBottomY = pt.Y + mapHeight; + Image myImg = new Bitmap(mapWidth, mapHeight); + Graphics g = Graphics.FromImage(myImg); + g.CopyFromScreen(pt, new Point(0, 0), new Size(rightBottomX, rightBottomY)); + + 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; + } + } + } + + /// + /// 在窗体的底部状态栏上显示 综合管线条件查询结果 + /// + /// + /// + 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 + " 条记录 | "; + } + } + + /// + /// 统计管线的里程数 + /// + /// + /// + /// + 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; + } + + /// + /// 窗体下方属性表格 右键菜单中的 “定位”菜单 + /// + /// + /// + 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); + + } + + /// + /// 表格中右键 “单个闪烁” 菜单 + /// + /// + /// + private void LightMenu_Click(object sender, EventArgs e) + { + flashflag = "single"; + timer1.Start(); + } + /// + /// 表格中右键 “全部闪烁” 菜单 + /// + /// + /// + private void AllLightMenuItem_Click(object sender, EventArgs e) + { + flashflag = "all"; + timer1.Start(); + } + + /// + /// 使用timer实现管线的闪烁效果 + /// + /// + /// + 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; + } + } + + /// + /// 绘制线 菜单 + /// + /// + /// + private void btnAddLine_Click(object sender, EventArgs e) + { + globeControl1.Globe.DestLayerFeatureAdd = globeControl1.Globe.MemoryLayer; + globeControl1.Globe.Action = EnumAction3D.DrawPolyline; + } + /// + /// 绘制面 菜单 + /// + /// + /// + private void btnAddPolygon_Click(object sender, EventArgs e) + { + globeControl1.Globe.DestLayerFeatureAdd = globeControl1.Globe.MemoryLayer; + globeControl1.Globe.Action = EnumAction3D.DrawPolygon; + } + /// + /// 图层目录树 右键菜单中的 目标图层 菜单 + /// + /// + /// + 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; + } + } + /// + /// 图层目录树 右键菜单中的 可选择 菜单 + /// + /// + /// + 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; + } + /// + /// 图层目录树 右键菜单中的 可编辑 菜单 + /// + /// + /// + 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; + } + /// + /// 图层目录树 右键菜单中的 保存 菜单 + /// + /// + /// + 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(); + } + + /// + /// 根据多边形范围统计管线的里程 + /// + /// + /// + /// 返回查询到的管线要素集合 + 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 pipeLineDis = new Dictionary(); + Dictionary workWellLen = new Dictionary(); + + + + + /// + /// 查找指定图层中在 指定范围内的feature对象集合 + /// + /// + /// + /// + 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; + } + /// + /// 清除结果 菜单 + /// + /// + /// + private void buttonItem47_Click(object sender, EventArgs e) + { + globeControl1.Globe.ClearAnalysis(); + dataGridViewX1.DataSource = null; + panelOfTable.Visible = false; + clearFeatureHighLight(); + } + /// + /// 设置菜单的选中状态 + /// + private void ActionToolMenuChecked() + { + if (globeControl1.Globe.Action != EnumAction3D.TrackPolyline) + { + buttonItemFX2_1.Checked = false; + buttonItemFX2_4.Checked = false; + buttonItemFX2_3.Checked = false; + buttonItemFX4_3.Checked = false; + } + if (globeControl1.Globe.Action != EnumAction3D.NormalHit) + { + buttonItemFX3_6.Checked = false; + // ClearConnexityAnalysis(); + + buttonItemFX3_5.Checked = false; + // ClearCloseValvesAnalysis(); + } + if (globeControl1.Globe.Action != EnumAction3D.TrackPolygon) + { + buttonItemFX4_2.Checked = false; + buttonItemFX4_1.Checked = false; + } + } + + /// + /// 主窗体关闭事件处理 + /// + /// + /// + private void MainFrm_FormClosing(object sender, FormClosingEventArgs e) + { + + if (MessageBox.Show("是否退出系统?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) + { + e.Cancel = true; + } + else { + globeControl1.Globe.MemoryLayer.SaveAs(Application.StartupPath + "/MyPlace.kml"); + } + + //saveLayerList(layerManagerNode.Nodes); + //注销id号为103的热键设定 + // UnregisterHotKey(Handle, 103); + } + + /// + /// 显示流向 功能 + /// + /// + /// + /// + 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(); + } + + FrmCloseValves frm; + + FrmBoosterValvers frmbooster = null; + + /// + /// 垂直净距分析 功能界面中的 选择图层复选框 选中状态改变事件处理 + /// + /// + /// + 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(); + } + /// + /// 水平净距分析 功能界面中的 选择图层复选框 选中状态改变事件处理 + /// + /// + /// + 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(); + } + /// + /// 垂直净距分析 功能界面中的 选择管线复选框 选中状态改变事件处理 + /// + /// + /// + private void checkBoxX1_CheckedChanged(object sender, EventArgs e) + { + clearFeatureHighLight(); + if (checkBoxX1.Checked) + { + comboBoxEx1.SelectedItem = null; + 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; + } + } + /// + /// 水平净距分析 功能界面中的 选择管线复选框 选中状态改变事件处理 + /// + /// + /// + private void checkBoxX1_CheckedChanged_shuiping(object sender, EventArgs e) + { + clearFeatureHighLight();//清除高亮 + if (checkBoxX7.Checked) + { + comboBoxEx4.SelectedItem = null; + 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(); + /// + /// 垂直净距分析 功能界面中的 选择图层下拉框 选中项改变 事件处理 + /// + /// + /// + 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; + } + } + } + /// + /// 水平净距分析 功能界面中的 选择图层下拉框 选中项改变 事件处理 + /// + /// + /// + 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 featCount = new Dictionary(); + Dictionary featLenth = new Dictionary(); + Dictionary m_FeaturesWithBianhao = new Dictionary();//记录编号和对应的标注点的位置 + GSOFeatures polygonJingJuAnalysises = new GSOFeatures(); + + /// + /// 垂直净距分析 功能界面中的 开始分析按钮 事件处理 + /// + /// + /// + 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; + } + + /// + /// 在指定的两点组成的线的中间添加一个marker对象,并将marker对象添加到指定的图层中 + /// + /// + /// + /// + /// + /// + 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; + } + + /// + /// 计算指定feature对象与除了该feature所在图层之外的 所有管线图层中的所有feature对象 的垂直距离 并在表格中记录符合要求的管线 + /// + /// + /// + /// + /// + private void VerticalDistanceAnalysis(string type, GSOFeature selectedFeature, List _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(); + } + /// + /// 垂直净距分析中 表格行的 双击定位 功能。 与覆土分析的实现方法不同,主要原因是需要标注垂距 + /// + /// + /// + 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); + } + } + } + } + + /// + /// 水平净距分析 功能界面中 开始分析按钮 的事件处理 + /// + /// + /// + 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; + } + + + /// + /// 计算指定feature对象与除了该feature所在图层之外的 所有管线图层中的所有feature对象 的水平距离 并记录符合要求的管线 功能 + /// + /// + /// + /// + /// + private void HorizontalDistanceAnalysis(GSOFeature selectedFeature, List _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)); + } + } + } + } + } + /// + /// 水平净距分析 功能界面中 表格的 双击定位 功能 + /// + /// + /// + 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); + } + } + } + } + } + /// + /// 碰撞分析 功能界面中 开始分析按钮 事件处理 + /// + /// + /// + 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; + } + /// + /// 碰撞分析功能界面中 表格的 双击定位 功能 + /// + /// + /// + 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); + } + } + } + } + + + + /// + /// 覆土分析功能操作界面中的 选择管线 复选框选中状态改变事件处理 + /// + /// + /// + private void checkBoxX5_CheckedChanged(object sender, EventArgs e) + { + clearFeatureHighLight(); + if (checkBoxX5.Checked) + { + comboBoxEx3.SelectedItem = null; + 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; + } + } + /// + /// 覆土分析功能操作界面中的 选择图层 复选框选中状态改变事件处理 + /// + /// + /// + 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(); + } + /// + /// 覆土分析功能操作界面中的 图层下拉框选中项改变事件处理 + /// + /// + /// + 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; + } + } + } + /// + /// 覆土分析功能操作界面中的 开始分析 按钮事件处理 + /// + /// + /// + 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; + + + GSOPoint3d markerPosition = new GSOPoint3d(); + 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]; + GSOPoint3d pt = new GSOPoint3d(); + + 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"); + + pt.X = pts[m].X; + pt.Y = pts[m].Y; + pt.Z = 0; + markerPosition = LabelVerticalDistance(layerTemp, pts[m], pt, Convert.ToDouble(dataGridViewX7.Rows[idx].Cells[2].Value), true); + 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]; + GSOPoint3d pt = new GSOPoint3d(); + 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"); + + pt.X = pts[m].X; + pt.Y = pts[m].Y; + pt.Z = 0; + markerPosition = LabelVerticalDistance(layerTemp, pts[m], pt, Convert.ToDouble(dataGridViewX7.Rows[idx].Cells[2].Value), true); + + 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; + } + + /// + /// 覆土分析中 表格的 双击定位 功能 + /// + /// + /// + 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); + } + } + } + } + } + /// + /// 覆土分析功能操作界面中的 导出Excel按钮 事件处理 + /// + /// + /// + private void buttonX10_Click(object sender, EventArgs e) + { + if (dataGridViewX7.Rows.Count > 0) + { + ExportExcel("覆土分析", dataGridViewX7, null); + } + else + { + MessageBox.Show("表格内容为空!", "提示"); + } + } + /// + /// 覆土分析功能操作界面底部的 关闭 按钮事件处理 + /// + /// + /// + 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(); + layerTemp.RemoveAllFeature(); + + if (buttonItem1.Checked) + { + sideBar1.ExpandedPanel = sideBarPanelItem3; + } + else + { + sideBar1.Visible = false; + } + globeControl1.Refresh(); + + //Refresh(); + } + + + /// + /// 垂直净距分析 功能界面中 清除分析结果按钮 事件处理 + /// + /// + /// + 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(); + } + /// + /// 水平净距分析 功能界面中 清除分析结果按钮 事件处理 + /// + /// + /// + 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(); + } + + /// + /// 垂直净距分析功能界面中 关闭按钮 事件处理 + /// + /// + /// + 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(); + } + /// + /// 水平净距分析功能界面中 删除缓冲区按钮 事件处理 + /// + /// + /// + private void buttonX14_Click(object sender, EventArgs e) + { + 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(); + } + + /// + /// 导出指定DataGridView控件中的内容 + /// + /// + /// + 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(); + } + } + } + } + + /// + /// 垂直净距分析功能界面中 导出Excel按钮 事件处理 + /// + /// + /// + private void buttonX4_Click(object sender, EventArgs e) + { + if (dataGridViewX3.Rows.Count > 0) + { + ExportExcel("垂直净距分析", dataGridViewX3, listBox1); + } + else + { + MessageBox.Show("表格内容为空!", "提示"); + } + } + /// + /// 水平净距分析功能界面中 导出Excel按钮 事件处理 + /// + /// + /// + private void buttonX4_Click_shuiping(object sender, EventArgs e) + { + if (dataGridViewX9.Rows.Count > 0) + { + ExportExcel("水平净距分析", dataGridViewX9, listBox3); + } + else + { + MessageBox.Show("表格内容为空!", "提示"); + } + } + + + /// + /// 清除所有坑 菜单 + /// + /// + /// + private void buttonItem3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItem3.Text); + + globeControl1.Globe.RemoveAllPits(); + } + + //} + /// + /// 大气层 菜单 + /// + /// + /// + private void buttonItem17_Click_1(object sender, EventArgs e) + { + globeControl1.Globe.Atmosphere.Visible = !globeControl1.Globe.Atmosphere.Visible; + buttonItemSH1.Checked = globeControl1.Globe.Atmosphere.Visible; + globeControl1.Refresh(); + } + /// + /// 经纬网 菜单 + /// + /// + /// + private void buttonItem20_Click(object sender, EventArgs e) + { + globeControl1.Globe.LatLonGrid.Visible = !globeControl1.Globe.LatLonGrid.Visible; + buttonItemSH3.Checked = globeControl1.Globe.LatLonGrid.Visible; + globeControl1.Globe.Refresh(); + } + /// + /// 状态条 菜单 + /// + /// + /// + private void buttonItem21_Click_1(object sender, EventArgs e) + { + globeControl1.Globe.StatusBar.Visible = !globeControl1.Globe.StatusBar.Visible; + buttonItemSH4.Checked = globeControl1.Globe.StatusBar.Visible; + globeControl1.Globe.Refresh(); + } + + + + /// + /// 添加指定路径下的数据 功能 + /// + /// + /// + 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); + //CheckDatasetGeoReference(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; + } + return objRes; + } + /// + /// 刷新目录树 功能 + /// + 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); + } + } + /// + /// 判断图层是否包含字段列表 + /// + /// + /// + 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; + } + + /// + /// 统计指定图层在指定范围内的所有feature对象 + /// + /// + /// + /// + 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; + } + /// + /// 碰撞分析功能界面中 选择管线复选框 选中状态改变事件处理 + /// + /// + /// + private void checkBoxX3_CheckedChanged(object sender, EventArgs e) + { + clearFeatureHighLight(); + if (checkBoxX3.Checked) + { + comboBoxEx2.SelectedItem = null; + 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; + } + } + /// + /// 碰撞分析功能界面中 选择图层复选框 选中状态改变事件处理 + /// + /// + /// + 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(); + } + /// + /// 碰撞分析功能界面中 选择图层下拉框 选中项改变事件处理 + /// + /// + /// + 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; + } + } + } + /// + /// 清除所有图层中的所有feature对象的高亮状态 功能 + /// + 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); + } + } + } + } + for (int i = 0; i < globeControl2.Globe.Layers.Count; i++) + { + GSOLayer layer = globeControl2.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; + } + } + } + + if (globeControl1.Globe.Action == EnumAction3D.SelectObject) + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + //globeControl1.Globe.Action = EnumAction3D.SelectObject; + } + } + + /// + /// 碰撞分析功能界面中 清除分析结果按钮 事件处理 + /// + /// + /// + 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(); + } + /// + /// 碰撞分析功能界面中 导出Excel按钮 事件处理 + /// + /// + /// + private void buttonX6_Click(object sender, EventArgs e) + { + if (dataGridViewX5.Rows.Count > 0) + { + ExportExcel("碰撞分析", dataGridViewX5, listBox2); + } + else + { + MessageBox.Show("表格内容为空!", "提示"); + } + } + /// + /// 导出CAD 菜单 + /// + /// + /// + private void btnExportCAD_Click(object sender, EventArgs e) + { + FrmExportCADS frm = new FrmExportCADS(globeControl1, m_PipelineLayerNames); + frm.ShowDialog(); + } + + ///// + ///// 区域分析 菜单 + ///// + ///// + ///// + //private void buttonItem50_Click(object sender, EventArgs e) + //{ + // buttonItem50.Checked = !buttonItem50.Checked; + // ribbonBarQY.Visible = buttonItem50.Checked; + // ribbonBarQY.Location = new Point(0, 0); + //} + + + /// + /// 连接数据库 菜单事件处理 + /// + /// + /// + 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; + } + } + } + /// + /// 数据验证 菜单 + /// + /// + /// + private void buttonItem80_Click(object sender, EventArgs e) + { + FrmValiData frm = new FrmValiData(globeControl1); + frm.ShowDialog(); + } + /// + /// 根据指定图层创建图层节点并将节点添加到图层管理节点的子节点集合中 + /// + /// + 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; + + if (!layerManagerNode.Nodes.Contains(node)) + { + layerManagerNode.Nodes.Insert(0, node); + layerManagerNode.Expand(); + } + } + } + /// + /// 数据库备份 菜单 + /// + /// + /// + 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(); + } + } + } + + + + #region Fan 去掉 + //GSOFeature emitterFeature; // 粒子要素 + /// + /// 添加火苗 功能 + /// + /// + /// + /// + 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); + + } + /// + /// 添加喷泉 功能 + /// + /// + /// + /// + 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); + } + #endregion + + /// + /// 获取指定图层中最后一个feature对象的名称对应的整数 + /// + /// + /// + 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; + } + /// + /// 设置除指定标注图层之外的所有标注图层不可见 + /// + /// + 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; + } + } + } + } + } + + /// + /// 判断选中的对象是否为管线 + /// + /// 被选中管线 + /// 返回一根线 + 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; + } + + /// + /// 创建label要素 功能 + /// + /// 添加label要素的feature + /// feature的位置 + /// label要素名字 + /// feature名字 + /// label要素距离点的位置 + /// + 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; + } + + + + /// + /// 获取指定两点组成的线的长度 功能 + /// + /// + /// + /// + 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; + } + + /// + /// 图层节点树中 节点 右键单击事件处理 + /// + /// + /// + 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; + } + } + } + } + } + + /// + /// 标注管理、传感器管理 图层目录树的右键菜单中的 刷新列表 菜单 + /// + /// + /// + 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); + } + } + /// + /// 给指定的图层节点添加代表feature对象的子节点 + /// + /// + private void RefreshTreeNodeLayerFeatureList(TreeNode layerTreeNode) + { + layerTreeNode.Nodes.Clear(); + GSOLayer layer = (GSOLayer)layerTreeNode.Tag; + // 只将类型为内存数据集的图层列出,如果是其它类型的数据集可能数据量太大,没发显示在树控件中 + if (layer.Dataset is GSOFeatureDataset) + { + VisitFeature3Ds(layer.GetAllFeatures(), layerTreeNode); + } + } + + /// + /// 标注管理、传感器管理 图层目录树的右键菜单中的 移除所有 菜单 + /// + /// + /// + 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(); + } + } + + /// + /// 图层目录树的 节点对应的复选框选中状态改变事件处理 + /// + /// + /// + private void layerMarkerTree_AfterCheck(object sender, TreeViewEventArgs e) + { + if (e.Action != TreeViewAction.Unknown) + { + CheckTreeNode(e.Node, e.Node.Checked); + } + } + /// + /// 改变指定节点对应的复选框的选中状态 + /// + /// + /// + private void CheckTreeNode(TreeNode node, Boolean bChecked) + { + CheckChildTreeNode(node, bChecked); + globeControl1.Globe.Refresh(); + } + /// + /// 改变指定节点的子节点对应的复选框的选中状态 + /// + /// + /// + 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); + } + } + /// + /// 标注管理、传感器管理 目录树中的feature节点的右键菜单中的 删除 菜单 + /// + /// + /// + 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(); + } + } + + /// + /// 双屏对比 菜单 + /// + /// + /// + //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(); + // } + //} + /// + /// 模拟分析 菜单 + /// + /// + /// + //private void buttonItem51_Click(object sender, EventArgs e) + //{ + // buttonItem51.Checked = !buttonItem51.Checked; + // ribbonBarMN.Visible = buttonItem51.Checked; + // ribbonBarMN.Location = new Point(0, 0); + //} + + /// + /// 双屏设置 菜单 + /// + /// + /// + //private void buttonItem96_Click(object sender, EventArgs e) + //{ + // FrmLayerControl frm = new FrmLayerControl(layerTree,globeControl1,globeControl2); + // frm.Show(this); + //} + /// + /// 双屏联动 菜单 + /// + /// + /// + //private void buttonItem95_Click(object sender, EventArgs e) + //{ + // buttonItem95.Checked = !buttonItem95.Checked; + //} + ///// + /// 添加用户仓库 菜单 + /// + /// + /// + private void buttonItem108_Click(object sender, EventArgs e) + { + FrmUserRepo frm = new FrmUserRepo(-1); + frm.ShowDialog(); + } + /// + /// 用户仓库管理 菜单 + /// + /// + /// + private void buttonItem111_Click(object sender, EventArgs e) + { + FrmUserRepoMgr frm = new FrmUserRepoMgr(); + frm.ShowDialog(); + } + /// + /// 添加分系统 菜单 + /// + /// + /// + private void buttonItem112_Click(object sender, EventArgs e) + { + //FrmAPP frm = new FrmAPP(-1); + //frm.ShowDialog(); + } + /// + /// 分系统管理 菜单 + /// + /// + /// + private void buttonItem113_Click(object sender, EventArgs e) + { + //FrmAPPMgr frm = new FrmAPPMgr(); + //frm.ShowDialog(); + } + /// + /// 添加操作 菜单 + /// + /// + /// + private void buttonItem114_Click(object sender, EventArgs e) + { + FrmOper frm = new FrmOper(-1); + frm.ShowDialog(); + } + /// + /// 操作管理 菜单 + /// + /// + /// + private void buttonItem115_Click(object sender, EventArgs e) + { + FrmOperMgr frm = new FrmOperMgr(); + frm.ShowDialog(); + } + /// + /// 添加资源 菜单 + /// + /// + /// + private void buttonItem116_Click(object sender, EventArgs e) + { + FrmRESC frm = new FrmRESC(-1); + frm.ShowDialog(); + } + /// + /// 资源管理 菜单 + /// + /// + /// + private void buttonItem117_Click(object sender, EventArgs e) + { + FrmRESCMgr frm = new FrmRESCMgr(); + frm.ShowDialog(); + } + /// + /// 添加权限 菜单 + /// + /// + /// + private void buttonItem118_Click(object sender, EventArgs e) + { + FrmPerm frm = new FrmPerm(-1); + frm.ShowDialog(); + } + /// + /// 权限管理 菜单 + /// + /// + /// + private void buttonItem119_Click(object sender, EventArgs e) + { + FrmPermMgr frm = new FrmPermMgr(); + frm.ShowDialog(); + } + /// + /// 添加访问控制 菜单 + /// + /// + /// + private void buttonItem120_Click(object sender, EventArgs e) + { + FrmAccess frm = new FrmAccess(-1); + frm.ShowDialog(); + } + /// + /// 访问控制管理 菜单 + /// + /// + /// + private void buttonItem121_Click(object sender, EventArgs e) + { + FrmAccessMgr frm = new FrmAccessMgr(); + frm.ShowDialog(); + } + /// + /// 部门类型管理 菜单 + /// + /// + /// + private void buttonItem122_Click(object sender, EventArgs e) + { + FrmRegionTypeMgr frm = new FrmRegionTypeMgr(); + frm.ShowDialog(); + } + /// + /// 添加用户 菜单 + /// + /// + /// + private void buttonItem127_Click(object sender, EventArgs e) + { + FrmUserAdd frm = new FrmUserAdd(-1); + frm.ShowDialog(); + } + /// + /// 用户信息管理 菜单 + /// + /// + /// + private void buttonItem128_Click_1(object sender, EventArgs e) + { + FrmUserManager frm = new FrmUserManager(); + frm.ShowDialog(); + } + /// + /// 添加角色 菜单 + /// + /// + /// + private void 添加角色_Click(object sender, EventArgs e) + { + FrmRole frm = new FrmRole(-1); + frm.ShowDialog(); + } + /// + /// 所有角色管理 菜单 + /// + /// + /// + private void 角色管理_Click(object sender, EventArgs e) + { + FrmRoleMgr frm = new FrmRoleMgr(); + frm.ShowDialog(); + } + + /// + /// 部门角色管理 菜单 + /// + /// + /// + private void buttonItem133_Click(object sender, EventArgs e) + { + FrmRegionRoleMgr frm = new FrmRegionRoleMgr(); + frm.ShowDialog(); + } + /// + /// 部门管理 菜单 + /// + /// + /// + private void buttonItem130_Click(object sender, EventArgs e) + { + FrmRegionMgr frm = new FrmRegionMgr(); + frm.ShowDialog(); + } + + /// + /// 日志管理 菜单 + /// + /// + /// + private void buttonItem135_Click(object sender, EventArgs e) + { + FrmLogManager frm = new FrmLogManager(); + frm.ShowDialog(); + } + /// + /// 传感器信息查询 菜单 + /// + /// + /// + 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); + } + } + } + /// + /// 根据指定的图层的caption属性的值在配置文件中查找对应的数据库中的表的名称 + /// + /// 图层的caption属性的值 + /// 对应的数据库中的表的名称 + 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; + } + /// + /// 根据数据库中的表的名称 查找对应的表中的字段名称的集合 + /// + /// 数据库中的表的名称 + /// 对应的表中的字段名称的集合 + 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; + } + + /// + /// 历史曲线查询 菜单 + /// + /// + /// + 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; + /// + /// 传感器在线报警 菜单 + /// + /// + /// + 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); + } + /// + /// 传感器报警 功能中的 定时器 的触发事件处理 + /// + /// + /// + 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; + } + } + } + } + } + } + } + + + /// + /// 沿线运动 菜单 + /// + /// + /// + private void buttonItem138_Click(object sender, EventArgs e) + { + if (globeControl1.Globe.SelectedObject == null) + { + MessageBox.Show("请先选择一条线!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + return; + } + + GSOFeature lineFeature = globeControl1.Globe.SelectedObject; + if (lineFeature.Geometry == null || lineFeature.Geometry.Type != EnumGeometryType.GeoPolyline3D) + { + MessageBox.Show("请先选择一条线!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + return; + } + + OpenFileDialog dlg = new OpenFileDialog(); + dlg.Filter = "*.gcm;*.3ds|*.gcm;*.3ds|*.3ds|*.3ds|*.gcm|*.gcm"; + if (dlg.ShowDialog() == DialogResult.OK) + { + GSOGeoModel model = new GSOGeoModel(); + model.FilePath = dlg.FileName; + + GSOGeoDynamicRoute dynamicRoute = new GSOGeoDynamicRoute(); + dynamicRoute.ActorGeometry = model; + + GSORoute route = new GSORoute(); + GSOGeoPolyline3D geoline = (GSOGeoPolyline3D)lineFeature.Geometry; + for (int i = 0; i < geoline[0].Count; i++) + { + route.Add(geoline[0][i]); + } + route.CircleRoute = false; + route.Speed = 30; + route.RotateSpeed = 50; + route.AltitudeMode = geoline.AltitudeMode; + dynamicRoute.Route = route; + + GSOFeature feature = new GSOFeature(); + + dynamicRoute.Play(); + feature.Geometry = dynamicRoute; + + //GSOLabel gsoLabel = new GSOLabel(); + //gsoLabel.Text = "模型测试"; + //feature.Label = gsoLabel; + globeControl1.Globe.MinModelVisibleSize = 0; + + globeControl1.Globe.MemoryLayer.AddFeature(feature); + globeControl1.Globe.Refresh(); + } + } + /// + /// 回退 菜单 + /// + /// + /// + private void buttonItem99_Click(object sender, EventArgs e) + { + globeControl1.Globe.UnDoEdit(); + } + /// + /// 前进 菜单 + /// + /// + /// + private void buttonItem100_Click(object sender, EventArgs e) + { + globeControl1.Globe.ReDoEdit(); + } + /// + /// 水平净距 功能界面中的 标签内容改变事件处理 + /// + /// + /// + 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() + "米的管线有:"; + } + } + } + /// + /// 垂直净距 功能界面中的 标签内容改变事件处理 + /// + /// + /// + 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() + "米的管线有:"; + } + } + } + /// + /// 覆土分析 功能界面中的 标签内容改变事件处理 + /// + /// + /// + 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() + "米的管线有:"; + } + } + } + + /// + /// 传感器分类查询 全区域 菜单 + /// + /// + /// + private void buttonItemSensor全区域查询_Click(object sender, EventArgs e) + { + FrmAccessoriesSensor.ShowForm(globeControl1, instrumenLayerNames, 0); + } + /// + /// 传感器分类查询 绘制区域 菜单 + /// + /// + /// + private void buttonItemSensor绘制区域查询_Click(object sender, EventArgs e) + { + FrmAccessoriesSensor.ShowForm(globeControl1, instrumenLayerNames, 1); + } + + + /// + /// 碰撞分析 功能界面中 关闭按钮 事件处理 + /// + /// + /// + 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(); + } + /// + /// 覆土分析 功能界面中的 清除分析结果 按钮事件处理 + /// + /// + /// + 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(); + } + /// + /// 数字预处理 功能 + /// + /// + /// + private void 数字预处理buttonItem140_Click(object sender, EventArgs e) + { + FrmEditShapeFile frm = new FrmEditShapeFile(globeControl1); + frm.ShowDialog(this); + } + + + /// + /// 导出矢量 功能 将图层导出为kml和shp格式数据 + /// + /// + /// + private void 导出矢量buttonItem140_Click(object sender, EventArgs e) + { + List listVectorNames = new List(); + for (int i = 0; i < m_PipelineLayerNames.Count; i++) + { + 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 = ""; + /// + /// 绘制城市七线 功能按钮 + /// + /// + /// + 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; + } + } + } + /// + /// 七线审核 功能按钮 + /// + /// + /// + private void 七线审核buttonItem141_Click(object sender, EventArgs e) + { + FrmCityServerLineAnalysis frm = new FrmCityServerLineAnalysis(globeControl1, m_PipelineLayerNames); + frm.ShowDialog(this); + } + + /// + /// 间距分析 开始分析按钮 分析绘制的七线和管线的距离是否符合标准 + /// + /// + /// + 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; + } + /// + /// 间距分析 清除分析结果 + /// + /// + /// + 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(); + } + /// + /// 间距分析 导出Excel按钮 将间距分析的结果以Excel表格的形式导出 + /// + /// + /// + private void buttonExportExcel_Click(object sender, EventArgs e) + { + if (dataGridViewAnalysisResult.Rows.Count > 0) + { + ExportExcel("间距分析", dataGridViewAnalysisResult, listBoxStasticsResult); + } + else + { + MessageBox.Show("表格内容为空!", "提示"); + } + } + /// + /// 间距分析 关闭按钮 + /// + /// + /// + 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(); + } + /// + /// 间距分析 分析结果表格双击定位 + /// + /// + /// + 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); + } + } + } + } + /// + /// 间距分析 选择管线复选框 + /// + /// + /// + private void checkBoxSelectPipeline_CheckedChanged(object sender, EventArgs e) + { + clearFeatureHighLight();//清除高亮 + if (checkBoxSelectPipeline.Checked) + { + comboBoxLayer.SelectedItem = null; + 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; + } + } + /// + /// 间距分析 选择图层复选框 + /// + /// + /// + 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(); + } + /// + /// 间距分析 选择图层下拉框 + /// + /// + /// + 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; + } + } + } + + + + /// + /// 管线自动缩进 菜单 + /// + /// + /// + private void 管线自动缩进buttonItem140_Click(object sender, EventArgs e) + { + FrmPipelineIndented frm = new FrmPipelineIndented(globeControl1, m_PipelineLayerNames, workwellLayerNames); + 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 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); + // } + //} + + /// + /// 统计指定图层在指定范围内的所有feature对象 + /// + /// + /// + /// + 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) + { + 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 setLayerVisible(string layerName) + { + GSOLayer templayer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + if (templayer != null) + { + templayer.Visible = false; + } + globeControl1.Globe.Refresh(); + } + + /// + /// 连接数据库 + /// + /// + /// + private void buttonItem129_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL4_1.Text); + + FrmDatabaseParaSetting2 frm = new FrmDatabaseParaSetting2(globeControl1); + if (frm.ShowDialog() == DialogResult.OK) + { + ds = FrmDatabaseParaSetting2.ds; + if (ds != null) + { + ds.IsCloseSaved = false; + } + } + } + + /// + /// 一键审核---导入数据 + /// + /// + /// + private void buttonItem127_Click_2(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, "打开数据"); + + try + { + //if (shds == null) + //{ + //没连的话,直接连接审核库; //审核库配置读配置文件 + string dbIp = Utility.sgdbip; + string database = Utility.sgdbname; + string user = Utility.sgdbuser; + string pass = Utility.sgdbpwd; + /* + 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; + //} + } + catch (Exception ex) + { + LogError.PublishError(ex); + MessageBox.Show("内存过载请清理内存,并重新启动规划分析!", "提示"); + return; + } + + } + + /// + ///自动导出图片 + /// + /// + /// + private void buttonItem130_Click_1(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, "导出审核图"); + + 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))); + */ + + int mapWidth = 0; + int mapHeight = 0; + Point pt = getUpperLeftPoint(pt1, pt2, out mapWidth, out mapHeight); + int rightBottomX = pt.X + mapWidth; + int rightBottomY = pt.Y + mapHeight; + Image myImg = new Bitmap(mapWidth, mapHeight); + Graphics g = Graphics.FromImage(myImg); + g.CopyFromScreen(pt, new Point(0, 0), new Size(rightBottomX, rightBottomY)); + + 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; + } + } + } + /// + /// 一键审核功能 + ///
+ /// + /// + private void buttonItem128_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItem128.Text); + //垂直净距标准 + + frmSh = new FrmYJSHTC(globeControl1, globeControl2,layerTree); + + if (frmSh.ShowDialog() == DialogResult.OK) + { + frmWait = new FrmWait("一键审核……"); + frmWait.Location = new Point(this.Width - frmWait.Width - 10, this.Height - frmWait.Height - 50); + frmWait.Owner = this; + frmWait.Show(); + Thread thread = new Thread(new ThreadStart(doWork)); + thread.IsBackground = true; + thread.Start(); + } + } + + void doWork() + { + FrmShResult frmShResult = null; + + double dVerticalJingJuBiaoZhun = 1, dHorizontalJingJuBiaoZhun = 1; + if (frmSh.rukuLayer != null) + { + #region + this.Invoke((EventHandler)delegate + { + try + { + List managerLayerList = new List(); + for (int i = 0; i < layerManagerNode.Nodes.Count; i++) + { + managerLayerList.Add(layerManagerNode.Nodes[i].Text); + } + if (!managerLayerList.Contains(frmSh.rukuLayer.Caption)) + { + TreeNode node = new TreeNode(); + node.Tag = frmSh.rukuLayer; + node.Text = frmSh.rukuLayer.Dataset.Caption; + node.ImageIndex = 0; + node.SelectedImageIndex = 0; + node.Checked = frmSh.rukuLayer.Visible; + layerManagerNode.Nodes.Insert(0, node); + layerManagerNode.Expand(); + } + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "提示"); + } + }); + #endregion + + shlayername = frmSh.rukuLayer.Name; + globeControl1.Refresh(); + } + + if (frmShResult != null && !frmShResult.IsDisposed) + { + try + { + clearFeatureHighLight(); + ClearRedlineAnalyseResult(); + frmShResult.Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message); + } + } + + 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.analysis(); + + //MainFrm窗体显示控制,回到一键审核Tab + this.Invoke((EventHandler)delegate + { + frmShResult.Show(); + frmWait.Close(); + //将tab页恢复到一键审核 + ribbonTabItem11.Checked = true; + try + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + //zhanshi = false; + splitContainer1.Panel2Collapsed = true; + + panelOfTable.Visible = false; + legendSC.Visible = false; + legendSG.Visible = false; + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + } + catch (Exception ex) + { + MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + + }); + + boolfrmShResult = true; + } + else + { + + } + } + + + /// + /// 清除渲染结果 + /// + 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(); + } + /// + /// 已审核的图层 + /// + /// + /// + private void buttonItem132_Click_1(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItem132.Text); + + if (shds == null) + { + //没连的话,直接连接审核库; //审核库配置读配置文件 + string dbIp = Utility.sgdbip; + string database = Utility.sgdbname; + string user = Utility.sgdbuser; + string pass = Utility.sgdbpwd; + + /* + 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; + //} + + } + /// + /// 审核入库 + /// + /// + /// + private void buttonItem133_Click_1(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, "审核入库"); + FrmShRK frmShrk = new FrmShRK(globeControl1); + frmShrk.Show(); + } + /// + /// 模拟设计修改 + /// + /// + /// + private void buttonItem134_Click_1(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, "模拟设计修改"); + + 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 + { + + } + + } + + + /// + /// 绘制垂线 + /// + /// + /// + 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); + } + /// + /// 比较两个点是否是同一个点 + /// + /// + /// + /// + 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; + } + /// + /// 获得点到线的垂线距离及垂点 + /// + /// + /// + /// + /// + 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); + 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]; + } + /// + /// 获得斜率 + /// + /// + /// + /// + /// + /// + /// + 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); + } + } + /// + /// 根据默认投影参数,经纬度转xyz + /// + /// + /// + /// + 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; + } + /// + /// 根据投影参数,经纬度转xyz + /// + /// + /// + /// + /// + 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; + } + /// + /// 根据默认投影参数,xyz转经纬度 + /// + /// + /// + /// + 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; + } + /// + /// 根据投影参数,Xyz转经纬度 + /// + /// + /// + /// + /// + 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; + } + /// + /// 获得inpolygon的管线长度 + /// + /// + 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; + } + + + /// + /// 一键审核中调节透明度 + /// + /// + /// + private void sliderItem1_ValueChanged(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.sliderItem1.Text); + + globeControl1.Globe.GroundOpaque = 100 - sliderItem1.Value; + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(roadLayerName);//("180fd"); + if (layer != null) + { + layer.Opaque = 100 - sliderItem1.Value; + } + + optiValue = sliderItem1.Value; + } + /// + /// 红线审核中的透明度分析 + /// + /// + /// + private void sliderItem3_ValueChanged(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.sliderItem3.Text); + + globeControl1.Globe.GroundOpaque = 100 - sliderItem3.Value; + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(roadLayerName);//("180fd"); + if (layer != null) + { + layer.Opaque = 100 - sliderItem3.Value; + } + optiValue = sliderItem3.Value; + } + + #region yanxiaowei + //初始化DataGridViewX1控件 + public delegate void DataGridViewDelegate(DataTable dt, string strLable, string strLayer, bool initDataGrid); + /// + /// 代理函数,操作DatgridViewX1 + /// + /// + /// + public void InitDataGridViewX1(DataTable dt, string strLable, string strLayer, bool initDataGrid) + { + if (initDataGrid == true) + { + dataGridViewX1.DataSource = dt; + panelOfTable.Visible = true; + toolStripNumbers.Text = strLable; + dataGridViewX1.Tag = strLayer; + } + else + { + dataGridViewX1.DataSource = null; + dataGridViewX1.Refresh(); + panelOfTable.Visible = false; + toolStripNumbers.Text = ""; + dataGridViewX1.Tag = ""; + globeControl1.Globe.MemoryLayer.RemoveAllFeature();//清除双击产生的标注 + } + } + FrmAnalysisGuiHuaResult from; + /// + /// 主窗体下方属性表格 双击定位 功能 + /// + /// + /// + private void dataGridViewX1_MouseDoubleClick(object sender, MouseEventArgs e) + { + if (redSH == false) + { + 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 if (dataGridViewX1.Columns.Contains("标识器编号")) + { + featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["标识器编号"].Value.ToString(); + } + featureName = featureName.Trim(); + + GSOLayer layer = null; + layer = globeControl1.Globe.Layers.GetLayerByCaption(dataGridViewX1.Tag.ToString()); + + if (layer == null) return; + + GSOFeatures features = layer.GetFeatureByName(featureName, false); + if (features.Length == 0) return; + GSOFeature rowFeature = features[0]; + + ClassSearchAnalysis.AddMakerToLineFeature(globeControl1, rowFeature); + + } + } + } + else + { + if (e.Button == MouseButtons.Left) + { + if (from != null && !from.IsDisposed) + { + try + { + from.Close(); + } + catch (Exception ex) + { + LogError.PublishError(ex); + } + } + try + { + DataGridView.HitTestInfo hittestinfo = dataGridViewX1.HitTest(e.X, e.Y); + if (hittestinfo.RowIndex >= 0) + { + string layer = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["管线类型"].Value.ToString(); + string hxName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["红线编号"].Value.ToString(); + FrmAnalysisGuiHuaResult frm = new FrmAnalysisGuiHuaResult(globeControl1, lineStruct, featsList, + panelOfTable, dataGridViewX1, layer, hxName); + frm.Location = new Point(this.Width - frm.Width - 10, this.Height - frm.Height - 20); + frm.Show(this); + + from = frm; + } + } + catch (Exception ex) + { + LogError.PublishError(ex); + } + } + } + } + + /// + /// 空间查询 + /// + /// + /// + private void buttonItemSearch1_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemSearch1.Text); + + trackflag = "PipelineSpatialQuery"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; + + } + /// + /// 关键字查询 + /// + /// + /// + private void buttonItemSearch9_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch9.Text); + + FrmKeywordQuery.ShowForm(globeControl1, m_PipelineLayerNames, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 编号查询 + /// + /// + /// + private void buttonItemSearch2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch2.Text); + + FrmCodingQuery.ShowForm(globeControl1, m_PipelineLayerNames, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 坐标查询 + /// + /// + /// + private void buttonItemSearch3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch3.Text); + + FrmSetLatLonPos.ShowForm(globeControl1); + } + /// + /// 附属物查询 + /// + /// + /// + private void buttonItemSearch10_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch10.Text); + + FrmFittingQuery.ShowForm(globeControl1, instrumenLayerNames, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 管径查询 + /// + /// + /// + private void buttonItemSearch4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch4.Text); + + FrmDiameterQuery.ShowForm(globeControl1, m_PipelineLayerNames, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 材质查询 + /// + /// + /// + private void buttonItemSearch5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch5.Text); + + FrmMaterialSel.ShowForm(globeControl1, m_PipelineLayerNames, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 基本查询 + /// + /// + /// + private void buttonItemSearch6_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch6.Text); + + FrmBasicQuery.ShowForm(globeControl1, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 复合查询 + /// + /// + /// + private void buttonItemSearch7_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch7.Text); + + FrmQuerySQL.ShowForm(globeControl1, new DataGridViewDelegate(InitDataGridViewX1)); + } + /// + /// 关联查询 + /// + /// + /// + private void buttonItemSearch8_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSearch8.Text); + + if (globeControl1.Globe.SelObjectCount != 1) + { + MessageBox.Show("请选中一个对象!", "提示"); + return; + } + + 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 || (feature.Geometry.Type == EnumGeometryType.GeoPolygon3D + || feature.Geometry.Type == EnumGeometryType.GeoWater)) + return; + else + { + ClassSearchAnalysis.ResultRelationAnalysis(globeControl1, feature, valueLayerNames, workwellLayerNames, + instrumenLayerNames, pipefittingLayerNames, m_PipelineLayerNames, valueAllowance); + } + } + } + #endregion + /// + /// 清除分析 + /// + /// + /// + private void buttonItemClear_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemClear.Text); + + globeControl1.Globe.ClearMeasure(); + layerTemp.RemoveAllFeature(); + layerTemp2.RemoveAllFeature(); + buttonItemLS5.Checked = false; + + dataGridViewX1.DataSource = null; + panelOfTable.Visible = false; + + 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); + + NetworkAnalysisTool.ClearAllTopAnalysis(this.globeControl1); + // 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();//清除所有坑 + + 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(); + } + } + + clearFeatureHighLight();//取消管线高亮 + + GSOLayer layerGround = globeControl1.Globe.Layers.GetLayerByCaption(roadLayerName);//("180fd"); + if (layerGround != null) + { + layerGround.Visible = true; + } + globeControl1.Refresh(); + globeControl2.Refresh(); + ClearRedlineAnalyseResult(); + globeControl1.Globe.Action = EnumAction3D.ActionNull; + } + /// + /// 管线长度全区域统计 + /// + /// + /// + private void buttonItemTJ1_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管线长度统计"); + + //pipeLineDis.Clear(); + //List list = new List(); + //for (int i = 0; i < m_PipelineLayerNames.Count; i++) + //{ + // GSOFeatures fs = Intersects_Pipeline(null, m_PipelineLayerNames[i]); + // if (fs!=null) + // list.Add(fs); + //} + + //FrmAllPipelineStatis frm = new FrmAllPipelineStatis(0, pipeLineDis, list, globeControl1, new DataGridViewDelegate(InitDataGridViewX1)); + FrmAllPipelineStatis frm = new FrmAllPipelineStatis(globeControl1,null, new DataGridViewDelegate(InitDataGridViewX1), m_PipelineLayerNames); + frm.Show(this); + + } + /// + /// 管线长度绘制区域统计 + /// + /// + /// + private void buttonItemTJ1_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管线长度统计"); + + trackflag = "PipelineDistanceStatistics"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; + } + /// + /// 阀门数量全区域统计 + /// + /// + /// + private void buttonItemTJ2_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "阀门数量统计"); + + //workWellLen.Clear(); + //List list = new List(); + ////找到所有阀门 + //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, globeControl1, new DataGridViewDelegate(InitDataGridViewX1)); + FrmValveStatistics frm = new FrmValveStatistics(globeControl1, null, new DataGridViewDelegate(InitDataGridViewX1)); + frm.Show(this); + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + } + /// + /// 阀门数量绘制区域统计 + /// + /// + /// + private void buttonItemTJ2_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "阀门数量统计"); + + trackflag = "valvequery"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; + } + /// + /// 井盖数量全区域统计 + /// + /// + /// + private void buttonItemTJ3_ALL_Click(object sender, EventArgs e) + { + FrmAllWorkWellStatis frm = new FrmAllWorkWellStatis(globeControl1, null, new DataGridViewDelegate(InitDataGridViewX1)); + frm.Show(this); + } + /// + /// 井盖数量绘制区域统计 + /// + /// + /// + private void buttonItemTJ3_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "井盖数量统计"); + + trackflag = "workwellquery"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; + } + /// + /// 管径分段统计全区域统计 + /// + /// + /// + private void buttonItemTJ4_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管径分段统计"); + + Frmpipediameterstatis.ShowForm(globeControl1, m_PipelineLayerNames, 0); + } + /// + /// 管径分段统计绘制区域统计 + /// + /// + /// + private void buttonItemTJ4_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管径分段统计"); + + trackflag = null; + Frmpipediameterstatis.ShowForm(globeControl1, m_PipelineLayerNames, 1); + } + /// + /// 埋深分段统计全区域统计 + /// + /// + /// + private void buttonItemTJ5_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "埋深分段统计"); + FrmpipeDeepstatis.ShowForm(globeControl1, m_PipelineLayerNames, 0); + } + /// + /// 埋深分段统计绘制区域统计 + /// + /// + /// + private void buttonItemTJ5_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "埋深分段统计"); + trackflag = null; + FrmpipeDeepstatis.ShowForm(globeControl1, m_PipelineLayerNames, 1); + } + /// + /// 管径分类统计全区域统计 + /// + /// + /// + private void buttonItemTJ6_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管径分类汇总"); + + FrmpipeDiametergather.ShowForm(globeControl1, m_PipelineLayerNames, 0); + } + /// + /// 管径分类统计绘制区域统计 + /// + /// + /// + private void buttonItemTJ6_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "管径分类汇总"); + + trackflag = null; + FrmpipeDiametergather.ShowForm(globeControl1, m_PipelineLayerNames, 1); + } + /// + /// 材质分类统计全区域统计 + /// + /// + /// + private void buttonItemTJ7_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "材质分类汇总"); + + FrmpipeMaterialGather.ShowForm(globeControl1, m_PipelineLayerNames, 0); + } + /// + /// 材质分类统计绘制区域统计 + /// + /// + /// + private void buttonItemTJ7_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "材质分类汇总"); + + trackflag = null; + FrmpipeMaterialGather.ShowForm(globeControl1, m_PipelineLayerNames, 1); + } + /// + /// 附属物分类统计全区域统计 + /// + /// + /// + private void buttonItemTJ8_ALL_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "附属物分类汇总"); + + FrmAccessoriesgather.ShowForm(globeControl1, instrumenLayerNames, 0); + } + /// + /// 附属物分类统计绘制区域统计 + /// + /// + /// + private void buttonItemTJ8_DRAW_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, "附属物分类汇总"); + + trackflag = null; + FrmAccessoriesgather.ShowForm(globeControl1, instrumenLayerNames, 1); + } + /// + /// 碰撞分析 + /// + /// + /// + private void buttonItemFX1_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_4.Text); + + this.dataGridViewX4.Size = new System.Drawing.Size(195, 120); + 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(); + } + /// + /// 覆土分析 + /// + /// + /// + private void buttonItemFX1_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX5_1.Text); + this.dataGridViewX6.Size = new System.Drawing.Size(195, 120); + 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(); + } + /// + /// 间距分析 + /// + /// + /// + private void buttonItemFX1_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX1_3.Text); + + this.dataGridViewLineList.Size = new System.Drawing.Size(185, 120); + 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(); + } + /// + /// 垂直净距分析 + /// + /// + /// + private void buttonItemFX1_4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX1_4.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(); + } + /// + /// 水平净距分析 + /// + /// + /// + private void buttonItemFX1_5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_6.Text); + this.dataGridViewX8.Size = new System.Drawing.Size(185, 120); + 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(); + } + + #region Predaotr,断面分析 + /// + /// 横断面分析 + /// + /// + /// + private void buttonItemFX2_1_Click(object sender, EventArgs e) + { + globeControl1.Globe.Action = EnumAction3D.TrackPolyline; + globeControl1.Globe.TrackPolylineTool.VerticalLineVisible = true; + globeControl1.Globe.TrackPolylineTool.TrackMode = EnumTrackMode.SpaceTrack; + trackPolylineEndMode = EnumTrackPolylineEndMode.HDM_Analysis; + + } + /// + /// 纵断面分析 + /// + /// + /// + private void buttonItemFX2_2_Click(object sender, EventArgs e) + { + if (globeControl1.Globe.SelObjectCount<1) + { + MessageBox.Show("请选择一条或者多条管线!", "提示", MessageBoxButtons.OK, + MessageBoxIcon.Information); + return; + } + 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); + } + } + List feats = SectionAnalysisTool.ZDMAnalysis(selectFeatures); + if (feats != null && feats.Count >= 1) + { + FrmProfileAnalysis frm = new FrmProfileAnalysis(globeControl1, feats); + frm.Show(this); + } + } + /// + /// 道路断面分析 + /// + /// + /// + private void buttonItemFX2_3_Click(object sender, EventArgs e) + { + globeControl1.Globe.Action = EnumAction3D.TrackPolyline; + globeControl1.Globe.TrackPolylineTool.VerticalLineVisible = true; + globeControl1.Globe.TrackPolylineTool.TrackMode = EnumTrackMode.SpaceTrack; + trackPolylineEndMode = EnumTrackPolylineEndMode.DLDM_Analysis; + + } + /// + /// 基线剖面分析 + /// + /// + /// + private void buttonItemFX2_4_Click(object sender, EventArgs e) + { + globeControl1.Globe.Action = EnumAction3D.TrackPolyline; + globeControl1.Globe.TrackPolylineTool.VerticalLineVisible = true; + globeControl1.Globe.TrackPolylineTool.TrackMode = EnumTrackMode.SpaceTrack; + trackPolylineEndMode = EnumTrackPolylineEndMode.JXPM_Analysis; + + } + + #endregion + /// + /// 创建拓扑 + /// + /// + /// + private void buttonItemFX3_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX3_1.Text); + + FrmGenAndFaMenTopu frm = new FrmGenAndFaMenTopu(globeControl1, m_PipelineLayerNames, valueLayerNames); + frm.Show(this); + } + #region Predator :拓扑分析 + /// + /// 上游分析 + /// + /// + /// + private void buttonItemFX3_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX3_2.Text); + NetworkTraceUpDown(true); + } + /// + /// 下游分析 + /// + /// + /// + private void buttonItemFX3_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX3_3.Text); + NetworkTraceUpDown(false); + } + + /// + /// 上下游追踪 功能 + /// + /// + private void NetworkTraceUpDown(Boolean bTraceUp) + { + GSOFeature selLineFeature = globeControl1.Globe.SelectedObject; + if (selLineFeature == null || selLineFeature.Geometry == null || selLineFeature.Geometry.Type != EnumGeometryType.GeoPolyline3D) + { + MessageBox.Show("请点击“编辑”—“选中对象”选择一条线!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); + return; + } + GSOLayer selLayer = globeControl1.Globe.SelectedObjectLayer; + + NetworkAnalysisTool.TraceUpDownAnalysis(bTraceUp, + selLineFeature, selLayer); + } + + /// + /// 流向分析 + /// + /// + /// + private void buttonItemFX3_4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX3_4.Text); + + FrmFlow frm = new FrmFlow(globeControl1, m_PipelineLayerNames); + frm.Show(this); + } + /// + /// 关阀分析 + /// + /// + /// + private void buttonItemFX3_5_Click(object sender, EventArgs e) + { + if (globeControl1.Globe.SelObjectCount < 1) + { + MessageBox.Show("请选中至少一根管线!!"); + buttonItemFX3_5.Checked = false; + return; + } + GSOLayer resLayer = null; + GSOFeature resFeature = null; + globeControl1.Globe.GetSelectObject(0, out resFeature, out resLayer); + + String pipeLayerName = resLayer.Caption; + String pipeLayerNamePrefix = pipeLayerName.Substring(0, pipeLayerName.IndexOf("管线")); + GSOLayer valveLayer = globeControl1.Globe.Layers[pipeLayerNamePrefix + "阀门"]; + if (valveLayer == null) + { + MessageBox.Show("无" + pipeLayerNamePrefix+"阀门图层", "提示"); + return; + } + + GSOFeatures valveFeats = NetworkAnalysisTool.CloseValvesAnalysis(resFeature, + resLayer, valveLayer); + + if (valveFeats != null) + { + FrmCloseValves frm = new FrmCloseValves(this.globeControl1, valveFeats); + frm.Show(this); + } + else + { + MessageBox.Show("未找到关闭阀门"); + } + } + + /// + /// 连通分析 + /// + /// + /// + private void buttonItemFX3_6_Click(object sender, EventArgs e) + { + if (globeControl1.Globe.SelObjectCount < 2) + { + MessageBox.Show("请选中至少两个管线!!"); + buttonItemFX3_6.Checked = false; + return; + } + GSOFeature selFeat0, selFeat1; + GSOLayer layer0,layer1; + globeControl1.Globe.GetSelectObject(0, out selFeat0, out layer0); + globeControl1.Globe.GetSelectObject(1, out selFeat1, out layer1); + + if (!layer0.IsSameInnerObject(layer1)) + { + MessageBox.Show("不在同一个图层!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); + buttonItemFX3_6.Checked = false; + return; + } + NetworkAnalysisTool.ConnexityAnalysis(selFeat0, selFeat1, layer0); + } + /// + /// 爆管分析 + /// + /// + /// + private void buttonItemFX3_7_Click(object sender, EventArgs e) + { + NetworkTraceUpDown(true); //上游追踪: + + GSOFeature selLineFeature = globeControl1.Globe.SelectedObject; + if (selLineFeature == null || selLineFeature.Geometry == null || selLineFeature.Geometry.Type != EnumGeometryType.GeoPolyline3D) + { + MessageBox.Show("请点击“编辑”—“选中对象”选择一条线!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); + return; + } + GSOLayer selLayer = globeControl1.Globe.SelectedObjectLayer; + + NetworkAnalysisTool.ExplodeAnalysis(this.globeControl1,selLineFeature,selLayer); + + this.buttonItemFX3_5_Click(sender, e); //关阀分析: + + } + + #endregion + /// + /// 多边形开挖 + /// + /// + /// + private void buttonItemFX4_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_1.Text); + + trackflag = "pit"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; //是这个么?是的,在模型上 + } + /// + /// 挖方量分析 + /// + /// + /// + private void buttonItemFX4_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_2.Text); + + trackflag = "digFillAnalysis"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; + ActionToolMenuChecked(); + } + /// + /// 沿线开挖 + /// + /// + /// + private void buttonItemFX4_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_3.Text); + + if (!buttonItemFX4_3.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; + buttonItemFX4_3.Checked = true; + } + } + else + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + buttonItemFX4_3.Checked = false; + globeControl1.Globe.TrackPolylineTool.VerticalLineVisible = false; + } + ActionToolMenuChecked(); + } + /// + /// 创建隧道 + /// + /// + /// + private void buttonItemFX4_4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_4.Text); + + 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("场景中未加载隧道图层!", "提示"); + } + } + /// + /// 隐藏隧道 + /// + /// + /// + private void buttonItemFX4_5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_5.Text); + + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption("隧道"); + if (layer != null) + { + layer.Visible = !layer.Visible; + } + } + /// + /// 删除隧道 + /// + /// + /// + private void buttonItemFX4_6_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX4_6.Text); + + 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("请选中要删除的隧道!", "提示"); + } + } + /// + /// 通视分析 + /// + /// + /// + private void buttonItemFX5_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX5_1.Text); + + if (globeControl1.Globe.Action != EnumAction3D.VisibilityAnalysis) + { + //btnSpaceVisibilityAnalysis.Checked = true; + globeControl1.Globe.Action = EnumAction3D.VisibilityAnalysis; + } + else + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + // SetButtonChecked(); + } + } + /// + /// 可视域分析 + /// + /// + /// + private void buttonItemFX5_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX5_2.Text); + + globeControl1.Globe.Action = EnumAction3D.ViewshedAnalysis; + } + /// + /// 可视包络分析 + /// + /// + /// + private void buttonItemFX5_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX5_3.Text); + + globeControl1.Globe.Action = EnumAction3D.ViewEnvelopeAnalysis; + } + /// + /// 缓冲区分析 + /// + /// + /// + private void buttonItemFX6_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX6_1.Text); + + GSOFeature feat = globeControl1.Globe.SelectedObject; + if (feat == null) + { + MessageBox.Show("请选择要分析的要素!"); + return; + } + if (feat.Geometry.Type == EnumGeometryType.GeoPolyline3D) + { + GSOGeoPolyline3D line1 = feat.Geometry as GSOGeoPolyline3D; + if (line1 == null) + { + MessageBox.Show("请选择一条管线!"); + return; + } + + FrmBufferAnalysis frm = new FrmBufferAnalysis(globeControl1, line1, layerTemp); + frm.Show(this); + } + else + { + FrmBufferAnalysisBSQ frm = new FrmBufferAnalysisBSQ(globeControl1, layerTemp, bsqPT); + frm.Show(this); + } + + } + /// + /// 附属物分析 + /// + /// + /// + private void buttonItemFX6_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX6_2.Text); + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + FrmAccessoryAnalysis dlg = new FrmAccessoryAnalysis(globeControl1, layerTemp); + dlg.Show(this); + } + /// + /// 无源淹没分析 + /// + /// + /// + private void buttonItemFX6_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFX6_3.Text); + + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + trackflag = "FloodAnalysis"; + } + /// + /// 水平距离 + /// + /// + /// + private void buttonItemLS1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS1.Text); + + globeControl1.Globe.Action = EnumAction3D.MeasureDistance; + globeControl1.Globe.DistanceRuler.SpaceMeasure = false; + buttonItemLS5.Checked = false; + } + /// + /// 垂直距离 + /// + /// + /// + private void buttonItemLS2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS2.Text); + + buttonItemLS5.Checked = false; + globeControl1.Globe.Action = EnumAction3D.MeasureHeight; + globeControl1.Globe.DistanceRuler.SpaceMeasure = false; + } + /// + /// 空间距离 + /// + /// + /// + private void buttonItemLS3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS3.Text); + + buttonItemLS5.Checked = false; + globeControl1.Globe.Action = EnumAction3D.MeasureDistance; + globeControl1.Globe.DistanceRuler.SpaceMeasure = true; + } + /// + /// 地表距离 + /// + /// + /// + private void buttonItemLS4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS4.Text); + + buttonItemLS5.Checked = false; + globeControl1.Globe.Action = EnumAction3D.MeasureDistance; + globeControl1.Globe.DistanceRuler.SpaceMeasure = false; + } + /// + /// 高度量算 + /// + /// + /// + private void buttonItemLS5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS5.Text); + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + buttonItemLS5.Checked = !buttonItemLS5.Checked; + if (buttonItemLS5.Checked) + { + globeControl1.Globe.Action = EnumAction3D.SelectObject; + } + } + /// + /// 水平面积 + /// + /// + /// + private void buttonItemLS6_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS6.Text); + + buttonItemLS5.Checked = false; + globeControl1.Globe.Action = EnumAction3D.MeasureArea; + globeControl1.Globe.AreaRuler.SpaceMeasure = true; + } + /// + /// 地表面积 + /// + /// + /// + private void buttonItemLS7_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemLS7.Text); + + buttonItemLS5.Checked = false; + globeControl1.Globe.Action = EnumAction3D.MeasureArea; + globeControl1.Globe.AreaRuler.SpaceMeasure = false; + + } + + # region Fan 重构标注代码 + /// + /// 标高标注 + /// + /// + /// + private void buttonItemSZ1_Click(object sender, EventArgs e) + { + GSOFeature resFeature = IsPipeLineOfSelectedObj(); + if (resFeature == null) + { + MessageBox.Show("请选中一根管线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + GSOGeoPolyline3D selLine = resFeature.Geometry as GSOGeoPolyline3D; + if (selLine[0].Count <= 1) + { + return; + } + + MarkTools.getInstance().showMarker(resFeature, + globeControl1, EnumMarkLayer.Mark_Altitude, ""); + } + /// + /// 管径标注 + /// + GSOFeature radiusMarkerFeature; + private void buttonItemBZ2_Click(object sender, EventArgs e) + { + GSOFeature resFeature = IsPipeLineOfSelectedObj(); + if (resFeature == null) + { + MessageBox.Show("请选中一根管线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + GSOGeoPolyline3D selLine = resFeature.Geometry as GSOGeoPolyline3D; + if (selLine[0].Count <= 1) + { + return; + } + + MarkTools.getInstance().showMarker(resFeature, + globeControl1, EnumMarkLayer.Mark_Diameter, ""); + } + /// + /// 埋深标注 + /// + /// + /// + private void buttonItemBZ3_Click(object sender, EventArgs e) + { + GSOFeature resFeature = IsPipeLineOfSelectedObj(); + if (resFeature == null) + { + MessageBox.Show("请选中一根管线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + GSOGeoPolyline3D selLine = resFeature.Geometry as GSOGeoPolyline3D; + if (selLine[0].Count <=1) + { + return; + } + + MarkTools.getInstance().showMarker(resFeature, + globeControl1, EnumMarkLayer.Mark_Depth, ""); + + } + /// + /// 坐标标注 + /// + /// + /// + private void buttonItemBZ4_Click(object sender, EventArgs e) + { + GSOFeature resFeature = IsPipeLineOfSelectedObj(); + if (resFeature == null) + { + MessageBox.Show("请选中一根管线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + GSOGeoPolyline3D selLine = resFeature.Geometry as GSOGeoPolyline3D; + if (selLine[0].Count <= 1) + { + return; + } + MarkTools.getInstance().showMarker(resFeature, + globeControl1, EnumMarkLayer.Mark_Location, ""); + } + /// + /// 距离标注 + /// + bool distanceMarker = false; + private void buttonItemBZ5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBZ5.Text); + + globeControl1.Globe.Action = EnumAction3D.TrackPolyline; + //globeControl1.Globe.DistanceRuler.MeasureMode = EnumDistanceMeasureMode.HVSLineMeasure; + distanceMarker = true; + } + /// + /// 自定义标注 + /// + /// + /// + private void buttonItemBZ6_Click(object sender, EventArgs e) + { + GSOFeature f = globeControl1.Globe.SelectedObject; + GSOLayer l = globeControl1.Globe.SelectedObjectLayer; + FrmCustomLabel frm = new FrmCustomLabel(globeControl1, l, f); + if (frm.ShowDialog() == DialogResult.OK) + { + MarkTools.getInstance().showMarker(f, globeControl1, EnumMarkLayer.Mark_Custom, frm.labelText); + } + } + /// + /// 扯旗标注 + /// + /// + /// + private void buttonItemBZ7_Click(object sender, EventArgs e) + { + GSOFeature f = globeControl1.Globe.SelectedObject; + GSOLayer l = globeControl1.Globe.SelectedObjectLayer; + FrmMarker frm = new FrmMarker(); + if (frm.ShowDialog() == DialogResult.OK) + { + MarkTools.getInstance().showMarker(f, globeControl1, EnumMarkLayer.Mark_Custom, frm.markerContent); + } + } + /// + /// 坡度标注 + /// + /// + /// + private void buttonItemBZ8_Click(object sender, EventArgs e) + { + GSOFeature resFeature = IsPipeLineOfSelectedObj(); + if (resFeature == null) + { + MessageBox.Show("请选中一根管线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + GSOGeoPolyline3D selLine = resFeature.Geometry as GSOGeoPolyline3D; + if (selLine[0].Count <= 1) + { + return; + } + + MarkTools.getInstance().showMarker(resFeature, + globeControl1, EnumMarkLayer.Mark_Slope, ""); + } + /// + /// 属性标注 + /// + /// + /// + private void buttonItemBZ9_Click(object sender, EventArgs e) + { + GSOFeature f = globeControl1.Globe.SelectedObject; + GSOLayer l = globeControl1.Globe.SelectedObjectLayer; + FrmPropertiesMarker frm = new FrmPropertiesMarker(globeControl1, l, f); + if (frm.ShowDialog() == DialogResult.OK) + { + MarkTools.getInstance().showMarker(f, globeControl1, EnumMarkLayer.Mark_Property, frm.labelText); + } + } + /// + /// 红线工具 + /// + /// + /// + private void buttonItemBZ10_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBZ10.Text); + 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; + } + } + /// + /// 标注管理 + /// + /// + /// + private void buttonItemBZ11_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBZ11.Text); + + buttonItemBZ11.Checked = !buttonItemBZ11.Checked; + 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 (buttonItemBZ11.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(); + } + } + + #endregion + /// + /// 飞行到目标点 + /// + /// + /// + private void buttonItemFXGJ1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFXGJ1.Text); + + FrmSetFlytoPos.ShowForm(globeControl1); + + } + /// + /// 自定义飞行 + /// + /// + /// + private void buttonItemFXGJ2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFXGJ2.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); + } + } + /// + /// 绕中心点飞行 + /// + /// + /// + private void buttonItemFXGJ3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFXGJ3.Text); + + globeControl1.Globe.FlyAroundCenter(10000, EnumFlyRepeatValueType.MiliSeconds); + globeControl1.Globe.CurFlyID = 1; + } + /// + /// 绕眼睛飞行 + /// + /// + /// + private void buttonItemFXGJ4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemFXGJ4.Text); + + globeControl1.Globe.FlyAroundEye(720, EnumFlyRepeatValueType.Degrees); + globeControl1.Globe.CurFlyID = 2; + } + + /// + /// 权限管理 + /// + /// + /// + private void buttonItemXT1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT1.Text); + + FrmUserRoleMgr frm = new FrmUserRoleMgr(); + frm.ShowDialog(); + } + /// + /// 数据库管理 + /// + /// + /// + private void buttonItemXT2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT2.Text); + + //查看数据库列表 + FrmDbManager frm = new FrmDbManager(); + frm.ShowDialog(); + } + /// + /// 用户列表 + /// + /// + /// + private void buttonItemXT3_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT3_1.Text); + + FrmUserManager frm = new FrmUserManager(); + frm.ShowDialog(); + } + /// + /// 创建新用户 + /// + /// + /// + private void buttonItemXT3_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT3_2.Text); + + FrmUserAdd frm = new FrmUserAdd(-1); + frm.ShowDialog(); + } + /// + /// 人员修改 + /// + /// + /// + private void buttonItemXT4_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT4_2.Text); + + FrmAppUSER appUSER = new FrmAppUSER(); + appUSER.ShowDialog(); + } + /// + /// 增加人员 + /// + /// + /// + private void buttonItemXT4_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemXT4_1.Text); + + FrmAppUSERRESET appUSERRESET = new FrmAppUSERRESET(); + appUSERRESET.ShowDialog(); + } + /// + /// 统计数据 + /// + /// + /// + private void buttonItemZTT1_Click(object sender, EventArgs e) + { + ////日志记录 + //LogManager.saveLog(Utility.userName, this.buttonItemZTT1.Text); + + //PATM patm = new PATM(); + //patm.operation = "Statistic"; + //patm.Text = "统计专题图管理"; + //patm.ShowDialog(); + } + /// + /// 热点功能统计 + /// + /// + /// + private void buttonItemZTT2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT2.Text); + + FrmHotFuncStat frmhfs = new FrmHotFuncStat(); + frmhfs.ShowDialog(); + } + + private void buttonItemZTT3_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT3_1.Text); + + FrmAPP appfrm = new FrmAPP("专题图申请"); + appfrm.ShowDialog(); + } + + private void buttonItemZTT3_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT3_2.Text); + + FrmAPPFORASK appForask = new FrmAPPFORASK("专题图审核"); + appForask.ShowDialog(); + } + + private void buttonItemZTT3_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT3_3.Text); + + FrmAPPregion appregion = new FrmAPPregion("专题图审核"); + appregion.ShowDialog(); + } + + private void buttonItemZTT4_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT4_1.Text); + + FrmAPP appfrm = new FrmAPP("打印申请"); + appfrm.ShowDialog(); + } + + private void buttonItemZTT4_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT4_2.Text); + + FrmAPPFORASK appForask = new FrmAPPFORASK("打印审核"); + appForask.ShowDialog(); + } + + private void buttonItemZTT4_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT4_3.Text); + + FrmAPPregion appregion = new FrmAPPregion("打印审核"); + appregion.ShowDialog(); + } + + private void buttonItemZTT5_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT5_1.Text); + + FrmAPP appfrm = new FrmAPP("拷贝申请"); + appfrm.ShowDialog(); + } + + private void buttonItemZTT5_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT5_2.Text); + + FrmAPPFORASK appForask = new FrmAPPFORASK("拷贝审核"); + appForask.ShowDialog(); + } + + private void buttonItemZTT5_3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemZTT5_3.Text); + + FrmAPPregion appregion = new FrmAPPregion("拷贝审核"); + appregion.Show(); + } + + private int connectServerCount = 0; + + /// + /// 还原球到实测库 + /// + 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); + } + + if (layerManagerNode.Nodes.Count > 0) + { + for (int i = layerManagerNode.Nodes.Count - 1; i >= 0; i--) + { + layerManagerNode.Nodes[i].Remove(); + + } + } + + globeControl1.Refresh(); + + } + + private void buttonItemSPSZ_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSPSZ.Text); + + FrmLayerControl frm = new FrmLayerControl(layerTree, globeControl1, globeControl2); + frm.Show(this); + } + + /// + /// 碰撞审查 + /// + /// + /// + private void buttonItemSH1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSH1.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 buttonItemSH2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSH2.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 buttonItemSH3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSH3.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 buttonItemSH4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSH4.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 buttonItemSH5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSH5.Text); + FrmCityServerLineAnalysis frm = new FrmCityServerLineAnalysis(globeControl1, m_PipelineLayerNames); + frm.Show(this); + } + #region 数据管理-导入文件 + ///// + ///// 数据管理-导入本地坐标系文件 + ///// + ///// + ///// + //private void buttonItemSJGL1_1_Click(object sender, EventArgs e) + //{ + // //日志记录 + // LogManager.saveLog(Utility.userName, this.buttonItemSJGL1_1.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(); + // } + // } + //} + + ///// + ///// 数据管理-导入其他坐标系文件 + ///// + ///// + ///// + //private void buttonItemSJGL1_2_Click(object sender, EventArgs e) + //{ + // //日志记录 + // LogManager.saveLog(Utility.userName, this.buttonItemSJGL1_2.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(); + // } + // } + //} + #endregion + /// + /// 数据质量检查 + /// + /// + /// + private void buttonItemSJGL2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL2.Text); + FrmValiData frm = new FrmValiData(globeControl1); + frm.ShowDialog(); + } + /// + /// 数据预处理 + /// + /// + /// + private void buttonItemSJGL3_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL3.Text); + + FrmEditShapeFile frm = new FrmEditShapeFile(globeControl1); + frm.ShowDialog(this); + } + /// + /// 连接数据库 + /// + /// + /// + private void buttonItemSJGL4_1_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL4_1.Text); + + FrmDatabaseParaSetting frm = new FrmDatabaseParaSetting(globeControl1); + if (frm.ShowDialog() == DialogResult.OK) + { + ds = FrmDatabaseParaSetting.ds; + if (ds != null) + { + ds.IsCloseSaved = false; + } + } + } + /// + /// 管线入库 + /// + /// + /// + private void buttonItemSJGL4_2_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL4_2.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 buttonItemSJGL4_3_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL4_3.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 buttonItemSJGL5_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL5.Text); + + Cyberpipe.Forms.FrmProject frm = new Cyberpipe.Forms.FrmProject(); + frm.ShowDialog(); + } + /// + /// 元数据基本管理 + /// + /// + /// + private void buttonItemSJGL6_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL6_1.Text); + + FrmMetadata frmmd = new FrmMetadata(); + frmmd.ShowDialog(); + } + /// + /// 元数据查询管理 + /// + /// + /// + private void buttonItemSJGL6_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL6_2.Text); + + FrmMetadataStat frmmds = new FrmMetadataStat(); + //frmmds.Show(); + frmmds.ShowDialog(); + } + /// + /// 操作日志管理 + /// + /// + /// + private void buttonItemSJGL7_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL7.Text); + + FrmLogOper frmlo = new FrmLogOper(); + frmlo.ShowDialog(); + } + /// + /// 数据字典管理 + /// + /// + /// + private void buttonItemSJGL8_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL8.Text); + + FrmMDDictory frmmdd = new FrmMDDictory(); + frmmdd.ShowDialog(); + } + /// + /// 数据库备份 + /// + /// + /// + private void buttonItemSJGL9_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL9.Text); + + //新 + FrmBACKORACLE backOracle = new FrmBACKORACLE(); + backOracle.Show(); + } + /// + /// 创建管段 + /// + /// + /// + private void buttonItemBJ1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ1.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; + } + } + /// + /// 创建附属物 + /// + /// + /// + private void buttonItemBJ2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ2.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); + } + } + /// + /// 创建特征管点 + /// + /// + /// + private void buttonItemBJ3_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ3.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); + } + } + /// + /// 绘制城市七线 + /// + /// + /// + private void buttonItemBJ4_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ4.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; + } + } + } + /// + /// 选中对象 + /// + /// + /// + private void buttonItemBJ5_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ5.Text); + + globeControl1.Globe.Action = EnumAction3D.SelectObject; + } + /// + /// 平移对象 + /// + /// + /// + private void buttonItemBJ6_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ6.Text); + + globeControl1.Globe.Action = EnumAction3D.MoveObject; + } + /// + /// 升降对象 + /// + /// + /// + private void buttonItemBJ7_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ7.Text); + + globeControl1.Globe.Action = EnumAction3D.ElevateObject; + } + /// + /// 旋转对象 + /// + /// + /// + private void buttonItemBJ8_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ8.Text); + + globeControl1.Globe.Action = EnumAction3D.RotateObject; + } + /// + /// 连接管段 + /// + /// + /// + private void buttonItemBJ9_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ9.Text); + + if (globeControl1.Globe.SelObjectCount < 2) + { + MessageBox.Show("对不起,请至少选中2个对象!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + return; + } + globeControl1.Globe.InsertJointPipeline(false); + } + /// + /// 后退 + /// + /// + /// + private void buttonItemBJ11_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemBJ11.Text); + globeControl1.Globe.UnDoEdit(); + } + /// + /// 前进 + /// + /// + /// + private void buttonItemBJ12_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemBJ12.Text); + + globeControl1.Globe.ReDoEdit(); + } + /// + /// 导出CAD + /// + /// + /// + private void buttonItemBJ10_1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ10_1.Text); + + #region 导出成dxf格式 + List listVectorNames = new List(); + 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(); + #endregion + } + /// + /// 导出矢量 + /// + /// + /// + private void buttonItemBJ10_2_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemBJ10_2.Text); + + List listVectorNames = new List(); + 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 buttonItemBJ13_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemBJ13.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(); + } + } + MessageBox.Show("删除成功!", "提示"); + } + else + { + MessageBox.Show("请选中要删除的模型!", "提示"); + } + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + } + + private void buttonItemHX1_1_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]; + string filePath = dlg.FileName; + string lastname = Path.GetFileName(filePath); + + 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(); + } + + } + } + } + + public struct LineStruct + { + public string layerName; + public string layerCode; + public string lineLength; + public string hxName; + } + + List lineStruct = new List(); + List featsList = new List(); + + /// + /// 红线审核 + /// + /// + /// + private void buttonItemHX2_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemHX2.Text); + redSH = true; + featsList.Clear(); + lineStruct.Clear(); + List listPipelineLayers = new List(); + + GSOLayer layer = null; + for (int i = 0; i < m_PipelineLayerNames.Count; i++) + { + layer = globeControl1.Globe.Layers.GetLayerByCaption(m_PipelineLayerNames[i]); + if (layer != null) + { + listPipelineLayers.Add(layer); + } + } + //yanxiaowei 重构 + GSOFeatures selectFeatures=new GSOFeatures(); + for (int i = 0; i < globeControl1.Globe.SelObjectCount; i++) + { + GSOFeature feature = null; + globeControl1.Globe.GetSelectObject(i, out feature, out layer); + selectFeatures.Add(feature); + } + DataTable table=new DataTable(); + + ClassGSOTool.CalculateRedLineResult(out table, redSH, selectFeatures, globeControl1, + listPipelineLayers,out lineStruct, out featsList); + + if (table.Rows.Count != 0) + AddDatagridView(table); + else + { + MessageBox.Show("没有侵入地块红线的管线数据!", "提示"); + dataGridViewX1.DataSource = null; + panelOfTable.Visible = false; + return; + } + } + + private void AddDatagridView(DataTable table) + { + dataGridViewX1.DataSource = table; + panelOfTable.Visible = true; + panelOfTable.Height = 200; + toolStripNumbers.Text = "红线审核 |共有:" + table.Rows.Count + "条"; + toolStripDropDownButton3.Visible = true; + } + /// + /// 主窗体 下方的工具条中的 导出.xls文件 按钮事件处理 + /// + /// + /// + private void toolStripDropDownButton3_Click(object sender, EventArgs e) + { + if (dataGridViewX1.Rows.Count == 0) + { + MessageBox.Show("表格内容为空!", "提示"); + return; + } + + string strSaveFile = string.Empty; + SaveFileDialog savefiledialog = new SaveFileDialog(); + savefiledialog.Filter = "Excel文件|*.xls,*.xlsx"; + savefiledialog.AddExtension = true; + savefiledialog.FileName = "红线审核"; + if (savefiledialog.ShowDialog() == DialogResult.OK) + strSaveFile = savefiledialog.FileName; + else return; + + ExpEXCEL.ExpToExcel(dataGridViewX1, strSaveFile, "红线审核", lineStruct, featsList); + MessageBox.Show("导出成功!"); + } + /// + /// 去除集合中重复的管线 + /// + /// + /// + /// + private GSOFeatures getFeaturesByFilter(GSOFeatures features, string fieldName) + { + if (features == null) + { + return null; + } + GSOFeatures featuresGet = new GSOFeatures(); + for (int i = 0; i < features.Length; i++) + { + GSOFeature featureFromFS = features[i]; + string fieldValueFromFS = featureFromFS.GetValue(fieldName).ToString().Trim(); + bool isHas = false; + for (int j = featuresGet.Length - 1; j >= 0; j--) + { + GSOFeature featureFromFSGet = featuresGet[j]; + string fieldValueFromFSGet = featureFromFSGet.GetValue(fieldName).ToString().Trim(); + if (fieldValueFromFS.Equals(fieldValueFromFSGet)) + { + isHas = true; + break; + } + } + if (isHas == false) + { + featuresGet.Add(featureFromFS.Clone()); + } + } + return featuresGet; + } + + private void sliderItem2_ValueChanged(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.sliderItem2.Text); + + globeControl1.Globe.GroundOpaque = 100 - sliderItem2.Value; + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(roadLayerName);//("180fd"); + if (layer != null) + { + layer.Opaque = 100 - sliderItem2.Value; + } + layer = globeControl2.Globe.Layers.GetLayerByCaption("180fd");//("180fd"); + if (layer != null) + { + layer.Opaque = 100 - sliderItem2.Value; + } + globeControl2.Globe.GroundOpaque = 100 - sliderItem2.Value; + + optiValue = sliderItem2.Value; + } + /// + /// 数据管理导入文件 + /// + /// + /// + private void buttonItemSJGL1_Click(object sender, EventArgs e) + { + //日志记录 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL1.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.Multiselect = true; + if (dlg.ShowDialog() == DialogResult.OK) + { + //自定义lprj文件名,从程序中复制一lprj文件。 + string filePath = dlg.FileName; + string lastname = Path.GetFileName(filePath); + + 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, 100); + + globeControl1.Refresh(); + } + } + } + + private void buttonItemHX1_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemHX1.Text); + + GSODataSource dataSpace = globeControl1.Globe.DataManager.OpenOracleDataSource(Utility.DBServer.Trim() + "/" + Utility.dbdatabase.Trim(), "", "", Utility.userID, Utility.DBPassword); + string filepath = ""; + //日志记录 + OpenFileDialog dlg = new OpenFileDialog(); + dlg.Filter = "矢量数据(*.shp)|*.shp|矢量数据(*.lgd)|*.lgd|CAD数据(*.dxf)|*.dxf|全部支持格式(*.lgd,*.shp,*.dxf)|*.lgd;*.shp;*.dxf;"; + dlg.Multiselect = true; + + #region 临时图层显示 + if (dlg.ShowDialog() == DialogResult.OK) + { + string filePath = dlg.FileName; + string lastname = Path.GetFileName(filePath); + + #region + for (int i = 0; i < dlg.FileNames.Length; i++) + { + string strDataPath = dlg.FileNames[i]; + filepath = strDataPath; + + GSOLayer layer = globeControl1.Globe.Layers.Add(strDataPath); + GSOFeatures RedFeatures = layer.GetAllFeatures(); + + 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(); + RedFeatures = features; + 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; + } + + /////////////////////////////////////////////////////////////////////////////////////////// + globeControl1.Globe.Layers.MoveTo(0, globeControl1.Globe.Layers.Count - 1); + globeControl1.Refresh(); + } + + IModelBuilder modelBuilder = new RedLineBuilder(); + + modelBuilder.batchInsert(dataSpace, redDt, RedFeatures); + + } + #endregion + + } + #endregion + } + /// + /// 定位 + /// + /// + /// + private void buttonItemLocation_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemLocation.Text); + + FrmFlyToPosition fly = new FrmFlyToPosition(globeControl1,globeControl2); + fly.Show(this); + } + /// + /// 2015-10-17演示代码 红线审核 + /// + /// + /// + private void ribbonTabItem6_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.FlyToPosition(new GSOPoint3d(120.610963, 31.188121, 50), EnumAltitudeMode.Absolute, -4, 50, 800); + globeControl1.Globe.FlyToPointSpeed = 10000000; + globeControl1.Globe.Action = EnumAction3D.SelectObject; + globeControl1.Refresh(); + + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + + //zhanshi = false; + redSH = true; + splitContainer1.Panel2Collapsed = true; + legendSG.Visible = false; + legendSC.Visible = false; + ClearGZData(); + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = true; + } + + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 基础工具 + /// + /// + /// + private void ribbonTabItem1_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + //zhanshi = false; + redSH = false; + splitContainer1.Panel2Collapsed = true; + panelOfTable.Visible = false; + legendSC.Visible = false; + legendSG.Visible = false; + ClearGZData(); + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + + + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 一键审核 + /// + /// + /// + private void ribbonTabItem11_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + //zhanshi = false; + redSH = false; + splitContainer1.Panel2Collapsed = true; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + panelOfTable.Visible = false; + legendSC.Visible = false; + legendSG.Visible = false; + ClearGZData(); + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + + + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 右屏添加冰箱数据 + /// + void AddDataToGlobeControl2() + { + + bool modelDataBool = false; + for (int i = globeControl2.Globe.Layers.Count - 1; i >= 0; i--) + { + GSOLayer layer = globeControl2.Globe.Layers[i]; + if (layer.Name.Contains("fttp:")) + { + modelDataBool = true; + break; + } + } + + if (modelDataBool == false) + { + GSOLayer ly = globeControl1.Globe.Layers.GetLayerByCaption("天地图地图"); + globeControl2.Globe.Layers.Add(ly); + } + else + { + return; + } + } + /// + /// 双屏对比 + /// + /// + /// + private void ribbonTabItem9_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent += new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent += new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + panelOfTable.Visible = false; + + splitContainer1.Panel2Collapsed = false; + //zhanshi = true; + redSH = false; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + sliderItem2.Value = 100 - globeControl1.Globe.GroundOpaque; + globeControl2.Globe.GroundOpaque = globeControl1.Globe.GroundOpaque; + legendSC.Visible = true; + legendSG.Visible = true; + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + AddDataToGlobeControl2(); + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 文档管理 + /// + /// + /// + private void ribbonTabItem4_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + panelOfTable.Visible = false; + //zhanshi = false; + redSH = false; + splitContainer1.Panel2Collapsed = true; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + legendSC.Visible = false; + legendSG.Visible = false; + ClearGZData(); + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 基础管理 + /// + /// + /// + private void ribbonTabItem14_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + panelOfTable.Visible = false; + //zhanshi = false; + redSH = false; + splitContainer1.Panel2Collapsed = true; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + legendSC.Visible = false; + legendSG.Visible = false; + ClearGZData(); + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + /// + /// 权限管理 + /// + /// + /// + private void ribbonTabItem2_MouseDown(object sender, MouseEventArgs e) + { + try + { + + globeControl1.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl1_BeforeSceneRenderEvent); + globeControl2.BeforeSceneRenderEvent -= new BeforeSceneRenderEventHandler(globeControl2_BeforeSceneRenderEvent); + + + globeControl1.Globe.Action = EnumAction3D.ActionNull; + panelOfTable.Visible = false; + //zhanshi = false; + redSH = false; + splitContainer1.Panel2Collapsed = true; + dataGridViewX1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; + legendSC.Visible = false; + legendSG.Visible = false; + ClearGZData(); + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + { + redLayer.Visible = false; + } + + } + catch (Exception ex) + { + //MessageBox.Show("系统运行错误:" + ex.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + GSOFeature dpFeatuer = null; + /// + /// 双屏分析,点击管段分析 + /// + /// + /// + private void buttonItem8_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItem8.Text); + + //FrmCompareFeature frmCompareFeature = new FrmCompareFeature(globeControl1, globeControl2, layerTemp, layerTemp2,m_PipelineLayerNames,sgPipeLayersNames); + int width = this.Width; + FrmCompareFeature.ShowForm(globeControl1, globeControl2, layerTemp, layerTemp2, m_PipelineLayerNames, sgPipeLayersNames,width); + //frmCompareFeature.Location = new Point((this.Width - frmCompareFeature.Width)/2,50); + //frmCompareFeature.Show(this); + + } + /// + /// 红线审核导出图片 + /// + /// + /// + private void buttonItemDCTP_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemDCTP.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))); + */ + int mapWidth = 0; + int mapHeight = 0; + Point pt = getUpperLeftPoint(pt1, pt2, out mapWidth, out mapHeight); + int rightBottomX = pt.X + mapWidth; + int rightBottomY = pt.Y + mapHeight; + Image myImg = new Bitmap(mapWidth, mapHeight); + Graphics g = Graphics.FromImage(myImg); + g.CopyFromScreen(pt, new Point(0, 0), new Size(rightBottomX, rightBottomY)); + + 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; + } + } + } + /// + /// 标识器全区域统计 + /// + /// + /// + private void 标识器分类统计ToolStripMenuItem_Click(object sender, EventArgs e) + { + globeControl1.Globe.Action = EnumAction3D.ActionNull; + FrmBSQStatis bsqStatis = new FrmBSQStatis(globeControl1,null); + //FrmBSQStatis bsqStatis = new FrmBSQStatis(); + bsqStatis.Show(this); + } + /// + /// 标识器绘制区域统计 + /// + /// + /// + private void 标识器分类统计ToolStripMenuItem1_Click(object sender, EventArgs e) + { + trackflag = "BSQDuoBianXiangStatis"; + globeControl1.Globe.Action = EnumAction3D.TrackPolygon; + } + + #region 保存和加载审核库加载的图层 + /* + private void saveLayerList(TreeNodeCollection treeNodeList) + { + string configPath = Application.StartupPath + "\\configLayerList.xml"; + try + { + XmlDocument doc = new XmlDocument(); + doc.Load(configPath); + XmlNode dbParams = doc.SelectSingleNode("Params/dbparams"); + XmlNode dbLayers = doc.SelectSingleNode("Params/dblayers"); + XmlNode layers = doc.SelectSingleNode("Params/layers"); + dbParams.RemoveAll(); + dbLayers.RemoveAll(); + layers.RemoveAll(); + + List listDS = new List(); + String shDatasourceName = Utility.sgdbip + "/" + Utility.sgdbname + "_" + Utility.sgdbuser; + bool flag = false; + + for (int i = 0; i < globeControl1.Globe.DataManager.DataSourceCount; i++) + { + GSODataSource ds = globeControl1.Globe.DataManager.GetDataSourceAt(i); + if (ds != null && ds.Type == EnumDataSourceType.SqlServer || ds.Type == EnumDataSourceType.Oracle) + { + if (ds.Name == shDatasourceName) + { + //防止因为多次连接同一个数据库 + if (flag == true) + { + break; + } + flag = true; + listDS.Add(ds); + GSODataSourceCnn conn = ds.GetConnectionInfo(); + + XmlElement dbparam = doc.CreateElement("shdbparam"); + XmlElement ip = doc.CreateElement("ship"); + ip.InnerText = conn.Server; + + XmlElement dbname = doc.CreateElement("shdbname"); + dbname.InnerText = conn.Database; + + XmlElement username = doc.CreateElement("shusername"); + username.InnerText = conn.User; + + XmlElement password = doc.CreateElement("shpassword"); + password.InnerText = conn.Password; + + XmlElement type = doc.CreateElement("shtype"); + if (ds.Type == EnumDataSourceType.SqlServer) + { + type.InnerText = "sqlserver"; + } + else + { + type.InnerText = "oracle"; + } + + dbparam.AppendChild(ip); + dbparam.AppendChild(dbname); + dbparam.AppendChild(username); + dbparam.AppendChild(password); + dbparam.AppendChild(type); + dbParams.AppendChild(dbparam); + } + + } + } + + for (int i = 0; i < treeNodeList.Count; i++) + { + GSOLayer layer = treeNodeList[i].Tag as GSOLayer; + if (Path.GetExtension(layer.Name) == "") + { + XmlElement dbLayer = doc.CreateElement("dblayer"); + XmlAttribute attri = doc.CreateAttribute("dbindex"); + for (int j = 0; j < listDS.Count; j++) + { + if (layer.Dataset.DataSource.Name == listDS[j].Name) + { + attri.Value = j.ToString(); + break; + } + } + dbLayer.Attributes.Append(attri); + dbLayer.InnerText = layer.Name; + + dbLayers.AppendChild(dbLayer); + } + else + { + XmlElement dbLayer = doc.CreateElement("layer"); + dbLayer.InnerText = layer.Name; + layers.AppendChild(dbLayer); + } + } + + doc.Save(configPath); + } + catch (Exception e) + { + + } + } + + private void openLayerList() + { + layerManagerNode.Nodes.Clear(); + + string configPath = Application.StartupPath + "\\configLayerList.xml"; + try + { + XmlDocument doc = new XmlDocument(); + doc.Load(configPath); + XmlNode dbParams = doc.SelectSingleNode("Params/dbparams"); + XmlNode dbLayers = doc.SelectSingleNode("Params/dblayers"); + XmlNode layers = doc.SelectSingleNode("Params/layers"); + + List listDS = new List(); + for (int i = 0; i < dbParams.ChildNodes.Count; i++) + { + string ip = ""; + string dbname = ""; + string username = ""; + string password = ""; + string type = ""; + XmlNode node = dbParams.ChildNodes.Item(i); + for (int j = 0; j < node.ChildNodes.Count; j++) + { + XmlNode nodeChild = node.ChildNodes.Item(j); + + if (nodeChild != null && nodeChild.Name == "ship") + { + ip = nodeChild.InnerText; + } + else if (nodeChild != null && nodeChild.Name == "shdbname") + { + dbname = nodeChild.InnerText; + } + else if (nodeChild != null && nodeChild.Name == "shusername") + { + username = nodeChild.InnerText; + } + else if (nodeChild != null && nodeChild.Name == "shpassword") + { + password = nodeChild.InnerText; + } + else if (nodeChild != null && nodeChild.Name == "shtype") + { + type = nodeChild.InnerText; + } + } + + if (type == "sqlserver") + { + GSODataSource ds = globeControl1.Globe.DataManager.OpenSqlServerDataSource(ip, "", dbname, username, password); + listDS.Add(ds); + } + else if (type == "oracle") + { + GSODataSource ds = globeControl1.Globe.DataManager.OpenOracleDataSource(ip + "/" + dbname, "", "", username, password); + listDS.Add(ds); + } + } + + for (int i = 0; i < dbLayers.ChildNodes.Count; i++) + { + XmlNode node = dbLayers.ChildNodes.Item(i); + if (node != null) + { + string layerName = node.InnerText; + XmlAttribute attri = node.Attributes["dbindex"]; + if (attri != null) + { + int dbIndex = -1; + if (int.TryParse(attri.Value, out dbIndex)) + { + GSODataset dataset = listDS[dbIndex].GetDatasetByName(layerName); + globeControl1.Globe.Layers.Add(dataset); + //更新树节点 + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + TreeNode layerNode = new TreeNode(); + layerNode.Tag = layer; + layerNode.Text = layer.Dataset.Caption; + layerNode.ImageIndex = 0; + layerNode.SelectedImageIndex = 0; + layerNode.Checked = layer.Visible; + layerManagerNode.Nodes.Insert(0, layerNode); + // layerManagerNode.Expand(); + + + } + } + } + } + for (int i = 0; i < layers.ChildNodes.Count; i++) + { + XmlNode node = layers.ChildNodes.Item(i); + if (node != null) + { + string layerName = node.InnerText; + globeControl1.Globe.Layers.Add(layerName); + + //更新树节点 + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + TreeNode layerNode = new TreeNode(); + layerNode.Tag = layer; + layerNode.Text = layer.Dataset.Caption; + layerNode.ImageIndex = 0; + layerNode.SelectedImageIndex = 0; + layerNode.Checked = layer.Visible; + layerManagerNode.Nodes.Insert(0, layerNode); + } + } + layerManagerNode.Expand(); + } + catch (Exception e) + { + + } + } + * */ + #endregion + + private void btn_check_history_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_check_history.Text); + + if (FrmCheckHistory.isOpen == true) + { + return; + } + FrmCheckHistory frm = new FrmCheckHistory(globeControl1, globeControl2); + frm.addNode += new AddNodeToLayerManagerNode(addNodeToLayerManagerNode); + frm.Show(); + + } + + private void buttonItem查看数据_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItem查看数据.Text); + + FrmThreeOracle tr = new FrmThreeOracle(globeControl1); + + if (tr.ShowDialog() == DialogResult.OK) + { + addNodeToLayerManagerNode(tr.rukuLayer); + globeControl1.Refresh(); + } + } + /// + /// 规划数据入库 + /// + /// + /// + private void buttonItemGHRK_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemGHRK.Text); + + FrmGHRK ghrk = new FrmGHRK(globeControl1, layerManagerNode); + ghrk.Show(this); + } + + private void btn_user_info_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_user_info.Text); + + if (!FrmSysUserInfoManger.IS_OPEN) + { + FrmSysUserInfoManger frm = new FrmSysUserInfoManger(); + frm.ShowDialog(); + } + } + + private void btn_role_info_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_role_info.Text); + + if (FrmRoleInfoManager.IS_OPEN) + { + return; + } + FrmRoleInfoManager frm = new FrmRoleInfoManager(); + frm.ShowDialog(); + } + + private void btn_resc_info_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_resc_info.Text); + + if (!SysRescInfoManager.IS_OPEN) + { + SysRescInfoManager frm = new SysRescInfoManager(); + frm.ShowDialog(); + } + } + + private void btn_role_resc_Click(object sender, EventArgs e) + { + + LogManager.saveLog(Utility.userName, this.btn_role_resc.Text); + + if (!FrmRoleRescManager.IS_OPEN) + { + FrmRoleRescManager frm = new FrmRoleRescManager(); + frm.ShowDialog(); + } + } + + private void btn_user_role_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_user_role.Text); + + if (FrmUserRole.IS_OPEN) + { + return; + } + FrmUserRole frm = new FrmUserRole(); + frm.ShowDialog(); + } + + private void btn_document_info_Click(object sender, EventArgs e) + { + + LogManager.saveLog(Utility.userName, this.btn_document_info.Text); + + //if (FormDocumentManager.IS_OPEN) + //{ + // return; + //} + //FormDocumentManager frm = new FormDocumentManager(); + //frm.ShowDialog(); + + //if (FormDocumentManager.IS_OPEN) + //{ + // return; + //} + //new FormDocumentManager().ShowDialog(); + if (FormDocumentManager.IS_OPEN) + { + return; + } + this.Cursor = Cursors.WaitCursor; + FormDocumentManager frm = new FormDocumentManager(); + frm.changeCursor += new ChangeCursor(changeCursorToDefault); + frm.ShowDialog(); + + } + + private void changeCursorToDefault() + { + this.Cursor = Cursors.Default; + } + + /// + /// 判断CAD文件是否有投影信息 + /// + /// + /// + Boolean CheckDatasetGeoReference(GSODataset dataset) + { + Boolean bSuccess = false; + if (dataset.GeoReferenceType == EnumGeoReferenceType.Flat) + { + if (MessageBox.Show("数据没有空间参考信息,请设置空间参考信息!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation) == DialogResult.OK) + { + String strPath = Path.GetDirectoryName(Application.ExecutablePath) + "\\Coordinate Systems"; + OpenFileDialog dlg = new OpenFileDialog(); + + dlg.InitialDirectory = strPath; + dlg.RestoreDirectory = true; + + dlg.Filter = "投影文件|*.prj||"; + if (dlg.ShowDialog() == DialogResult.OK) + { + bSuccess = dataset.LoadProjectionFromESRIFile(dlg.FileName); + } + } + } + else + { + return true; + } + return bSuccess; + } + + private void buttonItemexp_CAD_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.buttonItemexp_CAD.Text); + + OpenFileDialog dlg = new OpenFileDialog(); + dlg.Filter = "支持格式(*.dwg)|*.dwg"; + dlg.Multiselect = true; + if (dlg.ShowDialog() == DialogResult.OK) + { + for (int i = 0; i < dlg.FileNames.Length; i++) + { + //this.Cursor = Cursors.WaitCursor; + string strDataPath = dlg.FileNames[i]; + + #region + //string strDataPathPrj = strDataPath.ToLower().Replace(".dwg", ".lprj"); + + //if (File.Exists(strDataPathPrj) == false) + //{ + // if (MessageBox.Show("数据没有空间参考信息,请设置空间参考信息!", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation) == DialogResult.OK) + // { + // String strPath = Application.StartupPath + "\\Coordinate Systems"; + // OpenFileDialog dlgPrj = new OpenFileDialog(); + // dlgPrj.InitialDirectory = strPath; + // dlgPrj.RestoreDirectory = true; + // dlgPrj.Multiselect = false; + // dlg.Filter = "投影文件|*.prj"; + // if (dlg.ShowDialog() == DialogResult.OK) + // { + // this.Cursor = Cursors.WaitCursor; + // string proj4 = GSODataEngineUtility.ConvertEsriPrjFileToProj4(dlg.FileName); + // using (StreamWriter stream = new StreamWriter(strDataPathPrj, false)) + // { + // stream.WriteLine("0prj4" + proj4 + ""); + // } + // AddLayerData(strDataPath); + // //globeControl1.Globe.Layers.Add(strDataPath); + + // this.Cursor = Cursors.Default; + // } + // else + // { + // AddLayerData(strDataPath); + // //globeControl1.Globe.Layers.Add(strDataPath); + // } + // } + // else + // { + // AddLayerData(strDataPath); + // //globeControl1.Globe.Layers.Add(strDataPath); + // } + + //} + //else + //{ + // //globeControl1.Globe.Layers.Add(strDataPath); + // AddLayerData(strDataPath); + //} + #endregion + AddLayerData(strDataPath); + //this.Cursor = Cursors.Default; + } + } + + 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, 100); + + globeControl1.Refresh(); + } + } + + private void btn_password_edit_Click(object sender, EventArgs e) + { + LogManager.saveLog(Utility.userName, this.btn_password_edit.Text); + + if (FrmChangePassword.IS_OPEN) + { + return; + } + FrmChangePassword frm = new FrmChangePassword(); + frm.ShowDialog(); + } + /// + /// 多孔管线入库 + /// + /// + /// + private void buttonItem9_Click(object sender, EventArgs e) + { + //保存日志 + LogManager.saveLog(Utility.userName, this.buttonItemSJGL4_2.Text); + + if (ds == null) + { + MessageBox.Show("请先连接数据库", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + ConnectDB(null, null); + } + if (ds == null) + return; + + FrmMultiPipelineModelDB frm = new FrmMultiPipelineModelDB(globeControl1, ds); + if (frm.ShowDialog() == DialogResult.OK) + { + addNodeToLayerManagerNode(frm.rukuLayer); + } + //frm.Show(); + } + private void 导出CADToolStripMenuItem1_Click(object sender, EventArgs e) + { + TreeNode node = layerNodeContexMenu.Tag as TreeNode; + if (node == null) + { + MessageBox.Show("请在左侧节点集中选择要导出的图层", "提示"); + return; + } + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(node.Text.Trim()); + if (layer == null || layer.GetAllFeatures().Length <= 0) + { + MessageBox.Show("要导出的图层为空", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + return; + } + string strProjectName = Utility.projectStr; + if (strProjectName != "") + { + SaveFileDialog dlg = new SaveFileDialog(); + dlg.Filter = "*.dwg|*.dwg|*.dxf|*.dxf"; + dlg.FileName = layer.Caption; + if (dlg.ShowDialog(this) == DialogResult.OK) + { + globeControl1.Globe.MemoryLayer.SaveAs(dlg.FileName); + GSOLayer newlayer = globeControl1.Globe.Layers.Add(dlg.FileName); + newlayer.RemoveAllFeature(); + int featureCount = layer.GetAllFeatures().Length; + for (int i = 0; i < featureCount; i++) + { + GSOFeature feature = layer.GetAt(i); + if (feature != null && feature.Geometry != null) + { + if (feature.Geometry.Type == EnumGeometryType.GeoPolyline3D) + { + feature.Geometry.Style = new GSOSimpleLineStyle3D(); + } + else if (feature.Geometry.Type == EnumGeometryType.GeoPolygon3D) + { + feature.Geometry.Style = new GSOSimplePolygonStyle3D(); + } + newlayer.AddFeature(feature); + } + } + newlayer.Save(); + newlayer.Dataset.DataSource.RemoveDataset(newlayer.Dataset); + globeControl1.Globe.Layers.Remove(newlayer); + MessageBox.Show("导出CAD完成!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + } + } + } + + private void buttonItemGBJC_Click(object sender, EventArgs e) + { + FrmGBJC gb = new FrmGBJC(globeControl1, globeControl2, layerTemp, layerTemp2); + gb.Show(this); + } + + #region 右屏管纵数据控制 + private void 五十米主干道ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = true; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + + private void 三十六米次干道ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = true; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + + private void 四十二米次干道ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = true; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + + private void 二十四米一块板ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = true; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + + private void 二十四米三块板ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = true; + } + + private void 二十四米停车带ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = true; + lendendGZ24_3.Visible = false; + } + + private void 二十六米大堤路ToolStripMenuItem_Click(object sender, EventArgs e) + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = true; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + + private void 清除管纵数据ToolStripMenuItem_Click(object sender, EventArgs e) + { + ClearGZData(); + } + + private void ClearGZData() + { + lendendGZ50.Visible = false; + lendendGZ42.Visible = false; + lendendGZ36.Visible = false; + lendendGZ26.Visible = false; + lendendGZ24_1.Visible = false; + lendendGZ24_2.Visible = false; + lendendGZ24_3.Visible = false; + } + #endregion + + private void buttonItemPasswordReset_Click(object sender, EventArgs e) + { + Frm_password_reset reset = new Frm_password_reset(); + reset.Show(); + } + + private void pictureBox1_Paint(object sender, PaintEventArgs e) + { + int Width = this.Width; + string welcomeUser = "欢迎您:" + Utility.userName; + Graphics g = e.Graphics; + g.DrawString(welcomeUser, new Font("宋体", 12), new SolidBrush(Color.Black), Width - 180, 50); + } + + } +} \ No newline at end of file diff --git a/bin/x86/Debug/Cyberpipe.vshost.exe.manifest b/bin/x86/Debug/Cyberpipe.vshost.exe.manifest deleted file mode 100644 index 061c9ca..0000000 --- a/bin/x86/Debug/Cyberpipe.vshost.exe.manifest +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - diff --git a/bin/x86/Debug/glVersion.txt b/bin/x86/Debug/glVersion.txt index 06a7613..1fc46d0 100644 --- a/bin/x86/Debug/glVersion.txt +++ b/bin/x86/Debug/glVersion.txt Binary files differ diff --git a/bin/x86/Debug/log/2016/201611/20161107.txt b/bin/x86/Debug/log/2016/201611/20161107.txt new file mode 100644 index 0000000..d588178 --- /dev/null +++ b/bin/x86/Debug/log/2016/201611/20161107.txt @@ -0,0 +1,16 @@ + + +��¼ʱ�䣺2016-11-07 10:30:22,327 +�߳�ID:[9] +��־���� ERROR +�����ࣺCyberpipe.FrmBSQStatis property: [(null)] - +����������1 + + + +��¼ʱ�䣺2016-11-07 10:30:40,660 +�߳�ID:[9] +��־���� ERROR +�����ࣺCyberpipe.FrmBSQStatis property: [(null)] - +����������0 +