/** * When a IResourceList drag enters the link label, highlights it * as a drop target. */ private void OnLinkDragEnter(object sender, System.Windows.Forms.DragEventArgs e) { if (e.Data.GetDataPresent(typeof(IResourceList))) { _label.BackColor = SystemColors.Highlight; _label.ForeColor = SystemColors.HighlightText; IResourceList resList = (IResourceList)e.Data.GetData(typeof(IResourceList)); if (ResourceDragOver != null) { ResourceDragEventArgs args = new ResourceDragEventArgs(_resource, resList); ResourceDragOver(this, args); e.Effect = args.Effect; } else { if (Core.UIManager.CanDropResource(_resource, resList)) { e.Effect = DragDropEffects.Link; } else { e.Effect = DragDropEffects.None; } } } }
/// <summary> /// Handles the DnD <see cref="JetListView.DragOver"/> event from the underlying <see cref="JetListView"/>, and fires the own <see cref="ResourceDragOver"/> event for the external handlers (if none available, invokes the default handler). /// </summary> private void HandleDragOver(object sender, JetListViewDragEventArgs args) { try { IResource targetRes; if (!CheckDragDropMode(args, out targetRes)) { return; // Operation cancelled } // Call the outer handler for the drag-over operation if ((ResourceDragOver != null) && (args.Data.GetDataPresent(typeof(IResourceList)))) { // Call the custom handler IResourceList dragResources = (IResourceList)args.Data.GetData(typeof(IResourceList)); ResourceDragEventArgs resourceDragEventArgs = new ResourceDragEventArgs(targetRes, dragResources); ResourceDragOver(this, resourceDragEventArgs); args.Effect = resourceDragEventArgs.Effect; } else { // No custom handler defined, invoke the default handler if ((targetRes == RootResource) && (_rootResourceDropHandler != null)) // Empty/Root special handler { args.Effect = _rootResourceDropHandler.DragOver(targetRes, args.Data, args.AllowedEffect, args.KeyState); } else // Normal d'n'd handler { args.Effect = Core.UIManager.ProcessDragOver(targetRes, args.Data, args.AllowedEffect, args.KeyState, (args.Data.GetData(typeof(ResourceListView2)) == this)); } } } catch (Exception ex) { Core.ReportException(ex, ExceptionReportFlags.AttachLog); } }