예제 #1
0
        PhoneListData GroupByParameter(GroupParameterName parameter)
        {
            Dictionary <string, PhoneList> result = new Dictionary <string, PhoneList>();

            result.Add("All", phoneList);
            foreach (Contact contact in phoneList)
            {
                string groupedValue = GetGroupedValue(contact, parameter);
                if (!result.ContainsKey(groupedValue))
                {
                    result.Add(groupedValue, new PhoneList());
                }
                result[groupedValue].Add(contact);
            }
            PhoneListData phoneListData = new PhoneListData(result.Count);

            foreach (string group in result.Keys)
            {
                GroupedPhoneList groupedList = new GroupedPhoneList()
                {
                    Contacts = result[group], GroupName = group
                };
                if (GetShowGroupIcon(parameter))
                {
                    groupedList.ShowGroupIcon   = true;
                    groupedList.GroupIconSource = GetGroupIconSource(group);
                }
                phoneListData.Add(groupedList);
            }
            return(phoneListData);
        }
예제 #2
0
 public PhoneListViewModel()
 {
     phoneList = XmlDataDeserializer.GetData <PhoneList>("Resources.PhoneListData.xml");
     alphabeticalyPhoneListData = GroupByParameter(GroupParameterName.Alphabeticaly);
     categoryPhoneListData      = GroupByParameter(GroupParameterName.Category);
     currentGroupParameter      = GroupParameterName.Alphabeticaly;
 }