alfah
alfah

Reputation: 2085

Alternative to InkPresenter?

I have an app in Windows 8 which is a hand writing based. Im trying to port it to Windows Phone 8. But there are only 3 Inking classes available for WP8 and no Inkmanager class. Can we use a canvas instead of InkPresenter. Are all functions of stroke available for it. I tried the following code

private void MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
    {
        InkCanvas.CaptureMouse();
        StylusPointCollection MyStylusPointCollection = new StylusPointCollection();
        MyStylusPointCollection.Add(e.StylusDevice.GetStylusPoints(InkCanvas));
        NewStroke = new Stroke(MyStylusPointCollection);
        //InkCanvas.Strokes.Add(NewStroke);
        NewStroke.DrawingAttributes = SetAttributes(draw);
    }

There is an error in the second last line it says, canvas does not contain the definition for strokes. InkPresenter does not suit my needs. If not canvas is there any other element which can capture the touch input?

Upvotes: 1

Views: 1030

Answers (2)

alfah
alfah

Reputation: 2085

Thanks for your answer, The Inkpresenter does not meet my needs. So I have used the canvas and touch input. For those of you who are looking for clues...

I have made use Touch_FrameReported and basic line drawing like this

            if (pointCollection[i].Action == TouchAction.Move)
            {
                Line line = new Line();

                line.X1 = preXArray[i];
                line.Y1 = preYArray[i];
                line.X2 = pointCollection[i].Position.X;
                line.Y2 = pointCollection[i].Position.Y;

                line.Stroke = new SolidColorBrush(Colors.Black);
                line.Fill = new SolidColorBrush(Colors.Black);
                line.StrokeThickness = 15;
                line.StrokeDashCap = PenLineCap.Round;
                line.StrokeStartLineCap = PenLineCap.Round;
                line.StrokeEndLineCap = PenLineCap.Round;

                drawCanvas.Children.Add(line);                  

Upvotes: 1

JP Alioto
JP Alioto

Reputation: 45117

Canvas is the right way to go, but you should be able to use the InkPresenter class in Windows Phone 8 and place that inside your Canvas. It appears you are trying to add the Strokes to the Canvas rather than the InkPresenter in your code. Take a look at this sample on how to accomplish Ink on the WP8.

Upvotes: 1

Related Questions