/// <summary> /// 多个要素同时闪烁 add by xisheng 2011.07.01 /// </summary> private void DefaultSelNde() { Application.DoEvents(); IArray geoArray = new ArrayClass(); for (int i = 0; i < this.advTree.Nodes.Count; i++) { if (!this.advTree.Nodes[i].HasChildNodes) { continue; } for (int j = 0; j < this.advTree.Nodes[i].Nodes.Count; j++) { IFeature pFeature = this.advTree.Nodes[i].Nodes[j].Tag as IFeature; geoArray.Add(pFeature); } } if (geoArray == null) { return; } HookHelperClass hookHelper = new HookHelperClass(); hookHelper.Hook = m_pMapControl.Object; IHookActions hookAction = (IHookActions)hookHelper; hookAction.DoActionOnMultiple(geoArray, esriHookActions.esriHookActionsFlash); }
private void print_Load(object sender, EventArgs e) { //Display printer details //参数定义 IHookHelper layout_hookHelper = new HookHelperClass(); //参数赋值 }
/// <summary> /// 闪烁选中图斑 /// </summary> /// <param name="featureCursor"></param> private void FlashPolygons(IFeatureCursor featureCursor) { IArray geoArray = new ArrayClass(); IFeature feature = null; while ((feature = featureCursor.NextFeature()) != null) { //feature是循环外指针,所以必须用ShapeCopy geoArray.Add(feature.ShapeCopy); } //通过IHookActions闪烁要素集合 HookHelperClass m_pHookHelper = new HookHelperClass(); m_pHookHelper.Hook = m_MapControl.Object; IHookActions hookActions = (IHookActions)m_pHookHelper; hookActions.DoActionOnMultiple(geoArray, esriHookActions.esriHookActionsPan); System.Windows.Forms.Application.DoEvents(); m_pHookHelper.ActiveView.ScreenDisplay.UpdateWindow(); hookActions.DoActionOnMultiple(geoArray, esriHookActions.esriHookActionsFlash); System.Windows.Forms.Application.DoEvents(); m_pHookHelper.ActiveView.ScreenDisplay.UpdateWindow(); }
private void 根据排序结果来选择要素ToolStripMenuItem_Click(object sender, EventArgs e) { IHookHelper helper = new HookHelperClass(); helper.Hook = axMapControl1.Object; 空间查询与空间分析.TableSort实例 form = new TableSort实例(helper); form.Show(this as System.Windows.Forms.IWin32Window); }
private void 裁剪要素类ToolStripMenuItem_Click(object sender, EventArgs e) { IHookHelper helper = new HookHelperClass(); helper.Hook = axMapControl1.Object; 空间查询与空间分析.GPClip form = new GPClip(helper); form.Show(this as System.Windows.Forms.IWin32Window); }
private void button1_Click(object sender, EventArgs e) { IHookHelper hookHelper = new HookHelperClass(); //hookHelper.Hook = axMapControl1.Object; hookHelper.Hook = m_controlsSynchronizer.MapControl.Object; poverView = new EagleEyes(hookHelper); poverView.Show(); }
private void ToolStripLabel4_Click(object sender, EventArgs e) { IHookHelper map_hookHelper = new HookHelperClass(); //参数赋值 map_hookHelper.Hook = mainMapControl.Object; export_file frmExportDlg = new export_file(map_hookHelper); frmExportDlg.Show(); }
private void ExportToolStripMenuItem_Click(object sender, EventArgs e) { // HOOK实际是一个对象传出的自身的引用或者叫指针或者叫句柄。 IHookHelper map_hookHelper = new HookHelperClass(); //参数赋值 map_hookHelper.Hook = m_mapControl.Object; Export frmExportDlg = new Export(map_hookHelper); frmExportDlg.Show(); }
private void 缓冲区分析ToolStripMenuItem_Click(object sender, EventArgs e) { //定义参数 IHookHelper map_hookHelper = new HookHelperClass(); //参数赋值 //Hook定义 map_hookHelper.Hook = this.axMapControl1.Object; //窗体调用 BufferDlg BAFrm = new BufferDlg(map_hookHelper); BAFrm.ShowDialog(); }
/// <summary> /// Executes the action on the feature. /// </summary> /// <param name="source">The source.</param> /// <param name="hook">The hook.</param> /// <param name="action">The action.</param> /// <returns>Returns <see cref="bool" /> representing <c>true</c> when the action was successful.</returns> private static bool DoAction(this IFeature source, IApplication hook, esriHookActions action) { var helper = new HookHelperClass(); helper.Hook = hook; if (!helper.ActionSupported[source.Shape, action]) { return(false); } helper.DoAction(source.Shape, action); return(true); }
private void dgvResFind_MouseDoubleClick(object sender, MouseEventArgs e) { int iOID, iRowIndex, iPosition; string sRowTag, sLayerName; iRowIndex = dgvResFind.HitTest(e.X, e.Y).RowIndex; sRowTag = dgvResFind.Rows[iRowIndex].Tag.ToString(); iPosition = Strings.InStr(sRowTag, "_", CompareMethod.Text); iOID = Convert.ToInt32(sRowTag.Substring(0, iPosition - 1)); sLayerName = sRowTag.Substring(iPosition); IFeature pFeature; IFeatureLayer pFeatureLayer; IFeatureClass pFeatureClass; pFeature = null; m_pEnumLayer.Reset(); pFeatureLayer = (IFeatureLayer)m_pEnumLayer.Next(); while (pFeatureLayer != null) { if (pFeatureLayer.Name == sLayerName) { pFeatureClass = pFeatureLayer.FeatureClass; pFeature = pFeatureClass.GetFeature(iOID); break; } pFeatureLayer = m_pEnumLayer.Next() as IFeatureLayer; } if (pFeature == null) { return; } IHookActions pHookActions; IHookHelper pHookHelper; pHookHelper = new HookHelperClass(); pHookHelper.Hook = ClsDeclare.g_Sys.MapControl.Object; pHookActions = (IHookActions)pHookHelper; if (pHookActions.get_ActionSupported(pFeature.ShapeCopy, esriHookActions.esriHookActionsPan)) { pHookActions.DoAction(pFeature.ShapeCopy, esriHookActions.esriHookActionsPan); } Application.DoEvents(); if (pHookActions.get_ActionSupported(pFeature.ShapeCopy, esriHookActions.esriHookActionsFlash)) { pHookActions.DoAction(pFeature.ShapeCopy, esriHookActions.esriHookActionsFlash); } }
public void Measure(AxMapControl pMapControl) { if (pMapControl == null) return; else { pMapControl.CurrentTool = null; HookHelper hk = new HookHelperClass(); hk.Hook = pMapControl.Object; ITool pTool = new MeasureDisTool(hk); pMapControl.CurrentTool = pTool; pMapControl.MousePointer = esriControlsMousePointer.esriPointerDefault; } }
/// <summary> /// Occurs when this command is created /// </summary> /// <param name="hook">Instance of the application</param> public override void OnCreate(object hook) { if (hook == null) { return; } IHookHelper m_hookHelper; m_hookHelper = new HookHelperClass(); m_hookHelper.Hook = hook; m_mapControl = (IMapControl3)m_hookHelper.Hook; // TODO: Add other initialization code }
public override void OnCreate(object hook) { IHookHelper hookhelper = new HookHelperClass(); if (hook != null) { hookhelper.Hook = hook; m_mapControl = (IMapControl3)hookhelper.Hook; // Get the Network Analyst Env m_naEnv = new EngineNetworkAnalystEnvironmentClass(); } // TODO: Add other initialization code }
private void FlashAndIdentify(IArray inArray) { try { if (inArray == null) { return; } HookHelperClass hookHelper = new HookHelperClass(); hookHelper.Hook = MyMapControl.Object; IHookActions hookAction = (IHookActions)hookHelper; hookAction.DoActionOnMultiple(inArray, esriHookActions.esriHookActionsFlash); } catch (Exception exc) { MessageBox.Show(exc.Message); } }
//buffer查询并闪烁。 public static void BufferSelectAndFlash(IMapControl4 mapCtrl, IGeometry baseGeo, esriSpatialRelEnum spatialRef, ILayer layer) { IFeatureLayer featureLayer = layer as IFeatureLayer; if (mapCtrl == null || featureLayer == null) { return; } IFeatureClass fC = featureLayer.FeatureClass; ISpatialFilter pFilter = new SpatialFilterClass(); pFilter.Geometry = baseGeo; pFilter.GeometryField = "SHAPE"; pFilter.SpatialRel = spatialRef; IFeatureCursor pFeatureCursor = fC.Search(pFilter, false); IArray inArray = new ArrayClass(); IFeature fe = pFeatureCursor.NextFeature(); mapCtrl.Map.ClearSelection(); while (fe != null) { inArray.Add(fe); mapCtrl.Map.SelectFeature(layer, fe); fe = pFeatureCursor.NextFeature(); } if (inArray == null) { return; } HookHelper m_hookHelper = new HookHelperClass(); m_hookHelper.Hook = mapCtrl.Object; IHookActions hookAction = (IHookActions)m_hookHelper; ICommand cmd = new ControlsZoomToSelectedCommandClass(); cmd.OnCreate(m_hookHelper.Hook); cmd.OnClick(); Application.DoEvents(); hookAction.DoActionOnMultiple(inArray, esriHookActions.esriHookActionsFlash); }
public override void OnClick() { Plugin.Application.IAppFormRef pAppFormRef = myHook as Plugin.Application.IAppFormRef; IToolbarControl pTC = new ToolbarControlClass(); ClsEditorMain clsEM = new ClsEditorMain(pTC, myHook.ArcGisMapControl, pAppFormRef.MainForm); IHookHelper pHH = new HookHelperClass(); pHH.Hook = myHook.ArcGisMapControl.Object; clsEM.HookHelper = pHH; frmEditSnapAttri fmESA = new frmEditSnapAttri(clsEM); fmESA.ShowDialog(pAppFormRef.MainForm); ICommand createPolygon = new CreatePolygonTool(); (createPolygon as CreatePolygonTool).setClsEditorMain(clsEM); createPolygon.OnCreate(myHook.ArcGisMapControl.Object); createPolygon.OnClick(); myHook.ArcGisMapControl.CurrentTool = createPolygon as ITool; }
/// <summary> /// Executes the action on all of the features in the enumeration. /// </summary> /// <param name="source">The source.</param> /// <param name="hook">The hook.</param> /// <param name="action">The action.</param> /// <returns>Returns <see cref="bool" /> representing <c>true</c> when the action was successful.</returns> private static bool DoAction(this IEnumerable <IFeature> source, IApplication hook, esriHookActions action) { var helper = new HookHelperClass(); helper.Hook = hook; IArray shapes = new ArrayClass(); foreach (var unk in source) { shapes.Add(unk.Shape); } if (!helper.ActionSupportedOnMultiple[shapes, action]) { return(false); } helper.DoActionOnMultiple(shapes, action); return(true); }
/// <summary> /// 几何闪烁,实现ArcMap的闪烁效果 /// </summary> /// <param name="mapControl"></param> /// <param name="geometry"></param> /// <param name="bZoom">是否缩放到指定几何,默认不缩放</param> public void Flash(IMapControl4 mapControl, IGeometry geometry, bool bZoom = false) { if (geometry == null || geometry.IsEmpty) { return; } IHookHelper hookHelper = new HookHelperClass(); hookHelper.Hook = mapControl; IHookActions hookActions = hookHelper as IHookActions; if (bZoom) //先缩放 { hookActions.DoAction(geometry, esriHookActions.esriHookActionsZoom); hookHelper.ActiveView.ScreenDisplay.UpdateWindow(); } //再闪烁 if (hookActions.get_ActionSupported(geometry, esriHookActions.esriHookActionsFlash)) { hookActions.DoAction(geometry, esriHookActions.esriHookActionsFlash); } }
private void MainForm_Load(object sender, EventArgs e) { //get the MapControl m_mapControl = (IMapControl3)axMapControl1.Object; //disable the Save menu (since there is no document yet) menuSaveDoc.Enabled = false; m_pageLayoutControl = (IPageLayoutControl3)axPageLayoutControl1.Object; //Initialize controls synchronization calss m_controlsSynchronizer = new ControlsSynchronizer(m_mapControl, m_pageLayoutControl); //Bind MapControl and PageLayoutControl(Point to the same Map), Set MapControl as the active Control m_controlsSynchronizer.BindControls(true); //In order to switch MapControl and PageLayoutControl, we need to add Framework Control m_controlsSynchronizer.AddFrameworkControl(axToolbarControl1.Object); m_controlsSynchronizer.AddFrameworkControl(this.axTOCControl1.Object); IHookHelper hookHelper = new HookHelperClass(); //hookHelper.Hook = axMapControl1.Object; hookHelper.Hook = m_controlsSynchronizer.MapControl.Object; poverView = new EagleEyes(hookHelper); OpenNewMapDocument openMapDoc = new OpenNewMapDocument(m_controlsSynchronizer); axToolbarControl1.AddItem(openMapDoc, -1, 0, false, -1, esriCommandStyles.esriCommandStyleIconOnly); m_TocLayerMenu.AddItem(new OpenAttributeTableCmd(), 0, 0, false, esriCommandStyles.esriCommandStyleIconAndText); m_TocLayerMenu.AddItem(new RemoveLayerCmd(), 0, 1, false, esriCommandStyles.esriCommandStyleIconAndText); m_TocLayerMenu.SetHook(axMapControl1); m_TocMapMenu.AddItem(new ControlsAddDataCommandClass(), 0, -1, false, esriCommandStyles.esriCommandStyleIconAndText); m_TocMapMenu.AddItem(new TurnAllLayersOnCmd(), 0, -1, true, esriCommandStyles.esriCommandStyleIconAndText); m_TocMapMenu.AddItem(new TurnAllLayersOffCmd(), 0, -1, false, esriCommandStyles.esriCommandStyleIconAndText); m_TocMapMenu.SetHook(axMapControl1); m_toolbarMenu.AddItem(new ClearCurrentTool(), 0, -1, false, esriCommandStyles.esriCommandStyleIconAndText); m_toolbarMenu.AddItem(new ClearFeatureSelection(), 0, -1, false, esriCommandStyles.esriCommandStyleIconAndText); m_toolbarMenu.AddItem(new Refresh(), 0, -1, false, esriCommandStyles.esriCommandStyleIconAndText); m_toolbarMenu.SetHook(axMapControl1); }
// Fire polygons aggregation private void polygonsAggregationToolStripMenuItem_Click(object sender, EventArgs e) { IHookHelper hook = new HookHelperClass(); hook.Hook = axMapControl1.Object; FormAggregation frm = new FormAggregation(hook); frm.Show(); }
private void btnApply_Click(object sender, EventArgs e) { try { Verify(); string strQuery; strQuery = this.txtExpress.Text; if (strQuery == "") { return; } ILayer pLayer; pLayer = ClsSelectQuery.FunFindFeatureLayerByName(cboLayerList.Text, ClsDeclare.g_pMap); if (pLayer == null) { return; } IFeatureLayer pFeatLayer; pFeatLayer = pLayer as IFeatureLayer; if (pFeatLayer.Visible == false) { } //ClsDeclare.g_ErrorHandler.DisplayInformation("请选择可见图层",false,"确定",null); IFeatureSelection pFeatureSelection; pFeatureSelection = pFeatLayer as IFeatureSelection; IQueryFilter pQueryFilter = new QueryFilterClass(); pQueryFilter.WhereClause = strQuery; esriSelectionResultEnum SelType; SelType = esriSelectionResultEnum.esriSelectionResultNew; switch (this.cboSelectMethod.Text) { case "创建一个新的选择结果": { if (ClsDeclare.g_pMap.SelectionCount > 0) { ClsDeclare.g_pMap.ClearSelection(); } SelType = esriSelectionResultEnum.esriSelectionResultNew; } break; case "添加到当前选择集中": SelType = esriSelectionResultEnum.esriSelectionResultAdd; break; case "从当前选择结果中移除": SelType = esriSelectionResultEnum.esriSelectionResultSubtract; break; case "从当前选择结果中选择": SelType = esriSelectionResultEnum.esriSelectionResultAnd; break; } if (pFeatLayer.Selectable) { pFeatureSelection.SelectFeatures(pQueryFilter, SelType, false); } IActiveView pActiveView; pActiveView = ClsDeclare.g_pMap as IActiveView; pActiveView.Refresh(); IFeatureClass pFeatCls; IGeometryCollection pGeometryCol; IGeometryBag pGeometryBag; IEnumIDs pEnumIDs; IFeature pFeature; int iOBJID; pGeometryCol = new GeometryBagClass(); pGeometryBag = pGeometryCol as IGeometryBag; pFeatCls = pFeatLayer.FeatureClass; pEnumIDs = pFeatureSelection.SelectionSet.IDs; iOBJID = pEnumIDs.Next(); object Missing = Type.Missing; object Missing1 = Type.Missing; while (iOBJID != -1) { pFeature = pFeatCls.GetFeature(iOBJID); pGeometryCol.AddGeometry(pFeature.Shape, ref Missing, ref Missing1); iOBJID = pEnumIDs.Next(); } IHookActions pHookActions; IHookHelper pHookHelper; pHookHelper = new HookHelperClass(); pHookHelper.Hook = ClsDeclare.g_Sys.MapControl.Object; pHookActions = pHookHelper as IHookActions; if (pHookActions.get_ActionSupported(pGeometryBag.Envelope, esriHookActions.esriHookActionsPan)) { pHookActions.DoAction(pGeometryBag.Envelope, esriHookActions.esriHookActionsPan); } Application.DoEvents(); } catch (Exception ex) { MessageBox.Show("错误", ex.StackTrace, MessageBoxButtons.OK, MessageBoxIcon.Error); //ClsDeclare.g_ErrorHandler.HandleError(true,null,0,null,ex.StackTrace); throw; } }
public override void OnCreate(object hook) { try { mHookHelper = new HookHelperClass { Hook = hook }; if (mHookHelper.ActiveView == null) { mHookHelper = null; } } catch { mHookHelper = null; } }
// 工具箱 private void treeView1_MouseDown(Object sender, MouseEventArgs e) { if ((sender as TreeView) != null) { treeView1.SelectedNode = treeView1.GetNodeAt(e.X, e.Y); string name = treeView1.SelectedNode.Name; if (name == "缓冲区") { IHookHelper hookHelper = new HookHelperClass(); hookHelper.Hook = axMapControl1.Object; BufferAnalysisForm bufferAnalysisForm = new BufferAnalysisForm(hookHelper, addLayer); bufferAnalysisForm.ShowDialog(); // http://www.itboth.com/d/MFRRFf/textbox-buffer-arcengine-string-layer } else if (name == "擦除") { IHookHelper hookHelper = new HookHelperClass(); hookHelper.Hook = axMapControl1.Object; EraseForm eraseForm = new EraseForm(hookHelper, addLayer); eraseForm.ShowDialog(); } else if (name == "加载站点") { if (dataBasePath == null) { Show("未选择数据集路径 !"); return; } ICommand pCommand; pCommand = new AddNetStopsTool(dataBasePath); pCommand.OnCreate(axMapControl1.Object); axMapControl1.CurrentTool = pCommand as ITool; } else if (name == "加载障碍点") { if (dataBasePath == null) { Show("未选择数据集路径 !"); return; } ICommand pCommand; pCommand = new AddNetBarriesTool(dataBasePath); pCommand.OnCreate(axMapControl1.Object); axMapControl1.CurrentTool = pCommand as ITool; } else if (name == "生成最短路径") { if (dataBasePath == null) { Show("未选择数据集路径 !"); return; } if (featureName == null) { Show("未选择数据集 !"); return; } if (networkName == null) { Show("未选择网络数据集 !"); return; } ICommand pCommand; pCommand = new ShortPathSolveCommand(dataBasePath, featureName, networkName); pCommand.OnCreate(axMapControl1.Object); pCommand.OnClick(); } else if (name == "清除分析") { axMapControl1.CurrentTool = null; try { IFeatureWorkspace pFWorkspace; //string path = System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase; //打开工作空间 pFWorkspace = NetWorkAnalysClass.OpenWorkspace(dataBasePath) as IFeatureWorkspace; IGraphicsContainer pGrap = axMapControl1.ActiveView as IGraphicsContainer; pGrap.DeleteAllElements(); //删除所添加的图片要素 IFeatureClass inputFClass = pFWorkspace.OpenFeatureClass("Stops"); //删除站点要素 if (inputFClass.FeatureCount(null) > 0) { ITable pTable = inputFClass as ITable; pTable.DeleteSearchedRows(null); } IFeatureClass barriesFClass = pFWorkspace.OpenFeatureClass("Barries"); //删除障碍点要素 if (barriesFClass.FeatureCount(null) > 0) { ITable pTable = barriesFClass as ITable; pTable.DeleteSearchedRows(null); } for (int i = 0; i < axMapControl1.LayerCount; i++) //删除分析结果 { ILayer pLayer = axMapControl1.get_Layer(i); if (pLayer.Name == ShortPathSolveCommand.m_NAContext.Solver.DisplayName) { axMapControl1.DeleteLayer(i); break; } } } catch (Exception ex) { MessageBox.Show(ex.Message); } axMapControl1.Refresh(); } else if (name == "最短路径分析") { FolderBrowserDialog dialog = new FolderBrowserDialog(); if (dialog.ShowDialog() == DialogResult.OK) { dataBasePath = dialog.SelectedPath; NetWorkForm netWorkForm = new NetWorkForm( dataBasePath, setNetWorkPropety ); netWorkForm.ShowDialog(); } } } }
/// <summary> /// 空间定位 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnApply_Click(object sender, EventArgs e) { String uSource = string.Empty; List <ILayer> list = new List <ILayer>(); try { //Verify(); if (ClsDeclare.g_pMap.LayerCount <= 0) { MessageBox.Show("图层控件中没有图层,请添加图层!"); return; } string strQuery; strQuery = this.txtExpress.Text; if (strQuery == "") { return; } Collection <IRow> collect = new Collection <IRow>(); int i = 0, j = 0; try { //FrmItemAttr frmItemAttr = new FrmItemAttr(); if (this.txtExpress.Text == "") { //ClsDeclare.g_ErrorHandler.DisplayInformation("请选择查询表达式", false, "确定", null); return; } if (relationTable != null) { for (i = 0; i < relationTable.Fields.FieldCount; i++) { //string test1 = relationTable.Fields.get_Field(i).Name.ToString(); //string test2 = SubstrField(this.lstField.Text.Trim()); if (relationTable.Fields.get_Field(i).Name.ToString().Trim() == SubstrField(this.lstField.Text.Trim())) { ICursor pCursor; pCursor = relationTable.Search(null, false); IRow pRow; pRow = pCursor.NextRow(); while (pRow != null) { string test = this.lstValue.SelectedItem.ToString().Replace("'", ""); string test3 = pRow.get_Value(i).ToString(); if (pRow.get_Value(i).ToString() == this.lstValue.SelectedItem.ToString().Replace("'", "")) { collect.Add(pRow); } pRow = pCursor.NextRow(); } } } } //for (j = 0; j < collect.Count; j++) //{ // frmItemAttr.LoadData(collect[j]); //} //frmItemAttr.Show(); //break; } catch (Exception) { //ClsDeclare.g_ErrorHandler.DisplayInformation("可能表达式有误,请先验证表达式", false, "确定",null); //throw; MessageBoxEx.Show("可能表达式有误,请先验证表达式"); } if (collect.Count > 0) { for (j = 0; j < collect.Count; j++) { IRow ptempRow = collect[j]; uSource = ptempRow.get_Value(ptempRow.Fields.FindField("ESOURCE")).ToString(); list = GetLayers(uSource); } } for (int k = 0; k < list.Count; k++) { ILayer pLayer; //pLayer = ClsSelectQuery.FunFindFeatureLayerByName(cboLayerList.Text, ClsDeclare.g_pMap); pLayer = list[k]; if (pLayer == null) { return; } IFeatureLayer pFeatLayer; pFeatLayer = pLayer as IFeatureLayer; //if (pFeatLayer.Visible == false) //{ //} //ClsDeclare.g_ErrorHandler.DisplayInformation("请选择可见图层",false,"确定",null); IFeatureSelection pFeatureSelection; pFeatureSelection = pFeatLayer as IFeatureSelection; IQueryFilter pQueryFilter = new QueryFilterClass(); pQueryFilter.WhereClause = strQuery; esriSelectionResultEnum SelType; SelType = esriSelectionResultEnum.esriSelectionResultNew; switch (this.cboSelectMethod.Text) { case "创建一个新的选择结果": { if (ClsDeclare.g_pMap.SelectionCount > 0) { ClsDeclare.g_pMap.ClearSelection(); } SelType = esriSelectionResultEnum.esriSelectionResultNew; } break; case "添加到当前选择集中": SelType = esriSelectionResultEnum.esriSelectionResultAdd; break; case "从当前选择结果中移除": SelType = esriSelectionResultEnum.esriSelectionResultSubtract; break; case "从当前选择结果中选择": SelType = esriSelectionResultEnum.esriSelectionResultAnd; break; } if (pFeatLayer.Selectable) { pFeatureSelection.SelectFeatures(pQueryFilter, SelType, false); } IActiveView pActiveView; pActiveView = ClsDeclare.g_pMap as IActiveView; pActiveView.Refresh(); IFeatureClass pFeatCls; IGeometryCollection pGeometryCol; IGeometryBag pGeometryBag; IEnumIDs pEnumIDs; IFeature pFeature; int iOBJID; pGeometryCol = new GeometryBagClass(); pGeometryBag = pGeometryCol as IGeometryBag; pFeatCls = pFeatLayer.FeatureClass; pEnumIDs = pFeatureSelection.SelectionSet.IDs; iOBJID = pEnumIDs.Next(); object Missing = Type.Missing; object Missing1 = Type.Missing; while (iOBJID != -1) { pFeature = pFeatCls.GetFeature(iOBJID); pGeometryCol.AddGeometry(pFeature.Shape, ref Missing, ref Missing1); iOBJID = pEnumIDs.Next(); } IHookActions pHookActions; IHookHelper pHookHelper; pHookHelper = new HookHelperClass(); pHookHelper.Hook = ClsDeclare.g_Sys.MapControl.Object; pHookActions = pHookHelper as IHookActions; if (pHookActions.get_ActionSupported(pGeometryBag.Envelope, esriHookActions.esriHookActionsPan)) { pHookActions.DoAction(pGeometryBag.Envelope, esriHookActions.esriHookActionsPan); } Application.DoEvents(); } } catch (Exception ex) { //MessageBox.Show("错误", ex.StackTrace, MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show("表达式错误", ex.StackTrace, MessageBoxButtons.OK, MessageBoxIcon.Error); //ClsDeclare.g_ErrorHandler.HandleError(true,null,0,null,ex.StackTrace); throw; } }
/// <summary> /// 显示节点的信息 /// </summary> /// <param name="node"></param> private void ShowClickedNodeInfo(TreeNode nodeClicked, bool doFlash) { if (nodeClicked == null) { //初始化树型显示窗口 InitializeAttributesList(); return; } //获取点击点对应的要素 int nodeLevel = nodeClicked.Level; //获取点击的是图层还是图层下的要素 //若featureIndex < 0则表示点击的是图层,闪烁图层下选中的所有要素 //反之,则表示点击的是图层下的要素,获取图层索引和要素索引, //用于在结果列表中安索引获取要素或要素集属性 int layerIndex = -1; int featureIndex = -1; if (nodeLevel > 0) { TreeNode parentNode = nodeClicked.Parent; layerIndex = parentNode.Index; featureIndex = nodeClicked.Index; } else { layerIndex = nodeClicked.Index; } //获取对应要素 LayerIdentifiedResult layerResult = identifiedResultsList[layerIndex]; //点击了图层下的要素 if (featureIndex > -1) { IFeatureIdentifyObj identifyObjDefault = layerResult.IdentifiedFeatureObjList[featureIndex]; IFeature featureDefault = (identifyObjDefault as IRowIdentifyObject).Row as IFeature; //显示属性 ShowFeatureAttributes(featureDefault); //判断是否闪烁要素 if (doFlash) { HookHelperClass hookHelper = new HookHelperClass(); hookHelper.Hook = MainForm.Instance.AxMapCtrl.Object; IHookActions hookAction = (IHookActions)hookHelper; hookAction.DoAction(featureDefault.Shape, esriHookActions.esriHookActionsPan); Application.DoEvents(); hookAction.DoAction(featureDefault.Shape, esriHookActions.esriHookActionsFlash); //IIdentifyObj identifyObj = identifyObjDefault as IIdentifyObj; //if (identifyObj != null) //{ // // identifyObj.Flash(associateMapControl.ActiveView.ScreenDisplay); // // identifyObj.Flash(MapUtils.GetActiveView().ScreenDisplay); //} } } //点击了图层,同时闪烁图层下的所有要素图形 else { flashObjects.FlashObjects(layerResult); } }