Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

StrokeCollection Constructor (Stream)

Initializes a StrokeCollection from the specified Stream of Ink Serialized Format (ISF).

Namespace:  System.Windows.Ink
Assembly:  PresentationCore (in PresentationCore.dll)

public StrokeCollection(
	Stream stream
)

Parameters

stream
Type: System.IO.Stream

A stream that contains ink data.

The following example demonstrates how to save and load a StrokeCollection. This example assumes that there is an InkCanvas called inkCanvas1.

private void SaveStrokes_Click(object sender, RoutedEventArgs e)
{
    FileStream fs = null;

    try
    {
        fs = new FileStream(inkFileName, FileMode.Create);
        inkCanvas1.Strokes.Save(fs);
    }
    finally
    {
        if (fs != null)
        {
            fs.Close();
        }
    }
}


...


private void LoadStrokes_Click(object sender, RoutedEventArgs e)
{
    FileStream fs = null;

    if (!File.Exists(inkFileName))
    {
        MessageBox.Show("The file you requested does not exist." +
            " Save the StrokeCollection before loading it.");
        return;
    }

    try
    {
        fs = new FileStream(inkFileName,
            FileMode.Open, FileAccess.Read);
        StrokeCollection strokes = new StrokeCollection(fs);
        inkCanvas1.Strokes = strokes;
    }
    finally
    {
        if (fs != null)
        {
            fs.Close();
        }
    }

}

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
Show:
© 2015 Microsoft