123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- using Sunny.UI;
- using SuperMap.Analyst.NetworkAnalyst;
- using SuperMap.Data;
- using SuperMap.Mapping;
- using SuperMap.Plot;
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.Drawing;
- using System.Windows.Forms;
- namespace WWPipeLine.MapBasic.Results
- {
- public class RWWithDataGridViewMulti : ResultWindow
- {
- private UITabControl utc = new UITabControl()
- {
- Dock = DockStyle.Fill,
- MenuStyle = UIMenuStyle.Custom,
- Style = UIStyle.Custom,
- TabBackColor = Color.White,
- TabSelectedColor = Color.White,
- TabUnSelectedForeColor = Color.Black
- };
- private Layer m_LayerSelect = null;
- private string dgvTag = string.Empty;
- public RWWithDataGridViewMulti() : base()
- {
- Controls.Add(utc);
- CreateExportExcelButton();
- uiSymbolButtonExportToExcel.Click += UiSymbolButtonExportToExcel_Click;
- }
- private void UiSymbolButtonExportToExcel_Click(object sender, EventArgs e)
- {
- List<DataGridView> listdgv = new List<DataGridView>();
- foreach (Control ctr in Controls.Find("dgv", true))
- {
- DataGridView dgv = ctr as DataGridView;
- if (dgv == null) continue;
- listdgv.Add(dgv);
- }
- var errMsg = Commons.ExportDgvToExcel.ExportExcel(listdgv);
- if (string.IsNullOrEmpty(errMsg))
- {
- ComsStatic.ShowOKLog("导出Excel文件成功");
- }
- else
- {
- if (errMsg == Commons.ExportDgvToExcel.CANCELRESULTSTRING)
- return;
- else
- ComsStatic.ShowErrorLog("导出Excel文件失败,原因是" + errMsg);
- }
- }
- public override void ShowData(object data)
- {
- //if (!(data is List<DataTable>))
- // base.ShowData(data);
- //else
- //{ }
- var dats = data as List<DataTable>;
- for (int i = 0; i < dats.Count; i++)
- {
- UIPage up = new UIPage { Text = dats[i].TableName };
- UIDataGridView dgv = new UIDataGridView() { Name = "dgv", Tag = dats[i].TableName };
- up.Controls.Add(dgv);
- dgv.CellMouseDoubleClick += Dgv_CellMouseDoubleClick;
- utc.AddPage(up);
- ComsStatic.setUIDataGridView(dgv, dats[i]);
- }
- }
- private void Dgv_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
- {
- DataGridView dgv = sender as DataGridView;
- if (dgv is null) return;
- if (dgvTag == string.Empty || dgvTag != dgv.Tag?.ToString())
- {
- dgvTag = dgv.Tag?.ToString();
- foreach (Layer lyr in ComsStatic.MapLayersUsed)
- {
- if (lyr.Name.Contains(dgv.Tag.ToString()) || lyr.Caption.Contains(dgv.Tag.ToString()))
- {
- m_LayerSelect = lyr; break;
- }
- }
- }
- if (dgv.SelectedRows == null || dgv.SelectedRows.Count != 1 || m_LayerSelect == null) return;
- int smid = ComsStatic.StringToInt(dgv.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;
- new DoTrackingPoint().Doing(geoxy.InnerPoint.X, geoxy.InnerPoint.Y);
- }
- 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);
- }
- }
- }
|