/* Slide the main button left or right with the user's mouse movement when * the mouse is held down. Once it crosses the left or right slide limit * thresholds, fire the appropriate slide event, and fire the mouse up event * to reset the main button to a sane location. */ private void BtnEdit_MouseMove(object sender, MouseEventArgs e) { var withinLimitLeft = btnMain.Location.X >= btnLeft.Location.X - btnLeft.Width; var withinLimitRight = btnMain.Location.X <= btnLeft.Location.X + btnLeft.Width; if (Slide && withinLimitLeft && withinLimitRight) { btnMain.Location = new Point(btnMain.Location.X + (e.X - Mouse), btnMain.Location.Y); var beyondLimitLeft = btnMain.Location.X <= btnLeft.Location.X - btnLeft.Width; var beyondLimitRight = btnMain.Location.X >= btnLeft.Location.X + btnLeft.Width; if (beyondLimitLeft) { btnMain.Location = new Point(btnLeft.Location.X - btnLeft.Width, btnMain.Location.Y); SlideLeft?.Invoke(this, null); BtnEdit_MouseUp(this, null); } if (beyondLimitRight) { btnMain.Location = new Point(btnLeft.Location.X + btnLeft.Width, btnMain.Location.Y); SlideRight?.Invoke(this, null); BtnEdit_MouseUp(this, null); } } }
private void PrevButton_OnClick(object sender, RoutedEventArgs e) { if (BlockTransitions) { return; } SlideRight.Begin(); }
protected override void OnManipulationCompleted(ManipulationCompletedEventArgs e) { base.OnManipulationCompleted(e); if (BlockTransitions) { return; } var horizontalVelocity = e.FinalVelocities.LinearVelocity.X; var verticalVelocity = e.FinalVelocities.LinearVelocity.Y; var direction = GetDirection(horizontalVelocity, verticalVelocity); if (direction == Orientation.Horizontal && Math.Abs(horizontalVelocity) > 200) { if (e.TotalManipulation.Translation.X < 0) { if (ShowNextButton) { SlideLeft.Begin(); } else { SlideTopLeft.Begin(); } } else { if (ShowPreviousButton) { SlideRight.Begin(); } else { SlideTopRight.Begin(); } } } }
public virtual void OnSlideRight(GestureEventArgs e) { SlideRight?.Invoke(this, e); }