Пример #1
0
        /// <summary>
        /// On control paint
        /// </summary>
        protected override void OnPaint(PaintEventArgs e)
        {
            if (!Enabled || BackBuffer == null)
            {
                e.Graphics.FillRectangle(SystemBrushes.ControlDark, ClientRectangle);
                return;
            }

            Rectangle src = new Rectangle(0, 0, BackBuffer.Width, BackBuffer.Height);

            using (Bitmap image = BackBuffer.Clone(src, BackBuffer.PixelFormat))
            {
                Point srcPoint = GetTranslatePoint(Point.Empty);
                Size  size     = UseCanvas && _canvas != Size.Empty ? _canvas : _image != null ? _image.Size : BackBuffer.Size;
                AutoScrollMinSize            = new Size(size.Width * _scale, size.Height * _scale);
                e.Graphics.PixelOffsetMode   = PixelOffsetMode.Half;
                e.Graphics.InterpolationMode = InterpolationMode.NearestNeighbor;
                e.Graphics.ScaleTransform(_scale, _scale);
                e.Graphics.DrawImage(image, ClientRectangle, srcPoint.X, srcPoint.Y, ClientSize.Width, ClientSize.Height, GraphicsUnit.Pixel);
                e.Graphics.ResetTransform();
                OnDrawAfterOnPaint(ref e);
            }
        }