private void OnMouseStuff(object sender, MouseEventArgs args) { if (args.RoutedEvent == UIElement.PreviewMouseUpEvent || (args.RoutedEvent == UIElement.PreviewMouseDownEvent && args.Source == null) || (args.RoutedEvent == UIElement.PreviewMouseMoveEvent && args.Source == null && args.LeftButton == MouseButtonState.Released)) { MultitouchWindow.RemoveMouseListener(_attachedElement, OnMouseStuff); } else if (args.RoutedEvent == UIElement.PreviewMouseDownEvent) { MultitouchWindow.AddMouseListener(_attachedElement, OnMouseStuff); _pts[-1] = new FlickData() { DownPoint = args.GetPosition(_attachedElement) }; } else if (args.RoutedEvent == UIElement.PreviewMouseMoveEvent) { if (!_pts.ContainsKey(-1)) { return; } Point current = args.GetPosition(_attachedElement); FlickData data = _pts[-1]; Vector change = Point.Subtract(current, data.DownPoint); double delta = change.Length; if (data.BeginTime == 0 && delta > BeginThreshold) { data.BeginTime = args.Timestamp; } if (data.BeginTime != 0 && delta > EndThreshold && (args.Timestamp - data.BeginTime) < RequiredFlickSpeed.TotalMilliseconds) { MultitouchWindow.RemoveMouseListener(_attachedElement, OnMouseStuff); _pts.Remove(-1); FlickEventArgs fargs = new FlickEventArgs(change / delta); if (Flick != null) { Flick(_attachedElement, fargs); } if (fargs.AlignedDirection.X != 0 && HorizontalFlick != null) { HorizontalFlick(_attachedElement, fargs); } if (fargs.AlignedDirection.Y != 0 && VerticalFlick != null) { VerticalFlick(_attachedElement, fargs); } } } }
private void Flickable_HorizontalFlick(object sender, IdentityMine.Windows.SimpleMultitouch.FlickEventArgs e) { ListBoxItem item = (ListBoxItem)HelperClass.FindVisualAncestor((DependencyObject)sender, (o) => o.GetType() == typeof(ListBoxItem)); if (item != null) { item.IsSelected = !item.IsSelected; } }
private void Flickable_HorizontalFlick(object sender, IdentityMine.Windows.SimpleMultitouch.FlickEventArgs e) { if (e.AlignedDirection.X < 0) { flipper.Rotate(true); } else { flipper.Rotate(false); } }