Exemple #1
0
        private async System.Threading.Tasks.Task UpdateWallpaper()
        {
            if (CurrentWallpaper != null)
            {
                try
                {
                    var img = await CurrentWallpaper.getImage();

                    Wallpaper.Set(img, Wallpaper.Style.Stretched);
                }
                catch { }
            }
        }
Exemple #2
0
        /// <summary>
        /// 随机壁纸
        /// </summary>
        public async void SetRandomWallpaper()
        {
            try
            {
                var bingImg = HistoryImageProvider.getRandom();
                var img     = await bingImg.getImage();

                Wallpaper.Set(img, Wallpaper.Style.Stretched);
                _currentWallpaper = bingImg;
                ShowSetWallpaperNotification();
            }
            catch (Exception ex)
            {
                ShowErrorNotification();
            }
        }
Exemple #3
0
        /// <summary>
        /// SetWallpaper fetches the wallpaper from Bing and sets it
        /// </summary>
        public async void SetWallpaper()
        {
            try
            {
                var bingImg = await _provider.GetImage();

                Wallpaper.Set(bingImg.Img, Wallpaper.Style.Stretched);
                _currentWallpaper = bingImg.Img;
                SetCopyrightTrayLabel(bingImg.Copyright, bingImg.CopyrightLink);

                ShowSetWallpaperNotification();
            }
            catch
            {
                ShowErrorNotification();
            }
        }
Exemple #4
0
        /// <summary>
        /// 获取最新壁纸
        /// </summary>
        public async void SetWallpaper()
        {
            try
            {
                var bingImg = await _provider.GetLatestImage();

                var img = await bingImg.getImage();

                Wallpaper.Set(img, Wallpaper.Style.Stretched);
                _currentWallpaper = bingImg;
                ShowSetWallpaperNotification();

                // 保存到历史记录
                HistoryImageProvider.AddImage(bingImg);
            }
            catch
            {
                ShowErrorNotification();
            }
        }
        //Config End

        private void Run()
        {
            ReadConfig();
            _bingApi.Time     = _time;
            _bingApi.Location = _location;
            try
            {
                _bingApi.Init();
                String localImagePath = DownloadImage();
                Console.WriteLine("开始设置壁纸:" + localImagePath);
                Wallpaper.Set(localImagePath, Wallpaper.Style.Stretched);
                Console.WriteLine("设置壁纸成功");
            }
            catch (WebException e)
            {
                Console.WriteLine("网络连接失败,请连接网络后重试。");
            }
            catch (Exception e)
            {
                Console.WriteLine("程序运行发生异常:" + e.Message);
            }
        }