using Sunny.UI; using SuperMap.Data; using SuperMap.Layout; using SuperMap.Mapping; using SuperMap.UI; using System; using System.Collections.Generic; using System.Configuration; using System.Data; using System.Drawing; using System.IO; using System.Linq; using System.Net; using System.Security.Cryptography; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using WeifenLuo.WinFormsUI.Docking; using WWPipeLine.Commons; namespace WWPipeLine.MapBasic { public class ComsStatic { #region Instance private static ComsStatic m_Instance; public static ComsStatic Instance { get { if (m_Instance == null) m_Instance = new ComsStatic(); return m_Instance; } } private static Workspace m_Workspace; public void SetWorkspace(Workspace ws) { m_Workspace = ws; } private static MapControl m_MapControl; public void SetMapControl(MapControl mp) { m_MapControl = mp; } private static DockPanel m_DockPanel; public void SetDockPanel(DockPanel dp) { m_DockPanel = dp; } private static Datasource m_MemoryDatasource; public void SetMemoryDatasource(Datasource ds) { m_MemoryDatasource = ds; } private static IMessageInterface m_IMessageInterface; public void SetIMessageInterface(IMessageInterface mi) { m_IMessageInterface = mi; } public static IMessageInterface MessageInterface { get => m_IMessageInterface; } #endregion #region 配置文件信息 public static readonly string ConfigsNpgsql = ComsStatic.DesDecrypt(ConfigurationManager.AppSettings["ConfigsNpgsql"], "wwwwwwwwww"); public static string ConfigsNpgsqlServer { get => ConfigsNpgsql.Split('=')[1].Split(';')[0]; } public static readonly string MenusPath = ConfigurationManager.AppSettings["MenusPath"]; public static readonly string WorkspaceName = ConfigurationManager.AppSettings["WorkspaceName"]; public static readonly int WorkspaceMapIndex = StringToInt(ConfigurationManager.AppSettings["WorkspaceMapIndex"]); public static readonly double MapCenterX = StringToDouble(ConfigurationManager.AppSettings["MapCenterX"]); public static readonly double MapCenterY = StringToDouble(ConfigurationManager.AppSettings["MapCenterY"]); public static readonly double MapScale = StringToDouble(ConfigurationManager.AppSettings["MapScale"]); public static readonly int WorkspaceDatasourceIndex = StringToInt(ConfigurationManager.AppSettings["WorkspaceDatasourceIndex"]); public static readonly string bsURL = ConfigurationManager.AppSettings["bsURL"]; public static readonly string webTool = ConfigurationManager.AppSettings["webTool"]; public static readonly string GISversion = ConfigurationManager.AppSettings["GISversion"]; #endregion #region 用户信息 //public void SetUserID(int uid) { m_UserID = uid; } //private static int m_UserID; //public static int UserID { get => m_UserID; } //public void SetUserNick(string uNick) { m_UserNick = uNick; } //private static string m_UserNick; //public static string UserNick { get => m_UserNick; } public void SetLoginID(int uid) { m_LoginID = uid; } private static int m_LoginID; public static int LoginID { get => m_LoginID; } #endregion #region Workspace MapControl DatasetVector public static Datasource Datasource { get => m_Workspace.Datasources[WorkspaceDatasourceIndex]; } public static Datasource DatasourceMemory { get => m_MemoryDatasource; } public static Workspace Workspace { get => m_Workspace; } public static MapControl MapControl { get => m_MapControl; } public static DockPanel DockPanel { get => m_DockPanel; } public static DatasetVector dvConfig { get => Datasource.Datasets["wwconfig"] as DatasetVector; } public static DatasetVector gsGuanXian { get => Datasource.Datasets[dvGXDatasetName] as DatasetVector; } public static DatasetVector gsGuanDian { get => Datasource.Datasets["gsGD"] as DatasetVector; } /// /// B/S端用到的网络数据集名称 /// public static readonly string NetworkDatasetName = "DaAnPostgrsSQL_Network"; /// /// 供水管线的数据集 Name=gsGX /// public static readonly string dvGXDatasetName = "gsGX"; /// /// 供水管线的图层名称 Caption=供水管线 /// public static readonly string dvGXCaption = "供水管线"; #region 软件打开时 动态加载图层 这种情况需要确定工作空间内只有管线和其他图层,不能包含管点图层 public static List layerExList { get { //备注:1、节点图层的DatasetName必须带有dv,系统中会通过该字母判断是否选择的是节点图层 List list = new List(); list.Add(new LayerEx { Index = 0, Caption = "供水节点", Dataset = "dvJD", MarkerSymbolID = 14, MarkerSize = 2 }); list.Add(new LayerEx { Index = 0, Caption = "供水阀门", Dataset = "dvFM", MarkerSymbolID = 13, MarkerSize = 3 }); list.Add(new LayerEx { Index = 0, Caption = "消防栓", Dataset = "dvXFS", MarkerSymbolID = 19, MarkerSize = 3 }); list.Add(new LayerEx { Index = 0, Caption = "压力监测点", Dataset = "dvYL", MarkerSymbolID = 20, MarkerSize = 3 }); list.Add(new LayerEx { Index = 0, Caption = "流量监测点", Dataset = "dvLL", MarkerSymbolID = 15, MarkerSize = 3 }); list.Add(new LayerEx { Index = 0, Caption = "水质监测点", Dataset = "dvSZ", MarkerSymbolID = 18, MarkerSize = 3 }); list.Add(new LayerEx { Index = 0, Caption = "水表", Dataset = "dvSB", MarkerSymbolID = 17, MarkerSize = 3 }); list.Add(new LayerEx { Index = 0, Caption = "供水水厂", Dataset = "dvSC", MarkerSymbolID = 21, MarkerSize = 3 }); list.Add(new LayerEx { Index = 0, Caption = "排气阀", Dataset = "dvPQF", MarkerSymbolID = 16, MarkerSize = 3 }); list.Add(new LayerEx { Index = 0, Caption = "调压站", Dataset = "dvJY", MarkerSymbolID = 20, MarkerSize = 3 }); return list; } } public static void SetDatasetVectorAddLayer() { DatasetVector dv = null; LayerSettingVector layerSettingVector; string[] strField = GetFieldInfos(gsGuanDian); foreach (LayerEx lyrEx in layerExList.ToArray()) { if (!Datasource.Datasets.Contains(lyrEx.Dataset)) { dv = Datasource.Datasets.Create(new DatasetVectorInfo() { Name = lyrEx.Dataset, Type = DatasetType.Point }); bool result = dv.AppendFields(gsGuanDian, "smid", "smuserid", strField); } else { dv = Datasource.Datasets[lyrEx.Dataset] as DatasetVector; dv.Truncate(); } dv.Append(gsGuanDian.Query("FLDM='" + lyrEx.Caption + "'", CursorType.Static)); LayerGroup lg = m_MapControl.Map.Layers.FindLayer("LayerGroup") as LayerGroup; if (lg == null) continue; layerSettingVector = new LayerSettingVector(); //默认GeoStyle //{ FillBackColor=Color [A=255, R=255, G=255, B=255],FillForeColor=Color [A=255, R=189, G=235, B=255], // FillGradientAngle=0,FillGradientMode=None,FillGradientOffsetRatioX=0,FillGradientOffsetRatioY=0, // FillOpaqueRate=100,FillSymbolID=0,LineColor=Color [A=255, R=0, G=0, B=0],LineSymbolID=0,LineWidth=1, // MarkerAngle=0,MarkerSize={Width=2,Height=-0.1},MarkerSymbolID=0} GeoStyle geoStyle = new GeoStyle(); geoStyle.MarkerSize = new Size2D(lyrEx.MarkerSize, lyrEx.MarkerSize); geoStyle.LineColor = lyrEx.LineColor; geoStyle.MarkerSymbolID = lyrEx.MarkerSymbolID; layerSettingVector.Style = geoStyle; Layer layer = Layer.CreateLayer(dv, layerSettingVector); layer.Caption = lyrEx.Caption; layer.Selection.IsDefaultStyleEnabled = false; layer.Selection.Style = geoStyle_Selection; layer.Selection.SetStyleOptions(StyleOptions.MarkerSymbolID, true); layer.Selection.SetStyleOptions(StyleOptions.LineColor, true); layer.Selection.SetStyleOptions(StyleOptions.MarkerSize, true); lg.Insert(0, layer); } } public static bool SetDatasetVector() { try { DatasetVector dv = null; string[] strField = GetFieldInfos(gsGuanDian); foreach (LayerEx lyrEx in layerExList.ToArray()) { if (!Datasource.Datasets.Contains(lyrEx.Dataset)) { dv = Datasource.Datasets.Create(new DatasetVectorInfo() { Name = lyrEx.Dataset, Type = DatasetType.Point }); bool result = dv.AppendFields(gsGuanDian, "smid", "smuserid", strField); } else { dv = Datasource.Datasets[lyrEx.Dataset] as DatasetVector; dv.Truncate(); } dv.Append(gsGuanDian.Query("FLDM='" + lyrEx.Caption + "'", CursorType.Static)); } return true; } catch (Exception ex) { LogHelper.Fatal(ex); return false; } } public static GeoStyle geoStyle_Selection = new GeoStyle { MarkerSymbolID = 0, LineColor = Color.Red, MarkerSize = new Size2D(4, 4) }; #endregion public static Layer LayerGuanXian { get { LayerGroup lg = m_MapControl.Map.Layers.FindLayer("LayerGroup") as LayerGroup; if (lg.Count == 0) return null; Layer lyr = null; foreach (Layer lyrr in lg) { if (lyrr.Dataset == gsGuanXian) { lyr = lyrr; break; } } return lyr; } } //public static Layers MapLayers { get => m_MapControl.Map.Layers; } /// /// 管点管线图层 /// public static List MapLayers { get { List layerList = new List(); LayerGroup lg = m_MapControl.Map.Layers.FindLayer("LayerGroup") as LayerGroup; if (lg.Count == 0) return null; foreach (Layer lyrr in lg) { if (lyrr.Dataset == null || lyrr.Dataset.Datasource.Alias != Datasource.Alias) continue; layerList.Add(lyrr); } return layerList; } } /// /// 管点管线图层 + 用水单位图层 /// public static List MapLayersUsed { get { List layerList = MapLayers; LayerGroup lg = m_MapControl.Map.Layers.FindLayer("LayerGroup#1") as LayerGroup; if (lg.Count == 0) return layerList; foreach (Layer lyrr in lg) { if (lyrr.Dataset == null || lyrr.Dataset.Datasource.Alias != Datasource.Alias) continue; if (!",pyunit,".ToLower().Contains(lyrr.Dataset.Name.ToLower())) continue; layerList.Add(lyrr); } return layerList; } } /// /// 当前数据集的所有图层 /// public static List MapLayersAll { get { List layerList = new List(); foreach (Layer lyr in m_MapControl.Map.Layers) { if (lyr.Name.ToLower().Contains("layergroup")) { LayerGroup lyrG = lyr as LayerGroup; foreach (Layer lyrr in lyrG.Layers) { if (lyrr.Dataset.Datasource.Alias == Datasource.Alias) layerList.Add(lyrr); } } else if (lyr.Dataset.Datasource.Alias == Datasource.Alias) { layerList.Add(lyr); } } return layerList; } } public static void SetLayersIsSelectableFalse(string layerName, bool isSelect) { foreach (Layer r in MapLayers) { if (r.Name == layerName || r.Caption == layerName || r.Dataset.Name == layerName) r.IsSelectable = isSelect; else r.IsSelectable = !isSelect; } } public static void SetLayersIsVisibleFalse(string layerName, bool isSelect) { foreach (Layer r in MapLayers) { if (r.Name == layerName || r.Caption == layerName || r.Dataset.Name == layerName) r.IsVisible = isSelect; else r.IsVisible = !isSelect; } } /// /// 依据TrackingLayer的Name清空 /// /// public static void TrackingLayerRemove(string tag) { int index = MapControl.Map.TrackingLayer.IndexOf(tag); while (index != -1) { MapControl.Map.TrackingLayer.Remove(index); index = MapControl.Map.TrackingLayer.IndexOf(tag); } } public static readonly string ControlToolsTrackingName = "ControlToolAddGeoRegion"; public static void MapControl_Tracked_TrackingName(object sender, SuperMap.UI.TrackedEventArgs e) { m_MapControl.Tracked -= MapControl_Tracked_TrackingName; m_MapControl.Action = SuperMap.UI.Action.Select; m_MapControl.Action = SuperMap.UI.Action.Pan; if (e.Geometry is null) { Sunny.UI.UIMessageTip.ShowError("区域绘制失败"); return; } GeoRegion m_geo = e.Geometry.Clone() as GeoRegion; if (m_geo is null) { Sunny.UI.UIMessageTip.ShowError("区域绘制失败"); return; } m_geo.Style = ComsStatic.geoStyle_Red_1mm_OpaqueRate; m_MapControl.Map.TrackingLayer.Clear(); m_MapControl.Map.TrackingLayer.Add(m_geo, ComsStatic.ControlToolsTrackingName); m_MapControl.Map.RefreshTrackingLayer(); } /// /// 关闭当前主程序中除了Tag=MainControls的其他所有窗体 /// 默认4个主要窗体: 主窗体 工具栏 鹰眼 图层 /// public static void closeFormTagMainControls() { try { foreach (Form form in Application.OpenForms) { if (form.Tag?.ToString() != "MainControls" && form.Text?.ToString() != "工具栏") { form.Close(); break; } } if (Application.OpenForms.Count > 6) { closeFormTagMainControls(); } } catch (Exception ex) { ComsStatic.ShowErrorLog(ex); } } #endregion #region SuperMap.Data相关操作 public static readonly string[] resultFieldsGX = new string[] { "fldm", "cz", "gj", "cd", "yl", "msfs", "dzms", "qsdw", "tcdw" }; public static readonly string[] resultFieldsGD = new string[] { "fldm", "fsw", "xh", "gg", "cz", "kj", "gj", "yl", "dmgc", "ms", "msfs", "dzms", "qsdw", "tcdw" }; public static Recordset QueryRecordset(DatasetVector dv, string sqlWhere, string[] resultFields = null, string[] groupBy = null, string[] orderBy = null) { QueryParameter para = new QueryParameter(); if (sqlWhere != null) para.AttributeFilter = sqlWhere; if (resultFields != null) para.ResultFields = Commons.StringEx.setToLower(resultFields); if (groupBy != null) para.GroupBy = Commons.StringEx.setToLower(groupBy); if (orderBy != null) para.OrderBy = Commons.StringEx.setToLower(orderBy); para.CursorType = CursorType.Static; return dv.Query(para); } public static Recordset QueryRecordsetDynamic(DatasetVector dv, string sqlWhere, string[] resultFields = null, string[] groupBy = null, string[] orderBy = null) { QueryParameter para = new QueryParameter(); if (sqlWhere != null) para.AttributeFilter = sqlWhere; if (resultFields != null) para.ResultFields = Commons.StringEx.setToLower(resultFields); if (groupBy != null) para.GroupBy = Commons.StringEx.setToLower(groupBy); if (orderBy != null) para.OrderBy = Commons.StringEx.setToLower(orderBy); para.CursorType = CursorType.Dynamic; return dv.Query(para); } public static DataTable QueryDataTable(DatasetVector dv, string sqlWhere, string[] resultFields = null, string[] groupBy = null, string[] orderBy = null) { QueryParameter para = new QueryParameter(); if (sqlWhere != null) para.AttributeFilter = sqlWhere; if (resultFields != null) para.ResultFields = Commons.StringEx.setToLower(resultFields); if (groupBy != null) para.GroupBy = Commons.StringEx.setToLower(groupBy); if (orderBy != null) para.OrderBy = Commons.StringEx.setToLower(orderBy); para.CursorType = CursorType.Static; return RecordsetToDataTable(dv.Query(para), true, dv.Name); } public static List QueryFieldsValueList(DatasetVector dv, string sqlWhere, string resultFields, string[] groupBy = null, string[] orderBy = null) { Recordset rd = QueryRecordset(dv, sqlWhere, new string[] { resultFields }, groupBy, orderBy); List result = new List(); rd.MoveFirst(); if (!rd.IsEOF) { result.Add(rd.GetFieldValue(resultFields)); rd.MoveNext(); } return result; } public static DataTable RecordsetToDataTable(Recordset recordset, bool isDispose = true, string tableName = null) { if (string.IsNullOrEmpty(tableName)) tableName = recordset.Dataset.Name; DataTable dt = new DataTable { TableName = tableName }; foreach (FieldInfo info in recordset.GetFieldInfos()) { dt.Columns.Add(new DataColumn { ColumnName = info.Name, Caption = info.Caption }); } DataRow dr; recordset.MoveFirst(); while (!recordset.IsEOF) { dr = dt.NewRow(); foreach (DataColumn dc in dt.Columns) { dr[dc] = recordset.GetFieldValue(dc.ColumnName)?.ToString(); } dt.Rows.Add(dr); recordset.MoveNext(); } if (isDispose) RecordsetDispose(recordset); return dt; } //public static DataTable RecordsetToDataTable(Recordset recordset, bool isDispose = true, string tableName = null) //{ // if (string.IsNullOrEmpty(tableName)) tableName = recordset.Dataset.Name; // DataTable dt = new DataTable { TableName = tableName }; // FieldInfos fieldInfos = recordset.GetFieldInfos(); // Int32 count = fieldInfos.Count; // DataColumn dataColumn; // for (Int32 i = 0; i < count; i++) // { // dataColumn = new DataColumn { ColumnName = fieldInfos[i].Name, Caption = fieldInfos[i].Caption }; // dt.Columns.Add(dataColumn); // } // recordset.MoveFirst(); // Int32 length = recordset.RecordCount; // DataRow dr; // for (int i = 0; i < length; i++) // { // dr = dt.NewRow(); // var actIndex = 0; // for (Int32 j = 0; j < count; j++) // { // var objValue = recordset.GetFieldValue(j); // string value = objValue?.ToString(); // dr[actIndex++] = value; // } // dt.Rows.Add(dr); // recordset.MoveNext(); // } // if (isDispose) RecordsetDispose(recordset); // return dt; //} public static List TongJiFieldGroupCount(DatasetVector dv, string[] strField) { Recordset rd = null; List dts = new List(); DataTable dt; DataRow dr; string fieldValue = string.Empty; foreach (string field in strField) { string[] ck = new string[] { field }; rd = ComsStatic.QueryRecordset(dv, null, ck, ck, ck); dt = new DataTable(); dt.Columns.Add("类别"); dt.Columns.Add("数量"); if (!HasField(dv, field)) continue; dt.TableName = rd.GetFieldInfos()[field].Caption; if (rd.RecordCount == 0)//该字段所有值均为null 不能GroupBy { dr = dt.NewRow(); dr["类别"] = "未知"; dr["数量"] = dv.RecordCount; dt.Rows.Add(dr); } else { rd.MoveFirst(); while (!rd.IsEOF) { dr = dt.NewRow(); fieldValue = rd.GetFieldValue(field)?.ToString(); if (string.IsNullOrEmpty(fieldValue)) { dr["类别"] = "未知"; dr["数量"] = dv.Query(string.Format("{0} is null", field), CursorType.Static).RecordCount; } else { dr["类别"] = fieldValue; dr["数量"] = dv.Query(string.Format("{0}='{1}'", field, fieldValue), CursorType.Static).RecordCount; } dt.Rows.Add(dr); rd.MoveNext(); } } dr = dt.NewRow(); dr["类别"] = dt.TableName + "总量"; dr["数量"] = dv.RecordCount; dt.Rows.Add(dr); dts.Add(dt); } ComsStatic.RecordsetDispose(rd); return dts; } public static string getSqlCheckListBox(Dictionary dic, string otherWhere = null) { if (string.IsNullOrEmpty(otherWhere)) otherWhere = " 1=1 "; StringBuilder sb = new StringBuilder(otherWhere); foreach (string key in dic.Keys) { if (dic[key].CheckedItems.Count > 0) { sb.Append(" AND (1=2 "); foreach (string clbItem in dic[key].CheckedItems) { if (clbItem == "未知") sb.AppendFormat(" OR {0} is null ", key); else sb.AppendFormat(" OR {0}='{1}' ", key, clbItem); } sb.Append(" ) "); } } return sb.ToString(); } /// /// 获取DatasetVector的FieldInfos数组 不包含系统字段 /// /// /// public static string[] GetFieldInfos(DatasetVector dv) { List listStr = new List(); foreach (FieldInfo f in dv.FieldInfos) { if (f.IsSystemField || f.Name.ToLower() == "smuserid") continue; listStr.Add(f.Name); } return listStr.ToArray(); } public static bool HasField(DatasetVector m_DatasetVector, string _field) { bool hasField = false; FieldInfos fieldInfos = m_DatasetVector.FieldInfos; for (int i = 0; i < fieldInfos.Count; i++) { if (fieldInfos[i].Name.ToLower() == _field.ToLower()) { hasField = true; break; } } return hasField; } public static bool HasField(Recordset m_Recordset, string _field) { bool hasField = false; FieldInfos fieldInfos = m_Recordset.GetFieldInfos(); for (int i = 0; i < fieldInfos.Count; i++) { if (fieldInfos[i].Name.ToLower() == _field.ToLower()) { hasField = true; break; } } return hasField; } public static void RecordsetDispose(Recordset rd) { if (rd != null) { rd.Close(); rd.Dispose(); } } public static void EditHistoryUndo(EditHistory eh) { while (eh.CanUndo) { bool isSuccess = eh.Undo(); } eh.Clear(); eh.Dispose(); } public static DataTable GetJSLKbyJSJDPT(DataTable dt) { #region 构造 管线的起始管点和终点管点 信息 dt.Columns.Add(new DataColumn { ColumnName = "qdsmid", Caption = "起点SmID" }); dt.Columns.Add(new DataColumn { ColumnName = "qdsmx", Caption = "起点X坐标" }); dt.Columns.Add(new DataColumn { ColumnName = "qdsmy", Caption = "起点Y坐标" }); dt.Columns.Add(new DataColumn { ColumnName = "qddmgc", Caption = "起点地面高程" }); dt.Columns.Add(new DataColumn { ColumnName = "qdgdms", Caption = "起点埋深" }); dt.Columns.Add(new DataColumn { ColumnName = "qdgc", Caption = "起点高程" }); dt.Columns.Add(new DataColumn { ColumnName = "zdsmid", Caption = "终点SmID" }); dt.Columns.Add(new DataColumn { ColumnName = "zdsmx", Caption = "终点X坐标" }); dt.Columns.Add(new DataColumn { ColumnName = "zdsmy", Caption = "终点Y坐标" }); dt.Columns.Add(new DataColumn { ColumnName = "zddmgc", Caption = "终点地面高程" }); dt.Columns.Add(new DataColumn { ColumnName = "zdgdms", Caption = "终点埋深" }); dt.Columns.Add(new DataColumn { ColumnName = "zdgc", Caption = "终点高程" }); #endregion DataTable dtJSJDPT; foreach (DataRow dr in dt.Rows) { dtJSJDPT = QueryDataTable(gsGuanDian, string.Format(" bsm='{0}' ", dr["qsdh"])); if (dtJSJDPT.Rows.Count == 1) { dr["qdsmid"] = dtJSJDPT.Rows[0]["smid"]; dr["qdsmx"] = dtJSJDPT.Rows[0]["x"]; dr["qdsmy"] = dtJSJDPT.Rows[0]["y"]; dr["qddmgc"] = dtJSJDPT.Rows[0]["dmgc"]; dr["qdgdms"] = dtJSJDPT.Rows[0]["ms"]; dr["qdgc"] = StringToDouble(dtJSJDPT.Rows[0]["dmgc"], 2) - StringToDouble(dtJSJDPT.Rows[0]["ms"], 2); } dtJSJDPT = QueryDataTable(gsGuanDian, string.Format(" bsm='{0}' ", dr["zddh"])); if (dtJSJDPT.Rows.Count == 1) { dr["zdsmid"] = dtJSJDPT.Rows[0]["smid"]; dr["zdsmx"] = dtJSJDPT.Rows[0]["x"]; dr["zdsmy"] = dtJSJDPT.Rows[0]["y"]; dr["zddmgc"] = dtJSJDPT.Rows[0]["dmgc"]; dr["zdgdms"] = dtJSJDPT.Rows[0]["ms"]; dr["zdgc"] = StringToDouble(dtJSJDPT.Rows[0]["dmgc"], 2) - StringToDouble(dtJSJDPT.Rows[0]["ms"], 2); } } return dt; } public static Dictionary getGuanXianPeiZhi(string pzlx) { Dictionary dic = new Dictionary(); Recordset _rd = dvConfig.Query(string.Format(" pzlx='{0}' ", pzlx), CursorType.Static); if (_rd.RecordCount == 0) return dic; _rd.MoveFirst(); while (!_rd.IsEOF) { string gxcz = _rd.GetString("gxcz"); dic.Add(gxcz + "_gxyjnx", _rd.GetFieldValue("gxyjnx")); dic.Add(gxcz + "_gxbznx", _rd.GetFieldValue("gxbznx")); dic.Add(gxcz + "_gxms", _rd.GetFieldValue("gxms")); _rd.MoveNext(); } ComsStatic.RecordsetDispose(_rd); return dic; } public static double GetMaxValue(DatasetVector dv, string fieldName) { return dv.Statistic(fieldName, StatisticMode.Max); } public static int GetMaxValueInt(DatasetVector dv, string fieldName) { return StringToInt(dv.Statistic(fieldName, StatisticMode.Max)); } public static object GetOnlyValueByField(DatasetVector dv, string sqlWhere, string field) { Recordset rd = dv.Query(sqlWhere, CursorType.Static); if (rd is null || rd.RecordCount != 1) return null; return rd.GetFieldValue(field); } /// /// 在当前的DatasetVector中,获取指定列名的最小值 /// /// /// public static double GetMinValue(DatasetVector dv, string fieldName) { return dv.Statistic(fieldName, StatisticMode.Min); } #endregion #region ShowUIMessageTip界面提示信息 public static void ShowUIMessageTipOKorError(bool _result, string msg, string logMsg = "") { if (_result) { ShowOKLog(msg + "操作成功", logMsg); } else { ShowErrorLog(msg + "操作失败", logMsg); } } public static void ShowErrorLog(object msg, string logMsg = "") { LogHelper.Error(string.Format("{0} {1}", msg, logMsg)); UIMessageTip.ShowError(msg.ToString(), 2000, false); //UIMessageTip.ShowError(msg.ToString(), 2000, false, new Point(800, 400), true); } public static void ShowOK(string msg) { UIMessageTip.ShowOk(msg.ToString(), 2000, false); //UIMessageTip.ShowOk(msg, 2000, false, new Point(800, 400), true); } public static void ShowOKLog(object msg, string logMsg = "") { //pgAddLoginm(string.Format("{0} {1}", msg, logMsg)); LogHelper.Info(string.Format("{0} {1}", msg, logMsg)); UIMessageTip.ShowOk(msg.ToString(), 2000, false); //UIMessageTip.ShowOk(msg.ToString(), 2000, false, new Point(800, 400), true); } #endregion #region String操作 public static double StringToDouble(object str, int dleng = -1) { if (str is null) return 0; double result = 0.0D; double.TryParse(str.ToString(), out result); if (dleng != -1) { result = Math.Round(result, dleng); } return result; } /// /// Object转Int Ojbect=null或者转换失败时返回0; /// /// /// public static int StringToInt(object str) { if (str is null) return 0; Int32 result = 0; Int32.TryParse(str.ToString(), out result); return result; } public static Int16 StringToInt16(object str) { if (str is null) return 0; Int16 result = 0; Int16.TryParse(str.ToString(), out result); return result; } public static float StringToFloat(object str) { if (str is null) return 0.0F; float result = 0.0F; float.TryParse(str.ToString(), out result); return result; } public static string getMd5Hash(string input, string key) { MD5 md5Hasher = MD5.Create(); string str = input + key; byte[] data = md5Hasher.ComputeHash(Encoding.Default.GetBytes(str)); StringBuilder sBuilder = new StringBuilder(); for (int i = 0; i < data.Length; i++) { sBuilder.Append(data[i].ToString("x2")); } return sBuilder.ToString(); } /// /// DES加密 /// /// /// public static string DesEncrypt(string encryptString, string key) { byte[] keyBytes = Encoding.UTF8.GetBytes(key.Substring(0, 8)); byte[] keyIV = keyBytes; byte[] inputByteArray = Encoding.UTF8.GetBytes(encryptString); DESCryptoServiceProvider provider = new DESCryptoServiceProvider(); MemoryStream mStream = new MemoryStream(); CryptoStream cStream = new CryptoStream(mStream, provider.CreateEncryptor(keyBytes, keyIV), CryptoStreamMode.Write); cStream.Write(inputByteArray, 0, inputByteArray.Length); cStream.FlushFinalBlock(); return Convert.ToBase64String(mStream.ToArray()); } /// /// DES解密 /// /// /// public static string DesDecrypt(string decryptString, string key) { byte[] keyBytes = Encoding.UTF8.GetBytes(key.Substring(0, 8)); byte[] keyIV = keyBytes; byte[] inputByteArray = Convert.FromBase64String(decryptString); DESCryptoServiceProvider provider = new DESCryptoServiceProvider(); MemoryStream mStream = new MemoryStream(); CryptoStream cStream = new CryptoStream(mStream, provider.CreateDecryptor(keyBytes, keyIV), CryptoStreamMode.Write); cStream.Write(inputByteArray, 0, inputByteArray.Length); cStream.FlushFinalBlock(); return Encoding.UTF8.GetString(mStream.ToArray()); } #endregion #region SummyUI的控件设置和数据绑定 public static readonly UIStyle uiStyleCom = UIStyle.Blue; //R 80 G 160 B 255 /// /// HideEnableTag ,smid /// public static readonly string HideEnableTag = ",smx,smy,smkey,smsdriw,smsdrin,smsdrie,smsdris,smgranule,SmGeometry,smlength,smtopoerror,smlibtileid,smperimeter,smarea,smnodeid,smuserid,smgeometrysize,smgeoposition,objectid,bsm,wth,tfh,dmt,x,y,dinggc,digc,cqbh,tsdh,ssbh,ROTATEANGLE,lrrq,enabled,zcbh,qdms,zdms,shape_length,shape_area,lx,qsdh,zddh,fmlx,sblx,sbsl,sbdz,qdsmid,qdsmx,qdsmy,zdsmid,zdsmx,zdsmy,".ToLower(); public static void setUIDataGridView(UIDataGridView dgv, DataTable dt = null, string showTag = null, string hideTag = null) { dgv.Dock = DockStyle.Fill; dgv.ShowEditingIcon = false; dgv.ShowCellToolTips = false; dgv.AllowUserToAddRows = false; dgv.AllowUserToResizeRows = false; dgv.AllowUserToDeleteRows = false; dgv.AllowUserToOrderColumns = false; dgv.ReadOnly = true; dgv.MultiSelect = false; dgv.SelectionMode = DataGridViewSelectionMode.FullRowSelect; dgv.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.DisplayedCells; dgv.Style = UIStyle.Gray;// ComsStatic.uiStyleCom; dgv.RowPostPaint += Dgv_RowPostPaint; if (dt != null) { dgv.DataSource = dt; if (showTag != null) { string[] strShow = showTag.ToLower().Split(','); int indexStr = 0; for (int i = 0; i < dgv.Columns.Count; i++) { dgv.Columns[i].SortMode = DataGridViewColumnSortMode.NotSortable; dgv.Columns[i].HeaderText = dt.Columns[i].Caption; indexStr = strShow.ToList().IndexOf(dgv.Columns[i].Name.ToLower()); if (indexStr > -1) dgv.Columns[i].DisplayIndex = indexStr; else dgv.Columns[i].Visible = false; } return; } if (string.IsNullOrEmpty(hideTag)) { for (int i = 0; i < dgv.Columns.Count; i++) { dgv.Columns[i].SortMode = DataGridViewColumnSortMode.NotSortable; dgv.Columns[i].HeaderText = dt.Columns[i].Caption; if (HideEnableTag.Contains("," + dgv.Columns[i].Name.ToLower() + ",")) { dgv.Columns[i].Visible = false; } } } else { for (int i = 0; i < dgv.Columns.Count; i++) { dgv.Columns[i].SortMode = DataGridViewColumnSortMode.NotSortable; dgv.Columns[i].HeaderText = dt.Columns[i].Caption; if (HideEnableTag.Contains("," + dgv.Columns[i].Name.ToLower() + ",") || hideTag.ToLower().Contains("," + dgv.Columns[i].Name.ToLower() + ",")) { dgv.Columns[i].Visible = false; } } } } } private static void Dgv_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e) { DataGridView dgv = sender as DataGridView; Rectangle rect = new Rectangle(e.RowBounds.Location.X, e.RowBounds.Location.Y, dgv.RowHeadersWidth - 4, e.RowBounds.Height); TextRenderer.DrawText(e.Graphics, (e.RowIndex + 1).ToString(), dgv.RowHeadersDefaultCellStyle.Font, rect, dgv.RowHeadersDefaultCellStyle.ForeColor, TextFormatFlags.VerticalCenter | TextFormatFlags.Right); } public static void BindUICombox(UIComboBox cbx, bool hasGX = true) { foreach (Layer lyr in ComsStatic.MapLayers) { if (!hasGX && lyr.Dataset.Name == ComsStatic.gsGuanXian.Name) continue; cbx.Items.Add(new DoListItem(lyr.Dataset.Name, lyr.Caption)); } cbx.SelectedIndex = 0; } public static void BindDataTableOnCheckedListBox(DatasetVector _dv, CheckedListBox _cbg, string _ziduan) { Recordset rd = QueryRecordset(_dv, null, new string[] { _ziduan }, new string[] { _ziduan }, new string[] { _ziduan }); rd.MoveFirst(); string fieldValue = string.Empty; _cbg.Items.Clear(); while (!rd.IsEOF) { fieldValue = rd.GetString(_ziduan);// rd.GetFieldValue(_ziduan)?.ToString(); if (string.IsNullOrEmpty(fieldValue)) _cbg.Items.Add("未知"); else _cbg.Items.Add(fieldValue); rd.MoveNext(); } ComsStatic.RecordsetDispose(rd); } public static void BindDataTableOnCheckedListBox(string gdFLDM, CheckedListBox _cbg, string _ziduan) { Recordset rd = QueryRecordset(ComsStatic.gsGuanDian, string.Format("FLDM='{0}'", gdFLDM), new string[] { _ziduan }, new string[] { _ziduan }, new string[] { _ziduan }); rd.MoveFirst(); string fieldValue = string.Empty; _cbg.Items.Clear(); while (!rd.IsEOF) { fieldValue = rd.GetString(_ziduan); if (string.IsNullOrEmpty(fieldValue)) _cbg.Items.Add("未知"); else _cbg.Items.Add(fieldValue); rd.MoveNext(); } ComsStatic.RecordsetDispose(rd); } public static void BindDataTableOnComboBox(DatasetVector _dv, UIComboBox _cbg, string _ziduan) { Recordset rd = QueryRecordset(_dv, null, new string[] { _ziduan }, new string[] { _ziduan }, new string[] { _ziduan }); rd.MoveFirst(); _cbg.Items.Clear(); string fieldValue = string.Empty; while (!rd.IsEOF) { fieldValue = rd.GetString(_ziduan); if (string.IsNullOrEmpty(fieldValue)) _cbg.Items.Add("未知"); else _cbg.Items.Add(fieldValue); rd.MoveNext(); } _cbg.SelectedIndex = 0; ComsStatic.RecordsetDispose(rd); } public static DataTable getPaperSize() { DataTable dt = new DataTable { TableName = "PaperSizeTable" }; dt.Columns.Add("sizekey"); dt.Columns.Add("sizedesc"); dt.Rows.Add("A4", "A4 210x297mm"); dt.Rows.Add("A3", "A3 297x420mm"); dt.Rows.Add("ISOA2", "标准纸面大小(A2)"); dt.Rows.Add("ISOA1", "标准纸面大小(A1)"); dt.Rows.Add("ISOA0", "标准纸面大小(A0)"); return dt; } public static PaperSize getPaperSize(string size) { PaperSize ps = PaperSize.A4; switch (size) { case "A4": ps = PaperSize.A4; break; case "A3": ps = PaperSize.A3; break; case "ISOA2": ps = PaperSize.ISOA2; break; case "ISOA1": ps = PaperSize.ISOA1; break; case "ISOA0": ps = PaperSize.ISOA0; break; default: break; } return ps; } /// /// 设置CheckedListBox的选择状态 1全选 2反选 3全不选 /// /// /// 1全选 2反选 3全不选 public static void CheckListBoxDo(CheckedListBox clb, int doState) { switch (doState) { case 1://全选 for (int i = 0; i < clb.Items.Count; i++) { clb.SetItemChecked(i, true); } break; case 2://反选 for (int i = 0; i < clb.Items.Count; i++) { bool ck = clb.GetItemChecked(i); clb.SetItemChecked(i, !ck); } break; case 3://全不选 for (int i = 0; i < clb.Items.Count; i++) { clb.SetItemChecked(i, false); } break; default: break; } } private static ToolTip toolTips = new ToolTip(); public static void CheckedListBox_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e) { CheckedListBox clb = sender as CheckedListBox; int index = clb.IndexFromPoint(e.Location); if (index != -1 && toolTips.GetToolTip(clb) != clb.Items[index].ToString()) { toolTips.SetToolTip(clb, clb.Items[index].ToString()); } } //2021年12月27日 15:22:36 18个引用 public static void uiTextBox_num_KeyPress(object sender, KeyPressEventArgs e) { // 横向数字键的1-9 小键盘数字键的1-9 BackSpace 小键盘 . Del 字母按键 .> if ((e.KeyChar >= 48 || e.KeyChar <= 57) || (e.KeyChar >= 96 || e.KeyChar <= 105) || (e.KeyChar == 8) || (e.KeyChar == 110) || (e.KeyChar == 190)) e.Handled = false;//可以输入 else e.Handled = true; } public static void UIListBox_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e) { UIListBox clb = sender as UIListBox; int index = clb.IndexFromPoint(e.Location); if (index != -1 && toolTips.GetToolTip(clb) != clb.Items[index].ToString()) { toolTips.SetToolTip(clb, clb.Items[index].ToString()); } } #endregion #region 其他计算操作 /// /// 通过起点的坐标和数值、终点的坐标和数值,计算线上交点的数值 /// /// 起点坐标 /// 起点数值 /// 终点坐标 /// 终点数值 /// 线上的交点坐标 /// 交点数值 public static double getPointHeight(Point2D start, double startValue, Point2D end, double endValue, Point2D JiaoDian) { if (!Geometrist.IsPointOnLine(JiaoDian, start, end, false)) return 0.0; if (startValue == endValue) return Math.Round(startValue, 2); double JiaoDianValue = 0.0D; if (startValue < endValue)//确保起点数据 大于 终点数据 { double temp = startValue; startValue = endValue; endValue = temp; Point2D temPoint = start; start = end; end = temPoint; } // 参考链接 https://zhuanlan.zhihu.com/p/43660758 下面的公式可以用,是正式的,这里备份一下 //JiaoDian_gc = gx_end_gc + (gx_start_gc - gx_end_gc) * (Math.Sqrt(Math.Pow((JiaoDian.X - gx_end.X), 2.0) + Math.Pow((JiaoDian.Y - gx_end.Y), 2.0))) / (Math.Sqrt(Math.Pow((gx_start.X - gx_end.X), 2.0) + Math.Pow((gx_start.Y - gx_end.Y), 2.0))); JiaoDianValue = endValue + (startValue - endValue) * (Math.Sqrt(Math.Pow((JiaoDian.X - end.X), 2.0) + Math.Pow((JiaoDian.Y - end.Y), 2.0))) / (Math.Sqrt(Math.Pow((start.X - end.X), 2.0) + Math.Pow((start.Y - end.Y), 2.0))); if (JiaoDianValue == double.PositiveInfinity || JiaoDianValue == double.NegativeInfinity) { JiaoDianValue = endValue; } return Math.Round(JiaoDianValue, 2); } /// /// 返回Double数组的最大值或者最小值 /// /// /// True表示最大值,false表示最小值 /// public static double getMaxMin(double[] dblist, bool isMax) { double finalValue = dblist[0]; if (isMax)//最大值 { for (int i = 0; i < dblist.Length; i++) { if (finalValue < dblist[i]) finalValue = dblist[i]; } } else { for (int i = 0; i < dblist.Length; i++) { if (finalValue > dblist[i]) finalValue = dblist[i]; } } return finalValue; } /// /// 将逗号分隔的csv格式文件,转换为DataTable /// /// csv文件路径 /// 首行是否是标题行 /// public static DataTable CSVToDataTable(string filePath, bool FirstField) { DataTable table = new DataTable(); bool isField = true; using (StreamReader reader = new StreamReader(filePath, Encoding.GetEncoding("gb2312"), false)) { string line = string.Empty; while (reader.Peek() > 0) { line = reader.ReadLine(); if (string.IsNullOrEmpty(line) || line.Split(',').Length == 0) continue; string[] split = line.Split(','); if (isField) { isField = false; if (FirstField)//首行是标题 { foreach (string str in split) table.Columns.Add(str); continue; } else { for (int i = 0; i < split.Length; i++) table.Columns.Add("列" + i.ToString()); } } DataRow newRow = table.NewRow(); for (int j = 0; j < split.Length; j++) { newRow[j] = split[j].Trim('"'); } table.Rows.Add(newRow); } return table; } } #endregion #region postgresSql ///// ///// 获取本机所有IPV4地址列表 ///// ///// 本机所有IPV4地址列表,以分号分隔 //public static string GetSelfIpv4List() //{ // StringBuilder ips = new StringBuilder(); // try // { // IPHostEntry IpEntry = Dns.GetHostEntry(Dns.GetHostName()); // foreach (IPAddress ipa in IpEntry.AddressList) // { // if (ipa.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork) // { ips.AppendFormat("{0};", ipa.ToString()); break; } // } // } // catch { } // finally { ips.AppendFormat("未知"); } // return ips.ToString(); //} public static string AppConfigGetvalue(string strKey) { foreach (string key in ConfigurationManager.AppSettings) { if (key == strKey) { return ConfigurationManager.AppSettings[strKey]; } } return null; } public static void AppConfigUpdate(string newKey, string newValue) { bool isModified = false; foreach (string key in ConfigurationManager.AppSettings) { if (key == newKey) { isModified = true; } } Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); if (isModified) { config.AppSettings.Settings.Remove(newKey); } config.AppSettings.Settings.Add(newKey, newValue); config.Save(ConfigurationSaveMode.Modified); ConfigurationManager.RefreshSection("appSettings"); } public static string GetInterNetworkIp { get; } = Dns.GetHostEntry(Dns.GetHostName()).AddressList.FirstOrDefault(p => p.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork)?.ToString(); public static string GetSql(string select, List wheres, string orderby = null, string groupby = null) { StringBuilder sb = new StringBuilder(select); if (wheres.Count > 0) { sb.Append(" where " + string.Join(" and ", wheres.ToArray())); } if (!string.IsNullOrEmpty(orderby)) sb.Append(orderby); if (!string.IsNullOrEmpty(groupby)) sb.Append(groupby); return sb.ToString(); } public static void pgAddLogin(string n, string p, string c) { string sql = string.Format(" INSERT INTO userlogin(lgName,lgtime,lgIP,lgCup)VALUES('{0}','{1}','{2}','{3}') returning id;", n, DateTime.Now.ToLocalTime(), p, c); object obj = new NpgsqlHelper().ExecuteScalar(sql); ComsStatic.Instance.SetLoginID(StringToInt(obj)); } public static void pgAddLoginm(string n) { if (ComsStatic.LoginID == 0) return; string sql = string.Format(" INSERT INTO userloginm(lgid,czms,cztime)VALUES('{0}','{1}','{2}') returning id;", ComsStatic.LoginID, n, DateTime.Now.ToLocalTime()); new NpgsqlHelper().ExecuteScalar(sql); } //public static bool pgDeleteGuanDian(string bsm) //{ // string sql = string.Format(" DELETE FROM {0} WHERE bsm='{1}' RETURNING bsm ", gsGuanDian.TableName, bsm); // object obj = new NpgsqlHelper().ExecuteScalar(sql); // if (obj == null) return false; // return true; //} //public static bool pgDeleteGuanDian(string dvTableName, string bsm) //{ // string sql = string.Format(" DELETE FROM {0} WHERE bsm='{1}' RETURNING bsm ", dvTableName, bsm); // object obj = new NpgsqlHelper().ExecuteScalar(sql); // if (obj == null) return false; // return true; //} #endregion #region 管网标注的配置 /// ///线样式 LineColor = Color.Brown, LineWidth = 0.5 /// public static GeoStyle geoStyle_Brown_05mm = new GeoStyle() { LineColor = Color.Brown, LineWidth = 0.5 }; /// ///点样式 LineColor = Color.Red, MarkerSize = new Size2D(5, 5) /// public static GeoStyle geoStyle_Red_Mark5mm = new GeoStyle { LineColor = Color.Red, MarkerSize = new Size2D(5, 5) }; /// /// 标注样式 ForeColor = Color.Brown, IsSizeFixed = true, FontHeight = 6, Alignment = TextAlignment.BottomLeft /// public static TextStyle textStyle_Brown_6mm_BottomLeft = new TextStyle { ForeColor = Color.Brown, IsSizeFixed = true, FontHeight = 6, Alignment = TextAlignment.BottomLeft }; /// ///边框线样式 LineColor = Color.Red, LineWidth = 1, FillOpaqueRate = 10 /// public static GeoStyle geoStyle_Red_1mm_OpaqueRate = new GeoStyle { LineColor = Color.Red, LineWidth = 1, FillOpaqueRate = 10 }; public static Point2D GetPoint2D(object x, object y) { return new Point2D(StringToDouble(x), StringToDouble(y)); } /// /// 获取标注风格配置的TextStyle /// /// public static TextStyle BiaoZhuFengGe() { QueryParameter queryParameter = new QueryParameter { AttributeFilter = " pzlx='标注风格配置' and pzKey='TextStyleKey' ", ResultFields = new string[] { "pzValue" }, CursorType = CursorType.Static }; Recordset _rd = ComsStatic.dvConfig.Query(queryParameter); if (_rd.RecordCount != 1) return textStyle_Brown_6mm_BottomLeft; TextStyle ts = new TextStyle(); bool fromResult = ts.FromXML(_rd.GetFieldValue("pzValue").ToString()); ComsStatic.RecordsetDispose(_rd); if (!fromResult) return textStyle_Brown_6mm_BottomLeft; return ts; } #endregion #region 与bs的相关操作 public static string webGISVersion { get; } = ComsStatic.GetUrlString(webTool + "Tools/PictureUpload.ashx?action=getGISversion"); public static string GetUrlString(string Url) { string retString = string.Empty; try { HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Url); request.Proxy = null; request.KeepAlive = false; request.Method = "GET"; request.ContentType = "text/plain; charset=UTF-8"; request.AutomaticDecompression = DecompressionMethods.GZip; HttpWebResponse response = (HttpWebResponse)request.GetResponse(); Stream myResponseStream = response.GetResponseStream(); StreamReader myStreamReader = new StreamReader(myResponseStream, Encoding.UTF8); retString = myStreamReader.ReadToEnd(); myStreamReader.Close(); myResponseStream.Close(); if (response != null) response.Close(); if (request != null) request.Abort(); } catch { } return retString; } #endregion } public class DoListItem { private string _key = string.Empty; private string _value = string.Empty; public DoListItem(string pKey, string pValue) { _key = pKey; _value = pValue; } public override string ToString() { return _value; } public string Key { get => _key; set => _key = value; } public string Value { get => _value; set => _value = value; } } public class DoTrackingPoint { private Timer timer = new Timer() { Enabled = false, Interval = 300 }; private int Timertag = 1; private GeoPoint markPoint = null; public void Doing(double x, double y) { timer.Tick += Timer_Tick; Point2D p2d = new Point2D(x, y); ComsStatic.MapControl.Map.Center = p2d; ComsStatic.MapControl.Map.Refresh(); markPoint = new GeoPoint(p2d); markPoint.Style = new GeoStyle() { MarkerSize = new Size2D(5, 5), LineColor = Color.Red }; timer.Enabled = true; timer.Start(); } private void Timer_Tick(object sender, EventArgs e) { if (Timertag == 6) { timer.Stop(); timer.Enabled = false; Timertag = 1; int index = ComsStatic.MapControl.Map.TrackingLayer.IndexOf("DoInterestPoint"); if (index > -1) ComsStatic.MapControl.Map.TrackingLayer.Remove(index); ComsStatic.MapControl.Map.RefreshTrackingLayer(); return; } else if (Timertag % 2 == 1 && markPoint != null) { ComsStatic.MapControl.Map.TrackingLayer.Add(markPoint, "DoInterestPoint"); } else //if (Timertag % 2 == 0) { int index = ComsStatic.MapControl.Map.TrackingLayer.IndexOf("DoInterestPoint"); if (index > -1) ComsStatic.MapControl.Map.TrackingLayer.Remove(index); } Timertag++; ComsStatic.MapControl.Map.RefreshTrackingLayer(); } } public class LayerEx { //public LayerEx() { } private string caption; private string fldm; private string dataset; private DatasetVector datasetVector; private int markerSymbolID = 0; private double markerSize = 0; private double maxVisibleScale = 0; private double minVisibleScale = 0; private bool isEditable = false; private bool isVisible = true; private int index; private Color lineColor = Color.Blue; private double lineWidth; public string Caption { get => caption; set => caption = value; } public string FLDM { get => fldm; set => fldm = value; } public string Dataset { get => dataset; set => dataset = value; } public DatasetVector DatasetVector { get => datasetVector; set => datasetVector = value; } public int MarkerSymbolID { get => markerSymbolID; set => markerSymbolID = value; } public double MarkerSize { get => markerSize; set => markerSize = value; } public double MaxVisibleScale { get => maxVisibleScale; set => maxVisibleScale = value; } public double MinVisibleScale { get => minVisibleScale; set => minVisibleScale = value; } public bool IsEditable { get => isEditable; set => isEditable = value; } public bool IsVisible { get => isVisible; set => isVisible = value; } public int Index { get => index; set => index = value; } public double LineWidth { get => lineWidth; set => lineWidth = value; } public Color LineColor { get => lineColor; set => lineColor = value; } } }