/// <summary> /// Defines a target control for the drag and drop operation. /// </summary> /// <typeparam name="TControl">The type of the control to drop on</typeparam> /// <param name="target">The target control to drop on</param> /// <param name="dragDrop">A function to handle the drop on the target control</param> /// <returns></returns> public DragOperation <T> To <TControl>(TControl target, Action <TControl, T> dragDrop) where TControl : Control { var handler = DragHandler <T> .CreateDefault(); handler.DragDrop = (value, _) => { _previewFormController?.Stop(target, wasCancelled: false); dragDrop?.Invoke(target, value); }; return(To(target, handler)); }
/// <summary> /// Attaches the required drag and drop events to a given target control. /// </summary> /// <param name="target">The target control to attach the events to</param> /// <param name="handler">A handle class to link to the target control</param> /// <returns></returns> private DragOperation <T> To(Control target, DragHandler <T> handler) { target.AllowDrop = true; _targets[target] = handler; target.DragEnter += Target_DragEnter; target.DragOver += Target_DragOver; target.DragDrop += Target_DragDrop; target.DragLeave += Target_DragLeave; return(this); }