Exemple #1
0
        private void miShowTime_Click(object sender, EventArgs e)
        {
            //====将shp中的要素转换成Geometry对象========
            GeometryOperator geometryOperator = new GeometryOperator(axMapControl1.Map, this);
            DataOperator     dataoperator     = new DataOperator(axMapControl1.Map);
            //ILayer layer;
            //layer = dataoperator.GetLayerByName("DLTB");
            //IFeatureLayer featureLayer = layer as IFeatureLayer;
            //IFeatureCursor featureCursor = featureLayer.Search(null, false);
            //IFeature feature = featureCursor.NextFeature();
            IGeometry geometry = new PolygonClass();

            geometry = m_polygon;

            //====开始调用GeometryOperator类库中的函数
            geometryOperator.ShowGeometry(geometry);
            axMapControl1.ActiveView.Refresh();
        }
Exemple #2
0
        public override void OnClick()
        {
            frmInputValue1 frmInputValue = new frmInputValue1();

            frmInputValue.Text        = "输入X, Y值";
            frmInputValue.InputValue1 = EditTools.CurrentPosition.X;
            frmInputValue.InputValue2 = EditTools.CurrentPosition.Y;
            if (frmInputValue.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                double    inputValue  = frmInputValue.InputValue1;
                double    inputValue2 = frmInputValue.InputValue2;
                IGeometry shape       = EditTools.EditFeature.Shape;
                if (shape != null && EditTools.PartIndex != -1 && EditTools.PointIndex != -1 &&
                    (shape.GeometryType == esriGeometryType.esriGeometryPolyline ||
                     shape.GeometryType == esriGeometryType.esriGeometryPolygon))
                {
                    double num     = 0.0;
                    int    index   = -1;
                    int    num2    = -1;
                    double double_ = CommonHelper.ConvertPixelsToMapUnits((IActiveView)_context.FocusMap, 4.0);
                    IPoint point;
                    bool   flag;
                    if (
                        GeometryOperator.TestGeometryHit(double_, EditTools.CurrentPosition, shape, out point, ref num,
                                                         ref index, ref num2, out flag) && !flag)
                    {
                        IPath  path   = (IPath)((IGeometryCollection)shape).get_Geometry(index);
                        IPoint point2 = new Point();
                        point2.PutCoords(inputValue, inputValue2);
                        object value = Missing.Value;
                        object obj   = num2;
                        ((IPointCollection)path).AddPoint(point2, ref value, ref obj);
                        (shape as IGeometryCollection).GeometriesChanged();
                        Yutai.ArcGIS.Common.Editor.Editor.EditWorkspace.StartEditOperation();
                        EditTools.EditFeature.Shape = shape;
                        EditTools.EditFeature.Store();
                        Yutai.ArcGIS.Common.Editor.Editor.EditWorkspace.StopEditOperation();
                        (_context.FocusMap as IActiveView).PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null,
                                                                          null);
                    }
                }
            }
        }
Exemple #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();
        }
        public override void OnMouseDown(int int_2, int int_3, int int_4, int int_5)
        {
            IPoint point;
            object obj;
            object obj2;

            this._plugin.SceneGraph.Locate(this._plugin.ActiveViewer, int_4, int_5, esriScenePickMode.esriScenePickGeography, true, out point, out obj, out obj2);
            if (point != null)
            {
                IClone clone  = point as IClone;
                IPoint point2 = clone.Clone() as IPoint;
                point2.Z /= this._plugin.SceneGraph.VerticalExaggeration;
                point2.SpatialReference = this._plugin.Scene.SpatialReference;
                IDisplay3D display3D = this._plugin.SceneGraph as IDisplay3D;
                display3D.FlashLocation(point2);
                if (this.ipointCollection_0 == null)
                {
                    this.ipointCollection_0 = new Polyline();
                    (this.ipointCollection_0 as IGeometry).SpatialReference = this._plugin.Scene.SpatialReference;
                }
                object value = Missing.Value;
                this.ipointCollection_0.AddPoint(point, ref value, ref value);
                IPolyline polyline = null;
                if (this.ipointCollection_0.PointCount == 2)
                {
                    clone    = (this.ipointCollection_0 as IClone);
                    polyline = (clone.Clone() as IPolyline);
                    this.ipointCollection_0 = null;
                }
                if (polyline != null)
                {
                    this.bool_0             = false;
                    this.ipointCollection_0 = null;
                    IPoint fromPoint = polyline.FromPoint;
                    fromPoint.Z = this.isurface_0.GetElevation(fromPoint);
                    IPoint toPoint = polyline.ToPoint;
                    toPoint.Z = this.isurface_0.GetElevation(toPoint);
                    if (!this.isurface_0.IsVoidZ(fromPoint.Z) && !this.isurface_0.IsVoidZ(toPoint.Z))
                    {
                        fromPoint.Z += ToolSceneLineOfSight.ObserverOffset;
                        toPoint.Z   += ToolSceneLineOfSight.TargetOffset;
                        object    obj3 = 1;
                        IPoint    point3;
                        IPolyline ipolyline_;
                        IPolyline ipolyline_2;
                        bool      flag;
                        this.isurface_0.GetLineOfSight(fromPoint, toPoint, out point3, out ipolyline_, out ipolyline_2, out flag, ToolSceneLineOfSight.bCurvEnabled, ToolSceneLineOfSight.bCurvEnabled, ref obj3);
                        ISimpleLineSymbol simpleLineSymbol = new SimpleLineSymbol();
                        IRgbColor         rgbColor         = new RgbColor();
                        simpleLineSymbol.Width = 2.0;
                        simpleLineSymbol.Style = esriSimpleLineStyle.esriSLSSolid;
                        ISimpleFillSymbol simpleFillSymbol = new SimpleFillSymbol();
                        IMultiPatch       multiPatch       = new MultiPatch() as IMultiPatch;
                        multiPatch.SpatialReference = this._plugin.Scene.SpatialReference;
                        IMultiPatch multiPatch2 = new MultiPatch() as IMultiPatch;
                        multiPatch2.SpatialReference = this._plugin.Scene.SpatialReference;
                        double num;
                        GeometryOperator.CreateVerticalLOSPatches(flag, fromPoint, toPoint, ipolyline_, ipolyline_2, multiPatch as IGeometryCollection, multiPatch2 as IGeometryCollection, out num);
                        if (!multiPatch.IsEmpty)
                        {
                            rgbColor.Green         = 255;
                            rgbColor.Red           = 0;
                            simpleFillSymbol.Color = rgbColor;
                            this.AddGraphic(this._plugin.Scene, multiPatch, simpleFillSymbol as ISymbol, false, false, "");
                        }
                        if (!multiPatch2.IsEmpty)
                        {
                            rgbColor.Green         = 0;
                            rgbColor.Red           = 255;
                            simpleFillSymbol.Color = rgbColor;
                            this.AddGraphic(this._plugin.Scene, multiPatch2, simpleFillSymbol as ISymbol, false, false, "");
                        }
                    }
                }
            }
        }
Exemple #5
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();
     }
 }