Exemplo n.º 1
0
        /// <summary>
        /// Run the wallpaper retriever process
        /// </summary>
        public static void Run()
        {
            var newWallpaper = WallpaperRetriever.GetFromRemote();

            if (newWallpaper == null)
            {
                throw new Exception("Failed to connect to the wallpaper service. Please check your internet connectivity or try again later.");
            }
            WallpaperSetter.Set(newWallpaper.LocalLocation, WallpaperStyle.Fill);
            WallpaperSetter.UpdateAuthor(newWallpaper);
            CacheHousekeeper.Run();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Checks to see if the current desktop image was set by Flock
        /// </summary>
        /// <returns>True if it was set by Flock, false otherwise</returns>
        public static bool IsDesktopSetByFlock()
        {
            try
            {
                var       currentDesktopPath    = WallpaperRetriever.GetCurrentDesktop();
                Wallpaper currentSavedWallpaper = JsonConvert.DeserializeObject <Wallpaper>(File.ReadAllText(Config.AuthorTextFile));

                var currentDesktopHash = GetHash(new Bitmap(@currentDesktopPath));
                var currentSavedHash   = GetHash(new Bitmap(@currentSavedWallpaper.LocalLocation));

                int equalElements = currentDesktopHash.Zip(currentSavedHash, (i, j) => i == j).Count(eq => eq);

                return(equalElements > 250);
            }
            catch (Exception e)
            {
                return(false);
            }
        }