예제 #1
0
        private void WaitToImagePaint(object sender, PaintUpdatedEventArgs e)
        {
            e.Cancel = true;

            if (_miniblink.ViewWidth != _contentWidth || _miniblink.ViewHeight != _imageHeight)
            {
                return;
            }

            var height = _imageHeight;
            var scrTop = _imageHeight;
            var srcY   = 0;
            var isLast = false;

            if ((_images.Count + 1) * _imageHeight >= _contentHeight)
            {
                height = _contentHeight - _images.Count * _imageHeight;
                scrTop = height;
                srcY   = _imageHeight - height;
                isLast = true;
            }

            var bmp = new Bitmap(_contentWidth, height);

            using (var g = Graphics.FromImage(bmp))
            {
                WinApi.BitBlt(g.GetHdc(), 0, 0, bmp.Width, bmp.Height,
                              MBApi.wkeGetViewDC(_miniblink.MiniblinkHandle), 0, srcY,
                              (int)WinConst.SRCCOPY);
            }
            _images[_miniblink.ScrollTop] = bmp;

            if (isLast)
            {
                _miniblink.PaintUpdated -= WaitToImagePaint;
                _miniblink.ScrollTop     = _scrollTopBak;
                _miniblink.RunJs($"document.getElementsByTagName('body')[0].style.overflow='{_cssBak}'");
                _miniblink.PaintUpdated += DisablePaintUpdated;
                MBApi.wkeResize(_miniblink.MiniblinkHandle, (int)_miniblink.ActualWidth, (int)_miniblink.ActualHeight);

                var ss = new ScreenshotImage(_contentWidth, _contentHeight, _images.Values);
                _images.Clear();
                _callback?.Invoke(ss);
                _callback = null;
            }
            else
            {
                _miniblink.ScrollTop += scrTop;
            }
        }
예제 #2
0
 private void DisablePaintUpdated(object sender, PaintUpdatedEventArgs e)
 {
     _miniblink.PaintUpdated -= DisablePaintUpdated;
     e.Cancel = true;
 }