Исправлено закрытие редактора конфигов без открытого файла
Signed-off-by: Lev Rusanov <30170278+JDM170@users.noreply.github.com>
This commit is contained in:
@@ -65,17 +65,20 @@ namespace ConfigEditor
|
|||||||
|
|
||||||
private bool CheckChanges()
|
private bool CheckChanges()
|
||||||
{
|
{
|
||||||
if (richTextBox1.Text != File.ReadAllText(opened_file))
|
if (opened_file != null)
|
||||||
{
|
{
|
||||||
DialogResult result = MessageBox.Show("The document has been modified.\nDo you want to save your changes?", "Question", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
|
if (richTextBox1.Text != File.ReadAllText(opened_file))
|
||||||
if (result == DialogResult.Yes)
|
|
||||||
{
|
{
|
||||||
File.WriteAllText(opened_file, richTextBox1.Text);
|
DialogResult result = MessageBox.Show("The document has been modified.\nDo you want to save your changes?", "Question", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
|
||||||
MessageBox.Show("File successfully saved.", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
if (result == DialogResult.Yes)
|
||||||
return true;
|
{
|
||||||
|
File.WriteAllText(opened_file, richTextBox1.Text);
|
||||||
|
MessageBox.Show("File successfully saved.", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (result == DialogResult.Cancel)
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
else if (result == DialogResult.Cancel)
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user