123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 |
- using SuperMap.Data;
- using SuperMap.Mapping;
- using SuperMap.UI;
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.Drawing;
- using WeifenLuo.WinFormsUI.Docking;
- using WWPipeLine.MapBasic;
- using WWPipeLine.MapBasic.Conditions;
- using WWPipeLine.MapBasic;
- namespace WWPipeLine.MapTools.Conditions.Sercher
- {
- public class cxYuanXing : ConditionPanel
- {
- private Sunny.UI.UIComboBox uiCBLayers;
- private Sunny.UI.UILabel uilbMsg;
- GeoRegion m_geo = null;
- public cxYuanXing() : base()
- {
- this.ConditionPanelName = "圆形查询";
- InitializeComponent();
- uilbMsg.Text = "鼠标左键长按画圆形";
- }
- protected override void OnLoad(EventArgs e)
- {
- MapControl.Action = SuperMap.UI.Action.CreateCircle;
- MapControl.Tracked += new TrackedEventHandler(TrackedHandler);
- uiCBLayers.ValueMember = "LayerDatasetName";
- uiCBLayers.DisplayMember = "LayerCaption";
- uiCBLayers.DataSource = getLayers();
- }
- private void TrackedHandler(object sender, TrackedEventArgs e)
- {
- if (e.Geometry is null) return;
- m_geo = e.Geometry.Clone() as GeoRegion;
- if (m_geo is null) { Sunny.UI.UIMessageTip.ShowError("查询区域绘制失败"); return; }
- GeoStyle m_GeoStyle = new GeoStyle { LineColor = Color.Red, LineWidth = 1, FillBackOpaque = false, FillOpaqueRate = 10 };
- m_geo.Style = m_GeoStyle;
- MapControl.Map.TrackingLayer.Clear();
- MapControl.Map.TrackingLayer.Add(m_geo, "GeoRectangle");
- MapControl.Map.Refresh();
- }
- public override object Do(DockPanel dockPanel = null)
- {
- IsConditionValid = false;
- if (m_geo is null) { Sunny.UI.UIMessageTip.ShowError("请先绘制查询区域"); return false; }
- DatasetVector datasetVector = this.DatasourceMapControl.Datasets[uiCBLayers.SelectedValue.ToString()] as DatasetVector;
- if (datasetVector is null)
- {
- Sunny.UI.UIMessageTip.ShowError("当前选择的图层没有可用的数据"); return false;
- }
- Recordset recordset = datasetVector.Query(m_geo, 1, "1=1", CursorType.Static);
- if (recordset is null)
- {
- Sunny.UI.UIMessageTip.ShowError("当前图层没有查询到数据"); return false;
- }
- Layer layer = MapControl.Map.Layers.FindLayer(datasetVector);
- Selection selection = layer.Selection;
- selection.FromRecordset(recordset);
- layer.Selection = selection;
- MapControl.Map.Refresh();
- DataTable dt = RecordsetToDataTable(recordset, uiCBLayers.SelectedText);
- recordset.Close(); recordset.Dispose();
- return dt;
- }
- public override void AfterClose()
- {
- MapControl.Tracked -= new TrackedEventHandler(TrackedHandler);
- base.AfterClose();
- }
- private void InitializeComponent()
- {
- this.uilbMsg = new Sunny.UI.UILabel();
- this.uiCBLayers = new Sunny.UI.UIComboBox();
- this.SuspendLayout();
- //
- // uilbMsg
- //
- this.uilbMsg.AutoSize = true;
- this.uilbMsg.Font = new System.Drawing.Font("微软雅黑", 12F);
- this.uilbMsg.Location = new System.Drawing.Point(3, 39);
- this.uilbMsg.Name = "uilbMsg";
- this.uilbMsg.Size = new System.Drawing.Size(74, 21);
- this.uilbMsg.TabIndex = 0;
- this.uilbMsg.Text = "操作说明";
- this.uilbMsg.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
- //
- // uiCBLayers
- //
- this.uiCBLayers.DataSource = null;
- this.uiCBLayers.FillColor = System.Drawing.Color.White;
- this.uiCBLayers.Font = new System.Drawing.Font("微软雅黑", 12F);
- this.uiCBLayers.Location = new System.Drawing.Point(60, 5);
- this.uiCBLayers.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
- this.uiCBLayers.MinimumSize = new System.Drawing.Size(63, 0);
- this.uiCBLayers.Name = "uiCBLayers";
- this.uiCBLayers.Padding = new System.Windows.Forms.Padding(0, 0, 30, 2);
- this.uiCBLayers.Size = new System.Drawing.Size(328, 29);
- this.uiCBLayers.TabIndex = 3;
- this.uiCBLayers.Text = "请选择需要查询的图层";
- this.uiCBLayers.TextAlignment = System.Drawing.ContentAlignment.MiddleLeft;
- //
- // cxYuanXing
- //
- this.Controls.Add(this.uiCBLayers);
- this.Controls.Add(this.uilbMsg);
- this.Name = "cxYuanXing";
- this.Size = new System.Drawing.Size(392, 215);
- this.ResumeLayout(false);
- this.PerformLayout();
- }
- }
- }
|