static void Main(string[] args)
        {
            Screenshot scr = new Screenshot();
            Background bg  = new Background();
            ImageExt   img = new ImageExt(Environment.GetFolderPath(Environment.SpecialFolder.MyPictures) + "\\Wallpapers\\HigennoAce-1.jpg");//Image.FromFile(Environment.GetFolderPath(Environment.SpecialFolder.MyPictures) + "\\Wallpapers\\HigennoAce-1.jpg");

            bg.SetBackground(img, Background.PicturePosition.Fill);

            Console.ReadKey();
        }
Beispiel #2
0
        public void SetBackground(ImageExt background, PicturePosition style)
        {
            Console.WriteLine("Setting Wallpaper");

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

            //PrintUserKeys(key);
            switch (style)
            {
            case PicturePosition.Tile:
                key.SetValue(@"PicturePosition", "0");
                key.SetValue(@"TileWallpaper", "1");
                break;

            case PicturePosition.Center:
                key.SetValue(@"PicturePosition", "0");
                key.SetValue(@"TileWallpaper", "0");
                break;

            case PicturePosition.Stretch:
                key.SetValue(@"PicturePosition", "2");
                key.SetValue(@"TileWallpaper", "0");
                break;

            case PicturePosition.Fit:
                key.SetValue(@"PicturePosition", "6");
                key.SetValue(@"TileWallpaper", "0");
                break;

            case PicturePosition.Fill:
                key.SetValue(@"PicturePosition", "10");
                key.SetValue(@"TileWallpaper", "0");
                break;
            }
            key.Close();

            const int SET_DESKTOP_BACKGROUND  = 20;
            const int UPDATE_INI_FILE         = 1;
            const int SEND_WINDOWS_INI_CHANGE = 2;

            NativeMethods.SystemParametersInfo(SET_DESKTOP_BACKGROUND, 0, getBackgroundPath(background), UPDATE_INI_FILE | SEND_WINDOWS_INI_CHANGE);

            Console.WriteLine("Wallpaper set to Image at path ");
        }
Beispiel #3
0
 private static string getBackgroundPath(ImageExt background)
 {
     return(background.Filename);
 }