private void btnSetWallpaper_Click(object sender, EventArgs e) { string tempPath = Path.Combine(Path.GetTempPath(), "wallpaper.bmp"); picture.Image.Save(tempPath, System.Drawing.Imaging.ImageFormat.Bmp); Wallpaper.Set(tempPath, Wallpaper.Style.Fit); }
private static void MainConsole(string[] args) { var date = DateTime.Now; if (args[0].ToLower() == "-w" || args[0].ToLower() == "/w" || args[0].ToLower() == "-wallpaper" || args[0].ToLower() == "/wallpaper") { FreeConsole(); string imgUrl = null; if (args.Length < 2 || args[1].ToUpper() == "RANDOM") { imgUrl = MoonNasaImageHelper.GetRandomMoonImageUrl(date); } else { int id; if (int.TryParse(args[1], out id)) { imgUrl = MoonNasaImageHelper.GetMoonImageUrl(id, date); } else if (args[1].ToUpper().StartsWith("NASA") && args[1].Length > 4) { id = int.Parse(args[1].Substring(3, 1)); imgUrl = MoonNasaImageHelper.GetMoonImageUrl(id, date); } else { imgUrl = MoonNasaImageHelper.GetMoonImageUrl(args[1], date); } } if (imgUrl != null) { var style = args.Length < 3 ? Wallpaper.Style.Fit : (Wallpaper.Style)Enum.Parse(typeof(Wallpaper.Style), args[2], true); Wallpaper.Set(ImageDownload.FromUrl(imgUrl), style); } } else if (args[0].ToLower() == "-i" || args[0].ToLower() == "/i" || args[0].ToLower() == "-install" || args[0].ToLower() == "/install") { // install int mins = args.Length < 3 ? 15 : int.Parse(args[2]); int start_mins = args.Length < 4 ? 0 : int.Parse(args[3]); var imgType = args.Length < 2 ? "NASA1" : args[1]; var style = args.Length < 5 ? "Fit" : args[4]; TaskSchedule.CreateSchedule(mins, start_mins, imgType, style); } else if (args[0].ToLower() == "-u" || args[0].ToLower() == "/u" || args[0].ToLower() == "-uninstall" || args[0].ToLower() == "/uninstall") { TaskSchedule.DeleteSchedule(args[1]); } else { AttachToParentConsole(); ShowHelp(); } }