示例#1
0
        private void RequestManager()
        {
            Console.WriteLine("Running");

            File.WriteAllText(appDataFolder + "username.txt", username);

            // Reset stored resolution values
            primaryX = 0;
            primaryY = 0;
            totalX   = 0;
            totalY   = 0;

            primaryX        = Screen.PrimaryScreen.Bounds.Width;
            primaryY        = Screen.PrimaryScreen.Bounds.Height;
            desktopSizeType = Wallpaper.DesktopSizeType(primaryX, primaryY);
            Console.WriteLine(desktopSizeType);

            /*// Add up resolution of all displays
             * foreach (Screen i in Screen.AllScreens)
             * {
             *  totalX += i.Bounds.Width;
             *  totalY += i.Bounds.Height;
             * }
             *
             * desktopSizeType = Wallpaper.DesktopSizeType(totalX, totalY);*/

            Wallpaper.CopyOldWallpaper(Path.GetFullPath(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\Microsoft\Windows\Themes\TranscodedWallpaper"));
            timer           = new System.Timers.Timer(500);
            timer.Elapsed  += TimerCall;
            timer.AutoReset = true;
            timer.Enabled   = true;
            timer.Start();
        }
示例#2
0
        private void TimerCall(object source, ElapsedEventArgs e)
        {
            if (!active)
            {
                timer.Dispose();
                Wallpaper.SetWallpaper(Path.GetFullPath(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\Microsoft\Windows\Themes\oldwallpaper"));
            }

            GetRecentTracks().Wait();

            // If the latest scrobble is not a current scrobble, do not show

            /*if (recentTracks[0].IsNowPlaying == false || recentTracks[0].IsNowPlaying == null)
             * {
             *  Wallpaper.SetWallpaper(Path.GetFullPath(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\Microsoft\Windows\Themes\oldwallpaper"));
             *  // Erase artistName so artist change is triggered if track is resumed
             *  artistName = "";
             *  return;
             * }*/

            // Only update wallpaper if artist changes
            if (!(recentTracks[0].ArtistName == artistName))
            {
                artistName = recentTracks[0].ArtistName;
                DateTimeOffset?playTime = recentTracks[0].TimePlayed;
                Console.WriteLine("Artist: " + artistName + "\n");
                //Console.WriteLine("Time played: " + playTime.Value + "\n");
                //activeSong = recentTracks[0];

                // Update UI
                updateActiveSongDisplay();

                /*MessageBox.Show(artistName);*/
                Console.WriteLine("Latest scrobbled artist: " + artistName);

                // Download image
                GoogleImagesDownload.Download(artistName, desktopSizeType).Wait();

                // Create directory object
                DirectoryInfo di = new DirectoryInfo("downloads\\" + artistName);

                // Get name of downloaded image
                string firstFileName = di.GetFiles().Select(fi => fi.Name).FirstOrDefault(name => name != "Thumbs.db");

                // Set wallpaper
                Wallpaper.SetWallpaper(Path.GetFullPath("downloads\\" + artistName + "\\" + firstFileName));
            }
        }