drawing problem w/ clearing

A

asdf

I just started my first project where i draw lines and strings on the
screen. I sucessfully drew what i needed on the screen, then realized that
when it updated it just drew over the same area w/o clearing the first
instance of text and lines. How can i clear it? Below is my code,
basically it is a thermometer and my program is drawing a red line the
height of the temp and drawing the temp on the red bubble.


Dim g As Graphics

Dim b As New Bitmap(pictherm.Image)

Dim y As Integer

Dim tempint As Integer

'120 degrees => y = 20

'-20 degrees -> y = 230

If tempcheck() = True Then

'tempcheck() will check if temp value is a real integer or string = "N/A"

tempint = CInt(currentWeather.currentconditions.tmp)

If settings.units = "s" Then

'degrees F

y = CInt(Math.Round((-1.5) * CInt(currentWeather.currentconditions.tmp) +
200))

End If

If settings.units = "m" Then

'degrees C

y = CInt(Math.Round((-2.69) * CInt(currentWeather.currentconditions.tmp) +
151.92))

End If

Dim f As New Font("Arial", 16, FontStyle.Bold)

g = Graphics.FromImage(b)

Dim textposx As Integer = 30



If tempint >= 100 Then

textposx = 24

End If

If tempint < 0 Then

textposx = 26

End If

If tempint >= 0 And tempint < 100 Then

textposx = 30

End If

g.DrawLine(New Pen(Color.Red, 28), 46, y, 46, 242)

g.DrawString(currentWeather.currentconditions.tmp, f, New
SolidBrush(Color.White), textposx, 250)

pictherm.Image = b

g.Dispose()

End If
 
G

Guest

asdf said:
I just started my first project where i draw lines and strings on the
screen. I sucessfully drew what i needed on the screen, then realized that
when it updated it just drew over the same area w/o clearing the first
instance of text and lines. How can i clear it? Below is my code,
basically it is a thermometer and my program is drawing a red line the
height of the temp and drawing the temp on the red bubble.


Dim g As Graphics

Dim b As New Bitmap(pictherm.Image)

Dim y As Integer

Dim tempint As Integer

'120 degrees => y = 20

'-20 degrees -> y = 230

If tempcheck() = True Then

'tempcheck() will check if temp value is a real integer or string = "N/A"

tempint = CInt(currentWeather.currentconditions.tmp)

If settings.units = "s" Then

'degrees F

y = CInt(Math.Round((-1.5) * CInt(currentWeather.currentconditions.tmp) +
200))

End If

If settings.units = "m" Then

'degrees C

y = CInt(Math.Round((-2.69) * CInt(currentWeather.currentconditions.tmp) +
151.92))

End If

Dim f As New Font("Arial", 16, FontStyle.Bold)

g = Graphics.FromImage(b)

Dim textposx As Integer = 30



If tempint >= 100 Then

textposx = 24

End If

If tempint < 0 Then

textposx = 26

End If

If tempint >= 0 And tempint < 100 Then

textposx = 30

End If

g.DrawLine(New Pen(Color.Red, 28), 46, y, 46, 242)

g.DrawString(currentWeather.currentconditions.tmp, f, New
SolidBrush(Color.White), textposx, 250)

pictherm.Image = b

g.Dispose()

End If

Need to understand when you do this... please show more code
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top