private void TextBlock_TargetUpdated(object sender, DataTransferEventArgs e) { TextBlock block = (TextBlock)e.Source; if (block.Text.Length > 1) { Storyboard newBoard = new Storyboard(); newBoard.FillBehavior = FillBehavior.Stop; newBoard.Duration = TimeSpan.FromSeconds(1); int effectCount = block.TextEffects.Count; int textLength = block.Text.Length; double letterPercent = 1.0 / (textLength + effectCount); for (int i = 0; i < effectCount; ++i) { Int32AnimationUsingKeyFrames positionCount = new Int32AnimationUsingKeyFrames(); positionCount.BeginTime = TimeSpan.Zero; Storyboard.SetTargetProperty(positionCount, new PropertyPath(string.Format("(TextElement.TextEffects)[{0}].(TextEffect.PositionCount)", i))); if (i > 0) { KeyTime startKeyTime = KeyTime.FromPercent((i - 1) * letterPercent); positionCount.KeyFrames.Add(new DiscreteInt32KeyFrame(0, startKeyTime)); } KeyTime moveCountKeyTime = KeyTime.FromPercent(i * letterPercent); positionCount.KeyFrames.Add(new DiscreteInt32KeyFrame(1, moveCountKeyTime)); KeyTime endCountKeyTime = KeyTime.FromPercent((textLength + i) * letterPercent); positionCount.KeyFrames.Add(new DiscreteInt32KeyFrame(0, endCountKeyTime)); newBoard.Children.Add(positionCount); Int32AnimationUsingKeyFrames positionStart = new Int32AnimationUsingKeyFrames(); positionStart.BeginTime = TimeSpan.Zero; Storyboard.SetTargetProperty(positionStart, new PropertyPath(string.Format("(TextElement.TextEffects)[{0}].(TextEffect.PositionStart)", i))); for (int j = 0; j < textLength; ++j) { KeyTime nextStartTime = KeyTime.FromPercent((j + i) * letterPercent); DiscreteInt32KeyFrame nextFrame = new DiscreteInt32KeyFrame(j, nextStartTime); positionStart.KeyFrames.Add(nextFrame); } newBoard.Children.Add(positionStart); } block.BeginStoryboard(newBoard, HandoffBehavior.SnapshotAndReplace, false); } }
public GifAnimationProvider(string path, NConvert meta) : base(path, meta) { _fileHandle = (Bitmap)Image.FromFile(path); Animator = new Int32AnimationUsingKeyFrames { RepeatBehavior = RepeatBehavior.Forever }; Animator.KeyFrames.Add(new DiscreteInt32KeyFrame(0, KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(0)))); Animator.KeyFrames.Add(new DiscreteInt32KeyFrame(1, KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(10)))); Animator.KeyFrames.Add(new DiscreteInt32KeyFrame(2, KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(20)))); }
public GifAnimationProvider(string path, Dispatcher uiDispatcher) : base(path, uiDispatcher) { _frame = (Bitmap)Image.FromFile(path); _frameSource = _frame.ToBitmapSource(); Animator = new Int32AnimationUsingKeyFrames { RepeatBehavior = RepeatBehavior.Forever }; Animator.KeyFrames.Add(new DiscreteInt32KeyFrame(0, KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(0)))); Animator.KeyFrames.Add(new DiscreteInt32KeyFrame(1, KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(50)))); Animator.KeyFrames.Add(new DiscreteInt32KeyFrame(2, KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(100)))); }
public GifAnimationProvider(string path, MetaProvider meta) : base(path, meta) { _fileHandle = (Bitmap)Image.FromFile(path); _fileHandle.SetResolution(DpiHelper.DefaultDpi * DpiHelper.GetCurrentScaleFactor().Horizontal, DpiHelper.DefaultDpi * DpiHelper.GetCurrentScaleFactor().Vertical); Animator = new Int32AnimationUsingKeyFrames { RepeatBehavior = RepeatBehavior.Forever }; Animator.KeyFrames.Add(new DiscreteInt32KeyFrame(0, KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(0)))); Animator.KeyFrames.Add(new DiscreteInt32KeyFrame(1, KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(10)))); Animator.KeyFrames.Add(new DiscreteInt32KeyFrame(2, KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(20)))); }
public ImageMagickProvider(string path, Dispatcher uiDispatcher) : base(path, uiDispatcher) { _path = path; _thumbnail = new Meta(path).GetThumbnail(true); Animator = new Int32AnimationUsingKeyFrames(); Animator.KeyFrames.Add(new DiscreteInt32KeyFrame(0, KeyTime.FromTimeSpan(TimeSpan.Zero))); // thumbnail/full image if (_thumbnail != null) { Animator.KeyFrames.Add(new DiscreteInt32KeyFrame(1, KeyTime.FromTimeSpan(TimeSpan.FromSeconds(0.20)))); // full image } }
private void OnNumberChanged(int oldValue, int newValue) { Int32AnimationUsingKeyFrames animation = new Int32AnimationUsingKeyFrames(); Storyboard.SetTargetName(animation, "Root"); Storyboard.SetTargetProperty(animation, new PropertyPath("AnimatedNumber")); animation.KeyFrames.Add(new LinearInt32KeyFrame { Value = oldValue, KeyTime = new TimeSpan() }); animation.KeyFrames.Add(new LinearInt32KeyFrame { Value = newValue, KeyTime = AnimationDuration }); Storyboard storyboard = new Storyboard(); storyboard.Children.Add(animation); storyboard.Begin(this); }
public GifProvider(Uri path, MetaProvider meta, ContextObject contextObject) : base(path, meta, contextObject) { if (!ImageAnimator.CanAnimate(Image.FromFile(path.LocalPath))) { _nativeProvider = new NativeProvider(path, meta, contextObject); return; } _fileHandle = (Bitmap)Image.FromFile(path.LocalPath); _fileHandle.SetResolution(DisplayDeviceHelper.DefaultDpi * DisplayDeviceHelper.GetCurrentScaleFactor().Horizontal, DisplayDeviceHelper.DefaultDpi * DisplayDeviceHelper.GetCurrentScaleFactor().Vertical); Animator = new Int32AnimationUsingKeyFrames { RepeatBehavior = RepeatBehavior.Forever }; Animator.KeyFrames.Add(new DiscreteInt32KeyFrame(0, KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(0)))); Animator.KeyFrames.Add(new DiscreteInt32KeyFrame(1, KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(10)))); Animator.KeyFrames.Add(new DiscreteInt32KeyFrame(2, KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(20)))); }
private AnimationTimeline BuildGIFAnimation(BitmapFrame[] frames) { Int32AnimationUsingKeyFrames anim = new Int32AnimationUsingKeyFrames(); // check base metadata??? int len = frames.Length - 1; int totalTime = 0; for (int i = 0; i <= len; i++) { anim.KeyFrames.Add( new LinearInt32KeyFrame(i, KeyTime.FromTimeSpan(new TimeSpan(0, 0, 0, 0, totalTime)))); totalTime += this.GetFrameDelay(frames[i]); } // for-loop. // final frame must be held for its own hold time. anim.KeyFrames.Add( new LinearInt32KeyFrame(len, KeyTime.FromTimeSpan(new TimeSpan(0, 0, 0, 0, totalTime)))); return(anim); }
public NativeProvider(Uri path, MetaProvider meta, ContextObject contextObject) : base(path, meta, contextObject) { Animator = new Int32AnimationUsingKeyFrames(); Animator.KeyFrames.Add(new DiscreteInt32KeyFrame(0, KeyTime.FromTimeSpan(TimeSpan.Zero))); }
public NConvertImageProvider(string path, NConvert meta) : base(path, meta) { Animator = new Int32AnimationUsingKeyFrames(); Animator.KeyFrames.Add(new DiscreteInt32KeyFrame(0, KeyTime.FromTimeSpan(TimeSpan.Zero))); }
public ImageMagickProvider(Uri path, MetaProvider meta) : base(path, meta) { Animator = new Int32AnimationUsingKeyFrames(); Animator.KeyFrames.Add(new DiscreteInt32KeyFrame(0, KeyTime.FromTimeSpan(TimeSpan.Zero))); }
protected override void OnClosing(System.ComponentModel.CancelEventArgs e) { if (IsClosing) { e.Cancel = !AllowClose; } else { IsClosing = true; AllowClose = false; e.Cancel = true; if (PopupBoard is Storyboard) { PopupBoard.Stop(this); PopupBoard = null; } HideBoard = new Storyboard(); HideBoard.Completed += new EventHandler((od, ed) => { AllowClose = true; Close(); }); var rect = DockIcon.IconRect; var delay = Config.HideDelay; if ((System.Windows.Forms.Control.ModifierKeys & System.Windows.Forms.Keys.Shift) == System.Windows.Forms.Keys.Shift) { delay = 5000; } for (var i = 0; i < spContent.Children.Count; i++) { var ctrl = spContent.Children[i] as FanIconControl; ctrl.GridContent.Effect = null; var animRotate = new DoubleAnimationUsingKeyFrames(); animRotate.SetValue(Storyboard.TargetNameProperty, ctrl.Name); animRotate.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath("(UIElement.RenderTransform).(TransformGroup.Children)[0].(RotateTransform.Angle)")); animRotate.KeyFrames.Add(new SplineDoubleKeyFrame(0, KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(delay)))); animRotate.DecelerationRatio = 0.8; var animMargin = new ThicknessAnimationUsingKeyFrames(); animMargin.SetValue(Storyboard.TargetNameProperty, ctrl.Name); animMargin.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath("(FrameworkElement.Margin)")); animMargin.KeyFrames.Add(new SplineThicknessKeyFrame( new Thickness(0), KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(delay)))); animMargin.DecelerationRatio = 0.8; var animOpacity = new DoubleAnimationUsingKeyFrames(); animOpacity.SetValue(Storyboard.TargetNameProperty, ctrl.BorderTitle.Tag); animOpacity.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath("(FrameworkElement.Opacity)")); animOpacity.KeyFrames.Add(new SplineDoubleKeyFrame(0, KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(delay)))); animOpacity.DecelerationRatio = 1; var animIconSize = new Int32AnimationUsingKeyFrames(); animIconSize.SetValue(Storyboard.TargetNameProperty, ctrl.Name); animIconSize.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath("(FrameworkElement.IconSize)")); animIconSize.KeyFrames.Add(new SplineInt32KeyFrame(rect.Width, KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(delay)))); animIconSize.DecelerationRatio = 1; HideBoard.Children.Add(animRotate); HideBoard.Children.Add(animMargin); HideBoard.Children.Add(animOpacity); HideBoard.Children.Add(animIconSize); } HideBoard.Begin(this); } base.OnClosing(e); }
private void Window_Activated(object sender, EventArgs e) { if (IsClosing || IsOpened) { return; } IsOpened = true; DockIcon.IconName = App.StartupPath + "Container-Opened.png"; PopupBoard = new Storyboard(); PopupBoard.Completed += new EventHandler(PopupAnimation_Completed); var rect = DockIcon.IconRect; var delay = Config.PopupDelay; if ((System.Windows.Forms.Control.ModifierKeys & System.Windows.Forms.Keys.Shift) == System.Windows.Forms.Keys.Shift) { delay = 5000; } for (var i = 0; i < spContent.Children.Count; i++) { var ctrl = spContent.Children[i] as FanIconControl; var k = (double)(spContent.Children.Count - 1 - i) / MaxItems; var animRotate = new DoubleAnimationUsingKeyFrames(); animRotate.SetValue(Storyboard.TargetNameProperty, ctrl.Name); animRotate.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath("(UIElement.RenderTransform).(TransformGroup.Children)[0].(RotateTransform.Angle)")); animRotate.KeyFrames.Add(new SplineDoubleKeyFrame(k * Angle, KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(delay)))); animRotate.DecelerationRatio = 0.8; var animMargin = new ThicknessAnimationUsingKeyFrames(); animMargin.SetValue(Storyboard.TargetNameProperty, ctrl.Name); animMargin.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath("(FrameworkElement.Margin)")); animMargin.KeyFrames.Add(new SplineThicknessKeyFrame( new Thickness(0, 0, -IconSize / 2 * (1 - Math.Sin((1 - k) * Math.PI / 2)) - (IconSize - rect.Width) / 2, rect.Height + IconSize * (spContent.Children.Count - 1 - i)), KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(delay)))); animMargin.DecelerationRatio = 0.8; var animOpacity = new DoubleAnimationUsingKeyFrames(); animOpacity.SetValue(Storyboard.TargetNameProperty, ctrl.BorderTitle.Tag); animOpacity.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath("(FrameworkElement.Opacity)")); animOpacity.KeyFrames.Add(new SplineDoubleKeyFrame(1, KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(delay)))); animOpacity.DecelerationRatio = 1; var animIconSize = new Int32AnimationUsingKeyFrames(); animIconSize.SetValue(Storyboard.TargetNameProperty, ctrl.Name); animIconSize.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath("(FrameworkElement.IconSize)")); animIconSize.KeyFrames.Add(new SplineInt32KeyFrame(rect.Width, KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(0)))); animIconSize.KeyFrames.Add(new SplineInt32KeyFrame(IconSize, KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(delay)))); animIconSize.DecelerationRatio = 1; PopupBoard.Children.Add(animRotate); PopupBoard.Children.Add(animMargin); PopupBoard.Children.Add(animOpacity); PopupBoard.Children.Add(animIconSize); } PopupBoard.Begin(this); }
protected override void OnInitialized(EventArgs e) { base.OnInitialized(e); this.RenderTransform = new TransformGroup() { Children = { new TranslateTransform() { X = this.Position == ImagePanelPosition.Left ? -300 : (this.Position == ImagePanelPosition.Middle ? 0 : 500), Y = this.Position == ImagePanelPosition.Middle ? 0 : -10 }, new ScaleTransform() { ScaleX = this.Position == ImagePanelPosition.Middle ? 1 : 0.7, ScaleY = this.Position == ImagePanelPosition.Middle ? 1 : 0.7 } } }; this.zIndexAnimation = new Int32AnimationUsingKeyFrames(); Storyboard.SetTarget(this.zIndexAnimation, this); Storyboard.SetTargetProperty(this.zIndexAnimation, new PropertyPath(ImgPanel.ZIndexProperty)); this.translateXAnimation = new DoubleAnimation(); this.translateXAnimation.Duration = new Duration(this.AnimationDuration); Storyboard.SetTarget(this.translateXAnimation, this); Storyboard.SetTargetProperty(this.translateXAnimation, new PropertyPath("RenderTransform.Children[0].X")); this.translateYAnimation = new DoubleAnimation(); this.translateYAnimation.Duration = new Duration(this.AnimationDuration); Storyboard.SetTarget(this.translateYAnimation, this); Storyboard.SetTargetProperty(this.translateYAnimation, new PropertyPath("RenderTransform.Children[0].Y")); this.scaleXAnimation = new DoubleAnimation(); this.scaleXAnimation.Duration = new Duration(this.AnimationDuration); Storyboard.SetTarget(this.scaleXAnimation, this); Storyboard.SetTargetProperty(this.scaleXAnimation, new PropertyPath("RenderTransform.Children[1].ScaleX")); this.scaleYAnimation = new DoubleAnimation(); this.scaleYAnimation.Duration = new Duration(this.AnimationDuration); Storyboard.SetTarget(this.scaleYAnimation, this); Storyboard.SetTargetProperty(this.scaleYAnimation, new PropertyPath("RenderTransform.Children[1].ScaleY")); var shadow = this.FindName(this.Name + "border") as DropShadowEffect; this.borderAnimation = new DoubleAnimation(); this.borderAnimation.Duration = new Duration(this.AnimationDuration); Storyboard.SetTarget(this.borderAnimation, shadow); Storyboard.SetTargetProperty(this.borderAnimation, new PropertyPath(DropShadowEffect.ShadowDepthProperty)); this.animationList = new List <AnimationTimeline>() { this.zIndexAnimation, this.translateXAnimation, this.translateYAnimation, this.scaleXAnimation, this.scaleYAnimation, this.borderAnimation }; }
private void MoveToLeft(double time) { Dispatcher.BeginInvoke(new Action(() => { ////for (int i = 0; i < 10; i++) ////{ //// GamesControl.Add(new Button() { Content = i.ToString()}); ////} var games = GamesControl; var bTemp = false; for (int i = GamesControl.Count - 1; i >= 0; i--) { if (games[i].Visibility == Visibility.Hidden) { continue; } var left = new DoubleAnimationUsingKeyFrames(); var leftkeyFrames = left.KeyFrames; leftkeyFrames.Add(new LinearDoubleKeyFrame(Canvas.GetLeft(games[i]), TimeSpan.FromSeconds(0))); var top = new DoubleAnimationUsingKeyFrames(); var topkeyFrames = top.KeyFrames; topkeyFrames.Add(new LinearDoubleKeyFrame(Canvas.GetTop(games[i]), TimeSpan.FromSeconds(0))); var width = new DoubleAnimationUsingKeyFrames(); var widthkeyFrames = width.KeyFrames; widthkeyFrames.Add(new LinearDoubleKeyFrame(games[i].Width, TimeSpan.FromSeconds(0))); var height = new DoubleAnimationUsingKeyFrames(); var heightkeyFrames = height.KeyFrames; heightkeyFrames.Add(new LinearDoubleKeyFrame(games[i].Height, TimeSpan.FromSeconds(0))); var opacity = new DoubleAnimationUsingKeyFrames(); var opacitykeyFrames = opacity.KeyFrames; opacitykeyFrames.Add(new LinearDoubleKeyFrame(games[i].Opacity, TimeSpan.FromSeconds(0))); var zindex = new Int32AnimationUsingKeyFrames(); var zindexkeyFrames = zindex.KeyFrames; zindexkeyFrames.Add(new LinearInt32KeyFrame(Panel.GetZIndex(games[i]), TimeSpan.FromSeconds(0))); for (var j = ((i - 1) != -1?(i - 1): games.Count - 1); j != i; j = (j - 1) % (games.Count)) { if (games[j].Visibility != Visibility.Hidden) { leftkeyFrames.Add(new LinearDoubleKeyFrame(Canvas.GetLeft(games[j]), TimeSpan.FromSeconds(time))); topkeyFrames.Add(new LinearDoubleKeyFrame(Canvas.GetTop(games[j]), TimeSpan.FromSeconds(time))); widthkeyFrames.Add(new LinearDoubleKeyFrame(games[j].Width, TimeSpan.FromSeconds(time))); heightkeyFrames.Add(new LinearDoubleKeyFrame(games[j].Height, TimeSpan.FromSeconds(time))); opacitykeyFrames.Add(new LinearDoubleKeyFrame(games[j].Opacity, TimeSpan.FromSeconds(time))); zindexkeyFrames.Add(new LinearInt32KeyFrame(Panel.GetZIndex(games[j]), TimeSpan.FromSeconds(0.1))); break; } } //if (games[i].IsSelected && !bTemp) //{ // for (var j = (games.Count + i - 1) % games.Count; j != i; j = (games.Count + j - 1) % games.Count) // { // if (games[j].Visibility != Visibility.Hidden) // { // bTemp = true; // games[i].IsSelected = false; // games[j].IsSelected = true; // SelectGame = BasicData[j]; // break; // } // } //} games[i].BeginAnimation(Canvas.LeftProperty, left); games[i].BeginAnimation(Canvas.TopProperty, top); games[i].BeginAnimation(WidthProperty, width); games[i].BeginAnimation(HeightProperty, height); games[i].BeginAnimation(OpacityProperty, opacity); games[i].BeginAnimation(Panel.ZIndexProperty, zindex); } })); }