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