Пример #1
0
        /// <summary>
        /// Get Latest Wallpaper
        /// </summary>
        public async void GetLatestWallpaper()
        {
            HistoryImage historyImage = null;

            try
            {
                historyImage = await _provider.GetLatestImage();

                // 保存到历史记录
                HistoryImageProvider.AddImage(historyImage);
            }
            catch
            {
                historyImage = HistoryImageProvider.getRandom();
            }

            if (historyImage != null)
            {
                Invoke(new Action(async() =>
                {
                    this.CurrentWallpaper = historyImage;
                    await UpdateWallpaper();
                }));
            }
        }
Пример #2
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();
            }
        }