- April 27, 2009
- 778
- 333
- 32
- Home Country
- Netherlands
Hello,
I have made a plugin to retrieve a list of devices (lamps) in my home from a server, so I can turn them on / off. The plugin works, I can do what I want, but I only have to do some small improvements.
Now, I am refreshing the list of devices every x seconds, so the list gets updated so I can see which devices are on and off. (I use the item.IsPlayed for that, is that okay?). I have made this function for that:
Bad thing about is that when you are not at the top of the list, the cursor jumps back to top after the list has refreshed. So I have to refresh the list without readding the items. How is that possible?
I thought about something like this:
But unfortunately it's not working.. (Well yeah, I don't really understand how the GuiList works )
Please, help me
I have made a plugin to retrieve a list of devices (lamps) in my home from a server, so I can turn them on / off. The plugin works, I can do what I want, but I only have to do some small improvements.
Now, I am refreshing the list of devices every x seconds, so the list gets updated so I can see which devices are on and off. (I use the item.IsPlayed for that, is that okay?). I have made this function for that:
Code:
private void ListDevices()
{
GuiList.Clear();
try
{
foreach (device d in devicesList.Values)
{
GUIListItem item = new GUIListItem();
item.OnItemSelected += new MediaPortal.GUI.Library.GUIListItem.ItemSelectedHandler(listSelectDevice);
item.Label = d.name;
item.Label2 = d.type;
item.ItemId = d.id;
item.IsPlayed = d.status;
GuiList.Add(item);
}
GUIPropertyManager.SetProperty("#itemcount", GuiList.Count.ToString());
Log.Info("HCB: Devices listed");
//set active type
setActive(HCB.type.device);
}
catch
{
GUIPropertyManager.SetProperty("#hcb.status", "Listing devices failed!");
}
}
Bad thing about is that when you are not at the top of the list, the cursor jumps back to top after the list has refreshed. So I have to refresh the list without readding the items. How is that possible?
I thought about something like this:
Code:
private void RefreshDevices()
{
foreach (device d in devicesList.Values)
{
GUIListItem item = new GUIListItem();
item.OnItemSelected += new MediaPortal.GUI.Library.GUIListItem.ItemSelectedHandler(listSelectDevice);
item.Label = d.name;
item.Label2 = d.type;
item.ItemId = d.id;
item.IsPlayed = d.status;
}
GuiList.DoUpdate();
Log.Info("HCB: Devices refreshed");
GuiList.ReStorePosition();
}
Please, help me
Last edited: