private void SaveThreadList() { try { ThreadList.Save(); } catch { } }
private void LoadThreadList() { ThreadList.Load((watcher) => { AttachWatcherToUI(watcher); DisplayDescription(watcher); DisplayAddedOn(watcher); DisplayLastImageOn(watcher); if (watcher.IsStopping) { SetStopStatus(watcher); } }); }
private bool AddThread(string pageUrl, string pageAuth, string imageAuth, int checkIntervalSeconds, bool oneTimeDownload, string description, UrlTransformResult urlTransformResult) { if (urlTransformResult != null) { pageUrl = urlTransformResult.TransformedUrl; } SiteHelper siteHelper = SiteHelper.CreateByUrl(pageUrl); string globalThreadID = siteHelper.GetGlobalThreadID(); ThreadWatcher watcher = ThreadList.Items.FirstOrDefault(w => w.GlobalThreadID.Equals(globalThreadID, StringComparison.OrdinalIgnoreCase)); if (watcher == null) { description ??= urlTransformResult?.DefaultDescription ?? siteHelper.GetDefaultDescription(); watcher = ThreadWatcher.Create(siteHelper, pageUrl, pageAuth, imageAuth, oneTimeDownload, checkIntervalSeconds, description); AttachWatcherToUI(watcher); DisplayDescription(watcher); DisplayAddedOn(watcher); ThreadList.Add(watcher); } else { if (watcher.IsRunning) { return(false); } watcher.PageAuth = pageAuth; watcher.ImageAuth = imageAuth; watcher.CheckIntervalSeconds = checkIntervalSeconds; watcher.OneTimeDownload = oneTimeDownload; if (description != null) { watcher.Description = description; DisplayDescription(watcher); } } watcher.Start(); _saveThreadList = true; return(true); }
private void RemoveThreads(bool removeCompleted, bool removeSelected, Action <ThreadWatcher> preRemoveAction = null) { int i = 0; while (i < lvThreads.Items.Count) { ThreadWatcher watcher = (ThreadWatcher)lvThreads.Items[i].Tag; if ((removeCompleted || (removeSelected && lvThreads.Items[i].Selected)) && !watcher.IsRunning) { try { preRemoveAction?.Invoke(watcher); } catch { } lvThreads.Items.RemoveAt(i); ThreadList.Remove(watcher); } else { i++; } } _saveThreadList = true; }