Beispiel #1
0
        private Control CreateChildItems(Micajah.Common.Bll.Action item)
        {
            HtmlGenericControl div = null;

            if (item.ShowChildrenInDetailMenu)
            {
                ActionCollection availableChildActions = item.GetAvailableChildActions(m_ActionIdList, m_IsFrameworkAdmin, m_IsAuthenticated);
                if (availableChildActions.Count > 0)
                {
                    ControlList list = null;
                    try
                    {
                        div = new HtmlGenericControl("div");
                        div.Attributes["class"] = "C";
                        list           = new ControlList();
                        list.Delimiter = ", ";

                        foreach (Micajah.Common.Bll.Action childItem in availableChildActions)
                        {
                            if (list.Count < MaxChildItems)
                            {
                                list.Add(CreateItemLink(childItem));
                            }
                            else
                            {
                                list.Add(CreateItemLink(item, Resources.DetailMenu_Ellipsis, false));
                                break;
                            }
                        }

                        div.Controls.Add(list);
                    }
                    finally
                    {
                        if (div != null)
                        {
                            div.Dispose();
                        }
                        if (list != null)
                        {
                            list.Dispose();
                        }
                    }
                }
            }
            return(div);
        }
Beispiel #2
0
        /// <summary>
        /// Creates child controls.
        /// </summary>
        protected override void CreateChildControls()
        {
            this.Controls.Clear();

            if (this.Items.Count == 0)
            {
                return;
            }

            HtmlGenericControl mainContainer  = null;
            HtmlGenericControl container      = null;
            HtmlGenericControl innerContainer = null;
            HtmlGenericControl bar            = null;
            HtmlGenericControl ul             = null;
            HtmlGenericControl p           = null;
            ControlList        controlList = null;
            Control            itemLink    = null;
            Guid mainMenuItemId            = this.SelectedActionId;

            try
            {
                mainContainer = new HtmlGenericControl("div");
                mainContainer.Attributes["class"] = "Mp_Mm";
                this.Controls.Add(mainContainer);

                MasterPageTheme theme = FrameworkConfiguration.Current.WebApplication.MasterPage.Theme;

                switch (theme)
                {
                case MasterPageTheme.Gradient:
                case MasterPageTheme.StandardTabs:
                case MasterPageTheme.Modern:
                    ul = new HtmlGenericControl("ul");

                    string cssClass = null;

                    if (theme == MasterPageTheme.Modern)
                    {
                        p = new HtmlGenericControl("p");
                        p.Attributes["class"] = "mobile-nav";
                        p.InnerHtml           = Resources.MainMenu_MenuLink_Text;

                        innerContainer = new HtmlGenericControl("div");
                        innerContainer.Attributes["class"] = "col-sm-12";
                        innerContainer.Controls.Add(p);
                        innerContainer.Controls.Add(ul);

                        container = new HtmlGenericControl("div");
                        container.Attributes["class"] = "container";
                        container.Controls.Add(innerContainer);

                        mainContainer.Controls.Add(container);

                        cssClass = "active";
                    }
                    else
                    {
                        mainContainer.Controls.Add(ul);

                        cssClass = "S";
                    }

                    foreach (Micajah.Common.Bll.Action item in this.Items)
                    {
                        if (item.ActionId == ActionProvider.StartPageActionId)
                        {
                            bool redirect = false;

                            Micajah.Common.WebControls.AdminControls.StartControl.GetStartMenuCheckedItems(m_UserContext, out redirect);

                            if (redirect)
                            {
                                continue;
                            }
                        }

                        ul.Controls.Add(CreateLinkAsListItem(item, ((item.ActionId == mainMenuItemId) ? cssClass : null)));
                    }

                    if (theme != MasterPageTheme.Modern)
                    {
                        bar = new HtmlGenericControl("div");
                        bar.Attributes["class"] = "Mp_Mmb";

                        this.Controls.Add(bar);
                    }
                    break;

                case MasterPageTheme.Standard:
                    controlList           = new ControlList();
                    controlList.Delimiter = " &nbsp; | &nbsp; ";

                    foreach (Micajah.Common.Bll.Action item in this.Items)
                    {
                        if (item.ActionId == ActionProvider.StartPageActionId)
                        {
                            bool redirect = false;

                            Micajah.Common.WebControls.AdminControls.StartControl.GetStartMenuCheckedItems(m_UserContext, out redirect);

                            if (redirect)
                            {
                                continue;
                            }
                        }

                        itemLink = Submenu.CreateLink(item, ((item.ActionId == mainMenuItemId) ? "S" : null), false);

                        controlList.Add(itemLink);
                    }

                    mainContainer.Controls.Add(controlList);
                    break;
                }
            }
            finally
            {
                if (ul != null)
                {
                    ul.Dispose();
                }

                if (mainContainer != null)
                {
                    mainContainer.Dispose();
                }

                if (bar != null)
                {
                    bar.Dispose();
                }

                if (container != null)
                {
                    container.Dispose();
                }

                if (innerContainer != null)
                {
                    innerContainer.Dispose();
                }

                if (p != null)
                {
                    p.Dispose();
                }

                if (controlList != null)
                {
                    controlList.Dispose();
                }

                if (itemLink != null)
                {
                    itemLink.Dispose();
                }
            }
        }
Beispiel #3
0
        /// <summary>
        /// Creates the global navigation links.
        /// </summary>
        /// <param name="isSecureConnection">The flag indicating whether the HTTP connection uses secure sockets.</param>
        /// <returns>The control that represents the global navigation links.</returns>
        private Control CreateGlobalNavigation(bool isSecureConnection)
        {
            ControlList        links = null;
            HyperLink          link  = null;
            HyperLink          link2 = null;
            HtmlGenericControl ul    = null;
            HtmlGenericControl ul2   = null;
            HtmlGenericControl li    = null;
            HtmlGenericControl li2   = null;

            try
            {
                if (m_ModernTheme)
                {
                    ul = new HtmlGenericControl("ul");
                    ul.Attributes["class"] = "nav pull-right";
                }
                else
                {
                    links = new ControlList();
                }

                Micajah.Common.Bll.ActionCollection items = ActionProvider.GlobalNavigationLinks.FindByActionId(ActionProvider.GlobalNavigationLinksActionId).GetAvailableChildActions(m_ActionIdList, m_IsFrameworkAdmin, m_IsAuthenticated);

                if (m_ModernTheme)
                {
                    li = (HtmlGenericControl)CreateApplicationLogoListItem("Al");

                    ul.Controls.Add(li);
                }
                else
                {
                    Micajah.Common.Bll.Action item = items.FindByActionId(ActionProvider.MyAccountMenuGlobalNavigationLinkActionId);

                    if (item != null)
                    {
                        Micajah.Common.Bll.ActionCollection items2 = item.GetAvailableChildActions(m_ActionIdList, m_IsFrameworkAdmin, m_IsAuthenticated);

                        items.AddRange(items2);

                        items.Sort();
                    }
                }

                foreach (Micajah.Common.Bll.Action item in items)
                {
                    link             = new HyperLink();
                    link.NavigateUrl = item.CustomAbsoluteNavigateUrl;
                    link.ToolTip     = item.Description;

                    if (m_ModernTheme)
                    {
                        li = new HtmlGenericControl("li");

                        string iconUrl  = null;
                        string text     = item.CustomName;
                        string cssClass = "Icon";

                        if (item.ActionId == ActionProvider.MyAccountMenuGlobalNavigationLinkActionId)
                        {
                            iconUrl = string.Format(CultureInfo.InvariantCulture, "{0}{1}www.gravatar.com/avatar/{2}?s=24"
                                                    , (isSecureConnection ? Uri.UriSchemeHttps : Uri.UriSchemeHttp), Uri.SchemeDelimiter, Support.CalculateMD5Hash(m_UserContext.Email.ToLowerInvariant()));

                            cssClass += " Avtr";
                        }
                        else
                        {
                            if (item.ActionId == ActionProvider.PageHelpGlobalNavigationLinkActionId)
                            {
                                if (!m_MasterPage.VisibleHelpLink)
                                {
                                    continue;
                                }

                                link.Attributes["onclick"] = m_MasterPage.HelpLinkOnClick;
                            }

                            if (!string.IsNullOrEmpty(item.IconUrl))
                            {
                                iconUrl = item.IconUrl;
                                if (iconUrl.IndexOf("glyphicon", StringComparison.OrdinalIgnoreCase) == -1)
                                {
                                    iconUrl = CustomUrlProvider.CreateApplicationAbsoluteUrl(iconUrl);
                                }
                                else
                                {
                                    using (Label label = new Label())
                                    {
                                        label.CssClass = "glyphicon " + iconUrl;

                                        if (string.IsNullOrEmpty(text))
                                        {
                                            label.CssClass += " no-margin";
                                        }

                                        link.Controls.Add(label);
                                    }

                                    iconUrl = null;
                                }
                            }
                        }

                        if (!string.IsNullOrEmpty(iconUrl))
                        {
                            using (Image image = new Image())
                            {
                                image.ImageUrl = iconUrl;
                                image.CssClass = cssClass;

                                link.Controls.Add(image);
                            }
                        }

                        if (!string.IsNullOrEmpty(text))
                        {
                            using (LiteralControl literal = new LiteralControl(text))
                            {
                                link.Controls.Add(literal);
                            }
                        }

                        li.Controls.Add(link);
                        ul.Controls.Add(li);

                        ActionCollection childActions = item.GetAvailableChildActions(m_ActionIdList, m_IsFrameworkAdmin, m_IsAuthenticated);
                        if (childActions.Count > 0)
                        {
                            link.CssClass = "dropdown-toggle";
                            link.Attributes["data-toggle"] = "dropdown";

                            using (Label label = new Label())
                            {
                                label.CssClass = "caret";
                                link.Controls.Add(label);
                            }

                            ul2 = new HtmlGenericControl("ul");
                            ul2.Attributes["class"] = "dropdown-menu blue";

                            foreach (Micajah.Common.Bll.Action item2 in childActions)
                            {
                                li2 = new HtmlGenericControl("li");

                                link2             = new HyperLink();
                                link2.Text        = item2.CustomName;
                                link2.NavigateUrl = item2.CustomAbsoluteNavigateUrl;
                                link2.ToolTip     = item2.Description;

                                li2.Controls.Add(link2);
                                ul2.Controls.Add(li2);
                            }

                            li.Attributes["class"] = "dropdown";
                            li.Controls.Add(ul2);
                        }
                    }
                    else
                    {
                        if (item.ActionId == ActionProvider.MyAccountMenuGlobalNavigationLinkActionId)
                        {
                            if ((m_UserContext != null) && (m_UserContext.OrganizationId == Guid.Empty))
                            {
                                continue;
                            }
                        }

                        link.Text = item.CustomName;

                        links.Add(link);
                    }
                }

                if (m_ModernTheme)
                {
                    return(ul);
                }
                else
                {
                    return((links.Count > 0) ? links : null);
                }
            }
            finally
            {
                if (ul2 != null)
                {
                    ul2.Dispose();
                }
                if (li2 != null)
                {
                    li2.Dispose();
                }
                if (ul != null)
                {
                    ul.Dispose();
                }
                if (li != null)
                {
                    li.Dispose();
                }
                if (link != null)
                {
                    link.Dispose();
                }
                if (links != null)
                {
                    links.Dispose();
                }
            }
        }