public AnimationElements GetAnimationElements(string uniqueId) { if (this.UnusedAnimationElements.Count == 0) { AnimationElements animationElements = new AnimationElements(); animationElements.Storyboard = new Storyboard(); animationElements.Image = AnimationManager.GetImage(); animationElements.Image.Name = uniqueId; DoubleAnimation doubleAnimation = AnimationManager.GetAnimation(); animationElements.Storyboard.Duration = doubleAnimation.Duration; Storyboard.SetTargetProperty(doubleAnimation, new PropertyPath("(Canvas.Left)")); Storyboard.SetTarget(doubleAnimation, animationElements.Image); animationElements.Storyboard.Children.Add(doubleAnimation); this.AllAnimationElements.Add(animationElements); return animationElements; } else { AnimationElements animationElements = this.UnusedAnimationElements[this.UnusedAnimationElements.Count - 1]; this.UnusedAnimationElements.RemoveAt(this.UnusedAnimationElements.Count - 1); return animationElements; } }
/// <summary> /// When overridden in a derived class, is invoked whenever application code or internal processes (such as a rebuilding layout pass) call <see cref="M:System.Windows.Controls.Control.ApplyTemplate"/>. In simplest terms, this means the method is called just before a UI element displays in an application. For more information, see Remarks. /// </summary> public override void OnApplyTemplate() { base.OnApplyTemplate(); GridRoot = GetTemplateChild("GridRoot") as Grid; if (GridRoot == null) { throw new NotImplementedException("GridRoot is required to display LoadingIndicator."); } for (int i = 0; i < 12; i++) { AnimationElements.Add(GetTemplateChild(string.Format("Element{0}", i)) as FrameworkElement); } CreateAnimation(); }
public override void UpdateHtml() { ChildShapes.ForEach(e => e.UpdateHtml()); AnimationElements.ForEach(a => a.UpdateHtml()); StoredHtml = $"<g{string.Join("", Element.Attributes.Select(a => $" {a.Name}=\"{a.Value}\""))}>\n" + string.Join("", ChildShapes.Select(e => e.StoredHtml + "\n")) + string.Join("", AnimationElements.Select(a => a.StoredHtml + "\n")) + "</g>"; }