Some pictures of Inner harbor area.
Daily Archives: July 6, 2007
Using Resources out of ZIP
using Silverlight Alpha 1.1, you can zip your images/media files and use them in your application using downloader class. It is pretty straightforward.
- Download zip file using Downloader class
- hook the completed event for the Downloader class
- Use image.SetSource API that takes Downloader object and part name to set the image source
page.xaml
<Canvas xmlns="http://schemas.microsoft.com/client/2007" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" x:Name="parentCanvas" Loaded="Page_Loaded" x:Class="zippedimages.Page;assembly=ClientBin/zippedimages.dll" Width="640" Height="480" Background="White" > <Image Width="350" Height="250.757" Canvas.Left="152" Canvas.Top="119.129" x:Name="image" /> </Canvas>
page.xaml.cs
using System; using System.Windows; using System.Windows.Controls; namespace zippedimages { public partial class Page : Canvas { public void Page_Loaded(object o, EventArgs e) { // Required to initialize variables InitializeComponent(); Downloader d = new Downloader(); d.Open("GET", new Uri("images.zip", UriKind.Relative), true); d.Completed += new EventHandler(d_Completed); d.Send(); } void d_Completed(object sender, EventArgs e) { Downloader d = (Downloader)sender; image.SetSource(d, "image1.jpg"); } } }
Unfortunately there is no way today to just download the image directly and get a stream for that image and set the source of image element using that stream.
Source code for this simple project is here.