Export (0) Print
Expand All

Storing Ink

The Save methods provide support for storing ink as Ink Serialized Format (ISF). Constructors for the StrokeCollection class provide support for reading ink data.

Ink Storage and Retrieval

This section discusses how to store and retrieve ink in the WPF platform.

The following example implements a button-click event handler that presents the user with a File Save dialog box and saves the ink from an InkCanvas out to a file.

private void buttonSaveAsClick(object sender, RoutedEventArgs e)
{
    SaveFileDialog saveFileDialog1 = new SaveFileDialog();
    saveFileDialog1.Filter = "isf files (*.isf)|*.isf";

    if (saveFileDialog1.ShowDialog() == true)
    {
        FileStream fs = new FileStream(saveFileDialog1.FileName,
                                       FileMode.Create);
        theInkCanvas.Strokes.Save(fs);
        fs.Close();
    }
}

The following example implements a button-click event handler that presents the user with a File Open dialog box and reads ink from the file into an InkCanvas element.

private void buttonLoadClick(object sender, RoutedEventArgs e)
{
    OpenFileDialog openFileDialog1 = new OpenFileDialog();
    openFileDialog1.Filter = "isf files (*.isf)|*.isf";

    if (openFileDialog1.ShowDialog() == true)
    {
        FileStream fs = new FileStream(openFileDialog1.FileName,
                                       FileMode.Open);
        theInkCanvas.Strokes = new StrokeCollection(fs);
        fs.Close();
    }
}

See Also

Community Additions

ADD
Show:
© 2014 Microsoft