@@ -108,7 +108,10 @@ public class ChromiumWebBrowser : Control, IRenderWebBrowser, IWpfWebBrowser
108108 /// we can reuse the drag data provided from CEF
109109 /// </summary>
110110 private IDragData currentDragData ;
111-
111+ /// <summary>
112+ /// Keep the current drag&drop effects to return the appropriate effects on drag over.
113+ /// </summary>
114+ private DragDropEffects currentDragDropEffects ;
112115 /// <summary>
113116 /// A flag that indicates whether or not the designer is active
114117 /// NOTE: Needs to be static for OnApplicationExit
@@ -798,14 +801,14 @@ bool IRenderWebBrowser.StartDragging(IDragData dragData, DragOperationsMask allo
798801 if ( browser != null )
799802 {
800803 //DoDragDrop will fire DragEnter event
801- var result = DragDrop . DoDragDrop ( this , dataObject , GetDragEffects ( allowedOps ) ) ;
804+ var result = DragDrop . DoDragDrop ( this , dataObject , allowedOps . GetDragEffects ( ) ) ;
802805
803806 //DragData was stored so when DoDragDrop fires DragEnter we reuse a clone of the IDragData provided here
804807 currentDragData = null ;
805808
806809 //If result == DragDropEffects.None then we'll send DragOperationsMask.None
807810 //effectively cancelling the drag operation
808- browser . GetHost ( ) . DragSourceEndedAt ( x , y , GetDragOperationsMask ( result ) ) ;
811+ browser . GetHost ( ) . DragSourceEndedAt ( x , y , result . GetDragOperationsMask ( ) ) ;
809812 browser . GetHost ( ) . DragSourceSystemDragEnded ( ) ;
810813 }
811814 } ) ;
@@ -824,7 +827,7 @@ void IRenderWebBrowser.UpdateDragCursor(DragOperationsMask operation)
824827 /// <param name="operation">describes the allowed operation (none, move, copy, link). </param>
825828 protected virtual void UpdateDragCursor ( DragOperationsMask operation )
826829 {
827- //TODO: Someone should implement this
830+ currentDragDropEffects = operation . GetDragEffects ( ) ;
828831 }
829832
830833 /// <summary>
@@ -1550,7 +1553,7 @@ private void OnDrop(object sender, DragEventArgs e)
15501553 if ( browser != null )
15511554 {
15521555 var mouseEvent = GetMouseEvent ( e ) ;
1553- var effect = GetDragOperationsMask ( e . AllowedEffects ) ;
1556+ var effect = e . AllowedEffects . GetDragOperationsMask ( ) ;
15541557
15551558 browser . GetHost ( ) . DragTargetDragOver ( mouseEvent , effect ) ;
15561559 browser . GetHost ( ) . DragTargetDragDrop ( mouseEvent ) ;
@@ -1579,8 +1582,10 @@ private void OnDragOver(object sender, DragEventArgs e)
15791582 {
15801583 if ( browser != null )
15811584 {
1582- browser . GetHost ( ) . DragTargetDragOver ( GetMouseEvent ( e ) , GetDragOperationsMask ( e . AllowedEffects ) ) ;
1585+ browser . GetHost ( ) . DragTargetDragOver ( GetMouseEvent ( e ) , e . AllowedEffects . GetDragOperationsMask ( ) ) ;
15831586 }
1587+ e . Effects = currentDragDropEffects ;
1588+ e . Handled = true ;
15841589 }
15851590
15861591 /// <summary>
@@ -1593,7 +1598,7 @@ private void OnDragEnter(object sender, DragEventArgs e)
15931598 if ( browser != null )
15941599 {
15951600 var mouseEvent = GetMouseEvent ( e ) ;
1596- var effect = GetDragOperationsMask ( e . AllowedEffects ) ;
1601+ var effect = e . AllowedEffects . GetDragOperationsMask ( ) ;
15971602
15981603 //DoDragDrop will fire this handler for internally sourced Drag/Drop operations
15991604 //we use the existing IDragData (cloned copy)
@@ -1604,62 +1609,6 @@ private void OnDragEnter(object sender, DragEventArgs e)
16041609 }
16051610 }
16061611
1607- /// <summary>
1608- /// Converts .NET drag drop effects to CEF Drag Operations
1609- /// </summary>
1610- /// <param name="dragDropEffects">The drag drop effects.</param>
1611- /// <returns>DragOperationsMask.</returns>
1612- /// s
1613- private static DragOperationsMask GetDragOperationsMask ( DragDropEffects dragDropEffects )
1614- {
1615- var operations = DragOperationsMask . None ;
1616-
1617- if ( dragDropEffects . HasFlag ( DragDropEffects . All ) )
1618- {
1619- operations |= DragOperationsMask . Every ;
1620- }
1621- if ( dragDropEffects . HasFlag ( DragDropEffects . Copy ) )
1622- {
1623- operations |= DragOperationsMask . Copy ;
1624- }
1625- if ( dragDropEffects . HasFlag ( DragDropEffects . Move ) )
1626- {
1627- operations |= DragOperationsMask . Move ;
1628- }
1629- if ( dragDropEffects . HasFlag ( DragDropEffects . Link ) )
1630- {
1631- operations |= DragOperationsMask . Link ;
1632- }
1633-
1634- return operations ;
1635- }
1636-
1637- /// <summary>
1638- /// Gets the drag effects.
1639- /// </summary>
1640- /// <param name="mask">The mask.</param>
1641- /// <returns>DragDropEffects.</returns>
1642- private static DragDropEffects GetDragEffects ( DragOperationsMask mask )
1643- {
1644- if ( ( mask & DragOperationsMask . Every ) == DragOperationsMask . Every )
1645- {
1646- return DragDropEffects . All ;
1647- }
1648- if ( ( mask & DragOperationsMask . Copy ) == DragOperationsMask . Copy )
1649- {
1650- return DragDropEffects . Copy ;
1651- }
1652- if ( ( mask & DragOperationsMask . Move ) == DragOperationsMask . Move )
1653- {
1654- return DragDropEffects . Move ;
1655- }
1656- if ( ( mask & DragOperationsMask . Link ) == DragOperationsMask . Link )
1657- {
1658- return DragDropEffects . Link ;
1659- }
1660- return DragDropEffects . None ;
1661- }
1662-
16631612 /// <summary>
16641613 /// PresentationSource changed handler.
16651614 /// </summary>
0 commit comments