Hello All,
I'm a complete newbie on the mediaportal platform so sorry in advance .
Now for my problem; I'm been building a small little plugin to basically read some information from an external system. I want the plugin to update every 5 minutes or so to refresh the data being read from the external system. I also want a clock displayed.
I've been using the tutorial/wiki thing about developing plugins for mediaportal. It was very usefull. My plugin is running and visible in mediaportal. The problem consists of two parts;
The list is declared as follows;
Now in the code part, I've declared it like this;
The strange thing is that with this code;
I see 5 items in the list when the plugin shows. So at this point, the listcontrol is accessible.
When I try and add an item on a button click like so;
No item is added. In the logs I can see that the label is not found and that it is retrieved. The the text is set but no update on the screen. Same for the list.
I have the following questions
1) Do I have to call some update method or something on the main control?
2) Is there a special timer control provided by mediaportal which i can use? I'm now using system.windows.forms.timer but that gives me problems accessing the controls as well.
Thanks for your replies!
Ok small update;
The list problem has been fixed. I'm now using a GUIFacadeControl with it's view property set to List. This works perfectly.
What remains is why the label is not updating when I set new text to it?
I'm a complete newbie on the mediaportal platform so sorry in advance .
Now for my problem; I'm been building a small little plugin to basically read some information from an external system. I want the plugin to update every 5 minutes or so to refresh the data being read from the external system. I also want a clock displayed.
I've been using the tutorial/wiki thing about developing plugins for mediaportal. It was very usefull. My plugin is running and visible in mediaportal. The problem consists of two parts;
- Update the list during a timer action. I've tried to do this on a button click but to no avail. The item isn't showing in the list.
- Update a lable during a timer action. This label is somehow 'not found' (= null) when in the event handler for the timer action.
The list is declared as follows;
Code:
<control>
<description>listcontrol</description>
<type>listcontrol</type>
<id>3</id>
<posX>50</posX>
<posY>80</posY>
<width>100</width>
<height>100</height>
<spinWidth>-</spinWidth>
<spinHeight>-</spinHeight>
<spinPosX>-</spinPosX>
<spinPosY>-</spinPosY>
<spinAlign>Left</spinAlign>
<spinCanFocus>yes</spinCanFocus>
<onleft>51</onleft>
<onright>51</onright>
<onup>2</onup>
<ondown>2</ondown>
<textcolor>ffffffff</textcolor>
<textureFocus>-</textureFocus>
<textureNoFocus>-</textureNoFocus>
<textureUp>-</textureUp>
<textureDown>-</textureDown>
<textureHeight>21</textureHeight>
<scrollbarbg>-</scrollbarbg>
<scrollbartop>-</scrollbartop>
<scrollbarbottom>-</scrollbarbottom>
</control>
Now in the code part, I've declared it like this;
HTML:
[SkinControlAttribute(3)]
protected GUIListControl listView = null;
The strange thing is that with this code;
Code:
protected override void OnPageLoad()
{
LogMessage("entering OnPageLoad()");
base.OnPageLoad();
try
{
LogMessage("showing wait cursor");
GUIWaitCursor.Show();
LogMessage("filling some test items");
listView.Clear();
int totalItems = 0;
for (int i = 0; i < 5; i++)
{
GUIListItem newItem = new GUIListItem();
newItem.Label = "Label #" + i.ToString();
listView.Add(newItem);
totalItems++;
}
LogMessage("Items loaded: " + totalItems);
LogMessage("hiding wait cursor");
}
catch (Exception ex)
{
LogError("Error occured while executing the OnPageLoad: ", ex);
}
GUIWaitCursor.Hide();
}
I see 5 items in the list when the plugin shows. So at this point, the listcontrol is accessible.
When I try and add an item on a button click like so;
Code:
protected override void OnClicked(int controlId, GUIControl control, MediaPortal.GUI.Library.Action.ActionType actionType)
{
base.OnClicked(controlId, control, actionType);
// catch button click
if (control == null)
{
LogMessage("The passed control is null");
}
if (control == btnRefresh)
{
LogMessage("btnRefresh was clicked");
if (listCaption == null)
{
LogMessage("listCaption label is null, trying to grab it");
listCaption = new GUILabelControl(GetID);
}
listCaption.Label = "Button clicked @ " + DateTime.Now.ToString();
if (listView == null)
{
LogMessage("listView is null, trying to grab it");
listView = new GUIListControl(GetID);
}
LogMessage("adding a new item");
GUIListItem item = new GUIListItem();
item.Label = "Button clicked @ " + DateTime.Now.ToString();
listView.Add(item);
}
}
No item is added. In the logs I can see that the label is not found and that it is retrieved. The the text is set but no update on the screen. Same for the list.
I have the following questions
1) Do I have to call some update method or something on the main control?
2) Is there a special timer control provided by mediaportal which i can use? I'm now using system.windows.forms.timer but that gives me problems accessing the controls as well.
Thanks for your replies!
Ok small update;
The list problem has been fixed. I'm now using a GUIFacadeControl with it's view property set to List. This works perfectly.
What remains is why the label is not updating when I set new text to it?