Example #1
0
 public void Handle(CardMovedToList message)
 {
     Analytics.TagEvent("Move_Card", new Dictionary <string, string>
     {
         { "Method", "Drag_and_Drop" }
     });
     Handle(api => api.Cards.Move(new CardId(message.Card.Id), new ListId(message.DestinationListId)));
 }
Example #2
0
        private void ManipulationCompleted(object sender, ManipulationCompletedEventArgs e)
        {
            if (!IsActive || !IsEnabled)
            {
                return;
            }

            try
            {
                var element = sender as FrameworkElement;
                if (element == null)
                {
                    return;
                }

                if (HasPassedThresholds(element.ActualWidth,
                                        e.TotalManipulation.Translation.X,
                                        e.FinalVelocities.LinearVelocity.X))
                {
                    var movedLeft = e.TotalManipulation.Translation.X < 0.0;

                    // Perform the actions
                    var item = (CardViewModel)((FrameworkElement)sender).DataContext;
                    var evt  = new CardMovedToList
                    {
                        Card              = item.OriginalCard,
                        SourceListId      = item.ListId,
                        DestinationListId = movedLeft ? _previousListId : _nextListId
                    };

                    // Animate accordingly
                    AnimateMove(element, movedLeft, () =>
                    {
                        _eventAggregator.Publish(evt);
                        _cardsModel.Remove(item);
                        _cardsModel.Refresh();

                        Complete();
                    });
                }
                else
                {
                    // Cancel action
                    AnimateCancel(element, () =>
                    {
                        UpdateDragCues(element, 0, 0);
                        Complete();
                    });
                }
            }
            finally
            {
                IsActive = false;
                Complete();
            }
        }
Example #3
0
        public void Handle(CardMovedToList message)
        {
            FindCardViewModel(message.Card.Id)
            .IfHasValueThenDo(card =>
            {
                card.DisableInteractions();

                Cards.Remove(card);
                Cards.Refresh();
            })
            .ElseDo(() =>
            {
                if (message.DestinationListId != Id)
                {
                    return;     // Not moving to this list
                }
                var vm = _cardFactory()
                         .InitializeWith(message.Card)
                         .EnableInteractions(_interactionManager);

                Cards.Insert(0, vm);
                Cards.Refresh();
            });
        }