本文整理汇总了C#中System.Windows.Media.Animation.Storyboard.SetTarget方法的典型用法代码示例。如果您正苦于以下问题:C# Storyboard.SetTarget方法的具体用法?C# Storyboard.SetTarget怎么用?C# Storyboard.SetTarget使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Media.Animation.Storyboard
的用法示例。
在下文中一共展示了Storyboard.SetTarget方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RunTest
void RunTest ()
{
// Hold the Storyboard with a strong ref and the target with a weak ref.
WeakControl = new ContentControl ();
Storyboard = new Storyboard ();
DoubleAnimation anim = new DoubleAnimation { From = 0, To = 1, Duration = new Duration (TimeSpan.FromSeconds (1)) };
Storyboard.SetTarget (Storyboard, WeakControl);
Storyboard.SetTargetProperty (Storyboard, new PropertyPath ("Opacity"));
Storyboard.Children.Add (anim);
Storyboard.Begin ();
GCAndInvoke (() => {
if (WeakControl != null)
Fail ("Storyboard target should be GC'ed");
else
Succeed ();
});
}
示例2: Transition
private void Transition(Storyboard aStoryboard, Storyboard bStoryboard)
{
if (m_AnimationElement == null || bStoryboard == null)
return;
bStoryboard.Stop();
// Give the target a unique name so we can find it later
string name = Guid.NewGuid().ToString();
bStoryboard.SetTargetName(name);
m_AnimationElement.Tag = name;
bStoryboard.SetTarget(m_AnimationElement);
foreach (Timeline animation in bStoryboard.Children)
animation.SetTarget(m_AnimationElement);
//m_AnimationElement.Visibility = Visibility.Visible;
m_AnimationElement.UpdateLayout();
if (aStoryboard != null)
{
aStoryboard.Pause();
Duration duration = bStoryboard.Duration;
TimeSpan timeSpan = aStoryboard.GetCurrentTime();
bStoryboard.Begin();
if (timeSpan.TotalMilliseconds != 0 && duration.HasTimeSpan)
bStoryboard.Seek(duration.TimeSpan - timeSpan);
}
else
bStoryboard.Begin();
}
示例3: Begin
public override void Begin(Action completionAction)
{
Storyboard = new Storyboard();
double liCounter = 0;
var listBoxItems = ListBox.GetVisualDescendants().OfType<ListBoxItem>().Where(lbi => IsOnCurrentPage(lbi) && lbi.IsEnabled).ToList();
if (HoldSelectedItem && Direction == Directions.Out && ListBox.SelectedItem != null)
{
//move selected container to end
var selectedContainer = ListBox.ItemContainerGenerator.ContainerFromItem(ListBox.SelectedItem);
listBoxItems.Remove(selectedContainer);
listBoxItems.Add(selectedContainer);
}
foreach (ListBoxItem li in listBoxItems)
{
GeneralTransform gt = li.TransformToVisual(RootElement);
Point globalCoords = gt.Transform(new Point(0, 0));
double heightAdjustment = li.Content is FrameworkElement ? ((li.Content as FrameworkElement).ActualHeight / 2) : (li.ActualHeight / 2);
//double yCoord = globalCoords.Y + ((((System.Windows.FrameworkElement)(((System.Windows.Controls.ContentControl)(li)).Content)).ActualHeight) / 2);
double yCoord = globalCoords.Y + heightAdjustment;
double offsetAmount = (RootElement.ActualHeight / 2) - yCoord;
PlaneProjection pp = new PlaneProjection();
pp.GlobalOffsetY = offsetAmount * -1;
pp.CenterOfRotationX = 0;
li.Projection = pp;
CompositeTransform ct = new CompositeTransform();
ct.TranslateY = offsetAmount;
li.RenderTransform = ct;
var beginTime = TimeSpan.FromMilliseconds((FeatherDelay * liCounter) + InitialDelay);
if (Direction == Directions.In)
{
li.Opacity = 0;
DoubleAnimationUsingKeyFrames daukf = new DoubleAnimationUsingKeyFrames();
EasingDoubleKeyFrame edkf1 = new EasingDoubleKeyFrame();
edkf1.KeyTime = beginTime;
edkf1.Value = Angle;
daukf.KeyFrames.Add(edkf1);
EasingDoubleKeyFrame edkf2 = new EasingDoubleKeyFrame();
edkf2.KeyTime = TimeSpan.FromMilliseconds(Duration).Add(beginTime);
edkf2.Value = 0;
ExponentialEase ee = new ExponentialEase();
ee.EasingMode = EasingMode.EaseOut;
ee.Exponent = 6;
edkf2.EasingFunction = ee;
daukf.KeyFrames.Add(edkf2);
Storyboard.SetTarget(daukf, li);
Storyboard.SetTargetProperty(daukf, new PropertyPath("(UIElement.Projection).(PlaneProjection.RotationY)"));
Storyboard.Children.Add(daukf);
DoubleAnimation da = new DoubleAnimation();
da.Duration = TimeSpan.FromMilliseconds(0);
da.BeginTime = beginTime;
da.To = 1;
Storyboard.SetTarget(da, li);
Storyboard.SetTargetProperty(da, new PropertyPath("(UIElement.Opacity)"));
Storyboard.Children.Add(da);
}
else
{
li.Opacity = 1;
DoubleAnimation da = new DoubleAnimation();
da.BeginTime = beginTime;
da.Duration = TimeSpan.FromMilliseconds(Duration);
da.To = Angle;
ExponentialEase ee = new ExponentialEase();
ee.EasingMode = EasingMode.EaseIn;
ee.Exponent = 6;
da.EasingFunction = ee;
Storyboard.SetTarget(da, li);
Storyboard.SetTargetProperty(da, new PropertyPath("(UIElement.Projection).(PlaneProjection.RotationY)"));
Storyboard.Children.Add(da);
da = new DoubleAnimation();
da.Duration = TimeSpan.FromMilliseconds(10);
da.To = 0;
da.BeginTime = TimeSpan.FromMilliseconds(Duration).Add(beginTime);
Storyboard.SetTarget(da, li);
Storyboard.SetTargetProperty(da, new PropertyPath("(UIElement.Opacity)"));
Storyboard.Children.Add(da);
}
//.........这里部分代码省略.........
示例4: stb_border_Completed
/// <summary>
/// Event launched when ScatterViewItem's white borders are fully visible.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
public void stb_border_Completed(object sender, EventArgs e)
{
MainDesktop.Sessions.Items.Remove(SessionVM.SessionSVI);
MainDesktop.Photos.Items.Add(SessionVM.SessionSVI);
if (SessionVM.Orientation == "left") MainDesktop.LeftSessionActive = false;
if (SessionVM.Orientation == "right") MainDesktop.RightSessionActive = false;
MainDesktop.CheckDesktopToDisplay();
Storyboard = new Storyboard();
PointAnimation centerPosAnimation = new PointAnimation();
DoubleAnimation orientationAnimation = new DoubleAnimation();
ExponentialEase ease = new ExponentialEase();
ease.EasingMode = EasingMode.EaseOut;
ease.Exponent = 1.5;
Random r = new Random();
Point newCenter = new Point(r.Next((int)MainDesktop.Photos.ActualWidth), r.Next((int)MainDesktop.Photos.ActualHeight));
Double newOrientation = r.Next(-180, 180);
if (SessionVM.Orientation == "right" && MainDesktop.LeftSessionActive)
centerPosAnimation.From = new Point(SessionVM.SessionSVI.ActualCenter.X - 607.5, SessionVM.SessionSVI.ActualCenter.Y);
else centerPosAnimation.From = SessionVM.SessionSVI.ActualCenter;
centerPosAnimation.To = newCenter;
centerPosAnimation.Duration = new Duration(TimeSpan.FromSeconds(5));
centerPosAnimation.DecelerationRatio = .9;
centerPosAnimation.EasingFunction = ease;
centerPosAnimation.FillBehavior = FillBehavior.Stop;
Storyboard.Children.Add(centerPosAnimation);
Storyboard.SetTarget(centerPosAnimation, SessionVM.SessionSVI);
Storyboard.SetTargetProperty(centerPosAnimation, new PropertyPath(ScatterViewItem.CenterProperty));
orientationAnimation.From = SessionVM.SessionSVI.ActualOrientation;
orientationAnimation.To = newOrientation;
orientationAnimation.Duration = new Duration(TimeSpan.FromSeconds(5));
orientationAnimation.DecelerationRatio = .9;
orientationAnimation.EasingFunction = ease;
orientationAnimation.FillBehavior = FillBehavior.Stop;
Storyboard.Children.Add(orientationAnimation);
Storyboard.SetTarget(orientationAnimation, SessionVM.SessionSVI);
Storyboard.SetTargetProperty(orientationAnimation, new PropertyPath(ScatterViewItem.OrientationProperty));
SessionVM.SessionSVI.Center = newCenter;
SessionVM.SessionSVI.Orientation = newOrientation;
Storyboard.Begin();
SessionVM.SessionSVI.CanMove = true;
SessionVM.SessionSVI.CanRotate = true;
SessionVM.SessionSVI.CanScale = false;
SessionVM.SessionSVI.PreviewTouchDown += new EventHandler<System.Windows.Input.TouchEventArgs>(Session_PreviewTouchDown);
SessionVM.Reduced = true;
}
示例5: AddAnimation
/// <summary>
/// adds a looping opacity animation to item
/// </summary>
/// <param name="item"></param>
private Storyboard AddAnimation(ScatterViewItem item)
{
DoubleAnimation Animation = new DoubleAnimation();
Animation.From = 1.0;
Animation.To = 0.02;
//Duration needs to divide the timer length(set in Menu.Menu) evenly for the animation to be smooth
Animation.Duration = new Duration(TimeSpan.FromSeconds(7.5));
Animation.AutoReverse = true;
Animation.RepeatBehavior = RepeatBehavior.Forever;
Storyboard Storyboard = new Storyboard();
Storyboard.Children.Add(Animation);
Storyboard.SetTarget(Animation, item);
Storyboard.SetTargetProperty(Animation, new PropertyPath(ScatterViewItem.OpacityProperty));
Storyboard.Begin();
return Storyboard;
}
示例6: WpfSpinButton
public WpfSpinButton()
{
Width = 25;
Height = 25;
Background = new SolidColorBrush (Colors.White);
Storyboard = new Storyboard { RepeatBehavior = RepeatBehavior.Forever, Duration = TimeSpan.FromMilliseconds (Duration) };
for (int i = 0; i < 360; i += 30) {
// Create the rectangle and centre it in our widget
var rect = new WpfRectangle { Width = 2, Height = 8, Fill = new SolidColorBrush (Colors.Black), RadiusX = 1, RadiusY = 1, Opacity = Values[0] };
WpfCanvas.SetTop (rect, (Height - rect.Height) / 2);
WpfCanvas.SetLeft (rect, Width / 2);
// Rotate the element by 'i' degrees, creating a circle out of all the elements
var group = new TransformGroup ();
group.Children.Add (new RotateTransform (i, 0.5, -6));
group.Children.Add (new TranslateTransform (0, 10));
rect.RenderTransform = group;
// Set the animation
var timeline = new DoubleAnimationUsingKeyFrames ();
Storyboard.SetTarget (timeline, rect);
Storyboard.SetTargetProperty (timeline, new PropertyPath ("Opacity"));
var offset = Duration * (i / 360.0);
for (int j = 0; j < StartTimes.Length; j++) {
var start = (StartTimes[j] + offset) % Duration;
timeline.KeyFrames.Add (new EasingDoubleKeyFrame { KeyTime = KeyTime.FromTimeSpan (TimeSpan.FromMilliseconds (start)), Value = Values[j] });
}
Storyboard.Children.Add (timeline);
Children.Add (rect);
}
}
示例7: Begin
public override void Begin(Action completionAction)
{
Storyboard = new Storyboard();
double liCounter = 0;
var listBoxItems = GetEffectiveItems(RootElement as FrameworkElement);
foreach (FrameworkElement li in listBoxItems)
{
DependencyObject obj = RootElement.Parent;
AdjustPerspective(li, (obj as FrameworkElement), true);
var beginTime = TimeSpan.FromMilliseconds((FeatherDelay * liCounter) + InitialDelay);
if (Direction == Directions.In)
{
li.Opacity = 0;
DoubleAnimationUsingKeyFrames daukf = new DoubleAnimationUsingKeyFrames();
EasingDoubleKeyFrame edkf1 = new EasingDoubleKeyFrame();
edkf1.KeyTime = beginTime;
edkf1.Value = Angle;
daukf.KeyFrames.Add(edkf1);
EasingDoubleKeyFrame edkf2 = new EasingDoubleKeyFrame();
edkf2.KeyTime = TimeSpan.FromMilliseconds(Duration).Add(beginTime);
edkf2.Value = 0;
ExponentialEase ee = new ExponentialEase();
ee.EasingMode = EasingMode.EaseOut;
ee.Exponent = 6;
edkf2.EasingFunction = ee;
daukf.KeyFrames.Add(edkf2);
Storyboard.SetTarget(daukf, li);
Storyboard.SetTargetProperty(daukf, new PropertyPath("(UIElement.Projection).(PlaneProjection.RotationY)"));
Storyboard.Children.Add(daukf);
DoubleAnimation da = new DoubleAnimation();
da.Duration = TimeSpan.FromMilliseconds(0);
da.BeginTime = beginTime;
da.To = 1;
Storyboard.SetTarget(da, li);
Storyboard.SetTargetProperty(da, new PropertyPath("(UIElement.Opacity)"));
Storyboard.Children.Add(da);
}
else
{
li.Opacity = 1;
DoubleAnimation da = new DoubleAnimation();
da.BeginTime = beginTime;
da.Duration = TimeSpan.FromMilliseconds(Duration);
da.To = Angle;
ExponentialEase ee = new ExponentialEase();
ee.EasingMode = EasingMode.EaseIn;
ee.Exponent = 6;
da.EasingFunction = ee;
Storyboard.SetTarget(da, li);
Storyboard.SetTargetProperty(da, new PropertyPath("(UIElement.Projection).(PlaneProjection.RotationY)"));
Storyboard.Children.Add(da);
da = new DoubleAnimation();
da.Duration = TimeSpan.FromMilliseconds(10);
da.To = 0;
da.BeginTime = TimeSpan.FromMilliseconds(Duration).Add(beginTime);
Storyboard.SetTarget(da, li);
Storyboard.SetTargetProperty(da, new PropertyPath("(UIElement.Opacity)"));
Storyboard.Children.Add(da);
}
liCounter++;
}
base.Begin(completionAction);
}