123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175 |
-
- 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.CoreUI.Win.Form.Forms;
- using Tofly.CoreUI.Utils;
- using Tofly.Data.Metadata;
- using Tofly.GIS.Display;
- using Tofly.GISUI.Content;
- 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.Plugin;
- using Tofly.Data.General;
- using Tofly.GISUI.Utils;
- 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.FeatureBackSaveCommand")]
- public class FeatureBackSaveCommand : GISPluginButtonBase
- {
-
-
-
- private IMap _cmap;
-
-
-
- private Dictionary<IFeatureLayer, List<IFeature>> _dicEditableFeatures;
-
-
-
- private List<IFeatureLayer> _lstEditableGWLayer = new List<IFeatureLayer>();
-
-
-
- private IFormBackSaveEquipment _frmBackSave;
- public override void Create(IPluginContent content)
- {
- base.Create(content);
- this.Enable = false;
- this.content.ServiceLocator.ServiceValueChange += ServiceLocator_ServiceValueChange;
- }
- public override void Click()
- {
- try
- {
- if (this._cmap.SelectionCount == 0 || this._frmBackSave != null)
- {
- return;
- }
- if (this._dicEditableFeatures == null || this._dicEditableFeatures.Count == 0)
- {
- throw new System.Exception("无有效可编辑要素.");
- }
- List<IFeatureLayer> __lstLayerSelected = this._dicEditableFeatures.Keys.ToList();
- if (__lstLayerSelected.Count > 1)
- {
- __lstLayerSelected.Clear();
- IFormSelectMultiEditLayer __frmSelMutiLayer = ContextRegistry.GetContext().GetObject("Tofly.DataEditUI.Win.FormSelectMultiEditLayer") as IFormSelectMultiEditLayer;
- __frmSelMutiLayer.EditingLayerFeatures = this._dicEditableFeatures;
- __frmSelMutiLayer.LoadSelectableLayers(this._dicEditableFeatures.Keys.ToList());
- if (__frmSelMutiLayer.ShowDialog(this.content.PluginMainForm) == DialogResult.OK)
- {
- __lstLayerSelected = __frmSelMutiLayer.SelectedLayers;
- }
- __frmSelMutiLayer.Dispose();
- __frmSelMutiLayer = null;
- }
- if (__lstLayerSelected.Count > 0)
- {
- var __dicSelFeaturesByLayer = (from __kvLayerFeature in this._dicEditableFeatures
- where __lstLayerSelected.Contains(__kvLayerFeature.Key)
- select __kvLayerFeature).ToDictionary(kvItem => kvItem.Key, kvItem => kvItem.Value);
- this._frmBackSave = ContextRegistry.GetContext().GetObject("Tofly.DataEditUI.Win.FormBackSaveEquipment", new object[1] { __dicSelFeaturesByLayer }) as IFormBackSaveEquipment;
- this._frmBackSave.CMap = this._cmap;
- this._frmBackSave.Content = this.content;
- this._frmBackSave.FormClosedEvent += this.FromBackSave_FormClosed;
- this._frmBackSave.ShowDialog(this.content.PluginMainForm);
-
- this._cmap.ActiveView.PartialRefresh(ViewDrawPhase.ViewGeography | ViewDrawPhase.ViewGeoSelection, null, this._cmap.Extent);
- var __docContent = content.ServiceLocator.GetInstance<IDocumentContent>(ServiceLocatorKeys.DocumentContent);
- IActiveView __viewSelction = __docContent.ActiveViewContent.ActiveView;
- __viewSelction.PartialRefresh(ViewDrawPhase.ViewGeoSelection, null, __viewSelction.Extent);
- }
- }
- catch (System.Exception ex)
- {
- MessageManager.Show("属性处理错误: " + ex.Message, "属性自动化");
- }
- }
-
-
-
-
-
- protected void ServiceLocator_ServiceValueChange(string key, object value)
- {
- if (key.Equals(ServiceLocatorKeys.IsMapEdit))
- {
- this._lstEditableGWLayer.Clear();
- this.ActiveViewContent_ActiveViewSelectionChanged(null);
- }
- else if (key.Equals(ServiceLocatorKeys.DocumentContent))
- {
- this._cmap = (this.content.ServiceLocator.GetInstance<IControl>(ServiceLocatorKeys.MapControl) as IMapControl).Map;
- var documentcontent = content.ServiceLocator.GetInstance<IDocumentContent>(ServiceLocatorKeys.DocumentContent);
- documentcontent.ActiveViewContent.ActiveViewSelectionChanged -= ActiveViewContent_ActiveViewSelectionChanged;
- 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._lstEditableGWLayer.Count == 0)
- {
- this._lstEditableGWLayer.AddRange(FeatureLayerHelper.GetFeatureLayersByDataset(this._cmap, AppConfig.GWDatasetName));
- this._lstEditableGWLayer.RemoveAll(flayer => flayer.FeatureClass.Workspace.IsBeingEdited() == false);
- }
- this._dicEditableFeatures = MapSelectionHelper.GetSelectedFeaturesByLayer(this._cmap, this._lstEditableGWLayer, true);
- this.Enable = (this._dicEditableFeatures.Count > 0);
- }
- }
- }
- private void FromBackSave_FormClosed(object sender)
- {
- if (this._frmBackSave != null)
- {
- this._frmBackSave.Dispose();
- }
- this._frmBackSave = null;
- }
- }
- }
|