@@ -104,7 +104,10 @@ public class ChromiumWebBrowser : Control, IRenderWebBrowser, IWpfWebBrowser
104104 /// we can reuse the drag data provided from CEF
105105 /// </summary>
106106 private IDragData currentDragData ;
107-
107+ /// <summary>
108+ /// Keep the current drag&drop effects to return the appropriate effects on drag over.
109+ /// </summary>
110+ private DragDropEffects currentDragDropEffects ;
108111 /// <summary>
109112 /// A flag that indicates whether or not the designer is active
110113 /// NOTE: Needs to be static for OnApplicationExit
@@ -787,14 +790,14 @@ bool IRenderWebBrowser.StartDragging(IDragData dragData, DragOperationsMask allo
787790 if ( browser != null )
788791 {
789792 //DoDragDrop will fire DragEnter event
790- var result = DragDrop . DoDragDrop ( this , dataObject , GetDragEffects ( allowedOps ) ) ;
793+ var result = DragDrop . DoDragDrop ( this , dataObject , allowedOps . GetDragEffects ( ) ) ;
791794
792795 //DragData was stored so when DoDragDrop fires DragEnter we reuse a clone of the IDragData provided here
793796 currentDragData = null ;
794797
795798 //If result == DragDropEffects.None then we'll send DragOperationsMask.None
796799 //effectively cancelling the drag operation
797- browser . GetHost ( ) . DragSourceEndedAt ( x , y , GetDragOperationsMask ( result ) ) ;
800+ browser . GetHost ( ) . DragSourceEndedAt ( x , y , result . GetDragOperationsMask ( ) ) ;
798801 browser . GetHost ( ) . DragSourceSystemDragEnded ( ) ;
799802 }
800803 } ) ;
@@ -813,7 +816,7 @@ void IRenderWebBrowser.UpdateDragCursor(DragOperationsMask operation)
813816 /// <param name="operation">describes the allowed operation (none, move, copy, link). </param>
814817 protected virtual void UpdateDragCursor ( DragOperationsMask operation )
815818 {
816- //TODO: Someone should implement this
819+ currentDragDropEffects = operation . GetDragEffects ( ) ;
817820 }
818821
819822 /// <summary>
@@ -1524,7 +1527,7 @@ private void OnDrop(object sender, DragEventArgs e)
15241527 if ( browser != null )
15251528 {
15261529 var mouseEvent = GetMouseEvent ( e ) ;
1527- var effect = GetDragOperationsMask ( e . AllowedEffects ) ;
1530+ var effect = e . AllowedEffects . GetDragOperationsMask ( ) ;
15281531
15291532 browser . GetHost ( ) . DragTargetDragOver ( mouseEvent , effect ) ;
15301533 browser . GetHost ( ) . DragTargetDragDrop ( mouseEvent ) ;
@@ -1553,8 +1556,10 @@ private void OnDragOver(object sender, DragEventArgs e)
15531556 {
15541557 if ( browser != null )
15551558 {
1556- browser . GetHost ( ) . DragTargetDragOver ( GetMouseEvent ( e ) , GetDragOperationsMask ( e . AllowedEffects ) ) ;
1559+ browser . GetHost ( ) . DragTargetDragOver ( GetMouseEvent ( e ) , e . AllowedEffects . GetDragOperationsMask ( ) ) ;
15571560 }
1561+ e . Effects = currentDragDropEffects ;
1562+ e . Handled = true ;
15581563 }
15591564
15601565 /// <summary>
@@ -1567,7 +1572,7 @@ private void OnDragEnter(object sender, DragEventArgs e)
15671572 if ( browser != null )
15681573 {
15691574 var mouseEvent = GetMouseEvent ( e ) ;
1570- var effect = GetDragOperationsMask ( e . AllowedEffects ) ;
1575+ var effect = e . AllowedEffects . GetDragOperationsMask ( ) ;
15711576
15721577 //DoDragDrop will fire this handler for internally sourced Drag/Drop operations
15731578 //we use the existing IDragData (cloned copy)
@@ -1578,62 +1583,6 @@ private void OnDragEnter(object sender, DragEventArgs e)
15781583 }
15791584 }
15801585
1581- /// <summary>
1582- /// Converts .NET drag drop effects to CEF Drag Operations
1583- /// </summary>
1584- /// <param name="dragDropEffects">The drag drop effects.</param>
1585- /// <returns>DragOperationsMask.</returns>
1586- /// s
1587- private static DragOperationsMask GetDragOperationsMask ( DragDropEffects dragDropEffects )
1588- {
1589- var operations = DragOperationsMask . None ;
1590-
1591- if ( dragDropEffects . HasFlag ( DragDropEffects . All ) )
1592- {
1593- operations |= DragOperationsMask . Every ;
1594- }
1595- if ( dragDropEffects . HasFlag ( DragDropEffects . Copy ) )
1596- {
1597- operations |= DragOperationsMask . Copy ;
1598- }
1599- if ( dragDropEffects . HasFlag ( DragDropEffects . Move ) )
1600- {
1601- operations |= DragOperationsMask . Move ;
1602- }
1603- if ( dragDropEffects . HasFlag ( DragDropEffects . Link ) )
1604- {
1605- operations |= DragOperationsMask . Link ;
1606- }
1607-
1608- return operations ;
1609- }
1610-
1611- /// <summary>
1612- /// Gets the drag effects.
1613- /// </summary>
1614- /// <param name="mask">The mask.</param>
1615- /// <returns>DragDropEffects.</returns>
1616- private static DragDropEffects GetDragEffects ( DragOperationsMask mask )
1617- {
1618- if ( ( mask & DragOperationsMask . Every ) == DragOperationsMask . Every )
1619- {
1620- return DragDropEffects . All ;
1621- }
1622- if ( ( mask & DragOperationsMask . Copy ) == DragOperationsMask . Copy )
1623- {
1624- return DragDropEffects . Copy ;
1625- }
1626- if ( ( mask & DragOperationsMask . Move ) == DragOperationsMask . Move )
1627- {
1628- return DragDropEffects . Move ;
1629- }
1630- if ( ( mask & DragOperationsMask . Link ) == DragOperationsMask . Link )
1631- {
1632- return DragDropEffects . Link ;
1633- }
1634- return DragDropEffects . None ;
1635- }
1636-
16371586 /// <summary>
16381587 /// PresentationSource changed handler.
16391588 /// </summary>
0 commit comments