private void DifficultyChanged(object sender, EventArgs e) { var currentDifficulty = DataCache.Difficulty; if (NormalDifficultyRadioButton.Checked) { DataCache.Difficulty = "normal"; } else if (ExpensiveDifficultyRadioButton.Checked) { DataCache.Difficulty = "expensive"; } if (currentDifficulty == DataCache.Difficulty) { return; } Properties.Settings.Default.FactorioDifficulty = DataCache.Difficulty; Properties.Settings.Default.Save(); JObject savedGraph = JObject.Parse(JsonConvert.SerializeObject(GraphViewer)); ReloadFactorioData(); GraphViewer.LoadFromJson(savedGraph); UpdateControlValues(); }
private void EnableDisableButton_Click(object sender, EventArgs e) { EnableDisableItemsForm form = new EnableDisableItemsForm(); form.ShowDialog(); SaveEnabledObjects(); if (form.ModsChanged) { GraphViewer.LoadFromJson(JObject.Parse(JsonConvert.SerializeObject(GraphViewer))); UpdateControlValues(); } }
private void ModDirectoryButton_Click(object sender, EventArgs e) { using (DirectoryChooserForm form = new DirectoryChooserForm(Properties.Settings.Default.FactorioModPath)) { form.Text = "Locate the mods directory"; if (form.ShowDialog() == DialogResult.OK) { Properties.Settings.Default["FactorioModPath"] = form.SelectedPath; Properties.Settings.Default.Save(); JObject savedGraph = JObject.Parse(JsonConvert.SerializeObject(GraphViewer)); ReloadFactorioData(); GraphViewer.LoadFromJson(savedGraph); UpdateControlValues(); } } }
private void loadGraphButton_Click(object sender, EventArgs e) { OpenFileDialog dialog = new OpenFileDialog(); dialog.Filter = "JSON Files (*.json)|*.json|All files (*.*)|*.*"; dialog.CheckFileExists = true; if (dialog.ShowDialog() != DialogResult.OK) { return; } try { GraphViewer.LoadFromJson(JObject.Parse(File.ReadAllText(dialog.FileName))); } catch (Exception exception) { MessageBox.Show("Could not load this file. See log for more details"); ErrorLogging.LogLine(String.Format("Error loading file '{0}'. Error: '{1}'", dialog.FileName, exception.Message)); } UpdateControlValues(); GraphViewer.Invalidate(); }
private void ReloadButton_Click(object sender, EventArgs e) { GraphViewer.LoadFromJson(JObject.Parse(JsonConvert.SerializeObject(GraphViewer))); UpdateControlValues(); }