コード例 #1
0
 private void listView1_MouseLeave(object sender, EventArgs e)
 {
     //this.materialCard1.Visible = false;
     if (tf != null)
     {
         tf.Close();
         tf.Dispose();
         tf = null;
     }
 }
コード例 #2
0
        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 { } finally { lastHover = e.Item as ListViewItem; }
            ListViewItem lvi = e.Item as ListViewItem;

            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) == lvi.Name)
                    {
                        Bitmap thumb = (Bitmap)Bitmap.FromFile(imgfile);

                        double ratioL = 0;
                        if (thumb.Width > thumb.Height)
                        {
                            ratioL = 200.0 / thumb.Width;
                        }
                        else
                        {
                            ratioL = 200.0 / thumb.Height;
                        }
                        Bitmap thumbL = new Bitmap(thumb, new Size((int)Math.Round(thumb.Width * ratioL), (int)Math.Round(thumb.Height * ratioL)));
                        tf = new ThumbForm(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)
            {
                MessageBox.Show(ex.Message);
            }
        }