Ejemplo n.º 1
1
        /* ____________________________________________________________________
         *		Drag Source events
         * ____________________________________________________________________
         */
        static void DragSource_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            // Make this the new drag source
            _currentSourceAdvisor = GetDragSourceAdvisor(sender as DependencyObject);

            if (_currentSourceAdvisor.IsDraggable(e.Source as UIElement) == false) return;

            _draggedElt = e.Source as UIElement;
            _startPoint = e.GetPosition(GetTopContainer());
            _isMouseDown = true;
        }
Ejemplo n.º 2
0
        static void DragSource_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            IDragSourceAdvisor adv = GetDragSourceAdvisor(sender as UIElement);

            if (!adv.IsDraggable(e.Source as UIElement))
            {
                return;
            }

            DragSource = new DragInfo(adv);
            DragSource.DraggedElement = e.Source as UIElement;
            DragSource.StartPoint     = e.GetPosition(DragSource.DraggedElement);
            DragSource.IsMouseDown    = true;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Called when the left mouse button is pressed while the mouse pointer is over drag source element.
        /// </summary>
        /// <param name="sender">Drag source element.</param>
        /// <param name="e">Provides data for mouse button.</param>
        private static void DragSourcePreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            // Make this the new drag source
            currentSourceAdvisor = GetDragSourceAdvisor(sender as DependencyObject);

            // Todo: consider to pass FrameworkElement.DataContext directly instead if UIElement
            if (currentSourceAdvisor.IsDraggable(e.Source as UIElement) == false)
            {
                return;
            }

            dragElement = e.Source as UIElement;

            // Important: for global (i.e. "window root grid") adorner layer use local (to element) mouse position as start point.
            startPoint = e.GetPosition((UIElement)e.Source);

            // For local (to element) adorner layer use global mouse position as start point instead.
            //startPoint = e.GetPosition(GetTopContainer());

            isMouseDown = true;
        }
        /* ____________________________________________________________________
         *		Drag Source events 
         * ____________________________________________________________________
         */

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

            //UIElement candidat = e.Source as UIElement;

            //if (CurrentDragSourceAdvisor.IsDraggable(candidat) == false)
            //{
            //    candidat = e.OriginalSource as UIElement;

            //    if (CurrentDragSourceAdvisor.IsDraggable(candidat) == false)
            //        return;
            //}

            UIElement candidat = e.OriginalSource as UIElement;

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

                if (CurrentDragSourceAdvisor.IsDraggable(candidat) == false)
                    return;
            }

            _draggedElt = candidat;
            _dragStartPoint = e.GetPosition(null);
            _offsetPoint = e.GetPosition(_draggedElt);
            _isMouseDown = true;
        }