Ken, I did try your code, and it draws just fine. The thing that I was finding difficult extending is trying to save the drawn image from your version. Basically, I want to store the drawign that the user make onto storage. With my version I had a distinct
set of points of the images and one point of where the image would begin from, so it makes this very easy. I couldnt figure out how i would be able to use your version to 'save' the drawings.
I think that the easiest way to handle this would be to keep a list of points in memory that you can save to isolated storage when the user chooses to do so. Then you should be able to reconstruct the drawing using the point information. Ultimately, you'll
be accomplishing the same goal.
im trying to extend your version to save the drawings. But before that, can you explain to me the purpose of CaptureMouse() and ReleaseMouse(). Ive tried executing without those methods and the code works just fine. Im just trying to understand the purpose
of it there and if it absolutely needs to be there.
I think you're right, you can do without CaptureMouse() and ReleaseMouse(). These may be more useful if you had more UI elements that you didn't want to receive mouse events while you're updating the canvas.
The issue you're having where you have to place text in a hidden text box sounds SO similar to an issue I was having adding a point to a Polyline PointCollection [http://eightyeightpercentnerd.blogspot.com/2008/09/silverlight-c-polyline-adding-points.html].
It was like the UI was not being updated properly with the new addition to the collection. If I removed the element from the DOM and re-added it I could see it, but that seemed very inefficient. I ended up pulling out, updating and writing back to the
collection property itself.
Try doing the following [this was kind of by hand, so there may be some syntax mistakes] Also, remove the textbox part of your code just to make sure:
PathGeometry pathgeometry = path.Data as PathGeometry; PathFigure figure = pathgeometry.Figures[0] as PathFigure; Point p = e.GetPosition(this.canvasBlackboardArea);
p.X -= mouseDownPoint.X; p.Y -= mouseDownPoint.Y;
LineSegment myLineSegment = new LineSegment() { Point = p };
your code seemed to have fixed the problem, three lines more long winded but it does work. This has got to be a bug in SL2 beta 2, like you said, I am not sure how to explain it. Thanks.
Yeah, I literally just bumped into this issue the other day... I wasn't sure if it was a bug or not. I hadn't tried it pre beta 2 to know that it HAD been working before. Maybe I'll check out the beta 2 changes and see if there was any mention of collection
changes - something tells me there was.
RezaMohamed
Member
528 Points
328 Posts
Re: Drawing applet
Sep 19, 2008 01:45 PM | LINK
Ken, I did try your code, and it draws just fine. The thing that I was finding difficult extending is trying to save the drawn image from your version. Basically, I want to store the drawign that the user make onto storage. With my version I had a distinct set of points of the images and one point of where the image would begin from, so it makes this very easy. I couldnt figure out how i would be able to use your version to 'save' the drawings.
Thanks tho!
kwatts
Contributor
2159 Points
436 Posts
Re: Drawing applet
Sep 19, 2008 02:11 PM | LINK
I think that the easiest way to handle this would be to keep a list of points in memory that you can save to isolated storage when the user chooses to do so. Then you should be able to reconstruct the drawing using the point information. Ultimately, you'll be accomplishing the same goal.
-Ken
http://kenwatts.blogspot.com/
Please select "Mark as Answer" for posts that are helpful. Thanks!
RezaMohamed
Member
528 Points
328 Posts
Re: Drawing applet
Sep 19, 2008 10:10 PM | LINK
Ken,
im trying to extend your version to save the drawings. But before that, can you explain to me the purpose of CaptureMouse() and ReleaseMouse(). Ive tried executing without those methods and the code works just fine. Im just trying to understand the purpose of it there and if it absolutely needs to be there.
Thanks
kwatts
Contributor
2159 Points
436 Posts
Re: Drawing applet
Sep 20, 2008 02:30 AM | LINK
I think you're right, you can do without CaptureMouse() and ReleaseMouse(). These may be more useful if you had more UI elements that you didn't want to receive mouse events while you're updating the canvas.
-Ken
http://kenwatts.blogspot.com/
Please select "Mark as Answer" for posts that are helpful. Thanks!
ssawchenko
Member
438 Points
214 Posts
Re: Drawing applet
Sep 23, 2008 09:28 PM | LINK
The issue you're having where you have to place text in a hidden text box sounds SO similar to an issue I was having adding a point to a Polyline PointCollection [http://eightyeightpercentnerd.blogspot.com/2008/09/silverlight-c-polyline-adding-points.html].
It was like the UI was not being updated properly with the new addition to the collection. If I removed the element from the DOM and re-added it I could see it, but that seemed very inefficient. I ended up pulling out, updating and writing back to the collection property itself.
Try doing the following [this was kind of by hand, so there may be some syntax mistakes] Also, remove the textbox part of your code just to make sure:
RezaMohamed
Member
528 Points
328 Posts
Re: Drawing applet
Sep 23, 2008 10:52 PM | LINK
your code seemed to have fixed the problem, three lines more long winded but it does work. This has got to be a bug in SL2 beta 2, like you said, I am not sure how to explain it. Thanks.
oh...and whats the other 12% like? [;)]
ssawchenko
Member
438 Points
214 Posts
Re: Drawing applet
Sep 23, 2008 10:59 PM | LINK
Yeah, I literally just bumped into this issue the other day... I wasn't sure if it was a bug or not. I hadn't tried it pre beta 2 to know that it HAD been working before. Maybe I'll check out the beta 2 changes and see if there was any mention of collection changes - something tells me there was.
Scroll down to the bottom ;)
RezaMohamed
Member
528 Points
328 Posts
Re: Drawing applet
Sep 23, 2008 11:14 PM | LINK
haha....i am the other way around! [:P]