Author Topic: New Paged list related features  (Read 6102 times)

John Hughes

  • Administrator
  • Hero Member
  • *****
  • Posts: 2852
    • View Profile
    • Codecore Technologies
New Paged list related features
« on: May 30, 2012, 06:46:53 pm »
If you haven't taken a look already, I highly recommend you review the paged list related enhancements in the features thread here.

This is a new feature that I am quite pleased with and I think you will be too. :)
John Hughes
Codecore Technologies

bpwwer

  • Full Member
  • ***
  • Posts: 220
    • View Profile
Re: New Paged list related features
« Reply #1 on: June 07, 2012, 01:43:52 pm »
John,

I've been playing around with the ScriptPagedListCollection and ScriptExpandoObject ab it and it's working well.  The more I play with it, the more I want it to do :) For example, I created a ScriptExpandoObject with a couple of properties - A string ID, an image, and a image index.   In the paged list control's Item Pressed event  I can do something like:

Code: [Select]
TouchScreen.Icon.BackgroundImageLocation = "DEVICEIMAGE://<driver>/IconList/this.SelectedValue.imageIndex

And the control named Icon will get its background image appropriately when each item of the paged list is selected.

I see that the paged list control has attributes for "Item Background", "Selected Item Background" and "Pressed Item Background"  Can these be set in a script?  I'd like to be able to use the image I added to the ExpandoObject as the Item Background when I load the control and then be able to either change it or modify it when pressed/selected.

This is probably a separate feature request, but I'd like to be able to use a ScriptImage directly.  Using my above code:

Code: [Select]
TouchScreen.Icon.BackgroundImage = this.SelectedValue.image;

I'm basically trying to make use of the images that are provided dynamically by the device/driver instead of having them embedded in the touch screen itself.

John Hughes

  • Administrator
  • Hero Member
  • *****
  • Posts: 2852
    • View Profile
    • Codecore Technologies
New Paged list related features
« Reply #2 on: June 07, 2012, 02:02:44 pm »
In theory you could do all that but I would not recommend it. The reason is that paged list binding uses a lot of bandwidth. The entire object is serial educating the binary serializer.  You should do a test using ScriptObject.Serialize(yourObjectHere) to see how big the resulting byte array is. This data is transmitted every 60 seconds as wll as each time the devicepropertynotification method is called.

I'll look into your other property requests.

Ps: I'm also adding a list item filter to the control so you may filter out list items based on certain criteria.
« Last Edit: June 07, 2012, 03:33:28 pm by John Hughes »
John Hughes
Codecore Technologies

bpwwer

  • Full Member
  • ***
  • Posts: 220
    • View Profile
Re: New Paged list related features
« Reply #3 on: June 07, 2012, 04:20:16 pm »
Hmm, the paged list collection is big, with the image data it's about 434K.  However, it looks like it would use less bandwidth than what I'm doing now.

The image data is loaded into the driver when it queries the device. It's not static, it's not a fixed number of images, and each time I query, I could get a different set if images.  The driver builds a ScriptArray of ScriptImage.  With this configuration the array ends up being about 424K.   Using

Code: [Select]
control.BackgroundImageLocation = "DEVICEIMAGE://<driver>/imagelist/<array_index>"

seems to be the only way I can get those images displayed on a touch screen.   If I change a control's background image every time a new item is selected from the page list, it gets the array (all 424K of it).   The 434K page list is only fetched once every 60 seconds.  So if the user interaction happens more than once every minute, the existing method would use more bandwidth than being able to use the image data directly embedded in  the paged list control.

Just thinking out loud, would creating a dynamic driver property for the image data be a better solution?  I seem to recall that dynamic properties are supported.  If so, then maybe something like:
Code: [Select]
control.BackgroundImageLocation = "DEVICEIMAGE://<driver>/<image_name>";

where <image_name> is just a string property of the ExpandoObject.


bpwwer

  • Full Member
  • ***
  • Posts: 220
    • View Profile
Re: New Paged list related features
« Reply #4 on: June 07, 2012, 06:00:57 pm »
Using dynamic properties works quite well, why didn't I think of that earlier.

My end goal is to have a dynamic image based paged list control.    The flow should be something like this:

  • Enter touch screen
  • Ask driver to get current info
  • Driver updates the paged list collection with current info
  • Touch screen displays paged list of images (buttons)
  • User selects button from list (paging as necessary)

The key here is that when the driver queries the device for current info, it could, in theory, get a completely new set of images (and other info) from what was returned from the previous query.

It's pretty close to being able to do this today.  I think all that's missing is the ability to set the item background for each item in the paged control collection.  Would it make sense to be able to do something like this:
Code: [Select]
[ScriptObjectPropertyAttribute("My Paged List", "A paged list")]
[SupportsDriverPropertyBinding]
public ScriptPagedListCollection MyPagedList
{
    get
    {
        var list = new List<ScriptPagedListItem>();

        foreach (string item in itemList)
        {
            ScriptPagedListItem pgList = new ScriptPagedListItem()
            pgList.title = item;
            pgList.subtitle = "";
            pgList.itemBackgroundLocation = "DEVICEIMAGE://driver/item";
            pgList.itemPressedLocation = "";
            pgList.itemSelectedLocation = "";
           
            ScriptExpandoObject value = new ScriptExpandoObject();
            value.SetProperty("index", new ScriptNumber(item_index[item]));

            pgList.value = value;
            list.Add(pgList)
        }
    return new ScriptPagedListCollection(list);
}

John Hughes

  • Administrator
  • Hero Member
  • *****
  • Posts: 2852
    • View Profile
    • Codecore Technologies
Re: New Paged list related features
« Reply #5 on: June 08, 2012, 01:08:09 pm »
Wow, that's a huge amount of data to be sending and resending.  That could cause a performance issue as well.

As you know the Page List control supports an unselected item image, a selected item image, and a full control background image... but it does not support displaying specific images per item.

I think you best approach at this time if you really want to show a different image for each item is (as I believe you alluded to) to add a label control or image list control behind each item and dynamically update them. This is similar to how I use the paged list control with the forecast however the images in the image list do not change.
John Hughes
Codecore Technologies

bpwwer

  • Full Member
  • ***
  • Posts: 220
    • View Profile
Re: New Paged list related features
« Reply #6 on: June 08, 2012, 02:32:56 pm »
Wow, that's a huge amount of data to be sending and resending.  That could cause a performance issue as well.
Yeah, using dynamic properties for the images seems to solve this particular problem.   I can use "DEVICEIMAGE://<driver>/<name>" where name is the image name and this is working great.
 
Quote
As you know the Page List control supports an unselected item image, a selected item image, and a full control background image... but it does not support displaying specific images per item.

Ah, I had assumed that because they had "item" in the name, that they were per item so thanks for clarifying that.  Now that I've played with them a bit, I understand how they were meant to be used.

Quote
I think you best approach at this time if you really want to show a different image for each item is (as I believe you alluded to) to add a label control or image list control behind each item and dynamically update them. This is similar to how I use the paged list control with the forecast however the images in the image list do not change.
Ok, makes sense.  I can sort of make this work.  The problem now is how do I know which images to display?  I can get the initial page to display OK using SelectNext(), but once the user starts paging, I can't keep it in sync.   I think I need to know which item is the first item displayed and a way to get the information for each item by index.

bpwwer

  • Full Member
  • ***
  • Posts: 220
    • View Profile
Re: New Paged list related features
« Reply #7 on: June 09, 2012, 08:27:19 am »
I'm getting closer to making it work.  I realized that you can set the control's SelectedIndex  and then access the other Selected properties to get an items information.  I now have some crazy scripts that try to keep track of what index is at the top and update the images from the correct items.

One major problem is that as soon as I try to page this list, I get it stuck in an infinite loop.  It seems like something other than the page down button press is causing "Page Changed" events so they just keep coming.

On a "Page Changed" event I update the images by basically:
Code: [Select]
this.BeginUpdate();
first = touchscreen_variable_top_index;

this.SelectedIndex = first;
touchscreen.image1.backgroundlocation = "DEVICEIMAGE://<driver>/" + this.SelectedTitle;
first = first + 1;

if ( first < this.Count ) {
    update next image
} else {
    clear next image
}
first = first + 1;

// Repeat above block for each image

this.SelectedIndex = touchscreen_variable_top_index;

this.EndUpdate();

Something in the above seems to trigger the Page Changed event, but it doesn't seem like anything should.

John Hughes

  • Administrator
  • Hero Member
  • *****
  • Posts: 2852
    • View Profile
    • Codecore Technologies
Re: New Paged list related features
« Reply #8 on: June 09, 2012, 09:02:44 pm »
I added a new "FirstVisibleIndex" property to the control that you can get.

I haven't run your script but I don't see anything that would cause the page changed event to occur except when the first visible index changes.
John Hughes
Codecore Technologies

bpwwer

  • Full Member
  • ***
  • Posts: 220
    • View Profile
Re: New Paged list related features
« Reply #9 on: June 10, 2012, 09:40:59 am »
I added a new "FirstVisibleIndex" property to the control that you can get.
Thanks!  That will make things easier.

I think I figured out what's going on. You're hint about the first visible index changing pointed me in the right direction.  In pseudo code the flow looks something like this:

Code: [Select]
On control loaded
     set index = 0
     assign background of image 1 based on selected title

     set index = 1
     assign background of image 2 based on selected title

     // Do this for the next 5 indexes.

     set index = 0  // I'd like to not have an index selected here, but using -1 doesn't seem to work
     Set local_start_index = 0
     exit On control loaded


On down button press
    set local_start_index = local_start_index + 7
    if local_start_index > pglist.Count
           local_start_index = 0
    exit On down button press

On Paged event
    // selected index  = 8 at this point.  Why, it should = 7
    // I update the images based on local_start_index and then
    selected index = local_start_index  // I think this triggers the Paged Event again!

Looks like you have to make the size of the PagedList control exact.  I think I had 1 or 2 pixels of the 8th item showing and that's what caused it all. would it make sense to have a property that reports the number of visible items?  And should an item only be considered visible of some percentage of it is is visible?

bpwwer

  • Full Member
  • ***
  • Posts: 220
    • View Profile
Re: New Paged list related features
« Reply #10 on: June 11, 2012, 08:07:09 pm »
I though it might be nice to show the results of what I've been trying to do.



This isn't final, it's still a work in progress as I tweak the driver and the screen so that they work together correctly.

The gray/blue round buttons are the normal/selected images for the paged list.  Right now I'm using the paged list item title to get the rectangular logo image from the driver, that's why you see some of the titles showing up over the buttons. I'll have to change the driver to put the title in the expando object and set the titles to an empty string.

I'm curious, what would it take to have a paged list control that worked horizontally instead of vertically?  Then, the follow on would be can gestures be added so that something like cover flow can be implemented?


John Hughes

  • Administrator
  • Hero Member
  • *****
  • Posts: 2852
    • View Profile
    • Codecore Technologies
Re: New Paged list related features
« Reply #11 on: June 14, 2012, 12:52:47 pm »
Bob, I don't see an screenshot attached to your post.

Quote
I'm curious, what would it take to have a paged list control that worked horizontally instead of vertically?
Are you looking for a single row with multiple columns?

Quote
Then, the follow on would be can gestures be added so that something like cover flow can be implemented?
Gestures are something I would like to see although I am not looking forward to implementing them on all the different devices so it may not make it in version 2.0.
John Hughes
Codecore Technologies

bpwwer

  • Full Member
  • ***
  • Posts: 220
    • View Profile
Re: New Paged list related features
« Reply #12 on: June 14, 2012, 04:05:58 pm »
Bob, I don't see an screenshot attached to your post.
You're too late :)  The image is on my home web server which went down sometime after 12 today.  I won't be able to debug it until I get home later tonight.

Quote
Quote
I'm curious, what would it take to have a paged list control that worked horizontally instead of vertically?
Are you looking for a single row with multiple columns?
Yes, single row, with multiple columns.   Although a grid could be useful too.