diff --git a/Cyberpipe.suo b/Cyberpipe.suo index 191d4bb..f78f4b3 100644 --- a/Cyberpipe.suo +++ b/Cyberpipe.suo Binary files differ diff --git a/Cyberpipe.suo b/Cyberpipe.suo index 191d4bb..f78f4b3 100644 --- a/Cyberpipe.suo +++ b/Cyberpipe.suo Binary files differ diff --git a/FeatureStatisticsService.cs b/FeatureStatisticsService.cs index 331ee47..b127fe3 100644 --- a/FeatureStatisticsService.cs +++ b/FeatureStatisticsService.cs @@ -190,7 +190,7 @@ List result = new List(); //layer.Name是表名 - string[] accessStrs = Utility.getAccStrsByLayer(layer.Name); + string[] accessStrs = FeatureTools.GetAccStrsByLayer(layer.Name); foreach (string accssname in accessStrs) { diff --git a/Cyberpipe.suo b/Cyberpipe.suo index 191d4bb..f78f4b3 100644 --- a/Cyberpipe.suo +++ b/Cyberpipe.suo Binary files differ diff --git a/FeatureStatisticsService.cs b/FeatureStatisticsService.cs index 331ee47..b127fe3 100644 --- a/FeatureStatisticsService.cs +++ b/FeatureStatisticsService.cs @@ -190,7 +190,7 @@ List result = new List(); //layer.Name是表名 - string[] accessStrs = Utility.getAccStrsByLayer(layer.Name); + string[] accessStrs = FeatureTools.GetAccStrsByLayer(layer.Name); foreach (string accssname in accessStrs) { diff --git a/FeatureTools.cs b/FeatureTools.cs index be4b469..0ba33d7 100644 --- a/FeatureTools.cs +++ b/FeatureTools.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Data; using System.Linq; using System.Text; using System.Windows.Forms; @@ -106,5 +107,46 @@ } return value; } + + /// + /// 根据附属物图层名字得到里面含有的附属物 + /// + /// + /// + public static string[] GetAccStrsByLayer(string layername) + { + string[] accStrs = null; + string sql = "select 附属物名称 from " + layername + " group by 附属物名称"; + DataSet dataset = OledbHelper.getDataSet(sql, layername); + if (dataset == null) return null; + accStrs = new string[dataset.Tables[0].Rows.Count]; + for (int i = 0; i < dataset.Tables[0].Rows.Count; i++) + { + accStrs[i] = dataset.Tables[0].Rows[i][0].ToString(); + } + return accStrs; + } + + /// + /// 删除内存图层中指定名称的feature + /// + /// + /// + public static void RemoveFeatureFromName(GSOGlobeControl globeControl1, string featureName) + { + GSOFeatures features = globeControl1.Globe.MemoryLayer.GetFeatureByName(featureName, true); + if (features != null) + { + for (int i = features.Length - 1; i >= 0; i--) + { + GSOFeature feature = features[i]; + if (feature != null) + { + globeControl1.Globe.MemoryLayer.RemoveFeatureByID(feature.ID); + } + } + } + globeControl1.Refresh(); + } } } diff --git a/Cyberpipe.suo b/Cyberpipe.suo index 191d4bb..f78f4b3 100644 --- a/Cyberpipe.suo +++ b/Cyberpipe.suo Binary files differ diff --git a/FeatureStatisticsService.cs b/FeatureStatisticsService.cs index 331ee47..b127fe3 100644 --- a/FeatureStatisticsService.cs +++ b/FeatureStatisticsService.cs @@ -190,7 +190,7 @@ List result = new List(); //layer.Name是表名 - string[] accessStrs = Utility.getAccStrsByLayer(layer.Name); + string[] accessStrs = FeatureTools.GetAccStrsByLayer(layer.Name); foreach (string accssname in accessStrs) { diff --git a/FeatureTools.cs b/FeatureTools.cs index be4b469..0ba33d7 100644 --- a/FeatureTools.cs +++ b/FeatureTools.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Data; using System.Linq; using System.Text; using System.Windows.Forms; @@ -106,5 +107,46 @@ } return value; } + + /// + /// 根据附属物图层名字得到里面含有的附属物 + /// + /// + /// + public static string[] GetAccStrsByLayer(string layername) + { + string[] accStrs = null; + string sql = "select 附属物名称 from " + layername + " group by 附属物名称"; + DataSet dataset = OledbHelper.getDataSet(sql, layername); + if (dataset == null) return null; + accStrs = new string[dataset.Tables[0].Rows.Count]; + for (int i = 0; i < dataset.Tables[0].Rows.Count; i++) + { + accStrs[i] = dataset.Tables[0].Rows[i][0].ToString(); + } + return accStrs; + } + + /// + /// 删除内存图层中指定名称的feature + /// + /// + /// + public static void RemoveFeatureFromName(GSOGlobeControl globeControl1, string featureName) + { + GSOFeatures features = globeControl1.Globe.MemoryLayer.GetFeatureByName(featureName, true); + if (features != null) + { + for (int i = features.Length - 1; i >= 0; i--) + { + GSOFeature feature = features[i]; + if (feature != null) + { + globeControl1.Globe.MemoryLayer.RemoveFeatureByID(feature.ID); + } + } + } + globeControl1.Refresh(); + } } } diff --git a/FrmAccessoriesSensor.cs b/FrmAccessoriesSensor.cs index 98aa1cf..542f19a 100644 --- a/FrmAccessoriesSensor.cs +++ b/FrmAccessoriesSensor.cs @@ -240,7 +240,7 @@ { if (clbPipeLine.CheckedItems.Count > 0) { - Utility.RemoveFeatureFromName(globeControl1, "trackPolygon"); + FeatureTools.RemoveFeatureFromName(globeControl1, "trackPolygon"); globeControl1.Globe.Action = EnumAction3D.TrackPolygon; globeControl1.TrackPolygonEndEvent += globeControl1_TrackPolygonEndEvent; } @@ -259,7 +259,7 @@ private void FrmAccessoriesgather_FormClosing(object sender, FormClosingEventArgs e) { frm = null; - Utility.RemoveFeatureFromName(globeControl1, "trackPolygon"); + FeatureTools.RemoveFeatureFromName(globeControl1, "trackPolygon"); globeControl1.Globe.Action = EnumAction3D.ActionNull; globeControl1.TrackPolygonEndEvent -= globeControl1_TrackPolygonEndEvent; } diff --git a/Cyberpipe.suo b/Cyberpipe.suo index 191d4bb..f78f4b3 100644 --- a/Cyberpipe.suo +++ b/Cyberpipe.suo Binary files differ diff --git a/FeatureStatisticsService.cs b/FeatureStatisticsService.cs index 331ee47..b127fe3 100644 --- a/FeatureStatisticsService.cs +++ b/FeatureStatisticsService.cs @@ -190,7 +190,7 @@ List result = new List(); //layer.Name是表名 - string[] accessStrs = Utility.getAccStrsByLayer(layer.Name); + string[] accessStrs = FeatureTools.GetAccStrsByLayer(layer.Name); foreach (string accssname in accessStrs) { diff --git a/FeatureTools.cs b/FeatureTools.cs index be4b469..0ba33d7 100644 --- a/FeatureTools.cs +++ b/FeatureTools.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Data; using System.Linq; using System.Text; using System.Windows.Forms; @@ -106,5 +107,46 @@ } return value; } + + /// + /// 根据附属物图层名字得到里面含有的附属物 + /// + /// + /// + public static string[] GetAccStrsByLayer(string layername) + { + string[] accStrs = null; + string sql = "select 附属物名称 from " + layername + " group by 附属物名称"; + DataSet dataset = OledbHelper.getDataSet(sql, layername); + if (dataset == null) return null; + accStrs = new string[dataset.Tables[0].Rows.Count]; + for (int i = 0; i < dataset.Tables[0].Rows.Count; i++) + { + accStrs[i] = dataset.Tables[0].Rows[i][0].ToString(); + } + return accStrs; + } + + /// + /// 删除内存图层中指定名称的feature + /// + /// + /// + public static void RemoveFeatureFromName(GSOGlobeControl globeControl1, string featureName) + { + GSOFeatures features = globeControl1.Globe.MemoryLayer.GetFeatureByName(featureName, true); + if (features != null) + { + for (int i = features.Length - 1; i >= 0; i--) + { + GSOFeature feature = features[i]; + if (feature != null) + { + globeControl1.Globe.MemoryLayer.RemoveFeatureByID(feature.ID); + } + } + } + globeControl1.Refresh(); + } } } diff --git a/FrmAccessoriesSensor.cs b/FrmAccessoriesSensor.cs index 98aa1cf..542f19a 100644 --- a/FrmAccessoriesSensor.cs +++ b/FrmAccessoriesSensor.cs @@ -240,7 +240,7 @@ { if (clbPipeLine.CheckedItems.Count > 0) { - Utility.RemoveFeatureFromName(globeControl1, "trackPolygon"); + FeatureTools.RemoveFeatureFromName(globeControl1, "trackPolygon"); globeControl1.Globe.Action = EnumAction3D.TrackPolygon; globeControl1.TrackPolygonEndEvent += globeControl1_TrackPolygonEndEvent; } @@ -259,7 +259,7 @@ private void FrmAccessoriesgather_FormClosing(object sender, FormClosingEventArgs e) { frm = null; - Utility.RemoveFeatureFromName(globeControl1, "trackPolygon"); + FeatureTools.RemoveFeatureFromName(globeControl1, "trackPolygon"); globeControl1.Globe.Action = EnumAction3D.ActionNull; globeControl1.TrackPolygonEndEvent -= globeControl1_TrackPolygonEndEvent; } diff --git a/FrmAccessoriesgather.cs b/FrmAccessoriesgather.cs index e1d176e..c36273b 100644 --- a/FrmAccessoriesgather.cs +++ b/FrmAccessoriesgather.cs @@ -118,7 +118,7 @@ { if (clbPipeLine2.Text!="") { - Utility.RemoveFeatureFromName(globeControl1, "trackPolygon"); + FeatureTools.RemoveFeatureFromName(globeControl1, "trackPolygon"); globeControl1.Globe.Action = EnumAction3D.TrackPolygon; globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; globeControl1.TrackPolygonEndEvent += globeControl1_TrackPolygonEndEvent; @@ -295,7 +295,7 @@ private void FrmAccessoriesgather_FormClosing(object sender, FormClosingEventArgs e) { frm = null; - Utility.RemoveFeatureFromName(globeControl1, "trackPolygon"); + FeatureTools.RemoveFeatureFromName(globeControl1, "trackPolygon"); globeControl1.TrackPolygonEndEvent -= globeControl1_TrackPolygonEndEvent; globeControl1.Globe.Action = EnumAction3D.ActionNull; diff --git a/Cyberpipe.suo b/Cyberpipe.suo index 191d4bb..f78f4b3 100644 --- a/Cyberpipe.suo +++ b/Cyberpipe.suo Binary files differ diff --git a/FeatureStatisticsService.cs b/FeatureStatisticsService.cs index 331ee47..b127fe3 100644 --- a/FeatureStatisticsService.cs +++ b/FeatureStatisticsService.cs @@ -190,7 +190,7 @@ List result = new List(); //layer.Name是表名 - string[] accessStrs = Utility.getAccStrsByLayer(layer.Name); + string[] accessStrs = FeatureTools.GetAccStrsByLayer(layer.Name); foreach (string accssname in accessStrs) { diff --git a/FeatureTools.cs b/FeatureTools.cs index be4b469..0ba33d7 100644 --- a/FeatureTools.cs +++ b/FeatureTools.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Data; using System.Linq; using System.Text; using System.Windows.Forms; @@ -106,5 +107,46 @@ } return value; } + + /// + /// 根据附属物图层名字得到里面含有的附属物 + /// + /// + /// + public static string[] GetAccStrsByLayer(string layername) + { + string[] accStrs = null; + string sql = "select 附属物名称 from " + layername + " group by 附属物名称"; + DataSet dataset = OledbHelper.getDataSet(sql, layername); + if (dataset == null) return null; + accStrs = new string[dataset.Tables[0].Rows.Count]; + for (int i = 0; i < dataset.Tables[0].Rows.Count; i++) + { + accStrs[i] = dataset.Tables[0].Rows[i][0].ToString(); + } + return accStrs; + } + + /// + /// 删除内存图层中指定名称的feature + /// + /// + /// + public static void RemoveFeatureFromName(GSOGlobeControl globeControl1, string featureName) + { + GSOFeatures features = globeControl1.Globe.MemoryLayer.GetFeatureByName(featureName, true); + if (features != null) + { + for (int i = features.Length - 1; i >= 0; i--) + { + GSOFeature feature = features[i]; + if (feature != null) + { + globeControl1.Globe.MemoryLayer.RemoveFeatureByID(feature.ID); + } + } + } + globeControl1.Refresh(); + } } } diff --git a/FrmAccessoriesSensor.cs b/FrmAccessoriesSensor.cs index 98aa1cf..542f19a 100644 --- a/FrmAccessoriesSensor.cs +++ b/FrmAccessoriesSensor.cs @@ -240,7 +240,7 @@ { if (clbPipeLine.CheckedItems.Count > 0) { - Utility.RemoveFeatureFromName(globeControl1, "trackPolygon"); + FeatureTools.RemoveFeatureFromName(globeControl1, "trackPolygon"); globeControl1.Globe.Action = EnumAction3D.TrackPolygon; globeControl1.TrackPolygonEndEvent += globeControl1_TrackPolygonEndEvent; } @@ -259,7 +259,7 @@ private void FrmAccessoriesgather_FormClosing(object sender, FormClosingEventArgs e) { frm = null; - Utility.RemoveFeatureFromName(globeControl1, "trackPolygon"); + FeatureTools.RemoveFeatureFromName(globeControl1, "trackPolygon"); globeControl1.Globe.Action = EnumAction3D.ActionNull; globeControl1.TrackPolygonEndEvent -= globeControl1_TrackPolygonEndEvent; } diff --git a/FrmAccessoriesgather.cs b/FrmAccessoriesgather.cs index e1d176e..c36273b 100644 --- a/FrmAccessoriesgather.cs +++ b/FrmAccessoriesgather.cs @@ -118,7 +118,7 @@ { if (clbPipeLine2.Text!="") { - Utility.RemoveFeatureFromName(globeControl1, "trackPolygon"); + FeatureTools.RemoveFeatureFromName(globeControl1, "trackPolygon"); globeControl1.Globe.Action = EnumAction3D.TrackPolygon; globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; globeControl1.TrackPolygonEndEvent += globeControl1_TrackPolygonEndEvent; @@ -295,7 +295,7 @@ private void FrmAccessoriesgather_FormClosing(object sender, FormClosingEventArgs e) { frm = null; - Utility.RemoveFeatureFromName(globeControl1, "trackPolygon"); + FeatureTools.RemoveFeatureFromName(globeControl1, "trackPolygon"); globeControl1.TrackPolygonEndEvent -= globeControl1_TrackPolygonEndEvent; globeControl1.Globe.Action = EnumAction3D.ActionNull; diff --git a/FrmpipeDeepstatis.cs b/FrmpipeDeepstatis.cs index 6a5c895..8d915a9 100644 --- a/FrmpipeDeepstatis.cs +++ b/FrmpipeDeepstatis.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Diagnostics; using System.IO; +using System.Reflection; using System.Text; using System.Windows.Forms; using System.Windows.Forms.DataVisualization.Charting; @@ -320,7 +321,7 @@ MessageBox.Show("请添加分段"); return; } - Utility.RemoveFeatureFromName(globeControl1, "trackPolygon"); + FeatureTools.RemoveFeatureFromName(globeControl1, "trackPolygon"); globeControl1.Globe.Action = EnumAction3D.TrackPolygon; globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; globeControl1.TrackPolygonEndEvent += globeControl1_TrackPolygonEndEvent; @@ -408,12 +409,11 @@ TextBox control; private void dataGridViewX2_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) { - if (e.Control.GetType().BaseType.Name == "TextBox") - { - control = new TextBox(); - control = (TextBox)e.Control; - control.KeyPress += control_KeyPress; - } + MemberInfo memberInfo = e.Control.GetType().BaseType; + if (memberInfo != null && !memberInfo.Name.Equals("TextBox")) return; + control = new TextBox(); + control = (TextBox)e.Control; + control.KeyPress += control_KeyPress; } /// /// 键盘按键按下事件处理 @@ -423,28 +423,24 @@ void control_KeyPress(object sender, KeyPressEventArgs e) { TextBox text = sender as TextBox; + if (text == null) return; if ((e.KeyChar < 48 || e.KeyChar > 57) && (e.KeyChar != 8) && e.KeyChar != 46) { e.Handled = true; } - if (e.KeyChar == 46) //小数点 + if (e.KeyChar != 46) return; + if (text.Text.Length <= 0) + e.Handled = true; //小数点不能在第一位 + else //处理不规则的小数点 { - if (text.Text.Length <= 0) - e.Handled = true; //小数点不能在第一位 - else //处理不规则的小数点 + float f; + float oldf; + bool b1 = false, b2 = false; + b1 = float.TryParse(text.Text, out oldf); + b2 = float.TryParse(text.Text + e.KeyChar, out f); + if (!b2) { - float f; - float oldf; - bool b1 = false, b2 = false; - b1 = float.TryParse(text.Text, out oldf); - b2 = float.TryParse(text.Text + e.KeyChar, out f); - if (b2 == false) - { - if (b1) - e.Handled = true; - else - e.Handled = false; - } + e.Handled = b1; } } } @@ -457,7 +453,7 @@ { frm = null; - Utility.RemoveFeatureFromName(globeControl1, "trackPolygon"); + FeatureTools.RemoveFeatureFromName(globeControl1, "trackPolygon"); globeControl1.TrackPolygonEndEvent -= globeControl1_TrackPolygonEndEvent; globeControl1.Globe.Action = EnumAction3D.ActionNull; diff --git a/Cyberpipe.suo b/Cyberpipe.suo index 191d4bb..f78f4b3 100644 --- a/Cyberpipe.suo +++ b/Cyberpipe.suo Binary files differ diff --git a/FeatureStatisticsService.cs b/FeatureStatisticsService.cs index 331ee47..b127fe3 100644 --- a/FeatureStatisticsService.cs +++ b/FeatureStatisticsService.cs @@ -190,7 +190,7 @@ List result = new List(); //layer.Name是表名 - string[] accessStrs = Utility.getAccStrsByLayer(layer.Name); + string[] accessStrs = FeatureTools.GetAccStrsByLayer(layer.Name); foreach (string accssname in accessStrs) { diff --git a/FeatureTools.cs b/FeatureTools.cs index be4b469..0ba33d7 100644 --- a/FeatureTools.cs +++ b/FeatureTools.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Data; using System.Linq; using System.Text; using System.Windows.Forms; @@ -106,5 +107,46 @@ } return value; } + + /// + /// 根据附属物图层名字得到里面含有的附属物 + /// + /// + /// + public static string[] GetAccStrsByLayer(string layername) + { + string[] accStrs = null; + string sql = "select 附属物名称 from " + layername + " group by 附属物名称"; + DataSet dataset = OledbHelper.getDataSet(sql, layername); + if (dataset == null) return null; + accStrs = new string[dataset.Tables[0].Rows.Count]; + for (int i = 0; i < dataset.Tables[0].Rows.Count; i++) + { + accStrs[i] = dataset.Tables[0].Rows[i][0].ToString(); + } + return accStrs; + } + + /// + /// 删除内存图层中指定名称的feature + /// + /// + /// + public static void RemoveFeatureFromName(GSOGlobeControl globeControl1, string featureName) + { + GSOFeatures features = globeControl1.Globe.MemoryLayer.GetFeatureByName(featureName, true); + if (features != null) + { + for (int i = features.Length - 1; i >= 0; i--) + { + GSOFeature feature = features[i]; + if (feature != null) + { + globeControl1.Globe.MemoryLayer.RemoveFeatureByID(feature.ID); + } + } + } + globeControl1.Refresh(); + } } } diff --git a/FrmAccessoriesSensor.cs b/FrmAccessoriesSensor.cs index 98aa1cf..542f19a 100644 --- a/FrmAccessoriesSensor.cs +++ b/FrmAccessoriesSensor.cs @@ -240,7 +240,7 @@ { if (clbPipeLine.CheckedItems.Count > 0) { - Utility.RemoveFeatureFromName(globeControl1, "trackPolygon"); + FeatureTools.RemoveFeatureFromName(globeControl1, "trackPolygon"); globeControl1.Globe.Action = EnumAction3D.TrackPolygon; globeControl1.TrackPolygonEndEvent += globeControl1_TrackPolygonEndEvent; } @@ -259,7 +259,7 @@ private void FrmAccessoriesgather_FormClosing(object sender, FormClosingEventArgs e) { frm = null; - Utility.RemoveFeatureFromName(globeControl1, "trackPolygon"); + FeatureTools.RemoveFeatureFromName(globeControl1, "trackPolygon"); globeControl1.Globe.Action = EnumAction3D.ActionNull; globeControl1.TrackPolygonEndEvent -= globeControl1_TrackPolygonEndEvent; } diff --git a/FrmAccessoriesgather.cs b/FrmAccessoriesgather.cs index e1d176e..c36273b 100644 --- a/FrmAccessoriesgather.cs +++ b/FrmAccessoriesgather.cs @@ -118,7 +118,7 @@ { if (clbPipeLine2.Text!="") { - Utility.RemoveFeatureFromName(globeControl1, "trackPolygon"); + FeatureTools.RemoveFeatureFromName(globeControl1, "trackPolygon"); globeControl1.Globe.Action = EnumAction3D.TrackPolygon; globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; globeControl1.TrackPolygonEndEvent += globeControl1_TrackPolygonEndEvent; @@ -295,7 +295,7 @@ private void FrmAccessoriesgather_FormClosing(object sender, FormClosingEventArgs e) { frm = null; - Utility.RemoveFeatureFromName(globeControl1, "trackPolygon"); + FeatureTools.RemoveFeatureFromName(globeControl1, "trackPolygon"); globeControl1.TrackPolygonEndEvent -= globeControl1_TrackPolygonEndEvent; globeControl1.Globe.Action = EnumAction3D.ActionNull; diff --git a/FrmpipeDeepstatis.cs b/FrmpipeDeepstatis.cs index 6a5c895..8d915a9 100644 --- a/FrmpipeDeepstatis.cs +++ b/FrmpipeDeepstatis.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Diagnostics; using System.IO; +using System.Reflection; using System.Text; using System.Windows.Forms; using System.Windows.Forms.DataVisualization.Charting; @@ -320,7 +321,7 @@ MessageBox.Show("请添加分段"); return; } - Utility.RemoveFeatureFromName(globeControl1, "trackPolygon"); + FeatureTools.RemoveFeatureFromName(globeControl1, "trackPolygon"); globeControl1.Globe.Action = EnumAction3D.TrackPolygon; globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; globeControl1.TrackPolygonEndEvent += globeControl1_TrackPolygonEndEvent; @@ -408,12 +409,11 @@ TextBox control; private void dataGridViewX2_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) { - if (e.Control.GetType().BaseType.Name == "TextBox") - { - control = new TextBox(); - control = (TextBox)e.Control; - control.KeyPress += control_KeyPress; - } + MemberInfo memberInfo = e.Control.GetType().BaseType; + if (memberInfo != null && !memberInfo.Name.Equals("TextBox")) return; + control = new TextBox(); + control = (TextBox)e.Control; + control.KeyPress += control_KeyPress; } /// /// 键盘按键按下事件处理 @@ -423,28 +423,24 @@ void control_KeyPress(object sender, KeyPressEventArgs e) { TextBox text = sender as TextBox; + if (text == null) return; if ((e.KeyChar < 48 || e.KeyChar > 57) && (e.KeyChar != 8) && e.KeyChar != 46) { e.Handled = true; } - if (e.KeyChar == 46) //小数点 + if (e.KeyChar != 46) return; + if (text.Text.Length <= 0) + e.Handled = true; //小数点不能在第一位 + else //处理不规则的小数点 { - if (text.Text.Length <= 0) - e.Handled = true; //小数点不能在第一位 - else //处理不规则的小数点 + float f; + float oldf; + bool b1 = false, b2 = false; + b1 = float.TryParse(text.Text, out oldf); + b2 = float.TryParse(text.Text + e.KeyChar, out f); + if (!b2) { - float f; - float oldf; - bool b1 = false, b2 = false; - b1 = float.TryParse(text.Text, out oldf); - b2 = float.TryParse(text.Text + e.KeyChar, out f); - if (b2 == false) - { - if (b1) - e.Handled = true; - else - e.Handled = false; - } + e.Handled = b1; } } } @@ -457,7 +453,7 @@ { frm = null; - Utility.RemoveFeatureFromName(globeControl1, "trackPolygon"); + FeatureTools.RemoveFeatureFromName(globeControl1, "trackPolygon"); globeControl1.TrackPolygonEndEvent -= globeControl1_TrackPolygonEndEvent; globeControl1.Globe.Action = EnumAction3D.ActionNull; diff --git a/FrmpipeDiametergather.cs b/FrmpipeDiametergather.cs index a9d96fa..c09aaf1 100644 --- a/FrmpipeDiametergather.cs +++ b/FrmpipeDiametergather.cs @@ -154,7 +154,7 @@ MessageBox.Show("请选择图层!"); return; } - Utility.RemoveFeatureFromName(globeControl1, "trackPolygon"); + FeatureTools.RemoveFeatureFromName(globeControl1, "trackPolygon"); globeControl1.Globe.Action = EnumAction3D.TrackPolygon; globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; globeControl1.TrackPolygonEndEvent += globeControl1_TrackPolygonEndEvent; @@ -392,7 +392,7 @@ private void FrmpipeDiametergather_FormClosing(object sender, FormClosingEventArgs e) { frm = null; - Utility.RemoveFeatureFromName(globeControl1, "trackPolygon"); + FeatureTools.RemoveFeatureFromName(globeControl1, "trackPolygon"); globeControl1.TrackPolygonEndEvent -= globeControl1_TrackPolygonEndEvent; globeControl1.Globe.Action = EnumAction3D.ActionNull; diff --git a/Cyberpipe.suo b/Cyberpipe.suo index 191d4bb..f78f4b3 100644 --- a/Cyberpipe.suo +++ b/Cyberpipe.suo Binary files differ diff --git a/FeatureStatisticsService.cs b/FeatureStatisticsService.cs index 331ee47..b127fe3 100644 --- a/FeatureStatisticsService.cs +++ b/FeatureStatisticsService.cs @@ -190,7 +190,7 @@ List result = new List(); //layer.Name是表名 - string[] accessStrs = Utility.getAccStrsByLayer(layer.Name); + string[] accessStrs = FeatureTools.GetAccStrsByLayer(layer.Name); foreach (string accssname in accessStrs) { diff --git a/FeatureTools.cs b/FeatureTools.cs index be4b469..0ba33d7 100644 --- a/FeatureTools.cs +++ b/FeatureTools.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Data; using System.Linq; using System.Text; using System.Windows.Forms; @@ -106,5 +107,46 @@ } return value; } + + /// + /// 根据附属物图层名字得到里面含有的附属物 + /// + /// + /// + public static string[] GetAccStrsByLayer(string layername) + { + string[] accStrs = null; + string sql = "select 附属物名称 from " + layername + " group by 附属物名称"; + DataSet dataset = OledbHelper.getDataSet(sql, layername); + if (dataset == null) return null; + accStrs = new string[dataset.Tables[0].Rows.Count]; + for (int i = 0; i < dataset.Tables[0].Rows.Count; i++) + { + accStrs[i] = dataset.Tables[0].Rows[i][0].ToString(); + } + return accStrs; + } + + /// + /// 删除内存图层中指定名称的feature + /// + /// + /// + public static void RemoveFeatureFromName(GSOGlobeControl globeControl1, string featureName) + { + GSOFeatures features = globeControl1.Globe.MemoryLayer.GetFeatureByName(featureName, true); + if (features != null) + { + for (int i = features.Length - 1; i >= 0; i--) + { + GSOFeature feature = features[i]; + if (feature != null) + { + globeControl1.Globe.MemoryLayer.RemoveFeatureByID(feature.ID); + } + } + } + globeControl1.Refresh(); + } } } diff --git a/FrmAccessoriesSensor.cs b/FrmAccessoriesSensor.cs index 98aa1cf..542f19a 100644 --- a/FrmAccessoriesSensor.cs +++ b/FrmAccessoriesSensor.cs @@ -240,7 +240,7 @@ { if (clbPipeLine.CheckedItems.Count > 0) { - Utility.RemoveFeatureFromName(globeControl1, "trackPolygon"); + FeatureTools.RemoveFeatureFromName(globeControl1, "trackPolygon"); globeControl1.Globe.Action = EnumAction3D.TrackPolygon; globeControl1.TrackPolygonEndEvent += globeControl1_TrackPolygonEndEvent; } @@ -259,7 +259,7 @@ private void FrmAccessoriesgather_FormClosing(object sender, FormClosingEventArgs e) { frm = null; - Utility.RemoveFeatureFromName(globeControl1, "trackPolygon"); + FeatureTools.RemoveFeatureFromName(globeControl1, "trackPolygon"); globeControl1.Globe.Action = EnumAction3D.ActionNull; globeControl1.TrackPolygonEndEvent -= globeControl1_TrackPolygonEndEvent; } diff --git a/FrmAccessoriesgather.cs b/FrmAccessoriesgather.cs index e1d176e..c36273b 100644 --- a/FrmAccessoriesgather.cs +++ b/FrmAccessoriesgather.cs @@ -118,7 +118,7 @@ { if (clbPipeLine2.Text!="") { - Utility.RemoveFeatureFromName(globeControl1, "trackPolygon"); + FeatureTools.RemoveFeatureFromName(globeControl1, "trackPolygon"); globeControl1.Globe.Action = EnumAction3D.TrackPolygon; globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; globeControl1.TrackPolygonEndEvent += globeControl1_TrackPolygonEndEvent; @@ -295,7 +295,7 @@ private void FrmAccessoriesgather_FormClosing(object sender, FormClosingEventArgs e) { frm = null; - Utility.RemoveFeatureFromName(globeControl1, "trackPolygon"); + FeatureTools.RemoveFeatureFromName(globeControl1, "trackPolygon"); globeControl1.TrackPolygonEndEvent -= globeControl1_TrackPolygonEndEvent; globeControl1.Globe.Action = EnumAction3D.ActionNull; diff --git a/FrmpipeDeepstatis.cs b/FrmpipeDeepstatis.cs index 6a5c895..8d915a9 100644 --- a/FrmpipeDeepstatis.cs +++ b/FrmpipeDeepstatis.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Diagnostics; using System.IO; +using System.Reflection; using System.Text; using System.Windows.Forms; using System.Windows.Forms.DataVisualization.Charting; @@ -320,7 +321,7 @@ MessageBox.Show("请添加分段"); return; } - Utility.RemoveFeatureFromName(globeControl1, "trackPolygon"); + FeatureTools.RemoveFeatureFromName(globeControl1, "trackPolygon"); globeControl1.Globe.Action = EnumAction3D.TrackPolygon; globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; globeControl1.TrackPolygonEndEvent += globeControl1_TrackPolygonEndEvent; @@ -408,12 +409,11 @@ TextBox control; private void dataGridViewX2_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) { - if (e.Control.GetType().BaseType.Name == "TextBox") - { - control = new TextBox(); - control = (TextBox)e.Control; - control.KeyPress += control_KeyPress; - } + MemberInfo memberInfo = e.Control.GetType().BaseType; + if (memberInfo != null && !memberInfo.Name.Equals("TextBox")) return; + control = new TextBox(); + control = (TextBox)e.Control; + control.KeyPress += control_KeyPress; } /// /// 键盘按键按下事件处理 @@ -423,28 +423,24 @@ void control_KeyPress(object sender, KeyPressEventArgs e) { TextBox text = sender as TextBox; + if (text == null) return; if ((e.KeyChar < 48 || e.KeyChar > 57) && (e.KeyChar != 8) && e.KeyChar != 46) { e.Handled = true; } - if (e.KeyChar == 46) //小数点 + if (e.KeyChar != 46) return; + if (text.Text.Length <= 0) + e.Handled = true; //小数点不能在第一位 + else //处理不规则的小数点 { - if (text.Text.Length <= 0) - e.Handled = true; //小数点不能在第一位 - else //处理不规则的小数点 + float f; + float oldf; + bool b1 = false, b2 = false; + b1 = float.TryParse(text.Text, out oldf); + b2 = float.TryParse(text.Text + e.KeyChar, out f); + if (!b2) { - float f; - float oldf; - bool b1 = false, b2 = false; - b1 = float.TryParse(text.Text, out oldf); - b2 = float.TryParse(text.Text + e.KeyChar, out f); - if (b2 == false) - { - if (b1) - e.Handled = true; - else - e.Handled = false; - } + e.Handled = b1; } } } @@ -457,7 +453,7 @@ { frm = null; - Utility.RemoveFeatureFromName(globeControl1, "trackPolygon"); + FeatureTools.RemoveFeatureFromName(globeControl1, "trackPolygon"); globeControl1.TrackPolygonEndEvent -= globeControl1_TrackPolygonEndEvent; globeControl1.Globe.Action = EnumAction3D.ActionNull; diff --git a/FrmpipeDiametergather.cs b/FrmpipeDiametergather.cs index a9d96fa..c09aaf1 100644 --- a/FrmpipeDiametergather.cs +++ b/FrmpipeDiametergather.cs @@ -154,7 +154,7 @@ MessageBox.Show("请选择图层!"); return; } - Utility.RemoveFeatureFromName(globeControl1, "trackPolygon"); + FeatureTools.RemoveFeatureFromName(globeControl1, "trackPolygon"); globeControl1.Globe.Action = EnumAction3D.TrackPolygon; globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; globeControl1.TrackPolygonEndEvent += globeControl1_TrackPolygonEndEvent; @@ -392,7 +392,7 @@ private void FrmpipeDiametergather_FormClosing(object sender, FormClosingEventArgs e) { frm = null; - Utility.RemoveFeatureFromName(globeControl1, "trackPolygon"); + FeatureTools.RemoveFeatureFromName(globeControl1, "trackPolygon"); globeControl1.TrackPolygonEndEvent -= globeControl1_TrackPolygonEndEvent; globeControl1.Globe.Action = EnumAction3D.ActionNull; diff --git a/FrmpipeMaterialGather.cs b/FrmpipeMaterialGather.cs index 44e7f24..abbc336 100644 --- a/FrmpipeMaterialGather.cs +++ b/FrmpipeMaterialGather.cs @@ -304,7 +304,7 @@ MessageBox.Show("请选择材质类型!"); return; } - Utility.RemoveFeatureFromName(globeControl1, "trackPolygon"); + FeatureTools.RemoveFeatureFromName(globeControl1, "trackPolygon"); globeControl1.Globe.Action = EnumAction3D.TrackPolygon; globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; globeControl1.TrackPolygonEndEvent += globeControl1_TrackPolygonEndEvent; @@ -318,7 +318,7 @@ private void FrmpipeMaterialGather_FormClosing(object sender, FormClosingEventArgs e) { frm = null; - Utility.RemoveFeatureFromName(globeControl1, "trackPolygon"); + FeatureTools.RemoveFeatureFromName(globeControl1, "trackPolygon"); globeControl1.TrackPolygonEndEvent -= globeControl1_TrackPolygonEndEvent; globeControl1.Globe.Action = EnumAction3D.ActionNull; diff --git a/Cyberpipe.suo b/Cyberpipe.suo index 191d4bb..f78f4b3 100644 --- a/Cyberpipe.suo +++ b/Cyberpipe.suo Binary files differ diff --git a/FeatureStatisticsService.cs b/FeatureStatisticsService.cs index 331ee47..b127fe3 100644 --- a/FeatureStatisticsService.cs +++ b/FeatureStatisticsService.cs @@ -190,7 +190,7 @@ List result = new List(); //layer.Name是表名 - string[] accessStrs = Utility.getAccStrsByLayer(layer.Name); + string[] accessStrs = FeatureTools.GetAccStrsByLayer(layer.Name); foreach (string accssname in accessStrs) { diff --git a/FeatureTools.cs b/FeatureTools.cs index be4b469..0ba33d7 100644 --- a/FeatureTools.cs +++ b/FeatureTools.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Data; using System.Linq; using System.Text; using System.Windows.Forms; @@ -106,5 +107,46 @@ } return value; } + + /// + /// 根据附属物图层名字得到里面含有的附属物 + /// + /// + /// + public static string[] GetAccStrsByLayer(string layername) + { + string[] accStrs = null; + string sql = "select 附属物名称 from " + layername + " group by 附属物名称"; + DataSet dataset = OledbHelper.getDataSet(sql, layername); + if (dataset == null) return null; + accStrs = new string[dataset.Tables[0].Rows.Count]; + for (int i = 0; i < dataset.Tables[0].Rows.Count; i++) + { + accStrs[i] = dataset.Tables[0].Rows[i][0].ToString(); + } + return accStrs; + } + + /// + /// 删除内存图层中指定名称的feature + /// + /// + /// + public static void RemoveFeatureFromName(GSOGlobeControl globeControl1, string featureName) + { + GSOFeatures features = globeControl1.Globe.MemoryLayer.GetFeatureByName(featureName, true); + if (features != null) + { + for (int i = features.Length - 1; i >= 0; i--) + { + GSOFeature feature = features[i]; + if (feature != null) + { + globeControl1.Globe.MemoryLayer.RemoveFeatureByID(feature.ID); + } + } + } + globeControl1.Refresh(); + } } } diff --git a/FrmAccessoriesSensor.cs b/FrmAccessoriesSensor.cs index 98aa1cf..542f19a 100644 --- a/FrmAccessoriesSensor.cs +++ b/FrmAccessoriesSensor.cs @@ -240,7 +240,7 @@ { if (clbPipeLine.CheckedItems.Count > 0) { - Utility.RemoveFeatureFromName(globeControl1, "trackPolygon"); + FeatureTools.RemoveFeatureFromName(globeControl1, "trackPolygon"); globeControl1.Globe.Action = EnumAction3D.TrackPolygon; globeControl1.TrackPolygonEndEvent += globeControl1_TrackPolygonEndEvent; } @@ -259,7 +259,7 @@ private void FrmAccessoriesgather_FormClosing(object sender, FormClosingEventArgs e) { frm = null; - Utility.RemoveFeatureFromName(globeControl1, "trackPolygon"); + FeatureTools.RemoveFeatureFromName(globeControl1, "trackPolygon"); globeControl1.Globe.Action = EnumAction3D.ActionNull; globeControl1.TrackPolygonEndEvent -= globeControl1_TrackPolygonEndEvent; } diff --git a/FrmAccessoriesgather.cs b/FrmAccessoriesgather.cs index e1d176e..c36273b 100644 --- a/FrmAccessoriesgather.cs +++ b/FrmAccessoriesgather.cs @@ -118,7 +118,7 @@ { if (clbPipeLine2.Text!="") { - Utility.RemoveFeatureFromName(globeControl1, "trackPolygon"); + FeatureTools.RemoveFeatureFromName(globeControl1, "trackPolygon"); globeControl1.Globe.Action = EnumAction3D.TrackPolygon; globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; globeControl1.TrackPolygonEndEvent += globeControl1_TrackPolygonEndEvent; @@ -295,7 +295,7 @@ private void FrmAccessoriesgather_FormClosing(object sender, FormClosingEventArgs e) { frm = null; - Utility.RemoveFeatureFromName(globeControl1, "trackPolygon"); + FeatureTools.RemoveFeatureFromName(globeControl1, "trackPolygon"); globeControl1.TrackPolygonEndEvent -= globeControl1_TrackPolygonEndEvent; globeControl1.Globe.Action = EnumAction3D.ActionNull; diff --git a/FrmpipeDeepstatis.cs b/FrmpipeDeepstatis.cs index 6a5c895..8d915a9 100644 --- a/FrmpipeDeepstatis.cs +++ b/FrmpipeDeepstatis.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Diagnostics; using System.IO; +using System.Reflection; using System.Text; using System.Windows.Forms; using System.Windows.Forms.DataVisualization.Charting; @@ -320,7 +321,7 @@ MessageBox.Show("请添加分段"); return; } - Utility.RemoveFeatureFromName(globeControl1, "trackPolygon"); + FeatureTools.RemoveFeatureFromName(globeControl1, "trackPolygon"); globeControl1.Globe.Action = EnumAction3D.TrackPolygon; globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; globeControl1.TrackPolygonEndEvent += globeControl1_TrackPolygonEndEvent; @@ -408,12 +409,11 @@ TextBox control; private void dataGridViewX2_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) { - if (e.Control.GetType().BaseType.Name == "TextBox") - { - control = new TextBox(); - control = (TextBox)e.Control; - control.KeyPress += control_KeyPress; - } + MemberInfo memberInfo = e.Control.GetType().BaseType; + if (memberInfo != null && !memberInfo.Name.Equals("TextBox")) return; + control = new TextBox(); + control = (TextBox)e.Control; + control.KeyPress += control_KeyPress; } /// /// 键盘按键按下事件处理 @@ -423,28 +423,24 @@ void control_KeyPress(object sender, KeyPressEventArgs e) { TextBox text = sender as TextBox; + if (text == null) return; if ((e.KeyChar < 48 || e.KeyChar > 57) && (e.KeyChar != 8) && e.KeyChar != 46) { e.Handled = true; } - if (e.KeyChar == 46) //小数点 + if (e.KeyChar != 46) return; + if (text.Text.Length <= 0) + e.Handled = true; //小数点不能在第一位 + else //处理不规则的小数点 { - if (text.Text.Length <= 0) - e.Handled = true; //小数点不能在第一位 - else //处理不规则的小数点 + float f; + float oldf; + bool b1 = false, b2 = false; + b1 = float.TryParse(text.Text, out oldf); + b2 = float.TryParse(text.Text + e.KeyChar, out f); + if (!b2) { - float f; - float oldf; - bool b1 = false, b2 = false; - b1 = float.TryParse(text.Text, out oldf); - b2 = float.TryParse(text.Text + e.KeyChar, out f); - if (b2 == false) - { - if (b1) - e.Handled = true; - else - e.Handled = false; - } + e.Handled = b1; } } } @@ -457,7 +453,7 @@ { frm = null; - Utility.RemoveFeatureFromName(globeControl1, "trackPolygon"); + FeatureTools.RemoveFeatureFromName(globeControl1, "trackPolygon"); globeControl1.TrackPolygonEndEvent -= globeControl1_TrackPolygonEndEvent; globeControl1.Globe.Action = EnumAction3D.ActionNull; diff --git a/FrmpipeDiametergather.cs b/FrmpipeDiametergather.cs index a9d96fa..c09aaf1 100644 --- a/FrmpipeDiametergather.cs +++ b/FrmpipeDiametergather.cs @@ -154,7 +154,7 @@ MessageBox.Show("请选择图层!"); return; } - Utility.RemoveFeatureFromName(globeControl1, "trackPolygon"); + FeatureTools.RemoveFeatureFromName(globeControl1, "trackPolygon"); globeControl1.Globe.Action = EnumAction3D.TrackPolygon; globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; globeControl1.TrackPolygonEndEvent += globeControl1_TrackPolygonEndEvent; @@ -392,7 +392,7 @@ private void FrmpipeDiametergather_FormClosing(object sender, FormClosingEventArgs e) { frm = null; - Utility.RemoveFeatureFromName(globeControl1, "trackPolygon"); + FeatureTools.RemoveFeatureFromName(globeControl1, "trackPolygon"); globeControl1.TrackPolygonEndEvent -= globeControl1_TrackPolygonEndEvent; globeControl1.Globe.Action = EnumAction3D.ActionNull; diff --git a/FrmpipeMaterialGather.cs b/FrmpipeMaterialGather.cs index 44e7f24..abbc336 100644 --- a/FrmpipeMaterialGather.cs +++ b/FrmpipeMaterialGather.cs @@ -304,7 +304,7 @@ MessageBox.Show("请选择材质类型!"); return; } - Utility.RemoveFeatureFromName(globeControl1, "trackPolygon"); + FeatureTools.RemoveFeatureFromName(globeControl1, "trackPolygon"); globeControl1.Globe.Action = EnumAction3D.TrackPolygon; globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; globeControl1.TrackPolygonEndEvent += globeControl1_TrackPolygonEndEvent; @@ -318,7 +318,7 @@ private void FrmpipeMaterialGather_FormClosing(object sender, FormClosingEventArgs e) { frm = null; - Utility.RemoveFeatureFromName(globeControl1, "trackPolygon"); + FeatureTools.RemoveFeatureFromName(globeControl1, "trackPolygon"); globeControl1.TrackPolygonEndEvent -= globeControl1_TrackPolygonEndEvent; globeControl1.Globe.Action = EnumAction3D.ActionNull; diff --git a/Frmpipediameterstatis.cs b/Frmpipediameterstatis.cs index 4fb25a8..2f407dc 100644 --- a/Frmpipediameterstatis.cs +++ b/Frmpipediameterstatis.cs @@ -372,7 +372,7 @@ MessageBox.Show("请添加分段!"); return; } - Utility.RemoveFeatureFromName(globeControl1, "trackPolygon"); + FeatureTools.RemoveFeatureFromName(globeControl1, "trackPolygon"); globeControl1.Globe.Action = EnumAction3D.TrackPolygon; globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; globeControl1.TrackPolygonEndEvent += globeControl1_TrackPolygonEndEvent; @@ -422,7 +422,7 @@ globeControl1.Globe.Action = EnumAction3D.ActionNull; globeControl1.TrackPolygonEndEvent -= globeControl1_TrackPolygonEndEvent; - Utility.RemoveFeatureFromName(globeControl1, "trackPolygon"); + FeatureTools.RemoveFeatureFromName(globeControl1, "trackPolygon"); globeControl1.Globe.MemoryLayer.RemoveAllFeature(); } diff --git a/Cyberpipe.suo b/Cyberpipe.suo index 191d4bb..f78f4b3 100644 --- a/Cyberpipe.suo +++ b/Cyberpipe.suo Binary files differ diff --git a/FeatureStatisticsService.cs b/FeatureStatisticsService.cs index 331ee47..b127fe3 100644 --- a/FeatureStatisticsService.cs +++ b/FeatureStatisticsService.cs @@ -190,7 +190,7 @@ List result = new List(); //layer.Name是表名 - string[] accessStrs = Utility.getAccStrsByLayer(layer.Name); + string[] accessStrs = FeatureTools.GetAccStrsByLayer(layer.Name); foreach (string accssname in accessStrs) { diff --git a/FeatureTools.cs b/FeatureTools.cs index be4b469..0ba33d7 100644 --- a/FeatureTools.cs +++ b/FeatureTools.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Data; using System.Linq; using System.Text; using System.Windows.Forms; @@ -106,5 +107,46 @@ } return value; } + + /// + /// 根据附属物图层名字得到里面含有的附属物 + /// + /// + /// + public static string[] GetAccStrsByLayer(string layername) + { + string[] accStrs = null; + string sql = "select 附属物名称 from " + layername + " group by 附属物名称"; + DataSet dataset = OledbHelper.getDataSet(sql, layername); + if (dataset == null) return null; + accStrs = new string[dataset.Tables[0].Rows.Count]; + for (int i = 0; i < dataset.Tables[0].Rows.Count; i++) + { + accStrs[i] = dataset.Tables[0].Rows[i][0].ToString(); + } + return accStrs; + } + + /// + /// 删除内存图层中指定名称的feature + /// + /// + /// + public static void RemoveFeatureFromName(GSOGlobeControl globeControl1, string featureName) + { + GSOFeatures features = globeControl1.Globe.MemoryLayer.GetFeatureByName(featureName, true); + if (features != null) + { + for (int i = features.Length - 1; i >= 0; i--) + { + GSOFeature feature = features[i]; + if (feature != null) + { + globeControl1.Globe.MemoryLayer.RemoveFeatureByID(feature.ID); + } + } + } + globeControl1.Refresh(); + } } } diff --git a/FrmAccessoriesSensor.cs b/FrmAccessoriesSensor.cs index 98aa1cf..542f19a 100644 --- a/FrmAccessoriesSensor.cs +++ b/FrmAccessoriesSensor.cs @@ -240,7 +240,7 @@ { if (clbPipeLine.CheckedItems.Count > 0) { - Utility.RemoveFeatureFromName(globeControl1, "trackPolygon"); + FeatureTools.RemoveFeatureFromName(globeControl1, "trackPolygon"); globeControl1.Globe.Action = EnumAction3D.TrackPolygon; globeControl1.TrackPolygonEndEvent += globeControl1_TrackPolygonEndEvent; } @@ -259,7 +259,7 @@ private void FrmAccessoriesgather_FormClosing(object sender, FormClosingEventArgs e) { frm = null; - Utility.RemoveFeatureFromName(globeControl1, "trackPolygon"); + FeatureTools.RemoveFeatureFromName(globeControl1, "trackPolygon"); globeControl1.Globe.Action = EnumAction3D.ActionNull; globeControl1.TrackPolygonEndEvent -= globeControl1_TrackPolygonEndEvent; } diff --git a/FrmAccessoriesgather.cs b/FrmAccessoriesgather.cs index e1d176e..c36273b 100644 --- a/FrmAccessoriesgather.cs +++ b/FrmAccessoriesgather.cs @@ -118,7 +118,7 @@ { if (clbPipeLine2.Text!="") { - Utility.RemoveFeatureFromName(globeControl1, "trackPolygon"); + FeatureTools.RemoveFeatureFromName(globeControl1, "trackPolygon"); globeControl1.Globe.Action = EnumAction3D.TrackPolygon; globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; globeControl1.TrackPolygonEndEvent += globeControl1_TrackPolygonEndEvent; @@ -295,7 +295,7 @@ private void FrmAccessoriesgather_FormClosing(object sender, FormClosingEventArgs e) { frm = null; - Utility.RemoveFeatureFromName(globeControl1, "trackPolygon"); + FeatureTools.RemoveFeatureFromName(globeControl1, "trackPolygon"); globeControl1.TrackPolygonEndEvent -= globeControl1_TrackPolygonEndEvent; globeControl1.Globe.Action = EnumAction3D.ActionNull; diff --git a/FrmpipeDeepstatis.cs b/FrmpipeDeepstatis.cs index 6a5c895..8d915a9 100644 --- a/FrmpipeDeepstatis.cs +++ b/FrmpipeDeepstatis.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Diagnostics; using System.IO; +using System.Reflection; using System.Text; using System.Windows.Forms; using System.Windows.Forms.DataVisualization.Charting; @@ -320,7 +321,7 @@ MessageBox.Show("请添加分段"); return; } - Utility.RemoveFeatureFromName(globeControl1, "trackPolygon"); + FeatureTools.RemoveFeatureFromName(globeControl1, "trackPolygon"); globeControl1.Globe.Action = EnumAction3D.TrackPolygon; globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; globeControl1.TrackPolygonEndEvent += globeControl1_TrackPolygonEndEvent; @@ -408,12 +409,11 @@ TextBox control; private void dataGridViewX2_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) { - if (e.Control.GetType().BaseType.Name == "TextBox") - { - control = new TextBox(); - control = (TextBox)e.Control; - control.KeyPress += control_KeyPress; - } + MemberInfo memberInfo = e.Control.GetType().BaseType; + if (memberInfo != null && !memberInfo.Name.Equals("TextBox")) return; + control = new TextBox(); + control = (TextBox)e.Control; + control.KeyPress += control_KeyPress; } /// /// 键盘按键按下事件处理 @@ -423,28 +423,24 @@ void control_KeyPress(object sender, KeyPressEventArgs e) { TextBox text = sender as TextBox; + if (text == null) return; if ((e.KeyChar < 48 || e.KeyChar > 57) && (e.KeyChar != 8) && e.KeyChar != 46) { e.Handled = true; } - if (e.KeyChar == 46) //小数点 + if (e.KeyChar != 46) return; + if (text.Text.Length <= 0) + e.Handled = true; //小数点不能在第一位 + else //处理不规则的小数点 { - if (text.Text.Length <= 0) - e.Handled = true; //小数点不能在第一位 - else //处理不规则的小数点 + float f; + float oldf; + bool b1 = false, b2 = false; + b1 = float.TryParse(text.Text, out oldf); + b2 = float.TryParse(text.Text + e.KeyChar, out f); + if (!b2) { - float f; - float oldf; - bool b1 = false, b2 = false; - b1 = float.TryParse(text.Text, out oldf); - b2 = float.TryParse(text.Text + e.KeyChar, out f); - if (b2 == false) - { - if (b1) - e.Handled = true; - else - e.Handled = false; - } + e.Handled = b1; } } } @@ -457,7 +453,7 @@ { frm = null; - Utility.RemoveFeatureFromName(globeControl1, "trackPolygon"); + FeatureTools.RemoveFeatureFromName(globeControl1, "trackPolygon"); globeControl1.TrackPolygonEndEvent -= globeControl1_TrackPolygonEndEvent; globeControl1.Globe.Action = EnumAction3D.ActionNull; diff --git a/FrmpipeDiametergather.cs b/FrmpipeDiametergather.cs index a9d96fa..c09aaf1 100644 --- a/FrmpipeDiametergather.cs +++ b/FrmpipeDiametergather.cs @@ -154,7 +154,7 @@ MessageBox.Show("请选择图层!"); return; } - Utility.RemoveFeatureFromName(globeControl1, "trackPolygon"); + FeatureTools.RemoveFeatureFromName(globeControl1, "trackPolygon"); globeControl1.Globe.Action = EnumAction3D.TrackPolygon; globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; globeControl1.TrackPolygonEndEvent += globeControl1_TrackPolygonEndEvent; @@ -392,7 +392,7 @@ private void FrmpipeDiametergather_FormClosing(object sender, FormClosingEventArgs e) { frm = null; - Utility.RemoveFeatureFromName(globeControl1, "trackPolygon"); + FeatureTools.RemoveFeatureFromName(globeControl1, "trackPolygon"); globeControl1.TrackPolygonEndEvent -= globeControl1_TrackPolygonEndEvent; globeControl1.Globe.Action = EnumAction3D.ActionNull; diff --git a/FrmpipeMaterialGather.cs b/FrmpipeMaterialGather.cs index 44e7f24..abbc336 100644 --- a/FrmpipeMaterialGather.cs +++ b/FrmpipeMaterialGather.cs @@ -304,7 +304,7 @@ MessageBox.Show("请选择材质类型!"); return; } - Utility.RemoveFeatureFromName(globeControl1, "trackPolygon"); + FeatureTools.RemoveFeatureFromName(globeControl1, "trackPolygon"); globeControl1.Globe.Action = EnumAction3D.TrackPolygon; globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; globeControl1.TrackPolygonEndEvent += globeControl1_TrackPolygonEndEvent; @@ -318,7 +318,7 @@ private void FrmpipeMaterialGather_FormClosing(object sender, FormClosingEventArgs e) { frm = null; - Utility.RemoveFeatureFromName(globeControl1, "trackPolygon"); + FeatureTools.RemoveFeatureFromName(globeControl1, "trackPolygon"); globeControl1.TrackPolygonEndEvent -= globeControl1_TrackPolygonEndEvent; globeControl1.Globe.Action = EnumAction3D.ActionNull; diff --git a/Frmpipediameterstatis.cs b/Frmpipediameterstatis.cs index 4fb25a8..2f407dc 100644 --- a/Frmpipediameterstatis.cs +++ b/Frmpipediameterstatis.cs @@ -372,7 +372,7 @@ MessageBox.Show("请添加分段!"); return; } - Utility.RemoveFeatureFromName(globeControl1, "trackPolygon"); + FeatureTools.RemoveFeatureFromName(globeControl1, "trackPolygon"); globeControl1.Globe.Action = EnumAction3D.TrackPolygon; globeControl1.Globe.TrackPolygonTool.TrackMode = EnumTrackMode.SpaceTrack; globeControl1.TrackPolygonEndEvent += globeControl1_TrackPolygonEndEvent; @@ -422,7 +422,7 @@ globeControl1.Globe.Action = EnumAction3D.ActionNull; globeControl1.TrackPolygonEndEvent -= globeControl1_TrackPolygonEndEvent; - Utility.RemoveFeatureFromName(globeControl1, "trackPolygon"); + FeatureTools.RemoveFeatureFromName(globeControl1, "trackPolygon"); globeControl1.Globe.MemoryLayer.RemoveAllFeature(); } diff --git a/Utility.cs b/Utility.cs index 0756748..39d47cc 100644 --- a/Utility.cs +++ b/Utility.cs @@ -663,39 +663,7 @@ } } */ - - - //TODO LIST:下面两个方法移到featueTools.cs中 - //根据附属物图层名字得到里面含有的附属物 - public static string[] getAccStrsByLayer(string layername) - { - string[] accStrs = null; - string sql = "select 附属物名称 from " + layername + " group by 附属物名称"; - DataSet dataset = OledbHelper.getDataSet(sql, layername); - if (dataset == null) return null; - accStrs = new string[dataset.Tables[0].Rows.Count]; - for (int i = 0; i < dataset.Tables[0].Rows.Count; i++) - { - accStrs[i] = dataset.Tables[0].Rows[i][0].ToString(); - } - return accStrs; - } - //删除内存图层中指定名称的feature - public static void RemoveFeatureFromName(GSOGlobeControl globeControl1, string featureName) - { - GSOFeatures features = globeControl1.Globe.MemoryLayer.GetFeatureByName(featureName, true); - if (features != null) - { - for (int i = features.Length - 1; i >= 0; i--) - { - GSOFeature feature = features[i]; - if (feature != null) - { - globeControl1.Globe.MemoryLayer.RemoveFeatureByID(feature.ID); - } - } - } - globeControl1.Refresh(); - } + + } }