コード例 #1
0
 private static void old_acctor_mc()
 {
     CmdEditCopy.m_bIsCopyFeature = false;
     CmdEditCopy.m_pArray         = new ESRI.ArcGIS.esriSystem.Array();
     CmdEditCopy.m_pFeatureList   = new List <IFeature>();
     CmdEditCopy.m_pEnumFeature   = null;
 }
コード例 #2
0
ファイル: MergeForm.cs プロジェクト: voyagexiang/ArcObjects
        private void MargeForm_Load(object sender, EventArgs e)
        {
            IMap map = mAxMapControl1.Map;
            ISelection selection = map.FeatureSelection;
            IEnumFeatureSetup iEnumFeatureSetup = (IEnumFeatureSetup)selection;
            iEnumFeatureSetup.AllFields = true;
            this.pEnumFeature = (IEnumFeature)iEnumFeatureSetup;
            this.pEnumFeature.Reset();

            IFeature pFeature = pEnumFeature.Next();
            if (pFeature == null) return;
            while (pFeature != null)
            {
                IFeatureLayer pFeatureLayer = mLayer as IFeatureLayer;
                string name = pFeatureLayer.FeatureClass.OIDFieldName;
                if (!pFeature.HasOID)
                {
                    pFeature = pEnumFeature.Next();
                    return;
                }
                int ID = pFeature.OID;
                string sqlWhere = "";
                sqlWhere = name + "=" + ID;

                this.pItems.Add(sqlWhere);
                comboBox1.Items.Add(sqlWhere);
                pFeature = pEnumFeature.Next();


            }

            comboBox1.Text = pItems[0];
        }
コード例 #3
0
        public override void OnClick()
        {
            this.m_offset          = SketchShareEx.m_offset;
            this.m_ConstructOffset = SketchShareEx.ConstructOffset;
            IEnumFeature featureSelection = _context.FocusMap.FeatureSelection as IEnumFeature;

            featureSelection.Reset();
            object        value            = Missing.Value;
            object        mConstructOffset = this.m_ConstructOffset;
            IFeature      feature          = featureSelection.Next();
            IActiveView   focusMap         = _context.FocusMap as IActiveView;
            IFeatureClass featureClass     = Yutai.ArcGIS.Common.Editor.Editor.CurrentEditTemplate.FeatureLayer.FeatureClass;

            Yutai.ArcGIS.Common.Editor.Editor.EditWorkspace.StartEditOperation();
            while (feature != null)
            {
                if (feature.Shape.GeometryType == esriGeometryType.esriGeometryPolyline)
                {
                    IConstructCurve polylineClass = new Polyline() as IConstructCurve;
                    polylineClass.ConstructOffset(feature.Shape as IPolycurve, this.m_offset, ref mConstructOffset,
                                                  ref value);
                    this.CreateParallel(polylineClass as IGeometry, featureClass);
                }
                feature = featureSelection.Next();
            }
            Yutai.ArcGIS.Common.Editor.Editor.EditWorkspace.StopEditOperation();
            focusMap.Refresh();
        }
コード例 #4
0
 private void PerformAttributeSelect()
 {
     try
     {
         IQueryFilter  pQueryFilter = new QueryFilterClass();
         IFeatureLayer pFeatureLayer;
         pQueryFilter.WhereClause = strWhereClause;
         pFeatureLayer            = GetLayerByName(comboBox1.SelectedItem.ToString()) as IFeatureLayer;
         pFeatureSelection        = pFeatureLayer as IFeatureSelection;
         pFeatureSelection.SelectFeatures(pQueryFilter, esriSelectionResultEnum.esriSelectionResultNew, false);  //执行查询
         //如果本次查询后,查询的结果数目0,则认为本次查询不到结果
         if (pFeatureSelection.SelectionSet.Count == 0)
         {
             MessageBox.Show("没有符合本次查询条件的结果!");
             return;
         }  //定位到选择结果
         IEnumFeature pEnumFeature = Form1.m_mapControl.Map.FeatureSelection as IEnumFeature;
         IFeature     pFeature     = pEnumFeature.Next();
         IEnvelope    pEnvelope    = new EnvelopeClass() as IEnvelope;
         while (pFeature != null)
         {
             pEnvelope.Union(pFeature.Extent);
             pFeature = pEnumFeature.Next();
         }
         Form1.m_mapControl.ActiveView.Extent = pEnvelope;
         Form1.m_mapControl.ActiveView.Refresh();
     }
     catch (Exception ex)
     {
         MessageBox.Show("您的查询语句可能有误,请检查 | " + ex.Message);
         return;
     }
 }
コード例 #5
0
 public static void RefreshLayerWithSelection(IMap imap_0, IEnvelope ienvelope_0,
                                              esriViewDrawPhase esriViewDrawPhase_0)
 {
     if (imap_0 != null)
     {
         IActiveView imap0 = (IActiveView)imap_0;
         if (ienvelope_0 == null)
         {
             IEnumFeature featureSelection = (IEnumFeature)imap_0.FeatureSelection;
             featureSelection.Reset();
             IFeature feature = featureSelection.Next();
             ienvelope_0 = feature.Extent;
             while (feature != null)
             {
                 ienvelope_0.Union(feature.Extent);
                 feature = featureSelection.Next();
             }
         }
         for (int i = 0; i < imap_0.LayerCount; i++)
         {
             IFeatureLayer layer = (IFeatureLayer)imap_0.Layer[i];
             if (((IFeatureSelection)layer).SelectionSet.Count > 0)
             {
                 imap0.PartialRefresh(esriViewDrawPhase_0, layer, ienvelope_0);
             }
         }
     }
 }
コード例 #6
0
        public override void OnClick()
        {
            frmInputValue1 frmInputValue = new frmInputValue1();

            frmInputValue.Text = "输入x, y值";
            if (frmInputValue.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                double inputValue  = frmInputValue.InputValue1;
                double inputValue2 = frmInputValue.InputValue2;
                double dx          = inputValue - EditTools.CurrentPosition.X;
                double dy          = inputValue2 - EditTools.CurrentPosition.Y;
                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())
                {
                    ITransform2D transform2D = feature.Shape as ITransform2D;
                    if (transform2D != null)
                    {
                        transform2D.Move(dx, dy);
                        feature.Shape = (transform2D as IGeometry);
                        feature.Store();
                    }
                }
                Yutai.ArcGIS.Common.Editor.Editor.EditWorkspace.StopEditOperation();
                (_context.FocusMap as IActiveView).Refresh();
            }
        }
コード例 #7
0
 public static IGeometry GetSelectFeatureGeom(IMap pMap)
 {
     try
     {
         object              obj          = System.Reflection.Missing.Value;
         IGeometryBag        pGeometryBag = new GeometryBagClass();
         IGeometryCollection pGeomtryCol  = (IGeometryCollection)pGeometryBag;
         ISelection          pSelection   = pMap.FeatureSelection;
         IEnumFeature        pEnumFea     = pSelection as IEnumFeature;
         IFeature            pFea         = pEnumFea.Next();
         while (pFea != null)
         {
             if (pFea.Shape != null && pFea.Shape.GeometryType == esriGeometryType.esriGeometryPolygon)
             {
                 pGeomtryCol.AddGeometry(pFea.Shape, ref obj, ref obj);
             }
             pFea = pEnumFea.Next();
         }
         ITopologicalOperator pTopo = new PolygonClass();
         pTopo.ConstructUnion(pGeomtryCol as IEnumGeometry);
         IGeometry pGeometry = pTopo as IGeometry;
         return(pGeometry);
     }
     catch { return(null); }
 }
コード例 #8
0
ファイル: MovePoint.cs プロジェクト: siszoey/geosufan
        public override void OnMouseUp(int Button, int Shift, int X, int Y)
        {
            //OnClick();

            if (Button != 1)
            {
                return;
            }

            IFeatureLayer     curLayer   = layerCurSeleted();
            IFeatureSelection curLayerSn = curLayer as IFeatureSelection;
            ISelectionSet     pSS        = curLayerSn.SelectionSet;

            if (pSS.Count != 1)
            {
                return;
            }
            IEnumFeature pEnumFeature = m_MapControl.Map.FeatureSelection as IEnumFeature;

            pEnumFeature.Reset();
            IFeature tmpFeature = pEnumFeature.Next();
            IPoint   pp         = new PointClass();

            pp = m_MapControl.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y);

            tmpFeature.Shape = pp;
            tmpFeature.Store();
            curLayerSn.Clear();

            curLayerSn.Add(tmpFeature);
            m_MapControl.ActiveView.Refresh();
        }
コード例 #9
0
        /// <summary>
        /// Occurs when this command is clicked
        /// </summary>
        public override void OnClick()
        {
            IEnumFeature selectedFeatures = (IEnumFeature)m_mapControl.Map.FeatureSelection;

            selectedFeatures.Reset();

            IFeature selectedFeature = (IFeature)selectedFeatures.Next();

            if (selectedFeature == null)
            {
                m_PolylineLength = "无线要素";
                return;
            }
            else
            {
                IFeatureClass featureClass = (IFeatureClass)selectedFeature.Class;

                if (featureClass.ShapeType != esriGeometryType.esriGeometryPolyline)
                {
                    m_PolylineLength = "不是线要素";
                    return;
                }
                else
                {
                    IPolyline polyline = (IPolyline)selectedFeature.ShapeCopy;

                    m_PolylineLength = polyline.Length.ToString();
                }
            }
        }
コード例 #10
0
        public void DrawAllVertex()
        {
            if (m_pMap.SelectionCount == 1)
            {
                IPolyline    pPolyline;
                IPolygon     pPolygon;
                IFeature     pFeature;
                IEnumFeature pEnumFeature = m_pMap.FeatureSelection as IEnumFeature;
                if (pEnumFeature == null)
                {
                    return;
                }
                pEnumFeature.Reset();
                pFeature = pEnumFeature.Next();
                switch (pFeature.Shape.GeometryType)
                {
                case esriGeometryType.esriGeometryPolyline:
                    m_pPointCol = new PolylineClass();
                    pPolyline   = pFeature.Shape as IPolyline;
                    m_pPointCol.AddPointCollection(pPolyline as IPointCollection);
                    ShowAllVertex(m_pPointCol);
                    break;

                case esriGeometryType.esriGeometryPolygon:
                    m_pPointCol = new PolygonClass();
                    pPolygon    = pFeature.Shape as IPolygon;

                    m_pPointCol.AddPointCollection(pPolygon as IPointCollection);
                    ShowAllVertex(m_pPointCol);
                    break;

                default: break;
                }
            }
        }
コード例 #11
0
ファイル: frmAttributeTB.cs プロジェクト: radtek/geosufan
        /// <summary>
        /// 获得当前视图上的选择要素
        /// ZQ 2011 1203 将点要素自动去除 只合并线和面要素
        /// </summary>
        /// <param name="pMap"></param>
        /// <returns></returns>
        private IGeometry ConstructUnion(IMap pMap)
        {
            IGeometry pGeometry = null;

            try
            {
                IGeometryBag        pGeometryBag = new GeometryBagClass();
                IGeometryCollection pGeometryCol = pGeometryBag as IGeometryCollection;
                object       obj          = System.Type.Missing;
                ISelection   pSelection   = pMap.FeatureSelection;
                IEnumFeature pEnumFeature = pSelection as IEnumFeature;
                IFeature     pFeature     = pEnumFeature.Next();
                while (pFeature != null)
                {
                    ///排除点要素
                    if (pFeature.ShapeCopy.GeometryType != esriGeometryType.esriGeometryPoint && pFeature.ShapeCopy.GeometryType != esriGeometryType.esriGeometryMultipoint)
                    {
                        if (!pFeature.ShapeCopy.IsEmpty)
                        {
                            pGeometryCol.AddGeometry(pFeature.ShapeCopy, ref obj, ref obj);
                        }
                    }
                    pFeature = pEnumFeature.Next();
                }
                //构造合并
                ITopologicalOperator pTopo = new PolygonClass();
                pTopo.ConstructUnion(pGeometryCol as IEnumGeometry);
                pGeometry = pTopo as IGeometry;
                return(pGeometry);
            }
            catch
            { return(pGeometry = null); }
        }
コード例 #12
0
        private void axMapControl1_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e)
        {
            if (e.button == 4)
            {
                AeUtils.Pan();
            }
            else if (e.button == 1 && _isShowInfo)
            {
                IPoint pPoint = new PointClass()
                {
                    X = e.mapX, Y = e.mapY
                };
                m_pMapC2.Map.SelectByShape(pPoint, null, true);
                m_pMapC2.Refresh(esriViewDrawPhase.esriViewGeoSelection, null, null);
                IEnumFeature pEnumFeature = m_pMapC2.Map.FeatureSelection as IEnumFeature;
                IFeature     pFeature     = pEnumFeature.Next();
                if (pFeature == null)
                {
                    return;
                }
                int FID = (int)pFeature.get_Value(0);

                new FormInfo(AeUtils.GetLayerByName("Building") as IFeatureLayer, FID).Show();
            }
        }
コード例 #13
0
ファイル: ClsMapLayer.cs プロジェクト: johnforrest/GeoCoding
        /// <summary>
        /// 把Map中的选择要素转到Collection中
        /// </summary>
        /// <param name="pMap">选择对象</param>
        /// <returns>要素集合</returns>
        public Collection <object> GetSelectFeature(IMap pMap)
        {
            //获取选择集
            IEnumFeature pEnumFeature = null;

            pEnumFeature = pMap.FeatureSelection as IEnumFeature;

            if (pEnumFeature == null)
            {
                return(null);
            }

            IFeature pFeature = null;

            pEnumFeature.Reset();

            //遍历所选中的要素并将其放入一集合中
            Collection <object> pFeatureCol = new Collection <object>();

            while ((pFeature = pEnumFeature.Next()) != null)
            {
                pFeatureCol.Add(pFeature);
            }

            return(pFeatureCol);
        }
コード例 #14
0
ファイル: PublicClass.cs プロジェクト: siszoey/geosufan
        public static IGeometry GetSelectGeometry(IMap pMap)
        {
            if (pMap == null)
            {
                return(null);
            }
            if (pMap.SelectionCount == 0)
            {
                return(null);
            }

            IGeometryBag        pGeometryBag = new GeometryBagClass();
            IGeometryCollection pGeomtryCol  = (IGeometryCollection)pGeometryBag;
            IEnumFeature        pEnumFeature = (IEnumFeature)pMap.FeatureSelection;
            IFeature            pFeature     = pEnumFeature.Next();

            object obj = System.Reflection.Missing.Value;

            while (pFeature != null)
            {
                pGeomtryCol.AddGeometry(pFeature.ShapeCopy, ref obj, ref obj);
                pFeature = pEnumFeature.Next();
            }
            pGeometryBag.Project(pMap.SpatialReference);
            return((IGeometry)pGeometryBag);
        }
コード例 #15
0
ファイル: Form1.cs プロジェクト: Flame-c/CYHGIS
        private void ToolStripButton_ZoomSelect_Click(object sender, EventArgs e)
        {
            int nSlection = axMapControl1.Map.SelectionCount;

            if (nSlection == 0)
            {
                MessageBox.Show("请先选择要素!", "提示");
            }
            else
            {
                ISelection   selection   = axMapControl1.Map.FeatureSelection;
                IEnumFeature enumFeature = (IEnumFeature)selection;
                enumFeature.Reset();
                IEnvelope pEnvelope = new EnvelopeClass();
                IFeature  pFeature  = enumFeature.Next();
                while (pFeature != null)
                {
                    pEnvelope.Union(pFeature.Extent);
                    pFeature = enumFeature.Next();
                }
                pEnvelope.Expand(1.1, 1.1, true);
                axMapControl1.ActiveView.Extent = pEnvelope;
                axMapControl1.ActiveView.Refresh();
            }
        }
コード例 #16
0
        public override void OnMouseDown(int int_0, int int_1, int int_2, int int_3)
        {
            IPoint       mapPoint         = _context.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(int_2, int_3);
            IEnumFeature featureSelection = _context.FocusMap.FeatureSelection as IEnumFeature;

            featureSelection.Reset();
            IFeature     feature          = featureSelection.Next();
            IInvalidArea invalidAreaClass = new InvalidAreaClass()
            {
                Display = (_context.FocusMap as IActiveView).ScreenDisplay
            };

            invalidAreaClass.Add(feature);
            Yutai.ArcGIS.Common.Editor.Editor.StartEditOperation(feature.Class as IDataset);
            try
            {
                (feature as IFeatureEdit).Split(mapPoint);
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message);
            }
            Yutai.ArcGIS.Common.Editor.Editor.StopEditOperation(feature.Class as IDataset);
            invalidAreaClass.Invalidate(-2);
            _context.ClearCurrentTool();
        }
        //缩放至选择的要素
        private void barButtonItem24_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            int nSlection = Variable.pMapFrm.mainMapControl.Map.SelectionCount;

            if (nSlection == 0)
            {
                MessageBox.Show("请先选择要素!", "提示");
            }
            else
            {
                ISelection   selection   = Variable.pMapFrm.mainMapControl.Map.FeatureSelection;
                IEnumFeature enumFeature = (IEnumFeature)selection;
                enumFeature.Reset();
                IEnvelope pEnvelope = new EnvelopeClass();
                IFeature  pFeature  = enumFeature.Next();
                while (pFeature != null)
                {
                    pEnvelope.Union(pFeature.Extent);
                    pFeature = enumFeature.Next();
                }
                pEnvelope.Expand(1.1, 1.1, true);
                Variable.pMapFrm.mainMapControl.ActiveView.Extent = pEnvelope;
                Variable.pMapFrm.mainMapControl.ActiveView.Refresh();
            }
        }
コード例 #18
0
        private IFeature SelctFeatureBasedMousePoint(IPoint pPoint)
        {
            //对点对象做缓冲区运算
            ITopologicalOperator pTopo     = pPoint as ITopologicalOperator;
            IGeometry            pBuffer   = pTopo.Buffer(0.5);
            IGeometry            pGeometry = pBuffer.Envelope;

            SetAllPolylinePolygonLayersSelectable();
            ISelectionEnvironment selEnvironment = new SelectionEnvironmentClass();

            selEnvironment.CombinationMethod = esriSelectionResultEnum.esriSelectionResultNew;
            m_map.SelectByShape(pGeometry, selEnvironment, true);
            IEnumFeature SelectedFeatures = m_map.FeatureSelection as IEnumFeature;

            SelectedFeatures.Reset();
            IFeature extendFeature = SelectedFeatures.Next();

            SetAllLayersSelectable();

            m_activeView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, m_activeView.Extent);

            if (extendFeature != null && extendFeature.Shape.GeometryType == esriGeometryType.esriGeometryPolyline)
            {
                return(extendFeature);
            }
            return(null);
        }
コード例 #19
0
ファイル: CmdFollowAlong.cs プロジェクト: secondii/Yutai
        private void method_5()
        {
            this.bool_6 = true;
            this.bool_1 = false;
            IEnumFeature        enumFeature        = _context.FocusMap.FeatureSelection as IEnumFeature;
            IGeometryCollection geometryCollection = new GeometryBag() as IGeometryCollection;

            enumFeature.Reset();
            IFeature feature = enumFeature.Next();
            object   value   = Missing.Value;

            while (feature != null)
            {
                esriGeometryType geometryType = feature.Shape.GeometryType;
                if (geometryType == esriGeometryType.esriGeometryPolygon ||
                    geometryType == esriGeometryType.esriGeometryPolyline)
                {
                    IClone clone = feature.Shape as IClone;
                    geometryCollection.AddGeometry(clone.Clone() as IGeometry, ref value, ref value);
                    this.bool_4 = true;
                }
                feature = enumFeature.Next();
            }
            if (this.bool_2)
            {
                this.isegmentGraph_0.SetEmpty();
                this.isegmentGraphCursor_0 = null;
            }
            this.isegmentGraph_0.Load(geometryCollection as IEnumGeometry, false, true);
            this.bool_2 = false;
        }
コード例 #20
0
 public override void OnClick()
 {
     try
     {
         IEnumFeature featureSelection = _context.FocusMap.FeatureSelection as IEnumFeature;
         featureSelection.Reset();
         IFeature feature = featureSelection.Next();
         bool     flag    = false;
         Yutai.ArcGIS.Common.Editor.Editor.EditWorkspace.StartEditOperation();
         while (feature != null)
         {
             flag = Yutai.ArcGIS.Common.Editor.Editor.DeComposeGeometry(feature,
                                                                        feature.ShapeCopy as IGeometryCollection);
             feature = featureSelection.Next();
         }
         Yutai.ArcGIS.Common.Editor.Editor.EditWorkspace.StopEditOperation();
         if (flag)
         {
             _context.FocusMap.FeatureSelection.Clear();
             _context.ActiveView.Refresh();
         }
         else
         {
             MessageBox.Show("没有选择多部分要素");
         }
     }
     catch (Exception exception)
     {
         MessageBox.Show(exception.Message);
     }
 }
コード例 #21
0
ファイル: Form1.cs プロジェクト: 15968865116/arcengine
        private void 缩放至选择ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            int nSelection = axMapControl1.Map.SelectionCount;//统计选择的要素的个数

            if (nSelection == 0)
            {
                MessageBox.Show("请先选择要素!", "提示");
            }
            else
            {
                ISelection   selection   = axMapControl1.Map.FeatureSelection; //选择的要素
                IEnumFeature enumfeature = (IEnumFeature)selection;            //
                enumfeature.Reset();
                IEnvelope pEnvelop = new EnvelopeClass();
                IFeature  pFeature = enumfeature.Next();
                while (pFeature != null)
                {
                    pEnvelop.Union(pFeature.Extent);
                    pFeature = enumfeature.Next();
                }
                pEnvelop.Expand(1.1, 1.1, true);
                axMapControl1.ActiveView.Extent = pEnvelop;
                axMapControl1.ActiveView.Refresh();
            }
        }
コード例 #22
0
        private void button1_Click(object sender, EventArgs e)  //执行双击的事件
        {
            IEnumFeature pEnumFeature = axMapControl1.Map.FeatureSelection as IEnumFeature;

            pFeature = pEnumFeature.Next();
            if (pFeature == null)
            {
                return;
            }
            pGeometry = new PolygonClass();
            pGeometry = pFeature.Shape;

            //加载检测文本框
            CheckForm checkForm = new CheckForm();

            checkForm.treeView1.Nodes[0].Text          = axMapControl1.Map.get_Layer(0).Name;                            //加载图层名称
            checkForm.treeView1.Nodes[0].Nodes[0].Text = pFeature.get_Value(pFeature.Fields.FindField("Id")).ToString(); //加载Id值
            checkForm.textBox1.Text  = pFeature.get_Value(pFeature.Fields.FindField("FID")).ToString();                  //加载FID的值
            checkForm.textBox2.Text  = pFeature.get_Value(pFeature.Fields.FindField("Id")).ToString();                   //加载Id的值
            checkForm.comboBox1.Text = pFeature.get_Value(pFeature.Fields.FindField("Type")).ToString();                 //加载Type的值
            checkForm.button2.Click += new System.EventHandler(CheckButton2);                                            //添加检测事件
            checkForm.button3.Click += new System.EventHandler(CheckButton3);
            checkForm.Load          += new System.EventHandler(CheckLoad);
            checkForm.FormClosing   += new System.Windows.Forms.FormClosingEventHandler(CheckClosing);
            checkForm.ShowDialog();
        }
コード例 #23
0
ファイル: FormSurvey.cs プロジェクト: JZY0726/ArcEngine
        private void 给出可测区域ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            IGeometry          buffer;
            ISelection         pSeletion         = axMapControl1.Map.FeatureSelection;
            IEnumFeature       pEnumFeature      = (IEnumFeature)pSeletion;
            IGraphicsContainer graphicsContainer = axMapControl1.ActiveView.GraphicsContainer;

            graphicsContainer.DeleteAllElements();
            IFeature pFeature       = pEnumFeature.Next();
            double   bufferDistance = GlobalData.dist;

            if (bufferDistance <= 0.0)
            {
                MessageBox.Show("距离设置错误");
                return;
            }


            while (pFeature != null)
            {
                ITopologicalOperator topoOperator = pFeature.Shape as ITopologicalOperator;
                buffer = topoOperator.Buffer(bufferDistance);
                IElement element = new PolygonElementClass();
                element.Geometry = buffer;
                graphicsContainer.AddElement(element, 0);
                pFeature = pEnumFeature.Next();
            }
            axMapControl1.Refresh();
        }
コード例 #24
0
ファイル: ControlsAttribute.cs プロジェクト: siszoey/geosufan
        /// <summary>
        /// 将源要素的属性COPY给同层选中的要素
        /// </summary>
        private void CopyAttribute()
        {
            char[] sp            = { ' ' }; //以空格分割
            char[] sp1           = { ',' }; //以逗号分割
            string Feature_value = "";

            foreach (DictionaryEntry de in AttributeShow_state.hs_Feature)
            {
                Feature_value = de.Value.ToString();                                    //得到源OID的属性值
            }
            string[] Field = Feature_value.Split(sp1);                                  //以逗号分割

            IEnumFeature F_dateset = m_MapControl.Map.FeatureSelection as IEnumFeature; //得到MAP上选中的要素集

            F_dateset.Reset();
            IFeature Feature = F_dateset.Next();//取得下一个要素

            if (Feature == null)
            {
                SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "您没有选择任何要修改的目标要素属性!");
                return;
            }
            MoData.v_CurWorkspaceEdit.StartEditOperation();//开启编辑操作
            while (Feature != null)
            {
                IFeatureClass F_class = Feature.Class as IFeatureClass;

                //MoData.v_CurWorkspaceEdit.RedoEditOperation();//开启可回退
                if (Feature.FeatureType != esriFeatureType.esriFTAnnotation)//判别不是注记时发生操作
                {
                    //COPY时,将源要素属性除外
                    if (Feature.OID.ToString() != AttributeShow_state.OID)
                    {
                        for (int n = 0; n < AttributeShow_state.feature_count; n++)
                        {
                            string value = Feature.Fields.get_Field(n).Name.ToLower();
                            if (value == "objectid" || value == "shape" || value == "shape_length" || value == "shape_area" || value == "element") //确定控件上不能更改的属性
                            {
                                continue;                                                                                                          //如果是这些固定不变的字段那么属性值是不能COPY,进行一下一个字段赋值
                            }
                            else
                            {
                                string[] tempStr = Field[n].Split(sp); //以空格分割,得到字段
                                string   Value   = tempStr[1];         //值
                                Feature.set_Value(n, Value);
                            }
                        }
                    }
                }
                Feature.Store();

                Feature = F_dateset.Next();                //遍历下一个要素
            }
            MoData.v_CurWorkspaceEdit.StopEditOperation(); //结束编辑操作

            SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "修改成功!");
            m_MapControl.Map.ClearSelection();      //清除MAP上的选择集
            m_MapControl.ActiveView.Refresh();
            AttributeShow_state.state_brush = true; //确定我们已操作过属性刷,并改变状态,让后面的操作得以进行不出错。
        }
コード例 #25
0
        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            // TODO:  Add ToolCreateParallel.OnMouseDown implementation
            if (Button == 1 && (m_pMapCtl = ClsGlobal.GetMapControl(m_hookHelper)) != null)
            {
                IMap   pMap = m_pMapCtl.Map;
                IPoint po   = m_pMapCtl.ToMapPoint(X, Y);
                ISelectionEnvironment pSelectionEnv = new SelectionEnvironmentClass();

                IGeometry geometry = new PolygonClass();
                geometry = m_pMapCtl.TrackRectangle();
                pMap.SelectByShape(geometry, pSelectionEnv, true);
                m_pMapCtl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
                IEnumFeatureSetup pSelectionsetup = pMap.FeatureSelection as IEnumFeatureSetup;
                pSelectionsetup.AllFields = true;//这里是关键
                IEnumFeature pFeatureCollection = pSelectionsetup as IEnumFeature;
                IFeature     pF = pFeatureCollection.Next();
                if (pF != null && pF.Shape is IPolyline)
                {
                    FrmParallelLineOffset frm = new FrmParallelLineOffset();
                    if (frm.ShowDialog() == DialogResult.OK)
                    {
                        IPolyline pPolyline = ConstructOffset(pF.Shape as IPolyline, frm.offset);
                        IFeature  pFeature  = m_FLayer.FeatureClass.CreateFeature();
                        pFeature.Shape = pPolyline;
                        pFeature.Store();
                        m_pMapCtl.Refresh();
                    }
                }
            }
        }
コード例 #26
0
        /// <summary>
        /// Occurs when this command is clicked
        /// </summary>
        public override void OnClick()
        {
            IEnumFeature pEnumFeature = (IEnumFeature)m_MapControl.Map.FeatureSelection;
            IFeature     pFeature     = pEnumFeature.Next();
            IEnvelope    pEnvelope    = new EnvelopeClass();

            if (pFeature != null)
            {
                if (pFeature.ShapeCopy.GeometryType == esriGeometryType.esriGeometryPoint)
                {
                    IPoint pPoint = new PointClass();
                    pPoint.X = (pFeature.Extent.XMax + pFeature.Extent.XMin) / 2;
                    pPoint.Y = (pFeature.Extent.YMax + pFeature.Extent.YMin) / 2;

                    m_MapControl.CenterAt(pPoint);
                }
                else
                {
                    while (pFeature != null)
                    {
                        pEnvelope.Union(pFeature.Extent);
                        pFeature = pEnumFeature.Next();
                    }
                }
                m_MapControl.ActiveView.Extent = pEnvelope;

                m_MapControl.ActiveView.Refresh();
            }
        }
コード例 #27
0
        /// <summary>
        /// Occurs when this tool is clicked
        /// </summary>
        public override void OnClick()
        {
            IEnumFeature pEnumFeature = m_MapControl.Map.FeatureSelection as IEnumFeature;

            if (pEnumFeature == null || m_MapControl.Map.SelectionCount != 1)
            {
                return;
            }
            pEnumFeature.Reset();
            IFeature pFeature = pEnumFeature.Next();

            if (pFeature == null)
            {
                return;
            }

            //画出图形各节点
            if (MoData.v_bVertexSelectionTracker == true)
            {
                ModPublic.DrawEditSymbol(pFeature.Shape, m_MapControl.ActiveView);
            }

            //设置点选容差
            ISelectionEnvironment pSelectEnv = new SelectionEnvironmentClass();

            m_dblTolearance = ModPublic.ConvertPixelsToMapUnits(m_hookHelper.ActiveView, pSelectEnv.SearchTolerance);

            m_pFeature = pFeature;
        }
コード例 #28
0
        private bool method_1()
        {
            bool         flag;
            IEnumFeature featureSelection = this._appContext.MapControl.Map.FeatureSelection as IEnumFeature;

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

            while (true)
            {
                if (feature == null)
                {
                    flag = false;
                    break;
                }
                else if (feature.Shape.GeometryType != esriGeometryType.esriGeometryPolyline)
                {
                    flag = false;
                    break;
                }
                else if (Editor.CheckWorkspaceEdit(feature.Class as IDataset, "IsBeingEdited"))
                {
                    flag = true;
                    break;
                }
                else
                {
                    feature = featureSelection.Next();
                }
            }
            return(flag);
        }
コード例 #29
0
        private void Map_SearchByShape()
        {
            IMap       pMap             = axMapControl1.Map;
            ISelection pFeatureSelction = pMap.FeatureSelection;

            IEnumFeature      pEnumFeature      = pFeatureSelction as IEnumFeature;
            IEnumFeatureSetup pEnumFeatureSetup = pEnumFeature as IEnumFeatureSetup;

            pEnumFeatureSetup.AllFields = true;
            FeatureAttributeEventArgs FeatureAttributes = new FeatureAttributeEventArgs();
            IArray pFArray = new ArrayClass();

            pEnumFeature.Reset();
            IFeature pFeature = pEnumFeature.Next();

            while (pFeature != null)
            {
                pFArray.Add(pFeature);
                pFeature = pEnumFeature.Next();
            }
            FeatureAttributes.SelectFeatures = pFArray;
            if (SelectFeaturEvent != null)
            {
                SelectFeaturEvent(this, FeatureAttributes);
            }
        }
コード例 #30
0
ファイル: BufferAnalyseDlg.cs プロジェクト: secondii/Yutai
 private void method_0(double num)
 {
     if (!this.bGeo.Checked)
     {
         IMap         map = this.m_app.FocusMap;
         IEnumFeature featureSelection = (IEnumFeature)map.FeatureSelection;
         IFeature     feature          = featureSelection.Next();
         if (feature != null)
         {
             while (feature != null)
             {
                 this.EoQqirFnxu(feature.Shape, num);
                 feature = featureSelection.Next();
             }
         }
         else
         {
             MessageBox.Show("请确定范围!");
         }
     }
     else if (this.m_pDrawGeo != null)
     {
         this.EoQqirFnxu(this.m_pDrawGeo, num);
     }
     else
     {
         MessageBox.Show("请确定范围!");
     }
 }
コード例 #31
0
        /// <summary>
        /// Removes features from the map selection.
        /// </summary>
        /// <param name="features">A feature enumeration of those features to remove from the selection.</param>
        /// <param name="layer">The layer to which the features belong.</param>
        public static void RemoveFeaturesFromSelection(IEnumFeature features, ILayer layer)
        {
            if (features != null)
            {
                features.Reset();
                IFeature feature = features.Next();
                IFeatureSelection featureSelection = ((IFeatureLayer)layer) as IFeatureSelection;
                ISelectionSet selSet = featureSelection.SelectionSet;

                while (feature != null)
                {
                    RemoveFeatureFromSelection(feature, selSet);
                    feature = features.Next();
                }
                featureSelection.SelectionChanged();
            }
        }