private void listView1_MouseLeave(object sender, EventArgs e) { //this.materialCard1.Visible = false; if (tf != null) { tf.Close(); tf.Dispose(); tf = null; } }
private void listView1_ItemMouseHover(object sender, ListViewItemMouseHoverEventArgs e) { if (tf != null) { tf.Close(); tf.Dispose(); tf = null; } try { lastHover.BackColor = System.Drawing.Color.White; } catch { } ListViewItem lvi = e.Item as ListViewItem; PartTypes.Part p = _parts[lvi.Name]; try { String filepath = @"C:\Documents\ExtrusionLibrary\Thumbnails"; if (!System.IO.Directory.Exists(filepath)) { System.IO.Directory.CreateDirectory(filepath); } List <string> files = Directory.GetFiles(filepath).ToList(); string dwg = ""; foreach (string imgfile in files) { // Use local thumb resources if (Path.GetFileNameWithoutExtension(imgfile) == p.ID) { p.thumb = (Bitmap)Bitmap.FromFile(imgfile); double ratioL = 0; if (p.thumb.Width > p.thumb.Height) { ratioL = 200.0 / p.thumb.Width; } else { ratioL = 200.0 / p.thumb.Height; } p.thumbL = new Bitmap(p.thumb, new Size((int)Math.Round(p.thumb.Width * ratioL), (int)Math.Round(p.thumb.Height * ratioL))); tf = new ThumbForm(p.thumbL); tf.StartPosition = FormStartPosition.Manual; tf.Location = new Point(this.Location.X - (tf.Width + 5), this.Location.Y); tf.Show(this); break; } } } catch (Exception ex) { p.thumb = null; p.thumbL = null; MessageBox.Show(ex.Message); } }