public MainWindow() { string filePath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/TodoList/"; Directory.CreateDirectory(filePath); InitializeComponent(); IFormatter formatter = new BinaryFormatter(); try { Stream inStream = new FileStream(filePath + "todo.info", FileMode.Open, FileAccess.Read); lastFile = (String)formatter.Deserialize(inStream); } catch (Exception) { } if (!String.IsNullOrEmpty(lastFile)) { openFile(lastFile); } else { ph = new ProjectHolder(); projList.DataContext = ph; ph.UpdatePropertyHandlers(); } }
private void openFile(string file) { IFormatter formatter = new BinaryFormatter(); ph = new ProjectHolder(); try { Stream inStream = new FileStream(file, FileMode.Open, FileAccess.Read); ph = (ProjectHolder)formatter.Deserialize(inStream); inStream.Close(); } catch (Exception) { } DataContext = ph; projList.DataContext = ph; ph.UpdatePropertyHandlers(); }
private void MenuItem_Click_2(object sender, RoutedEventArgs e) { ph = new ProjectHolder(); projList.DataContext = ph; ph.UpdatePropertyHandlers(); }