Mi panel extendido tiene una propiedad para activar el "Scroll Loop" (el cual solo funciona con la propiedad AutoScroll activada).
Para hacer un "Scroll Loop" inteligente sin AutoScroll, ya te lo he dicho, resetea los valores del "Me.VerticalScroll.Value" al sobrepasar "X" valor, hazlo como quieras.
Para hacer un "Scroll Loop" inteligente sin AutoScroll, ya te lo he dicho, resetea los valores del "Me.VerticalScroll.Value" al sobrepasar "X" valor, hazlo como quieras.
Código (vbnet) [Seleccionar]
'
' /* *\
' |#* Panel Elektro *#|
' \* */
'
' // By Elektro H@cker
'
' Properties:
' ...........
' · Disable_Flickering
' · Double_Buffer
' · Opaccity
' · Scroll_Loop
Public Class Panel_Elektro
Inherits Panel
Private _Opaccity As Int16 = 100
Private _Diable_Flickering As Boolean = True
Private _Scroll_Loop As Boolean = False
Dim Scroll_Range As Int64 = 0
Public Sub New()
Me.Name = "Panel_Elektro"
' Me.AutoScroll = True
' ResumeLayout(False)
End Sub
#Region " Properties "
''' <summary>
''' Enable/Disable any flickering effect on the panel.
''' </summary>
Protected Overrides ReadOnly Property CreateParams() As CreateParams
Get
If _Diable_Flickering Then
Dim cp As CreateParams = MyBase.CreateParams
cp.ExStyle = cp.ExStyle Or &H2000000
Return cp
Else
Return MyBase.CreateParams
End If
End Get
End Property
''' <summary>
''' Set the Double Buffer.
''' </summary>
Public Property Double_Buffer() As Boolean
Get
Return Me.DoubleBuffered
End Get
Set(ByVal Value As Boolean)
Me.DoubleBuffered = Value
End Set
End Property
''' <summary>
''' Set the transparency for this panel.
''' </summary>
Public Property Opaccity() As Short
Get
Return _Opaccity
End Get
Set(ByVal Value As Short)
If Value > 100 Then Throw New Exception("Opaccity range is from 0 to 100")
If Value < 0 Then Throw New Exception("Opaccity range is from 0 to 100")
Me._Opaccity = Value
Make_Opaccity(Value, Me.BackColor)
End Set
End Property
''' <summary>
''' Enable/Disable the flickering effects on this panel.
'''
''' This property turns off any Flicker effect on the panel
''' ...but also reduces the performance (speed) of the panel about 30% slower.
''' This don't affect to the performance of the application itself, only to the performance of this control.
''' </summary>
Public Property Diable_Flickering() As Boolean
Get
Return _Diable_Flickering
End Get
Set(ByVal Value As Boolean)
Me._Diable_Flickering = Value
End Set
End Property
''' <summary>
''' Enable/Disable the scroll loop effect.
''' Only when AutoScroll option is set to "True".
''' </summary>
Public Property Scroll_Loop() As Boolean
Get
Return _Scroll_Loop
End Get
Set(ByVal Value As Boolean)
Me._Scroll_Loop = Value
End Set
End Property
#End Region
#Region " Event handlers "
' Scroll
Private Sub Infinite_Scroll_Button(sender As Object, e As ScrollEventArgs) Handles Me.Scroll
If _Scroll_Loop AndAlso Me.AutoScroll Then
Set_Scroll_Range()
If Me.VerticalScroll.Value >= Scroll_Range - 4 Then ' Button Down
Me.VerticalScroll.Value = 1
ElseIf Me.VerticalScroll.Value <= 0 Then ' Button Up
Me.VerticalScroll.Value = Scroll_Range
End If
End If
End Sub
' MouseWheel (Scroll)
Private Sub Infinite_Scroll_MouseWheel(sender As Object, e As MouseEventArgs) Handles Me.MouseWheel
If _Scroll_Loop AndAlso Me.AutoScroll Then
Set_Scroll_Range()
If e.Delta < 0 AndAlso Me.VerticalScroll.Value >= Scroll_Range - 4 Then ' MouseWheel Down
Me.VerticalScroll.Value = 1
ElseIf e.Delta > 0 AndAlso Me.VerticalScroll.Value <= 0 Then ' MouseWheel Up
Me.VerticalScroll.Value = Scroll_Range
End If
End If
End Sub
#End Region
#Region " Methods / Functions "
''' <summary>
''' Changes the transparency of this panel.
''' </summary>
Private Sub Make_Opaccity(ByVal Percent As Short, ByVal colour As Color)
Me.BackColor = Color.FromArgb(Percent * 255 / 100, colour.R, colour.G, colour.B)
End Sub
''' <summary>
''' Set the VerticalScrollBar Range.
''' </summary>
Private Sub Set_Scroll_Range()
Scroll_Range = Me.VerticalScroll.Maximum - Me.VerticalScroll.LargeChange + Me.VerticalScroll.SmallChange
End Sub
#End Region
End Class