本文整理汇总了C#中Transitions.Transition.Add方法的典型用法代码示例。如果您正苦于以下问题:C# Transition.Add方法的具体用法?C# Transition.Add怎么用?C# Transition.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Transitions.Transition
的用法示例。
在下文中一共展示了Transition.Add方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: transitionPictures
/// <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;
}
示例2: cmdDropAndBounce_Click
/// <summary>
/// Called when the "Drop and Bounce" button is pressed.
/// </summary>
private void cmdDropAndBounce_Click(object sender, EventArgs e)
{
// We animate the button to drop and bounce twice with bounces
// of diminishing heights. While it does this, it is moving to
// the right, as if thrown to the right. When this animation has
// finished, the button moves back to its original position.
// The diminishing-bounce is not one of the built-in transition types,
// so we create it here as a user-defined transition type. You define
// these as a collection of TransitionElements. These define how far the
// animated properties will have moved at various times, and how the
// transition between different elements is to be done.
// So in the example below:
// 0% - 40% The button acclerates to 100% distance (i.e. the bottom of the screen)
// 40% - 65% The button bounces back (decelerating) to 70% distance.
// etc...
IList<TransitionElement> elements = new List<TransitionElement>();
elements.Add(new TransitionElement(40, 100, InterpolationMethod.Accleration));
elements.Add(new TransitionElement(65, 70, InterpolationMethod.Deceleration));
elements.Add(new TransitionElement(80, 100, InterpolationMethod.Accleration));
elements.Add(new TransitionElement(90, 92, InterpolationMethod.Deceleration));
elements.Add(new TransitionElement(100, 100, InterpolationMethod.Accleration));
int iDestination = gbDropAndBounce.Height - cmdDropAndBounce.Height - 10;
Transition.Run(cmdDropAndBounce, "Top", iDestination, new UserDefined(elements, 2000));
// The transition above just animates the vertical bounce of the button, but not
// the left-to-right movement. This can't use the same transition, as otherwise the
// left-to-right movement would bounce back and forth.
// We run the left-to-right animation as a second, simultaneous transition.
// In fact, we run a transition chain, with the animation of the button back
// to its starting position as the second item in the chain. The second
// transition starts as soon as the first is complete...
Transition t1 = new Transition(new Linear(2000));
t1.Add(cmdDropAndBounce, "Left", cmdDropAndBounce.Left + 400);
Transition t2 = new Transition(new EaseInEaseOut(2000));
t2.Add(cmdDropAndBounce, "Top", 19);
t2.Add(cmdDropAndBounce, "Left", 6);
Transition.RunChain(t1, t2);
}
示例3: cmdTextTransition_Click
/// <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();
}
示例4: cmdSwap_Click
/// <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();
}
示例5: Run
/// <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();
}