Пример #1
0
        /// <summary>
        /// Handler for Page 1's hue change button.  This applies a random color to the background of the
        /// button.
        /// </summary>
        void hueChangeButton_Tapped(object sender, EventArgs e)
        {
            Button button = sender as Button;

            Random rnd = new Random();
            // Choose a random color, 0.0-1.0 for each component
            float r = (float)rnd.NextDouble();
            float g = (float)rnd.NextDouble();
            float b = (float)rnd.NextDouble();
            //Make the alpha value a random value between 0.5 and 1.0
            float a = (float)(rnd.NextDouble() * .5 + .5);

            Color newColor = new Color(r, g, b) * a;
            // Font color complements the hue
            Color fontColor = new Color(1.0f - r, 1.0f - g, 1.0f - b);

            // Apply a transition which changes the hue over 2 seconds
            DynamicMenu.Transitions.Transition transition =
                new DynamicMenu.Transitions.Transition(null, null, null, null, button.Hue, newColor);
            transition.TransitionLength = 2.0f;

            button.ApplyTransition(transition);

            // Set the text color immediately
            button.TextColor = fontColor;
        }
Пример #2
0
        /// <summary>
        /// Handler for the completion of Page 1's getBig button transition.  This will return the control to its
        /// normal size.
        /// </summary>
        void getBig_TransitionComplete(object sender, EventArgs e)
        {
            DynamicMenu.Transitions.Transition oldTransition = sender as DynamicMenu.Transitions.Transition;
            Button button = oldTransition.Control as Button;

            // Apply a transition that will return the control to it's original size
            DynamicMenu.Transitions.Transition newTransition = new DynamicMenu.Transitions.Transition(null,
                                                                                                      new Point(100, 280), null, new Point(200, 80), null, null);
            button.ApplyTransition(newTransition);
        }
Пример #3
0
        /// <summary>
        /// Handler for Page 1's getBig button.  This applies a transition to make the control larger
        /// </summary>
        void getBigButton_Tapped(object sender, EventArgs e)
        {
            Button button = sender as Button;

            // Apply a transition that will make the control bigger in place
            DynamicMenu.Transitions.Transition transition = new DynamicMenu.Transitions.Transition(null,
                                                                                                   new Point(0, 240), null, new Point(400, 160), null, null);
            // Create a handler for when the above transition is complete
            transition.TransitionComplete += new EventHandler(getBig_TransitionComplete);

            button.ApplyTransition(transition);
        }