Hi there,
I am trying to create a user control that does a slide show of images, but when I run it - it doesn't move the images. What am I doing wrong?
I am not to familiar with the Paint and Graphics class' so if its anything to do with that, which i suspect it is - go slow
I think the Paint methods are actually working as when I turn "DoubleBuffered" property off - you can see the refresh.
Thanks.
I am trying to create a user control that does a slide show of images, but when I run it - it doesn't move the images. What am I doing wrong?
I am not to familiar with the Paint and Graphics class' so if its anything to do with that, which i suspect it is - go slow
VB.NET:
Public Class UserControl1
Private _imageList, _backgroundImages As List(Of String)
Dim rectList As New List(Of Rectangle)
Public Sub New(ByVal imageList As List(Of String), ByVal location As Drawing.Point, ByVal backgroundImages As List(Of String), ByVal size As Size)
' This call is required by the Windows Form Designer.
InitializeComponent()
' Add any initialization after the InitializeComponent() call.
_imageList = imageList
_backgroundImages = backgroundImages
Me.Location = location
Me.Size = size
Me.BackgroundImage = Image.FromFile(backgroundImages(0), True)
For i As Integer = 0 To imageList.Count - 1
Dim xCor As Integer = 150 + (i * 135)
Dim newRect As New Rectangle(xCor, 15, 120, 120)
rectList.Add(newRect)
Next
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
For Each rect As Rectangle In rectList
rect.X -= 2
Next
Me.Refresh()
End Sub
Private Sub UserControl1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Timer1.Enabled = True
End Sub
Private Sub UserControl1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
For i As Integer = 0 To rectList.Count - 1
e.Graphics.DrawImage(Image.FromFile(_imageList(i)), rectList(i))
Next
End Sub
End Class
I think the Paint methods are actually working as when I turn "DoubleBuffered" property off - you can see the refresh.
Thanks.
Attachments
Last edited: