public void Read(System.IO.BinaryReader reader) { // read the Groups Groups = new List<Group>(); int groupsCount = reader.ReadInt32(); if (groupsCount > 0) { for (int i = 0; i < groupsCount; ++i) { var group = new Group(); group.Read(reader); Groups.Add(group); } } }
public void LoadGroup(Guid id) { Contacts.Clear(); if (AppState.Current.Groups.ContainsKey(id)) { _group = AppState.Current.Groups[id]; var orderedContacts = _group.Contacts.OrderBy(g => g.Name); foreach (var contact in orderedContacts) { Contacts.Add(contact); } GroupName = _group.Name; } else { // set a default name GroupName = DEFAULT_GROUP_NAME; // create the new group, but don't save till they take action on it _group = new Group { Id = Guid.NewGuid(), Name = GroupName, Contacts = new List<Contact>(), }; // add group to list AppState.Current.Groups.Add(_group.Id, _group); _SaveGroup(); // set the current group id AppState.Current.CurrentGroupId = _group.Id; } }