Ejemplo n.º 1
0
 public DragSourceAttacher(UIElement element, DragSourceHelper.DragSource dragData)
 {
     this.Element               = element;
     this.DragData              = dragData;
     this.DragStartPoint        = element.PointToScreen(Mouse.GetPosition((IInputElement)element));
     element.QueryContinueDrag += new QueryContinueDragEventHandler(this.Element_QueryContinueDrag);
     element.GiveFeedback      += new GiveFeedbackEventHandler(this.Element_GiveFeedback);
 }
Ejemplo n.º 2
0
 private static bool InternalDataOfType <T>(object data, ref T result)
 {
     DragSourceHelper.DragSource dragSource = data as DragSourceHelper.DragSource;
     if (dragSource != null && dragSource.Data is T)
     {
         result = (T)dragSource.Data;
         return(true);
     }
     if (!(data is T))
     {
         return(false);
     }
     result = (T)data;
     return(true);
 }
Ejemplo n.º 3
0
 public static DragDropEffects DoDragDrop(UIElement dragSource, object data, DragDropEffects allowedEffects)
 {
     DragSourceHelper.DragSource dragData = new DragSourceHelper.DragSource(data);
     using (new DragSourceHelper.DragSourceAttacher(dragSource, dragData))
     {
         try
         {
             return(DragDrop.DoDragDrop((DependencyObject)dragSource, (object)dragData, allowedEffects));
         }
         catch (Exception ex)
         {
             return(DragDropEffects.None);
         }
         finally
         {
             dragData.OnDragFinished((object)dragSource, EventArgs.Empty);
         }
     }
 }