private void Element_ManipulationCompleted(object sender, ManipulationCompletedEventArgs e)
        {
            if (!IsActive)
            {
                return;
            }

            IsActive = false;
            _autoScrollTimer.Stop();

            int dragIndex = GetDragIndex();

            // fade in the list
            _todoList.Animate(null, 1.0, FrameworkElement.OpacityProperty, 200, 0);

            // animated the dragged item into location
            double targetLocation = dragIndex * _dragImage.ActualHeight - _scrollViewer.VerticalOffset;
            var    trans          = _dragImage.GetVerticalOffset().Transform;

            trans.Animate(null, targetLocation, TranslateTransform.YProperty, 200, 0, null,
                          () =>
            {
                // move the dragged item
                var draggedItem = _todoItems[_initialDragIndex];
                _todoItems.Remove(draggedItem);
                _todoItems.Insert(dragIndex, draggedItem);

                // re-populate our ObservableCollection
                RefreshView();

                // fade out the dragged image and collapse on completion
                _dragImage.Animate(null, 0.0, FrameworkElement.OpacityProperty, 1000, 0, null, ()
                                   => _dragImage.Visibility = Visibility.Collapsed);
            });
        }
示例#2
0
        private void HoldCompleted(object sender, ManipulationCompletedEventArgs e)
        {
            if (!IsActive)
            {
                return;
            }

            // stop the timer so that we don't try to re-fix this thing after moving to our
            // final destination.
            _dispatcherTimer.Stop();

            var dragIndex      = _currentIndex;
            var targetItem     = _pointIndex.Get(_currentIndex);
            var targetLocation = targetItem.Position.Top - _scrollViewer.VerticalOffset;
            var transform      = _dragImage.GetVerticalOffset().Transform;

            transform.Animate(null, targetLocation, CompositeTransform.TranslateYProperty, 200, 0, completed: () =>
            {
                // reshow the hidden item
                if (_cardView != null)
                {
                    _cardView.Opacity = 1.0;
                }

                // fade out the dragged image
                if (_dragImage != null)
                {
                    _dragImage.Animate(null, 0.0, UIElement.OpacityProperty, 700, 0,
                                       completed: () => { _dragImage.Visibility = Visibility.Collapsed; });
                }

                Complete();

                if (dragIndex == _initialIndex)
                {
                    return;
                }

                // move the dragged item
                if (_cardView == null)
                {
                    return;
                }

                var item = (CardViewModel)_cardView.DataContext;

                _cardsModel.Remove(item);
                _cardsModel.Insert(dragIndex, item);
                _cardsModel.Refresh();

                // fire off the event for subscribers
                _eventAggregator.Publish(CardPriorityChanged.Create(item.Id, dragIndex, _cardsModel.ToList()));
            });

            IsActive = false;
        }
示例#3
0
        private void Element_ManipulationCompleted(object sender, ManipulationCompletedEventArgs e)
        {
            if (!IsActive)
            {
                return;
            }

            IsActive = false;
            _autoScrollTimer.Stop();

            int dragIndex = GetDragIndex();

            // fade in the list
            this.interactionListControl.Animate(null, 1.0, FrameworkElement.OpacityProperty, 200, 0);

            // animated the dragged item into location
            double targetLocation = dragIndex * _dragImage.ActualHeight - _scrollViewer.VerticalOffset;
            var    trans          = _dragImage.GetVerticalOffset().Transform;

            trans.Animate(null, targetLocation, TranslateTransform.YProperty, 200, 0, null,
                          () =>
            {
                // move the dragged item
                var draggedItem = this.interactionList[_initialDragIndex];
                this.itemManager.SetItemOrder(draggedItem, dragIndex == 0 ? null : this.interactionList[dragIndex - 1], dragIndex < this.interactionList.Count - 1 ? this.interactionList[dragIndex] : null, true);
                //this.interactionList.RemoveAt(_initialDragIndex);
                //this.interactionList.Add(draggedItem);

                // re-populate our ObservableCollection
                RefreshView();

                // fade out the dragged image and collapse on completion
                _dragImage.Animate(null, 0.0, FrameworkElement.OpacityProperty, 1000, 0, null, ()
                                   => _dragImage.Visibility = Visibility.Collapsed);
            });
        }