/// <summary> /// Pass mouse up to appropriate item /// </summary> /// <param name="e"></param> public override bool OnMouseUp(VCItem sender, ItemMouseEventArgs e) { var pt = e.Location; if (mouseDownPlacement != null) { try { var localPt = mouseDownPlacement.ToLocal(pt); return(mouseDownPlacement.Item.OnMouseUp(new ItemMouseEventArgs(e, localPt.X, localPt.Y))); } finally { mouseDownPlacement = null; } } else { VCItemPlacement placement = null; while ((placement = container.Items.Find(pt, placement)) != null) { var localPt = placement.ToLocal(pt); if (placement.Item.OnMouseUp(new ItemMouseEventArgs(e, localPt.X, localPt.Y))) { return(true); } } return(base.OnMouseUp(sender, e)); } }
/// <summary> /// Pass mouse move to appropriate item /// </summary> /// <param name="e"></param> public override bool OnMouseMove(VCItem sender, ItemMouseEventArgs e) { var pt = e.Location; if (mouseDownPlacement != null) { // Mouse button down, always send events to same placement var localPt = mouseDownPlacement.ToLocal(pt); return(mouseDownPlacement.Item.OnMouseMove(new ItemMouseEventArgs(e, localPt.X, localPt.Y))); } else { VCItemPlacement placement = container.Items.Find(pt, null); // Handle mouse leave if ((mouseOverPlacement != null) && (mouseOverPlacement != placement)) { mouseOverPlacement.Item.OnMouseLeave(EventArgs.Empty); mouseOverPlacement = null; } while (placement != null) { // Convert point to local var localPt = placement.ToLocal(pt); // Handle mouse enter if (mouseOverPlacement == null) { mouseOverPlacement = placement; mouseOverPlacement.Item.OnMouseEnter(EventArgs.Empty); } // Send mouse move mouseOverPlacement = placement; if (placement.Item.OnMouseMove(new ItemMouseEventArgs(e, localPt.X, localPt.Y))) { return(true); } placement = container.Items.Find(pt, placement); if ((placement != mouseOverPlacement) && (placement != null)) { mouseOverPlacement.Item.OnMouseLeave(EventArgs.Empty); mouseOverPlacement = null; } } return(base.OnMouseMove(sender, e)); } }
/// <summary> /// Occurs when a drag-and-drop operation is completed. /// </summary> /// <param name="e"></param> public override bool OnDragDrop(VCItem sender, ItemDragEventArgs e) { var pt = new Point(e.X, e.Y); VCItemPlacement placement = null; while ((placement = container.Items.Find(pt, placement)) != null) { Point localPt = placement.ToLocal(pt); if (placement.Item.OnDragDrop(new ItemDragEventArgs(e, localPt.X, localPt.Y))) { return(true); } } return(base.OnDragDrop(sender, e)); }
/// <summary> /// Pass mouse double click to appropriate item /// </summary> /// <param name="e"></param> public override bool OnMouseDoubleClick(VCItem sender, ItemMouseEventArgs e) { var pt = e.Location; VCItemPlacement placement = null; while ((placement = container.Items.Find(pt, placement)) != null) { var localPt = placement.ToLocal(pt); if (placement.Item.OnMouseDoubleClick(new ItemMouseEventArgs(e, localPt.X, localPt.Y))) { return(true); } } return(base.OnMouseDoubleClick(sender, e)); }
/// <summary> /// Occurs when an object is dragged over the item's bounds. /// </summary> /// <param name="e"></param> public override bool OnDragOver(VCItem sender, ItemDragEventArgs e) { var pt = new Point(e.X, e.Y); VCItemPlacement placement = container.Items.Find(pt, null); // Handle drag leave if ((dragOverPlacement != null) && (dragOverPlacement != placement)) { dragOverPlacement.Item.OnDragLeave(EventArgs.Empty); dragOverPlacement = null; } while (placement != null) { // Convert point to local Point localPt = placement.ToLocal(pt); // Handle drag enter if (dragOverPlacement == null) { dragOverPlacement = placement; dragOverPlacement.Item.OnDragEnter(EventArgs.Empty); } // Send drag over dragOverPlacement = placement; if (placement.Item.OnDragOver(new ItemDragEventArgs(e, localPt.X, localPt.Y))) { return(true); } placement = container.Items.Find(pt, placement); if ((placement != dragOverPlacement) && (placement != null)) { dragOverPlacement.Item.OnDragLeave(EventArgs.Empty); dragOverPlacement = null; } } return(base.OnDragOver(sender, e)); }