Exemple #1
0
    /// <summary>
    /// Writes the header to output.
    /// </summary>
    /// <param name="text">Header text</param>
    /// <param name="level">Header level</param>
    private void WriteHeader(string text, int level)
    {
        if (level > 6)
        {
            level = 6;
        }

        var h = new LocalizedHeading {
            Text = text, Level = level
        };

        pnlContent.Controls.Add(h);
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        // For up to 10 Gateways edit all on one page, hide UniGrid
        if (GatewayCount <= 10)
        {
            gridGateways.StopProcessing = true;
            pnlGrid.Visible             = false;
            string heading;
            string gatewayLbl = GetString("notification.template.gateway");
            bool   isRTL      = CultureHelper.IsCultureRTL(MembershipContext.AuthenticatedUser.PreferredUICultureCode);

            // Generate controls
            foreach (NotificationGatewayInfo info in mDsGateways)
            {
                if (isRTL)
                {
                    heading = HTMLHelper.HTMLEncode(ResHelper.LocalizeString(info.GatewayDisplayName)) + gatewayLbl;
                }
                else
                {
                    heading = String.Format("{0}: {1}", gatewayLbl, HTMLHelper.HTMLEncode(ResHelper.LocalizeString(info.GatewayDisplayName)));
                }
                var headingControl = new LocalizedHeading()
                {
                    Level = 4,
                    Text  = heading
                };

                Panel pnlGrouping = new Panel();
                pnlGrouping.Controls.Add(headingControl);

                TemplateTextEdit ctrl = Page.LoadUserControl("~/CMSModules/Notifications/Controls/TemplateTextEdit.ascx") as TemplateTextEdit;
                if (ctrl != null)
                {
                    ctrl.ID         = "templateEdit" + info.GatewayID;
                    ctrl.TemplateID = TemplateID;
                    ctrl.GatewayID  = info.GatewayID;

                    // Add gateway edit control to the container panel
                    pnlGrouping.Controls.Add(ctrl);
                    plcTexts.Controls.Add(pnlGrouping);
                }
            }
        }
        else
        {
            // Hook event handlers
            gridGateways.OnExternalDataBound += gridGateways_OnExternalDataBound;
            gridGateways.OnAction            += gridGateways_OnAction;
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        // For up to 10 Gateways edit all on one page, hide UniGrid
        if (GatewayCount <= 10)
        {
            gridGateways.StopProcessing = true;
            pnlGrid.Visible = false;
            string heading;
            string gatewayLbl = GetString("notification.template.gateway");
            bool isRTL = CultureHelper.IsCultureRTL(MembershipContext.AuthenticatedUser.PreferredUICultureCode);

            // Generate controls
            foreach (NotificationGatewayInfo info in mDsGateways)
            {
                if (isRTL)
                {
                    heading = HTMLHelper.HTMLEncode(ResHelper.LocalizeString(info.GatewayDisplayName)) + gatewayLbl;
                }
                else
                {
                    heading = String.Format("{0}: {1}", gatewayLbl, HTMLHelper.HTMLEncode(ResHelper.LocalizeString(info.GatewayDisplayName)));
                }
                var headingControl = new LocalizedHeading()
                {
                    Level = 4,
                    Text = heading
                };

                Panel pnlGrouping = new Panel();
                pnlGrouping.Controls.Add(headingControl);

                TemplateTextEdit ctrl = Page.LoadUserControl("~/CMSModules/Notifications/Controls/TemplateTextEdit.ascx") as TemplateTextEdit;
                if (ctrl != null)
                {
                    ctrl.ID = "templateEdit" + info.GatewayID;
                    ctrl.TemplateID = TemplateID;
                    ctrl.GatewayID = info.GatewayID;

                    // Add gateway edit control to the container panel
                    pnlGrouping.Controls.Add(ctrl);
                    plcTexts.Controls.Add(pnlGrouping);
                }
            }
        }
        else
        {
            // Hook event handlers
            gridGateways.OnExternalDataBound += gridGateways_OnExternalDataBound;
            gridGateways.OnAction += gridGateways_OnAction;
        }
    }
    /// <summary>
    /// Writes the header to output.
    /// </summary>
    /// <param name="text">Header text</param>
    /// <param name="level">Header level</param>
    private void WriteHeader(string text, int level)
    {
        if (level > 6)
        {
            level = 6;
        }

        var h = new LocalizedHeading { Text = text, Level = level };

        pnlContent.Controls.Add(h);
    }
    protected override void OnPreRender(EventArgs e)
    {
        base.OnPreRender(e);

        if (mParameters != null)
        {
            // Register JavaScript
            ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "detectTreeFrame", ScriptHelper.GetScript(InitScript()));

            Panel PanelModules = new Panel();
            Table tbl = new Table();
            tbl.CellSpacing = 10;
            TableRow tr = new TableRow();
            int actualRowIndex = 0;
            int relativeWidth = Convert.ToInt32(100 / mColumns);
            for (int i = 0; i < mParameters.Count; i++)
            {
                List<string> row = mParameters[i];
                if (row != null)
                {
                    actualRowIndex++;

                    // Initialize Image
                    Image img = new Image();
                    img.ImageUrl = UIHelper.ResolveImageUrl(row[0]);
                    img.CssClass = "PageTitleImage";

                    // Initialize Title
                    LocalizedHeading heading = new LocalizedHeading();
                    heading.Text = " " + HTMLHelper.HTMLEncode(row[1]);
                    heading.EnableViewState = false;
                    heading.Level = 4;

                    // Initialize Hyperlink
                    HyperLink h = new HyperLink();
                    h.Controls.Add(img);
                    h.Controls.Add(heading);

                    if (row.Count > 4)
                    {
                        string fullContent = "false";
                        if (row.Count > 5)
                        {
                            fullContent = row[5].ToLowerCSafe() == "true" ? "true" : "false";
                        }

                        // Ensure not-null help key
                        row[4] = row[4] ?? "";

                        // For personalized guide use code name
                        h.Attributes.Add("onclick", "ShowDesktopContent(" + ScriptHelper.GetString(row[2]) + ", " + fullContent + ", " + ScriptHelper.GetString("node_" + row[4].Replace(".", String.Empty).ToLowerCSafe()) + ");");
                    }
                    else
                    {
                        // Else use display name
                        h.Attributes.Add("onclick", "ShowDesktopContent(" + ScriptHelper.GetString(row[2]) + ", " + ScriptHelper.GetString(row[1]) + ");");
                    }
                    h.Attributes.Add("href", "#");

                    // Resolve description
                    string description = HTMLHelper.HTMLEncode(ResHelper.LocalizeString(row[3]));

                    // Initialize description
                    Label desc = new Label();
                    desc.Text = "<div>" + description + "</div>";

                    // Initialize wrapping panel
                    Panel p = new Panel();
                    p.Controls.Add(h);
                    p.Controls.Add(desc);

                    // Add style
                    p.CssClass = "Guide";

                    // Add to the table
                    TableCell td = new TableCell();

                    // Align all cells to top
                    td.VerticalAlign = VerticalAlign.Top;

                    // Add single description to table-cell
                    td.Controls.Add(p);

                    if (actualRowIndex == mColumns || (i == mParameters.Count - 1))
                    {
                        tr.Cells.Add(td);

                        // Ensure right column number for validity
                        if (i == mParameters.Count - 1)
                        {
                            for (int d = 0; d < (mColumns - (mParameters.Count % mColumns)); d++)
                            {
                                tr.Cells.Add(new TableCell());
                            }
                        }

                        // Add to table
                        tbl.Rows.Add(tr);

                        // Reset index counter
                        actualRowIndex = 0;

                        // Create new row
                        tr = new TableRow();
                    }
                    else
                    {
                        // Set relative width
                        td.Attributes.Add("style", "width:" + relativeWidth + "%;");

                        // Add to table-row
                        tr.Cells.Add(td);
                    }
                }
            }

            // Add single module description to PanelModules
            PanelModules.Controls.Add(tbl);

            // Render whole description
            plcGuide.Controls.Add(PanelModules);
        }
    }
Exemple #6
0
    protected override void OnPreRender(EventArgs e)
    {
        base.OnPreRender(e);

        if (mParameters != null)
        {
            // Register JavaScript
            ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "detectTreeFrame", ScriptHelper.GetScript(InitScript()));

            Panel PanelModules = new Panel();
            Table tbl          = new Table();
            tbl.CellSpacing = 10;
            TableRow tr             = new TableRow();
            int      actualRowIndex = 0;
            int      relativeWidth  = Convert.ToInt32(100 / mColumns);
            for (int i = 0; i < mParameters.Count; i++)
            {
                List <string> row = mParameters[i];
                if (row != null)
                {
                    actualRowIndex++;

                    // Initialize Image
                    Image img = new Image();
                    img.ImageUrl = UIHelper.ResolveImageUrl(row[0]);
                    img.CssClass = "PageTitleImage";

                    // Initialize Title
                    LocalizedHeading heading = new LocalizedHeading();
                    heading.Text            = " " + HTMLHelper.HTMLEncode(row[1]);
                    heading.EnableViewState = false;
                    heading.Level           = 4;


                    // Initialize Hyperlink
                    HyperLink h = new HyperLink();
                    h.Controls.Add(img);
                    h.Controls.Add(heading);

                    if (row.Count > 4)
                    {
                        string fullContent = "false";
                        if (row.Count > 5)
                        {
                            fullContent = row[5].ToLowerCSafe() == "true" ? "true" : "false";
                        }

                        // Ensure not-null help key
                        row[4] = row[4] ?? "";

                        // For personalized guide use code name
                        h.Attributes.Add("onclick", "ShowDesktopContent(" + ScriptHelper.GetString(row[2]) + ", " + fullContent + ", " + ScriptHelper.GetString("node_" + row[4].Replace(".", String.Empty).ToLowerCSafe()) + ");");
                    }
                    else
                    {
                        // Else use display name
                        h.Attributes.Add("onclick", "ShowDesktopContent(" + ScriptHelper.GetString(row[2]) + ", " + ScriptHelper.GetString(row[1]) + ");");
                    }
                    h.Attributes.Add("href", "#");

                    // Resolve description
                    string description = HTMLHelper.HTMLEncode(ResHelper.LocalizeString(row[3]));

                    // Initialize description
                    Label desc = new Label();
                    desc.Text = "<div>" + description + "</div>";

                    // Initialize wrapping panel
                    Panel p = new Panel();
                    p.Controls.Add(h);
                    p.Controls.Add(desc);

                    // Add style
                    p.CssClass = "Guide";

                    // Add to the table
                    TableCell td = new TableCell();

                    // Align all cells to top
                    td.VerticalAlign = VerticalAlign.Top;

                    // Add single description to table-cell
                    td.Controls.Add(p);

                    if (actualRowIndex == mColumns || (i == mParameters.Count - 1))
                    {
                        tr.Cells.Add(td);

                        // Ensure right column number for validity
                        if (i == mParameters.Count - 1)
                        {
                            for (int d = 0; d < (mColumns - (mParameters.Count % mColumns)); d++)
                            {
                                tr.Cells.Add(new TableCell());
                            }
                        }

                        // Add to table
                        tbl.Rows.Add(tr);

                        // Reset index counter
                        actualRowIndex = 0;

                        // Create new row
                        tr = new TableRow();
                    }
                    else
                    {
                        // Set relative width
                        td.Attributes.Add("style", "width:" + relativeWidth + "%;");

                        // Add to table-row
                        tr.Cells.Add(td);
                    }
                }
            }

            // Add single module description to PanelModules
            PanelModules.Controls.Add(tbl);

            // Render whole description
            plcGuide.Controls.Add(PanelModules);
        }
    }
    /// <summary>
    /// Creates table.
    /// </summary>
    private void CreateTable()
    {
        pnlCustomProperties.Controls.Clear();

        Table            table     = new Table();
        TableRow         row       = new TableRow();
        TableCell        labelCell = new TableCell();
        TableCell        valueCell = new TableCell();
        LocalizedHeading heading   = new LocalizedHeading();

        // Prepare title
        pnlCustomProperties.Controls.Add(table);
        heading.ResourceString  = "com.productedit.customproperties";
        heading.Level           = 5;
        heading.EnableViewState = false;
        labelCell.Controls.Add(heading);
        row.Cells.Add(labelCell);
        row.Cells.Add(valueCell);
        table.Rows.Add(row);

        // Create row for each field
        foreach (FormFieldInfo field in CustomProperties)
        {
            string value = null;
            row = new TableRow();
            Label           label      = new Label();
            CMSDropDownList drpColumns = new CMSDropDownList();

            // Get value
            if (dci != null)
            {
                value = ValidationHelper.GetString(dci.SKUMappings[field.Name], "0");
            }

            // Prepare caption
            string caption = field.GetPropertyValue(FormFieldPropertyEnum.FieldCaption, MacroContext.CurrentResolver);
            if (string.IsNullOrEmpty(caption))
            {
                caption = field.Name;
            }
            label.Text = HTMLHelper.HTMLEncode(ResHelper.LocalizeString(caption) + ResHelper.Colon);

            // Create cell with label
            labelCell = new TableCell();
            labelCell.Controls.Add(label);
            labelCell.CssClass = "FieldLabel";
            labelCell.Style.Add("width", "175px");
            row.Cells.Add(labelCell);

            // Create cell with drop down list
            valueCell = new TableCell();
            valueCell.Controls.Add(drpColumns);

            // Fill drop down list with values
            FillDropDownList(drpColumns);
            drpColumns.SelectedValue = value;
            drpColumns.CssClass      = "DropDownField";
            drpColumns.ID            = field.Name + "FieldName";

            row.Cells.Add(valueCell);

            // Add row to the table
            table.Rows.Add(row);
        }
    }