public static Chapter LoadChapter(BinaryReader br, Book parent) { Chapter cp = new Chapter(br.ReadString(), parent); // Title cp.Summary = br.ReadString(); cp.Notes = Note.LoadListOfNotes(); cp.MajorConflict = br.ReadString(); cp.MinorConflict = br.ReadString(); cp.Scenes = Scene.LoadListOfScenes(br, cp); return cp; }
/// <summary> /// Initializes scene via file read. /// </summary> /// <param name="br"></param> /// <param name="parent"></param> public Scene(BinaryReader br, Chapter parent) { Title = br.ReadString(); UID = br.ReadUInt32(); uids.Add(UID); AddToChapter(parent); Summary = ""; POV = null; Notes = new List<Note>(); Locked = false; }
/// <summary> /// Constructor when initializing scene via UI. /// </summary> /// <param name="title"></param> /// <param name="parent"></param> public Scene(string title, Chapter parent) { this.Title = title; AddToChapter(parent); Summary = ""; POV = null; Notes = new List<Note>(); Locked = false; // Find a unique, permanent FileID for this scene. UID = 1; while (uids.Contains(UID)) { UID++; } uids.Add(UID); }
/// <summary> /// Context menu: Add chapter /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void copAddChapter_Click(object sender, EventArgs e) { if (InputStrDialog.Show("Add Chapter", "Enter title for chapter:") == DialogResult.OK) { Chapter cp = new Chapter(InputStrDialog.Result, (Book)rightnode.Tag); TreeNode node = new TreeNode(cp.Title); rightnode.Nodes.Add(node); node.Tag = cp; SetTreeNodeIcons(node); ListViewItem lvi = new ListViewItem(cp.Title); lvi.SubItems.Add(""); sortChapters.AddItem(lvi); } treeSeries.SelectedNode = selnode; }
/// <summary> /// Add this scene to a chapter. /// </summary> /// <param name="chapter"></param> public void AddToChapter(Chapter parent) { parent.Scenes.Add(this); ParentChapter = parent; }
public static Scene LoadScene(BinaryReader br, Chapter parent) { // Title and UID read in constructor Scene sc = new Scene(br, parent); sc.Summary = br.ReadString(); sc.Notes = Note.LoadListOfNotes(); int povUID = br.ReadInt32(); if (povUID == 0) { sc.POV = null; } else { foreach (Character ch in parent.ParentBook.ParentSeries.Characters) { if (povUID == ch.UID) { sc.POV = ch; break; } } } return sc; }
public static List<Scene> LoadListOfScenes(BinaryReader br, Chapter parent) { List<Scene> list = new List<Scene>(); int count = br.ReadInt32(); for (int i = 0; i < count; i++) { list.Add(LoadScene(br, parent)); } return list; }
/// <summary> /// Search recursively through series until series is found. Delete series and its UID. /// </summary> /// <param name="scene"></param> public void DeleteScene(Scene scene, Chapter chapter) { chapter.Scenes.Remove(scene); Scene.deletedUIDS.Add(scene.UID); }
public void DeleteChapter(Chapter cp, Book book) { book.Chapters.Remove(cp); foreach (Scene sc in cp.Scenes) { Scene.deletedUIDS.Add(sc.UID); } }