StrokeCollection Constructors

Definition

Initializes a new instance of the StrokeCollection class.

Overloads

StrokeCollection()

Initializes a new instance of the StrokeCollection class.

StrokeCollection(IEnumerable<Stroke>)

Initializes a new instance of the StrokeCollection class that contains the specified strokes.

StrokeCollection(Stream)

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

StrokeCollection()

Initializes a new instance of the StrokeCollection class.

C#
public StrokeCollection();

Applies to

.NET Framework 4.8.1 dan versi lain
Produk Versi
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

StrokeCollection(IEnumerable<Stroke>)

Initializes a new instance of the StrokeCollection class that contains the specified strokes.

C#
public StrokeCollection(System.Collections.Generic.IEnumerable<System.Windows.Ink.Stroke> strokes);

Parameters

strokes
IEnumerable<Stroke>

The strokes to add to the StrokeCollection.

Applies to

.NET Framework 4.8.1 dan versi lain
Produk Versi
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

StrokeCollection(Stream)

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

C#
public StrokeCollection(System.IO.Stream stream);

Parameters

stream
Stream

A stream that contains ink data.

Examples

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

C#
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();
        }
    }
}
C#
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();
        }
    }
}

Applies to

.NET Framework 4.8.1 dan versi lain
Produk Versi
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10