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>");
        }
        protected void EditCondition(ClientPipelineArgs args)
        {
            Assert.ArgumentNotNull(args, "args");
            if (string.IsNullOrEmpty(args.Parameters["id"]))
            {
                SheerResponse.Alert("Please select a rule", new string[0]);
                return;
            }
            string str = ID.Decode(args.Parameters["id"]).ToString();

            if (args.IsPostBack)
            {
                if (args.HasResult)
                {
                    string   result   = args.Result;
                    XElement xElement = XElement.Parse(result).Element("rule");
                    XElement rulesSet = this.RulesSet;
                    if (xElement != null)
                    {
                        XElement xElement1 = (
                            from node in rulesSet.Elements("rule")
                            where node.GetAttributeValue("uid") == str
                            select node).FirstOrDefault <XElement>();
                        if (xElement1 != null)
                        {
                            xElement1.ReplaceWith(xElement);
                            this.RulesSet = rulesSet;
                            SheerResponse.SetInnerHtml(string.Concat(args.Parameters["id"], "_rule"), PersonalizationFormWithActions.GetRuleConditionsHtml(xElement));
                        }
                    }
                }
                return;
            }
            RulesEditorOptions rulesEditorOption = new RulesEditorOptions()
            {
                IncludeCommon = true,
                RulesPath     = "/sitecore/system/settings/Rules/Conditional Renderings",
                AllowMultiple = false
            };
            RulesEditorOptions rulesEditorOption1 = rulesEditorOption;
            XElement           xElement2          = (
                from node in this.RulesSet.Elements("rule")
                where node.GetAttributeValue("uid") == str
                select node).FirstOrDefault <XElement>();

            if (xElement2 != null)
            {
                rulesEditorOption1.Value = string.Concat("<ruleset>", xElement2, "</ruleset>");
            }
            // rulesEditorOption1.HideActions = true;  // FIRST CHANGE
            SheerResponse.ShowModalDialog(rulesEditorOption1.ToUrlString().ToString(), "580px", "712px", string.Empty, true);
            args.WaitForPostBack();
        }