年度变更建库软件5.0版本
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.
 
 

96 lines
3.7 KiB

using ESRI.ArcGIS.Carto;
using ESRI.ArcGIS.Controls;
using KGIS.Framework.AE.ExtensionMethod;
using KGIS.Framework.Maps;
using KGIS.Framework.Utils;
using Kingo.Plugin.MapView.Views;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
namespace Kingo.Plugin.MapView.Commands
{
//[PathAttribute("Kingo.Plugin.MapView.Commands.CmdOpenAttrTable")]
public class CmdOpenAttrTable : BaseMapMenuCommand
{
IFeatureLayer featureLayer = null;
List<ViewAttrTable> listPanel = new List<ViewAttrTable>();
ViewAttrTable uCAttribute_Form = null;
public override void OnClick()
{
try
{
object pLayer = m_hookHelper.GetCustomProperty();//获取对象的创建者的Application对象
IFeatureLayer pTocFeatureLayer = pLayer as IFeatureLayer;
if (pTocFeatureLayer == null) return;
featureLayer = pTocFeatureLayer;
string PanelName = "属性表_" + pTocFeatureLayer.Name;
uCAttribute_Form = listPanel.FirstOrDefault(f => f.Title == PanelName);
if (uCAttribute_Form == null || uCAttribute_Form.Title != PanelName)
{
uCAttribute_Form = new ViewAttrTable(m_hookHelper, null);//初始化当前的用户控件
uCAttribute_Form.CloseViewHandler += UCAttribute_Form_CloseViewHandler;
uCAttribute_Form.Title = PanelName;
listPanel.Add(uCAttribute_Form);
}
uCAttribute_Form.ShowPanel();
// 初始化的时候加载预定义查询条件
IFeatureLayerDefinition pFLDefinition = pTocFeatureLayer as IFeatureLayerDefinition;
string queryWhere = string.Empty;
if (pFLDefinition != null && !string.IsNullOrWhiteSpace(pFLDefinition.DefinitionExpression))
{
queryWhere += string.Format(" {0}", pFLDefinition.DefinitionExpression);
}
uCAttribute_Form.LoadData(featureLayer, queryWhere);
}
catch (Exception ex)
{
LogAPI.Debug("初始化 打开属性表 命令时异常,异常信息如下:");
LogAPI.Debug(ex);
LogAPI.Debug("初始化 打开属性表 命令时异常信息结束");
}
}
private void UCAttribute_Form_CloseViewHandler(object sender, EventArgs e)
{
try
{
ViewAttrTable view = sender as ViewAttrTable;
if (listPanel.FirstOrDefault(f => f.ID == view.ID) != null)
{
listPanel.Remove(view);
}
}
catch (Exception ex)
{
LogAPI.Debug("关闭属性列表异常,异常信息如下:");
LogAPI.Debug(ex);
LogAPI.Debug("关闭属性列表异常信息结束");
}
}
/// <summary>
/// 对象识别符.Hook
/// </summary>
/// <param name="Hook"></param>
public override void OnCreate(object Hook)
{
try
{
if (m_hookHelper == null)
{
m_hookHelper = new HookHelperClass();
}
m_hookHelper.Hook = Hook;
}
catch (Exception ex)
{
LogAPI.Debug("初始化 打开属性表 命令时异常,异常信息如下:");
LogAPI.Debug(ex);
LogAPI.Debug("初始化 打开属性表 命令时异常信息结束");
}
}
}
}