Esempio n. 1
0
 private void MainMapControl_OnDoubleClick(object sender, IMapControlEvents2_OnDoubleClickEvent e)
 {
     if (pMouseOperate == "MeasureLength")
     {
         if (frmMeasureResult != null)
         {
             frmMeasureResult.label2.Text = "线段总长度为:" + dToltalLength + sMapUnits;
         }
         if (pNewLineFeedback != null)
         {
             pNewLineFeedback.Stop();
             pNewLineFeedback = null;
             //清空所画的线对象
             (mainMapControl.Map as IActiveView).PartialRefresh(esriViewDrawPhase.esriViewForeground, null, null);
         }
         dToltalLength  = 0;
         dSegmentLength = 0;
     }
     else if (pMouseOperate == "MeasureArea")
     {
         if (pNewPolygonFeedback != null)
         {
             pNewPolygonFeedback.Stop();
             pNewPolygonFeedback = null;
             //清空所画的线对象
             (mainMapControl.Map as IActiveView).PartialRefresh(esriViewDrawPhase.esriViewForeground, null, null);
         }
         pAreaPointCol.RemovePoints(0, pAreaPointCol.PointCount); //清空点集中所有点
     }
 }
 private void axMapControl1_OnDoubleClick(object sender, IMapControlEvents2_OnDoubleClickEvent e)  //地图双击
 {
     #region 长度量算
     if (pMouseOperate == "MeasureLength")
     {
         if (frmMeasureResult != null)
         {
             frmMeasureResult.lblMeasureResult.Text = "量测的总路线距离为:" + dToltalLength + sMapUnits;
         }
         if (pNewLineFeedback != null)
         {
             pNewLineFeedback.Stop();
             pNewLineFeedback = null;
             //清空所画的线对象
             (axMapControl1.Map as IActiveView).PartialRefresh(esriViewDrawPhase.esriViewForeground, null, null);
         }
         dToltalLength  = 0;
         dSegmentLength = 0;
     }
     #endregion
     #region 面积量算
     if (pMouseOperate == "MeasureArea")
     {
         if (pNewPolygonFeedback != null)
         {
             pNewPolygonFeedback.Stop();
             pNewPolygonFeedback = null;
             //清空所画的线对象
             (axMapControl1.Map as IActiveView).PartialRefresh(esriViewDrawPhase.esriViewForeground, null, null);
         }
         pAreaPointCol.RemovePoints(0, pAreaPointCol.PointCount); //清空点集中所有点
     }
     #endregion
 }
        //双击则创建该线,并弹出缓冲窗体
        public override void OnDblClick()
        {
            //获取折线 并获取当前视图的屏幕显示
            if (m_pNewPolygonFeedback == null)
            {
                return;
            }
            IPolygon pPolygon = m_pNewPolygonFeedback.Stop();

            m_pNewPolygonFeedback = null;

            //不存在,为空。尺寸不够均退出
            if (pPolygon == null || pPolygon.IsEmpty)
            {
                return;
            }
            if (pPolygon.Envelope.Width < 0.01 || pPolygon.Envelope.Height < 0.01)
            {
                return;
            }

            //创建Topo对象,简化后统一空间参考
            ITopologicalOperator pTopo = (ITopologicalOperator)pPolygon;

            pTopo.Simplify();
            pPolygon.Project(m_MapControl.Map.SpatialReference);

            if (m_frmQuery == null)
            {
                m_frmQuery             = new frmQuery(m_MapControl, m_enumQueryMode);
                m_frmQuery.Owner       = m_mainFrm;
                m_frmQuery.FormClosed += new FormClosedEventHandler(frmQuery_FormClosed);
            }
            frmBufferSet pFrmBufSet = new frmBufferSet(pPolygon as IGeometry, m_MapControl.Map, m_frmQuery);
            IGeometry    pGeometry  = pFrmBufSet.GetBufferGeometry();

            if (pGeometry == null || pFrmBufSet.Res == false)
            {
                return;
            }

            // m_frmQuery.Show();
            //m_frmQuery.FillData(m_MapControl.ActiveView.FocusMap, pGeometry);
            _QuerBar.m_pMapControl = m_MapControl;
            _QuerBar.EmergeQueryData(m_MapControl.ActiveView.FocusMap, pGeometry, pFrmBufSet.pesriSpatialRelEnum);
            try
            {
                DevComponents.DotNetBar.Bar pBar = _QuerBar.Parent.Parent as DevComponents.DotNetBar.Bar;
                if (pBar != null)
                {
                    pBar.AutoHide = false;
                    //pBar.SelectedDockTab = 1;
                    int tmpindex = pBar.Items.IndexOf("dockItemDataCheck");
                    pBar.SelectedDockTab = tmpindex;
                }
            }
            catch
            { }
            m_frmQuery = null;
        }
Esempio n. 4
0
        /// <summary>
        /// 鼠标双击,结束本次量测,进行下一次量测,并在其中关闭定时器
        /// </summary>
        public override void OnDblClick()
        {
            //base.OnDblClick();

            //this.m_GeoMeasure = null;
            //this.m_Element.Geometry = new PolygonClass();
            //this.m_hookHelper.ActiveView.Refresh();
            //this.m_FormDis.WriteLabelText(this.m_GeoMeasure);

            //this.m_FormDis.m_timer.Stop();

            if (this.m_GeoMeasure == null)
            {
                return;
            }

            //结果显示窗口
            if (this.m_FormDis == null)
            {
                MeasureType type = MeasureType.Area;
                this.m_FormDis         = new FormDis(type, this);
                this.m_FormDis.TopMost = true;
                //窗口显示位置
                this.m_FormDis.Location = new System.Drawing.Point(130, 150);
                this.m_FormDis.Show();
            }

            this.m_GeoMeasure = m_pNewPolygonFeed.Stop();
            this.m_FormDis.WriteLabelText(this.m_GeoMeasure);

            this.m_GeoMeasure = null;
        }
Esempio n. 5
0
        private void OnOnDoubleClick(int button, int shift, int i, int i1, double mapX, double mapY)
        {
            if (button == 2)
            {
                return;
            }
            if (_polygonFeedback == null)
            {
                return;
            }
            IPoint point = new PointClass();

            point.PutCoords(mapX, mapY);
            _polygonFeedback.AddPoint(point);
            _polygon = _polygonFeedback.Stop();
            IRgbColor rgbColorClass = new RgbColor();

            rgbColorClass.Red   = (0);
            rgbColorClass.Green = (255);
            rgbColorClass.Blue  = (255);
            ISimpleFillSymbol simpleFillSymbolClass = new SimpleFillSymbol();

            ((ISymbol)simpleFillSymbolClass).ROP2 = (esriRasterOpCode)(10);
            simpleFillSymbolClass.Color           = (rgbColorClass);
            IElement element = new PolygonElement();

            element.Geometry = _polygon;
            ((IFillShapeElement)element).Symbol = simpleFillSymbolClass;
            _graphicsContainer.DeleteAllElements();
            _graphicsContainer.AddElement(element, 100);
            _context.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
            OnDrawCompleteEvent();
            //_polygon = null;
            _polygonFeedback = null;
        }
Esempio n. 6
0
        public override void OnDblClick()
        {
            //base.OnDblClick();
            if (m_pNewPolygonFeedback != null)
            {
                m_pPolygon            = m_pNewPolygonFeedback.Stop();
                m_pNewPolygonFeedback = null;
            }
            ISimpleFillSymbol pSimFillSym;
            IRgbColor         pRGB;

            pSimFillSym       = new SimpleFillSymbolClass();
            pRGB              = new RgbColorClass();
            pRGB.Red          = 255;
            pRGB.Green        = 50;
            pRGB.Blue         = 50;
            pRGB.Transparency = 0;
            pSimFillSym.Color = pRGB;
            if (m_pPolygon != null)
            {
                m_pScreenDisplay.StartDrawing(m_pScreenDisplay.hDC, -1);
                m_pScreenDisplay.SetSymbol((ISymbol)pSimFillSym);
                m_pScreenDisplay.DrawPolygon(m_pPolygon);
                m_pScreenDisplay.FinishDrawing();
            }
        }
Esempio n. 7
0
        /// <summary>
        /// 完成新建对象,取得绘制的对象,并添加到图层中
        /// 建议在Map.DblClick或Map.MouseDown(Button = 2)事件中调用本方法
        /// </summary>
        public void NewFeatureEnd()
        {
            IGeometry        pGeom = null;
            IPointCollection pPointCollection;

            try
            {
                if (m_pFeedback is INewMultiPointFeedback)
                {
                    INewMultiPointFeedback pMPFeed = (INewMultiPointFeedback)m_pFeedback;
                    pMPFeed.Stop();
                    pGeom = (IGeometry)m_pPointCollection;
                }
                else if (m_pFeedback is INewLineFeedback)
                {
                    INewLineFeedback pLineFeed = (INewLineFeedback)m_pFeedback;

                    pLineFeed.AddPoint(m_pPoint);
                    IPolyline pPolyLine = pLineFeed.Stop();

                    pPointCollection = (IPointCollection)pPolyLine;
                    if (pPointCollection.PointCount < 2)
                    {
                        MessageBox.Show("至少输入两个节点");
                    }
                    else
                    {
                        pGeom = (IGeometry)pPointCollection;
                    }
                }
                else if (m_pFeedback is INewPolygonFeedback)
                {
                    INewPolygonFeedback pPolyFeed = (INewPolygonFeedback)m_pFeedback;
                    pPolyFeed.AddPoint(m_pPoint);

                    IPolygon pPolygon;
                    pPolygon = pPolyFeed.Stop();
                    if (pPolygon != null)
                    {
                        pPointCollection = (IPointCollection)pPolygon;
                        if (pPointCollection.PointCount < 3)
                        {
                            MessageBox.Show("至少输入三个节点");
                        }
                        else
                        {
                            pGeom = (IGeometry)pPointCollection;
                        }
                    }
                }

                CreateFeature(pGeom);
                m_pFeedback = null;
                m_bInUse    = false;
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message.ToString());
            }
        }
Esempio n. 8
0
        /// <summary>
        /// 结束当前的测量,返回进行量算时在地图上绘的图形对象
        /// 建议在Map的DoubleClick事件或MouseDown(右键)事件中调用本方法
        /// 将返回对象用map.DrawShape方法绘在地图临时层上
        /// </summary>
        /// <param name="point">终点</param>
        /// <returns>地图上绘的图形对象</returns>
        public IGeometry SurveyEnd(IPoint point)
        {
            IGeometry geometry = null;

            if (_eMeasureType == EMeasureType.Distance || _eMeasureType == EMeasureType.Angle)
            {
                if (_newLineFeedback != null)
                {
                    _newLineFeedback.AddPoint(point);
                    geometry         = _newLineFeedback.Stop();
                    _newLineFeedback = null;
                }
            }
            else if (_eMeasureType == EMeasureType.Area)
            {
                if (_newPolygonFeedback != null)
                {
                    _newPolygonFeedback.AddPoint(point);
                    geometry            = _newPolygonFeedback.Stop();
                    _newPolygonFeedback = null;
                }
            }

            _pointCollection = null;
            IsSurveying      = false;
            return(geometry);
        }
Esempio n. 9
0
        public override void OnDblClick()
        {
            area             = fb.Stop();
            this.isSketching = false;

            DataCheckToolAuxiliary.Form1.SelectArea = area;
            DataCheckToolAuxiliary.Form1.pIsSelect  = true;
        }
Esempio n. 10
0
        private IEnvelope pEnv;                //记录数据视图的extent



        private void frmMeasureResult_frmClosed() //委托函数所调用的事件,主要用于结束量算和清空线和面对象
        {
            if (pNewLineFeedback != null)         //判断面对象是否为空不为空则清空
            {
                pNewLineFeedback.Stop();
                pNewLineFeedback = null;
            }
            if (pNewPolygonFeedback != null)//清空面对象
            {
                pNewPolygonFeedback.Stop();
                pNewPolygonFeedback = null;
                pAreaPointCollection.RemovePoints(0, pAreaPointCollection.PointCount);                 //清空点集中所有点
            }
            axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewForeground, null, null); //清空量算画的线、面对象
            axMapControl1.MousePointer = esriControlsMousePointer.esriPointerDefault;                  //结束量算功能
            mousedownname = "";
        }
Esempio n. 11
0
 public override void OnDblClick()
 {
     IPolygon      polygon = m_NewPolygonFeedback.Stop();
     CreateLayerM  cl      = new CreateLayerM((IMapControlDefault)m_hookHelper.Hook);
     IFeatureClass feac    = cl.CreatePolygonLayer(polygon);
     //frmCacu frmCacul = new frmCacu((IMapControlDefault)m_hookHelper.Hook,feac);
     //frmCacul.ShowDialog();
 }
Esempio n. 12
0
        public override void OnDblClick()
        {
            area             = fb.Stop();
            this.isSketching = false;
            CheckOutForm form = new CheckOutForm(CheckOutMode.Custom);

            form.CheckOutArea = area;
            form.Show();
        }
        public void OnDblClick()
        {
            IGeometry pResultGeometry = null;

            if (m_EngineEditLayers == null)
            {
                return;
            }
            //获取编辑目标图层
            IFeatureLayer pFeatLyr = m_EngineEditLayers.TargetLayer;

            if (pFeatLyr == null)
            {
                return;
            }
            IFeatureClass pFeatCls = pFeatLyr.FeatureClass;

            if (pFeatCls == null)
            {
                return;
            }

            switch (pFeatCls.ShapeType)
            {
            case esriGeometryType.esriGeometryPoint:
                m_newMultPtFeedBack.Stop();
                pResultGeometry     = m_pointCollection as IGeometry;
                m_newMultPtFeedBack = null;
                break;

            case esriGeometryType.esriGeometryPolyline:
                IPolyline pPolyline = null;
                pPolyline         = m_newLineFeedBack.Stop();
                pResultGeometry   = pPolyline as IGeometry;
                m_newLineFeedBack = null;
                break;

            case esriGeometryType.esriGeometryPolygon:
                IPolygon pPolygon = null;
                pPolygon          = m_newPolyFeedBack.Stop();
                pResultGeometry   = pPolygon as IGeometry;
                m_newPolyFeedBack = null;
                break;
            }

            IZAware pZAware = pResultGeometry as IZAware;

            if (pZAware == null)
            {
                return;
            }
            pZAware.ZAware = true;
            //创建新要素
            CreateFeature(pResultGeometry);
        }
Esempio n. 14
0
        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            // TODO:  Add ToolRasterEdit.OnMouseDown implementation
            IMapControl3 pMapCtrl = ClsGlobal.GetMapControl(m_hookHelper);

            if (pMapCtrl == null)
            {
                return;
            }
            IPoint pPoint = pMapCtrl.ToMapPoint(X, Y);

            if (Button == 1)
            {
                if (m_NewPolygonFeedback == null)
                {
                    m_NewPolygonFeedback         = new NewPolygonFeedbackClass();
                    m_NewPolygonFeedback.Display = pMapCtrl.ActiveView.ScreenDisplay;

                    m_NewPolygonFeedback.Start(pPoint);
                }
                else
                {
                    try
                    {
                        object Miss = Type.Missing;
                        m_NewPolygonFeedback.AddPoint(pPoint);
                    }
                    catch (System.Exception ex)
                    {
                    }
                }
            }
            if (Button == 2)
            {
                if (m_NewPolygonFeedback != null)
                {
                    m_NewPolygonFeedback.Stop();
                }

                m_NewPolygonFeedback = null;
            }
        }
Esempio n. 15
0
        private void axMapcontrol_OnDoubleClick(object sender, IMapControlEvents2_OnDoubleClickEvent e)
        {
            IPoint dblpnt = new PointClass();

            dblpnt.PutCoords(e.mapX, e.mapY);
            switch (pMouseOperate)
            {
            case "MeasureLength":
                if (m_newline != null)
                {
                    if (dblpnt.IsEmpty || dblpnt == null)
                    {
                        return;
                    }
                    IPolyline polyline = m_newline.Stop();
                    //绘制路径
                    DrawElement(polyline as IGeometry);
                    m_newline = null;
                    //显示长度
                    if (frmMeasureResult != null && !frmMeasureResult.IsDisposed)
                    {
                        //double deltaX = dblpnt.X - Dwnpoint.X;
                        //double deltaY = dblpnt.Y - Dwnpoint.Y;
                        //SegmentLength = Math.Round(Math.Sqrt(deltaX * deltaX + deltaY * deltaY));
                        ShowResultEvent(new double[] { SegmentLength, TotalLength }, sMapunits, pMouseOperate);
                        //清除绘制要素
                        this.axMapcontrol.ActiveView.GraphicsContainer.DeleteAllElements();
                    }
                }
                break;

            case "MeasureArea":
                if (m_newpolygon != null)
                {
                    Area_Pocoll.AddPoint(dblpnt, missing, missing);
                    IPolygon polygon = m_newpolygon.Stop() as IPolygon;
                    if (Area_Pocoll.PointCount < 3 || polygon.IsEmpty)
                    {
                        return;
                    }
                    polygon.Close();
                    IGeometry            pGeo = polygon as IGeometry;
                    ITopologicalOperator topo = pGeo as ITopologicalOperator;
                    topo.Simplify();
                    pGeo.Project(this.axMapcontrol.SpatialReference);
                    IArea area = pGeo as IArea;
                    if (frmMeasureResult != null && !frmMeasureResult.IsDisposed)
                    {
                        ShowResultEvent(new double[] { area.Area, polygon.Length }, sMapunits, pMouseOperate);
                    }
                }
                break;
            }
        }
Esempio n. 16
0
        public override void OnDblClick()
        {
            ITin     pTin     = pTinLayer.Dataset;
            ITinEdit pTinEdit = pTin as ITinEdit;

            if (mNewPolygonFeedback != null)
            {
                IPolygon      polygon      = mNewPolygonFeedback.Stop();
                ITinSelection tinselection = pTinEdit as ITinSelection;
                tinselection.SelectByArea(esriTinElementType.esriTinNode, polygon, true, true, esriTinSelectionType.esriTinSelectionAdd);
                pTinEdit.DeleteSelectedNodes();
                mNewPolygonFeedback = null;
                IMapControl2 pMapCtr = (((IToolbarControl)m_hookHelper.Hook).Buddy) as IMapControl2;
                if (pMapCtr != null)
                {
                    pMapCtr.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
                }
            }
            base.OnDblClick();
        }
Esempio n. 17
0
 private void FrmMeasureResult_frmColsed()
 {
     //清空线对象
     if (pNewLineFeedback != null)
     {
         pNewLineFeedback.Stop();
         pNewLineFeedback = null;
     }
     //清空面对象
     if (pNewPolygonFeedback != null)
     {
         pNewPolygonFeedback.Stop();
         pNewPolygonFeedback = null;
         pAreaPointCol.RemovePoints(0, pAreaPointCol.PointCount); //清空点集中所有点
     }
     //清空量算画的线、面对象
     axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewForeground, null, null);
     //结束量算功能
     pMouseOperate = string.Empty;
     axMapControl1.MousePointer = esriControlsMousePointer.esriPointerDefault;
 }
        //双击则创建该线,并弹出缓冲窗体
        public override void OnDblClick()
        {
            //获取折线 并获取当前视图的屏幕显示
            if (m_pNewPolygonFeedback == null)
            {
                return;
            }
            IPolygon pPolygon = m_pNewPolygonFeedback.Stop();

            m_pNewPolygonFeedback = null;

            //不存在,为空。尺寸不够均退出
            if (pPolygon == null || pPolygon.IsEmpty)
            {
                return;
            }
            if (pPolygon.Envelope.Width < 0.01 || pPolygon.Envelope.Height < 0.01)
            {
                return;
            }

            //创建Topo对象,简化后统一空间参考
            ITopologicalOperator pTopo = (ITopologicalOperator)pPolygon;

            pTopo.Simplify();
            pPolygon.Project(m_MapControl.Map.SpatialReference);

            frmBufferSet pFrmBufSet = new frmBufferSet(pPolygon as IGeometry, m_MapControl.Map);
            IGeometry    pGeometry  = pFrmBufSet.GetBufferGeometry();

            if (pGeometry == null || pFrmBufSet.Res == false)
            {
                return;
            }

            //==================================================================================================
            //执行查询数据操作
            ModDBOperator.QueryDataByGeometry(pGeometry, m_hook);
        }
Esempio n. 19
0
 public override void OnDblClick() //Stop drawing polygon
 {
     if (_drawStart)
     {
         _polygon = _polyFeedback.Stop();
         DataOperator  dataOperator = new DataOperator(m_map);
         ILayer        layer        = dataOperator.GetLayerByName(sLayerName);
         IFeatureLayer featureLayer = layer as IFeatureLayer;
         IFeature      feature      = dataOperator.AddGeometryToLayer(sLayerName, _polygon); //Add the new geometry to layer
         AddFeature    addFeature   = new AddFeature(feature, m_map, m_frmMain);
         addFeature.ShowDialog();                                                            //Change the attributes
         _startPoint = null;
     }
 }
Esempio n. 20
0
        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            if (Button == 1)
            {
                IPoint cursorPoint = m_screenDisplay.DisplayTransformation.ToMapPoint(X, Y);
                if (m_polygonFeedback == null)
                {
                    m_currentSides            = 0;
                    m_polygonFeedback         = new NewPolygonFeedbackClass();
                    m_polygonFeedback.Display = m_screenDisplay;

                    m_polygonFeedback.Start(cursorPoint);
                }
                else
                {
                    m_polygonFeedback.AddPoint(cursorPoint);
                }

                m_currentSides++;
                if (m_currentSides == m_maxSides) //Finish
                {
                    IPolygon polygon = m_polygonFeedback.Stop();

                    //Report area on status bar
                    IArea feedBackArea = polygon as IArea;
                    m_application.StatusBar.set_Message(0, "Feedback: area = " + Math.Abs(feedBackArea.Area).ToString());

                    m_polygonFeedback = null;
                }
                else
                {
                    //Report vertex remaining
                    m_application.StatusBar.set_Message(0, string.Format("Feedback: {0} point(s) remaining", m_maxSides - m_currentSides));
                }
            }
        }
Esempio n. 21
0
        public void OnDblClick()
        {
            IGeometry resultGeometry = null;

            if (engineEditLayers == null)
            {
                return;
            }
            //获取编辑目标图层
            IFeatureLayer featureLayer = engineEditLayers.TargetLayer;

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

            if (featureClass == null)
            {
                return;
            }
            switch (featureClass.ShapeType)
            {
            case esriGeometryType.esriGeometryMultipoint:
                newMultiPointFeedback.Stop();
                resultGeometry        = pointCollection as IGeometry;
                newMultiPointFeedback = null;
                break;

            case esriGeometryType.esriGeometryPolyline:
                IPolyline polyline = null;
                polyline        = newLineFeedback.Stop();
                resultGeometry  = polyline as IGeometry;
                newLineFeedback = null;
                break;

            case esriGeometryType.esriGeometryPolygon:
                IPolygon polygon = null;
                polygon            = newPolygonFeedback.Stop();
                resultGeometry     = polygon as IGeometry;
                newPolygonFeedback = null;
                break;
            }
            IZAware zaware = resultGeometry as IZAware;

            zaware.ZAware = true;
            CreateFeature(resultGeometry);//创建新要素
        }
        public void EndSketch()
        {
            IGeometry        resGeometry = null;
            IPointCollection pointColl   = null;

            try
            {
                if ((MyfeedBack as INewMultiPointFeedback) != null)
                {
                    INewMultiPointFeedback multiPointFeedback = MyfeedBack as INewMultiPointFeedback;
                    multiPointFeedback.Stop();
                }
                else if ((MyfeedBack as INewLineFeedback) != null)
                {
                    INewLineFeedback lineFeedback = MyfeedBack as INewLineFeedback;
                    lineFeedback.AddPoint(MycurrentMousePosition);
                    IPolyline polyline = lineFeedback.Stop();
                    pointColl = polyline as IPointCollection;
                    if (pointColl.PointCount > 1)
                    {
                        resGeometry = pointColl as IGeometry;
                    }
                }
                else if ((MyfeedBack as INewPolygonFeedback) != null)
                {
                    INewPolygonFeedback polygonFeedback = MyfeedBack as INewPolygonFeedback;
                    polygonFeedback.AddPoint(MycurrentMousePosition);
                    IPolygon polygon = polygonFeedback.Stop();
                    if (polygon != null)
                    {
                        pointColl = polygon as IPointCollection;
                        if (pointColl.PointCount > 2)
                        {
                            resGeometry = pointColl as IGeometry;
                            ITopologicalOperator pTopo = resGeometry as ITopologicalOperator;
                            if (!pTopo.IsKnownSimple)
                            {
                                pTopo.Simplify();
                            }
                        }
                    }
                }
                MyfeedBack = null;
                If_isInUse = false;
            }
            catch { return; }
        }
Esempio n. 23
0
        public override void OnDblClick()
        {
            if (m_NewPolygonFeedback == null)
            {
                return;
            }

            IEnvelope pEnvBounds = null;

            //获取上一次轨迹线的范围,以便确定刷新范围
            try
            {
                if (m_TracePolygon != null)
                {
                    m_TracePolygon.QueryEnvelope(pEnvBounds);
                    pEnvBounds.Expand(4, 4, true); //矩形框向四周扩大4倍(大于2倍就行),目的是为了保证有充足的刷新区域
                }
                else
                {
                    pEnvBounds = m_hookHelper.ActiveView.Extent;
                }
            }
            catch
            {
                pEnvBounds = m_hookHelper.ActiveView.Extent;
            }

            //绘制线与多边形几何图形时,双击结束绘制
            try
            {
                m_TracePolygon = m_NewPolygonFeedback.Stop();
                if (m_TracePolygon == null)
                {
                    return;
                }

                IElement traceElement = createElement_x(m_TracePolygon);
                m_TraceElement.AddElement(traceElement);
                m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, traceElement, pEnvBounds);
            }
            catch
            { }
            finally
            {
                Recycle();
            }
        }
Esempio n. 24
0
        private void EndSketch()
        {
            IGeometry        m_Geometry        = null;
            IPointCollection m_PointCollection = null;

            if (m_Feedback is INewLineFeedback)
            {
                INewLineFeedback m_LineFeed = (INewLineFeedback)m_Feedback;
                m_LineFeed.AddPoint(m_PointStop);
                IPolyline m_PolyLine = m_LineFeed.Stop();
                m_PointCollection = (IPointCollection)m_PolyLine;
                if (m_PointCollection.PointCount < 2)
                {
                    MessageBox.Show("需要两个点才能生成一条线!", "未能生成线", MessageBoxButtons.OK);
                    return;
                }
                else
                {
                    m_Geometry = (IGeometry)m_PointCollection;
                }
            }
            else if (m_Feedback is INewPolygonFeedback)
            {
                INewPolygonFeedback m_PolyFeed = (INewPolygonFeedback)m_Feedback;
                m_PolyFeed.AddPoint(m_PointStop);
                IPolygon m_Polygon = m_PolyFeed.Stop();
                if (m_Polygon != null)
                {
                    m_PointCollection = (IPointCollection)m_Polygon;
                }
                if (m_PointCollection.PointCount < 3)
                {
                    MessageBox.Show("需要三个点才能生成一个面!", "未能生成面", MessageBoxButtons.OK);
                    return;
                }
                else
                {
                    m_Geometry = (IGeometry)m_PointCollection;
                }
            }

            CreatFeature(m_Geometry);
            m_hookHelper.ActiveView.Refresh();
            m_Feedback = null;
            m_bInUse   = false;
        }
Esempio n. 25
0
        public override void OnKeyDown(int keyCode, int Shift)
        {
            if (keyCode == (int)Keys.Escape)
            {
                if (m_FeedbackLine != null)
                {
                    m_FeedbackLine.Stop();
                    m_FeedbackLine = null;
                }

                if (m_FeedbackPolygon != null)
                {
                    m_FeedbackPolygon.Stop();
                    m_FeedbackPolygon = null;
                }
                m_Geometry = null;
            }
        }
Esempio n. 26
0
        public override void OnDblClick()
        {
            base.OnDblClick();
            ITin     pTin     = pTinLayer.Dataset;
            ITinEdit pTinEdit = pTin as ITinEdit;

            frmAddTINPlane.pTinEdit = pTinEdit;
            if (mNewPolygonFeedback != null)
            {
                IPolygon polygon = mNewPolygonFeedback.Stop();
                frmAddTINPlane.pGeometry = polygon;
                frmAddTINPlane.setButtonOkEnable(true);
                frmAddTINPlane.CalPlaneHeight();
                IMapControl2 pMapCtr = (((IToolbarControl)m_hookHelper.Hook).Buddy) as IMapControl2;
                frmAddTINPlane.pMapCtr = pMapCtr;
                mNewPolygonFeedback    = null;
            }
        }
Esempio n. 27
0
        private void EndSketch(AxMapControl m_MapControl)                                             //结束一次画图操作
        {
            IGeometry        m_Geometry        = null;
            IPointCollection m_PointCollection = null;

            if (m_pNewLineFeedback != null)                            //线对象有效
            {
                //INewLineFeedback m_LineFeed = (INewLineFeedback)m_Feedback;
                m_pNewLineFeedback.AddPoint(m_PointStop);
                IPolyline m_PolyLine = m_pNewLineFeedback.Stop();
                m_PointCollection = (IPointCollection)m_PolyLine;
                if (m_PointCollection.PointCount < 2)
                {
                    MessageBoxEx.Show("需要两个点才能生成一条线!", "未能生成线", MessageBoxButtons.OK);
                    return;
                }
                else
                {
                    m_Geometry = (IGeometry)m_PointCollection;
                }
            }
            else if (m_pPlygonFeadback != null)                    //多边形对象有效
            {
                m_pPlygonFeadback.AddPoint(m_PointStop);
                IPolygon m_Polygon = m_pPlygonFeadback.Stop();
                if (m_Polygon != null)
                {
                    m_PointCollection = (IPointCollection)m_Polygon;
                }
                if (m_PointCollection.PointCount < 3)
                {
                    MessageBoxEx.Show("需要三个点才能生成一个面!", "未能生成面", MessageBoxButtons.OK);
                    return;
                }
                else
                {
                    m_Geometry = (IGeometry)m_PointCollection;
                }
            }
            CreateFeature(m_Geometry);
            m_pPlygonFeadback  = null;
            m_pNewLineFeedback = null;
            m_bInUse           = false;
        }
Esempio n. 28
0
        public override void OnDblClick()
        {
            m_Geometry = (IGeometry)m_NewPolygonFeedback.Stop();
            IMap pMap = m_hookHelper.FocusMap;
            ISpatialReference spatialReferencr = pMap.SpatialReference;

            m_Geometry.SpatialReference = spatialReferencr;
            IBorder pBorder = new SymbolBorderClass();

            m_hookHelper.FocusMap.ClipBorder = pBorder;
            // m_hookHelper.FocusMap.ClipGeometry = m_Geometry;
            m_ActiveView.Extent = m_Geometry.Envelope;
            m_ActiveView.Refresh();
            m_cursor = base.m_cursor;
            m_InUse  = false;

            /* string textTitle=""; //标题,制作者等信息
             * string textName="";
             * string textProject="";
             * string textDate="";
             * string textelevation="";
             * string textOtherInfo="";
             * frmTempleteProperties frmTempletePro = new frmTempleteProperties( pMap   , m_Geometry);
             * frmTempletePro.ShowDialog();
             * textTitle = frmTempletePro.ptextTitle;
             * textName = frmTempletePro.ptextName;
             * textProject = frmTempletePro.ptextProject;
             * textDate = frmTempletePro.ptextTime;
             *
             * textelevation = frmTempletePro.elevationName;
             * textOtherInfo =frmTempletePro .pOtherInfo ;*/
            m_ActiveView.Refresh();
            if (!frmTempletePro.ifCancle)
            {
                frmPrintByAnyRegion frmPrint = new frmPrintByAnyRegion(pMap, m_Geometry, textTitle,
                                                                       textName, textProject, textDate, textelevation, textOtherInfo);// checkLegend, checkNorthArrow, checkMapGrid, checkScaleBar, checkText);
                frmPrint.ShowDialog();
            }
            else
            {
            }
        }
Esempio n. 29
0
        /// <summary>
        /// MainMapControl双击事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MainMapControl_OnDoubleClick(object sender, IMapControlEvents2_OnDoubleClickEvent e)
        {
            #region 长度量算

            switch (pMouseOperate)
            {
            case "MeasureLength":
                if (frmMeasureResult != null)
                {
                    frmMeasureResult.lblMeasureResult.Text = "线段总长度为:" + dToltalLength + sMapUnits;
                }
                if (pNewLineFeedback != null)
                {
                    pNewLineFeedback.Stop();
                    pNewLineFeedback = null;
                    //清空所画的线对象
                    (MainMapControl.Map as IActiveView).PartialRefresh(esriViewDrawPhase.esriViewForeground, null, null);
                }
                dToltalLength  = 0;
                dSegmentLength = 0;
                break;

            case "MeasureArea":
                if (pNewPolygonFeedback != null)
                {
                    pNewPolygonFeedback.Stop();
                    pNewPolygonFeedback = null;
                    //清空所画的线对象
                    (MainMapControl.Map as IActiveView).PartialRefresh(esriViewDrawPhase.esriViewForeground, null, null);
                }
                pAreaPointCol.RemovePoints(0, pAreaPointCol.PointCount);     //清空点集中所有点
                break;

            default:
                break;
            }

            #endregion
        }
Esempio n. 30
0
        public override void OnDblClick()
        {
            IGeometry        pGeom            = null;
            IPointCollection pPointCollection = null;

            pPolygonFeedback.AddPoint(m_pPoint);
            IPolygon pPolygon = pPolygonFeedback.Stop();

            if (pPolygon != null)
            {
                pPointCollection = (IPointCollection)pPolygon;
            }
            if (pPointCollection.PointCount < 3)
            {
                MessageBox.Show("You must have at least three vertices in a polygon.", "Bad Line Geometry", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            else
            {
                pGeom = (IGeometry)pPointCollection;
            }

            pPolygonFeedback = null;
            CreateFeature(pGeom);
        }
Esempio n. 31
0
        public void frmDbClick(ref INewPolygonFeedback m_FeedbackPolygon, ref IGeometry m_Geometry)
        {
            if (tbtnArea.Checked == true)
            {
                if (m_FeedbackPolygon != null)
                {
                    pGeometry = m_FeedbackPolygon.Stop();
                    m_Geometry = pGeometry;
                    m_FeedbackPolygon = null;
                }

                IPolygon pPloygon = (IPolygon)pGeometry;
                Perimeter = pPloygon.Length;
                Perimeter = CntUnit.ConvertUnits(Perimeter, inUnit.pUnit, outUnit.pUnit);
                m_TotLen.value = Perimeter;
                m_TotLen.units = outUnit.pUnit;
                SegAreaLength = LastSegArea;
                double CntSegAreaLength = CntUnit.ConvertUnits(SegAreaLength, inUnit.pUnit, outUnit.pUnit);
                m_SegLen.value = CntSegAreaLength;
                m_SegLen.units = outUnit.pUnit;
                pArea = (IArea)pPloygon;
                myArea =Math.Abs( pArea.Area);
                double CntmyArea = myArea;
                 CntmyArea=ConvertToArea( CntmyArea, inAreaUnit.UnitName, outAreaUnit.UnitName);
                 m_Area.value = CntmyArea;
                 m_Area.units = outAreaUnit.pUnit;
                string AreaUnitMess;

                if (outAreaUnit.UnitName == "Unkown Units")
                    AreaUnitMess = outAreaUnit.UnitName;
                else AreaUnitMess = "Square " + outAreaUnit.UnitName;

                Perimeter = Math.Round(Perimeter, 6);
                SumPerimeters += Perimeter;

                CntSegAreaLength = Math.Round(CntSegAreaLength, 6);
                CntmyArea = Math.Round(CntmyArea, 6);
                SumAreas += CntmyArea;
                UnitSumArea = SumAreas;
                UnitSumPeri = SumPerimeters;
                txtMessage.Text = "测量面"+"\r\n线段长是" + CntSegAreaLength + outUnit.UnitName + "\r\n周长是:" + Perimeter + outUnit.UnitName + "\r\n面积是:" + CntmyArea + AreaUnitMess;
                if(tbtnSum.Checked==true)
                txtMessage.Text+="\r\n"+"\r\n周长长度之和是:"+ SumPerimeters+outUnit.UnitName +"\r\n面积之和是:"+SumAreas+AreaUnitMess ;

            }

            TotalLength = 0.0;
            SegLength = 0.0;
            TotalAreaLength = 0.0;
            SegAreaLength = 0.0;
            myArea = 0.0;
            Perimeter = 0.0;
            pCollection = new MultipointClass();
            pGeometry = null;
        }