Exercise 2: Drag and DropNot all users will have webcams, and even those who do may already have a picture they’d like to use instead of taking a new one. In this part of the lab, you’ll make it possible for users to drag a PNG or JPEG file from their computer into the application.
Note:
Don’t forget that the Completed folder in each lab contains a completed solution for every part of the lab. If you did not do the previous part (e.g., because you don’t have a webcam) you can use the solution in the Part 1 folder as your starting point for this part.
Add Drop Support
Load the Image from the Database (Optional)As an additional exercise, you might want to try writing code that loads the images saved in this lab to display them. One way to do this would be to add a method to the domain service that retrieves an Attendee entity for the currently logged in user. This has a UserPicture property containing the image bytes. Once you’ve got that on the client side, you can wrap it in a MemoryStream, and then pass that to a BitmapImage object’s SetSource method, just like you did with the file stream in the Drop handler. (Or if you want a more advanced approach, you could write an ASP.NET HTTP handler that makes the user pictures available via HTTP.)
Note:
The solution for this optional task can be found in the completed lab for Exercise 2.
|