public async void DoChange() { UnsplashImageProvider unsplahsImage = new UnsplashImageProvider(wallpaperMonsterConfiguration); WebResponse webResponse = unsplahsImage.LoadWebResponse(dimensions); InMemoryRandomAccessStream randomAccessStream = new InMemoryRandomAccessStream(); using (Stream stream = unsplahsImage.FindRandomImageStream(webResponse)) { Stream memoryStream = new MemoryStream(); await stream.CopyToAsync(memoryStream); memoryStream.Position = 0; await memoryStream.CopyToAsync(randomAccessStream.AsStreamForWrite()); memoryStream.Position = 0; if (wallpaperMonsterConfiguration.FindShouldChangeWallpaper()) { ChangeWallpaper(unsplahsImage, memoryStream); } } if (wallpaperMonsterConfiguration.FindShouldChangeLockScreen()) { ChangeLockScreen(randomAccessStream); } }
public SettingsForm() { InitializeComponent(); wallpaperMonsterConfiguration = new WallpaperMonsterConfiguration(); wallpaperMonsterService = new WallpaperMonsterService(wallpaperMonsterConfiguration, ScreenResolution.findScreenResolution(this)); wallpaperMonsterTimer = new WallpaperMonsterTimer(wallpaperMonsterService); periodSettings.Value = wallpaperMonsterConfiguration.FindPeriodDecimal(); wallpaperCheckBox.Checked = wallpaperMonsterConfiguration.FindShouldChangeWallpaper(); lockScreenCheckBox.Checked = wallpaperMonsterConfiguration.FindShouldChangeLockScreen(); wallpaperMonsterTimer.ChangeTimerPeriod(wallpaperMonsterConfiguration.FindPeriod()); prepareCategoryCombobox(); }