コード例 #1
0
        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            m_ActiveView = m_hookHelper.ActiveView;
            m_Map        = m_hookHelper.FocusMap;
            IScreenDisplay    pScreenDisplay = m_ActiveView.ScreenDisplay;
            IRubberBand       pRubberCircle  = new RubberCircleClass();
            ISimpleFillSymbol pFillSymbol    = new SimpleFillSymbolClass();

            pFillSymbol.Color = getRGB(255, 255, 0);
            IGeometry pCircle = pRubberCircle.TrackNew(pScreenDisplay, (ISymbol)pFillSymbol) as IGeometry;

            IConstructCircularArc pConstructArc   = pCircle as IConstructCircularArc;
            IPolygon           pPolygon           = new PolygonClass();
            ISegmentCollection pSegmentCollection = pPolygon as ISegmentCollection;
            ISegment           pSegment           = pConstructArc as ISegment;
            object             missing            = Type.Missing;

            pSegmentCollection.AddSegment(pSegment, ref missing, ref missing);
            pFillSymbol.Style = esriSimpleFillStyle.esriSFSDiagonalCross;
            pFillSymbol.Color = getRGB(255, 0, 0);
            IFillShapeElement pPolygonEle = new PolygonElementClass();

            pPolygonEle.Symbol = pFillSymbol;
            IElement pEle = pPolygonEle as IElement;

            pEle.Geometry = pPolygon;
            IGraphicsContainer pGraphicsContainer = m_Map as IGraphicsContainer;

            pGraphicsContainer.AddElement(pEle, 0);
            m_ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
        }
コード例 #2
0
ファイル: SelByCircle.cs プロジェクト: wwcc19870805/DIFGIS
        public override void OnMouseDown(int button, int shift, int x, int y, double mapX, double mapY)
        {
            if (button == 1)
            {
                int         dis;
                IRubberBand pRubberBand;
                pRubberBand = new RubberCircleClass();
                IGeometry          pCircle;
                ISegmentCollection pSegColl = new PolygonClass();

                pCircle = pRubberBand.TrackNew(m_Display, null);
                object a = Type.Missing;
                pSegColl.AddSegment((ISegment)pCircle, ref a, ref a);
                dis = Class.SelectionEnv.System_Selection_Environment(m_ActiveView).SearchTolerance;
                IFeatureSelection pFeaSel = m_pCurEditLayer as IFeatureSelection;

                IGeometry      pGeoSel    = Class.Common.DoBuffer((IPolygon)pSegColl, dis);
                ISpatialFilter pSpaFilter = new SpatialFilter();
                pSpaFilter.Geometry   = pGeoSel;
                pSpaFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;

                if (shift == 1)
                {
                    pFeaSel.CombinationMethod = esriSelectionResultEnum.esriSelectionResultAdd;

                    //Class.SelectionEnv.System_Selection_Environment(m_ActiveView).CombinationMethod = esriSelectionResultEnum.esriSelectionResultAdd;
                }

                if (Class.SelectionEnv.System_Selection_Environment(m_ActiveView).CombinationMethod == 0)//new selection
                {
                    this.m_ActiveView.FocusMap.ClearSelection();
                }
                else
                {
                    pFeaSel.CombinationMethod = esriSelectionResultEnum.esriSelectionResultNew;
                    this.m_ActiveView.FocusMap.ClearSelection();
                }
                pFeaSel.SelectFeatures(pSpaFilter, pFeaSel.CombinationMethod, false);

                //m_ActiveView.FocusMap.SelectByShape(Class.Common.DoBuffer(pLine, dis), Class.SelectionEnv.System_Selection_Environment(m_ActiveView), false);

                m_App.Workbench.UpdateMenu();

                if (m_ActiveView.FocusMap.SelectionCount > 0)
                {
                    m_ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, null);
                }
                else
                {
                    m_ActiveView.Refresh();
                }
            }
        }
コード例 #3
0
ファイル: SelectByCircle.cs プロジェクト: lidan233/C---
        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            // TODO:  Add SelectByCircle.OnMouseDown implementation

            // TODO:  Add selectAddByRectangle.OnMouseDown implementation


            IRubberBand        pRubberCircle      = new RubberCircleClass();
            IGeometry          pCircle            = pRubberCircle.TrackNew(m_hookHelper.ActiveView.ScreenDisplay, null) as IGeometry;
            IPolygon           pPolygon           = new PolygonClass();                //空的多边形
            ISegmentCollection pSegmentCollection = pPolygon as ISegmentCollection;    //段集合
            ISegment           pSegment           = pCircle as ISegment;               //将圆赋值给段
            object             missing            = Type.Missing;                      //显示默认值

            pSegmentCollection.AddSegment(pSegment, ref missing, ref missing);


            ISpatialFilter ipSpatialFilter = new SpatialFilterClass();


            ipSpatialFilter.Geometry   = pPolygon as IGeometry;
            ipSpatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;
            IFeatureSelection ipFeatSelect = m_hookHelper.FocusMap.get_Layer(1) as IFeatureSelection;

            ipFeatSelect.Clear();
            ipFeatSelect.SelectFeatures(ipSpatialFilter, esriSelectionResultEnum.esriSelectionResultNew, false);
            ipFeatSelect.SelectionSet.Refresh();
            m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, null);

            ICursor cur = null;

            ipFeatSelect.SelectionSet.Search(null, true, out cur);
            IFeature      feature = cur.NextRow() as IFeature;
            IFeatureLayer fl      = m_hookHelper.FocusMap.get_Layer(0) as IFeatureLayer;

            while (feature != null)
            {
                ITopologicalOperator to   = feature.Shape as ITopologicalOperator;
                IPolygon             poly = to.Buffer(0.01) as IPolygon;


                IFeature polyFeature = fl.FeatureClass.CreateFeature();
                polyFeature.Shape = poly;
                feature           = cur.NextRow() as IFeature;
                polyFeature.Store();
            }

            m_hookHelper.ActiveView.Refresh();
        }
コード例 #4
0
ファイル: GeometryUtility.cs プロジェクト: koson/CodeLab
        /// <summary>
        /// 屏幕上绘画几何形状
        /// </summary>
        /// <param name="screenDisplay">ESRI屏幕显示接口</param>
        /// <param name="geomType">几何形状类型的枚举类</param>
        /// <returns>ESRI几何形状接口</returns>
        public static IGeometry ScreenTrackGeometry(IScreenDisplay screenDisplay, dsGeometryType geomType)
        {
            IGeometry trackGeom = null;

            if (screenDisplay != null)
            {
                IRubberBand rubberBand = null;
                switch (geomType)
                {
                case dsGeometryType.dsGTPoint:
                    rubberBand = new RubberPointClass();
                    break;

                case dsGeometryType.dsGTLine:
                    rubberBand = new RubberLineClass();
                    break;

                case dsGeometryType.dsGTPolyline:
                    rubberBand = new RubberLineClass();
                    break;

                case dsGeometryType.dsGTRectangle:
                    rubberBand = new RubberEnvelopeClass();
                    break;

                case dsGeometryType.dsGTCircle:
                    rubberBand = new RubberCircleClass();
                    break;

                case dsGeometryType.dsGTEllipse:
                    rubberBand = new RubberEnvelopeClass();
                    break;

                case dsGeometryType.dsGTPolygon:
                    rubberBand = new RubberPolygonClass();
                    break;

                case dsGeometryType.dsGTRectangularPolygon:
                    rubberBand = new RubberRectangularPolygonClass();
                    break;

                default:
                    break;
                }
                if (rubberBand != null)
                {
                    trackGeom = rubberBand.TrackNew(screenDisplay, null);
                }
                if (geomType == dsGeometryType.dsGTEllipse)
                {
                    trackGeom = ConvertEnvelopeToEllipticArc(trackGeom);
                }
                else if ((geomType == dsGeometryType.dsGTLine) ||
                         (geomType == dsGeometryType.dsGTPolyline) ||
                         (geomType == dsGeometryType.dsGTPolygon))
                {
                    if (trackGeom is ITopologicalOperator)
                    {
                        (trackGeom as ITopologicalOperator).Simplify();
                    }
                }
            }
            return(trackGeom);
        }
コード例 #5
0
        public override void OnMouseDown(int button, int shift, int x, int y, double mapX, double mapY)
        {
            DF2DApplication app   = DF2DApplication.Application;
            bool            ready = true;

            if (app == null || app.Current2DMapControl == null)
            {
                return;
            }
            m_ActiveView = app.Current2DMapControl.ActiveView;
            IScreenDisplay m_Display = app.Current2DMapControl.ActiveView.ScreenDisplay;

            try
            {
                if (button == 1)
                {
                    ISimpleLineSymbol pLineSym = new SimpleLineSymbol();
                    IRgbColor         pColor   = new RgbColorClass();
                    pColor.Red     = 255;
                    pColor.Green   = 255;
                    pColor.Blue    = 0;
                    pLineSym.Color = pColor;
                    pLineSym.Style = esriSimpleLineStyle.esriSLSSolid;
                    pLineSym.Width = 2;

                    ISimpleFillSymbol pFillSym = new SimpleFillSymbol();

                    pFillSym.Color   = pColor;
                    pFillSym.Style   = esriSimpleFillStyle.esriSFSDiagonalCross;
                    pFillSym.Outline = pLineSym;

                    object symbol = pFillSym as object;
                    IPoint point  = new PointClass();
                    point.PutCoords(x, y);

                    IRubberBand        band = new RubberCircleClass();
                    ICircularArc       pCircArc;
                    ISegmentCollection pSegColl = new PolygonClass();
                    pCircArc = (ICircularArc)(band.TrackNew(m_Display, null));
                    object a = Type.Missing;
                    pSegColl.AddSegment((ISegment)pCircArc, ref a, ref a);
                    IGeometry pGeo = pSegColl as IGeometry;
                    app.Current2DMapControl.DrawShape(pGeo, ref symbol);
                    WaitForm.Start("正在查询...", "请稍后");
                    if (pGeo.IsEmpty)
                    {
                        IPoint searchPoint = new PointClass();
                        searchPoint.PutCoords(mapX, mapY);
                        pGeo = PublicFunction.DoBuffer(searchPoint, PublicFunction.ConvertPixelsToMapUnits(m_ActiveView, GlobalValue.System_Selection_Option().Tolerate));
                        //m_ActiveView.FocusMap.SelectByShape(geo, s, false);
                    }
                    if (ready)
                    {
                        IMap pMap = app.Current2DMapControl.Map;
                        ISelectionEnvironment selEnv = new SelectionEnvironmentClass();
                        pMap.SelectByShape(pGeo, selEnv, false);
                        ISelection pSelection = pMap.FeatureSelection;

                        FrmDxfExport dialog = new FrmDxfExport(pSelection, pMap);
                        WaitForm.Stop();
                        dialog.ShowDialog();
                    }
                }
            }
            catch (System.Exception ex)
            {
                WaitForm.Stop();
            }
        }