示例#1
0
        private void axMapControl1_OnMouseDown(object sender, ESRI.ArcGIS.Controls.IMapControlEvents2_OnMouseDownEvent e)
        {
            xMap = e.mapX;
            yMap = e.mapY;
            string selectedraster = "slope";

            if (listBox1.SelectedItem == null)
            {
                selectedraster = selectedraster + "512";//defaut finest raster
            }
            else
            {
                selectedraster = selectedraster + Math.Pow(2, double.Parse(listBox1.SelectedItem.ToString())).ToString();
            }
            IRaster2 ras2 = MapXY2RowCol(xMap, yMap, selectedraster);//FInest Resolution Ratername

            if (ras2.GetPixelValue(0, col, row) == null)
            {
                MessageBox.Show("Please open map");
                return;
            }
            float pixelvalue = ras2.GetPixelValue(0, col, row);

            if (e.button == 2)
            {
                MessageBox.Show("x:" + xMap + " y:" + yMap + "\n" + "row:" + row + " col:" + col + "value:" + pixelvalue);
            }
        }
        private void axMapControl1_OnMouseDown(object sender, ESRI.ArcGIS.Controls.IMapControlEvents2_OnMouseDownEvent e)
        {
            if (e.button == 2)
            {
                //Logic to determine which popup menu to show based on the current task and current tool

                IEngineEditTask currentTask = m_engineEditor.CurrentTask;

                switch (currentTask.UniqueName)
                {
                case "ControlToolsEditing_CreateNewFeatureTask":
                {
                    if (((ICommand)axToolbarControl1.CurrentTool).Name == "ControlToolsEditing_Sketch")
                    {
                        m_toolbarMenuSketch.PopupMenu(e.x, e.y, axMapControl1.hWnd);
                    }
                    else if (((ICommand)axToolbarControl1.CurrentTool).Name == "ControlToolsEditing_Edit")
                    {
                        //SetEditLocation method must be called to enable commands
                        ((IEngineEditSketch)m_engineEditor).SetEditLocation(e.x, e.y);
                        m_toolbarMenuVertex.PopupMenu(e.x, e.y, axMapControl1.hWnd);
                    }
                    break;
                }

                case "ControlToolsEditing_ModifyFeatureTask":
                {
                    //SetEditLocation method must be called to enable commands
                    ((IEngineEditSketch)m_engineEditor).SetEditLocation(e.x, e.y);
                    m_toolbarMenuVertex.PopupMenu(e.x, e.y, axMapControl1.hWnd);
                    break;
                }
                }
            }
        }
示例#3
0
        private void axMapControl1_OnMouseDown(object sender, ESRI.ArcGIS.Controls.IMapControlEvents2_OnMouseDownEvent e)
        {
            axMapControl1.MousePointer = esriControlsMousePointer.esriPointerCrosshair;
            IGeometry geometry = null;

            switch (flag)
            {
            case 1:
                ESRI.ArcGIS.Geometry.Point point = new ESRI.ArcGIS.Geometry.PointClass();
                point.X  = e.mapX;
                point.Y  = e.mapY;
                geometry = point as IGeometry;
                break;

            case 2:
                geometry = axMapControl1.TrackCircle();
                break;

            case 3:
                geometry = axMapControl1.TrackRectangle();
                break;

            case 4:
                geometry = axMapControl1.TrackPolygon();
                break;
            }
            axMapControl1.Map.SelectByShape(geometry, null, false);
            axMapControl1.Refresh(esriViewDrawPhase.esriViewGeoSelection, null, null);
        }
示例#4
0
 private void axMapControl1_OnMouseDown(object sender, ESRI.ArcGIS.Controls.IMapControlEvents2_OnMouseDownEvent e)
 {
     //Popup menu
     if (e.button == 2)
     {
         m_ToolbarMenu1.PopupMenu(e.x, e.y, axMapControl1.hWnd);
     }
 }
示例#5
0
 private void MapControlLayer_OnMouseDown(object sender, ESRI.ArcGIS.Controls.IMapControlEvents2_OnMouseDownEvent e)
 {
     if (e.button == 2)
     {
         System.Drawing.Point ClickPoint = MapControlLayer.PointToScreen(new System.Drawing.Point(e.x, e.y));
         axMapControlcontextMenu.Show(ClickPoint);
     }
 }
示例#6
0
        //鹰眼
        private void axMapEve_OnMouseDown(object sender, ESRI.ArcGIS.Controls.IMapControlEvents2_OnMouseDownEvent e)
        {
            IPoint Pnt;

            Pnt = new ESRI.ArcGIS.Geometry.Point();
            Pnt.PutCoords(e.mapX, e.mapY);
            axMapControl1.CenterAt(Pnt);
            axMapControl1.Refresh();
        }
示例#7
0
 void m_axmap_OnMouseDown(object sender, ESRI.ArcGIS.Controls.IMapControlEvents2_OnMouseDownEvent e)
 {
     if (e.button == 2)
     {
         //弹出右键菜单
         GIS.Common.DataEditCommon.contextMenu.PopupMenu(e.x, e.y, m_axmap.hWnd);
         return;
     }
 }
示例#8
0
 private void axMapControl1_OnMouseDown(object sender, ESRI.ArcGIS.Controls.IMapControlEvents2_OnMouseDownEvent e)
 {
     if (e.button == 2)//右健弹出快捷键
     {
         m_ToolbarMenu.PopupMenu(e.x, e.y, axMapControl1.hWnd);
     }
     // axMapControl1.Pan();
     // axMapControl1.MousePointer = ESRI.ArcGIS.Controls.esriControlsMousePointer.esriPointerCrosshair;
     // axMapControl1.Extent = axMapControl1.TrackRectangle();
     // axMapControl1.ActiveView.PartialRefresh(ESRI.ArcGIS.Carto.esriViewDrawPhase.esriViewGeography, null, null);
 }
示例#9
0
        public void MapControl_OnMouseDown(object sender, ESRI.ArcGIS.Controls.IMapControlEvents2_OnMouseDownEvent e)
        {
            //If left hand mouse button
            if (e.button == 1)
            {
                //Create a point and grab hold of the IPoint inteface
                IPoint pPoint = new PointClass();
                //Set point properties

                pPoint.PutCoords(e.mapX, e.mapY);

                ITextSymbol pTextSymbol = new TextSymbolClass();

                stdole.IFontDisp pFont;
                pFont = new stdole.StdFontClass() as stdole.IFontDisp;

                pFont.Name          = textBox1.Font.Name;
                pFont.Italic        = textBox1.Font.Italic;
                pFont.Underline     = textBox1.Font.Underline;
                pFont.Bold          = textBox1.Font.Bold;
                pFont.Size          = (decimal)textBox1.Font.Size;
                pFont.Strikethrough = textBox1.Font.Strikeout;

                IRgbColor pRGB = new RgbColorClass();
                pRGB.Red   = (int)textBox1.ForeColor.R;
                pRGB.Green = (int)textBox1.ForeColor.G;
                pRGB.Blue  = (int)textBox1.ForeColor.B;


                pTextSymbol.Size  = textBox1.Font.Size;
                pTextSymbol.Font  = pFont;
                pTextSymbol.Color = pRGB;



                ITextElement pTextEle = new TextElementClass();
                pTextEle.Text      = textBox1.Text;
                pTextEle.ScaleText = true;
                pTextEle.Symbol    = pTextSymbol;

                IElement pEle = (IElement)pTextEle;
                pEle.Geometry = pPoint;

                IActiveView        pActiveView         = (IActiveView)m_MapControl.Map;
                IGraphicsContainer pGraphicsContatiner = (IGraphicsContainer)m_MapControl.Map;

                pGraphicsContatiner.AddElement(pEle, 0);

                pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
            }
            this.Close();
        }
示例#10
0
        private void axMap_OnMouseDown(object sender, ESRI.ArcGIS.Controls.IMapControlEvents2_OnMouseDownEvent e)
        {
            if (axMap.MousePointer == esriControlsMousePointer.esriPointerPan && e.button == 1)
            {
                axMap.Pan();
            }

            if (e.button == 4)
            {
                axMap.MousePointer = esriControlsMousePointer.esriPointerPan;
                axMap.Pan();
            }
        }
        private void axMapControl1_OnMouseDown(object sender, ESRI.ArcGIS.Controls.IMapControlEvents2_OnMouseDownEvent e)
        {
            m_bUpdateFocusMap = true;

            if (e.button == 1)
            {
                axMapControl1.Extent = axMapControl1.TrackRectangle();
            }
            else if (e.button == 2)
            {
                axMapControl1.Pan();
            }
        }
示例#12
0
        //画线+测量
        private void axMapControl1_OnMouseDown(object sender, ESRI.ArcGIS.Controls.IMapControlEvents2_OnMouseDownEvent e)
        {
            //this.Cursor = Cursors.Default;
            if (e.button == 1) //== MouseButtons.Left)
            {
                if (isMeasure)
                {
                    GISHandler.GISTools.CreatLine(this.axMapControl1);
                    isMeasure = false;
                }
                if (areaMeasure)
                {
                    GISHandler.GISTools.MeasureArea(this.axMapControl1);
                    //

                    areaMeasure = false;
                }
                if (polygonSt)
                {
                    GISHandler.GISTools.FreePolygonSt(this.axMapControl1, SystemSet.Base_Map + "\\处理数据库\\图层数据");
                    polygonSt = false;
                }
                if (attribute)
                {
                    // GISHandler.GISTools.IdentifyTool(this.axMapControl1);
                    if (identifyDialog.IsDisposed)
                    {
                        ShowIdentifyDialog();
                    }
                    identifyDialog.OnMouseDown(e.button, e.mapX, e.mapY);

                    //attribute = false;
                }
                if (edit)
                {
                    Edit et = new Edit(this.axMapControl1);
                    et.Show();
                    et.TopMost = true;
                    edit       = false;
                }
            }

            if (e.button == 2)
            {
                GISHandler.GISTools.setNull(this.axMapControl1);
                //弹出右键菜单
                IMapControl3 m_mapControl = (IMapControl3)this.axMapControl1.Object;

                m_menuMap.PopupMenu(e.x, e.y, m_mapControl.hWnd);
            }
        }
示例#13
0
        /// <summary>
        /// 左键在flag=1时点选道路进行查询,右键将地图中心移至点击位置
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void axMapControl1_OnMouseDown(object sender, ESRI.ArcGIS.Controls.IMapControlEvents2_OnMouseDownEvent e)
        {
            if (e.button == 1)
            {
                if (flag == 1)
                {
                    if (pPopupWindow != null)
                    {
                        if (pPopupWindow.Visible == true)
                        {
                            pPopupWindow.Dispose();
                        }
                    }

                    IPoint pPoint = new ESRI.ArcGIS.Geometry.Point();
                    pPoint.PutCoords(e.mapX, e.mapY);
                    IFeatureLayer pFeatureLayer = this.axMapControl1.Map.Layer[0] as FeatureLayer;
                    IFeature      pFeature      = GetPointSelect(pPoint, pFeatureLayer, 16) as IFeature;
                    IPropertySet  pOptions      = new PropertySet();

                    IHTMLPopupInfo  pHTMLPopupInfo  = pFeatureLayer as IHTMLPopupInfo;
                    IHTMLPopupInfo2 pHTMLPopupInfo2 = pFeatureLayer as IHTMLPopupInfo2;
                    pHTMLPopupInfo2.HTMLDownloadAttachmentData = true;
                    pHTMLPopupInfo.HTMLPopupEnabled            = true;
                    pHTMLPopupInfo.HTMLPresentationStyle       = esriHTMLPopupStyle.esriHTMLPopupStyleXSLStylesheet;
                    pHTMLPopupInfo.HTMLXSLStylesheet           = Application.StartupPath + @"\popup_0.xsl";
                    this.axMapControl1.MousePointer            = ESRI.ArcGIS.Controls.esriControlsMousePointer.esriPointerIdentify;
                    if (pFeature != null)
                    {
                        axMapControl1.ActiveView.Refresh();
                        IGeometry pAnnoGeometry = pFeature.Shape;
                        pSLS = pSLineSymbol as object;
                        pSLineSymbol.Style = esriSimpleLineStyle.esriSLSSolid;
                        IRgbColor pColor = new RgbColor();
                        pColor.Red          = 255;
                        pColor.Transparency = 255;
                        pSLineSymbol.Color  = pColor;
                        axMapControl1.DrawShape(pAnnoGeometry, ref pSLS);
                        displayXMLdocumentContent(pHTMLPopupInfo2.HTMLOutput(pFeature, pOptions));
                    }
                }
            }
            if (e.button == 2)
            {
                IPoint pPoint = new ESRI.ArcGIS.Geometry.Point();
                pPoint.PutCoords(e.mapX, e.mapY);
                this.axMapControl1.MousePointer = esriControlsMousePointer.esriPointerHand;
                axMapControl1.CenterAt(pPoint);
            }
        }
示例#14
0
        private void axMapControl1_OnMouseDown(object sender, ESRI.ArcGIS.Controls.IMapControlEvents2_OnMouseDownEvent e)
        {
            //    IMapControlDefault pMCD;
            //    pMCD = axMapControl1.Object as IMapControlDefault;

            //    IMap pMap;
            //    pMap = pMCD.Map;

            //    IGeometry pGeom;
            //    pGeom = pMCD.TrackPolygon();
            //    pMap.SelectByShape(pGeom, null, false);

            //    pMCD.Refresh(esriViewDrawPhase.esriViewGeoSelection, null, null);
        }
示例#15
0
        private void axMapControl1_OnMouseDown(object sender, ESRI.ArcGIS.Controls.IMapControlEvents2_OnMouseDownEvent e)
        {
            //If left mouse button then zoom in
            if (e.button == 1)
            {
                m_MapControl.Extent = m_MapControl.TrackRectangle();
            }
            else
            {
                //Create a point and get the IPoint interface
                IPoint point = new PointClass();
                //Set points coordinates
                point.PutCoords(e.mapX, e.mapY);

                //QI for ITopologicalOperator interface through IPoint interface
                ITopologicalOperator topologicalOperator = (ITopologicalOperator)point;
                //Create a polygon by buffering the point and get the IPolygon interface
                IPolygon polygon = (IPolygon)topologicalOperator.Buffer(m_MapControl.Extent.Width * 0.02);
                //QI for IRelationalOperator interface through IPolygon interface
                IRelationalOperator relationalOperator = (IRelationalOperator)polygon;

                object o = null;
                //Draw the polygon
                m_MapControl.DrawShape(polygon, ref o);

                //Loop through the elements in the GraphicContainer and get the IElement interface
                m_GraphicsContainer.Reset();
                IElement element = m_GraphicsContainer.Next();
                while (element != null)
                {
                    //If the polygon contains the point
                    if (relationalOperator.Contains(element.Geometry) == true)
                    {
                        //QI for IMarkerElement interface through IElement interface
                        IMarkerElement markerElement = (IMarkerElement)element;
                        markerElement.Symbol = GetMarkerSymbol(true);
                        //QI for the IElementProperties interface through IElement interface
                        IElementProperties elementProperties = (IElementProperties)element;
                        elementProperties.Name = true.ToString();
                    }
                    element = m_GraphicsContainer.Next();
                }
                if (chkTracking.CheckState == CheckState.Unchecked)
                {
                    //Refresh the graphics
                    m_MapControl.Refresh(esriViewDrawPhase.esriViewGraphics, Type.Missing, Type.Missing);
                }
            }
        }
示例#16
0
 private void axMapControl1_OnMouseDown(object sender, ESRI.ArcGIS.Controls.IMapControlEvents2_OnMouseDownEvent e)
 {
     IActiveView pActiveView = axMapControl1.ActiveView;
     IScreenDisplay screenDisplay = pActiveView.ScreenDisplay;
     ISimpleLineSymbol lineSymbol = new SimpleLineSymbolClass();
     IRgbColor rgbColor = new RgbColorClass();
     rgbColor.Red = 255;
     lineSymbol.Color = rgbColor;
     // IRubberBand rubberLine = new RubberLineClass();
     // IPolyline pLine = (IPolyline)rubberLine.TrackNew(screenDisplay,            (ISymbol)lineSymbol);
     IPolyline pLine = axMapControl1.TrackLine() as IPolyline;
     screenDisplay.StartDrawing(screenDisplay.hDC, (short)esriScreenCache.esriNoScreenCache);
     screenDisplay.SetSymbol((ISymbol)lineSymbol);
     screenDisplay.DrawPolyline(pLine);
     screenDisplay.FinishDrawing();
 }
示例#17
0
 private void axMapControl1_OnMouseDown(object sender, ESRI.ArcGIS.Controls.IMapControlEvents2_OnMouseDownEvent e)//实现按住鼠标中间拖动,按住鼠标右键框选要素
 {
     if (e.button == 4)
     {
         this.Cursor = System.Windows.Forms.Cursors.Hand;
         axMapControl1.Pan();
     }
     if (e.button == 2)
     {
         this.Cursor = System.Windows.Forms.Cursors.Cross;
         IEnvelope pEnv = axMapControl1.TrackRectangle();
         axMapControl1.Map.SelectByShape(pEnv, null, false);
         axMapControl1.Refresh();
         this.Cursor = System.Windows.Forms.Cursors.Arrow;
     }
 }
示例#18
0
 private void axMapControl2_OnMouseDown(object sender, ESRI.ArcGIS.Controls.IMapControlEvents2_OnMouseDownEvent e)
 {
     if (axMapControl2.Map.LayerCount > 0)
     {
         if (e.button == 1)
         {
             IPoint pPoint = new PointClass();
             pPoint.PutCoords(e.mapX, e.mapY);
             axMapControl1.CenterAt(pPoint); axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
         }
         else if (e.button == 2)
         {
             IEnvelope pEnv = axMapControl2.TrackRectangle();
             axMapControl1.Extent = pEnv;
             axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
         }
     }
 }
示例#19
0
 /// <summary>
 /// 鹰眼视图上鼠标点击事件
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 public void axMapControl2_OnMouseDown(object sender, ESRI.ArcGIS.Controls.IMapControlEvents2_OnMouseDownEvent e)
 {
     if (axMapControl2.Map.LayerCount > 0)
     {
         if (e.button == 1)//左键将所点击的位置,设置为主视图的中心
         {
             IPoint pPoint = new PointClass();
             pPoint.PutCoords(e.mapX, e.mapY);//设置point对象的坐标
             axMapControl1.CenterAt(pPoint);
             axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
         }
         else if (e.button == 2)                              //右键拉框范围设置为主视图显示范围
         {
             IEnvelope pEnv = axMapControl2.TrackRectangle(); //获得拉框的范围
             axMapControl1.Extent = pEnv;
             axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
         }
     }
 }
示例#20
0
 //3. 实现互动
 private void axMapControl1_OnMouseDown(object sender, ESRI.ArcGIS.Controls.IMapControlEvents2_OnMouseDownEvent e)
 {
     if (this.axMapControl1.Map.LayerCount > 0)
     {
         if (e.button == 1)
         {
             IPoint pPt = new PointClass();
             pPt.PutCoords(e.mapX, e.mapY);
             //改变主控件的视图范围
             _myfrm._mainFrm.axMapControl1.CenterAt(pPt);
             _myfrm._mainFrm.axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
         }
         else if (e.button == 2)
         {
             IEnvelope pEnv = this.axMapControl1.TrackRectangle();
             _myfrm._mainFrm.axMapControl1.Extent = pEnv;;
             _myfrm._mainFrm.axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
         }
     }
 }
示例#21
0
        private void axMapControl2_OnMouseDown(object sender, ESRI.ArcGIS.Controls.IMapControlEvents2_OnMouseDownEvent e)
        {
            IPoint pPoint = new ESRI.ArcGIS.Geometry.Point();

            pPoint.PutCoords(e.mapX, e.mapY);
            this.axMapControl1.CenterAt(pPoint);
            this.axMapControl1.Extent.CenterAt(pPoint);
            IRgbColor pColor = new RgbColor();

            pColor.Transparency  = 0;
            pSFillSymbol.Color   = pColor;
            pSLineSymbol.Style   = esriSimpleLineStyle.esriSLSSolid;
            pColor.Red           = 255;
            pColor.Transparency  = 255;
            pSLineSymbol.Color   = pColor;
            pSFillSymbol.Outline = pSLineSymbol;
            pGeometry            = this.axMapControl1.ActiveView.Extent;
            pSFS = pSFillSymbol as object;
            this.axMapControl2.DrawShape(pGeometry, ref pSFS);
        }
示例#22
0
        private void axMapControl1_OnMouseDown(object sender, ESRI.ArcGIS.Controls.IMapControlEvents2_OnMouseDownEvent e)
        {
            //If left hand mouse button
            if (e.button == 1)
            {
                //Create a point and grab hold of the IPoint interface
                IPoint point = new PointClass();
                //Set point properties
                point.X = e.mapX;
                point.Y = e.mapY;

                //If this is the first point of a new line
                if (m_Polyline == null)
                {
                    //Create the forms private polyline member and grab hold of the IPolyline interface
                    m_Polyline = new PolylineClass();
                }

                //QI for the IPointsCollection interface using the IPolyline interface
                object o = Type.Missing;
                //object o1 = m_PointCollection.PointCount-1;
                m_PointCollection = (IPointCollection)m_Polyline;
                m_PointCollection.AddPoint(point, ref o, ref o);

                //Refresh the foreground thereby removing any text annotation
                axMapControl1.Refresh(esriViewDrawPhase.esriViewForeground, Type.Missing, Type.Missing);
            }
            else
            {
                //If right or middle mouse button zoom to user defined rectangle
                //Create an envelope and grab hold of the IEnvelope interface
                IEnvelope envelope = axMapControl1.TrackRectangle();
                //If user dragged a rectangle
                if (envelope != null)
                {
                    //Set map controls extent property
                    axMapControl1.Extent = envelope;
                }
            }
        }
示例#23
0
        private void axMapControl1_OnMouseDown(object sender, ESRI.ArcGIS.Controls.IMapControlEvents2_OnMouseDownEvent e)
        {
            if (e.button == 1)
            {
                object missing = Type.Missing;
                if (bCreateOrNot)
                {
                    axMapControl1.CurrentTool = null;

                    ESRI.ArcGIS.Geometry.IGeometry pGeometry = axMapControl1.TrackPolygon();

                    pGeometryCollection.AddGeometry(pGeometry, ref missing, ref missing);
                    ISimpleLineSymbol pSimpleLineSymbol = new SimpleLineSymbol();
                    pSimpleLineSymbol.Color = GetAEColor(this.listView1.Items.Count + 1);
                    pSimpleLineSymbol.Style = esriSimpleLineStyle.esriSLSSolid;
                    ISimpleFillSymbol pSimpleFillSymbol = new SimpleFillSymbol();
                    pSimpleFillSymbol.Color = GetAEColor(this.listView1.Items.Count + 1);
                    IFillShapeElement pFillElement = new PolygonElementClass();
                    pFillElement.Symbol = pSimpleFillSymbol;
                    IElement pElement;

                    pElement          = pFillElement as IElement;
                    pElement.Geometry = pGeometry;
                    pGraphic          = axMapControl1.ActiveView as IGraphicsContainer;
                    pGraphic.AddElement(pElement, 0);
                    axMapControl1.Refresh();

                    polyGonCount            += 1;
                    this.txtSampleCount.Text = polyGonCount.ToString();

                    IElementProperties pElementProperties = pElement as IElementProperties;
                    pElementProperties.Name = txtClassID.Text;
                }
            }
            if (e.button == 4)
            {
                axMapControl1.Pan();
            }
        }
示例#24
0
        private void axMapControl2_OnMouseDown(object sender,
                                               ESRI.ArcGIS.Controls.IMapControlEvents2_OnMouseDownEvent e)
        {
            if (this.axMapControl2.Map.LayerCount != 0)

            {
                // 按下鼠标左键移动矩形框

                if (e.button == 1)

                {
                    IPoint pPoint = new PointClass();

                    pPoint.PutCoords(e.mapX, e.mapY);

                    IEnvelope pEnvelope = this.axMapControl1.Extent;

                    pEnvelope.CenterAt(pPoint);

                    this.axMapControl1.Extent = pEnvelope;

                    this.axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
                }

                // 按下鼠标右键绘制矩形框

                else if (e.button == 2)

                {
                    IEnvelope pEnvelop = this.axMapControl2.TrackRectangle();

                    this.axMapControl1.Extent = pEnvelop;

                    this.axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
                }
            }
        }
示例#25
0
        private void axMapControl1_OnMouseDown(object sender, ESRI.ArcGIS.Controls.IMapControlEvents2_OnMouseDownEvent e)
        {
            //旋转
            if (frm_Rotate.flag == 1)
            {
                IScreenDisplay display = axMapControl1.ActiveView.ScreenDisplay;
                display.TrackRotate();
            }

            //裁剪
            if (Is_clip == true)
            {
                IRgbColor pcolor = new RgbColorClass();
                pcolor.Red   = 255;
                pcolor.Blue  = 0;
                pcolor.Green = 255;
                ISimpleFillSymbol linesymbol = new SimpleFillSymbolClass();
                linesymbol.Color = pcolor;
                //ISymbol symbol = linesymbol as ISymbol;
                object    symbol = linesymbol;
                IGeometry geom   = axMapControl1.TrackPolygon();
                //IScreenDisplay display = axMapControl1.ActiveView.ScreenDisplay;
                //display.StartDrawing(display.hDC, (short)esriScreenCache.esriAllScreenCaches);
                //display.SetSymbol(symbol);
                //display.DrawPolygon(geom);
                //display.FinishDrawing();
                axMapControl1.DrawShape(geom, ref symbol);
                //方法一
                IRasterLayer rasterlayer = axMapControl1.get_Layer(0) as IRasterLayer;
                IGeoDataset  geodataset  = rasterlayer as IGeoDataset;
                geom.SpatialReference = geodataset.SpatialReference;
                RasterClip(rasterlayer, geom as IPolygon);
                Is_clip = false;
                axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewForeground, null, null);
            }
        }
示例#26
0
        private void axMapControl1_OnMouseDown(object sender, ESRI.ArcGIS.Controls.IMapControlEvents2_OnMouseDownEvent e)
        {
            #region 多边形选择工具
            if (strTool == "多边形选择" && e.button == 1)
            {
                try
                {
                    IMapControlDefault pMCD;
                    pMCD = axMapControl1.Object as IMapControlDefault;
                    IMap pMap;
                    pMap = pMCD.Map;
                    IGeometry pGeom;
                    pGeom = pMCD.TrackPolygon();
                    pMap.SelectByShape(pGeom, null, false);
                    pMCD.Refresh(esriViewDrawPhase.esriViewGeoSelection, null, null);
                }
                catch { }
            }
            #endregion

            #region 圆选择
            if (strTool == "圆选择" && e.button == 1)
            {
                IMapControlDefault pMCD;
                pMCD = axMapControl1.Object as IMapControlDefault;
                IMap pMap;
                pMap = pMCD.Map;
                IGeometry pGeom;
                pGeom = pMCD.TrackCircle();
                pMap.SelectByShape(pGeom, null, false);
                pMCD.Refresh(esriViewDrawPhase.esriViewGeoSelection, null, null);
            }
            #endregion

            //图上度量单位与实际单位换算,用于面积测量与长度测量
            IPoint pPoint = null;
            double x;
            x = (6371110 * 2 * Math.PI) / 360;
            IActiveView pActiveView = axMapControl1.ActiveView.FocusMap as IActiveView;
            pPoint = pActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(e.x, e.y);

            #region 面积测量
            if (strTool == "面积量测" && e.button == 1)
            {
                try
                {
                    IMapControlDefault pMCD;
                    pMCD = axMapControl1.Object as IMapControlDefault;
                    IMap pMap;
                    pMap = pMCD.Map;
                    IGeometry pGeom;
                    pGeom = pMCD.TrackPolygon();
                    //画多边形
                    IPolygon          pPolygon          = pGeom as IPolygon;
                    IFillShapeElement pPolygonElement   = new PolygonElementClass();
                    ISimpleFillSymbol pSimpleFillSymbol = new SimpleFillSymbolClass();
                    pSimpleFillSymbol.Style = esriSimpleFillStyle.esriSFSBackwardDiagonal;

                    IRgbColor pColor = new RgbColorClass();
                    pColor.Red              = 175;
                    pColor.Green            = 0;
                    pColor.Blue             = 175;
                    pSimpleFillSymbol.Color = pColor as IColor;
                    pPolygonElement.Symbol  = pSimpleFillSymbol;
                    IElement pElement = pPolygonElement as IElement;
                    pElement.Geometry = pPolygon;
                    IGraphicsContainer pGraphicsContainer = pMap as IGraphicsContainer;
                    pGraphicsContainer.AddElement(pElement, 0);
                    axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);

                    IArea  pArea = (IArea)pGeom;
                    double s;
                    s = Math.Abs(Math.Round(pArea.Area * x * x / 1000000, 2));
                    DialogResult dr = MessageBox.Show("您量测的面积为" + s.ToString() + "平方公里。", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    if (dr == DialogResult.OK)
                    {
                        axMapControl1.ActiveView.GraphicsContainer.DeleteAllElements();
                    }
                    axMapControl1.Refresh();
                }
                catch { }
            }
            #endregion

            #region 长度测量
            if (strTool == "长度量测" && e.button == 1)
            {
                IPolyline pPolyline = null;
                pPolyline = (IPolyline)axMapControl1.TrackLine();
                double l;
                l = Math.Abs(Math.Round(pPolyline.Length * x / 1000, 2));
                //画直线
                ILineElement      pLineElement      = new LineElementClass();
                ISimpleLineSymbol pSimpleLineSymbol = new SimpleLineSymbol();
                IRgbColor         pColor            = new RgbColorClass();
                pColor.Red              = 175;
                pColor.Green            = 0;
                pColor.Blue             = 175;
                pSimpleLineSymbol.Color = pColor as IColor;
                pSimpleLineSymbol.Width = 3;
                pSimpleLineSymbol.Style = esriSimpleLineStyle.esriSLSSolid;
                pLineElement.Symbol     = pSimpleLineSymbol;
                IElement pElement = pLineElement as IElement;
                pElement.Geometry = pPolyline;
                axMapControl1.ActiveView.GraphicsContainer.AddElement(pElement, 0);
                axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);

                DialogResult dr = MessageBox.Show("您量测的距离为" + l.ToString() + "公里。", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                if (dr == DialogResult.OK)
                {
                    axMapControl1.ActiveView.GraphicsContainer.DeleteAllElements();
                }
                axMapControl1.Refresh();
            }
            #endregion
        }
示例#27
0
 private void axMapControl1_OnMouseDown(object sender, ESRI.ArcGIS.Controls.IMapControlEvents2_OnMouseDownEvent e)
 {
 }
示例#28
0
        private void axMapControl1_OnMouseDown(object sender, ESRI.ArcGIS.Controls.IMapControlEvents2_OnMouseDownEvent e)
        {
            IActiveView pActiveview = axMapControl1.ActiveView;
            IEnvelope   envelope    = new EnvelopeClass();

            pPointPt = axMapControl1.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(e.x, e.y);

            switch (mousedownname)
            {
            case "":
                break;

            case "zoomin":                                                                               //拉框放大
                envelope = axMapControl1.TrackRectangle();                                               //获取拉框信息
                if (envelope == null || envelope.IsEmpty || envelope.Height == 0 || envelope.Width == 0) //判断是否为空框
                {
                    return;
                }
                pActiveview.Extent = envelope;
                pActiveview.Refresh();
                break;

            case "zoomout":    //拉框缩小
                envelope = axMapControl1.TrackRectangle();
                if (envelope == null || envelope.IsEmpty || envelope.Height == 0 || envelope.Width == 0)
                {
                    return;
                }
                double dwidth  = pActiveview.Extent.Width * pActiveview.Extent.Width / envelope.Width;
                double dheight = pActiveview.Extent.Height * pActiveview.Extent.Height / envelope.Height;
                double dXmin   = pActiveview.Extent.XMin - ((envelope.XMin - pActiveview.Extent.XMin) * pActiveview.Extent.Width / envelope.Width);
                double dYmin   = pActiveview.Extent.YMin - ((envelope.YMin - pActiveview.Extent.YMin) * pActiveview.Extent.Height / envelope.Height);
                double dxMAX   = dXmin + dwidth;
                double dyMAX   = dYmin + dheight;
                envelope.PutCoords(dXmin, dYmin, dxMAX, dyMAX);
                pActiveview.Extent = envelope;
                pActiveview.Refresh();
                break;

            case "manyou":    //漫游
                axMapControl1.Pan();
                break;

            case "MeasureLength":    //长度量测

                if (pNewLineFeedback == null)
                {
                    pNewLineFeedback = new NewLineFeedback {
                        Display = pActiveview.ScreenDisplay
                    };                                   //实例化追踪线对象
                    pNewLineFeedback.Start(pPointPt);    //设置起点,开始动态绘制
                    dToltaLength = 0;
                }
                else    //如果追踪线对象不为空,则添加当前鼠标点
                {
                    pNewLineFeedback.AddPoint(pPointPt);
                }
                if (dSegmentLength != 0)
                {
                    dToltaLength = dToltaLength + dSegmentLength;
                }
                break;

            case "MeasureArea":    //面积量测

                if (pNewPolygonFeedback == null)
                {
                    pNewPolygonFeedback = new NewPolygonFeedback {
                        Display = pActiveview.ScreenDisplay
                    };                                                                     //实例化面对象
                    pAreaPointCollection.RemovePoints(0, pAreaPointCollection.PointCount); //清空点集
                    pNewPolygonFeedback.Start(pPointPt);                                   //开始绘制多边形
                    pAreaPointCollection.AddPoint(pPointPt, ref missing, ref missing);
                }
                else
                {
                    pNewPolygonFeedback.AddPoint(pPointPt);
                    pAreaPointCollection.AddPoint(pPointPt, ref missing, ref missing);
                }

                break;

            case "selectfeature":    //要素选择
                IEnvelope pEnv = axMapControl1.TrackRectangle();
                IGeometry pGeo = pEnv;
                if (pEnv.IsEmpty)    //若为空则在鼠标当前点进行选择部分区域作为框
                {
                    tagRECT r;
                    r.left   = e.x - 5;
                    r.top    = e.y - 5;
                    r.right  = e.x + 5;
                    r.bottom = e.y + 5;
                    pActiveview.ScreenDisplay.DisplayTransformation.TransformRect(pEnv, ref r, 4);
                    pEnv.SpatialReference = pActiveview.FocusMap.SpatialReference;
                }
                pGeo = pEnv;
                axMapControl1.Map.SelectByShape(pGeo, null, false);
                axMapControl1.Refresh(esriViewDrawPhase.esriViewGeoSelection, null, null);
                break;

            case "ExportRegion":
                pActiveview.GraphicsContainer.DeleteAllElements();
                pActiveview.Refresh();
                IPolygon pPolygon = ExportMap.DrawPolygon(axMapControl1);
                if (pPolygon == null)
                {
                    return;
                }
                ExportMap.AddElement(pPolygon, pActiveview);
                if (frmExpMap == null || frmExpMap.IsDisposed)
                {
                    frmExpMap = new mapexport(axMapControl1);
                }
                frmExpMap.isRegion = true;
                frmExpMap.geometry = pPolygon;
                frmExpMap.Show();
                frmExpMap.Activate();
                break;
            }
        }
示例#29
0
文件: MainForm.cs 项目: xcpxr/RareGIS
        private void axMapControl1_OnMouseDown(object sender, ESRI.ArcGIS.Controls.IMapControlEvents2_OnMouseDownEvent e)
        {
            //显示当前比例尺
            this.StatusScale.Text = "比例尺1:" + ((long)this.axMapControl1.MapScale).ToString();
            //显示当前坐标
            this.StatusCoordinate.Text = "当前坐标X=" + e.mapX.ToString() + " Y=" + e.mapY.ToString() + "" + this.axMapControl1.MapUnits;


            this.axMapControl1.Map.ClearSelection();
            //获取当前视图

            IActiveView pActiveView = this.axMapControl1.ActiveView;
            //获取鼠标点

            IPoint pPoint = pActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(e.x, e.y);

            switch (mTool)
            {
            case "ZoomIn":
                this.mZoomIn.OnMouseDown(e.button, e.shift, e.x, e.y);
                break;

            case "ZoomOut":
                //this.mZoomOut.OnMouseDown(e.button, e.shift, e.x, e.y);
                break;

            case "Pan":
                //设置鼠标形状
                this.axMapControl1.MousePointer = esriControlsMousePointer.esriPointerPanning;
                //this.mPan.OnMouseDown(e.button, e.shift, e.x, e.y);
                break;

            case "SpaceQuery":
                IGeometry pGeometry = null;
                if (this.mQueryMode == 0)
                {
                    //矩阵查询
                    pGeometry = this.axMapControl1.TrackRectangle();
                }
                else if (this.mQueryMode == 1)
                {
                    //线查询
                    pGeometry = this.axMapControl1.TrackLine();
                }
                else if (this.mQueryMode == 2)
                {
                    //点查询
                    ITopologicalOperator pTopo;
                    IGeometry            pBuffer;
                    pGeometry = pPoint;
                    pTopo     = pGeometry as ITopologicalOperator;

                    //根据点位创建缓冲区,缓冲半径为0.1,可修改

                    pBuffer   = pTopo.Buffer(0.1);
                    pGeometry = pBuffer.Envelope;
                }
                else if (this.mQueryMode == 3)
                {
                    pGeometry = this.axMapControl1.TrackCircle();
                }
                IFeatureLayer pFeatureLayer = this.axMapControl1.get_Layer(this.mLayerIndex) as IFeatureLayer;


                DataTable pDataTable = this.LoadQueryResult(this.axMapControl1, pFeatureLayer, pGeometry);

                this.dataGridView1.DataSource = pDataTable.DefaultView;

                this.dataGridView1.Refresh();
                break;

            default:
                break;
            }
            if (mZoomIn != null)
            {
                mZoomIn.OnMouseDown(e.button, e.shift, e.x, e.y);
            }
        }
        private void axMapControl1_OnMouseDown(object sender, ESRI.ArcGIS.Controls.IMapControlEvents2_OnMouseDownEvent e)
        {
            //if (e.button == 1)
            //    this.axMapControl1.Extent = this.axMapControl1.TrackRectangle();
            //else if (e.button == 2)
            //    this.axMapControl1.Pan();

            //空间点查询
            if (mMouseFlag==1)
            {
                IFeatureLayer pFeatureLayer;
                IFeatureClass pFeatureClass;
                //获取图层和要素类,为空时返回
                pFeatureLayer = this.axMapControl1.Map.get_Layer(0) as IFeatureLayer ;
                if (pFeatureLayer.Name != "states")
                    return;                
                pFeatureClass = pFeatureLayer.FeatureClass;
                if (pFeatureClass == null)
                    return;

                IActiveView pActiveView;
                IPoint pPoint;
                double length;
                //获取视图范围
                pActiveView = this.axMapControl1.ActiveView;
                //获取鼠标点击屏幕坐标
                pPoint = pActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(e.x, e.y);
                //屏幕距离转换为地图距离
                length = ConvertPixelToMapUnits(pActiveView, 2);


                ITopologicalOperator pTopoOperator;
                IGeometry pGeoBuffer;
                ISpatialFilter pSpatialFilter;
                //根据缓冲半径生成空间过滤器
                pTopoOperator = pPoint as ITopologicalOperator;
                pGeoBuffer = pTopoOperator.Buffer(length);

                pSpatialFilter = new SpatialFilterClass();
                pSpatialFilter.Geometry = pGeoBuffer;
                //根据图层类型选择缓冲方式
                switch (pFeatureClass.ShapeType)
                {
                    case esriGeometryType.esriGeometryPoint:
                        pSpatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelContains;
                        break;
                    case esriGeometryType.esriGeometryPolyline:
                        pSpatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelCrosses;
                        break;
                    case esriGeometryType.esriGeometryPolygon:
                        pSpatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;
                        break;
                }
                //定义空间过滤器的空间字段
                pSpatialFilter.GeometryField = pFeatureClass.ShapeFieldName;

                IQueryFilter pQueryFilter;
                IFeatureCursor pFeatureCursor;
                IFeature pFeature;
                //利用要素过滤器查询要素
                pQueryFilter = pSpatialFilter as IQueryFilter;
                pFeatureCursor = pFeatureLayer.Search(pQueryFilter, true);
                pFeature = pFeatureCursor.NextFeature();
                int fieldIndex;
                if(pFeature!=null)
                {
                    //选择指定要素
                    this.axMapControl1.Map.ClearSelection();
                    this.axMapControl1.Map.SelectFeature((ILayer)pFeatureLayer, pFeature);
                    this.axMapControl1.Refresh();
                    fieldIndex = pFeature.Fields.FindField("STATE_NAME");
                    MessageBox.Show("查找到“" + pFeature.get_Value(fieldIndex) + "”", "提示");
                }
            }

            if (e.button == 1)
            {
                //拉框放大
                if (mZoomIn != null)
                    mZoomIn.OnMouseDown(e.button, e.shift, e.x, e.y);
            }
            else if (e.button == 2)
            {
                axMapControl1.MousePointer = esriControlsMousePointer.esriPointerPan;
                axMapControl1.Pan();
                axMapControl1.MousePointer = esriControlsMousePointer.esriPointerDefault;
            }
        }