Jem
Sun Jan 14 04:18:37 CST 2007
Hi Chris
Thanks for demo program. Unfortunately it doesn't want to run :-(
I'm getting these error messages...
Error 1 Overload resolution failed because no accessible 'DrawLine' can be
called without a narrowing conversion:
'Public Sub DrawLine(pen As System.Drawing.Pen, x1 As Integer, y1 As
Integer, x2 As Integer, y2 As Integer)': Argument matching parameter 'x1'
narrows from 'Double' to 'Integer'.
'Public Sub DrawLine(pen As System.Drawing.Pen, x1 As Integer, y1 As
Integer, x2 As Integer, y2 As Integer)': Argument matching parameter 'x2'
narrows from 'Double' to 'Integer'.
'Public Sub DrawLine(pen As System.Drawing.Pen, x1 As Single, y1 As
Single, x2 As Single, y2 As Single)': Argument matching parameter 'x1'
narrows from 'Double' to 'Single'.
'Public Sub DrawLine(pen As System.Drawing.Pen, x1 As Single, y1 As
Single, x2 As Single, y2 As Single)': Argument matching parameter 'x2'
narrows from 'Double' to 'Single'. C:\Documents and Settings\Jeremy
Turner\My Documents\Visual Studio 2005\Projects\Lens Drawing Demo\Lens
Drawing Demo\Form1.vb 19 9 Lens Drawing Demo
Error 2 Overload resolution failed because no accessible 'DrawLine' can be
called without a narrowing conversion:
'Public Sub DrawLine(pen As System.Drawing.Pen, x1 As Integer, y1 As
Integer, x2 As Integer, y2 As Integer)': Argument matching parameter 'y1'
narrows from 'Double' to 'Integer'.
'Public Sub DrawLine(pen As System.Drawing.Pen, x1 As Integer, y1 As
Integer, x2 As Integer, y2 As Integer)': Argument matching parameter 'y2'
narrows from 'Double' to 'Integer'.
'Public Sub DrawLine(pen As System.Drawing.Pen, x1 As Single, y1 As
Single, x2 As Single, y2 As Single)': Argument matching parameter 'y1'
narrows from 'Double' to 'Single'.
'Public Sub DrawLine(pen As System.Drawing.Pen, x1 As Single, y1 As
Single, x2 As Single, y2 As Single)': Argument matching parameter 'y2'
narrows from 'Double' to 'Single'. C:\Documents and Settings\My
Documents\Visual Studio 2005\Projects\Lens Drawing Demo\Lens Drawing
Demo\Form1.vb 24 9 Lens Drawing Demo
It appears they are occurring exclusively in the 'DrawCrossHairs' Sub
Routine.
Any pointers?
I can't express how grateful I am to you for helping me along with this
project. The software I am trying to convert was written in VB6 for the
desktop PC in about 1999. I was never very good at programming then but I
managed to get by and the program has served me well for the last 8 years,
I'm now almost 8 years older (49) and i'm sure my brain isn't quite as
nimble as it used to be.
My work is in the Optical Lens field and this program saves me loads of time
calculating the prismatic effect at any point away from the Optical Centre
on a spherical or toric lens. The maths and writing the calculation bit of
the program is fine for me (i've managed to convert 8 other calculation
programs and this is the final one), but having never had to do .Net
graphics, along with rewriting the rest in .Net for the Pocket PC is
beginning to take its toll. It's now starting to become one of those jobs I
wish i'd never started!
I do hope that you can help me
Cheers
Jeremy
"<ctacke/>" <ctacke[@]opennetcf[dot]com> wrote in message
news:%23bczvk2NHHA.536@TK2MSFTNGP02.phx.gbl...
> How's this?
>
>
http://blog.opennetcf.org/ctacke/PermaLink,guid,93ce9487-4afc-401c-beec-dc63bc8876e7.aspx
>
>
> --
> Chris Tacke
> OpenNETCF Consulting
> Managed Code in the Embedded World
> www.opennetcf.com
> --
>
>
> "Jem" <xxxxxxxxxx> wrote in message
> news:06WdnUtVpZ-awjTYnZ2dnUVZ8v2vnZ2d@pipex.net...
>> Hi Chris
>>
>> Too right it's painful!! All i'm trying to do is update an old lens
>> calculation program. In VB6 I just grabbed the circle/line tool and
>> dropped it onto the form - Easy!
>>
>> O.K., so here's where i'm up to at the moment. I scrapped the initial
>> code and went down your suggested path. I now get an error in the
>> 'RefreshGraphics' Sub Routinewhen I try to refresh the drawing in order
>> to show the new CrossHair status. It's this bit of code that's causing
>> it...
>>
>> myGraphics.DrawEllipse(pen:=Pens.Blue, rect:=New Rectangle(x:=25, y:=25,
>> Width:=100, Height:=100))
>>
>>
>> The error is...
>> A first chance exception of type 'System.NullReferenceException
>>
>> I pretty much know that it's because the myGraphics variable isn't
>> available in this Sub - the question is how do I get it so that it is
>> recognised - i've tried various options, all of which were failures.
>> Could you possibly give me some ideas as to what I should be looking for.
>> I am trying hard - honest! :-)
>> Public Class Form1
>>
>> ' Variable for Graphics
>>
>> Dim myGraphics As Graphics
>>
>> ' Set up some variables for the CrossHair
>>
>> ' By changing these values (btnUp,btnDown, btnLeft, btnRight) we can move
>> the CrossHair
>>
>> Dim VertCrossHairX1 As Integer = 75
>>
>> Dim VertCrossHairX2 As Integer = 75
>>
>> Dim VertCrossHairY1 As Integer = 70
>>
>> Dim VertCrossHairY2 As Integer = 80
>>
>> Dim HorCrossHairY1 As Integer = 75
>>
>> Dim HorCrossHairY2 As Integer = 75
>>
>> Dim HorCrossHairX1 As Integer = 70
>>
>> Dim HorCrossHairX2 As Integer = 80
>>
>>
>>
>> Protected Overrides Sub onPaint(ByVal pe As PaintEventArgs)
>>
>> Dim MyGraphics As Graphics = pe.Graphics
>>
>> 'draw an ellipse inside a bounding rectangle
>>
>> MyGraphics.DrawEllipse(pen:=Pens.Blue, rect:=New Rectangle(x:=25, y:=25,
>> Width:=100, Height:=100))
>>
>> 'draw the vertical line on the form using the pen object
>>
>> MyGraphics.DrawLine(pen:=Pens.Black, x1:=75, y1:=25, x2:=75, y2:=125)
>>
>> 'draw the horizontal line on the form using the pen object
>>
>> MyGraphics.DrawLine(pen:=Pens.Black, x1:=25, y1:=75, x2:=125, y2:=75)
>>
>> ' Draw the vertical CrossHair line on the form using the pen object
>>
>> MyGraphics.DrawLine(pen:=Pens.Red, x1:=VertCrossHairX1,
>> y1:=VertCrossHairY1, x2:=VertCrossHairX2, y2:=VertCrossHairY2)
>>
>> ' Draw the horizontal CrossHair line on the form using the pen object
>>
>> MyGraphics.DrawLine(pen:=Pens.Red, x1:=HorCrossHairX1,
>> y1:=HorCrossHairY1, x2:=HorCrossHairX2, y2:=HorCrossHairY2)
>>
>> End Sub
>>
>> Private Sub RefreshGraphics()
>>
>> ' Clear all the graphics ready for redraw
>>
>> 'draw an ellipse inside a bounding rectangle with a Pen instance
>>
>> myGraphics.DrawEllipse(pen:=Pens.Blue, rect:=New Rectangle(x:=25, y:=25,
>> Width:=100, Height:=100))
>>
>> 'draw the vertical line on the form using the pen object
>>
>> myGraphics.DrawLine(pen:=Pens.Black, x1:=75, y1:=25, x2:=75, y2:=125)
>>
>> 'draw the horizontal line on the form using the pen object
>>
>> myGraphics.DrawLine(pen:=Pens.Black, x1:=25, y1:=75, x2:=125, y2:=75)
>>
>> ' Draw the vertical CrossHair line on the form using the pen object
>>
>> myGraphics.DrawLine(pen:=Pens.Red, x1:=VertCrossHairX1,
>> y1:=VertCrossHairY1, x2:=VertCrossHairX2, y2:=VertCrossHairY2)
>>
>> ' Draw the horizontal CrossHair line on the form using the pen object
>>
>> myGraphics.DrawLine(pen:=Pens.Red, x1:=HorCrossHairX1,
>> y1:=HorCrossHairY1, x2:=HorCrossHairX2, y2:=HorCrossHairY2)
>>
>> ' Set the variables back to their initial values
>>
>> VertCrossHairX1 = 75
>>
>> VertCrossHairX2 = 75
>>
>> VertCrossHairY1 = 70
>>
>> VertCrossHairY2 = 80
>>
>> HorCrossHairY1 = 75
>>
>> HorCrossHairY2 = 75
>>
>> HorCrossHairX1 = 70
>>
>> HorCrossHairX2 = 80
>>
>> End Sub
>>
>> Private Sub btnRight_Click(ByVal sender As System.Object, ByVal e As
>> System.EventArgs) Handles btnRight.Click
>>
>> VertCrossHairX1 = VertCrossHairX1 + 1
>>
>> VertCrossHairX2 = VertCrossHairX2 + 1
>>
>> HorCrossHairX1 = HorCrossHairX1 + 1
>>
>> HorCrossHairX2 = HorCrossHairX2 + 1
>>
>> RefreshGraphics()
>>
>> End Sub
>>
>> Private Sub btnLeft_Click(ByVal sender As System.Object, ByVal e As
>> System.EventArgs) Handles btnLeft.Click
>>
>> VertCrossHairX1 = VertCrossHairX1 - 1
>>
>> VertCrossHairX2 = VertCrossHairX2 - 1
>>
>> HorCrossHairX1 = HorCrossHairX1 - 1
>>
>> HorCrossHairX2 = HorCrossHairX2 - 1
>>
>> RefreshGraphics()
>>
>> End Sub
>>
>> Private Sub btnUp_Click(ByVal sender As System.Object, ByVal e As
>> System.EventArgs) Handles btnUp.Click
>>
>> VertCrossHairY1 = VertCrossHairY1 - 1
>>
>> VertCrossHairY2 = VertCrossHairY2 - 1
>>
>> HorCrossHairY1 = HorCrossHairY1 - 1
>>
>> HorCrossHairY2 = HorCrossHairY2 - 1
>>
>> RefreshGraphics()
>>
>> End Sub
>>
>> Private Sub btnDown_Click(ByVal sender As System.Object, ByVal e As
>> System.EventArgs) Handles btnDown.Click
>>
>> VertCrossHairY1 = VertCrossHairY1 + 1
>>
>> VertCrossHairY2 = VertCrossHairY2 + 1
>>
>> HorCrossHairY1 = HorCrossHairY1 + 1
>>
>> HorCrossHairY2 = HorCrossHairY2 + 1
>>
>> RefreshGraphics()
>>
>> End Sub
>>
>> End Class
>>
>> "Jem" <xxxxxxxxxx> wrote in message
>> news:kvudnWQfK-x2CjvYnZ2dnUVZ8surnZ2d@pipex.net...
>>> How difficult can it be to draw a circle and a couple of lines in VS
>>> 2005 VB.net???????
>>>
>>> It was so much easier when I could just select a tool and draw them at
>>> design time!
>>>
>>> This has got me really frustrated, and feeling pretty stupid. All I
>>> want to do is to display a circle on a pocket PC screen (WM5) have it
>>> intersected with a horizontal and vertical line so that it looks like
>>> the cross hairs on a gun sight. I then want a smaller crosshair in the
>>> middle that can be moved around by means of four buttons, one each for
>>> up, down, left and right. Each time a button is clicked I want the
>>> small crosshair to move .01mm in the corrosponding direction. The large
>>> crosshair will always remain stationary, thus referencing the cen