我正在使用BufferedGraphics绘制一些东西,然后我将它绘制到用户控件上.这是代码:
Private context As BufferedGraphicsContext
Private grafx As BufferedGraphics
Private Sub PaintDoc_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Me.SetStyle(ControlStyles.OptimizedDoubleBuffer, True)
Me.UpdateStyles()
context = BufferedGraphicsManager.Current
context.MaximumBuffer = New Size(Me.Width + 1, Me.Height + 1)
grafx = context.Allocate(Me.CreateGraphics, New Rectangle(0, 0, Me.Width, Me.Height))
grafx.Graphics.InterpolationMode = Drawing2D.InterpolationMode.HighQualityBilinear
grafx.Graphics.PixelOffsetMode = Drawing2D.PixelOffsetMode.HighQuality
grafx.Graphics.SmoothingMode = Drawing2D.SmoothingMode.HighQuality
grafx.Graphics.Clear(Color.Transparent)
End Sub
Private Sub PaintDoc_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove
If e.Button = Windows.Forms.MouseButtons.Left Then
grafx.Graphics.FillEllipse(New SolidBrush(DrawColorFinal), CInt(e.x - (BrushWidth / 2)), …
Run Code Online (Sandbox Code Playgroud)