Ejemplo n.º 1
0
        private void MovePoint(string sColumn, double pValue)
        {
            try
            {
                int num;
                int selectedIndex;
                IGeometryCollection geometry;
                IPointCollection    points;
                IPoint point;
                IEngineSketchOperation operation;
                DataRow focusedDataRow = this.gridView1.GetFocusedDataRow();
                if (focusedDataRow != null)
                {
                    num           = Convert.ToInt32(focusedDataRow[0]);
                    selectedIndex = this.listPart.SelectedIndex;
                    if (selectedIndex >= 0)
                    {
                        geometry = this.m_Geometry as IGeometryCollection;
                        points   = geometry.get_Geometry(selectedIndex) as IPointCollection;
                        point    = points.get_Point(num);
                        if (point != null)
                        {
                            if (sColumn == "gcX")
                            {
                                point.X = pValue;
                                goto Label_0096;
                            }
                            if (sColumn == "gcY")
                            {
                                point.Y = pValue;
                                goto Label_0096;
                            }
                        }
                    }
                }
                return;

Label_0096:
                operation = new EngineSketchOperationClass();
                operation.Start(Editor.UniqueInstance.EngineEditor);
                points.UpdatePoint(num, point);
                operation.SetMenuString("Move Vertex");
                esriEngineSketchOperationType esriEngineSketchOperationVertexMoved = esriEngineSketchOperationType.esriEngineSketchOperationVertexMoved;
                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, esriEngineSketchOperationVertexMoved, point);
                Editor.UniqueInstance.FinishSketch();
                IEngineEditTask taskByUniqueName = Editor.UniqueInstance.EngineEditor.GetTaskByUniqueName("ControlToolsEditing_ModifyFeatureTask");
                Editor.UniqueInstance.EngineEditor.CurrentTask = taskByUniqueName;
            }
            catch
            {
            }
        }
Ejemplo n.º 2
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    = 1.0 * this._hookHelper.ActiveView.FocusMap.MapScale;
             esriGeometryHitPartType esriGeometryPartBoundary = esriGeometryHitPartType.esriGeometryPartBoundary;
             test.HitTest(queryPoint, searchRadius, esriGeometryPartBoundary, 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;
                 object after   = new object();
                 after = hitSegmentIndex;
                 object before = new object();
                 before = hitPartIndex;
                 points.AddPoint(queryPoint, ref missing, ref after);
                 operation.SetMenuString("Insert Vertex");
                 esriEngineSketchOperationType esriEngineSketchOperationVertexAdded = esriEngineSketchOperationType.esriEngineSketchOperationVertexAdded;
                 geometrys.RemoveGeometries(hitPartIndex, 1);
                 geometrys.AddGeometry(points as IGeometry, ref before, ref missing);
                 operation.Finish(null, esriEngineSketchOperationVertexAdded, queryPoint);
                 Editor.UniqueInstance.FinishSketch();
                 this.OnClick();
             }
         }
         catch (Exception exception)
         {
             Editor.UniqueInstance.AbortEditOperation();
             this._mErrOpt.ErrorOperate(this._mSubSysName, "ShapeEdit.InsertVertex", "OnMouseUp", exception.GetHashCode().ToString(), exception.Source, exception.Message, "", "", "");
         }
     }
 }
Ejemplo n.º 3
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
     {
     }
 }
Ejemplo n.º 4
0
        /// <summary>
        /// The mouse up performs the action appropriate for each sub-typed command:
        /// insert vertex, add vertex or delete vertex
        /// </summary>
        /// <param name="Button"></param>
        /// <param name="Shift"></param>
        /// <param name="X">The X screen coordinate of the clicked location</param>
        /// <param name="Y">The Y screen coordinate of the clicked location</param>
        public override void OnMouseUp(int Button, int Shift, int X, int Y)
        {
            try
            {
                IEngineEditSketch editSketch = m_engineEditor as IEngineEditSketch;
                IGeometry         editShape  = editSketch.Geometry;

                //location clicked as a point object
                IPoint clickedPt = m_hookHelper.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y);

                #region local variables used in the HitTest

                IHitTest hitShape                   = editShape as IHitTest;
                IPoint   hitPoint                   = new PointClass();
                double   hitDistance                = 0;
                int      hitPartIndex               = 0;
                int      hitSegmentIndex            = 0;
                bool     bRightSide                 = false;
                esriGeometryHitPartType hitPartType = esriGeometryHitPartType.esriGeometryPartNone;

                //the searchRadius is the maximum distance away, in map units, from the shape that will be used
                //for the test - change to an appropriate value.
                double searchRadius = 1;
                switch (m_lSubType)
                {
                case 1:
                    hitPartType = esriGeometryHitPartType.esriGeometryPartBoundary;
                    break;

                case 2:
                    hitPartType = esriGeometryHitPartType.esriGeometryPartVertex;
                    break;
                }

                #endregion

                hitShape.HitTest(clickedPt, searchRadius, hitPartType, hitPoint, ref hitDistance, ref hitPartIndex, ref hitSegmentIndex, ref bRightSide);

                //check whether the HitTest was successful (i.e within the search radius)
                if (hitPoint.IsEmpty == false)
                {
                    IEngineSketchOperation sketchOp = new EngineSketchOperationClass();
                    sketchOp.Start(m_engineEditor);

                    //Get the PointCollection for a specific path or ring by hitPartIndex to handle multi-part features
                    IGeometryCollection geometryCol = editShape as IGeometryCollection;
                    IPointCollection    pathOrRingPointCollection = geometryCol.get_Geometry(hitPartIndex) as IPointCollection;

                    object missing = Type.Missing;
                    object hitSegmentIndexObject = new object();
                    hitSegmentIndexObject = hitSegmentIndex;
                    object partIndexObject = new object();
                    partIndexObject = hitPartIndex;
                    esriEngineSketchOperationType opType = esriEngineSketchOperationType.esriEngineSketchOperationGeneral;

                    switch (m_lSubType)
                    {
                    case 1:     //Insert Vertex

                        //add new vertex to the path or ring PointCollection
                        pathOrRingPointCollection.AddPoint(clickedPt, ref missing, ref hitSegmentIndexObject);
                        sketchOp.SetMenuString("Insert Vertex (Custom)");
                        opType = esriEngineSketchOperationType.esriEngineSketchOperationVertexAdded;
                        break;

                    case 2:     //Delete Vertex.

                        //delete a vertex from the path or ring PointCollection
                        pathOrRingPointCollection.RemovePoints(hitSegmentIndex, 1);
                        sketchOp.SetMenuString("Delete Vertex (Custom)");
                        opType = esriEngineSketchOperationType.esriEngineSketchOperationVertexDeleted;
                        break;
                    }

                    //remove the old PointCollection from the GeometryCollection and replace with the new one
                    geometryCol.RemoveGeometries(hitPartIndex, 1);
                    geometryCol.AddGeometry(pathOrRingPointCollection as IGeometry, ref partIndexObject, ref missing);

                    sketchOp.Finish(null, opType, clickedPt);
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Trace.WriteLine(ex.Message, "Unexpected Error");
            }
        }