private string GetRuleSectionHtml(XElement rule)
        {
            Assert.ArgumentNotNull(rule, "rule");
            HtmlTextWriter htmlTextWriter = new HtmlTextWriter(new StringWriter());
            string         str            = ShortID.Parse(rule.GetAttributeValue("uid")).ToString();

            htmlTextWriter.Write("<table id='{ID}_body' cellspacing='0' cellpadding='0' class='rule-body'>");
            htmlTextWriter.Write("<tbody>");
            htmlTextWriter.Write("<tr>");
            htmlTextWriter.Write("<td class='left-column'>");
            this.RenderRuleConditions(rule, htmlTextWriter);
            htmlTextWriter.Write("</td>");
            htmlTextWriter.Write("<td class='right-column'>");
            this.RenderRuleActions(rule, htmlTextWriter);
            htmlTextWriter.Write("</td>");
            htmlTextWriter.Write(this.RenderRulePlaceholder("afterAction", rule));
            htmlTextWriter.Write("</tr>");
            htmlTextWriter.Write("</tbody>");
            htmlTextWriter.Write("</table>");
            string str1 = htmlTextWriter.InnerWriter.ToString().Replace("{ID}", str);
            bool   flag = PersonalizationFormWithActions.IsDefaultCondition(rule);

            CollapsiblePanelRenderer.ActionsContext actionsMenu = new CollapsiblePanelRenderer.ActionsContext()
            {
                IsVisible = !flag
            };
            if (!flag)
            {
                actionsMenu.OnActionClick = "javascript:return Sitecore.CollapsiblePanel.showActionsMenu(this,event)";
                actionsMenu.Menu          = this.GetActionsMenu(str);
            }
            string attributeValue = "Default";

            if (!flag || !string.IsNullOrEmpty(rule.GetAttributeValue("name")))
            {
                attributeValue = rule.GetAttributeValue("name");
            }
            CollapsiblePanelRenderer.NameContext nameContext = new CollapsiblePanelRenderer.NameContext(attributeValue)
            {
                Editable      = !flag,
                OnNameChanged = "javascript:return Sitecore.CollapsiblePanel.renameComplete(this,event)"
            };
            CollapsiblePanelRenderer.NameContext nameContext1             = nameContext;
            CollapsiblePanelRenderer             collapsiblePanelRenderer = new CollapsiblePanelRenderer()
            {
                CssClass = "rule-container"
            };

            return(collapsiblePanelRenderer.Render(str, str1, nameContext1, actionsMenu));
        }
        private void RenderRules()
        {
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.Append("<div id='non-default-container'>");
            foreach (XElement xElement in this.RulesSet.Elements("rule"))
            {
                if (PersonalizationFormWithActions.IsDefaultCondition(xElement))
                {
                    stringBuilder.Append("</div>");
                }
                stringBuilder.Append(this.GetRuleSectionHtml(xElement));
            }
            this.RulesContainer.InnerHtml = stringBuilder.ToString();
        }
        private void RenderRuleConditions(XElement rule, HtmlTextWriter writer)
        {
            Assert.ArgumentNotNull(rule, "rule");
            Assert.ArgumentNotNull(writer, "writer");
            bool flag = PersonalizationFormWithActions.IsDefaultCondition(rule);

            if (!flag)
            {
                Button button = new Button()
                {
                    Header  = Translate.Text("Edit rule"),
                    ToolTip = Translate.Text("Edit this rule"),
                    Class   = "scButton edit-button",
                    Click   = "EditConditionClick(\\\"{ID}\\\")"
                };
                writer.Write(HtmlUtil.RenderControl(button));
            }
            writer.Write(string.Concat("<div id='{ID}_rule' class='", (!flag ? "condition-container" : "condition-container default"), "'>"));
            writer.Write((flag ? this.ConditionDescriptionDefault : PersonalizationFormWithActions.GetRuleConditionsHtml(rule)));
            writer.Write("</div>");
        }