示例#1
0
 void AssignListBox(HtmlTagList source, ListBox listBox)
 {
     listBox.Items.Clear();
     foreach (HtmlTag tag in source)
     {
         listBox.Items.Add(tag.TagSource);
     }
 }
示例#2
0
        private static void AddTag(ref TagBuilder sbElements, Controller outcontroller, string htmlTitle, HtmlTagList list, IEnumerable <PartialLoad> partialLoads, string resourceHtml, Guid htmlId, bool desginemode = false)
        {
            foreach (HtmlTag htmlTag in list)
            {
                var tag = htmlTag.NextTag;
                if (tag == null)
                {
                    continue;
                }
                if (string.IsNullOrEmpty(tag.Name))
                {
                    continue;
                }
                var span = new TagBuilder(tag.Name);
                if (tag.Name == "theme" && !string.IsNullOrEmpty(resourceHtml))
                {
                    span.InnerHtml = resourceHtml;
                }
                if (tag.Name == "title")
                {
                    span.SetInnerText(htmlTitle);
                }
                if (tag.NextTag != null && tag.NextTag.IsText)
                {
                    var text = tag.NextTag.Text;
                    if (!string.IsNullOrEmpty(text.Trim()) && text.Trim() != "\r\n")
                    {
                        span.SetInnerText(text);
                    }
                }
                foreach (HtmlAttribute attribute in tag.Attributes)
                {
                    if (attribute.Name == "Radyn.Web.Parser.HtmlAttribute")
                    {
                        continue;
                    }
                    if (span.Attributes.ContainsKey(attribute.Name))
                    {
                        span.Attributes[attribute.Name] =
                            tag.Attributes.AttributeValue(attribute.Name);
                    }
                    else
                    {
                        span.Attributes.Add(attribute.Name,
                                            tag.Attributes.AttributeValue(attribute.Name));
                    }
                }
                string str;
                span.Attributes.TryGetValue("customid", out str);
                if (span.Attributes.Count > 0 && !string.IsNullOrEmpty(str))
                {
                    var attributeValue = span.Attributes["customid"];
                    var enumerable     = partialLoads.Where(load => load.CustomId == attributeValue).OrderBy(load => load.position);
                    if (enumerable.Any())
                    {
                        foreach (var partialLoad in enumerable)
                        {
                            if (desginemode)
                            {
                                var stringWriter = new StringWriter();
                                var writer       = new Html32TextWriter(stringWriter);
                                writer.AddAttribute(HtmlTextWriterAttribute.Class, "row-edit mElement");
                                writer.AddAttribute("onmouseover", "visible(this);GetDragedItem('" + partialLoad.position + "');");
                                writer.AddAttribute("onmouseout", "HideMenu(this);");
                                writer.AddAttribute("id", "row_" + partialLoad.CustomId + "_" + partialLoad.PartialId + "_" + htmlId);
                                writer.RenderBeginTag(HtmlTextWriterTag.Div);
                                writer.RenderBeginTag(HtmlTextWriterTag.Div);
                                writer.Write(partialLoad.Html);
                                writer.RenderEndTag();
                                writer.AddAttribute("id", "Order_" + partialLoad.CustomId + "_" + partialLoad.position);
                                writer.RenderBeginTag(HtmlTextWriterTag.Div);
                                writer.RenderEndTag();
                                var radynRenderActionUrl = outcontroller.RadynRenderActionUrl(
                                    "/ContentManager/UIDesginPanel/GetEditNavbar?PartialId=" + partialLoad.PartialId + "&CustomId=" + partialLoad.CustomId + "&htmlId=" + htmlId + "&PartialName=" + (partialLoad.Partials != null ? partialLoad.Partials.Title : (partialLoad.Content != null ? partialLoad.Content.Title : "")));
                                writer.Write(radynRenderActionUrl);
                                writer.RenderEndTag();
                                span.InnerHtml += stringWriter.ToString();
                            }
                            else
                            {
                                span.InnerHtml += partialLoad.Html;
                            }
                        }
                    }
                    else
                    {
                        if (desginemode)
                        {
                            span.Attributes.Add("onmouseover", "GetDragedItem('0');");
                            span.Attributes.Add("onmouseout", "HideMenu(this);");
                            var spanAttribute = "row_" + attributeValue + "_" + htmlId;
                            if (!span.Attributes.ContainsKey("id"))
                            {
                                span.Attributes.Add("id", spanAttribute);
                            }
                            else
                            {
                                span.Attributes["id"] = spanAttribute;
                            }
                            span.InnerHtml += String.Format("<div id=\"Order_{0}_0\"></div>", attributeValue);
                        }
                    }
                }

                if (tag.Tags.Count > 0)
                {
                    AddTag(ref span, outcontroller, htmlTitle, tag.Tags, partialLoads, resourceHtml, htmlId, desginemode);
                }

                sbElements.InnerHtml += span;
            }
        }