/// <summary>
        /// Loads settings from registry storage (on package load)
        /// </summary>
        public override void LoadSettingsFromStorage()
        {
            VisualLocalizerPackage package     = VisualLocalizerPackage.Instance;
            RegistryKey            rootKey     = package.UserRegistryRoot;
            RegistryKey            settingsKey = null;

            try {
                settingsKey = rootKey.OpenSubKey(REG_KEY, false);
                if (settingsKey != null)
                {
                    RegistryKey filtersKey = settingsKey.OpenSubKey(FILTER_KEY);

                    if (filtersKey != null)
                    {
                        SettingsObject.Instance.IgnorePropertyChanges = true;

                        SettingsObject.Instance.ShowContextColumn              = ReadBoolFromRegKey(filtersKey, "ShowFilterContext");
                        SettingsObject.Instance.UseReflectionInAsp             = ReadBoolFromRegKey(filtersKey, "UseReflectionInAsp");
                        SettingsObject.Instance.NamespacePolicyIndex           = ReadIntFromRegKey(filtersKey, "NamespacePolicyIndex");
                        SettingsObject.Instance.MarkNotLocalizableStringsIndex = ReadIntFromRegKey(filtersKey, "MarkNotLocalizableStringsIndex");
                        SettingsObject.Instance.BatchMoveSplitterDistance      = ReadIntFromRegKey(filtersKey, "BatchMoveSplitterDistance", 110);
                        SettingsObject.Instance.SelectedKeyIndex         = ReadIntFromRegKey(filtersKey, "SelectedKeyIndex", 0);
                        SettingsObject.Instance.SelectedUseFullName      = ReadBoolFromRegKey(filtersKey, "SelectedUseFullName");
                        SettingsObject.Instance.SelectedResourceFilePath = (string)filtersKey.GetValue("SelectedResourceFilePath", null);

                        foreach (var pair in SettingsObject.Instance.CommonLocalizabilityCriteria)
                        {
                            LocalizationCommonCriterion crit = pair.Value;
                            object val = filtersKey.GetValue(crit.Name);
                            if (val != null)
                            {
                                crit.FromRegData(val.ToString());
                            }
                        }

                        SettingsObject.Instance.CustomLocalizabilityCriteria.Clear();
                        int customCriteriaCount = ReadIntFromRegKey(filtersKey, "CustomCriteriaCount", 0);
                        for (int i = 0; i < customCriteriaCount; i++)
                        {
                            object val = filtersKey.GetValue("CustomCriteria" + i);
                            if (val != null)
                            {
                                LocalizationCustomCriterion crit = new LocalizationCustomCriterion(LocalizationCriterionAction.VALUE, 0);
                                crit.FromRegData(val.ToString());
                                SettingsObject.Instance.CustomLocalizabilityCriteria.Add(crit);
                            }
                        }
                    }
                    else
                    {
                        ResetSettings();
                    }
                }
                else
                {
                    ResetSettings();
                }
            } finally {
                if (settingsKey != null)
                {
                    settingsKey.Close();
                }

                SettingsObject.Instance.IgnorePropertyChanges = false;
                SettingsObject.Instance.NotifySettingsLoaded();
            }
        }
        /// <summary>
        /// Loads settings from XML (on import settings)
        /// </summary>
        public override void LoadSettingsFromXml(IVsSettingsReader reader)
        {
            SettingsObject.Instance.IgnorePropertyChanges = true;

            SettingsObject.Instance.ShowContextColumn              = ReadBoolFromXml(reader, "ShowFilterContext");
            SettingsObject.Instance.UseReflectionInAsp             = ReadBoolFromXml(reader, "UseReflectionInAsp");
            SettingsObject.Instance.MarkNotLocalizableStringsIndex = ReadIntFromXml(reader, "MarkNotLocalizableStringsIndex");
            SettingsObject.Instance.NamespacePolicyIndex           = ReadIntFromXml(reader, "NamespacePolicyIndex");
            SettingsObject.Instance.BatchMoveSplitterDistance      = ReadIntFromXml(reader, "BatchMoveSplitterDistance");
            SettingsObject.Instance.SelectedKeyIndex    = ReadIntFromXml(reader, "SelectedKeyIndex");
            SettingsObject.Instance.SelectedUseFullName = ReadBoolFromXml(reader, "SelectedUseFullName");

            int    hr;
            string tmp;

            hr = reader.ReadSettingString("SelectedResourceFilePath", out tmp);
            SettingsObject.Instance.SelectedResourceFilePath = tmp;
            Marshal.ThrowExceptionForHR(hr);

            foreach (var pair in SettingsObject.Instance.CommonLocalizabilityCriteria)
            {
                LocalizationCommonCriterion crit = pair.Value;

                string val;
                hr = reader.ReadSettingString(crit.Name, out val);
                if (hr != VSConstants.S_OK)
                {
                    throw new Exception("Error retrieving data from XML.");
                }

                if (val != null)
                {
                    crit.FromRegData(val.ToString());
                }
            }

            SettingsObject.Instance.CustomLocalizabilityCriteria.Clear();
            int customCriteriaCount = 0;

            hr = reader.ReadSettingLong("CustomCriteriaCount", out customCriteriaCount);
            if (hr != VSConstants.S_OK)
            {
                throw new Exception("Error retrieving data from XML.");
            }

            for (int i = 0; i < customCriteriaCount; i++)
            {
                string val;
                hr = reader.ReadSettingString("CustomCriteria" + i, out val);

                if (val != null)
                {
                    LocalizationCustomCriterion crit = new LocalizationCustomCriterion(LocalizationCriterionAction.VALUE, 0);
                    crit.FromRegData(val.ToString());
                    SettingsObject.Instance.CustomLocalizabilityCriteria.Add(crit);
                }
            }

            SettingsObject.Instance.IgnorePropertyChanges = false;
            SettingsObject.Instance.NotifySettingsLoaded();
        }