Exemplo n.º 1
0
        //结束计算工作
        public void EndCalculateDistance()
        {
            IGeometry        pGeom = null;
            IPolyline        pPolyline;
            IPointCollection pPointCollection;

            System.Windows.Forms.DialogResult result;

            pPolyline = (IPolyline)CommonFunction.MadeSegmentCollection(ref m_pRecordPointArray);

            if (m_bInUse)
            {
                pPointCollection = (IPointCollection)pPolyline;
                if (pPointCollection.PointCount < 2)
                {
                    MessageBox.Show("线上必须有两个点!");
                }
                else
                {
                    pGeom = (IGeometry)pPointCollection;
                }

                CommonFunction.AddElement(m_MapControl, pGeom);//绘制地图元素

                result = MessageBox.Show("总长为:" + m_dblTotalDistance.ToString(".###") + "米", "距离计算", MessageBoxButtons.OK, MessageBoxIcon.Information);

                if (result == DialogResult.OK)
                {
                    Reset();//复位;
                }
            }
        }
Exemplo n.º 2
0
        //结束计算面积工作
        public void EndCalculateArea()
        {
            IGeometry        pGeom = null;
            IPolyline        pPolyline;
            IPolygon         pPolygon;
            IPointCollection pPointCollection;

            System.Windows.Forms.DialogResult result;

            pPolyline = (IPolyline)CommonFunction.MadeSegmentCollection(ref m_pRecordPointArray);

            if (m_bInUse)
            {
                pPolygon         = CommonFunction.PolylineToPolygon(pPolyline);
                pPointCollection = (IPointCollection)pPolygon;
                pGeom            = (IGeometry)pPointCollection;
                if (pPointCollection.PointCount < 3)
                {
                    MessageBox.Show("计算面积必须有三个或三个以上的点!");
                }
                else
                {
                    pGeom = (IGeometry)pPointCollection;
                }

                CommonFunction.AddElement(m_MapControl, pGeom);//绘制地图元素

                result = MessageBox.Show("面积为:" + ((IArea)pPolygon).Area.ToString(".###") + "平方米" + CRLF + "周长为:" + pPolygon.Length.ToString(".###") + "米", "面积计算", MessageBoxButtons.OK, MessageBoxIcon.Information);

                if (result == DialogResult.OK)
                {
                    Reset();//复位;
                }
            }
        }
Exemplo n.º 3
0
        private void CalculateCornerMouseDown(IPoint pPoint)
        {
            IGeometry pGeom = null;

            if (!m_bInUse)            //如果命令没有使用
            {
                     m_pPoint1 = pPoint;
                m_pLastPoint = pPoint;
                m_pRecordPointArray.Add(m_pPoint1);
                m_bInUse = true;

                m_pFeedback = new NewLineFeedbackClass();
                m_pLineFeed = (INewLineFeedback)m_pFeedback;
                m_pLineFeed.Start(pPoint);
                if (m_pFeedback != null)
                {
                    m_pFeedback.Display = m_pActiveView.ScreenDisplay;
                }

                CommonFunction.DrawPointSMSSquareSymbol(m_MapControl, m_pPoint1);
            }
            else             //如果命令正在使用
            {
                m_pPoint2 = pPoint;
                m_pRecordPointArray.Add(pPoint);
                m_bInUse = true;

                m_pLineFeed.AddPoint(pPoint);

                CommonFunction.DrawPointSMSSquareSymbol(m_MapControl, m_pPoint2);
                if (m_pRecordPointArray.Count > 2)
                {
                    IPolyline pPolyline;
                    pPolyline = (IPolyline)CommonFunction.MadeSegmentCollection(ref m_pRecordPointArray);
                    pGeom     = (IGeometry)pPolyline;
                    CommonFunction.AddElement(m_MapControl, pGeom);

                    double dblZimuth = CommonFunction.GetAngleZuo_P123(m_pPoint1, (IPoint)m_pRecordPointArray.get_Element(1), m_pPoint2);
                    dblZimuth = CommonFunction.RadToDeg(dblZimuth);

                    System.Windows.Forms.DialogResult result;
                    string strResult = "三点夹角:" + dblZimuth.ToString(".#####") + "(°′″)";
                    strResult = strResult + CRLF;
                    strResult = strResult + "第一点坐标 X=" + m_pPoint1.X.ToString(".###") + "Y=" + m_pPoint1.Y.ToString(".###");
                    strResult = strResult + CRLF;
                    strResult = strResult + "第二点坐标 X=" + ((IPoint)m_pRecordPointArray.get_Element(1)).X.ToString(".###") + "Y=" + ((IPoint)m_pRecordPointArray.get_Element(1)).Y.ToString(".###");
                    strResult = strResult + CRLF;
                    strResult = strResult + "第三点坐标 X=" + m_pPoint2.X.ToString(".###") + "Y=" + m_pPoint2.Y.ToString(".###");

                    result = MessageBox.Show(strResult, "三点夹角计算", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    if (result == DialogResult.OK)
                    {
                        Reset();                        //复位;
                    }
                }
            }
        }
Exemplo n.º 4
0
        private void CalculateZimuthMouseDown(IPoint pPoint)
        {
            IGeometry pGeom = null;

            if (!m_bInUse) //如果命令没有使用
            {
                m_pPoint1    = pPoint;
                m_pLastPoint = pPoint;
                m_pRecordPointArray.Add(m_pPoint1);
                m_bInUse = true;

                m_pFeedback = new NewLineFeedbackClass();
                m_pLineFeed = (INewLineFeedback)m_pFeedback;
                m_pLineFeed.Start(pPoint);
                if (m_pFeedback != null)
                {
                    m_pFeedback.Display = m_pActiveView.ScreenDisplay;
                }

                CommonFunction.DrawPointSMSSquareSymbol(m_pMapControl, m_pPoint1);
            }
            else //如果命令正在使用
            {
                m_pPoint2 = pPoint;
                m_pRecordPointArray.Add(m_pPoint2);


                CommonFunction.DrawPointSMSSquareSymbol(m_pMapControl, m_pPoint2);

                IPolyline pPolyline;
                pPolyline = (IPolyline)CommonFunction.MadeSegmentCollection(ref m_pRecordPointArray);
                pGeom     = (IGeometry)pPolyline;
                CommonFunction.AddElement(m_pMapControl, pGeom);

                double dblZimuth = CommonFunction.GetAzimuth_P12(m_pPoint1.Y, m_pPoint1.X, m_pPoint2.Y, m_pPoint2.X);
                dblZimuth = CommonFunction.RadToDeg(dblZimuth);

                strResult1 = dblZimuth.ToString(".#####") + " (°) ";
                strResult2 = "X=" + m_pPoint1.X.ToString(".##") + "; " + "Y=" + m_pPoint1.Y.ToString(".##");
                strResult3 = "X=" + m_pPoint2.X.ToString(".##") + "; " + "Y=" + m_pPoint2.Y.ToString(".##");
                if (strResult1 != null && strResult2 != null && strResult3 != null)
                {
                    FrmAzimuthAngle frmAzimuthAngle = FrmAzimuthAngle.Instance();
                    frmAzimuthAngle.ShowDialog();
                }
                if (m_pRecordPointArray.Count != 0)
                {
                    m_pRecordPointArray.RemoveAll();
                }
                m_bInUse = false;
            }
        }
Exemplo n.º 5
0
        public override void OnMouseDown(int button, int shift, int x, int y, double mapX, double mapY)
        {
            IGeometry Geom = null;

            if (!m_bInUse)
            {
                downPoint = m_pAnchorPoint;
                m_pRecordPointArray.Add(downPoint);
                m_pCircleFeed         = new NewCircleFeedbackClass();
                m_bInUse              = true;
                m_pCircleFeed.Display = m_pActiveView.ScreenDisplay;
                m_pLineFeed           = new NewLineFeedbackClass();
                m_pLineFeed.Start(downPoint);
                m_pCircleFeed.Start(downPoint);
            }
            else   //如果命令正在使用
            {
                if (pGraphicsContainer != null)
                {
                    pGraphicsContainer.DeleteAllElements();
                }
                movePoint = m_pAnchorPoint;

                //画半径线
                m_pRecordPointArray.Add(movePoint);
                IPolyline pPolyline;
                pPolyline = (IPolyline)CommonFunction.MadeSegmentCollection(ref m_pRecordPointArray);
                Geom      = (IGeometry)pPolyline;
                CommonFunction.AddElement(m_pMapControl, Geom);
                m_radius = CommonFunction.GetDistance_P12(downPoint, movePoint);  //半径
                //m_radius = Math.Round( m_radius,1,MidpointRounding.AwayFromZero);//保留一位小数
                //缓冲半径文本
                ITextElement iTextElement = new TextElementClass();
                iTextElement.Text = m_radius.ToString(".##") + "米";
                ITextSymbol sce = new TextSymbolClass();
                sce.Size = 15 /*SystemInfo.Instance.TextSize*/;
                Color  color  = ColorTranslator.FromHtml(SystemInfo.Instance.TextColor);
                IColor pColor = new RgbColorClass();
                pColor.RGB          = color.B * 65536 + color.G * 256 + color.R;
                sce.Color           = pColor;
                iTextElement.Symbol = sce;
                IElement iElement = (IElement)iTextElement;
                iElement.Geometry = Geom;
                this.m_pMapControl.ActiveView.GraphicsContainer.AddElement(iElement, 0);
                this.m_pMapControl.ActiveView.Refresh();
                //画圆
                pSegmentCollection = new PolygonClass();
                pSegmentCollection.SetCircle(downPoint, m_radius);
                pGeom = pSegmentCollection as IGeometry;
                if (pGeom != null)
                {
                    AddCreateCircleElement(pGeom, this.m_pMapControl.ActiveView);
                    this.m_pMapControl.ActiveView.Refresh();


                    GetPipeInfo();
                }
                if (m_pRecordPointArray.Count != 0)
                {
                    m_pRecordPointArray.RemoveAll();
                }
                m_bInUse = false;
            }
        }