private Control GetImage(Main main, DatabaseRowEntry entry, DatabaseRowEntry.KeyValuePair<string, string> image, int row) { Picture control = null; // First check if we've already downloaded this image. string cache = Path.Combine(Path.GetDirectoryName(Properties.Settings.Default.Collection), @"cache"); if (!File.Exists(cache)) Directory.CreateDirectory(cache); cache = Path.Combine(cache, image.Key); if (File.Exists(cache)) { control = new Picture(entry) { Image = Image.FromFile(cache), Width = 130, Height = 130, SizeMode = PictureBoxSizeMode.Zoom }; } else { control = new Picture() { Image = Properties.Resources.loading, Width = 130, Height = 130, SizeMode = PictureBoxSizeMode.CenterImage}; var imageDownloader = new DownloadImage(main, entry, control, row, image.Value, cache); new Thread(new ThreadStart(imageDownloader.Download)).Start(); } return control; }
public DownloadImage(Main main, DatabaseRowEntry entry, Control placeHolder, int row, string uri, string cache) { // TODO: Complete member initialization this.main = main; this.entry = entry; this.placeHolder = placeHolder; this.uri = uri; this.row = row; this.cache = cache; }
public Picture(DatabaseRowEntry entry) { DoubleClick += new System.EventHandler(OnDoubleClick); this.entry = entry; }