Esempio n. 1
0
        public void RefreshSnapAgent(List <SnapAgent> pSnapAgents, bool pSnapTip)
        {
            IEngineSnapEnvironment environment = this._editor as IEngineSnapEnvironment;

            environment.ClearSnapAgents();
            this._snapLayers.Clear();
            foreach (SnapAgent agent in pSnapAgents)
            {
                try
                {
                    esriGeometryHitPartType esriGeometryPartNone = esriGeometryHitPartType.esriGeometryPartNone;
                    if (agent.Vertex)
                    {
                        esriGeometryPartNone ^= esriGeometryHitPartType.esriGeometryPartVertex;
                    }
                    if (agent.Edge)
                    {
                        esriGeometryPartNone ^= esriGeometryHitPartType.esriGeometryPartBoundary;
                    }
                    if (agent.EndPoint)
                    {
                        esriGeometryPartNone ^= esriGeometryHitPartType.esriGeometryPartEndpoint;
                    }
                    if (esriGeometryPartNone != esriGeometryHitPartType.esriGeometryPartNone)
                    {
                        IEngineFeatureSnapAgent snapAgent = new EngineFeatureSnapClass
                        {
                            FeatureClass = agent.FeatureLayer.FeatureClass,
                            HitType      = esriGeometryPartNone
                        };
                        environment.AddSnapAgent(snapAgent);
                        this._snapLayers.Add(agent.FeatureLayer);
                    }
                }
                catch
                {
                }
            }
            ((IEngineEditProperties2)this._editor).SnapTips = pSnapTip;
        }
Esempio n. 2
0
        public void InitSnapEnvironment()
        {
            SnapConfigControl.LayerSnapInfo element;
            int i;
            int hitType;
            FeatureSnapAgent featureSnapAgent;

            try
            {
                double num = double.Parse(this.txtRadio.Text);
                if (num <= 0)
                {
                    MessageBox.Show("数据输入错误!");
                }
                else if (this.m_pEngineSnapEnvironment == null)
                {
                    this.m_pSnapEnvironment.SnapTolerance = num;
                }
                else
                {
                    this.m_pEngineSnapEnvironment.SnapTolerance = num;
                }
            }
            catch
            {
                MessageBox.Show("数据输入错误!");
            }
            if (this.m_pEngineSnapEnvironment == null)
            {
                this.m_pSnapEnvironment.SnapToleranceUnits =
                    (esriEngineSnapToleranceUnits)this.cboSnapUnits.SelectedIndex;
                ApplicationRef.Application.UseSnap = this.chkStartSnap.Checked;
                this.m_pSnapEnvironment.ClearSnapAgents();
                for (i = 0; i < this.m_pArray.Count; i++)
                {
                    element = (SnapConfigControl.LayerSnapInfo) this.m_pArray.Element[i];
                    hitType = element.HitType;
                    if (hitType != 0)
                    {
                        featureSnapAgent = new FeatureSnapAgent()
                        {
                            FeatureClass    = element.Layer.FeatureClass,
                            GeometryHitType = hitType
                        };
                        this.m_pSnapEnvironment.AddSnapAgent(featureSnapAgent);
                    }
                    if (element.bVerticalSnap)
                    {
                        featureSnapAgent = new FeatureSnapAgent()
                        {
                            FeatureClass = element.Layer.FeatureClass
                        };
                        this.m_pSnapEnvironment.AddSnapAgent(featureSnapAgent);
                    }
                }
            }
            else
            {
                this.m_pEngineSnapEnvironment.ClearSnapAgents();
                this.m_pEngineSnapEnvironment.SnapToleranceUnits =
                    (esriEngineSnapToleranceUnits)this.cboSnapUnits.SelectedIndex;
                for (i = 0; i < this.m_pArray.Count; i++)
                {
                    element = (SnapConfigControl.LayerSnapInfo) this.m_pArray.Element[i];
                    hitType = element.HitType;
                    if (hitType != 0)
                    {
                        IEngineFeatureSnapAgent engineFeatureSnapClass = new EngineFeatureSnapClass()
                        {
                            FeatureClass = element.Layer.FeatureClass,
                            HitType      = (esriGeometryHitPartType)hitType
                        };
                        this.m_pEngineSnapEnvironment.AddSnapAgent(engineFeatureSnapClass);
                    }
                    if (element.bVerticalSnap)
                    {
                        featureSnapAgent = new FeatureSnapAgent();
                        featureSnapAgent.FeatureClass = element.Layer.FeatureClass;
                    }
                }
            }
        }