Beispiel #1
0
        /// <summary>
        /// Creates a widget for the given category element.
        /// Category elements can contain only row elements.
        /// </summary>
        /// <param name="category"></param>
        /// <returns></returns>
        private NWidget CreateCategory(NXmlElement category)
        {
            string categoryTitle = category.GetAttributeValue("name");
            NColor color         = NColor.ParseHex(category.GetAttributeValue("color"));
            NColor lightColor    = color.Lighten(0.6f);

            // Create the header label
            NExampleCategoryHeader categoryHeader = new NExampleCategoryHeader(categoryTitle);

            categoryHeader.BackgroundFill = new NColorFill(color);
            categoryHeader.Status         = category.GetAttributeValue("status");

            // Create a stack panel for the category widgets
            NStackPanel stack = new NStackPanel();

            stack.VerticalSpacing = ItemVerticalSpacing;
            stack.BackgroundFill  = new NColorFill(lightColor);
            stack.Tag             = category;

            // Add the header label
            stack.Add(categoryHeader);

            // Loop through the rows
            for (int i = 0, count = category.ChildrenCount; i < count; i++)
            {
                NXmlElement row = category.GetChildAt(i) as NXmlElement;
                if (row == null)
                {
                    continue;
                }

                if (row.Name != "row")
                {
                    throw new Exception("Category elements should contain only rows");
                }

                NStackPanel rowStack = CreateRow(row, color);
                stack.Add(rowStack);
            }

            return(stack);
        }