GUI List Control (1 Viewer)

JestriK

Portal Member
August 10, 2006
7
0
Southsea, UK
Hello,

I am currently developing my first plugin for MP (a PDF ebook reader). I have read the "how to develop your first plugin" but that doesn't seem to help with this. I am trying to add a list control to my GUI which will load all the names of the ebooks into it - a similar layout to the my music plugin.

At the moment I am just trying to add an item to the list but it just doesn't show!

I'm initialising the list control with the following -
Code:
[SkinControlAttribute(21)]
        protected GUIListControl lstEbooks = null;

Then trying to add an item to it with the following -
Code:
lstEbooks.Add(new GUIListItem("A new item!"));

This the part in my XML file that declares the facade view (borrowed this from the My Music plugin) -
Code:
		<control>
			<type>group</type>
			<description>group element</description>
			<animation>FlyInFromTop</animation>
			<posX>120</posX>
			<posY>97</posY>
			<width>50</width>
			<height>60</height>
			<control>
				<description>composite control consisting of a list control and a thumbnail panel</description>
				<type>facadeview</type>
				<id>20</id>
				<control>
					<description>listcontrol</description>
					<type>listcontrol</type>
					<id>21</id>
					<width>50</width>
					<height>60</height>
					<onleft>2</onleft>
					<onright>51</onright>
					<onup>2</onup>
					<ondown>2</ondown>
					<textcolor>FFFFFFFF</textcolor>
				</control>
				<control>
					<description>Thumbnail Panel</description>
					<type>thumbnailpanel</type>
					<id>22</id>
					<onleft>2</onleft>
					<onright>52</onright>
					<onup>2</onup>
					<ondown>2</ondown>
				</control>
			</control>

Any help would be greatly appreciated!

Cheers,
JestriK
 

JestriK

Portal Member
August 10, 2006
7
0
Southsea, UK
Just to make it clearer, this is what i can see on my screen -

myebooksfm5.jpg
 

JestriK

Portal Member
August 10, 2006
7
0
Southsea, UK
OK, since my last post have figured out what I was doing wrong - I should be using a GUIFacadeControl.

Now I've got that sorted that out, I have the code below.

Code:
private void LoadList(string currentDirectory)
{
  ArrayList arry = new ArrayList();
  arry.Add(".pdf");
  virtualDirectory.SetExtensions(arry);

  List<GUIListItem> items = virtualDirectory.GetDirectoryExt(currentDirectory);

  facadeView.Clear();

  for (int i = 0; items.Count > i; i++)
    facadeView.Add(items[0]);
}

When it gets to adding the items to the facade control it throws the following exception -

Code:
OnMessage exception:System.DivideByZeroException: Attempted to divide by zero.
   at MediaPortal.GUI.Library.GUIListControl.Add(GUIListItem item)
   at MediaPortal.GUI.Library.GUIFacadeControl.Add(GUIListItem item)
   at MediaPortal.GUI.Library.GUIFacadeControl.OnMessage(GUIMessage message)
   at MediaPortal.GUI.Library.GUIWindow.OnMessage(GUIMessage message)

Can anyone see what I'm doing wrong, because I'm stumped!

Cheers,
JestriK
 

JestriK

Portal Member
August 10, 2006
7
0
Southsea, UK
I have now fixed this too, it seems there was something wrong with my XML file, I rewrote it and it now seems to work

Sorry for all the posts!

Cheers,
Jes_triK
 

mbuzina

Retired Team Member
  • Premium Supporter
  • April 11, 2005
    2,839
    726
    Germany
    Home Country
    Germany Germany
    Don't say sorry (sorry nobody answered!). It is good to show what pitfalls there are for developing.
     

    dukus

    Portal Pro
    January 20, 2006
    783
    748
    44
    Home Country
    Romania Romania
    Try someting like :
    Code:
    private void LoadList(string currentDirectory)
    {
      ArrayList arry = new ArrayList();
      arry.Add(".pdf");
      virtualDirectory.SetExtensions(arry);
    
      List<GUIListItem> items = virtualDirectory.GetDirectoryExt(currentDirectory);
    
      facadeView.Clear();
    
      for (int i = 0; items.Count= > i; i++)
        facadeView.Add(items[i]);
    }
     

    Users who are viewing this thread

    Top Bottom