/// <summary>
        /// Performs a random tarnsition between the two pictures.
        /// </summary>
        public void transitionPictures()
        {
            // We randomly choose where the current image is going to
            // slide off to (and where we are going to slide the inactive
            // image in from)...
            int iDestinationLeft = (m_Random.Next(2) == 0) ? Width : -Width;
            int iDestinationTop = (m_Random.Next(3) - 1) * Height;

            // We move the inactive image to this location...
            SuspendLayout();
            m_InactivePicture.Top = iDestinationTop;
            m_InactivePicture.Left = iDestinationLeft;
            m_InactivePicture.BringToFront();
            ResumeLayout();

            // We perform the transition which moves the active image off the
            // screen, and the inactive one onto the screen...
            Transition t = new Transition(new EaseInEaseOut(1000));
            t.Add(m_InactivePicture, "Left", 0);
            t.Add(m_InactivePicture, "Top", 0);
            t.Add(m_ActivePicture, "Left", iDestinationLeft);
            t.Add(m_ActivePicture, "Top", iDestinationTop);
            t.Run();

            // We swap over which image is active and inactive for next time
            // the function is called...
            PictureBox tmp = m_ActivePicture;
            m_ActivePicture = m_InactivePicture;
            m_InactivePicture = tmp;
        }
Example #2
0
        /// <summary>
        /// Creates and immediately runs a transition on the property passed in.
        /// </summary>
        public static void Run(object target, string strPropertyName, object destinationValue, ITransitionType transitionMethod)
        {
            var t = new Transition(transitionMethod);

            t.Add(target, strPropertyName, destinationValue);
            t.Run();
        }
Example #3
0
        /// <summary>
        /// Runs the next transition in the list.
        /// </summary>
        private void RunNextTransition()
        {
            if (_listTransitions.Count == 0)
            {
                return;
            }

            // We find the next transition and run it. We also register
            // for its completed event, so that we can start the next transition
            // when this one completes...
            Transition nextTransition = _listTransitions.First.Value;

            nextTransition.TransitionCompletedEvent += OnTransitionCompleted;
            nextTransition.Run();
        }
Example #4
0
        /// <summary>
        /// Called when the "Text Transition" button is pressed.
        /// </summary>
        private void cmdTextTransition_Click(object sender, EventArgs e)
        {
            // We transition four properties simulataneously here:
            // - The two labels' text is changed.
            // - The two labels' colors are changed.

            // We work out the new text and colors to transition to...
            string strText1, strText2;
            Color color1, color2;
            if (lblTextTransition1.Text == STRING_SHORT)
            {
                strText1 = STRING_LONG;
                color1 = Color.Red;
                strText2 = STRING_SHORT;
                color2 = Color.Blue;
            }
            else
            {
                strText1 = STRING_SHORT;
                color1 = Color.Blue;
                strText2 = STRING_LONG;
                color2 = Color.Red;
            }

            // We create a transition to animate all four properties at the same time...
            Transition t = new Transition(new Linear(1000));
            t.Add(lblTextTransition1, "Text", strText1);
            t.Add(lblTextTransition1, "ForeColor", color1);
            t.Add(lblTextTransition2, "Text", strText2);
            t.Add(lblTextTransition2, "ForeColor", color2);
            t.Run();
        }
Example #5
0
        /// <summary>
        /// Called when the "Swap" button is pressed.
        /// </summary>
        private void cmdSwap_Click(object sender, EventArgs e)
        {
            // We swap over the group-boxes that show the "Bounce" and
            // "Throw and Catch" transitions. The active one is animated
            // left off the screen and the inactive one is animated right
            // onto the screen...

            // We work out which box is currently on screen and
            // which is off screen...
            Control ctrlOnScreen, ctrlOffScreen;
            if (gbBounce.Left == GROUP_BOX_LEFT)
            {
                ctrlOnScreen = gbBounce;
                ctrlOffScreen = gbThrowAndCatch;
            }
            else
            {
                ctrlOnScreen = gbThrowAndCatch;
                ctrlOffScreen = gbBounce;
            }
            ctrlOnScreen.SendToBack();
            ctrlOffScreen.BringToFront();

            // We create a transition to animate the two boxes simultaneously. One is
            // animated onto the screen, the other off the screen.

            // The ease-in-ease-out transition acclerates the rate of change for the
            // first half of the animation, and decelerates during the second half.

            Transition t = new Transition(new EaseInEaseOut(1000));
            t.Add(ctrlOnScreen, "Left", -1 * ctrlOnScreen.Width);
            t.Add(ctrlOffScreen, "Left", GROUP_BOX_LEFT);
            t.Run();
        }
Example #6
0
 /// <summary>
 /// Creates and immediately runs a transition on the property passed in.
 /// </summary>
 public static void Run(object target, string strPropertyName, object destinationValue, ITransitionType transitionMethod)
 {
     var t = new Transition(transitionMethod);
     t.Add(target, strPropertyName, destinationValue);
     t.Run();
 }