private void UpdateRoller() { if (RenderSize.Height == 0) { return; } var offset = RenderSize.Height / 2; if (Items.Count > 0) { if (SelectedIndex < 0) { var firstItem = GetItem(0) as UIElement; if (firstItem != null) { offset += firstItem.RenderSize.Height / 2; } } for (var i = 0; i <= SelectedIndex; i++) { var targetItem = GetItem(i) as UIElement; if (targetItem != null) { if (SelectedIndex == i) { offset -= targetItem.RenderSize.Height / 2; } else { offset -= targetItem.RenderSize.Height; } } } if (IsLoaded) { UIElementUtils.BeginAnimation(_stkPanel, StackPanel.MarginProperty, new Thickness(0, offset, 0, 0), AnimationDuration, AnimationEase, false); } else { _stkPanel.Margin = new Thickness(0, offset, 0, 0); } } }
private void UpdateState() { if (!IsInitialized) { return; } switch (ContentPlacement) { case DrawerPlacement.Left: case DrawerPlacement.Right: if (double.IsNaN(MaxWidth)) { throw new Exception("Drawer Exception : value of MaxWidth property can not be Auto."); } if (!IsLoaded || AnimationDuration.TotalMilliseconds == 0) { if (IsOpen) { if (!double.IsInfinity(MaxWidth)) { Width = MaxWidth; } } else { Width = 0; } } else { if (IsOpen) { if (double.IsNaN(Width)) { Width = ActualWidth; } UIElementUtils.BeginAnimation(this, WidthProperty, MaxWidth, AnimationDuration, AnimationEase); } else { if (double.IsNaN(Width)) { Width = ActualWidth; } UIElementUtils.BeginAnimation(this, WidthProperty, 0, AnimationDuration, AnimationEase); } } break; case DrawerPlacement.Top: case DrawerPlacement.Bottom: if (double.IsNaN(MaxWidth)) { throw new Exception("Drawer Exception : value of MaxHeight property can not be Auto."); } if (!IsLoaded || AnimationDuration.TotalMilliseconds == 0) { if (IsOpen) { if (!double.IsInfinity(MaxHeight)) { Height = MaxHeight; } } else { Height = 0; } } else { if (IsOpen) { if (double.IsNaN(Height)) { Height = ActualHeight; } UIElementUtils.BeginAnimation(this, HeightProperty, MaxHeight, AnimationDuration, AnimationEase); } else { if (double.IsNaN(Height)) { Height = ActualHeight; } UIElementUtils.BeginAnimation(this, HeightProperty, 0, AnimationDuration, AnimationEase); } } break; } }
private void Tore(int oldIndex, int newIndex, bool useAnimate) { if (!IsInitialized) { return; } var totalCount = Children.Count; if (oldIndex < 0 || newIndex < 0 || oldIndex > totalCount || newIndex > totalCount) { return; } var isUpward = newIndex > oldIndex; var oldChild = Children[oldIndex]; var newChild = Children[newIndex]; newChild.Opacity = 0; newChild.IsHitTestVisible = true; oldChild.RenderTransformOrigin = new Point(0.5, 0.5); newChild.RenderTransformOrigin = new Point(0.5, 0.5); switch (Animation) { case StickyAnimation.Scale: var oldScale = new ScaleTransform() { ScaleX = 1, ScaleY = 1 }; var newScale = new ScaleTransform() { ScaleX = isUpward ? 1.5 : 0.75, ScaleY = isUpward ? 1.5 : 0.75 }; oldChild.RenderTransform = oldScale; oldChild.IsHitTestVisible = false; newChild.RenderTransform = newScale; UIElementUtils.BeginAnimation(oldScale, ScaleTransform.ScaleXProperty, isUpward ? 0.75 : 1.5, AnimationDuration, AnimationEase); UIElementUtils.BeginAnimation(oldScale, ScaleTransform.ScaleYProperty, isUpward ? 0.75 : 1.5, AnimationDuration, AnimationEase); UIElementUtils.BeginAnimation(oldChild, OpacityProperty, 0, AnimationDuration, AnimationEase); UIElementUtils.BeginAnimation(newScale, ScaleTransform.ScaleXProperty, 1, AnimationDuration, AnimationEase); UIElementUtils.BeginAnimation(newScale, ScaleTransform.ScaleYProperty, 1, AnimationDuration, AnimationEase); UIElementUtils.BeginAnimation(newChild, OpacityProperty, 1, AnimationDuration, AnimationEase); break; case StickyAnimation.Slide: if (isUpward) { var oldTranslate = new TranslateTransform() { X = 0 }; oldChild.RenderTransform = oldTranslate; UIElementUtils.BeginAnimation(oldTranslate, TranslateTransform.XProperty, -ActualWidth, AnimationDuration, AnimationEase); UIElementUtils.BeginAnimation(newChild, OpacityProperty, 1, AnimationDuration, AnimationEase); } else { var newTranslate = new TranslateTransform() { X = -ActualWidth }; newChild.RenderTransform = newTranslate; oldChild.IsHitTestVisible = false; UIElementUtils.BeginAnimation(newTranslate, TranslateTransform.XProperty, 0, AnimationDuration, AnimationEase); UIElementUtils.BeginAnimation(newChild, OpacityProperty, 1, AnimationDuration, AnimationEase); UIElementUtils.BeginAnimation(oldChild, OpacityProperty, 0, AnimationDuration, AnimationEase); } break; } }