locked
Changing color of existing stroke RRS feed

  • Question

  • Hello,

     

    I was just wondering whether it is possible to change the color of a stroke after it was painted.
     
    The only solution I found is to change the DefaultDrawingAttributes.Color attribute of the InkOverlay and then paint the stroke (I use Winforms).
    Does that mean I have to repaint or clone all strokes to get them colored?
     
    Is there maybe a way to change the color within the stroke or ink object after the strokes were painted; if so, how?
     

    Thanks a lot

     

    paul

    Wednesday, October 24, 2007 4:28 AM

Answers

  • Hi Paul,

     

    the Stroke object has a DrawingAttributes property [1]. You can walk up to that property and change the color, thickness, opacity and other attributes of the ink.

     

    For example, to change the color of the first stroke in your InkOverlay's Ink object, you can just set:

    inkOverlay.Ink.Strokes[0].DrawingAttributes.Color = Color.CornflowerBlue;

     

    Please note that you need to invalidate the control you are attached to (or at least the region that is covered by the stroke) to ensure your change gets updated visually on the screen.

     

    Thanks,

    Stefan Wick

     

    Microsoft - Windows Experience

     

    [1] http://msdn2.microsoft.com/en-us/library/microsoft.ink.stroke.drawingattributes.aspx

     

    Wednesday, October 24, 2007 5:08 AM