private Storyboard CollapseAnimation(SwipeListDirection direction, bool raise) { var animDrag = CreateDouble(0, 300, ContentDragTransform, "TranslateTransform.X", new ExponentialEase { EasingMode = EasingMode.EaseOut }); var animRight = CreateDouble((RightContainer.ActualWidth + 20), 300, RightTransform, "TranslateTransform.X", new ExponentialEase { EasingMode = EasingMode.EaseOut }); var currentAnim = new Storyboard(); currentAnim.Children.Add(animDrag); currentAnim.Children.Add(animRight); currentAnim.Completed += (s, args) => { ContentDragTransform.X = 0; RightTransform.X = (RightContainer.ActualWidth + 20); }; if (raise) { ItemSwipe?.Invoke(this, new ItemSwipeEventArgs(Content, direction)); } return(currentAnim); }
private Storyboard ExpandAnimation(SwipeListDirection direction) { var currentAnim = new Storyboard(); if (direction == SwipeListDirection.Left) { var animDrag = CreateDouble(ActualWidth + 100, 300, ContentDragTransform, "TranslateTransform.X", new ExponentialEase { EasingMode = EasingMode.EaseOut }); var animClip = CreateDouble(ActualWidth, 300, DragClipTransform, "TranslateTransform.X", new ExponentialEase { EasingMode = EasingMode.EaseOut }); var animLeft = CreateDouble(ActualWidth + 100, 300, LeftTransform, "TranslateTransform.X", new ExponentialEase { EasingMode = EasingMode.EaseIn }); var animRight = CreateDouble(ActualWidth + 100, 300, RightTransform, "TranslateTransform.X", new ExponentialEase { EasingMode = EasingMode.EaseIn }); currentAnim.Children.Add(animDrag); currentAnim.Children.Add(animClip); currentAnim.Children.Add(animLeft); currentAnim.Children.Add(animRight); } else if (direction == SwipeListDirection.Right) { var animDrag = CreateDouble(-ActualWidth - 100, 300, ContentDragTransform, "TranslateTransform.X", new ExponentialEase { EasingMode = EasingMode.EaseOut }); var animClip = CreateDouble(-ActualWidth, 300, DragClipTransform, "TranslateTransform.X", new ExponentialEase { EasingMode = EasingMode.EaseOut }); var animLeft = CreateDouble(-ActualWidth - 100, 300, LeftTransform, "TranslateTransform.X", new ExponentialEase { EasingMode = EasingMode.EaseIn }); var animRight = CreateDouble(-ActualWidth - 100, 300, RightTransform, "TranslateTransform.X", new ExponentialEase { EasingMode = EasingMode.EaseIn }); currentAnim.Children.Add(animDrag); currentAnim.Children.Add(animClip); currentAnim.Children.Add(animLeft); currentAnim.Children.Add(animRight); } currentAnim.Completed += (s, args) => { if (ItemSwipe != null) { ItemSwipe(this, new ItemSwipeEventArgs(Content, direction)); } if (_parent != null) { _parent.RaiseItemSwipe(new ItemSwipeEventArgs(Content, direction)); } }; return(currentAnim); }
protected override void OnManipulationCompleted(ManipulationCompletedRoutedEventArgs e) { var target = (ActualWidth / 5) * 2; Storyboard currentAnim; if (_direction == SwipeListDirection.Right && ContentDragTransform.X <= -target) { if (RightBehavior == SwipeListBehavior.Collapse) { currentAnim = CollapseAnimation(SwipeListDirection.Right, true); } else { currentAnim = ExpandAnimation(SwipeListDirection.Right); } } else { currentAnim = CollapseAnimation(SwipeListDirection.Right, false); } currentAnim.Begin(); _direction = SwipeListDirection.None; base.OnManipulationCompleted(e); }
private Storyboard ExpandAnimation(SwipeListDirection direction) { var currentAnim = new Storyboard(); var transform = HorizontalMode ? "TranslateTransform.X" : "TranslateTransform.Y"; var dimension = HorizontalMode ? ActualWidth : ActualHeight; if (direction == SwipeListDirection.Left || direction == SwipeListDirection.Top) { var animDrag = CreateDouble(dimension + 100, 300, ContentDragTransform, transform, new ExponentialEase { EasingMode = EasingMode.EaseOut }); var animClip = CreateDouble(dimension, 300, DragClipTransform1, transform, new ExponentialEase { EasingMode = EasingMode.EaseOut }); var animLeftOrTop = CreateDouble(dimension + 100, 300, LeftOrTopTransform, transform, new ExponentialEase { EasingMode = EasingMode.EaseIn }); var animRightOrButtom = CreateDouble(dimension + 100, 300, RightOrButtomTransform, transform, new ExponentialEase { EasingMode = EasingMode.EaseIn }); currentAnim.Children.Add(animDrag); currentAnim.Children.Add(animClip); currentAnim.Children.Add(animLeftOrTop); currentAnim.Children.Add(animRightOrButtom); } else if (direction == SwipeListDirection.Right || direction == SwipeListDirection.Buttom) { var animDrag = CreateDouble(-dimension - 100, 300, ContentDragTransform, transform, new ExponentialEase { EasingMode = EasingMode.EaseOut }); var animClip = CreateDouble(-dimension, 300, DragClipTransform1, transform, new ExponentialEase { EasingMode = EasingMode.EaseOut }); var animLeftOrTop = CreateDouble(-dimension - 100, 300, LeftOrTopTransform, transform, new ExponentialEase { EasingMode = EasingMode.EaseIn }); var animRightOrButtom = CreateDouble(-dimension - 100, 300, RightOrButtomTransform, transform, new ExponentialEase { EasingMode = EasingMode.EaseIn }); currentAnim.Children.Add(animDrag); currentAnim.Children.Add(animClip); currentAnim.Children.Add(animLeftOrTop); currentAnim.Children.Add(animRightOrButtom); } currentAnim.Completed += (s, args) => { if (ItemSwipe != null) { ItemSwipe(this, new ItemSwipeEventArgs(Content, direction)); } }; return(currentAnim); }
private Storyboard CollapseAnimation(SwipeListDirection direction, bool raise) { var transform = HorizontalMode ? "TranslateTransform.X" : "TranslateTransform.Y"; var animDrag = CreateDouble(0, 300, ContentDragTransform, transform, new ExponentialEase { EasingMode = EasingMode.EaseOut }); var animClip = CreateDouble(0, 300, DragClipTransform1, transform, new ExponentialEase { EasingMode = EasingMode.EaseOut }); var animLeftOrTop = CreateDouble(-(HorizontalMode?LeftOrTopContainer.ActualWidth: LeftOrTopContainer.ActualHeight + 20), 300, LeftOrTopTransform, transform, new ExponentialEase { EasingMode = EasingMode.EaseOut }); var animRightOrButtom = CreateDouble((HorizontalMode ? RightOrButtomContainer.ActualWidth: RightOrButtomContainer.ActualHeight + 20), 300, RightOrButtomTransform, transform, new ExponentialEase { EasingMode = EasingMode.EaseOut }); var currentAnim = new Storyboard(); currentAnim.Children.Add(animDrag); currentAnim.Children.Add(animClip); currentAnim.Children.Add(animLeftOrTop); currentAnim.Children.Add(animRightOrButtom); currentAnim.Completed += (s, args) => { DragBackground.Background = null; if (HorizontalMode) { ContentDragTransform.X = 0; LeftOrTopTransform.X = -(LeftOrTopContainer.ActualWidth + 20); RightOrButtomTransform.X = (RightOrButtomContainer.ActualWidth + 20); } else { ContentDragTransform.Y = 0; LeftOrTopTransform.Y = -(LeftOrTopContainer.ActualHeight + 20); RightOrButtomTransform.Y = (RightOrButtomContainer.ActualHeight + 20); } Grid.SetColumn(DragBackground, 1); Grid.SetColumnSpan(DragBackground, 1); }; if (raise) { if (ItemSwipe != null) { ItemSwipe(this, new ItemSwipeEventArgs(Content, direction)); } } return(currentAnim); }
private Storyboard CollapseAnimation(SwipeListDirection direction, bool raise) { var animDrag = CreateDouble(0, 300, ContentDragTransform, "TranslateTransform.X", new ExponentialEase { EasingMode = EasingMode.EaseOut }); var animClip = CreateDouble(0, 300, DragClipTransform, "TranslateTransform.X", new ExponentialEase { EasingMode = EasingMode.EaseOut }); var animLeft = CreateDouble(-(LeftContainer.ActualWidth + 20), 300, LeftTransform, "TranslateTransform.X", new ExponentialEase { EasingMode = EasingMode.EaseOut }); var animRight = CreateDouble((RightContainer.ActualWidth + 20), 300, RightTransform, "TranslateTransform.X", new ExponentialEase { EasingMode = EasingMode.EaseOut }); var currentAnim = new Storyboard(); currentAnim.Children.Add(animDrag); currentAnim.Children.Add(animClip); currentAnim.Children.Add(animLeft); currentAnim.Children.Add(animRight); currentAnim.Completed += (s, args) => { DragBackground.Background = null; ContentDragTransform.X = 0; LeftTransform.X = -(LeftContainer.ActualWidth + 20); RightTransform.X = (RightContainer.ActualWidth + 20); Grid.SetColumn(DragBackground, 1); Grid.SetColumnSpan(DragBackground, 1); }; if (raise) { if (ItemSwipe != null) { ItemSwipe(this, new ItemSwipeEventArgs(Content, direction)); } if (_parent != null) { _parent.RaiseItemSwipe(new ItemSwipeEventArgs(Content, direction)); } } return(currentAnim); }
protected override void OnManipulationCompleted(ManipulationCompletedRoutedEventArgs e) #endif { var target = (ActualWidth / 5) * 2; if ((_direction == SwipeListDirection.Left && LeftBehavior == SwipeListBehavior.Expand) || (_direction == SwipeListDirection.Right && RightBehavior == SwipeListBehavior.Expand)) { target = (ActualWidth / 5) * 3; } Storyboard currentAnim; if (_direction == SwipeListDirection.Left && ContentDragTransform.X >= target) { if (LeftBehavior == SwipeListBehavior.Collapse) { currentAnim = CollapseAnimation(SwipeListDirection.Left, true); } else { currentAnim = ExpandAnimation(SwipeListDirection.Left); } } else if (_direction == SwipeListDirection.Right && ContentDragTransform.X <= -target) { if (RightBehavior == SwipeListBehavior.Collapse) { currentAnim = CollapseAnimation(SwipeListDirection.Right, true); } else { currentAnim = ExpandAnimation(SwipeListDirection.Right); } } else { currentAnim = CollapseAnimation(SwipeListDirection.Left, false); } currentAnim.Begin(); _direction = SwipeListDirection.None; //e.Handled = true; //base.OnManipulationCompleted(e); }
private Storyboard ExpandAnimation(SwipeListDirection direction) { var currentAnim = new Storyboard(); if (direction == SwipeListDirection.Right) { var animDrag = CreateDouble(-ActualWidth - 100, 300, ContentDragTransform, "TranslateTransform.X", new ExponentialEase { EasingMode = EasingMode.EaseOut }); var animRight = CreateDouble(-ActualWidth - 100, 300, RightTransform, "TranslateTransform.X", new ExponentialEase { EasingMode = EasingMode.EaseIn }); currentAnim.Children.Add(animDrag); currentAnim.Children.Add(animRight); } currentAnim.Completed += (s, args) => { ItemSwipe?.Invoke(this, new ItemSwipeEventArgs(Content, direction)); }; return(currentAnim); }
protected override void OnManipulationDelta(ManipulationDeltaRoutedEventArgs e) #endif { #if SILVERLIGHT var delta = e.DeltaManipulation.Translation; var cumulative = e.CumulativeManipulation.Translation; #else if (e.PointerDeviceType != Windows.Devices.Input.PointerDeviceType.Touch || _parent?.SelectionMode == ListViewSelectionMode.Multiple || _parent?.SelectionMode == ListViewSelectionMode.Extended) { e.Complete(); return; } var delta = e.Delta.Translation; var cumulative = e.Cumulative.Translation; #endif var target = ((ActualWidth / 5) * 1); if (_direction == SwipeListDirection.None) { _direction = delta.X > 0 ? SwipeListDirection.Left : SwipeListDirection.Right; DragBackground.Background = _direction == SwipeListDirection.Left ? LeftBackground : RightBackground; LeftTransform.X = -(LeftContainer.ActualWidth + 20); RightTransform.X = (RightContainer.ActualWidth + 20); DragClip.Rect = new Rect(_direction == SwipeListDirection.Left ? -ActualWidth : ActualWidth, 0, ActualWidth, ActualHeight); if (_direction == SwipeListDirection.Left && LeftBehavior != SwipeListBehavior.Disabled) { DragBackground.Background = LeftBackground; LeftContainer.Visibility = Visibility.Visible; RightContainer.Visibility = Visibility.Collapsed; } else if (_direction == SwipeListDirection.Right && RightBehavior != SwipeListBehavior.Disabled) { DragBackground.Background = RightBackground; LeftContainer.Visibility = Visibility.Collapsed; RightContainer.Visibility = Visibility.Visible; } else { e.Complete(); return; } } if (_direction == SwipeListDirection.Left) { var area1 = LeftBehavior == SwipeListBehavior.Collapse ? 1.5 : 2.5; var area2 = LeftBehavior == SwipeListBehavior.Collapse ? 2 : 3; ContentDragTransform.X = Math.Max(0, Math.Min(cumulative.X, ActualWidth)); DragClipTransform.X = Math.Max(0, Math.Min(cumulative.X, ActualWidth)); if (ContentDragTransform.X < target * area1) { LeftTransform.X += (delta.X / 1.5); } else if (ContentDragTransform.X >= target * area1 && ContentDragTransform.X < target * area2) { LeftTransform.X += (delta.X * 2.5); } else { LeftTransform.X = Math.Max(0, Math.Min(cumulative.X, ActualWidth)) - LeftContainer.ActualWidth; } if (ContentDragTransform.X == 0 && delta.X < 0) { _direction = SwipeListDirection.None; } } else if (_direction == SwipeListDirection.Right) { var area1 = RightBehavior == SwipeListBehavior.Collapse ? 1.5 : 2.5; var area2 = RightBehavior == SwipeListBehavior.Collapse ? 2 : 3; ContentDragTransform.X = Math.Max(-ActualWidth, Math.Min(cumulative.X, 0)); DragClipTransform.X = Math.Max(-ActualWidth, Math.Min(cumulative.X, 0)); if (ContentDragTransform.X > -(target * area1)) { RightTransform.X += (delta.X / 1.5); } else if (ContentDragTransform.X <= -(target * area1) && ContentDragTransform.X > -(target * area2)) { RightTransform.X += (delta.X * 2.5); } else { RightTransform.X = Math.Max(-ActualWidth, Math.Min(cumulative.X, 0)) + RightContainer.ActualWidth; } if (ContentDragTransform.X == 0 && delta.X > 0) { _direction = SwipeListDirection.None; } } //e.Handled = true; //base.OnManipulationDelta(e); }
protected override void OnManipulationCompleted(ManipulationCompletedRoutedEventArgs e) { double target; if (HorizontalMode) { target = (ActualWidth / 5) * 2; } else { target = (ActualHeight / 5) * 2; } if (((_direction == SwipeListDirection.Left || _direction == SwipeListDirection.Top) && LeftOrTopBehavior == SwipeListBehavior.Expand) || ((_direction == SwipeListDirection.Right || _direction == SwipeListDirection.Buttom) && RightOrButtomBehavior == SwipeListBehavior.Expand)) { if (HorizontalMode) { target = (ActualWidth / 5) * 3; } else { target = (ActualHeight / 5) * 2; } } Storyboard currentAnim; if (HorizontalMode) { if (_direction == SwipeListDirection.Left && ContentDragTransform.X >= target) { if (LeftOrTopBehavior == SwipeListBehavior.Collapse) { currentAnim = CollapseAnimation(SwipeListDirection.Left, true); } else { currentAnim = ExpandAnimation(SwipeListDirection.Left); } } else if (_direction == SwipeListDirection.Right && ContentDragTransform.X <= -target) { if (RightOrButtomBehavior == SwipeListBehavior.Collapse) { currentAnim = CollapseAnimation(SwipeListDirection.Right, true); } else { currentAnim = ExpandAnimation(SwipeListDirection.Right); } } else { currentAnim = CollapseAnimation(SwipeListDirection.Left, false); } } else { if (_direction == SwipeListDirection.Top && ContentDragTransform.Y >= target) { if (LeftOrTopBehavior == SwipeListBehavior.Collapse) { currentAnim = CollapseAnimation(SwipeListDirection.Top, true); } else { currentAnim = ExpandAnimation(SwipeListDirection.Top); } } else if (_direction == SwipeListDirection.Buttom && ContentDragTransform.Y <= -target) { if (RightOrButtomBehavior == SwipeListBehavior.Collapse) { currentAnim = CollapseAnimation(SwipeListDirection.Buttom, true); } else { currentAnim = ExpandAnimation(SwipeListDirection.Buttom); } } else { currentAnim = CollapseAnimation(SwipeListDirection.Top, false); } } currentAnim.Begin(); _direction = SwipeListDirection.None; //e.Handled = true; //base.OnManipulationCompleted(e); }
private Storyboard ExpandAnimation(SwipeListDirection direction) { var currentAnim = new Storyboard(); var transform = HorizontalMode ? "TranslateTransform.X" : "TranslateTransform.Y"; var dimension = HorizontalMode ? ActualWidth : ActualHeight; if (direction == SwipeListDirection.Left || direction == SwipeListDirection.Top) { var animDrag = CreateDouble(dimension + 100, 300, ContentDragTransform, transform, new ExponentialEase { EasingMode = EasingMode.EaseOut }); var animClip = CreateDouble(dimension, 300, DragClipTransform1, transform, new ExponentialEase { EasingMode = EasingMode.EaseOut }); var animLeftOrTop = CreateDouble(dimension + 100, 300, LeftOrTopTransform, transform, new ExponentialEase { EasingMode = EasingMode.EaseIn }); var animRightOrButtom = CreateDouble(dimension + 100, 300, RightOrButtomTransform, transform, new ExponentialEase { EasingMode = EasingMode.EaseIn }); currentAnim.Children.Add(animDrag); currentAnim.Children.Add(animClip); currentAnim.Children.Add(animLeftOrTop); currentAnim.Children.Add(animRightOrButtom); } else if (direction == SwipeListDirection.Right|| direction == SwipeListDirection.Buttom) { var animDrag = CreateDouble(-dimension - 100, 300, ContentDragTransform, transform, new ExponentialEase { EasingMode = EasingMode.EaseOut }); var animClip = CreateDouble(-dimension, 300, DragClipTransform1, transform, new ExponentialEase { EasingMode = EasingMode.EaseOut }); var animLeftOrTop = CreateDouble(-dimension - 100, 300, LeftOrTopTransform, transform, new ExponentialEase { EasingMode = EasingMode.EaseIn }); var animRightOrButtom = CreateDouble(-dimension - 100, 300, RightOrButtomTransform, transform, new ExponentialEase { EasingMode = EasingMode.EaseIn }); currentAnim.Children.Add(animDrag); currentAnim.Children.Add(animClip); currentAnim.Children.Add(animLeftOrTop); currentAnim.Children.Add(animRightOrButtom); } currentAnim.Completed += (s, args) => { if (ItemSwipe != null) ItemSwipe(this, new ItemSwipeEventArgs(Content, direction)); }; return currentAnim; }
protected override void OnManipulationDelta(ManipulationDeltaRoutedEventArgs e) { if (e.PointerDeviceType != Windows.Devices.Input.PointerDeviceType.Touch) { e.Complete(); return; } var delta = e.Delta.Translation; var cumulative = e.Cumulative.Translation; var target = int.MaxValue;/*HorizontalMode ? (ActualWidth / 5) : (ActualHeight / 2) * 1;*/ if (_direction == SwipeListDirection.None) { _direction = HorizontalMode?(delta.X > 0 ? SwipeListDirection.Left : SwipeListDirection.Right): (delta.Y > 0 ? SwipeListDirection.Top : SwipeListDirection.Buttom); DragClip.Rect = HorizontalMode ? new Rect(_direction == SwipeListDirection.Left ? -ActualWidth : ActualWidth, 0, ActualWidth, ActualHeight) : new Rect(0, _direction == SwipeListDirection.Top ? -ActualHeight : ActualHeight, ActualWidth, ActualHeight); if ((_direction == SwipeListDirection.Left || _direction == SwipeListDirection.Top) && LeftOrTopBehavior != SwipeListBehavior.Disabled) { DragBackground.Background = LeftOrTopBackground; LeftOrTopContainer.Visibility = Windows.UI.Xaml.Visibility.Visible; RightOrButtomContainer.Visibility = Windows.UI.Xaml.Visibility.Collapsed; } else if ((_direction == SwipeListDirection.Right || _direction == SwipeListDirection.Buttom) && RightOrButtomBehavior != SwipeListBehavior.Disabled) { DragBackground.Background = RightOrButtomBackground; LeftOrTopContainer.Visibility = Windows.UI.Xaml.Visibility.Collapsed; RightOrButtomContainer.Visibility = Windows.UI.Xaml.Visibility.Visible; } else { e.Complete(); return; } } if (_direction == SwipeListDirection.Left || _direction == SwipeListDirection.Top) { var area1 = LeftOrTopBehavior == SwipeListBehavior.Collapse ? 1.5 : 2.5; var area2 = LeftOrTopBehavior == SwipeListBehavior.Collapse ? 2 : 3; if(HorizontalMode) { ContentDragTransform.X = Math.Max(0, Math.Min(cumulative.X, ActualWidth)); DragClipTransform1.X = Math.Max(0, Math.Min(cumulative.X, ActualWidth)); if (ContentDragTransform.X < target * area1) { LeftOrTopTransform.X += (delta.X / 1.5); } else if (ContentDragTransform.X >= target * area1 && ContentDragTransform.X < target * area2) { LeftOrTopTransform.X += (delta.X * 2.5); } else { LeftOrTopTransform.X = Math.Max(0, Math.Min(cumulative.X, ActualWidth)) - LeftOrTopContainer.ActualWidth; } if (ContentDragTransform.X == 0 && delta.X < 0) { _direction = SwipeListDirection.None; } } else { ContentDragTransform.Y = Math.Max(0, Math.Min(cumulative.Y, ActualHeight)); DragClipTransform1.Y = Math.Max(0, Math.Min(cumulative.Y, ActualHeight)); if (ContentDragTransform.Y < target * area1) { LeftOrTopTransform.Y += (delta.Y / 1.5); } else if (ContentDragTransform.Y >= target * area1 && ContentDragTransform.Y < target * area2) { LeftOrTopTransform.Y += (delta.Y * 2.5); } else { LeftOrTopTransform.Y = Math.Max(0, Math.Min(cumulative.Y, ActualHeight)) - LeftOrTopContainer.ActualHeight; } if (ContentDragTransform.Y == 0 && delta.Y < 0) { _direction = SwipeListDirection.None; } } } else if (_direction == SwipeListDirection.Right || _direction == SwipeListDirection.Buttom) { var area1 = RightOrButtomBehavior == SwipeListBehavior.Collapse ? 1.5 : 2.5; var area2 = RightOrButtomBehavior == SwipeListBehavior.Collapse ? 2 : 3; if (HorizontalMode) { ContentDragTransform.X = Math.Max(-ActualWidth, Math.Min(cumulative.X, 0)); DragClipTransform1.X = Math.Max(-ActualWidth, Math.Min(cumulative.X, 0)); if (ContentDragTransform.X > -(target * area1)) { RightOrButtomTransform.X += (delta.X / 1.5); } else if (ContentDragTransform.X <= -(target * area1) && ContentDragTransform.X > -(target * area2)) { RightOrButtomTransform.X += (delta.X * 2.5); } else { RightOrButtomTransform.X = Math.Max(-ActualWidth, Math.Min(cumulative.X, 0)) + RightOrButtomContainer.ActualWidth; } if (ContentDragTransform.X == 0 && delta.X > 0) { _direction = SwipeListDirection.None; } } else { ContentDragTransform.Y = Math.Max(-ActualHeight, Math.Min(cumulative.Y, 0)); DragClipTransform1.Y = Math.Max(-ActualHeight, Math.Min(cumulative.Y, 0)); if (ContentDragTransform.Y > -(target * area1)) { RightOrButtomTransform.Y += (delta.Y / 1.5); } else if (ContentDragTransform.Y <= -(target * area1) && ContentDragTransform.Y > -(target * area2)) { RightOrButtomTransform.Y += (delta.Y * 2.5); } else { RightOrButtomTransform.Y = Math.Max(-ActualHeight, Math.Min(cumulative.Y, 0)) + RightOrButtomContainer.ActualHeight; } if (ContentDragTransform.Y == 0 && delta.Y > 0) { _direction = SwipeListDirection.None; } } } }
protected override void OnManipulationCompleted(ManipulationCompletedRoutedEventArgs e) #endif { var target = (ActualWidth / 5) * 2; if ((_direction == SwipeListDirection.Left && LeftBehavior == SwipeListBehavior.Expand) || (_direction == SwipeListDirection.Right && RightBehavior == SwipeListBehavior.Expand)) { target = (ActualWidth / 5) * 3; } Storyboard currentAnim; if (_direction == SwipeListDirection.Left && ContentDragTransform.X >= target) { if (LeftBehavior == SwipeListBehavior.Collapse) currentAnim = CollapseAnimation(SwipeListDirection.Left, true); else currentAnim = ExpandAnimation(SwipeListDirection.Left); } else if (_direction == SwipeListDirection.Right && ContentDragTransform.X <= -target) { if (RightBehavior == SwipeListBehavior.Collapse) currentAnim = CollapseAnimation(SwipeListDirection.Right, true); else currentAnim = ExpandAnimation(SwipeListDirection.Right); } else { currentAnim = CollapseAnimation(SwipeListDirection.Left, false); } currentAnim.Begin(); _direction = SwipeListDirection.None; //e.Handled = true; //base.OnManipulationCompleted(e); }
protected override void OnManipulationDelta(ManipulationDeltaRoutedEventArgs e) { #if !DEBUG if (e.PointerDeviceType != Windows.Devices.Input.PointerDeviceType.Touch) { e.Complete(); return; } #endif var cancel = false; //var channel = ViewModel.Parent as TLChannel; //if (channel != null) //{ // if (channel.IsBroadcast) // { // cancel = !(channel.IsCreator || channel.HasAdminRights); // } //} if (cancel) { e.Complete(); return; } var delta = e.Delta.Translation; var cumulative = e.Cumulative.Translation; var target = ((ActualWidth / 5) * 1); if (_direction == SwipeListDirection.None) { _direction = SwipeListDirection.Right; RightTransform.X = (RightContainer.ActualWidth + 20); if (_direction == SwipeListDirection.Right && RightBehavior != SwipeListBehavior.Disabled) { RightContainer.Visibility = Visibility.Visible; } else { //e.Complete(); return; } } /*if (_direction == SwipeListDirection.Left) * { * var area1 = LeftBehavior == SwipeListBehavior.Collapse ? 1.5 : 2.5; * var area2 = LeftBehavior == SwipeListBehavior.Collapse ? 2 : 3; * * ContentDragTransform.X = Math.Max(0, Math.Min(cumulative.X, ActualWidth)); * DragClipTransform.X = Math.Max(0, Math.Min(cumulative.X, ActualWidth)); * * if (ContentDragTransform.X < target * area1) * { * LeftTransform.X += (delta.X / 1.5); * } * else if (ContentDragTransform.X >= target * area1 && ContentDragTransform.X < target * area2) * { * LeftTransform.X += (delta.X * 2.5); * } * else * { * LeftTransform.X = Math.Max(0, Math.Min(cumulative.X, ActualWidth)) - LeftContainer.ActualWidth; * } * * if (ContentDragTransform.X == 0 && delta.X < 0) * { * _direction = SwipeListDirection.None; * } * } * else*/ if (_direction == SwipeListDirection.Right) { var area1 = RightBehavior == SwipeListBehavior.Collapse ? 1.5 : 2.5; var area2 = RightBehavior == SwipeListBehavior.Collapse ? 2 : 3; ContentDragTransform.X = Math.Max(-ActualWidth, Math.Min(cumulative.X, 0)); if (ContentDragTransform.X > -(target * area1)) { RightTransform.X += (delta.X / 1.5); } else if (ContentDragTransform.X <= -(target * area1) && ContentDragTransform.X > -(target * area2)) { RightTransform.X += (delta.X * 2.5); } else { RightTransform.X = Math.Max(-ActualWidth, Math.Min(cumulative.X, 0)) + RightContainer.ActualWidth; } //if (ContentDragTransform.X == 0 && delta.X > 0) //{ // _direction = SwipeListDirection.None; //} } base.OnManipulationDelta(e); }
public ItemSwipeEventArgs(object item, SwipeListDirection direction) { SwipedItem = item; Direction = direction; }
private Storyboard CollapseAnimation(SwipeListDirection direction, bool raise) { var animDrag = CreateDouble(0, 300, ContentDragTransform, "TranslateTransform.X", new ExponentialEase { EasingMode = EasingMode.EaseOut }); var animClip = CreateDouble(0, 300, DragClipTransform, "TranslateTransform.X", new ExponentialEase { EasingMode = EasingMode.EaseOut }); var animLeft = CreateDouble(-(LeftContainer.ActualWidth + 20), 300, LeftTransform, "TranslateTransform.X", new ExponentialEase { EasingMode = EasingMode.EaseOut }); var animRight = CreateDouble((RightContainer.ActualWidth + 20), 300, RightTransform, "TranslateTransform.X", new ExponentialEase { EasingMode = EasingMode.EaseOut }); var currentAnim = new Storyboard(); currentAnim.Children.Add(animDrag); currentAnim.Children.Add(animClip); currentAnim.Children.Add(animLeft); currentAnim.Children.Add(animRight); currentAnim.Completed += (s, args) => { DragBackground.Background = null; ContentDragTransform.X = 0; LeftTransform.X = -(LeftContainer.ActualWidth + 20); RightTransform.X = (RightContainer.ActualWidth + 20); Grid.SetColumn(DragBackground, 1); Grid.SetColumnSpan(DragBackground, 1); }; if (raise) { if (ItemSwipe != null) ItemSwipe(this, new ItemSwipeEventArgs(Content, direction)); if (_parent != null) _parent.RaiseItemSwipe(new ItemSwipeEventArgs(Content, direction)); } return currentAnim; }
protected override void OnManipulationCompleted(ManipulationCompletedRoutedEventArgs e) { double target; if (HorizontalMode) { target = (ActualWidth / 5) * 2; } else { target = (ActualHeight / 5) * 2; } if (((_direction == SwipeListDirection.Left|| _direction == SwipeListDirection.Top) && LeftOrTopBehavior == SwipeListBehavior.Expand) || ((_direction == SwipeListDirection.Right || _direction == SwipeListDirection.Buttom) && RightOrButtomBehavior == SwipeListBehavior.Expand)) { if (HorizontalMode) { target = (ActualWidth / 5) * 3; } else { target = (ActualHeight / 5) *2; } } Storyboard currentAnim; if (HorizontalMode) { if (_direction == SwipeListDirection.Left && ContentDragTransform.X >= target) { if (LeftOrTopBehavior == SwipeListBehavior.Collapse) currentAnim = CollapseAnimation(SwipeListDirection.Left, true); else currentAnim = ExpandAnimation(SwipeListDirection.Left); } else if (_direction == SwipeListDirection.Right && ContentDragTransform.X <= -target) { if (RightOrButtomBehavior == SwipeListBehavior.Collapse) currentAnim = CollapseAnimation(SwipeListDirection.Right, true); else currentAnim = ExpandAnimation(SwipeListDirection.Right); } else { currentAnim = CollapseAnimation(SwipeListDirection.Left, false); } } else { if (_direction == SwipeListDirection.Top && ContentDragTransform.Y >= target) { if (LeftOrTopBehavior == SwipeListBehavior.Collapse) currentAnim = CollapseAnimation(SwipeListDirection.Top, true); else currentAnim = ExpandAnimation(SwipeListDirection.Top); } else if (_direction == SwipeListDirection.Buttom && ContentDragTransform.Y <= -target) { if (RightOrButtomBehavior == SwipeListBehavior.Collapse) currentAnim = CollapseAnimation(SwipeListDirection.Buttom, true); else currentAnim = ExpandAnimation(SwipeListDirection.Buttom); } else { currentAnim = CollapseAnimation(SwipeListDirection.Top, false); } } currentAnim.Begin(); _direction = SwipeListDirection.None; //e.Handled = true; //base.OnManipulationCompleted(e); }
private Storyboard ExpandAnimation(SwipeListDirection direction) { var currentAnim = new Storyboard(); if (direction == SwipeListDirection.Left) { var animDrag = CreateDouble(ActualWidth + 100, 300, ContentDragTransform, "TranslateTransform.X", new ExponentialEase { EasingMode = EasingMode.EaseOut }); var animClip = CreateDouble(ActualWidth, 300, DragClipTransform, "TranslateTransform.X", new ExponentialEase { EasingMode = EasingMode.EaseOut }); var animLeft = CreateDouble(ActualWidth + 100, 300, LeftTransform, "TranslateTransform.X", new ExponentialEase { EasingMode = EasingMode.EaseIn }); var animRight = CreateDouble(ActualWidth + 100, 300, RightTransform, "TranslateTransform.X", new ExponentialEase { EasingMode = EasingMode.EaseIn }); currentAnim.Children.Add(animDrag); currentAnim.Children.Add(animClip); currentAnim.Children.Add(animLeft); currentAnim.Children.Add(animRight); } else if (direction == SwipeListDirection.Right) { var animDrag = CreateDouble(-ActualWidth - 100, 300, ContentDragTransform, "TranslateTransform.X", new ExponentialEase { EasingMode = EasingMode.EaseOut }); var animClip = CreateDouble(-ActualWidth, 300, DragClipTransform, "TranslateTransform.X", new ExponentialEase { EasingMode = EasingMode.EaseOut }); var animLeft = CreateDouble(-ActualWidth - 100, 300, LeftTransform, "TranslateTransform.X", new ExponentialEase { EasingMode = EasingMode.EaseIn }); var animRight = CreateDouble(-ActualWidth - 100, 300, RightTransform, "TranslateTransform.X", new ExponentialEase { EasingMode = EasingMode.EaseIn }); currentAnim.Children.Add(animDrag); currentAnim.Children.Add(animClip); currentAnim.Children.Add(animLeft); currentAnim.Children.Add(animRight); } currentAnim.Completed += (s, args) => { if (ItemSwipe != null) ItemSwipe(this, new ItemSwipeEventArgs(Content, direction)); if (_parent != null) _parent.RaiseItemSwipe(new ItemSwipeEventArgs(Content, direction)); }; return currentAnim; }
private Storyboard CollapseAnimation(SwipeListDirection direction, bool raise) { var transform = HorizontalMode ? "TranslateTransform.X" : "TranslateTransform.Y"; var animDrag = CreateDouble(0, 300, ContentDragTransform, transform, new ExponentialEase { EasingMode = EasingMode.EaseOut }); var animClip = CreateDouble(0, 300, DragClipTransform1, transform, new ExponentialEase { EasingMode = EasingMode.EaseOut }); var animLeftOrTop = CreateDouble(-(HorizontalMode?LeftOrTopContainer.ActualWidth: LeftOrTopContainer.ActualHeight + 20), 300, LeftOrTopTransform, transform, new ExponentialEase { EasingMode = EasingMode.EaseOut }); var animRightOrButtom = CreateDouble((HorizontalMode ? RightOrButtomContainer.ActualWidth: RightOrButtomContainer.ActualHeight + 20), 300, RightOrButtomTransform, transform, new ExponentialEase { EasingMode = EasingMode.EaseOut }); var currentAnim = new Storyboard(); currentAnim.Children.Add(animDrag); currentAnim.Children.Add(animClip); currentAnim.Children.Add(animLeftOrTop); currentAnim.Children.Add(animRightOrButtom); currentAnim.Completed += (s, args) => { DragBackground.Background = null; if (HorizontalMode) { ContentDragTransform.X = 0; LeftOrTopTransform.X = -(LeftOrTopContainer.ActualWidth + 20); RightOrButtomTransform.X = (RightOrButtomContainer.ActualWidth + 20); } else { ContentDragTransform.Y = 0; LeftOrTopTransform.Y = -(LeftOrTopContainer.ActualHeight + 20); RightOrButtomTransform.Y = (RightOrButtomContainer.ActualHeight + 20); } Grid.SetColumn(DragBackground, 1); Grid.SetColumnSpan(DragBackground, 1); }; if (raise) { if (ItemSwipe != null) ItemSwipe(this, new ItemSwipeEventArgs(Content, direction)); } return currentAnim; }
protected override void OnManipulationDelta(ManipulationDeltaRoutedEventArgs e) #endif { #if SILVERLIGHT var delta = e.DeltaManipulation.Translation; var cumulative = e.CumulativeManipulation.Translation; #else if (e.PointerDeviceType != Windows.Devices.Input.PointerDeviceType.Touch || _parent?.SelectionMode == ListViewSelectionMode.Multiple || _parent?.SelectionMode == ListViewSelectionMode.Extended) { e.Complete(); return; } var delta = e.Delta.Translation; var cumulative = e.Cumulative.Translation; #endif var target = ((ActualWidth / 5) * 1); if (_direction == SwipeListDirection.None) { _direction = delta.X > 0 ? SwipeListDirection.Left : SwipeListDirection.Right; DragBackground.Background = _direction == SwipeListDirection.Left ? LeftBackground : RightBackground; LeftTransform.X = -(LeftContainer.ActualWidth + 20); RightTransform.X = (RightContainer.ActualWidth + 20); DragClip.Rect = new Rect(_direction == SwipeListDirection.Left ? -ActualWidth : ActualWidth, 0, ActualWidth, ActualHeight); if (_direction == SwipeListDirection.Left && LeftBehavior != SwipeListBehavior.Disabled) { DragBackground.Background = LeftBackground; LeftContainer.Visibility = Visibility.Visible; RightContainer.Visibility = Visibility.Collapsed; } else if (_direction == SwipeListDirection.Right && RightBehavior != SwipeListBehavior.Disabled) { DragBackground.Background = RightBackground; LeftContainer.Visibility = Visibility.Collapsed; RightContainer.Visibility = Visibility.Visible; } else { e.Complete(); return; } } if (_direction == SwipeListDirection.Left) { var area1 = LeftBehavior == SwipeListBehavior.Collapse ? 1.5 : 2.5; var area2 = LeftBehavior == SwipeListBehavior.Collapse ? 2 : 3; ContentDragTransform.X = Math.Max(0, Math.Min(cumulative.X, ActualWidth)); DragClipTransform.X = Math.Max(0, Math.Min(cumulative.X, ActualWidth)); if (ContentDragTransform.X < target * area1) { LeftTransform.X += (delta.X / 1.5); } else if (ContentDragTransform.X >= target * area1 && ContentDragTransform.X < target * area2) { LeftTransform.X += (delta.X * 2.5); } else { LeftTransform.X = Math.Max(0, Math.Min(cumulative.X, ActualWidth)) - LeftContainer.ActualWidth; } if (ContentDragTransform.X == 0 && delta.X < 0) { _direction = SwipeListDirection.None; } } else if (_direction == SwipeListDirection.Right) { var area1 = RightBehavior == SwipeListBehavior.Collapse ? 1.5 : 2.5; var area2 = RightBehavior == SwipeListBehavior.Collapse ? 2 : 3; ContentDragTransform.X = Math.Max(-ActualWidth, Math.Min(cumulative.X, 0)); DragClipTransform.X = Math.Max(-ActualWidth, Math.Min(cumulative.X, 0)); if (ContentDragTransform.X > -(target * area1)) { RightTransform.X += (delta.X / 1.5); } else if (ContentDragTransform.X <= -(target * area1) && ContentDragTransform.X > -(target * area2)) { RightTransform.X += (delta.X * 2.5); } else { RightTransform.X = Math.Max(-ActualWidth, Math.Min(cumulative.X, 0)) + RightContainer.ActualWidth; } if (ContentDragTransform.X == 0 && delta.X > 0) { _direction = SwipeListDirection.None; } } //e.Handled = true; //base.OnManipulationDelta(e); }
public ItemSwipeEventArgs(object item, SwipeListDirection direction) { SwipedItem = item; Direction = direction; }
protected override void OnManipulationDelta(ManipulationDeltaRoutedEventArgs e) { if (e.PointerDeviceType != Windows.Devices.Input.PointerDeviceType.Touch) { e.Complete(); return; } var delta = e.Delta.Translation; var cumulative = e.Cumulative.Translation; var target = int.MaxValue;/*HorizontalMode ? (ActualWidth / 5) : (ActualHeight / 2) * 1;*/ if (_direction == SwipeListDirection.None) { _direction = HorizontalMode?(delta.X > 0 ? SwipeListDirection.Left : SwipeListDirection.Right): (delta.Y > 0 ? SwipeListDirection.Top : SwipeListDirection.Buttom); DragClip.Rect = HorizontalMode ? new Rect(_direction == SwipeListDirection.Left ? -ActualWidth : ActualWidth, 0, ActualWidth, ActualHeight) : new Rect(0, _direction == SwipeListDirection.Top ? -ActualHeight : ActualHeight, ActualWidth, ActualHeight); if ((_direction == SwipeListDirection.Left || _direction == SwipeListDirection.Top) && LeftOrTopBehavior != SwipeListBehavior.Disabled) { DragBackground.Background = LeftOrTopBackground; LeftOrTopContainer.Visibility = Windows.UI.Xaml.Visibility.Visible; RightOrButtomContainer.Visibility = Windows.UI.Xaml.Visibility.Collapsed; } else if ((_direction == SwipeListDirection.Right || _direction == SwipeListDirection.Buttom) && RightOrButtomBehavior != SwipeListBehavior.Disabled) { DragBackground.Background = RightOrButtomBackground; LeftOrTopContainer.Visibility = Windows.UI.Xaml.Visibility.Collapsed; RightOrButtomContainer.Visibility = Windows.UI.Xaml.Visibility.Visible; } else { e.Complete(); return; } } if (_direction == SwipeListDirection.Left || _direction == SwipeListDirection.Top) { var area1 = LeftOrTopBehavior == SwipeListBehavior.Collapse ? 1.5 : 2.5; var area2 = LeftOrTopBehavior == SwipeListBehavior.Collapse ? 2 : 3; if (HorizontalMode) { ContentDragTransform.X = Math.Max(0, Math.Min(cumulative.X, ActualWidth)); DragClipTransform1.X = Math.Max(0, Math.Min(cumulative.X, ActualWidth)); if (ContentDragTransform.X < target * area1) { LeftOrTopTransform.X += (delta.X / 1.5); } else if (ContentDragTransform.X >= target * area1 && ContentDragTransform.X < target * area2) { LeftOrTopTransform.X += (delta.X * 2.5); } else { LeftOrTopTransform.X = Math.Max(0, Math.Min(cumulative.X, ActualWidth)) - LeftOrTopContainer.ActualWidth; } if (ContentDragTransform.X == 0 && delta.X < 0) { _direction = SwipeListDirection.None; } } else { ContentDragTransform.Y = Math.Max(0, Math.Min(cumulative.Y, ActualHeight)); DragClipTransform1.Y = Math.Max(0, Math.Min(cumulative.Y, ActualHeight)); if (ContentDragTransform.Y < target * area1) { LeftOrTopTransform.Y += (delta.Y / 1.5); } else if (ContentDragTransform.Y >= target * area1 && ContentDragTransform.Y < target * area2) { LeftOrTopTransform.Y += (delta.Y * 2.5); } else { LeftOrTopTransform.Y = Math.Max(0, Math.Min(cumulative.Y, ActualHeight)) - LeftOrTopContainer.ActualHeight; } if (ContentDragTransform.Y == 0 && delta.Y < 0) { _direction = SwipeListDirection.None; } } } else if (_direction == SwipeListDirection.Right || _direction == SwipeListDirection.Buttom) { var area1 = RightOrButtomBehavior == SwipeListBehavior.Collapse ? 1.5 : 2.5; var area2 = RightOrButtomBehavior == SwipeListBehavior.Collapse ? 2 : 3; if (HorizontalMode) { ContentDragTransform.X = Math.Max(-ActualWidth, Math.Min(cumulative.X, 0)); DragClipTransform1.X = Math.Max(-ActualWidth, Math.Min(cumulative.X, 0)); if (ContentDragTransform.X > -(target * area1)) { RightOrButtomTransform.X += (delta.X / 1.5); } else if (ContentDragTransform.X <= -(target * area1) && ContentDragTransform.X > -(target * area2)) { RightOrButtomTransform.X += (delta.X * 2.5); } else { RightOrButtomTransform.X = Math.Max(-ActualWidth, Math.Min(cumulative.X, 0)) + RightOrButtomContainer.ActualWidth; } if (ContentDragTransform.X == 0 && delta.X > 0) { _direction = SwipeListDirection.None; } } else { ContentDragTransform.Y = Math.Max(-ActualHeight, Math.Min(cumulative.Y, 0)); DragClipTransform1.Y = Math.Max(-ActualHeight, Math.Min(cumulative.Y, 0)); if (ContentDragTransform.Y > -(target * area1)) { RightOrButtomTransform.Y += (delta.Y / 1.5); } else if (ContentDragTransform.Y <= -(target * area1) && ContentDragTransform.Y > -(target * area2)) { RightOrButtomTransform.Y += (delta.Y * 2.5); } else { RightOrButtomTransform.Y = Math.Max(-ActualHeight, Math.Min(cumulative.Y, 0)) + RightOrButtomContainer.ActualHeight; } if (ContentDragTransform.Y == 0 && delta.Y > 0) { _direction = SwipeListDirection.None; } } } }