You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							103 lines
						
					
					
						
							3.3 KiB
						
					
					
				
			
		
		
	
	
							103 lines
						
					
					
						
							3.3 KiB
						
					
					
				using System; | 
						|
using ESRI.ArcGIS.Controls; | 
						|
using ESRI.ArcGIS.Geodatabase; | 
						|
using KGIS.Framework.EngineEditor; | 
						|
using KGIS.Framework.Platform; | 
						|
using KGIS.Framework.Utils; | 
						|
using KGIS.Framework.Utils.Helper; | 
						|
using KGIS.Framework.Utils.Interface; | 
						|
 | 
						|
namespace Kingo.Plugin.EngineEditor.Commands.Tools | 
						|
{ | 
						|
    public class CmdCoverRWTB : BaseToolCmd | 
						|
    { | 
						|
        private EngineEditorClass editor = new EngineEditorClass(); | 
						|
        private IHookHelper m_hookHelper; | 
						|
 | 
						|
        public override void OnCreate(object hook) | 
						|
        { | 
						|
            try | 
						|
            { | 
						|
                base.OnCreate(hook); | 
						|
                if (this.m_hookHelper == null) | 
						|
                { | 
						|
                    this.m_hookHelper = base.m_pHookHelper; | 
						|
                } | 
						|
                editor.OnStopEditing += Editor_OnStopEditing; | 
						|
                base.OnCreate(hook); | 
						|
            } | 
						|
            catch (Exception ex) | 
						|
            { | 
						|
                LogAPI.Debug("覆盖图斑初始化OnCreate异常:" + ex.Message); | 
						|
            } | 
						|
        } | 
						|
 | 
						|
        private void Editor_OnStopEditing(bool saveChanges) | 
						|
        { | 
						|
            try | 
						|
            { | 
						|
                (m_hookHelper.Hook as IMapControl2).CurrentTool = null; | 
						|
            } | 
						|
            catch (Exception ex) | 
						|
            { | 
						|
                LogAPI.Debug(ex); | 
						|
            } | 
						|
        } | 
						|
 | 
						|
        public override void OnClick() | 
						|
        { | 
						|
            base.OnClick(); | 
						|
            IFeature selectedFeature = null; | 
						|
            try | 
						|
            { | 
						|
                if (m_hookHelper.FocusMap.FeatureSelection is IEnumFeature) | 
						|
                { | 
						|
                    IEnumFeature enumFeature = m_hookHelper.FocusMap.FeatureSelection as IEnumFeature; | 
						|
                    while ((selectedFeature = enumFeature.Next()) != null) | 
						|
                    { | 
						|
                        if (MessageHelper.ShowYesNoAndTips($"是否从“{((IDataset)selectedFeature.Class).Name}”图层中,覆盖图斑?") == System.Windows.Forms.DialogResult.Yes) | 
						|
                        { | 
						|
                            break; | 
						|
                        } | 
						|
                        else | 
						|
                            selectedFeature = null; | 
						|
                    } | 
						|
                    if (selectedFeature == null) return; | 
						|
                    if (selectedFeature != null && ((IDataset)selectedFeature.Class).Name == "WYRW") | 
						|
                    { | 
						|
                        MessageHelper.ShowTips("覆盖选中要素不能为任务图斑!"); | 
						|
                        return; | 
						|
                    } | 
						|
                    Platform.Instance.SendMsg(new NotifyMsgPackage() { MsgType = "CoverRWTBToTreeNode", Content = selectedFeature }); | 
						|
                } | 
						|
            } | 
						|
            catch (Exception ex) | 
						|
            { | 
						|
                LogAPI.Debug("要素覆盖失败" + ex); | 
						|
                MessageHelper.ShowTips("要素覆盖失败!"); | 
						|
            } | 
						|
            finally | 
						|
            { | 
						|
                if (selectedFeature != null) | 
						|
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(selectedFeature); | 
						|
            } | 
						|
        } | 
						|
 | 
						|
        public override bool Enabled | 
						|
        { | 
						|
            get | 
						|
            { | 
						|
                if (editor != null && editor.EditState == esriEngineEditState.esriEngineStateEditing) | 
						|
                { | 
						|
                    return Platform.Instance.SystemType == SystemTypeEnum.DTBJK; ; | 
						|
                } | 
						|
                else | 
						|
                { | 
						|
                    return false; | 
						|
                } | 
						|
 | 
						|
            } | 
						|
        } | 
						|
 | 
						|
    } | 
						|
}
 | 
						|
 |