示例#1
0
 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);
 }
示例#2
0
        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();
            }
        }
示例#3
0
        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);
        }