示例#1
0
        /// <summary>
        /// Creates the product groups stack panel.
        /// </summary>
        /// <param name="root"></param>
        /// <returns></returns>
        private NStackPanel CreateProductGroupsStack(NXmlElement root)
        {
            NMap <string, NStackPanel> stackMap = new NMap <string, NStackPanel>();

            // Create the main stack
            NStackPanel mainStack = new NStackPanel();

            mainStack.Direction = ENHVDirection.LeftToRight;
            mainStack.Margins   = new NMargins(0, LaneSpacing * 2);

            // Create a stack panel for each license groups and add it to the main stack
            int count = root.ChildrenCount;

            for (int i = 0; i < count; i++)
            {
                NXmlElement categoryElement = root.GetChildAt(i) as NXmlElement;
                if (categoryElement == null)
                {
                    continue;
                }

                string license = categoryElement.GetAttributeValue("license");

                NStackPanel licenseGroupStack;
                if (!stackMap.TryGet(license, out licenseGroupStack))
                {
                    // A stack panel for the license group not found, so create one
                    licenseGroupStack = CreateProductGroupStack();
                    stackMap.Add(license, licenseGroupStack);

                    // Create a stack for the current group and its name
                    NStackPanel stack = new NStackPanel();
                    stack.Direction = ENHVDirection.TopToBottom;

                    // 1. Add the license group stack
                    stack.Add(licenseGroupStack);

                    // 2. Add the bracket
                    NColor  color   = NColor.Parse(categoryElement.GetAttributeValue("color"));
                    NWidget bracket = CreateLicenseGroupBracket(color);
                    stack.Add(bracket);

                    // 3. Add the label
                    NLabel label = new NLabel(license);
                    label.HorizontalPlacement = ENHorizontalPlacement.Center;
                    label.TextFill            = new NColorFill(color);
                    label.Font = new NFont(NFontDescriptor.DefaultSansFamilyName, InfoFontSize);
                    stack.Add(label);

                    mainStack.Add(stack);
                }

                // Create an image box for the current category
                NImageBox imageBox = CreateImageBox(categoryElement);
                licenseGroupStack.Add(imageBox);
            }

            return(mainStack);
        }
示例#2
0
        internal static NMap <string, string> LoadDescriptions(string descriptionTextFileContent)
        {
            NMap <string, string> descriptions = new NMap <string, string>();

            using (StringReader reader = new StringReader(descriptionTextFileContent))
            {
                string line;

                while ((line = reader.ReadLine()) != null)
                {
                    int dashIndex = line.IndexOf("-", 0);
                    if (dashIndex > 0)
                    {
                        string name        = line.Remove(dashIndex).Trim();
                        string description = line.Remove(0, dashIndex + 1).Trim();
                        descriptions.Add(name, description);
                    }
                }
            }

            return(descriptions);
        }