private void Bind()
{
List<IPublishable> visiblePosts = Posts.FindAll(delegate(IPublishable p) { return p.IsVisible; });
int count = Math.Min(BlogSettings.Instance.PostsPerPage, visiblePosts.Count);
//Init Pager
headPager.TotalRecords = footPager.TotalRecords = visiblePosts.Count;
headPager.PageSize = footPager.PageSize = BlogSettings.Instance.PostsPerPage;
headPager.FormatString = footPager.FormatString = Resources.labels.pagerFormatString;
headPager.FirstPageString = footPager.FirstPageString = Resources.labels.firstPage;
headPager.LastPageString = footPager.LastPageString = Resources.labels.lastPage;
headPager.NextPageString = footPager.NextPageString = Resources.labels.nextPage;
headPager.PrevPageString = footPager.PrevPageString = Resources.labels.prevPage;
int page = (int)footPager.PageIndex;
int index = page * count;
int stop = count;
if (index + count > footPager.TotalRecords)
stop = (int)footPager.TotalRecords - index;
string query = Request.QueryString["theme"];
string theme = !string.IsNullOrEmpty(query) ? query : BlogSettings.Instance.Theme;
string path = Utils.RelativeWebRoot + "themes/" + theme + "/PostView.ascx";
int counter = 0;
foreach (Post post in visiblePosts.GetRange(index, stop))
{
if (counter == stop)
break;
PostViewBase postView = (PostViewBase)LoadControl(path);
postView.ShowExcerpt = BlogSettings.Instance.ShowDescriptionInPostList;
postView.Post = post;
postView.ID = post.Id.ToString().Replace("-", string.Empty);
postView.Location = ServingLocation.PostList;
posts.Controls.Add(postView);
counter++;
}
}