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; } } }
public MarkdownTree(UniverseViewModel universe) { UniverseVm = universe; Items = new BindingList <MarkdownTreeItem>(); Categories = new BindingList <MarkdownCategoryViewModel>(); }
public FileBrowserViewModel(UniverseViewModel universe) { UniverseVm = universe; Files = new SortBySortIndexBindingList <FileBlobViewModel>(); }
public MarkdownDocumentViewModel(MarkdownDocument model, UniverseViewModel universe) { Model = model; UniverseVm = universe; }
public TicketTrackerViewModel(UniverseViewModel universe) { UniverseVm = universe; Tickets = new BindingList <TicketViewModel>(); }
public SpellcheckDictionary(UniverseViewModel universe) { Words = new BindingList <SpellcheckWord>(); UniverseVm = universe; LoadFromDatabase(); }
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; } }
public MarkdownCategoryViewModel(MarkdownCategory model, UniverseViewModel universe) { Model = model; UniverseVm = universe; }