private Boolean CreateDataset(NameEvents templateInfo)
        {
            try
            {
                IGxDatabase pDatabase = (IGxDatabase)m_SelectedObject;

                m_pWS = pDatabase.Workspace;

                ESRI.ArcGIS.Schematic.ISchematicWorkspaceFactory pSWF = new SchematicWorkspaceFactory();
                ESRI.ArcGIS.Schematic.ISchematicWorkspace        pSW  = pSWF.Open(m_pWS);
                //check to see if this dataset name is already used
                m_pSDS = pSW.get_SchematicDatasetByName(templateInfo.DatasetName.ToString());
                if (m_pSDS != null)
                {
                    return(false);
                }

                m_pSDS = pSW.CreateSchematicDataset(templateInfo.DatasetName, "");
                return(true);
            }
            catch
            {
                //nothing
                return(false);
            }
        }
        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);
        }