Beispiel #1
0
        public static void DoDragDrop(DependencyObject dragSource, object data, DragDropEffects allowedEffects,
                                      DragDropCompletedCallback onDragDropCompleted = null)
        {
            int callbackId = CallbackId++;

            _callbacks[callbackId] = onDragDropCompleted;
            DoDragDropHelper(dragSource, data, allowedEffects, callbackId, _dragDropCompleted);
        }
Beispiel #2
0
        public static void DoDragDrop(DependencyObject dragSource, object data, DragDropEffects allowedEffects,
                                      DragDropCompletedCallback onDragDropCompleted)
        {
            DragDropCallbackInfo info = new DragDropCallbackInfo {
                Callback = onDragDropCompleted
            };
            int callbackId = info.GetHashCode();

            _dragDropCallbacks[callbackId] = info;
            DoDragDropHelper(dragSource, data, allowedEffects, callbackId, _dragDropCompleted);
        }
Beispiel #3
0
 private static void OnDragDropCompleted(int callbackId, IntPtr sourcePtr,
                                         IntPtr dataPtr, IntPtr targetPtr, IntPtr dropPointPtr, int effects)
 {
     try {
         DragDropCompletedCallback callback = _callbacks[callbackId];
         if (callback != null)
         {
             DependencyObject source    = (DependencyObject)Extend.GetProxy(sourcePtr, false);
             DataObject       data      = new DataObject(Extend.GetProxy(dataPtr, false));
             UIElement        target    = (UIElement)Extend.GetProxy(targetPtr, false);
             Point            dropPoint = Marshal.PtrToStructure <Point>(dropPointPtr);
             callback(source, data, target, dropPoint, (DragDropEffects)effects);
         }
         _callbacks.Remove(callbackId);
     }
     catch (Exception e) {
         Noesis.Error.UnhandledException(e);
     }
 }