示例#1
0
 public void OnMouseUp(int button, int shift, int x, int y)
 {
     if (button == 1)
     {
         try
         {
             if (this.m_SelectedFeature == null)
             {
                 this.m_SelectedFeature = new List <IFeature>();
             }
             IPoint            pPoint      = this._hookHelper.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(x, y);
             IFeatureLayer     targetLayer = Editor.UniqueInstance.TargetLayer;
             IFeatureSelection selection   = targetLayer as IFeatureSelection;
             if (!this.m_IsSelecting)
             {
                 selection.Clear();
                 this.m_SelectedFeature.Clear();
             }
             this._hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, targetLayer, null);
             IEnvelope searchEnvelope = FeatureFuncs.GetSearchEnvelope(this._hookHelper.ActiveView, pPoint);
             if (searchEnvelope != null)
             {
                 IFeature item = FeatureFuncs.SearchFeatures(targetLayer, searchEnvelope, esriSpatialRelEnum.esriSpatialRelIntersects).NextFeature();
                 if (item != null)
                 {
                     if (this.m_SelectedFeature.Contains(item))
                     {
                         this.m_SelectedFeature.Remove(item);
                         selection.Clear();
                         for (int i = 0; i < this.m_SelectedFeature.Count; i++)
                         {
                             selection.Add(this.m_SelectedFeature[i]);
                         }
                     }
                     else
                     {
                         this.m_SelectedFeature.Add(item);
                         selection.Add(item);
                     }
                     this._hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, targetLayer, null);
                     if (!this.m_IsSelecting)
                     {
                         this.DeleteFeatures();
                     }
                 }
             }
         }
         catch (Exception exception)
         {
             Editor.UniqueInstance.AbortEditOperation();
             this._mErrOpt.ErrorOperate(this._mSubSysName, "ShapeEdit.Delete", "OnMouseUp", exception.GetHashCode().ToString(), exception.Source, exception.Message, "", "", "");
         }
     }
 }
示例#2
0
 public void OnMouseUp(int button, int shift, int x, int y)
 {
     if (button != 2)
     {
         IPoint    pPoint         = this.m_hookHelper.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(x, y);
         IEnvelope searchEnvelope = FeatureFuncs.GetSearchEnvelope(this.m_hookHelper.ActiveView, pPoint);
         IFeature  feature        = FeatureFuncs.SearchFeatures(Editor.UniqueInstance.TargetLayer, searchEnvelope, esriSpatialRelEnum.esriSpatialRelIntersects).NextFeature();
         if (feature != null)
         {
             ITopologicalOperator2 shape = feature.Shape as ITopologicalOperator2;
             Editor.UniqueInstance.StartEditOperation();
             shape.IsKnownSimple_2 = false;
             shape.Simplify();
             Editor.UniqueInstance.StopEditOperation("simplify");
             IActiveView       activeView  = this.m_hookHelper.ActiveView;
             IFeatureSelection targetLayer = Editor.UniqueInstance.TargetLayer as IFeatureSelection;
             targetLayer.Clear();
             targetLayer.Add(feature);
             activeView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection | esriViewDrawPhase.esriViewGeography, null, null);
         }
     }
 }
示例#3
0
 public void OnMouseUp(int button, int shift, int x, int y)
 {
     if (button != 2)
     {
         IPoint    pPoint         = this.m_hookHelper.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(x, y);
         IEnvelope searchEnvelope = FeatureFuncs.GetSearchEnvelope(this.m_hookHelper.ActiveView, pPoint);
         IFeature  feature        = FeatureFuncs.SearchFeatures(Editor.UniqueInstance.TargetLayer, searchEnvelope, esriSpatialRelEnum.esriSpatialRelIntersects).NextFeature();
         if (feature != null)
         {
             bool flag = false;
             Editor.UniqueInstance.StartEditOperation();
             IGeometryCollection shape   = feature.Shape as IGeometryCollection;
             int           geometryCount = shape.GeometryCount;
             List <string> list          = new List <string>();
             for (int i = 0; i < geometryCount; i++)
             {
                 flag = false;
                 list.Clear();
                 IGeometry geometry = shape.get_Geometry(i);
                 int       num3     = 0;
                 if ((geometry.GeometryType == esriGeometryType.esriGeometryPolygon) || (geometry.GeometryType == esriGeometryType.esriGeometryRing))
                 {
                     IRing ring = geometry as IRing;
                     if (ring.IsClosed)
                     {
                         num3 = 1;
                     }
                 }
                 IPointCollection points = geometry as IPointCollection;
                 int pointCount          = points.PointCount;
                 for (int j = num3; j < pointCount; j++)
                 {
                     IPoint point2 = points.get_Point(j);
                     string item   = string.Format("{0:F3},{1:F3}", point2.X, point2.Y);
                     if (list.Contains(item))
                     {
                         points.RemovePoints(j, 1);
                         j--;
                         pointCount--;
                         flag = true;
                     }
                     else
                     {
                         list.Add(item);
                     }
                 }
                 if (flag)
                 {
                     object missing = Type.Missing;
                     object before  = new object();
                     before = i;
                     shape.RemoveGeometries(i, 1);
                     shape.AddGeometry(points as IGeometry, ref before, ref missing);
                 }
             }
             feature.Shape = shape as IGeometry;
             feature.Store();
             Editor.UniqueInstance.StopEditOperation("delete repeat point");
             this.m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, this.m_hookHelper.ActiveView.Extent);
         }
     }
 }