Click here to Skip to main content
11,716,938 members (85,240 online)
Click here to Skip to main content
Articles » Web Development » ASP.NET » General » Downloads
Add your own
alternative version

PixelDragonsMVC.NET - An open source MVC framework

, 29 Jun 2007 56.9K 758 71
An MVC framework with built-in NHibernate support that makes creating ASP.NET 2 applications easier by minimizing code and configuration
pixeldragonsmvc_demo.zip
PixelDragons.MVCSample.Domain
bin
Debug
Iesi.Collections.dll
PixelDragons.MVCSample.Domain.dll
PixelDragons.MVCSample.Domain.pdb
Dependencies
Iesi.Collections.dll
hbm
obj
Debug
PixelDragons.EasyMVCSample.Domain.dll
PixelDragons.EasyMVCSample.Domain.pdb
PixelDragons.MVCSample.Domain.dll
PixelDragons.MVCSample.Domain.pdb
SimpleMVCSample.Domain.dll
SimpleMVCSample.Domain.pdb
TempPE
PixelDragons.MVCSample.Domain.csproj.user
Properties
PixelDragons.MVC
bin
Debug
Castle.DynamicProxy.dll
Iesi.Collections.dll
log4net.dll
NHibernate.dll
PixelDragons.MVC.dll
PixelDragons.MVC.pdb
Release
Common
Configuration
Controllers
Dependencies
Castle.DynamicProxy.dll
Iesi.Collections.dll
log4net.dll
NHibernate.dll
Exceptions
Interfaces
obj
Debug
PixelDragons.EasyMVC.dll
PixelDragons.EasyMVC.pdb
PixelDragons.MVC.dll
PixelDragons.MVC.pdb
Refactor
PixelDragons.MVC.dll
ResolveAssemblyReference.cache
SimpleMVC.dll
SimpleMVC.pdb
TempPE
Release
Persistence
PixelDragons.MVC.csproj.user
Properties
PixelDragons.MVCSample
App_Code
Controllers
Base
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
Documentation
PixelDragonsMVC.NET v0.2 BETA.odt
PixelDragonsMVC.NET v0.2 BETA.pdf
Thumbs.db
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
contacts
users
/***********************************************************
 * 
 * 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.

License

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

Share

About the Author

BigAndy
Web Developer
United Kingdom United Kingdom
No Biography provided

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.150901.1 | Last Updated 29 Jun 2007
Article Copyright 2007 by BigAndy
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid