public void LoadExtractionTestCases(string fileName) { if (!string.IsNullOrWhiteSpace(fileName)) { XmlSerializer reader = new XmlSerializer(typeof(ExtractionTestCases)); if (!File.Exists(fileName)) { MessageBox.Show("Save file with name \"" + fileName + "\" does not exist!", $"File not found - {Utils.ApplicationNameVersion}", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } using (System.IO.FileStream file = System.IO.File.OpenRead(fileName)) { try { cases = (ExtractionTestCases)reader.Deserialize(file); Properties.Settings.Default.LastSaveFileTestCases = fileName; } catch (Exception e) { MessageBox.Show("File Couldn't be opened, we thought you should know.\nErrormessage:\n\n" + e.Message, $"{Loc.S("error")} - {Utils.ApplicationNameVersion}", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { file.Close(); } } ShowTestCases(); UpdateFileLabel(); } }
public void loadExtractionTestCases(string fileName) { if (!string.IsNullOrWhiteSpace(fileName)) { XmlSerializer reader = new XmlSerializer(typeof(ExtractionTestCases)); if (!System.IO.File.Exists(fileName)) { MessageBox.Show("Save file with name \"" + fileName + "\" does not exist!", "File not found", MessageBoxButtons.OK, MessageBoxIcon.Error); } System.IO.FileStream file = System.IO.File.OpenRead(fileName); try { cases = (ExtractionTestCases)reader.Deserialize(file); Properties.Settings.Default.LastSaveFileTestCases = fileName; } catch (Exception e) { MessageBox.Show("File Couldn't be opened, we thought you should know.\nErrormessage:\n\n" + e.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); file.Close(); } file.Close(); showTestCases(); updateFileLabel(); } }
public void LoadExtractionTestCases(string fileName) { if (!string.IsNullOrWhiteSpace(fileName)) { XmlSerializer reader = new XmlSerializer(typeof(ExtractionTestCases)); if (!File.Exists(fileName)) { MessageBoxes.ShowMessageBox($"Save file with name \"{fileName}\" does not exist!", $"File not found"); return; } using (System.IO.FileStream file = System.IO.File.OpenRead(fileName)) { try { cases = (ExtractionTestCases)reader.Deserialize(file); Properties.Settings.Default.LastSaveFileTestCases = fileName; } catch (Exception ex) { MessageBoxes.ExceptionMessageBox(ex, "File Couldn't be opened, we thought you should know."); } finally { file.Close(); } } ShowTestCases(); UpdateFileLabel(); } }
private void ClearAll(bool clearCases = false) { foreach (var e in extractionTestControls) { e.Dispose(); } extractionTestControls.Clear(); if (cases == null) { cases = new ExtractionTestCases(); } if (clearCases) { cases.testCases.Clear(); } }
public ExtractionTestControl() { InitializeComponent(); extractionTestControls = new List <TestCaseControl>(); cases = new ExtractionTestCases(); }
public void loadExtractionTestCases(string fileName) { if (!string.IsNullOrWhiteSpace(fileName)) { XmlSerializer reader = new XmlSerializer(typeof(ExtractionTestCases)); if (!System.IO.File.Exists(fileName)) { MessageBox.Show("Save file with name \"" + fileName + "\" does not exist!", "File not found", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } System.IO.FileStream file = System.IO.File.OpenRead(fileName); try { cases = (ExtractionTestCases)reader.Deserialize(file); Properties.Settings.Default.LastSaveFileTestCases = fileName; } catch (Exception e) { MessageBox.Show("File Couldn't be opened, we thought you should know.\nErrormessage:\n\n" + e.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); file.Close(); } file.Close(); // convert from 8 to 12 stats, reorder // TODO remove var newToOldIndices = new int[] { 0, 1, 7, 2, 3, -1, -1, 4, 5, 6, -1, -1 }; foreach (var c in cases.testCases) { if (c.multipliers.Length == 8) { var newMultipliers = new double[12][]; for (int s = 0; s < 12; s++) { newMultipliers[s] = new double[4]; if (newToOldIndices[s] >= 0) { for (int si = 0; si < 4; si++) { newMultipliers[s][si] = c.multipliers[newToOldIndices[s]][si]; } } else { for (int si = 0; si < 4; si++) { newMultipliers[s][si] = 1; } } } c.multipliers = newMultipliers; } // fix statlevel-indices if (c.levelsWild.Length == 8) { var newLevels = new int[12]; for (int s = 0; s < 12; s++) { if (newToOldIndices[s] >= 0) { newLevels[s] = c.levelsWild[newToOldIndices[s]]; } } c.levelsWild = newLevels; } if (c.levelsDom.Length == 8) { var newLevels = new int[12]; for (int s = 0; s < 12; s++) { if (newToOldIndices[s] >= 0) { newLevels[s] = c.levelsDom[newToOldIndices[s]]; } } c.levelsDom = newLevels; } if (c.statValues.Length == 8) { var newValues = new double[12]; for (int s = 0; s < 12; s++) { if (newToOldIndices[s] >= 0) { newValues[s] = c.statValues[newToOldIndices[s]]; } } c.statValues = newValues; } // convert species-identifier if (string.IsNullOrEmpty(c.speciesName) || string.IsNullOrEmpty(c.speciesBP)) { if (Values.V.TryGetSpeciesByName(c.species, out Species species)) { c.Species = species; } } } showTestCases(); updateFileLabel(); } }