1.AddInEditorExtension
功能描述:编辑器扩展,实现在编辑要素,对编辑事件的监听,及对新创建的要素的处理
核心代码:
void Events_OnStartEditing() { //Since features of shapefiles, coverages etc cannot be validated, ignore wiring events for them if (ArcMap.Editor.EditWorkspace.Type != esriWorkspaceType.esriFileSystemWorkspace) { //wire OnCreateFeature Edit event Events.OnCreateFeature += new IEditEvents_OnCreateFeatureEventHandler(Events_OnCreateChangeFeature); //wire onChangeFeature Edit Event Events.OnChangeFeature += new IEditEvents_OnChangeFeatureEventHandler(Events_OnCreateChangeFeature); } } //Invoked at the end of Editor session (Editor->Stop Editing) void Events_OnStopEditing(bool Save) { //Since features of shapefiles, coverages etc cannot be validated, ignore wiring events for them if (ArcMap.Editor.EditWorkspace.Type != esriWorkspaceType.esriFileSystemWorkspace) { //unwire OnCreateFeature Edit event Events.OnCreateFeature -= new IEditEvents_OnCreateFeatureEventHandler(Events_OnCreateChangeFeature); //unwire onChangeFeature Edit Event Events.OnChangeFeature -= new IEditEvents_OnChangeFeatureEventHandler(Events_OnCreateChangeFeature); } } void Events_OnCreateChangeFeature(ESRI.ArcGIS.Geodatabase.IObject obj) { IFeature inFeature = (IFeature)obj; if (inFeature.Class is IValidation) { IValidate validate = (IValidate)inFeature; string errorMessage; //Validates connectivity rules, relationship rules, topology rules etc bool bIsvalid = validate.Validate(out errorMessage); if (!bIsvalid) { System.Windows.Forms.MessageBox.Show("Invalid Feature\n\n" + errorMessage); } else { System.Windows.Forms.MessageBox.Show("Valid Feature"); } } }
2.AddInExtensionPersist
功能描述:ArcMap扩展,实现对ArcMap事件的监听
比如启动,加载,保存等事件
3.AddInReportManager
功能说明:ESRI自带的一种报表导出方案
主要接口IReportDataSource,IReportTemplate
需要提前做好.rlf文件
4.AddInTimeSeriesGraph
功能描述:折线图 Tool
示例数据路径:C:\Program Files (x86)\ArcGIS\DeveloperKit10.1\Samples\data\StreamflowDateTime
相关接口
IIdentify :Provides access to members that identify features,相关矢量图层
IDisplayTable :Provides access to members that work with the display table associated with a standalone table. 该接口包含Joined 字段
IFeatureLayerDefinition:
ILookupSymbol .LookupSymbol ():Returns a reference to the renderer‘s symbol for the input feature.查询某个要素的Symbol
IDataGraphWindow2 :Provides access to members that control the DataGraph Window. ESRI自带的专题图窗口,可以使用下述代码调用显示
pDGWin = new DataGraphWindowClass(); pDGWin.DataGraphBase = pDataGraphBase; pDGWin.Application = ArcMap.Application; pDGWin.Show(true); pDataGraphs.AddDataGraph(pDataGraphBase);
设置Title,坐标轴显示内容等
pDataGraphT = new DataGraphTClass(); pDataGraphBase = (IDataGraphBase)pDataGraphT; // load template from <ARCGISHOME>\GraphTemplates\ string strPath = null; strPath = Environment.GetEnvironmentVariable("ARCGISHOME"); try { pDataGraphT.LoadTemplate(strPath + @"GraphTemplates\timeseries.tee"); } catch { } // graph, axis and legend titles. Substitute them for different input layer pDataGraphT.GeneralProperties.Title = "Daily Streamflow for Guadalupe Basin in 1999"; pDataGraphT.LegendProperties.Title = "Monitoring Point"; pDataGraphT.get_AxisProperties(0).Title = "Streamflow (cfs)"; pDataGraphT.get_AxisProperties(0).Logarithmic = true; pDataGraphT.get_AxisProperties(2).Title = "Date"; pDataGraphBase.Name = layerName;
设置绘图内容:
ISeriesProperties pSP = null; pSP = pDataGraphT.AddSeries("line:vertical"); pSP.ColorType = esriGraphColorType.esriGraphColorCustomAll; pSP.CustomColor = pSymbol.Color.RGB; pSP.WhereClause = whereClause; pSP.InLegend = true; pSP.Name = gageID; pSP.SourceData = pLayer; pSP.SetField(0, timefldName); pSP.SetField(1, dataFldName); IDataSortSeriesProperties pSortFlds = null; pSortFlds = (IDataSortSeriesProperties)pSP; int idx = 0; pSortFlds.AddSortingField(timefldName, true, ref idx); pDataGraphBase.UseSelectedSet = true; ITrackCancel pCancelTracker = null; pCancelTracker = new CancelTracker(); pDataGraphT.Update(pCancelTracker);
其他代码片段:
以下代码实现在检索时,先检测定义查询的Sql语句,如果有内容,则与新的查询语句And,没有,则直接使用新的查询语句
IFeatureLayerDefinition pFeatureLayerDef = null; pFeatureLayerDef = (IFeatureLayerDefinition)pLayer; string definitionExpression = null; definitionExpression = pFeatureLayerDef.DefinitionExpression; string whereClause = null; if (definitionExpression == "") whereClause = "[" + gageIDFldName + "] = ‘" + gageID + "‘"; else whereClause = "[" + gageIDFldName + "] = ‘" + gageID + "‘ AND " + definitionExpression;
5.\AlgorithmicColorRamp
功能说明:
接口:
IContentsView: Provides access to members that control table of contents views,
Used to manage a contents view. The tabs in ArcMap‘s Table of Contents (TOC) are examples of a contents view.
示例用法:判断TOC中选中的内容
IContentsView ContentsView = null; ContentsView = ArcMap.Document.CurrentContentsView; if (ContentsView is TOCDisplayView) { if (ContentsView.SelectedItem is DBNull) { // // If we don‘t have anything selected. // MessageBox.Show("SelectedItem is Null C#." + "Select a layer in the Table of Contents.", "No Layer Selected", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } // // Get the selected Item. // VarSelectedItem = ContentsView.SelectedItem; // // Selected Item should implement the IGeoFeatureLayer interface - therefore we // have selected a feature layer with a Renderer property (Note: Other interfaces // also have a Renderer property, which may behave differently. // if (VarSelectedItem is IGeoFeatureLayer) { //.... }
2.Brushing