/// <summary>
        /// Loads the values of the file into memory.
        /// </summary>
        private void LoadValuesFromFile()
        {
            if (!File.Exists(UserConfigPath))
            {
                //if the config file is not where it's supposed to be create a new one.
                CreateEmptyConfig();
            }

            try
            {
                //load the xml
                var configXml = XDocument.Load(UserConfigPath);

                //get all of the <setting name="..." serializeAs="..."> elements.
                var settingElements = configXml.Element(CONFIG).Element(USER_SETTINGS).Element(typeof(Properties.Settings).FullName).Elements(SETTING);

                //iterate through, adding them to the dictionary, (checking for nulls, xml no likey nulls)
                //using "String" as default serializeAs...just in case, no real good reason.
                foreach (var element in settingElements)
                {
                    var newSetting = new SettingStruct()
                    {
                        name = element.Attribute(NAME) == null ? String.Empty : element.Attribute(NAME).Value,
                        serializeAs = element.Attribute(SERIALIZE_AS) == null ? "String" : element.Attribute(SERIALIZE_AS).Value,
                        value = element.Value ?? String.Empty
                    };
                    SettingsDictionary.Add(element.Attribute(NAME).Value, newSetting);
                }
            }
            catch
            {
                if (File.Exists(UserConfigPath))
                    File.Delete(UserConfigPath);
            }
        }
        /// <summary>
        /// Must override this, this is the bit that does the saving to file.  Called when Settings.Save() is called
        /// </summary>
        /// <param name="context"></param>
        /// <param name="collection"></param>
        public override void SetPropertyValues(SettingsContext context, SettingsPropertyValueCollection collection)
        {
            //grab the values from the collection parameter and update the values in our dictionary.
            foreach (SettingsPropertyValue value in collection)
            {
                var setting = new SettingStruct()
                {
                    value = (value.PropertyValue == null ? String.Empty : value.SerializedValue.ToString()),
                    name = value.Name,
                    serializeAs = value.Property.SerializeAs.ToString()
                };

                if (!SettingsDictionary.ContainsKey(value.Name))
                {
                    SettingsDictionary.Add(value.Name, setting);
                }
                else
                {
                    SettingsDictionary[value.Name] = setting;
                }
            }

            //now that our local dictionary is up-to-date, save it to disk.
            SaveValuesToFile();
        }
        /// <summary>
        /// Must override this, this is the bit that does the saving to file.  Called when Settings.Save() is called
        /// </summary>
        /// <param name="context"></param>
        /// <param name="collection"></param>
        public override void SetPropertyValues(SettingsContext context, SettingsPropertyValueCollection collection)
        {
            //grab the values from the collection parameter and update the values in our dictionary.
            foreach (SettingsPropertyValue value in collection)
            {
                var setting = new SettingStruct()
                {
                    //value = (value.PropertyValue == null ? String.Empty : value.PropertyValue.ToString()),
                    name = value.Name,
                    serializeAs = value.Property.SerializeAs.ToString()
                };

                if (ShouldEncrypt(value.Property))
                {
                    setting.value = (value.PropertyValue == null ? String.Empty : Crypto.EncryptString(Crypto.ToSecureString(value.PropertyValue.ToString())));
                }
                else
                {
                    setting.value = (value.PropertyValue == null ? String.Empty : value.PropertyValue.ToString());
                    try
                    {
                        if (value.PropertyValue.GetType() == typeof (System.Drawing.Color))
                        {
                            SerializeColorAndPutToSetting(value, ref setting);
                        }
                    }
                    catch // Replace this try{}catch{} with appropriate collection
                    {

                    }
                }

                if (!SettingsDictionary.ContainsKey(value.Name))
                {
                    SettingsDictionary.Add(value.Name, setting);
                }
                else
                {
                    SettingsDictionary[value.Name] = setting;
                }
            }

            //now that our local dictionary is up-to-date, save it to disk.
            SaveValuesToFile();
        }
 private static void SerializeColorAndPutToSetting(SettingsPropertyValue value, ref SettingStruct setting)
 {
     var color = (Color)value.PropertyValue;
     if (color.IsKnownColor)
     {
         setting.value = color.Name;
     }
     else
     {
         setting.value = ColorTranslator.ToHtml(Color.FromArgb(color.ToArgb()));
     }
 }
        /// <summary>
        /// Loads the values of the file into memory.
        /// </summary>
        private void LoadValuesFromFile()
        {
            if (!File.Exists(UserConfigPath))
            {
                // If the config file is not where it's supposed to be create a new one:
                CreateEmptyConfig();
            }

            // Load the XML:
            var configXml = LoadConfiguration();

            // Get all of the <setting name="..." serializeAs="..."> elements:
            var settingElements = configXml.Element(CONFIG).Element(USER_SETTINGS).Element(typeof(Settings).FullName).Elements(SETTING);

            // Iterate through, adding them to the dictionary, (checking for nulls, XML no likey nulls),
            // using "String" as default serializeAs...just in case, no real good reason:
            foreach (var element in settingElements)
            {
                var newSetting = new SettingStruct()
                {
                    name = element.Attribute(NAME) == null ? String.Empty : element.Attribute(NAME).Value,
                    serializeAs = element.Attribute(SERIALIZE_AS) == null ? "String" : element.Attribute(SERIALIZE_AS).Value,
                    value = element.Value ?? String.Empty
                };
                SettingsDictionary.Add(element.Attribute(NAME).Value, newSetting);
            }
        }