Exemple #1
0
        /// <summary>
        ///     Starts the dragging operation.
        /// </summary>
        /// <param name="uiElt">The dragged UI element.</param>
        private static void DragStarted(UIElement uiElt)
        {
            isMouseDown = false;
            Mouse.Capture(uiElt);

            // Daten des Drag-Elements holen
            var data = CurrentDragSourceAdvisor.GetDataObject(draggedElt);

            // und diese Daten mit Zusatzinformationen anreichern
            data.SetData(DragOffsetFormat, offsetPoint);
            data.SetData(DragSourceFormat, draggedElt);

            // Die unterstützten DnD-Effekte bei der Drag-Quelle erfragen
            var supportedEffects = CurrentDragSourceAdvisor.SupportedEffects;

            // Perform Drag and Drop operation
            var effects = System.Windows.DragDrop.DoDragDrop(draggedElt, data, supportedEffects);

            // finish DnD operation
            CurrentDragSourceAdvisor.FinishDrag(draggedElt, effects);

            // Clean up
            RemovePreviewAdorner();
            Mouse.Capture(null);
            draggedElt = null;
        }
 private static void DragSource_PreviewMouseMove(object sender, MouseEventArgs e)
 {
     if (_isMouseDown && IsDragGesture(e.GetPosition(CurrentDragSourceAdvisor.GetTopContainer())))
     {
         DragStarted(sender as UIElement);
     }
 }
Exemple #3
0
        private static void DragStarted(UIElement uiElt)
        {
            _isMouseDown = false;
            if (uiElt == null || _draggedElt == null)
            {
                return;
            }
            //Mouse.Capture(uiElt);

            DataObject data = CurrentDragSourceAdvisor.GetDataObject(_draggedElt);

            data.SetData(DragOffsetFormat, _offsetPoint);
            DragDropEffects supportedEffects = CurrentDragSourceAdvisor.SupportedEffects;

            // Perform DragDrop

            DragDropEffects effects = DragDrop.DoDragDrop(_draggedElt, data, supportedEffects);

            CurrentDragSourceAdvisor.FinishDrag(_draggedElt, effects);

            // Clean up
            RemovePreviewAdorner();
            //Mouse.Capture(null);
            _draggedElt = null;
        }
Exemple #4
0
 private static void DragSource_PreviewMouseUp(object sender, MouseButtonEventArgs e)
 {
     if (_isMouseDown && IsDragGesture(e.GetPosition(CurrentDragSourceAdvisor.GetSourceTopContainer())))
     {
         _isMouseDown = false;
         Mouse.Capture(null);
     }
 }
Exemple #5
0
 private static void DragSource_PreviewMouseMove(object sender, MouseEventArgs e)
 {
     if (CurrentDragSourceAdvisor != null && e.LeftButton == MouseButtonState.Pressed &&
         IsDragGesture(e.GetPosition(CurrentDragSourceAdvisor.GetTopContainer())))
     {
         DragStarted(sender as UIElement);
     }
     else
     {
         Mouse.Capture(null);
     }
 }
        /* ____________________________________________________________________
         *		Drag Source events
         * ____________________________________________________________________
         */

        private static void DragSource_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            // Make this the new drag source
            CurrentDragSourceAdvisor = GetDragSourceAdvisor(sender as DependencyObject);

            if (CurrentDragSourceAdvisor.IsDraggable(e.Source as UIElement) == false)
            {
                return;
            }

            _draggedElt     = e.Source as UIElement;
            _dragStartPoint = e.GetPosition(CurrentDragSourceAdvisor.GetTopContainer());
            _offsetPoint    = e.GetPosition(_draggedElt);
            _isMouseDown    = true;
        }
Exemple #7
0
        private static void DragStarted(UIElement uiElt)
        {
            _isMouseDown = false;
            Mouse.Capture(uiElt);

            DataObject data = CurrentDragSourceAdvisor.GetDataObject(_draggedElt, _dragStartPoint);

            // NOTE: observed as being null during testing
            if (data != null)
            {
                data.SetData(DragOffsetFormat, _offsetPoint);
                DragDropEffects supportedEffects = CurrentDragSourceAdvisor.SupportedEffects;

                // Perform DragDrop
                DragDropEffects effects = System.Windows.DragDrop.DoDragDrop(_draggedElt, data, supportedEffects);
                CurrentDragSourceAdvisor.FinishDrag(_draggedElt, _dragStartPoint, effects);
            }

            // Clean up
            RemovePreviewAdorner();
            Mouse.Capture(null);
            _draggedElt = null;
        }