示例#1
0
        /// <summary>
        /// Update the window with the current snap environment and snap tip settings
        /// </summary>
        private void RefreshDisplay()
        {
            snapTolerance.Text         = snapEnvironment.SnapTolerance.ToString();
            snapTolUnits.SelectedIndex = (int)snapEnvironment.SnapToleranceUnits;
            snapTips.Checked           = ((IEngineEditProperties2)editor).SnapTips;

            //remove all feature snap agents from the data grid view
            snapAgents.Rows.Clear();

            //display feature snap and snap agents that are active
            for (int i = 0; i < snapEnvironment.SnapAgentCount; i++)
            {
                try
                {
                    IEngineSnapAgent        snapAgent    = snapEnvironment.get_SnapAgent(i);
                    IEngineFeatureSnapAgent ftrSnapAgent = snapAgent as IEngineFeatureSnapAgent;

                    if (ftrSnapAgent != null)
                    {
                        //for feature snap agents add a row to the data view grid
                        esriGeometryHitPartType hitType = ftrSnapAgent.HitType;
                        bool vertex, edge, end;
                        vertex = (hitType & esriGeometryHitPartType.esriGeometryPartVertex) == esriGeometryHitPartType.esriGeometryPartVertex;
                        edge   = (hitType & esriGeometryHitPartType.esriGeometryPartBoundary) == esriGeometryHitPartType.esriGeometryPartBoundary;
                        end    = (hitType & esriGeometryHitPartType.esriGeometryPartEndpoint) == esriGeometryHitPartType.esriGeometryPartEndpoint;
                        string   vertexString = vertex ? "vertex" : "      ";
                        string   edgeString   = edge ? " edge" : "     ";
                        string   endString = end ? " end  " : "     ";
                        string   hitTypes  = vertexString + edgeString + endString;
                        object[] rowData   = { snapAgent.Name.ToString(), ftrSnapAgent.FeatureClass.AliasName, hitTypes };
                        snapAgents.Rows.Add(rowData);
                    }
                    else
                    {
                        //add the active edit sketch snap agents
                        object[] rowData = { snapAgent.Name.ToString(), "<not applicable>", "<not applicable>" };
                        snapAgents.Rows.Add(rowData);
                    }
                }
                catch (Exception)
                {
                }
            }
        }
示例#2
0
        /// <summary>
        /// Turns off feature snap agents and turns off edit sketch snap agents by removing them
        /// </summary>
        /// <remarks>
        /// Using Clear or Remove feature snap agents can be deactivated so that the user can't enable them.
        /// Here we simply turn off all the agents, which will allow the user to turn them on.
        /// </remarks>
        private void TurnOffAgents()
        {
            for (int i = snapEnvironment.SnapAgentCount - 1; i >= 0; i--)
            {
                IEngineSnapAgent        snapAgent    = snapEnvironment.get_SnapAgent(i);
                IEngineFeatureSnapAgent ftrSnapAgent = snapAgent as IEngineFeatureSnapAgent;
                if (ftrSnapAgent != null)
                {
                    //turn off the feature snap agent
                    ftrSnapAgent.HitType = esriGeometryHitPartType.esriGeometryPartNone;
                }
                else
                {
                    //there is no way to turn snap agents off, they must be removed
                    snapEnvironment.RemoveSnapAgent(i);
                }
            }

            //refresh this window
            RefreshDisplay();
        }
示例#3
0
        private void reverseAgentsPriority_Click(object sender, EventArgs e)
        {
            //get all the snap agents in reverse order and then deactivate them
            ArrayList snapAgentList = new ArrayList();

            for (int i = snapEnvironment.SnapAgentCount - 1; i >= 0; i--)
            {
                IEngineSnapAgent tmpAgent = snapEnvironment.get_SnapAgent(i);
                snapAgentList.Add(tmpAgent);
                snapEnvironment.RemoveSnapAgent(i);
            }

            //add the agents back to the environment
            foreach (IEngineSnapAgent agent in snapAgentList)
            {
                snapEnvironment.AddSnapAgent(agent);
            }

            //refresh this window
            RefreshDisplay();
        }
示例#4
0
        /// <summary>
        /// Adds, and hence turns on, Edit Sketch snap agents
        /// </summary>
        private void AddSketchSnapAgents()
        {
            //give anchor snap (i.e. vertex snap) priority to get more accurate snap tips while snapped to a vertex
            Type t = Type.GetTypeFromProgID("esriControls.EngineAnchorSnap");

            System.Object    obj       = Activator.CreateInstance(t);
            IEngineSnapAgent snapAgent = (IEngineSnapAgent)obj;

            snapEnvironment.AddSnapAgent(snapAgent);

            //edge sketch edges
            t         = Type.GetTypeFromProgID("esriControls.EngineSketchSnap");
            obj       = Activator.CreateInstance(t);
            snapAgent = (IEngineSnapAgent)obj;
            snapEnvironment.AddSnapAgent(snapAgent);

            //perpendicular to edit sketch
            t         = Type.GetTypeFromProgID("esriControls.EnginePerpendicularSnap");
            obj       = Activator.CreateInstance(t);
            snapAgent = (IEngineSnapAgent)obj;
            snapEnvironment.AddSnapAgent(snapAgent);
        }
示例#5
0
 public void AddSnapAgent(IEngineSnapAgent iengineSnapAgent_0)
 {
     this.iarray_0.Add(iengineSnapAgent_0);
 }
示例#6
0
        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);
        }