Ejemplo n.º 1
0
 public PagerItem(string text, int pageIndex, bool disabled, PagerItemType type)
 {
     Text      = text;
     PageIndex = pageIndex;
     Disabled  = disabled;
     Type      = type;
 }
        /// <summary>
        ///     Get the actual <see cref="PagerItemOptions" /> for a specified <see cref="PagerItemType" />.
        /// </summary>
        /// <param name="itemType">The <see cref="PagerItemType" /> which indicates the role of the pager item.</param>
        /// <returns>A <see cref="PagerItemOptions" /> used for the current <see cref="PagerLayoutElement" />.</returns>
        /// <exception cref="ArgumentException">The value of <paramref name="itemType" /> is not a valid enum item.</exception>
        public PagerItemOptions GetOptionsFor(PagerItemType itemType)
        {
            switch (itemType)
            {
            case PagerItemType.Normal:
                return(Normal);

            case PagerItemType.First:
                return(FirstPageButton);

            case PagerItemType.Last:
                return(LastPageButton);

            case PagerItemType.Previous:
                return(PreviousPageButton);

            case PagerItemType.Next:
                return(NextPageButton);

            case PagerItemType.Current:
                return(Current);

            case PagerItemType.Omitted:
                return(Omitted);

            default:
                throw new ArgumentException("The value of the argument is not a valid enum item.", nameof(itemType));
            }
        }
Ejemplo n.º 3
0
 public PagerItem(string text, int pageIndex, bool disabled, PagerItemType type)
 {
     Text = text;
     PageIndex = pageIndex;
     Disabled = disabled;
     Type = type;
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PagerItem"/> class.
 /// </summary>
 /// <param name="text">
 /// The text.
 /// </param>
 /// <param name="pageIndex">
 /// The page index.
 /// </param>
 /// <param name="disabled">
 /// The disabled.
 /// </param>
 /// <param name="type">
 /// The type.
 /// </param>
 public PagerItem(string text, int pageIndex, bool disabled, PagerItemType type)
 {
     this.Text      = text;
     this.PageIndex = pageIndex;
     this.Disabled  = disabled;
     this.Type      = type;
 }
Ejemplo n.º 5
0
 public PagerItem(string text, string url, PagerItemType itemType, PagerItemState state)
 {
     this.Text      = text;
     this.Url       = url;
     this.Type      = itemType;
     this.State     = state;
     this.ExtraData = String.Empty;
 }
Ejemplo n.º 6
0
 public PagerItem(string text, string url, PagerItemType itemType, PagerItemState state)
 {
     this.Text = text;
     this.Url = url;
     this.Type = itemType;
     this.State = state;
     this.ExtraData = String.Empty;
 }
Ejemplo n.º 7
0
 public PagerItem(string text, string url, PagerItemType itemType, PagerItemState state)
 {
     Text      = text;
     Url       = url;
     Type      = itemType;
     State     = state;
     ExtraData = string.Empty;
 }
        /// <summary>
        ///     Get the base item type of a <see cref="PagerItemType" />. If no base itemType is appliable. This method will return
        ///     <c>null</c>.
        /// </summary>
        /// <param name="itemType">A <see cref="PagerItemType" /> to be getting the base type.</param>
        /// <returns>The base type of <paramref name="itemType" />, or <c>null</c> if no base itemType is appliable.</returns>
        public static PagerItemType?GetBaseItemType(PagerItemType itemType)
        {
            switch (itemType)
            {
            case PagerItemType.Current:
            case PagerItemType.Omitted:
                return(PagerItemType.Normal);

            default:
                return(null);
            }
        }
        public PagerItemOptions GetMergedOptionsFor(PagerItemType itemType)
        {
            // Stack used to LIFO operations
            var optionsStack = new Stack <PagerItemOptions>();

            // Recursively get base item
            PagerItemType?current = itemType;

            while (current != null)
            {
                optionsStack.Push(GetOptionsFor(itemType));
                current = GetBaseItemType(current.Value);
            }

            // Put default item
            optionsStack.Push(Default);

            // Merge all items
            return(PagerItemOptions.MergeAll(optionsStack));
        }
Ejemplo n.º 10
0
 public PagerItem(string text, string url, PagerItemType itemType)
     : this(text, url, itemType, PagerItemState.Normal)
 {
 }
Ejemplo n.º 11
0
 public PagerItem(string text, string url, PagerItemType itemType)
     : this(text, url, itemType, PagerItemState.Normal)
 {
 }
Ejemplo n.º 12
0
		public PagerItemOptions GetMergedOptionsFor(PagerItemType itemType)
		{
			// Stack used to LIFO operations
			var optionsStack = new Stack<PagerItemOptions>();

			// Recursively get base item
			PagerItemType? current = itemType;
			while (current != null)
			{
				optionsStack.Push(GetOptionsFor(itemType));
				current = GetBaseItemType(current.Value);
			}

			// Put default item
			optionsStack.Push(Default);

			// Merge all items
			return PagerItemOptions.MergeAll(optionsStack);
		}
Ejemplo n.º 13
0
		/// <summary>
		///     Get the base item type of a <see cref="PagerItemType" />. If no base itemType is appliable. This method will return
		///     <c>null</c>.
		/// </summary>
		/// <param name="itemType">A <see cref="PagerItemType" /> to be getting the base type.</param>
		/// <returns>The base type of <paramref name="itemType" />, or <c>null</c> if no base itemType is appliable.</returns>
		public static PagerItemType? GetBaseItemType(PagerItemType itemType)
		{
			switch (itemType)
			{
				case PagerItemType.Current:
				case PagerItemType.Omitted:
					return PagerItemType.Normal;
				default:
					return null;
			}
		}
Ejemplo n.º 14
0
		/// <summary>
		///     Get the actual <see cref="PagerItemOptions" /> for a specified <see cref="PagerItemType" />.
		/// </summary>
		/// <param name="itemType">The <see cref="PagerItemType" /> which indicates the role of the pager item.</param>
		/// <returns>A <see cref="PagerItemOptions" /> used for the current <see cref="PagerLayoutElement" />.</returns>
		/// <exception cref="ArgumentException">The value of <paramref name="itemType" /> is not a valid enum item.</exception>
		public PagerItemOptions GetOptionsFor(PagerItemType itemType)
		{
			switch (itemType)
			{
				case PagerItemType.Normal:
					return Normal;
				case PagerItemType.First:
					return FirstPageButton;
				case PagerItemType.Last:
					return LastPageButton;
				case PagerItemType.Previous:
					return PreviousPageButton;
				case PagerItemType.Next:
					return NextPageButton;
				case PagerItemType.Current:
					return Current;
				case PagerItemType.Omitted:
					return Omitted;
				default:
					throw new ArgumentException("The value of the argument is not a valid enum item.", nameof(itemType));
			}
		}
Ejemplo n.º 15
0
        private void createPagerItem(RenderTreeBuilder builder, ref int seq, int pageIndex, string text, PagerItemType itemType)
        {
            var containerTag   = PagerItemContainerTagName;
            var containerClass = PagerItemContainerCssClass;
            var itemClass      = PagerItemCssClass;

            switch (itemType)
            {
            case PagerItemType.Number:
                containerTag   = GetFirstNonNullString(new[] { NumericPagerItemContainerTagName, containerTag });
                containerClass = GetFirstNonNullString(new[] { NumericPagerItemContainerCssClass, containerClass });
                itemClass      = GetFirstNonNullString(new[] { NumericPagerItemCssClass, itemClass });
                break;

            case PagerItemType.Navigation:
                containerTag   = GetFirstNonNullString(new[] { NavigationPagerItemContainerTagName, containerTag });
                containerClass = GetFirstNonNullString(new[] { NavigationPagerItemContainerCssClass, containerClass });
                itemClass      = GetFirstNonNullString(new[] { NavigationPagerItemCssClass, itemClass });
                break;

            case PagerItemType.Current:
                containerTag   = GetFirstNonNullString(new[] { CurrentPagerItemContainerTagName, NumericPagerItemContainerTagName, containerTag });
                containerClass = GetFirstNonNullString(new[] { CurrentPagerItemContainerCssClass, NumericPagerItemContainerCssClass, containerClass });
                itemClass      = GetFirstNonNullString(new[] { CurrentPagerItemCssClass, NumericPagerItemCssClass, itemClass });
                break;

            case PagerItemType.More:
                containerTag   = GetFirstNonNullString(new[] { MorePagerItemContainerTagName, containerTag });
                containerClass = GetFirstNonNullString(new[] { MorePagerItemContainerCssClass, containerClass });
                itemClass      = GetFirstNonNullString(new[] { MorePagerItemCssClass, itemClass });
                break;

            case PagerItemType.Disabled:
                containerTag   = GetFirstNonNullString(new[] { DisabledPagerItemContainerTagName, NavigationPagerItemContainerTagName, containerTag });
                containerClass = GetFirstNonNullString(new[] { DisabledPagerItemContainerCssClass, NavigationPagerItemContainerCssClass, containerClass });
                itemClass      = GetFirstNonNullString(new[] { DisabledPagerItemCssClass, NavigationPagerItemCssClass, itemClass });
                break;
            }
            bool hasContainerTag = !string.IsNullOrWhiteSpace(containerTag);

            if (hasContainerTag)
            {
                builder.OpenElement(++seq, containerTag);
                if (!string.IsNullOrWhiteSpace(containerClass))
                {
                    builder.AddAttribute(++seq, "class", containerClass);
                }
            }
            builder.OpenElement(++seq, "a");
            if (!string.IsNullOrWhiteSpace(itemClass))
            {
                builder.AddAttribute(++seq, "class", itemClass);
            }
            if (pageIndex > 0)
            {
                builder.AddAttribute(++seq, "href", string.Format(RoutePattern, pageIndex));
                builder.AddAttribute(++seq, "onclick", BindMethods.GetEventHandlerValue <UIMouseEventArgs>(() => ChangePage(pageIndex)));
            }
            var pagerItemText = text;

            if (itemType == PagerItemType.Number || itemType == PagerItemType.Current)
            {
                var numberFormat = string.IsNullOrWhiteSpace(NumericPagerItemTextFormatString) ? "{0}" : NumericPagerItemTextFormatString;
                if (itemType == PagerItemType.Current && !string.IsNullOrWhiteSpace((CurrentPagerItemTextFormatString)))
                {
                    numberFormat = CurrentPagerItemTextFormatString;
                }
                pagerItemText = string.Format(numberFormat, text);
            }
            builder.AddMarkupContent(++seq, pagerItemText);
            builder.CloseElement();
            if (hasContainerTag)
            {
                builder.CloseElement();
            }
        }
Ejemplo n.º 16
0
        private PagerItem CreatePagerItem(PagerItemType itemType, int pageNumber, string text)
        {
            PagerItem i = new PagerItem(this, pageNumber, text);

            switch (itemType)
            {
            case PagerItemType.Item:
                _pagerItemTemplate.InstantiateIn(i);
                break;

            case PagerItemType.SelectedItem:
                _pagerSelectedItemTemplate.InstantiateIn(i);
                break;

            case PagerItemType.Header:
                _pagerHeaderTemplate.InstantiateIn(i);
                break;

            case PagerItemType.Footer:
                _pagerFooterTemplate.InstantiateIn(i);
                break;

            case PagerItemType.OnePage:
                _onePageTemplate.InstantiateIn(i);
                break;

            case PagerItemType.PrevPage:
                _prevPageTemplate.InstantiateIn(i);
                break;

            case PagerItemType.PrevInactivePage:
                _prevInactivePageTemplate.InstantiateIn(i);
                break;

            case PagerItemType.NextPage:
                _nextPageTemplate.InstantiateIn(i);
                break;

            case PagerItemType.NextInactivePage:
                _nextInactivePageTemplate.InstantiateIn(i);
                break;

            case PagerItemType.FirstPage:
                _firstPageTemplate.InstantiateIn(i);
                break;

            case PagerItemType.FirstInactivePage:
                _firstInactivePageTemplate.InstantiateIn(i);
                break;

            case PagerItemType.LastPage:
                _lastPageTemplate.InstantiateIn(i);
                break;

            case PagerItemType.LastInactivePage:
                _lastInactivePageTemplate.InstantiateIn(i);
                break;
            }
            if (pageNumber > -1)
            {
                i.DataBind();
            }
            return(i);
        }