ArcObjects 類庫(一)
---------------------------------------------------------------------------------------------------------
●·● 目錄:
O0 ………… 在線幫助 & 本地幫助
OMD(對象模型圖)
A1 ………… IWorkspaceFactory 接口
A2 ………… IWorkspace 接口
IFeatureWorkspace 接口
IWorkspaceEdit 接口
A3 ………… IFeatureClass 接口
A4 ………… IFeatureCursor 接口
A5 ………… IFeature 接口
A6 ………… IField 接口
IFieldEdit 接口
A7 ………… IFields 接口
IFieldsEdit 接口
A8 ………… IQueryFilter 接口
A9 ………… IGeoDataset 接口
Aa ………… IDataset 接口
G1 ………… ILayer 接口
G2 ………… IFeatureLayer 接口
IFeatureSelection 接口
ISelectionSet 接口
IEnumIDs 接口
G3 ………… IMap 接口
G4 ………… IMapDocument 接口
G5 ………… IGraphicsContainer 接口
G6 ………… IActiveView 接口
G7 ………… IFillShapeElement 接口
G8 ………… IElement 接口
G9 ………… IFrameProperties 接口
Ga ………… IMapFrame 接口
Gb ………… IMapGrid 接口
Gc ………… IMapGrids 接口
Gd ………… ISelectionEnvironment 接口
Ge ………… IPage 接口
Gf ………… ISnapGrid 接口
Gg ………… ISnapGuides 接口
Gh ………… IRulerSettings 接口
Gi ………… IGraphicsContainer 接口
Gj ………… IActiveView 接口
Gk ………… IFillShapeElement 接口
Gl ………… IElement 接口
Gm………… IElement 接口
Gn ………… IElement 接口
U1 ………… LicenseControl 控件
U2 ………… MapControl 控件
U3 ………… IMapControl2 接口
U4 ………… IMapControl3 接口
U5 ………… IMapControlEvents2 接口
U6 ………… PageLayoutControl 控件
U7 ………… IPageLayoutControl 接口
U8 ………… IPageLayoutControlEvents 控件
U9 ………… ToolbarControl 控件
Ua ………… IToolbarControl2 接口
Ub ………… TOCControl 控件
Uc ………… ITOCControl 接口
ILegendGroup 接口
ILegendClass 接口
Ud ………… ITOCControlEvents 接口
Ue ………… IHookHelper 接口
Uf ………… SymbologyControl 控件
Ug ………… ISymbologyControl 接口
ISymbologyStyleClass 接口
Uh ………… ISymbologyControlEvents 接口
Ui ………… TOCControl 控件
Uj ………… ITOCControl 接口
Uk ………… ITOCControlEvents 接口
Ul ………… GlobeControl 接口
Um………… GlobeControl 接口
---------------------------------------------------------------------------------------------------------
╔════════╗
╠════╣ 第O0個 ╠══════════════════════════════════════════════════╣
╚════════╝
●·● 在線幫助 & 本地幫助:
1. 通過在線幫助和本地幫助可以得到相同的內容,但是本地幫助速度更快,但是在線幫組效果更好,下面的圖示展示了如何將二者聯系起來,因為二者的排版還是存在一定的差別的!
---------------------------------------------------------------------------------------------------------
●·● OMD(對象模型圖):
1> AbstractClass:抽象類算一個超類,不能用來實例化一個對象,比如Line就是一個抽象類,其他的線是Line之上,Line給出了所有線的共同特性和方法。
符號:平面矩形,白色。
2> CoClass:這種類可以直接通過new方法實例化出一個對象。
符號:長方體,灰色。
3> Class:這種類不能直接new出一個對象,但是可以通過實例的屬性得到或者通過某個方法生成一個對象。
符號:長方體,白色。
4> Association(關聯):表示一個類的實例可以和幾個其他類的實例相關聯,比如一個Line Symbol對象只能和一個線對象相關。
符號:灰色的線。
5> Type Inheritance(繼承):是一個類可以通過繼承,得到其父類的屬性和方法,比如Line這個超類之上可以有其他類型的特定線類。
符號:空心三角箭頭。
6> Instantiation(實例化):是某個類的某個方法可以實例化其他類的實例,比如:IWorkspaceFactory類的OpenFromFile()方法可以實例化一個IFeatureWorkspace類的實例。
符號:虛線箭頭。
7> Composition(組成):是一個強制的關系,是一個類的實例包含了其他的類的實例,比如一個points會包含很多個point,當這么多的point的生命周期沒有結束,points對象就不能從內存中卸載掉。
符號:黑色菱形。
8> Inbounde Interface(入接口):封裝了若干屬性和方法。
符號:空心圓。
9> Outbound Interface(出接口):封裝的事件,即對象支持哪些事件的觸發。
符號:實心圓。
※ 參考:CoClass 和 Class 的區別1
※ 參考:CoClass 和 Class 的區別2
※ 參考:ArcObjects學習的重要工具 Object Model Diagrams
※ 參考:關於接口的理解

interface Iperson //接口
{
void xuexi();
}
interface Idustman : Iperson
{
void saodi();
}
interface Iprogramer : Idustman
{
void biancheng();
}
interface Imanager : Iprogramer
{
void guanji();
}
class Test : Imanager
{
public void xuexi()
{
}
public void saodi()
{
}
public void biancheng()
{
}
public void guanji()
{
}
}
class person //類
{
public void xuexi1()
{
}
}
class dustman : person
{
public void soadi1()
{
}
}
class programer : dustman
{
public void biancheng1()
{
}
}
class manager : programer
{
public void guanji1()
{
}
}
class Test2 : manager
{
}
private void Form1_Load(object sender, EventArgs e)
{
Iperson Person = new Test();
Person.xuexi();
Idustman Dustman = Person as Idustman;
Dustman.saodi();
Dustman.xuexi();
Iprogramer Programer = Dustman as Iprogramer;
Programer.biancheng();
Programer.xuexi();
Programer.saodi();
Imanager Manager = Programer as Imanager;
Manager.guanji();
Manager.biancheng();
Manager.xuexi();
Manager.saodi();
person p = new person();
p.xuexi1();
dustman d = p as dustman;
d.soadi1();
d.xuexi1();
programer pro = d as programer;
pro.soadi1();
pro.xuexi1();
pro.biancheng1();
manager m = pro as manager;
m.soadi1();
m.xuexi1();
m.biancheng1();
m.guanji1();
}
接口只需提供方法,但是不用提供解決的途徑,解決的途徑在相應的類中定義,一個類可以同時集成多個接口,這些接口可以沒有任何關系,但是類只能繼承一個類,這里就體現出接口的優勢,不同的接口可以將類的方法有機的分離開,更好的實現管理!(@McDelfino拙見)
參考:
其中,Nest和Chicken 是聚合關系(Aggregation),既它們之間不共存。
Wings和Chicken是組合關系(Composition),它們共存,翅膀是雞的一部分,雞不在了翅膀也就沒了。
Bird和Chicken是繼承關系(Type Inheritance),雞是鳥的一種。
Egg和Chicken是實例化關系(Instantiation),雞蛋可以用雞的方法來實例化,雞下蛋實例化雞蛋。
Bird是AbstractClass,不能實例化。
Chicken和Nest是CoClass,可以通過New關鍵字來實例化。
Egg和Wings是Class,可以通過其他實例的方法來實例化。
---------------------------------------------------------------------------------------------------------
●·● Geodatabase 命名空間
1. 該類庫提供了統一的接口來訪問空間數據,使用頻率非常高的接口 IFeatureClass、ITable、IQueryFilter 等接口都是位於該類庫中。用戶在打開要素類、打開表、查詢數據、讀取數據、更新數據時都需要引用此類庫。下圖描述了表格、要素類、字段等對象之間的關系。
---------------------------------------------------------------------------------------------------------
╔════════╗
╠════╣ 第A1個 ╠══════════════════════════════════════════════════╣
╚════════╝
●·● IWorkspaceFactory 接口:
1. Use IWorkspaceFactory when you need to create a new workspace, connect to an existing workspace or find information about a workspace.
2. 屬性和方法:
屬性和方法 | Description | |
---|---|---|
![]() |
ContainsWorkspace | Indicates if parentDirectory contains a valid workspace, or is a valid file-system workspace. |
![]() |
Copy | Copies a workspace to the specified destination folder. |
![]() |
Create | Creates a new workspace specified by the directory, file name, and connection properties. |
![]() |
GetClassID | The class ID of the WorkspaceFactory. |
![]() |
GetWorkspaceName | Retrieves the workspace name of a workspace from the given list of file names. |
![]() |
IsWorkspace | True if the specified file identifies a workspace supported by the workspace factory. |
![]() |
Move | Moves a workspace to the specified destination folder. |
![]() |
Open | Opens the workspace specified by the connection properties. |
![]() |
OpenFromFile (string fileName, int hWnd) 返回值:IWorkspace |
Opens the workspace specified by the given file name. 參考:http://www.gisvip.com/blog/?action-viewthread-tid-2400 |
![]() |
ReadConnectionPropertiesFromFile | The connection properties from the specified file. |
![]() |
WorkspaceDescription | A singular or plural description of the type of workspace the workspace factory opens/creates. |
![]() |
WorkspaceType | The type of workspace the workspace factory opens/creates. |
參考:http://www.3sfield.com/content.php?id=327
---------------------------------------------------------------------------------------------------------
╔════════╗
╠════╣ 第A2個 ╠══════════════════════════════════════════════════╣
╚════════╝
●·● IWorkspace 接口:
1. Provides access to members that have information about the workspace.
工作空間!
2. 屬性和方法:
方法和屬性 | Description | |
---|---|---|
![]() |
ConnectionProperties | The connection properties of the workspace. |
![]() |
DatasetNames | The DatasetNames in the workspace. |
![]() |
Datasets | The datasets in the workspace. |
![]() |
ExecuteSQL | Executes the specified SQL statement. |
![]() |
Exists | Checks if the workspace exists. |
![]() |
IsDirectory | TRUE if the workspace is a file system directory. |
![]() |
PathName | The file system full path of the workspace. |
![]() |
Type | The Type of the Workspace. |
![]() |
WorkspaceFactory | The factory that created the workspace. |
---------------------------------------------------------------------------------------------------------
●·● IFeatureWorkspace 接口:
1. Provides access to members that create and open various types of datasets and other workspace level objects.
Members
Description | ||
---|---|---|
![]() |
CreateFeatureClass (string Name, IFields Fields, UID CLSID, UID EXTCLSID, esriFeatureType FeatureType, string ShapeFieldName, string ConfigKeyword) 返回值:IFeatureClass |
Creates a new standalone feature class under the workspace. 第一個參數:shp文件名 第二個參數:添加的 Fields 第三個參數:null 第四個參數:null 第五個參數:要素類型 第六個參數:圖形列的名稱 第七個參數:"" |
![]() |
CreateFeatureDataset | Creates a new feature dataset. |
![]() |
CreateQueryDef | Create a query definition object. |
![]() |
CreateRelationshipClass | Creates a new relationship class. |
![]() |
CreateTable | Creates a new table. |
![]() |
OpenFeatureClass (string Name) 返回值:IFeatureClass |
Opens an existing feature class. 返回指定文件名的 FeatureClass。 |
![]() |
OpenFeatureDataset | Opens an existing feature dataset. |
![]() |
OpenFeatureQuery | Opens a feature dataset containing a single feature class defined by the specified Query. |
![]() |
OpenRelationshipClass | Opens an existing relationship class. |
![]() |
OpenRelationshipQuery | The table of a relationship join query. |
![]() |
OpenTable | Opens an existing table. |
---------------------------------------------------------------------------------------------------------
●·● IWorkspaceEdit 接口:
1. Provides access to members that control Workspace Editing. Note: the IWorkspaceEdit interface has been superseded byIWorkspaceEdit2. Please consider using the more recent version.
Members
Description | ||
---|---|---|
![]() |
AbortEditOperation | Aborts an edit operation. |
![]() |
DisableUndoRedo | Disables Undo and Redo of edit operations. |
![]() |
EnableUndoRedo | Enables Undo and Redo of edit operations. |
![]() |
HasEdits | True if there are any completed edit operations that need to be saved . |
![]() |
HasRedos | True if there are any completed undos that can be redone. |
![]() |
HasUndos | True if there are any completed edit operations that can be undone. |
![]() |
IsBeingEdited | True if the workspace is being edited. |
![]() |
RedoEditOperation | Causes a Redo to be performed on the last undo. |
![]() |
StartEditing | Starts editing the workspace. |
![]() |
StartEditOperation | Begins an edit operation. |
![]() |
StopEditing | Stops editing the workspace. |
![]() |
StopEditOperation | Ends an edit operation. |
![]() |
UndoEditOperation | Causes an Undo to be performed on the last edit operation. |
---------------------------------------------------------------------------------------------------------
╔════════╗
╠════╣ 第A3個 ╠══════════════════════════════════════════════════╣
╚════════╝
●·● IFeatureClass 接口:
1. The IFeatureClass interface is the main interface for getting and setting properties of a feature class. For example, use the IFeatureClass interface to get the type of feature class, get a count of features that satisfy some query, or create a new feature in the feature class. The IFeatureClass interface inherits from the IObjectClass interface.
獲取或設置要素的屬性,要素類!
2. 屬性和方法:
方法和屬性 | Description | |
---|---|---|
![]() |
AddField | Adds a field to this object class. |
![]() |
AddIndex | Adds an index to this object class. |
![]() |
AliasName | The alias name of the object class. |
![]() |
AreaField | The geometry area field. |
![]() |
CLSID | The GUID for the COM Class (CoClass) corresponding to instances of this object class. |
![]() |
CreateFeature 返回值:IFeature |
Create a new feature, with a system assigned object ID and null property values. |
![]() |
CreateFeatureBuffer | Create a feature buffer that can be used with an insert cursor. |
![]() |
DeleteField | Deletes a field from this object class. |
![]() |
DeleteIndex | Deletes an index from this object class. |
![]() |
EXTCLSID | The GUID for the COM Class (CoClass) corresponding to the class extension for this object class. |
![]() |
Extension | The extension for this object class. |
![]() |
ExtensionProperties | The extension properties for this object class. |
![]() |
FeatureClassID | The unique ID for the Feature Class. |
![]() |
FeatureCount (IQueryFilter QueryFilter) |
The number of features selected by the specified query. 若是null,則選擇全部~ |
![]() |
FeatureDataset | The feature dataset that contains the feature class. |
![]() |
FeatureType | The type of features in this feature class. |
![]() |
Fields | The fields collection for this object class. |
![]() |
FindField | The index of the field with the specified name. |
![]() |
GetFeature (int ID) |
Get the feature with the specified object ID. 通過獲取 FID 列的值來獲取 IFeature!!! |
![]() |
GetFeatures | Get a cursor of Rows given a set of object ids. |
![]() |
HasOID | Indicates if the class has an object identity (OID) field. |
![]() |
Indexes | The indexes collection for this object class. |
![]() |
Insert | Returns a cursor that can be used to insert new features. |
![]() |
LengthField | The geometry length field. |
![]() |
ObjectClassID | The unique ID for the object class. |
![]() |
OIDFieldName | The name of the field corresponding to the OID. |
![]() |
RelationshipClasses | The relationship classes in which this object class participates in for the specified role. |
![]() |
Search (IQueryFilter filter, bool Recycling) |
Returns an object cursor that can be used to fetch feature objects selected by the specified query. |
![]() |
Select | Returns a selection That contains the object ids selected by the specified query. |
![]() |
ShapeFieldName | The name of the default sShape field. |
![]() |
ShapeType | The type of the default Shape for the features in this feature class. |
![]() |
Update | Returns a cursor that can be used to update features selected by the specified query. |
※ 參考:http://www.3sfield.com/content.php?id=317
提取要素屬性:
ILayer pLayer = axMapControl1.get_Layer(0); //獲取圖層
IFeatureLayer pFLayer = pLayer as IFeatureLayer; //獲取矢量圖層
IFeatureClass pFC = pFLayer.FeatureClass; //獲取屬性列表
IFeatureCursor pFCursor = pFC.Search(null, false); //訪問要素
IFeature pFeature = pFCursor.NextFeature(); //獲取單個要素
DataTable pTable = new DataTable();
DataColumn colName = new DataColumn("國家名");
colName.DataType = System.Type.GetType("System.String");
pTable.Columns.Add(colName);
DataColumn colArea = new DataColumn("洲名");
colArea.DataType = System.Type.GetType("System.String");
pTable.Columns.Add(colArea);
int indexOfName = pFC.FindField("NAME");
int indexOfName2 = pFC.FindField("REGION");
while (pFeature != null)
{
string name = pFeature.get_Value(indexOfName);
string area = pFeature.get_Value(indexOfName2);
DataRow pRow = pTable.NewRow();
pRow[0] = name;
pRow[1] = area;
pTable.Rows.Add(pRow);
pFeature = pFCursor.NextFeature();
}
dataGridView1.DataSource = pTable;
---------------------------------------------------------------------------------------------------------
╔════════╗
╠════╣ 第A4個 ╠══════════════════════════════════════════════════╣
╚════════╝
●·● IFeatureCursor 接口:
1. Provides access to members that hand out enumerated features, field collections and allows for the updating, deleting and inserting of features.
用來訪問要素類中的一系列要素。
2. 屬性和方法:
方法和屬性 | Description | |
---|---|---|
![]() |
DeleteFeature | Delete the existing Feature in the database corresponding to the current position of the cursor. |
![]() |
Fields | The fields Collection for this cursor. |
![]() |
FindField | The index of the field with the specified name. |
![]() |
Flush | Flush any outstanding buffered writes to the database. |
![]() |
InsertFeature | Insert a new Feature into the database using the property values in the input buffer. The ID of the new Feature is returned. |
![]() |
NextFeature | Advance the position of the cursor by one and return the Feature object at that position. |
![]() |
UpdateFeature | Update the existing Feature in the database corresponding to the current position of the cursor. |
※ 參考:http://blog.163.com/shuai686868@126/blog/static/203034612010102613814320/
※ 參考:http://www.3sfield.com/content.php?id=319
---------------------------------------------------------------------------------------------------------
╔════════╗
╠════╣ 第A5個 ╠══════════════════════════════════════════════════╣
╚════════╝
●·● IFeature 接口:
1. Provides access to members that return and set properties of a feature.
相當於每一個單獨的要素,點、線或面!
2. 屬性和方法:
方法和屬性 | Description | |
---|---|---|
![]() |
Class | The Object Class for the row. |
![]() |
Delete | Deletes the row. |
![]() |
Extent | The extent of the feature. |
![]() |
FeatureType | The type of the feature. |
![]() |
Fields | The fields Collection for this row buffer. |
![]() |
HasOID | Indicates if the row has an OID. |
![]() |
OID | The OID for the row. |
![]() |
Shape 返回值:IGeometry |
A reference to the default shape for the feature. |
![]() |
ShapeCopy 返回值:IGeometry |
A cloned copy of the default shape for the feature. 與上面的Shape,在我看來沒有什么大的區別,可以獲得要素的幾何形體,以至於其envelope! |
![]() |
Store | Stores the row. |
![]() |
Table | The Table for the row. |
![]() |
Value object get_Value(int Index); void set_Value(int Index, object Value); |
The value of the field with the specified index. 第一個參數:索引 第二個參數:值 獲取要素某個字段的值、為要素的某個字段賦值! 通過“IFields.FindField("字段名稱")”可以獲取索引! |
※ 參考:http://www.3sfield.com/content.php?id=315
IFeature pFeature = pFeatureClass.CreateFeature(); pFeature.Shape = pPointColl as IPolygon; pFeature.Store(); pFeature.set_Value(pFeature.Fields.FindField(pColumns[2]), pBuildingList[i].Trim()); pFeature.Store();
---------------------------------------------------------------------------------------------------------
╔════════╗
╠════╣ 第A6個 ╠══════════════════════════════════════════════════╣
╚════════╝
●·● IField 接口:
1. Provides access to members that return information about the field. Note: the IField interface has been superseded byIField2. Please consider using the more recent version.
The field object represents a column in a table. A field has many properties, the most obvious ones being its name and its datatype. The esriFieldType enumeration lists the possible datatypes.
CoClasses that implement IField
CoClasses and Classes | Description |
---|---|
Field | ESRI Field object. |
2. 屬性和方法:
Description | ||
---|---|---|
![]() |
AliasName | The alias name of the field. |
![]() |
CheckValue | Indicates if the value is valid given the field definition. |
![]() |
DefaultValue | The default value of the field. |
![]() |
Domain | The default domain of the field. |
![]() |
DomainFixed | Indicates if the field's domain is fixed. |
![]() |
Editable | Indicates if the field is editable. |
![]() |
GeometryDef | The geometry definition for the field if IsGeometry is TRUE. |
![]() |
IsNullable | Indicates if the field can contain null values. |
![]() |
Length | The maximum length, in bytes, for values described by the field. |
![]() |
Name | The name of the field. |
![]() |
Precision | The precision for field values. |
![]() |
Required | Indicates if the field is required. |
![]() |
Scale | The scale for field values. |
![]() |
Type 返回值:esriFieldType |
The type of the field. esriFieldType 枚舉:int、long、Geometry、OID等 |
![]() |
VarType | The VARTYPE of the field (e.g. VT_I4). |
---------------------------------------------------------------------------------------------------------
●·● IFieldEdit 接口:
1. Provides access to members that edit the field properties including raster column definition.
Members
Description | ||
---|---|---|
![]() |
AliasName | The alias name of the field. |
![]() |
AliasName | The alias name of the field. |
![]() |
CheckValue | Indicates if the value is valid given the field definition. |
![]() |
DefaultValue | The default value of the field. |
![]() |
DefaultValue | The default value of the field. |
![]() |
Domain | The default domain of the field. |
![]() |
Domain | The default domain of the field. |
![]() |
DomainFixed | Indicates if the field's domain cannot be modified. |
![]() |
DomainFixed | Indicates if the field's domain is fixed. |
![]() |
Editable | Indicates if the field can be edited. This should always be set to true. |
![]() |
Editable | Indicates if the field is editable. |
![]() |
GeometryDef | The geometry definition for the field if IsGeometry is TRUE. |
![]() |
GeometryDef | The geometry definition if IsGeometry is TRUE. |
![]() |
IsNullable | Indicates if field values can be null. |
![]() |
IsNullable | Indicates if the field can contain null values. |
![]() |
Length | The maximum length, in bytes, for field values. |
![]() |
Length | The maximum length, in bytes, for values described by the field. |
![]() |
Name | The name of the field. |
![]() |
Name | The name of the field. |
![]() |
Precision | The precision for field values. |
![]() |
Precision | The precision for field values. |
![]() |
RasterDef | The raster column definition. |
![]() |
Required | Indicates if the field is required. |
![]() |
Required | Indicates if the field is required. |
![]() |
Scale | The scale for field values. |
![]() |
Scale | The scale for field values. |
![]() |
Type | The type for the field. |
![]() |
Type | The type of the field. |
![]() |
VarType | The VARTYPE of the field (e.g. VT_I4). |
---------------------------------------------------------------------------------------------------------
╔════════╗
╠════╣ 第A7個 ╠══════════════════════════════════════════════════╣
╚════════╝
●·● IFields 接口:
1. Provides access to members that return information about the fields. Note: the IFields interface has been superseded byIFields2. Please consider using the more recent version.
The Fields object represents a collection of columns in a table. The term field is synonymous with column. Each table in a database has an ordered collection of fields, there is always at least one field in a table. The ordered collection behaves like a list, so it is possible to access individual fields by a numbered position (or index) in the list.
CoClasses that implement IField
CoClasses and Classes | Description |
---|---|
Fields | ESRI Fields object. |
2. 屬性和方法:
Description | ||
---|---|---|
![]() |
Field | The field at the specified index in the fields collection. |
![]() |
FieldCount | The number of fields in the fields collection. |
![]() |
FindField | Finds the index of the named field in the fields collection. |
![]() |
FindFieldByAliasName | Finds the index of the field with the alias name in the fields collection. |
① 將矢量數據的所有字段名稱加到 comboBox1 中!
private void loadData()
{
ILayer pLayer = axMapControl1.get_Layer(0); //獲取圖層
IFeatureLayer pFLayer = pLayer as IFeatureLayer; //轉換為矢量圖層
IFeatureClass pFClass = pFLayer.FeatureClass; //獲取圖層表格數據
IFields pFields = pFClass.Fields; //獲取字段集合
for (int i = 2; i < pFields.FieldCount;i++ ) //遍歷字段
{
comboBox1.Items.Add(pFields.Field[i].Name); //獲取每個字段的名稱
}
comboBox1.Text = comboBox1.Items[2].ToString(); //設置默認顯示
}
② 將矢量數據某個字段的全部 feature 值加入到 comboBox2 中!
private void loadFieldData()
{
comboBox2.Items.Clear(); //刪除所有值
ILayer pLayer = axMapControl1.get_Layer(0); //獲取圖層
IFeatureLayer pFLayer = pLayer as IFeatureLayer; //轉換為矢量圖層
IFeatureClass pFClass = pFLayer.FeatureClass; //獲取圖層表格值
IFields pFields = pFClass.Fields; //獲取所有字段
int Index = pFClass.FindField(comboBox1.Text); //找到列所在的 Index!
IFeatureCursor pFCursor = pFClass.Search(null, false); //用於循環null就是遍歷全部
IFeature pFeature = pFCursor.NextFeature(); //用於獲取每一個feature
while (pFeature != null)
{
string name = pFeature.get_Value(Index); //獲取 Index 列的值!
comboBox2.Items.Add(name); //添加
pFeature = pFCursor.NextFeature(); //下一個要素
}
comboBox2.Text = comboBox2.Items[0].ToString(); //初始化
}
③ 在地圖上選擇特定的 feature!
private void comboBox2_SelectedIndexChanged(object sender, EventArgs e)
{
axMapControl1.Map.ClearSelection(); //清除地圖上的選擇
axMapControl1.Refresh(esriViewDrawPhase.esriViewGeography, null, null); //刷新地圖
ILayer pLayer = axMapControl1.get_Layer(0); //獲取圖層
IFeatureLayer pFLayer = pLayer as IFeatureLayer; //獲取矢量圖層
IFeatureClass pFC = pFLayer.FeatureClass; //獲取屬性
IQueryFilter pQFilter = new QueryFilter(); //新建查詢
pQFilter.WhereClause = comboBox1.Text + "='" + comboBox2.Text + "'"; //查詢內容
IFeatureCursor pFCursor = pFC.Search(pQFilter, false); //新建鼠標指針遍歷
IFeature pFeature = null; //新建一個要素
pFeature = pFCursor.NextFeature(); //下一個要素
if (pFeature != null) //遍歷
{
axMapControl1.Map.SelectFeature(axMapControl1.get_Layer(0), pFeature); //選擇要素
axMapControl1.Refresh(esriViewDrawPhase.esriViewGraphicSelection, null, null); //刷新
}
}
---------------------------------------------------------------------------------------------------------
●·● IFieldsEdit 接口:
1. Provides access to members that modify a fields collection.
Members
Description | ||
---|---|---|
![]() |
AddField | Add a field to the fields collection. |
![]() |
DeleteAllFields | Delete all the fields from the fields collection. |
![]() |
DeleteField | Delete a field from the fields collection. |
![]() |
Field | The field at the specified index in the fields collection. |
![]() |
Field | The field at the specified position. |
![]() |
FieldCount | The number of fields in the fields collection. |
![]() |
FieldCount | The Number of fields in this field collection. |
![]() |
FindField | Finds the index of the named field in the fields collection. |
![]() |
FindFieldByAliasName | Finds the index of the field with the alias name in the fields collection. |
---------------------------------------------------------------------------------------------------------
╔════════╗
╠════╣ 第A8個 ╠══════════════════════════════════════════════════╣
╚════════╝
●·● IQueryFilter 接口:
1. Provides access to members that filter data based on attribute values and or relationships.
IQueryFilter filters data based on an attribute query. A string defining a where clause is required. An optional list of columns may be included to specify the column values to be retrieved. If no columns are specified, all values will be returned.
CoClasses that implement IQueryFilter
CoClasses and Classes | Description |
---|---|
ImageQueryFilter (esriCarto) | An image query filter. |
QueryFilter | ESRI Query Filter object. |
SpatialFilter | ESRI Spatial Filter object. |
TemporalQueryFilter (esriTrackingAnalyst) | Controls properties for the temporal query filter. |
TimeQueryFilter (esriCarto) | TimeQueryFilter Class |
2. 屬性和方法:
Description | ||
---|---|---|
![]() |
AddField | Appends a single field name to the list of sub-fields. |
![]() |
OutputSpatialReference | The spatial reference in which to output geometry for a given field. |
![]() |
SubFields | The comma delimited list of field names for the filter. |
![]() |
WhereClause | The where clause for the filter 定義查詢的語句。 |
---------------------------------------------------------------------------------------------------------
╔════════╗
╠════╣ 第A9個 ╠══════════════════════════════════════════════════╣
╚════════╝
●·● IGeoDataset 接口:
Members
Description | ||
---|---|---|
![]() |
Extent | The extent of the GeoDataset. 相當於 FullExtent 的作用! |
![]() |
SpatialReference | The spatial reference of the GeoDataset. |
IFeatureLayer:對圖層縮放顯示!
---------------------------------------------------------------------------------------------------------
╔════════╗
╠════╣ 第Aa個 ╠══════════════════════════════════════════════════╣
╚════════╝
●·● IDataset 接口:
1. Provides access to members that supply dataset information.
Members
Description | ||
---|---|---|
![]() |
BrowseName | The browse name of the dataset. |
![]() |
CanCopy | True if this dataset can be copied. |
![]() |
CanDelete | True if this dataset can be deleted. |
![]() |
CanRename | True if this dataset can be renamed. |
![]() |
Category | The category of the dataset. |
![]() |
Copy | Copies this dataset to a new dataset with the specified name. |
![]() |
Delete | Deletes this dataset. |
![]() |
FullName | The associated name object. |
![]() |
Name | The name of the Dataset. |
![]() |
PropertySet | The set of properties for the dataset. |
![]() |
Rename | Renames this Dataset. |
![]() |
Subsets | Datasets contained within this dataset. |
![]() |
Type | The type of the Dataset. |
![]() |
Workspace | The workspace containing this dataset. |
---------------------------------------------------------------------------------------------------------
●·● Carto 命名空間
1. Carto 類庫中的對象負責創建地圖、顯示圖層。使用頻率比較高的 Imap、ILayer、IFeatureRenderer 都在 Carto 類庫中,另外還包括地圖元素 IElement 接口和子接口,例如:ILineElement、ITextElement 等。
---------------------------------------------------------------------------------------------------------
╔════════╗
╠════╣ 第G1個 ╠══════════════════════════════════════════════════╣
╚════════╝
●·● ILayer 接口:
1. ILayer is a generic 【通用的、一般的】 interface for all layer objects. This interface has a method to draw the layer and provides access to generic layer properties.
各種圖層的一個基類!
2. 屬性和方法:
方法和屬性 | Description | |
---|---|---|
![]() |
AreaOfInterest | The default area of interest for the layer. |
![]() |
Cached | Indicates if the layer needs its own display cache. |
![]() |
Draw | Draws the layer to the specified display for the given draw phase. |
![]() |
MaximumScale | Maximum scale (representative fraction) at which the layer will display. |
![]() |
MinimumScale | Minimum scale (representative fraction) at which the layer will display. |
![]() |
Name | Layer name. |
![]() |
ShowTips | Indicates if the layer shows map tips. |
![]() |
SpatialReference | Spatial reference for the layer. |
![]() |
SupportedDrawPhases | Supported draw phases. |
![]() |
TipText | Map tip text at the specified location. |
![]() |
Valid | Indicates if the layer is currently valid. |
![]() |
Visible | Indicates if the layer is currently visible. |
---------------------------------------------------------------------------------------------------------
╔════════╗
╠════╣ 第G2個 ╠══════════════════════════════════════════════════╣
╚════════╝
●·● IFeatureLayer 接口:
1. Provides access to the properties and methods of a layer based on vector geographic data, which is typically a geodatabase, shapefile, or coverage feature class.
矢量圖層,shapefile等!
FeatureLayer:CoClass。
2. 屬性和方法:
方法和屬性 | Description | |
---|---|---|
![]() |
AreaOfInterest | The default area of interest for the layer. |
![]() |
Cached | Indicates if the layer needs its own display cache. |
![]() |
DataSourceType | Data source type. |
![]() |
DisplayField | Primary display field. |
![]() |
Draw | Draws the layer to the specified display for the given draw phase. |
![]() |
FeatureClass | The layer's feature class. 獲取要素類! |
![]() |
MaximumScale | Maximum scale (representative fraction) at which the layer will display. |
![]() |
MinimumScale | Minimum scale (representative fraction) at which the layer will display. |
![]() |
Name | Layer name. 顯示在TOC上的名稱。 |
![]() |
ScaleSymbols | Indicates if symbols are scaled for the layer. |
![]() |
Search | Creates a cursor based upon the search criteria. |
![]() |
Selectable | Indicates if layer is selectable. 在框選的時候,該層的要素是否可以被選中! |
![]() |
ShowTips | Indicates if the layer shows map tips. |
![]() |
SpatialReference | Spatial reference for the layer. |
![]() |
SupportedDrawPhases | Supported draw phases. |
![]() |
TipText | Map tip text at the specified location. |
![]() |
Valid | Indicates if the layer is currently valid. |
![]() |
Visible | Indicates if the layer is currently visible. 圖層的復選框是否被選中! |
※ 參考:http://www.3sfield.com/content.php?id=321
插入矢量數據:
OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = "shapefile文件(*.shp)|*.shp";
ofd.InitialDirectory = @"F:\Desktop\Temp\ArcGIS_Data";
if (ofd.ShowDialog() != DialogResult.OK)
return;
FileInfo file = new FileInfo(ofd.FileName);
IWorkspaceFactory pWorkspaceFactory = new ShapefileWorkspaceFactory(); //工廠
IWorkspace pWorkspace = pWorkspaceFactory.OpenFromFile(file.DirectoryName, 0); //實例化工作空間
IFeatureWorkspace pFeatrueWorkspace = pWorkspace as IFeatureWorkspace; //實例化矢量工作空間
IFeatureClass pFC = pFeatrueWorkspace.OpenFeatureClass(file.Name); //實例化矢量要素類
IFeatureLayer pFLayer = new FeatureLayer(); //實例化矢量圖層
pFLayer.FeatureClass = pFC; //建立連接
pFLayer.Name = pFC.AliasName; //命名
IMap pMap = axMapControl1.Map; //實例地圖
pMap.AddLayer(pFLayer as ILayer); //增加圖層
---------------------------------------------------------------------------------------------------------
●·● IFeatureSelection 接口:
1. Provides access to members that control feature selection.
獲取選擇集!
---------------------------------------------------------------------------------------------------------
●·● ISelectionSet 接口:
1. Provides access to members that manage a set of selected table rows or features. Note: the ISelectionSet interface has been superseded byISelectionSet2. Please consider using the more recent version.
實例化選擇集!
---------------------------------------------------------------------------------------------------------
●·● IEnumIDs 接口:
1. Provides access to members that enumerate through IDs.
獲取選擇集中要素的 FID值 集合,依次可以獲取選擇的要素~
實現:縮放到所有選擇要素
IEnvelope layerEnvelope = null; //實例化一個envelope IFeatureClass pFeatCls = pLayer.FeatureClass; IFeatureSelection selectLayer = pLayer as IFeatureSelection; //QI一個要素選擇接口 ISelectionSet selectionSet = selectLayer.SelectionSet; //獲取選擇集 IEnumIDs enumIDs = selectionSet.IDs; //從選擇集中獲取FID值 IFeature feature; int i = 1; int iD = enumIDs.Next(); //讀取第一個FID值 while (iD != -1) //-1 is reutned after the last valid ID has been reached { feature = pFeatCls.GetFeature(iD); //通過FID值獲取要素 IEnvelope envelope = feature.ShapeCopy.Envelope; //獲取要素的envelope if (i == 1) layerEnvelope = envelope; //先給layerEnvelope賦個值,否則后面沒法用 else { layerEnvelope.Union(envelope); //其他情況就用union方法 } i++; iD = enumIDs.Next(); //遍歷到下一個FID值,依次循環 } pMapControl.Extent = layerEnvelope; pMapControl.ActiveView.Refresh();
---------------------------------------------------------------------------------------------------------
╔════════╗
╠════╣ 第G3個 ╠══════════════════════════════════════════════════╣
╚════════╝
●·● IMap 接口:
1. Use the IMap interface to display data from various data sources.
The IMap interface is a starting point for many of the tasks one does with a Map. For example, use IMap to add, delete, and access map layers containing data from various sources including feature layers and graphics layers; associate map surround objects (legends, scale bars, etc) with the Map; access the various properties of a Map including the area of interest, the current map units, and the spatial reference; select features and access the Map's current selection.
相當於一個地圖框架。
Map:CoClass。
2. 屬性和方法:
方法和屬性 | Description | |
---|---|---|
![]() |
ActiveGraphicsLayer | The active graphics layer. If no graphic layers exist a basic memory graphics layer will be created. |
![]() |
AddLayer | Adds a layer to the map. |
![]() |
AddLayers | Adds multiple layers to the map, arranging them nicely if specified. |
![]() |
AddMapSurround | Adds a map surround to the map. |
![]() |
AnnotationEngine | The annotation (label) engine the map will use. |
![]() |
AreaOfInterest | Area of interest for the map. |
![]() |
Barriers | The list of barriers and their weight for labeling. |
![]() |
BasicGraphicsLayer | The basic graphics layer. |
![]() |
ClearLayers | Removes all layers from the map. |
![]() |
ClearMapSurrounds | Removes all map surrounds from the map. |
![]() |
ClearSelection | Clears the map selection. |
![]() |
ClipBorder | An optional border drawn around ClipGeometry. |
![]() |
ClipGeometry | A shape that layers in the map are clipped to. |
![]() |
ComputeDistance | Computes the distance between two points on the map and returns the result. |
![]() |
CreateMapSurround | Create and initialize a map surround. An optional style from the style gallery may be specified. |
![]() |
DelayDrawing | Suspends drawing. |
![]() |
DelayEvents | Used to batch operations together to minimize notifications. |
![]() |
DeleteLayer | Deletes a layer from the map. |
![]() |
DeleteMapSurround | Deletes a map surround from the map. |
![]() |
Description | Description of the map. |
![]() |
DistanceUnits | The distance units for the map. |
![]() |
Expanded | Indicates if the Map is expanded. |
![]() |
FeatureSelection | The feature selection for the map. |
![]() |
GetPageSize | Gets the page size for the map. |
![]() |
IsFramed | Indicates if map is drawn in a frame rather than on the whole window. |
![]() |
Layer | The layer at the given index. |
![]() |
LayerCount | Number of layers in the map. |
![]() |
Layers | The layers in the map of the type specified in the uid. If recursive is true it will return layers in group layers. |
![]() |
MapScale | The scale of the map as a representative fraction. 設置和獲取當前地圖比例尺的屬性。 |
![]() |
MapSurround | The map surround at the given index. |
![]() |
MapSurroundCount | Number of map surrounds associated with the map. |
![]() |
MapUnits | The units for the map. |
![]() |
MoveLayer | Moves a layer to another position. |
![]() |
Name | Name of the map. |
![]() |
RecalcFullExtent | Forces the full extent to be recalculated. |
![]() |
ReferenceScale | The reference scale of the map as a representative fraction. 設置參考比例尺,若為“0”,則取消參考比例尺! |
![]() |
SelectByShape (IGeometry Shape, ISelectionEnvironment env, bool justone) |
Selects features in the map given a shape and a selection environment (optional).axMapControl1.Map.SelectByShape(geometry, null , false); |
![]() |
SelectFeature (ILayer layer, IFeature feature) |
Selects a feature. 給定 圖層 和 元素,選擇圖層中的該要素! private void SelecteFeatures(List<string> OIDList) { IFeatureClass pFeatureClass = pLayer.FeatureClass; string strID = string.Empty; string[] IDs = OIDList.ToArray(); for (int i = 0; i < IDs.Length;i++ ) { strID = IDs[i]; IFeature selectedFeature = pFeatureClass.GetFeature(Convert.ToInt32(strID)); pMap.SelectFeature(pLayer, selectedFeature); } pActiveView.Refresh(); } |
![]() |
SelectionCount | Number of selected features. |
![]() |
SetPageSize | Sets the page size for the map (optional). |
![]() |
SpatialReference | The spatial reference of the map. |
![]() |
SpatialReferenceLocked | Indicates whether the spatial reference is prevented from being changed. |
![]() |
UseSymbolLevels | Indicates if the Map draws using symbol levels. |
---------------------------------------------------------------------------------------------------------
╔════════╗
╠════╣ 第G4個 ╠══════════════════════════════════════════════════╣
╚════════╝
●·● IMapDocument 接口:
1. Provides access to members that control the reading and writing of map document files.
The IMapDocument interface provides properties and methods for reading map document files (*.mxd, *mxt, *.pmf) and writing and saving changes to map document files (*.mxd). However, since it is not tied to the ArcMap application, application-specific functionality in the MapDocument will not be persisted. Examples of application specific functionality are toolbar settings, UI customizations, VBA projects, and ArcMap graphs. For desktop developers who need to use this functionality, the MxDocument interface located in the ArcMapUI library is a better choice.
相當於一個地圖文件,包括多個地圖框架,具有“打開”、“保存”和“另存為”的方法。
MapDocument:CoClass。
MxDocument:CoClass。
2. 屬性和方法:
屬性和方法 | Description | |
---|---|---|
![]() |
ActiveView | The ActiveView of the map document. |
![]() |
Close | Close the map document. |
![]() |
DocumentFilename | The map document filename that the MapDocument coclass is linked to. |
![]() |
DocumentType | The type of map document currently loaded in the object. |
![]() |
DocumentVersion | Indicates if the version of the map document is compatible with the current version of software. |
![]() |
GetVersionInfo | Retrieve the detailed version information of the map document. |
![]() |
IsMapDocument | Indicates if the map document is a valid map document. |
![]() |
IsPasswordProtected | Indicates if the map document is protected by a passsword. |
![]() |
IsPresent | Indicates if the map document is present. |
![]() |
IsReadOnly | Indicates if the map document is read only. |
![]() |
IsRestricted | Indicates if the use of the map document is restricted to certain applications. |
![]() |
Layer | The Layer object at the specified index for the specified map. |
![]() |
Map 屬性:Map [int mapIndex] 方法:get_Map (int mapIndex) 指不同的數據框,每一個數據框相當於一個 Map 。 |
The Map object at the specified index.axMapControl1.Map = mapDocument.Map[i]; |
![]() |
MapCount | The number of Map objects contained within the map document. 數據框的個數,也就是 Map 的個數。 |
![]() |
New | Creates and opens a new map document in preparation for the contents to be retrieve or updated. |
![]() |
Open (string sDocument, string bsPassword) |
Open the map document in preparation for the contents to be retrieve or updated.mapDocument.Open(ofd.FileName, "");
|
![]() |
PageLayout | The PageLayout object. |
![]() |
Printer | The printer object. If no printer object is stored in the map document this returns NULL. |
![]() |
ReplaceContents | Replace the contents of the map document. |
![]() |
Save (bool bUseRelativePaths, bool bCreateThumnbail) |
Save the contents of the map document to the bound file.mapDocument.Save(true, true); |
![]() |
SaveAs (string sDocument, bool bUseRelativePaths, bool bCreateThumnbail) |
Save the contents of the map document to the specified file name. 第一個參數:完整路徑,包括名字在內,第二個參數:是否使用相對路徑,第三個參數:是否生成縮略圖,預覽的時候可以顯現! mapDocument.SaveAs(sfd.FileName, false, true); |
![]() |
SetActiveView | Set the ActiveView content of the map document. |
![]() |
Thumbnail | The thumbnail stored in the map document. If this is empty E_FAIL is returned. |
![]() |
UsesRelativePaths | Indicates if the data in the map document is referenced using relative paths. |
---------------------------------------------------------------------------------------------------------
╔════════╗
╠════╣ 第G5個 ╠══════════════════════════════════════════════════╣
╚════════╝
●·● IGraphicsContainer 接口:
1. Provides access to members that control the Graphics Container【容器】.
Objects which manage a collection of graphic elements implement this interface. For example, the PageLayout, Map, and FDOGraphicsLayer object all implement this interface to provide access to the graphic elements they manage.
The PageLayout object contains a collection of Element objects including, MapFrames, MapSurroundFrames, and GraphicElements such as the PictureElement, MarkerElement and LineElement. The members of this interface provide access to the Elements.
When using this interface to add elements to layer types that operate in a corrdinate system, such as FDOGraphicsLayer and CompositeGraphicsLayer, the elements must implement IGraphicElement.
CoClasses that implement IGraphicsContainer
CoClasses and Classes | Description |
---|---|
CompositeGraphicsLayer | A collection of graphics layers that behave like single layer. |
FDOGraphicsLayer | A collection of properties for an annotation layer (feature data object graphics layer). |
GlobeGraphicsLayer (esriGlobeCore) | The Globe Graphics Layer. |
GraphicsLayer3D (esri3DAnalyst) | A 3D Graphics Layer. |
GraphicsSubLayer | Graphic sublayer handed back by the composite graphics layer. |
Map | A container for the display and manipulation of map data. |
PageLayout | Page Layout class contains maps and map surrounds. |
2. 屬性和方法:
Description | ||
---|---|---|
![]() |
AddElement (IElement Element, int zorder) |
Add a new graphic element to the layer. zorder 大部分時候賦值為0. |
![]() |
AddElements | Add new graphic elements to the layer. |
![]() |
BringForward | Move the specified elements one step closer to the top of the stack of elements. |
![]() |
BringToFront | Make the specified elements draw in front of all other elements. |
![]() |
DeleteAllElements | Delete all the elements. 刪除地圖上面的所有臨時圖形元素! |
![]() |
DeleteElement (IElement Element) |
Delete the given element. |
![]() |
FindFrame (object frameObject) |
Find the frame that contains the specified object.IFrameProperties frameProperties = (IFrameProperties)axPageLayoutControl1.GraphicsContainer.FindFrame(axPageLayoutControl1.ActiveView.FocusMap); |
![]() |
GetElementOrder | Private order object. Used to undo ordering operations. |
![]() |
LocateElements | Returns the elements at the given coordinate. |
![]() |
LocateElementsByEnvelope | Returns the elements inside the given envelope. |
![]() |
MoveElementFromGroup | Move the element from the group to the container. |
![]() |
MoveElementToGroup | Move the element from the container to the group. |
![]() |
Next | Returns the next graphic in the container. |
![]() |
PutElementOrder | Private order object. Used to undo ordering operations. |
![]() |
Reset | Reset internal cursor so that Next returns the first element. |
![]() |
SendBackward | Move the specified elements one step closer to the bottom of the stack of elements. |
![]() |
SendToBack | Make the specified elements draw behind all other elements. |
![]() |
UpdateElement | The graphic element's properties have changed. |
---------------------------------------------------------------------------------------------------------
╔════════╗
╠════╣ 第G6個 ╠══════════════════════════════════════════════════╣
╚════════╝
●·● IActiveView 接口:
1. Provides access to members that control the active view - the main application window.
This interface manages the main application window in ArcMap and all drawing operations.
In ArcMap, two objects implement【實現】 this interface: PageLayout and Map. These two objects correspond to the two different views in ArcMap: layout and data view. Only one view can be active at a time and this is termed the active view. IMxDocument::ActiveView holds a reference to the current active view object (a Map or the PageLayout). For example, if the ArcMap application is in layout mode, IMxDocument::ActiveView returns an IActiveView reference to the PageLayout object. Alternatively, if the application is in data view, this propery returns a reference【參考】 to the focus map.
ArcMap has view commands which allow users to toggle【切換】 between layout view and data view. These commands appear on the View menu and on the scroll bar.
An ArcMap document can contain many Maps. Make sure you have the desired object when working with this interface. Otherwise, operations such as drawing may not be occurring in the application window as you expect. For example, a Map obtained through IMxDocument::Maps is not guaranteed to be the focus map. If you know you want a reference to the focus map, use IMxDocument::FocusMap. Similarly, if you know you want a reference to the page layout, use IMxDocument::PageLayout instead. You can change the document's active view by setting IMxDocument::ActiveView. Learn more by reading the help for this property.
CoClasses that implement IActiveView
CoClasses and Classes | Description |
---|---|
Globe (esriGlobeCore) | A container for the display and manipulation of data in the Globe. |
Map | A container for the display and manipulation of map data. |
PageLayout | Page Layout class contains maps and map surrounds. |
Scene (esri3DAnalyst) | A container for the display and manipulation of data. |
2. 屬性和方法:
Description | ||
---|---|---|
![]() |
Activate | Gives this view control of the specified window. |
![]() |
Clear | Empties the view contents. |
![]() |
ContentsChanged | Called by clients when view objects are modified. |
![]() |
Deactivate | Another view takes over the associated window. |
![]() |
Draw | Draws the view to the specified device context. |
![]() |
ExportFrame | The device rectangle to export. |
![]() |
Extent | The visible extent rectangle. |
![]() |
ExtentStack | The extent stack. |
![]() |
FocusMap | The map that tools and controls act on. |
![]() |
FullExtent | The full extent rectangle. |
![]() |
GetContextMenu | Called when a context menu should be displayed at the given xy location. Return menu that should be displayed. |
![]() |
GraphicsContainer | The active graphics container. |
![]() |
HitTestMap | Returns any maps present in the view at the given location. Return value may be zero if there are no maps or the coordinate is not over a map. |
![]() |
IsActive | Indicates if view is active or not. |
![]() |
IsMapActivated | Indicates if the focus map is activated. |
![]() |
OnMessage | Call from your application's message loop to enable automatic resizing and keyboard accelerators. |
![]() |
Output | Renders the view to the specified DC. |
![]() |
PartialRefresh (esriViewDrawPhase Phase, object Data, IEnvelope envelope) |
Draws the specified view phase. Use an envelope of zero to draw the entire phase. esriViewDrawPhase 枚舉: 參考:http://www.gisall.com/html/63/34963-3334.html activeView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null); |
![]() |
PrinterChanged | Called by application when printer changes. |
![]() |
Refresh | Causes the entire view to draw. |
![]() |
ScreenCacheID | The screen cache ID that is used to draw the specified phase. |
![]() |
ScreenDisplay 返回值:IScreenDisplay |
The screen display used by the view. |
![]() |
Selection | The selection. |
![]() |
ShowRulers | Indicates if rulers are visible. |
![]() |
ShowScrollBars | Indicates if scrollbars are visible. |
![]() |
ShowSelection | Indicates if selection is visible. |
![]() |
TipText | The tip text to display at the given location. |
---------------------------------------------------------------------------------------------------------
╔════════╗
╠════╣ 第G7個 ╠══════════════════════════════════════════════════╣
╚════════╝
●·● IFillShapeElement 接口:
1. IFillShapeElement is a generic interface implemented by all 2d elements (CircleElement, EllipseElement, PolygonElement, and RectangleElement).
Use this interface when you want to retrieve or set the fill symbol being used by one of the fill shape elements.
CoClasses that implement IFillShapeElement
CoClasses and Classes | Description |
---|---|
CircleElement | The Graphic Element to display Circles. |
EllipseElement | The Graphic Element to display Ellipses. |
GeoEllipseElement (esriDefenseSolutions) | The graphic element to display GeoEllipses. |
GeoPolygonElement (esriDefenseSolutions) | The graphic element for displaying GeoPolygons. |
MultiPatchElement | The MultiPatch Graphics Element CoClass. |
PolygonElement | The Graphic Element to display polygons. |
RectangleElement | The Graphic Element to display rectangles. |
Text3DElement | The Text3D Graphics Element CoClass. |
2. 屬性和方法:
Description | ||
---|---|---|
![]() |
Symbol 返回值:IFillSymbol |
Fill symbol this element uses to draw itself. |
---------------------------------------------------------------------------------------------------------
╔════════╗
╠════╣ 第G8個 ╠══════════════════════════════════════════════════╣
╚════════╝
●·● IElement 接口:
1. Provides access to members that control the Element.
CoClasses that implement IElement
CoClasses and Classes | Description |
---|---|
BmpPictureElement | The Graphic Element to display BMP Pictures. |
CircleElement | The Graphic Element to display Circles. |
DataGraphTElement (esriCartoUI) | A container for the display and manipulation of data graph graphic element on the ArcMap layout view. |
DisplacementLinkElement (esriEditorExt) | The Graphic Element to display adjustment links. |
EllipseElement | The Graphic Element to display Ellipses. |
EmfPictureElement | The Graphic Element to display Emf Pictures. |
FEGraphic (esriDefenseSolutions) | A cached graphic that symbolizes a point based military object (feature or force element). |
FrameElement | The Frame element to provide a neatline or background. |
GeoEllipseElement (esriDefenseSolutions) | The graphic element to display GeoEllipses. |
GeoPolygonElement (esriDefenseSolutions) | The graphic element for displaying GeoPolygons. |
GeoPolylineElement (esriDefenseSolutions) | The graphic element for displaying GeoPolylines. |
GifPictureElement | Graphic Element to display GIF Pictures. |
GroupElement | The Group Graphic Element to display a group of graphic elements. |
IdentityLinkElement (esriEditorExt) | The Graphic Element to display identity links. |
InkGraphic | Ink Graphic Object. |
Jp2PictureElement | Graphic Element to display JPEG2000 Pictures. |
JpgPictureElement | Graphic Element to display JPG Pictures. |
LineElement | The Graphic Element to display lines. |
MapFrame | A graphic element for displaying maps. |
MapSurroundFrame | A graphic element for displaying map surrounds. |
MarkerElement | The Graphic Element to display markers. |
MoleGroupElement (esriDefenseSolutions) | Mole Group Element Class. |
MultiPatchElement | The MultiPatch Graphics Element CoClass. |
OleFrame (esriArcMapUI) | The OLE frame. |
ParagraphTextElement | The Graphic Element to display text which flows into an area geometry. |
PictureElement | Picture Graphic Element. |
PMFTitleTextElement | The Graphic Element to display dynamic PMF titles. |
PngPictureElement | Graphic Element to display PNG Pictures. |
PolygonElement | The Graphic Element to display polygons. |
RectangleElement | The Graphic Element to display rectangles. 顯示矩形的圖形要素。 IElement element = new RectangleElement();
|
TableFrame (esriEditorExt) | Graphic Element to display table. |
TemporalChartElement (esriTrackingAnalystUI) | Controls elements of the temporal charts. |
Text3DElement | The Text3D Graphics Element CoClass. |
TextElement | The Graphic Element to display text. |
TifPictureElement | Graphic Element to display TIF Pictures. |
2. 屬性和方法:
Description | ||
---|---|---|
![]() |
Activate | Prepare to display graphic on screen. |
![]() |
Deactivate | ActiveView that graphics are displayed on is no longer visible. |
![]() |
Draw | Draws the element into the given display object. |
![]() |
Geometry | Shape of the element as a geometry. |
![]() |
HitTest | Indicates if the given x and y coordinates are contained by the element. |
![]() |
Locked | Indicates if the element is in a read-only state. |
![]() |
QueryBounds | Bounds of the element taking symbology into consideration. |
![]() |
QueryOutline | Bounds of the element taking symbology into consideration. |
![]() |
SelectionTracker | Selection tracker used by this element. |
---------------------------------------------------------------------------------------------------------
╔════════╗
╠════╣ 第G9個 ╠══════════════════════════════════════════════════╣
╚════════╝
●·● IFrameProperties 接口:
1. Provides access to members that control the General properties for a frame.
CoClasses that implement IFrameProperties
CoClasses and Classes | Description |
---|---|
BmpPictureElement | The Graphic Element to display BMP Pictures. |
EmfPictureElement | The Graphic Element to display Emf Pictures. |
FrameElement | The Frame element to provide a neatline or background. |
GifPictureElement | Graphic Element to display GIF Pictures. |
GroupElement | The Group Graphic Element to display a group of graphic elements. |
Jp2PictureElement | Graphic Element to display JPEG2000 Pictures. |
JpgPictureElement | Graphic Element to display JPG Pictures. |
LocatorRectangle | A map locator rectangle. |
MapFrame | A graphic element for displaying maps. |
MapSurroundFrame | A graphic element for displaying map surrounds. |
OleFrame (esriArcMapUI) | The OLE frame. |
Page | The On Screen Page. |
ParagraphTextElement | The Graphic Element to display text which flows into an area geometry. |
PictureElement | Picture Graphic Element. |
PngPictureElement | Graphic Element to display PNG Pictures. |
TableFrame (esriEditorExt) | Graphic Element to display table. |
TemporalChartElement (esriTrackingAnalystUI) | Controls elements of the temporal charts. |
TifPictureElement | Graphic Element to display TIF Pictures. |
2. 屬性和方法:
Description | ||
---|---|---|
![]() |
Background | Frame background used by this element. |
![]() |
Border | Frame border used by this element. |
![]() |
Shadow | Frame shadow used by this element. |
---------------------------------------------------------------------------------------------------------
╔════════╗
╠════╣ 第Ga個 ╠══════════════════════════════════════════════════╣
╚════════╝
●·● IMapFrame 接口:
1. Provides access to the members that control the map element object.
IMapFrame is the default interface for the MapFrame object. The main purpose of the interface is to give the developer access to the map object stored within the frame, and it's associated locator rectangles.
Inherited Interfaces
Interfaces | Description |
---|---|
IFrameElement | Provides access to members that control the Frame element object. |
CoClasses that implement IMapFrame
CoClasses and Classes | Description |
---|---|
MapFrame | A graphic element for displaying maps. |
2. 屬性和方法:
Description | ||
---|---|---|
![]() |
AddLocatorRectangle | Add a new locator rectangle to the data frame. |
![]() |
Background | Frame background used by this element. |
![]() |
Border | Frame border used by this element. |
![]() |
Container | The frame's container. |
![]() |
CreateSurroundFrame | Returns the map surround frame element of the type given in clsid. An optional style object may be specified. |
![]() |
DraftMode | Indicates if this element is in draft mode, i.e., draws fast. |
![]() |
ExtentType | The way in which the map extent of the frame is specified. |
![]() |
LocatorRectangle | Returns the locator rectangle at the specified index. |
![]() |
LocatorRectangleCount | The number of locator rectangles. |
![]() |
Map | The associated map. |
![]() |
MapBounds | The bounds of the map displayed by the frame. |
![]() |
MapScale | The scale at which the map should be displayed. |
![]() |
Object | Object framed by this element. |
![]() |
RemoveAllLocatorRectangles | Remove all the locator rectangles from the data frame. |
![]() |
RemoveLocatorRectangle | Remove a locator rectangle from the data frame. |
![]() |
Thumbnail | Small bitmap representation of this element. |
---------------------------------------------------------------------------------------------------------
╔════════╗
╠════╣ 第Gb個 ╠══════════════════════════════════════════════════╣
╚════════╝
●·● IMapGrid 接口:
1. Provides access to members that control a map grid.
IMapGrid is the main interface for setting properties that apply to all other types of grids. There are four specific types of MapGrid that all implement the IMapGrid interface. They are: IMeasuredGrid , IGraticule , IndexGrid , and ICustomGridOverlay .
CoClasses that implement IMapGrid
CoClasses and Classes | Description |
---|---|
CustomOverlayGrid | A custom map grid. |
Graticule | A map grid that divides the map with meridians and parallels. |
IndexGrid | A map grid that divides the map into a grid for indexing. |
MeasuredGrid | A map grid that divides the map into a grid of units in any coordinate system. |
MgrsGrid | The Military Grid Reference System (MGRS) object. |
2. 屬性和方法:
Description | ||
---|---|---|
![]() |
Border | The map grid border. |
![]() |
Draw | Draws the map grid for a map frame to the given display. |
![]() |
ExteriorWidth | The width (in display units) of the portion of the grid that is outside of the frame. |
![]() |
GenerateGraphics | Generates graphic elements corresponding to the grid lines and stores them in the specified graphics container. |
![]() |
LabelFormat | The label format for map grid labels. |
![]() |
LineSymbol | The symbol used to draw grid lines - null will draw no lines. |
![]() |
Name | The name of the map grid. |
![]() |
PrepareForOutput | Prepares the map grid for output to a device. |
![]() |
QueryLabelVisibility | Returns the visibility of the labels along all four sides of the map grid. |
![]() |
QuerySubTickVisibility | Returns the visibility of the subticks along all four sides of the map grid. |
![]() |
QueryTickVisibility | Returns the visibility of the ticks along all four sides of the map grid. |
![]() |
SetDefaults | Sets the properties of the map grid to default values. |
![]() |
SetLabelVisibility | Sets the visibility of the labels along all four sides of the map grid. |
![]() |
SetSubTickVisibility | Sets the visibility of the subticks along all four sides of the map grid. |
![]() |
SetTickVisibility | Sets the visibility of the ticks along all four sides of the map grid. |
![]() |
SubTickCount | The number of subticks to draw between the major ticks. |
![]() |
SubTickLength | The length of the subticks in points. |
![]() |
SubTickLineSymbol | The symbol used to draw the subtick lines. |
![]() |
TickLength | The length of the major ticks in points. |
![]() |
TickLineSymbol | The line symbol used to draw the major ticks. |
![]() |
TickMarkSymbol | The symbol used to draw tick marks at the grid interval intersections - null will draw no tick marks. |
![]() |
Visible | Indicates if the map grid is visible. |
---------------------------------------------------------------------------------------------------------
╔════════╗
╠════╣ 第Gc個 ╠══════════════════════════════════════════════════╣
╚════════╝
●·● IMapGrids 接口:
1. Provides access to members that control the map grids in a data frame.
IMapGrids is implemented only by the MapFrame object, but it is not the default interface for that object (IMapFrame is the default). Use this interface when you want to retrieve or set the grids (sometimes known as graticules) displayed with a particular MapFrame. The Grids are used to provide reference information for the map.
CoClasses that implement IMapGrids
CoClasses and Classes | Description |
---|---|
MapFrame | A graphic element for displaying maps. |
2. 屬性和方法:
Description | ||
---|---|---|
![]() |
AddMapGrid | Adds a map grid to the map frame. |
![]() |
ClearMapGrids | Clears all map grids from the map frame. |
![]() |
DeleteMapGrid | Deletes a map grid from the map frame. |
![]() |
MapGrid | The map grid at the specified index. |
![]() |
MapGridCount | The number of map grids associated with the map frame. |
---------------------------------------------------------------------------------------------------------
╔════════╗
╠════╣ 第Gd個 ╠══════════════════════════════════════════════════╣
╚════════╝
●·● ISelectionEnvironment 接口:
1. Provides access to members that control the selection environment.
CoClasses that implement ISelectionEnvironment
CoClasses and Classes | Description |
---|---|
SelectionEnvironment | Defines the feature selection environment. |
2. 屬性和方法:
Description | ||
---|---|---|
![]() |
AreaSearchDistance | Distance used for selecting areas by proximity. |
![]() |
AreaSelectionMethod | Selection method used for areas. |
![]() |
CombinationMethod | Combination method for the selection results. |
![]() |
DefaultColor | Default selection color. |
![]() |
LinearSearchDistance | Distance used for selecting lines by proximity. |
![]() |
LinearSelectionMethod | Selection method used for lines. |
![]() |
PointSearchDistance | Distance used for selecting points by proximity. |
![]() |
PointSelectionMethod | Selection method used for points. |
![]() |
SearchTolerance | Search tolerance in device units. |
---------------------------------------------------------------------------------------------------------
╔════════╗
╠════╣ 第Ge個 ╠══════════════════════════════════════════════════╣
╚════════╝
●·● IPage 接口:
1. Provides access to members that control the Page.
private void button2_Click(object sender, EventArgs e) { ColorDialog cd = new ColorDialog(); cd.ShowDialog(); IPage pPage = axPageLayoutControl1.PageLayout.Page; IRgbColor pColor = new RgbColor(); pColor.Red = cd.Color.R; pColor.Green = cd.Color.G; pColor.Blue = cd.Color.B; pPage.BackgroundColor = pColor; }
---------------------------------------------------------------------------------------------------------
╔════════╗
╠════╣ 第Gf個 ╠══════════════════════════════════════════════════╣
╚════════╝
●·● ISnapGrid 接口:
1. Provides access to members that control the Snapping grid.
private void button3_Click(object sender, EventArgs e) { ISnapGrid pSnapGrid = axPageLayoutControl1.PageLayout.SnapGrid; pSnapGrid.VerticalSpacing = .2; pSnapGrid.HorizontalSpacing = .1; pSnapGrid.IsVisible = true; axPageLayoutControl1.ActiveView.Refresh(); }
---------------------------------------------------------------------------------------------------------
╔════════╗
╠════╣ 第Gg個 ╠══════════════════════════════════════════════════╣
╚════════╝
●·● ISnapGuides 接口:
1. Provides access to members that control the Snapping guides.
private void button4_Click(object sender, EventArgs e) { ISnapGuides pSnapGuides = axPageLayoutControl1.PageLayout.HorizontalSnapGuides; for (int i = 0; i < 30;i++ ) { pSnapGuides.AddGuide(i); } pSnapGuides.AreVisible = true; ISnapGuides pSnapGuides2 = axPageLayoutControl1.PageLayout.VerticalSnapGuides; for (int i = 0; i < 20;i++ ) { pSnapGuides2.AddGuide(i); } pSnapGuides2.AreVisible = true; axPageLayoutControl1.ActiveView.Refresh(); }
---------------------------------------------------------------------------------------------------------
╔════════╗
╠════╣ 第Gh個 ╠══════════════════════════════════════════════════╣
╚════════╝
●·● IRulerSettings 接口:
1. Provides access to members that control Ruler setup.
---------------------------------------------------------------------------------------------------------
╔════════╗
╠════╣ 第Gh個 ╠══════════════════════════════════════════════════╣
╚════════╝
●·● IRulerSettings 接口:
1. Provides access to members that control Ruler setup.
---------------------------------------------------------------------------------------------------------
╔════════╗
╠════╣ 第Gi 個 ╠══════════════════════════════════════════════════╣
╚════════╝
●·● IRulerSettings 接口:
1. Provides access to members that control Ruler setup.
---------------------------------------------------------------------------------------------------------
╔════════╗
╠════╣ 第Gj 個 ╠══════════════════════════════════════════════════╣
╚════════╝
●·● IRulerSettings 接口:
1. Provides access to members that control Ruler setup.
---------------------------------------------------------------------------------------------------------
●·● Controls 命名空間
---------------------------------------------------------------------------------------------------------
╔════════╗
╠════╣ 第U1個 ╠══════════════════════════════════════════════════╣
╚════════╝
●·● LicenseControl 類:
1. 用來給控件提供許可,並不現實在程序上。
2. Using the LicenseControl.
3. How to programmatically handle LicenseControl initialization failure.
---------------------------------------------------------------------------------------------------------
╔════════╗
╠════╣ 第U2個 ╠══════════════════════════════════════════════════╣
╚════════╝
●·● MapControl 類:
1. MapControl 控件封裝了 Map 對象,並提供了其他的屬性、方法和事件,用於管理控件的外觀、顯示屬性和地圖屬性,管理、添加數據圖層,裝載地圖文擋,顯示、繪制跟蹤圖層。MapControl上存在着諸如 TrackRectangle 、TrackPolygon 、TrackLine 和 TrackCircle 等幫助方法,用於追蹤或" 橡皮圈住( rubber banding )"顯示上的幾何圖形( Shape )。VisibleRegion 屬性可用於更改MapControl 顯示區內的幾何圖形。MapControl 控件實現的主要接口有IMapControlDefault 、IMapControl2 、IMapControl3 、lMapConlrolEvents2 等
2. Using the MapControl.
3. How to get started with the MapControl property pages.
4. How to enable arrow key and mouse wheel navigation of the map display.
axMapControl1.KeyIntercept = (int)esriKeyIntercept.esriKeyInterceptArrowKeys;
axMapControl1.AutoKeyboardScrolling = true;
axMapControl1.AutoMouseWheel = true;
5. How to rotate the MapControl display.
6. How to drop data onto the MapControl. 從其他窗口拖拽數據!
7. Displaying MapTips in the MapControl.
---------------------------------------------------------------------------------------------------------
╔════════╗
╠════╣ 第U3個 ╠══════════════════════════════════════════════════╣
╚════════╝
●·● IMapControl2 類:
1. The IMapControl2 interface is a starting point for any tasks related to the MapControl, such as setting general appearance, setting map and display properties, adding and managing data layers and map documents, and drawing and tracking shapes.
2. 屬性和方法:
屬性和方法 | Description | |
---|---|---|
![]() |
AboutBox | Displays a dialog of information about the MapControl. |
![]() |
ActiveView | The active view of the Map contained by the MapControl. |
![]() |
AddLayer (ILayer Layer, int toIndex) |
Adds a layer to the Map's collection of layers at the specified index position. |
![]() |
AddLayerFromFile (string lyrPath, int toIndex) |
Loads a layer file and adds it to the Map's collection of layers at the specified index position. 默認為 0,toIndex 限制所處塗層的位置! |
![]() |
AddShapeFile (string Path, string fileName) |
Adds a shapefile as a layer to the Map. 添加 Shapefile 文件! |
![]() |
Appearance | The appearance of the MapControl. |
![]() |
BackColor | Background color of the MapControl. |
![]() |
BorderStyle | The border style of the MapControl. |
![]() |
CenterAt | Moves the center of the MapControl to the specified location. 指的是以地理坐標為中心。 IPoint point = new ESRI.ArcGIS.Geometry.Point(); //定義點 |
![]() |
CheckMxFile (string fileName) |
Checks the specified filename to see if it is a map document that can be loaded into the MapControl. 判斷是否為 *.mxd 文件。 |
![]() |
ClearLayers | Removes all layers from the Map. |
![]() |
CurrentTool | Current active tool for the MapControl. Set to nothing to clear the tool. |
![]() |
DeleteLayer (int index) |
Removes a Layer from the Map's collection of layers at the specified index position.for (int i = axMapControl1.LayerCount - 1; i >= 0;i--) |
![]() |
DrawShape (IGeometry, ref object symbol) |
Draws a geometry shape on the MapControl. |
![]() |
DrawText (IGeometry pGeometry, string text, ref object pSymbol) |
Draws text along the supplied geometry. |
![]() |
Enabled | Indicates whether the MapControl can respond to user generated events. |
![]() |
Extent IEnvelope |
Current extent of the Map in map units. 對於相同地圖來說,即使在不同的 MapControl 中,但是相同區域的長和寬都是相同的!通過這個特點,可以很容易的實現讓兩個 MapControl 顯示相同哦內容! private void axMapControl1_OnExtentUpdated(object sender, IMapControlEvents2_OnExtentUpdatedEvent e) |
![]() |
FlashShape (IGeometry pShape, int nFlashes, int flashInterval, object symbol) |
Flashes a shape on the MapControl, duration is in milliseconds. |
![]() |
FromMapPoint | Converts a point on the Map (in map units) to device co-ordinates (typically pixels). |
![]() |
FullExtent | Rectangular shape that encloses all features of all layers in the Map. |
![]() |
hWnd | Handle to the window associated with the MapControl. |
![]() |
Layer 屬性:Layer [int index] 方法:get_Layer (int index) |
Layer at the supplied index. |
![]() |
LayerCount | Number of layers in the Map. |
![]() |
LoadMxFile (string mxPath, object mapNmeOrIndex, object password) |
Loads the specified Map from the map document into the MapControl. The Map can be an index or a name, if it is not supplied the focus map is used. 加載 *.mxd 文件。(Type.Missing 默認值) axMapControl1.LoadMxFile(filePath, Type.Missing, Type.Missing); |
![]() |
Map | The Map contained by the MapControl. |
![]() |
MapScale | Scale of the map as a representative fraction. |
![]() |
MapUnits | The geographical units of the map. |
![]() |
MouseIcon | Custom mouse icon used if MousePointer is 99. |
![]() |
MousePointer | The mouse pointer displayed over the MapControl. esriControlsMousePointer 枚舉:鼠標的不同顯示樣式!(箭頭小圓圈) axMapControl1.MousePointer = esriControlsMousePointer.esriPointerHourglass; |
![]() |
MoveLayerTo (int fromIndex, int toIndex) |
Moves a layer within the Map's collection from its current index position to a new index position. 若向下移動,則其上的整體上移,若向上移動,則其下整體下移。 |
![]() |
OleDropEnabled | Indicates if the MapControl will fire events when data is dragged over the control's window. |
![]() |
Pan | Tracks the mouse while panning the MapControl. 實現在 MapControl 上面漫游。 |
![]() |
ReadMxMaps | Opens a map document specified by the supplied filename and reads the maps into an array object. |
![]() |
ReferenceScale | Reference scale of the Map as a representative fraction. |
![]() |
Refresh | Redraws the Map, optionally just redraw specified phases or envelope. |
![]() |
Rotation (double Rotation) |
Determines how many degrees the map display is rotated. 旋轉的角度,相對於最初位置而言的!下面實現在 0 ° 和 180° 之間切換! if (axMapControl1.Rotation == 0) { axMapControl1.Rotation = 180; axMapControl1.ActiveView.Refresh(); } else { axMapControl1.Rotation = 0; axMapControl1.ActiveView.Refresh(); } |
![]() |
ShowScrollbars | Indicates whether or not the Map's scrollbars are visible. |
![]() |
SpatialReference | Spatial reference of the Map. |
![]() |
ToMapPoint | Converts a point in device co-ordinates (typically pixels) to a point on the Map (in map units). |
![]() |
TrackCancel | The object used by the MapControl to check if drawing has been aborted. |
![]() |
TrackCircle | Rubber-bands【橡皮筋】 a circle on the MapControl. |
![]() |
TrackLine IGeometry |
Rubber-bands a polyline on the MapControl. 用鼠標在 MapControl 上畫折線。 |
![]() |
TrackPolygon | Rubber-bands a polygon on the MapControl.![]() int flag = 0; |
![]() |
TrackRectangle IGeometry |
Rubber-bands a rectangle on the MapControl. 用鼠標在 MapControl 上拉出一個矩形。 |
![]() |
VisibleRegion | The geometry specifying the visible region of the Map. |
KeyIntercept:A property that specifies interception of key strokes that are normally handled by the container. When intercepted the OnKeyDown and OnKeyUp events will be called. This value can be a combined bit mask of esriKeyIntercept enum values.
AutoKeyboardScrolling:Indicates whether keyboard scrolling is enabled.
AutoMouseWheel:Indicates whether the mouse wheel is enabled.
axMapControl1.KeyIntercept = (int)esriKeyIntercept.esriKeyInterceptArrowKeys; //接收方向鍵 axMapControl1.AutoKeyboardScrolling = true; //允許使用鍵盤 axMapControl1.AutoMouseWheel = false; //允許使用鼠標中建
---------------------------------------------------------------------------------------------------------
╔════════╗
╠════╣ 第U4個 ╠══════════════════════════════════════════════════╣
╚════════╝
●·● IMapControl4 類:
1. 屬性和方法:
- DocumentFilename:The filename of the last map document loaded into the control. 文檔的文件全名。
MessageBox.Show(axMapControl1.DocumentFilename);
- DocumentMap:The name of the map that was last loaded into the control from a map document. 地圖名稱。
- KeyIntercept:返回或設置 MapControl 截取鍵盤按鍵信息。
- Object:返回 MapControl 控件。
- ShowMapTips:Indicates if map tips are shown.
- CustomProperty:個人理解,很神奇的一個屬性,就是內部記錄N多東西,只要給他強制類型轉換,就可以指定的東西,前提是它里面有這個東西!
---------------------------------------------------------------------------------------------------------
╔════════╗
╠════╣ 第U5個 ╠══════════════════════════════════════════════════╣
╚════════╝
●·● IMapControlEvents2 類:
1. Provides access to events that occur with interaction to the MapControl.
This is the main events interface for the MapControl. Generally there is no need to explicitly set event handlers, as most development environments will automatically provide event handlers.
2. 事件:
事件 | Description | |
---|---|---|
![]() |
OnAfterDraw | Fires after the Map draws a specified view phase. |
![]() |
OnAfterScreenDraw | Fires after the Map contained by the MapControl has finished drawing. 效果好像和 OnExtentUpdated 比較類似! 不同點就是 OnAfterScreenDraw 是在操作之后才觸發,而 OnExtentUpdated 是只要有范圍變化即會觸發,因此用前者的時候消耗資源更少,特別是在 MapControl 和 PageLayoutControl 交互的時候表現的更明顯! |
![]() |
OnBeforeScreenDraw | Fires before the Map contained by the MapControl starts to draw. |
![]() |
OnDoubleClick | Fires when the user presses and releases the mouse button twice in quick succession. |
![]() |
OnExtentUpdated 參數:e (object displayTransformation, bool sizeChanged, object newEnvelope) |
Fires after the extent (visible bounds) of the MapControl is changed. 當 MapControl 的地圖可視邊界范圍變化的時候觸發! 其中 newEnvelope 指的是 鼠標畫的區域,若是通過滾輪放大縮小,則指的是 當前屏幕的區域。 Envelope 的大小是指地圖中矩形的相對大小,當放大地圖的時候,雖然同樣是 Extent,但是 Envelope 的 Width 和 Height 屬性都會縮小,同樣的大小的矩形,隨着比例尺的大小不同,Envelope的屬性也會發生變化! |
![]() |
OnFullExtentUpdated | Fires after the full extent (bounds) of the MapControl has changed. 當地圖的覆蓋范圍變化時觸發,例如,往地圖中新增加一個圖層,其覆蓋范圍大於原圖的范圍。 |
![]() |
OnKeyDown | Fires after a key is pressed on the keyboard. |
![]() |
OnKeyUp | Fires after a pressed key is released. |
![]() |
OnMapReplaced | Fires after the Map contained by the MapControl has been replaced. 當 MapControl 的 mxd 文件替換時候觸發事件!【鷹眼】 |
![]() |
OnMouseDown |
Fires when the user presses any mouse button while over the MapControl. 在 MapControl 上面點擊鼠標上面任何一個鍵觸發事件! e.button = 1 表示 左鍵。 e.button = 2 表示 右鍵。 e.button = 4 表示 中鍵。 e.x 表示 像素橫坐標。 e.y 表示 像素縱坐標。 e.MapX 表示 地圖橫坐標。 e.MapY 表示 地圖縱坐標。 label1.Text = "MapX:" + string.Format("{0:0.00000}", e.mapX).PadLeft(10) + "°"; |
![]() |
OnMouseMove | Fires when the user moves the mouse over the MapControl. 當鼠標在 MapControl 上面漫游的時候觸發! |
![]() |
OnMouseUp | Fires when the user releases a mouse button while over the MapControl. |
![]() |
OnOleDrop | Fires when an OLE drop action occurs on the MapControl. |
![]() |
OnSelectionChanged | Fires when the current selection changes. |
![]() |
OnViewRefreshed | Fires when the view is refreshed before drawing occurs. |
---------------------------------------------------------------------------------------------------------
╔════════╗
╠════╣ 第U6個 ╠══════════════════════════════════════════════════╣
╚════════╝
●·● PageLayoutControl 類:
1. PageLayoutControl 控件主要用於頁面布局與和制圖。該控件封裝了 PageLayout 類,提供了布局視圖中控制元素的屬性和方法,以及其他的事件、屬性和方法。
- Printer 屬性提供了處理地圖打印的設置。
- Page 屬性提供了處理控件的頁面效果。
- Element 屬性則用於管理控件中的地圖元素。
- PageLayoutControl 控件不能添加地圖圖層或地理數據,必須通過使用MXD 文件來加載需要處理的數據。PageLayoutControl 控件主要實現IPageLayoutControlDefaut、IPageLayoutControl 、IPageLayoutControl2 、IPageLayoutControlevents 等接口。
---------------------------------------------------------------------------------------------------------
╔════════╗
╠════╣ 第U7個 ╠══════════════════════════════════════════════════╣
╚════════╝
●·● IPageLayoutControl 類:
1. Provides access to members that control the PageLayoutControl. Note: the IPageLayoutControl interface has been superseded byIPageLayoutControl3. Please consider using the more recent version.
The IPageLayoutControl interface is a starting point for any tasks related to the PageLayoutControl, such as setting general appearance, setting page and display properties, adding and finding elements, loading map documents, and printing.
CoClasses that implement IPageLayoutControl
CoClasses and Classes | Description |
---|---|
PageLayoutControl | ESRI PageLayoutControl |
2. 屬性和方法:
Description | ||
---|---|---|
![]() |
AboutBox | Displays a dialog of information about the PageLayoutControl. |
![]() |
ActiveView | The active view of the PageLayout contained by the PageLayoutControl. |
![]() |
AddElement | Adds the supplied element to the PageLayout, with optional geometry, symbolization, name and Z order. |
![]() |
Appearance | The appearance of the PageLayoutControl. |
![]() |
BackColor | Background color of the PageLayoutControl. |
![]() |
BorderStyle | The border style of the PageLayoutControl. |
![]() |
CenterAt | Moves the center of the PageLayoutControl to the specified location. |
![]() |
CheckMxFile | Checks the specified filename to see if it is a map document that can be loaded into the PageLayoutControl. |
![]() |
CurrentTool | Current active tool for the PageLayoutControl. Set to nothing to clear the tool. |
![]() |
Enabled | Indicates whether the PageLayoutControl can respond to user generated events. |
![]() |
Extent | Current extent of the PageLayout in page units. 此 Extent 所表示的是那個 Layout 的外框范圍,所以外框放的越大,則 Extent 越小,這里的 Extent 與 MapControl 中的 Extent 沒辦法建立聯系,因為所控制的東西不同! |
![]() |
FindElementByName | Find the first element with the supplied name, supply an occurrence parameter to find the second, third and so on. |
![]() |
FromPagePoint | Converts a point on the page (in page units) to device co-ordinates (typically pixels). |
![]() |
FullExtent | Rectangular shape that encloses the PageLayout. |
![]() |
GraphicsContainer | The graphics container of the PageLayout object contained by the PageLayoutControl. |
![]() |
hWnd | Handle to the window associated with the PageLayoutControl. |
![]() |
LoadMxFile | Loads the specified map document into the PageLayout contained by the PageLayoutControl. |
![]() |
LocateFrontElement | Locates an element at the given page co-ordinates. If more than one element is at the location the element nearest the front is returned. |
![]() |
MouseIcon | Custom mouse icon used if MousePointer is 99. |
![]() |
MousePointer | The mouse pointer displayed over the PageLayoutControl. |
![]() |
OleDropEnabled | Indicates if the PageLayoutControl will fire events when data is dragged over the control's window. |
![]() |
Page | The Page associated with the PageLayout contained by the PageLayoutControl. |
![]() |
PageLayout | The PageLayout contained by the PageLayoutControl. |
![]() |
Pan | Tracks the mouse while panning the PageLayoutControl. |
![]() |
Printer | The printer object used by the PageLayoutControl for printing. |
![]() |
PrinterPageCount | The number of printer pages the PageLayout will cover. |
![]() |
PrintPageLayout | Sends the specified range of pages on the printer. |
![]() |
Refresh | Redraws the PageLayout, optionally just redraw specified phases or envelope. |
![]() |
ToPagePoint | Converts device co-ordinates (typically pixels) to a point on the page (in page units). |
![]() |
TrackCancel | The object used by the PageLayoutControl to check if drawing has been aborted. |
![]() |
TrackRectangle | Rubber-bands a rectangle on the PageLayoutControl. |
![]() |
ZoomToWholePage | Changes the extent of the PageLayout to show a whole page. |
---------------------------------------------------------------------------------------------------------
╔════════╗
╠════╣ 第U8個 ╠══════════════════════════════════════════════════╣
╚════════╝
●·● IPageLayoutControlEvents 類:
1. Provides access to events that occur with user interaction to the PageLayoutControl.
CoClasses that implement IPageLayoutControlEvents
CoClasses and Classes | Description |
---|---|
PageLayoutControl | ESRI PageLayoutControl |
PageLayoutControlEventsListener (esriSystemUtility) | Helper coclass to provide IPageLayoutControlEvents support to the C++ API. |
2. 屬性和方法:
Description | ||
---|---|---|
![]() |
OnAfterDraw | Fires after the PageLayoutControl draws a specified view phase. |
![]() |
OnAfterScreenDraw | Fires after the PageLayout contained by the PageLayoutControl has finished drawing. |
![]() |
OnBeforeScreenDraw | Fires before the PageLayout contained by the PageLayoutControl starts to draw. |
![]() |
OnDoubleClick | Fires when the user presses and releases the mouse button twice in quick succession. |
![]() |
OnExtentUpdated | Fires after the extent (visible bounds) of the PageLayoutControl is changed. |
![]() |
OnFocusMapChanged | Fires when the current focus map in the PageLayoutControl has been switched to a new map. |
![]() |
OnFullExtentUpdated | Fires after the full extent (bounds) of the PageLayoutControl has changed. |
![]() |
OnKeyDown | Fires after a key is pressed on the keyboard. |
![]() |
OnKeyUp | Fires after a pressed key is released. |
![]() |
OnMouseDown | Fires when the user presses any mouse button while over the PageLayoutControl. |
![]() |
OnMouseMove | Fires when the user moves the mouse pointer over the PageLayoutControl. |
![]() |
OnMouseUp | Fires when the user releases a mouse button while over the PageLayoutControl. |
![]() |
OnOleDrop | Fires when an OLE drop action occurs on the PageLayoutControl. |
![]() |
OnPageLayoutReplaced | Fires after the PageLayout object used by the PageLayoutControl has been replaced. |
![]() |
OnPageSizeChanged | Fires when the Page associated with the PageLayout has had its size changed. |
![]() |
OnViewRefreshed | Fires when the view is refreshed before drawing occurs. |
---------------------------------------------------------------------------------------------------------
╔════════╗
╠════╣ 第U9個 ╠══════════════════════════════════════════════════╣
╚════════╝
●·● ToolbarControl 類:
1. ToolbarControl 包括6個對象及相關接口: ToolbarControl 、ToolbarItem 、ToolbarMenu 、CommandPool 、CustomizeDialog 、MissingCommand。ToolbarControl 要與一個"伙伴控件"協同工作。通過ToolbarControl 屬性頁設置,或者在駐留ToolbarControl 的容器被顯示時用SetBuddyControl 方法通過編程設置。
ToolbarControl 的每個"伙伴控件"都實現了 IToolbarBuddy 接口,這個接口用於設置"伙伴控件"的 CurrentTool 屬性。如通過設置 MapControl 作為其"伙伴控件",當用戶單擊該 ToolbarControl 上的"拉框放大" 工具時,該放大工具就會成為 MapControl 的 CurrentTool 。放大工具的實現過程是:通過ToolbarControl 獲取其"伙伴控件",然后在 MapControl 上提供顯示終端用戶按動鼠標所畫的框,並改變 MapControl 的顯示范圍。ToolbarControl 一般要與一個"伙伴控件"協同工作,並有一個控件命令選擇集,以便快速提供功能強大的GIS 應用程序。ToolbarControl 不僅提供了部分用戶界面,而且還提供了部分應用程序框架。ArcGIS Desktop 應用程序,如 ArcMap 、ArcGlobe 和 ArcScene 等具有強大而靈活的框架,包括諸如工具條、命令、菜單、泊靠窗口和狀態條等用戶界面組件,這些框架使終端用戶可以通過改變位置、添加利刪除這些用戶界面組 件來定制應用程序。
ArcGIS Engine 提供了幾套使用 ArcGIS 控件的命令,以便執行某種特定動作,開發人員可通過創建執行特定任務的定和l命令來擴展這套控件命令。所有的命令對象都實現了 ICommand 接口,ToolbarControl 在適當的時候要使用該接口來調用方法和訪問屬性。在命令對象被駐留到 ToolbarControl 后,就會立即調用 ICommand: :OnCreate 方法,這個方法將一個句柄(Handle) 或鈎子(hook)傳遞給該命令操作的應用程序。命令的實現一般都要經過測試,以查看該鈎子(hook)對象是否被支持.如果不支持則該鈎子自動失效,如 果支持,命令則存儲該鈎子以便以后使用。ToolbarControl 使用鈎子(hook) 來聯系命令對象和..伙伴控件",並提供了屬性、方法和事件用於管理控件的外觀,設置伙伴控件,添加、刪除命令項,設置當前工具等。 ToolbarControl 的主要接口有: IToolbarControl 、IToolbarControlDefault、IToolbarControlEvents。
(1) IToolbarControl: 該接口是任何與 ToolbarControl 有關的任務的出發點,如設置"伙伴控件"的外觀,設置伙伴控件,添加或去除命令、工具、菜單等。
(2) ITooJbarControlDefault: 該接口是自動暴露的缺省的 dispatch 接口,該接口的屬性和方法與 ToolbarControl 的最高版本主接口的屬性、方法相同。例如目前版本中的 IToolbarControlDefault 等同於 IToolbarControl .但在今后的新版本中,可能會變為 IToolbarControl2 。在開發中使用 IToolbarControlDefault 接口,能夠保證總是訪問到最新版本的ToolbarControl。
(3) IToolbarControlEvents: 該接口是一個事件接口,定義了 ToolbarControl 能夠處理的全部事件,如 OnDoubleClick、OnltemClick、OnKeyDown 等。
在ToolbarControl 上可以駐留以下3 類命令。
(1)實現了響應單擊事件的 ICommand 接口的單擊命令。用戶單擊事件, 會導致對 ICommand : :OnClick 方法的調用,並執行某種動作。通過改變ICommand: :Checked 屬性的值,簡單命令項的行為就像開關那樣。單擊命令是可以駐留在菜單中的惟一命令類型。
(2)實現了 ICommand 接口和 ITool 接口、需要終端用戶與"伙伴控件"的顯示進行交互的工具。ToolbarControl 維護 CurrentTool 屬性。當終端用戶單擊ToolbarControl 上的工具時,該工具就成為 CurrentTool。ToolbarControl 會設置"伙伴控件"的 CurrentTool 屬性。當某個工具為 CurrentTool 時,該工具會從"伙伴控件"收到鼠標和鍵盤事件。
(3)實現了 ICommand 接口和 IToolControl 接口的工具控件。這通常是用戶界面組件。ToolbarControl 駐留了來自 ItoolControl: hWnd 屬性窗口句柄提供的一個小窗口,只能向 ToolbarControl 添加特定工具控件的一個例程。
可以使用3 種方法向 ToolbarControl 添加命令,第1 種是指定唯一識別命令的一個UID ,第2 種是指定一個 progID,第3 種是給 AddToolbarDef 方法提供某個現有命令對象的一個例程。下面給出樣例代碼。
//Add a toolbardef by passing a UIO
UID uID = new UIDClass();
uID.Value = "esriControls.ControlsMapNavigationToolbar";
axToolbarControl1.AddToolbarDef(uID, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
//Add a toolbardef by passing a ProgID
string progID = "esriControls.ControlsMapNavigationToolbar";
axToolbarControl1.AddToolbarDef(progID, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
//Add a toolbardef by passing an IToolbarDef
IToolBarDef toolBarDef = new ControlsMapNavigationToolbarClass();
axToolbarControl1.AddToolbarDef(toolBarDef, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
ToolbarControl 更新命令的使用。默認情況下,ToolbarControl 每半秒鍾自動更新一次,以確保駐留在 ToolbarControl 上的每個工具條命令項的外觀與底層命令的 Enabled 、Bitmap 、Caption 等屬性同步。改變 Updatelnterval 屬性可以更改更新頻率。Updatelnterval 為0會停止任何自動發生的更新,可以通過編程調用 Update 方法以刷新每個工具條命令項的狀態。
在應用程序中首次調用 Update 方法時,ToolbarControl 會檢查每個工具條命令項的底層命令的 ICommand: :OnCreate 方法是否已經被調用過,如果還沒有調用過該方法,該 ToolbarCommand 將作為鈎子被自動傳遞給 ICommand: :OnCreate 方法。
---------------------------------------------------------------------------------------------------------
╔════════╗
╠════╣ 第Ua個 ╠══════════════════════════════════════════════════╣
╚════════╝
●·● IToolbarControl2 類:
Member:
Description | ||
---|---|---|
![]() |
AboutBox | Displays a dialog of information about the ToolbarControl. |
![]() |
AddItem | Adds an item to the ToolbarControl. 增加單個工具或是命令!或是 ToolPalette! |
![]() |
AddMenuItem | Adds a menu item to the ToolbarControl. 增加菜單項! |
![]() |
AddToolbarDef | Appends the contents of the toolbar definition, specified by Guid or ToolbarDef, to the toolbar control. |
![]() |
Appearance | The appearance of the ToolbarControl. |
![]() |
BorderStyle | The border style of the ToolbarControl. |
![]() |
Buddy | The object that will have its current tool managed by the toolbar. |
![]() |
CommandPool | The command pool used by the ToolbarControl to manage command objects. The command pool object maybe shared with other ToolbarControls and ToolbarMenus. |
![]() |
Count | The number of items on the ToolbarControl. |
![]() |
CurrentTool | The current tool of the buddy. |
![]() |
Customize | Indicates if the ToolbarControl is in customize mode. |
![]() |
CustomProperty | A property to associate data with a control. |
![]() |
Enabled | Indicates whether the ToolbarControl can respond to user generated events. |
![]() |
Find | Returns the index of the first item containing the given command, menu or palette. Returns -1 if the command is not found. |
![]() |
GetItem | Returns the item at the specified index from the ToolbarControl. |
![]() |
GetItemRect | Returns the dimensions of the item at the specified index. |
![]() |
HitTest | Returns the index of the item at the specified x and y coordinates. |
![]() |
hWnd | Handle to the window associated with the ToolbarControl. |
![]() |
ItemAppearance | The appearance of the items on the ToolbarControl. |
![]() |
KeyIntercept | A property that specifies interception of key strokes that are normally handled by the container. When intercepted the OnKeyDown and OnKeyUp events will be called. This value can be a combined bit mask of esriKeyIntercept enum values. |
![]() |
LargeIcons | Indicates if large icons are shown on all items on the ToolbarControl. |
![]() |
MenuTracking | Indicates if menu tracking is enabled on the ToolbarControl. |
![]() |
MouseIcon | Custom mouse icon used if MousePointer is 99. |
![]() |
MousePointer | The mouse pointer displayed over the ToolbarControl. |
![]() |
MoveItem | Moves an item from one index to another. |
![]() |
Object | A property that returns the underlying control. This can be used when the control is inside a wrapper object that has been added by a development environment. |
![]() |
OperationStack | The operation stack used for undo and redo functionality. If present commands can use it to store operations. |
![]() |
Remove | Removes the item at the specified index from the ToolbarControl. |
![]() |
RemoveAll | Removes all items from the ToolbarControl. |
![]() |
SetBuddyControl | Sets a control to be a buddy of the toolbar, this control must support IToolbarBuddy. |
![]() |
TextAlignment | The caption placement for all items on the ToolbarControl. |
![]() |
ToolTips | Indicates if the items tooltips are shown. |
![]() |
Update | Updates the enabled state of the specified item or all items if an index of -1 is specified. Specify fullUpdate to update the group, group spacing, style and bitmap properties. |
![]() |
UpdateInterval | The frequency in millisecs that update method is called on the ToolbarControl. |
---------------------------------------------------------------------------------------------------------
╔════════╗
╠════╣ 第Ub個 ╠══════════════════════════════════════════════════╣
╚════════╝
●·● TOCControl 類:
1. TOCControl 是用來管理圖層的可見性和標簽的編輯。TOCControl 需要一個"伙伴控件",或實現了IActiveView 接口的對象協同工作。"伙伴控件"可以是MapControl 、PageLayoutControl 、ReaderControl 、SceneControl 或GlobeControl。"伙伴控件" 可以通過TOCControl 屬性頁設置,或者在駐留TOCControl 的容器被顯示時用SetBuddyControl 方法通過編程設置。TOCControl 的每個"伙伴控件"都實現了 ITOCBuddy 接口。TOCControl 用"伙伴控
件"來顯示其地圖、圖層和符號體系內容的一個交互樹視圖,並保持其內容與"伙伴控件"同步。TOCControl 通過 ITOCBuddy 接口來訪問其"伙伴控件" 。
TOCControl 的主要接口有兩個,一個是 ITOCControl,一個是 ITOCControlEvents。ITOCControl 接口是任何與 TOCControl 有關的任務的出發點,如設置控件的外觀、設置"伙伴控件" 、管理圖層的可見性和標簽的編籍等。ITOCControlEvents 是一個事件接口,它定義了 TOCControl 能夠處理的全部事件,如OnMouseDown 、OnMouseMove 、OnMouseUp 等,這些事件在構建獨立應用程序中經常使用,如 OnBeginLabelEdit 、OnEndLabelEdit 分別是TOCControl 中的標簽開始編箱、結束編輯時觸發。
---------------------------------------------------------------------------------------------------------
╔════════╗
╠════╣ 第Uc個 ╠══════════════════════════════════════════════════╣
╚════════╝
●·● ITOCControl 接口:
1. Provides access to members that control the TOCControl. Note: the ITOCControl interface has been superseded byITOCControl2. Please consider using the more recent version.
The ITOCControl interface is a starting point for any tasks related to the TOCControl such as setting the general appearance, setting the Buddy control, and managing layer visibility and label editing.
CoClasses that implement ITOCControl
CoClasses and Classes | Description |
---|---|
TOCControl | ESRI TOCControl |
2. 屬性和方法:
Description | ||
---|---|---|
![]() |
AboutBox | Displays a dialog of information about the TOCControl. 顯示此控件的一些信息!彈出窗口! |
![]() |
ActiveView | The ActiveView used to populate the TOCControl. |
![]() |
Appearance | The appearance of the TOCControl. |
![]() |
BorderStyle | The border style of the TOCControl. |
![]() |
Buddy | The object whose ActiveView is used to populate the TOCControl. |
![]() |
CustomProperty | A property to associate data with a control. |
![]() |
Enabled | Indicates whether the TOCControl can respond to user generated events. |
![]() |
HitTest (int X, int Y, ref esriTOCControlItem ItemType, ref IBasicMap BasicMap, ref ILayer Layer, ref object Unk, ref object Data) |
Returns the item in the TOCControl at the specified coordinates. esriTOCControlItem 枚舉:返回樣式 IBasicMap:綁定 MapControl 的 IBasicMap 接口!返回地圖框架 ILayer:被點擊的圖層!返回圖層 Unk:TOCControl 的 LegendGroup 對象! Data:LegendClass 在 LegendGroup 中的 Index! private void axTOCControl1_OnMouseDown(object sender, ITOCControlEvents_OnMouseDownEvent e) { IBasicMap map = new MapClass(); ILayer layer = new FeatureLayerClass(); object other = new object(); object index = new object(); esriTOCControlItem item = new esriTOCControlItem(); axTOCControl1.HitTest(e.x, e.y, ref item, ref map, ref layer, ref other, ref index); if (e.button == 1) { ILegendClass legendClass = new LegendClassClass(); ISymbol symbol = null; if (other is ILegendGroup && (int)index != -1) //判斷存在性 { legendClass = ((ILegendGroup)other).get_Class((int)index); //獲取 legendClass symbol = legendClass.Symbol; //將自帶的樣式賦值給變量 } symbol = GetSymbolByControl(symbol); //函數通過窗口獲取 symbol legendClass.Symbol = symbol; axMapControl1.Refresh(esriViewDrawPhase.esriViewGeography, null, null); } } |
![]() |
hWnd | Handle to the window associated with the TOCControl. 返回一個 int 類型的值,唯一標示此控件,每次運行的時候生成值不同! |
![]() |
KeyIntercept | A property that specifies interception of key strokes that are normally handled by the container. When intercepted the OnKeyDown and OnKeyUp events will be called. This value can be a combined bit mask of esriKeyIntercept enum values. |
![]() |
LabelEdit | Label editing state. |
![]() |
LayerVisibilityEdit | Layer visibility editing state. |
![]() |
MouseIcon | Custom mouse icon used if MousePointer is 99. |
![]() |
MousePointer | The mouse pointer displayed over the TOCControl. |
![]() |
Object | A property that returns the underlying control. This can be used when the control is inside a wrapper object that has been added by a development environment. |
![]() |
SetActiveView | Sets the ActiveView used to populate the TOCControl. |
![]() |
SetBuddyControl | Sets a control to be a buddy of the toolbar, this control must support ITOCBuddy. |
![]() |
Update | Updates the contents of the TOCControl to match its ActiveView. |
---------------------------------------------------------------------------------------------------------
●·● ILegendGroup 接口:
1. Provides access to members that control the collection of legend classes provided by a renderer.
---------------------------------------------------------------------------------------------------------
●·● ILegendClass 接口:
1. Provides access to members that control the legend/TOC entry for a renderer class.
---------------------------------------------------------------------------------------------------------
╔════════╗
╠════╣ 第Ud個 ╠══════════════════════════════════════════════════╣
╚════════╝
●·● ITOCControlEvents 接口:
1. Provides access to events that occur with interaction to the TOCControl.
This is the main events interface for the TOCControl. Generally there is no need to explicitly set event handlers, as most development environments will automatically provide event handlers.
CoClasses that implement ITOCControlEvents
CoClasses and Classes | Description |
---|---|
TOCControl | ESRI TOCControl |
TOCControlEventsListener (esriSystemUtility) | Helper coclass to provide ITOCControlEvents support to the C++ API. |
2. 屬性和方法:
Description | ||
---|---|---|
![]() |
OnBeginLabelEdit | Fires when label editing begins. |
![]() |
OnDoubleClick | Fires when the user presses and releases the mouse button twice in quick succession. |
![]() |
OnEndLabelEdit | Fires when label editing ends. |
![]() |
OnKeyDown | Fires after a key is pressed on the keyboard. |
![]() |
OnKeyUp | Fires after a pressed key is released. |
![]() |
OnMouseDown | Fires when the user presses any mouse button while over the TOCControl. |
![]() |
OnMouseMove | Fires when the user moves the mouse pointer over the TOCControl. |
![]() |
OnMouseUp | Fires when the user releases a mouse button while over the TOCControl. |
實現 ArcMap 樣子的圖層移動:
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e) //加載地圖
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = "map document(*.mxd)|*.mxd";
ofd.ShowDialog();
axMapControl1.LoadMxFile(ofd.FileName,0,null);
TopMost = true;
}
ILayer moveLayer; //要移動的圖層!
int mdY; //記錄鼠標點擊的位置中坐標!
bool isDown = false; //記錄鼠標是否點擊了!
int index; //記錄移動到的圖層的索引!
private void axTOCControl1_OnMouseDown(object sender, ESRI.ArcGIS.Controls.ITOCControlEvents_OnMouseDownEvent e) //鼠標點擊
{
esriTOCControlItem item = esriTOCControlItem.esriTOCControlItemNone;
IBasicMap map = null;
ILayer layer = null;
object Unk = null;
object Data = null;
axTOCControl1.HitTest(e.x, e.y,ref item,ref map,ref layer,ref Unk,ref Data);
moveLayer = layer; //獲取要移動的圖層
mdY = e.y;
panel1.Visible = true;
axTOCControl1.MousePointer = esriControlsMousePointer.esriPointerLabel;
isDown = true;
}
private void axTOCControl1_OnMouseUp(object sender, ITOCControlEvents_OnMouseUpEvent e) //鼠標松開
{
panel1.Visible = false;
axTOCControl1.MousePointer = esriControlsMousePointer.esriPointerDefault;
isDown = false;
esriTOCControlItem item = esriTOCControlItem.esriTOCControlItemNone;
IBasicMap map = null;
ILayer layer = null;
object Unk = null;
object Data = null;
axTOCControl1.HitTest(e.x, e.y, ref item, ref map, ref layer, ref Unk, ref Data);
IMap pMap = axMapControl1.ActiveView.FocusMap;
if (moveLayer != layer) //要是不是同一圖層則實行移動
{
for (int i = 0; i < pMap.LayerCount;i++ )
{
if (layer == pMap.get_Layer(i))
{
index = i; //獲取移動到圖層的索引
}
}
pMap.MoveLayer(moveLayer, index);
}
axTOCControl1.Refresh();
}
private void axTOCControl1_OnMouseMove(object sender, ITOCControlEvents_OnMouseMoveEvent e) //鼠標移動
{
esriTOCControlItem item = esriTOCControlItem.esriTOCControlItemNone;
IBasicMap map = null;
ILayer layer = null;
object Unk = null;
object Data = null;
axTOCControl1.HitTest(e.x, e.y, ref item, ref map, ref layer, ref Unk, ref Data);
IMap pMap = axMapControl1.ActiveView.FocusMap;
if (e.y > mdY) //往下移動的時候,要插入到圖層的下面
{
for (int i = 0; i < pMap.LayerCount;i++ )
{
if (layer == pMap.get_Layer(0))
panel1.Location = new System.Drawing.Point(50, 67);
else if (layer == pMap.get_Layer(1))
panel1.Location = new System.Drawing.Point(50, 103);
else if (layer == pMap.get_Layer(2))
panel1.Location = new System.Drawing.Point(50, 139);
else if (layer == pMap.get_Layer(3))
panel1.Location = new System.Drawing.Point(50, 175);
}
}
else //往上移動的時候,要插入到圖層的上面
{
for (int i = 0; i < pMap.LayerCount; i++)
{
if (layer == pMap.get_Layer(0))
panel1.Location = new System.Drawing.Point(50, 31);
else if (layer == pMap.get_Layer(1))
panel1.Location = new System.Drawing.Point(50, 67);
else if (layer == pMap.get_Layer(2))
panel1.Location = new System.Drawing.Point(50, 103);
else if (layer == pMap.get_Layer(3))
panel1.Location = new System.Drawing.Point(50, 139);
}
}
if (isDown) //若處於鼠標點擊狀態,只有鼠標點擊的時候才發生,普通狀態不發生!
{
if (layer == moveLayer || (moveLayer == pMap.get_Layer(0) && e.y <= 31) || (moveLayer == pMap.get_Layer(3) && e.y >= 139))
{
axTOCControl1.MousePointer = esriControlsMousePointer.esriPointerNoDrop;
panel1.Visible = false;
}
else
{
axTOCControl1.MousePointer = esriControlsMousePointer.esriPointerLabel;
panel1.Visible = true;
}
}
}
}
---------------------------------------------------------------------------------------------------------
╔════════╗
╠════╣ 第Ue個 ╠══════════════════════════════════════════════════╣
╚════════╝
●·● IHookHelper 接口:
可以實現控件之間的關聯,傳過去的 hook 會接收操作!
參考:http://gisfire.blog.163.com/blog/static/139077132201211942026566/
---------------------------------------------------------------------------------------------------------
╔════════╗
╠════╣ 第Uf 個 ╠══════════════════════════════════════════════════╣
╚════════╝
●·● SymbologyControl 類:
---------------------------------------------------------------------------------------------------------
╔════════╗
╠════╣ 第Ug個 ╠══════════════════════════════════════════════════╣
╚════════╝
●·● ISymbologyControl 接口:
1. Provides access to members that control the SymbologyControl.
The ISymbologyControl interface is a starting point for any tasks related to the SymbologyControl, such as setting general appearance, loading symbology from within server style files and setting the style class.
CoClasses that implement ISymbologyControl
CoClasses and Classes | Description |
---|---|
SymbologyControl | Provides access to the ESRI SymbologyControl. |
2. 屬性和方法:
Description | ||
---|---|---|
![]() |
AboutBox | Displays a dialog of information about the SymbologyControl. |
![]() |
Appearance | The appearance of the SymbologyControl. |
![]() |
BackColor | Background color of the SymbologyControl. |
![]() |
BorderStyle | The border style of the SymbologyControl. |
![]() |
Clear | Clears all symbols and files from the SymbologyControl. |
![]() |
CustomProperty | A property to associate data with the SymbologyControl. |
![]() |
DisplayStyle | The display style of the SymbologyControl. |
![]() |
Enabled | Indicates whether the SymbologyControl can respond to user generated events. |
![]() |
GetStyleClass (esriSymbologyStyleClass StyleClass) 返回值:ISymbologyStyleClass |
Returns the specified style class from the SymbologyControl. 指定默認選擇的符號樣式! esriSymbologyStyleClass 枚舉:各種樣式的集合,包括 Shadow、NorthArrow、ScaleBars 等! string strInstall = ESRI.ArcGIS.RuntimeManager.ActiveRuntime.Path; //獲取 Engine 的安裝目錄 string style = strInstall + @"Styles\ESRI.ServerStyle"; //獲取 ESRI 符號的文件 if (System.IO.File.Exists(style)) { axSymbologyControl1.LoadStyleFile(style); //加載樣式 axSymbologyControl1.StyleClass = esriSymbologyStyleClass.esriStyleClassNorthArrows; //獲取顯示的符號類型 |
![]() |
HitTest | Returns the item at the specified x and y coordinates. |
![]() |
hWnd | Handle to the window associated with the SymbologyControl. |
![]() |
KeyIntercept | A property that specifies interception of key strokes that are normally handled by the container. When intercepted the OnKeyDown and OnKeyUp events will be called. This value can be a combined bit mask of esriKeyIntercept enum values. |
![]() |
LoadDesktopStyleFile | Loads a desktop style file into the SymbologyControl. 加載擴展名為 .style 的文件! |
![]() |
LoadStyleFile (string fileName) |
Loads a server style file into the SymbologyControl. 加載擴展名為 .ServerStyle 的文件! //直接插入地址調入: |
![]() |
MouseIcon | Custom mouse icon used if MousePointer is 99. |
![]() |
MousePointer | The mouse pointer displayed over the SymbologyControl. |
![]() |
Object | A property that returns the underlying control. This can be used when the control is inside a wrapper object that has been added by a development environment. |
![]() |
RemoveFile | Removes a file from the SymbologyControl. |
![]() |
ShowContextMenu | Indicates if the SymbologyControl displays a context menu. |
![]() |
StyleClass 返回值:esriSymbologyStyleClass |
The style class used by the SymbologyControl. 用來獲取 SymbologyControl 的符號內容! axSymbologyControl1.StyleClass = esriSymbologyStyleClass.esriStyleClassBorders;
|
---------------------------------------------------------------------------------------------------------
●·● ISymbologyStyleClass 接口:
1. Provides access to members that control SymbologyControl style classes.
Members
Description | ||
---|---|---|
![]() |
AddItem | Adds an item to the SymbologyStyleClass. |
![]() |
GetItem | Returns the item at the specified index in the SymbologyStyleClass. |
![]() |
GetSelectedItem | Returns the selected item in the SymbologyStyleClass. |
![]() |
ItemCount | The number of items in the SymbologyStyleClass. |
![]() |
PreviewItem (IStyleGalleryItem item, int Width, int Height) 返回值:IPictureDisp |
Previews the specified item as a bitmap.
ISymbologyStyleClass symbologyStyleClass =
axSymbologyControl1.GetStyleClass(axSymbologyControl1.StyleClass);
//
Preview an image of the symbol stdole.IPictureDisp picture =
symbologyStyleClass.PreviewItem(m_styleGalleryItem, pictureBox1.Width, pictureBox1.Height); System.Drawing.Image image = System.Drawing.Image.FromHbitmap(
new
System.IntPtr(picture.Handle)); pictureBox1.Image = image;
|
![]() |
RemoveAll | Removes all items from the SymbologyStyleClass. |
![]() |
RemoveItem | Removes the item at the specified index from the SymbologyStyleClass. |
![]() |
SelectItem | Sets the selected item in the SymbologyStyleClass. |
![]() |
SortDirection | The sort direction of the items in the SymbologyStyleClass. |
![]() |
StyleCategory | The style category used by the SymbologyStyleClass. |
![]() |
StyleClass | The class of the symbols in the SymbologyStyleClass. |
![]() |
UnselectItem | Unsets the selected item in the SymbologyStyleClass. |
![]() |
Update | Updates the contents of the SymbologyStyleClass. |
---------------------------------------------------------------------------------------------------------
●·● IStyleGalleryItem 接口:
1. Provides access to members that define items in the Style Gallery.
Symbols and map elements are stored in the Style Gallery. Each symbol or map element has a unique ID that can be read from the item within the style gallery. A Name and Category are also properties of the items within the style gallery. These two fields, along with the Item itself, can be updated and changed as necessary.
Members
Description | ||
---|---|---|
![]() |
Category | The category of the item. |
![]() |
ID | Id for the item in the Style Gallery. |
![]() |
Item | The symbol or map element to be stored in the Style Gallery item. |
![]() |
Name | The name of the item in the Style Gallery. |
---------------------------------------------------------------------------------------------------------
╔════════╗
╠════╣ 第Uh個 ╠══════════════════════════════════════════════════╣
╚════════╝
●·● ISymbologyControlEvents 接口:
1. Provides access to events that occur with interaction to the SymbologyControl.
This is the main events interface for the SymbologyControl. Generally there is no need to explicitly set event handlers, as most development environments will automatically provide event handlers.
2. 屬性和方法:
Description | ||
---|---|---|
![]() |
OnDoubleClick | Fires when the user presses and releases the mouse button twice in quick succession. |
![]() |
OnItemSelected | Fires when an item is selected in the SymbologyControl. 當選中某個選項的時候觸發事件! e.styleGalleryItem 獲取選項的樣式 IStyleGalleryItem styleGalleryItem = (IStyleGalleryItem)e.styleGalleryItem; |
![]() |
OnKeyDown | Fires after a key is pressed on the keyboard. |
![]() |
OnKeyUp | Fires after a pressed key is released. |
![]() |
OnMouseDown | Fires when the user presses any mouse button while over the SymbologyControl. |
![]() |
OnMouseMove | Fires when the user moves the mouse pointer over the SymbologyControl. |
![]() |
OnMouseUp | Fires when the user releases a mouse button while over the SymbologyControl. |
![]() |
OnStyleClassChanged | Fires when the style class changes. |
--------------------------------------------------------------------------------------------------------
╔════════╗
╠════╣ 第Ui 個 ╠══════════════════════════════════════════════════╣
╚════════╝
●·● GlobeControl 類:
1. GlobeControl 是一個高性能的嵌入式的開發組件,提供給開發者建立和擴展ArcGlobe 程序,當然也提供了基於ArcGlobe TM 的功能給用戶,以便進行繪圖等操作。GlobeControl 顯示3D 視圖,並能提供全球表現的位置,而且是基於3D數據。GlobeControl 控件對應於ArcGlobe 桌面應用程序的三維視圖。GlobeControl 封裝了G10beViewer 對象, 可以加載ArcGlobe 應用程序創作的Globe文擋。
GlobeControl 也是單一的開發進程, 並且提供了粗粒度ArcEngine 組件對象,當然也提供了強大紋理着色的ArcEngine 組件。GlobeControl 通過對象接口來操作IGlobe 視圖,用戶可以通過IGlobeViewer 對象來操作ArcGlobe 應用程序。IGlobeViewer 接象包含一個GlobeDisplay,GlobeDisplay 又包含一個Globe。GlobeControl 提供了經常使用的屬性和方法, 例如,GlobeControl 有 GlobeCamera 、Globe 、GlobeDisplay 和 GlobeViewer 等屬性, 當然GlobeControl 也能執行一些方法或任務,例如, GlobeControl 有Load3dFile 方法用於導人globe 文檔。GlobeControl 是進行三維開發最基本的控件,因為其提供了用戶界面,所以更容易進行開發,當然使用對象模型也能很容易地理解及開發三維功能。
---------------------------------------------------------------------------------------------------------
╔════════╗
╠════╣ 第Uj 個 ╠══════════════════════════════════════════════════╣
╚════════╝
●·● SceneControl 類:
1. SceneControl 是一個高性能的嵌入式的開發組件,提供給開發者建立和擴展Scene 程序,當然也提供了基於ArcScene的功能給用戶,以便進行繪圖等操作。控件SceneControl 相當於ArcScene Desktop 應用程序中的3D視圖, 並且提供了顯示和增加空間數據到3D 的方法等。
SceneControl 是單一的開發進程,並且提供了粗粒度ArcEngine 組件對象,也提供了強大紋理着色的功能。SceneControl 通過對象接口ISceneViewer 來表現。ISceneViewer 接口提供了一個Camera 對象, 該對象囪視角( Observer ) 和目標( Target ) 構成。SceneControl 控件提供一些屬性和方法鐮作三維對象。例如. Camera 、Scene 、SceneGraph 和SceneViewer 等屬性。LoadSxFile方法, 用於導人sωne 文擋。SceneControl 是進行三維開發最基本的控件。
---------------------------------------------------------------------------------------------------------
╔════════╗
╠════╣ 第Uk個 ╠══════════════════════════════════════════════════╣
╚════════╝
●·● esriControlsMousePointer 類:
1.
esriTOCControlItem