Torna al Thread

'Contiene le PictureBox e i loro limiti rispetto alla PictureBox grande Dim pictRect As Dictionary(Of PictureBox, Rectangle) Protected Overrides Sub OnLoad(ByVal e As System.EventArgs) MyBase.OnLoad(e) pictRect = New Dictionary(Of PictureBox, Rectangle)(100) For Each pictBox As PictureBox In Me.Controls 'non bisogna aggiungere la PictureBox grande If Not pictBox Is Me.pictureBoxGrande Then 'Poichè la posizione è data rispetto al controllo padre... Dim location As Point = pictBox.Location '... Eseguo un offset per ottenerla rispetto alla PictureBox grande location.Offset(-pictureBoxGrande.Location.X, -pictureBoxGrande.Location.Y) 'Infine aggiungo PictureBox e Rettangolo al Dictionary pictRect.Add(pictBox, New Rectangle(location, pictBox.Size)) End If Next End Sub Private Sub pictureBoxGrande_MouseMove(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles pictureBoxGrande.MouseMove 'Ciclo tutti i rettangoli nel Dictionary For Each rect As Rectangle In pictRect.Values If rect.Contains(e.Location) Then Cursor = Cursors.Hand Return End If Next Cursor = Cursors.Default End Sub Private Sub pictureBoxGrande_MouseClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles pictureBoxGrande.MouseClick 'Ciclo tutte le PictureBox nel Dictionary For Each pictBox As PictureBox In pictRect.Keys 'Controllo se il rettangolo relativo alla PB grande contiene il cursore If pictRect(pictBox).Contains(e.Location) Then 'Se si mostro la PictureBox pictBox.BringToFront() Return End If Next End Sub
Copyright © dotNetHell.it 2002-2024
Running on Windows Server 2008 R2 Standard, SQL Server 2012 & ASP.NET 3.5