public static void CreatePaletteSchemesTest(Document doc, MSCDataset dataset)
        {
            ToolPaletteManager manager = ToolPaletteManager.Manager;

            try
            {
                try
                {
                    if (manager.Catalogs.Count > 0)
                    {
                        manager.SaveCatalogs();
                    }
                }
                catch
                {
                }
                ToolPalette.InitializePaletteFolders();
                ToolPalette.IncludeFolderLocation(ToolPalette.GroupFolder);
                ToolPalette.CreatePaletteFile(doc, dataset);
                if (!ToolPalette.GroupExists(doc))
                {
                    ToolPalette.CreateGroup();
                }
                Scheme scheme = new Scheme("ArcGIS");
                scheme.LoadCatalogs();
                scheme.SaveCatalogs();
                manager.Schemes.Add("ArcGIS");
            }
            catch
            {
            }
        }
 public static void GenerateBlockImages(Document doc, MSCDataset dataset)
 {
     try
     {
         ToolPalette.InitializePaletteFolders();
         Database database = doc.Database;
         using (doc.LockDocument())
         {
             using (Transaction transaction = database.TransactionManager.StartTransaction())
             {
                 foreach (MSCFeatureService current in dataset.FeatureServices.Values)
                 {
                     if (!current.QueryOnly && current.GeometryType == MSCFeatureClass.fcTypeCode.fcTypePoint)
                     {
                         ObjectId blockDefinition = DocUtil.GetBlockDefinition(doc, current.LayerName);
                         if (!(blockDefinition == ObjectId.Null))
                         {
                             ToolPalette.CreateBlockImage(transaction, doc, ToolPalette.ImageFolder, blockDefinition);
                         }
                     }
                 }
                 transaction.Commit();
             }
         }
     }
     catch
     {
     }
 }
        public static void CreatePalette(Document doc, MSCDataset dataset)
        {
            ToolPaletteManager manager = ToolPaletteManager.Manager;

            try
            {
                try
                {
                    if (manager.Catalogs.Count > 0)
                    {
                        manager.SaveCatalogs();
                    }
                }
                catch
                {
                }
                ToolPalette.InitializePaletteFolders();
                ToolPalette.IncludeFolderLocation(ToolPalette.GroupFolder);
                ToolPalette.CreatePaletteFile(doc, dataset);
                if (!ToolPalette.GroupExists(doc))
                {
                    ToolPalette.CreateGroup();
                }
                if (manager.Catalogs.Count > 0)
                {
                    if (dataset.FeatureServices.Count != 0)
                    {
                        manager.LoadCatalogs();
                    }
                    else if (ToolPalette.PaletteVisible())
                    {
                        manager.LoadCatalogs();
                    }
                }
            }
            catch
            {
            }
        }
 private static void CreateEmptyPalette()
 {
     try
     {
         ToolPalette.InitializePaletteFolders();
         if (File.Exists(ToolPalette.fullPaletteFileName))
         {
             File.Delete(ToolPalette.fullPaletteFileName);
         }
         using (FileStream fileStream = new FileStream(ToolPalette.fullPaletteFileName, FileMode.Create))
         {
             using (StreamWriter streamWriter = new StreamWriter(fileStream))
             {
                 streamWriter.Write(tpResources.xmlEmptyPalette);
                 streamWriter.Close();
             }
         }
     }
     catch
     {
     }
 }
 private static void CreatePaletteFile(Document doc, MSCDataset dataset)
 {
     try
     {
         ToolPalette.InitializePaletteFolders();
         Database database = doc.Database;
         if (!dataset.HasFeatureServicesOpenedForEditing())
         {
             ToolPalette.CreateEmptyPalette();
         }
         else
         {
             bool flag = false;
             foreach (MSCFeatureService current in dataset.FeatureServices.Values)
             {
                 if (!current.QueryOnly)
                 {
                     flag = true;
                     break;
                 }
             }
             if (!flag)
             {
                 ToolPalette.CreateEmptyPalette();
             }
             else
             {
                 if (File.Exists(ToolPalette.fullPaletteFileName))
                 {
                     File.Delete(ToolPalette.fullPaletteFileName);
                 }
                 using (FileStream fileStream = new FileStream(ToolPalette.fullPaletteFileName, FileMode.Create))
                 {
                     using (StreamWriter streamWriter = new StreamWriter(fileStream))
                     {
                         streamWriter.Write(tpResources.xmlPaletteBeginning);
                         using (doc.LockDocument())
                         {
                             using (Transaction transaction = database.TransactionManager.StartTransaction())
                             {
                                 foreach (MSCFeatureService current2 in dataset.FeatureServices.Values)
                                 {
                                     if (!current2.QueryOnly)
                                     {
                                         if (current2.SubTypes.Count == 0)
                                         {
                                             ToolPalette.WriteTool(current2, current2.LayerName, streamWriter, doc, transaction);
                                         }
                                         foreach (MSCFeatureClassSubType current3 in current2.SubTypes)
                                         {
                                             ToolPalette.WriteTool(current3, current3.CadLayerName, streamWriter, doc, transaction);
                                         }
                                     }
                                 }
                                 transaction.Commit();
                             }
                             streamWriter.Write(tpResources.xmlPaletteClose);
                             streamWriter.Close();
                         }
                     }
                 }
             }
         }
     }
     catch
     {
     }
 }