Example #1
0
        /// <summary>
        /// 更新多边形的某一点坐标
        /// </summary>
        /// <param name="oldLngLat">老坐标</param>
        /// <param name="newLngLat">新坐标</param>
        /// <returns></returns>
        public bool UpdatePosition(Core.Model.MapLngLat oldLngLat, Core.Model.MapLngLat newLngLat)
        {
            Dosomething((Action)(delegate
            {
                IPoint oldPoint = new PointClass()
                {
                    X = oldLngLat.Lng, Y = oldLngLat.Lat
                };
                IPoint newPoint = new PointClass()
                {
                    X = newLngLat.Lng, Y = newLngLat.Lat
                };
                for (int i = 0; i < pointCollection.PointCount; i++)
                {
                    if (pointCollection.get_Point(i).Compare(oldPoint) == 0)
                    {
                        pointCollection.RemovePoints(i, 1);
                        pointCollection.AddPoint(newPoint);
                        //坐标点集合
                        pointList.Remove(oldLngLat);
                        pointList.Add(newLngLat);
                        break;
                    }
                }
                base.Geometry = (IGeometry)pointCollection;
            }), true);

            Update();

            return(true);
        }
Example #2
0
        /// <summary>
        /// 更新线位置
        /// </summary>
        /// <param name="pList"></param>
        /// <returns></returns>
        public bool UpdatePosition(List <Core.Model.MapLngLat> pList)
        {
            if (mapControl.InvokeRequired)
            {
                mapControl.Invoke((Action) delegate()
                {
                    IPoint p = new PointClass();
                    pointCollection.RemovePoints(0, pointCollection.PointCount);
                    for (int i = 0; i < pList.Count; i++)
                    {
                        p.PutCoords(pList[i].Lng, pList[i].Lat);
                        pointCollection.AddPoint(p);
                    }

                    base.Geometry = pointCollection as IGeometry;
                });
            }
            else
            {
                IPoint p = new PointClass();
                pointCollection.RemovePoints(0, pointCollection.PointCount);
                for (int i = 0; i < pList.Count; i++)
                {
                    p.PutCoords(pList[i].Lng, pList[i].Lat);
                    pointCollection.AddPoint(p);
                }

                base.Geometry = pointCollection as IGeometry;
            }
            Update();

            pointList = pList;//更新坐标集合
            return(true);
        }
Example #3
0
        /// <summary>
        /// 更新圆心
        /// </summary>
        /// <param name="centerDot"></param>
        public void UpdatePosition(MapLngLat centerDot)
        {
            centerPoint = new PointClass()
            {
                X = centerDot.Lng, Y = centerDot.Lat
            };
            centerPoint.Z = centerDot.Alt;

            IZAware zAware = (IGeometry)centerPoint as IZAware;

            zAware.ZAware     = true;
            upperAxisVector3D = new Vector3DClass();
            upperAxisVector3D.SetComponents(0, 0, 10);
            lowerAxisVector3D = new Vector3DClass();
            lowerAxisVector3D.SetComponents(0, 0, -10);
            lowerAxisVector3D.XComponent -= vectorComponentOffset;
            normalVector3D           = upperAxisVector3D.CrossProduct(lowerAxisVector3D) as IVector3D;
            normalVector3D.Magnitude = this.radius;
            double rotationAngleInRadians = 2 * (Math.PI / 180);

            pointCollection.RemovePoints(0, pointCollection.PointCount);
            for (int i = 0; i < 180; i++)
            {
                normalVector3D.Rotate(-1 * rotationAngleInRadians, upperAxisVector3D);
                IPoint vertexPoint = new PointClass();
                vertexPoint.X = centerPoint.X + normalVector3D.XComponent;
                vertexPoint.Y = centerPoint.Y + normalVector3D.YComponent;
                vertexPoint.Z = centerPoint.Z;
                pointCollection.AddPoint(vertexPoint, missing, missing);
                //if (i == 0) pointCollection.AddPoint(vertexPoint, missing, missing);
            }

            base.Geometry = pointCollection as IGeometry;
            this.Update();
        }
Example #4
0
 //删除点对
 private void PointsDataGridView_CellClick(object sender, DataGridViewCellEventArgs e)
 {
     if (e.ColumnIndex == 0 && e.RowIndex < PointsDataGridView.Rows.Count)
     {
         PointsDataGridView.Rows.RemoveAt(e.RowIndex);
         fromPoint.RemovePoints(e.RowIndex, 1);
         toPoint.RemovePoints(e.RowIndex, 1);
         AddPoint();
         //Register();
         activeView.Refresh();
         DrawPoints();
     }
 }
Example #5
0
        private void btnImportControlPoints_Click(object sender, EventArgs e)
        {
            try
            {
                OpenFileDialog dlg = new OpenFileDialog();
                dlg.Filter = "文本文件(*.txt;*.TXT)|*.txt;*.TXT|所有文件(*.*)|*.*";
                if (dlg.ShowDialog() == DialogResult.OK)
                {
                    OriginPoints.RemovePoints(0, OriginPoints.PointCount);
                    TargetPoints.RemovePoints(0, TargetPoints.PointCount);
                    TransformedOriginPoints.RemovePoints(0, TransformedOriginPoints.PointCount);

                    StreamReader sr = new StreamReader(dlg.FileName);
                    while (!sr.EndOfStream)
                    {
                        string   szCurrent    = sr.ReadLine();
                        string[] szStringList = szCurrent.Split('\t');
                        if (szStringList.Length != 4)
                        {
                            continue;
                        }
                        else
                        {
                            IPoint pSrcPoint = new PointClass();
                            pSrcPoint.X = Convert.ToDouble(szStringList[0]);
                            pSrcPoint.Y = Convert.ToDouble(szStringList[1]);
                            OriginPoints.AddPoint(pSrcPoint);

                            IPoint pDstPoint = new PointClass();
                            pDstPoint.X = Convert.ToDouble(szStringList[2]);
                            pDstPoint.Y = Convert.ToDouble(szStringList[3]);
                            TargetPoints.AddPoint(pDstPoint);
                        }
                    }

                    sr.Close();

                    RefreshControlAllPoints();
                    if (OriginPoints.PointCount > 0)
                    {
                        dataGridViewX1.Rows[0].Selected = true;
                    }

                    //DrawControlPoint();
                }
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Example #6
0
        public static int ThinPolyline3D(IPointCollection ipointCollection_0)
        {
            int num   = -1;
            int index = 0;
            int num2  = -1;
            int num3  = 0;

            while (ipointCollection_0.PointCount != num2)
            {
                num2 = ipointCollection_0.PointCount;
                ISegmentCollection segmentCollection = ipointCollection_0 as ISegmentCollection;
                IEnumSegment       enumSegments      = segmentCollection.EnumSegments;
                enumSegments.Reset();
                ISegment segment;
                enumSegments.Next(out segment, ref num, ref index);
                ISegment segment2;
                enumSegments.Next(out segment2, ref num, ref index);
                while (segment2 != null)
                {
                    int num4 = segment.ReturnTurnDirection(segment2);
                    if (num4 == 1)
                    {
                        ipointCollection_0.RemovePoints(index, 1);
                    }
                    segment = segment2;
                    enumSegments.Next(out segment2, ref num, ref index);
                }
                num3++;
            }
            return(num3);
        }
Example #7
0
        /// <summary>
        /// 更新位置
        /// </summary>
        /// <param name="pList">点集合</param>
        /// <returns></returns>
        public bool UpdatePosition(List <MapLngLat> pList)
        {
            IPointCollection pointCollection = base.Geometry as IPointCollection;

            if (pointCollection == null)
            {
                return(false);
            }

            this.Dosomething((Action) delegate()
            {
                pointCollection.RemovePoints(0, pointCollection.PointCount);//清除集合内所有坐标点
                IPoint p = new PointClass();
                foreach (var item in pList)
                {
                    p.PutCoords(item.Lng, item.Lat);
                    p.Z = item.Alt;
                    pointCollection.AddPoint(p);
                }
                if (this.Rasterize) //判断图元是否为栅格化
                {
                    this.Rasterize = false;
                    base.Geometry  = pointCollection as IGeometry;
                    this.Rasterize = true;
                }
                else
                {
                    base.Geometry = pointCollection as IGeometry;
                }

                Update();
            }, true);

            return(true);
        }
        private void btnUndo_Click(object sender, EventArgs e)
        {
            int         entityId    = _entityId;
            IEditor3    editor      = ArcUtils.Editor;
            var         sketch      = editor as IEditSketch3;
            Measurement measurement = Measurement.Get(entityId);

            if (sketch != null)
            {
                if (measurement.IsTypeOfLayer(TypeOfLayer.Point))
                {
                    _frmGlobespotter.RemoveMeasurementPoint(entityId, _pointId);
                    _frmGlobespotter.AddMeasurementPoint(entityId);
                }
                else
                {
                    int              nrPoints;
                    IGeometry        geometry     = sketch.Geometry;
                    IPointCollection ptColl       = measurement.ToPointCollection(geometry, out nrPoints);
                    int              removePoints = ((measurement.IsTypeOfLayer(TypeOfLayer.Polygon)) && (ptColl.PointCount == 2) &&
                                                     (nrPoints == 1)) ? 2 : 1;
                    ptColl.RemovePoints((nrPoints - 1), removePoints);
                    sketch.Geometry = ptColl as IGeometry;
                    IActiveView activeView = ArcUtils.ActiveView;

                    if (activeView != null)
                    {
                        activeView.Refresh();
                    }
                }
            }
        }
        //删除节点事件
        void btnRemovePoint_Click(object sender, EventArgs e)
        {
            try
            {
                object misobj = Type.Missing;
                m_Editor.StartOperation();

                IGeometry        ring = (cbxRings.SelectedItem as CommonComboBoxItem).Tag as IGeometry;
                IPointCollection pc   = ring as IPointCollection;
                pc.RemovePoints((int)listPointCollection.SelectedItems[0].Tag, 1);

                IFeature            feature = (treeFeatures.SelectedNode.Tag as IFeature);
                IGeometryCollection geoCol  = cbxRings.Tag as IGeometryCollection;
                geoCol.AddGeometry(ring, ref misobj, ref misobj);
                geoCol.RemoveGeometries(cbxRings.SelectedIndex, 1);
                feature.Shape = geoCol as IGeometry;
                feature.Store();

                int removePointIndex = listPointCollection.SelectedItems[0].Index;
                listPointCollection.SelectedItems[0].Remove();

                m_Editor.StopOperation("RemovePoint");
                this.cbxRings_SelectedIndexChanged(sender, e);
                if (listPointCollection.Items.Count > removePointIndex)
                {
                    listPointCollection.Items[removePointIndex].Selected = true;
                    listPointCollection.TopItem = listPointCollection.SelectedItems[0];
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Example #10
0
        /// <summary>
        /// 结束编辑,删除坐标集合最后一个坐标点
        /// </summary>
        private void endEdit()
        {
            IPointCollection polygonPoint = polygonElement.Geometry as IPointCollection;

            polygonPoint.RemovePoints(polygonPoint.PointCount - 1, 1);
            polygonElement.Geometry = polygonPoint as IGeometry;
        }
Example #11
0
        /// <summary>
        /// 更新线的位置
        /// </summary>
        /// <param name="pList">经纬度列表</param>
        /// <returns></returns>
        public bool UpdatePosition(List <MapLngLat> pList)
        {
            IPointCollection pointCollection = base.Geometry as IPointCollection;

            if (pointCollection != null)
            {
                pointCollection.RemovePoints(0, pointCollection.PointCount);   // 清空之前的点,再添加新点

                for (int i = 0; i < pList.Count; i++)
                {
                    IPoint point = new PointClass();
                    point.PutCoords(pList[i].Lng, pList[i].Lat);
                    point.Z = pList[i].Alt;
                    (point as IZAware).ZAware = true;
                    pointCollection.AddPoint(point);
                }

                Dosomething((Action) delegate()
                {
                    int outIndex = -1;
                    graphcisLayer.FindElementIndex(this, out outIndex);
                    if (outIndex > 0)
                    {
                        base.Geometry = pointCollection as IGeometry;
                        graphcisLayer.UpdateElementByIndex(outIndex);
                    }
                }, true);

                return(true);
            }

            return(false);
        }
Example #12
0
        /// <summary>
        /// 更新位置
        /// </summary>
        /// <param name="oldLngLat">原来的位置</param>
        /// <param name="newLngLat">新的位置</param>
        /// <returns></returns>
        public bool UpdatePosition(MapLngLat oldLngLat, MapLngLat newLngLat)
        {
            this.Dosomething((Action) delegate()
            {
                IPoint newPoint = new PointClass();
                newPoint.PutCoords(newLngLat.Lng, newLngLat.Lat);
                newPoint.Z      = newLngLat.Alt;
                IPoint oldPoint = new PointClass()
                {
                    X = oldLngLat.Lng, Y = oldLngLat.Lat, Z = oldLngLat.Alt
                };
                IPointCollection pointCollection = base.Geometry as IPointCollection;
                for (int i = 0; i < pointCollection.PointCount; i++)
                {
                    if (pointCollection.get_Point(i).Compare(oldPoint) == 0)
                    {
                        pointCollection.RemovePoints(i, 1);
                        pointCollection.AddPoint(newPoint);
                        break;
                    }
                }
                base.Geometry = pointCollection as IGeometry;

                Update();
            }, true);

            return(true);
        }
Example #13
0
 /// <summary>
 /// 回收变量
 /// </summary>
 public void Recycle()
 {
     m_NewPolygonFeedback = null;
     m_ptCollection.RemovePoints(0, m_ptCollection.PointCount);
     m_ptCollection = null;
     m_TracePolygon = null;//20140218 lyf
     m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, m_hookHelper.ActiveView.Extent);
 }
Example #14
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 = "";
        }
Example #15
0
        private void button3_Click(object sender, EventArgs e)
        {
            listView1.Items.Clear();
            FromPoint.RemovePoints(0, FromPoint.PointCount);
            ToPoint.RemovePoints(0, ToPoint.PointCount);
            int Count = 0;

            OpenFileDialog filedlg = new OpenFileDialog();

            filedlg.Title  = "选择坐标文本文件";
            filedlg.Filter = "文本文件(.txt)|*.txt";
            if (filedlg.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            string fullpath = filedlg.FileName;
            string strline  = "";
            string strX0    = "";
            string strY0    = "";
            string strX1    = "";
            string strY1    = "";

            //char []split = new char
            using (StreamReader sr = new StreamReader(fullpath))
            {
                object obj = Type.Missing;
                while ((strline = sr.ReadLine()) != null)
                {
                    if (strline.Contains(",") == false || strline == "控制点" || strline.Contains("****") || strline.Trim() == "")
                    {
                        continue;
                    }
                    string[] splits = strline.Split(new char[] { ',', ';' });
                    strY0 = splits[1];
                    strX0 = splits[2];
                    strY1 = splits[3];
                    strX1 = splits[4];

                    ListViewItem newItem = new ListViewItem();
                    newItem.Checked = true;
                    Count++;//坐标个数增加
                    newItem.Text = Count.ToString();
                    newItem.SubItems.Add(strY0.Trim());
                    newItem.SubItems.Add(strX0.Trim());
                    newItem.SubItems.Add(strY1.Trim());
                    newItem.SubItems.Add(strX1.Trim());
                    listView1.Items.Add(newItem);
                    IPoint newPt = new PointClass();
                    newPt.X = double.Parse(strX0.Trim());
                    newPt.Y = double.Parse(strY0.Trim());
                    FromPoint.AddPoint(newPt, ref obj, ref obj);
                    newPt   = new PointClass();
                    newPt.X = double.Parse(strX1.Trim());
                    newPt.Y = double.Parse(strY1.Trim());
                    ToPoint.AddPoint(newPt, ref obj, ref obj);
                }
            }
        }
Example #16
0
        //#region 测试绘制
        //private void DrawControlPoint()
        //{
        //    try
        //    {
        //       // if (m_ToolAddControlPoints == null) return;

        //        int linelength = 8;
        //        IGraphicsContainer pGraphiccsContainer = pMapCtr.Map as IGraphicsContainer;
        //        if (pGraphiccsContainer == null)
        //            return;

        //        for (int i = 0; i < TargetPoints.PointCount; i++)
        //        {
        //            IPoint opt = TransformedOriginPoints.get_Point(i);
        //            IPoint tpt = TargetPoints.get_Point(i);
        //            IMapControl3 mapctrl = pMapCtr  as IMapControl3;

        //            //判断点是否在视图范围内,如果在即绘制,不在则不绘制
        //            IEnvelope pEnvelope = mapctrl.ActiveView.Extent;

        //            //int ox = 0; int oy = 0; int tx = 0; int ty = 0;
        //            //mapctrl.FromMapPoint(opt, ref ox, ref oy);
        //            //mapctrl.FromMapPoint(tpt, ref tx, ref ty);

        //            #region 连接线
        //            ILineElement pConnectLineElement = new LineElementClass();
        //            ILineSymbol pLineSymbol = new SimpleLineSymbolClass();
        //            pLineSymbol.Width = 2;
        //            pConnectLineElement.Symbol = pLineSymbol;
        //            IElement pConnectElement = pConnectLineElement as IElement;

        //            //设置GEOMETRY
        //            IPolyline pLine = new PolylineClass();
        //            //IPoint ptFromPoint = opt;// new PointClass();
        //            //ptFromPoint.X = ox;
        //            //ptFromPoint.Y = oy;
        //            pLine.FromPoint = opt;// ptFromPoint;

        //            //IPoint ptToPoint = new PointClass();
        //            //ptToPoint.X = ox;
        //            //ptToPoint.Y = oy;
        //            pLine.ToPoint = tpt;
        //            pConnectElement.Geometry = pLine;
        //            pGraphiccsContainer.AddElement(pConnectElement, 0);

        //            //设置颜色
        //            //if (pMapCtr.CurrentTool ==m_FrmLinkTableRaster.selectedidx)
        //            //{
        //            //
        //            //}
        //            #endregion

        //            #region 源点十字丝
        //            //            gcs.DrawLine(penred, ox - linelength, oy, ox + linelength, oy);
        //            //            gcs.DrawLine(penred, ox, oy - linelength, ox, oy + linelength);
        //            //            gcs.DrawLine(pengreen, tx - linelength, ty, tx + linelength, ty);
        //            //            gcs.DrawLine(pengreen, tx, ty - linelength, tx, ty + linelength);
        //            //            gcs.DrawString(i.ToString(), strFont, strBrush, ox+4, oy+4);
        //            //ILineElement pSrcLineElement = new LineElementClass();
        //            //IElement pSrcElement = pSrcLineElement as IElement;

        //            //ILine pSrcLine = new LineClass();
        //            //IPoint pSrcFromPoint = new PointClass();
        //            //pSrcFromPoint.X=ox - linelength;
        //            //pSrcFromPoint.Y = oy;

        //            //IPoint pSrcFromPoint = new PointClass();
        //            //pSrcFromPoint.X = ox - linelength;
        //            //pSrcFromPoint.Y = oy;
        //            #endregion

        //            #region 目标点十字丝
        //            #endregion

        //        }

        //        pMapCtr.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
        //    }
        //    catch (System.Exception ex)
        //    {

        //    }
        //}
        //#endregion

        //删除选中点
        private void buttonX1_Click(object sender, EventArgs e)
        {
            if (dataGridViewX1.SelectedRows.Count == 0)
            {
                return;
            }

            int        nCount     = dataGridViewX1.SelectedRows.Count;
            List <int> nIndexList = new List <int>();

            for (int i = 0; i < nCount; i++)
            {
                DataGridViewRow row = dataGridViewX1.SelectedRows[i];
                nIndexList.Add(row.Index);
            }

            //升序排列
            nIndexList.Sort();
            nCount = -1;
            while ((nCount = nIndexList.Count) != 0)
            {
                OriginPoints.RemovePoints(nIndexList[nCount - 1], 1);
                TargetPoints.RemovePoints(nIndexList[nCount - 1], 1);
                nIndexList.RemoveAt(nCount - 1);
            }
            //for (int i = 0; i < nCount; i++)
            //{
            //    int idx = nIndexArray[i];
            //    OriginPoints.RemovePoints(idx, 1);
            //    TargetPoints.RemovePoints(idx, 1);
            //}

            RefreshControlAllPoints();
            //if(dataGridViewX1)
            //if (idx - 1 >= 0)
            //{
            //    dataGridViewX1.Rows[idx - 1].Selected = true;
            //}
            //if (dataTable1.Rows.Count > 0)
            //{
            //    dataGridViewX1.Rows[idx-1].Selected = true;
            //}
        }
Example #17
0
        public void RemovePoint(int partIndex, int pointIndex)
        {
            // TODO:  添加 ModifyMultiPoint.WSGRI.DigitalFactory.DFQuery.IModifyGeometry.RemovePoint 实现
            IPointCollection pColl = (IPointCollection)Feature.Shape;

            if ((partIndex > -1) && (partIndex < pColl.PointCount))
            {
                pColl.RemovePoints(partIndex, 1);
                Feature.Shape = (IGeometry)pColl;
                Feature.Store();
            }
        }
Example #18
0
        public void CancleSketch()
        {
            IEngineEditSketch sketch   = this._editor as IEngineEditSketch;
            IPointCollection  geometry = (IPointCollection)sketch.Geometry;

            while (geometry.PointCount > 0)
            {
                geometry.RemovePoints(geometry.PointCount - 1, geometry.PointCount);
            }
            sketch.Geometry = (IGeometry)geometry;
            sketch.RefreshSketch();
        }
Example #19
0
        public void OnMouseUp(int button, int shift, int x, int y)
        {
            IRelationalOperator envelope = this._feedBack.Stop().Envelope as IRelationalOperator;

            if (!envelope.Disjoint(this._feature.Shape))
            {
                string[] strArray = this._errInf.Split(new char[] { ',' });
                double   num      = double.Parse(strArray[0]);
                double   num2     = double.Parse(strArray[1]);
                IPoint   point    = new PointClass {
                    X = num,
                    Y = num2
                };
                if (!envelope.Disjoint(point.Envelope))
                {
                    IGeometryCollection shape = this._feature.Shape as IGeometryCollection;
                    try
                    {
                        Editor.UniqueInstance.StartEditOperation();
                        for (int i = 0; i < shape.GeometryCount; i++)
                        {
                            IPointCollection points = shape.get_Geometry(i) as IPointCollection;
                            int num4 = -1;
                            for (int j = 0; j < points.PointCount; j++)
                            {
                                IPoint point2 = points.get_Point(j);
                                if ((point2.X == x) && (point2.Y == y))
                                {
                                    if (num4 == -1)
                                    {
                                        num4 = j;
                                    }
                                    else
                                    {
                                        points.RemovePoints(j, 1);
                                    }
                                }
                            }
                        }
                        Editor.UniqueInstance.StopEditOperation();
                        EditTask.ToplogicChkState = ToplogicCheckState.Failure;
                    }
                    catch (Exception exception)
                    {
                        Editor.UniqueInstance.AbortEditOperation();
                        this.mErrOpt.ErrorOperate(this.mSubSysName, "ShapeEdit.RPointDelete", "OnMouseUp", exception.GetHashCode().ToString(), exception.Source, exception.Message, "", "", "");
                    }
                }
            }
        }
Example #20
0
        private void btnSaveClass_Click(object sender, EventArgs e)
        {
            if (cbClassName.Text == "")
            {
                MessageBox.Show("请输入类别名称!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                return;
            }
            if (txtSampleCount.Text == "")
            {
                MessageBox.Show("没有需要保存的样本!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                return;
            }
            if (bNewClassOrNot)
            {
                ListViewItem pListViewItem = new ListViewItem(this.txtClassID.Text);
                pListViewItem.SubItems.Add(this.cbClassName.Text);
                pListViewItem.SubItems.Add(this.txtSampleCount.Text);
                pListViewItem.SubItems.Add(SetColorByIndex(this.listView1.Items.Count + 1).Name);
                for (int i = 0; i < pGeometryCollection.GeometryCount; i++)
                {
                    pointCollection = pGeometryCollection.get_Geometry(i) as IPointCollection;
                    for (int j = 0; j < pointCollection.PointCount; j++)
                    {
                        xCoordinate += pointCollection.get_Point(j).X.ToString() + ",";
                        yCoordinate += pointCollection.get_Point(j).Y.ToString() + ",";
                    }
                    xCoordinate = xCoordinate.Substring(0, xCoordinate.Length - 1);
                    yCoordinate = yCoordinate.Substring(0, yCoordinate.Length - 1);
                    xCoordinate = xCoordinate + "*";
                    yCoordinate = yCoordinate + "*";
                }
                xCoordinate = xCoordinate.Substring(0, xCoordinate.Length - 1);
                yCoordinate = yCoordinate.Substring(0, yCoordinate.Length - 1);

                pListViewItem.SubItems.Add(xCoordinate + ":" + yCoordinate);
                pListViewItem.BackColor = SetColorByIndex(this.listView1.Items.Count + 1);
                this.listView1.Items.Add(pListViewItem);

                pointCollection.RemovePoints(0, pointCollection.PointCount);
                pGeometryCollection.RemoveGeometries(0, pGeometryCollection.GeometryCount);
                xCoordinate = "";
                yCoordinate = "";
            }
            this.bNewClassOrNot       = false;
            this.tsbEndCreate.Enabled = false;
            this.bCreateOrNot         = false;
            this.btnSaveClass.Enabled = false;
        }
Example #21
0
        private void btnDeleteLink_Click(object sender, EventArgs e)
        {
            DataGridViewSelectedRowCollection rowCollection = this.dataGridViewX1.SelectedRows;
            int nCount    = rowCollection.Count;
            int nOriCount = m_OriginPoints.PointCount;

            IPointCollection tmpPointCollectionOri = new MultipointClass();
            IPointCollection tmpPointCollectionDst = new MultipointClass();

            for (int i = 0; i < nOriCount; i++)
            {
                bool bFlag = false;
                for (int j = 0; j < nCount; j++)
                {
                    if (i == rowCollection[j].Index)
                    {
                        bFlag = true;
                        break;
                    }
                }

                if (bFlag == false)
                {
                    tmpPointCollectionOri.AddPoint(m_OriginPoints.get_Point(i));
                    tmpPointCollectionDst.AddPoint(m_TargetPoints.get_Point(i));
                }
            }

            m_OriginPoints.RemovePoints(0, m_OriginPoints.PointCount);
            m_TargetPoints.RemovePoints(0, m_TargetPoints.PointCount);
            for (int i = 0; i < tmpPointCollectionDst.PointCount; i++)
            {
                m_OriginPoints.AddPoint(tmpPointCollectionOri.get_Point(i));
                m_TargetPoints.AddPoint(tmpPointCollectionDst.get_Point(i));
            }

            RefreshDataTable();

            //m_pMapCtr.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
            //m_pMapCtr.RefreshLayer();
            //if (refreshLayer != null)
            //{
            //    refreshLayer();
            //}
        }
        public void DeleteAllControlPoints()
        {
            IMapControl2 pMapCtr = (((IToolbarControl)m_hookHelper.Hook).Buddy) as IMapControl2;

            if (pMapCtr != null)
            {
                IGeoReference pGR = pRasterLayer as IGeoReference;
                if (pGR != null)
                {
                    pGR.Reset();
                    TransformedOriginPoints.RemovePoints(0, TransformedOriginPoints.PointCount);
                    OriginPoints.RemovePoints(0, OriginPoints.PointCount);
                    TargetPoints.RemovePoints(0, TargetPoints.PointCount);
                    m_FrmLinkTableRaster.RefreshControlAllPoints();
                    pMapCtr.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
                }
            }
        }
Example #23
0
 public void OnMouseUp(int button, int shift, int x, int y)
 {
     if (button != 2)
     {
         try
         {
             IGeometry editShape       = Editor.UniqueInstance.EditShape;
             IPoint    queryPoint      = this._hookHelper.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(x, y);
             IHitTest  test            = editShape as IHitTest;
             IPoint    hitPoint        = new PointClass();
             double    hitDistance     = 0.0;
             int       hitPartIndex    = 0;
             int       hitSegmentIndex = 0;
             bool      bRightSide      = false;
             double    searchRadius    = this._hookHelper.ActiveView.ScreenDisplay.DisplayTransformation.FromPoints(ToolConfig.MouseTolerance);
             esriGeometryHitPartType esriGeometryPartVertex = esriGeometryHitPartType.esriGeometryPartVertex;
             test.HitTest(queryPoint, searchRadius, esriGeometryPartVertex, hitPoint, ref hitDistance, ref hitPartIndex, ref hitSegmentIndex, ref bRightSide);
             if (!hitPoint.IsEmpty)
             {
                 IEngineSketchOperation operation = new EngineSketchOperationClass();
                 operation.Start(Editor.UniqueInstance.EngineEditor);
                 IGeometryCollection geometrys = editShape as IGeometryCollection;
                 IPointCollection    points    = geometrys.get_Geometry(hitPartIndex) as IPointCollection;
                 object missing = Type.Missing;
                 new object();
                 object before = new object();
                 before = hitPartIndex;
                 points.RemovePoints(hitSegmentIndex, 1);
                 operation.SetMenuString("Delete Vertex");
                 esriEngineSketchOperationType esriEngineSketchOperationVertexDeleted = esriEngineSketchOperationType.esriEngineSketchOperationVertexDeleted;
                 geometrys.RemoveGeometries(hitPartIndex, 1);
                 geometrys.AddGeometry(points as IGeometry, ref before, ref missing);
                 operation.Finish(null, esriEngineSketchOperationVertexDeleted, queryPoint);
                 Editor.UniqueInstance.FinishSketch();
                 this.OnClick();
             }
         }
         catch (Exception exception)
         {
             Editor.UniqueInstance.AbortEditOperation();
             this._mErrOpt.ErrorOperate(this._mSubSysName, "ShapeEdit.DeleteVertex", "OnMouseUp", exception.GetHashCode().ToString(), exception.Source, exception.Message, "", "", "");
         }
     }
 }
Example #24
0
 //测量结果窗口关闭响应事件
 private void frmMeasureResult_frmColsed()
 {
     //清空线对象
     if (pNewLineFeedback != null)
     {
         pNewLineFeedback.Stop();
         pNewLineFeedback = null;
     }
     //清空面对象
     if (pNewPolygonFeedback != null)
     {
         pNewPolygonFeedback.Stop();
         pNewPolygonFeedback = null;
         pAreaPointCol.RemovePoints(0, pAreaPointCol.PointCount); //清空点集中所有点
     }
     //清空量算画的线、面对象
     axMapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewForeground, null, null);
     //结束量算功能
     pMouseOperate             = string.Empty;
     axMapControl.MousePointer = esriControlsMousePointer.esriPointerDefault;
 }
Example #25
0
        /// <summary>
        /// 移除点
        /// </summary>
        /// <param name="lnglat"></param>
        public void RemovePoint(MapLngLat lnglat)
        {
            this.Dosomething((Action) delegate()
            {
                IPointCollection pointCollection = base.Geometry as IPointCollection;
                IPoint point = new PointClass();
                point.PutCoords(lnglat.Lng, lnglat.Lat);
                point.Z = lnglat.Alt;
                for (int i = 0; i < pointCollection.PointCount; i++)
                {
                    if (pointCollection.get_Point(i).Compare(point) == 0)
                    {
                        pointCollection.RemovePoints(i, 1);
                        break;
                    }
                }
                base.Geometry = pointCollection as IGeometry;

                Update();
            }, true);
        }
Example #26
0
 private void DeletePoint()
 {
     try
     {
         DataRow focusedDataRow = this.gridView1.GetFocusedDataRow();
         if (focusedDataRow != null)
         {
             int i             = Convert.ToInt32(focusedDataRow[0]);
             int selectedIndex = this.listPart.SelectedIndex;
             if (selectedIndex >= 0)
             {
                 IGeometryCollection geometry = this.m_Geometry as IGeometryCollection;
                 IPointCollection    points   = geometry.get_Geometry(selectedIndex) as IPointCollection;
                 IPoint data = points.get_Point(i);
                 points.RemovePoints(i, 1);
                 IEngineSketchOperation operation = new EngineSketchOperationClass();
                 operation.Start(Editor.UniqueInstance.EngineEditor);
                 operation.SetMenuString("Delete Vertex");
                 esriEngineSketchOperationType esriEngineSketchOperationVertexDeleted = esriEngineSketchOperationType.esriEngineSketchOperationVertexDeleted;
                 object missing = System.Type.Missing;
                 object before  = new object();
                 before = selectedIndex;
                 geometry.RemoveGeometries(selectedIndex, 1);
                 geometry.AddGeometry(points as IGeometry, ref before, ref missing);
                 operation.Finish(null, esriEngineSketchOperationVertexDeleted, data);
                 Editor.UniqueInstance.FinishSketch();
                 IEngineEditTask taskByUniqueName = Editor.UniqueInstance.EngineEditor.GetTaskByUniqueName("ControlToolsEditing_ModifyFeatureTask");
                 Editor.UniqueInstance.EngineEditor.CurrentTask = taskByUniqueName;
                 int index = this.listPart.SelectedIndex;
                 if (index >= 0)
                 {
                     this.ShowPointList(index);
                 }
             }
         }
     }
     catch
     {
     }
 }
Example #27
0
        /// <summary>
        /// 移除点
        /// </summary>
        /// <param name="lngLat">经纬度</param>
        public void RemovePoint(MapLngLat lngLat)
        {
            IPointCollection pointCollection = base.Geometry as IPointCollection;

            if (pointCollection != null)
            {
                IPoint point = new PointClass()
                {
                    X = lngLat.Lng, Y = lngLat.Lat, Z = lngLat.Alt
                };
                for (int i = 0; i < pointCollection.PointCount; i++)
                {
                    if (pointCollection.get_Point(i).Compare(point) == 0)
                    {
                        pointCollection.RemovePoints(i, 1);
                        Dosomething((Action) delegate()
                        {
                            base.Geometry = pointCollection as IGeometry;
                        }, true);
                        break;
                    }
                }
            }
        }
Example #28
0
        /// <summary>
        ///  ��ȡͼ��������
        /// </summary>
        /// <param name="ipPointCollection">����㼯��</param>
        /// <param name="ipTuFuEnvelope">ͼ����������</param>
        /// <returns></returns>
        private IArray GetTuFuGriddingLine(IPointCollection ipPointCollection, IEnvelope ipTuFuEnvelope)
        {
            try
            {
                IArray aryGriddingLine = new ArrayClass();
                double dMinX = 0.0;
                double dMaxX = 0.0;
                double dMinY = 0.0;
                double dMaxY = 0.0;

                dMinX = ipTuFuEnvelope.XMin;
                dMaxX = ipTuFuEnvelope.XMax;
                dMinY = ipTuFuEnvelope.YMin;
                dMaxY = ipTuFuEnvelope.YMax;

                int nPointCount = ipPointCollection.PointCount;

                IPoint ipPoint1 = null;
                IPoint ipPoint2 = null;

                double dX1 = 0.0;
                double dY1 = 0.0;
                double dX2 = 0.0;
                double dY2 = 0.0;

                double dHeight = (dMaxY - dMinY)/1000;
                double dWidth = (dMaxX - dMinX)/1000;
                double dTempTol = dHeight > dWidth ? dWidth : dHeight;

                List<int> aryVerticalIndex = new List<int>(); //CArray<long,long> aryVerticalIndex;//���д�ֱ�����ߵ��������
                List<int> aryHorizontal = new List<int>(); //CArray<long,long> aryHorizontal;//����ˮƽ�����ߵ��������

                int nVerCount = 0;
                int nHorCount = 0;
                int i, j;

                //����߿��ϵĵ�,�м�ĵ�ȥ��
                for (i = 0; i < nPointCount;)
                {
                    ipPoint1 = ipPointCollection.get_Point(i);
                    if (!PointBIsOverBoundary(ipPoint1, ipTuFuEnvelope, dTempTol))
                    {
                        ipPointCollection.RemovePoints(i, 1);
                        nPointCount--;
                    }
                    else
                    {
                        i++;
                    }
                }

                nPointCount = ipPointCollection.PointCount;
                for (i = 0; i < nPointCount; i++)
                {
                    ipPoint1 = ipPointCollection.get_Point(i);

                    dX1 = ipPoint1.X;
                    dY1 = ipPoint1.Y;

                    nVerCount = aryVerticalIndex.Count;
                    if (nVerCount == 0 && Math.Abs(dY1 - dMinY) < dTempTol
                        && Math.Abs(dX1 - dMinX) > dTempTol
                        && Math.Abs(dX1 - dMaxX) > dTempTol)
                    {
                        nVerCount++;
                        aryVerticalIndex.Add(i);
                    }

                    nHorCount = aryHorizontal.Count;
                    if (nHorCount == 0 && Math.Abs(dX1 - dMinX) < dTempTol
                        && Math.Abs(dY1 - dMinY) > dTempTol
                        && Math.Abs(dY1 - dMaxY) > dTempTol)
                    {
                        nHorCount++;
                        aryHorizontal.Add(i);
                    }

                    for (j = 0; j < nVerCount; j++)
                    {
                        ipPoint2 = ipPointCollection.get_Point(aryVerticalIndex[j]);
                        dX2 = ipPoint2.X;
                        dY2 = ipPoint2.Y;

                        if (Math.Abs(dX1 - dX2) < dTempTol && Math.Abs(dY1 - dY2) < dTempTol)
                        {
                            break;
                        }
                    }

                    if (j >= nVerCount)
                    {
                        //ȡ�ײ�ȥ����������ĵ�Ϊ���
                        if (Math.Abs(dY1 - dMinY) < dTempTol
                            && Math.Abs(dX1 - dMinX) > dTempTol
                            && Math.Abs(dX1 - dMaxX) > dTempTol)
                        {
                            aryVerticalIndex.Add(i);
                        }
                    }

                    for (j = 0; j < nHorCount; j++)
                    {
                        ipPoint2 = ipPointCollection.get_Point(aryHorizontal[j]);
                        dX2 = ipPoint2.X;
                        dY2 = ipPoint2.Y;
                        if (Math.Abs(dX1 - dX2) < dTempTol && Math.Abs(dY1 - dY2) < dTempTol)
                        {
                            break;
                        }
                    }

                    if (j >= nHorCount)
                    {
                        //ȡ���ȥ����������ĵ�Ϊ���
                        if (Math.Abs(dX1 - dMinX) < dTempTol
                            && Math.Abs(dY1 - dMinY) > dTempTol
                            && Math.Abs(dY1 - dMaxY) > dTempTol)
                        {
                            aryHorizontal.Add(i);
                        }
                    }
                }

                nPointCount = ipPointCollection.PointCount;

                //��֯��ֱ������
                nVerCount = aryVerticalIndex.Count;
                for (i = 0; i < nVerCount; i++)
                {
                    ipPoint1 = ipPointCollection.get_Point(aryVerticalIndex[i]);
                    dX1 = ipPoint1.X;
                    dY1 = ipPoint1.Y;

                    //������
                    IPolyline ipPolyline = new PolylineClass();
                    ipPolyline.FromPoint = ipPoint1;

                    for (j = 0; j < nPointCount; j++)
                    {
                        ipPoint2 = ipPointCollection.get_Point(j);
                        dX2 = ipPoint2.X;
                        dY2 = ipPoint2.Y;
                        if (Math.Abs(dX1 - dX2) < dTempTol && Math.Abs(dY1 - dY2) > dTempTol)
                        {
                            //����յ�
                            ipPolyline.ToPoint = ipPoint2;
                            break;
                        }
                    }
                    aryGriddingLine.Add(ipPolyline);
                }

                //��֯ˮƽ������
                nHorCount = aryHorizontal.Count;
                for (i = 0; i < nHorCount; i++)
                {
                    ipPoint1 = ipPointCollection.get_Point(aryHorizontal[i]);
                    dX1 = ipPoint1.X;
                    dY1 = ipPoint1.Y;

                    //������
                    IPolyline ipPolyline = new PolylineClass();
                    ipPolyline.FromPoint = ipPoint1;

                    for (j = 0; j < nPointCount; j++)
                    {
                        ipPoint2 = ipPointCollection.get_Point(j);
                        dX2 = ipPoint2.X;
                        dY2 = ipPoint2.Y;
                        if (Math.Abs(dY1 - dY2) < dTempTol && Math.Abs(dX1 - dX2) > dTempTol)
                        {
                            //����յ�
                            ipPolyline.ToPoint = ipPoint2;
                            break;
                        }
                    }
                    aryGriddingLine.Add(ipPolyline);
                }
                return aryGriddingLine;
            }
            catch (Exception ex)
            {
                SendMessage(enumMessageType.Exception, ex.ToString());
                return null;
            }
        }
Example #29
0
        public void DrawGrid()
        {
            string              str        = "";
            string              str2       = "";
            ITextElement        element    = null;
            ITextElement        element2   = null;
            ITextElement        element3   = null;
            ITextElement        element4   = null;
            double              num        = 40.0;
            double              num2       = 20.0;
            double              num3       = 10.0;
            int                 num4       = 13;
            int                 num5       = 10;
            IPoint              point      = null;
            IElement            item       = null;
            ITextSymbol         symbol     = new TextSymbolClass();
            ITextSymbol         symbol2    = new TextSymbolClass();
            ITextSymbol         symbol3    = new TextSymbolClass();
            ITextSymbol         symbol4    = new TextSymbolClass();
            ITextSymbol         symbol5    = new TextSymbolClass();
            ITextSymbol         symbol6    = new TextSymbolClass();
            int                 num6       = 0;
            int                 num7       = 0;
            int                 num8       = 1000;
            double              x          = 0.0;
            double              y          = 0.0;
            IPoint              point2     = new PointClass();
            object              missing    = System.Type.Missing;
            IElementProperties2 properties = null;
            IMarkerElement      element6   = null;
            ISymbol             symbol7    = new SimpleMarkerSymbolClass();
            ISimpleMarkerSymbol symbol8    = symbol7 as ISimpleMarkerSymbol;
            IRgbColor           color      = new RgbColorClass
            {
                Red   = 0,
                Blue  = 0,
                Green = 0
            };

            symbol8.Size  = 10.0;
            symbol8.Style = esriSimpleMarkerStyle.esriSMSCross;
            symbol8.Color = color;
            double num11 = 0.0;
            double num12 = 0.0;
            double num13 = 0.0;
            double num14 = 0.0;
            int    num15 = 0;
            int    num16 = 0;
            int    num17 = 0;
            int    num18 = 0;
            int    num19 = 0;
            double num20 = 0.0;
            double num21 = 0.0;
            double num22 = 0.0;
            double num23 = 0.0;

            try
            {
                symbol = base.FontStyle((double)num4, esriTextHorizontalAlignment.esriTHARight,
                                        esriTextVerticalAlignment.esriTVABottom);
                symbol2 = base.FontStyle((double)num5, esriTextHorizontalAlignment.esriTHALeft,
                                         esriTextVerticalAlignment.esriTVABottom);
                symbol3 = base.FontStyle((double)num5, esriTextHorizontalAlignment.esriTHARight,
                                         esriTextVerticalAlignment.esriTVATop);
                symbol4 = base.FontStyle((double)num4, esriTextHorizontalAlignment.esriTHALeft,
                                         esriTextVerticalAlignment.esriTVATop);
                symbol5 = base.FontStyle((double)num5, esriTextHorizontalAlignment.esriTHARight,
                                         esriTextVerticalAlignment.esriTVABottom);
                symbol6 = base.FontStyle((double)num4, esriTextHorizontalAlignment.esriTHALeft,
                                         esriTextVerticalAlignment.esriTVABottom);
                if (base.LeftUp.Y < base.RightUp.Y)
                {
                    y     = Math.Truncate(base.LeftUp.Y);
                    num23 = (base.RightUp.Y + base.InOutDist) + 1.0;
                }
                else
                {
                    y     = Math.Truncate(base.RightUp.Y);
                    num23 = (base.LeftUp.Y + base.InOutDist) + 1.0;
                }
                num15 = (int)(y % ((double)num8));
                if (num15 != 0)
                {
                    num12 = y - num15;
                }
                else
                {
                    num12 = y;
                }
                if (base.LeftUp.X > base.LeftLow.X)
                {
                    x     = Math.Truncate((double)(base.LeftUp.X + 1.0));
                    num20 = (base.LeftLow.X - base.InOutDist) - 1.0;
                }
                else
                {
                    x     = Math.Truncate((double)(base.LeftLow.X + 1.0));
                    num20 = (base.LeftUp.X - base.InOutDist) - 1.0;
                }
                num15 = (int)(x % ((double)num8));
                if (num15 != 0)
                {
                    num11 = x + (num8 - num15);
                }
                else
                {
                    num11 = x;
                }
                if (base.LeftLow.Y < base.RightLow.Y)
                {
                    y     = Math.Truncate(base.LeftLow.Y);
                    num21 = (base.LeftLow.Y - base.InOutDist) - 1.0;
                }
                else
                {
                    y     = Math.Truncate(base.RightLow.Y);
                    num21 = (base.RightLow.Y - base.InOutDist) - 1.0;
                }
                num15 = (int)(y % ((double)num8));
                if (num15 != 0)
                {
                    num14 = y + (num8 - num15);
                }
                else
                {
                    num14 = y;
                }
                if (base.RightUp.X > base.RightLow.X)
                {
                    x     = Math.Truncate(base.RightLow.X);
                    num22 = (base.RightUp.X + base.InOutDist) + 1.0;
                }
                else
                {
                    x     = Math.Truncate(base.RightUp.X);
                    num22 = (base.RightLow.X + base.InOutDist) + 1.0;
                }
                num15 = (int)(x % ((double)num8));
                if (num15 != 0)
                {
                    num13 = x - num15;
                }
                else
                {
                    num13 = x;
                }
                num16 = ((int)(num12 - num14)) / num8;
                num17 = ((int)(num13 - num11)) / num8;
                for (num18 = 0; num18 <= num16; num18++)
                {
                    y = num12 - (num18 * num8);
                    for (num19 = 0; num19 <= num17; num19++)
                    {
                        x = num11 + (num19 * num8);
                        point2.PutCoords(x, y);
                        item = new MarkerElementClass
                        {
                            Geometry = point2
                        };
                        element6        = item as IMarkerElement;
                        element6.Symbol = symbol8;
                        properties      = item as IElementProperties2;
                        properties.Type = "公里网";
                        this.ilist_0.Add(item);
                    }
                }
                IPolygon polygon = new PolygonClass();
                new PolygonElementClass();
                polygon = this.method_3();
                double           num1      = base.LeftUp.X - base.InOutDist;
                double           num24     = base.LeftUp.X;
                double           num25     = base.RightUp.X;
                double           num26     = base.RightUp.X + base.InOutDist;
                IPoint           inPoint   = null;
                IPoint           point4    = null;
                IPoint           point5    = null;
                IPoint           point6    = null;
                IPolyline        polyline  = new PolylineClass();
                IPolyline        polyline2 = new PolylineClass();
                IPolyline        polyline3 = new PolylineClass();
                IPoint           point7    = null;
                IPoint           point8    = null;
                IPointCollection points    = null;
                IPointCollection points2   = null;
                IElement         element7  = null;
                IElement         element8  = null;
                ILineElement     element9  = null;
                ILineSymbol      symbol9   = this.method_5(1);
                for (num18 = 0; num18 <= num16; num18++)
                {
                    y      = num12 - (num18 * num8);
                    point7 = new PointClass();
                    point8 = new PointClass();
                    point7.PutCoords(num20, y);
                    point8.PutCoords(num22, y);
                    points = polyline3 as IPointCollection;
                    if (points.PointCount >= 1)
                    {
                        points.RemovePoints(0, points.PointCount);
                    }
                    points.AddPoint(point7, ref missing, ref missing);
                    points.AddPoint(point8, ref missing, ref missing);
                    points          = this.method_4(polyline3, polygon);
                    inPoint         = points.get_Point(0);
                    point4          = points.get_Point(1);
                    point5          = points.get_Point(2);
                    point6          = points.get_Point(3);
                    element7        = new LineElementClass();
                    element9        = element7 as ILineElement;
                    element9.Symbol = symbol9;
                    points2         = polyline as IPointCollection;
                    if (points2.PointCount >= 1)
                    {
                        points2.RemovePoints(0, points2.PointCount);
                    }
                    points2.AddPoint(inPoint, ref missing, ref missing);
                    points2.AddPoint(point4, ref missing, ref missing);
                    element7.Geometry = polyline;
                    element8          = new LineElementClass();
                    element9          = element8 as ILineElement;
                    element9.Symbol   = symbol9;
                    points2           = polyline2 as IPointCollection;
                    if (points2.PointCount >= 1)
                    {
                        points2.RemovePoints(0, points2.PointCount);
                    }
                    points2.AddPoint(point5, ref missing, ref missing);
                    points2.AddPoint(point6, ref missing, ref missing);
                    element8.Geometry = polyline2;
                    this.ilist_0.Add(element7);
                    this.ilist_0.Add(element8);
                    element  = new TextElementClass();
                    element2 = new TextElementClass();
                    element3 = new TextElementClass();
                    element4 = new TextElementClass();
                    num6     = (int)Math.Truncate((double)(y / 100000.0));
                    str      = num6.ToString();
                    num7     = (int)Math.Truncate((double)((y - (num6 * 100000)) / 1000.0));
                    str2     = num7.ToString();
                    if (str2.Length < 2)
                    {
                        str2 = "0" + str2;
                    }
                    element.Text  = str2;
                    element2.Text = str;
                    element3.Text = str2;
                    element4.Text = str;
                    point         = new PointClass();
                    point.PutCoords(inPoint.X, inPoint.Y + num2);
                    item           = element as IElement;
                    item.Geometry  = point;
                    element.Symbol = symbol;
                    this.ilist_0.Add(item);
                    if ((num18 == 0) || (num18 == num16))
                    {
                        point = new PointClass();
                        point.PutCoords(point4.X, point4.Y + num);
                        item            = element2 as IElement;
                        item.Geometry   = point;
                        element2.Symbol = symbol2;
                        this.ilist_0.Add(item);
                    }
                    point = new PointClass();
                    point.PutCoords(point5.X, point5.Y + num2);
                    item            = element3 as IElement;
                    item.Geometry   = point;
                    element3.Symbol = symbol;
                    this.ilist_0.Add(item);
                    if ((num18 == 0) || (num18 == num16))
                    {
                        point = new PointClass();
                        point.PutCoords(point6.X, point6.Y + num);
                        item            = element4 as IElement;
                        item.Geometry   = point;
                        element4.Symbol = symbol2;
                        this.ilist_0.Add(item);
                    }
                }
                for (num18 = 0; num18 <= num17; num18++)
                {
                    x      = num11 + (num18 * num8);
                    point7 = new PointClass();
                    point8 = new PointClass();
                    point7.PutCoords(x, num23);
                    point8.PutCoords(x, num21);
                    points = polyline3 as IPointCollection;
                    if (points.PointCount >= 1)
                    {
                        points.RemovePoints(0, points.PointCount);
                    }
                    points.AddPoint(point7, ref missing, ref missing);
                    points.AddPoint(point8, ref missing, ref missing);
                    points          = this.method_4(polyline3, polygon);
                    inPoint         = points.get_Point(0);
                    point4          = points.get_Point(1);
                    point5          = points.get_Point(2);
                    point6          = points.get_Point(3);
                    element7        = new LineElementClass();
                    element9        = element7 as ILineElement;
                    element9.Symbol = symbol9;
                    points2         = polyline as IPointCollection;
                    if (points2.PointCount >= 1)
                    {
                        points2.RemovePoints(0, points2.PointCount);
                    }
                    points2.AddPoint(inPoint, ref missing, ref missing);
                    points2.AddPoint(point4, ref missing, ref missing);
                    element7.Geometry = polyline;
                    element8          = new LineElementClass();
                    element9          = element8 as ILineElement;
                    element9.Symbol   = symbol9;
                    points2           = polyline2 as IPointCollection;
                    if (points2.PointCount >= 1)
                    {
                        points2.RemovePoints(0, points2.PointCount);
                    }
                    points2.AddPoint(point5, ref missing, ref missing);
                    points2.AddPoint(point6, ref missing, ref missing);
                    element8.Geometry = polyline2;
                    this.ilist_0.Add(element7);
                    this.ilist_0.Add(element8);
                    element  = new TextElementClass();
                    element2 = new TextElementClass();
                    element3 = new TextElementClass();
                    element4 = new TextElementClass();
                    num6     = (int)Math.Truncate((double)(x / 100000.0));
                    str      = num6.ToString();
                    str2     = ((int)Math.Truncate((double)((x - (num6 * 100000)) / 1000.0))).ToString();
                    if (str2.Length < 2)
                    {
                        str2 = "0" + str2;
                    }
                    element.Text  = str2;
                    element2.Text = str;
                    element3.Text = str2;
                    element4.Text = str;
                    point         = new PointClass();
                    point.PutCoords(inPoint.X, inPoint.Y - num3);
                    item           = element as IElement;
                    item.Geometry  = point;
                    element.Symbol = symbol4;
                    this.ilist_0.Add(item);
                    if ((num18 == 0) || (num18 == num17))
                    {
                        point = new PointClass();
                        point.PutCoords(inPoint.X, inPoint.Y - num3);
                        item            = element2 as IElement;
                        item.Geometry   = point;
                        element2.Symbol = symbol3;
                        this.ilist_0.Add(item);
                    }
                    point = new PointClass();
                    point.PutCoords(point6.X, point6.Y + num3);
                    item            = element3 as IElement;
                    item.Geometry   = point;
                    element3.Symbol = symbol6;
                    this.ilist_0.Add(item);
                    if ((num18 == 0) || (num18 == num17))
                    {
                        point = new PointClass();
                        point.PutCoords(point6.X, point6.Y + num3);
                        item            = element4 as IElement;
                        item.Geometry   = point;
                        element4.Symbol = symbol5;
                        this.ilist_0.Add(item);
                    }
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message);
            }
        }
Example #30
0
        /// <summary>
        /// 地图中鼠标按下事件监听
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MainMapControl_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e)
        {
            //屏幕坐标点转化为地图坐标点
            pPointPt = (MainMapControl.Map as IActiveView).ScreenDisplay.DisplayTransformation.ToMapPoint(e.x, e.y);
            if (e.button == 1)
            {
                IActiveView pActiveView = MainMapControl.ActiveView;
                IEnvelope   pEnvelope   = new EnvelopeClass();

                switch (pMouseOperate)
                {
                case "ZoomIn":
                    pEnvelope = MainMapControl.TrackRectangle();
                    //  如果拉框范围为空则返回
                    if (pEnvelope == null || pEnvelope.IsEmpty || pEnvelope.Height == 0 || pEnvelope.Width == 0)
                    {
                        return;
                    }
                    // 如果拉框有范围,则拉大到拉框范围
                    MainMapControl.ActiveView.Extent = pEnvelope;
                    MainMapControl.ActiveView.Refresh();
                    break;

                case "ZoomOut":
                    pEnvelope = MainMapControl.TrackRectangle();
                    //  如果拉框范围为空则返回
                    if (pEnvelope == null || pEnvelope.IsEmpty || pEnvelope.Height == 0 || pEnvelope.Width == 0)
                    {
                        return;
                    }
                    else
                    {
                        double dWidth  = pActiveView.Extent.Width * pActiveView.Extent.Width / pEnvelope.Width;
                        double dHeight = pActiveView.Extent.Height * pActiveView.Extent.Height / pEnvelope.Height;
                        double dXmin   = pActiveView.Extent.XMin -
                                         ((pEnvelope.XMin - pActiveView.Extent.XMin) * pActiveView.Extent.Width /
                                          pEnvelope.Width);
                        double dYmin = pActiveView.Extent.YMin -
                                       ((pEnvelope.YMin - pActiveView.Extent.YMin) * pActiveView.Extent.Height /
                                        pEnvelope.Height);
                        double dXmax = dXmin + dWidth;
                        double dYmax = dYmin + dHeight;
                        pEnvelope.PutCoords(dXmin, dYmin, dXmax, dYmax);
                    }
                    pActiveView.Extent = pEnvelope;
                    pActiveView.Refresh();
                    break;

                case "Pan":
                    MainMapControl.Pan();
                    break;

                case "MeasureLength":
                    //判断追踪线对象是否为空,若是则实例化并设置当前鼠标点为起始点
                    if (pNewLineFeedback == null)
                    {
                        //实例化追踪线对象
                        pNewLineFeedback         = new NewLineFeedbackClass();
                        pNewLineFeedback.Display = (MainMapControl.Map as IActiveView).ScreenDisplay;
                        //设置起点,开始动态线绘制
                        pNewLineFeedback.Start(pPointPt);
                        dToltalLength = 0;
                    }
                    else     //如果追踪线对象不为空,则添加当前鼠标点
                    {
                        pNewLineFeedback.AddPoint(pPointPt);
                    }
                    //pGeometry = m_PointPt;
                    if (dSegmentLength != 0)
                    {
                        dToltalLength = dToltalLength + dSegmentLength;
                    }
                    break;

                case "MeasureArea":
                    if (pNewPolygonFeedback == null)
                    {
                        //实例化追踪面对象
                        pNewPolygonFeedback         = new NewPolygonFeedback();
                        pNewPolygonFeedback.Display = (MainMapControl.Map as IActiveView).ScreenDisplay;
                        ;
                        pAreaPointCol.RemovePoints(0, pAreaPointCol.PointCount);
                        //开始绘制多边形
                        pNewPolygonFeedback.Start(pPointPt);
                        pAreaPointCol.AddPoint(pPointPt, ref missing, ref missing);
                    }
                    else
                    {
                        pNewPolygonFeedback.AddPoint(pPointPt);
                        pAreaPointCol.AddPoint(pPointPt, ref missing, ref missing);
                    }
                    break;

                case "SelFeature":
                    IEnvelope pEnv = MainMapControl.TrackRectangle();
                    IGeometry pGeo = pEnv as IGeometry;
                    // 矩形框若为空,即为点选时,对点的范围进行扩展
                    if (pEnv.IsEmpty == true)
                    {
                        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 as IGeometry;
                    MainMapControl.Map.SelectByShape(pGeo, null, false);
                    MainMapControl.Refresh(esriViewDrawPhase.esriViewGeoSelection, null, null);

                    //IEnvelope pEnv = MainMapControl.TrackRectangle();
                    //IGeometry pGeo = pEnv as IGeometry;
                    ////矩形框若为空,即为点选时,对点范围进行扩展
                    //if (pEnv.IsEmpty == true)
                    //{
                    //    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 as IGeometry;
                    //MainMapControl.Map.SelectByShape(pGeo, null, false);
                    //MainMapControl.Refresh(esriViewDrawPhase.esriViewGeoSelection, null, null);

                    break;

                case "ExportRegion":
                    // 删除视图中的数据
                    MainMapControl.ActiveView.GraphicsContainer.DeleteAllElements();
                    MainMapControl.ActiveView.Refresh();
                    IPolygon polygon = DrawPolygon(MainMapControl);
                    if (polygon == null)
                    {
                        return;
                    }
                    ExportMap.AddElement(polygon, MainMapControl.ActiveView);
                    if (FrmExpMap == null || FrmExpMap.IsDisposed)
                    {
                        FrmExpMap = new FormExportMap(MainMapControl);
                    }
                    FrmExpMap.IsRegion   = true;
                    FrmExpMap.GetGometry = polygon as IGeometry;
                    FrmExpMap.Show();
                    FrmExpMap.Activate();
                    break;

                case "TxtSymbol":
                    TxtSymbol(e);
                    break;

                default:
                    break;
                }
            }
            else if (e.button == 2)
            {
                pMouseOperate = "";
                MainMapControl.MousePointer = esriControlsMousePointer.esriPointerDefault;
            }
        }
Example #31
0
 private void DelVertexNode(IPoint pPnt)
 {
     try
     {
         IFeatureLayer pFeaturelayer = m_EngineEditLayers.TargetLayer;
         IActiveView   pActiveView   = m_activeView;
         IPoint        pPoint        = pPnt;
         if (pFeaturelayer.FeatureClass == null)
         {
             return;
         }
         //如果不是面状地物则退出
         if (pFeaturelayer.FeatureClass.ShapeType != esriGeometryType.esriGeometryEnvelope &&
             pFeaturelayer.FeatureClass.ShapeType != esriGeometryType.esriGeometryPolygon &&
             pFeaturelayer.FeatureClass.ShapeType != esriGeometryType.esriGeometryLine &&
             pFeaturelayer.FeatureClass.ShapeType != esriGeometryType.esriGeometryPolyline)
         {
             return;
         }
         IGeometry pGeo        = null;
         IFeature  pSelFeature = null;
         pSelFeature = EditVertexClass.GetSelectedFeature(pFeaturelayer);
         //是否有选中的几何体
         if (pSelFeature == null)
         {
             return;
         }
         pGeo = pSelFeature.ShapeCopy;
         double pSrchDis = 0;
         double pHitDis  = 0;
         pSrchDis = pActiveView.Extent.Width / 200;
         pPoint.Z = 0;
         int              pIndex       = 0;
         IElement         pElement     = null;
         IHitTest         pHtTest      = null;
         bool             pBoolHitTest = false;
         IPoint           pPtHit       = null;
         IPointCollection pPointCol    = null;
         IPolygon         pPolygon     = null;
         IPolyline        pPyline      = null;
         bool             bRightZSide  = true;
         int              pInt         = 0;
         m_EngineEditor.StartOperation();
         //删除面状要素的节点
         if (pFeaturelayer.FeatureClass.ShapeType == esriGeometryType.esriGeometryPolygon ||
             pFeaturelayer.FeatureClass.ShapeType == esriGeometryType.esriGeometryEnvelope)
         {
             pElement          = new PolygonElement();
             pElement.Geometry = pSelFeature.Shape;
             IPolygon pPoly = null;
             pPoly        = pElement.Geometry as IPolygon;
             pHtTest      = pPoly as IHitTest;
             pBoolHitTest = pHtTest.HitTest(pPoint, pSrchDis, esriGeometryHitPartType.esriGeometryPartVertex,
                                            pPtHit, ref pHitDis, ref pInt, ref pIndex, ref bRightZSide);
             if (pBoolHitTest == false)
             {
                 return;
             }
             EditVertexClass.pHitPnt = pPtHit;
             pPointCol = pSelFeature.ShapeCopy as IPointCollection;
             //如果多边形的节点只有3个则不能再删除了
             if (pPointCol.PointCount <= 4)
             {
                 MessageBox.Show("多边形的节点至少需要3个!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                 return;
             }
             //顶点删除
             pPointCol.RemovePoints(pIndex, 1);
             pPolygon = pPointCol as IPolygon;
             pPolygon.Close();
             pSelFeature.Shape = pPolygon;
             pSelFeature.Store();
         }
         //删除线状要素的节点
         else if (pFeaturelayer.FeatureClass.ShapeType == esriGeometryType.esriGeometryPolyline ||
                  pFeaturelayer.FeatureClass.ShapeType == esriGeometryType.esriGeometryLine)
         {
             pElement          = new LineElement();
             pElement.Geometry = pSelFeature.Shape;
             IPolyline pPolyLine = default(IPolyline);
             pPolyLine    = pElement.Geometry as IPolyline;
             pHtTest      = pPolyLine as IHitTest;
             pBoolHitTest = pHtTest.HitTest(pPoint, pSrchDis, esriGeometryHitPartType.esriGeometryPartVertex,
                                            pPtHit, ref pHitDis, ref pInt, ref pIndex, ref bRightZSide);
             if (pBoolHitTest == false)
             {
                 return;
             }
             EditVertexClass.pHitPnt = pPtHit;
             pPointCol = pSelFeature.ShapeCopy as IPointCollection;
             //如果Polyline节点只有2个则不能再删除了
             if (pPointCol.PointCount <= 2)
             {
                 MessageBox.Show("线的节点至少需要2个!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                 return;
             }
             //顶点删除
             pPointCol.RemovePoints(pIndex, 1);
             pPyline           = pPointCol as IPolyline;
             pSelFeature.Shape = pPyline;
             pSelFeature.Store();
         }
         //与选中点坐标相同的节点都删除
         for (int i = 0; i <= pPointCol.PointCount - 1; i++)
         {
             if (i > pPointCol.PointCount - 1)
             {
                 break;
             }
             if (pPointCol.get_Point(i).X == pPoint.X & pPointCol.get_Point(i).Y == pPoint.Y)
             {
                 pPointCol.RemovePoints(i, 1);
                 i = i - 1;
             }
         }
         //停止编辑
         m_EngineEditor.StopOperation("DelVertexTool");
         //显示顶点
         EditVertexClass.ShowAllVertex(pFeaturelayer);
         m_activeView.Refresh();
     }
     catch (Exception ex)
     {
         m_activeView.Refresh();
     }
 }
        private void createpolygon(IPointCollection ippoints)
        {
            ISegmentCollection ppath = new PathClass();
            IGeometryCollection ppolyline = new PolylineClass();
            if (ippoints.PointCount >= 3)
            {
                int i;
                object o = Type.Missing;
                if (ippoints.PointCount >= 4)
                {
                    ippoints.RemovePoints(ippoints.PointCount - 2, 1);
                }
                ippoints.AddPoint(ippoints.get_Point(0));
                for (i = 0; i < ippoints.PointCount - 1; i++)
                {
                    ILine pline = new LineClass();
                    pline.PutCoords(ippoints.get_Point(i), ippoints.get_Point(i + 1));
                    ISegment psegment = pline as ISegment;

                    ppath.AddSegment(psegment, ref o, ref o);
                    ppolyline.AddGeometry(ppath as IGeometry, ref o, ref o);
                }
                ipPolyResult = ppolyline as IPolyline;
                ISegmentCollection pRing = new RingClass();
                IGeometryCollection pGeometryColl = new PolygonClass();
                for (int j = 0; j < ppolyline.GeometryCount; j++)
                {
                    pRing.AddSegmentCollection(ppolyline.get_Geometry(j) as ISegmentCollection);
                    pGeometryColl.AddGeometry(pRing as IGeometry, ref o, ref o);
                }
                ipolygon = pGeometryColl as IPolygon;
            }
        }