コード例 #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;
 }
コード例 #3
0
        async void OnItemClicked(object sender, EventArgs e)
        {
            var action = await DisplayActionSheet("Group by", "Cancel", null, GroupParameterName.Alphabeticaly.ToString(), GroupParameterName.Category.ToString());

            if (action != null && action != "Cancel")
            {
                PhoneListViewModel model = BindingContext as PhoneListViewModel;
                if (model != null && model.GroupParameter.ToString() != action)
                {
                    GroupParameterName parameter = action == GroupParameterName.Alphabeticaly.ToString()? GroupParameterName.Alphabeticaly: GroupParameterName.Category;
                    model.SelectedItem = model.PhoneListData[0];
                    model.SetGroupByParameter(parameter);
                    if (model.GroupParameter == GroupParameterName.Alphabeticaly)
                    {
                        dxTabView.HeaderPanelPosition         = Position.Right;
                        dxTabView.HeaderPanelContentAlignment = ContentAlignment.Start;
                    }
                    else
                    {
                        dxTabView.HeaderPanelPosition         = Position.Bottom;
                        dxTabView.HeaderPanelContentAlignment = ContentAlignment.Center;
                    }
                    dxTabView.ItemsSource  = model.PhoneListData;
                    dxTabView.SelectedItem = model.PhoneListData[0];
                }
            }
        }
コード例 #4
0
 string GetGroupedValue(Contact contact, GroupParameterName parameter)
 {
     if (parameter == GroupParameterName.Alphabeticaly)
     {
         return(contact.LastName[0].ToString());
     }
     else
     {
         return(contact.ContactCategory.ToString());
     }
 }
コード例 #5
0
 public void SetGroupByParameter(GroupParameterName parameter)
 {
     ResetSelectedItem(null);
     currentGroupParameter = parameter;
 }