public void AddThumb(string thumb, string name, int width, int height, object callback) { if (task.ShouldAbort()) { throw new AbortedException(); } long size = new long(); Stream http = ArtDownloader.GetHTTPStream(thumb, ref size); AlbumArtDownloader.ArtDownloader.ThumbRes result = new AlbumArtDownloader.ArtDownloader.ThumbRes(); result.Width = width; result.Height = height; result.CallbackData = callback; result.OwnerTask = task; result.ScriptOwner = script; if (callback == null) { result.FullSize = new MemoryStream(); artdownloader.GetStreamToStream(result.FullSize, http, 0, false); result.Thumb = System.Drawing.Bitmap.FromStream(result.FullSize); result.FullSize.Seek(0, SeekOrigin.Begin); } else { result.Thumb = System.Drawing.Bitmap.FromStream(http); } result.Name = name; task.AddResult(result); ++rescount; artdownloader.mainForm.BeginInvoke(artdownloader.mainForm.taskupdate, task, script, estimate == 0 ? string.Format("{0}", rescount) : string.Format("{0}/{1}", rescount, estimate)); if (rescount >= Properties.Settings.Default.MaxResults) { throw new AbortedException(); } }
public TaskThread(ArtDownloader a) { artdownloader = a; e_abort = new ManualResetEvent(false); e_wakeup = new AutoResetEvent(false); thread = new Thread(new ThreadStart(this.Run)); a.RegisterThread(this); }
public Task(ArtDownloader a, string artist, string album, string filesave, bool showExisting, bool showFolder, ListViewItem item) { e_abort = new ManualResetEvent(false); _Artist = artist; artdownloader = a; _Album = album; _showExisting = showExisting; _showFolder = showFolder; listviewitem = item; status = State.Waiting; savestr = filesave; _Done = false; scripts = new List <Script>(); results = new List <AlbumArtDownloader.ArtDownloader.ThumbRes>(); }
public Task(ArtDownloader a, string artist, string album, string filesave, bool showExisting, bool showFolder, bool bDebug) { e_abort = new ManualResetEvent(false); _Artist = artist; _Album = album; _showExisting = showExisting; _showFolder = showFolder; status = State.Waiting; artdownloader = a; savestr = filesave; isdebug = bDebug; _Done = false; scripts = new List <Script>(); results = new List <AlbumArtDownloader.ArtDownloader.ThumbRes>(); }
static void Main(string[] args) { if (args.Length == 0 || args.Contains("--help") || args.Contains("--h")){ PrintHelp(); return; } if (args.Contains("-l")){ PrintLicense(); return; } bool result; ArtDownloaderOptions opt = ParseArguments(args, out result); if (result) { ArtDownloader downloader = new ArtDownloader(opt); downloader.Run(); } }
internal Script(ArtDownloader a, Type thetype) { lock (this) { _Name = thetype.Name; artdownloader = a; getThumbs = thetype.GetMethod("GetThumbs", BindingFlags.Static | BindingFlags.Public); getResult = thetype.GetMethod("GetResult", BindingFlags.Static | BindingFlags.Public); PropertyInfo nameinfo = thetype.GetProperty("SourceName", BindingFlags.Static | BindingFlags.Public); _Name = nameinfo.GetValue(null, null).ToString(); nameinfo = thetype.GetProperty("SourceVersion", BindingFlags.Static | BindingFlags.Public); _Version = nameinfo.GetValue(null, null).ToString(); try { nameinfo = thetype.GetProperty("SourceCreator", BindingFlags.Static | BindingFlags.Public); _Creator = nameinfo.GetValue(null, null).ToString(); } catch { _Creator = ""; } if (getThumbs == null || getResult == null) { throw new Exception("Script must implement GetThumbs() And GetResult()"); } group = a.mainForm.AddGroup(this); listcol = a.mainForm.AddCol(this); } }
public ScriptTask(Script s, Task t, ArtDownloader a) { script = s; task = t; artdownloader = a; }