Esempio n. 1
0
        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            // TODO:  Add ToolCreateParallel.OnMouseDown implementation
            if (Button == 1 && (m_pMapCtl = ClsGlobal.GetMapControl(m_hookHelper)) != null)
            {
                IMap   pMap = m_pMapCtl.Map;
                IPoint po   = m_pMapCtl.ToMapPoint(X, Y);
                ISelectionEnvironment pSelectionEnv = new SelectionEnvironmentClass();

                IGeometry geometry = new PolygonClass();
                geometry = m_pMapCtl.TrackRectangle();
                pMap.SelectByShape(geometry, pSelectionEnv, true);
                m_pMapCtl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
                IEnumFeatureSetup pSelectionsetup = pMap.FeatureSelection as IEnumFeatureSetup;
                pSelectionsetup.AllFields = true;//这里是关键
                IEnumFeature pFeatureCollection = pSelectionsetup as IEnumFeature;
                IFeature     pF = pFeatureCollection.Next();
                if (pF != null && pF.Shape is IPolyline)
                {
                    FrmParallelLineOffset frm = new FrmParallelLineOffset();
                    if (frm.ShowDialog() == DialogResult.OK)
                    {
                        IPolyline pPolyline = ConstructOffset(pF.Shape as IPolyline, frm.offset);
                        IFeature  pFeature  = m_FLayer.FeatureClass.CreateFeature();
                        pFeature.Shape = pPolyline;
                        pFeature.Store();
                        m_pMapCtl.Refresh();
                    }
                }
            }
        }
Esempio n. 2
0
        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            // TODO:  Add TrackZoomIn.OnMouseDown implementation
            IEnvelope pEnv;

            pEnv = mapControl.TrackRectangle();
            mapControl.Extent = pEnv;//·Å´ó
        }
Esempio n. 3
0
        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            // TODO:  Add SearchAndZoomIn.OnMouseDown implementation
            //空间查询
            try
            {
                MyMapControl.Map.ClearSelection();
                MyMapControl.Refresh();
                IArray geoArray = new ArrayClass();

                if (MyselectedLayer == null)
                {
                    return;
                }
                IFeatureLayer featureLayer = MyselectedLayer as IFeatureLayer;
                if (featureLayer == null)
                {
                    return;
                }
                IFeatureClass featureClass = featureLayer.FeatureClass;
                if (featureClass == null)
                {
                    return;
                }

                IEnvelope      envelope      = MyMapControl.TrackRectangle();
                IGeometry      geometry      = envelope as IGeometry;
                ISpatialFilter spatialFilter = new SpatialFilterClass();
                spatialFilter.Geometry = geometry;//指定几何体
                switch (featureClass.ShapeType)
                {
                case esriGeometryType.esriGeometryPoint:
                    spatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelContains;
                    break;

                case esriGeometryType.esriGeometryPolygon:
                    spatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;
                    break;

                case esriGeometryType.esriGeometryPolyline:
                    spatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelCrosses;
                    break;
                }
                spatialFilter.GeometryField = featureClass.ShapeFieldName;

                IQueryFilter filter = spatialFilter as IQueryFilter;//筛选器

                IFeatureCursor cursor = featureClass.Search(filter, false);
                // 缩放到选择结果集,并高亮显示
                ZoomToSelectedFeature((IFeatureLayer)MyselectedLayer, filter);
            }
            catch { }
        }
Esempio n. 4
0
        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            // TODO:  Add TrackZoomOut.OnMouseDown implementation
            IEnvelope pEnv;

            //mapControl.MousePointer = esriControlsMousePointer.esriPointerZoomOut;
            pEnv = mapControl.TrackRectangle();
            mapControl.Extent = pEnv;//缩小前预处理
            try
            {
                pEnv.Expand(2, 2, true);  //缩小
                mapControl.Extent = pEnv; //先放大在按比例缩小;
            }
            catch { }
        }
Esempio n. 5
0
        private void axMapControl1_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e)
        {
            this.axMapControl1.Focus();
            this.axMapControl1.Map.ClearSelection();
            IPoint point = this.axMapControl1.ToMapPoint(e.x, e.y);

            switch (currentTool)
            {
            //矩形框查询
            case CustomTool.RectSelect:
                //  toolStripComboBox2.ComboBox.
                if (this.toolStripComboBox2.SelectedIndex < 0)
                {
                    MessageBox.Show("尚未选择任何查询图层");
                    return;
                }
                IEnvelope pRect = m_mapControl.TrackRectangle();
                spatiallUI.DealFeatureQuery(this.axMapControl1, pRect as IGeometry, null, this.toolStripComboBox2.Text);
                this.axMapControl1.Refresh(esriViewDrawPhase.esriViewGeography, null, null);
                break;

            //经过点插入
            case CustomTool.StopInsert:
                routeUI.InsertStopPoint(this.axMapControl1, point);
                break;

            //障碍点插入
            case CustomTool.BarryInsert:
                routeUI.InsertBarryPoint(this.axMapControl1, point);
                break;

            //经过点移除
            case CustomTool.StopRemove:
                routeUI.RemoveStopPoint(this.axMapControl1, point);
                break;

            //障碍点移除
            case CustomTool.BarryRemove:
                routeUI.RemoveBarryPoint(this.axMapControl1, point);
                break;
            }
        }
Esempio n. 6
0
        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            try
            {
                if (Button == 1)
                {
                    IPoint pPnt = m_hookHelper.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y);
                    ISelectionEnvironment pSelEnv = new SelectionEnvironmentClass();
                    pSelEnv.SearchTolerance   = 3;
                    pSelEnv.CombinationMethod = esriSelectionResultEnum.esriSelectionResultAdd;  //添加新的选择要素
                    m_hookHelper.FocusMap.SelectByShape(m_pMapControl.TrackRectangle(), pSelEnv, false);
                    m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, null);
                    //GIS.GraphicEdit.FeatureSelect featSelectTool = new GraphicEdit.FeatureSelect();
                    //featSelectTool.OnCreate(m_hookHelper.Hook);
                    //m_pMapControl.CurrentTool = featSelectTool;


                    m_FeatureExtend = GetExtendLine();

                    if (m_FeatureExtend != null && m_FeatureRef != null)
                    {
                        bool bSuccess = ExtendLine(m_FeatureExtend, m_FeatureRef);
                        if (bSuccess)
                        {
                            m_hookHelper.FocusMap.ClearSelection();
                            m_hookHelper.ActiveView.Refresh();
                        }
                        else
                        {
                            MessageBox.Show(@"无法将当前所选线要素延伸到参考线", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                    }
                }
                else if (Button == 2)
                {
                    //switch (m_MouseDownCount)
                    //{
                    //    case 0:
                    //        if (m_hookHelper.FocusMap.SelectionCount == 1)
                    //        {
                    //            m_FeatureRef =  GetRefPolyline();
                    //            m_MouseDownCount = 1;
                    //        }
                    //        break;

                    //    case 1:
                    //        if (m_hookHelper.FocusMap.SelectionCount > 1)
                    //        {
                    //            m_FeatureExtend= GetExtendLine();
                    //            m_MouseDownCount = 2;
                    //        }
                    //        break;

                    //    case 2:
                    //        m_MouseDownCount = 0;

                    //        //if (m_FeatureExtend != null && m_FeatureRef != null)
                    //        //{
                    //        //   bool bSuccess = ExtendLine(m_FeatureExtend, m_FeatureRef);
                    //        //    m_hookHelper.FocusMap.ClearSelection();
                    //        //    m_hookHelper.ActiveView.Refresh();
                    //        //}
                    //        //else
                    //        //{
                    //        //    MessageBox.Show("请先选择需要延伸的线要素", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    //        //}
                    //        break;
                    //}
                }
            }
            catch { }
        }
Esempio n. 7
0
        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            if (m_hookHelper != null)
            {
                ClsMapLayer pConvert = new ClsMapLayer();
                IGeometry   pGeometry;
                IActiveView pActiveView;
                pActiveView = m_hookHelper.ActiveView;
                IPoint pPoint;
                pPoint    = pActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y);
                pGeometry = (IGeometry)pPoint;

                if (ClsDeclare.g_pMap.SelectionCount != 0)
                {
                    ClsDeclare.g_pMap.ClearSelection();
                }
                pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, null);

                ISelectionEnvironment pSelectEnv = new SelectionEnvironmentClass();
                double Length;
                Length = pConvert.ConvertPixelDistanceToMapDistance(pActiveView, pSelectEnv.SearchTolerance);

                ITopologicalOperator pTopoOpera;
                IGeometry            pBuffer;
                pTopoOpera = (ITopologicalOperator)pGeometry;
                pBuffer    = pTopoOpera.Buffer(Length);

                IEnvelope pEnvelope;
                pEnvelope = m_pMapControl.TrackRectangle();
                pGeometry = (IGeometry)pEnvelope;

                Application.DoEvents();
                m_pMapControl.MousePointer = esriControlsMousePointer.esriPointerHourglass;

                if (pGeometry != null)
                {
                    if (pEnvelope.IsEmpty)
                    {
                        pGeometry = pBuffer.Envelope;
                    }
                }
                esriSelectionResultEnum pselecttype = new esriSelectionResultEnum();
                switch (Shift)
                {
                case 0:
                {
                    pselecttype = esriSelectionResultEnum.esriSelectionResultNew;
                    switch (mvarSelectMethod)
                    {
                    case "New":
                        pselecttype = esriSelectionResultEnum.esriSelectionResultNew;
                        break;

                    case "Add":
                        pselecttype = esriSelectionResultEnum.esriSelectionResultAnd;
                        break;

                    case "Sub":
                        pselecttype = esriSelectionResultEnum.esriSelectionResultSubtract;
                        break;

                    case "Xor":
                        pselecttype = esriSelectionResultEnum.esriSelectionResultXOR;
                        break;
                    }
                    break;
                }

                case 1:
                    pselecttype = esriSelectionResultEnum.esriSelectionResultAdd;
                    break;

                case 2:
                    pselecttype = esriSelectionResultEnum.esriSelectionResultXOR;
                    break;

                case 3:
                    pselecttype = esriSelectionResultEnum.esriSelectionResultNew;
                    break;

                case 4:
                    pselecttype = esriSelectionResultEnum.esriSelectionResultSubtract;
                    break;
                }
                if (m_FeatClsCln == null)
                {
                    bool blntemp = false;
                    m_pQueryResultCln = new Collection();
                    ClsSelectQuery.SelectGeometry(ref blntemp, pGeometry, pselecttype, ref m_pQueryResultCln);
                    pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, null);
                    if (m_frmQuery == null)
                    {
                        m_frmQuery = new FrmQuery();
                    }
                    if (m_frmQuery.IsDisposed)
                    {
                        m_frmQuery = new FrmQuery();
                    }
                    m_frmQuery.QueryResultCln = m_pQueryResultCln;
                    m_frmQuery.ReLoadQueryResult();
                    m_frmQuery.Visible = false;
                    m_frmQuery.Show((Form)(ClsDeclare.g_Sys.FrmMain));
                }
                m_pQueryResultCln          = null;
                m_pMapControl.MousePointer = esriControlsMousePointer.esriPointerDefault;
            }
            else if (m_sceneHookHelper != null)
            {
            }
            else if (m_globeHookHelper != null)
            {
            }
        }
Esempio n. 8
0
        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            // TODO:  Add TrackRectangleQuary.OnMouseDown implementation
            //空间查询
            try
            {
                MyMapControl.Map.ClearSelection();
                MyMapControl.Refresh();
                IArray geoArray = new ArrayClass();

                if (MyselectedLayer == null)
                {
                    return;
                }
                IFeatureLayer featureLayer = MyselectedLayer as IFeatureLayer;
                if (featureLayer == null)
                {
                    return;
                }
                IFeatureClass featureClass = featureLayer.FeatureClass;
                if (featureClass == null)
                {
                    return;
                }

                IEnvelope envelope = MyMapControl.TrackRectangle();
                //IGeometry geometry = MyMapControl.TrackCircle();
                IGeometry      geometry      = envelope as IGeometry;
                ISpatialFilter spatialFilter = new SpatialFilterClass();
                spatialFilter.Geometry = geometry;//指定几何体
                switch (featureClass.ShapeType)
                {
                case esriGeometryType.esriGeometryPoint:
                    spatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelContains;
                    break;

                case esriGeometryType.esriGeometryPolygon:
                    spatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;
                    break;

                case esriGeometryType.esriGeometryPolyline:
                    spatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelCrosses;
                    break;
                }
                spatialFilter.GeometryField = featureClass.ShapeFieldName;

                IQueryFilter filter = spatialFilter as IQueryFilter;//筛选器

                IFeatureCursor cursor   = featureClass.Search(filter, false);
                IFeature       pfeature = cursor.NextFeature();
                MyselectedFeature = new List <IFeature>();//此处**初始化list
                while (pfeature != null)
                {
                    //geoArray.Add(pfeature);//直接存入数组geoArray用于闪烁
                    MyselectedFeature.Add(pfeature); //存入list
                    pfeature = cursor.NextFeature(); //枚举
                }
                //或者将list(MyselectedFeature)转存入数组geoArray用于闪烁

                /*for (int i = 0; i < MyselectedFeature.Count; i++)
                 * {
                 *  geoArray.Add(MyselectedFeature[i]);
                 * }*/
                SelectOnMouseDown();        //高亮
                FlashAndIdentify(geoArray); //闪烁
            }
            catch { }
        }
Esempio n. 9
0
        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            if (m_hookHelper != null)
            {
                try
                {
                    IActiveView pActiveView;
                    pActiveView = m_hookHelper.ActiveView;

                    IEnvelope pEnv;
                    pEnv        = m_pMapControl.TrackRectangle();
                    m_pGeometry = (IGeometry)pEnv;

                    esriSelectionResultEnum pselecttype = new esriSelectionResultEnum();
                    switch (Shift)
                    {
                    case 0:
                    {
                        pselecttype = esriSelectionResultEnum.esriSelectionResultNew;
                        switch (mvarSelectMethod)
                        {
                        case "New":
                            pselecttype = esriSelectionResultEnum.esriSelectionResultNew;
                            break;

                        case "Add":
                            pselecttype = esriSelectionResultEnum.esriSelectionResultAnd;
                            break;

                        case "Sub":
                            pselecttype = esriSelectionResultEnum.esriSelectionResultSubtract;
                            break;

                        case "Xor":
                            pselecttype = esriSelectionResultEnum.esriSelectionResultXOR;
                            break;
                        }
                        break;
                    }

                    case 1:
                        pselecttype = esriSelectionResultEnum.esriSelectionResultAdd;
                        break;

                    case 2:
                        pselecttype = esriSelectionResultEnum.esriSelectionResultXOR;
                        break;

                    case 3:
                        pselecttype = esriSelectionResultEnum.esriSelectionResultNew;
                        break;

                    case 4:
                        pselecttype = esriSelectionResultEnum.esriSelectionResultSubtract;
                        break;
                    }
                    if (m_FeatClsCln == null)
                    {
                        bool blntemp = true;
                        m_pQueryResultCln = new Collection();
                        ClsSelectQuery.SelectGeometry(ref blntemp, m_pGeometry, pselecttype, ref m_pQueryResultCln);
                        pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, null);
                        if (m_frmQuery == null)
                        {
                            m_frmQuery = new FrmQuery();
                        }
                        if (m_frmQuery.IsDisposed)
                        {
                            m_frmQuery = new FrmQuery();
                        }
                        m_frmQuery.QueryResultCln = m_pQueryResultCln;
                        m_frmQuery.ReLoadQueryResult();
                        m_frmQuery.Visible = false;
                        m_frmQuery.Show((Form)(ClsDeclare.g_Sys.FrmMain));
                    }
                    m_pQueryResultCln = null;
                    if (ClsDeclare.g_pMap.SelectionCount > ClsDeclare.g_Sys.MaxSelectCount && ClsDeclare.g_Sys.MaxSelectCount != 0)
                    {
                        //if ((ClsDeclare.g_ErrorHandler.DisplayInformation("你选择的结果大于" + Convert.ToString(ClsDeclare.g_Sys.MaxSelectCount) + "个地物,是否继续选择操作?", true, "确定", "取消"))==false)
                        {
                            pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, null);
                            ClsDeclare.g_pMap.ClearSelection();
                            pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, null);
                        }
                    }
                }
                catch (Exception)
                {
                    //ClsDeclare.g_ErrorHandler.HandleError(true, null, 0, null, ex.StackTrace);
                    throw;
                }
            }
            else if (m_sceneHookHelper != null)
            {
            }
            else if (m_globeHookHelper != null)
            {
            }
        }