private async Task <ChangeWallpaperResult> ChangeWallpaperImpl(IProgress <string> progress) { int wallpaperGrabType = Properties.Settings.Default.wallpaperGrabType; string searchUrl = SearchUrlProvider.GetSearchUrl(wallpaperGrabType, progress); var imageInfo = await ImageInfoProvider.GetImageInfoAsync(searchUrl, wallpaperGrabType, progress); if (imageInfo == null || string.IsNullOrEmpty(imageInfo.Url)) { return(ChangeWallpaperResult.Failed()); } if (Database.IsBlackListed(imageInfo.Url)) { progress.Report("Wallpaper is blacklisted."); Logging.LogMessageToFile("The selected wallpaper has been blacklisted, searching again.", 0); return(ChangeWallpaperResult.Failed()); } if (Properties.Settings.Default.suppressDuplicates == true && HistoryList.Contains(imageInfo.ThreadId)) { progress.Report("Wallpaper already used in this session."); Logging.LogMessageToFile("The selected wallpaper has already been used in this session, searching again.", 0); return(ChangeWallpaperResult.Failed()); } return(await SetWallpaperAsync(imageInfo, progress)); }
public static void PushToHistoryList(string data) { if (!HistoryList.Contains(data)) { HistoryList.Remove(data); } // 超过最大限制则移除最后一个. var maxCount = 10; if (HistoryList.Count > maxCount) { HistoryList.RemoveAt(HistoryList.Count - 1); } HistoryList.Insert(0, data); SaveHistoryData(); // 调用委托 OnHistoryListChanged?.Invoke(); }