コード例 #1
0
        public UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath)
        {
            if (indexPath.Item == 0)
            {
                var cell = MemberListTable.DequeueReusableCell("AddMemberCell");

                (cell.ViewWithTag(100) as UILabel).Text = "Load member " + searchString;

                return(cell);
            }
            else
            {
                var cell = MemberListTable.DequeueReusableCell("MemberCell");

                int searchId;
                CodeProjectMember member = null;

                if (int.TryParse(searchString, out searchId))
                {
                    member = MemberList.Where(x => x.Id == searchId).ToList() [indexPath.Item - 1];
                }
                else
                {
                    member = MemberList.Where(x => x.Name.ToUpper().Contains(searchString.ToUpper())).ToList() [indexPath.Item - 1];
                }

                CodeProjectMemberListDataSource.FillCellWithMember(cell, member);

                return(cell);
            }
        }
コード例 #2
0
        public override void PrepareForSegue(UIStoryboardSegue segue, NSObject sender)
        {
            base.PrepareForSegue(segue, sender);

            int memberId = -1;

            if (segue.Identifier == "LoadMember")
            {
                if (!int.TryParse(searchString, out memberId))
                {
                    CodeProjectMember member = MemberList.Where(x => x.Name == searchString).FirstOrDefault();
                    if (member != null)
                    {
                        memberId = member.Id;
                    }
                }
                MemberSearchBarController.SearchBar.Text = String.Empty;
                MemberSearchBarController.SearchBar.ResignFirstResponder();
                MemberSearchBarController.Active = false;
            }
            else if (segue.Identifier == "ShowMember")
            {
                NSIndexPath selectedIndexPath = MemberListTable.IndexPathForSelectedRow;
                if (selectedIndexPath != null)
                {
                    CodeProjectMember member = MemberList [selectedIndexPath.Row];
                    if (member != null)
                    {
                        memberId = member.Id;
                    }
                }
                else
                {
                    selectedIndexPath = MemberSearchBarController.SearchResultsTableView.IndexPathForSelectedRow;
                    if (selectedIndexPath != null)
                    {
                        CodeProjectMember member = MemberList.Where(x => x.Name.ToUpper().Contains(searchString.ToUpper())).ToList() [selectedIndexPath.Row - 1];
                        if (member != null)
                        {
                            memberId = member.Id;
                        }
                        MemberSearchBarController.SearchBar.Text = String.Empty;
                        MemberSearchBarController.SearchBar.ResignFirstResponder();
                        MemberSearchBarController.Active = false;
                    }
                }
            }

            var memberProfileController = segue.DestinationViewController as CodeProjectMemberProfileViewController;

            if (memberProfileController != null)
            {
                memberProfileController.SetMemberId(memberId);
            }
        }
コード例 #3
0
        public override void CommitEditingStyle(UITableView tableView, UITableViewCellEditingStyle editingStyle, MonoTouch.Foundation.NSIndexPath indexPath)
        {
            if (editingStyle == UITableViewCellEditingStyle.Delete)
            {
                CodeProjectMember   memberToDelete = MemberList [indexPath.Row];
                CodeProjectDatabase database       = new CodeProjectDatabase();
                database.DeleteMember(memberToDelete.Id);

                MemberList = database.GetMembers();
                tableView.ReloadData();
            }
        }
コード例 #4
0
        public static UITableViewCell FillCellWithMember(UITableViewCell cell, CodeProjectMember member)
        {
            (cell.ViewWithTag(100) as UILabel).Text = member.Name;
            (cell.ViewWithTag(101) as UILabel).Text = "Posts: " + (member.ArticleCount + member.BlogCount);
            (cell.ViewWithTag(102) as UILabel).Text = member.Reputation;

            CodeProjectDatabase database = new CodeProjectDatabase();

            byte[] gravatar = database.GetGravatar(member.Id);
            if (gravatar != null)
            {
                UIImage image = UIImage.LoadFromData(NSData.FromArray(gravatar));
                (cell.ViewWithTag(105) as UIImageView).Image = image;
            }

            return(cell);
        }
コード例 #5
0
 public void SetMember(CodeProjectMember member)
 {
     viewModel.MemberId = member.Id;
     viewModel.MemberReputationGraphUrl = member.ReputationGraph;
 }