/// <summary> /// Create and initialize MoveScene UI. /// </summary> /// <param name="series"></param> /// <param name="scene"></param> public frmMoveItem(Series series, INotable item) { InitializeComponent(); this.series = series; this.item = item; PopulateBookList(); if (item is Scene) { PopulateChapterList(((Scene)item).ParentChapter.ParentBook); } else { lstChapters.Enabled = false; } }
public Book(string title, Series parent) { this.Title = title; AddToSeries(parent); Summary = ""; Notes = new List<Note>(); Chapters = new List<Chapter>(); }
public static Book LoadBook(BinaryReader br, Series parent) { Book bk = new Book(br.ReadString(), parent); bk.Summary = br.ReadString(); bk.UID = br.ReadInt32(); bk.Notes = Note.LoadListOfNotes(); bk.Chapters = Chapter.LoadListOfChapters(br, bk); return bk; }
public static List<Book> LoadListOfBooks(BinaryReader br, Series parent) { List<Book> books = new List<Book>(); int count = br.ReadInt32(); for (int i = 0; i < count; i++) { books.Add(LoadBook(br, parent)); } return books; }
/// <summary> /// /// </summary> /// <param name="csent">The character to be edited.</param> /// <param name="series">A reference to the current series.</param> /// <param name="f1">A reference to the main form.</param> /// <param name="lvi">A reference to the ListViewItem of this character. /// Null if creating a new character.</param> public frmCharacter(Character csent, Series series, ListViewItem lvi) { InitializeComponent(); ch = csent; this.series = series; this.lvi = lvi; this.Text = (lvi == null ? "New Character" : csent.Name); ch.Locked = true; frmMain.EditorOpened(); PopulateControls(); }
public EventEditor(Event evsent, Series series, ListViewItem lvi) { InitializeComponent(); frmMain.EditorOpened(); this.series = series; this.lvi = lvi; this.Text = evsent.Title; ev = evsent; ev.Locked = true; PopulateControls(); }
/// <summary> /// Give the user the option to create a new series. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void mopNewSeries_Click(object sender, EventArgs e) { if (!CanChangeSeries() || AskSaveSeries() == DialogResult.Cancel) return; // Make sure we're in the Projects directory to begin. Directory.SetCurrentDirectory(exec_dir); Utils.CreateSetDirectory("Projects"); while (InputStrDialog.Show("Create New Series", "Enter a title for this series:") == DialogResult.OK) { string projname = InputStrDialog.Result; if (Directory.Exists(projname)) { MessageBox.Show("A project with this name already exists."); } else { // Create series + data series = new Series(projname); SuperNode = new TreeNode(series.Title); // Set up directory hierarchy Utils.CreateSetDirectory(projname); // Set up UI + controls RepopulateTree(); Text = "SigmaWriter - " + series.Title; EnableControls(true); // Save project // (1st two lines have filename, // last has full file path+name) projectName = projname + Constant.PROJ_EXT; series.SaveToFile(projectName, SeriesSaveType.CreateNewProject); projectDir = Directory.GetCurrentDirectory(); // Start timer if (Config.BackupEnabled) timerBackup.Start(); treeSeries.SelectedNode = SuperNode; UpdateSeriesUI(); break; } } }
/// <summary> /// Load another series. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void mopLoadSeries_Click(object sender, EventArgs e) { if (!CanChangeSeries() || AskSaveSeries() == DialogResult.Cancel) return; Directory.SetCurrentDirectory(exec_dir); Utils.CreateSetDirectory("Projects"); DirectoryInfo thisDir = new DirectoryInfo(Directory.GetCurrentDirectory()); DirectoryInfo[] projectList = thisDir.GetDirectories(); DialogResult dr = new frmOpenProject(projectList).ShowDialog(); if (dr == DialogResult.OK) { // Find the .sws file. Directory.SetCurrentDirectory(frmOpenProject.Result); DirectoryInfo di = new DirectoryInfo(Directory.GetCurrentDirectory()); FileInfo[] fi = di.GetFiles("*" + Constant.PROJ_EXT); if (fi.Length > 1) { MessageBox.Show("More than one project file found in this directory."); Directory.SetCurrentDirectory((projectDir == "" ? exec_dir : projectDir)); return; } else if (fi.Length < 1) { MessageBox.Show("No valid project file found."); Directory.SetCurrentDirectory((projectDir == "" ? exec_dir : projectDir)); return; } // Load series projectName = fi[0].Name; series = new Series(); series.LoadFromFile(projectName); // Set data references workob = series; selnode = treeSeries.TopNode; // Initialize UI Text = "SigmaWriter - " + series.Title; RepopulateTree(); UpdateSeriesUI(); EnableControls(true); treeSeries.SelectedNode = treeSeries.TopNode; if (Config.BackupEnabled) timerBackup.Start(); return; } Directory.SetCurrentDirectory((projectDir == "" ? exec_dir : projectDir)); }
/// <summary> /// Close the current series (necessary?) /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void mopCloseSeries_Click(object sender, EventArgs e) { if (!CanChangeSeries() || AskSaveSeries() == DialogResult.Cancel) return; series = null; EnableControls(false); ClearControls(); tconMain.SelectedTab = tabSeries; tconSeries.SelectedTab = tabSeriesGeneral; Directory.SetCurrentDirectory(exec_dir); timerBackup.Stop(); }
/// <summary> /// Add this book to a series. /// </summary> /// <param name="parent"></param> public void AddToSeries(Series parent) { parent.Books.Add(this); ParentSeries = parent; // Ensure this book has a unique UID // Assign it the next highest List<int> uids = new List<int>(); foreach (Book b_item in parent.Books) { uids.Add(b_item.UID); } UID = 1; while (uids.Contains(UID)) UID++; }