-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOpenAttributeTableCmd.cs
133 lines (119 loc) · 4.6 KB
/
OpenAttributeTableCmd.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
using System;
using System.Drawing;
using System.Runtime.InteropServices;
using ESRI.ArcGIS.ADF.BaseClasses;
using ESRI.ArcGIS.ADF.CATIDs;
using ESRI.ArcGIS.Controls;
using ESRI.ArcGIS.Carto;
using System.Windows.Forms;
namespace SpatialDataManagement
{
/// <summary>
/// Command that works in ArcMap/Map/PageLayout
/// </summary>
[Guid("1cfb388e-e77e-4c6a-a489-d79cfc0992ec")]
[ClassInterface(ClassInterfaceType.None)]
[ProgId("SpatialDataManagement.OpenAttributeTableCmd")]
public sealed class OpenAttributeTableCmd : BaseCommand
{
#region COM Registration Function(s)
[ComRegisterFunction()]
[ComVisible(false)]
static void RegisterFunction(Type registerType)
{
// Required for ArcGIS Component Category Registrar support
ArcGISCategoryRegistration(registerType);
//
// TODO: Add any COM registration code here
//
}
[ComUnregisterFunction()]
[ComVisible(false)]
static void UnregisterFunction(Type registerType)
{
// Required for ArcGIS Component Category Registrar support
ArcGISCategoryUnregistration(registerType);
//
// TODO: Add any COM unregistration code here
//
}
#region ArcGIS Component Category Registrar generated code
/// <summary>
/// Required method for ArcGIS Component Category registration -
/// Do not modify the contents of this method with the code editor.
/// </summary>
private static void ArcGISCategoryRegistration(Type registerType)
{
string regKey = string.Format("HKEY_CLASSES_ROOT\\CLSID\\{{{0}}}", registerType.GUID);
MxCommands.Register(regKey);
ControlsCommands.Register(regKey);
}
/// <summary>
/// Required method for ArcGIS Component Category unregistration -
/// Do not modify the contents of this method with the code editor.
/// </summary>
private static void ArcGISCategoryUnregistration(Type registerType)
{
string regKey = string.Format("HKEY_CLASSES_ROOT\\CLSID\\{{{0}}}", registerType.GUID);
MxCommands.Unregister(regKey);
ControlsCommands.Unregister(regKey);
}
#endregion
#endregion
private IHookHelper m_hookHelper = null;
IMapControl3 m_mapcontrol = null;
IFeatureLayer currentLayer = null;
public OpenAttributeTableCmd()
{
//
// TODO: Define values for the public properties
//
base.m_category = "通用工具";
base.m_caption = "打开图层属性表";
base.m_message = "打开图层属性表";
base.m_toolTip = "打开图层属性表";
base.m_name = "OpenAttributeTableCmd";
try
{
string bitmapResourceName = GetType().Name + ".bmp";
base.m_bitmap = new Bitmap(GetType(), bitmapResourceName);
}
catch (Exception ex)
{
MessageBox.Show("无效位图!!" + ex.Message, "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
#region Overridden Class Methods
/// <summary>
/// Occurs when this command is created
/// </summary>
/// <param name="hook">Instance of the application</param>
public override void OnCreate(object hook)
{
if (hook == null)
return;
m_hookHelper = new HookHelperClass();
m_hookHelper.Hook = hook;
}
/// <summary>
/// Occurs when this command is clicked
/// </summary>
public override void OnClick()
{
IMap map = null;
if (m_hookHelper.Hook is IMapControl3)
{
m_mapcontrol = m_hookHelper.Hook as IMapControl3;
currentLayer = m_mapcontrol.CustomProperty as IFeatureLayer;
if (currentLayer == null) return;
map = m_mapcontrol.Map;
}
if (map == null) return;
SpatialDataManagement.AttributesContextMenu layerAttributeTable = new SpatialDataManagement.AttributesContextMenu(map, currentLayer);
layerAttributeTable.Show(m_hookHelper as System.Windows.Forms.IWin32Window);
//LayerAttributes layerAttributeTable = new LayerAttributes(map, currentLayer);
//layerAttributeTable.Show(m_hookHelper as System.Windows.Forms.IWin32Window);
}
#endregion
}
}