示例#1
0
        public override void OnMouseMove(int Button, int Shift, int X, int Y)
        {
            if (m_pFeature == null)
            {
                return;
            }
            IPoint pPnt = m_MapControl.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y);

            //鼠标在选择集的范围外为选择功能
            if (ModPublic.MouseOnSelection(pPnt, m_hookHelper.ActiveView) == false && m_bMouseDown == false)
            {//若光标不在选择的对象上,为选择功能
                ControlsEditSelFeature clsSelectFeature = new ControlsEditSelFeature();
                clsSelectFeature.OnCreate(m_hookHelper.Hook);
                clsSelectFeature.OnClick();
                m_MapControl.CurrentTool = clsSelectFeature as ITool;
                return;
            }
            //范围内为移动要素功能且不在要素节点上
            else if (ModPublic.MouseOnFeatureVertex(pPnt, m_pFeature, m_hookHelper.ActiveView) == false && m_bMouseDown == false)
            {
                ControlsMoveSelFeature pControlsMoveSelFeature = new ControlsMoveSelFeature();
                pControlsMoveSelFeature.OnCreate(m_hookHelper.Hook);
                pControlsMoveSelFeature.OnClick();
                m_MapControl.CurrentTool = pControlsMoveSelFeature as ITool;
                return;
            }


            if (m_pVertexFeed == null)
            {
                return;
            }
            //捕捉节点
            if (MoData.v_bSnapStart)
            {
                m_pSnapPoint = ModPublic.SnapPoint(pPnt, m_hookHelper.ActiveView);
            }

            IHitTest pHitTest           = m_pFeature.Shape as IHitTest;
            IPoint   pHitPoint          = new PointClass();
            double   dblHitDistance     = 0;
            int      lPart              = 0;
            int      intHitSegmentIndex = 0;
            bool     bRight             = false;
            bool     bHitTest           = pHitTest.HitTest(pPnt, m_dblTolearance, esriGeometryHitPartType.esriGeometryPartVertex, pHitPoint, ref dblHitDistance, ref lPart, ref intHitSegmentIndex, ref bRight);

            if (m_pSnapPoint != null && MoData.v_bSnapStart)
            {
                m_pVertexFeed.MoveTo(m_pSnapPoint);
            }
            else
            {
                m_pVertexFeed.MoveTo(pPnt);
            }
        }
示例#2
0
        public override void OnMouseMove(int Button, int Shift, int X, int Y)
        {
            //鼠标在选择集的范围内则TOOL置为移动工具
            IPoint pPnt = m_hookHelper.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y);

            if (ModPublic.MouseOnSelection(pPnt, m_hookHelper.ActiveView) == true)
            {
                if (m_pControlsMoveSelFeature == null)
                {
                    m_pControlsMoveSelFeature = new ControlsMoveSelFeature();
                    m_pControlsMoveSelFeature.OnCreate(m_hookHelper.Hook);
                    m_MapControl.CurrentTool = m_pControlsMoveSelFeature as ITool;
                }
                else
                {
                    m_MapControl.CurrentTool = m_pControlsMoveSelFeature as ITool;
                }
            }
            else
            {
                m_MapControl.CurrentTool = this as ITool;
            }
        }
示例#3
0
        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            if (Button != 1)
            {
                return;
            }
            MoData.v_bVertexSelectionTracker = false;

            //设置点选择容差
            ISelectionEnvironment pSelectEnv = new SelectionEnvironmentClass();
            double Length = ModPublic.ConvertPixelsToMapUnits(m_hookHelper.ActiveView, pSelectEnv.SearchTolerance);

            IPoint               pPoint    = m_hookHelper.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y);
            IGeometry            pGeometry = pPoint as IGeometry;
            ITopologicalOperator pTopo     = pGeometry as ITopologicalOperator;
            IGeometry            pBuffer   = pTopo.Buffer(Length);

            //仅与框架别界相交地物会被选取
            pGeometry = m_MapControl.TrackRectangle() as IGeometry;
            bool bjustone = true;

            if (pGeometry != null)
            {
                if (pGeometry.IsEmpty)
                {
                    pGeometry = pBuffer;
                }
                else
                {
                    bjustone = false;
                }
            }
            else
            {
                pGeometry = pBuffer;
            }

            UID pUID = new UIDClass();

            pUID.Value = "{40A9E885-5533-11d0-98BE-00805F7CED21}";   //UID for IFeatureLayer
            IEnumLayer pEnumLayer = m_MapControl.Map.get_Layers(pUID, true);

            pEnumLayer.Reset();
            ILayer pLayer = pEnumLayer.Next();

            while (pLayer != null)
            {
                if (pLayer.Visible == false)
                {
                    pLayer = pEnumLayer.Next();
                    continue;
                }
                IFeatureLayer pFeatureLayer = pLayer as IFeatureLayer;
                if (pFeatureLayer.Selectable == false)
                {
                    pLayer = pEnumLayer.Next();
                    continue;
                }

                GetSelctionSet(pFeatureLayer, pGeometry, bjustone, Shift);

                pLayer = pEnumLayer.Next();
            }

            //触发Map选择发生变化事件
            ISelectionEvents pSelectionEvents = m_hookHelper.FocusMap as ISelectionEvents;

            pSelectionEvents.SelectionChanged();
            //刷新
            m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, m_hookHelper.ActiveView.Extent);

            //鼠标在选择集的范围内则TOOL置为移动工具
            if (ModPublic.MouseOnSelection(pPoint, m_hookHelper.ActiveView) == true)
            {
                m_pControlsMoveSelFeature = new ControlsMoveSelFeature();
                m_pControlsMoveSelFeature.OnCreate(m_hookHelper.Hook);
                m_MapControl.CurrentTool = m_pControlsMoveSelFeature as ITool;
            }
        }