Click here to Skip to main content
15,890,825 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Everyone

I am working on a project to save and retrieve inkcanvas strokes.
Also I have to change the ink colour based on the pressure value dynamically.
I have completed with the saving. I am facing problem with changing the ink colour dynamically based on the pressure value.

My code:
C#
        private void setInkColor(float currentPressure)
        {
            System.Windows.Ink.DrawingAttributes inkDA = new System.Windows.Ink.DrawingAttributes();
            inkDA.Height = 4;
            inkDA.Width = 4;
            inkDA.FitToCurve = false;
            int press = Convert.ToInt32(currentPressure * 100);
            if (press >= 0 && press <= 20)
            { inkDA.Color = Colors.Green; }
            else if (press >= 21 && press <= 40)
            { inkDA.Color = Colors.Orange; }
            else if (press >= 41 && press <= 60)
            { inkDA.Color = Colors.Blue; }
            else if (press >= 61 && press <= 80)
            { inkDA.Color = Colors.Red; }
            else if (press >= 81 && press <= 100)
            { inkDA.Color = Colors.Black; }
            else { inkDA.Color = Colors.Green; }
 
           
            inkCanv.DefaultDrawingAttributes = inkDA;

}

This code is called in the stylusMove event

Here I have to raise the stylus pen from the inkcanvas so that the ink colour changes

How to change the ink colour dynamically without raising the pen.
Also on saving how to retrieve the ink with colour, I am retrieving the ink on inkpresenter control.

Please help

Thanks in advance
Posted
Updated 6-Dec-15 18:05pm
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900