ObservableCollection <Creation> RetrieveSavedCreations() { List <dataEntry> values = new List <dataEntry>(); values = QueryForCreations(); ObservableCollection <Creation> creations = new ObservableCollection <Creation>(); foreach (dataEntry creation in values) { string name = creation.creationName; //This atrocity converts the string in the database to the appropriate GeneratorTypesEnum to store in the new //Creation object GeneratorTypesEnum type = (GeneratorTypesEnum)Enum.Parse(typeof(GeneratorTypesEnum), creation.creationType); Dictionary <string, string> generation = new Dictionary <string, string>(); if (type == GeneratorTypesEnum.Encounter) { generation = RecreateEncouterDescription(creation.creationDescription); } else { generation["description"] = creation.creationDescription; } creations.Add(new Creation(name, type, generation)); } return(creations); }
/// <summary> /// Adds a new creation to the list of recent creations /// </summary> /// <param name="creationName">name of the creation to be added</param> /// <param name="creationType">type fo the creation to be added</param> /// <param name="creation">creation to be added</param> public void AddCreation(String creationName, GeneratorTypesEnum creationType, Dictionary <string, string> creation) { Creation newCreation = new Creation(creationName, creationType, creation); mostRecentCreations.Add(newCreation); if (mostRecentCreations.Count > 10) { mostRecentCreations.RemoveAt(0); } }
public Creation(string newName, GeneratorTypesEnum newType, Dictionary <string, string> newGeneration) { name = newName; type = newType; generation = newGeneration; }