private void Load(Book book, Note note = null) { InitializeComponent(); vm = new EditNoteViewModel(this, book, note); this.DataContext = vm; }
public EditNoteViewModel(Window window, Book book, Note noteForEdit = null) { this.window = window; this.book = book; this.note = noteForEdit; InitializeValues(); }
public void RemoveNote(Note note) { throw new NotImplementedException(); }
private void Parse() { try { ParsedNotes.Clear(); StringReader sr = new StringReader(InputText); string line; string current = ""; string NoteEnd = "Add a note"; string LocationStart = "Read more at location "; while ((line = sr.ReadLine()) != null) { current += line + " "; if (current.Contains(NoteEnd)) { int start, end; start = current.IndexOf(LocationStart); string text = current.Substring(0, start); start = start + LocationStart.Length; end = current.IndexOf(" ", start + 1); string location = current.Substring(start, end - start); Note note = new Note() { Created = DateTime.Now, Updated = DateTime.Now, Book = SelectedBook, Location = location, OriginalText = text, Topic = SelectedBook.DefaultTopic }; ParsedNotes.Add(new TreeNode(TreeNode.NodeType.Leaf, note, note.OriginalText)); current = ""; } } } catch (Exception e) { MessageBoxFactory.ShowError(e); } }
public EditNotesWindow(Book book, Note note) { Load(book, note); }
private void SaveChange() { try { if (string.IsNullOrEmpty(Location)) throw new RequiredFieldException("Location"); else if (string.IsNullOrEmpty(OriginalText)) throw new RequiredFieldException("OriginalText"); else if (SelectedTopic == null) throw new RequiredFieldException("Topic"); if (IsEdit) { note.Location = Location; note.OriginalText = OriginalText; note.Published = IsPublished; //note.SubTopic = SelectedSubTopic; note.Topic = SelectedTopic; note.Updated = DateTime.Now; note.WriteUp = WriteUp; note.Notes = Notes; } else { Note note = new Note() { Book = book, Topic = SelectedTopic, Location = Location, OriginalText = OriginalText, //SubTopic = SelectedSubTopic, Created = DateTime.Now, Updated = DateTime.Now, WriteUp = WriteUp, Notes = Notes }; Workspace.Current.DB.Notes.Add(note); } Workspace.Current.DB.SaveChanges(); cancelled = false; window.Close(); } catch (Exception e) { Workspace.Current.DB.RejectChanges(); MessageBoxFactory.ShowError(e); } }