﻿// Decompiled with JetBrains decompiler
// Type: System.Web.UI.WebControls.TreeView
// Assembly: System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
// MVID: 7E68A73E-4066-4F24-AB0A-F147209F50EC
// Assembly location: C:\Windows\Microsoft.NET\Framework\v4.0.30319\System.Web.dll

using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Drawing.Design;
using System.Globalization;
using System.IO;
using System.Runtime;
using System.Runtime.CompilerServices;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.Util;

namespace System.Web.UI.WebControls
{
  /// <summary>
  /// Displays hierarchical data, such as a table of contents, in a tree structure.
  /// </summary>
  [SupportsEventValidation]
  [ControlValueProperty("SelectedValue")]
  [DefaultEvent("SelectedNodeChanged")]
  [Designer("System.Web.UI.Design.WebControls.TreeViewDesigner, System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
  public class TreeView : HierarchicalDataBoundControl, IPostBackEventHandler, IPostBackDataHandler, ICallbackEventHandler
  {
    private static string populateNodeScript = "\r\n    function TreeView_PopulateNodeDoCallBack(context,param) {\r\n        ";
    private static string populateNodeScriptEnd = ";\r\n    }\r\n";
    private static readonly object CheckChangedEvent = new object();
    private static readonly object SelectedNodeChangedEvent = new object();
    private static readonly object TreeNodeCollapsedEvent = new object();
    private static readonly object TreeNodeExpandedEvent = new object();
    private static readonly object TreeNodePopulateEvent = new object();
    private static readonly object TreeNodeDataBoundEvent = new object();
    internal const int RootImageIndex = 0;
    internal const int ParentImageIndex = 1;
    internal const int LeafImageIndex = 2;
    internal const int NoExpandImageIndex = 3;
    internal const int PlusImageIndex = 4;
    internal const int MinusImageIndex = 5;
    internal const int IImageIndex = 6;
    internal const int RImageIndex = 7;
    internal const int RPlusImageIndex = 8;
    internal const int RMinusImageIndex = 9;
    internal const int TImageIndex = 10;
    internal const int TPlusImageIndex = 11;
    internal const int TMinusImageIndex = 12;
    internal const int LImageIndex = 13;
    internal const int LPlusImageIndex = 14;
    internal const int LMinusImageIndex = 15;
    internal const int DashImageIndex = 16;
    internal const int DashPlusImageIndex = 17;
    internal const int DashMinusImageIndex = 18;
    internal const int ImageUrlsCount = 19;
    internal const char InternalPathSeparator = '\\';
    private string[] _imageUrls;
    private string[] _levelImageUrls;
    private TreeNodeStyle _nodeStyle;
    private TreeNodeStyle _rootNodeStyle;
    private TreeNodeStyle _parentNodeStyle;
    private TreeNodeStyle _leafNodeStyle;
    private TreeNodeStyle _selectedNodeStyle;
    private Style _hoverNodeStyle;
    private HyperLinkStyle _hoverNodeHyperLinkStyle;
    private Style _baseNodeStyle;
    private List<TreeNodeStyle> _cachedParentNodeStyles;
    private List<string> _cachedParentNodeClassNames;
    private List<string> _cachedParentNodeHyperLinkClassNames;
    private List<TreeNodeStyle> _cachedLeafNodeStyles;
    private List<string> _cachedLeafNodeClassNames;
    private List<string> _cachedLeafNodeHyperLinkClassNames;
    private Collection<int> _cachedLevelsContainingCssClass;
    private TreeNode _rootNode;
    private TreeNode _selectedNode;
    private TreeNodeCollection _checkedNodes;
    private TreeNodeStyleCollection _levelStyles;
    private ArrayList _checkedChangedNodes;
    private TreeNodeBindingCollection _bindings;
    private int _cssStyleIndex;
    private bool _loadingNodeState;
    private bool _dataBound;
    private bool _accessKeyRendered;
    private bool _isNotIE;
    private bool _renderClientScript;
    private bool _fireSelectedNodeChanged;
    private string _cachedExpandImageUrl;
    private string _cachedCollapseImageUrl;
    private string _cachedNoExpandImageUrl;
    private string _cachedClientDataObjectID;
    private string _cachedExpandStateID;
    private string _cachedImageArrayID;
    private string _cachedPopulateLogID;
    private string _cachedSelectedNodeFieldID;
    private string _currentSiteMapNodeDataPath;
    private string _callbackEventArgument;
    private const char EscapeCharacter = '|';
    private const string EscapeSequenceForPathSeparator = "*|*";
    private const string EscapeSequenceForEscapeCharacter = "||";

    internal bool AccessKeyRendered
    {
      [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")] get
      {
        return this._accessKeyRendered;
      }
      [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")] set
      {
        this._accessKeyRendered = value;
      }
    }

    private List<string> CachedLeafNodeClassNames
    {
      get
      {
        if (this._cachedLeafNodeClassNames == null)
          this._cachedLeafNodeClassNames = new List<string>();
        return this._cachedLeafNodeClassNames;
      }
    }

    private List<TreeNodeStyle> CachedLeafNodeStyles
    {
      get
      {
        if (this._cachedLeafNodeStyles == null)
          this._cachedLeafNodeStyles = new List<TreeNodeStyle>();
        return this._cachedLeafNodeStyles;
      }
    }

    private List<string> CachedLeafNodeHyperLinkClassNames
    {
      get
      {
        if (this._cachedLeafNodeHyperLinkClassNames == null)
          this._cachedLeafNodeHyperLinkClassNames = new List<string>();
        return this._cachedLeafNodeHyperLinkClassNames;
      }
    }

    private Collection<int> CachedLevelsContainingCssClass
    {
      get
      {
        if (this._cachedLevelsContainingCssClass == null)
          this._cachedLevelsContainingCssClass = new Collection<int>();
        return this._cachedLevelsContainingCssClass;
      }
    }

    private List<TreeNodeStyle> CachedParentNodeStyles
    {
      get
      {
        if (this._cachedParentNodeStyles == null)
          this._cachedParentNodeStyles = new List<TreeNodeStyle>();
        return this._cachedParentNodeStyles;
      }
    }

    private List<string> CachedParentNodeClassNames
    {
      get
      {
        if (this._cachedParentNodeClassNames == null)
          this._cachedParentNodeClassNames = new List<string>();
        return this._cachedParentNodeClassNames;
      }
    }

    private List<string> CachedParentNodeHyperLinkClassNames
    {
      get
      {
        if (this._cachedParentNodeHyperLinkClassNames == null)
          this._cachedParentNodeHyperLinkClassNames = new List<string>();
        return this._cachedParentNodeHyperLinkClassNames;
      }
    }

    /// <summary>
    /// Gets or sets a value indicating whether the <see cref="T:System.Web.UI.WebControls.TreeView"/> control automatically generates tree node bindings.
    /// </summary>
    /// 
    /// <returns>
    /// true to have the <see cref="T:System.Web.UI.WebControls.TreeView"/> control automatically generate tree node bindings; otherwise, false. The default is true.
    /// </returns>
    [WebCategory("Behavior")]
    [WebSysDescription("TreeView_AutoGenerateDataBindings")]
    [DefaultValue(true)]
    public bool AutoGenerateDataBindings
    {
      get
      {
        object obj = this.ViewState["AutoGenerateDataBindings"];
        if (obj == null)
          return true;
        return (bool) obj;
      }
      set
      {
        this.ViewState["AutoGenerateDataBindings"] = (object) (bool) (value ? 1 : 0);
      }
    }

    /// <summary>
    /// Gets a collection of <see cref="T:System.Web.UI.WebControls.TreeNodeBinding"/> objects that define the relationship between a data item and the node that it is binding to.
    /// </summary>
    /// 
    /// <returns>
    /// A <see cref="T:System.Web.UI.WebControls.TreeNodeBindingCollection"/> that represents the relationship between a data item and the node that it is binding to.
    /// </returns>
    [Editor("System.Web.UI.Design.WebControls.TreeViewBindingsEditor, System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof (UITypeEditor))]
    [PersistenceMode(PersistenceMode.InnerProperty)]
    [DefaultValue(null)]
    [MergableProperty(false)]
    [WebCategory("Data")]
    [WebSysDescription("TreeView_DataBindings")]
    public TreeNodeBindingCollection DataBindings
    {
      get
      {
        if (this._bindings == null)
        {
          this._bindings = new TreeNodeBindingCollection();
          if (this.IsTrackingViewState)
            this._bindings.TrackViewState();
        }
        return this._bindings;
      }
    }

    /// <summary>
    /// Gets a collection of <see cref="T:System.Web.UI.WebControls.TreeNode"/> objects that represent the nodes in the <see cref="T:System.Web.UI.WebControls.TreeView"/> control that display a selected check box.
    /// </summary>
    /// 
    /// <returns>
    /// A <see cref="T:System.Web.UI.WebControls.TreeNodeCollection"/> that contains the nodes in the <see cref="T:System.Web.UI.WebControls.TreeView"/> that display a selected check box.
    /// </returns>
    [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
    [Browsable(false)]
    public TreeNodeCollection CheckedNodes
    {
      get
      {
        if (this._checkedNodes == null)
          this._checkedNodes = new TreeNodeCollection((TreeNode) null, false);
        return this._checkedNodes;
      }
    }

    private ArrayList CheckedChangedNodes
    {
      get
      {
        if (this._checkedChangedNodes == null)
          this._checkedChangedNodes = new ArrayList();
        return this._checkedChangedNodes;
      }
    }

    internal string ClientDataObjectID
    {
      get
      {
        if (this._cachedClientDataObjectID == null)
          this._cachedClientDataObjectID = this.ClientID + "_Data";
        return this._cachedClientDataObjectID;
      }
    }

    /// <summary>
    /// Gets or sets the ToolTip for the image that is displayed for the collapsible node indicator.
    /// </summary>
    /// 
    /// <returns>
    /// The ToolTip for the image displayed for the collapsible node indicator.
    /// </returns>
    [WebCategory("Appearance")]
    [WebSysDescription("TreeView_CollapseImageToolTip")]
    [WebSysDefaultValue("TreeView_CollapseImageToolTipDefaultValue")]
    [Localizable(true)]
    public string CollapseImageToolTip
    {
      get
      {
        return (string) this.ViewState["CollapseImageToolTip"] ?? System.Web.SR.GetString("TreeView_CollapseImageToolTipDefaultValue");
      }
      set
      {
        this.ViewState["CollapseImageToolTip"] = (object) value;
      }
    }

    /// <summary>
    /// Gets or sets the URL to a custom image for the collapsible node indicator.
    /// </summary>
    /// 
    /// <returns>
    /// The URL to a custom image to display for collapsible nodes. The default is an empty string (""), which displays the default minus sign (-) image.
    /// </returns>
    [UrlProperty]
    [WebCategory("Appearance")]
    [Editor("System.Web.UI.Design.ImageUrlEditor, System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof (UITypeEditor))]
    [DefaultValue("")]
    [WebSysDescription("TreeView_CollapseImageUrl")]
    public string CollapseImageUrl
    {
      get
      {
        return (string) this.ViewState["CollapseImageUrl"] ?? string.Empty;
      }
      set
      {
        this.ViewState["CollapseImageUrl"] = (object) value;
      }
    }

    internal string CollapseImageUrlInternal
    {
      get
      {
        if (this._cachedCollapseImageUrl == null)
        {
          switch (this.ImageSet)
          {
            case TreeViewImageSet.Custom:
              this._cachedCollapseImageUrl = this.CollapseImageUrl;
              break;
            case TreeViewImageSet.XPFileExplorer:
              this._cachedCollapseImageUrl = this.Page.ClientScript.GetWebResourceUrl(typeof (TreeView), "TreeView_XP_Explorer_Collapse.gif");
              break;
            case TreeViewImageSet.Msdn:
              this._cachedCollapseImageUrl = this.Page.ClientScript.GetWebResourceUrl(typeof (TreeView), "TreeView_MSDN_Collapse.gif");
              break;
            case TreeViewImageSet.WindowsHelp:
              this._cachedCollapseImageUrl = this.Page.ClientScript.GetWebResourceUrl(typeof (TreeView), "TreeView_Windows_Help_Collapse.gif");
              break;
            case TreeViewImageSet.Arrows:
              this._cachedCollapseImageUrl = this.Page.ClientScript.GetWebResourceUrl(typeof (TreeView), "TreeView_Arrows_Collapse.gif");
              break;
            case TreeViewImageSet.Contacts:
              this._cachedCollapseImageUrl = this.Page.ClientScript.GetWebResourceUrl(typeof (TreeView), "TreeView_Contacts_Collapse.gif");
              break;
            default:
              this._cachedCollapseImageUrl = string.Empty;
              break;
          }
        }
        return this._cachedCollapseImageUrl;
      }
    }

    internal bool CustomExpandCollapseHandlerExists
    {
      get
      {
        TreeNodeEventHandler nodeEventHandler1 = (TreeNodeEventHandler) this.Events[TreeView.TreeNodeCollapsedEvent];
        TreeNodeEventHandler nodeEventHandler2 = (TreeNodeEventHandler) this.Events[TreeView.TreeNodeExpandedEvent];
        if (nodeEventHandler1 == null)
          return nodeEventHandler2 != null;
        return true;
      }
    }

    /// <summary>
    /// Gets or sets a value indicating whether the <see cref="T:System.Web.UI.WebControls.TreeView"/> control renders client-side script to handle expanding and collapsing events.
    /// </summary>
    /// 
    /// <returns>
    /// true to render the client-side script on compatible browsers; otherwise, false. The default is true.
    /// </returns>
    [WebSysDescription("TreeView_EnableClientScript")]
    [DefaultValue(true)]
    [WebCategory("Behavior")]
    [Themeable(false)]
    public bool EnableClientScript
    {
      get
      {
        object obj = this.ViewState["EnableClientScript"];
        if (obj == null)
          return true;
        return (bool) obj;
      }
      set
      {
        this.ViewState["EnableClientScript"] = (object) (bool) (value ? 1 : 0);
      }
    }

    internal bool EnableHover
    {
      get
      {
        if (this.Page != null && (this.Page.SupportsStyleSheets || this.Page.IsCallback || this.Page.ScriptManager != null && this.Page.ScriptManager.IsInAsyncPostBack) && this.RenderClientScript)
          return this._hoverNodeStyle != null;
        return false;
      }
    }

    /// <summary>
    /// Gets or sets the number of levels that are expanded when a <see cref="T:System.Web.UI.WebControls.TreeView"/> control is displayed for the first time.
    /// </summary>
    /// 
    /// <returns>
    /// The depth to display when the <see cref="T:System.Web.UI.WebControls.TreeView"/> is initially displayed. The default is -1, which displays all the nodes.
    /// </returns>
    [TypeConverter(typeof (TreeView.TreeViewExpandDepthConverter))]
    [WebSysDescription("TreeView_ExpandDepth")]
    [DefaultValue(-1)]
    [WebCategory("Behavior")]
    public int ExpandDepth
    {
      get
      {
        object obj = this.ViewState["ExpandDepth"];
        if (obj == null)
          return -1;
        return (int) obj;
      }
      set
      {
        this.ViewState["ExpandDepth"] = (object) value;
      }
    }

    /// <summary>
    /// Gets or sets the ToolTip for the image that is displayed for the expandable node indicator.
    /// </summary>
    /// 
    /// <returns>
    /// The ToolTip for the image displayed for the expandable node indicator.
    /// </returns>
    [Localizable(true)]
    [WebCategory("Appearance")]
    [WebSysDescription("TreeView_ExpandImageToolTip")]
    [WebSysDefaultValue("TreeView_ExpandImageToolTipDefaultValue")]
    public string ExpandImageToolTip
    {
      get
      {
        return (string) this.ViewState["ExpandImageToolTip"] ?? System.Web.SR.GetString("TreeView_ExpandImageToolTipDefaultValue");
      }
      set
      {
        this.ViewState["ExpandImageToolTip"] = (object) value;
      }
    }

    /// <summary>
    /// Gets or sets the URL to a custom image for the expandable node indicator.
    /// </summary>
    /// 
    /// <returns>
    /// The URL to a custom image to display for expandable nodes. The default is an empty string (""), which displays the default plus sign (+) image.
    /// </returns>
    [UrlProperty]
    [WebCategory("Appearance")]
    [WebSysDescription("TreeView_ExpandImageUrl")]
    [Editor("System.Web.UI.Design.ImageUrlEditor, System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof (UITypeEditor))]
    [DefaultValue("")]
    public string ExpandImageUrl
    {
      get
      {
        return (string) this.ViewState["ExpandImageUrl"] ?? string.Empty;
      }
      set
      {
        this.ViewState["ExpandImageUrl"] = (object) value;
      }
    }

    internal string ExpandImageUrlInternal
    {
      get
      {
        if (this._cachedExpandImageUrl == null)
        {
          switch (this.ImageSet)
          {
            case TreeViewImageSet.Custom:
              this._cachedExpandImageUrl = this.ExpandImageUrl;
              break;
            case TreeViewImageSet.XPFileExplorer:
              this._cachedExpandImageUrl = this.Page.ClientScript.GetWebResourceUrl(typeof (TreeView), "TreeView_XP_Explorer_Expand.gif");
              break;
            case TreeViewImageSet.Msdn:
              this._cachedExpandImageUrl = this.Page.ClientScript.GetWebResourceUrl(typeof (TreeView), "TreeView_MSDN_Expand.gif");
              break;
            case TreeViewImageSet.WindowsHelp:
              this._cachedExpandImageUrl = this.Page.ClientScript.GetWebResourceUrl(typeof (TreeView), "TreeView_Windows_Help_Expand.gif");
              break;
            case TreeViewImageSet.Arrows:
              this._cachedExpandImageUrl = this.Page.ClientScript.GetWebResourceUrl(typeof (TreeView), "TreeView_Arrows_Expand.gif");
              break;
            case TreeViewImageSet.Contacts:
              this._cachedExpandImageUrl = this.Page.ClientScript.GetWebResourceUrl(typeof (TreeView), "TreeView_Contacts_Expand.gif");
              break;
            default:
              this._cachedExpandImageUrl = string.Empty;
              break;
          }
        }
        return this._cachedExpandImageUrl;
      }
    }

    internal string ExpandStateID
    {
      get
      {
        if (this._cachedExpandStateID == null)
          this._cachedExpandStateID = this.ClientID + "_ExpandState";
        return this._cachedExpandStateID;
      }
    }

    /// <summary>
    /// Gets a reference to the <see cref="T:System.Web.UI.WebControls.TreeNodeStyle"/> object that allows you to set the appearance of a node when the mouse pointer is positioned over it.
    /// </summary>
    /// 
    /// <returns>
    /// A reference to the <see cref="T:System.Web.UI.WebControls.TreeNodeStyle"/> that represents the style of a node when the mouse pointer is positioned over it.
    /// </returns>
    [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
    [PersistenceMode(PersistenceMode.InnerProperty)]
    [DefaultValue(null)]
    [WebSysDescription("TreeView_HoverNodeStyle")]
    [NotifyParentProperty(true)]
    [WebCategory("Styles")]
    public Style HoverNodeStyle
    {
      get
      {
        if (this._hoverNodeStyle == null)
        {
          this._hoverNodeStyle = new Style();
          if (this.IsTrackingViewState)
            ((IStateManager) this._hoverNodeStyle).TrackViewState();
        }
        return this._hoverNodeStyle;
      }
    }

    internal string ImageArrayID
    {
      get
      {
        if (this._cachedImageArrayID == null)
          this._cachedImageArrayID = this.ClientID + "_ImageArray";
        return this._cachedImageArrayID;
      }
    }

    /// <summary>
    /// Gets or sets the group of images to use for the <see cref="T:System.Web.UI.WebControls.TreeView"/> control.
    /// </summary>
    /// 
    /// <returns>
    /// One of the <see cref="T:System.Web.UI.WebControls.TreeViewImageSet"/> values. The default is TreeViewImageSet.Custom.
    /// </returns>
    /// <exception cref="T:System.ArgumentOutOfRangeException">The specified image set is not one of the <see cref="T:System.Web.UI.WebControls.TreeViewImageSet"/> values. </exception>
    [DefaultValue(TreeViewImageSet.Custom)]
    [WebCategory("Appearance")]
    [WebSysDescription("TreeView_ImageSet")]
    public TreeViewImageSet ImageSet
    {
      get
      {
        object obj = this.ViewState["ImageSet"];
        if (obj == null)
          return TreeViewImageSet.Custom;
        return (TreeViewImageSet) obj;
      }
      set
      {
        if (value < TreeViewImageSet.Custom || value > TreeViewImageSet.Faq)
          throw new ArgumentOutOfRangeException("value");
        this.ViewState["ImageSet"] = (object) value;
      }
    }

    private string[] ImageUrls
    {
      get
      {
        if (this._imageUrls == null)
          this._imageUrls = new string[19];
        return this._imageUrls;
      }
    }

    internal bool IsNotIE
    {
      [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")] get
      {
        return this._isNotIE;
      }
    }

    /// <summary>
    /// Gets a reference to the <see cref="T:System.Web.UI.WebControls.TreeNodeStyle"/> object that allows you to set the appearance of leaf nodes.
    /// </summary>
    /// 
    /// <returns>
    /// A reference to the <see cref="T:System.Web.UI.WebControls.TreeNodeStyle"/> that represents the style of the leaf nodes in the <see cref="T:System.Web.UI.WebControls.TreeView"/>.
    /// </returns>
    [DefaultValue(null)]
    [NotifyParentProperty(true)]
    [PersistenceMode(PersistenceMode.InnerProperty)]
    [WebSysDescription("TreeView_LeafNodeStyle")]
    [WebCategory("Styles")]
    [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
    public TreeNodeStyle LeafNodeStyle
    {
      get
      {
        if (this._leafNodeStyle == null)
        {
          this._leafNodeStyle = new TreeNodeStyle();
          if (this.IsTrackingViewState)
            this._leafNodeStyle.TrackViewState();
        }
        return this._leafNodeStyle;
      }
    }

    private string[] LevelImageUrls
    {
      get
      {
        if (this._levelImageUrls == null)
          this._levelImageUrls = new string[this.LevelStyles.Count];
        return this._levelImageUrls;
      }
    }

    /// <summary>
    /// Gets a collection of <see cref="T:System.Web.UI.WebControls.Style"/> objects that represent the node styles at the individual levels of the tree.
    /// </summary>
    /// 
    /// <returns>
    /// A <see cref="T:System.Web.UI.WebControls.StyleCollection"/> that represents the node styles at the individual levels of the tree.
    /// </returns>
    [WebSysDescription("TreeView_LevelStyles")]
    [DefaultValue(null)]
    [Editor("System.Web.UI.Design.WebControls.TreeNodeStyleCollectionEditor,System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof (UITypeEditor))]
    [PersistenceMode(PersistenceMode.InnerProperty)]
    [WebCategory("Styles")]
    public TreeNodeStyleCollection LevelStyles
    {
      get
      {
        if (this._levelStyles == null)
        {
          this._levelStyles = new TreeNodeStyleCollection();
          if (this.IsTrackingViewState)
            this._levelStyles.TrackViewState();
        }
        return this._levelStyles;
      }
    }

    /// <summary>
    /// Gets or sets the path to a folder that contains the line images that are used to connect child nodes to parent nodes.
    /// </summary>
    /// 
    /// <returns>
    /// The path to a folder that contains the line images used to connect nodes. The default is an empty string (""), which indicates that the <see cref="P:System.Web.UI.WebControls.TreeView.LineImagesFolder"/> property is not set.
    /// </returns>
    [WebCategory("Appearance")]
    [DefaultValue("")]
    [WebSysDescription("TreeView_LineImagesFolderUrl")]
    public string LineImagesFolder
    {
      get
      {
        return (string) this.ViewState["LineImagesFolder"] ?? string.Empty;
      }
      set
      {
        this.ViewState["LineImagesFolder"] = (object) value;
      }
    }

    internal bool LoadingNodeState
    {
      [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")] get
      {
        return this._loadingNodeState;
      }
    }

    /// <summary>
    /// Gets or sets the maximum number of tree levels to bind to the <see cref="T:System.Web.UI.WebControls.TreeView"/> control.
    /// </summary>
    /// 
    /// <returns>
    /// The maximum number of tree levels to bind to the <see cref="T:System.Web.UI.WebControls.TreeView"/> control. The default is -1, which binds all the tree levels in the data source to the control.
    /// </returns>
    /// <exception cref="T:System.ArgumentOutOfRangeException">The selected value is less than -1.</exception>
    [WebCategory("Behavior")]
    [DefaultValue(-1)]
    [WebSysDescription("TreeView_MaxDataBindDepth")]
    public int MaxDataBindDepth
    {
      get
      {
        object obj = this.ViewState["MaxDataBindDepth"];
        if (obj == null)
          return -1;
        return (int) obj;
      }
      set
      {
        if (value < -1)
          throw new ArgumentOutOfRangeException("value");
        this.ViewState["MaxDataBindDepth"] = (object) value;
      }
    }

    /// <summary>
    /// Gets or sets the URL to a custom image for the non-expandable node indicator.
    /// </summary>
    /// 
    /// <returns>
    /// The URL to a custom image to display for non-expandable nodes. The default is an empty string (""), which displays the default blank image.
    /// </returns>
    [WebCategory("Appearance")]
    [Editor("System.Web.UI.Design.ImageUrlEditor, System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof (UITypeEditor))]
    [UrlProperty]
    [DefaultValue("")]
    [WebSysDescription("TreeView_NoExpandImageUrl")]
    public string NoExpandImageUrl
    {
      get
      {
        return (string) this.ViewState["NoExpandImageUrl"] ?? string.Empty;
      }
      set
      {
        this.ViewState["NoExpandImageUrl"] = (object) value;
      }
    }

    internal string NoExpandImageUrlInternal
    {
      get
      {
        if (this._cachedNoExpandImageUrl == null)
        {
          switch (this.ImageSet)
          {
            case TreeViewImageSet.Custom:
              this._cachedNoExpandImageUrl = this.NoExpandImageUrl;
              break;
            case TreeViewImageSet.XPFileExplorer:
              this._cachedNoExpandImageUrl = this.Page.ClientScript.GetWebResourceUrl(typeof (TreeView), "TreeView_XP_Explorer_NoExpand.gif");
              break;
            case TreeViewImageSet.Msdn:
              this._cachedNoExpandImageUrl = this.Page.ClientScript.GetWebResourceUrl(typeof (TreeView), "TreeView_MSDN_NoExpand.gif");
              break;
            case TreeViewImageSet.WindowsHelp:
              this._cachedNoExpandImageUrl = this.Page.ClientScript.GetWebResourceUrl(typeof (TreeView), "TreeView_Windows_Help_NoExpand.gif");
              break;
            case TreeViewImageSet.Simple:
              this._cachedNoExpandImageUrl = this.Page.ClientScript.GetWebResourceUrl(typeof (TreeView), "TreeView_Simple_NoExpand.gif");
              break;
            case TreeViewImageSet.Simple2:
              this._cachedNoExpandImageUrl = this.Page.ClientScript.GetWebResourceUrl(typeof (TreeView), "TreeView_Simple2_NoExpand.gif");
              break;
            case TreeViewImageSet.Arrows:
              this._cachedNoExpandImageUrl = this.Page.ClientScript.GetWebResourceUrl(typeof (TreeView), "TreeView_Arrows_NoExpand.gif");
              break;
            case TreeViewImageSet.Contacts:
              this._cachedNoExpandImageUrl = this.Page.ClientScript.GetWebResourceUrl(typeof (TreeView), "TreeView_Contacts_NoExpand.gif");
              break;
            default:
              this._cachedNoExpandImageUrl = string.Empty;
              break;
          }
        }
        return this._cachedNoExpandImageUrl;
      }
    }

    /// <summary>
    /// Gets or sets the indentation amount (in pixels) for the child nodes of the <see cref="T:System.Web.UI.WebControls.TreeView"/> control.
    /// </summary>
    /// 
    /// <returns>
    /// The amount of space (in pixels) between a child node's left edge and its parent node's left edge. The default is 20.
    /// </returns>
    [DefaultValue(20)]
    [WebSysDescription("TreeView_NodeIndent")]
    [WebCategory("Appearance")]
    public int NodeIndent
    {
      get
      {
        object obj = this.ViewState["NodeIndent"];
        if (obj == null)
          return 20;
        return (int) obj;
      }
      set
      {
        this.ViewState["NodeIndent"] = (object) value;
      }
    }

    /// <summary>
    /// Gets or sets a value indicating whether text wraps in a node when the node runs out of space.
    /// </summary>
    /// 
    /// <returns>
    /// true to wrap the text; otherwise, false. The default is false.
    /// </returns>
    [WebCategory("Appearance")]
    [WebSysDescription("TreeView_NodeWrap")]
    [DefaultValue(false)]
    public bool NodeWrap
    {
      get
      {
        object obj = this.ViewState["NodeWrap"];
        if (obj == null)
          return false;
        return (bool) obj;
      }
      set
      {
        this.ViewState["NodeWrap"] = (object) (bool) (value ? 1 : 0);
      }
    }

    /// <summary>
    /// Gets a collection of <see cref="T:System.Web.UI.WebControls.TreeNode"/> objects that represents the root nodes in the <see cref="T:System.Web.UI.WebControls.TreeView"/> control.
    /// </summary>
    /// 
    /// <returns>
    /// A <see cref="T:System.Web.UI.WebControls.TreeNodeCollection"/> that contains the root nodes in the <see cref="T:System.Web.UI.WebControls.TreeView"/>.
    /// </returns>
    [PersistenceMode(PersistenceMode.InnerProperty)]
    [MergableProperty(false)]
    [WebSysDescription("TreeView_Nodes")]
    [DefaultValue(null)]
    [Editor("System.Web.UI.Design.WebControls.TreeNodeCollectionEditor,System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof (UITypeEditor))]
    public TreeNodeCollection Nodes
    {
      get
      {
        return this.RootNode.ChildNodes;
      }
    }

    /// <summary>
    /// Gets a reference to the <see cref="T:System.Web.UI.WebControls.TreeNodeStyle"/> object that allows you to set the default appearance of the nodes in the <see cref="T:System.Web.UI.WebControls.TreeView"/> control.
    /// </summary>
    /// 
    /// <returns>
    /// A reference to the <see cref="T:System.Web.UI.WebControls.TreeNodeStyle"/> that represents the default style of a node.
    /// </returns>
    [WebCategory("Styles")]
    [DefaultValue(null)]
    [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
    [NotifyParentProperty(true)]
    [PersistenceMode(PersistenceMode.InnerProperty)]
    [WebSysDescription("TreeView_NodeStyle")]
    public TreeNodeStyle NodeStyle
    {
      get
      {
        if (this._nodeStyle == null)
        {
          this._nodeStyle = new TreeNodeStyle();
          if (this.IsTrackingViewState)
            this._nodeStyle.TrackViewState();
        }
        return this._nodeStyle;
      }
    }

    /// <summary>
    /// Gets a reference to the <see cref="T:System.Web.UI.WebControls.TreeNodeStyle"/> object that allows you to set the appearance of parent nodes in the <see cref="T:System.Web.UI.WebControls.TreeView"/> control.
    /// </summary>
    /// 
    /// <returns>
    /// A reference to the <see cref="T:System.Web.UI.WebControls.TreeNodeStyle"/> that represents the style of the parent nodes in the <see cref="T:System.Web.UI.WebControls.TreeView"/>.
    /// </returns>
    [NotifyParentProperty(true)]
    [PersistenceMode(PersistenceMode.InnerProperty)]
    [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
    [WebCategory("Styles")]
    [DefaultValue(null)]
    [WebSysDescription("TreeView_ParentNodeStyle")]
    public TreeNodeStyle ParentNodeStyle
    {
      get
      {
        if (this._parentNodeStyle == null)
        {
          this._parentNodeStyle = new TreeNodeStyle();
          if (this.IsTrackingViewState)
            this._parentNodeStyle.TrackViewState();
        }
        return this._parentNodeStyle;
      }
    }

    /// <summary>
    /// Gets or sets the character that is used to delimit the node values that are specified by the <see cref="P:System.Web.UI.WebControls.TreeNode.ValuePath"/> property.
    /// </summary>
    /// 
    /// <returns>
    /// The character used to delimit the node values specified in the <see cref="P:System.Web.UI.WebControls.TreeNode.ValuePath"/> property. The default is a slash mark (/).
    /// </returns>
    [DefaultValue('/')]
    [WebSysDescription("TreeView_PathSeparator")]
    public char PathSeparator
    {
      get
      {
        object obj = this.ViewState["PathSeparator"];
        if (obj == null)
          return '/';
        return (char) obj;
      }
      set
      {
        if ((int) value == 0)
          this.ViewState["PathSeparator"] = (object) null;
        else
          this.ViewState["PathSeparator"] = (object) value;
        foreach (TreeNode treeNode in this.Nodes)
          treeNode.ResetValuePathRecursive();
      }
    }

    internal string PopulateLogID
    {
      get
      {
        if (this._cachedPopulateLogID == null)
          this._cachedPopulateLogID = this.ClientID + "_PopulateLog";
        return this._cachedPopulateLogID;
      }
    }

    /// <summary>
    /// Gets or sets a value indicating whether node data is populated on demand from the client.
    /// </summary>
    /// 
    /// <returns>
    /// true to populate tree node data on demand from the client; otherwise, false. The default is true.
    /// </returns>
    [WebCategory("Behavior")]
    [DefaultValue(true)]
    [WebSysDescription("TreeView_PopulateNodesFromClient")]
    public bool PopulateNodesFromClient
    {
      get
      {
        if (!this.DesignMode && this.Page != null && !this.Page.Request.Browser.SupportsCallback)
          return false;
        object obj = this.ViewState["PopulateNodesFromClient"];
        if (obj == null)
          return true;
        return (bool) obj;
      }
      set
      {
        this.ViewState["PopulateNodesFromClient"] = (object) (bool) (value ? 1 : 0);
      }
    }

    internal bool RenderClientScript
    {
      [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")] get
      {
        return this._renderClientScript;
      }
    }

    internal TreeNode RootNode
    {
      get
      {
        if (this._rootNode == null)
          this._rootNode = new TreeNode(this, true);
        return this._rootNode;
      }
    }

    internal Style BaseTreeNodeStyle
    {
      get
      {
        if (this._baseNodeStyle == null)
        {
          this._baseNodeStyle = new Style();
          this._baseNodeStyle.Font.CopyFrom(this.Font);
          if (!this.ForeColor.IsEmpty)
            this._baseNodeStyle.ForeColor = this.ForeColor;
          if (!this.ControlStyle.IsSet(8192))
            this._baseNodeStyle.Font.Underline = false;
        }
        return this._baseNodeStyle;
      }
    }

    /// <summary>
    /// Gets a reference to the <see cref="T:System.Web.UI.WebControls.TreeNodeStyle"/> object that allows you to set the appearance of the root node in the <see cref="T:System.Web.UI.WebControls.TreeView"/> control.
    /// </summary>
    /// 
    /// <returns>
    /// A reference to the <see cref="T:System.Web.UI.WebControls.TreeNodeStyle"/> that represents the style of the root node in the <see cref="T:System.Web.UI.WebControls.TreeView"/>.
    /// </returns>
    [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
    [WebCategory("Styles")]
    [NotifyParentProperty(true)]
    [PersistenceMode(PersistenceMode.InnerProperty)]
    [WebSysDescription("TreeView_RootNodeStyle")]
    [DefaultValue(null)]
    public TreeNodeStyle RootNodeStyle
    {
      get
      {
        if (this._rootNodeStyle == null)
        {
          this._rootNodeStyle = new TreeNodeStyle();
          if (this.IsTrackingViewState)
            this._rootNodeStyle.TrackViewState();
        }
        return this._rootNodeStyle;
      }
    }

    /// <summary>
    /// Gets a <see cref="T:System.Web.UI.WebControls.TreeNode"/> object that represents the selected node in the <see cref="T:System.Web.UI.WebControls.TreeView"/> control.
    /// </summary>
    /// 
    /// <returns>
    /// A <see cref="T:System.Web.UI.WebControls.TreeNode"/> that represents the selected node in the <see cref="T:System.Web.UI.WebControls.TreeView"/>.
    /// </returns>
    [Browsable(false)]
    [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
    public TreeNode SelectedNode
    {
      [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")] get
      {
        return this._selectedNode;
      }
    }

    internal string SelectedNodeFieldID
    {
      get
      {
        if (this._cachedSelectedNodeFieldID == null)
          this._cachedSelectedNodeFieldID = this.ClientID + "_SelectedNode";
        return this._cachedSelectedNodeFieldID;
      }
    }

    /// <summary>
    /// Gets the <see cref="T:System.Web.UI.WebControls.TreeNodeStyle"/> object that controls the appearance of the selected node in the <see cref="T:System.Web.UI.WebControls.TreeView"/> control.
    /// </summary>
    /// 
    /// <returns>
    /// A <see cref="T:System.Web.UI.WebControls.TreeNodeStyle"/> that represents the style of the selected node in the <see cref="T:System.Web.UI.WebControls.TreeView"/> control. The default is null, which indicates that the <see cref="P:System.Web.UI.WebControls.TreeView.SelectedNodeStyle"/> property is not set.
    /// </returns>
    [WebCategory("Styles")]
    [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
    [NotifyParentProperty(true)]
    [PersistenceMode(PersistenceMode.InnerProperty)]
    [WebSysDescription("TreeView_SelectedNodeStyle")]
    [DefaultValue(null)]
    public TreeNodeStyle SelectedNodeStyle
    {
      get
      {
        if (this._selectedNodeStyle == null)
        {
          this._selectedNodeStyle = new TreeNodeStyle();
          if (this.IsTrackingViewState)
            this._selectedNodeStyle.TrackViewState();
        }
        return this._selectedNodeStyle;
      }
    }

    /// <summary>
    /// Gets the value of the selected node.
    /// </summary>
    /// 
    /// <returns>
    /// The value of the selected node.
    /// </returns>
    [Browsable(false)]
    [DefaultValue("")]
    [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
    public string SelectedValue
    {
      get
      {
        if (this.SelectedNode != null)
          return this.SelectedNode.Value;
        return string.Empty;
      }
    }

    /// <summary>
    /// Gets or sets a value indicating which node types will display a check box in the <see cref="T:System.Web.UI.WebControls.TreeView"/> control.
    /// </summary>
    /// 
    /// <returns>
    /// A bitwise combination of the <see cref="T:System.Web.UI.WebControls.TreeNodeTypes"/> values. The default is TreeNodeType.None.
    /// </returns>
    /// <exception cref="T:System.ArgumentOutOfRangeException">The bitwise combination value is outside the range of the <see cref="T:System.Web.UI.WebControls.TreeNodeTypes"/> enumeration. </exception>
    [WebCategory("Behavior")]
    [WebSysDescription("TreeView_ShowCheckBoxes")]
    [DefaultValue(TreeNodeTypes.None)]
    public TreeNodeTypes ShowCheckBoxes
    {
      get
      {
        object obj = this.ViewState["ShowCheckBoxes"];
        if (obj == null)
          return TreeNodeTypes.None;
        return (TreeNodeTypes) obj;
      }
      set
      {
        if (value < TreeNodeTypes.None || value > TreeNodeTypes.All)
          throw new ArgumentOutOfRangeException("value");
        this.ViewState["ShowCheckBoxes"] = (object) value;
      }
    }

    /// <summary>
    /// Gets or sets a value indicating whether expansion node indicators are displayed.
    /// </summary>
    /// 
    /// <returns>
    /// true to show the expansion node indicators; otherwise, false. The default is true.
    /// </returns>
    [WebCategory("Appearance")]
    [WebSysDescription("TreeView_ShowExpandCollapse")]
    [DefaultValue(true)]
    public bool ShowExpandCollapse
    {
      get
      {
        object obj = this.ViewState["ShowExpandCollapse"];
        if (obj == null)
          return true;
        return (bool) obj;
      }
      set
      {
        this.ViewState["ShowExpandCollapse"] = (object) (bool) (value ? 1 : 0);
      }
    }

    /// <summary>
    /// Gets or sets a value indicating whether lines connecting child nodes to parent nodes are displayed.
    /// </summary>
    /// 
    /// <returns>
    /// true to display lines connecting nodes; otherwise, false. The default is false.
    /// </returns>
    [WebCategory("Appearance")]
    [WebSysDescription("TreeView_ShowLines")]
    [DefaultValue(false)]
    public bool ShowLines
    {
      get
      {
        object obj = this.ViewState["ShowLines"];
        if (obj == null)
          return false;
        return (bool) obj;
      }
      set
      {
        this.ViewState["ShowLines"] = (object) (bool) (value ? 1 : 0);
      }
    }

    /// <summary>
    /// Gets or sets a value that is used to render alternate text for screen readers to skip the content for the control.
    /// </summary>
    /// 
    /// <returns>
    /// A string that the <see cref="T:System.Web.UI.WebControls.TreeView"/> renders as alternate text with an invisible image as a hint to screen readers. The default is "Skip Navigation Links."
    /// </returns>
    [WebSysDefaultValue("TreeView_Default_SkipLinkText")]
    [WebCategory("Accessibility")]
    [WebSysDescription("TreeView_SkipLinkText")]
    [Localizable(true)]
    public string SkipLinkText
    {
      get
      {
        return this.ViewState["SkipLinkText"] as string ?? System.Web.SR.GetString("TreeView_Default_SkipLinkText");
      }
      set
      {
        this.ViewState["SkipLinkText"] = (object) value;
      }
    }

    /// <summary>
    /// Gets or sets the target window or frame in which to display the Web page content that is associated with a node.
    /// </summary>
    /// 
    /// <returns>
    /// The target window or frame in which to display the linked Web page content. Values must begin with a letter in the range of A through Z (case insensitive), except for certain special values that begin with an underscore, as shown in the following table.Target value Renders the content in _blankA new window without frames. _parentThe immediate frameset parent. _searchThe search pane._selfThe frame with focus. _topThe full window without frames. NoteCheck your browser documentation to determine if the _search value is supported.  For example, Microsoft Internet Explorer 5.0 and later supports the _search target value.The default is an empty string (""), which refreshes the window or frame with focus.
    /// </returns>
    [WebSysDescription("TreeNode_Target")]
    [DefaultValue("")]
    public string Target
    {
      get
      {
        return (string) this.ViewState["Target"] ?? string.Empty;
      }
      set
      {
        this.ViewState["Target"] = (object) value;
      }
    }

    /// <summary>
    /// Gets the <see cref="T:System.Web.UI.HtmlTextWriterTag"/> value for the <see cref="T:System.Web.UI.WebControls.TreeView"/> control.
    /// </summary>
    /// 
    /// <returns>
    /// Always returns a <see cref="F:System.Web.UI.HtmlTextWriterTag.Div"/> value.
    /// </returns>
    protected override HtmlTextWriterTag TagKey
    {
      get
      {
        return !this.DesignMode ? HtmlTextWriterTag.Div : HtmlTextWriterTag.Table;
      }
    }

    /// <summary>
    /// Gets or sets a value indicating whether the control is rendered as UI on the page.
    /// </summary>
    /// 
    /// <returns>
    /// true, if the control is visible on the page; otherwise, false.
    /// </returns>
    public override bool Visible
    {
      get
      {
        return base.Visible;
      }
      set
      {
        if (value && this.Page != null && (this.Page.IsPostBack && this.ViewState["NeverExpanded"] != null) && (bool) this.ViewState["NeverExpanded"])
          this.ExpandToDepth(this.Nodes, this.ExpandDepth);
        base.Visible = value;
      }
    }

    /// <summary>
    /// Occurs when a check box in the <see cref="T:System.Web.UI.WebControls.TreeView"/> control changes state between posts to the server.
    /// </summary>
    [WebSysDescription("TreeView_CheckChanged")]
    [WebCategory("Behavior")]
    public event TreeNodeEventHandler TreeNodeCheckChanged
    {
      add
      {
        this.Events.AddHandler(TreeView.CheckChangedEvent, (Delegate) value);
      }
      remove
      {
        this.Events.RemoveHandler(TreeView.CheckChangedEvent, (Delegate) value);
      }
    }

    /// <summary>
    /// Occurs when a node is selected in the <see cref="T:System.Web.UI.WebControls.TreeView"/> control.
    /// </summary>
    [WebCategory("Behavior")]
    [WebSysDescription("TreeView_SelectedNodeChanged")]
    public event EventHandler SelectedNodeChanged
    {
      add
      {
        this.Events.AddHandler(TreeView.SelectedNodeChangedEvent, (Delegate) value);
      }
      remove
      {
        this.Events.RemoveHandler(TreeView.SelectedNodeChangedEvent, (Delegate) value);
      }
    }

    /// <summary>
    /// Occurs when a node is collapsed in the <see cref="T:System.Web.UI.WebControls.TreeView"/> control.
    /// </summary>
    [WebCategory("Behavior")]
    [WebSysDescription("TreeView_TreeNodeCollapsed")]
    public event TreeNodeEventHandler TreeNodeCollapsed
    {
      add
      {
        this.Events.AddHandler(TreeView.TreeNodeCollapsedEvent, (Delegate) value);
      }
      remove
      {
        this.Events.RemoveHandler(TreeView.TreeNodeCollapsedEvent, (Delegate) value);
      }
    }

    /// <summary>
    /// Occurs when a data item is bound to a node in the <see cref="T:System.Web.UI.WebControls.TreeView"/> control.
    /// </summary>
    [WebCategory("Behavior")]
    [WebSysDescription("TreeView_TreeNodeDataBound")]
    public event TreeNodeEventHandler TreeNodeDataBound
    {
      add
      {
        this.Events.AddHandler(TreeView.TreeNodeDataBoundEvent, (Delegate) value);
      }
      remove
      {
        this.Events.RemoveHandler(TreeView.TreeNodeDataBoundEvent, (Delegate) value);
      }
    }

    /// <summary>
    /// Occurs when a node is expanded in the <see cref="T:System.Web.UI.WebControls.TreeView"/> control.
    /// </summary>
    [WebCategory("Behavior")]
    [WebSysDescription("TreeView_TreeNodeExpanded")]
    public event TreeNodeEventHandler TreeNodeExpanded
    {
      add
      {
        this.Events.AddHandler(TreeView.TreeNodeExpandedEvent, (Delegate) value);
      }
      remove
      {
        this.Events.RemoveHandler(TreeView.TreeNodeExpandedEvent, (Delegate) value);
      }
    }

    /// <summary>
    /// Occurs when a node with its <see cref="P:System.Web.UI.WebControls.TreeNode.PopulateOnDemand"/> property set to true is expanded in the <see cref="T:System.Web.UI.WebControls.TreeView"/> control.
    /// </summary>
    [WebSysDescription("TreeView_TreeNodePopulate")]
    [WebCategory("Behavior")]
    public event TreeNodeEventHandler TreeNodePopulate
    {
      add
      {
        this.Events.AddHandler(TreeView.TreeNodePopulateEvent, (Delegate) value);
      }
      remove
      {
        this.Events.RemoveHandler(TreeView.TreeNodePopulateEvent, (Delegate) value);
      }
    }

    /// <summary>
    /// Initializes a new instance of the <see cref="T:System.Web.UI.WebControls.TreeView"/> class.
    /// </summary>
    [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
    public TreeView()
    {
    }

    /// <summary>
    /// Adds HTML attributes and styles that need to be rendered to the specified <see cref="T:System.Web.UI.HtmlTextWriter"/> control.
    /// </summary>
    /// <param name="writer">An <see cref="T:System.Web.UI.HtmlTextWriter"/> that represents the output stream to render HTML content on the client. </param>
    protected override void AddAttributesToRender(HtmlTextWriter writer)
    {
      if (this.Page != null)
        this.Page.VerifyRenderingInServerForm((Control) this);
      string accessKey = this.AccessKey;
      if (!string.IsNullOrEmpty(accessKey))
      {
        this.AccessKey = string.Empty;
        base.AddAttributesToRender(writer);
        this.AccessKey = accessKey;
      }
      else
        base.AddAttributesToRender(writer);
    }

    private static T CacheGetItem<T>(List<T> cacheList, int index) where T : class
    {
      if (index < cacheList.Count)
        return cacheList[index];
      return default (T);
    }

    private static void CacheSetItem<T>(List<T> cacheList, int index, T item) where T : class
    {
      if (cacheList.Count > index)
      {
        cacheList[index] = item;
      }
      else
      {
        for (int count = cacheList.Count; count < index; ++count)
          cacheList.Add(default (T));
        cacheList.Add(item);
      }
    }

    /// <summary>
    /// Closes every node in the tree.
    /// </summary>
    public void CollapseAll()
    {
      foreach (TreeNode treeNode in this.Nodes)
        treeNode.CollapseAll();
    }

    /// <summary>
    /// Creates a collection to store child controls.
    /// </summary>
    /// 
    /// <returns>
    /// Always returns an <see cref="T:System.Web.UI.EmptyControlCollection"/>.
    /// </returns>
    protected override ControlCollection CreateControlCollection()
    {
      return (ControlCollection) new EmptyControlCollection((Control) this);
    }

    /// <summary>
    /// Returns a new instance of the <see cref="T:System.Web.UI.WebControls.TreeNode"/> class. The <see cref="M:System.Web.UI.WebControls.TreeView.CreateNode"/> is a helper method.
    /// </summary>
    /// 
    /// <returns>
    /// A new instance of the <see cref="T:System.Web.UI.WebControls.TreeNode"/>.
    /// </returns>
    protected internal virtual TreeNode CreateNode()
    {
      return new TreeNode(this, false);
    }

    internal string CreateNodeId(int index)
    {
      return this.ClientID + (object) "n" + (string) (object) index;
    }

    internal string CreateNodeTextId(int index)
    {
      return this.ClientID + (object) "t" + (string) (object) index;
    }

    /// <summary>
    /// Calls the <see cref="M:System.Web.UI.WebControls.BaseDataBoundControl.DataBind"/> method of the base class.
    /// </summary>
    public override sealed void DataBind()
    {
      base.DataBind();
    }

    /// <summary>
    /// Opens every node in the tree.
    /// </summary>
    public void ExpandAll()
    {
      foreach (TreeNode treeNode in this.Nodes)
        treeNode.ExpandAll();
    }

    /// <summary>
    /// Retrieves the <see cref="T:System.Web.UI.WebControls.TreeNode"/> object in the <see cref="T:System.Web.UI.WebControls.TreeView"/> control at the specified value path.
    /// </summary>
    /// 
    /// <returns>
    /// The <see cref="T:System.Web.UI.WebControls.TreeNode"/> at the specified value path.
    /// </returns>
    /// <param name="valuePath">The value path of a node. </param>
    public TreeNode FindNode(string valuePath)
    {
      if (valuePath == null)
        return (TreeNode) null;
      return this.Nodes.FindNode(valuePath.Split(this.PathSeparator), 0);
    }

    internal string GetCssClassName(TreeNode node, bool hyperLink)
    {
      bool containsClassName;
      return this.GetCssClassName(node, hyperLink, out containsClassName);
    }

    internal string GetCssClassName(TreeNode node, bool hyperLink, out bool containsClassName)
    {
      if (node == null)
        throw new ArgumentNullException("node");
      containsClassName = false;
      int depth = node.Depth;
      bool flag1 = node.ChildNodes.Count != 0 || node.PopulateOnDemand;
      List<string> cacheList = flag1 ? (hyperLink ? this.CachedParentNodeHyperLinkClassNames : this.CachedParentNodeClassNames) : (hyperLink ? this.CachedLeafNodeHyperLinkClassNames : this.CachedLeafNodeClassNames);
      string str = TreeView.CacheGetItem<string>(cacheList, depth);
      if (this.CachedLevelsContainingCssClass.Contains(depth))
        containsClassName = true;
      bool flag2 = node.Selected && this._selectedNodeStyle != null;
      if (!flag2 && str != null)
        return str;
      StringBuilder builder = new StringBuilder();
      if (str != null)
      {
        builder.Append(str);
        builder.Append(' ');
      }
      else
      {
        if (hyperLink)
        {
          builder.Append(this.BaseTreeNodeStyle.RegisteredCssClass);
          builder.Append(' ');
        }
        containsClassName |= TreeView.AppendCssClassName(builder, this._nodeStyle, hyperLink);
        if (depth < this.LevelStyles.Count && this.LevelStyles[depth] != null)
          containsClassName |= TreeView.AppendCssClassName(builder, this.LevelStyles[depth], hyperLink);
        if (depth == 0 && flag1)
          containsClassName |= TreeView.AppendCssClassName(builder, this._rootNodeStyle, hyperLink);
        else if (flag1)
          containsClassName |= TreeView.AppendCssClassName(builder, this._parentNodeStyle, hyperLink);
        else
          containsClassName |= TreeView.AppendCssClassName(builder, this._leafNodeStyle, hyperLink);
        str = builder.ToString().Trim();
        TreeView.CacheSetItem<string>(cacheList, depth, str);
        if (containsClassName && !this.CachedLevelsContainingCssClass.Contains(depth))
          this.CachedLevelsContainingCssClass.Add(depth);
      }
      if (!flag2)
        return str;
      containsClassName |= TreeView.AppendCssClassName(builder, this._selectedNodeStyle, hyperLink);
      return builder.ToString().Trim();
    }

    internal string GetImageUrl(int index)
    {
      if (this.ImageUrls[index] == null)
      {
        switch (index)
        {
          case 0:
            string relativeUrl1 = this.RootNodeStyle.ImageUrl;
            if (relativeUrl1.Length == 0)
              relativeUrl1 = this.NodeStyle.ImageUrl;
            if (relativeUrl1.Length == 0)
            {
              switch (this.ImageSet)
              {
                case TreeViewImageSet.XPFileExplorer:
                  relativeUrl1 = this.Page.ClientScript.GetWebResourceUrl(typeof (TreeView), "TreeView_XP_Explorer_RootNode.gif");
                  break;
                case TreeViewImageSet.BulletedList:
                  relativeUrl1 = this.Page.ClientScript.GetWebResourceUrl(typeof (TreeView), "TreeView_BulletedList_RootNode.gif");
                  break;
                case TreeViewImageSet.BulletedList2:
                  relativeUrl1 = this.Page.ClientScript.GetWebResourceUrl(typeof (TreeView), "TreeView_BulletedList2_RootNode.gif");
                  break;
                case TreeViewImageSet.BulletedList3:
                  relativeUrl1 = this.Page.ClientScript.GetWebResourceUrl(typeof (TreeView), "TreeView_BulletedList3_RootNode.gif");
                  break;
                case TreeViewImageSet.BulletedList4:
                  relativeUrl1 = this.Page.ClientScript.GetWebResourceUrl(typeof (TreeView), "TreeView_BulletedList4_RootNode.gif");
                  break;
                case TreeViewImageSet.News:
                  relativeUrl1 = this.Page.ClientScript.GetWebResourceUrl(typeof (TreeView), "TreeView_News_RootNode.gif");
                  break;
                case TreeViewImageSet.Inbox:
                  relativeUrl1 = this.Page.ClientScript.GetWebResourceUrl(typeof (TreeView), "TreeView_Inbox_RootNode.gif");
                  break;
                case TreeViewImageSet.Events:
                  relativeUrl1 = this.Page.ClientScript.GetWebResourceUrl(typeof (TreeView), "TreeView_Events_RootNode.gif");
                  break;
                case TreeViewImageSet.Faq:
                  relativeUrl1 = this.Page.ClientScript.GetWebResourceUrl(typeof (TreeView), "TreeView_FAQ_RootNode.gif");
                  break;
              }
            }
            if (relativeUrl1.Length != 0)
              relativeUrl1 = this.ResolveClientUrl(relativeUrl1);
            this.ImageUrls[index] = relativeUrl1;
            break;
          case 1:
            string relativeUrl2 = this.ParentNodeStyle.ImageUrl;
            if (relativeUrl2.Length == 0)
              relativeUrl2 = this.NodeStyle.ImageUrl;
            if (relativeUrl2.Length == 0)
            {
              switch (this.ImageSet)
              {
                case TreeViewImageSet.XPFileExplorer:
                  relativeUrl2 = this.Page.ClientScript.GetWebResourceUrl(typeof (TreeView), "TreeView_XP_Explorer_ParentNode.gif");
                  break;
                case TreeViewImageSet.BulletedList:
                  relativeUrl2 = this.Page.ClientScript.GetWebResourceUrl(typeof (TreeView), "TreeView_BulletedList_ParentNode.gif");
                  break;
                case TreeViewImageSet.BulletedList2:
                  relativeUrl2 = this.Page.ClientScript.GetWebResourceUrl(typeof (TreeView), "TreeView_BulletedList2_ParentNode.gif");
                  break;
                case TreeViewImageSet.BulletedList3:
                  relativeUrl2 = this.Page.ClientScript.GetWebResourceUrl(typeof (TreeView), "TreeView_BulletedList3_ParentNode.gif");
                  break;
                case TreeViewImageSet.BulletedList4:
                  relativeUrl2 = this.Page.ClientScript.GetWebResourceUrl(typeof (TreeView), "TreeView_BulletedList4_ParentNode.gif");
                  break;
                case TreeViewImageSet.News:
                  relativeUrl2 = this.Page.ClientScript.GetWebResourceUrl(typeof (TreeView), "TreeView_News_ParentNode.gif");
                  break;
                case TreeViewImageSet.Inbox:
                  relativeUrl2 = this.Page.ClientScript.GetWebResourceUrl(typeof (TreeView), "TreeView_Inbox_ParentNode.gif");
                  break;
                case TreeViewImageSet.Events:
                  relativeUrl2 = this.Page.ClientScript.GetWebResourceUrl(typeof (TreeView), "TreeView_Events_ParentNode.gif");
                  break;
                case TreeViewImageSet.Faq:
                  relativeUrl2 = this.Page.ClientScript.GetWebResourceUrl(typeof (TreeView), "TreeView_FAQ_ParentNode.gif");
                  break;
              }
            }
            if (relativeUrl2.Length != 0)
              relativeUrl2 = this.ResolveClientUrl(relativeUrl2);
            this.ImageUrls[index] = relativeUrl2;
            break;
          case 2:
            string relativeUrl3 = this.LeafNodeStyle.ImageUrl;
            if (relativeUrl3.Length == 0)
              relativeUrl3 = this.NodeStyle.ImageUrl;
            if (relativeUrl3.Length == 0)
            {
              switch (this.ImageSet)
              {
                case TreeViewImageSet.XPFileExplorer:
                  relativeUrl3 = this.Page.ClientScript.GetWebResourceUrl(typeof (TreeView), "TreeView_XP_Explorer_LeafNode.gif");
                  break;
                case TreeViewImageSet.BulletedList:
                  relativeUrl3 = this.Page.ClientScript.GetWebResourceUrl(typeof (TreeView), "TreeView_BulletedList_LeafNode.gif");
                  break;
                case TreeViewImageSet.BulletedList2:
                  relativeUrl3 = this.Page.ClientScript.GetWebResourceUrl(typeof (TreeView), "TreeView_BulletedList2_LeafNode.gif");
                  break;
                case TreeViewImageSet.BulletedList3:
                  relativeUrl3 = this.Page.ClientScript.GetWebResourceUrl(typeof (TreeView), "TreeView_BulletedList3_LeafNode.gif");
                  break;
                case TreeViewImageSet.BulletedList4:
                  relativeUrl3 = this.Page.ClientScript.GetWebResourceUrl(typeof (TreeView), "TreeView_BulletedList4_LeafNode.gif");
                  break;
                case TreeViewImageSet.News:
                  relativeUrl3 = this.Page.ClientScript.GetWebResourceUrl(typeof (TreeView), "TreeView_News_LeafNode.gif");
                  break;
                case TreeViewImageSet.Inbox:
                  relativeUrl3 = this.Page.ClientScript.GetWebResourceUrl(typeof (TreeView), "TreeView_Inbox_LeafNode.gif");
                  break;
                case TreeViewImageSet.Events:
                  relativeUrl3 = this.Page.ClientScript.GetWebResourceUrl(typeof (TreeView), "TreeView_Events_LeafNode.gif");
                  break;
                case TreeViewImageSet.Faq:
                  relativeUrl3 = this.Page.ClientScript.GetWebResourceUrl(typeof (TreeView), "TreeView_FAQ_LeafNode.gif");
                  break;
              }
            }
            if (relativeUrl3.Length != 0)
              relativeUrl3 = this.ResolveClientUrl(relativeUrl3);
            this.ImageUrls[index] = relativeUrl3;
            break;
          case 3:
            this.ImageUrls[index] = !this.ShowLines ? (this.NoExpandImageUrlInternal.Length <= 0 ? (this.LineImagesFolder.Length <= 0 ? this.Page.ClientScript.GetWebResourceUrl(typeof (TreeView), "TreeView_Default_NoExpand.gif") : this.ResolveClientUrl(UrlPath.SimpleCombine(this.LineImagesFolder, "noexpand.gif"))) : this.ResolveClientUrl(this.NoExpandImageUrlInternal)) : (this.LineImagesFolder.Length != 0 ? this.ResolveClientUrl(UrlPath.SimpleCombine(this.LineImagesFolder, "noexpand.gif")) : this.Page.ClientScript.GetWebResourceUrl(typeof (TreeView), "TreeView_Default_NoExpand.gif"));
            break;
          case 4:
            this.ImageUrls[index] = !this.ShowLines ? (this.ExpandImageUrlInternal.Length <= 0 ? (this.LineImagesFolder.Length <= 0 ? this.Page.ClientScript.GetWebResourceUrl(typeof (TreeView), "TreeView_Default_Expand.gif") : this.ResolveClientUrl(UrlPath.SimpleCombine(this.LineImagesFolder, "plus.gif"))) : this.ResolveClientUrl(this.ExpandImageUrlInternal)) : (this.LineImagesFolder.Length != 0 ? this.ResolveClientUrl(UrlPath.SimpleCombine(this.LineImagesFolder, "plus.gif")) : this.Page.ClientScript.GetWebResourceUrl(typeof (TreeView), "TreeView_Default_Expand.gif"));
            break;
          case 5:
            this.ImageUrls[index] = !this.ShowLines ? (this.CollapseImageUrlInternal.Length <= 0 ? (this.LineImagesFolder.Length <= 0 ? this.Page.ClientScript.GetWebResourceUrl(typeof (TreeView), "TreeView_Default_Collapse.gif") : this.ResolveClientUrl(UrlPath.SimpleCombine(this.LineImagesFolder, "minus.gif"))) : this.ResolveClientUrl(this.CollapseImageUrlInternal)) : (this.LineImagesFolder.Length != 0 ? this.ResolveClientUrl(UrlPath.SimpleCombine(this.LineImagesFolder, "minus.gif")) : this.Page.ClientScript.GetWebResourceUrl(typeof (TreeView), "TreeView_Default_Collapse.gif"));
            break;
          case 6:
            this.ImageUrls[index] = this.LineImagesFolder.Length != 0 ? this.ResolveClientUrl(UrlPath.SimpleCombine(this.LineImagesFolder, "i.gif")) : this.Page.ClientScript.GetWebResourceUrl(typeof (TreeView), "TreeView_Default_I.gif");
            break;
          case 7:
            this.ImageUrls[index] = this.LineImagesFolder.Length != 0 ? this.ResolveClientUrl(UrlPath.SimpleCombine(this.LineImagesFolder, "r.gif")) : this.Page.ClientScript.GetWebResourceUrl(typeof (TreeView), "TreeView_Default_R.gif");
            break;
          case 8:
            this.ImageUrls[index] = this.LineImagesFolder.Length != 0 ? this.ResolveClientUrl(UrlPath.SimpleCombine(this.LineImagesFolder, "rplus.gif")) : this.Page.ClientScript.GetWebResourceUrl(typeof (TreeView), "TreeView_Default_RExpand.gif");
            break;
          case 9:
            this.ImageUrls[index] = this.LineImagesFolder.Length != 0 ? this.ResolveClientUrl(UrlPath.SimpleCombine(this.LineImagesFolder, "rminus.gif")) : this.Page.ClientScript.GetWebResourceUrl(typeof (TreeView), "TreeView_Default_RCollapse.gif");
            break;
          case 10:
            this.ImageUrls[index] = this.LineImagesFolder.Length != 0 ? this.ResolveClientUrl(UrlPath.SimpleCombine(this.LineImagesFolder, "t.gif")) : this.Page.ClientScript.GetWebResourceUrl(typeof (TreeView), "TreeView_Default_T.gif");
            break;
          case 11:
            this.ImageUrls[index] = this.LineImagesFolder.Length != 0 ? this.ResolveClientUrl(UrlPath.SimpleCombine(this.LineImagesFolder, "tplus.gif")) : this.Page.ClientScript.GetWebResourceUrl(typeof (TreeView), "TreeView_Default_TExpand.gif");
            break;
          case 12:
            this.ImageUrls[index] = this.LineImagesFolder.Length != 0 ? this.ResolveClientUrl(UrlPath.SimpleCombine(this.LineImagesFolder, "tminus.gif")) : this.Page.ClientScript.GetWebResourceUrl(typeof (TreeView), "TreeView_Default_TCollapse.gif");
            break;
          case 13:
            this.ImageUrls[index] = this.LineImagesFolder.Length != 0 ? this.ResolveClientUrl(UrlPath.SimpleCombine(this.LineImagesFolder, "l.gif")) : this.Page.ClientScript.GetWebResourceUrl(typeof (TreeView), "TreeView_Default_L.gif");
            break;
          case 14:
            this.ImageUrls[index] = this.LineImagesFolder.Length != 0 ? this.ResolveClientUrl(UrlPath.SimpleCombine(this.LineImagesFolder, "lplus.gif")) : this.Page.ClientScript.GetWebResourceUrl(typeof (TreeView), "TreeView_Default_LExpand.gif");
            break;
          case 15:
            this.ImageUrls[index] = this.LineImagesFolder.Length != 0 ? this.ResolveClientUrl(UrlPath.SimpleCombine(this.LineImagesFolder, "lminus.gif")) : this.Page.ClientScript.GetWebResourceUrl(typeof (TreeView), "TreeView_Default_LCollapse.gif");
            break;
          case 16:
            this.ImageUrls[index] = this.LineImagesFolder.Length != 0 ? this.ResolveClientUrl(UrlPath.SimpleCombine(this.LineImagesFolder, "dash.gif")) : this.Page.ClientScript.GetWebResourceUrl(typeof (TreeView), "TreeView_Default_Dash.gif");
            break;
          case 17:
            this.ImageUrls[index] = this.LineImagesFolder.Length != 0 ? this.ResolveClientUrl(UrlPath.SimpleCombine(this.LineImagesFolder, "dashplus.gif")) : this.Page.ClientScript.GetWebResourceUrl(typeof (TreeView), "TreeView_Default_DashExpand.gif");
            break;
          case 18:
            this.ImageUrls[index] = this.LineImagesFolder.Length != 0 ? this.ResolveClientUrl(UrlPath.SimpleCombine(this.LineImagesFolder, "dashminus.gif")) : this.Page.ClientScript.GetWebResourceUrl(typeof (TreeView), "TreeView_Default_DashCollapse.gif");
            break;
        }
      }
      return this.ImageUrls[index];
    }

    internal string GetLevelImageUrl(int index)
    {
      if (this.LevelImageUrls[index] == null)
      {
        string imageUrl = this.LevelStyles[index].ImageUrl;
        this.LevelImageUrls[index] = imageUrl.Length <= 0 ? string.Empty : this.ResolveClientUrl(imageUrl);
      }
      return this.LevelImageUrls[index];
    }

    internal static void GetMergedStyle(Style style1, Style style2)
    {
      string cssClass = style1.CssClass;
      style1.CopyFrom(style2);
      if (cssClass.Length == 0 || style2.CssClass.Length == 0)
        return;
      Style style = style1;
      string str = style.CssClass + (object) ' ' + cssClass;
      style.CssClass = str;
    }

    internal TreeNodeStyle GetStyle(TreeNode node)
    {
      if (node == null)
        throw new ArgumentNullException("node");
      bool flag1 = node.ChildNodes.Count != 0 || node.PopulateOnDemand;
      List<TreeNodeStyle> cacheList = flag1 ? this.CachedParentNodeStyles : this.CachedLeafNodeStyles;
      bool flag2 = node.Selected && this._selectedNodeStyle != null;
      int depth = node.Depth;
      TreeNodeStyle treeNodeStyle1 = TreeView.CacheGetItem<TreeNodeStyle>(cacheList, depth);
      if (!flag2 && treeNodeStyle1 != null)
        return treeNodeStyle1;
      if (treeNodeStyle1 == null)
      {
        treeNodeStyle1 = new TreeNodeStyle();
        treeNodeStyle1.CopyFrom(this.BaseTreeNodeStyle);
        if (this._nodeStyle != null)
          TreeView.GetMergedStyle((Style) treeNodeStyle1, (Style) this._nodeStyle);
        if (depth == 0 && flag1)
        {
          if (this._rootNodeStyle != null)
            TreeView.GetMergedStyle((Style) treeNodeStyle1, (Style) this._rootNodeStyle);
        }
        else if (flag1)
        {
          if (this._parentNodeStyle != null)
            TreeView.GetMergedStyle((Style) treeNodeStyle1, (Style) this._parentNodeStyle);
        }
        else if (this._leafNodeStyle != null)
          TreeView.GetMergedStyle((Style) treeNodeStyle1, (Style) this._leafNodeStyle);
        if (depth < this.LevelStyles.Count && this.LevelStyles[depth] != null)
          TreeView.GetMergedStyle((Style) treeNodeStyle1, (Style) this.LevelStyles[depth]);
        TreeView.CacheSetItem<TreeNodeStyle>(cacheList, depth, treeNodeStyle1);
      }
      if (!flag2)
        return treeNodeStyle1;
      TreeNodeStyle treeNodeStyle2 = new TreeNodeStyle();
      treeNodeStyle2.CopyFrom((Style) treeNodeStyle1);
      TreeView.GetMergedStyle((Style) treeNodeStyle2, (Style) this._selectedNodeStyle);
      return treeNodeStyle2;
    }

    internal static string Escape(string value)
    {
      StringBuilder stringBuilder = (StringBuilder) null;
      if (string.IsNullOrEmpty(value))
        return string.Empty;
      int startIndex = 0;
      int count = 0;
      for (int index = 0; index < value.Length; ++index)
      {
        switch (value[index])
        {
          case '\\':
            if (stringBuilder == null)
              stringBuilder = new StringBuilder(value.Length + 5);
            if (count > 0)
              stringBuilder.Append(value, startIndex, count);
            stringBuilder.Append("*|*");
            startIndex = index + 1;
            count = 0;
            break;
          case '|':
            if (stringBuilder == null)
              stringBuilder = new StringBuilder(value.Length + 5);
            if (count > 0)
              stringBuilder.Append(value, startIndex, count);
            stringBuilder.Append("||");
            startIndex = index + 1;
            count = 0;
            break;
          default:
            ++count;
            break;
        }
      }
      if (stringBuilder == null)
        return value;
      if (count > 0)
        stringBuilder.Append(value, startIndex, count);
      return stringBuilder.ToString();
    }

    internal static string UnEscape(string value)
    {
      return value.Replace("*|*", '\\'.ToString()).Replace("||", '|'.ToString());
    }

    /// <summary>
    /// Loads the previously saved view state of the <see cref="T:System.Web.UI.WebControls.TreeView"/> control.
    /// </summary>
    /// <param name="state">A object that contains the saved view state values for the control. </param>
    protected override void LoadViewState(object state)
    {
      if (state == null)
        return;
      object[] objArray = (object[]) state;
      if (objArray[0] != null)
        base.LoadViewState(objArray[0]);
      if (objArray[1] != null)
        this.NodeStyle.LoadViewState(objArray[1]);
      if (objArray[2] != null)
        this.RootNodeStyle.LoadViewState(objArray[2]);
      if (objArray[3] != null)
        this.ParentNodeStyle.LoadViewState(objArray[3]);
      if (objArray[4] != null)
        this.LeafNodeStyle.LoadViewState(objArray[4]);
      if (objArray[5] != null)
        this.SelectedNodeStyle.LoadViewState(objArray[5]);
      if (objArray[6] != null)
        ((IStateManager) this.HoverNodeStyle).LoadViewState(objArray[6]);
      if (objArray[7] != null)
        this.LevelStyles.LoadViewState(objArray[7]);
      if (objArray[8] == null)
        return;
      ((IStateManager) this.Nodes).LoadViewState(objArray[8]);
    }

    /// <summary>
    /// Raises the <see cref="E:System.Web.UI.Control.Init"/> event.
    /// </summary>
    /// <param name="e">An <see cref="T:System.EventArgs"/> that contains the event data.</param>
    protected internal override void OnInit(EventArgs e)
    {
      this.ChildControlsCreated = true;
      base.OnInit(e);
    }

    /// <summary>
    /// Raises the <see cref="E:System.Web.UI.WebControls.TreeView.TreeNodeCheckChanged"/> event of the <see cref="T:System.Web.UI.WebControls.TreeView"/> control.
    /// </summary>
    /// <param name="e">A <see cref="T:System.Web.UI.WebControls.TreeNodeEventArgs"/> that contains event data. </param>
    protected virtual void OnTreeNodeCheckChanged(TreeNodeEventArgs e)
    {
      TreeNodeEventHandler nodeEventHandler = (TreeNodeEventHandler) this.Events[TreeView.CheckChangedEvent];
      if (nodeEventHandler == null)
        return;
      nodeEventHandler((object) this, e);
    }

    /// <summary>
    /// Raises the <see cref="E:System.Web.UI.Control.PreRender"/> event.
    /// </summary>
    /// <param name="e">An <see cref="T:System.EventArgs"/> that contains event data. </param>
    protected internal override void OnPreRender(EventArgs e)
    {
      base.OnPreRender(e);
      this.EnsureRenderSettings();
      if (this.Page == null)
        return;
      if (!this.Page.IsPostBack && !this._dataBound)
        this.ExpandToDepth(this.Nodes, this.ExpandDepth);
      this.Page.RegisterRequiresPostBack((Control) this);
      StringBuilder expandState = new StringBuilder();
      int index1 = 0;
      for (int index2 = 0; index2 < this.Nodes.Count; ++index2)
        this.SaveNodeState(this.Nodes[index2], ref index1, expandState, true);
      if (!this.RenderClientScript)
        return;
      ClientScriptManager clientScript = this.Page.ClientScript;
      clientScript.RegisterHiddenField((Control) this, this.ExpandStateID, expandState.ToString());
      int num = 6;
      if (this.ShowLines)
        num = 19;
      for (int index2 = 0; index2 < num; ++index2)
      {
        string str = this.GetImageUrl(index2);
        if (str.Length > 0)
          str = Util.QuoteJScriptString(str);
        clientScript.RegisterArrayDeclaration((Control) this, this.ImageArrayID, "'" + str + "'");
      }
      string hiddenFieldValue = string.Empty;
      if (this.SelectedNode != null)
      {
        TreeNode treeNode = this.SelectedNode;
        while (treeNode != null && treeNode != this.RootNode)
          treeNode = treeNode.GetParentInternal();
        if (treeNode == this.RootNode)
        {
          hiddenFieldValue = this.SelectedNode.SelectID;
          this.ViewState["SelectedNode"] = (object) this.SelectedNode.SelectID;
        }
        else
          this.ViewState["SelectedNode"] = (object) null;
      }
      else
        this.ViewState["SelectedNode"] = (object) null;
      clientScript.RegisterHiddenField((Control) this, this.SelectedNodeFieldID, hiddenFieldValue);
      this.Page.RegisterWebFormsScript();
      clientScript.RegisterClientScriptResource((Control) this, typeof (TreeView), "TreeView.js");
      string clientDataObjectId = this.ClientDataObjectID;
      string str1 = string.Empty;
      if (this.PopulateNodesFromClient)
      {
        this.ViewState["LastIndex"] = (object) index1;
        clientScript.RegisterHiddenField((Control) this, this.PopulateLogID, string.Empty);
        str1 = clientDataObjectId + (object) ".lastIndex = " + (string) (object) index1 + ";\r\n" + clientDataObjectId + ".populateLog = theForm.elements['" + this.PopulateLogID + "'];\r\n" + clientDataObjectId + ".treeViewID = '" + this.UniqueID + "';\r\n" + clientDataObjectId + ".name = '" + clientDataObjectId + "';\r\n";
        if (!clientScript.IsClientScriptBlockRegistered(this.GetType(), "PopulateNode"))
          clientScript.RegisterClientScriptBlock((Control) this, this.GetType(), "PopulateNode", TreeView.populateNodeScript + clientScript.GetCallbackEventReference("context.data.treeViewID", "param", "TreeView_ProcessNodeData", "context", "TreeView_ProcessNodeData", false) + TreeView.populateNodeScriptEnd, true);
      }
      string str2 = string.Empty;
      if (this._selectedNodeStyle != null)
      {
        string registeredCssClass1 = this._selectedNodeStyle.RegisteredCssClass;
        if (registeredCssClass1.Length > 0)
          registeredCssClass1 += " ";
        string registeredCssClass2 = this._selectedNodeStyle.HyperLinkStyle.RegisteredCssClass;
        if (registeredCssClass2.Length > 0)
          registeredCssClass2 += " ";
        if (!string.IsNullOrEmpty(this._selectedNodeStyle.CssClass))
        {
          string str3 = this._selectedNodeStyle.CssClass + " ";
          registeredCssClass1 += str3;
          registeredCssClass2 += str3;
        }
        str2 = clientDataObjectId + ".selectedClass = '" + registeredCssClass1 + "';\r\n" + clientDataObjectId + ".selectedHyperLinkClass = '" + registeredCssClass2 + "';\r\n";
      }
      string str4 = string.Empty;
      if (this.EnableHover)
      {
        string registeredCssClass1 = this._hoverNodeStyle.RegisteredCssClass;
        string registeredCssClass2 = this._hoverNodeHyperLinkStyle.RegisteredCssClass;
        if (!string.IsNullOrEmpty(this._hoverNodeStyle.CssClass))
        {
          string cssClass = this._hoverNodeStyle.CssClass;
          if (!string.IsNullOrEmpty(registeredCssClass1))
            registeredCssClass1 += " ";
          if (!string.IsNullOrEmpty(registeredCssClass2))
            registeredCssClass2 += " ";
          registeredCssClass1 += cssClass;
          registeredCssClass2 += cssClass;
        }
        str2 = clientDataObjectId + ".hoverClass = '" + registeredCssClass1 + "';\r\n" + clientDataObjectId + ".hoverHyperLinkClass = '" + registeredCssClass2 + "';\r\n";
      }
      string script = "var " + (object) clientDataObjectId + " = new Object();\r\n" + clientDataObjectId + ".images = " + this.ImageArrayID + ";\r\n" + clientDataObjectId + ".collapseToolTip = \"" + Util.QuoteJScriptString(this.CollapseImageToolTip) + "\";\r\n" + clientDataObjectId + ".expandToolTip = \"" + Util.QuoteJScriptString(this.ExpandImageToolTip) + "\";\r\n" + clientDataObjectId + ".expandState = theForm.elements['" + this.ExpandStateID + "'];\r\n" + clientDataObjectId + ".selectedNodeID = theForm.elements['" + this.SelectedNodeFieldID + "'];\r\n" + str2 + str4 + "(function() {\r\n  for (var i=0;i<" + (string) (object) num + ";i++) {\r\n  var preLoad = new Image();\r\n  if (" + this.ImageArrayID + "[i].length > 0)\r\n    preLoad.src = " + this.ImageArrayID + "[i];\r\n  }\r\n})();\r\n" + str1;
      clientScript.RegisterClientScriptBlock((Control) this, this.GetType(), this.ClientID + "_CreateDataObject1", "var " + clientDataObjectId + " = null;", true);
      clientScript.RegisterStartupScript((Control) this, this.GetType(), this.ClientID + "_CreateDataObject2", script, true);
      IScriptManager scriptManager = this.Page.ScriptManager;
      if (scriptManager == null || !scriptManager.SupportsPartialRendering)
        return;
      scriptManager.RegisterDispose((Control) this, this.ImageArrayID + ".length = 0;\r\n" + clientDataObjectId + " = null;");
    }

    /// <summary>
    /// Raises the <see cref="E:System.Web.UI.WebControls.TreeView.SelectedNodeChanged"/> event of the <see cref="T:System.Web.UI.WebControls.TreeView"/> control.
    /// </summary>
    /// <param name="e">An <see cref="T:System.EventArgs"/> that contains event data. </param>
    protected virtual void OnSelectedNodeChanged(EventArgs e)
    {
      EventHandler eventHandler = (EventHandler) this.Events[TreeView.SelectedNodeChangedEvent];
      if (eventHandler == null)
        return;
      eventHandler((object) this, e);
    }

    /// <summary>
    /// Raises the <see cref="E:System.Web.UI.WebControls.TreeView.TreeNodeCollapsed"/> event of the <see cref="T:System.Web.UI.WebControls.TreeView"/> control.
    /// </summary>
    /// <param name="e">A <see cref="T:System.Web.UI.WebControls.TreeNodeEventArgs"/> that contains event data. </param>
    protected virtual void OnTreeNodeCollapsed(TreeNodeEventArgs e)
    {
      TreeNodeEventHandler nodeEventHandler = (TreeNodeEventHandler) this.Events[TreeView.TreeNodeCollapsedEvent];
      if (nodeEventHandler == null)
        return;
      nodeEventHandler((object) this, e);
    }

    /// <summary>
    /// Raises the <see cref="E:System.Web.UI.WebControls.TreeView.TreeNodeExpanded"/> event of the <see cref="T:System.Web.UI.WebControls.TreeView"/> control.
    /// </summary>
    /// <param name="e">A <see cref="T:System.Web.UI.WebControls.TreeNodeEventArgs"/> that contains event data. </param>
    protected virtual void OnTreeNodeExpanded(TreeNodeEventArgs e)
    {
      TreeNodeEventHandler nodeEventHandler = (TreeNodeEventHandler) this.Events[TreeView.TreeNodeExpandedEvent];
      if (nodeEventHandler == null)
        return;
      nodeEventHandler((object) this, e);
    }

    /// <summary>
    /// Raises the <see cref="E:System.Web.UI.WebControls.TreeView.TreeNodeDataBound"/> event of the <see cref="T:System.Web.UI.WebControls.TreeView"/> control.
    /// </summary>
    /// <param name="e">A <see cref="T:System.Web.UI.WebControls.TreeNodeEventArgs"/> that contains event data. </param>
    protected virtual void OnTreeNodeDataBound(TreeNodeEventArgs e)
    {
      TreeNodeEventHandler nodeEventHandler = (TreeNodeEventHandler) this.Events[TreeView.TreeNodeDataBoundEvent];
      if (nodeEventHandler == null)
        return;
      nodeEventHandler((object) this, e);
    }

    /// <summary>
    /// Raises the <see cref="E:System.Web.UI.WebControls.TreeView.TreeNodePopulate"/> event of the <see cref="T:System.Web.UI.WebControls.TreeView"/> control.
    /// </summary>
    /// <param name="e">A <see cref="T:System.Web.UI.WebControls.TreeNodeEventArgs"/> that contains event data. </param>
    protected virtual void OnTreeNodePopulate(TreeNodeEventArgs e)
    {
      TreeNodeEventHandler nodeEventHandler = (TreeNodeEventHandler) this.Events[TreeView.TreeNodePopulateEvent];
      if (nodeEventHandler == null)
        return;
      nodeEventHandler((object) this, e);
    }

    /// <summary>
    /// Creates all the nodes based on the data source.
    /// </summary>
    protected internal override void PerformDataBinding()
    {
      base.PerformDataBinding();
      if (!this.DesignMode && this._dataBound && (string.IsNullOrEmpty(this.DataSourceID) && this.DataSource == null))
      {
        this.Nodes.Clear();
      }
      else
      {
        this.DataBindNode(this.RootNode);
        if (!string.IsNullOrEmpty(this.DataSourceID) || this.DataSource != null)
          this._dataBound = true;
        this.ExpandToDepth(this.Nodes, this.ExpandDepth);
      }
    }

    internal void PopulateNode(TreeNode node)
    {
      if (node.DataBound)
        this.DataBindNode(node);
      else
        this.OnTreeNodePopulate(new TreeNodeEventArgs(node));
      node.Populated = true;
      node.PopulateOnDemand = false;
    }

    internal void RaiseSelectedNodeChanged()
    {
      this.OnSelectedNodeChanged(EventArgs.Empty);
    }

    internal void RaiseTreeNodeCollapsed(TreeNode node)
    {
      this.OnTreeNodeCollapsed(new TreeNodeEventArgs(node));
    }

    internal void RaiseTreeNodeExpanded(TreeNode node)
    {
      this.OnTreeNodeExpanded(new TreeNodeEventArgs(node));
    }

    /// <summary>
    /// Renders the HTML opening tag of the control to the specified writer.
    /// </summary>
    /// <param name="writer">An <see cref="T:System.Web.UI.HtmlTextWriter"/> that represents the output stream to render HTML content on the client. </param>
    public override void RenderBeginTag(HtmlTextWriter writer)
    {
      ControlRenderingHelper.WriteSkipLinkStart(writer, this.RenderingCompatibility, this.DesignMode, this.SkipLinkText, this.SpacerImageUrl, this.ClientID);
      base.RenderBeginTag(writer);
      if (!this.DesignMode)
        return;
      writer.RenderBeginTag(HtmlTextWriterTag.Tr);
      writer.RenderBeginTag(HtmlTextWriterTag.Td);
    }

    /// <summary>
    /// Renders the nodes in the <see cref="T:System.Web.UI.WebControls.TreeView"/> control.
    /// </summary>
    /// <param name="writer">The <see cref="T:System.Web.UI.HtmlTextWriter"/> that represents the output stream used to write content to a Web page. </param>
    protected internal override void RenderContents(HtmlTextWriter writer)
    {
      base.RenderContents(writer);
      if (this.Page != null)
        this.Page.VerifyRenderingInServerForm((Control) this);
      bool isEnabled = this.IsEnabled;
      for (int position = 0; position < this.Nodes.Count; ++position)
      {
        TreeNode treeNode = this.Nodes[position];
        bool[] isLast = new bool[10];
        isLast[0] = position == this.Nodes.Count - 1;
        treeNode.Render(writer, position, isLast, isEnabled);
      }
      if (!this.DesignMode)
        return;
      if (this._nodeStyle != null)
        this._nodeStyle.ResetCachedStyles();
      if (this._leafNodeStyle != null)
        this._leafNodeStyle.ResetCachedStyles();
      if (this._parentNodeStyle != null)
        this._parentNodeStyle.ResetCachedStyles();
      if (this._rootNodeStyle != null)
        this._rootNodeStyle.ResetCachedStyles();
      if (this._selectedNodeStyle != null)
        this._selectedNodeStyle.ResetCachedStyles();
      if (this._hoverNodeStyle != null)
        this._hoverNodeHyperLinkStyle = new HyperLinkStyle(this._hoverNodeStyle);
      foreach (TreeNodeStyle treeNodeStyle in (StateManagedCollection) this.LevelStyles)
        treeNodeStyle.ResetCachedStyles();
      if (this._imageUrls != null)
      {
        for (int index = 0; index < this._imageUrls.Length; ++index)
          this._imageUrls[index] = (string) null;
      }
      this._cachedExpandImageUrl = (string) null;
      this._cachedCollapseImageUrl = (string) null;
      this._cachedNoExpandImageUrl = (string) null;
      this._cachedLeafNodeClassNames = (List<string>) null;
      this._cachedLeafNodeHyperLinkClassNames = (List<string>) null;
      this._cachedLeafNodeStyles = (List<TreeNodeStyle>) null;
      this._cachedLevelsContainingCssClass = (Collection<int>) null;
      this._cachedParentNodeClassNames = (List<string>) null;
      this._cachedParentNodeHyperLinkClassNames = (List<string>) null;
      this._cachedParentNodeStyles = (List<TreeNodeStyle>) null;
    }

    /// <summary>
    /// Renders the HTML closing tag of the control to the specified writer.
    /// </summary>
    /// <param name="writer">An <see cref="T:System.Web.UI.HtmlTextWriter"/> that represents the output stream to render HTML content on the client. </param>
    public override void RenderEndTag(HtmlTextWriter writer)
    {
      if (this.DesignMode)
      {
        writer.RenderEndTag();
        writer.RenderEndTag();
      }
      base.RenderEndTag(writer);
      ControlRenderingHelper.WriteSkipLinkEnd(writer, this.DesignMode, this.SkipLinkText, this.ClientID);
    }

    /// <summary>
    /// Saves the state of the <see cref="T:System.Web.UI.WebControls.TreeView"/> control.
    /// </summary>
    /// 
    /// <returns>
    /// The server control's current view state; otherwise, null, if there is no view state associated with the control.
    /// </returns>
    protected override object SaveViewState()
    {
      if (!this.Visible && this.Page != null && !this.Page.IsPostBack)
        this.ViewState["NeverExpanded"] = (object) true;
      object[] objArray = new object[9];
      objArray[0] = base.SaveViewState();
      bool flag = objArray[0] != null;
      if (this._nodeStyle != null)
      {
        objArray[1] = this._nodeStyle.SaveViewState();
        flag |= objArray[1] != null;
      }
      if (this._rootNodeStyle != null)
      {
        objArray[2] = this._rootNodeStyle.SaveViewState();
        flag |= objArray[2] != null;
      }
      if (this._parentNodeStyle != null)
      {
        objArray[3] = this._parentNodeStyle.SaveViewState();
        flag |= objArray[3] != null;
      }
      if (this._leafNodeStyle != null)
      {
        objArray[4] = this._leafNodeStyle.SaveViewState();
        flag |= objArray[4] != null;
      }
      if (this._selectedNodeStyle != null)
      {
        objArray[5] = this._selectedNodeStyle.SaveViewState();
        flag |= objArray[5] != null;
      }
      if (this._hoverNodeStyle != null)
      {
        objArray[6] = ((IStateManager) this._hoverNodeStyle).SaveViewState();
        flag |= objArray[6] != null;
      }
      if (this._levelStyles != null)
      {
        objArray[7] = this._levelStyles.SaveViewState();
        flag |= objArray[7] != null;
      }
      objArray[8] = ((IStateManager) this.Nodes).SaveViewState();
      if (flag | objArray[8] != null)
        return (object) objArray;
      return (object) null;
    }

    /// <summary>
    /// Allows a derived class to set whether the specified <see cref="T:System.Web.UI.WebControls.TreeNode"/> control is data-bound.
    /// </summary>
    /// <param name="node">The <see cref="T:System.Web.UI.WebControls.TreeNode"/> to set. </param><param name="dataBound">true to set the node as data-bound; otherwise, false. </param>
    protected void SetNodeDataBound(TreeNode node, bool dataBound)
    {
      node.SetDataBound(dataBound);
    }

    /// <summary>
    /// Allows a derived class to set the data item for the specified <see cref="T:System.Web.UI.WebControls.TreeNode"/> control.
    /// </summary>
    /// <param name="node">The <see cref="T:System.Web.UI.WebControls.TreeNode"/> to set. </param><param name="dataItem">The data item for the <see cref="T:System.Web.UI.WebControls.TreeNode"/>. </param>
    protected void SetNodeDataItem(TreeNode node, object dataItem)
    {
      node.SetDataItem(dataItem);
    }

    /// <summary>
    /// Allows a derived class to set the data path for the specified <see cref="T:System.Web.UI.WebControls.TreeNode"/> control.
    /// </summary>
    /// <param name="node">The <see cref="T:System.Web.UI.WebControls.TreeNode"/> to set. </param><param name="dataPath">The data path for the <see cref="T:System.Web.UI.WebControls.TreeNode"/>. </param>
    protected void SetNodeDataPath(TreeNode node, string dataPath)
    {
      node.SetDataPath(dataPath);
    }

    internal void SetSelectedNode(TreeNode node)
    {
      if (this._selectedNode == node)
        return;
      if (this._selectedNode != null && this._selectedNode.Selected)
        this._selectedNode.SetSelected(false);
      this._selectedNode = node;
      if (this._selectedNode == null || this._selectedNode.Selected)
        return;
      this._selectedNode.SetSelected(true);
    }

    /// <summary>
    /// Tracks view-state changes to the <see cref="T:System.Web.UI.WebControls.TreeView"/> control so that they can be stored in the <see cref="T:System.Web.UI.StateBag"/> object for the control. This <see cref="T:System.Web.UI.StateBag"/> is accessible through the <see cref="P:System.Web.UI.Control.ViewState"/> property.
    /// </summary>
    protected override void TrackViewState()
    {
      base.TrackViewState();
      if (this._nodeStyle != null)
        this._nodeStyle.TrackViewState();
      if (this._rootNodeStyle != null)
        this._rootNodeStyle.TrackViewState();
      if (this._parentNodeStyle != null)
        this._parentNodeStyle.TrackViewState();
      if (this._leafNodeStyle != null)
        this._leafNodeStyle.TrackViewState();
      if (this._selectedNodeStyle != null)
        this._selectedNodeStyle.TrackViewState();
      if (this._hoverNodeStyle != null)
        ((IStateManager) this._hoverNodeStyle).TrackViewState();
      if (this._levelStyles != null)
        this._levelStyles.TrackViewState();
      if (this._bindings != null)
        this._bindings.TrackViewState();
      ((IStateManager) this.Nodes).TrackViewState();
    }

    [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
    void IPostBackEventHandler.RaisePostBackEvent(string eventArgument)
    {
      this.RaisePostBackEvent(eventArgument);
    }

    /// <summary>
    /// Enables the <see cref="T:System.Web.UI.WebControls.TreeView"/> control to process an event that is raised when a form is posted to the server. The <see cref="M:System.Web.UI.WebControls.TreeView.RaisePostBackEvent(System.String)"/> method is a helper method for the <see cref="M:System.Web.UI.WebControls.TreeView.System#Web#UI#ICallbackEventHandler#RaiseCallbackEvent(System.String)"/> method.
    /// </summary>
    /// <param name="eventArgument">A string that represents an optional event argument to pass to the event handler. </param>
    protected virtual void RaisePostBackEvent(string eventArgument)
    {
      this.ValidateEvent(this.UniqueID, eventArgument);
      if (!this.IsEnabled)
        return;
      if (this.AdapterInternal != null)
      {
        IPostBackEventHandler backEventHandler = this.AdapterInternal as IPostBackEventHandler;
        if (backEventHandler == null)
          return;
        backEventHandler.RaisePostBackEvent(eventArgument);
      }
      else
      {
        if (eventArgument.Length == 0)
          return;
        char ch = eventArgument[0];
        TreeNode node = this.Nodes.FindNode(HttpUtility.HtmlDecode(eventArgument.Substring(1)).Split('\\'), 0);
        if (node != null)
        {
          switch (ch)
          {
            case 's':
              if (node.SelectAction == TreeNodeSelectAction.Expand || node.SelectAction == TreeNodeSelectAction.SelectExpand)
              {
                bool? expanded = node.Expanded;
                if ((!expanded.GetValueOrDefault() ? 1 : (!expanded.HasValue ? 1 : 0)) != 0)
                  node.Expanded = new bool?(true);
                else if (node.SelectAction == TreeNodeSelectAction.Expand)
                  node.Expanded = new bool?(false);
              }
              if (node.SelectAction == TreeNodeSelectAction.Select || node.SelectAction == TreeNodeSelectAction.SelectExpand)
              {
                bool flag = false;
                if (!node.Selected)
                  flag = true;
                node.Selected = true;
                if (flag)
                {
                  this._fireSelectedNodeChanged = true;
                  break;
                }
                break;
              }
              break;
            case 't':
              if (this.ShowExpandCollapse || node.SelectAction == TreeNodeSelectAction.Expand || node.SelectAction == TreeNodeSelectAction.SelectExpand)
              {
                node.ToggleExpandState();
                break;
              }
              break;
          }
        }
        if (!this._fireSelectedNodeChanged)
          return;
        try
        {
          this.RaiseSelectedNodeChanged();
        }
        finally
        {
          this._fireSelectedNodeChanged = false;
        }
      }
    }

    [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
    void ICallbackEventHandler.RaiseCallbackEvent(string eventArgument)
    {
      this.RaiseCallbackEvent(eventArgument);
    }

    [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
    string ICallbackEventHandler.GetCallbackResult()
    {
      return this.GetCallbackResult();
    }

    /// <summary>
    /// Raises the callback event using the specified arguments.
    /// </summary>
    /// <param name="eventArgument">A string that represents an optional event argument to pass to the event handler.</param>
    protected virtual void RaiseCallbackEvent(string eventArgument)
    {
      this._callbackEventArgument = eventArgument;
    }

    /// <summary>
    /// Returns the result of a callback event that targets a control.
    /// </summary>
    /// 
    /// <returns>
    /// The results of the callback.
    /// </returns>
    protected virtual string GetCallbackResult()
    {
      if (!this.IsEnabled)
        return string.Empty;
      int startIndex1 = 0;
      int length = this._callbackEventArgument.IndexOf('|');
      string s = this._callbackEventArgument.Substring(startIndex1, length);
      int index1 = int.Parse(s, (IFormatProvider) CultureInfo.InvariantCulture);
      int startIndex2 = length + 1;
      int num1 = this._callbackEventArgument.IndexOf('|', startIndex2);
      int index2 = int.Parse(this._callbackEventArgument.Substring(startIndex2, num1 - startIndex2), (IFormatProvider) CultureInfo.InvariantCulture);
      bool dataBound = (int) this._callbackEventArgument[num1 + 1] == 116;
      bool flag = (int) this._callbackEventArgument[num1 + 2] == 116;
      int startIndex3 = num1 + 3;
      int num2 = this._callbackEventArgument.IndexOf('|', startIndex3);
      string str1 = this._callbackEventArgument.Substring(startIndex3, num2 - startIndex3);
      int startIndex4 = num2 + 1;
      int num3 = this._callbackEventArgument.IndexOf('|', startIndex4);
      int num4 = int.Parse(this._callbackEventArgument.Substring(startIndex4, num3 - startIndex4), (IFormatProvider) CultureInfo.InvariantCulture);
      int startIndex5 = num3 + 1;
      int num5 = startIndex5 + num4;
      string str2 = this._callbackEventArgument.Substring(startIndex5, num5 - startIndex5);
      int startIndex6 = num5;
      int num6 = this._callbackEventArgument.IndexOf('|', startIndex6);
      int num7 = int.Parse(this._callbackEventArgument.Substring(startIndex6, num6 - startIndex6), (IFormatProvider) CultureInfo.InvariantCulture);
      int startIndex7 = num6 + 1;
      int startIndex8 = startIndex7 + num7;
      string dataPath = this._callbackEventArgument.Substring(startIndex7, startIndex8 - startIndex7);
      string newPath = this._callbackEventArgument.Substring(startIndex8);
      int num8 = newPath.LastIndexOf('\\');
      string str3 = TreeView.UnEscape(newPath.Substring(num8 + 1));
      this.ValidateEvent(this.UniqueID, s + str2 + newPath + dataPath);
      TreeNode node = this.CreateNode();
      node.PopulateOnDemand = true;
      if (str2 != null && str2.Length != 0)
        node.Text = str2;
      if (str3 != null && str3.Length != 0)
        node.Value = str3;
      node.SetDataBound(dataBound);
      node.Checked = flag;
      node.SetPath(newPath);
      node.SetDataPath(dataPath);
      this.PopulateNode(node);
      string str4 = string.Empty;
      if (node.ChildNodes.Count > 0)
      {
        StringBuilder expandState = new StringBuilder();
        for (int index3 = 0; index3 < node.ChildNodes.Count; ++index3)
          this.SaveNodeState(node.ChildNodes[index3], ref index2, expandState, true);
        StringWriter stringWriter = new StringWriter((IFormatProvider) CultureInfo.InvariantCulture);
        HtmlTextWriter writer = new HtmlTextWriter((TextWriter) stringWriter);
        int depth = node.Depth;
        bool[] isLast = new bool[depth + 5];
        if (str1.Length > 0)
        {
          for (int index3 = 0; index3 < str1.Length; ++index3)
          {
            if ((int) str1[index3] == 116)
              isLast[index3] = true;
          }
        }
        this.EnsureRenderSettings();
        bool? expanded = node.Expanded;
        if ((!expanded.GetValueOrDefault() ? 1 : (!expanded.HasValue ? 1 : 0)) != 0)
          writer.AddStyleAttribute("display", "none");
        writer.AddAttribute(HtmlTextWriterAttribute.Id, this.CreateNodeId(index1) + "Nodes");
        writer.RenderBeginTag(HtmlTextWriterTag.Div);
        node.RenderChildNodes(writer, depth, isLast, true);
        writer.RenderEndTag();
        writer.Flush();
        writer.Close();
        str4 = index2.ToString((IFormatProvider) CultureInfo.InvariantCulture) + "|" + expandState.ToString() + "|" + stringWriter.ToString();
      }
      this._callbackEventArgument = string.Empty;
      return str4;
    }

    [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
    bool IPostBackDataHandler.LoadPostData(string postDataKey, NameValueCollection postCollection)
    {
      return this.LoadPostData(postDataKey, postCollection);
    }

    /// <summary>
    /// Processes postback data for the <see cref="T:System.Web.UI.WebControls.TreeView"/> control.
    /// </summary>
    /// 
    /// <returns>
    /// true, if the <see cref="T:System.Web.UI.WebControls.TreeView"/> control's state changes as a result of the postback event; otherwise, false.
    /// </returns>
    /// <param name="postDataKey">The key identifier for the control. </param><param name="postCollection">The collection of all incoming name values. </param>
    protected virtual bool LoadPostData(string postDataKey, NameValueCollection postCollection)
    {
      if (!this.IsEnabled)
        return false;
      int selectedNodeIndex = -1;
      string s = postCollection[this.SelectedNodeFieldID];
      if (!string.IsNullOrEmpty(s))
        selectedNodeIndex = this.GetTrailingIndex(s);
      this._loadingNodeState = true;
      try
      {
        Dictionary<int, TreeNode> dictionary = (Dictionary<int, TreeNode>) null;
        int[] numArray = (int[]) null;
        int val1 = -1;
        if (this.PopulateNodesFromClient)
        {
          string str = postCollection[this.PopulateLogID];
          if (str != null)
          {
            string[] strArray = str.Split(',');
            val1 = strArray.Length;
            dictionary = new Dictionary<int, TreeNode>(Math.Min(val1, 16));
            numArray = new int[val1];
            for (int index = 0; index < val1; ++index)
            {
              if (strArray[index].Length > 0)
              {
                int key = int.Parse(strArray[index], NumberStyles.Integer, (IFormatProvider) CultureInfo.InvariantCulture);
                if (key >= 0 && !dictionary.ContainsKey(key))
                {
                  numArray[index] = key;
                  dictionary.Add(key, (TreeNode) null);
                }
                else
                  numArray[index] = -1;
              }
              else
                numArray[index] = -1;
            }
          }
        }
        string expandState = postCollection[this.ExpandStateID];
        int index1 = 0;
        for (int index2 = 0; index2 < this.Nodes.Count; ++index2)
          this.LoadNodeState(this.Nodes[index2], ref index1, expandState, (IDictionary) dictionary, selectedNodeIndex);
        if (this.PopulateNodesFromClient)
        {
          if (val1 > 0)
          {
            object obj = this.ViewState["LastIndex"];
            int index2 = obj != null ? (int) obj : -1;
            for (int index3 = 0; index3 < val1; ++index3)
            {
              int key = numArray[index3];
              if (key >= 0 && dictionary.ContainsKey(key))
              {
                TreeNode node = dictionary[key];
                if (node != null)
                {
                  this.PopulateNode(node);
                  if (node.ChildNodes.Count > 0 && index2 != -1)
                  {
                    TreeNodeCollection childNodes = node.ChildNodes;
                    for (int index4 = 0; index4 < childNodes.Count; ++index4)
                      this.LoadNodeState(childNodes[index4], ref index2, expandState, (IDictionary) dictionary, selectedNodeIndex);
                  }
                }
              }
            }
          }
        }
      }
      finally
      {
        this._loadingNodeState = false;
      }
      return this._checkedChangedNodes != null;
    }

    [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
    void IPostBackDataHandler.RaisePostDataChangedEvent()
    {
      this.RaisePostDataChangedEvent();
    }

    /// <summary>
    /// Signals the <see cref="T:System.Web.UI.WebControls.TreeView"/> control to notify the ASP.NET application that the state of the control has changed.
    /// </summary>
    protected virtual void RaisePostDataChangedEvent()
    {
      if (this._checkedChangedNodes == null)
        return;
      foreach (TreeNode node in this._checkedChangedNodes)
        this.OnTreeNodeCheckChanged(new TreeNodeEventArgs(node));
    }

    private static bool AppendCssClassName(StringBuilder builder, TreeNodeStyle style, bool hyperlink)
    {
      bool flag = false;
      if (style != null)
      {
        if (style.CssClass.Length != 0)
        {
          builder.Append(style.CssClass);
          builder.Append(' ');
          flag = true;
        }
        string str = hyperlink ? style.HyperLinkStyle.RegisteredCssClass : style.RegisteredCssClass;
        if (str.Length > 0)
        {
          builder.Append(str);
          builder.Append(' ');
        }
      }
      return flag;
    }

    private void DataBindNode(TreeNode node)
    {
      if (node.PopulateOnDemand && !this.IsBoundUsingDataSourceID && !this.DesignMode)
        throw new InvalidOperationException(System.Web.SR.GetString("TreeView_PopulateOnlyForDataSourceControls", new object[1]
        {
          (object) this.ID
        }));
      HierarchicalDataSourceView data = this.GetData(node.DataPath);
      if (!this.IsBoundUsingDataSourceID && this.DataSource == null)
        return;
      if (data == null)
        throw new InvalidOperationException(System.Web.SR.GetString("TreeView_DataSourceReturnedNullView", new object[1]
        {
          (object) this.ID
        }));
      IHierarchicalEnumerable enumerable = data.Select();
      node.ChildNodes.Clear();
      if (enumerable == null)
        return;
      if (this.IsBoundUsingDataSourceID)
      {
        SiteMapDataSource siteMapDataSource = this.GetDataSource() as SiteMapDataSource;
        if (siteMapDataSource != null && this._currentSiteMapNodeDataPath == null)
        {
          IHierarchyData hierarchyData = (IHierarchyData) siteMapDataSource.Provider.CurrentNode;
          this._currentSiteMapNodeDataPath = hierarchyData == null ? string.Empty : hierarchyData.Path;
        }
      }
      this.DataBindRecursive(node, enumerable, true);
    }

    private void DataBindRecursive(TreeNode node, IHierarchicalEnumerable enumerable, bool ignorePopulateOnDemand)
    {
      int depth = checked (node.Depth + 1);
      if (this.MaxDataBindDepth != -1 && depth > this.MaxDataBindDepth)
        return;
      foreach (object obj1 in (IEnumerable) enumerable)
      {
        IHierarchyData hierarchyData = enumerable.GetHierarchyData(obj1);
        string str1 = (string) null;
        string str2 = (string) null;
        string str3 = string.Empty;
        string str4 = string.Empty;
        string str5 = string.Empty;
        string str6 = string.Empty;
        string str7 = string.Empty;
        TreeNodeSelectAction nodeSelectAction = TreeNodeSelectAction.Select;
        bool? nullable = new bool?();
        string str8 = string.Empty;
        bool flag = false;
        TreeNodeBinding binding = this.DataBindings.GetBinding(hierarchyData.Type, depth);
        if (binding != null)
        {
          flag = binding.PopulateOnDemand;
          PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(obj1);
          string textField = binding.TextField;
          if (textField.Length > 0)
          {
            PropertyDescriptor propertyDescriptor = properties.Find(textField, true);
            if (propertyDescriptor != null)
            {
              object obj2 = propertyDescriptor.GetValue(obj1);
              if (obj2 != null)
              {
                if (!string.IsNullOrEmpty(binding.FormatString))
                  str1 = string.Format((IFormatProvider) CultureInfo.CurrentCulture, binding.FormatString, new object[1]
                  {
                    obj2
                  });
                else
                  str1 = obj2.ToString();
              }
            }
            else
              throw new InvalidOperationException(System.Web.SR.GetString("TreeView_InvalidDataBinding", (object) textField, (object) "TextField"));
          }
          if (string.IsNullOrEmpty(str1))
            str1 = binding.Text;
          string valueField = binding.ValueField;
          if (valueField.Length > 0)
          {
            PropertyDescriptor propertyDescriptor = properties.Find(valueField, true);
            if (propertyDescriptor != null)
            {
              object obj2 = propertyDescriptor.GetValue(obj1);
              if (obj2 != null)
                str2 = obj2.ToString();
            }
            else
              throw new InvalidOperationException(System.Web.SR.GetString("TreeView_InvalidDataBinding", (object) valueField, (object) "ValueField"));
          }
          if (string.IsNullOrEmpty(str2))
            str2 = binding.Value;
          string imageUrlField = binding.ImageUrlField;
          if (imageUrlField.Length > 0)
          {
            PropertyDescriptor propertyDescriptor = properties.Find(imageUrlField, true);
            if (propertyDescriptor != null)
            {
              object obj2 = propertyDescriptor.GetValue(obj1);
              if (obj2 != null)
                str4 = obj2.ToString();
            }
            else
              throw new InvalidOperationException(System.Web.SR.GetString("TreeView_InvalidDataBinding", (object) imageUrlField, (object) "ImageUrlField"));
          }
          if (str4.Length == 0)
            str4 = binding.ImageUrl;
          string navigateUrlField = binding.NavigateUrlField;
          if (navigateUrlField.Length > 0)
          {
            PropertyDescriptor propertyDescriptor = properties.Find(navigateUrlField, true);
            if (propertyDescriptor != null)
            {
              object obj2 = propertyDescriptor.GetValue(obj1);
              if (obj2 != null)
                str3 = obj2.ToString();
            }
            else
              throw new InvalidOperationException(System.Web.SR.GetString("TreeView_InvalidDataBinding", (object) navigateUrlField, (object) "NavigateUrlField"));
          }
          if (str3.Length == 0)
            str3 = binding.NavigateUrl;
          string targetField = binding.TargetField;
          if (targetField.Length > 0)
          {
            PropertyDescriptor propertyDescriptor = properties.Find(targetField, true);
            if (propertyDescriptor != null)
            {
              object obj2 = propertyDescriptor.GetValue(obj1);
              if (obj2 != null)
                str5 = obj2.ToString();
            }
            else
              throw new InvalidOperationException(System.Web.SR.GetString("TreeView_InvalidDataBinding", (object) targetField, (object) "TargetField"));
          }
          if (string.IsNullOrEmpty(str5))
            str5 = binding.Target;
          string toolTipField = binding.ToolTipField;
          if (toolTipField.Length > 0)
          {
            PropertyDescriptor propertyDescriptor = properties.Find(toolTipField, true);
            if (propertyDescriptor != null)
            {
              object obj2 = propertyDescriptor.GetValue(obj1);
              if (obj2 != null)
                str6 = obj2.ToString();
            }
            else
              throw new InvalidOperationException(System.Web.SR.GetString("TreeView_InvalidDataBinding", (object) toolTipField, (object) "ToolTipField"));
          }
          if (str6.Length == 0)
            str6 = binding.ToolTip;
          string imageToolTipField = binding.ImageToolTipField;
          if (imageToolTipField.Length > 0)
          {
            PropertyDescriptor propertyDescriptor = properties.Find(imageToolTipField, true);
            if (propertyDescriptor != null)
            {
              object obj2 = propertyDescriptor.GetValue(obj1);
              if (obj2 != null)
                str7 = obj2.ToString();
            }
            else
              throw new InvalidOperationException(System.Web.SR.GetString("TreeView_InvalidDataBinding", (object) imageToolTipField, (object) "imageToolTipField"));
          }
          if (str7.Length == 0)
            str7 = binding.ImageToolTip;
          nodeSelectAction = binding.SelectAction;
          nullable = binding.ShowCheckBox;
        }
        else
        {
          if (obj1 is INavigateUIData)
          {
            INavigateUIData navigateUiData = (INavigateUIData) obj1;
            str1 = navigateUiData.Name;
            str2 = navigateUiData.Value;
            str3 = navigateUiData.NavigateUrl;
            if (string.IsNullOrEmpty(str3))
              nodeSelectAction = TreeNodeSelectAction.None;
            str6 = navigateUiData.Description;
          }
          if (this.IsBoundUsingDataSourceID)
            flag = this.PopulateNodesFromClient;
        }
        if (this.AutoGenerateDataBindings && str1 == null)
          str1 = obj1.ToString();
        TreeNode treeNode = (TreeNode) null;
        if (str1 != null || str2 != null)
        {
          treeNode = this.CreateNode();
          if (!string.IsNullOrEmpty(str1))
            treeNode.Text = str1;
          if (!string.IsNullOrEmpty(str2))
            treeNode.Value = str2;
          if (!string.IsNullOrEmpty(str4))
            treeNode.ImageUrl = str4;
          if (!string.IsNullOrEmpty(str3))
            treeNode.NavigateUrl = str3;
          if (!string.IsNullOrEmpty(str5))
            treeNode.Target = str5;
        }
        if (treeNode != null)
        {
          if (!string.IsNullOrEmpty(str6))
            treeNode.ToolTip = str6;
          if (!string.IsNullOrEmpty(str7))
            treeNode.ImageToolTip = str7;
          if (nodeSelectAction != treeNode.SelectAction)
            treeNode.SelectAction = nodeSelectAction;
          if (nullable.HasValue)
            treeNode.ShowCheckBox = nullable;
          treeNode.SetDataPath(hierarchyData.Path);
          treeNode.SetDataBound(true);
          node.ChildNodes.Add(treeNode);
          if (string.Equals(hierarchyData.Path, this._currentSiteMapNodeDataPath, StringComparison.OrdinalIgnoreCase))
          {
            treeNode.Selected = true;
            if (this.Page == null || !this.Page.IsCallback)
            {
              for (TreeNode parent = treeNode.Parent; parent != null; parent = parent.Parent)
              {
                bool? expanded = parent.Expanded;
                if ((!expanded.GetValueOrDefault() ? 1 : (!expanded.HasValue ? 1 : 0)) != 0)
                  parent.Expanded = new bool?(true);
              }
            }
          }
          treeNode.SetDataItem(hierarchyData.Item);
          this.OnTreeNodeDataBound(new TreeNodeEventArgs(treeNode));
          treeNode.SetDataItem((object) null);
          if (hierarchyData.HasChildren && (this.MaxDataBindDepth == -1 || depth < this.MaxDataBindDepth))
          {
            if (flag && !this.DesignMode)
            {
              treeNode.PopulateOnDemand = true;
            }
            else
            {
              IHierarchicalEnumerable children = hierarchyData.GetChildren();
              if (children != null)
                this.DataBindRecursive(treeNode, children, false);
            }
          }
        }
      }
    }

    private void EnsureRenderSettings()
    {
      HttpBrowserCapabilities browser = this.Page.Request.Browser;
      this._isNotIE = this.Page.Request.Browser.MSDomVersion.Major < 4;
      this._renderClientScript = this.GetRenderClientScript(browser);
      if (this._hoverNodeStyle != null && this.Page != null && this.Page.Header == null)
        throw new InvalidOperationException(System.Web.SR.GetString("NeedHeader", new object[1]
        {
          (object) "TreeView.HoverStyle"
        }));
      if (this.Page == null || !this.Page.SupportsStyleSheets && !this.Page.IsCallback && (this.Page.ScriptManager == null || !this.Page.ScriptManager.IsInAsyncPostBack))
        return;
      this.RegisterStyle(this.BaseTreeNodeStyle);
      if (this._nodeStyle != null)
      {
        this._nodeStyle.HyperLinkStyle.DoNotRenderDefaults = true;
        this.RegisterStyle((Style) this._nodeStyle.HyperLinkStyle);
        this.RegisterStyle((Style) this._nodeStyle);
      }
      if (this._rootNodeStyle != null)
      {
        this._rootNodeStyle.HyperLinkStyle.DoNotRenderDefaults = true;
        this.RegisterStyle((Style) this._rootNodeStyle.HyperLinkStyle);
        this.RegisterStyle((Style) this._rootNodeStyle);
      }
      if (this._parentNodeStyle != null)
      {
        this._parentNodeStyle.HyperLinkStyle.DoNotRenderDefaults = true;
        this.RegisterStyle((Style) this._parentNodeStyle.HyperLinkStyle);
        this.RegisterStyle((Style) this._parentNodeStyle);
      }
      if (this._leafNodeStyle != null)
      {
        this._leafNodeStyle.HyperLinkStyle.DoNotRenderDefaults = true;
        this.RegisterStyle((Style) this._leafNodeStyle.HyperLinkStyle);
        this.RegisterStyle((Style) this._leafNodeStyle);
      }
      foreach (TreeNodeStyle treeNodeStyle in (StateManagedCollection) this.LevelStyles)
      {
        treeNodeStyle.HyperLinkStyle.DoNotRenderDefaults = true;
        this.RegisterStyle((Style) treeNodeStyle.HyperLinkStyle);
        this.RegisterStyle((Style) treeNodeStyle);
      }
      if (this._selectedNodeStyle != null)
      {
        this._selectedNodeStyle.HyperLinkStyle.DoNotRenderDefaults = true;
        this.RegisterStyle((Style) this._selectedNodeStyle.HyperLinkStyle);
        this.RegisterStyle((Style) this._selectedNodeStyle);
      }
      if (this._hoverNodeStyle == null)
        return;
      this._hoverNodeHyperLinkStyle = new HyperLinkStyle(this._hoverNodeStyle);
      this._hoverNodeHyperLinkStyle.DoNotRenderDefaults = true;
      this.RegisterStyle((Style) this._hoverNodeHyperLinkStyle);
      this.RegisterStyle(this._hoverNodeStyle);
    }

    private void ExpandToDepth(TreeNodeCollection nodes, int depth)
    {
      this.ViewState["NeverExpanded"] = (object) null;
      foreach (TreeNode treeNode in nodes)
      {
        if (depth == -1 || treeNode.Depth < depth)
        {
          if (!treeNode.Expanded.HasValue)
            treeNode.Expanded = new bool?(true);
          this.ExpandToDepth(treeNode.ChildNodes, depth);
        }
      }
    }

    private bool GetRenderClientScript(HttpBrowserCapabilities caps)
    {
      if (this.EnableClientScript && this.Enabled && (caps.EcmaScriptVersion.Major > 0 && caps.W3CDomVersion.Major > 0))
        return !StringUtil.EqualsIgnoreCase(caps["tagwriter"], typeof (Html32TextWriter).FullName);
      return false;
    }

    private int GetTrailingIndex(string s)
    {
      int index = s.Length - 1;
      while (index > 0 && char.IsDigit(s[index]))
        --index;
      if (index > -1 && index < s.Length - 1 && s.Length - index < 11)
        return int.Parse(s.Substring(index + 1), (IFormatProvider) CultureInfo.InvariantCulture);
      return -1;
    }

    private void LoadNodeState(TreeNode node, ref int index, string expandState, IDictionary populatedNodes, int selectedNodeIndex)
    {
      RuntimeHelpers.EnsureSufficientExecutionStack();
      if (this.PopulateNodesFromClient && populatedNodes != null && populatedNodes.Contains((object) index))
        populatedNodes[(object) index] = (object) node;
      if (selectedNodeIndex != -1)
      {
        if (node.Selected && index != selectedNodeIndex)
          node.Selected = false;
        if (index == selectedNodeIndex && (node.SelectAction == TreeNodeSelectAction.Select || node.SelectAction == TreeNodeSelectAction.SelectExpand))
        {
          bool selected = node.Selected;
          node.Selected = true;
          if (!selected)
            this._fireSelectedNodeChanged = true;
        }
      }
      else if (node.Selected)
        this.SetSelectedNode(node);
      if (node.GetEffectiveShowCheckBox())
      {
        bool @checked = node.Checked;
        string index1 = this.CreateNodeId(index) + "CheckBox";
        if (this.Context.Request.Form[index1] != null || this.Context.Request.QueryString[index1] != null)
        {
          if (!node.Checked)
            node.Checked = true;
          if (@checked != node.Checked)
            this.CheckedChangedNodes.Add((object) node);
        }
        else
        {
          if (@checked && !node.PreserveChecked && node.Checked)
            node.Checked = false;
          if (@checked != node.Checked)
            this.CheckedChangedNodes.Add((object) node);
        }
      }
      if (this.Page != null && this.Page.RequestInternal != null && (expandState != null && expandState.Length > index) && (this.ShowExpandCollapse || node.SelectAction == TreeNodeSelectAction.Expand || node.SelectAction == TreeNodeSelectAction.SelectExpand))
      {
        switch (expandState[index])
        {
          case 'c':
            node.Expanded = new bool?(false);
            break;
          case 'e':
            node.Expanded = new bool?(true);
            break;
        }
      }
      ++index;
      TreeNodeCollection childNodes = node.ChildNodes;
      if (childNodes.Count <= 0)
        return;
      for (int index1 = 0; index1 < childNodes.Count; ++index1)
        this.LoadNodeState(childNodes[index1], ref index, expandState, populatedNodes, selectedNodeIndex);
    }

    private void RegisterStyle(Style style)
    {
      if (style.IsEmpty || this.Page == null || !this.Page.SupportsStyleSheets)
        return;
      string cssClass = this.ClientID + "_" + this._cssStyleIndex++.ToString((IFormatProvider) NumberFormatInfo.InvariantInfo);
      this.Page.Header.StyleSheet.CreateStyleRule(style, (IUrlResolutionService) this, "." + cssClass);
      style.SetRegisteredCssClass(cssClass);
    }

    private void SaveNodeState(TreeNode node, ref int index, StringBuilder expandState, bool rendered)
    {
      node.Index = index++;
      if (node.CheckedSet)
        node.PreserveChecked = !this.Enabled || !this.RenderClientScript && !rendered && node.Checked;
      if (node.PopulateOnDemand)
      {
        if (node.ChildNodes.Count != 0)
        {
          bool? expanded = node.Expanded;
          if ((!expanded.GetValueOrDefault() ? 1 : (!expanded.HasValue ? 1 : 0)) == 0)
          {
            expandState.Append('e');
            goto label_14;
          }
        }
        expandState.Append('c');
      }
      else if (node.ChildNodes.Count == 0)
        expandState.Append('n');
      else if (!node.Expanded.HasValue)
      {
        expandState.Append('u');
      }
      else
      {
        bool? expanded = node.Expanded;
        if ((!expanded.GetValueOrDefault() ? 0 : (expanded.HasValue ? 1 : 0)) != 0)
          expandState.Append('e');
        else
          expandState.Append('c');
      }
label_14:
      if (node.ChildNodes.Count <= 0)
        return;
      TreeNodeCollection childNodes = node.ChildNodes;
      for (int index1 = 0; index1 < childNodes.Count; ++index1)
      {
        TreeNode node1 = childNodes[index1];
        // ISSUE: explicit reference operation
        // ISSUE: variable of a reference type
        int& index2 = @index;
        StringBuilder expandState1 = expandState;
        bool? expanded = node.Expanded;
        int num = (!expanded.GetValueOrDefault() ? 0 : (expanded.HasValue ? 1 : 0)) == 0 ? 0 : (rendered ? 1 : 0);
        this.SaveNodeState(node1, index2, expandState1, num != 0);
      }
    }

    private class TreeViewExpandDepthConverter : Int32Converter
    {
      private static object[] expandDepthValues = new object[32]
      {
        (object) -1,
        (object) 0,
        (object) 1,
        (object) 2,
        (object) 3,
        (object) 4,
        (object) 5,
        (object) 6,
        (object) 7,
        (object) 8,
        (object) 9,
        (object) 10,
        (object) 11,
        (object) 12,
        (object) 13,
        (object) 14,
        (object) 15,
        (object) 16,
        (object) 17,
        (object) 18,
        (object) 19,
        (object) 20,
        (object) 21,
        (object) 22,
        (object) 23,
        (object) 24,
        (object) 25,
        (object) 26,
        (object) 27,
        (object) 28,
        (object) 29,
        (object) 30
      };
      private const string fullyExpandedString = "FullyExpand";

      public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
      {
        if (sourceType == typeof (string))
          return true;
        return base.CanConvertFrom(context, sourceType);
      }

      public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
      {
        if (destinationType == typeof (int) || destinationType == typeof (string))
          return true;
        return base.CanConvertTo(context, destinationType);
      }

      public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
      {
        string a = value as string;
        if (a != null && string.Equals(a, "FullyExpand", StringComparison.OrdinalIgnoreCase))
          return (object) -1;
        return base.ConvertFrom(context, culture, value);
      }

      public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
      {
        if (destinationType == typeof (string))
        {
          if (value is int && (int) value == -1)
            return (object) "FullyExpand";
          string a = value as string;
          if (a != null && string.Equals(a, "FullyExpand", StringComparison.OrdinalIgnoreCase))
            return value;
        }
        else if (destinationType == typeof (int))
        {
          string a = value as string;
          if (a != null && string.Equals(a, "FullyExpand", StringComparison.OrdinalIgnoreCase))
            return (object) -1;
        }
        return base.ConvertTo(context, culture, value, destinationType);
      }

      public override TypeConverter.StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
      {
        return new TypeConverter.StandardValuesCollection((ICollection) TreeView.TreeViewExpandDepthConverter.expandDepthValues);
      }

      public override bool GetStandardValuesSupported(ITypeDescriptorContext context)
      {
        return true;
      }
    }
  }
}
