예제 #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 { }
            }
        }
예제 #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();
            }
        }
예제 #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();
            }
        }
예제 #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();
            }
        }
예제 #5
0
        //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);
            }
        }