- /* © Andrey Bushman, 2013 
-  * AutoCAD 2014 x64 SP1 
-  * The sample, how to save the some settings of your custom controls into the AWS file. 
-  * I showed the feature of the "IConfigurationSection.Save" event's registration. 
-  */ 
-   
- using System; 
- using Microsoft.Win32; 
-   
- using cad = Autodesk.AutoCAD.ApplicationServices.Application; 
- using App = Autodesk.AutoCAD.ApplicationServices; 
- using Db = Autodesk.AutoCAD.DatabaseServices; 
- using Ed = Autodesk.AutoCAD.EditorInput; 
- using Rtm = Autodesk.AutoCAD.Runtime; 
- using Win = Autodesk.AutoCAD.Windows; 
-   
- [assembly: Rtm.CommandClass(typeof(Bushman.CAD.Problems.Commands))] 
-   
- namespace Bushman.CAD.Problems { 
-   
-         public class Commands { 
-   
-                 [Rtm.CommandMethod("cmd_4", Rtm.CommandFlags.Modal)] 
-                 public void Command_4() { 
-                         Ed.Editor ed = cad.DocumentManager.MdiActiveDocument.Editor; 
-   
-                         // This settings will be saved into the  
-                         // %AppData%\Autodesk\AutoCAD 2014\R19.1\enu\Support\Profiles\Unnamed Profile\Profile.aws 
-                         // if the current profile is <<Unnamed Profile>>. 
-                         Win.PaletteSet palette_set = new Win.PaletteSet("My Palette", 
-                                 new Guid("{49DBC66F-21BE-4D9F-A5A9-BA750543042E}")); 
-                         palette_set.Load += new Win.PalettePersistEventHandler(palette_set_Load); 
-                         palette_set.Save += new Win.PalettePersistEventHandler(palette_set_Save); 
-   
-                         // WARNING! If you will comment the next code line, the 'Save' event not occurs! 
-                         // I think it is a bug of API. 
-                         palette_set.Saving += new Win.PalettePersistEventHandler(palette_set_Saving); 
-   
-                         palette_set.KeepFocus = true; 
-                         palette_set.Visible = true; 
-                 } 
-   
-                 void palette_set_Save(object sender, Win.PalettePersistEventArgs e) { 
-                         palette_set_Save(e.ConfigurationSection); 
-                 } 
-   
-                 void palette_set_Saving(object sender, Win.PalettePersistEventArgs e) { 
-                         // The empty implementation... 
-                 } 
-   
-                 // This names can't to contain the spaces (it will used as the xml  
-                 // element's and attribute's names)! 
-                 const String name = "AAA"; 
-                 const String name2 = "BBB"; 
-                 const String val_1_name = "Value_1"; 
-                 const String val_2_name = "Value_2"; 
-   
-                 void palette_set_Load(object sender, Win.PalettePersistEventArgs e) { 
-                         App.IConfigurationSection section = e.ConfigurationSection; 
-                         App.IConfigurationSection subsection = null; 
-                         App.IConfigurationSection subsection2 = null; 
-   
-                         if (!section.IsReadOnly) { 
-                                 Boolean n = section.ContainsSubsection(name); 
-                                 if (n) 
-                                         subsection = section.OpenSubsection(name); 
-                                 else 
-                                         subsection = section.CreateSubsection(name); 
-   
-                                 if (!subsection.IsReadOnly) { 
-                                         Boolean b = subsection.ContainsSubsection(name2); 
-                                         if (b) 
-                                                 subsection2 = subsection.OpenSubsection(name2); 
-                                         else 
-                                                 subsection2 = subsection.CreateSubsection(name2); 
-                                 } 
-   
-                                 Int32 val_1 = (Int32)subsection2.ReadProperty(val_1_name, 100); 
-                                 Int32 val_2 = (Int32)subsection2.ReadProperty(val_2_name, 200);                          
-                         } 
-                 } 
-   
-                 void palette_set_Save(App.IConfigurationSection section) { 
-                         if (section == null || section.IsReadOnly) 
-                                 return; 
-                         App.IConfigurationSection subsection = null; 
-                         App.IConfigurationSection subsection2 = null; 
-   
-                         Boolean b = section.ContainsSubsection(name); 
-                         if (b) 
-                                 subsection = section.OpenSubsection(name); 
-                         else 
-                                 subsection = section.CreateSubsection(name); 
-   
-                         if (subsection != null && !subsection.IsReadOnly) { 
-                                 Boolean n = subsection.ContainsSubsection(name2); 
-                                 if (n) 
-                                         subsection2 = subsection.OpenSubsection(name2); 
-                                 else 
-                                         subsection2 = subsection.CreateSubsection(name2); 
-                         } 
-   
-                         if (subsection2 != null && !subsection2.IsReadOnly) { 
-                                 subsection2.WriteProperty(val_1_name, 123); 
-                                 subsection2.WriteProperty(val_2_name, 456); 
-                         } 
-                 } 
-         } 
- }