コード例 #1
0
        /// <summary>
        /// Go to the specified slide.  If it is already shown, then recompute its layout.
        /// </summary>
        public void GoToSlide(PMultiSizeImage slide)
        {
            if (hiliteSlide != slide)
            {
                HiliteSlide(-1);                  // Unhilite any slide that might be hilited
            }

            // First unfocus any slide that has focus
            if ((focusSlide != null) && (focusSlide != slide))
            {
                ((PMultiSizeImage)focusSlide).ShowThumb = true;
                focusSlide.AnimateToMatrix(GetUnfocusedMatrix(focusSlide, (int)focusSlide.Tag), ANIMATION_TIME_MILLIS);
            }

            // Then set the focus to the new slide
            focusSlide = slide;
            if (focusSlide != null)
            {
                ((PMultiSizeImage)focusSlide).Hilite = false;
                PTransformActivity activity = focusSlide.AnimateToMatrix(GetFocusedMatrix(focusSlide), ANIMATION_TIME_MILLIS);
                activity.ActivityFinished = new ActivityFinishedDelegate(FocusActivityFinished);

                // Move the current position indicator to the new focus slide's spot in the slide bar
                LayoutCurrentPosition();
            }
        }
コード例 #2
0
        /// <summary>
        /// When the hilite animation finishes, put the slide back in its proper place
        /// </summary>
        protected void HiliteActivityFinished(PActivity activity)
        {
            PTransformActivity transformActivity = activity as PTransformActivity;

            PNode.PNodeTransformTarget nodeTarget = (PNode.PNodeTransformTarget)transformActivity.ActivityTarget;
            PNode slide = nodeTarget.Target;

            slideBar.AddChild((int)slide.Tag, slide);              // Reinsert slide in the right slot
        }
コード例 #3
0
        /// <summary>
        /// When the focus animation finishes, show the hires version of the slide
        /// </summary>
        protected void FocusActivityFinished(PActivity activity)
        {
            PTransformActivity transformActivity = activity as PTransformActivity;

            PNode.PNodeTransformTarget nodeTarget = (PNode.PNodeTransformTarget)transformActivity.ActivityTarget;
            PNode slide = nodeTarget.Target;

            ((PMultiSizeImage)slide).ShowThumb = false;
        }
コード例 #4
0
        protected void CreateText(Random rnd)
        {
            // Create some text
            P3Text text = new P3Text("Direct3D Piccolo Renderer");

            text.Brush     = Brushes.Blue;
            text.TextBrush = Brushes.Yellow;
            text.Font      = new System.Drawing.Font("Arial", 120);
            canvas.Layer.AddChild(text);

            PMatrix tMatrix = text.Matrix;

            tMatrix.TranslateBy(canvas.Width - text.Width, 0);
            PTransformActivity translateActivity = text.AnimateToMatrix(tMatrix, 10000 + (long)(2000 * rnd.NextDouble()));

            translateActivity.LoopCount = 1000;
            translateActivity.Mode      = ActivityMode.SourceToDestinationToSource;
        }
コード例 #5
0
ファイル: PCamera.cs プロジェクト: stangelandcl/piccolo2d.net
        /// <summary>
        /// Animate the camera's view matrix from its current value when the activity starts
        /// to the new destination matrix value.
        /// </summary>
        /// <param name="destination">The final matrix value.</param>
        /// <param name="duration">The amount of time that the animation should take.</param>
        /// <returns>
        /// The newly scheduled activity, if the duration is greater than 0; else null.
        /// </returns>
        public virtual PTransformActivity AnimateViewToMatrix(PMatrix destination, long duration)
        {
            if (duration == 0)
            {
                ViewMatrix = destination;
                return(null);
            }

            PTransformActivity ta = new PTransformActivity(duration, PUtil.DEFAULT_ACTIVITY_STEP_RATE, new PCameraTransformTarget(this), destination);

            PRoot r = Root;

            if (r != null)
            {
                r.AddActivity(ta);
            }

            return(ta);
        }
コード例 #6
0
        /// <summary>
        /// Hilite the specified slide - or unhilite all slides if hiliteIndex is -1.
        /// </summary>
        private void HiliteSlide(int newHiliteIndex)
        {
            PNode newSlide = null;

            if (newHiliteIndex >= 0)
            {
                newSlide = slides[newHiliteIndex];
            }
            if (newSlide != hiliteSlide)
            {
                // First unhilite previously hilited slide
                if ((hiliteSlide != null) && (hiliteSlide != focusSlide))
                {
                    // If this slide is currently animating, then kill that animation
                    int index = (int)hiliteSlide.Tag;
                    if (slideActivities[index] != null)
                    {
                        slideActivities[index].Terminate();
                        slideActivities[index] = null;
                    }
                    (hiliteSlide as PMultiSizeImage).ShowThumb = true;
                    (hiliteSlide as PMultiSizeImage).Hilite    = false;
                    PTransformActivity activity = hiliteSlide.AnimateToMatrix(GetUnfocusedMatrix(hiliteSlide, (int)hiliteSlide.Tag), SLIDEBAR_ANIMATION_TIME_MILLIS);
                    // Put the slide in order when the animation finishes
                    activity.ActivityFinished = new ActivityFinishedDelegate(HiliteActivityFinished);
                    hiliteSlide = null;
                }
                // Then hilite new slide (as long is it isn't the currently focused slide)
                if (newSlide != focusSlide)
                {
                    hiliteSlide = newSlide;
                    if (hiliteSlide != null)
                    {
                        PMatrix matrix = GetUnfocusedMatrix(hiliteSlide, (int)hiliteSlide.Tag);
                        matrix.ScaleBy(1.3f, (hiliteSlide.Bounds.Width / 2), hiliteSlide.Bounds.Height);
                        (hiliteSlide as PMultiSizeImage).Hilite = true;
                        hiliteSlide.MoveToFront();
                        currentPosition.MoveToFront();
                        slideActivities[newHiliteIndex] = hiliteSlide.AnimateToMatrix(matrix, SLIDEBAR_ANIMATION_TIME_MILLIS);
                    }
                }
            }
        }
コード例 #7
0
        /// <summary>
        /// Move the camera so that its focusing on the found location
        /// </summary>
        /// <param Name="foundLocation">The location to focus on</param>
        protected void NavigateToFoundPage(Location foundLocation)
        {
            Page foundPage = foundLocation.Page;

            //The camera should first zoom out so that it is looking at both the start location and the found page
            //And then zoom in so that it is only looking at the found page
            RectangleF         planeBounds = RectangleF.Union(Window.Canvas.Camera.ViewBounds, foundPage.GlobalBounds);
            RectangleF         pageBounds  = foundPage.GlobalBounds;
            PTransformActivity zoomOut     = Window.Canvas.Camera.AnimateViewToCenterBounds(planeBounds, true, 400);
            PTransformActivity zoomIn      = Window.Canvas.Camera.AnimateViewToCenterBounds(pageBounds, true, 400);

            //The camera action can happen faster without causing the user to lose track of where they are
            //or getting motion sick if the zoom accelerates toward the middle of each animation
            //and decelerates toward the end of the animation than if the animation moves at constant speed
            zoomOut.SlowInSlowOut = true;
            zoomIn.SlowInSlowOut  = true;

            //Order the animations
            zoomIn.StartAfter(zoomOut);
        }