Finishing photoCmd?

Jun 6, 2010 at 6:11 AM


So I've been working on finishing the photoCmd (which I didn't start, but would love to use!). The issue seems to be creating shortcuts from within Media Center. I've tried the WSH Shell interop method, this fails with some sort of cryptic error (x80020000 if I recall). I've tried the Shell32.Shell method; this crashes the add-in as soon as it's instantiated. Have tried running under full priveledges, no dice.

Does anyone have any suggestions?



Jun 6, 2010 at 2:50 PM

OK, scratch that, got it sorted (via Shell32). Here's the code. I'm working to incorporate into photoCmd.cs and will post a patch when done.

                    string folderPath = System.Environment.GetEnvironmentVariable("TEMP") + "\\" + System.Security.Principal.WindowsIdentity.GetCurrent().Name.Replace("\\","-") + DateTime.Now.ToString().Replace(" ", "").Replace(":", "").Replace("/", "");
                    Shell32.Shell shortcut = new Shell32.ShellClass();
                    StreamWriter shortcutWriter = new StreamWriter(folderPath + "\\" + e.Name + ".lnk", false);

                    Shell32.Folder directory = shortcut.NameSpace(folderPath);
                    Shell32.FolderItem item = directory.Items().Item(e.Name + ".lnk");
                    Shell32.ShellLinkObject link = (Shell32.ShellLinkObject)item.GetLink;
                    link.Path = e.FullPath;  //the full path to the target
                    link.WorkingDirectory = e.FullPath.Replace("\\" + e.Name, ""); //the directory
                    link.SetIconLocation(e.FullPath, 0);
                    link.Save(folderPath + "\\" + e.Name + ".lnk");

                    NavigateToPage slideshow = new NavigateToPage();
                    AddInHost.Current.MediaCenterEnvironment.NavigateToPage(PageId.Slideshow, folderPath);
                    System.Threading.Thread.Sleep(_duration * 1000);
                    AddInHost.Current.MediaCenterEnvironment.NavigateToPage(PageId.Start, folderPath);
                    System.IO.Directory.Delete(folderPath, true);


Jun 7, 2010 at 7:26 PM
Edited Jun 7, 2010 at 7:27 PM
James, sorry I haven't updated the code - I didn't realize that anyone was using the photo functionality except me. I believe that I have made a lot of command / cache / performance changes since the last checkin. I'll try to check in my changes today. Looking at your code I'm not sure what you are trying to do. Are you trying to mimic slide show behavior and change the photos manually every <_duration> seconds? I don't think that will work as it's going to completely tie up the vmc connection while running (won't be able to pause / ff / change what you are doing). I wasn't able to get the slideshow to run using short cuts to the image file (not even manually) so I ended up copying the entire image to a temp directory to play as a slideshow. Does your above code (using shortcuts) work? Thanks, Tony
Jun 8, 2010 at 12:30 AM

Yup, the shortcut code works for me with slideshows. I'm basically creating a directory full of shortcuts and then calling NavigateToPage on it to start the slideshow- seems to work well.

I'm actually using this to integrate with an card, so when I take a picture it uploads it automatically and it appears on my big screen. Looking forward to your check-in, I'll hold off messing with it for now.

Jun 15, 2010 at 6:04 PM

OK I've made the update to use shortcuts instead of copies. Also added a bit of code to differentiate the Slideshows folder from extender to extender, so it works properly with extenders. Will post the updated photoCmd.cs soon.

Jun 17, 2010 at 2:31 AM



Quick question. Does the start/end date filtering work for you? I've been trying to figure out the implementation as it's not working for me and I can't seem to see where in the code it's implemented.



Jun 18, 2010 at 12:32 AM
Edited Jun 18, 2010 at 12:33 AM

Basically dates are treated as tags on a photo. So the logic is all in the get_list() function. At the beginning of the function the results set is defined as a Union of all the matching Dates in the keywords dictionary (a "matching" date is one that is >= the start date, and <= the end date). That result set is intersected with the is-tagged result set to get the final results set.

It's a little counter-intuitive treating the dates as keywords in the tag dictionary, but it was the best way I could come up with performance wise.

Hope this makes sense



Ok, glad I checked my source. When I added the caching code I created a variable "clean_filter_params" that would store normalized set of parameters. The problem is it was stripping the actual date values due to a bad cut and paste move. I've fixed it and checked it in... date filtering should work now.

Sorry :-)

Jun 25, 2010 at 1:32 AM

So... the photos have to have a the date in a tag? (That is to say, the logic doesn't look at the actual date-taken attribute of the photo)?

Jun 25, 2010 at 1:50 AM

OK, got it figured out, thanks. I wasn't giving enough time for the cache to build. New photoCmd.cs, with shortcut code, posted.