/Source Code/Plugins/CountDownPlugin/CountDownPlugin.vb
Visual Basic | 105 lines | 58 code | 15 blank | 32 comment | 0 complexity | 0a0ea24bf293fdc2976f40c40eba03bd MD5 | raw file
- Imports PluginSupport
- Imports System.Drawing
-
- ''' <summary>
- ''' CountDown plugin.
- ''' </summary>
- Public Class CountDownPlugin
- Implements PluginSupport.IPlugin
-
- Private FContext As PluginContextBase = Nothing
- Private FEndTime As Date = Now
- Private FStartTime As Date = Now
- Private FMenuItem As System.Windows.Forms.ToolStripItem = Nothing
-
- #Region " Plugin Interface Methods "
-
- ''' <summary>
- ''' Returns the name of the plugin.
- ''' </summary>
- Public ReadOnly Property Name() As String Implements IPlugin.Name
- Get
- Return "CountDown Plug In"
- End Get
- End Property
-
- ''' <summary>
- ''' Returns the name of the author of the plugin.
- ''' </summary>
- Public ReadOnly Property Author() As String Implements IPlugin.Author
- Get
- Return "Nicholas Hill"
- End Get
- End Property
-
- ''' <summary>
- ''' Called when the plugin is initialised.
- ''' Use this method to store the given context so that it can be used later.
- ''' </summary>
- ''' <param name="context">An object by which communication is possible to PowerSong.</param>
- Public Sub Initialise(ByVal context As PluginSupport.PluginContextBase) Implements IPlugin.Initialise
- FContext = context
- End Sub
-
- ''' <summary>
- ''' Called when the plugin is installed into a database.
- ''' </summary>
- Public Sub Install() Implements IPlugin.Install
- End Sub
-
- ''' <summary>
- ''' Called when the plugin is uninstalled from a database.
- ''' </summary>
- Public Sub Uninstall() Implements IPlugin.Uninstall
- End Sub
-
- ''' <summary>
- ''' Called when the PowerSong program opens the database containing the plugin.
- ''' </summary>
- ''' <remarks></remarks>
- Public Sub Start() Implements PluginSupport.IPlugin.Start
- FMenuItem = FContext.AddSubMenuItem(PluginContextBase.EMainMenuItem.Tools, "Start &CountDown...", New EventHandler(AddressOf StartCountDown_Click))
- End Sub
-
- ''' <summary>
- ''' Called when the PowerSong program closes the database containing the plugin.
- ''' </summary>
- ''' <remarks></remarks>
- Public Sub [Stop]() Implements PluginSupport.IPlugin.Stop
- If FMenuItem IsNot Nothing Then FMenuItem.Dispose()
- End Sub
-
- ''' <summary>
- ''' This method allows custom-drawing on the projector screen.
- ''' </summary>
- ''' <param name="graphics">The graphics object that can be used for drawing.</param>
- Public Sub Project(ByVal graphics As System.Drawing.Graphics, ByVal width As Integer, ByVal height As Integer) Implements PluginSupport.IPlugin.Project
- Dim SecondsPast As Integer = FEndTime.Subtract(Now).TotalSeconds
- If SecondsPast > -1 Then
- Dim Minutes As Integer = SecondsPast \ 60
- Dim Seconds As Integer = SecondsPast Mod 60
- Dim TimeLeft As String = Minutes.ToString + ":" + Seconds.ToString
- If Seconds < 10 Then TimeLeft = Minutes.ToString + ":0" + Seconds.ToString
- Dim FontSize As Integer = width / 5
- graphics.DrawString(TimeLeft, New Font("Consolas", FontSize, FontStyle.Bold), Brushes.Black, 8, height \ 3 + 8)
- graphics.DrawString(TimeLeft, New Font("Consolas", FontSize, FontStyle.Bold), Brushes.White, 0, height \ 3)
- End If
- End Sub
-
- #End Region
-
- Private Sub StartCountDown_Click()
- Dim Data As String = InputBox("Please enter the number of seconds to count down from:", "CountDown Plugin", "60")
- If Not IsNumeric(Data) Then Data = "60"
- Dim TimeLeft As Integer = CInt(Data)
- FStartTime = Now
- FEndTime = Now.AddSeconds(TimeLeft)
- End Sub
-
- Public ReadOnly Property Description() As String Implements PluginSupport.IPlugin.Description
- Get
- Return "Shows a count down from a specified time, down to zero."
- End Get
- End Property
-
- End Class