/// <summary>
        /// 
        /// </summary>
        /// <author>
        /// Created by Iulian Iuga; 28 December, 2002
        /// </author>
        internal ElementsCollection( TreeElement proprietor )
        {
            if( proprietor == null )
                throw new ArgumentNullException();

            _proprietor = proprietor;
        }
		/// <summary>
		/// 
		/// </summary>
		/// <param name="tabs">IList - can be a Array or ArrayList</param>
		/// <param name="parent"></param>
		private void InternalBuildTree(ArrayList tabs, TreeElement parent)
		{
			foreach(PortalDefinition.Tab t in tabs)
			{
				int n = parent.Elements.Add(t.title);
				parent.Elements[n].Key = t.reference;
				parent.Elements[n].Text = "<a class=\"LinkButton\" href=" + 
					Page.GetPostBackClientHyperlink(this, t.reference) + 
					">" + t.title + "</a>";

				if(t.tabs != null && t.tabs.Count != 0)
				{
					InternalBuildTree(t.tabs, parent.Elements[n]);
					parent.Elements[n].Expand();
				}
				else
				{
					parent.Elements[n].ImageIndex = 0;
				}
			}
		}
        /// <summary>
        ///
        /// </summary>
        /// <param name="index"></param>
        /// <param name="element"></param>
        /// <returns></returns>
        /// <author>
        /// Created by Iulian Iuga; 28 December, 2002
        /// </author>
        public int AddAt(int index, TreeElement element)
        {
            if (_members == null)
            {
                _members = new ArrayList();
            }

            int elementIndex = index;

            if (index == -1)
            {
                elementIndex = _members.Add(element);
            }
            else
            {
                _members.Insert(index, element);
            }

            // configure the new added element
            ConfigureNewElement(element);

            return(elementIndex);
        }
        /// <summary>
        /// Finds a specified child element of current tree element.
        ///
        /// Note: The search algorithm can be optimized.
        /// </summary>
        /// <param name="ID">The searched element id.</param>
        /// <returns>The child element coresponding to the ID parameter value.</returns>
        /// <author>
        /// Created by Iulian Iuga; 04 January, 2003
        /// </author>
        public TreeElement FindElement(string ID)
        {
            // TODO: optimize the search algorithm.

            foreach (TreeElement element in Elements)
            {
                if (element.ID == ID)
                {
                    return(element);
                }
            }

            foreach (TreeElement element in Elements)
            {
                TreeElement _found = element.FindElement(ID);
                if (_found != null)
                {
                    return(_found);
                }
            }

            return(null);
        }
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        /// <author>
        /// Created by Iulian Iuga; 11 January, 2003
        /// </author>
        object IStateManager.SaveViewState()
        {
            if (Count == 0)
            {
                return(null);
            }

            object[] membersState = new object[Count];

            int index = 0;

            foreach (TreeElement _element in this)
            {
                membersState[index] = new object[3] {
                    ((IStateManager)_element).SaveViewState(),
                    _element.ElementType,
                    index++
                }
            }
            ;

            return(membersState);
        }

        /// <summary>
        ///
        /// </summary>
        /// <author>
        /// Created by Iulian Iuga; 11 January, 2003
        /// </author>
        void IStateManager.LoadViewState(object state)
        {
            if (state != null)
            {
                object[] membersState = (object[])state;
                for (int index = 0; index < membersState.Length; index++)
                {
                    object[] stateElement = (object[])membersState[index];
                    if (stateElement[0] != null)
                    {
                        if ((byte)stateElement[1] == (byte)_ElementType._designTimeElement)
                        {
                            ((IStateManager)this[index]).LoadViewState(stateElement[0]);
                        }
                        else if ((byte)stateElement[1] == (byte)_ElementType._runTimeElement)
                        {
                            TreeElement _element      = new TreeElement();
                            int         _elementIndex = AddAt((int)stateElement[2], _element);

                            ((IStateManager)this[_elementIndex]).TrackViewState();
                            ((IStateManager)this[_elementIndex]).LoadViewState(stateElement[0]);
                        }
                    }
                }
            }
        }

        /// <summary>
        ///
        /// </summary>
        /// <author>
        /// Created by Iulian Iuga; 11 January, 2003
        /// </author>
        void IStateManager.TrackViewState()
        {
            _marked = true;

            foreach (TreeElement _element in this)
            {
                ((IStateManager)_element).TrackViewState();
            }
        }

        /// <summary>
        ///
        /// </summary>
        /// <author>
        /// Created by Iulian Iuga; 11 January, 2003
        /// </author>
        bool IStateManager.IsTrackingViewState
        {
            get {
                return(_marked);
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="index"></param>
        /// <param name="text"></param>
        /// <returns></returns>
        /// <author>
        /// Created by Iulian Iuga; 28 December, 2002
        /// </author>
        public int AddAt(int index, string text)
        {
            TreeElement _element = new TreeElement(text);

            return(AddAt(index, _element));
        }
 /// <summary>
 ///
 /// </summary>
 /// <param name="element"></param>
 /// <returns></returns>
 /// <author>
 /// Created by Iulian Iuga; 28 December, 2002
 /// </author>
 public int Add(TreeElement element)
 {
     // add the element at the end of the elements list
     return(AddAt(-1, element));
 }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="element"></param>
 /// <returns></returns>
 /// <author>
 /// Created by Iulian Iuga; 28 December, 2002
 /// </author>
 public int Add( TreeElement element )
 {
     // add the element at the end of the elements list
     return AddAt( -1, element );
 }
 /// <summary>
 /// Internaly sets the node parent.
 /// </summary>
 /// <param name="parent"></param>
 /// <author>
 /// Created by Iulian Iuga; 01 January, 2003
 /// </author>
 internal void SetParent( TreeElement parent )
 {
     _parent = parent;
 }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="element"></param>
 /// <author>
 /// Created by Iulian Iuga; 28 December, 2002
 /// </author>
 public void Remove( TreeElement element )
 {
     if(_members == null) return;
     _members.Remove(element);
 }
        /// <summary>
        /// 
        /// </summary>
        /// <author>
        /// Created by Iulian Iuga; 11 January, 2003
        /// </author>
        void IStateManager.LoadViewState( object state )
        {
            if( state != null )
            {
                object[] membersState = (object[])state;
                for( int index = 0; index < membersState.Length; index++ )
                {
                    object[] stateElement = (object[])membersState[index];
                    if( stateElement[0] != null )
                    {
                        if( (byte)stateElement[1] == (byte)_ElementType._designTimeElement )
                        {
                            ((IStateManager)this[index]).LoadViewState( stateElement[0] );
                        }
                        else if( (byte)stateElement[1] == (byte)_ElementType._runTimeElement )
                        {
                            TreeElement _element = new TreeElement();
                            int _elementIndex = AddAt( (int)stateElement[2], _element );

                            ((IStateManager)this[_elementIndex]).TrackViewState();
                            ((IStateManager)this[_elementIndex]).LoadViewState( stateElement[0] );
                        }
                    }
                }
            }
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="element"></param>
        /// <returns></returns>
        /// <author>
        /// Created by Iulian Iuga; 01 January, 2003
        /// </author>
        public int IndexOf( TreeElement element )
        {
            if( element != null && _members != null )
                return _members.IndexOf( element, 0, Count );

            return -1;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="index"></param>
        /// <param name="text"></param>
        /// <returns></returns>
        /// <author>
        /// Created by Iulian Iuga; 28 December, 2002
        /// </author>
        public int AddAt( int index, string text )
        {
            TreeElement _element = new TreeElement( text );

            return AddAt( index, _element );
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="index"></param>
        /// <param name="element"></param>
        /// <returns></returns>
        /// <author>
        /// Created by Iulian Iuga; 28 December, 2002
        /// </author>
        public int AddAt( int index, TreeElement element )
        {
            if( _members == null )
                _members =  new ArrayList();

            int elementIndex = index;
            if( index == -1 )
                elementIndex = _members.Add( element );
            else
                _members.Insert( index, element );

            // configure the new added element
            ConfigureNewElement( element );

            return elementIndex;
        }
		/// <summary>
		/// 
		/// </summary>
		/// <param name="writer"></param>
		/// <param name="element"></param>
		/// <author>
		/// Created by Iulian Iuga; 04 January, 2003
		/// </author>
		public void RenderElement( HtmlTextWriter writer, TreeElement element )
		{
			_element = element;

			Render( writer );
		}
示例#16
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="writer"></param>
        /// <param name="element"></param>
        /// <author>
        /// Created by Iulian Iuga; 04 January, 2003
        /// </author>
        public void RenderElement(HtmlTextWriter writer, TreeElement element)
        {
            _element = element;

            Render(writer);
        }
        /// <summary>
        /// Configure internaly the required properties for a new tree element.
        /// </summary>
        /// <param name="element"></param>
        /// <author>
        /// Created by Iulian Iuga; 01 January, 2003
        /// </author>
        private void ConfigureNewElement( TreeElement element )
        {
            element.SetParent( _proprietor );
            element.SetTreeWeb( _proprietor.TreeWeb );
            element.SetLevel( _proprietor.Level + 1 );
            element.ElementType = _ElementType._runTimeElement;

            // configure element children too
            foreach( TreeElement _element in element.Elements )
                ConfigureNewElement( _element );
        }
 /// <summary>
 /// Internaly sets the node parent.
 /// </summary>
 /// <param name="parent"></param>
 /// <author>
 /// Created by Iulian Iuga; 01 January, 2003
 /// </author>
 internal void SetParent(TreeElement parent)
 {
     _parent = parent;
 }
示例#19
0
		/// <summary>
		/// 
		/// </summary>
		/// <param name="element"></param>
		/// <author>
		/// Created by Iulian Iuga; 18 January, 2003
		/// </author>
		private void ConfigureParsedElements( TreeElement element )
		{
			foreach( TreeElement _element in element.Elements ) 
			{
				_element.SetParent( element );
				_element.SetTreeWeb( this );
				_element.SetLevel( element.Level + 1 );
				_element.ElementType = _ElementType._designTimeElement;

				ConfigureParsedElements( _element );
			}
		}
示例#20
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="element"></param>
 /// <author>
 /// Created by Iulian Iuga; 23 February, 2003
 /// </author>
 public TreeWebEventArgs(TreeElement element)
 {
     this._element = element;
 }
示例#21
0
			/// <summary>
			/// 
			/// </summary>
			/// <param name="element"></param>
			/// <author>
			/// Created by Iulian Iuga; 23 February, 2003
			/// </author>
			public TreeWebEventArgs( TreeElement element )
			{
				this._element = element;
			}