public bool SameAs(Wallpaper other)
 {
     if (other.ID == ID)
         if (other.Name == Name)
             if (other.WallpaperStyle == WallpaperStyle)
                 return other.Path == Path;
     return false;
 }
        public void SetWallpaper(Wallpaper wall)
        {
            if (wall == null || !wall.PathExist)
                return;
            WallpaperStyle? style = CurrentStyle;
            if (wall?.WallpaperStyle != null)
                style = wall.WallpaperStyle;

            Uri uri = new Uri(wall.Path);
            Stream s = new System.Net.WebClient().OpenRead(uri.ToString());

            System.Drawing.Image img = System.Drawing.Image.FromStream(s);
            string tempPath = Path.Combine(Path.GetTempPath(), "wallpaper.bmp");
            img.Save(tempPath, System.Drawing.Imaging.ImageFormat.Bmp);

            RegistryKey key = Registry.CurrentUser.OpenSubKey(@"Control Panel\Desktop", true);

            switch (style)
            {
                case WallpaperStyle.Tile:
                    key.SetValue(@"WallpaperStyle", 0.ToString());
                    key.SetValue(@"TileWallpaper", 1.ToString());
                    break;
                case WallpaperStyle.Stretch:
                    key.SetValue(@"WallpaperStyle", 2.ToString());
                    key.SetValue(@"TileWallpaper", 0.ToString());
                    break;
                case WallpaperStyle.Center:
                    key.SetValue(@"WallpaperStyle", 0.ToString());
                    key.SetValue(@"TileWallpaper", 0.ToString());
                    break;
                case WallpaperStyle.Fit: // (Windows 7 and later)
                    key.SetValue(@"WallpaperStyle", 6.ToString());
                    key.SetValue(@"TileWallpaper", 0.ToString());
                    break;
                case WallpaperStyle.Fill: // (Windows 7 and later)
                    key.SetValue(@"WallpaperStyle", 10.ToString());
                    key.SetValue(@"TileWallpaper", 0.ToString());
                    break;
            }

            SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, tempPath, SPIF_UPDATEINIFILE | SPIF_SENDWININICHANGE);
        }
 private void editSelectedWallpapers()
 {
     Wallpaper[] walls = new Wallpaper[fileListView1.SelectedItems.Count];
     for (int i = 0; i < walls.Length; i++)
         walls[i] = fileListView1.SelectedItems[i].Tag as Wallpaper;
     WallpaperDetailsForm details = new WallpaperDetailsForm(walls);
     if (details.ShowDialog(this) == DialogResult.OK)
         queue.changeWallpapers(details.Result);
     updateComponent();
 }
        private void removeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Wallpaper[] walls = new Wallpaper[fileListView1.SelectedItems.Count];

            for (int i = 0; i < fileListView1.SelectedItems.Count; i++)
                walls[i] = fileListView1.SelectedItems[i].Tag as Wallpaper;

            removeWallpapers(walls);
            updateComponent();
        }
        private void addNewWallpaperFiles(params string[] files)
        {
            List<Wallpaper> walls = new List<Wallpaper>();
            foreach (var file in files)
            {
                if (!File.Exists(file))
                    continue;

                string ext = Path.GetExtension(file).ToUpper();
                if (!wallHelper.extAllowed(ext))
                    continue;

                Wallpaper wall = new Wallpaper(file);
                if (queue.Wallpapers.Contains(wall))
                    continue;

                walls.Add(wall);
            }
            queue.addWallpapers(walls);
            addWallpaperToListView(walls.ToArray());
        }
        public void advance(Wallpaper current)
        {
            CurrentWallpaper = current;
            currentQueueIndex = Queue.IndexOf(current.ID);

            nextQueueIndex = currentQueueIndex + 1;
            if (nextQueueIndex >= Queue.Count)
                nextQueueIndex = 0;

            if (Queue.Count < 1)
                NextWallpaper = CurrentWallpaper;
            else
                if (QueueOrder == QueueMode.Random)
                NextWallpaper = Wallpapers[random.Next(Wallpapers.Count - 1)];
            else
                NextWallpaper = getWallpaperById(Queue[nextQueueIndex]);
        }
 public void removeWallpaper(Wallpaper wallpaper)
 {
     Wallpapers.Remove(wallpaper);
     queue.Remove(wallpaper.ID);
     if (NextWallpaper != null && NextWallpaper.Equals(wallpaper))
     {
         NextWallpaper = null;
         advance(CurrentWallpaper);
     }
     if (Wallpapers.Count <= 0)
         wallpapersCleared(this, new EventArgs());
 }