【024】◀▶ ArcObjects 類庫(一)


ArcObjects 類庫(一)

---------------------------------------------------------------------------------------------------------

●·● 目錄:

O0 ………… 在線幫助 & 本地幫助
  OMD(對象模型圖)


Geodatabase 命名空間

A1 ………… IWorkspaceFactory 接口
A2 ………… IWorkspace 接口
       IFeatureWorkspace 接口
       IWorkspaceEdit 接口
A3 ………… IFeatureClass 接口
A4 ………… IFeatureCursor 接口
A5 ………… IFeature 接口
A6 ………… IField 接口
                   IFieldEdit 接口
A7 ………… IFields 接口
                   IFieldsEdit 接口
A8 ………… IQueryFilter 接口
A9 ………… IGeoDataset 接口
Aa ………… IDataset 接口


Carto 命名空間

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 接口


Controls 命名空間

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

※ 參考:關於接口的理解

※ 參考:Arcgis Engine -- 接口編程思想

View Code
        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
Method ContainsWorkspace Indicates if parentDirectory contains a valid workspace, or is a valid file-system workspace.
Method Copy Copies a workspace to the specified destination folder.
Method Create Creates a new workspace specified by the directory, file name, and connection properties.
Method GetClassID The class ID of the WorkspaceFactory.
Method GetWorkspaceName Retrieves the workspace name of a workspace from the given list of file names.
Method IsWorkspace True if the specified file identifies a workspace supported by the workspace factory.
Method Move Moves a workspace to the specified destination folder.
Method Open Opens the workspace specified by the connection properties.
Method OpenFromFile
(string fileName, int hWnd)
返回值:IWorkspace
Opens the workspace specified by the given file name.
參考:http://www.gisvip.com/blog/?action-viewthread-tid-2400
Method ReadConnectionPropertiesFromFile The connection properties from the specified file.
Read-only property WorkspaceDescription A singular or plural description of the type of workspace the workspace factory opens/creates.
Read-only property 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
Read-only property ConnectionProperties The connection properties of the workspace.
Read-only property DatasetNames The DatasetNames in the workspace.
Read-only property Datasets The datasets in the workspace.
Method ExecuteSQL Executes the specified SQL statement.
Method Exists Checks if the workspace exists.
Method IsDirectory TRUE if the workspace is a file system directory.
Read-only property PathName The file system full path of the workspace.
Read-only property Type The Type of the Workspace.
Read-only property 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
Method 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
第五個參數:要素類型
第六個參數:圖形列的名稱
第七個參數:""
Method CreateFeatureDataset Creates a new feature dataset.
Method CreateQueryDef Create a query definition object.
Method CreateRelationshipClass Creates a new relationship class.
Method CreateTable Creates a new table.
Method OpenFeatureClass
(string Name)
返回值:IFeatureClass
Opens an existing feature class.
返回指定文件名的 FeatureClass。
Method OpenFeatureDataset Opens an existing feature dataset.
Method OpenFeatureQuery Opens a feature dataset containing a single feature class defined by the specified Query.
Method OpenRelationshipClass Opens an existing relationship class.
Method OpenRelationshipQuery The table of a relationship join query.
Method 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
Method AbortEditOperation Aborts an edit operation.
Method DisableUndoRedo Disables Undo and Redo of edit operations.
Method EnableUndoRedo Enables Undo and Redo of edit operations.
Method HasEdits True if there are any completed edit operations that need to be saved .
Method HasRedos True if there are any completed undos that can be redone.
Method HasUndos True if there are any completed edit operations that can be undone.
Method IsBeingEdited True if the workspace is being edited.
Method RedoEditOperation Causes a Redo to be performed on the last undo.
Method StartEditing Starts editing the workspace.
Method StartEditOperation Begins an edit operation.
Method StopEditing Stops editing the workspace.
Method StopEditOperation Ends an edit operation.
Method 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
Method AddField Adds a field to this object class.
Method AddIndex Adds an index to this object class.
Read-only property AliasName The alias name of the object class.
Read-only property AreaField The geometry area field.
Read-only property CLSID The GUID for the COM Class (CoClass) corresponding to instances of this object class.
Method CreateFeature
返回值:IFeature
Create a new feature, with a system assigned object ID and null property values.
Method CreateFeatureBuffer Create a feature buffer that can be used with an insert cursor.
Method DeleteField Deletes a field from this object class.
Method DeleteIndex Deletes an index from this object class.
Read-only property EXTCLSID The GUID for the COM Class (CoClass) corresponding to the class extension for this object class.
Read-only property Extension The extension for this object class.
Read-only property ExtensionProperties The extension properties for this object class.
Read-only property FeatureClassID The unique ID for the Feature Class.
Method FeatureCount
(IQueryFilter QueryFilter)
The number of features selected by the specified query.
若是null,則選擇全部~
Read-only property FeatureDataset The feature dataset that contains the feature class.
Read-only property FeatureType The type of features in this feature class.
Read-only property Fields The fields collection for this object class.
Method FindField The index of the field with the specified name.
Method GetFeature
(int ID)
Get the feature with the specified object ID.
通過獲取 FID 列的值來獲取 IFeature!!!
Method GetFeatures Get a cursor of Rows given a set of object ids.
Read-only property HasOID Indicates if the class has an object identity (OID) field.
Read-only property Indexes The indexes collection for this object class.
Method Insert Returns a cursor that can be used to insert new features.
Read-only property LengthField The geometry length field.
Read-only property ObjectClassID The unique ID for the object class.
Read-only property OIDFieldName The name of the field corresponding to the OID.
Read-only property RelationshipClasses The relationship classes in which this object class participates in for the specified role.
Method Search
(IQueryFilter filter, bool Recycling)
Returns an object cursor that can be used to fetch feature objects selected by the specified query.
Method Select Returns a selection That contains the object ids selected by the specified query.
Read-only property ShapeFieldName The name of the default sShape field.
Read-only property ShapeType The type of the default Shape for the features in this feature class.
Method 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
Method DeleteFeature Delete the existing Feature in the database corresponding to the current position of the cursor.
Read-only property Fields The fields Collection for this cursor.
Method FindField The index of the field with the specified name.
Method Flush Flush any outstanding buffered writes to the database.
Method InsertFeature Insert a new Feature into the database using the property values in the input buffer. The ID of the new Feature is returned.
Method NextFeature Advance the position of the cursor by one and return the Feature object at that position.
Method 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
Read-only property Class The Object Class for the row.
Method Delete Deletes the row.
Read-only property Extent The extent of the feature.
Read-only property FeatureType The type of the feature.
Read-only property Fields The fields Collection for this row buffer.
Read-only property HasOID Indicates if the row has an OID.
Read-only property OID The OID for the row.
Read/write property Shape
返回值:IGeometry
A reference to the default shape for the feature.
Read-only property ShapeCopy
返回值:IGeometry
A cloned copy of the default shape for the feature.
與上面的Shape,在我看來沒有什么大的區別,可以獲得要素的幾何形體,以至於其envelope!
Method Store Stores the row.
Read-only property Table The Table for the row.
Read/write property 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
Read-only property AliasName The alias name of the field.
Method CheckValue Indicates if the value is valid given the field definition.
Read-only property DefaultValue The default value of the field.
Read-only property Domain The default domain of the field.
Read-only property DomainFixed Indicates if the field's domain is fixed.
Read-only property Editable Indicates if the field is editable.
Read-only property GeometryDef The geometry definition for the field if IsGeometry is TRUE.
Read-only property IsNullable Indicates if the field can contain null values.
Read-only property Length The maximum length, in bytes, for values described by the field.
Read-only property Name The name of the field.
Read-only property Precision The precision for field values.
Read-only property Required Indicates if the field is required.
Read-only property Scale The scale for field values.
Read-only property Type
返回值:esriFieldType
The type of the field.
esriFieldType 枚舉:int、long、Geometry、OID等
Read-only property 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
Read-only property AliasName The alias name of the field.
Write-only property AliasName The alias name of the field.
Method CheckValue Indicates if the value is valid given the field definition.
Read-only property DefaultValue The default value of the field.
Write-only property DefaultValue The default value of the field.
Read-only property Domain The default domain of the field.
Write-only property Domain The default domain of the field.
Write-only property DomainFixed Indicates if the field's domain cannot be modified.
Read-only property DomainFixed Indicates if the field's domain is fixed.
Write-only property Editable Indicates if the field can be edited. This should always be set to true.
Read-only property Editable Indicates if the field is editable.
Read-only property GeometryDef The geometry definition for the field if IsGeometry is TRUE.
Write-only property GeometryDef The geometry definition if IsGeometry is TRUE.
Write-only property IsNullable Indicates if field values can be null.
Read-only property IsNullable Indicates if the field can contain null values.
Write-only property Length The maximum length, in bytes, for field values.
Read-only property Length The maximum length, in bytes, for values described by the field.
Read-only property Name The name of the field.
Write-only property Name The name of the field.
Read-only property Precision The precision for field values.
Write-only property Precision The precision for field values.
Read/write property RasterDef The raster column definition.
Read-only property Required Indicates if the field is required.
Write-only property Required Indicates if the field is required.
Read-only property Scale The scale for field values.
Write-only property Scale The scale for field values.
Write-only property Type The type for the field.
Read-only property Type The type of the field.
Read-only property 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
Read-only property Field The field at the specified index in the fields collection.
Read-only property FieldCount The number of fields in the fields collection.
Method FindField Finds the index of the named field in the fields collection.
Method 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
Method AddField Add a field to the fields collection.
Method DeleteAllFields Delete all the fields from the fields collection.
Method DeleteField Delete a field from the fields collection.
Read-only property Field The field at the specified index in the fields collection.
Write-only property Field The field at the specified position.
Read-only property FieldCount The number of fields in the fields collection.
Write-only property FieldCount The Number of fields in this field collection.
Method FindField Finds the index of the named field in the fields collection.
Method 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
Method AddField Appends a single field name to the list of sub-fields.
Read/write property OutputSpatialReference The spatial reference in which to output geometry for a given field.
Read/write property SubFields The comma delimited list of field names for the filter.
Read/write property WhereClause The where clause for the filter
定義查詢的語句。

---------------------------------------------------------------------------------------------------------

            ╔════════╗
╠════╣    第A9個    ╠══════════════════════════════════════════════════╣
            ╚════════╝

●·● IGeoDataset 接口

  Members

    Description
Read-only property Extent The extent of the GeoDataset.
相當於 FullExtent 的作用!
Read-only property SpatialReference The spatial reference of the GeoDataset.

IFeatureLayer:對圖層縮放顯示!

---------------------------------------------------------------------------------------------------------

            ╔════════╗
╠════╣    第Aa個    ╠══════════════════════════════════════════════════╣
            ╚════════╝

●·● IDataset 接口

1. Provides access to members that supply dataset information.

  Members

    Description
Read/write property BrowseName The browse name of the dataset.
Method CanCopy True if this dataset can be copied.
Method CanDelete True if this dataset can be deleted.
Method CanRename True if this dataset can be renamed.
Read-only property Category The category of the dataset.
Method Copy Copies this dataset to a new dataset with the specified name.
Method Delete Deletes this dataset.
Read-only property FullName The associated name object.
Read-only property Name The name of the Dataset.
Read-only property PropertySet The set of properties for the dataset.
Method Rename Renames this Dataset.
Read-only property Subsets Datasets contained within this dataset.
Read-only property Type The type of the Dataset.
Read-only property 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
Read-only property AreaOfInterest The default area of interest for the layer.
Read/write property Cached Indicates if the layer needs its own display cache.
Method Draw Draws the layer to the specified display for the given draw phase.
Read/write property MaximumScale Maximum scale (representative fraction) at which the layer will display.
Read/write property MinimumScale Minimum scale (representative fraction) at which the layer will display.
Read/write property Name Layer name.
Read/write property ShowTips Indicates if the layer shows map tips.
Write-only property SpatialReference Spatial reference for the layer.
Read-only property SupportedDrawPhases Supported draw phases.
Read-only property TipText Map tip text at the specified location.
Read-only property Valid Indicates if the layer is currently valid.
Read/write property 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
Read-only property AreaOfInterest The default area of interest for the layer.
Read/write property Cached Indicates if the layer needs its own display cache.
Read/write property DataSourceType Data source type.
Read/write property DisplayField Primary display field.
Method Draw Draws the layer to the specified display for the given draw phase.
Read/write property FeatureClass The layer's feature class. 獲取要素類!
Read/write property MaximumScale Maximum scale (representative fraction) at which the layer will display.
Read/write property MinimumScale Minimum scale (representative fraction) at which the layer will display.
Read/write property Name Layer name. 顯示在TOC上的名稱。
Read/write property ScaleSymbols Indicates if symbols are scaled for the layer.
Method Search Creates a cursor based upon the search criteria.
Read/write property Selectable Indicates if layer is selectable.
在框選的時候,該層的要素是否可以被選中!
Read/write property ShowTips Indicates if the layer shows map tips.
Write-only property SpatialReference Spatial reference for the layer.
Read-only property SupportedDrawPhases Supported draw phases.
Read-only property TipText Map tip text at the specified location.
Read-only property Valid Indicates if the layer is currently valid.
Read/write property 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
Read/write property ActiveGraphicsLayer The active graphics layer. If no graphic layers exist a basic memory graphics layer will be created.
Method AddLayer Adds a layer to the map.
Method AddLayers Adds multiple layers to the map, arranging them nicely if specified.
Method AddMapSurround Adds a map surround to the map.
Read/write property AnnotationEngine The annotation (label) engine the map will use.
Write-only property AreaOfInterest Area of interest for the map.
Read-only property Barriers The list of barriers and their weight for labeling.
Read-only property BasicGraphicsLayer The basic graphics layer.
Method ClearLayers Removes all layers from the map.
Method ClearMapSurrounds Removes all map surrounds from the map.
Method ClearSelection Clears the map selection.
Read/write property ClipBorder An optional border drawn around ClipGeometry.
Read/write property ClipGeometry A shape that layers in the map are clipped to.
Method ComputeDistance Computes the distance between two points on the map and returns the result.
Method CreateMapSurround Create and initialize a map surround. An optional style from the style gallery may be specified.
Method DelayDrawing Suspends drawing.
Method DelayEvents Used to batch operations together to minimize notifications.
Method DeleteLayer Deletes a layer from the map.
Method DeleteMapSurround Deletes a map surround from the map.
Read/write property Description Description of the map.
Read/write property DistanceUnits The distance units for the map.
Read/write property Expanded Indicates if the Map is expanded.
Read/write property FeatureSelection The feature selection for the map.
Method GetPageSize Gets the page size for the map.
Read/write property IsFramed Indicates if map is drawn in a frame rather than on the whole window.
Read-only property Layer The layer at the given index.
Read-only property LayerCount Number of layers in the map.
Read-only property Layers The layers in the map of the type specified in the uid. If recursive is true it will return layers in group layers.
Read/write property MapScale The scale of the map as a representative fraction.
設置和獲取當前地圖比例尺的屬性。
Read-only property MapSurround The map surround at the given index.
Read-only property MapSurroundCount Number of map surrounds associated with the map.
Read/write property MapUnits The units for the map.
Method MoveLayer Moves a layer to another position.
Read/write property Name Name of the map.
Method RecalcFullExtent Forces the full extent to be recalculated.
Read/write property ReferenceScale The reference scale of the map as a representative fraction.
設置參考比例尺,若為“0”,則取消參考比例尺!
Method 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);
axMapControl1.Refresh(esriViewDrawPhase.esriViewGeoSelection, null , null);
//esriViewDrawPhase.esriViewGeoSelection刷新選區
Method 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();
}
Read-only property SelectionCount Number of selected features.
Method SetPageSize Sets the page size for the map (optional).
Read/write property SpatialReference The spatial reference of the map.
Read/write property SpatialReferenceLocked Indicates whether the spatial reference is prevented from being changed.
Read/write property 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
Read-only property ActiveView The ActiveView of the map document.
Method Close Close the map document.
Read-only property DocumentFilename The map document filename that the MapDocument coclass is linked to.
Read-only property DocumentType The type of map document currently loaded in the object.
Read-only property DocumentVersion Indicates if the version of the map document is compatible with the current version of software.
Method GetVersionInfo Retrieve the detailed version information of the map document.
Read-only property IsMapDocument Indicates if the map document is a valid map document.
Read-only property IsPasswordProtected Indicates if the map document is protected by a passsword.
Read-only property IsPresent Indicates if the map document is present.
Read-only property IsReadOnly Indicates if the map document is read only.
Read-only property IsRestricted Indicates if the use of the map document is restricted to certain applications.
Read-only property Layer The Layer object at the specified index for the specified map.
Read-only property Map
屬性:Map [int mapIndex]
方法:get_Map (int mapIndex)
指不同的數據框,每一個數據框相當於一個 Map 。

The Map object at the specified index.
axMapControl1.Map = mapDocument.Map[i];
axMapControl1.Map = mapDocument.get_Map(i);
Read-only property MapCount The number of Map objects contained within the map document.
數據框的個數,也就是 Map 的個數。
Method New Creates and opens a new map document in preparation for the contents to be retrieve or updated.
Method Open
(string sDocument, string bsPassword)
Open the map document in preparation for the contents to be retrieve or updated.
mapDocument.Open(ofd.FileName, "");
Read-only property PageLayout The PageLayout object.
Read-only property Printer The printer object. If no printer object is stored in the map document this returns NULL.
Method ReplaceContents Replace the contents of the map document.
Method Save
(bool bUseRelativePaths, bool bCreateThumnbail)
Save the contents of the map document to the bound file.
mapDocument.Save(true, true);
Method 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);
Method SetActiveView Set the ActiveView content of the map document.
Read-only property Thumbnail The thumbnail stored in the map document. If this is empty E_FAIL is returned.
Read-only property 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
Method AddElement
(IElement Element, int zorder)
Add a new graphic element to the layer.
zorder 大部分時候賦值為0.
Method AddElements Add new graphic elements to the layer.
Method BringForward Move the specified elements one step closer to the top of the stack of elements.
Method BringToFront Make the specified elements draw in front of all other elements.
Method DeleteAllElements Delete all the elements.
刪除地圖上面的所有臨時圖形元素!
Method DeleteElement
(IElement Element)
Delete the given element.
Method FindFrame
(object frameObject)
Find the frame that contains the specified object.
IFrameProperties frameProperties = (IFrameProperties)axPageLayoutControl1.GraphicsContainer.FindFrame(axPageLayoutControl1.ActiveView.FocusMap);
Method GetElementOrder Private order object. Used to undo ordering operations.
Method LocateElements Returns the elements at the given coordinate.
Method LocateElementsByEnvelope Returns the elements inside the given envelope.
Method MoveElementFromGroup Move the element from the group to the container.
Method MoveElementToGroup Move the element from the container to the group.
Method Next Returns the next graphic in the container.
Method PutElementOrder Private order object. Used to undo ordering operations.
Method Reset Reset internal cursor so that Next returns the first element.
Method SendBackward Move the specified elements one step closer to the bottom of the stack of elements.
Method SendToBack Make the specified elements draw behind all other elements.
Method 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
Method Activate Gives this view control of the specified window.
Method Clear Empties the view contents.
Method ContentsChanged Called by clients when view objects are modified.
Method Deactivate Another view takes over the associated window.
Method Draw Draws the view to the specified device context.
Read-only property ExportFrame The device rectangle to export.
Read/write property Extent The visible extent rectangle.
Read-only property ExtentStack The extent stack.
Read/write property FocusMap The map that tools and controls act on.
Read/write property FullExtent The full extent rectangle.
Method GetContextMenu Called when a context menu should be displayed at the given xy location. Return menu that should be displayed.
Read-only property GraphicsContainer The active graphics container.
Method 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.
Method IsActive Indicates if view is active or not.
Read/write property IsMapActivated Indicates if the focus map is activated.
Method OnMessage Call from your application's message loop to enable automatic resizing and keyboard accelerators.
Method Output Renders the view to the specified DC.
Method 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);
Method PrinterChanged Called by application when printer changes.
Method Refresh Causes the entire view to draw.
Read-only property ScreenCacheID The screen cache ID that is used to draw the specified phase.
Read-only property ScreenDisplay
返回值:IScreenDisplay
The screen display used by the view.
Read/write property Selection The selection.
Read/write property ShowRulers Indicates if rulers are visible.
Read/write property ShowScrollBars Indicates if scrollbars are visible.
Read/write property ShowSelection Indicates if selection is visible.
Read-only property 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
Read/write property 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
Method Activate Prepare to display graphic on screen.
Method Deactivate ActiveView that graphics are displayed on is no longer visible.
Method Draw Draws the element into the given display object.
Read/write property Geometry Shape of the element as a geometry.
Method HitTest Indicates if the given x and y coordinates are contained by the element.
Read/write property Locked Indicates if the element is in a read-only state.
Method QueryBounds Bounds of the element taking symbology into consideration.
Method QueryOutline Bounds of the element taking symbology into consideration.
Read-only property 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
Read/write property Background Frame background used by this element.
Read/write property Border Frame border used by this element.
Read/write property 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
Method AddLocatorRectangle Add a new locator rectangle to the data frame.
Read/write property Background Frame background used by this element.
Read/write property Border Frame border used by this element.
Read/write property Container The frame's container.
Method CreateSurroundFrame Returns the map surround frame element of the type given in clsid. An optional style object may be specified.
Read/write property DraftMode Indicates if this element is in draft mode, i.e., draws fast.
Read/write property ExtentType The way in which the map extent of the frame is specified.
Method LocatorRectangle Returns the locator rectangle at the specified index.
Read-only property LocatorRectangleCount The number of locator rectangles.
Read/write property Map The associated map.
Read/write property MapBounds The bounds of the map displayed by the frame.
Read/write property MapScale The scale at which the map should be displayed.
Read-only property Object Object framed by this element.
Method RemoveAllLocatorRectangles Remove all the locator rectangles from the data frame.
Method RemoveLocatorRectangle Remove a locator rectangle from the data frame.
Read-only property 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
Read/write property Border The map grid border.
Method Draw Draws the map grid for a map frame to the given display.
Read-only property ExteriorWidth The width (in display units) of the portion of the grid that is outside of the frame.
Method GenerateGraphics Generates graphic elements corresponding to the grid lines and stores them in the specified graphics container.
Read/write property LabelFormat The label format for map grid labels.
Read/write property LineSymbol The symbol used to draw grid lines - null will draw no lines.
Read/write property Name The name of the map grid.
Method PrepareForOutput Prepares the map grid for output to a device.
Method QueryLabelVisibility Returns the visibility of the labels along all four sides of the map grid.
Method QuerySubTickVisibility Returns the visibility of the subticks along all four sides of the map grid.
Method QueryTickVisibility Returns the visibility of the ticks along all four sides of the map grid.
Method SetDefaults Sets the properties of the map grid to default values.
Method SetLabelVisibility Sets the visibility of the labels along all four sides of the map grid.
Method SetSubTickVisibility Sets the visibility of the subticks along all four sides of the map grid.
Method SetTickVisibility Sets the visibility of the ticks along all four sides of the map grid.
Read/write property SubTickCount The number of subticks to draw between the major ticks.
Read/write property SubTickLength The length of the subticks in points.
Read/write property SubTickLineSymbol The symbol used to draw the subtick lines.
Read/write property TickLength The length of the major ticks in points.
Read/write property TickLineSymbol The line symbol used to draw the major ticks.
Read/write property TickMarkSymbol The symbol used to draw tick marks at the grid interval intersections - null will draw no tick marks.
Read/write property 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
Method AddMapGrid Adds a map grid to the map frame.
Method ClearMapGrids Clears all map grids from the map frame.
Method DeleteMapGrid Deletes a map grid from the map frame.
Read/write property MapGrid The map grid at the specified index.
Read-only property 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
Read/write property AreaSearchDistance Distance used for selecting areas by proximity.
Read/write property AreaSelectionMethod Selection method used for areas.
Read/write property CombinationMethod Combination method for the selection results.
Read/write property DefaultColor Default selection color.
Read/write property LinearSearchDistance Distance used for selecting lines by proximity.
Read/write property LinearSelectionMethod Selection method used for lines.
Read/write property PointSearchDistance Distance used for selecting points by proximity.
Read/write property PointSelectionMethod Selection method used for points.
Read/write property 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
Method AboutBox Displays a dialog of information about the MapControl.
Read-only property ActiveView The active view of the Map contained by the MapControl.
Method AddLayer
(ILayer Layer, int toIndex)
Adds a layer to the Map's collection of layers at the specified index position.
Method 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 限制所處塗層的位置!
Method AddShapeFile
(string Path, string fileName)
Adds a shapefile as a layer to the Map.
添加 Shapefile 文件!
Read/write property Appearance The appearance of the MapControl.
Read/write property BackColor Background color of the MapControl.
Read/write property BorderStyle The border style of the MapControl.
Method CenterAt Moves the center of the MapControl to the specified location.
指的是以地理坐標為中心。
IPoint point = new ESRI.ArcGIS.Geometry.Point();  //定義點
point.PutCoords(e.mapX, e.mapY);  //給點賦值
axMapControl3.CenterAt(point);  //操作方法
Method CheckMxFile
(string fileName)
Checks the specified filename to see if it is a map document that can be loaded into the MapControl.
判斷是否為 *.mxd 文件。

Method ClearLayers Removes all layers from the Map.
Read/write property CurrentTool Current active tool for the MapControl. Set to nothing to clear the tool.
Method 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--)
axMapControl1.DeleteLayer(i); //倒序,刪除所有圖層!
Method DrawShape
(IGeometry, ref object symbol)
Draws a geometry shape on the MapControl.
Method DrawText
(IGeometry pGeometry, string text, ref object pSymbol)
Draws text along the supplied geometry.
Read/write property Enabled Indicates whether the MapControl can respond to user generated events.
Read/write property Extent
IEnvelope
Current extent of the Map in map units.
對於相同地圖來說,即使在不同的 MapControl 中,但是相同區域的長和寬都是相同的!通過這個特點,可以很容易的實現讓兩個 MapControl 顯示相同哦內容!
        private void axMapControl1_OnExtentUpdated(object sender, IMapControlEvents2_OnExtentUpdatedEvent e)
{  //觸發同步事件
axMapControl2.Extent = axMapControl1.Extent;  //讓1和2之間建立聯系,保證顯示相同的地圖。
}

//獲取當前地圖中心點的坐標,通過四個端點的坐標來反推中心點的坐標!

  IPoint centerPoint = new ESRI.ArcGIS.Geometry.Point();
  centerPoint.X = (pEnv.XMin + pEnv.XMax) / 2;
  centerPoint.Y = (pEnv.YMin + pEnv.YMax) / 2;
Method FlashShape
(IGeometry pShape, int nFlashes, int flashInterval, object symbol)

Flashes a shape on the MapControl, duration is in milliseconds.
第一個參數表示幾何形狀;
第二個參數表示閃爍的次數;
第三個參數表示閃爍的間隔;
第四個參數表示樣式。

Method FromMapPoint Converts a point on the Map (in map units) to device co-ordinates (typically pixels).
Read/write property FullExtent Rectangular shape that encloses all features of all layers in the Map.
Read-only property hWnd Handle to the window associated with the MapControl.
Read-only property Layer
屬性:Layer [int index]
方法:get_Layer (int index)
Layer at the supplied index.
Read-only property LayerCount Number of layers in the Map.
Method 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);
axMapControl1.LoadMxFile(filePath, 0, Type.Missing);  //加載第一個框架
axMapControl1.LoadMxFile(filePath, 1, Type.Missing);  //加載第二個框架
axMapControl1.LoadMxFile(filePath, "China", Type.Missing);  //加載名稱為China的框架
Read/write property Map The Map contained by the MapControl.
Read/write property MapScale Scale of the map as a representative fraction.
Read/write property MapUnits The geographical units of the map.
Read/write property MouseIcon Custom mouse icon used if MousePointer is 99.
Read/write property MousePointer The mouse pointer displayed over the MapControl.
esriControlsMousePointer 枚舉:鼠標的不同顯示樣式!(箭頭小圓圈)
axMapControl1.MousePointer = esriControlsMousePointer.esriPointerHourglass;
Method MoveLayerTo
(int fromIndex, int toIndex)
Moves a layer within the Map's collection from its current index position to a new index position.
若向下移動,則其上的整體上移,若向上移動,則其下整體下移。
Read/write property OleDropEnabled Indicates if the MapControl will fire events when data is dragged over the control's window.
Method Pan Tracks the mouse while panning the MapControl.
實現在 MapControl 上面漫游。
Method ReadMxMaps Opens a map document specified by the supplied filename and reads the maps into an array object.
Read/write property ReferenceScale Reference scale of the Map as a representative fraction.
Method Refresh Redraws the Map, optionally just redraw specified phases or envelope.
Read/write property 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();
}
Read/write property ShowScrollbars Indicates whether or not the Map's scrollbars are visible.
Read/write property SpatialReference Spatial reference of the Map.
Method ToMapPoint Converts a point in device co-ordinates (typically pixels) to a point on the Map (in map units).
Read/write property TrackCancel The object used by the MapControl to check if drawing has been aborted.
Method TrackCircle Rubber-bands【橡皮筋】 a circle on the MapControl.
Method TrackLine
IGeometry
Rubber-bands a polyline on the MapControl.
用鼠標在 MapControl 上畫折線。
Method TrackPolygon Rubber-bands a polygon on the MapControl.
畫 Polyline & 畫 Circle
        int flag = 0;
Random r = new Random();
private void button1_Click(object sender, EventArgs e)
{
flag = 1;
}
private void button2_Click(object sender, EventArgs e)
{
flag = 2;
}
private void axMapControl1_OnMouseDown(object sender, ESRI.ArcGIS.Controls.IMapControlEvents2_OnMouseDownEvent e)
{
axMapControl1.MousePointer = esriControlsMousePointer.esriPointerCrosshair;
IGeometry geometry = null;
if (flag == 1)
{
geometry = axMapControl1.TrackLine();
object symbol = null;

IRgbColor pRgbColor = new RgbColor();
pRgbColor.Red = (int)r.Next(255);
pRgbColor.Green = (int)r.Next(255);
pRgbColor.Blue = (int)r.Next(255);

ISimpleLineSymbol pSympleLineSymbol = new SimpleLineSymbol();
pSympleLineSymbol.Color = pRgbColor;
pSympleLineSymbol.Width = 1;

symbol = pSympleLineSymbol;
axMapControl1.DrawShape(geometry, ref symbol);
}
else if (flag == 2)
{
geometry = axMapControl1.TrackCircle();
object symbol = null;

IRgbColor pRgbColor = new RgbColor();
pRgbColor.Red = (int)r.Next(255);
pRgbColor.Green = (int)r.Next(255);
pRgbColor.Blue = (int)r.Next(255);

ISimpleFillSymbol pSimpleFillSymbol = new SimpleFillSymbol();
pSimpleFillSymbol.Color = pRgbColor;

symbol = pSimpleFillSymbol;
axMapControl1.DrawShape(geometry,ref symbol);
}
}
Method TrackRectangle
IGeometry
Rubber-bands a rectangle on the MapControl.
用鼠標在 MapControl 上拉出一個矩形。
Write-only property 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
Event OnAfterDraw Fires after the Map draws a specified view phase.

Event OnAfterScreenDraw Fires after the Map contained by the MapControl has finished drawing.
效果好像和 OnExtentUpdated 比較類似!
不同點就是 OnAfterScreenDraw 是在操作之后才觸發,而 OnExtentUpdated 是只要有范圍變化即會觸發,因此用前者的時候消耗資源更少,特別是在 MapControl 和 PageLayoutControl 交互的時候表現的更明顯!
Event OnBeforeScreenDraw Fires before the Map contained by the MapControl starts to draw.
Event OnDoubleClick Fires when the user presses and releases the mouse button twice in quick succession.
Event 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的屬性也會發生變化!

Event OnFullExtentUpdated Fires after the full extent (bounds) of the MapControl has changed.
當地圖的覆蓋范圍變化時觸發,例如,往地圖中新增加一個圖層,其覆蓋范圍大於原圖的范圍。
Event OnKeyDown Fires after a key is pressed on the keyboard.
Event OnKeyUp Fires after a pressed key is released.
Event OnMapReplaced Fires after the Map contained by the MapControl has been replaced.
當 MapControl 的 mxd 文件替換時候觸發事件!【鷹眼】
Event 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) + "°";
label2.Text = "MapY:" + string.Format("{0:0.00000}", e.mapY).PadLeft(10) + "°";
label3.Text = "X:" + e.x.ToString().PadLeft(5);
label4.Text = "Y:" + e.y.ToString().PadLeft(5);
Event OnMouseMove Fires when the user moves the mouse over the MapControl.
當鼠標在 MapControl 上面漫游的時候觸發!
Event OnMouseUp Fires when the user releases a mouse button while over the MapControl.
Event OnOleDrop Fires when an OLE drop action occurs on the MapControl.
Event OnSelectionChanged Fires when the current selection changes.
Event 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
Method AboutBox Displays a dialog of information about the PageLayoutControl.
Read-only property ActiveView The active view of the PageLayout contained by the PageLayoutControl.
Method AddElement Adds the supplied element to the PageLayout, with optional geometry, symbolization, name and Z order.
Read/write property Appearance The appearance of the PageLayoutControl.
Read/write property BackColor Background color of the PageLayoutControl.
Read/write property BorderStyle The border style of the PageLayoutControl.
Method CenterAt Moves the center of the PageLayoutControl to the specified location.
Method CheckMxFile Checks the specified filename to see if it is a map document that can be loaded into the PageLayoutControl.
Read/write property CurrentTool Current active tool for the PageLayoutControl. Set to nothing to clear the tool.
Read/write property Enabled Indicates whether the PageLayoutControl can respond to user generated events.
Read/write property Extent Current extent of the PageLayout in page units.
此 Extent 所表示的是那個 Layout 的外框范圍,所以外框放的越大,則 Extent 越小,這里的 Extent 與 MapControl 中的 Extent 沒辦法建立聯系,因為所控制的東西不同!
Method FindElementByName Find the first element with the supplied name, supply an occurrence parameter to find the second, third and so on.
Method FromPagePoint Converts a point on the page (in page units) to device co-ordinates (typically pixels).
Read/write property FullExtent Rectangular shape that encloses the PageLayout.
Read-only property GraphicsContainer The graphics container of the PageLayout object contained by the PageLayoutControl.
Read-only property hWnd Handle to the window associated with the PageLayoutControl.
Method LoadMxFile Loads the specified map document into the PageLayout contained by the PageLayoutControl.
Method 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.
Read/write property MouseIcon Custom mouse icon used if MousePointer is 99.
Read/write property MousePointer The mouse pointer displayed over the PageLayoutControl.
Read/write property OleDropEnabled Indicates if the PageLayoutControl will fire events when data is dragged over the control's window.
Read-only property Page The Page associated with the PageLayout contained by the PageLayoutControl.
Read/write property PageLayout The PageLayout contained by the PageLayoutControl.
Method Pan Tracks the mouse while panning the PageLayoutControl.
Read/write property Printer The printer object used by the PageLayoutControl for printing.
Read-only property PrinterPageCount The number of printer pages the PageLayout will cover.
Method PrintPageLayout Sends the specified range of pages on the printer.
Method Refresh Redraws the PageLayout, optionally just redraw specified phases or envelope.
Method ToPagePoint Converts device co-ordinates (typically pixels) to a point on the page (in page units).
Read/write property TrackCancel The object used by the PageLayoutControl to check if drawing has been aborted.
Method TrackRectangle Rubber-bands a rectangle on the PageLayoutControl.
Method 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
Event OnAfterDraw Fires after the PageLayoutControl draws a specified view phase.
Event OnAfterScreenDraw Fires after the PageLayout contained by the PageLayoutControl has finished drawing.
Event OnBeforeScreenDraw Fires before the PageLayout contained by the PageLayoutControl starts to draw.
Event OnDoubleClick Fires when the user presses and releases the mouse button twice in quick succession.
Event OnExtentUpdated Fires after the extent (visible bounds) of the PageLayoutControl is changed.
Event OnFocusMapChanged Fires when the current focus map in the PageLayoutControl has been switched to a new map.
Event OnFullExtentUpdated Fires after the full extent (bounds) of the PageLayoutControl has changed.
Event OnKeyDown Fires after a key is pressed on the keyboard.
Event OnKeyUp Fires after a pressed key is released.
Event OnMouseDown Fires when the user presses any mouse button while over the PageLayoutControl.
Event OnMouseMove Fires when the user moves the mouse pointer over the PageLayoutControl.
Event OnMouseUp Fires when the user releases a mouse button while over the PageLayoutControl.
Event OnOleDrop Fires when an OLE drop action occurs on the PageLayoutControl.
Event OnPageLayoutReplaced Fires after the PageLayout object used by the PageLayoutControl has been replaced.
Event OnPageSizeChanged Fires when the Page associated with the PageLayout has had its size changed.
Event 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
Method AboutBox Displays a dialog of information about the ToolbarControl.
Method AddItem Adds an item to the ToolbarControl.
增加單個工具或是命令!或是 ToolPalette!
Method AddMenuItem Adds a menu item to the ToolbarControl.
增加菜單項!
Method AddToolbarDef Appends the contents of the toolbar definition, specified by Guid or ToolbarDef, to the toolbar control.
Read/write property Appearance The appearance of the ToolbarControl.
Read/write property BorderStyle The border style of the ToolbarControl.
Read-only property Buddy The object that will have its current tool managed by the toolbar.
Read/write property CommandPool The command pool used by the ToolbarControl to manage command objects. The command pool object maybe shared with other ToolbarControls and ToolbarMenus.
Read-only property Count The number of items on the ToolbarControl.
Read/write property CurrentTool The current tool of the buddy.
Read/write property Customize Indicates if the ToolbarControl is in customize mode.
Read/write property CustomProperty A property to associate data with a control.
Read/write property Enabled Indicates whether the ToolbarControl can respond to user generated events.
Method Find Returns the index of the first item containing the given command, menu or palette. Returns -1 if the command is not found.
Method GetItem Returns the item at the specified index from the ToolbarControl.
Method GetItemRect Returns the dimensions of the item at the specified index.
Method HitTest Returns the index of the item at the specified x and y coordinates.
Read-only property hWnd Handle to the window associated with the ToolbarControl.
Read/write property ItemAppearance The appearance of the items on the ToolbarControl.
Read/write property 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.
Read/write property LargeIcons Indicates if large icons are shown on all items on the ToolbarControl.
Read/write property MenuTracking Indicates if menu tracking is enabled on the ToolbarControl.
Read/write property MouseIcon Custom mouse icon used if MousePointer is 99.
Read/write property MousePointer The mouse pointer displayed over the ToolbarControl.
Method MoveItem Moves an item from one index to another.
Read-only property 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.
Read/write property OperationStack The operation stack used for undo and redo functionality. If present commands can use it to store operations.
Method Remove Removes the item at the specified index from the ToolbarControl.
Method RemoveAll Removes all items from the ToolbarControl.
Method SetBuddyControl Sets a control to be a buddy of the toolbar, this control must support IToolbarBuddy.
Read/write property TextAlignment The caption placement for all items on the ToolbarControl.
Read/write property ToolTips Indicates if the items tooltips are shown.
Method 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.
Read/write property 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
Method AboutBox Displays a dialog of information about the TOCControl.
顯示此控件的一些信息!彈出窗口!
Read-only property ActiveView The ActiveView used to populate the TOCControl.
Read/write property Appearance The appearance of the TOCControl.
Read/write property BorderStyle The border style of the TOCControl.
Read-only property Buddy The object whose ActiveView is used to populate the TOCControl.
Read/write property CustomProperty A property to associate data with a control.
Read/write property Enabled Indicates whether the TOCControl can respond to user generated events.
Method 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);
    }
}
Read-only property hWnd Handle to the window associated with the TOCControl.
返回一個 int 類型的值,唯一標示此控件,每次運行的時候生成值不同!
Read/write property 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.
Read/write property LabelEdit Label editing state.
Read/write property LayerVisibilityEdit Layer visibility editing state.
Read/write property MouseIcon Custom mouse icon used if MousePointer is 99.
Read/write property MousePointer The mouse pointer displayed over the TOCControl.
Read-only property 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.
Method SetActiveView Sets the ActiveView used to populate the TOCControl.
Method SetBuddyControl Sets a control to be a buddy of the toolbar, this control must support ITOCBuddy.
Method 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
Event OnBeginLabelEdit Fires when label editing begins.
Event OnDoubleClick Fires when the user presses and releases the mouse button twice in quick succession.
Event OnEndLabelEdit Fires when label editing ends.
Event OnKeyDown Fires after a key is pressed on the keyboard.
Event OnKeyUp Fires after a pressed key is released.
Event OnMouseDown Fires when the user presses any mouse button while over the TOCControl.
Event OnMouseMove Fires when the user moves the mouse pointer over the TOCControl.
Event 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
Method AboutBox Displays a dialog of information about the SymbologyControl.
Read/write property Appearance The appearance of the SymbologyControl.
Read/write property BackColor Background color of the SymbologyControl.
Read/write property BorderStyle The border style of the SymbologyControl.
Method Clear Clears all symbols and files from the SymbologyControl.
Read/write property CustomProperty A property to associate data with the SymbologyControl.
Read/write property DisplayStyle The display style of the SymbologyControl.
Read/write property Enabled Indicates whether the SymbologyControl can respond to user generated events.
Method 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;  //獲取顯示的符號類型  
    axSymbologyControl1.GetStyleClass(axSymbologyControl1.StyleClass).SelectItem(0);  //獲取默認選擇的符號樣式 }
Method HitTest Returns the item at the specified x and y coordinates.
Read-only property hWnd Handle to the window associated with the SymbologyControl.
Read/write property 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.
Method LoadDesktopStyleFile Loads a desktop style file into the SymbologyControl.
加載擴展名為 .style 的文件!
Method LoadStyleFile
(string fileName)
Loads a server style file into the SymbologyControl.
加載擴展名為 .ServerStyle 的文件!
//直接插入地址調入:
axSymbologyControl1.LoadStyleFile(@"C:\Program Files (x86)\ArcGIS\Engine10.0\Styles\ESRI.ServerStyle");

//通過注冊表讀取:
Microsoft.Win32.RegistryKey regKey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("SOFTWARE\\ESRI\\CoreRuntime", true);

axSymbologyControl1.LoadStyleFile(regKey.GetValue("InstallDir") + "\\Styles\\ESRI.ServerStyle");
Read/write property MouseIcon Custom mouse icon used if MousePointer is 99.
Read/write property MousePointer The mouse pointer displayed over the SymbologyControl.
Read-only property 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.
Method RemoveFile Removes a file from the SymbologyControl.
Read/write property ShowContextMenu Indicates if the SymbologyControl displays a context menu.
Read/write property 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
Method AddItem Adds an item to the SymbologyStyleClass.
Method GetItem Returns the item at the specified index in the SymbologyStyleClass.
Method GetSelectedItem Returns the selected item in the SymbologyStyleClass.
Read-only property ItemCount The number of items in the SymbologyStyleClass.
Method 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;
Method RemoveAll Removes all items from the SymbologyStyleClass.
Method RemoveItem Removes the item at the specified index from the SymbologyStyleClass.
Method SelectItem Sets the selected item in the SymbologyStyleClass.
Read/write property SortDirection The sort direction of the items in the SymbologyStyleClass.
Read/write property StyleCategory The style category used by the SymbologyStyleClass.
Read-only property StyleClass The class of the symbols in the SymbologyStyleClass.
Method UnselectItem Unsets the selected item in the SymbologyStyleClass.
Method 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
Read/write property Category The category of the item.
Read-only property ID Id for the item in the Style Gallery.
Read/write property Item The symbol or map element to be stored in the Style Gallery item.
Read/write property 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
Event OnDoubleClick Fires when the user presses and releases the mouse button twice in quick succession.
Event OnItemSelected Fires when an item is selected in the SymbologyControl.
當選中某個選項的時候觸發事件!
e.styleGalleryItem  獲取選項的樣式
IStyleGalleryItem styleGalleryItem = (IStyleGalleryItem)e.styleGalleryItem;
Event OnKeyDown Fires after a key is pressed on the keyboard.
Event OnKeyUp Fires after a pressed key is released.
Event OnMouseDown Fires when the user presses any mouse button while over the SymbologyControl.
Event OnMouseMove Fires when the user moves the mouse pointer over the SymbologyControl.
Event OnMouseUp Fires when the user releases a mouse button while over the SymbologyControl.
Event 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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM