External/Aga.Controls/Tree/Input/InputWithShift.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 
     5 namespace Aga.Controls.Tree
     6 {
     7 	internal class InputWithShift: NormalInputState
     8 	{
     9 		public InputWithShift(TreeViewAdv tree): base(tree)
    10 		{
    11 		}
    12 
    13 		protected override void FocusRow(TreeNodeAdv node)
    14 		{
    15 			Tree.SuspendSelectionEvent = true;
    16 			try
    17 			{
    18 				if (Tree.SelectionMode == TreeSelectionMode.Single || Tree.SelectionStart == null)
    19 					base.FocusRow(node);
    20 				else if (CanSelect(node))
    21 				{
    22 					SelectAllFromStart(node);
    23 					Tree.CurrentNode = node;
    24 					Tree.ScrollTo(node);
    25 				}
    26 			}
    27 			finally
    28 			{
    29 				Tree.SuspendSelectionEvent = false;
    30 			}
    31 		}
    32 
    33 		protected override void DoMouseOperation(TreeNodeAdvMouseEventArgs args)
    34 		{
    35 			if (Tree.SelectionMode == TreeSelectionMode.Single || Tree.SelectionStart == null)
    36 			{
    37 				base.DoMouseOperation(args);
    38 			}
    39 			else if (CanSelect(args.Node))
    40 			{
    41 				Tree.SuspendSelectionEvent = true;
    42 				try
    43 				{
    44 					SelectAllFromStart(args.Node);
    45 				}
    46 				finally
    47 				{
    48 					Tree.SuspendSelectionEvent = false;
    49 				}
    50 			}
    51 		}
    52 
    53 		protected override void MouseDownAtEmptySpace(TreeNodeAdvMouseEventArgs args)
    54 		{
    55 		}
    56 
    57 		private void SelectAllFromStart(TreeNodeAdv node)
    58 		{
    59 			Tree.ClearSelectionInternal();
    60 			int a = node.Row;
    61 			int b = Tree.SelectionStart.Row;
    62 			for (int i = Math.Min(a, b); i <= Math.Max(a, b); i++)
    63 			{
    64 				if (Tree.SelectionMode == TreeSelectionMode.Multi || Tree.RowMap[i].Parent == node.Parent)
    65 					Tree.RowMap[i].IsSelected = true;
    66 			}
    67 		}
    68 	}
    69 }