private void ClearSurfaces() { _lastStroke = null; if (_bitmap != null) { using (_bitmap) { var g = _bitmap.BeginDraw(); _graphicsPath.Widen(_dirtyMarkerPen); g.SetClip(_graphicsPath); g.Clear(Color.Transparent); _bitmap.EndDraw(); var pathDirty = Rectangle.Ceiling(_graphicsPath.GetBounds()); pathDirty.Offset(Bounds.Location); pathDirty.Intersect(Bounds); pathDirty.Offset(-Bounds.X, -Bounds.Y); //挪回来变为基于窗口的坐标 SetDiBitmap(_bitmap, pathDirty); _graphicsPath.Reset(); _dirtyGraphicsPath.Reset(); } _bitmap = null; } }
protected void PointCapture_PointCaptured(object sender, PointsCapturedEventArgs e) { var pointCapture = (IPointCapture)sender; if (pointCapture.Mode != CaptureMode.UserDisabled && pointCapture.State == CaptureState.Capturing && AppConfig.VisualFeedbackWidth > 0 && !(e.Points.Count == 1 && e.Points.First().Count == 1)) { if (_bitmap == null || _lastStroke == null) { ClearSurfaces(); _bitmap = new DiBitmap(this.Size); } DrawSegments(e.Points); } }
public void DrawPoints(List <List <Point> > points) { if (_penWidth > 0 && !(points.Count == 1 && points[0].Count == 1)) { if (_bitmap == null || _lastStroke == null) { ClearSurfaces(); try { _bitmap = new DiBitmap(this.Size); } catch (ApplicationException ex) { Logging.LogException(ex); } } DrawSegments(points); } }
private void SetDiBitmap(DiBitmap bmp, Rectangle dirtyRect, byte opacity = 255) { SetHBitmap(bmp.HBitmap, Bounds, Point.Empty, dirtyRect, opacity); }
protected void MouseCapture_PointCaptured(object sender, PointsCapturedEventArgs e) { var touchCapture = (ITouchCapture)sender; if (touchCapture.Mode != CaptureMode.UserDisabled && touchCapture.State == CaptureState.Capturing && AppConfig.VisualFeedbackWidth > 0 && !(e.Points.Count == 1 && e.Points.First().Count == 1)) { if (_bitmap == null || _lastStroke == null) { ClearSurfaces(); _bitmap = new DiBitmap(Screen.PrimaryScreen.Bounds.Size); } DrawSegments(e.Points); } }