private void OnGalleryMouseDown(object sender, MouseEventArgs e) { _menuHitInfo = null; ImageListView.HitInfo hitInfo; imageListView.HitTest(new Point(e.X, e.Y), out hitInfo); if (ModifierKeys != Keys.None) return; if (!hitInfo.InItemArea) return; switch (e.Button) { case MouseButtons.Right: _menuHitInfo = hitInfo; contextMenuStrip.Show(MousePosition); break; } }
/// <summary> /// Draws an overlay image over the client area. /// </summary> /// <param name="g">The System.Drawing.Graphics to draw on.</param> /// <param name="bounds">The bounding rectangle of the client area.</param> public override void DrawOverlay(Graphics g, Rectangle bounds) { // Refresh process info Process p = Process.GetCurrentProcess(); p.Refresh(); long mem = Math.Max(0, p.PrivateMemorySize64 - baseMem); // Display memory stats string s = string.Format("Total: {0}\r\nCache: {1}\r\nCache*: {2}", Utility.FormatSize(baseMem), Utility.FormatSize(mem), Utility.FormatSize(mImageListView.cacheManager.MemoryUsed)); SizeF sz = g.MeasureString(s, ImageListView.Font); Rectangle r = new Rectangle(ItemAreaBounds.Right - 120, ItemAreaBounds.Top + 5, 115, (int)sz.Height); using (Brush b = new SolidBrush(Color.FromArgb(220, Color.LightGray))) { g.FillRectangle(b, r); } using (Pen pen = new Pen(Color.FromArgb(128, Color.Gray))) { g.DrawRectangle(pen, r); } g.DrawString(s, ImageListView.Font, Brushes.Black, r.Location); // Display navigation parameters r = new Rectangle(ItemAreaBounds.Right - 120, ItemAreaBounds.Top + 5 + (int)sz.Height + 10, 115, 125); using (Brush b = new SolidBrush(Color.FromArgb(220, Color.LightGray))) { g.FillRectangle(b, r); } using (Pen pen = new Pen(Color.FromArgb(128, Color.Gray))) { g.DrawRectangle(pen, r); } // Is left button down? r = new Rectangle(r.Left + 5, r.Top + 5, 15, 15); if (mImageListView.navigationManager.LeftButton) { g.FillRectangle(Brushes.DarkGray, r); } g.DrawRectangle(Pens.Black, r); r.Offset(15, 0); r.Offset(15, 0); // Is right button down? if (mImageListView.navigationManager.RightButton) { g.FillRectangle(Brushes.DarkGray, r); } g.DrawRectangle(Pens.Black, r); r.Offset(-30, 22); // Is shift key down? Color tColor = Color.Gray; if (mImageListView.navigationManager.ShiftKey) { tColor = Color.Black; } using (Brush b = new SolidBrush(tColor)) { g.DrawString("Shift", mImageListView.Font, b, r.Location); } r.Offset(0, 12); // Is control key down? tColor = Color.Gray; if (mImageListView.navigationManager.ControlKey) { tColor = Color.Black; } using (Brush b = new SolidBrush(tColor)) { g.DrawString("Control", mImageListView.Font, b, r.Location); } r.Offset(0, 20); // Display hit test details for item area ImageListView.HitInfo h = null; mImageListView.HitTest(mImageListView.PointToClient(Control.MousePosition), out h); tColor = Color.Gray; if (h.InItemArea) { tColor = Color.Black; } using (Brush b = new SolidBrush(tColor)) { g.DrawString("InItemArea (" + h.ItemIndex.ToString() + ")", mImageListView.Font, b, r.Location); } r.Offset(0, 12); // Display hit test details for column header area tColor = Color.Gray; if (h.InHeaderArea) { tColor = Color.Black; } using (Brush b = new SolidBrush(tColor)) { g.DrawString("InHeaderArea (" + h.ColumnIndex.ToString() + ")", mImageListView.Font, b, r.Location); } r.Offset(0, 12); // Display hit test details for pane area tColor = Color.Gray; if (h.InPaneArea) { tColor = Color.Black; } using (Brush b = new SolidBrush(tColor)) { g.DrawString("InPaneArea " + (h.PaneBorder ? " (Border)" : ""), mImageListView.Font, b, r.Location); } r.Offset(0, 12); }
private void toolStripMenuItemCopy_Click(object sender, EventArgs e) { var imageSource = imageListView.Items[_menuHitInfo.ItemIndex].Tag as ImageSource; if (imageSource == null || !imageSource.ContainsData) return; Clipboard.SetText(imageSource.Serialize(), TextDataFormat.Html); _menuHitInfo = null; }
private void toolStripMenuItemFavorites_Click(object sender, EventArgs e) { var imageSource = imageListView.Items[_menuHitInfo.ItemIndex].Tag as ImageSource; if (imageSource == null) return; var imageName = imageSource.Name; using (var form = new FormAddFavoriteImage(imageSource.BigImage, imageName, FavoriteImagesManager.Instance.Images.Select(i => i.Name.ToLower()))) { form.Text = "Add Image to Favorites"; form.laTitle.Text = "Save this Image in your Favorites folder for future presentations"; if (form.ShowDialog() != DialogResult.OK) return; imageName = form.ImageName; } FavoriteImagesManager.Instance.SaveImage(imageSource.BigImage, imageName); PopupMessageHelper.Instance.ShowInformation("Image successfully added to Favorites"); _menuHitInfo = null; }
private void imageListView_MouseUp(object sender, MouseEventArgs e) { _downHitInfo = null; }
private void imageListView_MouseMove(object sender, MouseEventArgs e) { imageListView.Focus(); if (e.Button != MouseButtons.Left || _downHitInfo == null || _downHitInfo.ItemIndex < 0) return; var sourceItem = imageListView.Items[_downHitInfo.ItemIndex].Tag as ImageSource; if (sourceItem == null) return; var dragSize = SystemInformation.DragSize; var dragRect = new Rectangle(new Point(_hitPoint.X - dragSize.Width / 2, _hitPoint.Y - dragSize.Height / 2), dragSize); if (dragRect.Contains(new Point(e.X, e.Y))) return; _dragRowCursor = GetDragCursor(sourceItem.BigImage); imageListView.DoDragDrop(sourceItem, DragDropEffects.All); _downHitInfo = null; }
private void toolStripMenuItemDelete_Click(object sender, EventArgs e) { var imageSource = imageListView.Items[_menuHitInfo.ItemIndex].Tag as ImageSource; if (imageSource == null) return; if (PopupMessageHelper.Instance.ShowWarningQuestion("Are you sure you want to delete image?") != DialogResult.Yes) return; _manager.DeleteImage(imageSource); _menuHitInfo = null; }
private void toolStripMenuItemRename_Click(object sender, EventArgs e) { var imageSource = imageListView.Items[_menuHitInfo.ItemIndex].Tag as ImageSource; if (imageSource == null) return; var image = imageSource.BigImage.Clone() as Image; using (var form = new FormAddFavoriteImage(image, null, _manager.Images.Select(i => i.Name.ToLower()))) { form.Text = "Rename Favorite Image"; form.laTitle.Text = "Set new name for your Favorite Image"; if (form.ShowDialog() != DialogResult.OK) return; _manager.DeleteImage(imageSource); _manager.SaveImage(image, form.ImageName); } _menuHitInfo = null; }
private void OnGalleryMouseUp(object sender, MouseEventArgs e) { _downHitInfo = null; }