Esempio n. 1
0
        public void CreateUniverse()
        {
            NameItemDialog dialog = new NameItemDialog(DialogOwner, "New Universe");
            bool?          result = dialog.ShowDialog();

            if (result.HasValue && result.Value)
            {
                Universe uni = new Universe(_connection);
                uni.Name = dialog.UserInput;
                if (Universes.Count == 0)
                {
                    uni.SortIndex = 0;
                }
                else
                {
                    uni.SortIndex = Universes.Max(i => i.Model.SortIndex) + 1;
                }
                uni.Create();
                UniverseViewModel vm = new UniverseViewModel(uni, this);
                Universes.Add(vm);

                if (Universes.Count == 1)
                {
                    SelectedUniverse = vm;
                }
            }
        }
Esempio n. 2
0
        public void CreateDocument(MarkdownCategoryViewModel parent = null)
        {
            NameItemDialog dialog       = new NameItemDialog(DialogOwner, "New Note");
            bool?          dialogResult = dialog.ShowDialog();

            if (dialogResult.HasValue && dialogResult.Value)
            {
                MarkdownDocument doc = new MarkdownDocument(UniverseVm.Model.Connection);
                doc.Name         = dialog.UserInput;
                doc.UniverseId   = UniverseVm.Model.id;
                doc.MarkdownText = string.Format("# {0}\r\nThis is a new note document.", doc.Name);
                doc.PlainText    = Markdig.Markdown.ToPlainText(doc.MarkdownText);
                doc.Create();

                MarkdownDocumentViewModel docVm = new MarkdownDocumentViewModel(doc, UniverseVm);

                if (parent != null)
                {
                    MarkdownCategoryDocument link = new MarkdownCategoryDocument(UniverseVm.Model.Connection);
                    link.MarkdownDocumentId = doc.id;
                    link.MarkdownCategoryId = parent.Model.id;
                    link.Create();

                    docVm.Parent = parent;
                    parent.Children.Add(docVm);
                }
                else
                {
                    Items.Add(docVm);
                }
            }
        }
Esempio n. 3
0
        public void CreateScene()
        {
            NameItemDialog dialog = new NameItemDialog(DialogOwner, "New Scene");
            bool?          result = dialog.ShowDialog();

            if (result.HasValue && result.Value)
            {
                FlowDocument doc = new FlowDocument(Model.Connection);
                doc.UniverseId = StoryVm.Model.UniverseId;
                doc.WordCount  = 0;
                doc.PlainText  = "";
                doc.Xml        = FlowDocumentViewModel.GetEmptyFlowDocXml();
                doc.Create();

                Scene scene = new Scene(Model.Connection);
                scene.ChapterId = Model.id;
                scene.Name      = dialog.UserInput;
                if (Scenes.Count == 0)
                {
                    scene.SortIndex = 0;
                }
                else
                {
                    scene.SortIndex = Scenes.Max(i => i.Model.SortIndex) + 1;
                }
                scene.FlowDocumentId = doc.id;
                scene.Create();
                SceneViewModel sceneVm = new SceneViewModel(scene);
                sceneVm.ChapterVm = this;
                Scenes.Add(sceneVm);
            }
        }
Esempio n. 4
0
        public void Rename()
        {
            NameItemDialog dialog = new NameItemDialog(DialogOwner, Model.Name);
            bool?          result = dialog.ShowDialog();

            if (result.HasValue && result.Value)
            {
                Model.Name = dialog.UserInput;
            }
        }
        public void Rename()
        {
            NameItemDialog dialog       = new NameItemDialog(ViewModelBase.DialogOwner, Owner.Model.Name);
            bool?          dialogResult = dialog.ShowDialog();

            if (dialogResult.Value)
            {
                Owner.Model.Name = dialog.UserInput;
                Owner.Model.Save();
                Name = Owner.Model.Name;
            }
        }
Esempio n. 6
0
 public void Rename()
 {
     if (Owner is SceneViewModel)
     {
         SceneViewModel scene        = (SceneViewModel)Owner;
         NameItemDialog dialog       = new NameItemDialog(ViewModelBase.DialogOwner, scene.Model.Name);
         bool?          dialogResult = dialog.ShowDialog();
         if (dialogResult.Value)
         {
             scene.Model.Name = dialog.UserInput;
             scene.Model.Save();
             Name = scene.Model.Name;
         }
     }
 }
Esempio n. 7
0
        public void AddFile()
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            if (openFileDialog.ShowDialog().Value)
            {
                NameItemDialog nameDialog   = new NameItemDialog(DialogOwner, "New File");
                bool?          dialogResult = nameDialog.ShowDialog();
                if (dialogResult.HasValue && dialogResult.Value)
                {
                    FileBlob file = new FileBlob(UniverseVm.Model.Connection);
                    file.Name       = nameDialog.UserInput;
                    file.FileName   = Path.GetFileName(openFileDialog.FileName);
                    file.UniverseId = UniverseVm.Model.id;

                    string extension = Path.GetExtension(openFileDialog.FileName).ToLower();

                    if (extension == ".png")
                    {
                        file.FileType = FileBlob.FILE_TYPE_PNG;
                    }
                    else if (extension == ".jpg" || extension == ".jpeg")
                    {
                        file.FileType = FileBlob.FILE_TYPE_JPEG;
                    }
                    else if (extension == ".dotx")
                    {
                        file.FileType = FileBlob.FILE_TYPE_TEMPLATE;
                    }
                    else
                    {
                        file.FileType = FileBlob.FILE_TYPE_OTHER;
                    }

                    if (Files.Count > 0)
                    {
                        file.SortIndex = Files.Max(i => i.Model.SortIndex) + 1;
                    }
                    file.Create();
                    file.LoadFile(openFileDialog.FileName);

                    FileBlobViewModel vm = new FileBlobViewModel(file, this);
                    Files.Add(vm);
                }
            }
        }
Esempio n. 8
0
        public void CreateCategory()
        {
            NameItemDialog dialog = new NameItemDialog(DialogOwner, "New Category");
            bool?          result = dialog.ShowDialog();

            if (result.HasValue && result.Value)
            {
                Category category = new Category(Model.Connection);
                category.UniverseId = Model.id;
                category.Name       = dialog.UserInput;
                if (SubItems.Count > 0)
                {
                    category.SortIndex = SubItems.Max(i => i.SortIndex) + 1;
                }
                category.Create();

                CategoryViewModel catVm = new CategoryViewModel(category);
                catVm.UniverseVm = this;
                Categories.Add(catVm);
                SubItems.Add(catVm);
            }
        }
Esempio n. 9
0
        public void CreateChapter()
        {
            NameItemDialog dialog = new NameItemDialog(DialogOwner, "New Chapter");
            bool?          result = dialog.ShowDialog();

            if (result.HasValue && result.Value)
            {
                Chapter chapter = new Chapter(Model.Connection);
                chapter.StoryId = Model.id;
                chapter.Name    = dialog.UserInput;
                if (Chapters.Count == 0)
                {
                    chapter.SortIndex = 0;
                }
                else
                {
                    chapter.SortIndex = Chapters.Max(i => i.Model.SortIndex) + 1;
                }
                chapter.Create();
                ChapterViewModel chapterVm = new ChapterViewModel(chapter);
                chapterVm.StoryVm = this;
                Chapters.Add(chapterVm);
            }
        }