Exemplo n.º 1
0
        //Recursively write the nodes of the current ViewNode data-tree
        private static void WriteNode(ViewNode condition, XmlWriter xw)
        {
            //We don't write the root node, or the "HasValue" test
            if (condition.DisplayValues.Count > 0 && condition.DisplayValues[0].Value != "root" && condition.DisplayValues[0].Value != "HasValue")
            {
                xw.WriteStartElement("td");

                xw.WriteAttributeString("RowSpan", GetRawSpan(condition).ToString());
                xw.WriteAttributeString("bgcolor", "#FAFAFA");

                if (condition.DisplayValues[0].Attributes.Count > 0 && condition.DisplayValues[0].Type != DisplayValueType.Answer)
                {
                    xw.WriteAttributeString(condition.DisplayValues[0].Attributes[0].Name, condition.DisplayValues[0].Attributes[0].Value);
                }

                if (condition.DisplayValues.Count > 0)
                {
                    foreach (var value in condition.DisplayValues)
                    {
                        xw.WriteStartElement("div");
                        xw.WriteAttributeString("class", "tooltip");
                        xw.WriteStartElement("font");
                        if (value.Attributes.Count > 0 && value.Type != DisplayValueType.Answer)
                        {
                            foreach (var attribute in value.Attributes)
                            {
                                xw.WriteAttributeString(attribute.Name, attribute.Value);
                            }
                        }

                        xw.WriteAttributeString("color", GetColor(value));

                        if (value.Type == DisplayValueType.Answer)
                        {
                            numberAnswer += 1;
                            xw.WriteRaw(value.Value);
                            xw.WriteRaw("<div id=\"answer" + numberAnswer + "\" style=\"display: none\" >" + value.HiddenInfo + "</div>");
                        }
                        else
                        {
                            xw.WriteString(value.Value);
                        }

                        if (condition.DisplayValues.Count > 1)
                        {
                            xw.WriteString(" | ");
                        }

                        xw.WriteEndElement(); //font

                        if (value.Type == DisplayValueType.Answer || value.Type == DisplayValueType.Assign)
                        {
                            if (value.SecondaryInfo != "")
                            {
                                xw.WriteStartElement("span");
                                xw.WriteAttributeString("class", "tooltiptext");
                                xw.WriteRaw(value.SecondaryInfo);
                                xw.WriteEndElement(); //span
                            }
                        }

                        xw.WriteEndElement(); //div
                    }
                }


                xw.WriteEndElement(); //td
            }

            //As long as there's a child node, we keep going
            if (condition.Children != null && condition.Children.Count > 0)
            {
                foreach (var child in condition.Children)
                {
                    WriteNode(child, xw);
                }
            }

            //if there's no child left, it's a leaf, we end the row </tr> and start a new one <tr>
            if (condition.Children != null || condition.Children.Count > 0)
            {
                xw.WriteEndElement();
                xw.WriteStartElement("tr");
            }
        }
Exemplo n.º 2
0
 //Write the root of the current ViewNode data-tree
 private static void WriteRoot(ViewNode condition, XmlWriter xw)
 {
     xw.WriteStartElement("tr");
     WriteNode(condition, xw);
     xw.WriteEndElement();
 }
        private ViewNode ReadRoot(DialogNode node)
        {
            ViewNode condition = new ViewNode(node, answerStore);

            return(ReadNode(node, condition));
        }
Exemplo n.º 4
0
        //Get the number of leaves a node has
        private static int GetRawSpan(ViewNode condition)
        {
            int rowspan = (GetNextChild(condition, 0) >= 1) ? GetNextChild(condition, 0) : 1;

            return(rowspan);
        }
 //Adding a node Method
 public void AddChild(ViewNode condition)
 {
     this.Children.Add(condition);
 }