Guicontrolsdemo ? come out, come out, whereever you are? (1 Viewer)

gpnash

Portal Pro
March 2, 2015
70
16
65
Linden, Michigan
Home Country
United States of America United States of America
Hi, I'm trying my hand a writing a windows plugin using vb.net 4+ mediaportal 1.50.0 and the directions I'm seeing while giving a example that will just about work, fall short in a couple of places. I was hoping to find the guicontrolsdemo mentioned but all links to it result in a 404 not found error.

specifically I'm trying to find out how to change text the plugin has displayed and create a list (similar to the recorded tv list or the program guide) of shows for approval. so far I haven't been able to get more than a couple of buttons to show up with their dialog boxes (as show in the one online sample)

Thanks for any and all help..
guy
 

ajs

Development Group
  • Team MediaPortal
  • February 29, 2008
    15,492
    10,371
    Kyiv
    Home Country
    Ukraine Ukraine

    gpnash

    Portal Pro
    March 2, 2015
    70
    16
    65
    Linden, Michigan
    Home Country
    United States of America United States of America
    Thanks for that, but being neither lazy nor an idiot I'd found those days ago.
    the first is a nice description of what I was looking for but the link t"o the repository results in a 404 not found error.
    "https://www.team-mediaportal.com/extensions/guicontrolsdemo"
    "|404| Bad karma, sorry...we can't find that page!
    You asked for this page, but despite our computers looking very hard, we could not find it. What happened ?

    • the link you clicked to arrive here is not valid anymore or has a typo in it
    • or we removed that page, or gave it another name
    • or, quite unlikely for sure, maybe you typed it yourself and there was a little mistake ?
    Please use the search-field on top or start browsing from home-page, thanks!"


    I've followed the second link as far as it'd take me, it unfortunately doesn't give you any clue how to add any kind of list control to the skin page, nor how to populate it from the code page. I've tried..
    Code:
    <SkinControlAttribute(1)> Protected lblText As GUILabelControl = Nothing
            <SkinControlAttribute(2)> Protected buttonOne As GUIButtonControl = Nothing
            <SkinControlAttribute(3)> Protected buttonTwo As GUIButtonControl = Nothing
            <SkinControlAttribute(4)> Protected myList As GUIListControl = Nothing
            Private _windowID As Integer = 10001
    
          Protected Overrides Sub OnPageLoad()
                lblText.Label = "this is set from the plugin."
                myList.Add(New GUIListItem("test1"))
                myList.Add(New GUIListItem("test2"))
                myList.Add(New GUIListItem("test3"))
            End Sub


    which of course doesn't work.

    Thanks again for trying.
     

    gpnash

    Portal Pro
    March 2, 2015
    70
    16
    65
    Linden, Michigan
    Home Country
    United States of America United States of America
    ok... looks like I'm cooking with gas now. Last hurdle.
    seems like the guilistcontrol with it's guilistitem is great for a single column list.
    What do we do for a multiple column list? my requirement is for each line to have a checkbox, date/time, channel,channelname, series name, season/episode, episodetitle
    without a table structure it's difficult to fake columns and I'm not sure how to either skin or access 6 guilistcontrols across the screen....
     

    ajs

    Development Group
  • Team MediaPortal
  • February 29, 2008
    15,492
    10,371
    Kyiv
    Home Country
    Ukraine Ukraine

    gpnash

    Portal Pro
    March 2, 2015
    70
    16
    65
    Linden, Michigan
    Home Country
    United States of America United States of America
    Guess I just don't get it.... but then again the windows 10 universal windows code baffles me too. windows forms... that I understand.

    Thanks for the last straw.. Here's the working vb example....



    Code:
     <window>
      <id>10001</id>
      <defaultcontrol>3</defaultcontrol>
      <allowoverlay>yes</allowoverlay>
      <controls>
        <control>
          <id>0</id>
          <type>image</type>
          <posX>66</posX>
          <posY>34</posY>
          <width>61</width>
          <height>57</height>
          <texture>icon_tv.png</texture>
          <animation effect="fade" time="250">WindowOpen</animation>
          <animation effect="fade" time="250">WindowClose</animation>
        </control>
        <import>common.time.xml</import>
        <control>
          <description>Refresh</description>
          <type>button</type>
          <id>3</id>
          <posX>100</posX>
          <posY>175</posY>
          <height>60</height>
          <onleft>3</onleft>
          <onright>3</onright>
          <onup>3</onup>
          <ondown>4</ondown>
          <label>Refresh</label>
        </control>
        <control>
          <description>text label</description>
          <type>label</type>
          <id>2</id>
          <posX>100</posX>
          <posY>240</posY>
          <label></label>
          <font>font16</font>
          <align>left</align>
          <textcolor>ffffffff</textcolor>
        </control>
        <control>
          <description>GuiList</description>
          <type>listcontrol</type>
          <id>4</id>
          <posX>100</posX>
          <posY>305</posY>
          <scrollOffset>2</scrollOffset>
          <font>font10</font>
          <align>left</align>
          <onleft>3</onleft>
          <onright>3</onright>
          <textcolor>ffffffff</textcolor>
          <unfocusedAlpha>160</unfocusedAlpha>
        </control>
      </controls>
    </window>
    Code:
    Imports System
    
    Imports System.Windows.Forms
    
    Imports MediaPortal.GUI.Library
    
    Imports MediaPortal.Dialogs
    
    
    
    Namespace MPtvApprove
    
    ' http://wiki.team-mediaportal.com/1_MEDIAPORTAL_1/18_Contribute/6_Plugins/Plugin_Developer's_Guide/1_Develop_a_Plugin/Visual_Basic
    
    Public Class TvApprove
    
    Inherits GUIWindow
    
    Implements ISetupForm
    
    <SkinControlAttribute(2)> Protected lblText As GUILabelControl = Nothing
    
    <SkinControlAttribute(3)> Protected buttonOne As GUIButtonControl = Nothing
    
    <SkinControlAttribute(4)> Protected myList As GUIListControl = Nothing
    
    Private _windowID As Integer = 10001
    
    Private errors As String = String.Empty
    
    ' With GetID it will be an window-plugin / otherwise a process-plugin
    
    ' Enter the id number here again
    
    Public Overrides Property GetID As Integer
    
    Get
    
    Return _windowID
    
    End Get
    
    Set(value As Integer)
    
    _windowID = value
    
    End Set
    
    End Property
    
    Public Overrides Function Init() As Boolean
    
    Dim result As Boolean = Load(GUIGraphicsContext.Skin + "\MPtvapprove.xml")
    
    Return result
    
    End Function
    
    Protected Overrides Sub OnPageLoad()
    
    GUIPropertyManager.SetProperty("#header.label", "TV Approve for Recording")
    
    myList.Clear()
    
    errors = String.Empty
    
    myList.SetTextOffsets(100, 0, 1090, 0, 1100, 0)
    
    myList.IconOffsetX = 0
    
    myList.IconOffsetY = 0
    
    myList.TypeOfList = GUIListControl.ListType.CONTROL_LIST
    
    myList.Space = 1
    
    For Each candidate As tvCandidate In getTitlesToApprove()
    
    myList.Add(candidate.toGuiListItem)
    
    Next
    
    errors += If(errors.Length > 0, "\n", "")
    
    lblText.Label = errors + "found:" + myList.Count.ToString + " records"
    
    MyBase.OnPageLoad()
    
    End Sub
    
    Public Sub New()
    
    MyBase.New
    
    End Sub
    
    Public Function PluginName() As String Implements ISetupForm.PluginName
    
    Return "TvApprove"
    
    End Function
    
    Public Function Description() As String Implements ISetupForm.Description
    
    Return "TvApprove - Approve selected TVshows for recording."
    
    End Function
    
    Public Function Author() As String Implements ISetupForm.Author
    
    Return "Guy Nash"
    
    End Function
    
    Public Sub ShowPlugin() Implements ISetupForm.ShowPlugin
    
    MessageBox.Show("Nothing to configure, this is just an example")
    
    End Sub
    
    Public Function CanEnable() As Boolean Implements ISetupForm.CanEnable
    
    Return True
    
    End Function
    
    ' Get Windows-ID
    
    Public Function GetWindowId() As Integer Implements ISetupForm.GetWindowId
    
    Return _windowID
    
    End Function
    
    Public Function DefaultEnabled() As Boolean Implements ISetupForm.DefaultEnabled
    
    Return True
    
    End Function
    
    Public Function HasSetup() As Boolean Implements ISetupForm.HasSetup
    
    Return False
    
    End Function
    
    ''' <summary>
    
    ''' If the plugin should have it's own button on the main menu of MediaPortal then it
    
    ''' should return true to this method, otherwise if it should not be on home
    
    ''' it should return false
    
    ''' </summary>
    
    ''' <param name="strButtonText">text the button should have</param>
    
    ''' <param name="strButtonImage">image for the button, or empty for default</param>
    
    ''' <param name="strButtonImageFocus">image for the button, or empty for default</param>
    
    ''' <param name="strPictureImage">subpicture for the button or empty for none</param>
    
    ''' <returns>true : plugin needs it's own button on home
    
    ''' false : plugin does not need it's own button on home</returns>
    
    Public Function GetHome(ByRef strButtonText As String, ByRef strButtonImage As String, ByRef strButtonImageFocus As String, ByRef strPictureImage As String) As Boolean Implements ISetupForm.GetHome
    
    strButtonText = PluginName()
    
    strButtonImage = "c:\\programdata\\team mediaportal\\mediaportal\\skin\\Titan\\Media\\hover_my tv.png"
    
    strButtonImageFocus = [String].Empty
    
    strPictureImage = [String].Empty
    
    Return True
    
    End Function
    
    Public Overrides Function OnMessage(ByVal message As GUIMessage) As Boolean
    
    Select Case message.Message
    
    Case GUIMessage.MessageType.GUI_MSG_CLICKED
    
    If message.SenderControlId = myList.GetID Then
    
    If CType(MediaPortal.GUI.Library.Action.ActionType.ACTION_SELECT_ITEM, Integer) = message.Param1 Then
    
    Dim item As GUIListItem = myList.SelectedListItem
    
    'MessageBox.Show("msg:" + item.IconImage)
    
    item.Selected = item.IconImage.ToLower.EndsWith("checkmark_unchecked.png")
    
    item.IconImage = If(item.Selected, "c:\\programdata\\Team MediaPortal\\MediaPortal\\skin\\Titan\\Media\\checkmark_checked.png", "c:\\programdata\\Team MediaPortal\\MediaPortal\\skin\\Titan\\Media\\checkmark_unchecked.png")
    
    Return True
    
    End If
    
    End If
    
    Case Else
    
    End Select
    
    Return MyBase.OnMessage(message)
    
    End Function
    
    Protected Overrides Sub OnClicked(ByVal controlId As Integer, ByVal control As GUIControl, ByVal actionType As MediaPortal.GUI.Library.Action.ActionType)
    
    Select Case controlId
    
    Case buttonOne.GetID
    
    OnButtonOne()
    
    Case myList.GetID
    
    Dim item As GUIListItem = myList.SelectedListItem
    
    'MessageBox.Show(item.IconImage)
    
    item.Selected = item.IconImage.ToLower.EndsWith("checkmark_unchecked.png")
    
    item.IconImage = If(item.Selected, "c:\\programdata\\Team MediaPortal\\MediaPortal\\skin\\Titan\\Media\\checkmark_checked.png", "c:\\programdata\\Team MediaPortal\\MediaPortal\\skin\\Titan\\Media\\checkmark_unchecked.png")
    
    Case Else
    
    End Select
    
    MyBase.OnClicked(controlId, control, actionType)
    
    End Sub
    
    Private Sub OnButtonOne()
    
    myList.Clear()
    
    myList.SetTextOffsets(100, 0, 1090, 0, 1100, 0)
    
    myList.IconOffsetX = 0
    
    myList.IconOffsetY = 0
    
    myList.Space = 1
    
    For Each candidate As tvCandidate In getTitlesToApprove()
    
    myList.Add(candidate.toGuiListItem)
    
    Next
    
    errors += If(errors.Length > 0, "\r", "")
    
    lblText.Label = errors + "found:" + myList.Count.ToString + " records"
    
    End Sub
    
    Function getTitlesToApprove() As List(Of tvCandidate)
    
    Dim result As List(Of tvCandidate) = New List(Of tvCandidate)
    
    errors = String.Empty
    
    Try
    
    Using c0 As SqlClient.SqlConnection = New SqlClient.SqlConnection("server=mediaportalserv;user id=xx;password=xxxxxxxx;database=mptvdb;")
    
    c0.Open()
    
    Using c1 As SqlClient.SqlCommand = New SqlClient.SqlCommand("select idprogram,series,episode,season,episodenumber,dbchannelid,channel,channeldisplayname,starttime,endtime from tvshowcandidates where starttime > getdate() order by starttime,series,channel desc", c0)
    
    Using c2 As SqlClient.SqlDataReader = c1.ExecuteReader
    
    If c2.HasRows Then
    
    While c2.Read
    
    result.Add(New tvCandidate(c2))
    
    End While
    
    End If
    
    End Using
    
    End Using
    
    c0.Close()
    
    End Using
    
    Catch ex As Exception
    
    Dim a As tvCandidate = New tvCandidate
    
    a.series = ex.Message
    
    result.Add(a)
    
    errors += "\r" + ex.Message
    
    End Try
    
    Return result
    
    End Function
    
    End Class
    
    End Namespace

    Code:
    Imports MediaPortal.GUI.Library
    
    Imports MediaPortal.Dialogs
    
    Public Class tvCandidate
    
    Public idprogram As Integer
    
    Public series As String
    
    Public episode As String
    
    Public season As String
    
    Public episodenumber As String
    
    Public dbchannelid As Integer
    
    Public channel As String
    
    Public channeldisplayname As String
    
    Public starttime As DateTime
    
    Public endtime As DateTime
    
    Public Sub New()
    
    End Sub
    
    Public Sub New(ByVal i() As Object)
    
    idprogram = i(0)
    
    series = i(1)
    
    episode = i(2)
    
    season = i(3)
    
    episodenumber = i(4)
    
    dbchannelid = i(5)
    
    channel = i(6)
    
    channeldisplayname = i(7)
    
    starttime = i(8)
    
    endtime = i(9)
    
    End Sub
    
    Public Sub New(ByVal i0 As Integer, ByVal i1 As String, ByVal i2 As String, ByVal i3 As String, ByVal i4 As String, ByVal i5 As Integer, ByVal i6 As String, ByVal i7 As String, ByVal i8 As DateTime, ByVal i9 As DateTime)
    
    Me.New({i0, i1, i2, i3, i4, i5, i6, i7, i8, i9})
    
    End Sub
    
    Public Sub New(ByVal sqlrdr As SqlClient.SqlDataReader)
    
    Dim i() As Object = {New Object, New Object, New Object, New Object, New Object, New Object, New Object, New Object, New Object, New Object, New Object}
    
    Dim mydefault() As Object = {-1, String.Empty, String.Empty, String.Empty, String.Empty, -1, String.Empty, String.Empty, Date.MinValue, Date.MinValue}
    
    For j = 0 To 9
    
    i(j) = getSQLvalue(sqlrdr, j, mydefault(j))
    
    Next
    
    idprogram = i(0)
    
    series = i(1)
    
    episode = i(2)
    
    season = i(3)
    
    episodenumber = i(4)
    
    dbchannelid = i(5)
    
    channel = i(6)
    
    channeldisplayname = i(7)
    
    starttime = i(8)
    
    endtime = i(9)
    
    End Sub
    
    Private Function getSQLvalue(ByVal r As SqlClient.SqlDataReader, ByVal c As Integer, ByVal empty As Object) As Object
    
    Dim result As Object = empty
    
    If r.IsDBNull(c) Then
    
    Else
    
    result = r.GetValue(c)
    
    End If
    
    Return result
    
    End Function
    
    Public Function toGuiListItem() As GUIListItem
    
    Dim result As GUIListItem = New GUIListItem(starttime.ToString("MM/dd/yyyy hh:mm tt"))
    
    result.Label += StrDup(6 - channel.Length, "_") + channel + " " + channeldisplayname
    
    result.IconImage = "c:\\programdata\\Team MediaPortal\\MediaPortal\\skin\\Titan\\Media\\checkmark_unchecked.png"
    
    result.Label2 = series
    
    result.Label3 = season + "." + episodenumber + " " + episode
    
    'AddHandler result.OnItemSelected, New GUIListItem.ItemSelectedHandler(AddressOf myOnItemselected)
    
    Return result
    
    End Function
    
    End Class
     
    Last edited:

    Users who are viewing this thread

    Top Bottom