Beispiel #1
0
        public void Excute()
        {
            IPolygon tempLine = SketchToolAssist.TempLine as IPolygon;

            tempLine.SimplifyPreserveFromTo();
            IEnumFeature featureSelection = _context.FocusMap.FeatureSelection as IEnumFeature;

            featureSelection.Reset();
            IFeature feature   = featureSelection.Next();
            IPolygon shapeCopy = feature.ShapeCopy as IPolygon;

            if (!(shapeCopy as IRelationalOperator).Contains(tempLine))
            {
                MessageService.Current.Warn("挖空多边形必须包含原多边形!");
            }
            else
            {
                IGeometry geometry = (shapeCopy as ITopologicalOperator).Difference(tempLine);
                if (!geometry.IsEmpty)
                {
                    Yutai.ArcGIS.Common.Editor.Editor.SetGeometryZM(geometry, shapeCopy);
                    Yutai.ArcGIS.Common.Editor.Editor.EditWorkspace.StartEditOperation();
                    try
                    {
                        feature.Shape = geometry;
                        feature.Store();
                        if (MessageService.Current.Ask("保留挖空面吗?"))
                        {
                            if (this.int_0 == 1)
                            {
                                IFeature feature1 = RowOperator.CreatRowByRow(feature) as IFeature;
                                if (feature1 != null)
                                {
                                    Yutai.ArcGIS.Common.Editor.Editor.SetGeometryZM(tempLine, shapeCopy);
                                    feature1.Shape = tempLine;
                                    feature1.Store();
                                }
                            }
                        }
                    }
                    catch (Exception exception)
                    {
                        //CErrorLog.writeErrorLog(this, exception, "");
                    }
                    Yutai.ArcGIS.Common.Editor.Editor.EditWorkspace.StopEditOperation();
                    (_context.FocusMap as IActiveView).PartialRefresh(esriViewDrawPhase.esriViewGeography, null,
                                                                      shapeCopy.Envelope);
                    (_context.FocusMap as IActiveView).PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, null);
                    _context.UpdateUI();
                }
            }
        }
Beispiel #2
0
        public void Excute()
        {
            IPolygon     tempLine         = SketchToolAssist.TempLine as IPolygon;
            IInvalidArea invalidAreaClass = new InvalidArea()
            {
                Display = (_context.FocusMap as IActiveView).ScreenDisplay
            };

            invalidAreaClass.Add(tempLine);
            tempLine.SimplifyPreserveFromTo();
            IEnumFeature featureSelection = _context.FocusMap.FeatureSelection as IEnumFeature;

            featureSelection.Reset();
            IFeature feature = featureSelection.Next();

            if (feature != null)
            {
                IPolygon shapeCopy = feature.ShapeCopy as IPolygon;
                if (!(shapeCopy as IRelationalOperator).Disjoint(tempLine))
                {
                    IGeometry geometry = (shapeCopy as ITopologicalOperator).Difference(tempLine);
                    if (!geometry.IsEmpty)
                    {
                        invalidAreaClass.Add(feature);
                        Yutai.ArcGIS.Common.Editor.Editor.SetGeometryZM(geometry, shapeCopy);
                        Yutai.ArcGIS.Common.Editor.Editor.EditWorkspace.StartEditOperation();
                        try
                        {
                            feature.Shape = geometry;
                            feature.Store();
                            IGeometry geometry1 = (shapeCopy as ITopologicalOperator).Difference(geometry);
                            if (!geometry1.IsEmpty)
                            {
                                Yutai.ArcGIS.Common.Editor.Editor.SetGeometryZM(geometry1, shapeCopy);
                                IFeature feature1 = RowOperator.CreatRowByRow(feature as Row) as IFeature;
                                feature1.Shape = geometry1;
                                feature1.Store();
                            }
                        }
                        catch (Exception exception)
                        {
                            CErrorLog.writeErrorLog(this, exception, "");
                        }
                        Yutai.ArcGIS.Common.Editor.Editor.EditWorkspace.StopEditOperation();
                        _context.UpdateUI();
                    }
                }
            }
            invalidAreaClass.Invalidate(-2);
        }
Beispiel #3
0
        private void MirrorCopy(IPolyline ipolyline_0)
        {
            Yutai.ArcGIS.Common.Editor.Editor.EditWorkspace.StartEditOperation();
            IEnumFeature enumFeature = _context.FocusMap.FeatureSelection as IEnumFeature;

            enumFeature.Reset();
            for (IFeature feature = enumFeature.Next(); feature != null; feature = enumFeature.Next())
            {
                try
                {
                    IGeometry shape = GeometryOperator.Mirror(feature.Shape, ipolyline_0);
                    IRow      row   = RowOperator.CreatRowByRow(feature);
                    (row as IFeature).Shape = shape;
                    row.Store();
                }
                catch
                {
                }
            }
            Yutai.ArcGIS.Common.Editor.Editor.EditWorkspace.StopEditOperation();
            (_context.FocusMap as IActiveView).Refresh();
        }
Beispiel #4
0
        private bool Do()
        {
            ListViewItem        item;
            int                 num2;
            bool                flag;
            int                 num6;
            int                 num7;
            IGeometryCollection geometrys;
            object              obj2;
            int                 num8;
            IRow                row;
            double              distance = 0.0;

            for (num2 = 0; num2 < this.listView1.Items.Count; num2++)
            {
                item = this.listView1.Items[num2];
                try
                {
                    distance += (double)item.Tag;
                }
                catch
                {
                }
            }
            double num3 = distance - this.m_pPolyline.Length;
            double num4 = 1.0;

            if (num3 != 0.0)
            {
                num4 = this.m_pPolyline.Length / distance;
            }
            Yutai.ArcGIS.Common.Editor.Editor.EditWorkspace.StartEditOperation();
            int count = this.listView1.Items.Count;

            item = this.listView1.Items[count - 1];
            try
            {
                if (((double)item.Tag) == 0.0)
                {
                    count--;
                }
            }
            catch
            {
                count--;
            }
            if (this.rdoStartType.SelectedIndex == 0)
            {
                for (num2 = 0; num2 < count; num2++)
                {
                    item     = this.listView1.Items[num2];
                    distance = (double)item.Tag;
                    if (distance != 0.0)
                    {
                        distance *= num4;
                        this.m_pPolyline.SplitAtDistance(distance, false, true, out flag, out num6, out num7);
                        if (flag)
                        {
                            geometrys = new PolylineClass();
                            obj2      = Missing.Value;
                            num8      = 0;
                            while (num8 < num6)
                            {
                                geometrys.AddGeometry((this.m_pPolyline as IGeometryCollection).get_Geometry(num8),
                                                      ref obj2, ref obj2);
                                num8++;
                            }
                            if (num2 == 0)
                            {
                                this.m_pFeature.Shape = geometrys as IGeometry;
                                this.m_pFeature.Store();
                            }
                            else
                            {
                                row = RowOperator.CreatRowByRow(this.m_pFeature);
                                (row as IFeature).Shape = geometrys as IGeometry;
                                row.Store();
                            }
                            (this.m_pPolyline as IGeometryCollection).RemoveGeometries(0, num6);
                        }
                    }
                }
                if (!this.m_pPolyline.IsEmpty)
                {
                    row = RowOperator.CreatRowByRow(this.m_pFeature);
                    (row as IFeature).Shape = this.m_pPolyline;
                    row.Store();
                }
            }
            else
            {
                for (num2 = count - 1; num2 >= 0; num2--)
                {
                    try
                    {
                        item     = this.listView1.Items[num2];
                        distance = (double)item.Tag;
                        if (distance != 0.0)
                        {
                            distance *= num4;
                            this.m_pPolyline.SplitAtDistance(distance, false, true, out flag, out num6, out num7);
                            if (flag)
                            {
                                geometrys = new PolylineClass();
                                obj2      = Missing.Value;
                                for (num8 = 0; num8 < num6; num8++)
                                {
                                    geometrys.AddGeometry((this.m_pPolyline as IGeometryCollection).get_Geometry(num8),
                                                          ref obj2, ref obj2);
                                }
                                if (num2 == (count - 1))
                                {
                                    this.m_pFeature.Shape = geometrys as IGeometry;
                                    this.m_pFeature.Store();
                                }
                                else
                                {
                                    row = RowOperator.CreatRowByRow(this.m_pFeature);
                                    (row as IFeature).Shape = geometrys as IGeometry;
                                    row.Store();
                                }
                                (this.m_pPolyline as IGeometryCollection).RemoveGeometries(0, num6);
                            }
                        }
                    }
                    catch
                    {
                    }
                }
                if (!this.m_pPolyline.IsEmpty)
                {
                    row = RowOperator.CreatRowByRow(this.m_pFeature);
                    (row as IFeature).Shape = this.m_pPolyline;
                    row.Store();
                }
            }
            Yutai.ArcGIS.Common.Editor.Editor.EditWorkspace.StopEditOperation();
            return(true);
        }
Beispiel #5
0
 public override void OnMouseUp(int int_0, int int_1, int int_2, int int_3)
 {
     if (int_0 != 2 && this.bool_0)
     {
         this.bool_0 = false;
         IActiveView activeView = (IActiveView)_context.FocusMap;
         IEnvelope   envelope   = null;
         IPoint      point      = null;
         if (this.inewEnvelopeFeedback_0 == null)
         {
             point = this.ipoint_0;
         }
         else
         {
             envelope = this.inewEnvelopeFeedback_0.Stop();
             this.inewEnvelopeFeedback_0 = null;
             if (envelope.Width == 0.0 || envelope.Height == 0.0)
             {
                 point    = this.ipoint_0;
                 envelope = null;
             }
         }
         IList        list        = new ArrayList();
         IEnumFeature enumFeature = _context.FocusMap.FeatureSelection as IEnumFeature;
         enumFeature.Reset();
         IFeature            feature            = enumFeature.Next();
         IGeometryCollection geometryCollection = new GeometryBag() as IGeometryCollection;
         object value = Missing.Value;
         while (feature != null)
         {
             list.Add(feature);
             geometryCollection.AddGeometry(feature.ShapeCopy, ref value, ref value);
             feature = enumFeature.Next();
         }
         IEnvelope envelope2 = (geometryCollection as IGeometryBag).Envelope;
         IPoint    point2    = new Point
         {
             X = (envelope2.XMax + envelope2.XMin) / 2.0,
             Y = (envelope2.YMax + envelope2.YMin) / 2.0
         };
         double num;
         double num2;
         if (envelope != null)
         {
             IPoint point3 = new Point
             {
                 X = (envelope.XMax + envelope.XMin) / 2.0,
                 Y = (envelope.YMax + envelope.YMin) / 2.0
             };
             num  = point2.X - point3.X;
             num2 = point2.Y - point3.Y;
             double num3 = envelope.Width / envelope2.Width;
             double num4 = envelope.Height / envelope2.Height;
             num3 = ((num3 > num4) ? num4 : num3);
             (geometryCollection as ITransform2D).Scale(point2, num3, num3);
         }
         else
         {
             num  = point2.X - point.X;
             num2 = point2.Y - point.Y;
         }
         (geometryCollection as ITransform2D).Move(-num, -num2);
         Yutai.ArcGIS.Common.Editor.Editor.EditWorkspace.StartEditOperation();
         for (int i = 0; i < list.Count; i++)
         {
             feature = (list[i] as IFeature);
             try
             {
                 IFeature feature2 = RowOperator.CreatRowByRow(feature) as IFeature;
                 feature2.Shape = geometryCollection.get_Geometry(i);
                 feature2.Store();
             }
             catch (Exception exception_)
             {
                 CErrorLog.writeErrorLog(this, exception_, "");
             }
         }
         Yutai.ArcGIS.Common.Editor.Editor.EditWorkspace.StopEditOperation();
         activeView.Refresh();
     }
 }
Beispiel #6
0
        public static void DoSplit(ITopology pTopology, ITopologyErrorFeature pTopoErrorFeat)
        {
            IFeatureClass class2 = (pTopology as IFeatureClassContainer).get_ClassByID(pTopoErrorFeat.OriginClassID);
            IFeatureClass class3 = null;

            try
            {
                if (pTopoErrorFeat.DestinationClassID != 0)
                {
                    class3 = (pTopology as IFeatureClassContainer).get_ClassByID(pTopoErrorFeat.DestinationClassID);
                }
            }
            catch
            {
            }
            esriTopologyRuleType topologyRuleType = pTopoErrorFeat.TopologyRuleType;

            if (((topologyRuleType == esriTopologyRuleType.esriTRTLineNoIntersection) ||
                 (topologyRuleType == esriTopologyRuleType.esriTRTLineNoIntersectOrInteriorTouch)) &&
                ((pTopoErrorFeat as IFeature).Shape is IPoint))
            {
                int        num;
                IFeature   feature2;
                IFeature   feature3;
                IFeature   feature   = class2.GetFeature(pTopoErrorFeat.OriginOID);
                IPolycurve shapeCopy = feature.ShapeCopy as IPolycurve;
                IPoint     shape     = (pTopoErrorFeat as IFeature).Shape as IPoint;
                IList      list      = PointSplitLine(shapeCopy, shape);
                for (num = 0; num < list.Count; num++)
                {
                    if (num == 0)
                    {
                        feature.Shape = list[num] as IGeometry;
                        feature.Store();
                    }
                    else
                    {
                        feature2       = RowOperator.CreatRowByRow(feature) as IFeature;
                        feature2.Shape = list[num] as IGeometry;
                    }
                }
                if (class3 == null)
                {
                    feature3 = class2.GetFeature(pTopoErrorFeat.DestinationOID);
                }
                else
                {
                    feature3 = class3.GetFeature(pTopoErrorFeat.DestinationOID);
                }
                shapeCopy = feature3.ShapeCopy as IPolycurve;
                list      = PointSplitLine(shapeCopy, shape);
                for (num = 0; num < list.Count; num++)
                {
                    if (num == 0)
                    {
                        feature3.Shape = list[num] as IGeometry;
                        feature3.Store();
                    }
                    else
                    {
                        feature2       = RowOperator.CreatRowByRow(feature3) as IFeature;
                        feature2.Shape = list[num] as IGeometry;
                        feature2.Store();
                    }
                }
            }
        }
Beispiel #7
0
        public override void OnMouseDown(int int_0, int int_1, int int_2, int int_3)
        {
            IFeature feature;
            int      i;
            IPoint   point;

            if (int_0 == 1)
            {
                IActiveView focusMap    = (IActiveView)_context.FocusMap;
                IPoint      anchorPoint = SketchToolAssist.AnchorPoint;
                double      mapUnits    = Common.ConvertPixelsToMapUnits(_context.FocusMap as IActiveView,
                                                                         _context.Config.EngineSnapEnvironment.SnapTolerance);
                Yutai.ArcGIS.Common.Editor.Editor.GetClosesFeature(_context.FocusMap, anchorPoint, mapUnits,
                                                                   esriGeometryType.esriGeometryPolyline, out feature);
                if (feature == null)
                {
                    MessageService.Current.Warn("没有点击的要素上,请设置较大的捕捉范围!");
                }
                else
                {
                    IPolycurve2 shape      = feature.Shape as IPolycurve2;
                    IEnvelope   envelope   = shape.Envelope;
                    object      value      = Missing.Value;
                    IHitTest    hitTest    = shape as IHitTest;
                    IPoint      pointClass = new Point();
                    double      num        = 0;
                    int         num1       = -1;
                    int         num2       = -1;
                    bool        flag       = false;
                    if (hitTest.HitTest(anchorPoint, mapUnits, esriGeometryHitPartType.esriGeometryPartBoundary,
                                        pointClass, ref num, ref num1, ref num2, ref flag))
                    {
                        Yutai.ArcGIS.Common.Editor.Editor.EditWorkspace.StartEditOperation();
                        IGeometryCollection polylineClass = new Polyline() as IGeometryCollection;
                        for (i = 0; i < num1; i++)
                        {
                            polylineClass.AddGeometry((shape as IGeometryCollection).Geometry[i], ref value, ref value);
                        }
                        IPointCollection geometry  = (shape as IGeometryCollection).Geometry[num1] as IPointCollection;
                        IPointCollection pathClass = new ESRI.ArcGIS.Geometry.Path();
                        for (i = 0; i < num2 + 1; i++)
                        {
                            point = (geometry.Point[i] as IClone).Clone() as IPoint;
                            pathClass.AddPoint(point, ref value, ref value);
                        }
                        pathClass.AddPoint((pointClass as IClone).Clone() as IPoint, ref value, ref value);
                        polylineClass.AddGeometry(pathClass as IGeometry, ref value, ref value);
                        if ((polylineClass as IPointCollection).PointCount > 1)
                        {
                            Yutai.ArcGIS.Common.Editor.Editor.SetGeometryZM(polylineClass as IGeometry, shape);
                            feature.Shape = polylineClass as IGeometry;
                            feature.Store();
                        }
                        pathClass = new ESRI.ArcGIS.Geometry.Path();
                        pathClass.AddPoint((pointClass as IClone).Clone() as IPoint, ref value, ref value);
                        for (i = num2 + 1; i < geometry.PointCount; i++)
                        {
                            point = (geometry.Point[i] as IClone).Clone() as IPoint;
                            pathClass.AddPoint(point, ref value, ref value);
                        }
                        polylineClass = new Polyline() as IGeometryCollection;
                        polylineClass.AddGeometry(pathClass as IGeometry, ref value, ref value);
                        for (i = num1 + 1; i < (shape as IGeometryCollection).GeometryCount; i++)
                        {
                            polylineClass.AddGeometry((shape as IGeometryCollection).Geometry[i], ref value, ref value);
                        }
                        if ((polylineClass as IPointCollection).PointCount > 1)
                        {
                            IFeature feature1 = RowOperator.CreatRowByRow(feature as Row) as IFeature;
                            Yutai.ArcGIS.Common.Editor.Editor.SetGeometryZM(polylineClass as IGeometry, shape);
                            feature1.Shape = polylineClass as IGeometry;
                            feature1.Store();
                        }
                        Yutai.ArcGIS.Common.Editor.Editor.EditWorkspace.StopEditOperation();
                        (_context.FocusMap as IActiveView).PartialRefresh(esriViewDrawPhase.esriViewGeography, null,
                                                                          envelope);
                        (_context.FocusMap as IActiveView).PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null,
                                                                          null);
                    }
                }
            }
        }
Beispiel #8
0
 public void HandleCommandParameter(string string_0)
 {
     if (string_0.Length != 0)
     {
         if (string_0.Length == 1)
         {
             string text = string_0.ToUpper();
             if (text != null)
             {
                 if (!(text == "N"))
                 {
                     if (!(text == "P"))
                     {
                         if (!(text == "B"))
                         {
                             if (text == "I")
                             {
                                 _context.ShowCommandString("输入点:", CommandTipsType.CTTCommandTip);
                                 this.int_0 = 1;
                                 return;
                             }
                             if (!(text == "D"))
                             {
                                 if (text == "E")
                                 {
                                     this.ifeature_0         = null;
                                     this.ipointCollection_0 = null;
                                     this.int_2           = 0;
                                     _context.CurrentTool = null;
                                     (_context.FocusMap as IActiveView).Refresh();
                                 }
                             }
                             else
                             {
                                 this.ipointCollection_0.RemovePoints(this.int_2, 1);
                                 if (this.int_2 == this.ipointCollection_0.PointCount)
                                 {
                                     this.int_2--;
                                 }
                                 Yutai.ArcGIS.Common.Editor.Editor.StartEditOperation(
                                     this.ifeature_0.Class as IDataset);
                                 this.ifeature_0.Shape = (this.ipointCollection_0 as IGeometry);
                                 this.ifeature_0.Store();
                                 Yutai.ArcGIS.Common.Editor.Editor.StopEditOperation(
                                     this.ifeature_0.Class as IDataset);
                                 this.ZoomToCenter();
                             }
                         }
                         else
                         {
                             if (this.ipointCollection_0 is IPolyline && this.int_2 > 0 &&
                                 this.int_2 < this.ipointCollection_0.PointCount - 1)
                             {
                                 Yutai.ArcGIS.Common.Editor.Editor.StartEditOperation(
                                     this.ifeature_0.Class as IDataset);
                                 try
                                 {
                                     IPoint           point            = this.ipointCollection_0.get_Point(this.int_2);
                                     GeometryOperator geometryOperator =
                                         GeometryOperatorFectory.CreateGeometryOperator(
                                             this.ipointCollection_0 as IGeometry);
                                     IGeometryBag geometryBag;
                                     geometryOperator.SplitAtPoint(point, out geometryBag);
                                     if (geometryBag != null)
                                     {
                                         try
                                         {
                                             this.ifeature_0.Shape =
                                                 (geometryBag as IGeometryCollection).get_Geometry(0);
                                             this.ifeature_0.Store();
                                             this.ipointCollection_0 =
                                                 (this.ifeature_0.Shape as IPointCollection);
                                             this.int_2 = 0;
                                             this.ShowCommand();
                                             for (int i = 1;
                                                  i < (geometryBag as IGeometryCollection).GeometryCount;
                                                  i++)
                                             {
                                                 IRow row = RowOperator.CreatRowByRow(this.ifeature_0);
                                                 (row as IFeature).Shape =
                                                     (geometryBag as IGeometryCollection).get_Geometry(i);
                                                 row.Store();
                                             }
                                         }
                                         catch (Exception ex)
                                         {
                                             CErrorLog.writeErrorLog(this, ex, "");
                                         }
                                     }
                                 }
                                 catch (Exception ex)
                                 {
                                     System.Windows.Forms.MessageBox.Show(ex.Message);
                                 }
                                 Yutai.ArcGIS.Common.Editor.Editor.StopEditOperation(
                                     this.ifeature_0.Class as IDataset);
                             }
                             this.ZoomToCenter();
                         }
                     }
                     else
                     {
                         if (this.int_2 > 0)
                         {
                             this.int_2--;
                         }
                         this.ZoomToCenter();
                     }
                 }
                 else
                 {
                     if (this.int_2 < this.ipointCollection_0.PointCount - 1)
                     {
                         this.int_2++;
                     }
                     this.ZoomToCenter();
                 }
             }
         }
         if (this.int_0 == 1)
         {
             try
             {
                 this.int_0 = 0;
                 string[] array = string_0.Split(new char[]
                 {
                     ','
                 });
                 IPoint point = new ESRI.ArcGIS.Geometry.Point();
                 if (array.Length >= 2)
                 {
                     double x = Convert.ToDouble(array[0]);
                     double y = Convert.ToDouble(array[1]);
                     point.PutCoords(x, y);
                     if (array.Length >= 3)
                     {
                         double z = Convert.ToDouble(array[2]);
                         point.Z = z;
                     }
                     object obj   = 0;
                     object value = Missing.Value;
                     if (this.int_2 == this.ipointCollection_0.PointCount - 1)
                     {
                         obj = this.int_2 - 1;
                     }
                     else
                     {
                         obj = this.int_2;
                     }
                     this.ipointCollection_0.AddPoint(point, ref value, ref obj);
                     Yutai.ArcGIS.Common.Editor.Editor.StartEditOperation(this.ifeature_0.Class as IDataset);
                     this.ifeature_0.Shape = (this.ipointCollection_0 as IGeometry);
                     this.ifeature_0.Store();
                     Yutai.ArcGIS.Common.Editor.Editor.StopEditOperation(this.ifeature_0.Class as IDataset);
                     this.ZoomToCenter();
                 }
                 else
                 {
                     _context.ShowCommandString("输入不正确", CommandTipsType.CTTLog);
                 }
             }
             catch
             {
                 _context.ShowCommandString("输入不正确", CommandTipsType.CTTLog);
                 return;
             }
         }
         this.ShowCommand();
     }
 }