Example #1
0
        private void ProcessComboBoxNode(RibbonPanel panel, XmlNode node)
        {
            string commandName = node.Attributes["internalName"].Value;

            ComboBoxDefinition controlDef =
                _Application.CommandManager.ControlDefinitions[commandName] as ComboBoxDefinition;

            bool?  useLargeIcon  = XmlUtilities.GetAttributeValueAsNullable <bool>(node, "useLargeIcon");
            bool?  showText      = XmlUtilities.GetAttributeValueAsNullable <bool>(node, "showText");
            bool?  insertBefore  = XmlUtilities.GetAttributeValueAsNullable <bool>(node, "insertBefore");
            bool?  isInSlideout  = XmlUtilities.GetAttributeValueAsNullable <bool>(node, "isInSlideout");
            string targetControl = XmlUtilities.GetAttributeValue <string>(node, "targetControl");

            bool slideout = isInSlideout.HasValue ? isInSlideout.Value : false;

            CommandControls controls = (slideout ? panel.SlideoutControls : panel.CommandControls);

            controls.AddComboBox(
                controlDef,
                string.IsNullOrEmpty(targetControl) ? string.Empty : targetControl,
                insertBefore.HasValue ? insertBefore.Value : false);

            XmlNodeList nodes = node.SelectNodes("ComboItem");

            foreach (XmlNode comboItemNode in nodes)
            {
                string comboItem = comboItemNode.Attributes["item"].Value;

                int?index = XmlUtilities.GetAttributeValueAsNullable <int>(comboItemNode, "index");

                controlDef.AddItem(
                    comboItem,
                    index.HasValue ? index.Value : 0);
            }
        }