コード例 #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;
                }
            }
        }
コード例 #2
0
 public MarkdownTree(UniverseViewModel universe)
 {
     UniverseVm = universe;
     Items      = new BindingList <MarkdownTreeItem>();
     Categories = new BindingList <MarkdownCategoryViewModel>();
 }
コード例 #3
0
 public FileBrowserViewModel(UniverseViewModel universe)
 {
     UniverseVm = universe;
     Files      = new SortBySortIndexBindingList <FileBlobViewModel>();
 }
コード例 #4
0
 public MarkdownDocumentViewModel(MarkdownDocument model, UniverseViewModel universe)
 {
     Model      = model;
     UniverseVm = universe;
 }
コード例 #5
0
 public TicketTrackerViewModel(UniverseViewModel universe)
 {
     UniverseVm = universe;
     Tickets    = new BindingList <TicketViewModel>();
 }
コード例 #6
0
 public SpellcheckDictionary(UniverseViewModel universe)
 {
     Words      = new BindingList <SpellcheckWord>();
     UniverseVm = universe;
     LoadFromDatabase();
 }
コード例 #7
0
        public void Load()
        {
            // Load database entities and create viewmodels.
            var universes  = Universe.GetAllUniverses(_connection).Select(i => new UniverseViewModel(i, this)).ToList();
            var categories = Category.GetAllSeries(_connection).Select(i => new CategoryViewModel(i)).ToList();
            var stories    = Story.GetAllStories(_connection).Select(i => new StoryViewModel(i)).ToList();
            var chapters   = Chapter.GetAllChapters(_connection).Select(i => new ChapterViewModel(i)).ToList();
            var scenes     = Scene.GetAllScenes(_connection).Select(i => new SceneViewModel(i)).ToList();

            // Link up objects.
            foreach (var chapter in chapters)
            {
                var chapterScenes = scenes.Where(i => i.Model.ChapterId == chapter.Model.id);
                foreach (var scene in chapterScenes)
                {
                    scene.ChapterVm = chapter;
                    chapter.Scenes.Add(scene);
                }
            }

            foreach (var story in stories)
            {
                var storyChapters = chapters.Where(i => i.Model.StoryId == story.Model.id);
                foreach (var chapter in storyChapters)
                {
                    chapter.StoryVm = story;
                    story.Chapters.Add(chapter);
                }
            }

            foreach (var cat in categories)
            {
                var catStories = stories.Where(i => i.Model.CategoryId == cat.Model.id);
                foreach (var ss in catStories)
                {
                    cat.Stories.Add(ss);
                }
            }

            foreach (var u in universes)
            {
                var cats = categories.Where(i => i.Model.UniverseId == u.Model.id);
                foreach (var cat in cats)
                {
                    u.Categories.Add(cat);
                    u.SubItems.Add(cat);
                    cat.UniverseVm = u;
                }

                var stories1 = stories.Where(i => i.Model.UniverseId == u.Model.id);
                foreach (var s in stories1)
                {
                    u.Stories.Add(s);
                    s.UniverseVm = u;
                    u.UpdateStoryInTree(s);
                }

                Universes.Add(u);
            }

            long defaultUniverseId            = Metadata.DefaultUniverseId;
            UniverseViewModel defaultUniverse = Universes.SingleOrDefault(i => i.Model.id == defaultUniverseId);

            if (defaultUniverse != null)
            {
                SelectedUniverse = defaultUniverse;
            }
        }
コード例 #8
0
 public MarkdownCategoryViewModel(MarkdownCategory model, UniverseViewModel universe)
 {
     Model      = model;
     UniverseVm = universe;
 }