Наследование: System.Windows.Controls.Panel
Пример #1
0
        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();
                }

            }
        }
Пример #2
0
        //TODO: be smart about item changes...make sure the control doesn't jump around
        //TODO: be smart about wiring/unwiring this callback. Expensive!!
        private void CompositionTarget_Rendering(object sender, EventArgs e)
        {
            if (this.Child != _zapPanel)
            {
                _zapPanel = this.Child as ZapPanel;
                _zapPanel.RenderTransform = _traslateTransform;
            }
            if (_zapPanel != null)
            {
                int actualTargetIndex = Math.Max(0, Math.Min(_zapPanel.Children.Count - 1, TargetIndex));

                double targetPercentOffset = -actualTargetIndex / (double)_zapPanel.Children.Count;
                double currentPercent = _percentOffset;
                double deltaPercent = targetPercentOffset - currentPercent;

                if (!double.IsNaN(deltaPercent) && !double.IsInfinity(deltaPercent))
                {
                    _velocity *= .9;
                    _velocity += deltaPercent * .01;

                    if (Math.Abs(_velocity) > DIFF || Math.Abs(deltaPercent) > DIFF)
                    {
                        _percentOffset += _velocity;
                    }
                    else
                    {
                        _percentOffset = targetPercentOffset;
                        _velocity = 0;
                    }
                }

                double targetPixelOffset = _percentOffset * (this.RenderSize.Width * _zapPanel.Children.Count);

                _traslateTransform.X = targetPixelOffset;

            }
        }