// Does not replace existing public void AddCodexSection(int id, BioCodexSection codexSection = null) { if (CodexSections == null) { CodexSections = InitCollection <KeyValuePair <int, BioCodexSection> >(); } if (CodexSections.Any(pair => pair.Key == id)) { return; } var codexSectionPair = new KeyValuePair <int, BioCodexSection>(id, codexSection ?? new BioCodexSection()); CodexSections.Add(codexSectionPair); SelectedCodexSection = codexSectionPair; }
public void RemoveCodexSection() { if (CodexSections == null || SelectedCodexSection.Value == null) { return; } var index = CodexSections.IndexOf(SelectedCodexSection); if (!CodexSections.Remove(SelectedCodexSection)) { return; } if (CodexSections.Any()) { SelectedCodexSection = ((index - 1) >= 0) ? CodexSections[index - 1] : CodexSections.First(); } }
private int GetMaxCodexSectionId() { return(CodexSections.Any() ? CodexSections.Max(pair => pair.Key) : -1); }