public static async Task RunAsync() { var y = YandeSettings.Current; var a = AppSettings.Current; var key = y.WallpaperUpdateTaskSearchKey; var shuffle = y.WallpaperUpdateTaskShuffleCount; var old = y.WallpaperUpdateTaskCurrentImageFileUri; y.WallpaperUpdateTaskCurrentImageID = ""; try { // Search for posts var posts = await Posts.DownloadPostsAsync(1, $"https://yande.re/post.xml?tags={ WebUtility.UrlEncode(key) }"); // Set wallpaper var result = await AnimePersonalization.SetBackgroundImageAsync(posts, shuffle, y.WallpaperUpdateTaskCropMethod, a.ScreenSize, false); // Notice the app that the wallpapaer was changed y.WallpaperUpdateTaskCurrentImageID = result; // Motice user about the change BigImageToast(result, y.WallpaperUpdateTaskCurrentImageFileUri, y.AvatarUri); } catch (Exception ex) { y.WallpaperUpdateTaskCurrentImageID = old; ToastService.ToastDebug("Cannot Update Wallpaper", ex.StackTrace); ToastService.ToastDebug("Cannot Update Wallpaper", ex.Message); } }
private async void Button_Click(object sender, RoutedEventArgs e) { try { var p = await Posts.DownloadPostsAsync(1, $"https://yande.re/post.xml?tags={ WebUtility.UrlEncode(TileTextBox.Text) }"); await AnimePersonalization.SetTileAsync(p); } catch (Exception ex) { } }
public async void Run(IBackgroundTaskInstance taskInstance) { var d = taskInstance.GetDeferral(); try { var cost = BackgroundWorkCost.CurrentBackgroundWorkCost; var p = await Posts.DownloadPostsAsync(1, $"https://yande.re/post.xml?tags={ WebUtility.UrlEncode(YandeSettings.Current.TileUpdateTaskSearchKey) }"); await AnimePersonalization.SetTileAsync(p); } catch (Exception ex) { ToastService.ToastDebug("Cannot Update Tile", ex.StackTrace); ToastService.ToastDebug("Cannot Update Tile", ex.Message); } d.Complete(); }
public static async Task RunAsync() { var yandeSettings = YandeSettings.Current; var key = yandeSettings.TileUpdateTaskSearchKey; var filter = yandeSettings.TilePostFilter; try { var cost = BackgroundWorkCost.CurrentBackgroundWorkCost; var posts = await Posts.DownloadPostsAsync(1, $"{YandeClient.HOST}/post.xml?tags={ WebUtility.UrlEncode(key) }"); var filteredPosts = new FilteredCollection <Post, Posts>(posts, filter); await AnimePersonalization.SetTileAsync(filteredPosts); } catch (Exception ex) { ToastService.ToastDebug("Cannot Update Tile", ex.StackTrace); ToastService.ToastDebug("Cannot Update Tile", ex.Message); } }
public static async Task RunAsync() { var yandeSettings = YandeSettings.Current; var appSettings = AppSettings.Current; var key = yandeSettings.WallpaperUpdateTaskSearchKey; var shuffle = yandeSettings.WallpaperUpdateTaskShuffleCount; var filter = yandeSettings.WallpaperPostFilter; var old = yandeSettings.WallpaperUpdateTaskCurrentImageFileUri; yandeSettings.WallpaperUpdateTaskCurrentImageID = ""; try { // Search for posts var posts = await Posts.DownloadPostsAsync(1, $"https://yande.re/post.xml?tags={ WebUtility.UrlEncode(key) }"); var filteredPosts = new FilteredCollection <Post, Posts>(posts, filter); // Unset the previous wallpaper, so that the image file is no longer in use yandeSettings.WallpaperUpdateTaskCurrentImageID = ""; // Set wallpaper var result = await AnimePersonalization.SetBackgroundImageAsync(filteredPosts, shuffle, yandeSettings.WallpaperUpdateTaskCropMethod, appSettings.ScreenSize, false, yandeSettings.WallpaperUpdateTaskQuality); // Notice the app that the wallpapaer was changed yandeSettings.WallpaperUpdateTaskCurrentImageID = result; // Motice user about the change // TODO: need opt out settings //BigImageToast(result, yandeSettings.WallpaperUpdateTaskCurrentImageFileUri, yandeSettings.AvatarUri); } catch (Exception ex) { yandeSettings.WallpaperUpdateTaskCurrentImageID = old; ToastService.ToastDebug("Cannot Update Wallpaper", ex.StackTrace); ToastService.ToastDebug("Cannot Update Wallpaper", ex.Message); } }
private void Button_Click_1(object sender, RoutedEventArgs e) { AnimePersonalization.ResetTile(); }