public static void FabricRowCreate(ESRI.ArcGIS.Geodatabase.IObject obj) { //if (InMemTableExistsForRow(obj)) //{ // // code for fabric row create here // string sOID = obj.OID.ToString(); // string sTable = obj.Class.AliasName; // MessageBox.Show("Fabric row created in table " + sTable + Environment.NewLine + // "OID: " + sOID); //} }
void Events_OnCreateFeature(ESRI.ArcGIS.Geodatabase.IObject obj) { //if (!UseExtension) // return; IFeature inFeature = null; try { inFeature = (IFeature)obj; } catch { return; } IFeatureClass fc = (IFeatureClass)inFeature.Class; int date_created_id = fc.Fields.FindField("DATE_CREATED"); if (date_created_id > -1) { try { inFeature.set_Value(date_created_id, DateTime.Now.ToString()); } catch (Exception ex) { System.Diagnostics.EventLog.WriteEntry("AddressingToolsEditExtension", ex.StackTrace, System.Diagnostics.EventLogEntryType.Error); } } if (fc.ShapeType == ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryLine || fc.ShapeType == ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolyline) { int clid = fc.Fields.FindField("CLID"); if (clid >= 0) { if (fc.Fields.get_Field(clid).Type == esriFieldType.esriFieldTypeInteger || fc.Fields.get_Field(clid).Type == esriFieldType.esriFieldTypeSmallInteger) { int newVal = getNextID(fc, clid, inFeature); inFeature.set_Value(clid, newVal); } } } if (fc.ShapeType == ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPoint) { int clid = fc.Fields.FindField("APID"); if (clid >= 0) { if (fc.Fields.get_Field(clid).Type == esriFieldType.esriFieldTypeSmallInteger || fc.Fields.get_Field(clid).Type == esriFieldType.esriFieldTypeInteger) { int newVal = getNextID(fc, clid, inFeature); inFeature.set_Value(clid, newVal); } } } }
public static void FabricRowChange(ESRI.ArcGIS.Geodatabase.IObject obj) { if (InMemTableExistsForRow(obj)) { // code for fabric row change here string sOID = obj.OID.ToString(); string sTable = obj.Class.AliasName; MessageBox.Show("Fabric row change in table " + sTable + Environment.NewLine + "OID: " + sOID); } }
private static bool InMemTableExistsForRow(ESRI.ArcGIS.Geodatabase.IObject obj) { if (_fabricInMemTablesLookUp == null) { return(false); } int iObjClassID = obj.Class.ObjectClassID; if (_fabricInMemTablesLookUp[iObjClassID] != null) { return(true); } else { return(false); } }
void Events_OnCreateChangeFeature(ESRI.ArcGIS.Geodatabase.IObject obj) { IFeature inFeature = (IFeature)obj; if (inFeature.Class is IValidation) { IValidate validate = (IValidate)inFeature; string errorMessage; //Validates connectivity rules, relationship rules, topology rules etc bool bIsvalid = validate.Validate(out errorMessage); if (!bIsvalid) { System.Windows.Forms.MessageBox.Show("Invalid Feature\n\n" + errorMessage); } else { System.Windows.Forms.MessageBox.Show("Valid Feature"); } } }
public static void FabricGeometryRowChange(ESRI.ArcGIS.Geodatabase.IObject obj) { if (obj is IFeature) { IFeatureChanges pFeatChanges = obj as IFeatureChanges; if (!pFeatChanges.ShapeChanged) { return; } if (pFeatChanges.OriginalShape.IsEmpty) //means new fabric parcel { return; } } if (InMemTableExistsForRow(obj)) { // code for fabric geometry change here MessageBox.Show("Fabric geometry change"); } }
protected override void editor_OnCreateFeature(ESRI.ArcGIS.Geodatabase.IObject obj) { ESRI.ArcGIS.Geodatabase.IFeature feature = obj as ESRI.ArcGIS.Geodatabase.IFeature; if (null != feature && null != feature.Class) { ESRI.ArcGIS.Geodatabase.IDataset dataset = (ESRI.ArcGIS.Geodatabase.IDataset)feature.Class; string tableName = GdbUtils.ParseTableName(dataset); if (ConfigUtil.IsDeviceClassName(tableName)) { if (InputPorts != Int32.MinValue && OutputPorts != Int32.MinValue) { try { ConfigureDevice(feature, InputPorts, OutputPorts, true); } catch (Exception ex) { _logHelper.addLogEntry(DateTime.Now.ToString(), "ERROR", "Failed to configure device.", ex.Message); string message = "Failed to configure device:" + System.Environment.NewLine + ex.Message; MessageBox.Show(message, "Configure Device", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { AbortOperation(); _logHelper.addLogEntry(DateTime.Now.ToString(), "ERROR", "Port counts are not set.", "Please specify a valid configuration of port settings."); string message = "Port counts are not set." + System.Environment.NewLine + "Please specify a valid configuration of port settings."; MessageBox.Show(message, "Configure Device", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } } }
/// <summary> /// Gets the count of related objects for a given object /// </summary> /// <param name="anObject">Object to check</param> /// <param name="relationshipClassName">Relationship class to check</param> /// <returns>int</returns> public static int GetRelatedObjectCount(ESRI.ArcGIS.Geodatabase.IObject anObject, string relationshipClassName) { int result = 0; if (null == anObject) { throw new ArgumentNullException("anObject"); } if (1 > relationshipClassName.Length) { throw new ArgumentException("relationshipClassName not specified."); } ESRI.ArcGIS.Geodatabase.IRelationshipClass relationshipClass = GetRelationshipClass(anObject.Class, relationshipClassName); if (null == relationshipClass) { throw new Exception(string.Format("Relationship class {0} could not be found.", relationshipClassName)); } ESRI.ArcGIS.esriSystem.ISet relatedObjects = relationshipClass.GetObjectsRelatedToObject(anObject); result = relatedObjects.Count; return(result); }
void OnDeleteFeature(ESRI.ArcGIS.Geodatabase.IObject obj) { // Don't do anything if the extension is disabled if (IsExtensionEnabled != true) { return; } // Bail if this is not a valid NCGMP workspace if (m_DatabaseIsValid == false) { return; } #region "Groundwork" // Grab the FeatureClass name from the Row's Table (as an IDataset). IRow theRow = obj; ITable theTable = theRow.Table; IDataset theDS = (IDataset)theTable; string TableName = theDS.Name; // Parse the table name in order to strip out unneccessary bits of SDE tables ISQLSyntax nameParser = (ISQLSyntax)theDS.Workspace; string parsedDbName, parsedOwnerName, parsedTableName; nameParser.ParseTableName(TableName, out parsedDbName, out parsedOwnerName, out parsedTableName); #endregion // #region "Delete Related Station Data" // if (parsedTableName == "Stations") // { // // Get the related information first, then prompt, then delete if that's what they want. // string stationName = (string)theRow.get_Value(theTable.FindField("FieldID")); // IRelationshipClass stationStructureLink = commonFunctions.OpenRelationshipClass(m_EditWorkspace, "StationOrientationPointsLink"); // IRelationshipClass stationSamplesLink = commonFunctions.OpenRelationshipClass(m_EditWorkspace, "StationSampleLink"); // IRelationshipClass stationNotesLink = commonFunctions.OpenRelationshipClass(m_EditWorkspace, "StationNotesLink"); // IRelationshipClass stationDocsLink = commonFunctions.OpenRelationshipClass(m_EditWorkspace, "StationDocumentLink"); // ESRI.ArcGIS.esriSystem.ISet structureSet = stationStructureLink.GetObjectsRelatedToObject(obj); // ESRI.ArcGIS.esriSystem.ISet sampleSet = stationSamplesLink.GetObjectsRelatedToObject(obj); // ESRI.ArcGIS.esriSystem.ISet noteSet = stationNotesLink.GetObjectsRelatedToObject(obj); // ESRI.ArcGIS.esriSystem.ISet docSet = stationDocsLink.GetObjectsRelatedToObject(obj); // string theMessage = ("Deleting Station " + stationName + " will also delete the following:"); // theMessage += Environment.NewLine; // theMessage += structureSet.Count.ToString() + " structural observations"; // theMessage += Environment.NewLine; // theMessage += sampleSet.Count.ToString() + " sample locations"; // theMessage += Environment.NewLine; // theMessage += noteSet.Count.ToString() + " recorded notes"; // theMessage += Environment.NewLine; // theMessage += docSet.Count.ToString() + " related document links"; // theMessage += Environment.NewLine; // theMessage += Environment.NewLine; // theMessage += "Are you sure you want to do this?"; // // Probably would be wise to warn them first... // System.Windows.Forms.DialogResult result = System.Windows.Forms.MessageBox.Show(theMessage, "NCGMP Tools", System.Windows.Forms.MessageBoxButtons.YesNo); // if (result == System.Windows.Forms.DialogResult.Yes) // { // IFeature theFeature = (IFeature)structureSet.Next(); // while (theFeature != null) // { // theFeature.Delete(); // theFeature = (IFeature)structureSet.Next(); // } // theFeature = (IFeature)sampleSet.Next(); // while (theFeature != null) // { // theFeature.Delete(); // theFeature = (IFeature)sampleSet.Next(); // } // theFeature = (IFeature)noteSet.Next(); // while (theFeature != null) // { // theFeature.Delete(); // theFeature = (IFeature)noteSet.Next(); // } // theFeature = (IFeature)docSet.Next(); // while (theFeature != null) // { // theFeature.Delete(); // theFeature = (IFeature)docSet.Next(); // } // } // } // #endregion }
void OnChangeFeature(ESRI.ArcGIS.Geodatabase.IObject obj) { // Don't do anything if the extension is disabled if (IsExtensionEnabled != true) { return; } // Bail if this is not a valid NCGMP workspace if (m_DatabaseIsValid == false) { return; } #region "Groundwork" // Grab the FeatureClass name from the Row's Table (as an IDataset). IRow theRow = obj; ITable theTable = theRow.Table; IDataset theDS = (IDataset)theTable; string TableName = theDS.Name; // Parse the table name in order to strip out unneccessary bits of SDE tables ISQLSyntax nameParser = (ISQLSyntax)theDS.Workspace; string parsedDbName, parsedOwnerName, parsedTableName; nameParser.ParseTableName(TableName, out parsedDbName, out parsedOwnerName, out parsedTableName); #endregion #region "Calculate SymbolRotation" if (m_DatabaseUsesRepresentation == true) { if (parsedTableName == "OrientationPoints") { // Get the Azimuth from the feature - this is ugly -- why is this m_identifier a double? int Azimuth = (int)Math.Round((double)theRow.get_Value(theTable.FindField("Azimuth")), 0); // Calculate the stupid form of rotation... int Rotation = CalculateSymbolRotation(Azimuth); // Set the SymbolRotation Field theRow.set_Value(theTable.FindField("SymbolRotation"), double.Parse(Rotation.ToString())); } } #endregion // Debugging flag to turn off repositioning of related data when stations are edited: bool adjustLocations = false; if (adjustLocations == true) { #region "Adjust Samples/OrientationPoints to Match Stations" if (parsedTableName == "Stations") { // Cast the obj as a Feature in order to access Geometry information IFeature theStation = (IFeature)obj; IGeometry stationGeom = theStation.ShapeCopy; // Find related Samples IRelationshipClass stationSampleLink = commonFunctions.OpenRelationshipClass(m_EditWorkspace, "StationSampleLink"); ESRI.ArcGIS.esriSystem.ISet relatedSamples = stationSampleLink.GetObjectsRelatedToObject(obj); // Loop through the related Samples and set their Geometry to that of the Station relatedSamples.Reset(); IFeature aSample = (IFeature)relatedSamples.Next(); while (aSample != null) { aSample.Shape = stationGeom; aSample.Store(); aSample = (IFeature)relatedSamples.Next(); } // Find related OrientationPoints IRelationshipClass stationStructureLink = commonFunctions.OpenRelationshipClass(m_EditWorkspace, "StationOrientationPointsLink"); ESRI.ArcGIS.esriSystem.ISet relatedStructures = stationStructureLink.GetObjectsRelatedToObject(obj); // Loop through the related OrientationPoints and set their Geometry to that of the Station relatedStructures.Reset(); IFeature aStructure = (IFeature)relatedStructures.Next(); while (aStructure != null) { aStructure.Shape = stationGeom; aStructure.Store(); aStructure = (IFeature)relatedStructures.Next(); } } #endregion } }
void OnCreateFeature(ESRI.ArcGIS.Geodatabase.IObject obj) { // Don't do anything if the extension is disabled if (IsExtensionEnabled != true) { return; } // Bail if this is not a valid NCGMP workspace if (m_DatabaseIsValid == false) { return; } #region "Groundwork" // Grab the FeatureClass name from the Row's Table (as an IDataset). IRow theRow = obj; ITable theTable = theRow.Table; IDataset theDS = (IDataset)theTable; string TableName = theDS.Name; // Parse the table name in order to strip out unneccessary bits of SDE tables ISQLSyntax nameParser = (ISQLSyntax)theDS.Workspace; string parsedDbName, parsedOwnerName, parsedTableName; nameParser.ParseTableName(TableName, out parsedDbName, out parsedOwnerName, out parsedTableName); #endregion #region "Set New ID" // Call the routine to get a new ID int id = m_SysInfo.GetNextIdValue(parsedTableName); // Set the new ID value on the row itself theRow.set_Value(theTable.FindField(parsedTableName + "_ID"), m_SysInfo.ProjAbbr + "." + parsedTableName + "." + id); #endregion #region "Calculate SymbolRotation" if (m_DatabaseUsesRepresentation == true) { if (parsedTableName == "OrientationPoints") { // Get the Azimuth from the feature int Azimuth; bool result = int.TryParse(theRow.get_Value(theTable.FindField("Azimuth")).ToString(), out Azimuth); // Calculate the stupid form of rotation... int Rotation = CalculateSymbolRotation(Azimuth); // Set the SymbolRotation Field theRow.set_Value(theTable.FindField("SymbolRotation"), double.Parse(Rotation.ToString())); } } #endregion #region "Set DataSource" // Bail if the new object is in fact a Data Source if (parsedTableName != "DataSources") { if (globalVariables.currentDataSource == null) { // I can warn the user that they should choose a data source, but I can't keep the feature from being created anyways System.Windows.Forms.MessageBox.Show("You have not selected a valid Data Source for this edit session." + Environment.NewLine + "Your feature was created without a Data Source.", "NCGMP Tools"); return; } else { // Set the DataSourceID value if (parsedTableName == "Glossary") { theRow.set_Value(theTable.FindField("DefinitionSourceID"), globalVariables.currentDataSource); } else if (parsedTableName == "DescriptionOfMapUnits") { theRow.set_Value(theTable.FindField("DescriptionSourceID"), globalVariables.currentDataSource); } else if (obj.get_Value(theTable.FindField("DataSourceID")).ToString() == "") { theRow.set_Value(theTable.FindField("DataSourceID"), globalVariables.currentDataSource); } } } #endregion }
internal void OnCreateFeature(ESRI.ArcGIS.Geodatabase.IObject obj) { throw new NotImplementedException(); }
private void m_editEvents_OnCreateFeature(ESRI.ArcGIS.Geodatabase.IObject obj) { // _logHelper.addLogEntry(DateTime.Now.ToString(), "INFO", "Creating feature."); sendEvent(obj as IObject, "OnCreate"); }
/// <summary> /// Method called when a feature is created. /// </summary> /// <param name="obj">The object that was created</param> public void Events_OnCreateFeature(ESRI.ArcGIS.Geodatabase.IObject obj) { if (EditorTrackHelper.extensionEnabled && trackingFields != null && obj != null) { ReplacementTemplate globaltemplates = trackingFields.TemplateOnCreateFields[Constants.GlobalName]; ReplacementTemplate featclasstemplates = null; if (trackingFields.TemplateOnCreateFields.ContainsKey((obj.Class as IDataset).Name)) { featclasstemplates = trackingFields.TemplateOnCreateFields[(obj.Class as IDataset).Name]; } if (globaltemplates != null && globaltemplates.FieldReplacements != null) { foreach (KeyValuePair <string, string> item in globaltemplates.FieldReplacements) { int i = obj.Fields.FindField(item.Key); if (i > -1) { object val = this.EvaluateValue(obj, item, trackingFields.ReplacementFieldDictionary); if (val != null) { if (val is byte[]) { IMemoryBlobStreamVariant memoryBlobStream = new MemoryBlobStreamClass(); memoryBlobStream.ImportFromVariant(val); obj.set_Value(i, memoryBlobStream); } else { obj.set_Value(i, val); } } } } } if (featclasstemplates != null && featclasstemplates.FieldReplacements != null) { foreach (KeyValuePair <string, string> item in featclasstemplates.FieldReplacements) { int i = obj.Fields.FindField(item.Key); if (i > -1) { object val = this.EvaluateValue(obj, item, trackingFields.ReplacementFieldDictionary); if (val != null) { if (val is byte[]) { IMemoryBlobStreamVariant memoryBlobStream = new MemoryBlobStreamClass(); memoryBlobStream.ImportFromVariant(val); obj.set_Value(i, memoryBlobStream); } else { obj.set_Value(i, val); } } } } } } }