Пример #1
0
        public async Task RefreshWallpaper(Settings settings)
        {
            Logger.LogInformation("> Downloading wallpaper image...");
            await Wallpaper.Set(
                new Uri(settings.Source.BuildUrlString(settings)),
                settings.WallpaperDisplayStyle);

            Logger.LogInformation("> New wallpaper set!");
        }
Пример #2
0
        public static void Main(string[] args)
        {
            Console.WriteAscii("Unsplash", Color.MediumSlateBlue);
            Console.WriteLine("Version 1.2.5", Color.YellowGreen);
            Console.WriteLine("Help us @ https://github.com/redbaty/Unsplash.Desktop\n", Color.Gray);

            if (args.Length == 0 || args[0] != "-g")
            {
                try
                {
                    Settings =
                        JsonConvert.DeserializeObject <Settings>(
                            File.ReadAllText(Environment.ExpandEnvironmentVariables("%USERPROFILE%\\Unsplash.desktop")),
                            JsonSettings
                            );
                }
                catch (Exception ex)
                {
                    Console.WriteLine("> Failed to load settings.", Color.Crimson);
                    Console.WriteLine(ex.Message, Color.Crimson);
                    Console.WriteLine("> Run the program with -g to generate another one.", Color.CadetBlue);
                    return;
                }
            }
            else if (args.Length != 0 && args[0] == "-g")
            {
                GenerateSettings();
            }

            Console.WriteLine("> Downloading wallpaper image...", Color.Gray);
            Wallpaper.Set(
                new Uri(Settings.Source.BuildUrlString(Settings)),
                Settings.WallpaperDisplayStyle);
            Console.WriteLine("> New wallpaper set!", Color.LimeGreen);
            Console.WriteLine("> Press any key to continue", Color.Gray);
        }