External/Aga.Controls/Tree/TreePath.cs
author sl
Thu, 01 Jan 2015 23:35:49 +0100
changeset 405 5715aefd2bcc
permissions -rw-r--r--
SharpDisplay: Migrating to new robust client scheme.
     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 }