public void Render()
        {
            base.CssClass = "LinkBiServerConnection";
            this.Attributes.Add("id", "LinkBiServerConnection" + this.ServerConnection.Identity);

            Table table = new Table();

            TableRow  tableRowValid  = new TableRow();
            TableCell tableCellValid = new TableCell();

            tableCellValid.Attributes.Add("id", "LinkBiServerConnectionValid" + this.ServerConnection.Identity);
            tableCellValid.ColumnSpan = 2;

            tableRowValid.Cells.Add(tableCellValid);
            table.Rows.Add(tableRowValid);

            TableRow tableRowInterfaceType = new TableRow();

            TableCell tableCellInterfaceTypeTitle = new TableCell();
            TableCell tableCellInterfaceTypeValue = new TableCell();

            tableCellInterfaceTypeTitle.Text = base.LanguageManager.GetText("LinkBiInterfaceType");

            DropDownList ddlInterfaceType = new DropDownList();

            ddlInterfaceType.BindEnum(typeof(LinkBiInterfaceType));
            ddlInterfaceType.SelectedValue = this.ServerConnection.InterfaceType.ToString();

            ddlInterfaceType.Attributes.Add("onchange", string.Format(
                                                "UpdateServerConnectionProperty('{0}' ,'{1}', '{2}', this.value);",
                                                this.ServerConnection.Owner.FileName.Replace("\\", "/"),
                                                this.ServerConnection.XmlNode.GetXPath(),
                                                "InterfaceType"
                                                ));

            tableCellInterfaceTypeValue.Controls.Add(ddlInterfaceType);

            tableRowInterfaceType.Cells.Add(tableCellInterfaceTypeTitle);
            tableRowInterfaceType.Cells.Add(tableCellInterfaceTypeValue);

            table.Rows.Add(tableRowInterfaceType);

            TableRow tableRowType = new TableRow();

            TableCell tableCellTypeTitle = new TableCell();
            TableCell tableCellTypeValue = new TableCell();

            tableCellTypeTitle.Text = base.LanguageManager.GetText("LinkBiServerConnectionType");

            DropDownList ddlType = new DropDownList();

            ddlType.BindEnum(typeof(LinkBiServerConnectionType));
            ddlType.SelectedValue = this.ServerConnection.Type.ToString();

            ddlType.Attributes.Add("onchange", string.Format(
                                       "ChangeServerConnectionType(this, '{0}', '{1}')",
                                       this.ServerConnection.Owner.FileName.Replace("\\", "/"),
                                       this.ServerConnection.XmlNode.GetXPath()
                                       ));

            tableCellTypeValue.Controls.Add(ddlType);

            tableRowType.Cells.Add(tableCellTypeTitle);
            tableRowType.Cells.Add(tableCellTypeValue);

            table.Rows.Add(tableRowType);

            TableRow[] tableRowsConnectionProperties = this.ServerConnection.Render();

            foreach (TableRow tableRowConnectionProperties in tableRowsConnectionProperties)
            {
                table.Rows.Add(tableRowConnectionProperties);
            }

            base.Controls.Add(table);


            base.Attributes.Add("oncontextmenu", string.Format(
                                    "DeleteServerConnection(this, '{0}', '{1}');return false;",
                                    this.ServerConnection.Owner.FileName.Replace("\\", "/"),
                                    this.ServerConnection.XmlNode.GetXPath()
                                    ));

            /*base.Attributes.Add(
             *  "onmouseout",
             *  ""
             * );*/
        }
        public Panel Render(int idLanguage)
        {
            Panel pnlField = new Panel();

            pnlField.ID       = "pnlField" + this.Id;
            pnlField.CssClass = "TaxonomyStructureField BackgroundColor1";
            pnlField.Style.Add("opacity", "0.0");

            pnlField.Attributes.Add("oncontextmenu", string.Format(
                                        "DeleteField(this, '{0}');return false;",
                                        this.XmlNode.GetXPath()
                                        ));

            Table table = new Table();

            TableRow tableRow = new TableRow();

            TableCell tableCellLabel = new TableCell();
            TableCell tableCellType  = new TableCell();

            tableCellLabel.VerticalAlign = System.Web.UI.WebControls.VerticalAlign.Top;
            tableCellType.VerticalAlign  = System.Web.UI.WebControls.VerticalAlign.Top;

            TextBox txtFieldLabel = new TextBox();

            txtFieldLabel.CssClass = "BackgroundColor1";
            txtFieldLabel.Text     = this.Labels[idLanguage];

            txtFieldLabel.Attributes.Add(
                "onchange",
                "SetFieldLabel('" + this.XmlNode.GetXPath() + "', this.value)"
                );

            DropDownList ddlType = new DropDownList();

            ddlType.BindEnum(typeof(ProjectHierarchyFieldType));
            ddlType.SelectedValue = this.Type.ToString();

            ddlType.Attributes.Add(
                "onchange",
                "SetFieldType('" + this.Id + "', '" + this.XmlNode.GetXPath() + "',this.value)"
                );

            tableCellLabel.Controls.Add(txtFieldLabel);
            tableCellType.Controls.Add(ddlType);

            tableRow.Cells.Add(tableCellLabel);
            tableRow.Cells.Add(tableCellType);

            table.Rows.Add(tableRow);

            if (this.Type == ProjectHierarchyFieldType.Single || this.Type == ProjectHierarchyFieldType.Multi)
            {
                tableCellLabel.RowSpan = this.Values.Count + 2;
                tableCellType.RowSpan  = tableCellLabel.RowSpan;

                // Run through all values of the field.
                foreach (ProjectHierarchyFieldValue value in this.Values.Values)
                {
                    TableRow tableRowValue = new TableRow();

                    TableCell tableCellValue = new TableCell();

                    tableCellValue.Attributes.Add("oncontextmenu", string.Format(
                                                      "DeleteFieldValue(this, '{0}');return false;",
                                                      value.XmlNode.GetXPath()
                                                      ));

                    TextBox txtValueLabel = new TextBox();
                    txtValueLabel.CssClass = "BackgroundColor1";

                    txtValueLabel.Attributes.Add(
                        "onchange",
                        "SetFieldValueLabel('" + value.XmlNode.GetXPath() + "', this.value)"
                        );

                    txtValueLabel.Text = value.Labels[idLanguage];

                    tableCellValue.Controls.Add(txtValueLabel);

                    tableRowValue.Cells.Add(tableCellValue);

                    table.Rows.Add(tableRowValue);
                }

                TableRow  tableRowNewFieldValue  = new TableRow();
                TableCell tableCellNewFieldValue = new TableCell();

                Image imgNewFieldValue = new Image();
                imgNewFieldValue.ImageUrl = "/Images/Icons/Add2.png";
                imgNewFieldValue.Style.Add("cursor", "pointer");
                imgNewFieldValue.Attributes.Add("onclick", string.Format(
                                                    "AddFieldValue('{0}', '{1}');",
                                                    this.Id,
                                                    this.XmlNode.GetXPath()
                                                    ));

                tableCellNewFieldValue.Controls.Add(imgNewFieldValue);

                tableRowNewFieldValue.Cells.Add(tableCellNewFieldValue);

                table.Rows.Add(tableRowNewFieldValue);
            }

            pnlField.Controls.Add(table);

            return(pnlField);
        }
Ejemplo n.º 3
0
        public void Render()
        {
            base.Controls.Clear();

            // Check if a post back was made from this filter category operator.
            if (HttpContext.Current.Request.Params["__EVENTARGUMENT"] == this.XmlNode.GetXPath())
            {
                Guid idCategory = Guid.Parse(
                    HttpContext.Current.Request.Params["__EVENTTARGET"].Replace("CategorySelectorCategory", "")
                    );

                if (this.FilterCategories.Find(x => x.IdCategory == idCategory) == null)
                {
                    this.XmlNode.InnerXml += string.Format(
                        "<Category Id=\"{0}\"></Category>",
                        idCategory
                        );

                    this.Owner.Owner.ClearData();
                    this.Owner.Owner.Save();

                    Parse();
                }
            }

            if (HttpContext.Current.Request.Params["__EVENTTARGET"] != null &&
                HttpContext.Current.Request.Params["__EVENTTARGET"].EndsWith("lnkNewOperator" + this.Identity))
            {
                this.XmlNode.InnerXml += string.Format(
                    "<Operator Id=\"{0}\" Type=\"AND\"></Operator>",
                    Guid.NewGuid()
                    );

                this.Owner.Owner.Save();

                Parse();
            }

            // Create a new panel for the result.
            Panel result = new Panel();

            result.ID = "pnlFilterCategoryOperator" + this.Identity;

            result.PreRender += result_PreRender;

            Table    table    = new Table();
            TableRow tableRow = new TableRow();

            TableCell tableCellSelector = new TableCell();
            TableCell tableCellElements = new TableCell();

            tableCellSelector.Style.Add("width", "1px");

            // Set the css class of the result panel.
            result.CssClass = "FilterOperator FilterOperator" + this.Type;

            if (this.Level % 2 == 1)
            {
                result.CssClass += " BackgroundColor9";
            }
            else
            {
                result.CssClass += " BackgroundColor1";
            }

            if (this.Parent != null)
            {
                Image imgDeleteFilterCategoryOperator = new Image();
                imgDeleteFilterCategoryOperator.Style.Add("cursor", "pointer");
                imgDeleteFilterCategoryOperator.ID       = "imgDeleteFilterCategoryOperator" + this.Identity;
                imgDeleteFilterCategoryOperator.CssClass = "DeleteFilterCategoryOperator";
                imgDeleteFilterCategoryOperator.ImageUrl = "/Images/Icons/Delete2.png";
                //imgDeleteFilterCategoryOperator.Click += imgDeleteFilterCategoryOperator_Click;
                imgDeleteFilterCategoryOperator.Attributes.Add("onclick", string.Format(
                                                                   "DeleteFilterCategoryOperator('{0}', '{1}')",
                                                                   this.FileName,
                                                                   this.XmlNode.GetXPath()
                                                                   ));

                tableCellElements.Controls.Add(imgDeleteFilterCategoryOperator);
            }

            // Create a new drop down list for the filter operator's type.
            DropDownList ddlType = new DropDownList();

            ddlType.ID       = "DropDownListType" + this.Identity;
            ddlType.CssClass = "DropDownListType";
            ddlType.BindEnum(typeof(FilterCategoryOperatorType));
            ddlType.SelectedValue = this.Type.ToString();
            ddlType.AutoPostBack  = false;

            ddlType.Attributes.Add(
                "onchange",
                string.Format(
                    "ChangeFilterCategoryOperator('{0}', '{1}',this.value);",
                    this.FileName,
                    this.XmlNode.GetXPath()
                    )
                );

            if (this.FilterCategories.Count > 0)
            {
                ddlType.CssClass = "DropDownListCategoriesType";
                tableCellElements.Controls.Add(ddlType);
            }
            else
            {
                // Add the type drop down list to the result panel's controls.
                tableCellSelector.Controls.Add(ddlType);
            }

            // Run through all filter categories of the filter category operator.
            foreach (FilterCategory filterCategory in this.FilterCategories)
            {
                // Render the filter category and
                // add it to the result panel's controls.
                tableCellElements.Controls.Add(
                    filterCategory.RenderControl()
                    );
            }

            int i = 0;

            // Run through all child filter category operators.
            foreach (FilterCategoryOperator filterCategoryOperator in this.FilterCategoryOperators)
            {
                // Set the child filter category operator's on change event handler.
                filterCategoryOperator.OnChange = this.OnChange;

                // Render the child filter category operator and
                // add it to the result panel's controls.
                tableCellElements.Controls.Add(
                    filterCategoryOperator
                    );

                filterCategoryOperator.Render();
            }

            if (this.FilterCategoryOperators.Count == 0 && this.Parent != null)
            {
                /*CategorySelector selector = new CategorySelector(this.Owner.Owner, this.FileName);
                 * selector.ID = "FilterCategorySelector" + this.Identity;
                 * selector.XPath = this.XmlNode.GetXPath();
                 *
                 * tableCellElements.Controls.Add(selector);
                 *
                 * selector.Render();*/
                Image imgNewCategory = new Image();
                imgNewCategory.ImageUrl = "/Images/Icons/Add2.png";
                imgNewCategory.Style.Add("cursor", "pointer");

                imgNewCategory.Attributes.Add(
                    "onclick",
                    "EnableFilterCategorySearch(this, '" + this.FileName + "', '" + this.XmlNode.GetXPath() + "')"
                    );

                tableCellElements.Controls.Add(imgNewCategory);
            }

            if (this.FilterCategories.Count == 0)
            {
                System.Web.UI.WebControls.LinkButton lnkNewOperator = new System.Web.UI.WebControls.LinkButton();
                lnkNewOperator.ID       = "lnkNewOperator" + this.Identity;
                lnkNewOperator.Text     = (this.FilterCategoryOperators.Count == 0 && this.Parent != null ? "<br />" : "") + base.LanguageManager.GetText("AddFilterOperator");
                lnkNewOperator.CssClass = "NewFilterOperator";
                //lnkNewOperator.Click += lnkNewOperator_Click;

                lnkNewOperator.Attributes.Add("href", string.Format(
                                                  "javascript:AddFilterCategoryOperator('{0}', '{1}');",
                                                  this.FileName,
                                                  this.XmlNode.GetXPath()
                                                  ));

                tableCellElements.Controls.Add(lnkNewOperator);
            }

            tableRow.Cells.Add(tableCellSelector);
            tableRow.Cells.Add(tableCellElements);

            table.Rows.Add(tableRow);

            result.Controls.Add(table);

            base.Controls.Add(result);
        }