I am using canvas in wp7 silverlight application. I am facing two problems.
So on Canvas_MouseLeftButtonDown event capturing single point and then in MouseMove event i am capturing the other point and then drawing a line and adding this children to Canvas. Everything is going fine except that in mouse move event some points are missing between two if i move my finger a little bit fast and the result is that i am getting straight lines instead of curves. For grabbing point I am using e.GetPosition(where e is MouseButtonEventArgs and MouseEventArgs type).Is there other way through which i can grab point like using Touch class.
If i have already drawn many lines(added many children to canvas) then adding more lines with different color over prior lines is slow and points are missing again resulting in straight lines. I think its happening becos capturing of points in MouseMove events over already drawn area is becoming slow and middle points are missing.
So please suggests me any solutions or way to handle this problematic scenario. Basically what i have to achieve is to add children over children with different colors and different stroke size as the finger moves over canvas.
I am attaching my current logic so please tell me where I am lagging.
Thanks in Advance.
Code:
void myCanvas_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
currentPoint = e.GetPosition(myCanvas);
oldPoint = currentPoint;
}
void myCanvas_MouseMove(object sender, MouseEventArgs e)
{
currentPoint = e.GetPosition(myCanvas);
Line line = new Line() { X1 = currentPoint.X, Y1 = currentPoint.Y, X2 = oldPoint.X, Y2 = oldPoint.Y };
line.Stroke = new SolidColorBrush(myColor);
line.StrokeThickness = 10;
line.StrokeStartLineCap = PenLineCap.Round;
line.StrokeEndLineCap = PenLineCap.Round;
this.myCanvas.Children.Add(line);
oldPoint = currentPoint;
}
}