External/Aga.Controls/Tree/FixedRowHeightLayout.cs
changeset 345 0c551e8818e0
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/External/Aga.Controls/Tree/FixedRowHeightLayout.cs	Sun May 27 15:16:19 2012 +0000
     1.3 @@ -0,0 +1,61 @@
     1.4 +using System;
     1.5 +using System.Collections.Generic;
     1.6 +using System.Text;
     1.7 +using System.Drawing;
     1.8 +
     1.9 +namespace Aga.Controls.Tree
    1.10 +{
    1.11 +	internal class FixedRowHeightLayout : IRowLayout
    1.12 +	{
    1.13 +		private TreeViewAdv _treeView;
    1.14 +
    1.15 +		public FixedRowHeightLayout(TreeViewAdv treeView, int rowHeight)
    1.16 +		{
    1.17 +			_treeView = treeView;
    1.18 +			PreferredRowHeight = rowHeight;
    1.19 +		}
    1.20 +
    1.21 +		private int _rowHeight;
    1.22 +		public int PreferredRowHeight
    1.23 +		{
    1.24 +			get { return _rowHeight; }
    1.25 +			set { _rowHeight = value; }
    1.26 +		}
    1.27 +
    1.28 +		public Rectangle GetRowBounds(int rowNo)
    1.29 +		{
    1.30 +			return new Rectangle(0, rowNo * _rowHeight, 0, _rowHeight);
    1.31 +		}
    1.32 +
    1.33 +		public int PageRowCount
    1.34 +		{
    1.35 +			get
    1.36 +			{
    1.37 +				return Math.Max((_treeView.DisplayRectangle.Height - _treeView.ColumnHeaderHeight) / _rowHeight, 0);
    1.38 +			}
    1.39 +		}
    1.40 +
    1.41 +		public int CurrentPageSize
    1.42 +		{
    1.43 +			get
    1.44 +			{
    1.45 +				return PageRowCount;
    1.46 +			}
    1.47 +		}
    1.48 +
    1.49 +		public int GetRowAt(Point point)
    1.50 +		{
    1.51 +			point = new Point(point.X, point.Y + (_treeView.FirstVisibleRow * _rowHeight) - _treeView.ColumnHeaderHeight);
    1.52 +			return point.Y / _rowHeight;
    1.53 +		}
    1.54 +
    1.55 +		public int GetFirstRow(int lastPageRow)
    1.56 +		{
    1.57 +			return Math.Max(0, lastPageRow - PageRowCount + 1);
    1.58 +		}
    1.59 +
    1.60 +		public void ClearCache()
    1.61 +		{
    1.62 +		}
    1.63 +	}
    1.64 +}