NextPVR Forums
  • ______
  • Home
  • New Posts
  • Wiki
  • Members
  • Help
  • Search
  • Register
  • Login
  • Home
  • Wiki
  • Members
  • Help
  • Search
NextPVR Forums Public Developers v
« Previous 1 … 19 20 21 22 23 … 93 Next »
Numeric args[]

 
  • 0 Vote(s) - 0 Average
Numeric args[]
mvallevand
Online

Posting Freak

Ontario Canada
Posts: 52,767
Threads: 954
Joined: May 2006
#1
2010-07-29, 11:48 PM
I am trying to change the location and size of a field using my own placement but I can't recall how, I was able to populate the tvguide before but I've lost the test code

I have in the skin location="@locX,@locY" size="@sizeX,@sizeY"

I've tried with

args["@locX"] = "0.0m";
args["@locX"] = 0.0m;

and d and f and capitals etc and I'm forgetting something.

Martin
sub
Offline

Administrator

NextPVR HQ, New Zealand
Posts: 106,626
Threads: 767
Joined: Nov 2003
#2
2010-07-30, 12:10 AM
You cant really do it that way, instead you typically adjust the Location attribute of the control. For example,

myUiButtonControl.Location = new RectangleF(locX, locY, width, height);
mvallevand
Online

Posting Freak

Ontario Canada
Posts: 52,767
Threads: 954
Joined: May 2006
#3
2010-07-30, 12:22 AM
sub Wrote:You cant really do it that way, instead you typically adjust the Location attribute of the control. For example,

myUiButtonControl.Location = new RectangleF(locX, locY, width, height);

Great so if I use something like this to get the value

<!-- placements -->
<Placements>
<Placement name="CoversItemNowPlayingArt" location="x,y" size="x,y"/>
<Placement name="ListItemNowPlayingArt" location="x,y" size="x,y"/>
</Placements>

I can use this to change the Location when I changes from list to cover mode. This is static not meta data.

Martin
mvallevand
Online

Posting Freak

Ontario Canada
Posts: 52,767
Threads: 954
Joined: May 2006
#4
2010-07-30, 03:21 AM
This works nicely, but I was was wondering if anyone wants to critique they way I do this, it it pretty new to me.

Code:
XmlNode xn = null;
    if (uiList.GetViewMode() == UiList.ViewMode.COVERS)
    {
        uiList.SetViewMode(UiList.ViewMode.LIST);
        xn = skinHelper.GetBackingDocument().SelectSingleNode("/Skin/Placements/Placement[@name='ListItemNowPlayingArt']");
    }
    else
    {
        uiList.SetViewMode(UiList.ViewMode.COVERS);
        xn = skinHelper.GetBackingDocument().SelectSingleNode("/Skin/Placements/Placement[@name='CoversItemNowPlayingArt']");
    }
    if (xn != null)
    {
        string[] locations = xn.Attributes["location"].InnerText.Split(',');
        string[] sizes = xn.Attributes["size"].InnerText.Split(',');
        nowPlayingUiStatic.Location = new RectangleF(float.Parse(locations[0]), float.Parse(locations[1]), float.Parse(sizes[0]), float.Parse(sizes[1]));
    }

Martin
whurlston
Offline

Posting Freak

Posts: 7,885
Threads: 102
Joined: Nov 2006
#5
2010-07-30, 03:41 AM
Looks fine to me. The only thing you might want to do differently is change the last line to:

Code:
// Set default values (use any values you want).
float locationX = 0;
float locationY = 0;
float sizeW = 0;
float sizeH = 0;

// Try to parse the skin values.
float.TryParse(locations[0], out locationX);
float.TryParse(locations[1], out locationY);
float.TryParse(sizes[0], out sizeW);
float.TryParse(sizes[1], out sizeH);

// Now create the rectangle.
nowPlayingUiStatic.Location = new RectangleF(locationX, locationY, sizeW, sizeH);
This way, you don't get an error thrown if there is a strange value in the skin and float.Parse() fails. Of course, you could always use a try/catch statement instead.
sub
Offline

Administrator

NextPVR HQ, New Zealand
Posts: 106,626
Threads: 767
Joined: Nov 2003
#6
2010-07-30, 03:49 AM
One thing to be aware of, you should do this to parse a float:

float.Parse(locationX, System.Globalization.NumberFormatInfo.InvariantInfo);

Otherwise you'll find problems in some European countries that use commas instead of decimal point.
mvallevand
Online

Posting Freak

Ontario Canada
Posts: 52,767
Threads: 954
Joined: May 2006
#7
2010-07-30, 03:50 AM
whurlston Wrote:This way, you don't get an error thrown if there is a strange value in the skin and float.Parse() fails. Of course, you could always use a try/catch statement instead.

Thanks whurlston, I sort of stumble along learning the skinning stuff and I like help from people who know more than me. In this case I actually did want skinners to fix their Placements (or not use them at all), and I think not having catch is a good way, especially while NPVR is in beta. This would still fail for other skin issues.

Martin
mvallevand
Online

Posting Freak

Ontario Canada
Posts: 52,767
Threads: 954
Joined: May 2006
#8
2010-07-30, 03:52 AM
sub Wrote:One thing to be aware of, you should do this to parse a float:

float.Parse(locationX, System.Globalization.NumberFormatInfo.InvariantInfo);

Otherwise you'll find problems in some European countries that use commas instead of decimal point.

Excellent info. Does this mean that skins where skinners use periods will fail in those countries?

Martin
whurlston
Offline

Posting Freak

Posts: 7,885
Threads: 102
Joined: Nov 2006
#9
2010-07-30, 04:05 AM
Yeah, I was just pointing it out. I probably wouldn't bother with the checks myself. Out of curiosity though, if you're not manipulating the values, why are you even bothering with the location/size elements? If you just need to render it, why not just use a UIStatic?

Code:
public override List<UiElement> GetRenderList()
        {
            string node = "ItemNowPlayingArt";
            if (uiList.GetViewMode() == UiList.ViewMode.List) node = "List" + node;
            else node = "Covers" + node;

            Hashtable args= new Hashtable();
            args.Add("@nowPlayingImage", nowPlayingImage);
            args.Add("@nowPlayingText", "Some text");

            UIStatic staticNowPlaying = new UiStatic(node, args, this.GetSkinHelper());

            List<UiElement> renderList = base.GetRenderList();
            renderList.InsertRange(0, staticNowPlaying.GetRenderList());
            return renderList;
        }

(Just an example, I actually create my UIStatics outside the GetRenderList statement and just use the last three lines to insert them there. This way, they are not getting created every time GetRenderList is called.)
mvallevand
Online

Posting Freak

Ontario Canada
Posts: 52,767
Threads: 954
Joined: May 2006
#10
2010-07-30, 04:11 AM
The skin is manipulating them

Code:
    <!-- placements -->
    <Placements>
        <Placement name="CoversItemNowPlayingArt" location="0,5" size="40,45"/>
        <Placement name="ListItemNowPlayingArt" location="36,45" size="40,40"/>
    </Placements>


Martin
« Next Oldest | Next Newest »

Users browsing this thread: 1 Guest(s)

Pages (2): 1 2 Next »


Possibly Related Threads…
Thread Author Replies Views Last Post
  PluginHelper.SetPlayerMetaData(Hashtable args) not working alibert 12 4,575 2011-01-23, 05:33 PM
Last Post: sub

  • View a Printable Version
  • Subscribe to this thread
Forum Jump:

© Designed by D&D, modified by NextPVR - Powered by MyBB

Linear Mode
Threaded Mode