private void AddFunctionButton_Click(object sender, EventArgs e) { var inputForm = new FunctionInputForm(); inputForm.Show(); AddOwnedForm(inputForm); }
public void LoadFrom(string filePath) { var retry = false; do { retry = false; FileStream fs = null; try { fs = new FileStream(filePath, FileMode.Open); var formatter = new BinaryFormatter(); // By putting the deserialization earlier than the closing of the forms, // they will only close when the file is successfully deserialized. var settings = (Settings)formatter.Deserialize(fs); foreach (var form in OwnedForms) { form.Close(); } State.Settings = settings; State.SavePath = filePath; foreach (var function in State.Settings.Functions) { var inputForm = new FunctionInputForm(function.Key); inputForm.Show(); AddOwnedForm(inputForm); } } catch (Exception e) { retry = ErrorBox(e.Message, "Failed to load file") == DialogResult.Retry; } finally { if (fs != null) { fs.Close(); } } } while (retry); TryEnableQuickSave(); }