Esempio n. 1
0
        private static bool updateChildData(AnimatingPanelItemData data, double dampening, double attractionFactor, double variation)
        {
            if (data == null)
            {
                return(false);
            }
            else
            {
                Debug.Assert(dampening > 0 && dampening < 1);
                Debug.Assert(attractionFactor > 0 && !double.IsInfinity(attractionFactor));

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

                Point  newLocation;
                Vector newVelocity;

                bool anythingChanged =
                    GeoHelper.Animate(data.Current, data.LocationVelocity, data.Target,
                                      attractionFactor, dampening, c_terminalVelocity, c_diff, c_diff,
                                      out newLocation, out newVelocity);

                data.Current          = newLocation;
                data.LocationVelocity = newVelocity;

                var transformVector = data.Current - data.Target;
                data.Transform.SetToVector(transformVector);

                return(anythingChanged);
            }
        }
Esempio n. 2
0
        private void m_listener_rendering(object sender, EventArgs e)
        {
            if (this.Child != m_zapPanel)
            {
                m_zapPanel = (PagingPanel)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 = !GeoHelper.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();
                }
            }
        }
Esempio n. 3
0
        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 = GeoHelper.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();
            }
        }