잉크 저장
업데이트: 2007년 11월
Save 메서드를 사용하면 잉크를 ISF(Serialize된 잉크 형식)로 저장할 수 있습니다. StrokeCollection 클래스의 생성자는 잉크 데이터를 읽을 수 있도록 합니다.
잉크 저장소 및 검색
이 단원에서는 WPF 플랫폼에서 잉크를 저장하고 검색하는 방법에 대해 설명합니다.
다음 예제에서는 사용자에게 파일 저장 대화 상자를 표시하고 InkCanvas의 잉크를 파일로 저장할 수 있는 단추 클릭 이벤트 처리기를 구현합니다.
Private Sub buttonSaveAsClick(ByVal sender As Object, ByVal e As RoutedEventArgs)
Dim saveFileDialog1 As New SaveFileDialog()
saveFileDialog1.Filter = "isf files (*.isf)|*.isf"
If saveFileDialog1.ShowDialog() Then
Dim fs As New FileStream(saveFileDialog1.FileName, FileMode.Create)
theInkCanvas.Strokes.Save(fs)
fs.Close()
End If
End Sub 'buttonSaveAsClick
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();
}
}
다음 예제에서는 사용자에게 파일 열기 대화 상자를 표시하고 파일에서 InkCanvas 요소로 잉크를 읽어들이는 단추 클릭 이벤트 처리기를 구현합니다.
Private Sub buttonLoadClick(ByVal sender As Object, ByVal e As RoutedEventArgs)
Dim openFileDialog1 As New OpenFileDialog()
openFileDialog1.Filter = "isf files (*.isf)|*.isf"
If openFileDialog1.ShowDialog() Then
Dim fs As New FileStream(openFileDialog1.FileName, FileMode.Open)
theInkCanvas.Strokes = New StrokeCollection(fs)
fs.Close()
End If
End Sub 'buttonLoadClick
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();
}
}