Mürekkep Depolama
Yöntemler, Save mösyöleri Mürekkep SeriLeştirilmiş Biçimi (ISF) olarak depolama desteği sağlar. Sınıfın StrokeCollection oluşturucuları mürekkep verilerini okuma desteği sağlar.
Mürekkep Depolama ve Alma
Bu bölümde WPF platformunda mürekkep depolama ve alma konuları ele alınmaktadır.
Aşağıdaki örnek, kullanıcıya Dosya Kaydet iletişim kutusu sunan ve mürekkepten dosyaya kaydeden InkCanvas bir düğme tıklaması olay işleyicisi uygular.
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();
}
}
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
Aşağıdaki örnek, kullanıcıya Dosya Aç iletişim kutusu sunan ve dosyadan bir öğeye InkCanvas mürekkep okuyan bir düğme tıklaması olay işleyicisi uygular.
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();
}
}
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
Ayrıca bkz.
GitHub'da bizimle işbirliği yapın
Bu içeriğin kaynağı GitHub'da bulunabilir; burada ayrıca sorunları ve çekme isteklerini oluşturup gözden geçirebilirsiniz. Daha fazla bilgi için katkıda bulunan kılavuzumuzu inceleyin.
.NET Desktop feedback