Exemple #1
0
        private MenuItem PopulateMenuItem(ScriptLI li)
        {
            MenuItem item = new MenuItem();

            if (!li.IsListItem)
            {
                item.Text = li.Text;
            }
            else
            {
                ScreenViewer.API.Elements.LinkController controller = new ScreenViewer.API.Elements.LinkController();
                var scriptLink   = controller.GetScriptLink(Convert.ToDecimal(li.ElementID));
                var linkResponse = scriptLink as OkNegotiatedContentResult <Data.ScriptLink>;

                if (linkResponse.Content.LinkType == "Web")
                {
                    item.Text = linkResponse.Content.LinkDesc;
                    item.Url  = linkResponse.Content.LinkURL;

                    if (linkResponse.Content.LinkNewWindow.Equals(true))
                    {
                        item.LinkHtmlAttributes.Add("target", "_blank");
                    }
                }

                if (linkResponse.Content.LinkType == "Workflow")
                {
                    item.Text = linkResponse.Content.LinkDesc;
                    item.Action("DisplayByUniqueName", "Workflow", new { id = linkResponse.Content.LinkTypeID });

                    if (linkResponse.Content.LinkNewWindow.Equals(true))
                    {
                        item.HtmlAttributes.Add("target", "_blank");
                    }

                    //item.HtmlAttributes.Add("onclick", "$('#myForm #btnSave').click();");
                }

                if (linkResponse.Content.LinkType == "Section")
                {
                    item.Text = linkResponse.Content.LinkDesc;
                    item.Action("DisplayByUniqueName", "Section", new { id = linkResponse.Content.LinkTypeID });

                    if (linkResponse.Content.LinkNewWindow.Equals(true))
                    {
                        item.HtmlAttributes.Add("target", "_blank");
                    }
                }
            }

            if (li.theUL != null && li.theUL.LIArray.Length > 0)
            {
                foreach (ScriptLI cli in li.theUL.LIArray)
                {
                    item.Items.Add(PopulateMenuItem(cli));
                }
            }

            return(item);
        }
Exemple #2
0
        private string PopulateLItem(ScriptLI li)
        {
            StringWriter stringWriter = new StringWriter();

            if (!li.IsListItem)
            {
                using (HtmlTextWriter writer = new HtmlTextWriter(stringWriter))
                {
                    writer.AddAttribute(HtmlTextWriterAttribute.Class, "dropdown");
                    writer.RenderBeginTag(HtmlTextWriterTag.Li);

                    writer.AddAttribute(HtmlTextWriterAttribute.Class, "dropdown-toggle");
                    writer.AddAttribute("data-toggle", "dropdown");
                    writer.AddAttribute("role", "button");
                    writer.AddAttribute("aria - haspopup", "true");
                    writer.AddAttribute("aria-expanded", "false");
                    writer.RenderBeginTag(HtmlTextWriterTag.A);
                    writer.Write(li.Text);
                    writer.AddAttribute(HtmlTextWriterAttribute.Class, "caret");
                    writer.RenderBeginTag(HtmlTextWriterTag.Span);
                    writer.RenderEndTag(); // end span
                    writer.RenderEndTag(); // end A


                    writer.AddAttribute(HtmlTextWriterAttribute.Class, "dropdown-menu");
                    writer.RenderBeginTag(HtmlTextWriterTag.Ul); // Begin #1

                    foreach (ScriptLI items in li.theUL.LIArray)
                    {
                        writer.Write(PopulateLItem(items));
                    }

                    writer.RenderEndTag();

                    writer.RenderEndTag(); // end Li

                    return(stringWriter.ToString());
                }
            }

            ScreenViewer.API.Elements.LinkController controller = new ScreenViewer.API.Elements.LinkController();
            var scriptLink   = controller.GetScriptLink(Convert.ToDecimal(li.ElementID));
            var linkResponse = scriptLink as OkNegotiatedContentResult <ScriptLink>;


            using (HtmlTextWriter writer = new HtmlTextWriter(stringWriter))
            {
                writer.AddAttribute(HtmlTextWriterAttribute.Class, "nav-item");
                writer.RenderBeginTag(HtmlTextWriterTag.Li); // Begin #1

                if (linkResponse.Content.LinkType == "Web")
                {
                    writer.AddAttribute(HtmlTextWriterAttribute.Href, linkResponse.Content.LinkURL);
                }

                if (linkResponse.Content.LinkType == "Workflow")
                {
                    writer.AddAttribute(HtmlTextWriterAttribute.Href, "/Workflow/Display/" + linkResponse.Content.LinkTypeID.ToString());
                }


                if (linkResponse.Content.LinkType == "Section")
                {
                    writer.AddAttribute(HtmlTextWriterAttribute.Href, "/Section/DefaultWithLayout/" + linkResponse.Content.LinkTypeID.ToString());
                }

                if (linkResponse.Content.LinkNewWindow.Equals(true))
                {
                    writer.AddAttribute("target", "_blank");
                }

                writer.AddAttribute(HtmlTextWriterAttribute.Class, "nav-link");

                writer.RenderBeginTag(HtmlTextWriterTag.A);

                writer.Write(linkResponse.Content.LinkDesc);

                writer.RenderEndTag();
                writer.RenderEndTag();

                return(stringWriter.ToString());
            }
        }