private void SetFlowLayout(string path) { if (!Directory.Exists(path)) { return; } this.flowLayoutPanel_GalleryItem.Controls.Clear(); DirectoryInfo di = new DirectoryInfo(path); FileSystemInfo[] files = di.GetFileSystemInfos(); try { for (int i = 0; i < files.Length; i++) { //如果不是文件 if (files[i] is FileInfo) { FileInfo file = files[i] as FileInfo; string ext = file.Extension; if (ext.ToLower() != ".mxd") { continue; } string title = Path.GetFileNameWithoutExtension(file.FullName); string hoverImgPath = clsConfig.GetThumbFolder(dataPath) + "\\" + title + ".jpg"; ucGalleryItem gi = new ucGalleryItem(); gi.Title = title; gi.HoverImagePath = hoverImgPath; gi.DataPath = file.FullName; gi.delegateClick += new delegateClick(gi_Click); gi.delegateMouseEnter += new delegateMouseEnter(gi_MouseEnter); gi.delegateMouseLeave += new delegateMouseLeave(gi_MouseLeave); //滚动事件 gi.MouseWheel += FlowLayoutMouseWheel_MouseWheel; //gi.BackColorPanel.MouseWheel += FlowLayoutMouseWheel_MouseWheel; //gi.TitleLabel.MouseWheel += FlowLayoutMouseWheel_MouseWheel; this.flowLayoutPanel_GalleryItem.Controls.Add(gi); } } } catch { } }
void gi_MouseEnter(ucGalleryItem ucgi) { if (ucgi != null) { if (!File.Exists(ucgi.HoverImagePath)) { return; } Image img = Image.FromFile(ucgi.HoverImagePath); this.pic_PreView.BackgroundImage = img; this.lbl_PreViewMapTitle.Text = ucgi.Title; this.pic_PreView.Tag = ucgi.DataPath; } }
void gi_MouseLeave(ucGalleryItem ucgi) { //this.pic_PreView.BackgroundImage = null; //this.lbl_PreViewMapTitle.Text = ""; }
void gi_Click(ucGalleryItem ucgi) { frmMapView frmMap = new frmMapView(parentForm, this); frmMap.MapPath = ucgi.DataPath; frmMap.Show(); }