public void Save() { // do not save, if we have nothing to save if (isSaved) { return; } SavableNote savableNote = new SavableNote(); savableNote.Title = titleBox.Text; savableNote.IsPdfPresent = isPdfPresent; foreach (Slide slide in slidesList) { savableNote.AddSlide(new SavableSlide(slide)); } IFormatter formatter = new BinaryFormatter(); Stream stream = new FileStream(fileName, FileMode.Create, FileAccess.Write, FileShare.None); formatter.Serialize(stream, savableNote); stream.Close(); isSaved = true; }
public Note(StackPanel panel, string fileName, NoteWindow noteWindow) : this(panel, noteWindow) { this.fileName = fileName; IFormatter formatter = new BinaryFormatter(); Stream stream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read); SavableNote savableNote = (SavableNote)formatter.Deserialize(stream); stream.Close(); titleBox.Text = savableNote.Title; noteWindow.Title = System.IO.Path.GetFileNameWithoutExtension(fileName) + " - NoteIt"; foreach (SavableSlide slide in savableNote.SlidesList) { AddSlideOnEnd(slide); } isPdfPresent = savableNote.IsPdfPresent; isSaved = true; }