Example #1
0
 private void UpdateDragAdorner(Point currentPosition)
 {
     if (_myDragAdorner != null)
     {
         _myDragAdorner.UpdatePosition(currentPosition.X, currentPosition.Y);
     }
 }
Example #2
0
 void UpdateDragAdorner(Point currentPosition)
 {
     if (_itemAdorner != null)
     {
         Debug.WriteLine("UpdateDragAdorner " + currentPosition.X + "," + currentPosition.Y);
         _itemAdorner.UpdatePosition(currentPosition.X, currentPosition.Y);
     }
 }
Example #3
0
 private void TaskItem_GiveFeedback(object sender, GiveFeedbackEventArgs e)
 {
     if (_adorner != null)
     {
         Point pos = PointFromScreen(GetMousePosition());
         _adorner.UpdatePosition(pos);
     }
     else
     {
         e.Handled = false;
     }
 }
        private void InitializeDragAdorner(Point startPosition)
        {
            if (adorner != null)
            {
                return;
            }
            if (draggedItem == null)
            {
                return;
            }
            var contentContainer = draggedItem.FindChild <Grid>(ItemContentContainer);

            adorner = new DragAdorner(AssociatedObject, contentContainer, true, 1);
            var adornerLayer = AdornerLayer.GetAdornerLayer(AssociatedObject);

            adornerLayer.Add(adorner);
            adorner.UpdatePosition(startPosition);
        }
Example #5
0
        void InitializeDragAdorner(object dragData, Point startPosition)
        {
            if (this.DataTemplate != null)
            {
                if (_itemAdorner == null)
                {
                    //FrameworkElement el = this.AssociatedObject;
                    //while (!(el is UserControl))
                    //    el = (FrameworkElement)VisualTreeHelper.GetParent(el);

                    var adornerLayer = AdornerLayer.GetAdornerLayer(_el);
                    _itemAdorner = new DragAdorner(dragData, DataTemplate, _el, adornerLayer);
                    _itemAdorner.UpdatePosition(startPosition.X, startPosition.Y);
                    // set adorner z-order
                    var setZOrderMethodInfo = adornerLayer.GetType().GetMethod("SetAdornerZOrder", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
                    setZOrderMethodInfo.Invoke(adornerLayer, new object[] { _itemAdorner, 1 });
                }
            }
        }
Example #6
0
        private void InitializeDragAdorner(UIElement itemsControl, object dragData, Point startPosition)
        {
            if (DataTemplate == null)
            {
                return;
            }
            if (_myDragAdorner != null)
            {
                return;
            }

            var adornerLayer = AdornerLayer.GetAdornerLayer(itemsControl);

            if (adornerLayer == null)
            {
                return;
            }

            _myDragAdorner = new DragAdorner(dragData, DataTemplate, itemsControl, adornerLayer);
            _myDragAdorner.UpdatePosition(startPosition.X, startPosition.Y);
        }
 private void UpdateDragAdorner(Point currentPosition)
 {
     adorner?.UpdatePosition(currentPosition);
 }
Example #8
0
        private static void StartDrag(DependencyObject source)
        {
            var dragScope = Application.Current.MainWindow as FrameworkElement;
            //var dragScope = Application.Current.MainWindow.Content as FrameworkElement;
            dragScope.AllowDrop = true;
            SetIsDragging(source, true);

            DataObject dataObject = new DataObject();

            var data = GetDragData(source);
            dataObject.SetData(data);

            var adorner = new DragAdorner(source as UIElement, data, true, 1);

            var layer = AdornerLayer.GetAdornerLayer(((Window)dragScope).Content as FrameworkElement);

            layer.Add(adorner);

            var startPoint = (Point)source.GetValue(StartPointProperty);
            adorner.UpdatePosition(startPoint);

            //var adjustPoint = GetAdjustPoint(source);
            //adorner.UpdatePosition(adjustPoint);

            dragScope.DragOver += (sender, e) =>
            {
                if (adorner != null)
                {
                    adorner.UpdatePosition(e.GetPosition(dragScope));
                }
            };

            DragDrop.DoDragDrop(source, dataObject, DragDropEffects.Move);

            layer.Remove(adorner);
            adorner = null;

            SetIsDragging(source, false);
        }