Beispiel #1
0
        /// <summary>
        /// Creates a hierarchical repeater item.
        /// </summary>
        /// <param name="itemIndex"></param>
        /// <param name="itemType"></param>
        /// <returns></returns>
        protected override RepeaterItem CreateItem(int itemIndex, ListItemType itemType)
        {
            HierarchicalRepeaterItem item = new HierarchicalRepeaterItem(this, itemIndex, itemType);

            if (this.useDataSource)
            {
                // We need a way to create our child hiearchy _after_ this control was added to the
                // control hierarchy. It seems that one of the only ways to achieve this is by
                // overriding AddedControl and see if the added control is this repeater item.
                this.nextExpectedControl = item;
            }
            return(item);
        }
Beispiel #2
0
        /// <summary>
        /// Creates the child hierarchy.
        /// </summary>
        /// <param name="parent"></param>
        protected internal virtual void CreateChildHierarchy(HierarchicalRepeaterItem parent)
        {
            IEnumerable enumerable = null;

            if (this.useDataSource)
            {
                if (parent.ItemCount > -1)
                {
                    return;
                }

                TreeNode <object> node = this.data.FindRecursive(new Predicate <object>(delegate(object target)
                {
                    return(parent.DataItem == target);
                }));

                if (node != null)
                {
                    enumerable = node.Nodes;
                }
            }
            else
            {
                if (parent.ItemCount > -1 && parent.ChildPanel.Controls.Count == 0)
                {
                    enumerable = new DummyDataSource(parent.ItemCount);
                }
            }

            if (enumerable != null)
            {
                bool isSeparated = (this.SeparatorTemplate != null);
                int  itemLength  = 0;

                foreach (object dataObject in enumerable)
                {
                    if (isSeparated && (itemLength > 0))
                    {
                        this.CreateItem(parent, itemLength - 1, ListItemType.Separator, useDataSource, null);
                    }
                    ListItemType             type      = ((itemLength % 2) == 0) ? ListItemType.Item : ListItemType.AlternatingItem;
                    HierarchicalRepeaterItem childItem = (HierarchicalRepeaterItem)this.CreateItem(parent, itemLength, type, useDataSource, dataObject);
                    itemLength++;
                }
            }
        }
Beispiel #3
0
        /// <summary>
        /// Creates an item.
        /// </summary>
        /// <param name="parent"></param>
        /// <param name="itemIndex"></param>
        /// <param name="itemType"></param>
        /// <param name="dataBind"></param>
        /// <param name="dataItem"></param>
        /// <returns></returns>
        private RepeaterItem CreateItem(HierarchicalRepeaterItem parent, int itemIndex, ListItemType itemType, bool dataBind, object dataItem)
        {
            HierarchicalRepeaterItem item = (HierarchicalRepeaterItem)this.CreateItem(itemIndex, itemType);
            RepeaterItemEventArgs    args = new RepeaterItemEventArgs(item);

            this.InitializeItem(item);
            if (dataBind)
            {
                item.DataItem = dataItem;
            }
            this.OnItemCreated(args);

            parent.ChildPanel.Controls.Add(item);
            if (!this.ChildContainerStyle.IsEmpty)
            {
                parent.ChildPanel.ApplyStyle(this.ChildContainerStyle);
            }

            if (this.useDataSource && (item.ItemType == ListItemType.AlternatingItem || item.ItemType == ListItemType.Item))
            {
                if (parent.ItemCount == -1)
                {
                    parent.ItemCount = 1;
                }
                else
                {
                    parent.ItemCount++;
                }

                this.CreateChildHierarchy(item);
            }

            if (dataBind)
            {
                item.DataBind();
                this.OnItemDataBound(args);
            }
            return(item);
        }
Beispiel #4
0
		/// <summary>
		/// Creates an item.
		/// </summary>
		/// <param name="parent"></param>
		/// <param name="itemIndex"></param>
		/// <param name="itemType"></param>
		/// <param name="dataBind"></param>
		/// <param name="dataItem"></param>
		/// <returns></returns>
		private RepeaterItem CreateItem(HierarchicalRepeaterItem parent, int itemIndex, ListItemType itemType, bool dataBind, object dataItem)
		{
			HierarchicalRepeaterItem item = (HierarchicalRepeaterItem)this.CreateItem(itemIndex, itemType);
			RepeaterItemEventArgs args = new RepeaterItemEventArgs(item);
			this.InitializeItem(item);
			if (dataBind)
			{
				item.DataItem = dataItem;
			}
			this.OnItemCreated(args);
			
			parent.ChildPanel.Controls.Add(item);
			if (!this.ChildContainerStyle.IsEmpty)
			{
				parent.ChildPanel.ApplyStyle(this.ChildContainerStyle);
			}

			if (this.useDataSource && (item.ItemType == ListItemType.AlternatingItem || item.ItemType == ListItemType.Item))
			{
				if (parent.ItemCount == -1)
					parent.ItemCount = 1;
				else
					parent.ItemCount++;
				
				this.CreateChildHierarchy(item);
			}
			
			if (dataBind)
			{
				item.DataBind();
				this.OnItemDataBound(args);
			}
			return item;
		}
Beispiel #5
0
		/// <summary>
		/// Creates the child hierarchy.
		/// </summary>
		/// <param name="parent"></param>
		protected internal virtual void CreateChildHierarchy(HierarchicalRepeaterItem parent)
		{
			IEnumerable enumerable = null;
			if (this.useDataSource)
			{
				if (parent.ItemCount > -1)
					return;

				TreeNode<object> node = this.data.FindRecursive(new Predicate<object>(delegate(object target)
				{
					return (parent.DataItem == target);
				}));
				
				if (node != null)
				{
					enumerable = node.Nodes;
				}
			}
			else
			{
				if (parent.ItemCount > -1 && parent.ChildPanel.Controls.Count == 0)
				{
					enumerable = new DummyDataSource(parent.ItemCount);
				}
			}

			if (enumerable != null)
			{
				bool isSeparated = (this.SeparatorTemplate != null);
				int itemLength = 0;

				foreach (object dataObject in enumerable)
				{
					if (isSeparated && (itemLength > 0))
					{
						this.CreateItem(parent, itemLength - 1, ListItemType.Separator, useDataSource, null);
					}
					ListItemType type = ((itemLength % 2) == 0) ? ListItemType.Item : ListItemType.AlternatingItem;
					HierarchicalRepeaterItem childItem = (HierarchicalRepeaterItem)this.CreateItem(parent, itemLength, type, useDataSource, dataObject);
					itemLength++;
				}
			}
		}
Beispiel #6
0
		/// <summary>
		/// Creates a hierarchical repeater item.
		/// </summary>
		/// <param name="itemIndex"></param>
		/// <param name="itemType"></param>
		/// <returns></returns>
		protected override RepeaterItem CreateItem(int itemIndex, ListItemType itemType)
		{
			HierarchicalRepeaterItem item = new HierarchicalRepeaterItem(this, itemIndex, itemType);
			if (this.useDataSource)
			{
				// We need a way to create our child hiearchy _after_ this control was added to the 
				// control hierarchy. It seems that one of the only ways to achieve this is by 
				// overriding AddedControl and see if the added control is this repeater item.
				this.nextExpectedControl = item;
			}
			return item;
		}