StrokeCollection Constructor (Stream)

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

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
Available since 3.0
Return to top
Show: