Hi,
I wrote a simple program using GDI+ that places two rectangles on the screen based on values typed in two textboxes. I did this by creating 24 rectangles 10 pixels apart and drawing the rectangle that coorisponds with the typed int32 when a button is pressed. Now I want all the rectangles in between the two that are drawn to the screen to also be drawn. I tried doing this many ways and googling for info and had no luck. My code is below. Any ideas
I wrote a simple program using GDI+ that places two rectangles on the screen based on values typed in two textboxes. I did this by creating 24 rectangles 10 pixels apart and drawing the rectangle that coorisponds with the typed int32 when a button is pressed. Now I want all the rectangles in between the two that are drawn to the screen to also be drawn. I tried doing this many ways and googling for info and had no luck. My code is below. Any ideas
VB.NET:
[font=Arial][size=2] Private Sub Button1Click(sender As System.Object, ByVal e As System.EventArgs)[/size][/font]
[font=Arial][size=2] Dim g As Graphics = Me.CreateGraphics[/size][/font]
[font=Arial][size=2] Dim fillcol As Color[/size][/font]
[font=Arial][size=2] [/size][/font]
[font=Arial][size=2] 'assigns textbox value to int[/size][/font]
[font=Arial][size=2] Dim box1val As Int32= Me.beginbox.text[/size][/font]
[font=Arial][size=2] Dim box2val As Int32= Me.textbox1.text[/size][/font]
[font=Arial][size=2] Dim szlwxval1 As Int32=Me.comboBox1.Text[/size][/font]
[font=Arial][size=2] dim szlboxesamt as int32=box1val-box2val[/size][/font]
[font=Arial][size=2] Dim x as integer[/size][/font]
[font=Arial][size=2] Dim SZLBOXES(23) As rectangle[/size][/font]
[font=Arial][size=2] [/size][/font]
[font=Arial][size=2] 'Set values for boxes[/size][/font]
[font=Arial][size=2] Dim SZLNUMS(23) As Integer[/size][/font]
[font=Arial][size=2] [/size][/font]
[font=Arial][size=2] Dim VAL1 As Integer=1[/size][/font]
[font=Arial][size=2] Dim VAL2 As Integer=1[/size][/font]
[font=Arial][size=2] Dim VAL3 As Integer=1[/size][/font]
[font=Arial][size=2] Dim VAL4 As Integer=1[/size][/font]
[font=Arial][size=2] Dim VAL5 As Integer=1[/size][/font]
[font=Arial][size=2] Dim VAL6 As Integer=1[/size][/font]
[font=Arial][size=2] Dim VAL7 As Integer=1[/size][/font]
[font=Arial][size=2] Dim VAL8 As Integer=1[/size][/font]
[font=Arial][size=2] Dim VAL9 As Integer=1[/size][/font]
[font=Arial][size=2] Dim VAL10 As Integer=1[/size][/font]
[font=Arial][size=2] Dim VAL11 As Integer=1[/size][/font]
[font=Arial][size=2] Dim VAL12 As Integer=1[/size][/font]
[font=Arial][size=2] Dim VAL13 As Integer=1[/size][/font]
[font=Arial][size=2] Dim VAL14 As Integer=1[/size][/font]
[font=Arial][size=2] Dim VAL15 As Integer=1[/size][/font]
[font=Arial][size=2] Dim VAL16 As Integer=1[/size][/font]
[font=Arial][size=2] Dim VAL17 As Integer=1[/size][/font]
[font=Arial][size=2] Dim VAL18 As Integer=1[/size][/font]
[font=Arial][size=2] Dim VAL19 As Integer=1[/size][/font]
[font=Arial][size=2] Dim VAL20 As Integer=1[/size][/font]
[font=Arial][size=2] Dim VAL21 As Integer=1[/size][/font]
[font=Arial][size=2] Dim VAL22 As Integer=1[/size][/font]
[font=Arial][size=2] Dim VAL23 As Integer=1[/size][/font]
[font=Arial][size=2] Dim VAL24 As Integer=1[/size][/font]
[font=Arial][size=2] [/size][/font]
[font=Arial][size=2] SZLNUMS(0)=VAL1[/size][/font]
[font=Arial][size=2] SZLNUMS(1)=VAL2[/size][/font]
[font=Arial][size=2] SZLNUMS(2)=VAL3[/size][/font]
[font=Arial][size=2] SZLNUMS(3)=VAL4[/size][/font]
[font=Arial][size=2] SZLNUMS(4)=VAL5[/size][/font]
[font=Arial][size=2] [/size][/font]
[font=Arial][size=2] 'Defines cases for colors of your lines[/size][/font]
[font=Arial][size=2] If szlwxval1=1 Then[/size][/font]
[font=Arial][size=2] fillcol=color.Green[/size][/font]
[font=Arial][size=2] ElseIf szlwxval1<5 Then[/size][/font]
[font=Arial][size=2] fillcol=color.Yellow[/size][/font]
[font=Arial][size=2] else fillcol=color.Red[/size][/font]
[font=Arial][size=2] End If[/size][/font]
[font=Arial][size=2] [/size][/font]
[font=Arial][size=2] 'Defines pens and brushes[/size][/font]
[font=Arial][size=2] Dim NPN As pen=new Pen(color.Red,3)[/size][/font]
[font=Arial][size=2] Dim BXBS As Solidbrush=new SolidBrush(fillcol)[/size][/font]
[font=Arial][size=2] [/size][/font]
[font=Arial][size=2] 'Defines SZL boxes[/size][/font]
[font=Arial][size=2] Dim pt1 As New Point(10,10)[/size][/font]
[font=Arial][size=2] [/size][/font]
[font=Arial][size=2] [/size][/font]
[font=Arial][size=2] Dim SZLBX1 As New Rectangle(10,10,20,20)[/size][/font]
[font=Arial][size=2] Dim SZLBX2 As New Rectangle(20,10,20,20)[/size][/font]
[font=Arial][size=2] Dim SZLBX3 As New Rectangle(30,10,20,20)[/size][/font]
[font=Arial][size=2] Dim SZLBX4 As New Rectangle(90,10,20,20)[/size][/font]
[font=Arial][size=2] Dim SZLBX5 As New Rectangle(90,10,20,20)[/size][/font]
[font=Arial][size=2] [/size][/font]
[font=Arial][size=2] me.Refresh()[/size][/font]
[font=Arial][size=2] [/size][/font]
[font=Arial][size=2] 'assign values to array[/size][/font]
[font=Arial][size=2] If box1val=12 Then[/size][/font]
[font=Arial][size=2] val1=box1val[/size][/font]
[font=Arial][size=2] ElseIf box1val=13 Then[/size][/font]
[font=Arial][size=2] val2=box1val[/size][/font]
[font=Arial][size=2] ElseIf box1val=14 Then[/size][/font]
[font=Arial][size=2] val3=box1val[/size][/font]
[font=Arial][size=2] ElseIf box1val=15 Then[/size][/font]
[font=Arial][size=2] val4=box1val[/size][/font]
[font=Arial][size=2] End If[/size][/font]
[font=Arial][size=2] [/size][/font]
[font=Arial][size=2] If box2val=12 Then[/size][/font]
[font=Arial][size=2] val1=box2val[/size][/font]
[font=Arial][size=2] ElseIf box2val=13 Then[/size][/font]
[font=Arial][size=2] val2=box2val[/size][/font]
[font=Arial][size=2] ElseIf box2val=14 Then[/size][/font]
[font=Arial][size=2] val3=box2val[/size][/font]
[font=Arial][size=2] ElseIf box2val=15 Then[/size][/font]
[font=Arial][size=2] val4=box2val[/size][/font]
[font=Arial][size=2] End If[/size][/font]
[font=Arial][size=2] [/size][/font]
[font=Arial][size=2] For x=box1val To box2val[/size][/font]
[font=Arial][size=2] SZLBOXES((x-box1val))=new rectangle(10-x,10,20,20)[/size][/font]
[font=Arial][size=2] Next x[/size][/font]
[font=Arial][size=2] g.FillRectangles(bxbs, SZLBOXES)[/size][/font]
[font=Arial][size=2] [/size][/font]
[font=Arial][size=2] End Sub[/size][/font]
[font=Arial][size=2] [/size][/font]