123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131 |
- using SuperMap.Analyst.NetworkAnalyst;
- using SuperMap.Data;
- using SuperMap.Mapping;
- using SuperMap.Plot;
- using System;
- using System.Data;
- using System.Drawing;
- using System.Windows.Forms;
- namespace WWPipeLine.MapBasic.Results
- {
- public class RWWithDataGridView : ResultWindow
- {
- private Sunny.UI.UIDataGridView m_DataGridView;
- private Layer m_LayerSelect = null;
- private GeoPoint markPoint = null;
- private int Timertag = 1;
- private Timer TimerM = new Timer();
- public RWWithDataGridView() : base()
- {
- m_DataGridView = new Sunny.UI.UIDataGridView();
- this.Controls.Add(m_DataGridView);
- m_DataGridView.CellMouseDoubleClick += DataGridView_CellMouseDoubleClick;
- CreateExportExcelButton();
- uiSymbolButtonExportToExcel.Click += UiSymbolButtonExportToExcel_Click;
- TimerM.Interval = 300;
- TimerM.Tick += TimerM_Tick;
- }
- private void TimerM_Tick(object sender, EventArgs e)
- {
- if (Timertag == 6)
- {
- TimerM.Stop();
- TimerM.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();
- }
- //导出
- private void UiSymbolButtonExportToExcel_Click(object sender, EventArgs e)
- {
- ExportToExcel(this.m_DataGridView);
- }
- /// <summary>
- /// 鼠标双击
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- protected void DataGridView_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
- {
- if (m_LayerSelect is null) return;
- if (m_DataGridView.SelectedRows == null || m_DataGridView.SelectedRows.Count != 1) return;//选择不是一行
- int smid = ComsStatic.StringToInt(m_DataGridView.SelectedRows[0].Cells["smid"].Value);
- if (smid == 0) return;
- var fs = (m_LayerSelect.Dataset as DatasetVector).GetAllFeatures();
- if (!fs.ContainsKey(smid)) return;
- Geometry geoxy = fs[smid].GetGeometry();
- ComsStatic.MapControl.Map.Center = geoxy.InnerPoint;
- markPoint = new GeoPoint { X = geoxy.InnerPoint.X, Y = geoxy.InnerPoint.Y, Style = ComsStatic.geoStyle_Red_Mark5mm };
- TimerM.Enabled = true; TimerM.Start();
- ComsStatic.MapControl.Map.Refresh();
- }
- public override void ShowData(object data)
- {
- if (data == null)
- {
- DataTable dt = new DataTable();
- dt.Columns.Add("执行结果");
- DataRow dr = dt.NewRow();
- dr[0] = "查询无结果";
- dt.Rows.Add(dr);
- }
- else if (data is DataTable)
- {
- var dt = data as DataTable;
- foreach (Layer lyr in ComsStatic.MapLayers)
- {
- if (lyr.Name.Contains(dt.TableName) || lyr.Caption.Contains(dt.TableName))
- {
- m_LayerSelect = lyr; break;
- }
- }
- if (System.Text.RegularExpressions.Regex.IsMatch(dt.TableName?.ToString(), @"[\u4e00-\u9fa5]"))
- this.m_DataGridView.Tag = dt.TableName?.ToString();
- else
- this.m_DataGridView.Tag = base.Text;
- ComsStatic.setUIDataGridView(m_DataGridView, dt);
- }
- else
- {
- ComsStatic.ShowErrorLog("需要的参数为DataTable", string.Format("RWWithDataGridView中data的数据类型是{0}", data.GetType()));
- throw new ArgumentException("需要的参数为DataTable");
- }
- }
- private void InitializeComponent()
- {
- this.SuspendLayout();
- //
- // RWWithDataGridView
- //
- this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
- this.ClientSize = new System.Drawing.Size(800, 450);
- this.Name = "RWWithDataGridView";
- this.ResumeLayout(false);
- }
- }
- }
|