/// <summary>
        /// Creates the elementManager style as provided by the QLS node by inserting
        /// the manager objects provided by the QLS and insterts the given children into
        /// the tree on the positions defined in the QLS
        /// </summary>
        /// <param name="collection">Collection element to be reconstructed</param>
        /// <param name="children">Children that can occur as a child of the collection element</param>
        /// <param name="qlsChildren">Children of the QLS node that mached the collection node</param>
        /// <param name="controller">ElementManagerController for element creation</param>
        /// <returns>Element manager collection that contains all QLS defined children</returns>
        private static ElementManagerCollection ReconstructElementCollection(ElementManagerCollection collection, ref List <ElementManagerLeaf> children, QLSNode qlsNode, ElementManagerController controller)
        {
            collection.Children.Clear();

            foreach (QLSNode node in qlsNode.Children)
            {
                switch (node.NodeType)
                {
                case QLSNodeType.Page:
                case QLSNodeType.Section:
                    ElementManagerCollection collectionChild = AddQLSToCollection(node, collection, controller);
                    collectionChild = ReconstructElementCollection(collectionChild, ref children, node, controller);
                    collection.AddChild(collectionChild);
                    break;

                case QLSNodeType.Question:
                    IEnumerable <ElementManagerLeaf> foundMatches = children.Where(o => o.Identifier == node.ID).Select(o => o as ElementManagerLeaf);
                    if (foundMatches.Count() != 1)
                    {
                        throw new InvalidOperationException(string.Format("Identifier: {0}, used in QLS, was found {1} times in QL!", node.ID, foundMatches.Count()));
                    }

                    ElementManagerLeaf child = foundMatches.First();
                    children.Remove(child);
                    collection.AddChild(AddQLSToLeaf(node, child));
                    break;
                }
            }
            collection.AddStyle(qlsNode.NodeStyles.ToArray());
            return(collection);
        }
 private void AnwerUpdate(ElementManagerLeaf elementManagerLeaf, bool calculated)
 {
     if (calculated)
     {
         UpdateColor(elementManagerLeaf.AnswerToString());
     }
 }
        private static ElementManagerLeaf AddQLSToLeaf(QLSNode node, ElementManagerLeaf leaf)
        {
            QLSStyle style = new QLSStyle(QValueType.Unknown, new QLSWidgetSpecification(WidgetType.Default, new List <string>()));

            if (node.NodeStyles.Count > 1)
            {
                throw new InvalidOperationException("Multiple styles in leaf node");
            }
            else if (node.NodeStyles.Count == 1)
            {
                style = node.NodeStyles[0];
            }

            leaf.SetStyle(style);
            return(leaf);
        }
Exemple #4
0
        private static WidgetBuilder <Control> GetLeafBuilder(ElementManagerLeaf elementManagerLeaf)
        {
            switch (elementManagerLeaf)
            {
            case BoolQuestionManager boolQuestion:
                return(new BoolBuilderWindows(boolQuestion));

            case DoubleQuestionManager doubleQuestion:
                return(new DoubleBuilderWindows(doubleQuestion));

            case IntQuestionManager intQuestion:
                return(new IntBuilderWindows(intQuestion));

            case MoneyQuestionManager moneyQuestion:
                return(new MoneyBuilderWindows(moneyQuestion));

            case StringQuestionManager stringQuestion:
                return(new StringBuilderWindows(stringQuestion));

            case HexQuestionManager hexQuestion:
                return(new HexBuilderWindows(hexQuestion));
            }
            throw new NotImplementedException();
        }