description
One of the common complaints (or features, depending on your perspective) of Silverlight photo galleries is that the viewer is no longer able to right click on the image and save it to their computer. If you are hosting copyrighted content, that can be great. But, if you are hosting a personal photo album and want to allow your family members and friends to download the pictures on your site, Silverlight photo albums like Slide.Show 2 aren't user friendly in that regard. For my personal website, adding this ability to Slide.Show was an important feature requirement. Besides, I figured I’d learn something about Silverlight in the process. I just didn’t realize how much…
Because this is fairly involved, I have attached the modified files to this issue. You can download the modified files here. You can then just overwrite the files available with the base download package with these and recompile the Slide.Show project, or you can use a tool like WinMerge to merge in the changes into your code.
You can read more about these changes and some of the issues encountered along the way in the related discussion thread.
Themes\Generic.xaml
• Add a HyperlinkButton element named SaveHyperlinkButtonElement with an embedded disabled PathButton element called SaveButtonElement to the NavigationTray before the AlbumButtonElement
Navigation\Navigation.cs
• Modify the ToggleAlbumView method in Navigation.cs to disable the Save Hyperlink Button when in album view.
Controls\ImageViewer.cs
• Modify OnShourceChanged to set SaveHyperlinkButtonElement’s NavigateUri property
Controls\NavigationTray.cs
• Add TemplateParts for SaveHyperlinkButton and SaveButton before the class declaration
• Add code to the NavigationTray() constructor to set up the ToggleSaveButton options
• Add HyperlinkButton and PathButton properties in the Template Parts region
• Add the SaveHyperlinkButton and SaveButtonElement public properties
• Add the SaveButton properties in the Dependency Properties region
• Modify OnApplyTemplate to setup the SaveHyperlinkButton and SaveButton
Configuration\Configuration.cs
• Add new ToggleSaveButtonOptions property to Options class.
• Add new SaveButtonOptions property to Options class.
• Add new ToggleSaveButtonOptions subclass to Options class.
• Add new SaveButtonOptions subclass to Options class
Configuration\XmlConfigurationProvider.cs
• Add new ToggleSaveButton Options.
Configuration*Theme.cs
• Set the default Options.ToggleSaveButton options in each of the themes.
• NOTE: The DownloadImageHandler property is an ABSOLUTE URI to the image download handler on your web site. It is NOT a relative URI based on the Silverlight app’s location like most references are. BE SURE TO UPDATE THE THEME FILES to set the default DownloadImageHandler appropriately for your site, or overwrite it using XML configuration.
DownloadImage.ashx
• A new image download handler that should be added to your site. It takes the relative path to the image to download as a query string parameter. I have this located in the same directory as the silde.show .xap file. Any image download handler or page will work, I just offer this one up as an example if you don’t already have one. Note that you should modify DowhloadImage.ashx.cs so that the paths are correct for your web site.
I hope this helps,
--Scott