protected override CardView RemoveDelayedTool(Card card, bool isCopy) { LargeDelayedToolView dtv = null; foreach (var tmpDtv in delayedToolsDock.Children) { dtv = tmpDtv as LargeDelayedToolView; 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); }
protected override void AddDelayedTool(CardView card, bool isFaked) { LargeDelayedToolView dtv = new LargeDelayedToolView() { Width = 30, Height = 30 }; dtv.DataContext = card.CardModel; dtv.Opacity = 0; dtv.Margin = new Thickness(50d, 0, 0, 0); delayedToolsDock.Children.Add(dtv); dtv.Opacity = 1d; dtv.Margin = new Thickness(0d, 0, 0, 0); if (isFaked) { card.Disappear(0d, true); } else { Point dest = delayedToolsDock.TranslatePoint(new Point(delayedToolsDock.ActualWidth + 15, 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(LargeDelayedToolView.MarginProperty)); Storyboard.SetTargetProperty(animation2, new PropertyPath(LargeDelayedToolView.OpacityProperty)); storyBoard.Children.Add(animation1); storyBoard.Children.Add(animation2); storyBoard.Begin(); }
protected override void AddDelayedTool(CardView card, bool isFaked) { LargeDelayedToolView dtv = new LargeDelayedToolView() { Width=30, Height=30 }; dtv.DataContext = card.CardModel; dtv.Opacity = 0; dtv.Margin = new Thickness(50d, 0, 0, 0); delayedToolsDock.Children.Add(dtv); dtv.Opacity = 1d; dtv.Margin = new Thickness(0d, 0, 0, 0); if (isFaked) { card.Disappear(0d); } else { Point dest = delayedToolsDock.TranslatePoint(new Point(delayedToolsDock.ActualWidth + 15, delayedToolsDock.ActualHeight / 2), ParentGameView.GlobalCanvas); dest.Offset(-card.Width / 2, -card.Height / 2); card.Position = dest; card.Disappear(0.5d); card.Rebase(0.5d); } 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(LargeDelayedToolView.MarginProperty)); Storyboard.SetTargetProperty(animation2, new PropertyPath(LargeDelayedToolView.OpacityProperty)); storyBoard.Children.Add(animation1); storyBoard.Children.Add(animation2); storyBoard.Begin(); }