External/Aga.Controls/Tree/FixedRowHeightLayout.cs
author moel.mich
Sun, 23 Sep 2012 18:37:43 +0000
changeset 380 573f1fff48b2
permissions -rw-r--r--
Fixed Issue 387. The new implementation does not try to start a ring 0 driver that already exists, but could not be opened. It tries to delete the driver and install it new. The driver is now stored temporarily in the application folder. The driver is not correctly removed on system shutdown.
     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 }