public void ContextShrinkAnimation() { Border contextCircle = stickyWindow.sContextCircle; DoubleAnimation animationsContextGrowX = new DoubleAnimation(10, TimeSpan.FromMilliseconds(250)); animationsContextGrowX.SetValue(Storyboard.TargetNameProperty, contextCircle.Name); animationsContextGrowX.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath(Border.WidthProperty)); DoubleAnimation animationsContextGrowY = new DoubleAnimation(10, TimeSpan.FromMilliseconds(250)); animationsContextGrowY.SetValue(Storyboard.TargetNameProperty, contextCircle.Name); animationsContextGrowY.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath(Border.HeightProperty)); DoubleAnimation animationsContextMoveX = new DoubleAnimation(1.5, TimeSpan.FromMilliseconds(250)); animationsContextMoveX.SetValue(Storyboard.TargetNameProperty, contextCircle.Name); animationsContextMoveX.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath(Canvas.LeftProperty)); DoubleAnimation animationsContextMoveY = new DoubleAnimation(1.5, TimeSpan.FromMilliseconds(250)); animationsContextMoveY.SetValue(Storyboard.TargetNameProperty, contextCircle.Name); animationsContextMoveY.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath(Canvas.TopProperty)); Storyboard storyContextShrink = new Storyboard(); storyContextShrink.Children.Add(animationsContextGrowX); storyContextShrink.Children.Add(animationsContextGrowY); storyContextShrink.Children.Add(animationsContextMoveX); storyContextShrink.Children.Add(animationsContextMoveY); storyContextShrink.Begin(stickyWindow.sContextCircle); }
/// <summary> /// Initializes a please wait window with default text. /// </summary> /// <param name="text">Text to display in the window.</param> public PleaseWaitWindow(string text) { InitializeComponent(); DoubleAnimation dimmAnimation = new DoubleAnimation(DimmedValue, new Duration(new TimeSpan(0, 0, 0, 0, 200))); dimmAnimation.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath("Opacity")); _dimmStoryboard.Children.Add(dimmAnimation); DoubleAnimation undimmAnimation = new DoubleAnimation(UndimmedValue, new Duration(new TimeSpan(0, 0, 0, 0, 200))); undimmAnimation.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath("Opacity")); _undimmStoryboard.Children.Add(undimmAnimation); _dimmStoryboard.Completed += delegate { IsOwnerDimmed = true; UpdateLayout(); }; _undimmStoryboard.Completed += delegate { IsOwnerDimmed = false; Owner.IsHitTestVisible = true; UpdateLayout(); Close(); }; this.SetOwnerWindow(); Loaded += OnLoaded; LayoutUpdated += OnLayoutUpdated; Text = text; }
public static Timeline Create(DependencyObject target, DependencyProperty targetProperty, Duration duration, Thickness from, Thickness to) { DoubleAnimation timeAnimation = new DoubleAnimation() { From = 0, To = 1, Duration = duration }; timeAnimation.EasingFunction = new ExponentialEase() { Exponent = 9, EasingMode = System.Windows.Media.Animation.EasingMode.EaseOut }; timeAnimation.SetValue(TargetProperty, target); timeAnimation.SetValue(TargetPropertyProperty, targetProperty); timeAnimation.SetValue(FromProperty, from); timeAnimation.SetValue(ToProperty, to); Storyboard.SetTargetProperty(timeAnimation, new PropertyPath("(ThicknessAnimation.Time)")); Storyboard.SetTarget(timeAnimation, timeAnimation); return timeAnimation; }
private static DoubleAnimation GetOpac(bool isInanimation, int animationTime) { double from = isInanimation ? 0 : 1; double to = from == 1 ? 0 : 1; var opac = new DoubleAnimation(from, to, new Duration(new TimeSpan(0, 0, 0, 0, animationTime))); opac.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath("Opacity")); return opac; }
private void StartTimer() { DoubleAnimation daValueProperty = new DoubleAnimation(); daValueProperty.From = 200; daValueProperty.To = 0; daValueProperty.Duration = TimeSpan.FromSeconds(200); daValueProperty.SetValue(Storyboard.TargetNameProperty, "progressBarTimeLeft"); daValueProperty.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath("Value")); ColorAnimation caForegroundProperty = new ColorAnimation(); caForegroundProperty.To = Colors.Red; caForegroundProperty.BeginTime = TimeSpan.FromSeconds(170); caForegroundProperty.SetValue(Storyboard.TargetNameProperty, "progressBarTimeLeft"); caForegroundProperty.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath("Foreground.Color")); //gör så att mot slutet börja progressbaren blinka //DoubleAnimation daOpacityProperty = new DoubleAnimation(); //daOpacityProperty.From = 1; //daOpacityProperty.To = 0; //daOpacityProperty.Duration = TimeSpan.FromMilliseconds(900); //daOpacityProperty.AutoReverse = true; //daOpacityProperty.RepeatBehavior = RepeatBehavior.Forever; //daOpacityProperty.BeginTime = TimeSpan.FromSeconds(185); //daOpacityProperty.SetValue(Storyboard.TargetNameProperty, "progressBarTimeLeft"); //daOpacityProperty.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath("Opacity")); App.TimerStoryboard = new Storyboard(); App.TimerStoryboard.Children.Add(daValueProperty); App.TimerStoryboard.Children.Add(caForegroundProperty); //App.TimerStoryboard.Children.Add(daOpacityProperty); App.TimerStoryboard.Duration = TimeSpan.FromSeconds(200); //sb.Completed += new EventHandler(GameOver); App.TimerStoryboard.Begin(gameGrid, true); }
/// <summary> /// Initializes static members of the <see cref="EffectsHelper"/> class. /// </summary> static EffectsHelper() { #if NETFX_CORE var propertyPath = "Opacity"; #else var propertyPath = new PropertyPath("Opacity"); #endif var dimmAnimation = new DoubleAnimation(); dimmAnimation.To = DimmedValue; dimmAnimation.Duration = new Duration(new TimeSpan(0, 0, 0, 0, 200)); dimmAnimation.SetValue(Storyboard.TargetPropertyProperty, propertyPath); _dimmStoryboard.Children.Add(dimmAnimation); var undimmAnimation = new DoubleAnimation(); undimmAnimation.To = UndimmedValue; undimmAnimation.Duration = new Duration(new TimeSpan(0, 0, 0, 0, 200)); undimmAnimation.SetValue(Storyboard.TargetPropertyProperty, propertyPath); _undimmStoryboard.Children.Add(undimmAnimation); }
public DoubleAnimation GetDoubleAnimation() { var doubleAnimation = new DoubleAnimation(); doubleAnimation.SetValue(Storyboard.TargetNameProperty,mohamedAhmed.Name); return doubleAnimation; }
private Storyboard createFadeStoryboard(Rectangle obj) { DoubleAnimation fade = new DoubleAnimation(); fade.To = 0; fade.Duration = new Duration(new TimeSpan(0, 0, 0, 0, 500)); fade.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath("Opacity")); fade.SetValue(Storyboard.TargetProperty, obj); Storyboard sb = new Storyboard(); sb.Children.Add(fade); return sb; }
public static void SetTime(DoubleAnimation animation, double value) { animation.SetValue(TimeProperty, value); }
private Storyboard CreateAnimation(IEnumerable<ExpandableWrapper> controls, bool visible) { Storyboard sb = new Storyboard(); sb.FillBehavior = FillBehavior.HoldEnd; var ease = new PowerEase() { Power = 5 }; var duration = TimeSpan.FromMilliseconds(700); foreach (var c in controls) { DoubleAnimation opacity = new DoubleAnimation(visible ? 1 : 0, duration); opacity.EasingFunction = ease; opacity.SetValue(Storyboard.TargetProperty, c); opacity.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath(ExpandableWrapper.OpacityProperty)); sb.Children.Add(opacity); // replace the current transform with one that's not currently locked by an old animation. ScaleTransform st = new ScaleTransform(c.Scale.ScaleX, c.Scale.ScaleY); if (Orientation == Orientation.Horizontal) st.ScaleY = 1; else st.ScaleX = 1; c.Scale = st; DoubleAnimation size = new DoubleAnimation(visible ? 1 : 0, duration); size.EasingFunction = ease; size.SetValue(Storyboard.TargetProperty, c); size.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath(Orientation == Orientation.Horizontal ? "LayoutTransform.ScaleX" : "LayoutTransform.ScaleY")); sb.Children.Add(size); c.Child.Focusable = visible && c.ChildFocusableDefault; } return sb; }
private void ApplyResizeEffect(FrameworkElement element, double factor, double width, double height) { TimeSpan speed = TimeSpan.FromMilliseconds(100); DoubleAnimation daWidth = new DoubleAnimation { To = factor*width, Duration = new Duration(speed) }; DoubleAnimation daHeight = new DoubleAnimation { To = factor*height, Duration = new Duration(speed) }; Storyboard sb = new Storyboard(); daHeight.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath("Height")); daWidth.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath("Width")); sb.Children.Add(daWidth); sb.Children.Add(daHeight); Storyboard.SetTarget(daWidth, element); Storyboard.SetTarget(daHeight, element); sb.Begin(); }
private void OnCloseButtonClicked(object sender, RoutedEventArgs e) { if (_popup != null && _border != null) { if (_popup.PopupAnimation == PopupAnimation.Slide) { _border.RenderTransform = new TranslateTransform(0, 0); var closeAnimation = new DoubleAnimation(this.RenderSize.Height * -1, new Duration(new System.TimeSpan(0, 0, 0, 0, 200))); closeAnimation.SetValue(Storyboard.TargetProperty, _border); closeAnimation.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath("RenderTransform.Y")); var storyboard = new Storyboard(); storyboard.Children.Add(closeAnimation); storyboard.Completed += this.OnCloseStoryboardCompleted; storyboard.Begin(); } else { _popup.IsOpen = false; } } }
public static void SetTo(DoubleAnimation animation, Thickness value) { animation.SetValue(ToProperty, value); }
public static void SetFrom(DoubleAnimation animation, Thickness value) { animation.SetValue(FromProperty, value); }
void ShowComment(bool show) { if(show && BorderComment.Height != 0) return; if(!show && BorderComment.Height != 40) return; DoubleAnimation animation = new DoubleAnimation(); animation.From = show ? 0 : 40; animation.To = show ? 40 : 0; animation.Duration = new Duration(TimeSpan.FromMilliseconds(300)); animation.SetValue(Storyboard.TargetProperty, BorderComment); animation.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath(Border.HeightProperty)); Storyboard board = new Storyboard(); board.Children.Add(animation); board.Begin(this); }
void AnimateCloseControl(bool show) { DoubleAnimation animation = new DoubleAnimation(); animation.From = show ? 0 : 1; animation.To = show ? 1 : 0; animation.BeginTime = new TimeSpan(0, 0, show ? 0 : 1); animation.Duration = new Duration(TimeSpan.FromMilliseconds(500)); animation.SetValue(Storyboard.TargetProperty, this.PinCloseControl); animation.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath(Rectangle.OpacityProperty)); Storyboard board = new Storyboard(); board.Children.Add(animation); board.Begin(this); }
private void RotatePerson(ListBox lb) { FrameworkElement el = GetRandomElement(lb); if (el!=null) { el.Tag="Dead"; RotateTransform rt = new RotateTransform { CenterX = childSize.Width/2, CenterY = childSize.Height -14 }; el.RenderTransform = rt; Storyboard sb = new Storyboard(); var da = new DoubleAnimation { To=90, Duration= new Duration(TimeSpan.FromMilliseconds(300)) }; da.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath("Angle")); Storyboard.SetTarget(da, rt); sb.Children.Add(da); sb.Begin(); } }
private void ShowImage(Image img, bool enableFading) { if (enableFading) { DoubleAnimation animation = new DoubleAnimation { From = new double?(img.Opacity), To = 1.0, Duration = TimeSpan.FromSeconds(0.5) }; animation.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath("Opacity", new object[0])); Storyboard storyboard = new Storyboard(); storyboard.Children.Add(animation); Storyboard.SetTarget(animation, img); storyboard.Completed += (s, e) => { base.Dispatcher.BeginInvoke(delegate { base.OnProgress(this.GetProgress()); }); }; storyboard.Begin(); } else { img.Opacity = 1.0; } base.OnProgress(this.GetProgress()); //到处都有你的身影 }
private void Show() { DoubleAnimation animation = new DoubleAnimation(); animation.From = 1; animation.To = 0; animation.Duration = new Duration(TimeSpan.FromSeconds(2)); animation.SetValue(Storyboard.TargetProperty, this); animation.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath(Rectangle.OpacityProperty)); Storyboard board = new Storyboard(); board.Children.Add(animation); board.Begin(this); }
public void ManagedVisualStates () { Rectangle r = new Rectangle { Name = "rect", Width = 0 }; VisualStateGroup group = new VisualStateGroup (); group.SetValue (FrameworkElement.NameProperty, "group"); VisualState vstate = new VisualState (); vstate.SetValue (FrameworkElement.NameProperty, "state"); DoubleAnimation anim = new DoubleAnimation { From = 100, To = 200, Duration = TimeSpan.FromSeconds (1) }; anim.SetValue (Control.NameProperty, "ANIMATION"); Storyboard.SetTargetName (anim, "rect"); Storyboard.SetTargetProperty (anim, new PropertyPath ("Width")); Storyboard sb = new Storyboard (); sb.Children.Add (anim); vstate.Storyboard = sb; group.States.Add (vstate); Enqueue (() => TestPanel.Children.Add (r)); Enqueue (() => VisualStateManager.GetVisualStateGroups ((FrameworkElement)TestPanel.Parent).Add (group)); Enqueue (() => Assert.AreEqual(0, r.Width, "#1")); Enqueue (() => Assert.IsTrue (VisualStateManager.GoToState ((Control) TestPage, "state", false), "#2")); Enqueue (() => Assert.IsGreater (99, r.Width, "#3")); Enqueue (() => TestPanel.Children.Clear ()); Enqueue (() => VisualStateManager.GetVisualStateGroups (TestPage).Clear ()); EnqueueTestComplete(); }
private void ShowImage(Image img) { int num = 0; for (int i = base.Container.Children.Count - 1; i >= 0; i--) { FrameworkElement element = base.Container.Children[num] as FrameworkElement; if (img == element) { num++; } else if (element.Parent != null) { (element.Parent as Panel).Children.Remove(element); } } img.Opacity = 1.0; if ((bool)img.DataContext) { Storyboard storyboard = new Storyboard(); DoubleAnimation animation = new DoubleAnimation { From = new double?(img.Opacity), To = 1.0, Duration = TimeSpan.FromSeconds(0.5) }; animation.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath("Opacity", new object[0])); storyboard.Children.Add(animation); Storyboard.SetTarget(animation, img); storyboard.Begin(); } else { img.Opacity = 1.0; } }
void request_MapDataDownloadCompleted(object sender, DownloadStringCompletedEventArgs e) { KMLFeed feed = currentFeed; currentFeed = null; // let the next one go ... if (e.Error != null) { Console.WriteLine("Error : " + e.Error.Message); return; } Console.Error.WriteLine("Success : "); XDocument xDoc = XDocument.Parse(e.Result); XNamespace ns = xDoc.Root.Attributes("xmlns").First().Value;//http://earth.google.com/kml/2.1"; // seems some are 2.2 if (xDoc.Descendants(ns + "Polygon").Count() > 0) { var elements = from results in xDoc.Descendants(ns + "Placemark") select new PlaceMarkRegion { description = results.Element(ns + "description").Value, // Polygon, outerBoundaryIs, LinearRing, coordinates coords = results.Element(ns + "Polygon").Element(ns + "outerBoundaryIs").Element(ns + "LinearRing").Element(ns + "coordinates").Value }; feed.RefMapLayer = new MapLayer(); feed.IsRegionData = true; foreach (PlaceMarkRegion reg in elements) { MapRegionControl polygon = new MapRegionControl(); polygon.Tag = reg.description; polygon.Locations = new LocationCollection(); foreach (Location loc in reg.coordList) { polygon.Locations.Add(loc); } feed.RefMapLayer.Children.Add(polygon); } } else { var elements = from results in xDoc.Descendants(ns + "Placemark") select new PlaceMark { Id = results.Element(ns + "description").Value, FeedId = feed.ID, IsSystem = feed.IsSystem, Name = results.Element(ns + "name").Value, Coords = results.Element(ns + "Point").Element(ns + "coordinates").Value }; ImageBrush brush = null; if (feed.Icon != null) { brush = new ImageBrush(); brush.ImageSource = new BitmapImage(new Uri(feed.Icon)); } feed.RefMapLayer = new MapLayer(); feed.IsRegionData = false; foreach (PlaceMark elem in elements) { if (brush != null) { Pushpin pin = new Pushpin(); pin.Background = brush; pin.MouseLeftButtonUp += pin_MouseLeftButtonUp; pin.Tag = elem; pin.Name = Guid.NewGuid().ToString(); pin.RenderTransform = new CompositeTransform(); (pin.RenderTransform as CompositeTransform).TranslateY = -300; pin.Loaded += (loadedSender, loadedEventArgs) => { Pushpin currentPin = loadedSender as Pushpin; Guid random = new Guid(currentPin.Name); byte[] bytes = random.ToByteArray(); int seed = BitConverter.ToInt32(bytes, 0); Random fromValueRandom = new Random(seed); Random durationRandom = new Random(seed); var storyboard = new Storyboard(); var translateAnimation = new DoubleAnimation() { From = -fromValueRandom.Next(100, 400), To = 0, Duration = TimeSpan.FromMilliseconds(durationRandom.Next(1000, 5000)), EasingFunction = new CircleEase() { EasingMode = EasingMode.EaseInOut } }; translateAnimation.SetValue(Storyboard.TargetNameProperty, currentPin.Name); translateAnimation.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath("(UIElement.RenderTransform).(CompositeTransform.TranslateY)")); storyboard.Children.Add(translateAnimation); Resources.Add(currentPin.Name, storyboard); storyboard.Begin(); }; feed.RefMapLayer.AddChild(pin, elem.Location, PositionOrigin.BottomCenter); string hint = elem.Id.Replace("<br/>", "\n"); ToolTipService.SetToolTip(pin, hint); } else { Pushpin pin = new Pushpin(); pin.Location = elem.Location; pin.Height = pin.Width = 22; pin.Tag = elem; feed.RefMapLayer.AddChild(pin, elem.Location,PositionOrigin.BottomCenter); } } } // we are seperating region layers from points, so everything stacks nicely if (feed.IsRegionData) { regionsMapLayer.Children.Add(feed.RefMapLayer); } else { pointsMapLayer.Children.Add(feed.RefMapLayer); } }