本文整理汇总了C#中System.Windows.Media.Animation.Storyboard.Begin方法的典型用法代码示例。如果您正苦于以下问题:C# Storyboard.Begin方法的具体用法?C# Storyboard.Begin怎么用?C# Storyboard.Begin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Media.Animation.Storyboard
的用法示例。
在下文中一共展示了Storyboard.Begin方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SurfaceWindow1
/// <summary>
/// Default constructor.
/// </summary>
public SurfaceWindow1()
{
InitializeComponent();
// Add handlers for window availability events
AddWindowAvailabilityHandlers();
flickr.DownloadStringCompleted += new DownloadStringCompletedEventHandler(flickr_DownloadStringCompleted);
sb = this.FindResource("Animate") as Storyboard;
if (settings.Load() == false)
{
tbError.Text = "Error loading Settings.";
sb.Begin();
}
else
{
sFlickrAPIKey = settings.FlickrApiKey;
if (sFlickrAPIKey == "")
{
tbError.Text = "Flickr API Key not set.";
sb.Begin();
}
TagVisualizationDefinition1.Value = settings.ByteTag;
if (TagVisualizationDefinition1.Value == "")
{
tbError.Text = "No Byte Tag defined in Settings.";
sb.Begin();
}
}
}
示例2: ExecuteStoryboard
public void ExecuteStoryboard()
{
try
{
StaticFunctions.AnimateScale(260, 178, 0, 0, this, 0.2);
var fade = new DoubleAnimation
{
From = 1,
To = 0,
Duration = TimeSpan.FromSeconds(0.3)
};
Storyboard.SetTarget(fade, this);
Storyboard.SetTargetProperty(fade, new PropertyPath(UIElement.OpacityProperty));
var sb = new Storyboard();
sb.Children.Add(fade);
sb.Begin();
sb.Completed +=
(o, e1) =>
{
var parent = Parent as Grid;
parent.Children.Remove(this);
};
sb.Begin();
} catch { }
}
示例3: PopupMsg
public PopupMsg(TextBlock msg)
{
//Store TextBlock for message display
this.msg = msg;
//Register the textblock's name, this is necessary for creating Storyboard using codes instead of XAML
NameScope.SetNameScope(msg, new NameScope());
msg.RegisterName("fadetext", msg);
//Create the fade in & fade out animation
DoubleAnimationUsingKeyFrames fadeInOutAni = new DoubleAnimationUsingKeyFrames();
LinearDoubleKeyFrame keyframe = new LinearDoubleKeyFrame();
keyframe.KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(2));
keyframe.Value = 1;
fadeInOutAni.KeyFrames.Add(keyframe);
//keyframe = new LinearDoubleKeyFrame();
fadeInOutAni.Duration = new Duration(TimeSpan.FromSeconds(4));
fadeInOutAni.AutoReverse = true;
fadeInOutAni.AccelerationRatio = .2;
fadeInOutAni.DecelerationRatio = .7;
// Configure the animation to target the message's opacity property
Storyboard.SetTargetName(fadeInOutAni, "fadetext");
Storyboard.SetTargetProperty(fadeInOutAni, new PropertyPath(TextBlock.OpacityProperty));
// Add the fade in & fade out animation to the Storyboard
Storyboard fadeInOutStoryBoard = new Storyboard();
fadeInOutStoryBoard.Children.Add(fadeInOutAni);
// Set event trigger, make this animation played on an event we can control
msg.IsVisibleChanged += delegate(object sender, System.Windows.DependencyPropertyChangedEventArgs e)
{
if (msg.IsVisible) fadeInOutStoryBoard.Begin(msg);
};
}
示例4: PressureTank
public PressureTank()
{
InitializeComponent();
// Initialize visualization resources
_pumpingStoryboard = (Storyboard)Resources["RotatePump"];
_pumpingStoryboard.Begin();
_pressureLevelStoryboard = (Storyboard)Resources["PressureLevel"];
_pressureLevelStoryboard.Begin();
_pressureLevelStoryboard.Pause();
_timerAlertStoryboard = (Storyboard)Resources["TimerEvent"];
_sensorAlertStoryboard = (Storyboard)Resources["SensorEvent"];
// Initialize the simulation environment
_simulator = new RealTimeSimulator(_model, stepDelay: 1000);
_simulator.SimulationStateChanged += (o, e) => UpdateSimulationButtonVisibilities();
_simulator.ModelStateChanged += (o, e) => UpdateModelState();
// Initialize the visualization state
UpdateSimulationButtonVisibilities();
UpdateModelState();
TimerAlert.Opacity = 0;
SensorAlert.Opacity = 0;
ChangeSpeed(8);
}
示例5: PerformCaptureAnimation
private void PerformCaptureAnimation()
{
LoadingView.Text = "Processing ...";
ShowLoadingView();
curtain = new Rectangle();
curtain.Fill = new SolidColorBrush(Colors.White);
LayoutRoot.Children.Add(curtain);
Storyboard animation = new Storyboard();
Duration duration = new Duration(TimeSpan.FromSeconds(0.3));
animation.Duration = duration;
DoubleAnimation curtainAnimation = new DoubleAnimation();
animation.Children.Add(curtainAnimation);
curtainAnimation.Duration = duration;
curtainAnimation.To = 0;
curtainAnimation.EasingFunction = new CubicEase() { EasingMode = EasingMode.EaseIn };
Storyboard.SetTarget(curtainAnimation, curtain);
Storyboard.SetTargetProperty(curtainAnimation, new PropertyPath("Opacity"));
animation.Completed += (sender, e) => {
LayoutRoot.Children.Remove(curtain);
};
animation.Begin();
}
示例6: SmoothSetAsync
public static Task SmoothSetAsync(this FrameworkElement @this, DependencyProperty dp, double targetvalue,
TimeSpan iDuration, CancellationToken iCancellationToken)
{
TaskCompletionSource<object> tcs = new TaskCompletionSource<object>();
DoubleAnimation anim = new DoubleAnimation(targetvalue, new Duration(iDuration));
PropertyPath p = new PropertyPath("(0)", dp);
Storyboard.SetTargetProperty(anim, p);
Storyboard sb = new Storyboard();
sb.Children.Add(anim);
EventHandler handler = null;
handler = delegate
{
sb.Completed -= handler;
sb.Remove(@this);
@this.SetValue(dp, targetvalue);
tcs.TrySetResult(null);
};
sb.Completed += handler;
sb.Begin(@this, true);
iCancellationToken.Register(() =>
{
double v = (double)@this.GetValue(dp);
sb.Stop();
sb.Remove(@this);
@this.SetValue(dp, v);
tcs.TrySetCanceled();
});
return tcs.Task;
}
示例7: SetScrollEffect
public static void SetScrollEffect(DependencyObject obj, int value)
{
var elem = obj as FrameworkElement;
var transGroup = new TransformGroup();
transGroup.Children.Add(new ScaleTransform());
transGroup.Children.Add(new SkewTransform());
transGroup.Children.Add(new RotateTransform());
transGroup.Children.Add(new TranslateTransform());
elem.RenderTransform = transGroup;
var sb = new Storyboard();
var da = new DoubleAnimationUsingKeyFrames();
Storyboard.SetTarget(da, obj);
Storyboard.SetTargetProperty(da, new PropertyPath("(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)", new object[0]));
da.KeyFrames.Add(new EasingDoubleKeyFrame { KeyTime = KeyTime.FromTimeSpan(TimeSpan.Zero), Value = 60 });
da.KeyFrames.Add(new EasingDoubleKeyFrame { KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(value)), Value = 60 });
da.KeyFrames.Add(new EasingDoubleKeyFrame { KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(value + 900)), Value = 0, EasingFunction = new CircleEase { EasingMode = EasingMode.EaseOut } });
sb.Children.Add(da);
var da2 = new DoubleAnimationUsingKeyFrames();
Storyboard.SetTarget(da2, obj);
Storyboard.SetTargetProperty(da2, new PropertyPath(UIElement.OpacityProperty));
da2.KeyFrames.Add(new EasingDoubleKeyFrame { KeyTime = KeyTime.FromTimeSpan(TimeSpan.Zero), Value = 0 });
da2.KeyFrames.Add(new EasingDoubleKeyFrame { KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(value)), Value = 0 });
da2.KeyFrames.Add(new EasingDoubleKeyFrame { KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(value + 400)), Value = 1 });
sb.Children.Add(da2);
elem.Loaded += (a, b) =>
{
sb.Begin();
};
obj.SetValue(ScrollEffectProperty, value);
}
示例8: DismissEVHUD
public void DismissEVHUD()
{
if (evHUDView == null)
{
return;
}
Storyboard storyboard = new Storyboard();
Duration duration = new Duration(TimeSpan.FromSeconds(0.3));
storyboard.Duration = duration;
DoubleAnimation panelAnimation = new DoubleAnimation();
panelAnimation.Duration = duration;
panelAnimation.To = evHUDView.Width;
panelAnimation.EasingFunction = new CubicEase() { EasingMode = EasingMode.EaseOut };
Storyboard.SetTarget(panelAnimation, evHUDView);
Storyboard.SetTargetProperty(panelAnimation, new PropertyPath("(UIElement.RenderTransform).(TranslateTransform.X)"));
storyboard.Children.Add(panelAnimation);
storyboard.Begin();
storyboard.Completed += (sender, e) =>
{
evHUDView.Visibility = Visibility.Collapsed;
if (Orientation == PageOrientation.LandscapeLeft || Orientation == PageOrientation.LandscapeRight)
{
ShowLandscapeShutterButton();
}
};
}
示例9: OnTextChanged
private static void OnTextChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var control = d as AnimatingTextControl;
var newText = e.NewValue as string;
var animation = new DoubleAnimation();
animation.From = 1;
animation.To = 0;
animation.Duration = new Duration(TimeSpan.FromMilliseconds(200));
animation.Completed += (sender, args) =>
{
control.TheTextBlock.Text = newText;
var fadeInAnimation = new DoubleAnimation();
fadeInAnimation.From = 0.0;
fadeInAnimation.To = 1.0;
fadeInAnimation.Duration = new Duration(TimeSpan.FromMilliseconds(200));
Storyboard.SetTarget(fadeInAnimation, control);
Storyboard.SetTargetProperty(fadeInAnimation, new PropertyPath("Opacity"));
var storyboard2 = new Storyboard();
storyboard2.Children.Add(fadeInAnimation);
storyboard2.Begin();
};
Storyboard.SetTarget(animation, control);
Storyboard.SetTargetProperty(animation, new PropertyPath("Opacity"));
var storyboard = new Storyboard();
storyboard.Children.Add(animation);
storyboard.Begin();
}
示例10: PerformTranstition
public override void PerformTranstition(UserControl newPage, UserControl oldPage)
{
this.newPage = newPage;
this.oldPage = oldPage;
Duration duration = new Duration(TimeSpan.FromSeconds(1));
DoubleAnimation animation = new DoubleAnimation();
animation.Duration = duration;
switch (direction)
{
case WipeDirection.LeftToRight:
animation.To = oldPage.ActualWidth;
break;
case WipeDirection.RightToLeft:
animation.To = -oldPage.ActualWidth;
break;
}
Storyboard sb = new Storyboard();
sb.Duration = duration;
sb.Children.Add(animation);
sb.Completed += sb_Completed;
TranslateTransform sc = new TranslateTransform();
oldPage.RenderTransform = sc;
Storyboard.SetTarget(animation, sc);
Storyboard.SetTargetProperty(animation, new PropertyPath("X"));
//oldPage.Resources.Add(sb);
sb.Begin();
}
示例11: RunByCode
private void RunByCode(object sender, RoutedEventArgs e)
{
var storyBoard = new Storyboard();
var animation1 = new DoubleAnimation
{
To = 400, From = 0,
Duration = TimeSpan.FromSeconds(1),
FillBehavior = FillBehavior.HoldEnd
};
var animation2 = new DoubleAnimation
{
To = 400, From = 0,
Duration = TimeSpan.FromSeconds(1),
FillBehavior = FillBehavior.HoldEnd
};
var animation3 = new DoubleAnimation
{
To = 400, From = 0,
Duration = TimeSpan.FromSeconds(1),
FillBehavior = FillBehavior.HoldEnd
};
Storyboard.SetTargetName(animation1, "WhiteAthlete");
Storyboard.SetTargetProperty(animation1, new PropertyPath(TranslateTransform.XProperty));
Storyboard.SetTargetName(animation2, "BlackAthlete");
Storyboard.SetTargetProperty(animation2, new PropertyPath(TranslateTransform.XProperty));
Storyboard.SetTargetName(animation3, "BrownAthlete");
Storyboard.SetTargetProperty(animation3, new PropertyPath(TranslateTransform.XProperty));
storyBoard.Duration = TimeSpan.FromSeconds(1);
storyBoard.Children.Add(animation1);
storyBoard.Children.Add(animation2);
storyBoard.Children.Add(animation3);
storyBoard.Begin(this);
}
示例12: ExpandTweetPanel
/// <summary>
/// 展开推文显示区域
/// </summary>
///
/// <param name="mainWindow">主窗体this指针</param>
/// <param name="expandHeight">需要展开的高度</param>
public static void ExpandTweetPanel(MainWindow w,int expandHeight)
{
DoubleAnimation a = new DoubleAnimation();
a.From = w.TweetPanel.Height;
a.To = w.TweetPanel.Height + expandHeight;
a.Duration = new Duration(TimeSpan.Parse("0:0:1"));
a.AccelerationRatio = 0.5;
a.DecelerationRatio = 0.5;
Storyboard aHeightsb = new Storyboard();
Storyboard.SetTargetProperty(a, new PropertyPath(StackPanel.HeightProperty));
aHeightsb.Children.Add(a);
aHeightsb.Begin(w.TweetPanel);
DoubleAnimation b = new DoubleAnimation();
b.From = w.Top;
b.To = b.From - expandHeight;
b.Duration = new Duration(TimeSpan.Parse("0:0:1"));
b.AccelerationRatio = 0.5;
b.DecelerationRatio = 0.5;
w.BeginAnimation(Window.TopProperty, b);
DoubleAnimation c = new DoubleAnimation();
c.From = w.Height;
c.To = w.Height + expandHeight;
c.Duration = new Duration(TimeSpan.Parse("0:0:1"));
c.AccelerationRatio = 0.5;
c.DecelerationRatio = 0.5;
w.BeginAnimation(MainWindow.HeightProperty, c);
}
示例13: Wave
/// <summary>
/// 空间扭曲波动
/// </summary>
public void Wave(Point center)
{
DoubleAnimationUsingKeyFrames d0 = new DoubleAnimationUsingKeyFrames();
SplineDoubleKeyFrame s0 = new SplineDoubleKeyFrame() { KeyTime = TimeSpan.Zero, Value = 70 };
EasingDoubleKeyFrame e0 = new EasingDoubleKeyFrame() { EasingFunction = new SineEase() { EasingMode = EasingMode.EaseOut }, KeyTime = TimeSpan.FromMilliseconds(300), Value = 0 };
d0.KeyFrames.Add(s0);
d0.KeyFrames.Add(e0);
Storyboard.SetTarget(d0, this);
Storyboard.SetTargetProperty(d0, new PropertyPath("(UIElement.Effect).(RippleEffect.Frequency)"));
DoubleAnimationUsingKeyFrames d1 = new DoubleAnimationUsingKeyFrames();
SplineDoubleKeyFrame s1 = new SplineDoubleKeyFrame() { KeyTime = TimeSpan.Zero, Value = 0 };
EasingDoubleKeyFrame e1 = new EasingDoubleKeyFrame() { KeyTime = TimeSpan.FromMilliseconds(150), Value = 0.01 };
EasingDoubleKeyFrame e11 = new EasingDoubleKeyFrame() { EasingFunction = new SineEase() { EasingMode = EasingMode.EaseOut }, KeyTime = TimeSpan.FromMilliseconds(300), Value = 0 };
d1.KeyFrames.Add(s1);
d1.KeyFrames.Add(e1);
d1.KeyFrames.Add(e11);
Storyboard.SetTarget(d1, this);
Storyboard.SetTargetProperty(d1, new PropertyPath("(UIElement.Effect).(RippleEffect.Amplitude)"));
if (waveStoryboard != null) { Wave_Completed(waveStoryboard, null); }
center.X = (center.X + offset.X) / mapRoot.BodyWidth;
center.Y = (center.Y + offset.Y) / mapRoot.BodyHeight;
this.Effect = new WaveRipple() { Phase = 0, Amplitude = 0, Frequency = 0, Center = center };
waveStoryboard = new Storyboard();
waveStoryboard.Children.Add(d0);
waveStoryboard.Children.Add(d1);
waveStoryboard.Completed += new EventHandler(Wave_Completed);
waveStoryboard.Begin();
}
示例14: StepFiveControl
public StepFiveControl(MainWindow window)
{
InitializeComponent();
countdownControl.Initial(200, 170, 200,60);
countdownControl.CountdownCompleted += () => {
countdownControl.Visibility = Visibility.Collapsed;
PlaySound();
};
sb = Resources["sb1"] as Storyboard;
media.MediaEnded += OnSceneOver;
media.MediaFailed += (sender, args) =>
{
_isMediaPlaying = false;
};
media.MediaOpened += (s, e) =>
{
//Panel.SetZIndex(media, 999);
//border.Visibility = Visibility.Collapsed;
//media.Opacity = 1;
sb.Begin(media, true);
};
sb.Completed += (s, e) =>
{
sb.Remove(media);
media.Opacity = 1;
};
Window = window;
}
示例15: ImageQueue_OnComplate
private static void ImageQueue_OnComplate(Image i, string u, BitmapImage b)
{
//System.Windows.MessageBox.Show(u);
string source = ImageDecoder.GetSource(i);
if (source == u.ToString())
{
i.Source = b;
Storyboard storyboard = new Storyboard();
DoubleAnimation doubleAnimation = new DoubleAnimation(0.0, 1.0, new Duration(TimeSpan.FromMilliseconds(500.0)));
Storyboard.SetTarget(doubleAnimation, i);
Storyboard.SetTargetProperty(doubleAnimation, new PropertyPath("Opacity", new object[0]));
storyboard.Children.Add(doubleAnimation);
storyboard.Begin();
if (i.Parent is Grid)
{
Grid grid = i.Parent as Grid;
//foreach (var c in grid.Children)
//{
// if (c is WaitingProgress && c != null)
// {
// (c as WaitingProgress).Stop();
// break;
// }
//}
}
}
}