StrokeCollection 建構函式
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
初始化 StrokeCollection 類別的新執行個體。
多載
StrokeCollection() |
初始化 StrokeCollection 類別的新執行個體。 |
StrokeCollection(IEnumerable<Stroke>) |
初始化包含指定筆劃之 StrokeCollection 類別的新執行個體。 |
StrokeCollection(Stream) |
從 Ink Serialized Format (ISF) 的指定 StrokeCollection 初始化 Stream。 |
StrokeCollection()
初始化 StrokeCollection 類別的新執行個體。
public:
StrokeCollection();
public StrokeCollection ();
Public Sub New ()
適用於
StrokeCollection(IEnumerable<Stroke>)
初始化包含指定筆劃之 StrokeCollection 類別的新執行個體。
public:
StrokeCollection(System::Collections::Generic::IEnumerable<System::Windows::Ink::Stroke ^> ^ strokes);
public StrokeCollection (System.Collections.Generic.IEnumerable<System.Windows.Ink.Stroke> strokes);
new System.Windows.Ink.StrokeCollection : seq<System.Windows.Ink.Stroke> -> System.Windows.Ink.StrokeCollection
Public Sub New (strokes As IEnumerable(Of Stroke))
參數
- strokes
- IEnumerable<Stroke>
要加入至 StrokeCollection 的筆劃。
適用於
StrokeCollection(Stream)
從 Ink Serialized Format (ISF) 的指定 StrokeCollection 初始化 Stream。
public:
StrokeCollection(System::IO::Stream ^ stream);
public StrokeCollection (System.IO.Stream stream);
new System.Windows.Ink.StrokeCollection : System.IO.Stream -> System.Windows.Ink.StrokeCollection
Public Sub New (stream As Stream)
參數
- stream
- Stream
包含筆墨資料的資料流。
範例
下列範例示範如何儲存和載入 StrokeCollection 。 此範例假設有一個名為 InkCanvas 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 Sub SaveStrokes_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
Dim fs As FileStream = Nothing
Try
fs = New FileStream(inkFileName, FileMode.Create)
inkCanvas1.Strokes.Save(fs)
Finally
If Not fs Is Nothing Then
fs.Close()
End If
End Try
End Sub
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();
}
}
}
Private Sub LoadStrokes_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
Dim fs As FileStream = Nothing
If Not File.Exists(inkFileName) Then
MessageBox.Show("The file you requested does not exist." & _
" Save the StrokeCollection before loading it.")
Return
End If
Try
fs = New FileStream(inkFileName, _
FileMode.Open, FileAccess.Read)
Dim strokes As StrokeCollection = New StrokeCollection(fs)
inkCanvas1.Strokes = strokes
Finally
If Not fs Is Nothing Then
fs.Close()
End If
End Try
End Sub