/// <summary> /// Handler for when slide manipulation is complete /// </summary> private void ContentGrid_ManipulationCompleted(object sender, ManipulationCompletedRoutedEventArgs e) { if (!MouseSlidingEnabled && e.PointerDeviceType == PointerDeviceType.Mouse) { return; } var x = _transform.TranslateX; _contentAnimation.From = x; _contentStoryboard.Begin(); _leftCommandTransform.TranslateX = 0; _rightCommandTransform.TranslateX = 0; _leftCommandPanel.Opacity = 1; _rightCommandPanel.Opacity = 1; if (x < -ActivationWidth) { RightCommandRequested?.Invoke(this, new EventArgs()); RightCommand?.Execute(null); } else if (x > ActivationWidth) { LeftCommandRequested?.Invoke(this, new EventArgs()); LeftCommand?.Execute(null); } }
/// <summary> /// Handler for when slide manipulation is complete /// </summary> private void ContentGrid_ManipulationCompleted(object sender, ManipulationCompletedRoutedEventArgs e) { if (SwipeStatus == SwipeStatus.Idle) { return; } var x = _transform.TranslateX; _contentAnimation.From = x; _commandContainerClipTranslateAnimation.From = 0; _commandContainerClipTranslateAnimation.To = -x; _contentStoryboard.Begin(); if (SwipeStatus == SwipeStatus.SwipingPassedLeftThreshold) { RightCommandRequested?.Invoke(this, EventArgs.Empty); RightCommand?.Execute(RightCommandParameter); } else if (SwipeStatus == SwipeStatus.SwipingPassedRightThreshold) { LeftCommandRequested?.Invoke(this, EventArgs.Empty); LeftCommand?.Execute(LeftCommandParameter); } Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { SwipeStatus = SwipeStatus.Idle; }).AsTask(); }
/// <summary> /// Handler for when slide manipulation is complete /// </summary> private void ContentGrid_ManipulationCompleted(object sender, ManipulationCompletedRoutedEventArgs e) { if ((!MouseSlidingEnabled && e.PointerDeviceType == PointerDeviceType.Mouse) || (!IsLeftCommandEnabled && !IsRightCommandEnabled)) { return; } var endcapX = _endcapPathTransform.TranslateX; _endcapPathAnimation.From = endcapX; var startcapX = _startcapPathTransform.TranslateX; _startcapAnimation.From = startcapX; var x = _transform.TranslateX; _contentAnimation.From = x; _commandContainerClipTranslateAnimation.From = 0; _commandContainerClipTranslateAnimation.To = -x; if (x > _startcapPath.ActualWidth) { double unitsPerMs = x / FinishAnimationDuration; double distanceTillStartCap = x - _startcapPath.ActualWidth; double millisecondsTillStartCap = distanceTillStartCap / unitsPerMs; _startcapAnimation.BeginTime = TimeSpan.FromMilliseconds(millisecondsTillStartCap); double millisecondsFromStartCapToEnd = _startcapPath.ActualWidth / unitsPerMs; _startcapAnimation.Duration = new Duration(TimeSpan.FromMilliseconds(millisecondsFromStartCapToEnd)); } else { _startcapAnimation.BeginTime = null; _startcapAnimation.Duration = new Duration(TimeSpan.FromMilliseconds(FinishAnimationDuration)); } _contentStoryboard.Begin(); if (SwipeStatus == SwipeStatus.SwipingPassedLeftThreshold) { RightCommandRequested?.Invoke(this, new EventArgs()); RightCommand?.Execute(RightCommandParameter); } else if (SwipeStatus == SwipeStatus.SwipingPassedRightThreshold) { LeftCommandRequested?.Invoke(this, new EventArgs()); LeftCommand?.Execute(LeftCommandParameter); } Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { SwipeStatus = SwipeStatus.Idle; }).AsTask(); }
private void TryExecuteCommand(double x) { if (x < -ActivationOffset) { RightCommandRequested?.Invoke(this, new EventArgs()); RightCommand?.Execute(RightCommandParameter); } else if (x > ActivationOffset) { LeftCommandRequested?.Invoke(this, new EventArgs()); LeftCommand?.Execute(LeftCommandParameter); } }
private void LeftControl_Invoked(SwipeItem sender, SwipeItemInvokedEventArgs args) { LeftCommandRequested?.Invoke(this, EventArgs.Empty); }