Example #1
0
        protected override Storyboard PrepareItemAnimation(ElementFlow owner, int index, ElementFlow.ElementAnimationType type)
        {
            // Initialize storyboard
            Storyboard sb = owner.PrepareTemplateStoryboard(index);

            // Child animations
            Rotation3DAnimation rotAnim = sb.Children[0] as Rotation3DAnimation;
            DoubleAnimation     xAnim   = sb.Children[1] as DoubleAnimation;
            DoubleAnimation     yAnim   = sb.Children[2] as DoubleAnimation;
            DoubleAnimation     zAnim   = sb.Children[3] as DoubleAnimation;

            switch (type)
            {
            case ElementFlow.ElementAnimationType.Left:
                (rotAnim.To as AxisAngleRotation3D).Angle = owner.TiltAngle;
                (rotAnim.To as AxisAngleRotation3D).Axis  = new Vector3D(1, 0, 0);
                yAnim.To = -1 * owner.ItemGap * (owner.SelectedIndex - index) - owner.FrontItemGap;
                break;

            case ElementFlow.ElementAnimationType.Right:
                (rotAnim.To as AxisAngleRotation3D).Angle = -1 * owner.TiltAngle;
                (rotAnim.To as AxisAngleRotation3D).Axis  = new Vector3D(1, 0, 0);
                yAnim.To = owner.ItemGap * (index - owner.SelectedIndex) + owner.FrontItemGap;
                break;

            case ElementFlow.ElementAnimationType.Selection:
                (rotAnim.To as AxisAngleRotation3D).Angle = 0;
                yAnim.To = 0;
                zAnim.To = owner.PopoutDistance;
                break;
            }

            return(sb);
        }
Example #2
0
        public void SelectElement(int selectionIndex)
        {
            for (int beforeIndex = 0; beforeIndex < selectionIndex; beforeIndex++)
            {
                var leftSB = Owner.PrepareTemplateStoryboard(beforeIndex);
                PrepareStoryboard(leftSB, GetBeforeMotion(beforeIndex - selectionIndex));
                leftSB.Begin(Owner.Viewport);
            }

            var centerSB = Owner.PrepareTemplateStoryboard(selectionIndex);

            PrepareStoryboard(centerSB, GetSelectionMotion());
            centerSB.Begin(Owner.Viewport);

            for (int afterIndex = selectionIndex + 1; afterIndex < Owner.Items.Count; afterIndex++)
            {
                var rightSB = Owner.PrepareTemplateStoryboard(afterIndex);
                PrepareStoryboard(rightSB, GetAfterMotion(afterIndex - selectionIndex));
                rightSB.Begin(Owner.Viewport);
            }
        }