Exemplo n.º 1
0
        /// <summary>
        /// Reads the combo setting specific parameters from the XML element and fills the given
        /// combo setting with them.
        /// </summary>
        /// <param name="settingElement">The XML element to read the specific parameters from.</param>
        /// <param name="comboSetting">The combo setting to be filled.</param>
        private static void FillComboSetting(XElement settingElement, XBeeSettingCombo comboSetting)
        {
            List <string> comboItems = new List <string>();

            XElement comboItemsElement = settingElement.Element(XMLFirmwareConstants.ITEM_ITEMS);

            if (comboItemsElement == null)
            {
                return;
            }

            List <XElement> comboItemsList = new List <XElement>();

            foreach (XElement element in comboItemsElement.Elements())
            {
                if (element.Name.ToString().Equals(XMLFirmwareConstants.ITEM_ITEM))
                {
                    comboItemsList.Add(element);
                }
            }
            if (comboItemsList == null || comboItemsList.Count == 0)
            {
                return;
            }

            for (int i = 0; i < comboItemsList.Count; i++)
            {
                string index = ParsingUtils.IntegerToHexString(i, 1);
                while (index.StartsWith("0"))
                {
                    if (index.Length == 1)
                    {
                        break;
                    }

                    index = index.Substring(1);
                }
                comboItems.Add(comboItemsList[i].Value + " [" + index + "]");
            }
            comboSetting.Items = comboItems;
        }