Is this possible with Skin Expressions? (1 Viewer)

mbuzina

Retired Team Member
  • Premium Supporter
  • April 11, 2005
    2,839
    726
    Germany
    Home Country
    Germany Germany
    Hi,

    I would like to set the posY of a control depending on some properties. So I cooked up the following Expression:
    #(switch(string.equals(#latestMediaHandler.tvrecordings.active1.title,),925,string.equals(#latestMediaHandler.tvrecordings.active2.title,),961,string.equals(#latestMediaHandler.tvrecordings.active3.title,),997))

    but it does not work. When I put that into a lable I get: "System.InvalidCastException @ MediaPortal.GUI.Library.GUIFunctions.Switch(Object[] args)"

    I also tried to use '' instead of the empty string without success.
     

    Marduk65

    Portal Pro
    November 28, 2011
    190
    244
    59
    Home Country
    Italy Italy
    ...I am not a very experienced skinner, but I don't think it is necessary a so "complicated and sofisticated expression" (more complicated=more possible problems ;) ); I think it could be done simply duplicating 3 times the control (with the different PosY you need) and setting the proper visible condition for each one to have only the needed one displayed for each condition. In this way it should be more simple to check what is wrong with each visible condition
     

    mbuzina

    Retired Team Member
  • Premium Supporter
  • April 11, 2005
    2,839
    726
    Germany
    Home Country
    Germany Germany
    I know that would work, but I am completely opinioned to the contrary: Duplication of functionality is the root of a lot of legacy bugs. Check the MP code, everyone copied & pasted parts of code from one end to the other. Now the original is update for new functionality and the old code produces bugs no end. Re-useability is key here.

    I would prefer to have a group control with layout table and tell it to only show the first 3 visible rows, but that is not possible as well.
     

    Marduk65

    Portal Pro
    November 28, 2011
    190
    244
    59
    Home Country
    Italy Italy
    ...okay, absolutely nothing to say against your opinion, also if I don't think that my (very very very) little suggestion can be defined as a "duplication of functionality" (...ultimately only a few extra lines into the xml :) ); for Re-usability, I think all problems can be overcome just with a sufficiently clear description for each control (something like "label (or image or everything you want) x visible on condition y")

    Ciao
     

    ncoH

    Retired Team Member
  • Premium Supporter
  • January 27, 2007
    925
    1,569
    Hannover
    Home Country
    Germany Germany
    Hi,

    I would like to set the posY of a control depending on some properties. So I cooked up the following Expression:
    #(switch(string.equals(#latestMediaHandler.tvrecordings.active1.title,),925,string.equals(#latestMediaHandler.tvrecordings.active2.title,),961,string.equals(#latestMediaHandler.tvrecordings.active3.title,),997))

    but it does not work. When I put that into a lable I get: "System.InvalidCastException @ MediaPortal.GUI.Library.GUIFunctions.Switch(Object[] args)"

    I also tried to use '' instead of the empty string without success.

    Hi,

    you can try "eq" instead of "string.equals".

    Or use "iif" with a <define>.

    Something like (not tested):

    Code:
    <define>#skin.activerecordings.posy:#(iif(eq(#latestMediaHandler.tvrecordings.active1.title,''),'925',iif(eq(#latestMediaHandler.tvrecordings.active2.title,''),'961','997')))</define>

    #skin.activerecordings.posy is the <posY> property then.
     

    Users who are viewing this thread

    Top Bottom