I am working on wpf project, I want to know how to measure the angle of the stroke on the ink canvas? whether the stroke is right inclined or left inclined?
A:
When you get a mouse down on the canvas, save away the current mouse position. Later, when you receive a mouse up event, you know the stroke is finished. Get the mouse position a second time and calculate the difference between the second position and the first position. Then you just have some simple math to do, and there are a couple cases to consider.
Note that this will not work so well for complex, curved strokes (because you will only receive a mouse-up event at the end of the stroke). This will work best in the case of single, straight lines.
Charlie
2010-03-31 20:32:10