コード例 #1
0
ファイル: InkCanvas.cs プロジェクト: zhuangfangwang/ise
		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
ファイル: InkCanvas.cs プロジェクト: zhuangfangwang/ise
		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
ファイル: InkCanvas.cs プロジェクト: zhuangfangwang/ise
		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
ファイル: InkCanvas.cs プロジェクト: zhuangfangwang/ise
		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);
				}
			}
		}