Arrays of Rectangles

User1984

New member
Joined
Nov 23, 2011
Messages
1
Programming Experience
Beginner
Hi Guys,

I'm creating a little GUI for touch screens and so I'm using a lot of rectangles as "touchzones" (using the rectangle.contains(e.location) in mouse click events) but there are some things I'd like to do on lots of rectangles at the same time. I'd like to copy the rectangles into an array BY REFERENCE so that I can carry out operations on lots of rectangles at a time but the changes will flow back to the original instances of each rectangle.

Is it possible to create an array of rectangles and copy them in by reference rather than by value which seems to be the default?

Thanks in advanced.
 

Gopher2011

Well-known member
Joined
Mar 3, 2011
Messages
111
Location
South England
Programming Experience
10+
I had a similar problem last year, where I had 30 circles on the screen.
You can however set them all to go to one handler which is what I did, then handle the code in one place. I am not sure if this applies to you or will help you.

VB.NET:
       Public Digitals_OutOnScreen As New Collection
......
        'Create the Digital Output Object Collection. DO_01_Cmd is a screen object (circle).
        '---Do NOT CHANGE THE ORDER as it affects the 'array'---
        Digitals_OutOnScreen.Add(DO_01_Cmd)
        Digitals_OutOnScreen.Add(DO_02_Cmd)
        Digitals_OutOnScreen.Add(DO_03_Cmd)

.......

        'Attached the Comands .click handler
        'You can change the order ;)
        AddHandler DO_01_Cmd.Click, AddressOf OutputsClick
        AddHandler DO_02_Cmd.Click, AddressOf OutputsClick
        AddHandler DO_03_Cmd.Click, AddressOf OutputsClick
......

    Sub OutputsClick(ByVal sender As Object, ByVal e As System.EventArgs)
         'code here
    End Sub
 
Top Bottom