External/Aga.Controls/Tree/FixedRowHeightLayout.cs
author StephaneLenclud
Sun, 03 Feb 2013 18:01:50 +0100
branchMiniDisplay
changeset 433 090259cfd699
permissions -rw-r--r--
Adding SoundGraphDisplay and SensorFrontView classes.
They were respectively based on SystemTray and SensorNotifyIcon.
SoundGraphDisplay is now able to load iMONDisplay.dll providing it lives on your PATH.
Adding option to sensor context menu for adding it into FrontView.
     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 }