private static bool updateElement(AnimatingFillPanelData data, double dampening, double attractionFactor, double variation) { Debug.Assert(dampening > 0 && dampening < 1); Debug.Assert(attractionFactor > 0 && !double.IsInfinity(attractionFactor)); if (data == null) return false; attractionFactor *= 1 + (variation * data.Random - .5); Point newLocation; Vector newVelocity; bool anythingChanged = Animate(data.ChildLocation, data.Velocity, data.ChildTarget, attractionFactor, dampening, c_terminalVelocity, c_diff, c_diff, out newLocation, out newVelocity); data.ChildLocation = newLocation; data.Velocity = newVelocity; return anythingChanged; }
protected override Size ArrangeOverride(Size finalSize) { bool animateNewItem = AnimatesNewItem && m_hasArranged; m_hasArranged = true; //Size theChildSize = new Size(this.ItemWidth, this.ItemHeight); for (int i = 0; i < this.Children.Count; i++) { UIElement child = this.Children[i]; // Figure out where the child goes Rect rect = GetFillData(child); Point newOffset = rect.Location(); AnimatingFillPanelData data = (AnimatingFillPanelData)child.GetValue(DataProperty); if (data == null) { data = new AnimatingFillPanelData(); child.SetValue(DataProperty, data); } //set the location attached DP data.ChildTarget = newOffset; if (data.IsNew) // first time I've seen this... { data.IsNew = false; if (animateNewItem) { //newOffset.X -= theChildSize.Width; newOffset.Y = finalSize.Height; newOffset.X = finalSize.Width / 2; } data.ChildLocation = newOffset; child.Arrange(new Rect(newOffset.X, newOffset.Y, child.DesiredSize.Width, child.DesiredSize.Height)); } else { Point currentOffset = data.ChildLocation; // Position the child and set its size child.Arrange(new Rect(currentOffset.X, currentOffset.Y, child.DesiredSize.Width, child.DesiredSize.Height)); } } return finalSize; }