Hi Ale
Thanks for the advice... I've done most of what you suggested, but I'm a bit stuck on what to do with the rectangles. I will be drawing various sizes and positions of rectangles; so I guess I need a separate rectangle instance of each size/position? I can't change the position or size of a rectangle after it's been instantiated can I? So will I have to create a new rectangle instance every time the draw method is called, and then dispose of it
Any ideas? I've put the beginnings of the class below so you can get an idea of where I'm going
Cheer
Ric
Public Class DirectDra
' --------------- Declare Class Variables ------------------
' Brushe
Private BrushWhite As New SolidBrush(Color.White
Private Brushcyan As New SolidBrush(Color.Cyan
Private Brushskyblue As New SolidBrush(Color.SkyBlue
Private Brushplum As New SolidBrush(Color.Plum
Private Brushlime As New SolidBrush(Color.Lime
Private Brushyellowgreen As New SolidBrush(Color.YellowGreen
Private Brushspringgreen As New SolidBrush(Color.SpringGreen
Private Brushdodgerblue As New SolidBrush(Color.Gold
Private Brushgold As New SolidBrush(Color.Gold
' Rectangle
' ??
' Font
Private f_arial_10 As New Font("arial", 10, FontStyle.Regular
Private f_tahoma_10 As New Font("tahoma", 10, FontStyle.Regular
Private f_arial_11 As New Font("arial", 11, FontStyle.Regular
Private f_tahoma_11 As New Font("tahoma", 11, FontStyle.Regular
Private f_arial_12 As New Font("arial", 12, FontStyle.Regular
Private f_tahoma_12 As New Font("tahoma", 12, FontStyle.Regular
Private f_tahoma_70 As New Font("tahoma", 70, FontStyle.Regular
' Bitmap
Private bmpOff As New Bitmap(640, 480) ' off-screen bitmap : full scree
' Graphics Object
Private gxOff As Graphics = Graphics.FromImage(bmpOff) ' graphics object associated with offscreen drawin
'Private r As New RectangleF(pointx, pointy, sizex, sizey
'Private rr As New RectangleF(0, 0, sizex, sizey
'Private b As New SolidBrush(text_col
' ------------------- Create Properties ---------------------
' -------------------- Create Methods -----------------------
Public Sub draw_text(ByVal text_col As String, ByVal pointx As Integer, ByVal pointy As Integer, ByVal sizex As Integer, ByVal sizey As Integer, ByVal drawtext As String, ByVal e As System.Windows.Forms.PaintEventArgs
' To avoid flicker, double buffer onto bitmap then display
' clear the section of bitma
' to do : need to handle rectangles..
' decide what colour this is and draw text onto bitma
Select Case text_co
Case "white
gxOff.DrawString(drawtext, f_tahoma_10, BrushWhite, pointx, pointy
Case "cyan
gxOff.DrawString(drawtext, f_tahoma_10, Brushcyan, pointx, pointy
Case "dodgerblue
gxOff.DrawString(drawtext, f_tahoma_10, Brushdodgerblue, pointx, pointy
Case "skyblue
gxOff.DrawString(drawtext, f_tahoma_10, Brushskyblue, pointx, pointy
Case "lime
gxOff.DrawString(drawtext, f_tahoma_10, Brushlime, pointx, pointy
Case "yellowgreen
gxOff.DrawString(drawtext, f_tahoma_10, Brushyellowgreen, pointx, pointy
Case "springgreen
gxOff.DrawString(drawtext, f_tahoma_10, Brushspringgreen, pointx, pointy
Case "plum
gxOff.DrawString(drawtext, f_tahoma_10, Brushplum, pointx, pointy
Case "gold
gxOff.DrawString(drawtext, f_tahoma_10, Brushgold, pointx, pointy
End Selec
' Draw bitmap section onto scree
' this bit draws the appropriate section of bmpOff (written to above) to the passed graphics objec
' r needs to be sorted out, as does the last paramete
e.Graphics.DrawImage(bmpOff, r, pointx, pointy, sizex, sizey, GraphicsUnit.Pixel, 0
End Su
End Class