vb.net & GUIFacadeControl problem (1 Viewer)

Messiahs

Portal Pro
December 11, 2008
222
106
Home Country
Germany Germany
Hello,

I'm currently developing my first plugin and I'm having some very basic problems with the GUIFacadeControl.

I'm trying to get the current selected Item in a list (like current selected item in a playlist).

Code:
Imports MediaPortal.GUI.Library

Public Class cGUIHandler
    Inherits GUIFacadeControl
    <SkinControlAttribute(50)> Public facadeView As GUIFacadeControl = Nothing

    Sub New()
        MyBase.new(50) ' -> how to call ???
    End Sub

    Public Sub getSelectedItem()
       Dim itemIndex As Integer
       Dim cView As GUIControl

       cView = CurrentView   '-> CurrentView is always Nothing

       facadeView = New GUIFacadeControl(GetID)
       itemIndex = facadeView.SelectedItem '-> returns zero
    End Sub
End Class

Can somebody please help me?
 

bpell

New Member
August 4, 2010
3
0
Home Country
United States of America United States of America
Hello,

I'm currently developing my first plugin and I'm having some very basic problems with the GUIFacadeControl.

I'm trying to get the current selected Item in a list (like current selected item in a playlist).

Code:
Imports MediaPortal.GUI.Library

Public Class cGUIHandler
    Inherits GUIFacadeControl
    <SkinControlAttribute(50)> Public facadeView As GUIFacadeControl = Nothing

    Sub New()
        MyBase.new(50) ' -> how to call ???
    End Sub

    Public Sub getSelectedItem()
       Dim itemIndex As Integer
       Dim cView As GUIControl

       cView = CurrentView   '-> CurrentView is always Nothing

       facadeView = New GUIFacadeControl(GetID)
       itemIndex = facadeView.SelectedItem '-> returns zero
    End Sub
End Class

Can somebody please help me?

I'm new to developing for MediaPortal as of yesterday (Vb.Net) so excuse some of my ignorance of the internals. It looks like first that you're not returning anything from the getSelectedItem and there is no "ByRef" variable. I suspect you want to use a Function to return the selected value. Here's an example from another control, it's an extension method I created, as you can see, it returns a String value (or an Int value) based on the selected item in the dialog that I create. This is a different dialog than you're using, but the principle is the same.

Code:
Imports System.Runtime.CompilerServices
Imports System.Windows.Forms
Imports MediaPortal.GUI.Library
Imports MediaPortal.Dialogs

''' <summary>
''' Extension methods for MediaPortal.
''' </summary>
''' <remarks></remarks>
Public Module MediaPortalExtensions

    ''' <summary>
    ''' Shows a context menu with it's items populated from a string array, then returns the selected index in that list.
    ''' </summary>
    ''' <param name="win"></param>
    ''' <param name="menuItems"></param>
    ''' <param name="header"></param>
    ''' <returns>The selected index of the item choosen.  If no item is choosen or the dialog window is null a -1 will be returned.</returns>
    ''' <remarks>
    ''' The selected index maybe useful if you need to match that back to a list of objects that contain more information than
    ''' just a string title.
    ''' </remarks>
    <Extension()> _
    Public Function ShowContextMenuToInt(ByVal win As GUIWindow, ByVal menuItems() As String, ByVal header As String) As Integer
        Dim dlgMenu As GUIDialogMenu = GUIWindowManager.GetWindow(GUIWindow.Window.WINDOW_DIALOG_MENU)

        If dlgMenu IsNot Nothing Then
            dlgMenu.Reset()
            dlgMenu.SetHeading(header)
            For Each item As String In menuItems
                dlgMenu.Add(item)
            Next
            dlgMenu.DoModal(win.GetID)

            Return dlgMenu.SelectedLabel
        Else
            Return -1
        End If
    End Function

    ''' <summary>
    ''' Shows a context menu with it's items populated from a string array, then returns the selected displayed string.
    ''' </summary>
    ''' <param name="win"></param>
    ''' <param name="menuItems"></param>
    ''' <param name="header"></param>
    ''' <returns>The string value of the item selected, if no item is selected or the dialog window is null a blank string is returned.</returns>
    ''' <remarks></remarks>
    <Extension()> _
    Public Function ShowContextMenuToString(ByVal win As GUIWindow, ByVal menuItems() As String, ByVal header As String) As String
        Dim dlgMenu As GUIDialogMenu = GUIWindowManager.GetWindow(GUIWindow.Window.WINDOW_DIALOG_MENU)

        If dlgMenu IsNot Nothing Then
            dlgMenu.Reset()
            dlgMenu.SetHeading(header)
            For Each item As String In menuItems
                dlgMenu.Add(item)
            Next
            dlgMenu.DoModal(win.GetID)

            Return dlgMenu.SelectedLabelText
        Else
            Return ""
        End If
    End Function

End Module
 

Users who are viewing this thread

Top Bottom