/// <summary> /// Performs a hit test. /// </summary> private void DoHitTest(Point pt) { ImageListView.HitInfo h; mImageListView.HitTest(pt, out h); if (h.ItemHit) { HoveredItem = mImageListView.Items[h.ItemIndex]; } else { HoveredItem = null; } if (h.PaneBorder) { HoveredPaneBorder = true; } else { HoveredPaneBorder = false; } inItemArea = h.InItemArea; inHeaderArea = h.InHeaderArea; inPaneArea = h.InPaneArea; }
/// <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(ImageListView.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 (ImageListView.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 (ImageListView.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 (ImageListView.navigationManager.ShiftKey) { tColor = Color.Black; } using (Brush b = new SolidBrush(tColor)) { g.DrawString("Shift", ImageListView.Font, b, r.Location); } r.Offset(0, 12); // Is control key down? tColor = Color.Gray; if (ImageListView.navigationManager.ControlKey) { tColor = Color.Black; } using (Brush b = new SolidBrush(tColor)) { g.DrawString("Control", ImageListView.Font, b, r.Location); } r.Offset(0, 20); // Display hit test details for item area ImageListView.HitInfo h = null; ImageListView.HitTest(ImageListView.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() + ")", ImageListView.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() + ")", ImageListView.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)" : ""), ImageListView.Font, b, r.Location); } r.Offset(0, 12); }