Esempio n. 1
0
        /// <summary>
        /// 解析操作
        /// </summary>
        /// <param name="element"></param>
        /// <param name="bundle"></param>
        /// <returns></returns>
        protected override void OnResolver(XElement element, IBundle bundle)
        {
            // 检查是否符合规范,并起始于ribbon节点
            if (!element.Name.LocalName.Equals("ribbon"))
            {
                return;
            }
            // 检查ribbon子节点,有且仅有一个tabs节点
            IEnumerable <XElement> xTabsElements = element.Elements(xns + "tabs");

            if (xTabsElements == null && xTabsElements.Count() != 1)
            {
                return;
            }
            XElement xTabsElement = xTabsElements.FirstOrDefault();
            // 获取所有的tab节点
            IEnumerable <XElement> xTabs = xTabsElement.Elements(xns + "tab");

            if (xTabs == null || xTabs.Count() == 0)
            {
                return;
            }
            // 遍历所有的tab节点
            foreach (XElement xTab in xTabs)
            {
                // 根据元素类型解析器
                IRibbonResolver tabResolver = CreateResolver(xTab.Name.LocalName, ribbonAdmin);
                // 解析Tab元素
                if (tabResolver != null)
                {
                    tabResolver.Resolve(xTab, bundle);
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 解析操作
        /// </summary>
        /// <param name="element"></param>
        /// <param name="bundle"></param>
        /// <returns></returns>
        protected override void OnResolver(XElement element, IBundle bundle)
        {
            // 首先获取当前页签的唯一标示
            string id = element.AttibuteStringValue("id");

            if (string.IsNullOrEmpty(id))
            {
                return;
            }
            // 获取上级页签的唯一标示
            string ContainerId = element.Parent.AttibuteStringValue("id");
            // 尝试从缓存中加载
            XRibbonMenu xRibbonMenu = ribbonAdmin.Find <XRibbonMenu>(id);
            // 将当前菜单的容器对象
            CompositeRibbonElement xRibbonContainer = ribbonAdmin.Find <CompositeRibbonElement>(ContainerId);

            if (xRibbonMenu != null)
            {
                if (xRibbonContainer != xRibbonMenu.Parent)
                {
                    return;
                }
            }
            else
            {
                // 创建分组对象
                xRibbonMenu = new XRibbonMenu();
                bool success = xRibbonMenu.InitProperties(element, bundle);
                if (!success)
                {
                    return;
                }
                // 将当前菜单添加到容器中
                xRibbonContainer.Append(xRibbonMenu);
                // 添加到缓存
                ribbonAdmin.CacheRibbonElement(id, xRibbonMenu);
            }
            // 获取所有的元素列表
            IEnumerable <XElement> xChildElements = element.Elements();

            if (xChildElements == null && xChildElements.Count() == 0)
            {
                return;
            }
            // 遍历所有元素
            foreach (XElement xChildElement in xChildElements)
            {
                if (SupportNestedType(xChildElement.Name.LocalName))
                {
                    IRibbonResolver resolver = CreateResolver(xChildElement.Name.LocalName, ribbonAdmin);
                    if (resolver != null)
                    {
                        resolver.Resolve(xChildElement, bundle);
                    }
                }
            }
        }
Esempio n. 3
0
        /// <summary>
        /// 解析操作
        /// </summary>
        /// <param name="element"></param>
        /// <param name="bundle"></param>
        /// <returns></returns>
        protected override void OnResolver(XElement element, IBundle bundle)
        {
            // 首先获取当前页签的唯一标示
            string id = element.AttibuteStringValue("id");

            if (string.IsNullOrEmpty(id))
            {
                return;
            }
            // 获取上级页签的唯一标示
            string tabId = element.Parent.AttibuteStringValue("id");
            // 尝试从缓存中加载
            XRibbonGroup xRibbonGroup = ribbonAdmin.Find <XRibbonGroup>(id);

            if (xRibbonGroup != null)
            {
                if (!ribbonAdmin.GroupInTab(tabId, id))
                {
                    return;
                }
            }
            else
            {
                // 创建分组对象
                xRibbonGroup = new XRibbonGroup();
                bool success = xRibbonGroup.InitProperties(element, bundle);
                if (!success)
                {
                    return;
                }
                // 将当前分组添加到页签中
                XRibbonTab xRibbonTab = ribbonAdmin.Find <XRibbonTab>(tabId);
                xRibbonTab.Append(xRibbonGroup);
                // 添加到缓存
                ribbonAdmin.CacheRibbonElement(id, xRibbonGroup);
            }
            // 获取所有的元素列表
            IEnumerable <XElement> xChildElements = element.Elements();

            if (xChildElements == null && xChildElements.Count() == 0)
            {
                return;
            }
            // 遍历所有元素
            foreach (XElement xChildElement in xChildElements)
            {
                if (UnSupportNestedType(xChildElement.Name.LocalName))
                {
                    continue;
                }
                IRibbonResolver resolver = CreateResolver(xChildElement.Name.LocalName, ribbonAdmin);
                if (resolver != null)
                {
                    resolver.Resolve(xChildElement, bundle);
                }
            }
        }
Esempio n. 4
0
 /// <summary>
 /// 添加扩展对象
 /// </summary>
 /// <param name="extension"></param>
 public void AddExtension(IExtension extension)
 {
     CheckValid();
     if (extension.Data != null)
     {
         foreach (XElement xElement in extension.Data)
         {
             IRibbonResolver ribbonResolver = BaseRibbonResolver.CreateResolver("ribbon", this);
             ribbonResolver.Resolve(xElement, extension.Owner);
             break;
         }
     }
 }
Esempio n. 5
0
        /// <summary>
        /// 解析操作
        /// </summary>
        /// <param name="element"></param>
        /// <param name="bundle"></param>
        /// <returns></returns>
        protected override void OnResolver(XElement element, IBundle bundle)
        {
            // 首先获取当前页签的唯一标示
            string id = element.AttibuteStringValue("id");

            if (string.IsNullOrEmpty(id))
            {
                return;
            }
            // 尝试从缓存中加载
            XRibbonTab xRibbonTab = ribbonAdmin.Find <XRibbonTab>(id);

            if (xRibbonTab == null)
            {
                // 创建页签对象
                xRibbonTab = new XRibbonTab();
                bool success = xRibbonTab.InitProperties(element, bundle);
                if (!success)
                {
                    return;
                }
                // 将当前页签添加到页签集合中
                ribbonAdmin.xRibbon.Tabs.Append(xRibbonTab);
                // 添加到缓存
                ribbonAdmin.CacheRibbonElement(id, xRibbonTab);
            }
            // 获取所有的分组元素列表
            IEnumerable <XElement> xGroups = element.Elements(xns + "group");

            if (xGroups == null && xGroups.Count() == 0)
            {
                return;
            }
            // 遍历所有分组
            foreach (XElement xGroup in xGroups)
            {
                IRibbonResolver groupResolver = CreateResolver(xGroup.Name.LocalName, ribbonAdmin);
                if (groupResolver != null)
                {
                    groupResolver.Resolve(xGroup, bundle);
                }
            }
        }