void OnOwnerManipulationInertiaStarting(object sender, ManipulationInertiaStartingEventArgs e) { ISimpleManupulationSupport sms = this.owner as ISimpleManupulationSupport; if (sms != null) { e.TranslationBehavior.DesiredDeceleration = sms.DesiredDeseleration; } e.Handled = true; }
void OnOwnerManipulationCompleted(object sender, ManipulationCompletedEventArgs e) { e.Handled = true; ISimpleManupulationSupport sms = this.owner as ISimpleManupulationSupport; if (sms != null) { sms.FinishManipulation(false); } if (e.TotalManipulation.Translation.X == 0.0 && e.TotalManipulation.Translation.Y == 0.0 && e.TotalManipulation.Scale.X == 1.0 && e.TotalManipulation.Scale.Y == 1.0) { RaiseClick(); } }
void OnOwnerMouseMove(object sender, MouseEventArgs e) { if (!this.manipulationInProgress) { return; } mouseMoveHandled = true; Point newPosition = e.GetPosition(this.owner); ISimpleManupulationSupport sms = this.owner as ISimpleManupulationSupport; if (sms != null) { sms.ScrollBy(this.lastPosition.X - newPosition.X, this.lastPosition.Y - newPosition.Y, true); } this.lastPosition = newPosition; }
void OnOwnerMouseLeftButtonUp(object sender, MouseButtonEventArgs e) { if (!this.manipulationInProgress) { return; } e.Handled = true; this.manipulationInProgress = false; this.owner.ReleaseMouseCapture(); ISimpleManupulationSupport sms = this.owner as ISimpleManupulationSupport; if (sms != null) { sms.FinishManipulation(true); } if (!mouseMoveHandled) { doNotProcessMouse = true; RaiseClick(); doNotProcessMouse = false; } }
void OnOwnerManipulationDelta(object sender, ManipulationDeltaEventArgs e) { ISimpleManupulationSupport sms = this.owner as ISimpleManupulationSupport; if (sms != null) { double sx = 1.0 + (e.DeltaManipulation.Scale.X - 1.0) / 1.0; double sy = 1.0 + (e.DeltaManipulation.Scale.Y - 1.0) / 1.0; double prec = 0.0005; bool b1 = Math.Abs(sx - 1.0) <= prec; bool b2 = Math.Abs(sy - 1.0) <= prec; if (!b1 || !b2) { sms.ScaleBy(sx, false); } else { sms.ScrollBy(-e.DeltaManipulation.Translation.X, -e.DeltaManipulation.Translation.Y, false); } } e.Handled = true; }
void OnOwnerMouseWheel(object sender, MouseWheelEventArgs e) { if ((Keyboard.Modifiers & ModifierKeys.Control) == 0) { e.Handled = true; ISimpleManupulationSupport sms = this.owner as ISimpleManupulationSupport; if (sms != null) { RenderScrollViewer rsv = this.owner as RenderScrollViewer; if (rsv == null) { return; } bool vScroll = rsv.ComputedVerticalScrollBarVisibility == Visibility.Visible; bool hScroll = rsv.ComputedHorizontalScrollBarVisibility == Visibility.Visible; double delta = -e.Delta * 1.0; if (vScroll) { sms.ScrollBy(0, delta, true); } else if (hScroll) { sms.ScrollBy(delta, 0, true); } } } else { e.Handled = true; ISimpleManupulationSupport sms = this.owner as ISimpleManupulationSupport; if (sms != null) { sms.ScaleBy((double)e.Delta, true); } } }