protected override void OnMouseMove(MouseEventArgs e) { ToolboxItemBase item = HitTest(e.Location); if (e.Button == MouseButtons.Left && item is ToolboxItem) { ToolboxItem toolboxItem = item as ToolboxItem; if (toolboxItem.Data != null) { this.DoDragDrop(toolboxItem.Data, DragDropEffects.Copy); } } else { if (item != null && item.MouseOver == false) { if (currentMouseOverItem != null) { currentMouseOverItem.MouseOver = false; Invalidate(GetItemRect(currentMouseOverItem)); } item.MouseOver = true; Invalidate(GetItemRect(item)); currentMouseOverItem = item; } } base.OnMouseMove(e); }
protected override void OnMouseLeave(EventArgs e) { base.OnMouseLeave(e); if (currentMouseOverItem != null) { currentMouseOverItem.MouseOver = false; Invalidate(GetItemRect(currentMouseOverItem)); currentMouseOverItem = null; } }
private bool PointOverToolboxItem(Point point, ToolboxItemBase item) { if (item.Top == -1) { return(false); } if (point.Y >= item.Top && point.Y <= item.Top + 18) { return(true); } return(false); }
protected override void OnMouseDown(MouseEventArgs e) { ToolboxItemBase item = HitTest(e.Location); if (item is ToolboxItem) { ItemMouseDown(item as ToolboxItem); } else if (item is ToolboxGroup) { GroupMouseDown(item as ToolboxGroup); } base.OnMouseDown(e); }
private Rectangle GetItemRect(ToolboxItemBase item) { return(new Rectangle(0, item.Top, this.Width, 19)); }