public void OpenInWindow(IHasMarkdownDocument parent = null) { // Synchronize item names if necessary. if (parent != null && Model.IsSpecial) { Model.Name = (parent as IHasNameProperty).Name; Model.Save(); } MarkdownDocumentWindow.ShowMarkdownDocument(this); }
public void OpenOrCreateNoteForItem() { if (SelectedTreeViewItem == null) { return; } IHasMarkdownDocument item = null; if (SelectedTreeViewItem is CategoryViewModel) { item = (SelectedTreeViewItem as CategoryViewModel).Model; } else if (SelectedTreeViewItem is StoryViewModel) { item = (SelectedTreeViewItem as StoryViewModel).Model; } else if (SelectedTreeViewItem is ChapterViewModel) { item = (SelectedTreeViewItem as ChapterViewModel).Model; } else if (SelectedTreeViewItem is SceneViewModel) { item = (SelectedTreeViewItem as SceneViewModel).Model; } if (item == null) { return; } MarkdownDocument doc = null; if (item.MarkdownDocumentId.HasValue) { doc = new MarkdownDocument(Model.Connection); doc.id = item.MarkdownDocumentId.Value; doc.Load(); } else { doc = MarkdownDocumentViewModel.CreateDocForItem(item, Model.id, true, (item as IHasNameProperty).Name); } if (doc != null) { MarkdownDocumentViewModel vm = new MarkdownDocumentViewModel(doc, this); vm.OpenInWindow(); } }
public static MarkdownDocument CreateDocForItem(IHasMarkdownDocument item, long universeId, bool isSpecial, string name) { MarkdownDocument doc = new MarkdownDocument(item.Connection); doc.UniverseId = universeId; doc.IsSpecial = isSpecial; doc.Name = name; doc.MarkdownText = ""; doc.PlainText = ""; doc.Create(); item.MarkdownDocumentId = doc.id; item.Save(); return(doc); }