DarkRoomW.frmMain.frmMain_FormClosing C# (CSharp) Method

frmMain_FormClosing() private method

private frmMain_FormClosing ( object sender, FormClosingEventArgs e ) : void
sender object
e FormClosingEventArgs
return void
        private void frmMain_FormClosing(object sender, FormClosingEventArgs e)
        {
            DialogResult UserResponse = new DialogResult();
            if (txtPage.Modified)
            {
                UserResponse = MessageBox.Show("Your document has changed since the last save. \n\n Would you like to save?", "Warning", MessageBoxButtons.YesNoCancel);
            }
            if (txtPage.Modified & UserResponse == DialogResult.Cancel)
            {
                e.Cancel = true;
            }
            else if (txtPage.Modified & UserResponse == DialogResult.Yes)
            {
                if (!(SaveFile()))
                {
                    e.Cancel = true;
                }
            }
            Properties.Settings.Default.Content = txtPage.Text;
            if (FileName != "")
            {
                Properties.Settings.Default.LastFileName = FileName;
            }
            Properties.Settings.Default.Save();
            CacheFile();
        }