Exemplo n.º 1
0
        /// <summary>
        /// Updating with an animation (after a tap)
        /// </summary>
        private void UpdatePositionsWithAnimationAsync(PickerSelectorItem selectedItem, Double delta, TimeSpan duration)
        {
            animationSnap.From           = selectedItem.GetTranslateTransform().Y;
            animationSnap.To             = selectedItem.GetTranslateTransform().Y + delta;
            animationSnap.Duration       = duration;
            animationSnap.EasingFunction = new ExponentialEase {
                EasingMode = EasingMode.EaseInOut
            };

            sliderVertical.ValueChanged -= OnVerticalOffsetChanged;
            sliderVertical.Value         = selectedItem.GetTranslateTransform().Y;
            sliderVertical.ValueChanged += OnVerticalOffsetChanged;

            this.storyboard.Completed += (sender, o) =>
            {
                if (SelectedItemChanged != null)
                {
                    SelectedItemChanged(this, selectedItem);
                }
            };

            this.storyboard.RunAsync();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Translate items to a new offset
        /// </summary>
        private void UpdatePosition(Int32 startIndex, Int32 endIndex, Double offset)
        {
            for (Int32 i = startIndex; i < endIndex; i++)
            {
                PickerSelectorItem loopListItem = this.Children[i] as PickerSelectorItem;
                if (loopListItem == null)
                {
                    continue;
                }

                TranslateTransform translateTransform = loopListItem.GetTranslateTransform();

                translateTransform.Y = offset;
            }
        }
        /// <summary>
        /// Updating with an animation (after a tap)
        /// </summary>
        private void UpdatePositionsWithAnimationAsync(PickerSelectorItem selectedItem, Double delta, TimeSpan duration)
        {
            if (Orientation == Orientation.Vertical)
            {
                animationSnap.From = selectedItem.GetTranslateTransform().Y;
                animationSnap.To = selectedItem.GetTranslateTransform().Y + delta;
            }
            else
            {
                animationSnap.From = selectedItem.GetTranslateTransform().X;
                animationSnap.To = selectedItem.GetTranslateTransform().X + delta;
            }

            animationSnap.Duration = duration;
            animationSnap.EasingFunction = new ExponentialEase { EasingMode = EasingMode.EaseInOut };

            internalSlider.ValueChanged -= OnOffsetChanged;
            internalSlider.Value = Orientation == Orientation.Vertical
                ? selectedItem.GetTranslateTransform().Y
                : selectedItem.GetTranslateTransform().X;

            internalSlider.ValueChanged += OnOffsetChanged;

            this.storyboard.Completed += (sender, o) =>
            {
                if (SelectedItemChanged != null)
                {
                    SelectedItemChanged(this, selectedItem);
                }
            };

            this.storyboard.RunAsync();
        }