locked
How can I load saved strokes to an inkCanvas in Silverlight? RRS feed

  • Question

  • Hi!

    I have searched a lot without any answer.

    I save all the inkCanvas's strokes in a database field from my WPF application as a byte[][] and then I send it throught a webservice. This is my code:

                int count = 0;
                byte[] dibujo;

                using (MemoryStream st = new MemoryStream())
                {
                    inkTrazos.Strokes.Save(st);

                    st.Seek(0, SeekOrigin.Begin);
                    dibujo = new byte[st.Length];

                    // Read the remaining bytes, byte by byte.
                    while (count < st.Length)
                    {
                            dibujo[count++] =
                            Convert.ToByte(st.ReadByte());
                    }

                    WebService.saveStrokes(id, dibujo);

     

    Now, I want to retrieve them from a Silverlight application and paint them into an inkCanvas/inkPresenter. But StrokeCollection class only accepts an empty constructor, not as in WPF where I can do this:

                   byte[][]  dibujo2 = WebService.loadStrokes(id);

                    MemoryStream st = new MemoryStream(dibujo2);
                    StrokeCollection trazos = new StrokeCollection(st);
                    inkTrazos.Strokes = trazos;

     

    But it isn't possible to do "new StrokeCollection(st)" in Silverlight. It says that this class doesn't accept constructor with 1 argument.

    How can I pass a stream to a StrokeCollection instance?

    Thank you for your attemption.

    Monday, April 18, 2011 11:59 PM