private void saveToolStripMenuItem_Click(object sender, EventArgs e) { if (currentFileEditor.IsDirty()) { if (currentFileEditor.IsNew()) { SaveAs(); } else { Save(currentFileEditor.Path()); } } }
private void CloseTab() { bool success = true; int currentTabIndex = tabControl.SelectedIndex; currentFileEditor = (FileEditor)fileEditors[currentTabIndex]; if (currentFileEditor.IsDirty()) { if (currentFileEditor.IsNew()) { DialogResult result = MessageBox.Show("Do you want to save " + currentFileEditor.ShortName() + "?", "Saving file", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); if (result == DialogResult.Yes) { success = SaveAs(); } else if (result == DialogResult.Cancel) { success = false; } } else { DialogResult result = MessageBox.Show("Do you want to save " + currentFileEditor.ShortName() + "?", "Saving file", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); if (result == DialogResult.Yes) { Save(currentFileEditor.Path()); } else if (result == DialogResult.Cancel) { success = false; } } } if (success) { if (tabControl.TabCount == 1) { System.Environment.Exit(0); } else { fileEditors.RemoveAt(currentTabIndex); tabControl.SelectedTab.Dispose(); if (currentTabIndex == tabControl.TabCount) { tabControl.SelectTab(currentTabIndex - 1); } else { tabControl.SelectTab(currentTabIndex); } } } }
private bool CloseFile() { int i = 0; while (i < tabControl.TabCount) { currentFileEditor = (FileEditor)fileEditors[i]; tabControl.SelectTab(i); if (currentFileEditor.IsDirty()) { if (currentFileEditor.IsNew()) { DialogResult result = MessageBox.Show("Do you want to save this file?", "Saving new file", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); if (result == DialogResult.Yes) { if (SaveAs() == false) { return(false); } } else if (result == DialogResult.Cancel) { return(false); } } else { DialogResult result = MessageBox.Show("Do you want to save " + currentFileEditor.ShortName() + "?", "Saving file", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); if (result == DialogResult.Yes) { Save(currentFileEditor.Path()); } else if (result == DialogResult.Cancel) { return(false); } } } i++; } saveSession(); return(true); }
private bool CloseFile() { int i = 0; while (i < tabControl.TabCount) { currentFileEditor = (FileEditor)fileEditors[i]; tabControl.SelectTab(i); if (currentFileEditor.IsDirty()) { if (currentFileEditor.IsNew()) { DialogResult result = MessageBox.Show("Do you want to save this file?", "Saving new file", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); if (result == DialogResult.Yes) { if (SaveAs() == false) return false; } else if (result == DialogResult.Cancel) return false; } else { DialogResult result = MessageBox.Show("Do you want to save " + currentFileEditor.ShortName() + "?", "Saving file", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); if (result == DialogResult.Yes) Save(currentFileEditor.Path()); else if (result == DialogResult.Cancel) return false; } } i++; } saveSession (); return true; }
private void CloseTab() { bool success = true; int currentTabIndex = tabControl.SelectedIndex; currentFileEditor = (FileEditor)fileEditors[currentTabIndex]; if (currentFileEditor.IsDirty()) { if (currentFileEditor.IsNew()) { DialogResult result = MessageBox.Show("Do you want to save " + currentFileEditor.ShortName() + "?", "Saving file", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); if (result == DialogResult.Yes) success = SaveAs(); else if (result == DialogResult.Cancel) success = false; } else { DialogResult result = MessageBox.Show("Do you want to save " + currentFileEditor.ShortName() + "?", "Saving file", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); if (result == DialogResult.Yes) Save(currentFileEditor.Path()); else if (result == DialogResult.Cancel) success = false; } } if (success) { if (tabControl.TabCount == 1) System.Environment.Exit(0); else { fileEditors.RemoveAt(currentTabIndex); tabControl.SelectedTab.Dispose(); if (currentTabIndex == tabControl.TabCount) { tabControl.SelectTab(currentTabIndex - 1); } else tabControl.SelectTab(currentTabIndex); } } }