Main Site Documentation

Selecting file from a list


#1

Hi,
I can display a list of all files on the SD card using the following code:



        uint xpos = 100;
        uint ypos = 100;
        uint nextpic = 0;
        string[] fileList;

if (sdCard.IsCardInserted)
            {
                sdCard.MountSDCard();
                GT.StorageDevice sdStorage = sdCard.GetStorageDevice();
                fileList = sdStorage.ListRootDirectoryFiles();
                nextpic = 0;
                for (int i = 0; i < fileList.Length; i++)
                {
                    xpos = 3;
                    ypos = 3 + ((uint)nextpic * 20);
                    display.SimpleGraphics.DisplayText(fileList[i], Resources.GetFont(Resources.FontResources.NinaB), GT.Color.Blue, xpos, ypos);
                    nextpic = nextpic + 1;
                }
               }

But can I then select one of the files shown on the screen to open? E.g. show a list of all image files, and then tap on one of them to open up the image and display it on the screen?
Thanks for any help.


#2

You mean like in this video?
http://wiki.tinyclr.com/index.php?title=GHI_Graphical_Demo

Note that Glide does this better.


#3

With the SimpleGraphics it is pretty easy to display text on the screen.
But for using a list and click on items you should give Glide a try.

Try searching on the forums for Glide.

If you dont want to use Glide, you could store a list of points and on the clickevent of the display you could react on that.
But this is going to be really dirty, just try to use Glide or other Frameworks because they make such way more easy…


#4

Yeah - the bit at around 0:35, only when you tap on an image file it opens (I presume the setup in the video does that anyway).