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.
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. Looks like I'm getting in the COMPLETED EVENT just at the last image. so on my page I just
see the last image :(
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.
One day I will certainly knows how to use the downloader as I need it. Maybe I can't do what I want to do the way the downloader works. 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. 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.
I just don't really understand the behavio of the Completed that doesn't get fired after the SEND() for EACH IMAGE.
Sorry its at home so I'm opened between 6:00am and 8:00pm EST.
Sure I can share it. I will put a SILVERLIGHT LINK :) on the page so you can download the entire object, XAML + C# code. Will do it tonight at 6:00pm at least
Sure I can share it. I will put a SILVERLIGHT LINK :) on the page so you can download the entire object, XAML + C# code. Will do it tonight at 6:00pm at least
Cool, Thanks a lot, man. :)
(If this has answered your question, please click on "Mark as Answer" on this post. Thank you!)
GearWorld
Participant
1661 Points
2024 Posts
Downloader behavior
Feb 17, 2008 12:44 PM | LINK
Look at this code :
void _Downloader_Completed(object sender, EventArgs e){
Icon.Photo.SetSource(_Downloader, null);
}
private void AddImageToCollection(string ImageName, double Left, double Top, bool FlipInfoBullRight, bool FlipInfoBullBottom, string InfoBullText, string Link)
{
Icon = new ImageGrower(this, FlipInfoBullRight, FlipInfoBullBottom, InfoBullText, Link);
_Downloader.Open("GET", new Uri("Images/" + ImageName + ".jpg", UriKind.RelativeOrAbsolute));
_Downloader.Send();
Icon.Left = Left;
Icon.Top = Convert.ToDouble((!FlipInfoBullBottom ? ImageContainerB.GetValue(Canvas.TopProperty) : ImageContainer.GetValue(Canvas.TopProperty))) + Top;
Icons.Add(Icon);
}
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.
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. Looks like I'm getting in the COMPLETED EVENT just at the last image. so on my page I just see the last image :(
mchlSync
Star
14968 Points
2799 Posts
Re: Downloader behavior
Feb 17, 2008 01:08 PM | LINK
I haven't tested yet but could you please try the code below?
private void AddImageToCollection(string ImageName, double Left, double Top, bool FlipInfoBullRight, bool FlipInfoBullBottom, string InfoBullText, string Link)
{
Icon = new ImageGrower(this, FlipInfoBullRight, FlipInfoBullBottom, InfoBullText, Link);
Downloader _Downloader;
_Downloader.Open("GET", new Uri("Images/" + ImageName + ".jpg", UriKind.RelativeOrAbsolute));
_Downloader.Send();
_Downloader.Completed += new EventHandler((object sender, EventArgs eDwdr) => Icon.Photo.SetSource(_Downloader, null));
Icon.Left = Left;
Icon.Top = Convert.ToDouble((!FlipInfoBullBottom ? ImageContainerB.GetValue(Canvas.TopProperty) : ImageContainer.GetValue(Canvas.TopProperty))) + Top;
Icons.Add(Icon);
Let me know the result.}
Regards,
Michael Sync
Silverlight MVP
Blog : http://michaelsync.net
GearWorld
Participant
1661 Points
2024 Posts
Re: Downloader behavior
Feb 17, 2008 04:56 PM | LINK
Yo,
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.
private void AddImageToCollection(string ImageName, double Left, double Top, bool FlipInfoBullRight, bool FlipInfoBullBottom, string InfoBullText, string Link){ Downloader _Downloader = new Downloader();
_Downloader.Open("GET", new Uri("Images/" + ImageName + ".jpg", UriKind.RelativeOrAbsolute));
_Downloader.Send();
_Downloader.Completed += new EventHandler((object sender, EventArgs eDwdr) => Icon.Photo.SetSource(_Downloader, null));
}
GearWorld
Participant
1661 Points
2024 Posts
Re: Downloader behavior
Feb 17, 2008 05:08 PM | LINK
One day I will certainly knows how to use the downloader as I need it. Maybe I can't do what I want to do the way the downloader works. 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. 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.
I just don't really understand the behavio of the Completed that doesn't get fired after the SEND() for EACH IMAGE.
GearWorld
Participant
1661 Points
2024 Posts
Re: Downloader behavior
Feb 17, 2008 08:42 PM | LINK
Now I managed to make it work.
I had to put the downloader in the xaml c# code behind for which the image is handled. As you can feel by going there :
http://gearworld.homedns.org:8082/devpreview
mchlSync
Star
14968 Points
2799 Posts
Re: Downloader behavior
Feb 18, 2008 02:25 AM | LINK
Your link is not working.
Can you share the code? :)
Regards,
Michael Sync
Silverlight MVP
Blog : http://michaelsync.net
GearWorld
Participant
1661 Points
2024 Posts
Re: Downloader behavior
Feb 18, 2008 12:25 PM | LINK
Hi,
Sorry its at home so I'm opened between 6:00am and 8:00pm EST.
Sure I can share it. I will put a SILVERLIGHT LINK :) on the page so you can download the entire object, XAML + C# code. Will do it tonight at 6:00pm at least
mchlSync
Star
14968 Points
2799 Posts
Re: Downloader behavior
Feb 18, 2008 02:20 PM | LINK
Cool, Thanks a lot, man. :)
Regards,
Michael Sync
Silverlight MVP
Blog : http://michaelsync.net
GearWorld
Participant
1661 Points
2024 Posts
Re: Downloader behavior
Feb 18, 2008 10:01 PM | LINK
Wow, I just saw that I don't put a lot of comment in my code. Mhuaaaaaaa