External/Aga.Controls/Tree/FixedRowHeightLayout.cs
author moel.mich
Sun, 27 May 2012 15:16:19 +0000
changeset 345 0c551e8818e0
permissions -rw-r--r--
Added the source code of Aga.Controls (TreeViewAdv for .Net) version 1.7.0.0.
     1 using System;
     2 using System.Collections.Generic;
     3 using System.Text;
     4 using System.Drawing;
     5 
     6 namespace Aga.Controls.Tree
     7 {
     8 	internal class FixedRowHeightLayout : IRowLayout
     9 	{
    10 		private TreeViewAdv _treeView;
    11 
    12 		public FixedRowHeightLayout(TreeViewAdv treeView, int rowHeight)
    13 		{
    14 			_treeView = treeView;
    15 			PreferredRowHeight = rowHeight;
    16 		}
    17 
    18 		private int _rowHeight;
    19 		public int PreferredRowHeight
    20 		{
    21 			get { return _rowHeight; }
    22 			set { _rowHeight = value; }
    23 		}
    24 
    25 		public Rectangle GetRowBounds(int rowNo)
    26 		{
    27 			return new Rectangle(0, rowNo * _rowHeight, 0, _rowHeight);
    28 		}
    29 
    30 		public int PageRowCount
    31 		{
    32 			get
    33 			{
    34 				return Math.Max((_treeView.DisplayRectangle.Height - _treeView.ColumnHeaderHeight) / _rowHeight, 0);
    35 			}
    36 		}
    37 
    38 		public int CurrentPageSize
    39 		{
    40 			get
    41 			{
    42 				return PageRowCount;
    43 			}
    44 		}
    45 
    46 		public int GetRowAt(Point point)
    47 		{
    48 			point = new Point(point.X, point.Y + (_treeView.FirstVisibleRow * _rowHeight) - _treeView.ColumnHeaderHeight);
    49 			return point.Y / _rowHeight;
    50 		}
    51 
    52 		public int GetFirstRow(int lastPageRow)
    53 		{
    54 			return Math.Max(0, lastPageRow - PageRowCount + 1);
    55 		}
    56 
    57 		public void ClearCache()
    58 		{
    59 		}
    60 	}
    61 }