views:

1346

answers:

2

I have a network directory that has a dump of all employee pics here at our company. The images are named FirstnameLastinitial.jpg. I ultimately am trying to build a photo browser of these pics in Silverlight but I thought I would start with how to harvest the Pictures from that location.

I would imagine that I should generate an XML file based off the pictures in that folder or maybe I should be using a DB. Then I could use, maybe, the Wall3D control in Blend to Display them. That would only be one possible way to display them.

If I create a shell of an XML, like below, can I also then allow my app to modify the XML after generation?

  <Photo>
<URL>Images/img10.jpg</URL>
<ImageName>Test 2</ImageName>
<ImageDescription>This is a picture of someone</ImageDescription>
 </Photo>

Another thought that occured to me. Is Silverlight even capable of reading images from a location or do they have to be included in the XAP? What if I used RIA services to, somehow, feed the images to my Silverlight app?

Has anyone attempted something similar? I know what I WANT to do but I will admit this is all very new ground to me and as such I would appreciate any pointers, guidance, insight or if nothing else links to help point me in the right direction.

Here is a similar example to what I am shooting for --> http://tozon.info/gallery/


I have the below, which can read an image in but only from an http, like so -->

BitmapImage bi = new BitmapImage();
        bi.UriSource = new Uri("http://upload.wikimedia.org/wikipedia/en/d/d6/Dragon_Age.jpg");
        MyImage.Source = bi;

What I want to be able to do is read them from either a local network share(\\server\share\filename.jpg) or from a folder in the Web portion on the server.

A: 

I don't mean to be off-topic or anything, do you absolutely need to use Silverlight? I don't have it installed and never used it so I can't see what it looks like on the website you posted in the link. What I do know tho, is that outputting pictures as an album from images in a directory is very, very easy in PHP:

1 - Scan the directory for the pictures:

 $dir = opendir($filePath);
 $fileCount = 0;
 while ($file = readdir($dir)) {
     if (eregi($Ext,$file)) { //$Ext = Extension of the file you're looking for (.jpg)
         $files[$fileCount] = $file;
         $fileCount++;
     }
 }
 sort($files);//This will, obviously, sort the array alphabetically.
 return $files;

2 - Run trough the array (for, while, whatever you like) and output the filepath in some sort of container:

echo '<div id="img'.$i.'" class="pictures"><img src="'.$ArrayOfPictures[$i].'" /></div>';

3 - Thats pretty much it. You could also add a function to build thumbnails, then add a link to the thumbnail wich would show the image in full screen when clicked. You can play with CSS and javascript to make the pictures "whiter" on mouse over by using alpha. Php is easy and mostly everything has been done. Google would be a very good friend :)

If you're stuck with Silverlight tho, Well I'm sorry I wasted your time.

KBFTech
Definitely not a waste of my time. I suggested Silverlight because we are A) a Microsoft shop, B) I want to learn SL, C) I wanted to show the Boss how nice a SL app could look. If I fail down this path then yours would be the direction I went.
Refracted Paladin
If you falied in silverlight, it's a very easy thing to do in ASP.Net. If you're a microsoft shop with predominantly microsoft servers I'd look at this before php.
Sam Meldrum
Indeed, mostly everything that can be done in php can be done aswell in asp.net. Good luck with that!
KBFTech
By the way, he is an example of what I'm talking about:http://dev.kbftech.com/maibec/gallery/index.php?Lang=enThat's a website I'm currently building/updating. Everything in there is in PHP and it's quite simple. I could even give you some parts of the code if you decide to go that route. Everything is customizable. The same module is used for this other page aswell:http://dev.kbftech.com/maibec/inspiration/provincia.php?Gallery=01)
KBFTech
+1  A: 

So, one thing to remember is that Silverlight is a client side technology. All of the code that you write in Silverlight executes on the client's computer, not on the web server. So, if you ask "can Silverlight read files from a folder?", it appears that you are asking if Silverlight can read files from a client's machine and the answer is no, because that would clearly be a major security concern.

But I presume that you want to read files from a directory on the server, not on the client; this also cannot be done, since the code is not executed on the server.

So, to do what you want to do, you could do something like this: Make the directory of images available via the webserver, so you can access the images via http://server/images/FirstnameLastinitial.jpg, etc. Now, you can display the images with a regular Image element, setting the Source to the appropriate URL.

Then the problem remaining is; how can the Silverlight application know what images are available? i.e. it needs to be able to somehow "get a directory listing". This is something that has to be provided by the web server. If you wanted to, you could set up some kind of web-service that the Silverlight app could call to get back a list of image URLs. Or if you wanted to go for the totally simple solution; just put a text file at http://server/images/list.txt which contains a list of the images found there and from Silverlight use WebClient.DownloadString to download this list.

Whether you go with the web-service or the text list is up to you (the web service is probably better, but slightly more complex).

KeithMahoney