Ejemplo n.º 1
0
        public void CreateTicket()
        {
            Ticket ticket = new Ticket(UniverseVm.Model.Connection);

            ticket.UniverseId = UniverseVm.Model.id;
            ticket.Name       = "New Ticket";
            ticket.Priority   = 2;
            ticket.Status     = "Not Started";
            ticket.DueDate    = ""; // Not fully implemented.
            ticket.Create();

            // Create MarkdownDocument for ticket.
            MarkdownDocument doc = MarkdownDocumentViewModel.CreateDocForItem(ticket, ticket.UniverseId, true, string.Format("Ticket {0}", ticket.id));

            doc.MarkdownText = "New Ticket.";
            doc.PlainText    = Markdig.Markdown.ToPlainText(doc.MarkdownText);
            doc.Save();

            // Add to list.
            TicketViewModel vm = new TicketViewModel(ticket, this);

            Tickets.Add(vm);

            // Show edit dialog.
            vm.Edit();
        }
Ejemplo n.º 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();
            }
        }