12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214 |
-
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Drawing;
- using System.Data;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- using Tofly.Core.Stereotype;
- using Tofly.Core.ServiceLocator;
- using Tofly.CoreUI.Control;
- using Tofly.CoreUI.Message;
- using Tofly.CoreUI.Plot;
- using Tofly.Data.General;
- using Tofly.GIS;
- using Tofly.GIS.Carto;
- using Tofly.GIS.Geometry;
- using Tofly.GIS.Util;
- using Tofly.GIS.SpatialDatabase;
- using Tofly.GISUI.Controls;
- using Tofly.GISUI.Utils;
- using Tofly.GIS.Display;
- using Tofly.Core.Context.Support;
- namespace Tofly.SearchUI.Win
- {
-
-
-
- [Component(IsSingleton = "false", Name = "Tofly.SearchUI.Win.FormIdentifyBySpatial")]
- public partial class FormIdentifyBySpatial : Tofly.CoreUI.Win.Form.Forms.FormClass, Tofly.SearchUI.Query.IFormIdentifyBySpatial
- {
- #region ----- 模块级变量 -----
- private const string TopMostLayer = "<最顶图层>";
- private const string SelectableLayers = "<可选图层>";
- private const string VisibleLayers = "<可见图层>";
- private const string AllLayers = "<所有图层>";
-
-
-
- private IPluginContent _mainContent;
-
-
-
- private IMap _cmap;
-
-
-
- private List<CustomMapLayer> _lstIdentifyRange = new List<CustomMapLayer>();
-
-
-
- private List<IFeatureLayer> _lstIdentifyLayer = new List<IFeatureLayer>();
-
-
-
- private Dictionary<IFeatureLayer, List<IFeature>> _dicIdentifyResults = new Dictionary<IFeatureLayer, List<IFeature>>();
-
-
-
- private IFeatureLayer _layerSelected;
-
-
-
- private IFeature _ftrSelected;
-
-
-
- private bool _bQueryingAttachments = false;
- #endregion
- #region ----- IFormIdentifyBySpatial 接口实现 -----
-
-
-
-
- public Dictionary<IFeatureLayer, List<IFeature>> DoIdentify(IGeometry geomIdentify)
- {
-
-
- if (this.IsDisposed)
- {
- return null;
- }
- this._layerSelected = null;
- this._ftrSelected = null;
- this.tvIdentifyResult.Nodes.Clear();
- this._dicIdentifyResults.Clear();
- this.ShowClickedNodeInfo(null, false);
- Application.DoEvents();
- List<IFeatureLayer> __lstIdentifyLayers = this._lstIdentifyLayer;
- if (geomIdentify == null || __lstIdentifyLayers.Count == 0)
- {
- return null;
- }
- this.lblFeatureCount.Text = "正在查询...";
- Application.DoEvents();
- Dictionary<IFeatureLayer, List<IFeature>> __dicIdentifyResult = this.ExecuteIdentify(__lstIdentifyLayers, geomIdentify);
- #region ----- 显示识别结果 -----
- if (this.identifyRange.IfTopLayers)
- {
- if (this._dicIdentifyResults.Count > 0)
- {
- List<ILayer> __lstIdentifiedLayers = this._dicIdentifyResults.Keys.Select(flyrItem => flyrItem as ILayer).ToList();
- ILayer __lyrTopLayer = this.GetTopMostLayer(__lstIdentifiedLayers);
- this._dicIdentifyResults = this._dicIdentifyResults.Where(kvItem => kvItem.Key == __lyrTopLayer).ToDictionary(kvItem => kvItem.Key, kvItem => kvItem.Value);
- }
- }
- int __iCount = this._dicIdentifyResults.Sum(kvLayerFeature => kvLayerFeature.Value.Count);
- if (__iCount > 1000)
- {
- throw new System.Exception("查看范围过大,结果超过1000个,请缩小查看范围。");
- }
- this.tvIdentifyResult.Nodes.Clear();
- #region 选择要素的符号缩略图集合
- IBaseSymbolHelper __symolHelper = ContextRegistry.GetContext().GetObject("Tofly.GIS.ArcGIS.Util.BaseSymbolHelper") as IBaseSymbolHelper;
- ImageList __imgList = __symolHelper.GetSelectedFeaturesSymbol(this._dicIdentifyResults);
-
- while (this.imgListTV.Images.Count > 6)
- {
- this.imgListTV.Images.RemoveAt(6);
- }
- for (int __iKey = 0; __iKey < __imgList.Images.Keys.Count; __iKey++)
- {
- this.imgListTV.Images.Add(__imgList.Images.Keys[__iKey], __imgList.Images[__imgList.Images.Keys[__iKey]]);
- }
- #endregion
- foreach (var __identifyResultItem in this._dicIdentifyResults)
- {
- TreeNode __tnLayer = this.tvIdentifyResult.Nodes.Add(__identifyResultItem.Key.Name);
- string __strClassPrefix = __identifyResultItem.Key.FeatureClass.ObjectClassID.ToString();
- foreach (var __identifyObj in __identifyResultItem.Value)
- {
-
- __tnLayer.Nodes.Add(new TreeNode()
- {
- Text = __identifyObj.OID.ToString(),
- ImageKey = string.Format("{0}_{1}", __strClassPrefix, __identifyObj.OID)
- });
- }
- }
- this.tvIdentifyResult.ExpandAll();
- if (this.tvIdentifyResult.Nodes.Count > 0)
- {
- this.tvIdentifyResult.TopNode = tvIdentifyResult.Nodes[0];
- this.tvIdentifyResult.SelectedNode = tvIdentifyResult.Nodes[0];
- }
- #endregion
- return __dicIdentifyResult;
-
-
-
-
-
-
-
-
-
- }
-
-
-
-
-
- public void DisplayCoordinates(double mapX, double mapY)
- {
- if (this.IsDisposed)
- {
- return;
- }
-
- this.txtCoordinate.Text = string.Format("{0}, {1}", mapX.ToString("########.########"), mapY.ToString("########.########")) + " " + this.MapUnitChinese(this._cmap.MapUnits);
- }
- #endregion
-
-
-
- private FormIdentifyBySpatial()
- {
- InitializeComponent();
- tsbtnAttachFile.Visible = false;
- this.identifyRange.DropHeight = this.Height * 2 / 3;
- this.identifyRange.LayerSelectedChanged += this.IdentifyRange_LayerSelectedChanged;
- this.ucsFeatureViewer.IsViewer = true;
- }
-
-
-
-
- public FormIdentifyBySpatial(IPluginContent content)
- : this()
- {
- this._mainContent = content;
- }
- #region ----- 实现Singleton模式(单例) -----
-
-
-
-
-
- public static FormIdentifyBySpatial GetInstance(IPluginContent content)
- {
- return Nested.GetIdentifyForm(content);
- }
-
-
-
- private class Nested
- {
- private static FormIdentifyBySpatial _frmIndentify;
-
-
-
-
-
- internal static FormIdentifyBySpatial GetIdentifyForm(IPluginContent content)
- {
- if (Nested._frmIndentify == null || Nested._frmIndentify.IsDisposed)
- {
- Nested._frmIndentify = new FormIdentifyBySpatial(content);
- }
- return Nested._frmIndentify;
- }
- }
- #endregion
-
-
-
-
-
- private void FormIdentifyBySpatial_Load(object sender, EventArgs e)
- {
- try
- {
- IMapControl __cmapControl = ServiceLocatorFactory.ServiceLocator.GetInstance<IControl>(ServiceLocatorKeys.MapControl) as IMapControl;
- this._cmap = __cmapControl.Map;
- this._mainContent.ServiceLocator.ServiceValueChange += ServiceLocator_ServiceValueChange;
- this.pbarIdentify.Visible = false;
- this.identifyRange.InitLayer();
- this.IdentifyRange_LayerSelectedChanged(null);
- this.ucsFeatureViewer.CMap = this._cmap;
- }
- catch { }
- }
-
-
-
-
-
- private void FormIdentifyBySpatial_Deactivate(object sender, EventArgs e)
- {
-
- }
-
-
-
-
-
- private void FormIdentifyBySpatial_FormClosed(object sender, FormClosedEventArgs e)
- {
-
- this._lstIdentifyRange.Clear();
- this._dicIdentifyResults.Clear();
- this.identifyRange.LayerSelectedChanged -= this.IdentifyRange_LayerSelectedChanged;
- }
- private void tvIdentifyResult_AfterSelect(object sender, TreeViewEventArgs e)
- {
- try
- {
- if (e != null)
- {
- this.ShowClickedNodeInfo(e.Node, true);
- }
- }
- catch (System.Exception ex)
- {
- MessageManager.Show(ex.Message, "查看台帐");
- }
- }
- private void tvIdentifyRange_Leave(object sender, EventArgs e)
- {
-
- }
- private void tvIdentifyRange_AfterSelect(object sender, TreeViewEventArgs e)
- {
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- }
- private void cmbLayerFilter_Click(object sender, EventArgs e)
- {
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- }
-
-
-
-
-
- private void tsbtnAttachFile_Click(object sender, EventArgs e)
- {
- try
- {
- if (this._ftrSelected == null || this._bQueryingAttachments)
- {
- return;
- }
- #region ------------ 查询/查看附件 ------------
- Tofly.CoreUI.Control.IForm pForm = Tofly.Core.Context.Support.ContextRegistry.GetContext().GetObject("FormFTPManager", new object[] { this._ftrSelected,false }) as Tofly.CoreUI.Control.IForm;
- pForm.ShowDialog();
- #endregion
- }
- catch (System.Exception ex)
- {
- MessageManager.Show(string.Format("获取失败:{0}", ex.Message), "查看要素附件");
- }
- }
- private void tsbtnCreateSelectionset_Click(object sender, EventArgs e)
- {
- try
- {
- this._cmap.ClearSelection();
- this._cmap.ActiveView.PartialRefresh(ViewDrawPhase.ViewGeoSelection, null, this._cmap.Extent);
- List<int> __lstFeatureOIDs = new List<int>();
- foreach (var __identifyResult in this._dicIdentifyResults)
- {
- __lstFeatureOIDs.Clear();
- __lstFeatureOIDs.AddRange(__identifyResult.Value.Select(feat => feat.OID));
- __identifyResult.Key.AddSelectFeatureList(__lstFeatureOIDs);
- }
- this._cmap.PartialRefresh(ViewDrawPhase.ViewGeoSelection, null, this._cmap.Extent);
- MessageManager.Show(string.Format("生成选择集成功."));
- }
- catch(System.Exception ex)
- {
- MessageManager.Show(string.Format("生成失败:{0}", ex.Message), "生成选择集");
- }
- }
- private void tsbtnFlashSelected_Click(object sender, EventArgs e)
- {
- try
- {
- if (this.tvIdentifyResult.SelectedNode != null)
- {
- IGeometry[] __arrShineGeoms = new IGeometry[0];
- if (this.tvIdentifyResult.SelectedNode.Nodes.Count == 0)
- {
- __arrShineGeoms = new IGeometry[] { this._ftrSelected.ShapeCopy };
- }
- else
- {
- var __kvSelectedFeatureByLayer = this._dicIdentifyResults.First(kvItem => kvItem.Key.Name == this.tvIdentifyResult.SelectedNode.Text);
- __arrShineGeoms = __kvSelectedFeatureByLayer.Value.Select(feat => feat.ShapeCopy as IGeometry).ToArray();
- }
- this._cmap.FlashGeometry(this._cmap.ActiveView, __arrShineGeoms, 1, 200);
- }
- }
- catch { }
- }
- private void FormIdentifyBySpatial_MouseEnter(object sender, EventArgs e)
- {
- if (!this.Focused)
- {
- this.Focus();
- }
- }
- private void tvIdentifyResult_MouseUp(object sender,System.Windows.Forms.MouseEventArgs e)
- {
- try
- {
- var __nodeMouseDown = this.tvIdentifyResult.GetNodeAt(e.Location);
- if (e.Button == System.Windows.Forms.MouseButtons.Right)
- {
-
- if (__nodeMouseDown != null)
- {
- if (__nodeMouseDown != this.tvIdentifyResult.SelectedNode)
- {
- this.tvIdentifyResult.SelectedNode = __nodeMouseDown;
- }
- this.contextMenuTree.Show(this.tvIdentifyResult, e.Location);
- }
- }
- else if (e.Button == System.Windows.Forms.MouseButtons.Left)
- {
- if (this.tvIdentifyResult.SelectedNode != null && __nodeMouseDown == this.tvIdentifyResult.SelectedNode)
- {
- this.tsbtnFlashSelected.PerformClick();
- }
- }
- }
- catch { }
- }
-
-
-
-
-
- private void contextMenuTree_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
- {
- try
- {
- if (e == null)
- {
- return;
- }
- List<IFeature> __lstFeatureSelected = new List<IFeature>();
- KeyValuePair<IFeatureLayer, List<IFeature>> __kvSelectedFeatureByLayer = new KeyValuePair<IFeatureLayer, List<IFeature>>();
- if (this.tvIdentifyResult.SelectedNode.Nodes.Count == 0)
- {
- __kvSelectedFeatureByLayer = this._dicIdentifyResults.First(kvItem => kvItem.Key.Name == this.tvIdentifyResult.SelectedNode.Parent.Text);
- __lstFeatureSelected.Add(__kvSelectedFeatureByLayer.Value.Find(ftrItem => ftrItem.OID == Convert.ToInt32(this.tvIdentifyResult.SelectedNode.Text)));
- }
- else
- {
- __kvSelectedFeatureByLayer = this._dicIdentifyResults.First(kvItem => kvItem.Key.Name == this.tvIdentifyResult.SelectedNode.Text);
- __lstFeatureSelected.AddRange(__kvSelectedFeatureByLayer.Value);
- }
- if (e.ClickedItem == this.miFlashFeature)
- {
- List<IGeometry> __lstFeatureGeoms = new List<IGeometry>();
- foreach (var __ftrSel in __lstFeatureSelected)
- {
- __lstFeatureGeoms.Add(__ftrSel.ShapeCopy);
- }
- this._cmap.FlashGeometry(this._cmap.ActiveView, __lstFeatureGeoms.ToArray(), 1, 200);
- }
- else if (e.ClickedItem == this.miZoomTo)
- {
- IEnvelope __gEnv = MapSelectionHelper.GetFeaturesEnvelope(__lstFeatureSelected);
- this._cmap.ActiveView.Extent = __gEnv;
- this._cmap.PartialRefresh(ViewDrawPhase.ViewGeography | ViewDrawPhase.ViewGeoSelection, null, null);
- }
- else if (e.ClickedItem == this.miPanTo)
- {
- IEnvelope __gEnvNew = MapSelectionHelper.GetFeaturesEnvelope(__lstFeatureSelected);
- IEnvelope __gEnvCurrent = this._cmap.Extent;
- __gEnvCurrent.CenterAt(__gEnvNew.GetCentroid());
- this._cmap.ActiveView.Extent = __gEnvCurrent;
- this._cmap.PartialRefresh(ViewDrawPhase.ViewGeography | ViewDrawPhase.ViewGeoSelection, null, null);
- }
- Application.DoEvents();
- }
- catch(System.Exception ex)
- {
- MessageManager.Show(ex.Message, "要素识别");
- }
- }
- #region ----- 事件处理 -----
-
-
-
-
- private void IdentifyRange_LayerSelectedChanged(object sender)
- {
- List<ILayer> __lstSelectLayer = this.identifyRange.SelectNodeLayers();
- this._lstIdentifyLayer.Clear();
- foreach (var __layer in __lstSelectLayer)
- {
- if (__layer is IFeatureLayer)
- {
- this._lstIdentifyLayer.Add(__layer as IFeatureLayer);
- }
- }
- }
-
-
-
-
-
- private void ServiceLocator_ServiceValueChange(string key, object value)
- {
- try
- {
- if (key.Equals(ServiceLocatorKeys.MapDocument))
- {
- this.DoIdentify(null);
- }
- }
- catch { }
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
- private void OnIdentifyRangeChanged(object item)
- {
- this._lstIdentifyRange.Clear();
- #region ----- 装载逻辑图层 -----
- CustomMapLayer topMostLayerProperty = new CustomMapLayer()
- {
- Category = TopMostLayer,
- FeatureType = tfLayerFeatureType.LayerFeatureLogic,
- LayerAliasName = TopMostLayer,
- SourceLayer = null,
- Valid = true
- };
- CustomMapLayer visibleLayerProperty = new CustomMapLayer()
- {
- Category = VisibleLayers,
- FeatureType = tfLayerFeatureType.LayerFeatureLogic,
- LayerAliasName = VisibleLayers,
- SourceLayer = null,
- Valid = true
- };
- CustomMapLayer selectableLayerProperty = new CustomMapLayer()
- {
- Category = SelectableLayers,
- FeatureType = tfLayerFeatureType.LayerFeatureLogic,
- LayerAliasName = SelectableLayers,
- SourceLayer = null,
- Valid = true
- };
- CustomMapLayer allLayerProperty = new CustomMapLayer()
- {
- Category = AllLayers,
- FeatureType = tfLayerFeatureType.LayerFeatureLogic,
- LayerAliasName = AllLayers,
- SourceLayer = null,
- Valid = true
- };
- this._lstIdentifyRange.Add(topMostLayerProperty);
- this._lstIdentifyRange.Add(visibleLayerProperty);
- this._lstIdentifyRange.Add(selectableLayerProperty);
- this._lstIdentifyRange.Add(allLayerProperty);
- #endregion
-
-
- #region ------- 呈现识别范围 -------
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- #endregion
- }
- #endregion
- #region ----- < 指定图层过滤器的获取方法 > -----
-
-
-
- private List<ILayer> getAllLayers
- {
- get
- {
- List<ILayer> __lstSourceLayer = new List<ILayer>();
- List<tfLayerFeatureType> __lstExceptedLayerType = new List<tfLayerFeatureType>()
- {
- tfLayerFeatureType.LayerFeatureLogic,
- tfLayerFeatureType.LayerFeatureUnknown,
- tfLayerFeatureType.LayerFeatureRaster
- };
- foreach (CustomMapLayer __custMapLayerItem in this._lstIdentifyRange)
- {
- if (__custMapLayerItem.Valid && !__lstExceptedLayerType.Contains(__custMapLayerItem.FeatureType))
- {
- if (__custMapLayerItem.FeatureType == tfLayerFeatureType.LayerFeatureGroupLayer)
- {
- List<ILayer> __lstSubLayerSource = this.GetSubLayerSource(__custMapLayerItem);
- __lstSourceLayer.AddRange(__lstSubLayerSource);
- }
- else
- {
- __lstSourceLayer.Add(__custMapLayerItem.SourceLayer);
- }
- }
- }
- return __lstSourceLayer;
- }
- }
-
-
-
- private List<ILayer> getSelectableLayers
- {
- get
- {
- List<ILayer> __lstSourceLayers = this.getAllLayers;
- __lstSourceLayers.RemoveAll(layerItem => !((IFeatureLayer)layerItem).Selectable);
- __lstSourceLayers.RemoveAll(layerItem => !layerItem.Visible);
- return __lstSourceLayers;
- }
- }
-
-
-
- private List<ILayer> getVisibleLayers
- {
- get
- {
-
-
- List<ILayer> __lstSourceLayers = new List<ILayer>();
- List<tfLayerFeatureType> __lstExceptedLayerType = new List<tfLayerFeatureType>()
- {
- tfLayerFeatureType.LayerFeatureLogic,
- tfLayerFeatureType.LayerFeatureUnknown,
- tfLayerFeatureType.LayerFeatureRaster
- };
- foreach (CustomMapLayer __custMapLayerItem in this._lstIdentifyRange)
- {
- if (__custMapLayerItem.Valid && !__lstExceptedLayerType.Contains(__custMapLayerItem.FeatureType) && __custMapLayerItem.SourceLayer.Visible)
- {
- if (__custMapLayerItem.FeatureType == tfLayerFeatureType.LayerFeatureGroupLayer)
- {
- List<ILayer> __lstSubLayerSource = this.GetSubLayerSource(__custMapLayerItem);
- __lstSourceLayers.AddRange(__lstSubLayerSource);
- }
- else
- {
- __lstSourceLayers.Add(__custMapLayerItem.SourceLayer);
- }
- }
- }
- __lstSourceLayers.RemoveAll(lyrItem => !lyrItem.Visible);
- return __lstSourceLayers;
- }
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- private CustomMapLayer getTopmostLayer
- {
-
- get
- {
- CustomMapLayer layer = null;
- int layerCount = _lstIdentifyRange.Count;
- for (int i = 4; i < layerCount; i++)
- {
- CustomMapLayer layerProp = _lstIdentifyRange[i];
- ILayer esriLayer = layerProp.SourceLayer;
- if (!(esriLayer is IGroupLayer) &&
- !(esriLayer is ICompositeLayer))
- {
- layer = layerProp;
- break;
- }
- }
- return layer;
- }
- }
- #endregion
- #region ----- 其他私有方法 -----
-
-
-
-
-
- private string MapUnitChinese(Units mapUnit)
- {
- string mapUnitChinese = "未知单位";
- switch (mapUnit)
- {
- case Units.Centimeters:
- mapUnitChinese = "厘米";
- break;
- case Units.DecimalDegrees:
- mapUnitChinese = "分米";
- break;
- case Units.Decimeters:
- mapUnitChinese = "";
- break;
-
-
-
-
-
-
- case Units.Kilometers:
- mapUnitChinese = "千米";
- break;
- case Units.Meters:
- mapUnitChinese = "米";
- break;
- case Units.Miles:
- mapUnitChinese = "英里";
- break;
- case Units.Millimeters:
- mapUnitChinese = "毫米";
- break;
-
-
-
- }
- return mapUnitChinese;
- }
-
-
-
-
-
- private List<TreeNode> GetSubLayerNodes(CustomMapLayer groupLayer)
- {
- List<TreeNode> __lstLayerNodes = new List<TreeNode>();
- List<tfLayerFeatureType> __lstExceptedLayerType = new List<tfLayerFeatureType>()
- {
- tfLayerFeatureType.LayerFeatureLogic,
- tfLayerFeatureType.LayerFeatureUnknown,
- tfLayerFeatureType.LayerFeatureRaster
- };
- foreach (CustomMapLayer __custMapLayerItem in groupLayer.SubLayers)
- {
- if (__custMapLayerItem.Valid && !__lstExceptedLayerType.Contains(__custMapLayerItem.FeatureType))
- {
- TreeNode __tnRootItem = new TreeNode(__custMapLayerItem.LayerAliasName)
- {
- Name = __custMapLayerItem.LayerAliasName,
- Tag = __custMapLayerItem
- };
- switch (__custMapLayerItem.FeatureType)
- {
- case tfLayerFeatureType.LayerFeatureGroupLayer:
- __tnRootItem.ImageKey = "LayerGroup";
- __tnRootItem.SelectedImageKey = "LayerGroup";
- break;
- case tfLayerFeatureType.LayerFeatureLogic:
- __tnRootItem.ImageKey = "LayerLogic";
- __tnRootItem.SelectedImageKey = "LayerLogic";
- break;
- case tfLayerFeatureType.LayerFeaturePoint:
- __tnRootItem.ImageKey = "LayerPoint";
- __tnRootItem.SelectedImageKey = "LayerPoint";
- break;
- case tfLayerFeatureType.LayerFeaturePolyline:
- __tnRootItem.ImageKey = "LayerLine";
- __tnRootItem.SelectedImageKey = "LayerLine";
- break;
- case tfLayerFeatureType.LayerFeaturePolygon:
- __tnRootItem.ImageKey = "LayerPolygon";
- __tnRootItem.SelectedImageKey = "LayerPolygon";
- break;
- }
- if (__custMapLayerItem.FeatureType == tfLayerFeatureType.LayerFeatureGroupLayer)
- {
- List<TreeNode> __lstSubLayerNodes = this.GetSubLayerNodes(__custMapLayerItem);
- __tnRootItem.Nodes.AddRange(__lstSubLayerNodes.ToArray());
- }
- __lstLayerNodes.Add(__tnRootItem);
- }
- }
- return __lstLayerNodes;
- }
-
-
-
-
-
- private List<ILayer> GetSubLayerSource(CustomMapLayer groupLayer)
- {
- List<ILayer> __lstSourceLayer = new List<ILayer>();
- List<tfLayerFeatureType> __lstExceptedLayerType = new List<tfLayerFeatureType>()
- {
- tfLayerFeatureType.LayerFeatureLogic,
- tfLayerFeatureType.LayerFeatureUnknown,
- tfLayerFeatureType.LayerFeatureRaster
- };
- foreach (CustomMapLayer __custMapLayerItem in groupLayer.SubLayers)
- {
- if (__custMapLayerItem.Valid && !__lstExceptedLayerType.Contains(__custMapLayerItem.FeatureType))
- {
- if (__custMapLayerItem.FeatureType == tfLayerFeatureType.LayerFeatureGroupLayer)
- {
- List<ILayer> __lstSubLayerSource = this.GetSubLayerSource(__custMapLayerItem);
- __lstSourceLayer.AddRange(__lstSubLayerSource);
- }
- else
- {
- __lstSourceLayer.Add(__custMapLayerItem.SourceLayer);
- }
- }
- }
- return __lstSourceLayer;
- }
-
-
-
-
- private List<ILayer> GetIdentifyLayers()
- {
- List<ILayer> __lstIdentifyLayers = new List<ILayer>();
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- return __lstIdentifyLayers;
- }
-
-
-
-
-
- private Dictionary<IFeatureLayer, List<IFeature>> ExecuteIdentify(List<IFeatureLayer> identifyLayers, IGeometry geomIdentify)
- {
-
- #region ----- 显示处理进度 -----
- this.pbarIdentify.Visible = true;
- this.pbarIdentify.Maximum = 10;
- this.pbarIdentify.Minimum = 0;
- this.pbarIdentify.Value = 0;
- #endregion
- Dictionary<object, List<object>> __dicFeaturesByLayer = new Dictionary<object, List<object>>();
- List<ILayer> __lstIdenLayer = identifyLayers.Select(flayer => flayer as ILayer).ToList();
- Dictionary<object, List<object>> __dicTempLayerRow = this._cmap.GetSelectedFeaturesByGeometry(__lstIdenLayer, geomIdentify);
- if (this.identifyRange.IfTopLayers)
- {
- if (__dicTempLayerRow != null && __dicTempLayerRow.Count != 0)
- {
- foreach (KeyValuePair<object, List<object>> __kvLayerRow in __dicTempLayerRow)
- {
- __dicFeaturesByLayer.Add(__kvLayerRow.Key, __kvLayerRow.Value);
- break;
- }
- }
- }
- else
- {
- __dicFeaturesByLayer = __dicTempLayerRow;
- }
- this.pbarIdentify.Maximum = __dicFeaturesByLayer.Count;
- IFeatureLayer __flayer = null;
- foreach (var __kvFeatureByLayer in __dicFeaturesByLayer)
- {
- __flayer = __kvFeatureByLayer.Key as IFeatureLayer;
- if (this._dicIdentifyResults.ContainsKey(__flayer) == false)
- {
- this._dicIdentifyResults.Add(__kvFeatureByLayer.Key as IFeatureLayer, __kvFeatureByLayer.Value.Select(objSel => objSel as IFeature).ToList());
- }
- else
- {
-
- }
- #region ----- 显示处理进度 -----
- if ((this.pbarIdentify.Value + 1) > this.pbarIdentify.Maximum)
- {
- this.pbarIdentify.Value = 0;
- }
- this.pbarIdentify.Value += 1;
- Application.DoEvents();
- #endregion
- }
- this.pbarIdentify.Value = this.pbarIdentify.Maximum;
- int __identifiedObjCount = 0;
- if (this._dicIdentifyResults.Count > 0)
- {
- __identifiedObjCount = this._dicIdentifyResults.Sum(kvSelFeaturesByLayer => kvSelFeaturesByLayer.Value.Count);
- }
- this.pbarIdentify.Visible = false;
- this.lblFeatureCount.Text = "查询到 " + __identifiedObjCount + " 条记录";
- return this._dicIdentifyResults;
- }
-
-
-
-
-
- private void ShowClickedNodeInfo(TreeNode nodeClicked, bool doFlash)
- {
- try
- {
- if (nodeClicked == null)
- {
- this.ShowFeatureAttributes(null, null);
- }
- else
- {
- KeyValuePair<IFeatureLayer, List<IFeature>> __kvSelectedFeatureByLayer = new KeyValuePair<IFeatureLayer, List<IFeature>>();
- int __iFeatureIndex = -1;
- if (nodeClicked.Nodes.Count == 0)
- {
- __iFeatureIndex = nodeClicked.Index;
- __kvSelectedFeatureByLayer = this._dicIdentifyResults.First(kvItem => kvItem.Key.Name == nodeClicked.Parent.Text);
- }
- else
- {
- __kvSelectedFeatureByLayer = this._dicIdentifyResults.First(kvItem => kvItem.Key.Name == nodeClicked.Text);
- }
- this._layerSelected = __kvSelectedFeatureByLayer.Key;
- if (__iFeatureIndex > -1)
- {
- this._ftrSelected = __kvSelectedFeatureByLayer.Value.Find(ftrItem => ftrItem.OID == Convert.ToInt32(nodeClicked.Text));
- this.ShowFeatureAttributes(__kvSelectedFeatureByLayer.Key, this._ftrSelected);
-
- if (doFlash)
- {
- IGeometry[] __arrGeoms = new IGeometry[] { this._ftrSelected.ShapeCopy };
- this._cmap.FlashGeometry(this._cmap.ActiveView, __arrGeoms, 1, 200);
-
-
-
-
-
-
-
- }
- }
- else
- {
- if (nodeClicked.Nodes.Count > 0 && this.ucsFeatureViewer.ProcessingFeature == null)
- {
- int __iFeatOID = Convert.ToInt32(nodeClicked.Nodes[0].Text);
- this._ftrSelected = __kvSelectedFeatureByLayer.Value.Find(ftrItem => ftrItem.OID == __iFeatOID);
- this.ShowClickedNodeInfo(nodeClicked.Nodes[0], false);
- }
- Application.DoEvents();
- IGeometry[] __arrGeoms = __kvSelectedFeatureByLayer.Value.Select(feat => feat.ShapeCopy as IGeometry).ToArray();
- this._cmap.FlashGeometry(this._cmap.ActiveView, __arrGeoms, 1, 200);
- }
-
-
- }
- }
- catch (System.Exception ex)
- {
- MessageManager.Show("显示失败:" + ex.Message, "显示选择设备信息");
- }
- }
-
-
-
-
-
- private void ShowFeatureAttributes(IFeatureLayer fLayerSelected, IFeature identifiedFeature)
- {
- this.ucsFeatureViewer.ResetUserControlState(null);
- if (identifiedFeature == null)
- {
- return;
- }
- this.ucsFeatureViewer.SetFeatureView(fLayerSelected, identifiedFeature);
- }
-
-
-
-
-
- private ILayer GetTopMostLayer(List<ILayer> layers)
- {
- ILayer __lyrTopLayer = null;
- List<ILayer> __lstLayersAnalysting = new List<ILayer>(layers);
- TreeNode __tnTopNode = null;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- __lyrTopLayer = __lstLayersAnalysting[0];
-
- return __lyrTopLayer;
- }
-
-
-
-
- private void ProcessAttachmentsResult(bool showForm)
- {
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- }
- #endregion
- }
- }
|