private void SnapFeature(out IFeature pFeature) { pFeature = null; IFeatureCache featureCacheClass = new FeatureCache(); featureCacheClass.Initialize(SketchShareEx.m_pAnchorPoint, 6); IFeatureLayer featureLayer = Yutai.ArcGIS.Common.Editor.Editor.CurrentEditTemplate.FeatureLayer; if (featureLayer.FeatureClass != null) { featureCacheClass.AddFeatures(featureLayer.FeatureClass); if (featureCacheClass.Count != 0) { Yutai.ArcGIS.Common.Editor.Editor.GetClosestSelectedFeature(featureCacheClass, SketchShareEx.m_pAnchorPoint, out pFeature); } } }
public bool SnapPoint(IPoint ipoint_0, IPoint ipoint_1) { bool result; if (!this.bool_0) { result = false; } else { double num = this.double_0; if (this._appContext != null && this.esriEngineSnapToleranceUnits_0 == esriEngineSnapToleranceUnits.esriEngineSnapTolerancePixels) { num = this.method_0(this._appContext.MapControl.Map as IActiveView, this.double_0); if (num == 0.0) { num = this.double_0; } } System.Collections.Hashtable hashtable = new System.Collections.Hashtable(); for (int i = 0; i < this.iarray_0.Count; i++) { IEngineSnapAgent engineSnapAgent = (IEngineSnapAgent)this.iarray_0.get_Element(i); IFeatureCache featureCache = null; if (engineSnapAgent is IFeatureSnapAgent) { IFeatureClass featureClass = (engineSnapAgent as IFeatureSnapAgent).FeatureClass; try { featureCache = (hashtable[featureClass] as IFeatureCache); goto IL_10F; } catch { goto IL_10F; } goto IL_C6; IL_E9: (engineSnapAgent as IFeatureSnapAgent).FeatureCache = featureCache; goto IL_F7; IL_10F: if (featureCache != null) { goto IL_E9; } IL_C6: featureCache = new FeatureCache(); featureCache.Initialize(ipoint_1, num); featureCache.AddFeatures(featureClass); hashtable.Add(featureClass, featureCache); goto IL_E9; } IL_F7: if (engineSnapAgent.Snap(ipoint_0, ipoint_1, num)) { result = true; return(result); } } hashtable.Clear(); result = false; } return(result); }
private bool SnapAll(IPoint pPoint, IAppContext appContext, double torelance, out IPoint snapPoint) { IMap focusMap = appContext.FocusMap; snapPoint = null; bool result; if (!appContext.Config.UseSnap) { result = false; } else { if (appContext.Config.IsSnapSketch) { IHitTest hitTest = SketchToolAssist.m_pPointColn as IHitTest; if (hitTest != null) { double num = 0.0; int num2 = 0; int num3 = 0; bool flag = false; IPoint point = new Point(); if (hitTest.HitTest(pPoint, torelance, esriGeometryHitPartType.esriGeometryPartVertex, point, ref num, ref num2, ref num3, ref flag)) { snapPoint = point; string toolTip = "草图:折点"; ApplicationRef.Application.SetToolTip(toolTip); result = true; return(result); } } } IEnumLayer enumLayer = focusMap.get_Layers(new UID { Value = "{6CA416B1-E160-11D2-9F4E-00C04F6BC78E}" }, true); enumLayer.Reset(); enumLayer.Next(); IFeatureCache2 featureCache = new FeatureCache() as IFeatureCache2; featureCache.Initialize(pPoint, torelance); try { featureCache.AddLayers(enumLayer, (appContext.MapControl.ActiveView as IActiveView).Extent); } catch { } if (featureCache.Count == 0) { result = false; } else { if (appContext.Config.IsSnapPoint) { snapPoint = this.SnapPoint(pPoint, featureCache, torelance); if (snapPoint != null) { result = true; return(result); } } if (appContext.Config.IsSnapIntersectionPoint) { snapPoint = this.SnapIntersectPoint(pPoint, featureCache, torelance); if (snapPoint != null) { result = true; return(result); } } if (appContext.Config.IsSnapEndPoint) { snapPoint = this.SnapEndPoint(pPoint, featureCache, torelance); if (snapPoint != null) { result = true; return(result); } } if (appContext.Config.IsSnapVertexPoint) { snapPoint = this.SnapVertexPoint(pPoint, featureCache, torelance); if (snapPoint != null) { result = true; return(result); } } if (appContext.Config.IsSnapMiddlePoint) { snapPoint = this.SnapMiddlePoint(pPoint, featureCache, torelance); if (snapPoint != null) { result = true; return(result); } } if (appContext.Config.IsSnapBoundary) { snapPoint = this.SnapBoundary(pPoint, featureCache, torelance); if (snapPoint != null) { result = true; return(result); } } result = false; } } return(result); }