static void RaiseCaptureEvent(Contact contact, RoutedEvent routedEvent, DependencyObject source, long timestamp) { ContactEventArgs args = new ContactEventArgs(contact, timestamp); args.RoutedEvent = routedEvent; args.Source = source; MultitouchLogic.RaiseEvent(source, args); }
public ElementRoutedEventArgs(FrameworkElement element, Point offset, ContactEventArgs e) { contactEventArgs = e; contact = e.Contact; this.element = element; this.offset = offset; }
public bool Capture(Contact contact, IInputElement element, CaptureMode captureMode) { if(element == null) captureMode = CaptureMode.None; if(captureMode == CaptureMode.None) element = null; DependencyObject oldCaptured = contact.InputArgs.Captured; if(oldCaptured == element) return true; using (dispatcher.DisableProcessing()) { long timestamp = Stopwatch.GetTimestamp(); if (contact.InputArgs.Captured != null) RaiseCaptureEvent(contact, MultitouchScreen.LostContactCaptureEvent, contact.InputArgs.Captured, timestamp); contact.InputArgs.Captured = (DependencyObject)element; contact.InputArgs.CaptureState = captureMode; if (contact.InputArgs.Captured != null) RaiseCaptureEvent(contact, MultitouchScreen.GotContactCaptureEvent, contact.InputArgs.Captured, timestamp); } return true; }
internal NewContactEventArgs(Contact contact, int timestamp) : base(contact, timestamp) { }
internal ContactEventArgs(Contact contact, long timestamp) : base(contact, (int)timestamp) { }
protected virtual void EndStroke(Contact contact) { Stroke stroke = (Stroke)contact.GetUserData(key); if (stroke != null) { InkCanvasStrokeCollectedEventArgs args = new InkCanvasStrokeCollectedEventArgs(stroke); OnStrokeCollected(args); } }
protected virtual void AddPointsToStroke(Contact contact) { Stroke stroke = (Stroke)contact.GetUserData(key); if (stroke == null) StartStroke(contact); else { StylusPointCollection stylusPoints = stroke.StylusPoints; if (stylusPoints != null) { Point position = contact.GetPosition(this); stylusPoints.Add(new StylusPoint(position.X, position.Y, 0.5f)); } } }
protected virtual void StartStroke(Contact contact) { StylusPointCollection stylusPoints = new StylusPointCollection(); Point position = contact.GetPosition(this); stylusPoints.Add(new StylusPoint(position.X, position.Y, 0.5f)); Stroke stroke = new Stroke(stylusPoints, DefaultDrawingAttributes); inkCanvas.Strokes.Add(stroke); contact.SetUserData(key, stroke); }
private void EraseStroke(Contact contact) { Point position = contact.GetPosition(this); foreach (Stroke stroke in inkCanvas.Strokes.HitTest(new[] {position}, EraserShape)) { InkCanvasStrokeErasingEventArgs e = new InkCanvasStrokeErasingEventArgs(stroke); OnStrokeErasing(e); if (!e.Cancel) { inkCanvas.Strokes.Remove(stroke); RoutedEventArgs e2 = new RoutedEventArgs(StrokeErasedEvent, this); RaiseEvent(e2); } } }
private void ErasePoint(Contact contact) { Point position = contact.GetPosition(this); Point[] points = new[] { position }; foreach (Stroke stroke in inkCanvas.Strokes.HitTest(points, EraserShape)) { InkCanvasStrokeErasingEventArgs e = new InkCanvasStrokeErasingEventArgs(stroke); OnStrokeErasing(e); if (!e.Cancel) { StrokeCollection eraseResult = stroke.GetEraseResult(points, EraserShape); inkCanvas.Strokes.Replace(stroke, eraseResult); RoutedEventArgs e2 = new RoutedEventArgs(StrokeErasedEvent, this); RaiseEvent(e2); } } }
private void RemovePartialStroke(Contact contact) { Stroke stroke = (Stroke) contact.GetUserData(key); if(stroke != null) { inkCanvas.Strokes.Remove(stroke); contact.SetUserData(key, null); } }