public void ApplyTo(IHtmlNode target)
        {
            var hierarchyCell = new HtmlTag("th")
                .AddClass(UIPrimitives.Header, UIPrimitives.Grid.HierarchyCell);

            target.Children.Insert(0, hierarchyCell);
        }
 private void AppendPageInput(IHtmlNode container, GridPagerData section)
 {
     if (section.Input)
     {
         inputSectionBuilder.Create(section).AppendTo(container);
     }
 }
Exemple #3
0
        protected object GetData( IHtmlNode node, bool asContainer )
        {
            if ( node == null )
            return null;

              lock ( _dataItems.SyncRoot )
              {

            if ( asContainer )
            {
              var _container = node as IHtmlContainer;

              if ( _container != null && _dataItems.Contains( _container ) )
            return _dataItems[_container];
            }

            var container = node.Container;

            if ( _dataItems.Contains( container ) )
              return _dataItems[container];

            else
              return GetData( container as IHtmlNode, false );
              }
        }
        public void ApplyTo(IHtmlNode target)
        {
            var filtered = column.Grid.DataProcessor.FilterDescriptors.SelectRecursive(filter =>
            {
                CompositeFilterDescriptor compositeDescriptor = filter as CompositeFilterDescriptor;

                if (compositeDescriptor != null)
                {
                    return compositeDescriptor.FilterDescriptors;
                }

                return null;
            })
            .Where(filter => filter is FilterDescriptor)
            .OfType<FilterDescriptor>()
            .Any(filter => filter.Member.IsCaseInsensitiveEqual(column.Member));

            var wrapper = new HtmlTag("div")
                .AddClass("t-grid-filter", "t-state-default")
                .ToggleClass("t-active-filter", filtered);

            wrapper.AppendTo(target);

            var icon = new HtmlTag("span").AddClass("t-icon", "t-filter");
            icon.AppendTo(wrapper);
        }
 private static string AsString(IHtmlNode node)
 {
     var sb = new StringBuilder();
     using (var writer = new HtmlTextWriter(new StringWriter(sb)))
         node.Write(writer);
     return sb.ToString();
 }
        public GridButtonImageDecoratorTests()
        {
            button = new Mock<IGridButtonBuilder>();
            html = new HtmlElement("button");

            decorator = new GridButtonImageDecorator(button.Object);
        }
Exemple #7
0
        public HtmlRange( IHtmlNode node1, IHtmlNode node2, bool inclusiveNode1, bool inclusiveNode2 )
        {
            if ( node1 == null )
            throw new ArgumentNullException( "node1" );

              if ( node2 == null )
            throw new ArgumentNullException( "node2" );

              container = node1.Container;

              if ( container == null || !container.Equals( node2.Container ) || node1.Equals( node2 ) )
            throw new InvalidOperationException();

              if ( node1.NodesIndexOfSelf() <= node2.NodesIndexOfSelf() )
              {
            beginNode = node1;
            endNode = node2;
            inclusiveBegin = inclusiveNode1;
            inclusiveEnd = inclusiveNode2;
              }
              else
              {
            beginNode = node2;
            endNode = node1;
            inclusiveBegin = inclusiveNode2;
            inclusiveEnd = inclusiveNode1;
              }
        }
 private void AppendNumericSection(IHtmlNode container, GridPagerStyles style, IGridUrlBuilder urlBuilder, int currentPage, int pageCount)
 {
     if ((style & GridPagerStyles.Numeric) == GridPagerStyles.Numeric)
     {
         numericSectionBuilder.Create(urlBuilder, currentPage, pageCount).AppendTo(container);
     }
 }
 protected override void AppendCellContent(IHtmlNode td, object dataItem)
 {
     foreach (var builder in builders)
     {
         builder(dataItem).AppendTo(td);
     }
 }
        private void AppendPageSizeDropDown(IHtmlNode container, GridPagerStyles style, GridPagerData section)
        {
            if ((style & GridPagerStyles.PageSizeDropDown) != GridPagerStyles.PageSizeDropDown)
                return;

            gridPagerPageSizeSection.Create(section).AppendTo(container);
        }
        private void AppendPageInput(IHtmlNode container, GridPagerStyles style, GridPagerData section)
        {
            if ((style & GridPagerStyles.PageInput) != GridPagerStyles.PageInput)
                return;

            inputSectionBuilder.Create(section).AppendTo(container);
        }
Exemple #12
0
    bool IHtmlRenderAdapter.Render( IHtmlNode node, IHtmlRenderContext context )
    {
      var element = node as IHtmlElement;

      if ( element == null )
        return false;

      if ( element.Name.EqualsIgnoreCase( "content" ) )
      {
        GetContentBody( element ).RenderChilds( context.Writer, RenderAdapters );
        return true;
      }
      else if ( element.Name.EqualsIgnoreCase( "head" ) )
      {

        View.ViewContext.HttpContext.Trace.Write( "ContentView", "Begin Merge Head" );
        var head = MergeHead( element, Document.FindSingle( "head" ) );
        View.ViewContext.HttpContext.Trace.Write( "ContentView", "End Merge Head" );

        head.Render( context.Writer, RenderAdapters );

        return true;
      }
      else
        return false;
    }
 protected void Decorate(IHtmlNode td)
 {
     foreach (var decorator in Decorators)
     {
         decorator.Decorate(td);
     }
 }
 private void ApplyDecorators(IHtmlNode table)
 {
     foreach (var decorator in Decorators)
     {
         decorator.Decorate(table);
     }
 }
 protected void AppendFooter(IHtmlNode table, GridRenderingData renderingData)
 {
     if (renderingData.ShowFooter)
     {
         var tfoot = CreateFooter(renderingData);
         tfoot.AppendTo(table);
     }
 }
 private void AppendNumericSection(IHtmlNode container, IGridUrlBuilder urlBuilder, GridPagerData section)
 {
     if (section.Numeric)
     {
         numericSectionBuilder.Create(urlBuilder, section.Page, section.TotalPages, section.ButtonCount)
                              .AppendTo(container);
     }
 }
 protected void AppendBottomToolBar(IHtmlNode div, GridFunctionalData functionalData)
 {
     if (functionalData.ShowBottomToolBar)
     {
         var toolBar = CreateToolBar(functionalData.ToolBarData);
         toolBar.AddClass("t-grid-bottom").AppendTo(div);
     }
 }
 private void AppendNumericButtons(IGridUrlBuilder urlBuilder, int currentPage, int numericStart, IHtmlNode numericDiv, int numericEnd)
 {
     for (var page = numericStart; page <= numericEnd; page++)
     {
         buttonFactory.CreateButton(GridPagerButtonType.NumericLink, page.ToString(), page != currentPage,
                                    GetUrl(urlBuilder, page)).AppendTo(numericDiv);
     }
 }
        public override void WriteHtml(IHtmlNode parent)
        {
            var li = CreateElement();

            li.Children.Add(CreateLink());

            parent.Children.Add(li);
        }
 private void AppendNextButtonsLink(int pageCount, IHtmlNode numericDiv, int numericEnd, IGridUrlBuilder urlBuilder)
 {
     if (numericEnd < pageCount)
     {
         buttonFactory.CreateButton(GridPagerButtonType.NumericLink, "...", true,
                                    GetUrl(urlBuilder, numericEnd + 1)).AppendTo(numericDiv);
     }
 }
        public void Apply(IHtmlNode parent)
        {
            var span = new HtmlElement("span");

            span.Attributes(button.ImageHtmlAttributes).AddClass(UIPrimitives.Icon, button.SpriteCssClass);

            span.AppendTo(parent);
        }
 private void AppendPrevButtonsLink(int numericStart, IHtmlNode numericDiv, IGridUrlBuilder urlBuilder)
 {
     if (numericStart > 1)
     {
         buttonFactory.CreateButton(GridPagerButtonType.NumericLink, "...", true,
                                    GetUrl(urlBuilder, numericStart - 1)).AppendTo(numericDiv);
     }
 }
 public void Decorate(IHtmlNode table)
 {
     var colGroup = table.Children.FirstOrDefault();
     if (colGroup != null && hasDetails)
     {
         var td = CreateCol();
         colGroup.Children.Insert(0, td);
     }
 }
        private void AppendGroupIndicators(IHtmlNode div, GridGroupingData groupingData)
        {
            var groupDescriptors = groupingData.GroupDescriptors;

            foreach (var group in groupDescriptors)
            {
                AppendGroupIndicator(div, group, groupingData);
            }
        }
        protected override void ApplyDecoration(IHtmlNode htmlNode)
        {
            for (int i = 0; i < CurrentGridItem.GroupLevel; i++)
            {
                var td = CreateCell();

                htmlNode.Children.Insert(0, td);
            }
        }
Exemple #26
0
        private void AppendButtons(IHtmlNode form)
        {
            foreach (var buttonBuilder in buttonBuilders)
            {
                var button = buttonBuilder();

                button.AppendTo(form);
            }
        }
Exemple #27
0
    public void RemoveNode( IHtmlNode node )
    {
      var _node = node.RawObject as HAP.HtmlNode;

      if ( _node == null )
        throw new ArgumentException( "node" );

      _node.Remove();
    }
		internal TestHtml(IHtmlNode node)
		{
			if (node == null)
			{
				throw new ArgumentNullException("node");
			}

			this.node = node;
		}
        protected override void AppendData(IHtmlNode div, GridRenderingData renderingData)
        {
            AppendHeader(div,renderingData);

            var content = CreateContent(renderingData);

            content.AppendTo(div);

            AppendFooter(div, renderingData);
        }
        private void AppendFirstPrevButtons(IHtmlNode container, GridPagerStyles style, IGridUrlBuilder urlBuilder, int currentPage)
        {
            if ((style & GridPagerStyles.NextPrevious) != GridPagerStyles.NextPrevious)
                return;

            buttonFactory.CreateButton(GridPagerButtonType.Icon, "first", currentPage > 1,
                                       GetUrl(urlBuilder, 1)).AppendTo(container);

            buttonFactory.CreateButton(GridPagerButtonType.Icon, "prev", currentPage > 1,
                                       GetUrl(urlBuilder, currentPage - 1)).AppendTo(container);
        }
Exemple #31
0
        /// <summary>
        /// 尝试生成节点的HTML表现形式
        /// </summary>
        /// <param name="node">要生成HTML的节点</param>
        /// <returns></returns>
        private static string GenerateHtml(IHtmlNode node)
        {
            var textNode = node as IHtmlTextNode;

            if (textNode != null)
            {
                return(textNode.HtmlText);
            }

            var specialNode = node as IHtmlSpecial;//对于特殊标签无条件原样输出。

            if (specialNode != null)
            {
                return(specialNode.RawHtml);
            }

            var commentNode = node as IHtmlComment;

            if (commentNode != null)
            {
                return(string.Format(CultureInfo.InvariantCulture, "<!--{0}-->", commentNode.Comment));
            }

            var element = node as IHtmlElement;

            if (element != null)
            {
                return(GenerateElementHtml(element));
            }

            var document = node as IHtmlDocument;

            if (document != null)
            {
                var builder = new StringBuilder();
                document.Nodes().ForAll(child => builder.Append(GenerateHtml(child)));
                return(builder.ToString());
            }

            throw new InvalidOperationException();
        }
Exemple #32
0
        private void WriteItem(TreeViewItem item, IHtmlNode parentTag, TreeViewHtmlBuilder builder)
        {
            if (ItemAction != null)
            {
                ItemAction(item);
            }

            if (item.Visible)
            {
                var accessible = true;
                if (this.SecurityTrimming)
                {
                    accessible = item.IsAccessible(Authorization, ViewContext);
                }


                if (accessible)
                {
                    var hasAccessibleChildren = item.Items.Any(x => x.Visible);
                    if (hasAccessibleChildren && this.SecurityTrimming)
                    {
                        hasAccessibleChildren = item.Items.IsAccessible(Authorization, ViewContext);
                    }

                    IHtmlNode itemTag = builder.ItemTag(item, hasAccessibleChildren).AppendTo(parentTag);

                    builder.ItemInnerContent(item).AppendTo(itemTag.Children[0]);

                    if (item.Template.HasValue())
                    {
                        builder.ItemContentTag(item).AppendTo(itemTag);
                    }
                    else if (hasAccessibleChildren)
                    {
                        IHtmlNode ul = builder.ChildrenTag(item).AppendTo(itemTag);

                        item.Items.Each(child => WriteItem(child, ul, builder));
                    }
                }
            }
        }
        public static void WriteItem <TComponent, TItem>(this TItem item, TComponent component, IHtmlNode parentTag, INavigationComponentHtmlBuilder <TItem> builder)
            where TItem : NavigationItem <TItem>, IContentContainer, INavigationItemContainer <TItem>
            where TComponent : ViewComponentBase, INavigationItemComponent <TItem>
        {
            var accessible = true;

            if (component.SecurityTrimming)
            {
                accessible = item.IsAccessible(component.Authorization, component.ViewContext);
            }

            if (component.ItemAction != null)
            {
                component.ItemAction(item);
            }

            if (item.Visible && accessible)
            {
                var hasAccessibleChildren = item.Items.Any() && item.Items.Any(i => i.Visible);
                if (component.SecurityTrimming && hasAccessibleChildren)
                {
                    hasAccessibleChildren = item.Items.IsAccessible(component.Authorization, component.ViewContext);
                }

                IHtmlNode itemTag = builder.ItemTag(item).AppendTo(parentTag);

                builder.ItemInnerContentTag(item, hasAccessibleChildren).AppendTo(itemTag);

                if (item.Template.HasValue() ||
                    (item is IAsyncContentContainer ? !string.IsNullOrEmpty(((IAsyncContentContainer)item).ContentUrl) : false))
                {
                    builder.ItemContentTag(item).AppendTo(itemTag);
                }
                else if (hasAccessibleChildren)
                {
                    IHtmlNode ul = builder.ChildrenTag(item).AppendTo(itemTag);

                    item.Items.Each(child => child.WriteItem(component, ul, builder));
                }
            }
        }
Exemple #34
0
        public void InnerContentTag_should_not_render_value_if_no_item_has_Component_value()
        {
            combobox.Name = "combobox";
            combobox.Items.Add(new DropDownItem {
                Text = "Item1", Value = "1"
            });
            combobox.Items.Add(new DropDownItem {
                Text = "Item2", Value = "2"
            });

            combobox.InputHtmlAttributes.Add("ID", "1");

            combobox.SelectedIndex = -1;
            combobox.Value         = "0";

            combobox.SyncSelectedIndex();

            IHtmlNode tag = renderer.InnerContentTag();

            Assert.Throws(typeof(System.Collections.Generic.KeyNotFoundException), () => tag.Children[0].Attribute("value"));
        }
        private void AppendSortLink(IHtmlNode indicator, GroupDescriptor group, List <GroupDescriptor> groups, IGridUrlBuilder urlBuilder, Func <string, string> title)
        {
            group.CycleSortDirection();

            var a = new HtmlElement("a")
                    .AddClass(UIPrimitives.Link)
                    .Attribute("href", urlBuilder.SelectUrl(GridUrlParameters.Group, GridDescriptorSerializer.Serialize(groups)))
                    .AppendTo(indicator);

            group.CycleSortDirection();

            new HtmlElement("span")
            .AddClass(UIPrimitives.Icon)
            .ToggleClass("k-si-arrow-n", group.SortDirection == ListSortDirection.Ascending)
            .ToggleClass("k-si-arrow-s", group.SortDirection == ListSortDirection.Descending)
            .AppendTo(a);

            groups.Remove(group);

            new TextNode(title(group.Member)).AppendTo(a);
        }
        private void GetQuote()
        {
            this.DataPoints.Add(new DataPoint(
                                    name: "COMPANY",
                                    value: this.Document.GetNodeBySelector("//h1").GetText()
                                    ));

            IHtmlNode quoteHeader = this.Document.GetNodesByAttribute("div", "id", "quote-market-notice").First();

            IHtmlNode[] items = quoteHeader.GetAncestor().GetNodesBySelector("span").ToArray();

            this.DataPoints.Add(new DataPoint(
                                    name: "PRICE",
                                    value: items[0].GetText()
                                    ));

            this.DataPoints.Add(new DataPoint(
                                    name: "VARIATION",
                                    value: items[1].GetText()
                                    ));
        }
        /// <summary>
        /// 判断指定节点是否为指定容器的子代。
        /// </summary>
        /// <param name="node">要判断的节点</param>
        /// <param name="container">要判断的容器</param>
        /// <returns>若节点位于容器的子代,则返回 true ,否则返回 false 。</returns>
        public static bool IsDescendantOf(this IHtmlNode node, IHtmlContainer container)
        {
            if (node == null)
            {
                throw new ArgumentNullException("node");
            }

            if (container == null)
            {
                throw new ArgumentNullException("container");
            }

            var collection = container as IHtmlCollection;

            if (collection != null)
            {
                return(IsDescendantOf(node, collection));
            }


            while (true)
            {
                if (node.Container == null)
                {
                    return(false);
                }

                if (object.Equals(node.Container, container))
                {
                    return(true);
                }

                node = node.Container as IHtmlNode;

                if (node == null)
                {
                    return(false);
                }
            }
        }
Exemple #38
0
        protected override void WriteHtml(HtmlTextWriter writer)
        {
            Guard.IsNotNull(writer, "writer");

            if (Items.Any())
            {
                if (SelectedIndex != -1 && Items.Count < SelectedIndex)
                {
                    throw new ArgumentOutOfRangeException(TextResource.IndexOutOfRange);
                }

                int itemIndex = 0;

                INavigationComponentHtmlBuilder <PanelBarItem> builder = builderFactory.Create(this);

                IHtmlNode panelbarTag = builder.Build();

                //this loop is required because of SelectedIndex feature.
                if (HighlightPath)
                {
                    Items.Each(HighlightSelectedItem);
                }

                this.Items.Each(item =>
                {
                    if (item.Enabled)
                    {
                        PrepareItem(item, itemIndex);
                    }

                    itemIndex++;

                    item.WriteItem <PanelBar, PanelBarItem>(this, panelbarTag, builder);
                });

                panelbarTag.WriteTo(writer);
            }
            base.WriteHtml(writer);
        }
Exemple #39
0
        public override IHtmlNode Build()
        {
            IHtmlNode htmlNode = base.Build().Attribute("type", base.Component.Type.ToString(), true);

            if (base.Component.Group.HasValue())
            {
                htmlNode.Attribute("name", base.Component.Group, true);
            }
            if (base.Component.Value.HasValue())
            {
                htmlNode.Attribute("value", base.Component.Value, true);
            }
            if (base.Component.Checked)
            {
                htmlNode.Attribute("checked", "true", true);
            }
            if (base.Component.Text.HasValue())
            {
                new HtmlNode("label").Attribute("for", base.Component.Id, true).Text(base.Component.Text).AppendTo(htmlNode.NextSibings);
            }
            return(htmlNode);
        }
        /// <summary>
        /// Создать обёртну над узлом.
        /// </summary>
        /// <param name="n">Исходный узел.</param>
        /// <param name="parent">Родительский узел.</param>
        /// <returns>Обёртка.</returns>
        internal static IHtmlNode CreateNode(HtmlNode n, IHtmlNode parent)
        {
            switch (n)
            {
            case HtmlCommentNode c:
                return(new AgilityHtmlCommentNode <HtmlCommentNode>(c)
                {
                    ParentNode = parent
                });

            case HtmlTextNode t:
                return(new AgilityHtmlTextNode <HtmlTextNode>(t)
                {
                    ParentNode = parent
                });

            default:
                return(new AgilityHtmlNode <HtmlNode>(n)
                {
                    ParentNode = parent
                });
            }
        }
Exemple #41
0
        public void WriteTo(TextWriter writer, HtmlEncoder encoder)
        {
            VerifyProperties();
            if (this is IDataBind)
            {
                ((IDataBind)this).DataBind();
            }

            // builder之后render之前发生
            this.OnCreateControl();

            if (!IsOnlyScriptable)
            {
                IHtmlNode html = HtmlBuilder.Build();
                RenderHtml(writer, html);
            }
            if (IsNeedScriptable)
            {
                StringWriter stringWriter = new StringWriter();
                WriteInitScript(stringWriter);
                Context.AppendInitScripts(stringWriter.ToString());
            }
        }
Exemple #42
0
        /// <summary>
        /// 确定一个节点是否在索引范围内
        /// </summary>
        /// <param name="node">要检测的节点</param>
        /// <returns></returns>
        public bool InScope(IHtmlNode node)
        {
            lock ( SyncRoot )
            {
                if (node == null)
                {
                    throw new ArgumentNullException("node");
                }

                if (node.Container.Equals(Container))
                {
                    return(true);
                }

                var element = node.Container as IHtmlElement;
                if (element == null)
                {
                    return(false);
                }

                return(DescendantElements.Contains(element));
            }
        }
Exemple #43
0
        private IHtmlNode BuildMonthView(ICalendarHtmlBuilder renderer)
        {
            NormalizeSelectDates();

            IHtmlNode monthTag = renderer.MonthTag();

            DateTime focusedDate = this.DetermineFocusedDate();
            DateTime prevMonth   = GetLastDayOfMonth(focusedDate).AddMonths(-1);
            DateTime startDate   = GetStartOfWeek(prevMonth, CultureInfo.CurrentCulture.DateTimeFormat.FirstDayOfWeek);

            for (int weekRow = 0; weekRow < 6; weekRow++)
            {
                IHtmlNode rowTag = renderer.RowTag();

                for (int day = 0; day < 7; day++)
                {
                    renderer.CellTag(startDate, Value, urlFormat, startDate.Month != focusedDate.Month).AppendTo(rowTag);
                    startDate = startDate.AddDays(1);
                }
                monthTag.Children.Add(rowTag);
            }
            return(monthTag);
        }
Exemple #44
0
        protected override void WriteHtml(System.Web.UI.HtmlTextWriter writer)
        {
            ICalendarHtmlBuilder renderer = rendererFactory.Create(this);

            urlFormat = SelectionSettings.GenerateUrl(ViewContext, UrlGenerator);
            if (urlFormat.HasValue())
            {
                urlFormat = HttpUtility.UrlDecode(urlFormat).ToLowerInvariant();
            }

            IHtmlNode rootTag = renderer.Build();

            IHtmlNode contentTag = renderer.ContentTag();

            contentTag.Children.Add(BuildWeekHeader(renderer));
            contentTag.Children.Add(BuildMonthView(renderer));

            rootTag.Children.Add(contentTag);

            rootTag.WriteTo(writer);

            base.WriteHtml(writer);
        }
Exemple #45
0
 public void Apply(object data, IHtmlNode node)
 {
     node.Template(delegate(TextWriter writer)
     {
         if (data is DataTable dt)
         {
             int index = 1;
             dt.Rows.Each <DataRow>(row =>
             {
                 WriteItem(writer, row.ToObject <T>(index++));
             });
         }
         else if (data is IEnumerable <DataRow> list)
         {
             int index = 1;
             list.Each(row =>
             {
                 WriteItem(writer, row.ToObject <T>(index++));
             });
         }
         else if (data is DataRow row)
         {
             WriteItem(writer, row.ToObject <T>());
         }
         else if (data is IEnumerable <T> list2)
         {
             list2.Each(item =>
             {
                 WriteItem(writer, item);
             });
         }
         else
         {
             WriteItem(writer, (T)data);
         }
     });
 }
Exemple #46
0
        protected override void WriteHtml(HtmlTextWriter writer)
        {
            Guard.IsNotNull(writer, "writer");

            if (Items.Any())
            {
                ITabStripHtmlBuilder builder = builderFactory.Create(this);

                int  itemIndex         = 0;
                bool isPathHighlighted = false;

                IHtmlNode tabStripTag = builder.TabStripTag();

                //this loop is required because of SelectedIndex feature.
                if (HighlightPath)
                {
                    Items.Each(HighlightSelectedItem);
                }

                Items.Each(item =>
                {
                    if (!isPathHighlighted)
                    {
                        if (itemIndex == this.SelectedIndex)
                        {
                            item.Selected = true;
                        }
                        itemIndex++;
                    }

                    WriteItem(item, tabStripTag, builder);
                });

                tabStripTag.WriteTo(writer);
            }
            base.WriteHtml(writer);
        }
Exemple #47
0
        protected override void WriteHtml(HtmlTextWriter writer)
        {
            if (Items.Any())
            {
                if (SelectedIndex != -1 && Items.Count < SelectedIndex)
                {
                    throw new ArgumentOutOfRangeException(Exceptions.IndexOutOfRange);
                }

                int itemIndex = 0;

                var builder = new PanelBarHtmlBuilder(this, DI.Current.Resolve <IActionMethodCache>());

                IHtmlNode panelbarTag = builder.Build();

                //this loop is required because of SelectedIndex feature.
                if (HighlightPath)
                {
                    Items.Each(HighlightSelectedItem);
                }

                this.Items.Each(item =>
                {
                    if (item.Enabled)
                    {
                        PrepareItem(item, itemIndex);
                    }

                    itemIndex++;

                    item.WriteItem <PanelBar, PanelBarItem>(this, panelbarTag, builder);
                });

                panelbarTag.WriteTo(writer);
            }
            base.WriteHtml(writer);
        }
Exemple #48
0
        /*
         * /// <summary>
         * /// 在末尾添加节点的副本,此方法总是创建节点的副本
         * /// </summary>
         * /// <param name="container">要添加节点的容器</param>
         * /// <param name="node">要添加的节点</param>
         * /// <remarks>
         * /// 此方法要求容器所在的文档支持创建节点,即GetNodeFactory方法不能返回null,否则将抛出NotSupportedException。
         * /// 使用此方法可以轻易地将元素或者其他节点从一个文档复制到另一个文档。
         * /// </remarks>
         * /// <exception cref="System.NotSupportedException">容器所在的文档不支持创建节点,或不支持创建此类节点的副本(譬如说IHtmlDocument)</exception>
         * public static TContainer AppendCopy<TContainer>( this TContainer container, IHtmlNode node ) where TContainer : IHtmlContainer
         * {
         * if ( container == null )
         *  throw new ArgumentNullException( "container" );
         *
         * if ( node == null )
         *  throw new ArgumentNullException( "node" );
         *
         *
         * lock ( container.SyncRoot )
         * {
         *  return InsertCopy( container, container.Nodes().Count(), node );
         * }
         * }
         *
         *
         * /// <summary>
         * /// 在指定位置添加节点的副本,此方法总是创建节点的副本
         * /// </summary>
         * /// <param name="container">要添加节点的容器</param>
         * /// <param name="index">要插入节点的位置</param>
         * /// <param name="node">要添加的节点</param>
         * /// <remarks>
         * /// 此方法要求容器所在的文档支持创建节点,即GetNodeFactory方法不能返回null,否则将抛出NotSupportedException。
         * /// 使用此方法可以轻易地将元素或者其他节点从一个文档复制到另一个文档。
         * /// </remarks>
         * /// <exception cref="System.NotSupportedException">容器所在的文档不支持创建节点,或不支持创建此类节点的副本(譬如说IHtmlDocument)</exception>
         * public static TContainer InsertCopy<TContainer>( this TContainer container, int index, IHtmlNode node ) where TContainer : IHtmlContainer
         * {
         * var fragment = container as HtmlFragment;
         *
         * if ( fragment != null )
         * {
         *  fragment.AddCopy( index, node );
         *  return container;
         * }
         *
         *
         * lock ( container.SyncRoot )
         * {
         *
         *  var factory = container.Document.GetNodeFactory();
         *  if ( factory == null )
         *    throw new NotSupportedException();
         *
         *  var nodeCopy = factory.MakeCopy( node );
         *
         *  nodeCopy.Into( container, index );
         *
         *  return container;
         * }
         * }
         */


        /*
         * /// <summary>
         * /// 替换指定节点
         * /// </summary>
         * /// <param name="oldNode">被替换的节点</param>
         * /// <param name="newNode">用于替换的节点</param>
         * /// <remarks>
         * /// 此方法要求容器所在的文档支持创建节点,即GetNodeFactory方法不能返回null,否则将抛出NotSupportedException。
         * /// 使用此方法可以轻易地将元素或者其他节点从一个文档复制到另一个文档。
         * /// </remarks>
         * /// <exception cref="System.NotSupportedException">容器所在的文档不支持创建节点,或不支持创建此类节点的副本(譬如说IHtmlDocument)</exception>
         * public static IHtmlNode ReplaceCopy( this IHtmlNode oldNode, IHtmlNode newNode )
         * {
         * var container = oldNode.Container;
         *
         * if ( container == null )
         *  throw new InvalidOperationException();
         *
         * lock ( container.SyncRoot )
         * {
         *  var factory = container.Document.GetNodeFactory();
         *  if ( factory == null )
         *    throw new NotSupportedException();
         *
         *  var nodeCopy = factory.MakeCopy( newNode );
         *
         *  var result = nodeCopy.Into( container, oldNode.NodesIndexOfSelf() );
         *  oldNode.Remove();
         *
         *  return result;
         * }
         * }
         */


        /// <summary>
        /// 创建节点的副本
        /// </summary>
        /// <param name="factory">用于创建节点的构建器</param>
        /// <param name="node">需要被创建副本的节点</param>
        /// <returns>节点的未分配副本</returns>
        /// <exception cref="System.NotSupportedException">试图创建不被支持的节点的副本</exception>
        public static IFreeNode MakeCopy(this IHtmlNodeFactory factory, IHtmlNode node)
        {
            if (factory == null)
            {
                throw new ArgumentNullException("factory");
            }

            if (node == null)
            {
                throw new ArgumentNullException("node");
            }


            var element = node as IHtmlElement;

            if (element != null)
            {
                return(MakeCopy(factory, element));
            }

            var comment = node as IHtmlComment;

            if (comment != null)
            {
                return(MakeCopy(factory, comment));
            }

            var textNode = node as IHtmlTextNode;

            if (textNode != null)
            {
                return(MakeCopy(factory, textNode));
            }

            throw new NotSupportedException();
        }
        /// <summary>
        /// 判断指定节点是否为指定容器的子代。
        /// </summary>
        /// <param name="node">要判断的节点</param>
        /// <param name="collection">要判断的容器</param>
        /// <returns>若节点位于容器的子代,则返回 true ,否则返回 false 。</returns>
        /// <remarks>
        /// 出于性能考虑, IsDescendantOf( this node, container ) 方法检查节点的所有父级是否包含指定的容器,但对于IHtmlCollection来说,即使节点是其子代,其也不会在其父级中出现。
        /// 所以这是针对 IHtmlCollection 的一个特定实现,而 IsDescendantOf( this IHtmlNode, IHtmlContainer ) 方法发现第二个参数是IHtmlCollection时,也会自动调用此重载
        /// </remarks>
        internal static bool IsDescendantOf(this IHtmlNode node, IHtmlCollection collection)
        {
            if (node == null)
            {
                throw new ArgumentNullException("node");
            }

            if (collection == null)
            {
                throw new ArgumentNullException("collection");
            }

            if (collection.Nodes().Contains(node))
            {
                return(true);
            }

            if (collection.Nodes().OfType <IHtmlContainer>().Any(child => node.IsDescendantOf(child)))
            {
                return(true);
            }

            return(false);
        }
        protected override void ApplyDecoration(IHtmlNode htmlNode)
        {
            var tagName = IsHeaderRow() ? "th" : "td";

            var td = new HtmlElement(tagName)
                     .AddClass(UIPrimitives.Grid.HierarchyCell)
                     .ToggleClass(UIPrimitives.Header, IsHeaderRow())
                     .ToggleAttribute("scope", "col", IsHeaderRow())
                     .Html("&nbsp;");

            if ((CurrentGridItem.State & GridItemStates.Master) == GridItemStates.Master)
            {
                td.Html(string.Empty);
                var a = new HtmlElement("a")
                        .Attribute("href", "#")
                        .AddClass(UIPrimitives.Icon)
                        .ToggleClass("t-plus", !CurrentGridItem.Expanded)
                        .ToggleClass("t-minus", CurrentGridItem.Expanded);

                a.AppendTo(td);
            }

            htmlNode.Children.Insert(CurrentGridItem.GroupLevel, td);
        }
Exemple #51
0
        protected override void BuildContent(IContentWidget content, IHtmlNode html)
        {
            IHtmlNode html2 = new HtmlNode("div").AddClass("fl").AppendTo(html);

            base.BuildContent(content, html2);
            if (base.Component.Button.HasValue && base.Component.Button.Value)
            {
                base.Component.Ace.Button().Text("查询").IconCls("fa fa-search")
                .Css("ml5")
                .Click("AX.gridSrh('#" + base.Component.For + "','#" + base.Component.Id + "')")
                .AppendTo(html2);
                base.Component.Ace.Button().Text("清空").IconCls("fa fa-remove")
                .Click("AX.gridClr('#" + base.Component.For + "','#" + base.Component.Id + "')")
                .AppendTo(html2);
            }
            if (base.Component.Tools.Any())
            {
                IHtmlNode right = new HtmlNode("div").AddClass("fr").AppendTo(html);
                base.Component.Tools.Each(delegate(IHtmlContent tool)
                {
                    new LiteralNode(tool.ToHtml()).AppendTo(right);
                });
            }
        }
Exemple #52
0
        private void AppendPopupEditor(IHtmlNode container, GridRenderingData renderingData)
        {
            var popup     = Editable.PopUp;
            var cancelUrl = renderingData.UrlBuilder.CancelUrl(null);

            new WindowBuilder(popup)
            .Content(renderingData.PopUpContainer.InnerHtml)
            //TODO: Add positioning of the window
            //.HtmlAttributes(new { style = "top:10%;left:50%;margin-left: -" + (popup.Width == 0 ? 360 : popup.Width) / 4 + "px" })
            .HtmlAttributes(new { @class = UIPrimitives.Grid.PopupEditForm })
            .Actions(buttons => buttons
                     .Close()
                     );

            if (!IsClientBinding)
            {
                popup.Events["activate"] = new ClientHandlerDescriptor {
                    TemplateDelegate = obj => "function(e){this.center();}"
                };
                popup.Events["close"] = new ClientHandlerDescriptor {
                    TemplateDelegate = obj => "function(e){e.preventDefault();" + string.Format("window.location.href = \"{0}\";", cancelUrl) + "}"
                };
            }

            if (!popup.Name.HasValue())
            {
                popup.Name = Name + "PopUp";
            }

            if (popup.Title == null || (string)(popup.Title) == "")
            {
                popup.Title = CurrentItemMode == GridItemMode.Edit ? Messages.Grid_Edit : Messages.Grid_Create;
            }

            new LiteralNode(popup.ToHtmlString()).AppendTo(container);
        }
Exemple #53
0
        private void SerializeViews(IHtmlNode html)
        {
            if (component.Views.Length == 0)
            {
                return;
            }

            var output = new StringBuilder();

            output.Append("[");

            foreach (var view in component.Views)
            {
                output.Append("\"");
                output.Append(HttpUtility.HtmlAttributeEncode(view));
                output.Append("\",");
            }

            output.Remove(output.Length - 1, 1);

            output.Append("]");

            html.Attribute("data-views", output.ToString());
        }
Exemple #54
0
        protected virtual void AddAttributes(IHtmlNode link)
        {
            if (Url.HasValue())
            {
                link.Attribute("href", Url);
            }

            if (Target.HasValue())
            {
                link.Attribute("data-target", Target);
            }

            if (Rel != MobileButtonRel.None)
            {
                link.Attribute("data-rel", Rel.ToString().ToLower());

                if (Rel == MobileButtonRel.ActionSheet)
                {
                    link.Attribute("data-actionsheet-context", ActionsheetContext);
                }
            }

            link.Attributes(LinkHtmlAttributes);
        }
Exemple #55
0
        /// <summary>
        /// 添加节点的副本
        /// </summary>
        /// <param name="container">要添加副本的容器</param>
        /// <param name="index">要添加的位置</param>
        /// <param name="node">要创作副本的节点</param>
        /// <returns>添加后的节点</returns>
        public static IHtmlNode AddCopy(this IHtmlContainer container, int index, IHtmlNode node)
        {
            if (container == null)
            {
                throw new ArgumentNullException("container");
            }

            if (node == null)
            {
                throw new ArgumentNullException("node");
            }


            var textNode = node as IHtmlTextNode;

            if (textNode != null)
            {
                return(AddCopy(container, index, textNode));
            }

            var comment = node as IHtmlComment;

            if (comment != null)
            {
                return(AddCopy(container, index, comment));
            }

            var element = node as IHtmlElement;

            if (element != null)
            {
                return(AddCopy(container, index, element));
            }

            throw new NotSupportedException();
        }
 protected override void ApplyDecoration(IHtmlNode htmlNode)
 {
     htmlNode.AddClass("k-grid-edit-row");
 }
Exemple #57
0
 public override IHtmlNode Execute(IHtmlNode node, XPathExpression[] ex)
 {
     return(node.GetElementsByName(Text));
 }
 /// <summary>
 /// Adds an option to the Group.
 /// </summary>
 /// <param name="Option">Node to Parse and add.</param>
 internal void AddOption(IHtmlNode Option)
 {
     _Options.Add(new RadioOption(this, Option));
 }
 internal RadioControl(HtmlForm Form, IHtmlNode Node) : base(Form, Node)
 {
     _Options = new List <ListOption>();
     AddOption(Node);
 }
Exemple #60
0
 public IHtmlNode AppendTo(IHtmlNode parent)
 {
     parent.Children.Add(this);
     return(this);
 }