public LifeApplication() { // Layouts doen we tijdens het implementeren van LifeApplication Layouts = new List <Layout>(); Simulations = new List <ILifeSimulation>(); Species = new SpeciesCollection(); }
public bool Load() { SpeciesCollection.Clear(); foreach (var species in IDatabaseHost.ISpeciesStore.Enumerator) { SpeciesCollection.Add(species); } return(true); }
public void Setup(System.Action <SpeciesWidget, int> onSelect, SpeciesCollection species, int selection = -1) { OnSpeciesSelected = onSelect; speciesField.options = species.dropDownItems; if (selection < 0 || selection >= species.dropDownItems.Count) { selection = Random.Range(0, species.dropDownItems.Count); } speciesField.SetValueWithoutNotify(selection); OnChangeSpecies(selection); }
/// <summary> /// Loads species from the XML file. /// /// If the XML file does not exist, a new list will be created. /// </summary> /// <param name="fileName">Path and filename for the XML file to be loaded</param> public void LoadSpecies(string fileName) { try { var fs = new FileStream(fileName, FileMode.Open); var reader = XmlDictionaryReader.CreateTextReader(fs, new XmlDictionaryReaderQuotas()); var ser = new DataContractSerializer(typeof(SpeciesCollection)); // Deserialize the data and read it from the instance. Species = (SpeciesCollection)ser.ReadObject(reader, true); reader.Close(); fs.Close(); } catch (Exception) { Species = new SpeciesCollection(); } }
public void InsertSpecies(DBObject.Species species) { IDatabaseHost.Database.BeginTransaction(); try { IDatabaseHost.ISpeciesStore.Insert(species); WriteImages(species); IDatabaseHost.Database.CompleteTransaction(); } catch (Exception exception) { IDatabaseHost.Database.AbortTransaction(); } Load(); var enumerator = SpeciesCollection.Where(n => n.id == species.id); if ((enumerator != null) && (enumerator.Count() > 0)) { SelectedSpecies = enumerator.First(); } }