Interaction logic for SmallDelayedToolView.xaml
Inheritance: System.Windows.Controls.UserControl
Example #1
0
        protected override CardView RemoveDelayedTool(Card card, bool isCopy)
        {
            SmallDelayedToolView dtv = null;

            foreach (var tmpDtv in delayedToolsDock.Children)
            {
                dtv = tmpDtv as SmallDelayedToolView;
                Trace.Assert(dtv != null);
                CardViewModel model = dtv.DataContext as CardViewModel;
                Trace.Assert(model != null);
                if (model.Card == card)
                {
                    break;
                }
                dtv = null;
            }

            Trace.Assert(dtv != null);

            Point dest = dtv.TranslatePoint(new Point(0, 0),
                                            ParentGameView.GlobalCanvas);

            if (!isCopy)
            {
                delayedToolsDock.Children.Remove(dtv);
            }

            CardView result = CardView.CreateCard(card);

            ParentGameView.GlobalCanvas.Children.Add(result);
            result.Opacity = 0;
            result.SetCurrentPosition(dest);

            return(result);
        }
Example #2
0
        protected override void AddDelayedTool(CardView card, bool isFaked)
        {
            SmallDelayedToolView dtv = new SmallDelayedToolView()
            {
                Width = 23, Height = 24
            };

            dtv.DataContext = card.CardModel;
            dtv.Opacity     = 0;
            dtv.Margin      = new Thickness(0, 0, 50d, 0);
            delayedToolsDock.Children.Add(dtv);

            if (isFaked)
            {
                card.Disappear(0d, true);
            }
            else
            {
                Point dest = delayedToolsDock.TranslatePoint(new Point(-11.5, delayedToolsDock.ActualHeight / 2),
                                                             ParentGameView.GlobalCanvas);
                dest.Offset(-card.Width / 2, -card.Height / 2);
                card.Position = dest;
                card.Disappear(0.5d, true);
                card.Rebase();
            }

            Storyboard         storyBoard = new Storyboard();
            ThicknessAnimation animation1 = new ThicknessAnimation();
            DoubleAnimation    animation2 = new DoubleAnimation();

            animation1.To       = new Thickness(0d, 0d, 0d, 0d);
            animation2.To       = 1.0d;
            animation1.Duration = TimeSpan.FromMilliseconds(500);
            animation2.Duration = TimeSpan.FromMilliseconds(500);
            Storyboard.SetTarget(animation1, dtv);
            Storyboard.SetTarget(animation2, dtv);
            Storyboard.SetTargetProperty(animation1, new PropertyPath(SmallDelayedToolView.MarginProperty));
            Storyboard.SetTargetProperty(animation2, new PropertyPath(SmallDelayedToolView.OpacityProperty));
            storyBoard.Children.Add(animation1);
            storyBoard.Children.Add(animation2);
            storyBoard.Begin();
        }
Example #3
0
        protected override void AddDelayedTool(CardView card, bool isFaked)
        {
            SmallDelayedToolView dtv = new SmallDelayedToolView() { Width = 23, Height = 24 };
            dtv.DataContext = card.CardModel;
            dtv.Opacity = 0;
            dtv.Margin = new Thickness(0, 0, 50d, 0);
            delayedToolsDock.Children.Add(dtv);

            if (isFaked)
            {
                card.Disappear(0d, true);
            }
            else
            {
                Point dest = delayedToolsDock.TranslatePoint(new Point(-11.5, delayedToolsDock.ActualHeight / 2),
                                                                       ParentGameView.GlobalCanvas);
                dest.Offset(-card.Width / 2, -card.Height / 2);
                card.Position = dest;
                card.Disappear(0.5d, true);
                card.Rebase();
            }

            Storyboard storyBoard = new Storyboard();
            ThicknessAnimation animation1 = new ThicknessAnimation();
            DoubleAnimation animation2 = new DoubleAnimation();
            animation1.To = new Thickness(0d, 0d, 0d, 0d);
            animation2.To = 1.0d;
            animation1.Duration = TimeSpan.FromMilliseconds(500);
            animation2.Duration = TimeSpan.FromMilliseconds(500);
            Storyboard.SetTarget(animation1, dtv);
            Storyboard.SetTarget(animation2, dtv);
            Storyboard.SetTargetProperty(animation1, new PropertyPath(SmallDelayedToolView.MarginProperty));
            Storyboard.SetTargetProperty(animation2, new PropertyPath(SmallDelayedToolView.OpacityProperty));
            storyBoard.Children.Add(animation1);
            storyBoard.Children.Add(animation2);
            storyBoard.Begin();
        }