Vb.Net screensaver 1.0
Submitted By:
FuzzyDaze
Rating:





(
Rate It)
Imports FileWriter.FileWriter
Public Class frmFuzzyScreen
Inherits System.Windows.Forms.Form
Private booIsActive As Boolean = False
Private pntMouseLocation As Point
Private intNextImage As Integer = 0
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents picShowImage As System.Windows.Forms.PictureBox
Friend WithEvents tmrImageChange As System.Windows.Forms.Timer
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.components = New System.ComponentModel.Container
Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(frmFuzzyScreen))
Me.picShowImage = New System.Windows.Forms.PictureBox
Me.tmrImageChange = New System.Windows.Forms.Timer(Me.components)
Me.SuspendLayout()
'
'picShowImage
'
Me.picShowImage.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _
Or System.Windows.Forms.AnchorStyles.Left) _
Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
Me.picShowImage.Location = New System.Drawing.Point(0, 0)
Me.picShowImage.Name = "picShowImage"
Me.picShowImage.Size = New System.Drawing.Size(416, 402)
Me.picShowImage.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage
Me.picShowImage.TabIndex = 0
Me.picShowImage.TabStop = False
'
'tmrImageChange
'
Me.tmrImageChange.Interval = 1000
'
'frmFuzzyScreen
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(408, 368)
Me.ControlBox = False
Me.Controls.Add(Me.picShowImage)
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None
Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
Me.MaximizeBox = False
Me.MinimizeBox = False
Me.Name = "frmFuzzyScreen"
Me.ShowInTaskbar = False
Me.Text = "Fuzzy ScreenSaver"
Me.TopMost = True
Me.WindowState = System.Windows.Forms.FormWindowState.Maximized
Me.ResumeLayout(False)
End Sub
#End Region
#Region "User Actions"
Private Sub picShowImage_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles picShowImage.Click
'** If the user clicks a mousebutton, the screensaver must disappear
Application.Exit()
End Sub
Private Sub frmScreenSaver_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles MyBase.KeyPress
'** If the user pushes a keyboard button, the screensaver must disappear
Application.Exit()
End Sub
Private Sub picShowImage_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles picShowImage.MouseMove
'** If the user moves the mouse, the screensaver must disappear
If Not booIsActive Then
Me.pntMouseLocation = New Point(e.X, e.Y)
booIsActive = True
Else
If Math.Abs(e.X - Me.pntMouseLocation.X) > 50 Or _
Math.Abs(e.Y - Me.pntMouseLocation.Y) > 50 Then
Application.Exit()
End If
End If
End Sub
#End Region
Private Sub frmFuzzyScreen_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'** Immediatly show the first image, so the screen will not be blank
picShowImage.Image = Image.FromFile(strImageList(0))
'** Set the Timer interval to the desired delay and enble the timer
tmrImageChange.Interval = intDelay * 1000
tmrImageChange.Enabled = True
End Sub
Private Sub ShowImage()
'** Discard the current image and show the next. Discarding saves some memory, but is not nessecary.
'** You do run the risk of being unable to load the next image, and end up with a blank screen.
picShowImage.Image.Dispose()
picShowImage.Image = Image.FromFile(strImageList(intNextImage))
End Sub
Private Sub tmrImageChange_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrImageChange.Tick
'** Select the next image to show
If intNextImage < intImageCount - 1 Then
intNextImage += 1
Else
intNextImage = 0
End If
Try
'** try to show the next image. Do nothing if it fails.
ShowImage()
Catch ex As Exception
End Try
End Sub
End Class