The Team System Team just got a big beautiful 52" LCD for displaying Team news - Yeah!
Unfortunately i was silly enough to volunteer to help put content on the computer driving this screen-boo!.
Luckily Jeff mentioned an internal tool for displaying a list of websites in a Screen saver that should make my life much easier-yeah!
Unfortunately the silly utility doesn't work in Vista and the creator didn't include the source code-sigh.
So after three hours of fighting with this tool ( pretty certain it is trying to write a temp file the UAC protected Windows directory) i and an internet search to see if there were projects on the internet for this (all the ones i found cost money (not a huge deal) and installed a bunch of junk i didnt want). I decided to write my own...Since have never written a screen saver I thought it a good chance to play a little "on the clock"
Turns out to write a screen saver all that is need is to rename an application from *.exe to *.SCR and drop it into the Windows directory.
To make it look like an screen saver all that is needed is to change a couple of properties:
Me.MaximizeBox = False Me.MinimizeBox = False Me.Text = "" Me.TopMost = True Me.WindowState = System.Windows.Forms.FormWindowState.Maximized
-Tada you have written a screen saver!
The code below reads a list of Web pages from a text file into an array...at some point i will probably enable the settings of my screen saver to set the filename and speed rotation into isolatedstorage for but for now i have just hard coded a path:
Imports Microsoft.VisualBasic.FileIO Imports System.IO Public Class Form1 Dim URLS(0) As String Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim filename As String = "c:\devdiv\urllist2.txt" Dim sr As StreamReader = New StreamReader(filename) Dim line As String If My.Computer.FileSystem.FileExists(filename) Then ' Create an instance of StreamReader to read from a file. ' Read and display the lines from the file until the end ' of the file is reached. Do line = sr.ReadLine() URLS(UBound(URLS)) = line ReDim Preserve URLS(UBound(URLS) + 1) Loop Until line Is Nothing sr.Close() End If End Sub
Imports Microsoft.VisualBasic.FileIO Imports System.IO
Public Class Form1 Dim URLS(0) As String Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim filename As String = "c:\devdiv\urllist2.txt" Dim sr As StreamReader = New StreamReader(filename) Dim line As String If My.Computer.FileSystem.FileExists(filename) Then ' Create an instance of StreamReader to read from a file. ' Read and display the lines from the file until the end ' of the file is reached. Do line = sr.ReadLine() URLS(UBound(URLS)) = line ReDim Preserve URLS(UBound(URLS) + 1) Loop Until line Is Nothing sr.Close() End If End Sub
To enable my screen saver to display a webpage i used the built in Windows Form Web Browser control. Finally to randomly change the web page i have used a timer control and the default code Snippet from Visual Studio for generating Random numbers. -Not bad for less time than i fought to debug a completed version.
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick Dim generator As New Random Dim randomValue As Integer randomValue = generator.Next(0, UBound(URLS) - 1) WebBrowser1.Url = New Uri(URLS(randomValue)) End Sub End Class