123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171 |
-
- using System;
- using System.Collections.Generic;
- using System.Text;
- using System.Linq;
- using Tofly.Core.Context.Support;
- using Tofly.Core.Context;
- using Tofly.Core.ServiceLocator;
- using Tofly.CoreUI.Plot;
- using Tofly.CoreUI.Control;
- using Tofly.CoreUI.Message;
- using Tofly.Data.Metadata;
- using Tofly.GIS.Display;
- using Tofly.GISUI.Controls;
- using Tofly.GIS.Geometry;
- using Tofly.GIS.Carto;
- using Tofly.GIS.SpatialDatabase;
- using Tofly.GIS.Util;
- using Tofly.DataEditUI.Properties;
- using Tofly.GISUI.Content;
- using Tofly.GISUI.Plugin;
- using Tofly.GISUI.Utils;
- using Tofly.DataEdit;
- namespace Tofly.DataEditUI
- {
-
-
-
- [PluginComponentAttribute((long)Core.SysRegist.ModuleKey.Edit, PluginGISType.ArcGIS, GroupName = "编辑", Caption = "连通性编辑", Describe = "点要素连通性编辑管理", IsCreate = true, States = Tofly.CoreUI.Control.Status.STATE_EDIT)]
- [Tofly.Core.Stereotype.Component(IsSingleton = "false", Name = "Tofly.DataEditUI.ConnectionManageCommand")]
- public class ConnectionManageCommand : GISPluginButtonBase
- {
-
-
-
- private IMap _cmap;
-
-
-
- private IFormSetEditFeatureCollection _frmConnectionManage;
-
-
-
- private List<IFeatureLayer> _lstEditableLayer = new List<IFeatureLayer>();
-
-
-
- private Dictionary<IFeatureLayer, List<IFeature>> _dicEditableFeatures;
-
-
-
- public ConnectionManageCommand()
- {
- this.Enable = false;
- }
- public override void Create(IPluginContent content)
- {
- base.Create(content);
- this.content.ServiceLocator.ServiceValueChange += ServiceLocator_ServiceValueChange;
- }
- public override void Click()
- {
- try
- {
- if (this._frmConnectionManage != null && this._frmConnectionManage.Visible)
- {
- this._frmConnectionManage.FormWindowState = FormWindowState.Normal;
- return;
- }
- if (this._cmap.SelectionCount == 0)
- {
- return;
- }
- if (this._dicEditableFeatures == null || this._dicEditableFeatures.Count == 0)
- {
- throw new System.Exception("无有效可编辑要素.");
- }
- if (this._dicEditableFeatures.Count > 0)
- {
- this._frmConnectionManage = ContextRegistry.GetContext().GetObject("Tofly.DataEditUI.Win.FormConnectionManage") as IFormSetEditFeatureCollection;
- this._frmConnectionManage.FormClosedEvent += (s) =>
- {
- System.Windows.Forms.Form __frmBase = this._frmConnectionManage as System.Windows.Forms.Form;
- if (__frmBase != null && __frmBase.IsDisposed == false)
- {
- __frmBase.Dispose();
- }
- this._frmConnectionManage = null;
- };
- this._frmConnectionManage.FormStartPosition = FormStartPositionType.CenterScreen;
- this._frmConnectionManage.Content = this.content;
- this._frmConnectionManage.CMap = this._cmap;
- this._frmConnectionManage.SetEditFeatures(this._dicEditableFeatures);
- this._frmConnectionManage.Show(this.content.PluginMainForm);
- }
- else
- {
- MessageManager.Show("请选择需要进行连通性编辑的点要素!", "连通性编辑");
- }
- }
- catch(System.Exception ex)
- {
- MessageManager.Show("打开编辑失败: " + ex.Message, "连通性编辑");
- }
- }
- protected virtual void ServiceLocator_ServiceValueChange(string key, object value)
- {
- if (key.Equals(ServiceLocatorKeys.IsMapEdit))
- {
- this.ActiveViewContent_ActiveViewSelectionChanged(null);
- bool __bIsWorkspaceEditing = this.content.ServiceLocator.GetInstance<bool>(ServiceLocatorKeys.IsMapEdit);
- if (__bIsWorkspaceEditing == false && this._frmConnectionManage != null)
- {
- this._frmConnectionManage.Dispose();
- this._frmConnectionManage = null;
- }
- }
- else if (key.Equals(ServiceLocatorKeys.DocumentContent))
- {
- this._cmap = (this.content.ServiceLocator.GetInstance<IControl>(ServiceLocatorKeys.MapControl) as IMapControl).Map;
- var documentcontent = this.content.ServiceLocator.GetInstance<IDocumentContent>(ServiceLocatorKeys.DocumentContent);
- documentcontent.ActiveViewContent.ActiveViewSelectionChanged += ActiveViewContent_ActiveViewSelectionChanged;
- }
- }
-
-
-
-
- protected void ActiveViewContent_ActiveViewSelectionChanged(ActiveViewSelectionChangedEventArgs e)
- {
- this.Enable = false;
- this._dicEditableFeatures = null;
- if (content.ServiceLocator.GetInstance<bool>(ServiceLocatorKeys.IsMapEdit))
- {
- if (this._cmap.SelectionCount > 0)
- {
- if (this._lstEditableLayer.Count == 0)
- {
- this._lstEditableLayer.AddRange(this._cmap.GetFeatureLayersByMap());
- this._lstEditableLayer.RemoveAll(clayer => clayer.FeatureClass == null || clayer.FeatureClass.Workspace.IsBeingEdited() == false);
- this._lstEditableLayer.RemoveAll(clayer => clayer.FeatureClass.ShapeType != GeometryType.GeometryPoint);
- }
- List<IFeatureLayer> __lstEditableLayer = this._lstEditableLayer.Where(flayer => flayer.Visible).ToList();
- this._dicEditableFeatures = MapSelectionHelper.GetSelectedFeaturesByLayer(this._cmap, __lstEditableLayer, true);
- this.Enable = (this._dicEditableFeatures.Count > 0);
- }
- }
- }
- }
- }
|