public void RegisterDropType(Type type, DragDropTypeHandler handler) { if (drag_drop_type_handlers.ContainsKey(type)) { throw new Exception(String.Format("The type {0} already has a drop handler", type)); } drag_drop_type_handlers[type] = handler; }
public bool OnDrop(DragEventArgs e, Point mouse_current_virtual) { foreach (Type type in drag_drop_type_handlers.Keys) { if (e.Data.GetDataPresent(type)) { object dropped_object = e.Data.GetData(type); DragDropTypeHandler drag_drop_type_handler = drag_drop_type_handlers[type]; drag_drop_type_handler(dropped_object, mouse_current_virtual); return(true); } } // If we get here, we don't know how to handle this drop item return(false); }