External/Aga.Controls/Tree/TreePath.cs
author moel.mich
Tue, 30 Dec 2014 22:47:39 +0000
changeset 431 0e46e3ca812a
permissions -rw-r--r--
Fixed the following issue (present only on 32-bit systems):

Version: 0.7.0.0

System.NullReferenceException: Object reference not set to an instance of an object.
at OpenHardwareMonitor.GUI.MainForm.timer_Tick(Object sender, EventArgs e)
at System.Windows.Forms.Timer.OnTick(EventArgs e)
at System.Windows.Forms.Timer.TimerNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

Common Language Runtime: 4.0.30319.18444
Operating System: Microsoft Windows NT 6.1.7601 Service Pack 1
Process Type: 32-Bit
     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 }