Ejemplo n.º 1
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;
                    IRubberBand band   = new RubberPolygonClass();
                    IGeometry   pGeo   = band.TrackNew(m_Display, null);
                    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();
            }
        }
Ejemplo n.º 2
0
        public override void OnMouseDown(int button, int shift, int x, int y, double mapX, double mapY)
        {
            try
            {
                IPoint pPoint = new PointClass();
                pPoint.PutCoords(mapX, mapY);
                FrmMapExportByCoordinate dialog = new FrmMapExportByCoordinate(pPoint);
                dialog.ShowDialog();

                if (dialog.DialogResult == DialogResult.OK)
                {
                    IPointCollection pColl = new PolygonClass();
                    pColl.AddPoint(pPoint);
                    IPoint point1 = new PointClass();
                    point1.PutCoords(mapX + dialog.Length, mapY);
                    pColl.AddPoint(point1);
                    IPoint point2 = new PointClass();
                    point2.PutCoords(mapX, mapY + dialog.Width);
                    pColl.AddPoint(point2);
                    IPoint point3 = new PointClass();
                    point3.PutCoords(mapX + dialog.Length, mapY + dialog.Width);
                    pColl.AddPoint(point3);
                    IGeometry pGeo = pColl as IGeometry;

                    DF2DApplication       app    = DF2DApplication.Application;
                    IMap                  pMap   = app.Current2DMapControl.Map;
                    ISelectionEnvironment selEnv = new SelectionEnvironmentClass();
                    pMap.SelectByShape(pGeo, selEnv, false);
                    ISelection pSelection = pMap.FeatureSelection;

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