Ejemplo n.º 1
0
        public NinjaCard(ScanInData inData)
        {
            // save ref to scan in
            ScanInData = inData;
            ScanInData.PropertyChanged += ScanInTick;

            // create shake animation
            _shakeAnim = new Storyboard();
            var doubleAnimation = new DoubleAnimation
            {
                From           = -10.0,
                To             = 10.0,
                Duration       = new Duration(TimeSpan.FromSeconds(1)),
                AutoReverse    = true,
                RepeatBehavior = RepeatBehavior.Forever
            };

            doubleAnimation.SetValue(Storyboard.TargetNameProperty, nameof(MainGridTransform));
            doubleAnimation.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath(TranslateTransform.XProperty));
            var bounceEase = new BounceEase
            {
                Bounces    = 1,
                Bounciness = 2.0,
                EasingMode = EasingMode.EaseOut
            };

            doubleAnimation.EasingFunction = bounceEase;
            _shakeAnim.Children.Add(doubleAnimation);

            // set data context
            InitializeComponent();
            MainGrid.DataContext = this;
        }
Ejemplo n.º 2
0
 private void Close(object sender, RoutedEventArgs e)
 {
     // remove from parent
     // TODO: add restore option
     (Parent as AlignableWrapPanel).Children.Remove(this);
     ScanInData.PropertyChanged -= ScanInTick;
     MainWindow.HideCard(ScanInData);
     ScanInData = null;
 }
Ejemplo n.º 3
0
 private void OnScanIn(ScanInData n)
 {
     MainWrapPanel.Children.Add(new NinjaCard(n));
 }
Ejemplo n.º 4
0
 public static void HideCard(ScanInData c)
 {
     hideCard?.Invoke(c);
 }