|
-
Sep 24th, 2020, 10:54 AM
#1
[RESOLVED] Why does my screen blank ?
Hi,
I have a tool which I programmed several years ago to produce a text file of coordinates to draw a regular polygon. The tool draws these Points around the horizontal centre of the form in order that the largest diameter can be achieved and outputs these Points to a text file.
I am using this tool today as part of a special tool for a specific job, I call the polygon tool, read-in the (x,y) Points and then draw a line from the same origin Point on the screen to each Point given in the text file to form a 'star'.
The difference is that in the new tool, the form's background colour and the pen colour are to be chosen before drawing.
I had a bit of trouble detecting a miss-spelt or unknown colour, just converting the String to a Color doesn't automatically cause an error, it just gives 'Black', but found a way around that... I think !
I run the tool, the 'star' is drawn, so far, so good, then the screen immediately goes blank... I can't find why.
I have also found that the blank form, (blank except for the 'Exit' button, all other controls are 'Hidden') is not the colour given in the design page (Lavender) but the form's default colour 'Control'.
Code:
Private Sub MakeDrawing()
Dim back, ink As Color, pen1 As Pen
Dim gr As Graphics = CreateGraphics()
Dim memo As Color = Me.BackColor
Try
ink = Color.FromName(TextBox2.Text)
Me.BackColor = ink ' This is to detect colour error.
back = Color.FromName(TextBox1.Text)
Me.BackColor = back ' This is to detect colour error.
Catch ex As Exception
Me.BackColor = memo
StartUp()
Label3.Show() ' Tell the user that there's a colour error.
Exit Sub
End Try
Me.BackColor = Nothing ' This is required else no drawing shown.
gr.Clear(back)
pen1 = New Pen(ink, 1)
For i = 0 To cords.Count - 1
gr.DrawLine(pen1, centre, cords(i))
Next
End Sub
I must be doing something wrong, or not doing something I ought to be doing... But what ?
Poppa
PS.
Typical text file:
Radius : 200
Centre : 432
1: 561, 585 Green start
2: 629, 467
3: 605, 332
4: 500, 244
5: 364, 244
6: 259, 332
7: 235, 467
8: 303, 585
9: 432, 632 Red finish
Pop.
Last edited by Poppa Mintin; Sep 24th, 2020 at 11:00 AM.
Along with the sunshine there has to be a little rain sometime.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|