internal void setPix(ScoreEntry2 sel, bool first, PictureBox pbox, Label plab) { if (sel == null) { return; } string zipF; string fi; if (first) { zipF = sel.F1 == null ? "" : sel.F1.ZipFile; fi = sel.F1 != null ? sel.F1.InnerPath : ""; } else { zipF = sel.F2 == null ? "" : sel.F2.ZipFile; fi = sel.F2 != null ? sel.F2.InnerPath : ""; } if (string.IsNullOrEmpty(zipF) || string.IsNullOrEmpty(fi)) { pbox.Image = null; plab.Text = ""; return; } var imgF = _loader.Extract(zipF, fi); if (!string.IsNullOrEmpty(imgF)) // clean up all created temp files on close { _toCleanup.Add(imgF); } try { if (string.IsNullOrEmpty(imgF)) { pbox.Image = null; plab.Text = ""; return; } // load image to picturebox with no file lock pbox.Image = Image.FromStream(new MemoryStream(File.ReadAllBytes(imgF))); // no file lock // set image stats to label var info1 = new FileInfo(imgF); var size1 = pbox.Image.Size; plab.Text = string.Format("{0},{1} [{2:0.00}K]", size1.Width, size1.Height, (double)info1.Length / 1024.0); } catch { } }
private void listBox1_SelectedIndexChanged(object sender, EventArgs e) { var sel = listBox1.SelectedItem as ScoreEntry; if (sel == null) { return; } return; // TODO #if false var f1 = sel.F1.path; var f2 = sel.F2.path; pictureBox1.SizeMode = PictureBoxSizeMode.Zoom; pictureBox2.SizeMode = PictureBoxSizeMode.Zoom; pictureBox1.ImageLocation = _loader.Extract(sel.F1.ZipFile, sel.F1.InnerPath); pictureBox2.ImageLocation = _loader.Extract(sel.F2.ZipFile, sel.F2.InnerPath); try { pictureBox1.Load(); imageStat(pictureBox1, label1); } catch { } try { pictureBox2.Load(); imageStat(pictureBox2, label2); } catch { } #endif }