protected override Storyboard PrepareItemAnimation(UIFlow3D owner, int index, UIFlow3D.ElementAnimationType type)
        {
            // Initialize storyboard
            Storyboard sb = (owner.InternalResources["ItemAnimator"] as Storyboard).Clone();

            owner.PrepareTemplateStoryboard(sb, 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 UIFlow3D.ElementAnimationType.Left:
                xAnim.To = -1 * owner.ItemGap * (owner.SelectedIndex - index);
                zAnim.To = owner.ItemGap * (owner.SelectedIndex - index);
                break;

            case UIFlow3D.ElementAnimationType.Selection:
                (rotAnim.To as AxisAngleRotation3D).Angle = -1 * 45;
                (rotAnim.To as AxisAngleRotation3D).Axis  = new Vector3D(0, 0, 1);
                xAnim.To = 2 * owner.ItemGap;
                break;

            case UIFlow3D.ElementAnimationType.Right:
                xAnim.To = owner.ItemGap * (index - owner.SelectedIndex);
                zAnim.To = -1 * owner.ItemGap * (index - owner.SelectedIndex);
                break;
            }

            return(sb);
        }
Пример #2
0
        private static void OnViewModeChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            UIFlow3D ef = d as UIFlow3D;

            ef.ChangeViewState((ViewModeType)e.NewValue);
            ef.ReflowItems();
        }
Пример #3
0
        private static void OnSelectedIndexChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            UIFlow3D ef = d as UIFlow3D;

            if (ef.IsLoaded == false)
            {
                return;
            }

            ef.SelectItemCore((int)e.NewValue);
        }
Пример #4
0
        private static void OnCameraChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            PerspectiveCamera camera = e.NewValue as PerspectiveCamera;

            if (camera == null)
            {
                return;
            }

            UIFlow3D flow = d as UIFlow3D;

            if (flow == null)
            {
                return;
            }

            flow._viewport.Camera = camera;
        }
Пример #5
0
        public void SelectElement(UIFlow3D owner, int index)
        {
            Storyboard anim;

            for (int leftItem = 0; leftItem < index; leftItem++)
            {
                anim = PrepareItemAnimation(owner, leftItem, UIFlow3D.ElementAnimationType.Left);
                owner.AnimateElement(anim);
            }

            anim = PrepareItemAnimation(owner, index, UIFlow3D.ElementAnimationType.Selection);
            owner.AnimateElement(anim);

            for (int rightItem = index + 1; rightItem < owner.VisibleChildrenCount; rightItem++)
            {
                anim = PrepareItemAnimation(owner, rightItem, UIFlow3D.ElementAnimationType.Right);
                owner.AnimateElement(anim);
            }
        }
Пример #6
0
        private static void OnLightChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            Light light = e.NewValue as Light;

            if (light == null)
            {
                return;
            }

            UIFlow3D flow = d as UIFlow3D;

            if (flow == null)
            {
                return;
            }

            Model3DGroup lightContainer = flow._viewport.FindName("LightContainer") as Model3DGroup;

            lightContainer.Children.Clear();
            lightContainer.Children.Add(light);
        }
        protected override Storyboard PrepareItemAnimation(UIFlow3D owner, int index, UIFlow3D.ElementAnimationType type)
        {
            // Initialize storyboard
            Storyboard sb = (owner.InternalResources["ItemAnimator2"] as Storyboard).Clone();

            owner.PrepareTemplateStoryboard(sb, index);

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

            SplineRotation3DKeyFrame rotKf = rotAnim.KeyFrames[0] as SplineRotation3DKeyFrame;

            switch (type)
            {
            case UIFlow3D.ElementAnimationType.Left:
                (rotKf.Value as AxisAngleRotation3D).Angle = owner.TiltAngle;
                xAnim.KeyFrames[0].Value = -1 * owner.ItemGap * (owner.SelectedIndex - index) - owner.FrontItemGap;

                break;

            case UIFlow3D.ElementAnimationType.Right:
                (rotKf.Value as AxisAngleRotation3D).Angle = -1 * owner.TiltAngle;
                xAnim.KeyFrames[0].Value = owner.ItemGap * (index - owner.SelectedIndex) + owner.FrontItemGap;

                break;

            case UIFlow3D.ElementAnimationType.Selection:
                (rotKf.Value as AxisAngleRotation3D).Angle = 0;
                xAnim.KeyFrames[0].Value = 0;
                zAnim.KeyFrames[0].Value = owner.PopoutDistance;

                break;
            }

            return(sb);
        }
Пример #8
0
        private static void OnPopoutDistanceChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            UIFlow3D ef = d as UIFlow3D;

            ef.ReflowItems();
        }
Пример #9
0
        private static void OnFrontItemGapChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            UIFlow3D ef = d as UIFlow3D;

            ef.ReflowItems();
        }
Пример #10
0
        private static void OnTiltAngleChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            UIFlow3D cf = d as UIFlow3D;

            cf.ReflowItems();
        }
Пример #11
0
 protected virtual Storyboard PrepareItemAnimation(UIFlow3D owner, int index, UIFlow3D.ElementAnimationType type)
 {
     return(null);
 }