本文整理汇总了C#中System.Windows.Media.Animation.DoubleAnimationUsingKeyFrames类的典型用法代码示例。如果您正苦于以下问题:C# DoubleAnimationUsingKeyFrames类的具体用法?C# DoubleAnimationUsingKeyFrames怎么用?C# DoubleAnimationUsingKeyFrames使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DoubleAnimationUsingKeyFrames类属于System.Windows.Media.Animation命名空间,在下文中一共展示了DoubleAnimationUsingKeyFrames类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Popup
public Popup(String heading, String body, String imageSource, Int32 numPopups)
{
InitializeComponent();
this.Left = SystemParameters.WorkArea.Width - this.Width;
this.Top = SystemParameters.WorkArea.Height - (this.Height * (numPopups + 1));
tweetText.Text = body;
userName.Text = heading;
ImageSourceConverter conv = new ImageSourceConverter();
avatarImage.Source = (ImageSource)conv.ConvertFromString(imageSource);
this.Topmost = true;
sbFadeOut = (Storyboard)FindResource("sbFadeOut");
sbFadeOut.Completed += new EventHandler(sbFadeOut_Completed);
DoubleAnimationUsingKeyFrames animation = new DoubleAnimationUsingKeyFrames();
Storyboard.SetTargetName(animation, "MainGrid");
Storyboard.SetTargetProperty(animation, new PropertyPath(UIElement.OpacityProperty));
animation.KeyFrames.Add(new SplineDoubleKeyFrame(1, KeyTime.FromTimeSpan(TimeSpan.FromSeconds(0))));
animation.KeyFrames.Add(new SplineDoubleKeyFrame(1, KeyTime.FromTimeSpan(TimeSpan.FromSeconds(Double.Parse(Properties.Settings.Default.NotificationDisplayTime)))));
animation.KeyFrames.Add(new SplineDoubleKeyFrame(0, KeyTime.FromTimeSpan(TimeSpan.FromSeconds(Double.Parse(Properties.Settings.Default.NotificationDisplayTime) + 1))));
sbFadeOut.Children.Add(animation);
ShowPopup = (Storyboard)FindResource("ShowPopup");
ShowPopup.Completed += new EventHandler(ShowPopup_Completed);
ShowPopup.Begin(this, true);
}
示例2: Down
private void Down()
{
Storyboard sb2 = new Storyboard();
if((SystemParameters.WorkArea.Height -Top - Height) <= 0)
{
DoubleAnimationUsingKeyFrames da1 = new DoubleAnimationUsingKeyFrames();
var top = SystemParameters.WorkArea.Height - this.Height;
da1.KeyFrames.Add(new LinearDoubleKeyFrame(top, TimeSpan.FromSeconds(0)));
da1.KeyFrames.Add(new LinearDoubleKeyFrame(top + 260, TimeSpan.FromSeconds(1)));
Storyboard.SetTarget(da1, metroWindow);
Storyboard.SetTargetProperty(da1, new PropertyPath("Top"));
sb2.Children.Add(da1);
}
DoubleAnimationUsingKeyFrames da2 = new DoubleAnimationUsingKeyFrames();
da2.KeyFrames.Add(new LinearDoubleKeyFrame(406, TimeSpan.FromSeconds(0)));
da2.KeyFrames.Add(new LinearDoubleKeyFrame(146, TimeSpan.FromSeconds(1)));
Storyboard.SetTarget(da2, metroWindow);
Storyboard.SetTargetProperty(da2, new PropertyPath("Height"));
sb2.Children.Add(da2);
DoubleAnimationUsingKeyFrames da3 = new DoubleAnimationUsingKeyFrames();
da3.KeyFrames.Add(new LinearDoubleKeyFrame(260, TimeSpan.FromSeconds(0)));
da3.KeyFrames.Add(new LinearDoubleKeyFrame(0, TimeSpan.FromSeconds(1)));
Storyboard.SetTarget(da3, grid);
Storyboard.SetTargetProperty(da3, new PropertyPath("Height"));
sb2.Children.Add(da3);
sb2.Begin(this);
_isOpen = false;
}
示例3: GetAnimation
public Storyboard GetAnimation(DependencyObject target, double to, double from)
{
Storyboard story = new Storyboard();
Storyboard.SetTargetProperty(story, new PropertyPath("(TextBlock.RenderTransform).(TranslateTransform.X)"));
Storyboard.SetTarget(story, target);
var doubleAnimation = new DoubleAnimationUsingKeyFrames();
var fromFrame = new EasingDoubleKeyFrame(from)
{
EasingFunction = new ExponentialEase() {EasingMode = EasingMode.EaseIn},
KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(0))
};
var toFrame = new EasingDoubleKeyFrame(to)
{
EasingFunction = new QuadraticEase() {EasingMode = EasingMode.EaseOut},
KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(600))
};
doubleAnimation.KeyFrames.Add(fromFrame);
doubleAnimation.KeyFrames.Add(toFrame);
story.Children.Add(doubleAnimation);
return story;
}
示例4: btnSaveConfig_Click
private void btnSaveConfig_Click(object sender, RoutedEventArgs e)
{
BmclCore.Config.Autostart = checkAutoStart.IsChecked != null && (bool)checkAutoStart.IsChecked;
BmclCore.Config.ExtraJvmArg = txtExtJArg.Text;
BmclCore.Config.Javaw = txtJavaPath.Text;
BmclCore.Config.Javaxmx = txtJavaXmx.Text;
BmclCore.Config.Login = listAuth.SelectedItem.ToString();
BmclCore.Config.LastPlayVer = BmclCore.MainWindow.GridGame.GetSelectedVersion();
BmclCore.Config.Passwd = Encoding.UTF8.GetBytes(txtPwd.Password);
BmclCore.Config.Username = txtUserName.Text;
BmclCore.Config.WindowTransparency = sliderWindowTransparency.Value;
BmclCore.Config.Report = checkReport.IsChecked != null && checkReport.IsChecked.Value;
BmclCore.Config.CheckUpdate = checkCheckUpdate.IsChecked != null && checkCheckUpdate.IsChecked.Value;
BmclCore.Config.DownloadSource = listDownSource.SelectedIndex;
BmclCore.Config.Lang = LangManager.GetLangFromResource("LangName");
BmclCore.Config.Height = int.Parse(ScreenHeightTextBox.Text);
BmclCore.Config.Width = int.Parse(ScreenWidthTextBox.Text);
BmclCore.Config.FullScreen = FullScreenCheckBox.IsChecked??false;
BmclCore.Config.Save(null);
var dak = new DoubleAnimationUsingKeyFrames();
dak.KeyFrames.Add(new LinearDoubleKeyFrame(0, TimeSpan.FromSeconds(0)));
dak.KeyFrames.Add(new LinearDoubleKeyFrame(30, TimeSpan.FromSeconds(0.3)));
dak.KeyFrames.Add(new LinearDoubleKeyFrame(30, TimeSpan.FromSeconds(2.3)));
dak.KeyFrames.Add(new LinearDoubleKeyFrame(0, TimeSpan.FromSeconds(2.6)));
popupSaveSuccess.BeginAnimation(FrameworkElement.HeightProperty, dak);
}
示例5: StopAsync
public Task StopAsync()
{
TaskCompletionSource<object> tcs = new TaskCompletionSource<object>();
if (_Running != true)
{
tcs.SetResult(null);
return tcs.Task;
}
Storyboard SB = new Storyboard();
_Running = false;
double cangle = RotateTransform.Angle;
int Nb = (int)Math.Round((360 - cangle) / 45) + 1;
DoubleAnimationUsingKeyFrames dauk = new DoubleAnimationUsingKeyFrames();
for (int i = 0; i < 17; i++)
{
DiscreteDoubleKeyFrame first = new DiscreteDoubleKeyFrame(cangle + 45 * i, KeyTime.FromTimeSpan(TimeSpan.FromSeconds(i * Frequency)));
dauk.KeyFrames.Add(first);
}
Storyboard.SetTarget(dauk, VB);
Storyboard.SetTargetProperty(dauk, new PropertyPath("(RenderTransform).(RotateTransform.Angle)"));
SB.Children.Add(dauk);
for (int i = 0; i < 8; i++)
{
ObjectAnimationUsingKeyFrames oauk = new ObjectAnimationUsingKeyFrames();
oauk.RepeatBehavior = new RepeatBehavior(1);
DiscreteObjectKeyFrame first = new DiscreteObjectKeyFrame(Visibility.Visible, KeyTime.FromTimeSpan(TimeSpan.FromSeconds(Frequency * Nb)));
oauk.KeyFrames.Add(first);
DiscreteObjectKeyFrame first_1 = new DiscreteObjectKeyFrame(Visibility.Collapsed, KeyTime.FromTimeSpan(TimeSpan.FromSeconds((i + Nb) * Frequency)));
oauk.KeyFrames.Add(first_1);
DiscreteObjectKeyFrame second = new DiscreteObjectKeyFrame(Visibility.Collapsed, KeyTime.FromTimeSpan(TimeSpan.FromSeconds((i + Nb) * Frequency)));
oauk.KeyFrames.Add(second);
Storyboard.SetTarget(oauk, this.FindName(string.Format("E{0}", i)) as DependencyObject);
Storyboard.SetTargetProperty(oauk, new PropertyPath("Visibility"));
SB.Children.Add(oauk);
}
_SB.Stop();
EventHandler handler = null;
handler = delegate
{
SB.Completed -= handler;
tcs.SetResult(null);
};
SB.Completed += handler;
SB.Begin();
return tcs.Task;
}
示例6: StartAnimation
void StartAnimation(DependencyProperty property, TimeSpan beginTime, bool isLast = false)
{
DoubleAnimationUsingKeyFrames d = new DoubleAnimationUsingKeyFrames();
d.KeyFrames.Add(new LinearDoubleKeyFrame(.25d, KeyTime.FromPercent(.10d)));
d.KeyFrames.Add(new LinearDoubleKeyFrame(.3d, KeyTime.FromPercent(.15d)));
d.KeyFrames.Add(new LinearDoubleKeyFrame(.7d, KeyTime.FromPercent(.85d)));
d.KeyFrames.Add(new LinearDoubleKeyFrame(.75d, KeyTime.FromPercent(.90d)));
d.KeyFrames.Add(new LinearDoubleKeyFrame(1d, KeyTime.FromPercent(1d)));
d.Duration = TimeSpan.FromSeconds(3);
d.BeginTime = beginTime;
d.FillBehavior = FillBehavior.Stop;
if (isLast)
{
if (this.observedAnimation != null)
{
this.observedAnimation.StopObserving();
}
this.observedAnimation = new AnimationObserver(this, d);
}
this.BeginAnimation(property, null);
this.BeginAnimation(property, d);
}
示例7: 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();
}
示例8: OnMoviesLoading
/// <summary>
/// Fade in opacity of the window, let the progress ring appear and collapse the NoMouvieFound label when loading movies
/// </summary>
/// <param name="sender">Sender object</param>
/// <param name="e">EventArgs</param>
private void OnMoviesLoading(object sender, EventArgs e)
{
// We have to deal with the DispatcherHelper, otherwise we're having the classic cross-thread access exception
DispatcherHelper.CheckBeginInvokeOnUI(() =>
{
ProgressRing.IsActive = true;
#region Fade in opacity
DoubleAnimationUsingKeyFrames opacityAnimation = new DoubleAnimationUsingKeyFrames();
opacityAnimation.Duration = new Duration(TimeSpan.FromSeconds(0.5));
PowerEase opacityEasingFunction = new PowerEase();
opacityEasingFunction.EasingMode = EasingMode.EaseInOut;
EasingDoubleKeyFrame startOpacityEasing = new EasingDoubleKeyFrame(1, KeyTime.FromPercent(0));
EasingDoubleKeyFrame endOpacityEasing = new EasingDoubleKeyFrame(0.2, KeyTime.FromPercent(1.0),
opacityEasingFunction);
opacityAnimation.KeyFrames.Add(startOpacityEasing);
opacityAnimation.KeyFrames.Add(endOpacityEasing);
ItemsList.BeginAnimation(OpacityProperty, opacityAnimation);
#endregion
if (NoMouvieFound.Visibility == Visibility.Visible)
{
NoMouvieFound.Visibility = Visibility.Collapsed;
}
});
}
示例9: CreateStoryboard
protected override Storyboard CreateStoryboard(FrameworkElement element)
{
var storyboard = new Storyboard();
var WidthAnimation = new DoubleAnimationUsingKeyFrames();
var HeightAnimation = new DoubleAnimationUsingKeyFrames();
Storyboard.SetTargetProperty(WidthAnimation, new PropertyPath("(FrameworkElement.Width)"));
Storyboard.SetTargetProperty(HeightAnimation, new PropertyPath("(FrameworkElement.Height)"));
storyboard.Children.Add(WidthAnimation);
storyboard.Children.Add(HeightAnimation);
WidthAnimation.KeyFrames.Add(new SplineDoubleKeyFrame()
{
KeySpline = new KeySpline()
{
ControlPoint1 = new Point(0.528, 0),
ControlPoint2 = new Point(0.142, 0.847)
}
});
HeightAnimation.KeyFrames.Add(new SplineDoubleKeyFrame()
{
KeySpline = new KeySpline()
{
ControlPoint1 = new Point(0.528, 0),
ControlPoint2 = new Point(0.142, 0.847)
}
});
return storyboard;
}
示例10: ClosingWindow
public void ClosingWindow()
{
//キーフレームで時間を区切る
var frame0 = new EasingDoubleKeyFrame(this.Width, KeyTime.FromTimeSpan(new TimeSpan(1)));
var frame1 = new EasingDoubleKeyFrame(0, KeyTime.FromTimeSpan(new TimeSpan(2500000)));
var frame2 = new EasingDoubleKeyFrame(this.Height, KeyTime.FromTimeSpan(new TimeSpan(2500001)));
var frame3 = new EasingDoubleKeyFrame(0, KeyTime.FromTimeSpan(new TimeSpan(5000000)));
//キーフレームをアニメーションとしてまとめる
var animationWidth = new DoubleAnimationUsingKeyFrames();
animationWidth.KeyFrames.Add(frame0);
animationWidth.KeyFrames.Add(frame1);
//アニメーションをアニメーションさせたいオブジェクトクラスのプロパティにひもづける
//...ということはオブジェクト毎にアニメーションさせるのはだめ?
Storyboard.SetTargetName(animationWidth, this.Name);
Storyboard.SetTargetProperty(animationWidth, new PropertyPath(MainWindow.WidthProperty));
var animationHeight = new DoubleAnimationUsingKeyFrames();
animationHeight.KeyFrames.Add(frame2);
animationHeight.KeyFrames.Add(frame3);
Storyboard.SetTargetName(animationHeight, this.Name);
Storyboard.SetTargetProperty(animationHeight, new PropertyPath(MainWindow.HeightProperty));
//静的にひもづけられたストーリーボードへアニメーションを登録する
myStoryboard = new Storyboard();
myStoryboard.Completed += new EventHandler(endAnimation);
myStoryboard.Children.Add(animationWidth);
myStoryboard.Children.Add(animationHeight);
//アニメーションを実行する
myStoryboard.Begin(this);
myStoryboard.Stop();
}
示例11: Spinner
public Spinner()
{
var duration = TimeSpan.FromSeconds(1.3);
m_Animation = new DoubleAnimationUsingKeyFrames()
{
RepeatBehavior = RepeatBehavior.Forever,
Duration = duration
};
for (int i = 0; i < c_Blobs; i++)
{
m_Animation.KeyFrames.Add(new DiscreteDoubleKeyFrame(i * 360.0 / c_Blobs, KeyTime.Paced));
}
var rotateTransform = new RotateTransform();
RenderTransform = rotateTransform;
for (int i = 0; i < c_Blobs; i++)
{
var r = (byte)(0xFF - (((0xFF - 0x17) / c_Blobs) * i));
var g = (byte)(0xFF - (((0xFF - 0x7F) / c_Blobs) * i));
var b = (byte)(0xFF - (((0xFF - 0x2E) / c_Blobs) * i));
m_Brushes[i] = new SolidColorBrush(Color.FromRgb(r, g, b));
m_Brushes[i].Freeze();
}
}
示例12: WpfSpinButton
public WpfSpinButton ()
{
Width = 25;
Height = 25;
Background = new SolidColorBrush (Colors.Transparent);
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);
}
}
示例13: CreateAnim
public static DoubleAnimationUsingKeyFrames CreateAnim(this Storyboard sb, DependencyObject target,
string propertyPath, IEasingFunction easing, double value, TimeSpan keyTime)
{
var doubleAnim = (from anim in sb.Children.OfType<DoubleAnimationUsingKeyFrames>()
where GetSBExtTarget(anim) == target
let prop = Storyboard.GetTargetProperty(anim)
where prop.Path == propertyPath
select anim).FirstOrDefault();
if (doubleAnim == null)
{
doubleAnim = new DoubleAnimationUsingKeyFrames();
SetSBExtTarget(doubleAnim, target);
Storyboard.SetTarget(doubleAnim, target);
Storyboard.SetTargetProperty(doubleAnim, new System.Windows.PropertyPath(propertyPath));
sb.Children.Add(doubleAnim);
}
EasingDoubleKeyFrame kf = new EasingDoubleKeyFrame();
kf.EasingFunction = easing;
kf.KeyTime = keyTime;
kf.Value = value;
doubleAnim.KeyFrames.Add(kf);
return doubleAnim;
}
示例14: PlayControlAnimation
public static void PlayControlAnimation(UIElement controlToAnimate, double factor)
{
Storyboard story = new Storyboard();
//stretch horizontally
DoubleAnimationUsingKeyFrames scaleXAnimation = new DoubleAnimationUsingKeyFrames();
scaleXAnimation.BeginTime = TimeSpan.FromMilliseconds(0);
scaleXAnimation.KeyFrames.Add(CreateFrame(factor, 100));
Storyboard.SetTarget(scaleXAnimation, controlToAnimate);
Storyboard.SetTargetProperty(scaleXAnimation, new PropertyPath("(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)"));
story.Children.Add(scaleXAnimation);
//stretch vertically
DoubleAnimationUsingKeyFrames scaleYAnimation = new DoubleAnimationUsingKeyFrames();
scaleYAnimation.BeginTime = TimeSpan.FromMilliseconds(0);
scaleYAnimation.KeyFrames.Add(CreateFrame(factor, 100));
Storyboard.SetTarget(scaleYAnimation, controlToAnimate);
Storyboard.SetTargetProperty(scaleYAnimation, new PropertyPath("(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)"));
story.Children.Add(scaleYAnimation);
if (!(controlToAnimate.RenderTransform is TransformGroup))
{
TransformGroup group = new TransformGroup();
ScaleTransform transform = new ScaleTransform();
transform.ScaleX = 1;
transform.ScaleY = 1;
group.Children.Add(transform);
controlToAnimate.RenderTransformOrigin = new Point(0.5, 0.5);
controlToAnimate.RenderTransform = group;
}
story.Begin();
}
示例15: StartAnimationHour
private void StartAnimationHour(DateTime now)
{
Storyboard stH = new Storyboard();
stH.RepeatBehavior = RepeatBehavior.Forever;
DoubleAnimationUsingKeyFrames daHour = new DoubleAnimationUsingKeyFrames();
daHour.Duration = new Duration(TimeSpan.FromHours(12));
LinearDoubleKeyFrame keyHour = new LinearDoubleKeyFrame();
//keyHour.Value = 360;
daHour.KeyFrames.Add(keyHour);
double hour = now.Hour;
if (hour >= 12)
{
hour = hour - 12;
}
double angleHour = 360 * ((hour + (double)now.Minute / 60 + (double)now.Second / 3600) / 12);
keyHour.Value = angleHour + 360;
RotateTransform rtHour = ((TransformGroup)pathHour.RenderTransform).Children[2] as RotateTransform;
rtHour.Angle = angleHour;
this.RegisterName("RtHour", rtHour);
Storyboard.SetTargetName(daHour, "RtHour");
Storyboard.SetTargetProperty(daHour, new PropertyPath(RotateTransform.AngleProperty));
stH.Children.Add(daHour);
stH.Begin(this);
}