Example #1
0
        /// <inheritdoc />
        public override object Clone()
        {
            WallpaperDefaultSettings clonedInstance = new WallpaperDefaultSettings();

            // Clone all fields defined by WallpaperSettingsBase.
            base.Clone(clonedInstance);

            clonedInstance.autoDetermineIsMultiscreen = this.AutoDetermineIsMultiscreen;
            clonedInstance.autoDeterminePlacement     = this.AutoDeterminePlacement;

            return(clonedInstance);
        }
Example #2
0
        /// <summary>
        ///   Assigns all member values of this instance to the respective members of the given instance.
        /// </summary>
        /// <param name="other">
        ///   The target instance to assign to.
        /// </param>
        /// <exception cref="ArgumentNullException">
        ///   <paramref name="other" /> is <c>null</c>.
        /// </exception>
        protected override void AssignTo(WallpaperSettingsBase other)
        {
            if (other == null)
            {
                throw new ArgumentNullException();
            }

            // Assign all members defined by WallpaperSettingsBase.
            base.AssignTo(other);

            WallpaperDefaultSettings defaultSettingsInstance = (other as WallpaperDefaultSettings);

            if (defaultSettingsInstance != null)
            {
                defaultSettingsInstance.AutoDetermineIsMultiscreen = this.AutoDetermineIsMultiscreen;
                defaultSettingsInstance.AutoDeterminePlacement     = this.AutoDeterminePlacement;
            }
        }
Example #3
0
        /// <summary>
        ///   Initializes a new instance of the <see cref="WallpaperCategory" /> class.
        /// </summary>
        /// <param name="name">
        ///   The name of the category.
        /// </param>
        /// <param name="wallpapers">
        ///   A collection of wallpapers which should be added to the category be default.
        ///   Set to <c>null</c> to create an empty category.
        /// </param>
        /// <exception cref="ArgumentException">
        ///   <paramref name="name" /> contains invalid characters.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///   <paramref name="name" /> is <c>null</c>.
        /// </exception>
        /// <exception cref="ArgumentOutOfRangeException">
        ///   <paramref name="name" /> is a string which's length is lower than 1 or greater than 100 chars.
        /// </exception>
        /// <seealso cref="Wallpaper">Wallpaper Class</seealso>
        /// <overloads>
        ///   <summary>
        ///     Initializes a new instance of the <see cref="WallpaperCategory" /> class.
        ///   </summary>
        ///   <seealso cref="Wallpaper">Wallpaper Class</seealso>
        /// </overloads>
        public WallpaperCategory(string name, IEnumerable <Wallpaper> wallpapers = null)
        {
            if (!name.Length.IsBetween(WallpaperCategory.Name_MinLength, WallpaperCategory.Name_MaxLength))
            {
                throw new ArgumentOutOfRangeException();
            }
            if (WallpaperCategory.Name_InvalidChars.Any(name.Contains))
            {
                throw new ArgumentException();
            }

            this.name = name;
            if (wallpapers != null)
            {
                foreach (Wallpaper wallpaper in wallpapers)
                {
                    this.Add(wallpaper);
                }
            }

            this.wallpaperDefaultSettings = new WallpaperDefaultSettings();
        }
Example #4
0
        /// <summary>
        ///   Adds wallpaper related settings to a given <see cref="XmlElement" />.
        /// </summary>
        /// <param name="document">
        ///   The <see cref="XmlDocument" /> to add the data for.
        /// </param>
        /// <param name="element">
        ///   The <see cref="XmlElement" /> to add the data to.
        /// </param>
        /// <param name="wallpaperBaseSettings">
        ///   The wallpaper settings to add.
        /// </param>
        /// <exception cref="ArgumentNullException">
        ///   <paramref name="document" /> or <paramref name="element" /> or <paramref name="wallpaperBaseSettings" /> is
        ///   <c>null</c>.
        /// </exception>
        protected static void AddWallpaperDataToXmlElement(XmlDocument document, XmlElement element, WallpaperSettingsBase wallpaperBaseSettings)
        {
            if (document == null)
            {
                throw new ArgumentNullException();
            }
            if (element == null)
            {
                throw new ArgumentNullException();
            }
            if (wallpaperBaseSettings == null)
            {
                throw new ArgumentNullException();
            }

            Wallpaper wallpaperSettings = (wallpaperBaseSettings as Wallpaper);
            WallpaperDefaultSettings defaultSettings = (wallpaperBaseSettings as WallpaperDefaultSettings);
            XmlElement currentElement;

            if (wallpaperSettings != null)
            {
                currentElement = document.CreateElement("ImagePath");
                if (wallpaperSettings.ImagePath != Path.None)
                {
                    currentElement.InnerText = wallpaperSettings.ImagePath;
                }
                element.AppendChild(currentElement);
            }

            currentElement           = document.CreateElement("IsActivated");
            currentElement.InnerText = wallpaperBaseSettings.IsActivated.ToString();
            element.AppendChild(currentElement);

            currentElement           = document.CreateElement("IsMultiscreen");
            currentElement.InnerText = wallpaperBaseSettings.IsMultiscreen.ToString();
            element.AppendChild(currentElement);

            currentElement           = document.CreateElement("Priority");
            currentElement.InnerText = wallpaperBaseSettings.Priority.ToString(CultureInfo.InvariantCulture);
            element.AppendChild(currentElement);

            currentElement           = document.CreateElement("OnlyCycleBetweenStart");
            currentElement.InnerText = wallpaperBaseSettings.OnlyCycleBetweenStart.ToString();
            element.AppendChild(currentElement);

            currentElement           = document.CreateElement("OnlyCycleBetweenStop");
            currentElement.InnerText = wallpaperBaseSettings.OnlyCycleBetweenStop.ToString();
            element.AppendChild(currentElement);

            currentElement           = document.CreateElement("Placement");
            currentElement.InnerText = wallpaperBaseSettings.Placement.ToString();
            element.AppendChild(currentElement);

            currentElement           = document.CreateElement("HorizontalOffset");
            currentElement.InnerText = wallpaperBaseSettings.Offset.X.ToString(CultureInfo.InvariantCulture);
            element.AppendChild(currentElement);

            currentElement           = document.CreateElement("VerticalOffset");
            currentElement.InnerText = wallpaperBaseSettings.Offset.Y.ToString(CultureInfo.InvariantCulture);
            element.AppendChild(currentElement);

            currentElement           = document.CreateElement("HorizontalScale");
            currentElement.InnerText = wallpaperBaseSettings.Scale.X.ToString(CultureInfo.InvariantCulture);
            element.AppendChild(currentElement);

            currentElement           = document.CreateElement("VerticalScale");
            currentElement.InnerText = wallpaperBaseSettings.Scale.Y.ToString(CultureInfo.InvariantCulture);
            element.AppendChild(currentElement);

            currentElement           = document.CreateElement("Effects");
            currentElement.InnerText = wallpaperBaseSettings.Effects.ToString();
            element.AppendChild(currentElement);

            currentElement           = document.CreateElement("BackgroundColor");
            currentElement.InnerText = ColorTranslator.ToHtml(wallpaperBaseSettings.BackgroundColor);
            element.AppendChild(currentElement);

            currentElement = document.CreateElement("DisabledScreens");
            StringBuilder disabledScreensString = new StringBuilder(wallpaperBaseSettings.DisabledScreens.Count * 2);

            for (int i = 0; i < wallpaperBaseSettings.DisabledScreens.Count; i++)
            {
                if (i > 0)
                {
                    disabledScreensString.Append(',');
                }

                disabledScreensString.Append(wallpaperBaseSettings.DisabledScreens[i]);
            }
            currentElement.InnerText = disabledScreensString.ToString();
            element.AppendChild(currentElement);

            if (defaultSettings != null)
            {
                currentElement           = document.CreateElement("AutoDetermineIsMultiscreen");
                currentElement.InnerText = defaultSettings.AutoDetermineIsMultiscreen.ToString(CultureInfo.InvariantCulture);
                element.AppendChild(currentElement);

                currentElement           = document.CreateElement("AutoDeterminePlacement");
                currentElement.InnerText = defaultSettings.AutoDeterminePlacement.ToString(CultureInfo.InvariantCulture);
                element.AppendChild(currentElement);
            }
        }
Example #5
0
        /// <summary>
        ///   Gets wallpaper related settings from a given <see cref="XmlElement" />.
        /// </summary>
        /// <param name="element">
        ///   The <see cref="XmlElement" /> to get the data from.
        /// </param>
        /// <param name="wallpaperSettingsType">
        ///   The type of the wallpaper settings to read.
        /// </param>
        /// <returns>
        ///   An instance of a type inherited from <see cref="WallpaperSettingsBase" /> containing the data get from the
        ///   <see cref="XmlElement" />.
        /// </returns>
        /// <exception cref="ArgumentNullException">
        ///   <paramref name="element" /> or <paramref name="wallpaperSettingsType" /> is <c>null</c>.
        /// </exception>
        /// <exception cref="XmlException">
        ///   The XML Data are invalid.
        /// </exception>
        protected static WallpaperSettingsBase GetWallpaperDataFromXmlElement(XmlElement element, Type wallpaperSettingsType)
        {
            if (element == null)
            {
                throw new ArgumentNullException();
            }
            if (wallpaperSettingsType == null)
            {
                throw new ArgumentNullException();
            }

            WallpaperSettingsBase    settings        = null;
            WallpaperDefaultSettings defaultSettings = null;
            XmlElement subElement;

            if (wallpaperSettingsType == typeof(Wallpaper))
            {
                subElement = element["ImagePath"];
                if (subElement != null)
                {
                    Wallpaper wallpaper;

                    if (subElement.InnerText.Length > 0)
                    {
                        wallpaper = new Wallpaper(new Path(subElement.InnerText));
                    }
                    else
                    {
                        wallpaper = new Wallpaper();
                    }

                    wallpaper.SuggestIsMultiscreen = false;
                    wallpaper.SuggestPlacement     = false;
                    settings = wallpaper;
                }
            }
            else if (wallpaperSettingsType == typeof(WallpaperDefaultSettings))
            {
                defaultSettings = new WallpaperDefaultSettings();
                settings        = defaultSettings;
            }

            if (settings == null)
            {
                throw new XmlException("A wallpaper setting node is missing.");
            }

            subElement = element["IsActivated"];
            if (subElement != null)
            {
                settings.IsActivated = bool.Parse(subElement.InnerText);
            }

            subElement = element["IsMultiscreen"];
            if (subElement != null)
            {
                settings.IsMultiscreen = bool.Parse(subElement.InnerText);
            }

            subElement = element["Priority"];
            if (subElement != null)
            {
                settings.Priority = byte.Parse(subElement.InnerText, CultureInfo.InvariantCulture);
            }

            subElement = element["OnlyCycleBetweenStart"];
            if (subElement != null)
            {
                settings.OnlyCycleBetweenStart = TimeSpan.Parse(subElement.InnerText, CultureInfo.InvariantCulture);
            }

            subElement = element["OnlyCycleBetweenStop"];
            if (subElement != null)
            {
                settings.OnlyCycleBetweenStop = TimeSpan.Parse(subElement.InnerText, CultureInfo.InvariantCulture);
            }

            subElement = element["Placement"];
            if (subElement != null)
            {
                settings.Placement = (WallpaperPlacement)Enum.Parse(typeof(WallpaperPlacement), subElement.InnerText);
            }

            subElement = element["HorizontalOffset"];
            if (subElement != null)
            {
                int horizontalOffset = int.Parse(subElement.InnerText, CultureInfo.InvariantCulture);

                subElement = element["VerticalOffset"];
                if (subElement != null)
                {
                    settings.Offset = new Point(horizontalOffset, int.Parse(subElement.InnerText, CultureInfo.InvariantCulture));
                }
            }

            subElement = element["HorizontalScale"];
            if (subElement != null)
            {
                int horizontalScale = int.Parse(subElement.InnerText, CultureInfo.InvariantCulture);

                subElement = element["VerticalScale"];
                if (subElement != null)
                {
                    settings.Offset = new Point(horizontalScale, int.Parse(subElement.InnerText, CultureInfo.InvariantCulture));
                }
            }

            subElement = element["Effects"];
            if (subElement != null)
            {
                settings.Effects = (WallpaperEffects)Enum.Parse(typeof(WallpaperEffects), subElement.InnerText);
            }

            subElement = element["BackgroundColor"];
            if (subElement != null)
            {
                settings.BackgroundColor = ColorTranslator.FromHtml(subElement.InnerText);
            }

            subElement = element["DisabledScreens"];
            if (subElement != null)
            {
                string[] disabledScreens = subElement.InnerText.Split(',');

                for (int i = 0; i < disabledScreens.Length; i++)
                {
                    string disabledScreenString = disabledScreens[i].Trim();

                    if (disabledScreens[i].Length != 0)
                    {
                        settings.DisabledScreens.Add(int.Parse(disabledScreenString, CultureInfo.InvariantCulture));
                    }
                }
            }

            if (defaultSettings != null)
            {
                subElement = element["AutoDetermineIsMultiscreen"];
                if (subElement != null)
                {
                    defaultSettings.AutoDetermineIsMultiscreen = bool.Parse(subElement.InnerText);
                }

                subElement = element["AutoDeterminePlacement"];
                if (subElement != null)
                {
                    defaultSettings.AutoDeterminePlacement = bool.Parse(subElement.InnerText);
                }
            }

            return(settings);
        }
Example #6
0
        // TODO: Use XmlSerializer for reading and writing the config.
        // TODO: Extract Read/Write functionality into a new class (and interface perhaps)
        /// <summary>
        ///   Creates a new <see cref="Configuration" /> instance by reading the data from a <see cref="Stream" />.
        /// </summary>
        /// <remarks>
        ///   This method reads Wallpaper Manager configuration files (version 1.0, 1.1 and 1.2) by using
        ///   <see cref="XmlDocument" />.
        /// </remarks>
        /// <param name="sourceStream">
        ///   The source <see cref="Stream" /> to read from.
        /// </param>
        /// <returns>
        ///   A new <see cref="Configuration" /> instance containing the read data.
        /// </returns>
        /// <exception cref="ArgumentNullException">
        ///   <paramref name="sourceStream" /> is <c>null</c>.
        /// </exception>
        /// <exception cref="IOException">
        ///   <paramref name="sourceStream" /> is not readable.
        /// </exception>
        /// <exception cref="XmlException">
        ///   There is a load or parse error in the XML-Data.
        /// </exception>
        /// <exception cref="InvalidOperationException">
        ///   Error while deserializing. Refer to the object returned by the  <see cref="Exception.InnerException" /> property
        ///   for details.
        /// </exception>
        /// <overloads>
        ///   <summary>
        ///     Creates a new <see cref="Configuration" /> instance by reading the data from a data source.
        ///   </summary>
        ///   <returns>
        ///     A new <see cref="Configuration" /> instance containing the read data.
        ///   </returns>
        /// </overloads>
        /// <seealso cref="Stream">Stream Class</seealso>
        public static Configuration Read(Stream sourceStream)
        {
            if (sourceStream == null)
            {
                throw new ArgumentNullException();
            }
            if (!sourceStream.CanRead)
            {
                throw new IOException();
            }

            XmlDocument document = new XmlDocument();

            document.Load(sourceStream);

            if ((document.DocumentElement == null) || (document.DocumentElement.Name != Configuration.RootNodeName))
            {
                throw new XmlException("The configuration file has an invalid root element.");
            }

            XmlAttribute versionAttribute = document.DocumentElement.Attributes["Version"];
            Version      configVersion;

            if ((versionAttribute == null) || (!Version.TryParse(versionAttribute.InnerText, out configVersion)))
            {
                throw new XmlException("The configuration file has an invalid root element.");
            }

            Configuration configuration = new Configuration();

            #region <General>
            XmlElement generalElement = document.DocumentElement["General"];
            if (generalElement == null)
            {
                throw new XmlException("The configuration file does not contain expected element 'General'.");
            }

            XmlElement element = generalElement["CycleAfterStartup"];
            if (element != null)
            {
                configuration.General.CycleAfterStartup = bool.Parse(element.InnerText);
            }

            element = generalElement["TerminateAfterStartup"];
            if (element != null)
            {
                configuration.General.TerminateAfterStartup = bool.Parse(element.InnerText);
            }

            element = (generalElement["MinimizeAfterStart"] ?? generalElement["MinimizeAfterStartup"]);
            if (element != null)
            {
                configuration.General.MinimizeAfterStartup = bool.Parse(element.InnerText);
            }

            element = generalElement["StartAutoCyclingAfterStartup"];
            if (element != null)
            {
                configuration.General.StartAutocyclingAfterStartup = bool.Parse(element.InnerText);
            }

            element = generalElement["WallpaperChangeType"];
            if (element != null)
            {
                configuration.General.WallpaperChangeType = (WallpaperChangeType)Enum.Parse(typeof(WallpaperChangeType), element.InnerText);
            }

            element = generalElement["AutoCycleInterval"];
            if (element != null)
            {
                configuration.General.AutocycleInterval = TimeSpan.Parse(element.InnerText, CultureInfo.InvariantCulture);
            }

            element = generalElement["LastActiveListSize"];
            if (element != null)
            {
                configuration.General.LastActiveListSize = byte.Parse(element.InnerText, CultureInfo.InvariantCulture);
            }

            element = generalElement["CycleAfterDisplaySettingsChanged"];
            if (element != null)
            {
                configuration.General.CycleAfterDisplaySettingsChanged = bool.Parse(element.InnerText);
            }

            element = generalElement["MinimizeOnClose"];
            if (element != null)
            {
                configuration.General.MinimizeOnClose = bool.Parse(element.InnerText);
            }

            element = generalElement["DisplayCycleTimeAsIconOverlay"];
            if (element != null)
            {
                configuration.General.DisplayCycleTimeAsIconOverlay = bool.Parse(element.InnerText);
            }

            element = generalElement["WallpaperDoubleClickAction"];
            if (element != null)
            {
                configuration.General.WallpaperDoubleClickAction = (WallpaperClickAction)Enum.Parse(typeof(WallpaperClickAction), element.InnerText);
            }

            element = generalElement["TrayIconSingleClickAction"];
            if (element != null)
            {
                configuration.General.TrayIconSingleClickAction = (TrayIconClickAction)Enum.Parse(typeof(TrayIconClickAction), element.InnerText);
            }

            element = generalElement["TrayIconDoubleClickAction"];
            if (element != null)
            {
                configuration.General.TrayIconDoubleClickAction = (TrayIconClickAction)Enum.Parse(typeof(TrayIconClickAction), element.InnerText);
            }
            #endregion

            #region <ScreensSettings>
            XmlElement screensSettingsElement = document.DocumentElement["ScreensSettings"];
            if (screensSettingsElement != null)
            {
                int settingsCounter = 0;
                var screensSettings = new List <ScreenSettings>();

                foreach (XmlElement screenSettingsElement in screensSettingsElement)
                {
                    if (screenSettingsElement.Name != "ScreenSettings")
                    {
                        continue;
                    }

                    // Make sure there aren't too many screen settings in the configuration.
                    if (settingsCounter >= Screen.AllScreens.Length)
                    {
                        break;
                    }

                    ScreenSettings screenSettings = new ScreenSettings(settingsCounter);
                    element = screenSettingsElement["CycleRandomly"];
                    if (element != null)
                    {
                        screenSettings.CycleRandomly = bool.Parse(element.InnerText);
                    }

                    element = screenSettingsElement["MarginLeft"];
                    if (element != null)
                    {
                        screenSettings.Margins.Left = int.Parse(element.InnerText, CultureInfo.InvariantCulture);
                    }

                    element = screenSettingsElement["MarginRight"];
                    if (element != null)
                    {
                        screenSettings.Margins.Right = int.Parse(element.InnerText, CultureInfo.InvariantCulture);
                    }

                    element = screenSettingsElement["MarginTop"];
                    if (element != null)
                    {
                        screenSettings.Margins.Top = int.Parse(element.InnerText, CultureInfo.InvariantCulture);
                    }

                    element = screenSettingsElement["MarginBottom"];
                    if (element != null)
                    {
                        screenSettings.Margins.Bottom = int.Parse(element.InnerText, CultureInfo.InvariantCulture);
                    }

                    #region <OverlayTexts>
                    XmlElement overlayTextsElement = screenSettingsElement["OverlayTexts"];
                    if (overlayTextsElement != null)
                    {
                        foreach (XmlElement overlayTextElement in overlayTextsElement)
                        {
                            if (overlayTextElement.Name != "OverlayText")
                            {
                                continue;
                            }
                            WallpaperTextOverlay textOverlay = new WallpaperTextOverlay();

                            element = overlayTextElement["Format"];
                            if (element != null)
                            {
                                textOverlay.Format = element.InnerText;
                            }

                            element = overlayTextElement["Position"];
                            if (element != null)
                            {
                                textOverlay.Position = (TextOverlayPosition)Enum.Parse(typeof(TextOverlayPosition), element.InnerText);
                            }

                            element = overlayTextElement["FontName"];
                            if (element != null)
                            {
                                textOverlay.FontName = element.InnerText;
                            }

                            element = overlayTextElement["FontSize"];
                            if (element != null)
                            {
                                textOverlay.FontSize = float.Parse(element.InnerText, CultureInfo.InvariantCulture);
                            }

                            element = overlayTextElement["FontStyle"];
                            if (element != null)
                            {
                                textOverlay.FontStyle = (FontStyle)Enum.Parse(typeof(FontStyle), element.InnerText);
                            }

                            element = overlayTextElement["ForeColor"];
                            if (element != null)
                            {
                                textOverlay.ForeColor = ColorTranslator.FromHtml(element.InnerText);
                            }

                            element = overlayTextElement["BorderColor"];
                            if (element != null)
                            {
                                textOverlay.BorderColor = ColorTranslator.FromHtml(element.InnerText);
                            }

                            element = overlayTextElement["HorizontalOffset"];
                            if (element != null)
                            {
                                textOverlay.HorizontalOffset = int.Parse(element.InnerText, CultureInfo.InvariantCulture);
                            }

                            element = overlayTextElement["VerticalOffset"];
                            if (element != null)
                            {
                                textOverlay.VerticalOffset = int.Parse(element.InnerText, CultureInfo.InvariantCulture);
                            }

                            screenSettings.TextOverlays.Add(textOverlay);
                        }
                    }
                    #endregion

                    #region <StaticWallpaper>
                    XmlElement staticWallpaperElement = screenSettingsElement["StaticWallpaper"];
                    if (staticWallpaperElement != null)
                    {
                        screenSettings.StaticWallpaper = (Wallpaper)Configuration.GetWallpaperDataFromXmlElement(staticWallpaperElement, typeof(Wallpaper));
                    }
                    #endregion

                    screensSettings.Add(screenSettings);
                    settingsCounter++;
                }

                configuration.General.ScreensSettings = new ScreenSettingsCollection(screensSettings);
            }
            #endregion

            #region <WallpaperCategories>
            XmlElement wallpaperCategoriesElement = document.DocumentElement["WallpaperCategories"];
            if (wallpaperCategoriesElement != null)
            {
                foreach (XmlElement wallpaperCategoryElement in wallpaperCategoriesElement)
                {
                    if (
                        wallpaperCategoryElement.Name != "Category" &&
                        wallpaperCategoryElement.Name != "SynchronizedFolder" &&
                        wallpaperCategoryElement.Name != "WatchedCategory" /* Version 1.1 name for synchronized folders. */
                        )
                    {
                        continue;
                    }

                    element = wallpaperCategoryElement["Name"];
                    if (element == null)
                    {
                        continue;
                    }
                    string categoryName = element.InnerText;

                    WallpaperDefaultSettings defaultSettings = null;
                    element = wallpaperCategoryElement["WallpaperDefaultSettings"];
                    if (element != null)
                    {
                        defaultSettings = (WallpaperDefaultSettings)Configuration.GetWallpaperDataFromXmlElement(element, typeof(WallpaperDefaultSettings));
                    }

                    #region <Wallpapers>
                    List <Wallpaper> wallpapers;

                    XmlElement wallpapersElement = wallpaperCategoryElement["Wallpapers"];
                    if (wallpapersElement != null)
                    {
                        wallpapers = new List <Wallpaper>(wallpapersElement.ChildNodes.Count);

                        foreach (XmlElement wallpaperElement in wallpapersElement)
                        {
                            if (wallpaperElement.Name != "Wallpaper")
                            {
                                continue;
                            }

                            Wallpaper wallpaper = (Wallpaper)Configuration.GetWallpaperDataFromXmlElement(wallpaperElement, typeof(Wallpaper));
                            wallpapers.Add(wallpaper);
                        }
                    }
                    else
                    {
                        wallpapers = new List <Wallpaper>(0);
                    }
                    #endregion

                    bool isSynchronizedFolder = ((wallpaperCategoryElement.Name == "SynchronizedFolder") || (wallpaperCategoryElement.Name == "WatchedCategory"));
                    WallpaperCategory category;
                    if (isSynchronizedFolder)
                    {
                        element = (wallpaperCategoryElement["SynchronizedFolderPath"] ?? wallpaperCategoryElement["WatchedDirectoryPath"]);
                        if (element == null)
                        {
                            continue;
                        }
                        Path synchronizedDirPath = new Path(element.InnerText);

                        if (!Directory.Exists(synchronizedDirPath))
                        {
                            continue;
                        }

                        category = new SynchronizedWallpaperCategory(categoryName, synchronizedDirPath, wallpapers);
                    }
                    else
                    {
                        category = new WallpaperCategory(categoryName, wallpapers);
                    }

                    category.WallpaperDefaultSettings = defaultSettings;
                    configuration.WallpaperCategories.Add(category);
                }
            }
            #endregion

            return(configuration);
        }