private Boolean CreateTemplate(NameEvents templateInfo) { //need to get everything first IGxDatabase pDatabase = null; ISchematicDiagramClassContainer pDiagramClassContainer = null; if (m_SelectedObject.Category == "Schematic Dataset") { pDatabase = (IGxDatabase)m_SelectedObject.Parent; } else //on the database already { pDatabase = (IGxDatabase)m_SelectedObject; } m_pWS = pDatabase.Workspace; ESRI.ArcGIS.Schematic.ISchematicWorkspaceFactory pSWF = new SchematicWorkspaceFactory(); ESRI.ArcGIS.Schematic.ISchematicWorkspace pSW = pSWF.Open(m_pWS); m_pSDS = pSW.get_SchematicDatasetByName(templateInfo.DatasetName); //check to see if the template name already exists pDiagramClassContainer = (ISchematicDiagramClassContainer)m_pSDS; m_pSDT = pDiagramClassContainer.GetSchematicDiagramClass(templateInfo.TemplateName.ToString()); if (m_pSDT != null) { return(false); } //create the schematic template m_pSDT = m_pSDS.CreateSchematicDiagramClass(templateInfo.TemplateName); if ((templateInfo.AutoCreate == true) || (templateInfo.UseVertices == true)) { m_pB = (ESRI.ArcGIS.Schematic.ISchematicBuilder)m_pSDT; m_pSB = (ESRI.ArcGIS.Schematic.ISchematicStandardBuilder)m_pSDT.SchematicBuilder; m_pSB.InitializeLinksVertices = templateInfo.UseVertices; m_pSB.AutoCreateElementClasses = templateInfo.AutoCreate; } m_pSDS.Save(ESRI.ArcGIS.esriSystem.esriArcGISVersion.esriArcGISVersion10, false); return(true); }
private Boolean CreateTemplate(NameEvents templateInfo) { //need to get everything first IGxDatabase pDatabase = null; ISchematicDiagramClassContainer pDiagramClassContainer = null; if (m_SelectedObject.Category == "Schematic Dataset") { pDatabase = (IGxDatabase)m_SelectedObject.Parent; } else //on the database already { pDatabase = (IGxDatabase)m_SelectedObject; } m_pWS = pDatabase.Workspace; ESRI.ArcGIS.Schematic.ISchematicWorkspaceFactory pSWF = new SchematicWorkspaceFactory(); ESRI.ArcGIS.Schematic.ISchematicWorkspace pSW = pSWF.Open(m_pWS); m_pSDS = pSW.get_SchematicDatasetByName(templateInfo.DatasetName); //check to see if the template name already exists pDiagramClassContainer = (ISchematicDiagramClassContainer)m_pSDS; m_pSDT = pDiagramClassContainer.GetSchematicDiagramClass(templateInfo.TemplateName.ToString()); if (m_pSDT != null) return false; //create the schematic template m_pSDT = m_pSDS.CreateSchematicDiagramClass(templateInfo.TemplateName); if ((templateInfo.AutoCreate == true) || (templateInfo.UseVertices == true)) { m_pB = (ESRI.ArcGIS.Schematic.ISchematicBuilder)m_pSDT; m_pSB = (ESRI.ArcGIS.Schematic.ISchematicStandardBuilder)m_pSDT.SchematicBuilder; m_pSB.InitializeLinksVertices = templateInfo.UseVertices; m_pSB.AutoCreateElementClasses = templateInfo.AutoCreate; } m_pSDS.Save(ESRI.ArcGIS.esriSystem.esriArcGISVersion.esriArcGISVersion10, false); return true; }
private string CreateSchLayers(IEnumLayer pLayers) { if (pLayers == null) { return(""); } ILayer pLayer = pLayers.Next(); IFeatureLayer featureLayer; IFeatureClass featureClass; string pStrLayerNames = ""; IDataset pDataset; System.Windows.Forms.Cursor.Current = Cursors.WaitCursor; System.Windows.Forms.Cursor.Show(); m_pSDS.DesignMode = true; m_pSDI = (ESRI.ArcGIS.Schematic.ISchematicDatasetImport)m_pSDS; Dictionary <string, IFeatureClass> myDictionary = new Dictionary <string, IFeatureClass>(); IGeometricNetwork gn = null; do { featureLayer = (IFeatureLayer)pLayer; featureClass = featureLayer.FeatureClass; pDataset = (IDataset)featureClass; if (featureClass.FeatureType == esriFeatureType.esriFTSimpleJunction || featureClass.FeatureType == esriFeatureType.esriFTSimpleEdge || featureClass.FeatureType == esriFeatureType.esriFTComplexEdge || featureClass.FeatureType == esriFeatureType.esriFTComplexJunction) { //The FeatureType property of feature classes that implement this interface will be esriFTSimpleJunction, esriDTSimpleEdge, esriFTComplexJunction, or esriFTComplexEdge. INetworkClass networkClass = (INetworkClass)featureLayer.FeatureClass; if (networkClass.GeometricNetwork != null) { //we have a network class if ((gn == null) || (gn != networkClass.GeometricNetwork)) { //need to process all the classes Dictionary <string, IFeatureClass> localDictionary = new Dictionary <string, IFeatureClass>(); gn = networkClass.GeometricNetwork; IEnumFeatureClass fcComplexEdge = networkClass.GeometricNetwork.get_ClassesByType(esriFeatureType.esriFTComplexEdge); IEnumFeatureClass fcComplexNode = networkClass.GeometricNetwork.get_ClassesByType(esriFeatureType.esriFTComplexJunction); IEnumFeatureClass fcSimpleEdge = networkClass.GeometricNetwork.get_ClassesByType(esriFeatureType.esriFTSimpleEdge); IEnumFeatureClass fcSimpleNode = networkClass.GeometricNetwork.get_ClassesByType(esriFeatureType.esriFTSimpleJunction); localDictionary = ProcessFCs(fcComplexEdge, fcComplexNode, fcSimpleEdge, fcSimpleNode); if (myDictionary.Count == 0) //just copy it { myDictionary = localDictionary; } else //merge { Dictionary <string, IFeatureClass> .KeyCollection keyColl = localDictionary.Keys; foreach (string s in keyColl) { IFeatureClass fc; bool bln = localDictionary.TryGetValue(s, out fc); myDictionary.Add(s, fc); } } } //Build up the string that will go to the select items to reduce form pStrLayerNames += pDataset.Name.ToString(); pStrLayerNames += ";"; //Build up the string for just the node feature classes if (featureClass.FeatureType == esriFeatureType.esriFTSimpleJunction || featureClass.FeatureType == esriFeatureType.esriFTComplexJunction) { strNodeLayers += pDataset.Name.ToString(); strNodeLayers += ";"; } //create the fields collections to be used by the frmAdvanced form IFields pFields = featureClass.Fields; if (pFields.FieldCount > 0) { for (int i = 0; i < pFields.FieldCount; i++) { //don't mess with objectid or shape or GlobalID if ((pFields.get_Field(i).Name.ToString() != "OBJECTID") && (pFields.get_Field(i).Name.ToString() != "SHAPE") && (pFields.get_Field(i).Name.ToString() != "GlobalID") && (pFields.get_Field(i).Name.ToString() != featureClass.OIDFieldName.ToString()) && (pFields.get_Field(i).Name.ToString() != featureClass.ShapeFieldName.ToString())) { m_myCol.Add(pDataset.Name.ToString(), pFields.get_Field(i).Name.ToString()); } } } //remove the layer from the list of dictionary classes if (myDictionary.ContainsKey(featureClass.AliasName)) { myDictionary.Remove(featureClass.AliasName); } m_pSDI.ImportFeatureLayer(featureLayer, m_pSDT, true, true, true); } } pLayer = pLayers.Next(); } while (pLayer != null); //handle any feature classes that were not in the map if (myDictionary.Count > 0) { Dictionary <string, IFeatureClass> .KeyCollection keyColl = myDictionary.Keys; foreach (string s in keyColl) { IFeatureClass fc; bool bln = myDictionary.TryGetValue(s, out fc); IObjectClass o = (IObjectClass)fc; pDataset = (IDataset)fc; pStrLayerNames += pDataset.Name.ToString(); pStrLayerNames += ";"; //Build up the string for just the node feature classes if (fc.FeatureType == esriFeatureType.esriFTSimpleJunction || featureClass.FeatureType == esriFeatureType.esriFTComplexJunction) { strNodeLayers += pDataset.Name.ToString(); strNodeLayers += ";"; } //create the fields collections to be used by the frmAdvanced form IFields pFields = fc.Fields; if (pFields.FieldCount > 0) { for (int i = 0; i < pFields.FieldCount; i++) { //don't mess with objectid or shape or GlobalID if ((pFields.get_Field(i).Name.ToString() != "OBJECTID") && (pFields.get_Field(i).Name.ToString() != "SHAPE") && (pFields.get_Field(i).Name.ToString() != "GlobalID") && (pFields.get_Field(i).Name.ToString() != fc.OIDFieldName.ToString()) && (pFields.get_Field(i).Name.ToString() != fc.ShapeFieldName.ToString())) { m_myCol.Add(pDataset.Name.ToString(), pFields.get_Field(i).Name.ToString()); } } } if ((fc.FeatureType == esriFeatureType.esriFTComplexJunction) || (fc.FeatureType == esriFeatureType.esriFTSimpleJunction)) { //node m_pSDI.ImportObjectClass(o, m_pSDT, true, esriSchematicElementType.esriSchematicNodeType); } else { //link m_pSDI.ImportObjectClass(o, m_pSDT, true, esriSchematicElementType.esriSchematicLinkType); } } } m_pSDS.Save(ESRI.ArcGIS.esriSystem.esriArcGISVersion.esriArcGISVersionCurrent, true); m_pSDS.DesignMode = false; return(pStrLayerNames); }