示例#1
0
        /// <summary>
        /// 作用:创建RibbonPage
        /// 作者:汪建龙
        /// 编写时间:2016年12月30日13:57:41
        /// </summary>
        /// <param name="ribbonControl"></param>
        /// <param name="node"></param>
        /// <returns></returns>
        private static object CreateItemRibbonPage(RibbonControl ribbonControl, XmlNode node)
        {
            if (node == null || node.NodeType == XmlNodeType.Comment || node.Attributes == null)
            {
                return(null);
            }
            object obj = InstanceHelper.CreateInstance(AssemblyNameOfDevExpress, "Ribbon.RibbonPage") as RibbonPage;

            if (obj == null)
            {
                return(null);
            }
            RibbonPage ribbonPage = obj as RibbonPage;

            ribbonPage.Name    = XMLHelper.GetAttribute(node, "Name");
            ribbonPage.Text    = XMLHelper.GetAttribute(node, "Text");
            ribbonPage.Visible = XMLHelper.GetAttribute(node, "Visible").ToUpper().IndexOf("F") > -1 ? false : true;

            XmlNodeList nodeListSubPageItem = node.ChildNodes;

            foreach (XmlNode nodeSubPageItem in nodeListSubPageItem)
            {
                RibbonPageGroup group = CreateItem(ribbonControl, nodeSubPageItem) as RibbonPageGroup;
                if (group != null)
                {
                    ribbonPage.Groups.Add(group);
                }
            }
            return(obj);
        }
示例#2
0
        /// <summary>
        /// 作用:创建RibbonControl中的Group
        /// 作者:汪建龙
        /// 编写时间:2016年12月30日14:11:06
        /// </summary>
        /// <param name="ribbonControl"></param>
        /// <param name="nodePageGroup"></param>
        /// <returns></returns>
        private static object CreateItemRibbonPageGroup(RibbonControl ribbonControl, XmlNode nodePageGroup)
        {
            if (nodePageGroup == null || nodePageGroup.NodeType == XmlNodeType.Comment || nodePageGroup.Attributes == null)
            {
                return(null);
            }
            object obj = InstanceHelper.CreateInstance(AssemblyNameOfDevExpress, "Ribbon.RibbonPageGroup") as RibbonPageGroup;

            if (obj == null)
            {
                return(null);
            }
            RibbonPageGroup ribbonPageGroup = obj as RibbonPageGroup;

            ribbonPageGroup.Name    = XMLHelper.GetAttribute(nodePageGroup, "Name");
            ribbonPageGroup.Text    = XMLHelper.GetAttribute(nodePageGroup, "Text");
            ribbonPageGroup.Visible = XMLHelper.GetAttribute(nodePageGroup, "Visible").ToUpper().IndexOf("F") > -1 ? false : true;

            XmlNodeList nodeListSubPageItems = nodePageGroup.ChildNodes;

            foreach (XmlNode nodeSubPageItem in nodeListSubPageItems)
            {
                object        obj_node = CreateItem(ribbonControl, nodeSubPageItem);
                BarButtonItem item     = obj_node as BarButtonItem;
                if (item != null && item.Tag is IUICommand)
                {
                    IUICommand uicmd = item.Tag as IUICommand;
                    ribbonPageGroup.ItemLinks.Add(item, uicmd.Group);
                    ribbonControl.Items.Add(item);
                }
                else
                {
                    BarSubItem subItem = obj_node as BarSubItem;
                    if (subItem != null)
                    {
                        ribbonPageGroup.ItemLinks.Add(subItem);
                        ribbonControl.Items.Add(subItem);
                    }
                    XmlNodeList subListItems = nodeSubPageItem.ChildNodes;
                    foreach (XmlNode subNodeSubItem in subListItems)
                    {
                        BarButtonItem item2 = CreateItem(ribbonControl, subNodeSubItem) as BarButtonItem;
                        if (item2 != null && item2.Tag is IUICommand)
                        {
                            IUICommand uiCmd2 = item2.Tag as IUICommand;
                            subItem.ItemLinks.Add(item2, uiCmd2.Group);
                            ribbonControl.Items.Add(item2);
                        }
                    }
                }
            }
            return(obj);
        }
示例#3
0
        private static object CreateItemBarButtonItem(XmlNode node)
        {
            if (node == null || node.NodeType == XmlNodeType.Comment)
            {
                return(null);
            }
            object obj = InstanceHelper.CreateInstance(AssemblyNameOfDevExpress, "BarButtonItem") as BarButtonItem;

            if (obj == null)
            {
                return(null);
            }
            BarButtonItem barButtonItem = obj as BarButtonItem;

            barButtonItem.Name    = XMLHelper.GetAttribute(node, "Name");
            barButtonItem.Caption = XMLHelper.GetAttribute(node, "Text");
            var strVisible = XMLHelper.GetAttribute(node, "Visible");

            barButtonItem.Visibility = !string.IsNullOrEmpty(strVisible) && strVisible.ToUpper().IndexOf("F") > -1 ? BarItemVisibility.Never : BarItemVisibility.Always;
            bool largeGlyph = false;

            bool.TryParse(XMLHelper.GetAttribute(node, "LargeGlyph"), out largeGlyph);

            Image image = LoadImageFromResource(XMLHelper.GetAttribute(node, "ImageFile") ?? barButtonItem.Name);

            if (largeGlyph)
            {
                barButtonItem.RibbonStyle = RibbonItemStyles.Large;
                barButtonItem.LargeGlyph  = image;
            }
            else
            {
                barButtonItem.RibbonStyle = RibbonItemStyles.SmallWithText;
                barButtonItem.Glyph       = image;
            }

            var  strBeginGroup = XMLHelper.GetAttribute(node, "Group");
            bool beginGroup    = false;

            if (!string.IsNullOrEmpty(strBeginGroup) && strBeginGroup.ToUpper().IndexOf("T") > -1)
            {
                beginGroup = true;
            }
            XmlNode nodeCmdCls = node.SelectSingleNode("CommandClass");
        }