Beispiel #1
0
 private bool ReconcileVersionFindConflicts(IFeatureWorkspace pFeatureWorkspace, string strTargetVersion)
 {
     try
     {
         bool         flag = false;
         IVersionEdit edit = pFeatureWorkspace as IVersionEdit;
         edit.CanPost();
         if (edit.Reconcile(strTargetVersion))
         {
             IVersion           startEditingVersion   = edit.StartEditingVersion;
             IVersion           preReconcileVersion   = edit.PreReconcileVersion;
             IVersion           commonAncestorVersion = edit.CommonAncestorVersion;
             IVersion           reconcileVersion      = edit.ReconcileVersion;
             IEnumConflictClass conflictClasses       = edit.ConflictClasses;
             conflictClasses.Reset();
             for (IConflictClass class3 = conflictClasses.Next(); class3 != null; class3 = conflictClasses.Next())
             {
                 IDataset dataset = (IDataset)class3;
                 if (class3.HasConflicts)
                 {
                     flag = true;
                     string   str = dataset.Name + ":";
                     IEnumIDs iDs = class3.UpdateUpdates.IDs;
                     iDs.Reset();
                     int num = iDs.Next();
                     while (num != -1)
                     {
                         str = str + num.ToString() + ";";
                         num = iDs.Next();
                     }
                     iDs = class3.DeleteUpdates.IDs;
                     iDs.Reset();
                     num = iDs.Next();
                     while (num != -1)
                     {
                         str = str + num.ToString() + ";";
                         num = iDs.Next();
                     }
                     iDs = class3.UpdateDeletes.IDs;
                     iDs.Reset();
                     for (num = iDs.Next(); num != -1; num = iDs.Next())
                     {
                         str = str + num.ToString() + ";";
                     }
                     MessageBox.Show("发现冲突," + str, "版本编辑", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                 }
                 else
                 {
                     MessageBox.Show(dataset.Name + " Does Not Have Conflicts", "版本编辑", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                 }
             }
         }
         return(flag);
     }
     catch (Exception exception)
     {
         this.mErrOpt.ErrorOperate(this.mSubSysName, "ShapeEdit.Editor", "ReconcileVersionFindConflicts", exception.GetHashCode().ToString(), exception.Source, exception.Message, "", "", "");
         return(false);
     }
 }
Beispiel #2
0
        public override void OnClick()
        {
            if (m_MergeLayer != null)
            {
                List <int>        OIDLst        = new List <int>();
                IFeatureSelection pFeatSel      = m_MergeLayer as IFeatureSelection;
                ISelectionSet     pSelectionSet = pFeatSel.SelectionSet;

                //如果选择的要素多余一个,则可以开始融合
                if (pSelectionSet.Count > 1)
                {
                    int      pOID     = -1;
                    IEnumIDs pEnumIDs = pSelectionSet.IDs;
                    pEnumIDs.Reset();
                    pOID = pEnumIDs.Next();
                    while (pOID != -1)
                    {
                        OIDLst.Add(pOID);
                        pOID = pEnumIDs.Next();
                    }
                    frmDataMerge pfrmDataMerge = new frmDataMerge(m_MergeLayer.FeatureClass, OIDLst, m_Hook);
                    pfrmDataMerge.ShowDialog();
                }
            }
        }
Beispiel #3
0
        private void Update(int status, IFeatureLayer buildingsfeaturelayer)
        {
            //Get the editor
            _editor = GetEditorFromArcMap(_application as IMxApplication);
            if (_editor == null)
            {
                MessageBox.Show("Editor version of ArcMap required.", "Building Inspector", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return;
            }

            if (_editor.EditState != esriEditState.esriStateEditing)
            {
                MessageBox.Show("Start an edit session first.", "Building Inspector", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return;
            }

            IFeatureSelection featureselection = buildingsfeaturelayer as IFeatureSelection;

            if (featureselection.SelectionSet.Count == 0)
            {
                MessageBox.Show("Select at least one feature.", "Building Inspector", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return;
            }



            IFeatureClass featureclass = buildingsfeaturelayer.FeatureClass;
            IEnumIDs      enumIDs      = featureselection.SelectionSet.IDs;

            _editor.StartOperation();
            enumIDs.Reset();
            int intOID = enumIDs.Next();

            while (intOID != -1)
            {
                IFeature feature = featureclass.GetFeature(intOID);
                if (feature != null)
                {
                    int inspectionfieldindex = _utilitiesArcMap.FindField(featureclass, "rsi");
                    if (inspectionfieldindex > -1)
                    {
                        //_editor.StartOperation();
                        feature.set_Value(inspectionfieldindex, status);
                        //_editor.StopOperation("Status updated!" + feature.OID);
                        feature.Store();
                    }
                    else
                    {
                        throw new Exception("Selected layer does not have the 'rsi field'.");
                    }
                }
                intOID = enumIDs.Next();
            }

            _activeView.Refresh();

            _editor.StopOperation("Inspected...");

            GetStatus();
        }
Beispiel #4
0
        private void ApplyDomain(DomainCode code)
        {
            if (CheckRequirements())
            {
                IFeatureLayer     featureLayer     = _utilities.FeatureLayer(cboFeatureLayer.Text);
                IFeatureClass     featureClass     = featureLayer.FeatureClass;
                IFeatureSelection featureSelection = featureLayer as IFeatureSelection;
                IEnumIDs          enumIDs          = featureSelection.SelectionSet.IDs;
                int fieldIndex = _utilities.FindField(featureClass, cboField.Text);


                _editor.StartOperation();
                enumIDs.Reset();

                int intOID = enumIDs.Next();

                while (intOID != -1)
                {
                    IFeature feature = featureClass.GetFeature(intOID);
                    if (feature != null)
                    {
                        feature.set_Value(fieldIndex, (int)code);

                        feature.Store();
                    }
                    intOID = enumIDs.Next();
                }

                _activeView.Refresh();
                _editor.StopOperation("Update Class Type");
            }
        }
Beispiel #5
0
        /// <summary>
        /// 根据表,OIDs构造查询条件
        /// </summary>
        /// <param name="pTable"></param>
        /// <param name="OIDs"></param>
        /// <param name="isSwitch"></param>
        /// <returns></returns>
        public static string GetQuerySQL(ITable pTable, IEnumIDs OIDs, bool isSwitch)
        {
            string tmpStr = pTable.OIDFieldName;

            if (OIDs == null)
            {
                return(tmpStr + " in ()");
            }

            OIDs.Reset();
            if (isSwitch)
            {
                tmpStr += " not in (";
            }
            else
            {
                tmpStr += " in (";
            }

            int oid = -1;

            oid = OIDs.Next();
            if (oid != -1)
            {
                while (oid != -1)
                {
                    tmpStr += oid.ToString() + " , ";
                    oid     = OIDs.Next();
                }
                tmpStr = tmpStr.Remove(tmpStr.Length - 3, 3);
            }
            tmpStr += ")";
            return(tmpStr);
        }
Beispiel #6
0
 private void frmAttributeTable_FeatureLayerSelectionChanged()
 {
     if ((this.m_pTable is IFeatureSelection) && this.m_CanDoFeatureLayerSelectChange)
     {
         this.m_CanDoSelectChange = false;
         IFeatureSelection pTable = this.m_pTable as IFeatureSelection;
         IEnumIDs          iDs    = pTable.SelectionSet.IDs;
         iDs.Reset();
         int    num          = iDs.Next();
         string oIDFieldName = (this.m_pTable as IFeatureLayer).FeatureClass.OIDFieldName;
         int    num2         = 0;
         while (num != -1)
         {
             ((GridView)this.dataGrid1.MainView).ClearSelection();
             for (int i = num2; i < ((GridView)this.dataGrid1.MainView).RowCount; i++)
             {
                 object row = ((GridView)this.dataGrid1.MainView).GetRow(i);
                 if ((row is DataRowView) && (Convert.ToInt32((row as DataRowView).Row[oIDFieldName]) == num))
                 {
                     ((GridView)this.dataGrid1.MainView).SelectRow(i);
                     num2 = i + 1;
                     break;
                 }
             }
             num = iDs.Next();
         }
         this.m_CanDoSelectChange = true;
     }
 }
Beispiel #7
0
 public override void OnClick()
 {
     try
     {
         if (MessageBox.Show("是否删除所选择的要素?", "提示", MessageBoxButtons.YesNo) != DialogResult.No)
         {
             Editor.UniqueInstance.StartEditOperation();
             IFeatureSelection targetLayer = Editor.UniqueInstance.TargetLayer as IFeatureSelection;
             IEnumIDs          iDs         = targetLayer.SelectionSet.IDs;
             iDs.Reset();
             for (int i = iDs.Next(); i != -1; i = iDs.Next())
             {
                 IFeature editFeature = Editor.UniqueInstance.TargetLayer.FeatureClass.GetFeature(i);
                 AttributeManager.AttributeDeleteHandleClass.AttributeDelete(editFeature);
                 editFeature.Delete();
             }
             this._hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection | esriViewDrawPhase.esriViewGeography, Editor.UniqueInstance.TargetLayer, this._hookHelper.ActiveView.Extent);
             Editor.UniqueInstance.StopEditOperation("delete");
         }
     }
     catch (Exception exception)
     {
         Editor.UniqueInstance.AbortEditOperation();
         this._mErrOpt.ErrorOperate(this._mSubSysName, "ShapeEdit.Delete1", "OnClick", exception.GetHashCode().ToString(), exception.Source, exception.Message, "", "", "");
     }
 }
        private void BuildFileList()
        {
            _fileList.Clear();

            IFeatureLayer featureLayer = ((CustomLayer)cbo_layers.SelectedItem).FeatureLayer();
            IFeatureClass featureClass = ((CustomLayer)cbo_layers.SelectedItem).FeatureClass();


            if (rb_all.Checked)
            {
                IFeatureCursor cursor     = featureClass.Search(null, false);
                IFields        fields     = cursor.Fields;
                int            fieldIndex = _utilitiesArcMap.FindField(featureClass, cbo_fieldname.Text);

                IFeature feature = cursor.NextFeature();

                while (feature != null)
                {
                    //string fileName = Utilities.Utilities_General.AddPrefixAndSuffixToFileName(Convert.ToString(feature.get_Value(fieldIndex)), txb_prefix.Text, txb_suffix.Text);
                    string fileName = Convert.ToString(feature.get_Value(fieldIndex));
                    if (!_fileList.ContainsKey(fileName))
                    {
                        _fileList.Add(fileName, false);
                    }

                    feature = cursor.NextFeature();
                }
            }

            if (rb_selected.Checked)
            {
                IFeatureSelection selection = featureLayer as IFeatureSelection;
                IEnumIDs          IDs       = selection.SelectionSet.IDs;
                IDs.Reset();

                int oid = IDs.Next();

                while (oid != -1)
                {
                    IFeature feature = featureClass.GetFeature(oid);
                    if (feature != null)
                    {
                        int    fieldIndex = _utilitiesArcMap.FindField(featureClass, cbo_fieldname.Text);
                        string fileName   = Convert.ToString(feature.get_Value(fieldIndex));
                        if (!_fileList.ContainsKey(fileName))
                        {
                            _fileList.Add(fileName, false);
                        }

                        oid = IDs.Next();
                    }
                }
            }
        }
        private void GenerateFileList()
        {
            // Clear File List
            _fileList.Clear();

            IFeatureLayer featureLayer = _utilitiesArcMap.FeatureLayer(cbo_TileIndex.Text);
            IFeatureClass featureClass = featureLayer.FeatureClass;

            if (rb_all.Checked)  // Grab All Of The Raster :)
            {
                IFeatureCursor cursor = featureClass.Search(null, false);

                IFields fields     = cursor.Fields;
                int     fieldIndex = _utilitiesArcMap.FindField(featureClass, cbo_FieldName.Text);

                IFeature feature = cursor.NextFeature();

                while (feature != null)
                {
                    // Default To True I will validate After Adding All To Dictonary
                    if (!_fileList.ContainsKey(Convert.ToString(feature.get_Value(fieldIndex))))
                    {
                        _fileList.Add(Convert.ToString(feature.get_Value(fieldIndex)), true);
                    }

                    feature = cursor.NextFeature();
                }
            }
            else // Grab Only The Selected Tiles
            {
                IFeatureSelection featureSelection = featureLayer as IFeatureSelection;
                IEnumIDs          enumIDs          = featureSelection.SelectionSet.IDs;
                enumIDs.Reset();
                int intOID = enumIDs.Next();
                while (intOID != -1)
                {
                    IFeature feature = featureClass.GetFeature(intOID);
                    if (feature != null)
                    {
                        int fieldIndex = _utilitiesArcMap.FindField(featureClass, cbo_FieldName.Text);
                        // Default To True I will validate After Adding All To Dictonary
                        if (!_fileList.ContainsKey(Convert.ToString(feature.get_Value(fieldIndex))))
                        {
                            _fileList.Add(Convert.ToString(feature.get_Value(fieldIndex)), true);
                        }
                    }
                    intOID = enumIDs.Next();
                }
            }
        }
Beispiel #10
0
        public override void OnClick()
        {
            IFeatureSelection targetLayer = Editor.UniqueInstance.TargetLayer as IFeatureSelection;
            IEnumIDs          iDs         = targetLayer.SelectionSet.IDs;

            iDs.Reset();
            int iD = iDs.Next();

            if (iD != -1)
            {
                IFeature pFeature = Editor.UniqueInstance.TargetLayer.FeatureClass.GetFeature(iD);
                this.ExplodeFeature(pFeature);
            }
        }
Beispiel #11
0
        /// <summary>
        ///     Creates an <see cref="IEnumerable{T}" /> from an <see cref="IEnumIDs" />
        /// </summary>
        /// <param name="source">An <see cref="IEnumIDs" /> to create an <see cref="IEnumerable{T}" /> from.</param>
        /// <returns>An <see cref="IEnumerable{T}" /> that contains the values from the input source.</returns>
        public static IEnumerable <int> AsEnumerable(this IEnumIDs source)
        {
            if (source != null)
            {
                source.Reset();
                int oid = source.Next();
                while (oid >= 0)
                {
                    yield return(oid);

                    oid = source.Next();
                }
            }
        }
Beispiel #12
0
        public List <IFeature> GetSelectedFeatures()
        {
            List <IFeature> list = new List <IFeature>();

            if (this.TargetLayer != null)
            {
                IFeatureSelection targetLayer = this.TargetLayer as IFeatureSelection;
                IEnumIDs          iDs         = targetLayer.SelectionSet.IDs;
                iDs.Reset();
                for (int i = iDs.Next(); i != -1; i = iDs.Next())
                {
                    IFeature item = this.TargetLayer.FeatureClass.GetFeature(i);
                    list.Add(item);
                }
            }
            return(list);
        }
Beispiel #13
0
        private void Delete(IFeatureLayer buildingsfeaturelayer)
        {
            //Get the editor
            _editor = GetEditorFromArcMap(_application as IMxApplication);
            if (_editor == null)
            {
                MessageBox.Show("Editor version of ArcMap required.", "Building Inspector", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return;
            }

            if (_editor.EditState != esriEditState.esriStateEditing)
            {
                MessageBox.Show("Start an edit session first.", "Building Inspector", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return;
            }

            IFeatureSelection featureselection = buildingsfeaturelayer as IFeatureSelection;

            if (featureselection.SelectionSet.Count == 0)
            {
                MessageBox.Show("Select at least one feature.", "Building Inspector", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return;
            }

            IFeatureClass featureclass = buildingsfeaturelayer.FeatureClass;
            IEnumIDs      enumIDs      = featureselection.SelectionSet.IDs;

            enumIDs.Reset();
            int intOID = enumIDs.Next();

            while (intOID != -1)
            {
                IFeature feature = featureclass.GetFeature(intOID);
                if (feature != null)
                {
                    _editor.StartOperation();
                    feature.Delete();
                    _editor.StopOperation("Status updated!" + feature.OID);
                    feature.Store();
                }
                intOID = enumIDs.Next();
            }

            _activeView.Refresh();
        }
Beispiel #14
0
        private void method_2(TreeNode treeNode_0, ISelectionSet iselectionSet_0, IConflictClass iconflictClass_0)
        {
            IEnumIDs iDs = iselectionSet_0.IDs;

            iDs.Reset();
            for (int i = iDs.Next(); i != -1; i = iDs.Next())
            {
                TreeNode      node = new TreeNode(i.ToString());
                RowCollection unk  = new RowCollection
                {
                    ConflictClass = iconflictClass_0
                };
                this.iarray_0.Add(unk);
                unk.OID  = i;
                node.Tag = unk;
                treeNode_0.Nodes.Add(node);
            }
        }
Beispiel #15
0
        public static void DeletedSelectedZD(IFeatureSelection ifeatureSelection_0)
        {
            IEnumIDs ds = ifeatureSelection_0.SelectionSet.IDs;

            ds.Reset();
            int             num          = ds.Next();
            List <IFeature> features     = new List <IFeature>();
            IFeatureClass   featureClass = (ifeatureSelection_0 as IFeatureLayer).FeatureClass;

            while (num > 0)
            {
                features.Add(featureClass.GetFeature(num));
                num = ds.Next();
            }
            foreach (IFeature feature in features)
            {
                ZDEditTools.DeleteZD(feature);
            }
        }
Beispiel #16
0
        private void button2_Click(object sender, EventArgs e)
        {
            for (int i = 0; i < layerCount; i++)
            {
                if (pMap.get_Layer(i).Name.Equals(comboBox1.Text))
                {
                    currentLayer = pMap.get_Layer(i) as IFeatureLayer;
                }
            }
            if (currentLayer != null)
            {
                IFeatureSelection featureSelection = currentLayer as IFeatureSelection;
                ISelectionSet     selectionSet     = featureSelection.SelectionSet;
                IEnumIDs          selectedIDs      = selectionSet.IDs;
                selectedIDs.Reset();
                int selectedID = selectedIDs.Next();
                if (selectedID == -1)
                {
                    return;
                }
                IFeature baseFeature = currentLayer.FeatureClass.GetFeature(selectedID);

                if (baseFeature != null)
                {
                    IGeometry      baseGeom = baseFeature.Shape;
                    ISpatialFilter pSFilter = new SpatialFilterClass();
                    pSFilter.Geometry      = baseGeom;
                    pSFilter.GeometryField = "Shape";
                    pSFilter.SpatialRel    = esriSpatialRelEnum.esriSpatialRelTouches;

                    featureSelection.SelectFeatures(pSFilter, esriSelectionResultEnum.esriSelectionResultNew, false);
                    axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, axMapControl1.ActiveView.Extent);
                }
                else
                {
                    MessageBox.Show("筛选之后为空");
                }
            }
            else
            {
                MessageBox.Show("请先选择面图层里面的一个要素");
            }
        }
Beispiel #17
0
        private void btnQuery_Click(object sender, EventArgs e)
        {
            DeleteGraphics();

            txtMessages.Text += "开始邻接多边形查询: " + "\r\n";
            txtMessages.Text += "查询图层: " + currentLayer.Name + "\r\n";
            txtMessages.Text += DateAndTime.Now.ToString() + "\r\n\r\n";
            txtMessages.Update();

            IFeatureSelection featureSelection = currentLayer as IFeatureSelection;
            ISelectionSet     selectionSet     = featureSelection.SelectionSet;
            IEnumIDs          selectedIDs      = selectionSet.IDs;

            selectedIDs.Reset();
            int selectedID = selectedIDs.Next();

            if (selectedID == -1)
            {
                return;
            }
            IFeature baseFeature = currentLayer.FeatureClass.GetFeature(selectedID);

            //The following code using SpatialFilter, and has been tested successfully!
            if (baseFeature != null)
            {
                IGeometry      baseGeom = baseFeature.Shape;
                ISpatialFilter pSFilter = new SpatialFilterClass();
                pSFilter.Geometry      = baseGeom;
                pSFilter.GeometryField = "Shape";
                pSFilter.SpatialRel    = esriSpatialRelEnum.esriSpatialRelTouches;
                featureSelection.SelectFeatures(pSFilter, esriSelectionResultEnum.esriSelectionResultNew, false);
            }
            m_activeView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, m_activeView.Extent);
            //突出显示基多边形要素
            DrawGraphics(baseFeature.ShapeCopy);

            txtMessages.Text += "邻接多边形查询结束! " + "\r\n";
            txtMessages.Text += "总查询要素个数: " + m_map.SelectionCount.ToString() + " \r\n";
            txtMessages.Text += DateAndTime.Now.ToString() + "\r\n";
            ScrollToBottom(txtMessages);
            txtMessages.Update();
        }
Beispiel #18
0
        public ISelectionSetBarriers GetSelectionSetBarries()
        {
            int featureClassID = this._networkInfo.LayerPoint.FeatureClass.FeatureClassID;
            ISelectionSetBarriers selectionSetBarriers = new SelectionSetBarriers();
            IFeatureSelection     featureSelection     = (IFeatureSelection)this._networkInfo.LayerPoint;
            IQueryFilter          barrierQuery         = this.GetBarrierQuery();

            featureSelection.SelectFeatures(barrierQuery, 0, false);
            IEnumIDs iDs = featureSelection.SelectionSet.IDs;

            iDs.Reset();
            for (int i = iDs.Next(); i > 0; i = iDs.Next())
            {
                if (this.listOutBarriers.Items.IndexOf(i.ToString()) == -1)
                {
                    selectionSetBarriers.Add(featureClassID, i);
                }
            }
            return(selectionSetBarriers);
        }
Beispiel #19
0
        public static void DeletedSelectedZD(IFeatureSelection ifeatureSelection_0)
        {
            IEnumIDs iDs = ifeatureSelection_0.SelectionSet.IDs;

            iDs.Reset();
            int i = iDs.Next();

            System.Collections.Generic.List <IFeature> list = new System.Collections.Generic.List <IFeature>();
            IFeatureClass featureClass = (ifeatureSelection_0 as IFeatureLayer).FeatureClass;

            while (i > 0)
            {
                IFeature feature = featureClass.GetFeature(i);
                list.Add(feature);
                i = iDs.Next();
            }
            foreach (IFeature current in list)
            {
                ZDEditTools.DeleteZD(current);
            }
        }
Beispiel #20
0
        public void Refresh()
        {
            // This method is called internally during a solve operation immediately prior to performing the actual solve
            // This gives us an opportunity to update our evaluator's internal state based on changes to the current source feature selection set within ArcMap

            if (m_mxDocument != null)
            {
                // Clear the hashtable of any previous selections
                m_sourceHashTable.Clear();

                // Loop through every layer in the map, find the appropriate network source feature layer, and add its selection set to the source hashtable
                IMap map = m_mxDocument.FocusMap;
                IFeatureClassContainer fcContainer = m_networkDataset as IFeatureClassContainer;
                IFeatureClass          sourceFC    = fcContainer.get_ClassByName(m_networkSource.Name);

                ILayer        layer;
                IFeatureClass layerFC;
                IEnumLayer    enumLayer = map.get_Layers(null, true);
                while ((layer = enumLayer.Next()) != null)
                {
                    if (layer.Visible && layer is IFeatureLayer)
                    {
                        layerFC = ((IFeatureLayer)layer).FeatureClass;
                        if (layerFC == sourceFC)
                        {
                            IFeatureSelection featureSelection = layer as IFeatureSelection;
                            ISelectionSet     selectionSet     = featureSelection.SelectionSet;
                            IEnumIDs          idEnumerator     = selectionSet.IDs;
                            idEnumerator.Reset();
                            int oid;
                            while ((oid = idEnumerator.Next()) != -1)
                            {
                                m_sourceHashTable.Add(oid, oid);
                            }
                            break;
                        }
                    }
                }
            }
        }
Beispiel #21
0
        private void ApplyDomainNull()
        {
            if (CheckRequirements())
            {
                try
                {
                    IFeatureLayer     featureLayer     = _utilities.FeatureLayer(cboFeatureLayer.Text);
                    IFeatureClass     featureClass     = featureLayer.FeatureClass;
                    IFeatureSelection featureSelection = featureLayer as IFeatureSelection;
                    IEnumIDs          enumIDs          = featureSelection.SelectionSet.IDs;
                    int fieldIndex = _utilities.FindField(featureClass, cboField.Text);

                    enumIDs.Reset();

                    _editor.StartOperation();
                    int intOID = enumIDs.Next();

                    while (intOID != -1)
                    {
                        IFeature feature = featureClass.GetFeature(intOID);
                        if (feature != null)
                        {
                            feature.set_Value(fieldIndex, System.DBNull.Value);
                            feature.Store();
                        }
                        intOID = enumIDs.Next();
                    }

                    _activeView.Refresh();
                    _editor.StopOperation("Update Class Type");
                }
#pragma warning disable CS0168 // Variable is declared but never used
                catch (Exception ex)
#pragma warning restore CS0168 // Variable is declared but never used
                {
                    MessageBox.Show("Shapefiles Don't Accept Null");
                }
            }
        }
        protected override void OnMouseUp(ESRI.ArcGIS.Desktop.AddIns.Tool.MouseEventArgs arg)
        {
            base.OnMouseUp(arg);

            try
            {
                IPoint p = ArcMap.Document.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(arg.X, arg.Y);

                ITopologicalOperator to   = (ITopologicalOperator)p;
                IGeometry            poly = to.Buffer(20.0d);

                ISpatialFilter sp = new SpatialFilterClass();
                sp.Geometry      = poly;
                sp.GeometryField = Globals.CenterlineLayer.FeatureClass.ShapeFieldName;
                sp.SpatialRel    = esriSpatialRelEnum.esriSpatialRelIntersects;
                sp.SearchOrder   = esriSearchOrder.esriSearchOrderSpatial;

                ArcMap.Document.FocusMap.ClearSelection();

                IFeatureSelection fsel = (IFeatureSelection)Globals.CenterlineLayer;
                fsel.SelectFeatures(sp, esriSelectionResultEnum.esriSelectionResultNew, true);

                ISelectionSet selset = fsel.SelectionSet;
                if (selset.Count > 0)
                {
                    IEnumIDs pEnumIDs = selset.IDs;
                    pEnumIDs.Reset();
                    int oid = pEnumIDs.Next();

                    if (oid > -1)
                    {
                        Globals.SelectedCenterlineID = oid;
                        ArcMap.Document.ActiveView.Refresh();
                    }
                }
            }
            catch (Exception ex) { log.WriteError(ex, TAG, System.Security.Principal.WindowsIdentity.GetCurrent().Name, null); }
        }
Beispiel #23
0
 public void OnDblClick()
 {
     if (this._isLineStarted)
     {
         this._snapPoint = null;
         try
         {
             this._isLineStarted = false;
             this._linePoints.RemoveAll();
             IPolyline         other       = this._feedback.Stop();
             IFeatureSelection targetLayer = Editor.UniqueInstance.TargetLayer as IFeatureSelection;
             IEnumIDs          iDs         = targetLayer.SelectionSet.IDs;
             iDs.Reset();
             IFeature srcFeature = Editor.UniqueInstance.TargetLayer.FeatureClass.GetFeature(iDs.Next());
             if (other.SpatialReference != srcFeature.Shape.SpatialReference)
             {
                 other.Project(srcFeature.Shape.SpatialReference);
                 other.SpatialReference = srcFeature.Shape.SpatialReference;
             }
             ITopologicalOperator2 shape = srcFeature.Shape as ITopologicalOperator2;
             if (shape != null)
             {
                 shape.IsKnownSimple_2 = false;
                 shape.Simplify();
                 ITopologicalOperator2 operator2 = other as ITopologicalOperator2;
                 operator2.IsKnownSimple_2 = false;
                 operator2.Simplify();
                 IGeometry geometry = null;
                 if (srcFeature.Shape.GeometryType == esriGeometryType.esriGeometryPolyline)
                 {
                     geometry = shape.Intersect(other, esriGeometryDimension.esriGeometry0Dimension);
                 }
                 else
                 {
                     geometry = shape.Intersect(other, esriGeometryDimension.esriGeometry1Dimension);
                 }
                 if (!geometry.IsEmpty)
                 {
                     IGeometry geometry2;
                     IGeometry geometry3;
                     shape.Cut(other, out geometry3, out geometry2);
                     if ((geometry3 != null) && (geometry2 != null))
                     {
                         (geometry3 as ITopologicalOperator).Simplify();
                         (geometry2 as ITopologicalOperator).Simplify();
                         IFeatureClass featureClass = Editor.UniqueInstance.TargetLayer.FeatureClass;
                         IFeature      feature      = featureClass.CreateFeature();
                         IFeature      feature3     = featureClass.CreateFeature();
                         feature.Shape  = geometry3;
                         feature3.Shape = geometry2;
                         IAttributeSplit attributeSplitHandleClass = AttributeManager.AttributeSplitHandleClass;
                         if (attributeSplitHandleClass != null)
                         {
                             try
                             {
                                 Editor.UniqueInstance.StartEditOperation();
                                 Editor.UniqueInstance.AddAttribute = false;
                                 List <IFeature> pFeatureList = null;
                                 pFeatureList = new List <IFeature> {
                                     feature,
                                     feature3
                                 };
                                 attributeSplitHandleClass.AttributeSplit(srcFeature, ref pFeatureList);
                                 feature  = pFeatureList[0];
                                 feature3 = pFeatureList[1];
                                 feature.Store();
                                 feature3.Store();
                                 srcFeature.Delete();
                                 Editor.UniqueInstance.StopEditOperation("split");
                                 targetLayer.Clear();
                                 targetLayer.Add(feature);
                                 this._hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection | esriViewDrawPhase.esriViewGeography, null, null);
                             }
                             catch (Exception exception)
                             {
                                 Editor.UniqueInstance.AbortEditOperation();
                                 this._mErrOpt.ErrorOperate(this._mSubSysName, "ShapeEdit.Split", "OnDblClick", exception.GetHashCode().ToString(), exception.Source, exception.Message, "", "", "");
                             }
                         }
                     }
                 }
             }
         }
         catch (Exception exception2)
         {
             this._mErrOpt.ErrorOperate(this._mSubSysName, "ShapeEdit.Split", "OnDblClick", exception2.GetHashCode().ToString(), exception2.Source, exception2.Message, "", "", "");
         }
     }
 }
Beispiel #24
0
        private bool MergeFeatures(int nFeatureID)
        {
            IEngineEditor     pEngineEdit  = new EngineEditorClass();
            IEngineEditLayers pEEditLayers = pEngineEdit as IEngineEditLayers;
            IFeatureLayer     targetLayer  = pEEditLayers.TargetLayer;
            IFeatureClass     featureClass = targetLayer.FeatureClass;

            IFeatureSelection featureSelection = targetLayer as IFeatureSelection;
            ISelectionSet     selectionSet     = featureSelection.SelectionSet;

            if (selectionSet.Count < 2)
            {
                return(false);
            }
            pEngineEdit.StartOperation();
            try
            {
                object miss = Type.Missing;
                if (targetLayer.FeatureClass.ShapeType == esriGeometryType.esriGeometryPoint)
                {
                    return(false);
                }

                IFeature featureTarget = featureClass.GetFeature(nFeatureID);
                if (featureTarget == null)
                {
                    return(false);
                }

                ITopologicalOperator top = featureTarget.ShapeCopy as ITopologicalOperator;

                int      nID     = -1;
                IEnumIDs enumIDs = selectionSet.IDs;
                enumIDs.Reset();
                while ((nID = enumIDs.Next()) >= 0)
                {
                    if (nID == nFeatureID)
                    {
                        continue;
                    }
                    IFeature feature = featureClass.GetFeature(nID);
                    top = top.Union(feature.Shape) as ITopologicalOperator;
                }
                featureTarget.Shape = top as IGeometry;
                featureTarget.Store();

                //删除其余要素
                enumIDs.Reset();
                while ((nID = enumIDs.Next()) >= 0)
                {
                    if (nID == nFeatureID)
                    {
                        continue;
                    }
                    IFeature feature = featureClass.GetFeature(nID);
                    feature.Delete();
                }

                pEngineEdit.StopOperation("Merge features");
                return(true);
            }
            catch (System.Exception ex)
            {
                pEngineEdit.AbortOperation();
            }

            return(false);
        }
Beispiel #25
0
 public void OnDblClick()
 {
     Editor.UniqueInstance.CheckOverlap = false;
     try
     {
         IFeatureLayer targetLayer = Editor.UniqueInstance.TargetLayer;
         object        missing     = Type.Missing;
         if (!this.m_IsUsed || (this.m_LineFeedback == null))
         {
             return;
         }
         if (this.m_Step > 1)
         {
             IPolyline polyline = this.m_LineFeedback.Stop();
             if (polyline == null)
             {
                 this.Init();
                 return;
             }
             IFeatureClass featureClass = targetLayer.FeatureClass;
             if (featureClass == null)
             {
                 this.Init();
                 return;
             }
             IGeoDataset dataset = featureClass as IGeoDataset;
             if (polyline.SpatialReference != dataset.SpatialReference)
             {
                 polyline.Project(dataset.SpatialReference);
                 polyline.SpatialReference = dataset.SpatialReference;
             }
             IGeometry        inGeometry = polyline;
             GeometryBagClass lineSrc    = new GeometryBagClass();
             lineSrc.AddGeometry(inGeometry, ref missing, ref missing);
             targetLayer.Selectable = true;
             IDataset             dataset2           = featureClass as IDataset;
             IWorkspace           selectionWorkspace = dataset2.Workspace;
             IEnvelope            extent             = dataset.Extent;
             IInvalidArea         invalidArea        = new InvalidAreaClass();
             IFeatureConstruction construction       = new FeatureConstructionClass();
             IFeatureSelection    selection          = targetLayer as IFeatureSelection;
             ISelectionSet        selectionSet       = selection.SelectionSet;
             Editor.UniqueInstance.SetArea = false;
             Editor.UniqueInstance.StartEditOperation();
             ISpatialReferenceTolerance spatialReference = (ISpatialReferenceTolerance)dataset.SpatialReference;
             construction.AutoCompleteFromGeometries(featureClass, extent, lineSrc, invalidArea, spatialReference.XYTolerance, selectionWorkspace, out selectionSet);
             if ((selectionSet == null) || (selectionSet.Count < 1))
             {
                 Editor.UniqueInstance.AbortEditOperation();
             }
             else
             {
                 List <IFeature> pFeatureList = new List <IFeature>();
                 IEnumIDs        iDs          = selectionSet.IDs;
                 iDs.Reset();
                 for (int i = iDs.Next(); i >= 0; i = iDs.Next())
                 {
                     IFeature pFeature = featureClass.GetFeature(i);
                     FeatureFuncs.SetFeatureArea(pFeature);
                     pFeatureList.Add(pFeature);
                 }
                 if (selectionSet.Count == 1)
                 {
                     IFeature feature = pFeatureList[0];
                     selection.Clear();
                     selection.Add(feature);
                     AttributeManager.AttributeAddHandleClass.AttributeAdd(ref feature);
                 }
                 else
                 {
                     AttributeManager.AttributeSplitHandleClass.AttributeSplit(null, ref pFeatureList);
                 }
                 Editor.UniqueInstance.StopEditOperation("AutoComplete");
             }
             Editor.UniqueInstance.SetArea = true;
             this.m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection | esriViewDrawPhase.esriViewGeography, null, this.m_hookHelper.ActiveView.Extent);
         }
     }
     catch (Exception exception)
     {
         this.mErrOpt.ErrorOperate(this.mSubSysName, "ShapeEdit.AutoComplete", "OnDblClick", exception.GetHashCode().ToString(), exception.Source, exception.Message, "", "", "");
     }
     this.Init();
     Editor.UniqueInstance.CheckOverlap = true;
 }
Beispiel #26
0
        /// <summary>
        ///     The main method for resolving conflicts for all of the rows for the <paramref name="conflictClass" />
        ///     that have the conflict type matching the <paramref name="conflictType" /> enumeration.
        /// </summary>
        /// <param name="conflictClass">The class that has the conflicts.</param>
        /// <param name="currentTable">The table in the current version.</param>
        /// <param name="preReconcileTable">The table prior to reconciliation.</param>
        /// <param name="reconcileTable">The table that the current version is reconciling against.</param>
        /// <param name="commonAncestorTable">The common ancestor table of this version and the reconcile version.</param>
        /// <param name="conflictType">Type of the conflict.</param>
        /// <param name="filters">The conflict filters.</param>
        /// <returns>
        ///     A boolean indicating if all conflicts have been resolved.
        /// </returns>
        protected bool ResolveConflicts(IConflictClass conflictClass, ITable currentTable, ITable preReconcileTable, ITable reconcileTable, ITable commonAncestorTable, TableConflictType conflictType, IEnumerable <IConflictFilter> filters)
        {
            ISelectionSet set = this.GetConflictSet(conflictClass, conflictType);

            if (set == null)
            {
                return(false);
            }

            string tableName = ((IDataset)conflictClass).Name;

            Log.Info("Resolving the '{0}' type of conflicts for {1} row(s) in the {2} class.", conflictType, set.Count, tableName);

            var list = filters.Where(o => o.CanResolve(conflictType, conflictClass)).ToArray();

            if (list.Length == 0)
            {
                Log.Warn("There's no conflict filters available that support the conflict type of {0} for the {1} class.", conflictType, tableName);
                return(false);
            }

            FieldsEqualityComparer equalityComparer = new FieldsEqualityComparer();
            List <IConflictRow>    rows             = new List <IConflictRow>();
            IEnumIDs enumIDs = set.IDs;

            enumIDs.Reset();

            int oid;

            while ((oid = enumIDs.Next()) != -1)
            {
                using (ComReleaser cr = new ComReleaser())
                {
                    // The row from the edited (current) version.
                    IRow currentRow = currentTable.Fetch(oid);
                    cr.ManageLifetime(currentRow);

                    // The row from the edit (child) version.
                    IRow preReconcileRow = preReconcileTable.Fetch(oid);
                    cr.ManageLifetime(preReconcileRow);

                    // The row from the target (parent) version.
                    IRow reconcileRow = reconcileTable.Fetch(oid);
                    cr.ManageLifetime(reconcileRow);

                    // The row from the common ancestor (as is in the database) version.
                    IRow commonAncestorRow = commonAncestorTable.Fetch(oid);
                    cr.ManageLifetime(commonAncestorRow);

                    // Determine the row conflict type at a granular level.
                    RowConflictType rowConflictType = this.GetRowConflictType(preReconcileRow, reconcileRow, commonAncestorRow, equalityComparer);
                    Log.Info("Resolving the '{0}' conflict type for the {1} row using {2} filter(s).", rowConflictType, oid, list.Length);

                    // Use the filters to "attempt" to resolve the conflicts.
                    IConflictRow conflictRow = new ConflictRow(oid, tableName, rowConflictType);
                    foreach (var filter in list.OrderBy(o => o.Priority))
                    {
                        conflictRow.Resolution = filter.Resolve(conflictRow, conflictClass, currentRow, preReconcileRow, reconcileRow, commonAncestorRow, this.ChildWins, this.ColumnLevel);
                    }

                    Log.Info("The resolution of the {0} row has been marked as '{1}'.", oid, conflictRow.Resolution);

                    // Save the changes when a resolution was determined.
                    if (conflictRow.Resolution != ConflictResolution.None)
                    {
                        this.SaveAndRebuild(currentRow);
                    }

                    // Add to the list of rows.
                    rows.Add(conflictRow);
                }
            }

            // Add the rows to the extension collection.
            this.Rows.AddRange(rows);

            // Remove the OIDs of the conflicts that have been resolved.
            int[] oids = rows.Where(o => o.Resolution != ConflictResolution.None).Select(o => o.OID).ToArray();
            if (this.IsRemovedAfterResolved)
            {
                // ESRI states that the RemoveList method on the ISelectionSet should not used from .NET. Instead, call IGeoDatabaseBridge2.RemoveList.
                set.Remove(oids);
            }

            // Output the statistics for the conflicts.
            int remainder = rows.Count - oids.Length;

            Log.Info("{0} of the {1} row(s) have been resolved and {2} remain in conflict.", oids.Length, rows.Count, remainder);

            // Return true when all of the conflicts have been resolved.
            return(remainder == 0);
        }
Beispiel #27
0
        /// <summary>
        /// 获取选择的要素
        /// </summary>
        /// <param name="pMap">地图</param>
        /// <param name="pFeaType">要素类型:参照要素、目标要素</param>
        /// <param name="pError">异常</param>
        /// <returns>返回选中的要素</returns>
        public static IFeature getFea(IMap pMap, EnumFeatureType pFeaType, out Exception pError)
        {
            pError = null;        //异常
            IFeature pFea = null; //用来保存返回的要素

            //必须要选择要素
            if (pMap.SelectionCount == 0)
            {
                pError = new Exception("请选择一个需要更新的要素");
                return(null);
            }
            if (pMap.SelectionCount > 1)
            {
                pError = new Exception("请只选择一个参照要素!");
                return(null);
            }
            //遍历控件上的所有图层
            for (int i = 0; i < pMap.LayerCount; i++)
            {
                //ILayer pLayer = pMap.get_Layer(i);
                //if (pLayer is IGroupLayer)
                //{
                //}
                //获得图层
                IFeatureLayer pFeaLayer = pMap.get_Layer(i) as IFeatureLayer;
                if (pFeaLayer == null)
                {
                    return(null);
                }
                //获得图层的选择集
                IFeatureSelection pFeaSelection = pFeaLayer as IFeatureSelection;
                if (pFeaSelection == null)
                {
                    continue;
                }
                ISelectionSet pSelectionSet = pFeaSelection.SelectionSet;
                if (pSelectionSet == null)
                {
                    continue;
                }
                if (pSelectionSet.Count == 0)
                {
                    continue;
                }
                IEnumIDs pEnumIDs = pSelectionSet.IDs;
                pEnumIDs.Reset();
                int pOID = pEnumIDs.Next();

                if (pOID != -1)
                {
                    //若存在选择集

                    //图层对应的要素类
                    IFeatureClass pFeaCls = pFeaLayer.FeatureClass;
                    if (pFeaCls == null)
                    {
                        return(null);
                    }
                    //获得选择的要素
                    pFea = pFeaCls.GetFeature(pOID);
                    if (pFea == null)
                    {
                        if (pFeaType == EnumFeatureType.参照要素)
                        {
                            pError = new Exception("获取参照要素失败!");
                            return(null);
                        }
                        else if (pFeaType == EnumFeatureType.更新要素)
                        {
                            pError = new Exception("获取更新要素失败!");
                            return(null);
                        }
                    }
                }
                break;
            }
            return(pFea);
        }
Beispiel #28
0
        //<CSCM>
        //********************************************************************************
        //** 函 数 名: InsertFeatIntoFeatClsByEnumIDs
        //** 版    权: CopyRight (C)
        //** 创 建 人: 杨旭斌
        //** 功能描述: 把EnumIDs中的要素插入到目标要素类中
        //** 创建日期:
        //** 修 改 人:
        //** 修改日期:
        //** 修改时间:20070818
        //** 参数列表: pDesFeatCls (IFeatureClass)
        //             pEnumIDs (IEnumIDs)
        //             pOriFeatCls "原要素类(把该要素类中的要素插入到目标要素类中)
        //** 版    本:1.0
        //*********************************************************************************
        //</CSCM>
        public static long InsertFeatIntoFeatClsByEnumIDs(ref IFeatureClass pDesFeatCls, ref IFeatureClass pOriFeatCls, ref IEnumIDs pEnumIDs, bool bIsCut, IGeometry pDomainGeometry, ref ISpatialReference pSpatialReference, ref Dictionary <string, string> pDicField, ref ProgressBar vProgressBar)
        {
            //bIsCut = false;
            //pDomainGeometry = null;
            //pSpatialReference = null;
            //pDicField = null;
            //vProgressBar = null;

            long     functionReturnValue = 0;
            IFeature pFeat = default(IFeature);
            //要素类,用于循环
            IFeatureCursor pDesFeatCursor = default(IFeatureCursor);
            //用新建要素类的游标,使用该游标向新要素类中插入要素,并写入数据库
            IFeatureBuffer pDesFeatBuffer = default(IFeatureBuffer);
            //新建要素类创建的要素缓冲区,

            int       iFeatCount = 0;
            IGeometry pGeometry  = default(IGeometry);
            long      lID        = 0;
            //Dim pGeometryCol As ESRI.ArcGIS.Geometry.IGeometryCollection
            //Dim j As Integer
            //Dim pSubGeometry As ESRI.ArcGIS.Geometry.IGeometry
            //Dim pOriPntCol As ESRI.ArcGIS.Geometry.IPointCollection
            //Dim pPntCol As ESRI.ArcGIS.Geometry.IPointCollection
            IPoint                pPnt                  = default(IPoint);
            IGeometry             pDesGeometry          = default(IGeometry);
            esriGeometryDimension EnumGeometryDimension = default(esriGeometryDimension);

            // ERROR: Not supported in C#: OnErrorStatement

            if (pDomainGeometry == null)
            {
                bIsCut = false;
            }

            if (pDesFeatCls.ShapeType == esriGeometryType.esriGeometryPolyline)
            {
                EnumGeometryDimension = esriGeometryDimension.esriGeometry1Dimension;
            }
            else if (pDesFeatCls.ShapeType == esriGeometryType.esriGeometryPolygon)
            {
                EnumGeometryDimension = esriGeometryDimension.esriGeometry2Dimension;
            }
            else
            {
                bIsCut = false;
            }

            pEnumIDs.Reset();
            lID = pEnumIDs.Next();
            if (lID != -1)
            {
                //从新建要素类中获得新游标,用于插入新的要素
                pDesFeatCursor = pDesFeatCls.Insert(true);
                //创建要素缓冲区,和insert cursor 配合,创建新要素
                pDesFeatBuffer = pDesFeatCls.CreateFeatureBuffer();
            }
            else
            {
                return(functionReturnValue);
            }

            if (lID > -1)
            {
                while (lID > -1)
                {
                    pFeat     = pOriFeatCls.GetFeature((int)lID);
                    pGeometry = pFeat.ShapeCopy;
                    if ((pGeometry != null))
                    {
                        if (pGeometry.IsEmpty == false)
                        {
                            //进行剪切或不剪切
                            if (bIsCut)
                            {
                                pDesGeometry = ClsGeometryOperator.CutFeatByGeometry(ref pGeometry, ref pDomainGeometry, ref EnumGeometryDimension);
                            }
                            else
                            {
                                pDesGeometry = pGeometry;
                            }
                            InsertOneFeatIntoCursor(ref pFeat, pDesGeometry, ref pDesFeatCursor, ref pDesFeatBuffer, pSpatialReference, ref pDicField);
                        }
                    }
                    lID = pEnumIDs.Next();

                    //每一千个要素就把缓冲区内的要素类写入数据库
                    if (iFeatCount >= 1000)
                    {
                        pDesFeatCursor.Flush();
                        System.Windows.Forms.Application.DoEvents();
                        iFeatCount = 0;
                    }

                    if ((vProgressBar != null))
                    {
                        vProgressBar.Value = vProgressBar.Value + 1;
                    }
                }

                if (iFeatCount % 1000 != 0)
                {
                    pDesFeatCursor.Flush();
                }
            }
            if (vProgressBar != null)
            {
                vProgressBar.Value   = 0;
                vProgressBar.Visible = false;
            }
            pDesFeatCursor = null;
            pDesFeatBuffer = null;
            return(functionReturnValue);
        }
        public static Dictionary <string, ILongArray> GetOIDArraysBySourceNameFromMapSelection(IMap map, List <string> sourceNames)
        {
            UIDClass uid = new UIDClass();

            uid.Value = "{E156D7E5-22AF-11D3-9F99-00C04F6BC78E}";             //IGeoFeatureLayer

            IEnumLayer searchEnumLayer = map.get_Layers(uid, true);

            searchEnumLayer.Reset();

            //create result dictionary from source names with empty oidArrays

            Dictionary <string, ILongArray> oidArraysBySourceName = new Dictionary <string, ILongArray>();
            ILongArray oidArray = null;

            foreach (string sourceName in sourceNames)
            {
                if (!oidArraysBySourceName.TryGetValue(sourceName, out oidArray))
                {
                    oidArray = new LongArrayClass();
                    oidArraysBySourceName.Add(sourceName, oidArray);
                }
            }

            ILayer layer = searchEnumLayer.Next();

            while (layer != null)
            {
                IDisplayTable displayTable = layer as IDisplayTable;
                string        sourceName   = "";
                if (layer.Valid && layer.Visible && displayTable != null)
                {
                    IDataset ds = displayTable.DisplayTable as IDataset;
                    if (ds != null)
                    {
                        sourceName = ds.Name;
                    }
                }

                if (sourceName.Length > 0)
                {
                    if (oidArraysBySourceName.TryGetValue(sourceName, out oidArray))
                    {
                        ISelectionSet selSet   = displayTable.DisplaySelectionSet;
                        IEnumIDs      enumOIDs = null;
                        if (selSet != null)
                        {
                            enumOIDs = selSet.IDs;
                        }

                        if (enumOIDs != null)
                        {
                            enumOIDs.Reset();
                            int oid = enumOIDs.Next();
                            while (oid != -1)
                            {
                                oidArray.Add(oid);
                                oid = enumOIDs.Next();
                            }
                        }
                    }
                }

                layer = searchEnumLayer.Next();
            }

            return(oidArraysBySourceName);
        }
Beispiel #30
0
        public override void OnClick()
        {
            try
            {
                ITopologicalOperator2 @operator;
                List <IFeature>       list;
                IFeature          feature2;
                IFeatureSelection targetLayer = Editor.UniqueInstance.TargetLayer as IFeatureSelection;
                IEnumIDs          iDs         = targetLayer.SelectionSet.IDs;
                iDs.Reset();
                int iD = iDs.Next();
                if (iD != -1)
                {
                    IFeature feature = Editor.UniqueInstance.TargetLayer.FeatureClass.GetFeature(iD);
                    @operator = feature.Shape as ITopologicalOperator2;
                    @operator.IsKnownSimple_2 = false;
                    @operator.Simplify();
                    iD   = iDs.Next();
                    list = null;
                    if (iD != -1)
                    {
                        list = new List <IFeature> {
                            feature
                        };
                        goto Label_00F4;
                    }
                }
                return;

Label_0088:
                feature2 = Editor.UniqueInstance.TargetLayer.FeatureClass.GetFeature(iD);
                ITopologicalOperator2 shape = feature2.Shape as ITopologicalOperator2;
                shape.IsKnownSimple_2 = false;
                shape.Simplify();
                @operator = @operator.Union(feature2.Shape) as ITopologicalOperator2;
                @operator.IsKnownSimple_2 = false;
                @operator.Simplify();
                iD = iDs.Next();
                list.Add(feature2);
Label_00F4:
                if (iD != -1)
                {
                    goto Label_0088;
                }
                Editor.UniqueInstance.StartEditOperation();
                Editor.UniqueInstance.AddAttribute = false;
                IFeature resultFeature = Editor.UniqueInstance.TargetLayer.FeatureClass.CreateFeature();
                resultFeature.Shape = @operator as IGeometry;
                if (AttributeManager.AttributeCombineHandleClass.AttributeCombine(list, ref resultFeature) == DialogResult.OK)
                {
                    resultFeature.Store();
                    foreach (IFeature feature4 in list)
                    {
                        feature4.Delete();
                    }
                    targetLayer.Clear();
                    targetLayer.Add(resultFeature);
                }
                Editor.UniqueInstance.StopEditOperation("combine");
                this._hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection | esriViewDrawPhase.esriViewGeography, null, null);
            }
            catch (Exception exception)
            {
                Editor.UniqueInstance.AbortEditOperation();
                this._mErrOpt.ErrorOperate(this._mSubSysName, "ShapeEdit.Combine", "OnClick", exception.GetHashCode().ToString(), exception.Source, exception.Message, "", "", "");
            }
        }