Exemplo n.º 1
0
        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;
            }
        }
Exemplo n.º 2
0
        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);
            }
        }
Exemplo n.º 3
0
 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);
     }
 }
Exemplo n.º 4
0
 private void SetDiBitmap(DiBitmap bmp, Rectangle dirtyRect, byte opacity = 255)
 {
     SetHBitmap(bmp.HBitmap, Bounds, Point.Empty, dirtyRect, opacity);
 }
Exemplo n.º 5
0
 private void SetDiBitmap(DiBitmap bmp, Rectangle dirtyRect, byte opacity = 255)
 {
     SetHBitmap(bmp.HBitmap, Bounds, Point.Empty, dirtyRect, opacity);
 }
Exemplo n.º 6
0
        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;
            }
        }
Exemplo n.º 7
0
 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);
     }
 }