/*

CLASS {Set_wallpaper_color}, UNTESTED, NATIVE:

NATIVE: "///COPY Set_wallpaper_color.cs" .

*/

using System;
using System.Data;
using System.Text;
using System.Runtime.InteropServices;
using AL4;

namespace AL4_project
{

	public class AL4_Set_wallpapercolor
	{
	
		[DllImport("user32.dll")]
        public static extern Int32 SystemParametersInfo(
            UInt32 action, UInt32 uParam, String vParam, UInt32 winIni);
 
        public static readonly UInt32 SPI_SETDESKWALLPAPER  = 0x14;
        public static readonly UInt32 SPI_GETDESKWALLPAPER  = 0x73;
        public static readonly UInt32 SPIF_UPDATEINIFILE    = 0x01;
        public static readonly UInt32 SPIF_SENDWININICHANGE = 0x02;

        public static void Set_wallpaper(String path)
        {
            //Console.WriteLine("Setting wallpaper to '" + path + "'");
            SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, path,
                SPIF_UPDATEINIFILE | SPIF_SENDWININICHANGE);
        }
        
        [DllImport("user32.dll")]
		static extern bool SetSysColors(
		int cElements, int [] lpaElements, uint [] lpaRgbValues);
		
		public const int COLOR_DESKTOP = 1;
        
        public static void Set_color(int color)
        {
        
        	StringBuilder space = new StringBuilder();
        	space.Append(' ', 4096);
        	String was_wall = space.ToString(); 
        	SystemParametersInfo(SPI_GETDESKWALLPAPER, 4095, was_wall, 0);
                
        	if (was_wall != "")
        	{
	        	SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, "",
	                SPIF_UPDATEINIFILE | SPIF_SENDWININICHANGE);
        	}

			int[] elements = {COLOR_DESKTOP};
			uint[] colors = {(uint)(color & 0xFFFFFF)};
			SetSysColors(elements.Length, elements, colors);
        }

		
	}
	
}

/*

FUN Set_color(INT Color|_RGB), NATIVE : @
	"AL4_Set_wallpapercolor.Set_color((int)X_Color);" .

FUN Set_wallpaper(
STR Path|_to_image_BMP_or_JPEG), NATIVE : @
	"AL4_Set_wallpapercolor.Set_wallpaper(X_Path);" .

END

*/
