private void btnSave_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(FileName) && MessageBox.Show("Save settings? This overwrites existing files", "Overwrite savegame", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { WOS4.Write(C, FileName); MessageBox.Show("Settings saved", "Settings saved", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void btnOpen_Click(object sender, EventArgs e) { if (OFD.ShowDialog() == DialogResult.OK) { try { C = WOS4.Read(FileName = OFD.FileName); } catch (Exception ex) { MessageBox.Show(string.Format("Cannot read settings file. Error:\r\n{0}\r\nPlease make sure, the file is an actual savegame file and WOS4 is not running", ex.Message), "Cannot read file", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } cbSetting.Items.Clear(); foreach (Setting S in C.Settings) { cbSetting.Items.Add(S.Name); } } }