예제 #1
0
        public static void SetWallpaper(uint id, string path)
        {
            DesktopWallpaper.IDesktopWallpaper wallpaper = DesktopWallpaper.WallpaperWrapper.GetWallpaper();

            if (id <= wallpaper.GetMonitorDevicePathCount())
            {
                string monitor = wallpaper.GetMonitorDevicePathAt(id);
                wallpaper.SetWallpaper(monitor, path);
            }

            Marshal.ReleaseComObject(wallpaper);
        }
예제 #2
0
        public static void NextWallpaper()
        {
            DesktopWallpaper.IDesktopWallpaper wallpaper = DesktopWallpaper.WallpaperWrapper.GetWallpaper();

            Console.Out.WriteLine("Mon amount: " + wallpaper.GetMonitorDevicePathCount());
            string monitor = wallpaper.GetMonitorDevicePathAt(0);

            Console.Out.WriteLine("mon id: " + monitor);
            wallpaper.AdvanceSlideshow(null, DesktopWallpaper.DesktopSlideshowDirection.Forward);

            Marshal.ReleaseComObject(wallpaper);
        }
예제 #3
0
        public static void GetSlideShow(string[] paths)
        {
            // Load into memory
            DesktopWallpaper.IDesktopWallpaper wallpaper = DesktopWallpaper.WallpaperWrapper.GetWallpaper();
            IShellItemArray slideshow = wallpaper.GetSlideshow();
            IShellItemArray pictures  = FoldersToShellItemArray(paths);

            Console.Out.WriteLine("Now: ");
            PrintShellItemArray(slideshow);
            Console.Out.WriteLine("Program: ");
            PrintShellItemArray(pictures);

            // Cleanup
            Marshal.ReleaseComObject(pictures);
            Marshal.ReleaseComObject(slideshow);
            Marshal.ReleaseComObject(wallpaper);
        }
예제 #4
0
        public static void SetSlideShow(Settings settings, Settings.Resolution resolution)
        {
            DesktopWallpaper.IDesktopWallpaper wallpaper = DesktopWallpaper.WallpaperWrapper.GetWallpaper();

            try
            {
                IShellItemArray pictures =
                    FoldersToShellItemArray(settings.Resolutions.Find(res => res.Equals(resolution))?.Folders
                                            .ToArray());
                if (pictures == null)
                {
                    throw new Exception("No resolution found");
                }
                wallpaper.SetSlideshow(pictures);
            }
            catch (Exception)
            {
                // ignored
            }
            finally
            {
                Marshal.ReleaseComObject(wallpaper);
            }
        }