private void Form1_FormClosing(object sender, FormClosingEventArgs e) { if (isNeedSave == true) { DialogResult result = MessageBox.Show("Сохранить изменения?", "Сохранить?", MessageBoxButtons.YesNoCancel); if (result == DialogResult.Yes) { if (!string.IsNullOrEmpty(path)) { FileLogic.Save(ref text, ref isNeedSave, ref path); } else { FileLogic.SaveAs(ref text, ref isNeedSave, ref path); } Application.Exit(); } else if (result == DialogResult.No) { isNeedSave = false; Application.Exit(); } else if (result == DialogResult.Cancel) { e.Cancel = true; } } }
private void создатьToolStripMenuItem_Click(object sender, EventArgs e) { if (isNeedSave == true) { DialogResult message = MessageBox.Show("Сохранить изменения?", "Создание документа", MessageBoxButtons.YesNoCancel); if (message == DialogResult.Yes) { if (string.IsNullOrEmpty(path)) { FileLogic.Save(ref text, ref isNeedSave, ref path); } else { FileLogic.SaveAs(ref text, ref isNeedSave, ref path); } FileLogic.Create(ref text, ref isNeedSave, ref path); } else if (message == DialogResult.No) { FileLogic.Create(ref text, ref isNeedSave, ref path); } } else { FileLogic.Create(ref text, ref isNeedSave, ref path); } }
private void сохранитьToolStripMenuItem_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(path)) { FileLogic.Save(ref text, ref isNeedSave, ref path); } else { FileLogic.SaveAs(ref text, ref isNeedSave, ref path); } }