Hi All,
I am drawing on a panel and use my drawing as background image on a form.
All the things I draw are on the panel are OK, but on the form a part is missing.
I guess it takes to long for this part to paint.
How can I make my code to wait until all the painting is done?
The part that is miissing is commented draw arc top.
Here is my code:
Thanks in advance,
Groover
I am drawing on a panel and use my drawing as background image on a form.
All the things I draw are on the panel are OK, but on the form a part is missing.
I guess it takes to long for this part to paint.
How can I make my code to wait until all the painting is done?
The part that is miissing is commented draw arc top.
Here is my code:
VB.NET:
Private Sub Panel2_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Panel2.Paint
e.Graphics.DrawImage(ball1, ulcorner)
If start = False Then
Dim arcbrush As New TextureBrush(New Bitmap(My.Resources.bally))
Dim silverbrush As New TextureBrush(New Bitmap(My.Resources.Crystalsilver))
Dim topbrush As New SolidBrush(Color.DarkOliveGreen)
'draw arc top
Dim arcpen As New Drawing.Pen(arcbrush, 25)
arcpen.Alignment = PenAlignment.Inset
e.Graphics.SmoothingMode = SmoothingMode.HighQuality
topArch.StartFigure()
topArch.AddLine(6, 6, 6, 115)
topArch.AddArc(ArcRect, startAngle, sweepAngle)
topArch.AddLine(603, 115, 603, 6)
topArch.CloseFigure()
reg = New Region(topArch)
e.Graphics.FillRegion(topbrush, reg)
e.Graphics.DrawPath(arcpen, topArch)
'draw rectangle and line
Dim boardPen As New Drawing.Pen(Color.BlueViolet, 10)
Dim boardPen1 As New Drawing.Pen(Color.BlueViolet, 15)
e.Graphics.DrawRectangle(boardPen1, 4, 1, 600, 800)
e.Graphics.DrawLine(boardPen, 540, 200, 540, 800)
''draw left triangle
Dim myPen As New Pen(Color.BlueViolet, 5)
Dim myGraphicsPath As New GraphicsPath
'vertic. line, left triangle
myGraphicsPath.AddLine(14, 700, 14, 794)
e.Graphics.DrawLine(myPen, 14, 700, 14, 794)
'hor.l line,left triangle
myGraphicsPath.AddLine(14, 794, 200, 794)
e.Graphics.DrawLine(myPen, 14, 794, 200, 794)
'diag. line, left triangle
myGraphicsPath.AddLine(14, 700, 200, 794)
e.Graphics.DrawLine(myPen, 14, 700, 200, 794)
'fill right triangle
Dim myRegion As New Region(myGraphicsPath)
Dim myBrush As New TextureBrush(New Bitmap(My.Resources.bally))
e.Graphics.FillRegion(myBrush, myRegion)
'draw right triangle
Dim myPen1 As New Pen(Color.Blue, 5)
myPen1.Alignment = PenAlignment.Center
myPen.LineJoin = LineJoin.Round
Dim myGraphicsPathr As New GraphicsPath
'vertic. line, right triangle
myGraphicsPathr.AddLine(534, 700, 534, 794)
e.Graphics.DrawLine(myPen1, 534, 794, 534, 700)
'hor.l line, right triangle
myGraphicsPathr.AddLine(534, 794, 334, 794)
e.Graphics.DrawLine(myPen1, 334, 794, 534, 794)
'diag. line, right triangle
myGraphicsPathr.AddLine(534, 700, 334, 794)
e.Graphics.DrawLine(myPen1, 534, 700, 334, 794)
'fill right triangle
Dim myRegionr As New Region(myGraphicsPathr)
e.Graphics.FillRegion(myBrush, myRegionr)
'draw rightflipper first time
Dim myPenF As New Pen(Color.OldLace, 5)
Dim mybrushF As New SolidBrush(Color.OrangeRed)
Dim p1 As New Point
p1 = endr
Dim p2 As New Point
p2 = pivotr
Dim p3 As New Point(pivotr.X + 10, pivotr.Y + 20)
Dim p4 As New Point(endr.X, endr.Y + 10)
Dim polygonR As Point() = {p1, p2, p3, p4}
If flipperRightMoveU = False Then 'makes polygonR drawn for fist time
e.Graphics.TranslateTransform(365, 718)
e.Graphics.SmoothingMode = Drawing2D.SmoothingMode.HighQuality
myPenF.LineJoin = LineJoin.Round
e.Graphics.FillPolygon(mybrushF, polygonR)
e.Graphics.DrawPolygon(myPenF, polygonR)
End If
' Use panel as formbackgroundImage
Dim panelBitmap As New Bitmap(Panel2.Width, Panel2.Height)
Panel2.DrawToBitmap(panelBitmap, Panel2.Bounds)
Me.BackgroundImage = panelBitmap
Panel2.Hide()
End If
End Sub
Groover
Last edited: