private void UnSelectToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            if (item == null)
            {
                return;
            }
            IFeature pFeature = (IFeature)m_ArrayListFeatures[item.Index];
            ILayer   Layer    = (ILayer)m_ArrayListLayers[item.Index];

            IActiveView ActiveView = (IActiveView)m_Map;

            if (Layer == null || pFeature == null)
            {
                return;
            }

            IFeatureSelection FSelection = (IFeatureSelection)Layer;
            ISelectionSet     SSet       = FSelection.SelectionSet;

            //  Dim pSelectionEvents As ISelectionEvents
            SSet.RemoveList(1, pFeature.OID);
            //  pSelectionEvents = Map
            FSelection.SelectionChanged();
            ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
            // pSelectionEvents.SelectionChanged()
        }
Exemple #2
0
        private void bbiUnSelectFeature_ItemClick(object sender, ItemClickEventArgs e)
        {
            int[]             selectedRows = (this.gcFeatures.MainView as ColumnView).GetSelectedRows();
            IFeature          feature      = this._features[selectedRows[0]];
            IFeatureSelection selection    = (IFeatureSelection)this._layer;
            ISelectionSet     selectionSet = selection.SelectionSet;
            int oID = feature.OID;

            selectionSet.RemoveList(1, ref oID);
            this._hook.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, this._hook.ActiveView.Extent);
        }
 /// <summary>
 /// Removes the feature from a selection set.
 /// </summary>
 /// <param name="feature">The feature to remove from the selection set.</param>
 /// <param name="selSet">The selection set from which to remove the feature.</param>
 public static void RemoveFeatureFromSelection(IFeature feature, ISelectionSet selSet)
 {
     int oid = feature.OID;
     selSet.RemoveList(1, ref oid);
 }
 /// <summary>
 /// Pseudocode:
 /// - Loop through all conflicts classes after the reconcile.
 /// - Loop through every UpdateUpdate conflict on the class.
 /// - Determine if geometry is in conflict on the feature.
 /// - If so, merge geometries together (handling errors) and store the feature.
 /// </summary>
 public void OnConflictsDetected(ref bool conflictsRemoved, ref bool errorOccurred, ref string errorString)
 {
     try
     {
         IVersionEdit4 versionEdit4 = (IVersionEdit4)featureWorkspace;
         // Get the various versions on which to output information.
         IFeatureWorkspace commonAncestorFWorkspace = (IFeatureWorkspace)
                                                      versionEdit4.CommonAncestorVersion;
         IFeatureWorkspace preReconcileFWorkspace = (IFeatureWorkspace)
                                                    versionEdit4.PreReconcileVersion;
         IFeatureWorkspace reconcileFWorkspace = (IFeatureWorkspace)
                                                 versionEdit4.ReconcileVersion;
         IEnumConflictClass enumConflictClass = versionEdit4.ConflictClasses;
         IConflictClass     conflictClass     = null;
         while ((conflictClass = enumConflictClass.Next()) != null)
         {
             IDataset dataset = (IDataset)conflictClass;
             // Make sure class is a feature class.
             if (dataset.Type == esriDatasetType.esriDTFeatureClass)
             {
                 String        datasetName  = dataset.Name;
                 IFeatureClass featureClass = featureWorkspace.OpenFeatureClass
                                                  (datasetName);
                 Console.WriteLine("Conflicts on feature class {0}", datasetName);
                 // Get all UpdateUpdate conflicts.
                 ISelectionSet updateUpdates = conflictClass.UpdateUpdates;
                 if (updateUpdates.Count > 0)
                 {
                     // Get conflict feature classes on the three reconcile versions.
                     IFeatureClass featureClassPreReconcile =
                         preReconcileFWorkspace.OpenFeatureClass(datasetName);
                     IFeatureClass featureClassReconcile =
                         reconcileFWorkspace.OpenFeatureClass(datasetName);
                     IFeatureClass featureClassCommonAncestor =
                         commonAncestorFWorkspace.OpenFeatureClass(datasetName);
                     // Iterate through each OID, outputting information.
                     IEnumIDs enumIDs = updateUpdates.IDs;
                     int      oid     = -1;
                     while ((oid = enumIDs.Next()) != -1)
                     //loop through all conflicting features
                     {
                         Console.WriteLine("UpdateUpdate conflicts on feature {0}", oid);
                         // Get conflict feature on the three reconcile versions.
                         IFeature featurePreReconcile =
                             featureClassPreReconcile.GetFeature(oid);
                         IFeature featureReconcile      = featureClassReconcile.GetFeature(oid);
                         IFeature featureCommonAncestor =
                             featureClassCommonAncestor.GetFeature(oid);
                         // Check to make sure each shape is different than the common ancestor (conflict is on shape field).
                         if (IsShapeInConflict(featureCommonAncestor, featurePreReconcile,
                                               featureReconcile))
                         {
                             Console.WriteLine(
                                 " Shape attribute has changed on both versions...");
                             // Geometries are in conflict ... merge geometries.
                             try
                             {
                                 IConstructMerge constructMerge = new GeometryEnvironmentClass
                                                                      ();
                                 IGeometry newGeometry = constructMerge.MergeGeometries
                                                             (featureCommonAncestor.ShapeCopy,
                                                             featureReconcile.ShapeCopy, featurePreReconcile.ShapeCopy);
                                 // Setting new geometry as a merge between the two versions.
                                 IFeature feature = featureClass.GetFeature(oid);
                                 feature.Shape = newGeometry;
                                 feature.Store();
                                 updateUpdates.RemoveList(1, ref oid);
                                 conflictsRemoved = true;
                             }
                             catch (Exception eError) //COMException comExc
                             {
                                 //******************************************
                                 //guozheng added System Exception log
                                 if (SysCommon.Log.Module.SysLog == null)
                                 {
                                     SysCommon.Log.Module.SysLog = new SysCommon.Log.clsWriteSystemFunctionLog();
                                 }
                                 SysCommon.Log.Module.SysLog.Write(eError);
                                 //******************************************
                                 //// Check if the error is from overlapping edits.
                                 //if (comExc.ErrorCode == (int)
                                 //  fdoError.FDO_E_WORKSPACE_EXTENSION_DATASET_CREATE_FAILED ||
                                 //  comExc.ErrorCode == (int)
                                 //  fdoError.FDO_E_WORKSPACE_EXTENSION_DATASET_DELETE_FAILED)
                                 //{
                                 //    // Edited areas overlap.
                                 //    Console.WriteLine(
                                 //      "Error from overlapping edits on feature {0}", oid);
                                 //    Console.WriteLine(" Error Message: {0}", comExc.Message);
                                 //    Console.WriteLine(
                                 //      " Can't merge overlapping edits to same feature.");
                                 //}
                                 //else
                                 //{
                                 //    // Unexpected COM exception throw this to exception handler.
                                 //    throw comExc;
                                 //}
                             }
                         }
                         else
                         {
                             Console.WriteLine(
                                 " Shape field not in conflict: merge not necessary ... ");
                         }
                     }
                 }
             }
         }
     }
     catch (Exception eError)
     {
         //******************************************
         //guozheng added System Exception log
         if (SysCommon.Log.Module.SysLog == null)
         {
             SysCommon.Log.Module.SysLog = new SysCommon.Log.clsWriteSystemFunctionLog();
         }
         SysCommon.Log.Module.SysLog.Write(eError);
         //******************************************
         //Console.WriteLine("Error Message: {0}, Error Code: {1}", comExc.Message,
         //  comExc.ErrorCode);
     }
     //catch (Exception exc)
     //{
     //    Console.WriteLine("Unhandled Exception: {0}", exc.Message);
     //}
 }