/// <summary> /// Saves the current configuration to the field assembly. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void saveToolStripMenuItem_Click(object sender, EventArgs e) { Forms.PleaseWaitForm pleaseWait = new Forms.PleaseWaitForm("Saving config..."); Enabled = false; pleaseWait.Show(); try { if (Program.ASSEMBLY_DOCUMENT != null) { Exporter.FieldProperties fieldProps = new Exporter.FieldProperties(FieldMetaForm.GetSpawnpoints(), GetPropertySetsTabControl().TranslateToGamepieces()); List <PropertySet> propSets = GetPropertySetsTabControl().TranslateToPropertySets(); Exporter.SaveManager.Save(Program.ASSEMBLY_DOCUMENT, fieldProps, propSets); } Enabled = true; pleaseWait.Close(); } catch (Exporter.FailedToSaveException er) { pleaseWait.Close(); MessageBox.Show("Failed to save field configuration. The following error occurred:\n" + er.InnerException.ToString(), "Error", MessageBoxButtons.OK); Enabled = true; } }
/// <summary> /// Prepares the window. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void MainWindow_Load(object sender, EventArgs e) { menuStrip.Renderer = new ToolStripProfessionalRenderer(new SynthesisColorTable()); Forms.PleaseWaitForm pleaseWait = new Forms.PleaseWaitForm("Loading config..."); Enabled = false; pleaseWait.Show(); try { if (Program.ASSEMBLY_DOCUMENT != null) { Exporter.FieldProperties fieldProps; List <PropertySet> propSets; Dictionary <string, List <string> > occPropSets; Exporter.SaveManager.Load(Program.ASSEMBLY_DOCUMENT, out fieldProps, out propSets, out occPropSets); fieldMeta.SetSpawnpoints(fieldProps.spawnpoints); GetPropertySetsTabControl().ApplyPropertySets(propSets); GetPropertySetsTabControl().ApplyGamepieces(fieldProps.gamepieces); GetPropertySetsTabControl().ApplyOccurrences(occPropSets); } } catch (Exporter.FailedToLoadException) { // Failed to load config } pleaseWait.Close(); Enabled = true; }