PageRenderTime 26ms CodeModel.GetById 20ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/Source Code/Plugins/TestProjectionPlugin/TestProjectionPlugin.vb

#
Visual Basic | 103 lines | 54 code | 21 blank | 28 comment | 0 complexity | f139dbc406ed2c65d370c0eb813a729b MD5 | raw file
  1Imports PluginSupport
  2Imports System.Drawing
  3
  4''' <summary>
  5''' Test Projection plugin.
  6''' </summary>
  7Public Class TestProjectionPlugin
  8    Implements PluginSupport.IPlugin
  9
 10    Private FContext As PluginContextBase = Nothing
 11    Private FMenuItem As System.Windows.Forms.ToolStripItem = Nothing
 12    Private FTicksLeft As Integer = -1
 13
 14#Region " Plugin Interface Methods "
 15
 16    ''' <summary>
 17    ''' Returns the name of the plugin.
 18    ''' </summary>
 19    Public ReadOnly Property Name() As String Implements IPlugin.Name
 20        Get
 21            Return "Test Projection Plug In"
 22        End Get
 23    End Property
 24
 25    Public ReadOnly Property Description() As String Implements PluginSupport.IPlugin.Description
 26        Get
 27            Return "Shows a changing screen that allows users to test whether or not projection is working."
 28        End Get
 29    End Property
 30
 31    ''' <summary>
 32    ''' Returns the name of the author of the plugin.
 33    ''' </summary>
 34    Public ReadOnly Property Author() As String Implements IPlugin.Author
 35        Get
 36            Return "Nicholas Hill"
 37        End Get
 38    End Property
 39
 40    ''' <summary>
 41    ''' Called when the plugin is initialised.
 42    ''' Use this method to store the given context so that it can be used later.
 43    ''' </summary>
 44    ''' <param name="context">An object by which communication is possible to PowerSong.</param>
 45    Public Sub Initialise(ByVal context As PluginSupport.PluginContextBase) Implements IPlugin.Initialise
 46        FContext = context
 47    End Sub
 48
 49    ''' <summary>
 50    ''' Called when the plugin is installed into a database.
 51    ''' </summary>
 52    Public Sub Install() Implements IPlugin.Install
 53    End Sub
 54
 55    ''' <summary>
 56    ''' Called when the plugin is uninstalled from a database.
 57    ''' </summary>
 58    Public Sub Uninstall() Implements IPlugin.Uninstall
 59    End Sub
 60
 61    ''' <summary>
 62    ''' Called when the PowerSong program opens the database containing the plugin.
 63    ''' </summary>
 64    ''' <remarks></remarks>
 65    Public Sub Start() Implements PluginSupport.IPlugin.Start
 66        FMenuItem = FContext.AddSubMenuItem(PluginContextBase.EMainMenuItem.Tools, "&Stop Projection Test", New EventHandler(AddressOf StopColourCycling_Click))
 67    End Sub
 68
 69    ''' <summary>
 70    ''' Called when the PowerSong program closes the database containing the plugin.
 71    ''' </summary>
 72    ''' <remarks></remarks>
 73    Public Sub [Stop]() Implements PluginSupport.IPlugin.Stop
 74        If FMenuItem IsNot Nothing Then FMenuItem.Dispose()
 75    End Sub
 76
 77#End Region
 78
 79    Private Sub StopColourCycling_Click()
 80        FTicksLeft = 60
 81    End Sub
 82
 83    Private FTick As Integer = -1
 84
 85    Public Sub Project(ByVal graphics As System.Drawing.Graphics, ByVal width As Integer, ByVal height As Integer) Implements PluginSupport.IPlugin.Project
 86
 87        If FTicksLeft = 0 Then Exit Sub
 88
 89        FTick += 1
 90        If FTicksLeft > 0 Then FTicksLeft -= 1
 91
 92        Dim A As Double = 1
 93        If FTicksLeft > 0 Then A = FTicksLeft / 60
 94        Dim R As Double = Math.Sin(FTick / 100)
 95        Dim G As Double = Math.Cos(FTick / 70)
 96        Dim B As Double = Math.Sin(FTick / 50)
 97
 98        Dim C As Color = Color.FromArgb(255 * A, 255 * ((R + 1) / 2), 255 * ((G + 1) / 2), 255 * ((B + 1) / 2))
 99        graphics.FillRectangle(New SolidBrush(C), 0, 0, width, height)
100
101    End Sub
102
103End Class