private async void MyCreation_OnLoaded(object sender, RoutedEventArgs e) { GenerateBgService generateBgService = new GenerateBgService(); MyCreationPageBg.ImageSource = await generateBgService.GetBitmapImageAsync(); //await MyCreationPageBg.Blur(value: 10, duration: 10, delay: 0).StartAsync(); }
/// <summary> /// Page Loading. /// </summary> /// <param name="sender"></param> /// <param name="args"></param> private async void RecommendPage_OnLoading(FrameworkElement sender, object args) { GridLoading.Visibility = Visibility.Visible; ProgressRingLoading.IsActive = true; GenerateBgService generateBgService = new GenerateBgService(); try { // 显示背景 RecommendPageBg.ImageSource = await generateBgService.GetBitmapImageAsync(); // 显示诗句 DataContext = ViewModelLocator.Instance.RecommendPageViewModel; string text = ShowPoetryArea.Text; if (localSettings.Values["SetWallpaper"] != null && localSettings.Values["SetWallpaper"].Equals(true)) { // 用户允许将每日推荐图片设置为壁纸 await generateBgService.CreateBackgroundImageAsync(text); WallpaperService wallpaperService = new WallpaperService(); if (!await wallpaperService.WallpaperChanger()) { // Todo: 当设置壁纸失败时异常处理。 } } else if (localSettings.Values["SetLockScreen"] != null && localSettings.Values["SetLockScreen"].Equals(true)) { // 用户允许将每日推荐图片设置为锁屏 await generateBgService.CreateBackgroundImageAsync(text); WallpaperService wallpaperService = new WallpaperService(); if (!await wallpaperService.LockScreenChanger()) { // Todo: 当设置锁屏失败时异常处理。 } } ProgressRingLoading.IsActive = false; GridLoading.Visibility = Visibility.Collapsed; } catch (Exception imgOrTxtException) { TextBlockLoading.FontSize = 20; TextBlockLoading.Text = "ExceptionInfo: " + imgOrTxtException.Message + "\n抱歉,这里发生了一些错误,请您确保网络连接正常 " + "\n如果仍存在加载失败的情况,请您及时给予我们反馈" + "\n我们将在新版本中解决该问题,以带给您更好的使用体验。谢谢!"; } }