示例#1
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));
				}
			}
		}
示例#2
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);
				}
			}
		}
示例#3
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);
		}
示例#4
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);
				}
			}
		}