void WidgetDropHandler(object sender, System.Windows.DragEventArgs e) { // Do a DragOverCheck before proceeding to the drop. This is required since in some cases the DragOver // handler may not be called. CheckDrop(sender, e); if (e.Effects == DragDropEffects.None) { return; } WidgetDragLeaveHandler(sender, e); var types = e.Data.GetFormats().Select(DataConverter.ToXwtTransferType).ToArray(); var pos = e.GetPosition(Widget).ToXwtPoint(); var actualEffect = currentDragEffect; e.Handled = true; // Prevent default handlers from being used. e.Effects = DragDropEffects.None; if ((enabledEvents & WidgetEvent.DragDropCheck) > 0) { var checkArgs = new DragCheckEventArgs(pos, types, actualEffect.ToXwtDropAction()); bool res = Context.InvokeUserCode(delegate { eventSink.OnDragDropCheck(checkArgs); }); if (checkArgs.Result == DragDropResult.Canceled || !res) { e.Effects = DragDropEffects.None; return; } } if ((enabledEvents & WidgetEvent.DragDrop) > 0) { var store = new TransferDataStore(); FillDataStore(store, e.Data); //, DragDropInfo.TargetTypes); var args = new DragEventArgs(pos, store, actualEffect.ToXwtDropAction()); Context.InvokeUserCode(delegate { eventSink.OnDragDrop(args); }); if (args.Success) { e.Effects = actualEffect; } } }
void WidgetDropHandler(object sender, System.Windows.DragEventArgs e) { WidgetDragLeaveHandler(sender, e); var types = e.Data.GetFormats().Select(t => t.ToXwtTransferType()).ToArray(); var pos = e.GetPosition(Widget).ToXwtPoint(); var actualEffect = currentDragEffect; e.Handled = true; // Prevent default handlers from being used. e.Effects = DragDropEffects.None; if ((enabledEvents & WidgetEvent.DragDropCheck) > 0) { var checkArgs = new DragCheckEventArgs(pos, types, actualEffect.ToXwtDropAction()); bool res = Context.InvokeUserCode(delegate { eventSink.OnDragDropCheck(checkArgs); }); if (checkArgs.Result == DragDropResult.Canceled || !res) { e.Effects = DragDropEffects.None; return; } } if ((enabledEvents & WidgetEvent.DragDrop) > 0) { var store = new TransferDataStore(); FillDataStore(store, e.Data, DragDropInfo.TargetTypes); var args = new DragEventArgs(pos, store, actualEffect.ToXwtDropAction()); Context.InvokeUserCode(delegate { eventSink.OnDragDrop(args); }); if (args.Success) { e.Effects = actualEffect; } } }