/// <summary> /// Perform the drop action associated with the target. /// </summary> /// <param name="screenPt">Position in screen coordinates.</param> /// <param name="data">Data to pass to the target to process drop.</param> /// <returns>Drop was performed and the source can perform any removal of pages as required.</returns> public override bool PerformDrop(Point screenPt, PageDragEndData data) { // Transfer the dragged pages into our navigator instance KryptonPage page = ProcessDragEndData(_navigator, data); // Make the last page transfer the newly selected page of the navigator if (page != null) { // If the navigator is allowed to have a selected page then select it if (_navigator.AllowTabSelect) { _navigator.SelectedPage = page; } // Need to layout so the new cell has been added as a child control and // therefore can receive the focus we want to give it immediately afterwards _navigator.PerformLayout(); if (!_navigator.IsDisposed) { // Without this DoEvents() call the dropping of multiple pages in a complex arrangement causes an exception for // a complex reason that is hard to work out (i.e. I'm not entirely sure). Something to do with using select to // change activation is causing the source workspace control to dispose to earlier. Application.DoEvents(); _navigator.Select(); } } return(true); }
/// <summary> /// Add a list of drag targets from the provided interface. /// </summary> /// <param name="provider">Interface reference.</param> /// <param name="dragEndData">Pages data being dragged.</param> public void AddRange(IDragTargetProvider provider, PageDragEndData dragEndData) { DragTargetList targets = provider?.GenerateDragTargets(dragEndData); if ((targets != null) && (targets.Count > 0)) { AddRange(targets); } }
/// <summary> /// Find the target the first matches the provided screen point. /// </summary> /// <param name="screenPt">Point in screen coordinates.</param> /// <param name="dragEndData">Data to be dropped at destination.</param> /// <returns>First target that matches; otherwise null.</returns> protected virtual DragTarget FindTarget(Point screenPt, PageDragEndData dragEndData) { // Ask each target in turn if they are a match for the given screen point foreach (DragTarget target in DragTargets) { if (target.IsMatch(screenPt, dragEndData)) { return(target); } } // Nothing matches return(null); }
/// <summary> /// Called to initialize the implementation when dragging starts. /// </summary> /// <param name="paletteDragDrop">Drawing palette.</param> /// <param name="renderer">Drawing renderer.</param> /// <param name="pageDragEndData">Drag data associated with drag operation.</param> /// <param name="dragTargets">List of all drag targets.</param> public virtual void Start(IPaletteDragDrop paletteDragDrop, IRenderer renderer, PageDragEndData pageDragEndData, DragTargetList dragTargets) { Debug.Assert(paletteDragDrop != null); Debug.Assert(renderer != null); Debug.Assert(pageDragEndData != null); Debug.Assert(dragTargets != null); PaletteDragDrop = paletteDragDrop; Renderer = renderer; PageDragEndData = pageDragEndData; DragTargets = dragTargets; }
/// <summary> /// Called to initialize the implementation when dragging starts. /// </summary> /// <param name="paletteDragDrop">Drawing palette.</param> /// <param name="renderer">Drawing renderer.</param> /// <param name="pageDragEndData">Drag data associated with drag operation.</param> /// <param name="dragTargets">List of all drag targets.</param> public override void Start(IPaletteDragDrop paletteDragDrop, IRenderer renderer, PageDragEndData pageDragEndData, DragTargetList dragTargets) { base.Start(paletteDragDrop, renderer, pageDragEndData, dragTargets); if (_solid == null) { // Create and show a window without it taking focus _solid = new DropSolidWindow(PaletteDragDrop, Renderer); _solid.SetBounds(0, 0, 1, 1, BoundsSpecified.All); _solid.ShowWithoutActivate(); _solid.Refresh(); } }
/// <summary> /// Is this target a match for the provided screen position. /// </summary> /// <param name="screenPt">Position in screen coordinates.</param> /// <param name="dragEndData">Data to be dropped at destination.</param> /// <returns>True if a match; otherwise false.</returns> public override bool IsMatch(Point screenPt, PageDragEndData dragEndData) { // First time around... if (_notDraggedPagesFromNavigator == -1) { // Search for any pages that are not from this navigator _notDraggedPagesFromNavigator = 0; foreach (KryptonPage page in dragEndData.Pages) { if (!_navigator.Pages.Contains(page)) { _notDraggedPagesFromNavigator = 1; break; } } } // If 1 or more pages are not from this navigator then allow transfer into the target return(_notDraggedPagesFromNavigator > 0 && base.IsMatch(screenPt, dragEndData)); }
/// <summary> /// Called to initialize the implementation when dragging starts. /// </summary> /// <param name="paletteDragDrop">Drawing palette.</param> /// <param name="renderer">Drawing renderer.</param> /// <param name="pageDragEndData">Drag data associated with drag operation.</param> /// <param name="dragTargets">List of all drag targets.</param> public override void Start(IPaletteDragDrop paletteDragDrop, IRenderer renderer, PageDragEndData pageDragEndData, DragTargetList dragTargets) { base.Start(paletteDragDrop, renderer, pageDragEndData, dragTargets); if (_solid == null) { // Create and show a solid feedback window without it taking focus _solid = new DropSolidWindow(PaletteDragDrop, Renderer); _solid.SetBounds(0, 0, 1, 1, BoundsSpecified.All); _solid.ShowWithoutActivate(); _solid.Refresh(); } ClearClusters(); // Create clusters of related drag targets foreach (DragTarget target in dragTargets) { // Check if the target is actually able to drop inside itself if (target.IsMatch(target.HotRect.Location, pageDragEndData)) { // Find the existing cluster for the targets screen rectangle DockCluster cluster = FindTargetCluster(target); // Is the target allowed to be added to the found cluster (if there is one found) if ((cluster == null) || cluster.ExcludeCluster || ((target.Hint & DragTargetHint.ExcludeCluster) == DragTargetHint.ExcludeCluster)) { _clusters.Add(new DockCluster(PaletteDragDrop, Renderer, target)); } else { cluster.Add(target); } } } }
private DragTarget FindTarget(Point screenPt, PageDragEndData dragEndData) { // Nothing matches return(null); }
/// <summary> /// Perform the drop action associated with the target. /// </summary> /// <param name="screenPt">Position in screen coordinates.</param> /// <param name="dragEndData">Data to be dropped at destination.</param> /// <returns>Drop was performed and the source can perform any removal of pages as required.</returns> public abstract bool PerformDrop(Point screenPt, PageDragEndData dragEndData);
/// <summary> /// Is this target a match for the provided screen position. /// </summary> /// <param name="screenPt">Position in screen coordinates.</param> /// <param name="dragEndData">Data to be dropped at destination.</param> /// <returns>True if a match; otherwise false.</returns> public virtual bool IsMatch(Point screenPt, PageDragEndData dragEndData) { // Default to matching if the mouse is inside the targets hot area return(HotRect.Contains(screenPt)); }