private void OnLoad_Click(object sender, RoutedEventArgs e) { OpenFileDialog openFileDlg = new OpenFileDialog() { Filter = "WILL3 file (*.uim)|*.uim|All files (*.*)|*.*" }; if (openFileDlg.ShowDialog() == true) { using (BinaryReader reader = new BinaryReader(File.Open(openFileDlg.FileName, FileMode.Open))) { var info = new FileInfo(openFileDlg.FileName); byte[] buff = new byte[info.Length]; reader.Read(buff, 0, (int)info.Length); var inkDocument = Will3Codec.Decode(buff); InkControlBase inkCtrl = null; if (inkDocument.Brushes.RasterBrushes.Count > 0 && inkDocument.Brushes.VectorBrushes.Count > 0) { MessageBox.Show("This sample does not support serialization of both raster and vector brushes"); } else if (inkDocument.Brushes.RasterBrushes.Count > 0) { SetCurrentControl(inkCtrl = new RasterInkControl(RasterBrushStyle.Pencil, BrushColor, inkDocument)); ToggleBrushButton(BtnPencil); } else if (inkDocument.Brushes.VectorBrushes.Count > 0) { SetCurrentControl(inkCtrl = new VectorInkControl(VectorBrushStyle.Pen, BrushColor, inkDocument)); ToggleBrushButton(BtnPen); } else { inkCtrl = NavFrame.Content as InkControlBase; inkCtrl?.ClearStrokes(); } } } }
private void OnClear_Click(object sender, RoutedEventArgs e) { InkControlBase inkCtrl = NavFrame.Content as InkControlBase; inkCtrl?.ClearStrokes(); }