private void m_listener_Rendering(object sender, EventArgs e)
        {
            bool stillAnimating = false;

            foreach (SetCard3D card in m_cards)
            {
                double zTranslateTarget = (card.IsChecked) ? 50 : 0;
                zTranslateTarget += (card.IsMouseOver) ? -10 : 0;

                double attractionFactor = .05;
                attractionFactor *= 1 + (card.Variation - .5);

                double newTranslate, newVelocity;
                stillAnimating = WpfUtil.Animate(card.TranslateTransform3D.OffsetZ, card.CurrentZVelocity, zTranslateTarget,
                                                 attractionFactor, .3, 1000, .00001, .00001,
                                                 out newTranslate, out newVelocity) || stillAnimating;

                card.CurrentZVelocity             = newVelocity;
                card.TranslateTransform3D.OffsetZ = newTranslate;
            }

            if (!stillAnimating)
            {
                m_listener.StopListening();
            }
        }
        private void m_listener_rendering(object sender, EventArgs e)
        {
            if (this.Child != m_zapPanel)
            {
                m_zapPanel = (ZapPanel)this.Child;
                m_zapPanel.RenderTransform = m_traslateTransform;
            }
            if (m_zapPanel != null)
            {
                int actualTargetIndex = Math.Max(0, Math.Min(m_zapPanel.Children.Count - 1, TargetIndex));

                double targetPercentOffset = -actualTargetIndex / (double)m_zapPanel.Children.Count;
                targetPercentOffset = double.IsNaN(targetPercentOffset) ? 0 : targetPercentOffset;

                bool stopListening = !WpfUtil.Animate(
                    m_percentOffset, m_velocity, targetPercentOffset,
                    .05, .3, .1, c_diff, c_diff,
                    out m_percentOffset, out m_velocity);

                double targetPixelOffset = m_percentOffset * (this.RenderSize.Width * m_zapPanel.Children.Count);
                m_traslateTransform.X = targetPixelOffset;

                if (stopListening)
                {
                    m_listener.StopListening();
                }
            }
        }
Exemplo n.º 3
0
        private static bool updateElement(AnimatingTilePanelData data, double dampening, double attractionFactor, double variation)
        {
            Debug.Assert(dampening > 0 && dampening < 1);
            Debug.Assert(attractionFactor > 0 && !double.IsInfinity(attractionFactor));

            attractionFactor *= 1 + (variation * data.Random - .5);

            Point  newLocation;
            Vector newVelocity;

            bool anythingChanged =
                WpfUtil.Animate(data.ChildLocation, data.Velocity, data.ChildTarget,
                                attractionFactor, dampening, c_terminalVelocity, c_diff, c_diff,
                                out newLocation, out newVelocity);

            data.ChildLocation = newLocation;
            data.Velocity      = newVelocity;

            return(anythingChanged);
        }