- pixeldragonsmvc_demo.zip
- PixelDragons.MVC
- ArrayConverter.cs
- bin
- Debug
- Castle.DynamicProxy.dll
- Iesi.Collections.dll
- log4net.dll
- NHibernate.dll
- PixelDragons.MVC.dll
- PixelDragons.MVC.pdb
- Release
- Command.cs
- Common
- Configuration
- Controllers
- Dependencies
- Castle.DynamicProxy.dll
- Iesi.Collections.dll
- log4net.dll
- NHibernate.dll
- Exceptions
- Interfaces
- MVCHandler.cs
- obj
- Persistence
- PixelDragons.MVC.csproj
- PixelDragons.MVC.csproj.user
- Properties
- View.cs
- PixelDragons.MVCSample.Domain
- PixelDragons.MVCSample
- App_Code
- Controllers
- Bin
- Castle.DynamicProxy.dll
- Iesi.Collections.dll
- log4net.dll
- NHibernate.dll
- PixelDragons.MVC.dll
- PixelDragons.MVC.pdb
- PixelDragons.MVCSample.Domain.dll
- PixelDragons.MVCSample.Domain.pdb
- default.aspx
- Documentation
- PixelDragonsMVC.NET v0.2 BETA.odt
- PixelDragonsMVC.NET v0.2 BETA.pdf
- Thumbs.db
- mvc.config
- PixelDragons.MVCSample.sln
- SQL Scripts
- UI
- controls
- css
- images
- background.gif
- buttons
- back.gif
- login.gif
- next.gif
- save.gif
- Thumbs.db
- icons
- error.gif
- info.gif
- Thumbs.db
- shadow_content.png
- shadow_footer.png
- shadow_header.png
- Thumbs.db
- javascript
- masterPages
- viewParts
- views
- web.config
|
/***********************************************************
*
* Copyright 2007 Pixel Dragons Ltd. All rights reserved.
*
* http://www.codeplex.com/PixelDragonsMVC for licence, more
* information and latest source code.
*
* Check out our other stuff at http://www.pixeldragons.com
*
***********************************************************/
using System;
using System.Collections;
using System.Collections.Generic;
using NHibernate.Expression;
namespace PixelDragons.MVC.Persistence
{
public enum SortDirection { None, Ascending, Descending }
public class PageSettings
{
public PageSettings()
{
}
private Dictionary<string, SortDirection> _columnSorting = null;
private List<SimpleExpression> _filterExpressions = null;
private int _pageSize = 10;
private int _currentPageIndex = 0;
private int _totalPageCount = 0;
private int _totalItemCount = 0;
private bool _calculateTotal = false;
public Dictionary<string, SortDirection> ColumnSorting
{
get
{
if (_columnSorting == null)
{
_columnSorting = new Dictionary<string, SortDirection>();
}
return _columnSorting;
}
set { _columnSorting = value; }
}
public List<SimpleExpression> FilterExpressions
{
get
{
if (_filterExpressions == null)
{
_filterExpressions = new List<SimpleExpression>();
}
return _filterExpressions;
}
set { _filterExpressions = value; }
}
public int PageSize
{
get { return _pageSize; }
set
{
if (_pageSize < 1)
{
throw new ArgumentOutOfRangeException("PageSize", _pageSize, "Page Size cannot be less than 1");
}
_pageSize = value;
}
}
public int CurrentPageIndex
{
get { return _currentPageIndex; }
set { _currentPageIndex = value; }
}
public int TotalPageCount
{
get { return _totalPageCount; }
}
public int TotalItemCount
{
get { return _totalItemCount; }
set
{
if (_totalItemCount < 0)
{
throw new ArgumentOutOfRangeException("ItemCount", _totalItemCount, "Item Count cannot be less than zero");
}
_totalItemCount = value;
_totalPageCount = _totalItemCount / PageSize;
if ((_totalItemCount % PageSize) > 0)
{
_totalPageCount ++;
}
//check if current page is still valid
if (CurrentPageIndex > MaxPageIndex)
{
CurrentPageIndex = MaxPageIndex;
}
}
}
public bool IsFirstPage()
{
return CurrentPageIndex == 0;
}
public bool IsLastPage()
{
return CurrentPageIndex == MaxPageIndex;
}
public int MaxPageIndex
{
get
{
return TotalPageCount - 1;
}
}
public bool CalculateTotal
{
get { return _calculateTotal; }
set { _calculateTotal = value; }
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.
A list of licenses authors might use can be found here
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.