private void OnSnapAnimationCompleted() { currentInteractionStatus = InteractionStatus.None; isSnapAnimationCompleted = true; AssociatedObject.ScrollPosition = SnapAnimationHelper.FinalValue; this.ScrollCompleted.ExecuteCommand(); }
public Task SetStatusForInteractions(IEnumerable <string> interactionIds, InteractionStatus status, string statusDescription) { return(UpdateInteractionStatusesAsync(interactionIds.Select(x => new UpdateInteractionStatus { Id = x, Status = status, StatusDescription = statusDescription }))); }
private void BeginInteraction(Point initialPoint) { CurrentForce = 0.0; currentInteractionStatus = InteractionStatus.Interacting; if (AssociatedObject == null) { return; } InitialTime = DateTime.Now; InitialPosition = initialPoint; PreviousPosition = InitialPosition; InitialOffset = AssociatedObject.ScrollPosition; this.ScrollStarted.ExecuteCommand(); }
/// <summary> /// Установить статус для взаимодействий /// </summary> /// <param name="ids"></param> /// <param name="status"></param> /// <param name="statusDescription"></param> /// <returns></returns> public Task SetStatusForInteractions(IEnumerable <string> ids, InteractionStatus status, string statusDescription) { var now = Application.DateTimeProvider.Now; var list = ids.Select(x => new InteractionStatusLog { Id = Guid.NewGuid().ToString(), Status = status, StartedOn = now, InteractionId = x, StatusDescription = statusDescription }); GetRepository <InteractionStatusLog>().CreateHandled(list); return(SaveChangesAsync()); }
private void FinishInteraction(Point releasePoint) { if (currentInteractionStatus != InteractionStatus.Interacting) { return; } var delta = releasePoint - PreviousPosition; if (delta.Length <= InertiaTriggerArea) { this.ScrollCompleted.ExecuteCommand(); currentInteractionStatus = InteractionStatus.Scrolling; return; } CalculateForce(); currentInteractionStatus = InteractionStatus.Scrolling; }
private void Engage(Point point, EngagementArea engagementArea) { CurrentForce = 0.0; currentInteractionStatus = InteractionStatus.Engaged; if (AssociatedObject == null) { return; } InitialTime = DateTime.Now; InitialPosition = point; PreviousPosition = InitialPosition; InitialOffset = AssociatedObject.ScrollPosition; this.engagementArea = engagementArea; //var preEngagedItem = GetPreEngagementCarouselItem(point, engagementArea); //this.preEngagedItem = preEngagedItem; //var direction = engagementArea == EngagementArea.Left ? 1 : -1; //var finalValue = preEngagedItem.ScrollPosition + PreEngagementScrollPositionDelta * direction; //PreEngagementAnimationHelper.StartAnimation(preEngagedItem.ScrollPosition, finalValue); }
private void CompositionTarget_Rendering(object sender, EventArgs e) { if (AssociatedObject == null || !AssociatedObject.IsVisible) { return; } if (currentInteractionStatus == InteractionStatus.PreEngaged) { PreEngagementAnimationHelper.Update(); } if (currentInteractionStatus != InteractionStatus.Scrolling) { return; } UpdateSnapAnimation(); if (CurrentForce <= 0 && (Convert.ToInt32(AssociatedObject.ScrollPosition % MaximumDegreeReturnSnap) == 0) && isSnapAnimationCompleted) { currentInteractionStatus = InteractionStatus.None; return; } var currentTime = DateTime.Now; var elapsedTime = currentTime - LastUpdate; CurrentVelocity = CurrentForce / BodyMass; var dueDisplacement = CurrentVelocity * (Double)elapsedTime.TotalMilliseconds; if (CurrentForceDirection == ForceDirection.Down) { dueDisplacement *= -1; } var newOffset = AssociatedObject.ScrollPosition + dueDisplacement; if (Double.IsNaN(newOffset)) { return; } AssociatedObject.ScrollPosition = newOffset; CurrentForce = Math.Max(0, CurrentForce - ((Double)elapsedTime.TotalMilliseconds * CurrentForce * Friction)); if (CurrentForce < 0.0001) { CurrentForce = 0; } if (!isSnapAnimationCompleted) { return; } if (CurrentVelocity <= SnapVelocity) { var roundedOffset = Math.Round(newOffset, 0); var goalOffset = GetSnapOffset(roundedOffset); CurrentForce = 0; StartSnapAnimation(AssociatedObject.ScrollPosition, goalOffset); } LastUpdate = DateTime.Now; }
private void OnPreEngagementAnimationCompleted() { preEngagedItem.ScrollPosition = PreEngagementAnimationHelper.FinalValue; currentInteractionStatus = InteractionStatus.Engaged; }