home
products
contribute
download
documentation
forum
Home
Forums
New posts
Search forums
What's new
New posts
All posts
Latest activity
Members
Registered members
Current visitors
Donate
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Search titles only
By:
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
MediaPortal 1
Development
General Development (no feature request here!)
Update List during timer action
Contact us
RSS
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="MrMosin" data-source="post: 389115" data-attributes="member: 89447"><p>Hello All,</p><p></p><p>I'm a complete newbie on the mediaportal platform so sorry in advance <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite8" alt=":D" title="Big Grin :D" loading="lazy" data-shortname=":D" />.</p><p></p><p>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.</p><p></p><p>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;</p><ol> <li data-xf-list-type="ol">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.</li> <li data-xf-list-type="ol">Update a lable during a timer action. This label is somehow 'not found' (= null) when in the event handler for the timer action.</li> </ol><p></p><p>The list is declared as follows;</p><p>[CODE]<control></p><p> <description>listcontrol</description></p><p> <type>listcontrol</type></p><p> <id>3</id></p><p> <posX>50</posX></p><p> <posY>80</posY></p><p> <width>100</width></p><p> <height>100</height></p><p> <spinWidth>-</spinWidth></p><p> <spinHeight>-</spinHeight></p><p> <spinPosX>-</spinPosX></p><p> <spinPosY>-</spinPosY></p><p> <spinAlign>Left</spinAlign></p><p> <spinCanFocus>yes</spinCanFocus></p><p> <onleft>51</onleft></p><p> <onright>51</onright></p><p> <onup>2</onup></p><p> <ondown>2</ondown></p><p> <textcolor>ffffffff</textcolor></p><p> <textureFocus>-</textureFocus></p><p> <textureNoFocus>-</textureNoFocus></p><p> <textureUp>-</textureUp></p><p> <textureDown>-</textureDown></p><p> <textureHeight>21</textureHeight></p><p> <scrollbarbg>-</scrollbarbg></p><p> <scrollbartop>-</scrollbartop></p><p> <scrollbarbottom>-</scrollbarbottom></p><p> </control>[/CODE]</p><p></p><p>Now in the code part, I've declared it like this;</p><p>[HTML][SkinControlAttribute(3)]</p><p> protected GUIListControl listView = null;[/HTML]</p><p></p><p>The strange thing is that with this code;</p><p>[CODE]protected override void OnPageLoad()</p><p> {</p><p> LogMessage("entering OnPageLoad()");</p><p> base.OnPageLoad();</p><p></p><p> try</p><p> {</p><p> LogMessage("showing wait cursor");</p><p> GUIWaitCursor.Show();</p><p></p><p> LogMessage("filling some test items");</p><p> listView.Clear();</p><p> int totalItems = 0;</p><p> for (int i = 0; i < 5; i++)</p><p> {</p><p> GUIListItem newItem = new GUIListItem();</p><p> newItem.Label = "Label #" + i.ToString();</p><p> listView.Add(newItem);</p><p> totalItems++;</p><p> }</p><p> LogMessage("Items loaded: " + totalItems);</p><p></p><p> LogMessage("hiding wait cursor");</p><p> }</p><p> catch (Exception ex)</p><p> {</p><p> LogError("Error occured while executing the OnPageLoad: ", ex);</p><p> }</p><p> GUIWaitCursor.Hide();</p><p> }[/CODE]</p><p></p><p>I see 5 items in the list when the plugin shows. So at this point, the listcontrol is accessible.</p><p></p><p>When I try and add an item on a button click like so;</p><p>[CODE]protected override void OnClicked(int controlId, GUIControl control, MediaPortal.GUI.Library.Action.ActionType actionType)</p><p> {</p><p> base.OnClicked(controlId, control, actionType);</p><p></p><p> // catch button click</p><p> if (control == null)</p><p> {</p><p> LogMessage("The passed control is null");</p><p> }</p><p> if (control == btnRefresh)</p><p> {</p><p> LogMessage("btnRefresh was clicked");</p><p> if (listCaption == null)</p><p> {</p><p> LogMessage("listCaption label is null, trying to grab it");</p><p> listCaption = new GUILabelControl(GetID);</p><p> }</p><p></p><p> listCaption.Label = "Button clicked @ " + DateTime.Now.ToString();</p><p></p><p> if (listView == null)</p><p> {</p><p> LogMessage("listView is null, trying to grab it");</p><p> listView = new GUIListControl(GetID);</p><p> }</p><p></p><p> LogMessage("adding a new item");</p><p> GUIListItem item = new GUIListItem();</p><p> item.Label = "Button clicked @ " + DateTime.Now.ToString();</p><p> listView.Add(item);</p><p> }</p><p></p><p> }[/CODE]</p><p></p><p>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.</p><p></p><p>I have the following questions</p><p>1) Do I have to call some update method or something on the main control?</p><p>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. </p><p></p><p>Thanks for your replies!</p><p></p><p>Ok small update;</p><p></p><p>The list problem has been fixed. I'm now using a GUIFacadeControl with it's view property set to List. This works perfectly.</p><p></p><p>What remains is why the label is not updating when I set new text to it?</p></blockquote><p></p>
[QUOTE="MrMosin, post: 389115, member: 89447"] Hello All, I'm a complete newbie on the mediaportal platform so sorry in advance :D. 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; [LIST=1] [*]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. [/LIST] 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>[/CODE] Now in the code part, I've declared it like this; [HTML][SkinControlAttribute(3)] protected GUIListControl listView = null;[/HTML] 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(); }[/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; [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); } }[/CODE] 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? [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
MediaPortal 1
Development
General Development (no feature request here!)
Update List during timer action
Contact us
RSS
Top
Bottom