using ESRI.ArcGIS.Carto; using ESRI.ArcGIS.Controls; using ESRI.ArcGIS.Geodatabase; using KGIS.Framework.Maps; using KGIS.Framework.Utils; using KGIS.Framework.Views; using Kingo.PluginServiceInterface; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using UIShell.OSGi; namespace Kingo.Plugin.NYYP.Commands { /// /// 图斑预判 /// public class CmdNYYPInfo : BaseMapMenuCommand { IEngineEditor m_pEditor; IAttrTableHelper uCAttribute_Form = null; IDockPanel2 _Panel = null; private IProofManager ProofMgr = null; IElementInfo _NYYP = null; public override void OnClick() { try { if (ProofMgr == null) ProofMgr = BundleRuntime.Instance.GetFirstOrDefaultService(); IFeatureLayer featureLayer = MapsManager.Instance.MapService.GetFeatureLayerByName("JCTB"); IDockViewService _DockViewService = null; List lstElement = BundleRuntime.Instance.GetService(); if (lstElement == null) return; _NYYP = lstElement.FirstOrDefault(f => f.Title == "图斑预判组件"); IElementInfo _FeatureInfo = lstElement.FirstOrDefault(f => f.Title == "内业预判图斑信息"); _DockViewService = BundleRuntime.Instance.GetFirstOrDefaultService(); if (_DockViewService == null) return; _DockViewService.IsShowSaveButton = true; _DockViewService.Orientation = EnumOrientation.Vertical; _Panel = _DockViewService.InitView(); if (_NYYP != null) { _NYYP.AllowEdit = true; _NYYP.IsShow = true; _NYYP.BindData(null); _DockViewService.AddElement(_NYYP); } if (_FeatureInfo != null) { _FeatureInfo.AllowEdit = true; _FeatureInfo.BindData(m_hookHelper); _DockViewService.AddElement(_FeatureInfo); } if (MapsManager.Instance.MapService != null) { MapsManager.Instance.MapService.ProjectClosed -= MapService_ProjectClosed; MapsManager.Instance.MapService.ProjectClosed += MapService_ProjectClosed; } _Panel.Title = "自主变更图斑预判"; _Panel.DefaultArea = DockStyle.DockRight; _Panel.DockWidth = 400; _Panel.ShowCloseButton = true; _Panel.ShowPanel(); //打开属性检测图斑属性表 uCAttribute_Form = BundleRuntime.Instance.GetFirstOrDefaultService(); if (uCAttribute_Form != null) { _DockViewService.Callback = uCAttribute_Form.SelectRowPrevOrNextRow; //List _ViewParam = new List(); //Dictionary dic = new Dictionary(); //dic.Add("监测图斑", "监测图斑"); //dic.Add("变更范围", "变更范围"); //_ViewParam.Add(new AttributeViewParameter() //{ // LableInfo = "数据图层:", // Type = "Combox", // Data = dic, // Filterriteria = " AND (SUBSTRING(ZLDWDM,1,9) in ({0}))" //}); //Dictionary dic2 = new Dictionary(); //dic2.Add("国家监测图斑", "国家监测图斑"); //dic2.Add("自主变更图斑", "自主变更图斑"); //_ViewParam.Add(new AttributeViewParameter() //{ // LableInfo = "数据来源:", // Type = "Combox", // Data = featureLayer, // Filterriteria = " AND SFJCTB <> '' " //}); //uCAttribute_Form.InitView("检测图斑", m_hookHelper, _ViewParam); uCAttribute_Form.InitView("监测图斑", m_hookHelper, null); if (uCAttribute_Form.CurrentView != null) { uCAttribute_Form.CurrentView.LoadData(featureLayer, null); } } //重置数据 if (featureLayer != null && featureLayer.FeatureClass.FeatureCount(null) > 0) { IFeature TempFC = featureLayer.FeatureClass.Search(null, false).NextFeature(); if (TempFC != null) _NYYP.BindData(TempFC); } } catch (Exception ex) { LogAPI.Debug("检测图斑初始化失败:" + ex.Message); } } private List GetProofData(IFeature pFeature) { //List result = new List(); //if (ProofMgr != null && SystemCfg != null) //{ // if (SystemCfg.JZCGCfg == null) // SystemCfg.Load(); // if (SystemCfg.JZCGCfg != null && SystemCfg.JZCGCfg.LayerInfo != null && SystemCfg.JZCGCfg.LayerInfo.Count != 0) // { // string name = (pFeature.Class as IDataset).Name; // List layerInfoList = SystemCfg.JZCGCfg.LayerInfo.FindAll(x => x.IsCheck == true && x.LayerName == name || x.LayerAliasName == name); // if (layerInfoList != null && layerInfoList.Count != 0) // { // foreach (var wylayer in layerInfoList) // { // if (wylayer.RelevantModel == "属性") // { // if (!string.IsNullOrWhiteSpace(wylayer.AttributeField)) // { // int fieldIndex = pFeature.Fields.FindField(wylayer.AttributeField); // if (fieldIndex < 0) // continue; // string jcbh = pFeature.Value[fieldIndex].ToString(); // if (!string.IsNullOrWhiteSpace(jcbh)) // { // //根据属性字段关联照片 // result = ProofMgr.GetProofInfoList(jcbh);//("528") // //ucImgXZZP.InitData(ProofInfo, false); // //EnvironmentVariables.Instance.cameraPoint.AddCameraPoint(ProofInfo); // } // } // } // else if (wylayer.RelevantModel == "图形") // { // ////根据图形范围关联照片 // if (!string.IsNullOrWhiteSpace(wylayer.AreaScale)) // { // result = ProofMgr.GetProofInfoList(pFeature.ShapeCopy, wylayer.AreaScale); // //ucImgXZZP.InitData(ProofInfo, false); // //EnvironmentVariables.Instance.cameraPoint.AddCameraPoint(ProofInfo); // } // } // } // } // else // { // //ucImgXZZP.InitData(null, false); // } // } //} //return result; List result = new List(); int fieldIndex = pFeature.Fields.FindField("TBBH"); if (fieldIndex > 0) { result = ProofMgr.GetProofInfoList(pFeature.Value[fieldIndex].ToString()); } return result; } private void MapService_ProjectClosed(object sender, EventArgs e) { if (_Panel != null) { _Panel.ClosePanel(); _Panel = null; } } public override void OnCreate(object Hook) { try { if (m_hookHelper == null) { m_hookHelper = new HookHelperClass(); } m_hookHelper.Hook = Hook; m_pEditor = new EngineEditorClass(); } catch (Exception ex) { LogAPI.Debug("初始化 打开属性表 命令时异常,异常信息如下:"); LogAPI.Debug(ex); LogAPI.Debug("初始化 打开属性表 命令时异常信息结束"); } } public override bool Enabled => JudgeIsHaveTargetPath(); private bool JudgeIsHaveTargetPath() { try { ProjectInfo prj = MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo; if (prj == null) { return false; } return !string.IsNullOrWhiteSpace(prj.BGDatabase) && m_pEditor.EditState == esriEngineEditState.esriEngineStateEditing; } catch (Exception ex) { LogAPI.Debug("判定 检测数据加载 按钮是否有效时失败,异常原因: " + ex + " ; "); return false; } } } }