예제 #1
0
		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);
		}
예제 #2
0
 public ElementRoutedEventArgs(FrameworkElement element, Point offset, ContactEventArgs e)
 {
     contactEventArgs = e;
     contact = e.Contact;
     this.element = element;
     this.offset = offset;
 }
예제 #3
0
		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;
		}
예제 #4
0
		internal NewContactEventArgs(Contact contact, int timestamp)
			: base(contact, timestamp)
		{ }
예제 #5
0
			internal ContactEventArgs(Contact contact, long timestamp)
			: base(contact, (int)timestamp)
		{ }
예제 #6
0
		protected virtual void EndStroke(Contact contact)
		{
			Stroke stroke = (Stroke)contact.GetUserData(key);
			if (stroke != null)
			{
				InkCanvasStrokeCollectedEventArgs args = new InkCanvasStrokeCollectedEventArgs(stroke);
				OnStrokeCollected(args);
			}
		}
예제 #7
0
		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));
				}
			}
		}
예제 #8
0
		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);
		}
예제 #9
0
		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);
				}
			}
		}
예제 #10
0
		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);
				}
			}
		}
예제 #11
0
		private void RemovePartialStroke(Contact contact)
		{
			Stroke stroke = (Stroke) contact.GetUserData(key);
			if(stroke != null)
			{
				inkCanvas.Strokes.Remove(stroke);
				contact.SetUserData(key, null);
			}
		}