Пример #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        var imageTags =
            from iconHandle in IconResourceSystemFacade.GetAllIconHandles()
            orderby iconHandle.ResourceNamespace, iconHandle.ResourceName
       select new XElement("div",
                           new XAttribute("class", "iconcontainer"),
                           new XElement("img",
                                        new XAttribute("src", BuildImgUrl(iconHandle))),
                           new XElement("span",
                                        new XAttribute("class", "iconnamespace"),
                                        new XText(iconHandle.ResourceNamespace)),
                           new XElement("span",
                                        new XAttribute("class", "iconname"),
                                        new XText(iconHandle.ResourceName))
                           );

        XElement imageContainer =
            new XElement("div",
                         new XAttribute("class", "iconscontainer " + IconSize.SelectedValue),
                         imageTags);

        IconPlaceHolder.Controls.Add(new LiteralControl(imageContainer.ToString()));
    }
Пример #2
0
        private Element CreateElement(SimpleVirtualElement simpleElementNode)
        {
            EntityToken entityToken = new VirtualElementProviderEntityToken(_context.ProviderName, simpleElementNode.Name);

            Element element = new Element(_context.CreateElementHandle(entityToken))
            {
                TagValue   = simpleElementNode.Tag,
                VisualData = new ElementVisualizedData
                {
                    Label       = StringResourceSystemFacade.ParseString(simpleElementNode.Label),
                    HasChildren = true // fixing refresh problem easy way... was: HasChildren(baseElementNode)
                }
            };



            Action <IEnumerable> collectProviders = null;

            // Recursively searching for attached providers
            var attachedProviders = new List <AttachProviderVirtualElement>();

            collectProviders = currentElements =>
            {
                attachedProviders.AddRange(currentElements.OfType <AttachProviderVirtualElement>());
                currentElements.OfType <SimpleVirtualElement>().ForEach(e => collectProviders(e.Elements));
            };
            collectProviders(simpleElementNode.Elements);


            foreach (var attachedProvider in attachedProviders)
            {
                if (ElementFacade.ContainsLocalizedData(new ElementProviderHandle(attachedProvider.ProviderName)))
                {
                    element.IsLocaleAware = true;
                }
            }


            if (element.VisualData.HasChildren)
            {
                ResourceHandle openHandle  = IconResourceSystemFacade.GetResourceHandle(simpleElementNode.OpenFolderIconName);
                ResourceHandle closeHandle = IconResourceSystemFacade.GetResourceHandle(simpleElementNode.CloseFolderIconName);

                closeHandle = closeHandle ?? openHandle;
                openHandle  = openHandle ?? closeHandle;

                if (openHandle == null)
                {
                    openHandle  = CommonElementIcons.Folder;
                    closeHandle = CommonElementIcons.FolderOpen;
                }

                element.VisualData.Icon       = openHandle;
                element.VisualData.OpenedIcon = closeHandle;
            }
            else
            {
                element.VisualData.Icon = CommonElementIcons.FolderDisabled;
            }


            return(element);
        }