Example #1
0
        public static Settings DeSerializeSettings(string settingsFilePath)
        {
            // Deserialize settings
            XmlSerializer serializer = new XmlSerializer(typeof(Settings));
            Settings      settings;

            using (StreamReader tr = new StreamReader(settingsFilePath))
            {
                settings = (Settings)serializer.Deserialize(tr);
            }

            // Loop through the PicasaDB objects to set some things right after deserialising...
            bool defaultDBFound = false;

            for (int i = 0; i < settings.picasaDBs.Count; i++)
            {
                // Overwrite the default DB with the just added version...
                if (settings.picasaDBs[i].IsStandardDB == true)
                {
                    string backupDir = settings.picasaDBs[i].BackupDir;
                    settings.picasaDBs[i]           = GetDefaultPicasaDB();
                    settings.picasaDBs[i].BackupDir = backupDir;
                    defaultDBFound = true;
                }

                // NewLine's in an XML file are stored as \n while Windows wants \r\n in it's textboxes,...
                // Because the description can contain newlines... replace them.
                settings.picasaDBs[i].Description = settings.picasaDBs[i].Description.Replace("\n", Environment.NewLine);
            }

            // Loop through the PicasaButton objects to set some things right after deserialising...
            for (int i = 0; i < settings.picasaButtons.ButtonList.Count; i++)
            {
                // NewLine's in an XML file are stored as \n while Windows wants \r\n in it's textboxes,...
                // For all field that can contain newlines... replace them.
                settings.picasaButtons.ButtonList[i].Description = settings.picasaButtons.ButtonList[i].Description.Replace("\n", Environment.NewLine);
                if (!string.IsNullOrEmpty(settings.picasaButtons.ButtonList[i].Script))
                {
                    settings.picasaButtons.ButtonList[i].Script = settings.picasaButtons.ButtonList[i].Script.Replace("\n", Environment.NewLine);
                }
            }

            // Check if the settings contained a PicasaExePath. It will be null if the settings don't contain
            // an entry yet for the Path of this OS type (x86/x64) for this PC.  Set it to likely path if not.
            if (settings.PicasaExePath == "")
            {
                settings.PicasaExePath = (SettingsHelper.ProgramFilesx86() + "\\google\\Picasa3\\picasa3.exe");
            }

            if (defaultDBFound == false)
            {
                settings.picasaDBs.Insert(0, GetDefaultPicasaDB());
            }

            return(settings);
        }
Example #2
0
        /// <summary>
        /// Contstructor of the settings class.
        /// </summary>
        public Settings()
        {
            string value = "";

            try
            {
                RegistryKey key = Registry.CurrentUser.OpenSubKey("Software\\Google\\Picasa\\Picasa2\\Runtime\\");
                value = (string)key.GetValue("appPath");
            }
            catch (Exception Ex)
            {
                throw Ex;
            }
            if (string.IsNullOrEmpty(value) == false)
            {
                PicasaExePaths.SetPath(new PathOnComputer(Environment.MachineName, value));
            }
            else
            {
                PicasaExePaths.SetPath(new PathOnComputer(Environment.MachineName, SettingsHelper.ProgramFilesx86() + "\\google\\Picasa3\\picasa3.exe"));
            }
        }