External/Aga.Controls/Tree/TreePath.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.Text;
     3 using System.Collections.ObjectModel;
     4 
     5 namespace Aga.Controls.Tree
     6 {
     7 	public class TreePath
     8 	{
     9 		[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")]
    10 		public static readonly TreePath Empty = new TreePath();
    11 
    12 		private object[] _path;
    13 		public object[] FullPath
    14 		{
    15 			get { return _path; }
    16 		}
    17 
    18 		public object LastNode
    19 		{
    20 			get
    21 			{
    22 				if (_path.Length > 0)
    23 					return _path[_path.Length - 1];
    24 				else
    25 					return null;
    26 			}
    27 		}
    28 
    29 		public object FirstNode
    30 		{
    31 			get
    32 			{
    33 				if (_path.Length > 0)
    34 					return _path[0];
    35 				else
    36 					return null;
    37 			}
    38 		}
    39 
    40 		public TreePath()
    41 		{
    42 			_path = new object[0];
    43 		}
    44 
    45 		public TreePath(object node)
    46 		{
    47 			_path = new object[] { node };
    48 		}
    49 
    50 		public TreePath(object[] path)
    51 		{
    52 			_path = path;
    53 		}
    54 
    55 		public TreePath(TreePath parent, object node)
    56 		{
    57 			_path = new object[parent.FullPath.Length + 1];
    58 			for (int i = 0; i < _path.Length - 1; i++)
    59 				_path[i] = parent.FullPath[i];
    60 			_path[_path.Length - 1] = node;
    61 		}
    62 
    63 		public bool IsEmpty()
    64 		{
    65 			return (_path.Length == 0);
    66 		}
    67 	}
    68 }