private void topBarSaveAs_Click(object sender, EventArgs e) { if (ProjectManager.SaveFileExists) { saveFileDialog.InitialDirectory = ProjectManager.FilePath; } DialogResult result = saveFileDialog.ShowDialog(); if (result == DialogResult.OK) { switch (ProjectManager.SaveProject(saveFileDialog.FileName)) { case 1: MessageBox.Show("Specified directory does not exist.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; case 2: MessageBox.Show("An error has occurred during saving.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } unsaved = false; Settings.Save(textBoxMain.Font, textBoxMain.ForeColor, textBoxMain.BackColor); RefreshTitle(); RefreshMostRecentAvailable(); } }
private void topBarNew_Click(object sender, EventArgs e) { if (unsaved) { DialogResult result = MessageBox.Show("All unsaved changes will be lost, do you want to save them before creating a new project?", "New Project", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); if (result == DialogResult.Cancel) { return; } else if (result == DialogResult.Yes) { if (ProjectManager.SaveFileExists) { switch (ProjectManager.SaveProject(ProjectManager.FilePath)) { case 1: MessageBox.Show("Specified directory does not exist.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; case 2: MessageBox.Show("An error has occurred during saving.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } unsaved = false; } else { result = saveFileDialog.ShowDialog(); if (result == DialogResult.OK) { switch (ProjectManager.SaveProject(saveFileDialog.FileName)) { case 1: MessageBox.Show("Specified directory does not exist.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; case 2: MessageBox.Show("An error has occurred during saving.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } unsaved = false; } } } } ProjectManager.NewProject(); dropdownTriggers.Items.Clear(); dropdownDialogues.Items.Clear(); sequence = 0; initializing = true; dropdownCharacters.SelectedIndex = 0; initializing = false; unsaved = false; RefreshWindow(); }
private void EditorWindow_FormClosing(object sender, FormClosingEventArgs e) { if (unsaved) { DialogResult result = MessageBox.Show("All unsaved changes will be lost, do you want to save them before creating a new project?", "New Project", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); if (result == DialogResult.Cancel) { e.Cancel = true; } else if (result == DialogResult.Yes) { if (ProjectManager.SaveFileExists) { switch (ProjectManager.SaveProject(ProjectManager.FilePath)) { case 1: MessageBox.Show("Specified directory does not exist.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; case 2: MessageBox.Show("An error has occurred during saving.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } unsaved = false; return; } result = saveFileDialog.ShowDialog(); if (result == DialogResult.OK) { switch (ProjectManager.SaveProject(saveFileDialog.FileName)) { case 1: MessageBox.Show("Specified directory does not exist.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; case 2: MessageBox.Show("An error has occurred during saving.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } unsaved = false; } } } }
private void topBarOpenRecent_Click(object sender, EventArgs e) { if (unsaved) { DialogResult result = MessageBox.Show("All unsaved changes will be lost, do you want to save them before creating a new project?", "New Project", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); if (result == DialogResult.Cancel) { return; } else if (result == DialogResult.Yes) { if (ProjectManager.SaveFileExists) { switch (ProjectManager.SaveProject(ProjectManager.FilePath)) { case 1: MessageBox.Show("Specified directory does not exist.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; case 2: MessageBox.Show("An error has occurred during saving.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } unsaved = false; RefreshTitle(); } else { result = saveFileDialog.ShowDialog(); if (result == DialogResult.OK) { switch (ProjectManager.SaveProject(saveFileDialog.FileName)) { case 1: MessageBox.Show("Specified directory does not exist.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; case 2: MessageBox.Show("An error has occurred during saving.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } unsaved = false; RefreshTitle(); } } } } if (!ProjectManager.LastSaveFileExists) { MessageBox.Show("Most recent file not detected.", "Open Last", MessageBoxButtons.OK, MessageBoxIcon.Error); RefreshMostRecentAvailable(); return; } if (ProjectManager.LoadProject(ProjectManager.LastFilePath) == 1) { MessageBox.Show("An error has occurred while opening the file.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { dropdownTriggers.Items.Clear(); dropdownDialogues.Items.Clear(); sequence = 0; initializing = true; dropdownCharacters.SelectedIndex = 0; initializing = false; foreach (Area area in ProjectManager.Areas) { dropdownTriggers.Items.Add(area.Name); } if (dropdownTriggers.Items.Count > 0) { refreshing = true; dropdownTriggers.SelectedIndex = 0; refreshing = false; } unsaved = false; RefreshWindow(); } }