Ziff Davis EnterpriseDevLife
Advertisement

Friday, September 12, 2008 9:15 AM/EST

Silverlight InkPresenter: Staying inside the lines

Remember your first coloring book and the big challenge of staying inside of the lines?

Well, it's a problem with InkPresenter too. If you being a stroke in the InkPresenter and then draw outside of its border, the line will continue to draw. The first time I realized this, I was told to just use a Silverlight clipping path to solve the problem and it works like a charm. Not only will it stop drawing outside of the border, but if you loop around and come back into the InkPresenter, the line will continue at that point. You can see how to do this in my article on the InkPresenter: Write On! Create Web Apps You Can Draw On with Silverlight 2.

I did an INETA sponsored presentation at the Western Mass User Group last week on this topic and someone asked "what about MouseLeave and MouseEnter?" I had never tried it. So on the spot, I wired up MouseLeave and it worked - kind of.

mouseleave

Notice the right edge where some lines don't meet it and others overwrite it? I don't like that behavior.

With a clipping path, the edge is clean.
clippingpath

Then there's MouseEnter. With the clipping path, you can renter and continue the stroke. MouseEnter doesn't have a (discoverable) way to determine the mouse state. Is the left button down? Are we drawing? Even without the state, I can't seem to get MouseEnter to start drawing in the InkPresenter. Oh well.

It was a worthy path to go down just to make sure I hadn't missed something. Thanks to John Thayer from the group, not only posing the question, but following up with some of his own experiments.

TrackBack

TrackBack

http://blogs.devsource.com/cgi-bin/mte/mt-tb.cgi/14921

Post a Comment

 
 

Advertisement

Syndication

Subscribe: