VB.net (3 Viewers)

reverson1

Portal Pro
May 23, 2006
88
4
Williamsburg,VA
Home Country
United States of America United States of America
Ok, this is probably a stupid question but I did search and couldn't find an answer.

Is there a sample for developing a plugin in VB.net, is it even possible to do this?

I sure would appreciate to push in the right direction....

Thanks,
Richard
 

reverson1

Portal Pro
May 23, 2006
88
4
Williamsburg,VA
Home Country
United States of America United States of America
Thanks, got another question that I'm sure has already been answered. But I'm gonna ask it anyways :)

Do I have to compile Mediaportal in order to write a plugin for it or can I just use the current release and reference it that way?

Thanks
Richard
 

tourettes

Retired Team Member
  • Premium Supporter
  • January 7, 2005
    17,301
    4,800
    reverson1 said:
    Thanks, got another question that I'm sure has already been answered. But I'm gonna ask it anyways :)

    Do I have to compile Mediaportal in order to write a plugin for it or can I just use the current release and reference it that way?

    No need to compile the MediaPortal.
     

    slapout

    Portal Member
    May 8, 2006
    7
    0
    I believe you should be able to write a plugin in any dot net enabled language. I started to create a vb.net version of the C# sample, but got side tracked.
     

    reverson1

    Portal Pro
    May 23, 2006
    88
    4
    Williamsburg,VA
    Home Country
    United States of America United States of America
    I started working on converting the sample as well this morning. Hopefully I'll get to finish that part up when I get home tonight.

    Considering I'm a vb6 kind of guy I'm sure I'll end up with some more questions along the way.

    Thanks for the help so far, I really do appreciate it.
     

    reverson1

    Portal Pro
    May 23, 2006
    88
    4
    Williamsburg,VA
    Home Country
    United States of America United States of America
    I've tried my best at converting the sample to vb.net. I'm no longer receiving any error messages, however the plugin still doesn't show up in MediaPortal. Can someone give me a clue as what is wrong with the following code?

    Thanks,
    Richard

    Code:
    Public Class Class1
        Inherits MediaPortal.GUI.Library.GUIWindow
        Implements MediaPortal.GUI.Library.ISetupForm
        Public Function PluginName() As String Implements MediaPortal.GUI.Library.ISetupForm.PluginName
    
            Return "MyFirstPlugin"
    
        End Function
    
    
        Public Function Description() As String Implements MediaPortal.GUI.Library.ISetupForm.Description
    
            Return "My First plugin tutorial"
    
        End Function
    
    
        Public Function Author() As String Implements MediaPortal.GUI.Library.ISetupForm.Author
    
            Return "Frodo"
    
        End Function
    
    
    
        Public Sub ShowPlugin() Implements MediaPortal.GUI.Library.ISetupForm.ShowPlugin
    
            MsgBox("Nothing to configure, this is just an example")
    
        End Sub
    
    
        Public Function CanEnable() As Boolean Implements MediaPortal.GUI.Library.ISetupForm.CanEnable
    
            Return True
    
        End Function
    
    
        Public Function GetWindowId() As Integer Implements MediaPortal.GUI.Library.ISetupForm.GetWindowId
    
            Return 5678
    
        End Function
    
    
        Public Function DefaultEnabled() As Boolean Implements MediaPortal.GUI.Library.ISetupForm.DefaultEnabled
    
            Return True
    
        End Function
    
    
    
        Public Function HasSetup() As Boolean Implements MediaPortal.GUI.Library.ISetupForm.HasSetup
    
            Return True
    
        End Function
    
    
    
        Public Function GetHome(ByRef strButtonText As String, ByRef strButtonImage As String, ByRef strButtonImageFocus As String, ByRef strPictureImage As String) As Boolean Implements MediaPortal.GUI.Library.ISetupForm.GetHome
    
            strButtonText = String.Empty
    
            strButtonImage = String.Empty
    
            strButtonImageFocus = String.Empty
    
            strPictureImage = String.Empty
    
            Return False
    
        End Function
    End Class
     

    samuel337

    Portal Pro
    August 25, 2004
    772
    0
    Melbourne, Australia
    Also implement MediaPortal.GUI.Library.IShowPlugin.

    You also need these methods:
    Code:
        Public Overrides Function Init() As Boolean
            Return Load(MediaPortal.GUI.Library.GUIGraphicsContext.Skin & "\<filename of skin xml file>")
        End Function
    
        Public Overrides Sub OnAction(ByVal action As MediaPortal.GUI.Library.Action)
            If action.wID = MediaPortal.GUI.Library.Action.ActionType.ACTION_PREVIOUS_MENU Then
                MediaPortal.GUI.Library.GUIWindowManager.ActivateWindow(MediaPortal.GUI.Library.GUIWindow.Window.WINDOW_HOME)
                Exit Sub
            End If
    
            MyBase.OnAction(action)
        End Sub
    
        Public Overrides Function OnMessage(ByVal message As MediaPortal.GUI.Library.GUIMessage) As Boolean
            Select Case message.Message
                Case MediaPortal.GUI.Library.GUIMessage.MessageType.GUI_MSG_WINDOW_INIT
                    'load any settings here and anything else that needs to be done when screen is shown
                    MyBase.OnMessage(message)
    
                Case MediaPortal.GUI.Library.GUIMessage.MessageType.GUI_MSG_WINDOW_DEINIT
                    'save any settings here
    
                Case MediaPortal.GUI.Library.GUIMessage.MessageType.GUI_MSG_ITEM_FOCUS_CHANGED
    'this is triggered when focus has changed on screen, use message.SenderControlId to find out which control
    
                Case MediaPortal.GUI.Library.GUIMessage.MessageType.GUI_MSG_CLICKED
    'this is triggered when a control on screen has been clicked, use message.SenderControlId to find out which control
    
    
                Case Else
                    Return MyBase.OnMessage(message)
            End Select
        End Function

    HTH

    Sam
     

    reverson1

    Portal Pro
    May 23, 2006
    88
    4
    Williamsburg,VA
    Home Country
    United States of America United States of America
    That worked like a champ, thanks!

    And just to make this thread complete so maybe someone else who is looking for this can find it a little easier, here's the complete sample class for vb.net:

    Code:
    Public Class MediaPortalInterface
        Inherits MediaPortal.GUI.Library.GUIWindow
        Implements MediaPortal.GUI.Library.ISetupForm
        Public Function PluginName() As String _
    	     Implements MediaPortal.GUI.Library.ISetupForm.PluginName
    
            Return "myFirstPlugin"
    
        End Function
    
    
        Public Function Description() As String _
    	     Implements MediaPortal.GUI.Library.ISetupForm.Description
    
            Return "VB.net Sample Code"
    
        End Function
    
    
        Public Function Author() As String _
    	     Implements MediaPortal.GUI.Library.ISetupForm.Author
    
            Return "SampleCoder"
    
        End Function
    
    
    
        Public Sub ShowPlugin() _
    	     Implements MediaPortal.GUI.Library.ISetupForm.ShowPlugin
    
            msgbox "Nothing to configure."
    
        End Sub
    
    
        Public Function CanEnable() As Boolean _
    	     Implements MediaPortal.GUI.Library.ISetupForm.CanEnable
    
            Return True
    
        End Function
    
    
        Public Function GetWindowId() As Integer _
    	     Implements MediaPortal.GUI.Library.ISetupForm.GetWindowId
    
            Return 5678
    
        End Function
    
        Public Overrides Property GetID() As Integer
            Get
                Return GetWindowId()
            End Get
            Set(ByVal value As Integer)
            End Set
        End Property
    
        Public Function DefaultEnabled() As Boolean _
    	     Implements MediaPortal.GUI.Library.ISetupForm.DefaultEnabled
    
            Return True
    
        End Function
    
    
    
        Public Function HasSetup() As Boolean _
    	     Implements MediaPortal.GUI.Library.ISetupForm.HasSetup
    
            Return True
    
        End Function
    
    
    
        Public Function GetHome(ByRef strButtonText As String, _
    	     ByRef strButtonImage As String, _
    	     ByRef strButtonImageFocus As String, _
    	     ByRef strPictureImage As String) As Boolean _
    	     Implements MediaPortal.GUI.Library.ISetupForm.GetHome
    
            strButtonText = String.Empty
    
            strButtonImage = String.Empty
    
            strButtonImageFocus = String.Empty
    
            strPictureImage = String.Empty
    
            Return False
    
        End Function
    
        Public Overrides Function Init() As Boolean
            Return Load(MediaPortal.GUI.Library.GUIGraphicsContext.Skin & _
    		        "\<filename>")
        End Function
    
        Public Overrides Sub OnAction(ByVal action As MediaPortal.GUI.Library.Action)
    
            If action.wID = _
                MediaPortal.GUI.Library.Action.ActionType.ACTION_PREVIOUS_MENU Then
                MediaPortal.GUI.Library.GUIWindowManager.ActivateWindow( _
    		      MediaPortal.GUI.Library.GUIWindow.Window.WINDOW_HOME)
                Exit Sub
            End If
    
            MyBase.OnAction(action)
        End Sub
    
        Public Overrides Function OnMessage( _
    	      ByVal message As MediaPortal.GUI.Library.GUIMessage) As Boolean
    
            Select Case message.Message
                Case MediaPortal.GUI.Library.GUIMessage.MessageType.GUI_MSG_WINDOW_INIT
                    'load any settings here and anything else 
                    'that needs to be done when screen is shown 
                    MyBase.OnMessage(message)
    
                Case MediaPortal.GUI.Library.GUIMessage.MessageType.GUI_MSG_WINDOW_DEINIT
                    'save any settings here 
    
                Case MediaPortal.GUI.Library.GUIMessage.MessageType.GUI_MSG_ITEM_FOCUS_CHANGED
                    'this is triggered when focus has changed on screen, 
    		          'use message.SenderControlId to find out which control 
    
                Case MediaPortal.GUI.Library.GUIMessage.MessageType.GUI_MSG_CLICKED
                    'this is triggered when a control on screen has been clicked, 
    		          'use message.SenderControlId to find out which control 
    
    
                Case Else
                    Return MyBase.OnMessage(message)
            End Select
        End Function
    End Class
     

    Users who are viewing this thread

    Top Bottom