Programming with .NET - Generalhttp://forums.silverlight.net//17.aspx/1?Programming+with+NET+GeneralGeneral discussions around authoring Silverlight .NET applications.Mon, 01 Jan 0001 00:00:00 -05001731438http://forums.silverlight.net//p/9916/31438.aspx/1?Downloader+behaviorDownloader behavior <p>Look at this code :</p> <p>&nbsp;</p> <font size="2"></font><font color="#0000ff" size="2">void</font><font size="2"> _Downloader_Completed(</font><font color="#0000ff" size="2">object</font><font size="2"> sender, </font><font color="#2b91af" size="2">EventArgs</font><font size="2"> e)<br> {<br> &nbsp;&nbsp;&nbsp; Icon.Photo.SetSource(_Downloader, </font><font color="#0000ff" size="2">null</font><font size="2">);<br> }<br> </font><font size="2"></font><font color="#0000ff" size="2">private</font><font size="2"> </font><font color="#0000ff" size="2">void</font><font size="2"> AddImageToCollection(</font><font color="#0000ff" size="2">string</font><font size="2"> ImageName, </font><font color="#0000ff" size="2">double</font><font size="2"> Left, </font><font color="#0000ff" size="2">double</font><font size="2"> Top, </font><font color="#0000ff" size="2">bool</font><font size="2"> FlipInfoBullRight, </font><font color="#0000ff" size="2">bool</font><font size="2"> FlipInfoBullBottom, </font><font color="#0000ff" size="2">string</font><font size="2"> InfoBullText, </font> <font color="#0000ff" size="2">string</font><font size="2"> Link)<br> {<br> &nbsp;&nbsp;&nbsp; Icon = </font><font color="#0000ff" size="2">new</font><font size="2"> </font> <font color="#2b91af" size="2">ImageGrower</font><font size="2">(</font><font color="#0000ff" size="2">this</font><font size="2">, FlipInfoBullRight, FlipInfoBullBottom, InfoBullText, Link);<br> <br> &nbsp;&nbsp;&nbsp; </font><font size="2">_Downloader.Open(</font><font color="#a31515" size="2">&quot;GET&quot;</font><font size="2">, </font><font color="#0000ff" size="2">new</font><font size="2"> </font><font color="#2b91af" size="2">Uri</font><font size="2">(</font><font color="#a31515" size="2">&quot;Images/&quot;</font><font size="2"> &#43; ImageName &#43; </font><font color="#a31515" size="2">&quot;.jpg&quot;</font><font size="2">, </font><font color="#2b91af" size="2">UriKind</font><font size="2">.RelativeOrAbsolute));<br> &nbsp;&nbsp;&nbsp; _Downloader.Send();<br> <br> &nbsp;&nbsp;&nbsp; Icon.Left = Left;<br> &nbsp;&nbsp;&nbsp; Icon.Top = </font><font color="#2b91af" size="2">Convert</font><font size="2">.ToDouble((!FlipInfoBullBottom ? ImageContainerB.GetValue(</font><font color="#2b91af" size="2">Canvas</font><font size="2">.TopProperty) : ImageContainer.GetValue(</font><font color="#2b91af" size="2">Canvas</font><font size="2">.TopProperty))) &#43; Top;</font><font size="2"> <p>&nbsp;&nbsp;&nbsp; Icons.Add(Icon);<br> }</p> <p>Very simple right ? Well, I don't understand why it goes in the _Downloader_Completed event ONLY at the last image I'm adding in the collection.<br> What I would like is to set my image source as soon as I downloaded it and this for EACH image I add to the collection because I'm adding it to an object of my own.&nbsp; Looks like I'm getting in the COMPLETED EVENT just at the last image.&nbsp; so on my page I just see the last image :(</p> <p>&nbsp;</p> </font> 2008-02-17T11:44:44-05:0031442http://forums.silverlight.net//p/9916/31442.aspx/1?Re+Downloader+behaviorRe: Downloader behavior <p>I haven't tested yet but could you please try the code below?</p> <p><font color="#0000ff" size="2">private</font><font size="2"> </font><font color="#0000ff" size="2">void</font><font size="2"> AddImageToCollection(</font><font color="#0000ff" size="2">string</font><font size="2"> ImageName, </font><font color="#0000ff" size="2">double</font><font size="2"> Left, </font><font color="#0000ff" size="2">double</font><font size="2"> Top, </font><font color="#0000ff" size="2">bool</font><font size="2"> FlipInfoBullRight, </font><font color="#0000ff" size="2">bool</font><font size="2"> FlipInfoBullBottom, </font><font color="#0000ff" size="2">string</font><font size="2"> InfoBullText, </font> <font color="#0000ff" size="2">string</font><font size="2"> Link)<br> {<br> &nbsp;&nbsp;&nbsp; Icon = </font><font color="#0000ff" size="2">new</font><font size="2"> </font> <font color="#2b91af" size="2">ImageGrower</font><font size="2">(</font><font color="#0000ff" size="2">this</font><font size="2">, FlipInfoBullRight, FlipInfoBullBottom, InfoBullText, Link);<br> <br> <b>&nbsp;&nbsp;&nbsp; Downloader </b></font><b><font size="2">_Downloader</font></b><font size="2"><b>;</b><br> <br> &nbsp;&nbsp;&nbsp; </font><font size="2">_Downloader.Open(</font><font color="#a31515" size="2">&quot;GET&quot;</font><font size="2">, </font><font color="#0000ff" size="2">new</font><font size="2"> </font><font color="#2b91af" size="2">Uri</font><font size="2">(</font><font color="#a31515" size="2">&quot;Images/&quot;</font><font size="2"> &#43; ImageName &#43; </font><font color="#a31515" size="2">&quot;.jpg&quot;</font><font size="2">, </font><font color="#2b91af" size="2">UriKind</font><font size="2">.RelativeOrAbsolute));<br> &nbsp;&nbsp;&nbsp; _Downloader.Send();<br> <b>&nbsp;&nbsp;&nbsp; _Downloader.Completed &#43;= new EventHandler((object sender, EventArgs eDwdr) =&gt; Icon.Photo.SetSource(_Downloader, null));</b><br> <br> &nbsp;&nbsp;&nbsp; Icon.Left = Left;<br> &nbsp;&nbsp;&nbsp; Icon.Top = </font><font color="#2b91af" size="2">Convert</font><font size="2">.ToDouble((!FlipInfoBullBottom ? ImageContainerB.GetValue(</font><font color="#2b91af" size="2">Canvas</font><font size="2">.TopProperty) : ImageContainer.GetValue(</font><font color="#2b91af" size="2">Canvas</font><font size="2">.TopProperty))) &#43; Top;</font><font size="2"> </p> <p>&nbsp;&nbsp;&nbsp; Icons.Add(Icon);<br> }</p> </font>Let me know the result. &nbsp; <p></p> <p>&nbsp;</p> 2008-02-17T12:08:26-05:0031455http://forums.silverlight.net//p/9916/31455.aspx/1?Re+Downloader+behaviorRe: Downloader behavior <p>Yo,</p> <p>&nbsp;Still have only the last image as if the downloader wants to download all the images which doesn't make sense of course because I'm in a method that download for each image.</p> <font size="2"></font><font color="#2b91af" size="2"><font size="2"></font><font color="#0000ff" size="2">private</font><font size="2"> </font><font color="#0000ff" size="2">void</font><font size="2"> AddImageToCollection(</font><font color="#0000ff" size="2">string</font><font size="2"> ImageName, </font><font color="#0000ff" size="2">double</font><font size="2"> Left, </font><font color="#0000ff" size="2">double</font><font size="2"> Top, </font><font color="#0000ff" size="2">bool</font><font size="2"> FlipInfoBullRight, </font><font color="#0000ff" size="2">bool</font><font size="2"> FlipInfoBullBottom, </font><font color="#0000ff" size="2">string</font><font size="2"> InfoBullText, </font> <font color="#0000ff" size="2">string</font><font size="2"> Link)<br> {</font></font><font size="2"> <p></font>&nbsp;&nbsp;&nbsp; Downloader<font size="2"> _Downloader = </font><font color="#0000ff" size="2">new</font><font size="2"> </font><font color="#2b91af" size="2">Downloader</font><font size="2">();<br> &nbsp;&nbsp;&nbsp; <br> &nbsp;&nbsp;&nbsp; </font><font size="2">_Downloader.Open(</font><font color="#a31515" size="2">&quot;GET&quot;</font><font size="2">, </font><font color="#0000ff" size="2">new</font><font size="2"> </font><font color="#2b91af" size="2">Uri</font><font size="2">(</font><font color="#a31515" size="2">&quot;Images/&quot;</font><font size="2"> &#43; ImageName &#43; </font><font color="#a31515" size="2">&quot;.jpg&quot;</font><font size="2">, </font><font color="#2b91af" size="2">UriKind</font><font size="2">.RelativeOrAbsolute));<br> &nbsp;&nbsp;&nbsp; _Downloader.Send();<br> <br> &nbsp;&nbsp;&nbsp; _Downloader.Completed &#43;= </font><font color="#0000ff" size="2">new</font><font size="2"> </font><font color="#2b91af" size="2">EventHandler</font><font size="2">((</font><font color="#0000ff" size="2">object</font><font size="2"> sender, </font><font color="#2b91af" size="2">EventArgs</font><font size="2"> eDwdr) =&gt; Icon.Photo.SetSource(_Downloader, </font><font color="#0000ff" size="2">null</font><font size="2">));</font></p> <p><font size="2">}</p> </font> 2008-02-17T15:56:31-05:0031456http://forums.silverlight.net//p/9916/31456.aspx/1?Re+Downloader+behaviorRe: Downloader behavior <p>One day I will certainly knows how to use the downloader as I need it.&nbsp; Maybe I can't do what I want to do the way the downloader works.&nbsp; I mean, I'm presenting the PAGE.XAML which the C# code behind add image to a collection and then add this collection to the children of the page.xaml.&nbsp; This is where I try to download the image to the client to put it in the collection prior to add it the children of the page.</p> <p>&nbsp;I just don't really understand the behavio of the Completed that doesn't get fired after the SEND() for EACH IMAGE.</p> <p>&nbsp;</p> 2008-02-17T16:08:25-05:0031474http://forums.silverlight.net//p/9916/31474.aspx/1?Re+Downloader+behaviorRe: Downloader behavior <p>Now I managed to make it work.</p> <p>I had to put the downloader in the xaml c# code behind for which the image is handled.&nbsp; As you can feel by going there :</p> <p><a href="http://gearworld.homedns.org:8082/devpreview">http://gearworld.homedns.org:8082/devpreview</a></p> <p>&nbsp;</p> 2008-02-17T19:42:47-05:0031502http://forums.silverlight.net//p/9916/31502.aspx/1?Re+Downloader+behaviorRe: Downloader behavior <p></p> <blockquote><span class="icon-blockquote"></span> <h4>GearWorld</h4> http://gearworld.homedns.org:8082/devpreview</blockquote> &nbsp; <p></p> <p>Your link is not working. </p> <p></p> <blockquote><span class="icon-blockquote"></span> <h4>GearWorld</h4> I had to put the downloader in the xaml c# code behind for which the image is handled.</blockquote> &nbsp; <p></p> <p>Can you share the code? :) &nbsp;</p> 2008-02-18T01:25:18-05:0031557http://forums.silverlight.net//p/9916/31557.aspx/1?Re+Downloader+behaviorRe: Downloader behavior <p>Hi,</p> <p>&nbsp;Sorry its at home so I'm opened between 6:00am and 8:00pm EST.</p> <p>Sure I&nbsp;can share it.&nbsp; I will put a SILVERLIGHT LINK :) on the page so you can download the entire object, XAML &#43; C# code.&nbsp; Will do it tonight at 6:00pm at least</p> <p>&nbsp;</p> 2008-02-18T11:25:14-05:0031575http://forums.silverlight.net//p/9916/31575.aspx/1?Re+Downloader+behaviorRe: Downloader behavior <p></p> <blockquote><span class="icon-blockquote"></span> <h4>GearWorld</h4> Sure I&nbsp;can share it.&nbsp; I will put a SILVERLIGHT LINK :) on the page so you can download the entire object, XAML &#43; C# code.&nbsp; Will do it tonight at 6:00pm at least</blockquote> &nbsp; <p></p> <p>Cool, Thanks a lot, man. :) &nbsp;</p> 2008-02-18T13:20:39-05:0031632http://forums.silverlight.net//p/9916/31632.aspx/1?Re+Downloader+behaviorRe: Downloader behavior <p>Wow, I just saw that I don't put a lot of comment in my code.&nbsp; Mhuaaaaaaa</p> <p>&nbsp;</p> 2008-02-18T21:01:04-05:00