private void RefreshThumbnails() { foreach (var item in m_thumbnailControl.Items) { if (item.Image != null) { item.Image.Dispose(); } } m_thumbnailControl.Selection.Clear(); m_thumbnailControl.Items.Clear(); m_thumbnailControl.Invalidate(); if (m_treeContext != null) { IResourceFolder currentAssetFolder = m_treeContext.GetLastSelected <IResourceFolder>(); if (currentAssetFolder == null || !m_thumbnailControl.Visible) { return; } foreach (Uri resourceUri in currentAssetFolder.ResourceUris) { m_thumbnailService.ResolveThumbnail(resourceUri); string assetPath = resourceUri.LocalPath; string assetFileName = Path.GetFileName(assetPath); Icon shellIcon = FileIconUtil.GetFileIcon(assetFileName, FileIconUtil.IconSize.Large, false); Bitmap tempThumbnail = shellIcon.ToBitmap(); shellIcon.Dispose(); ThumbnailControlItem item = NewItem(resourceUri, tempThumbnail); m_thumbnailControl.Items.Add(item); } m_thumbnailControl.RecalculateClientSize(); } }
private void ThumbnailManager_ThumbnailReady(object sender, ThumbnailReadyEventArgs e) { // get rid of temporary thumbnail Uri resourceUri = e.ResourceUri; ThumbnailControlItem item = GetItem(resourceUri); if (item != null) { if (item.Image != null) { item.Image.Dispose(); } item.Image = e.Image; } m_thumbnailControl.Invalidate(); }
private Uri GetClickedItemUri(Point point) { Uri resourceUri = null; if (m_thumbnailControl.Visible) { ThumbnailControlItem item = m_thumbnailControl.PickThumbnail(point); if (item != null) { resourceUri = item.Uri; } } else { resourceUri = (Uri)m_listViewAdapter.GetItemAt(point); } return(resourceUri); }
/// <summary> /// Raises the MouseMove event</summary> /// <param name="e">Event args</param> protected override void OnMouseMove(MouseEventArgs e) { if (e.Button == MouseButtons.None) { ThumbnailControlItem thumbnail = PickThumbnail(new Point(e.X, e.Y)); if (thumbnail != m_hoverThumbnail) { m_hoverThumbnail = thumbnail; m_hoverTimer.Start(); } } if (m_multiSelecting) { m_mousePt = e.Location; Invalidate(); } base.OnMouseMove(e); }
/// <summary> /// Raises the MouseDown event</summary> /// <param name="e">Event args</param> protected override void OnMouseDown(MouseEventArgs e) { this.Focus(); if (e.Button == MouseButtons.Left) { ThumbnailControlItem hitItem = PickThumbnail(e.Location); if (hitItem != null) { if (!m_selection.Contains(hitItem)) { ThumbnailControlItem[] items = { hitItem }; SelectItem(items); } } else { m_multiSelecting = true; m_startPt = e.Location; m_mousePt = e.Location; } } this.Invalidate(); base.OnMouseDown(e); }
private ThumbnailControlItem NewItem(Uri resourceUri, Image image) { ThumbnailControlItem item = new ThumbnailControlItem(image, resourceUri); return(item); }