Esempio n. 1
0
/// <summary>
/// Deserialize
/// </summary>
/// <param name="vertexName"></param>
/// <param name="q"></param>
/// <param name="tr"></param>
/// <returns></returns>

        internal static VertexMx Deserialize(
            string name,
            Query q,
            XmlTextReader tr)
        {
            Enum iEnum = null;

            VertexMx v = new VertexMx();

            if (XmlUtil.GetEnumAttribute(tr, "ShowLabels", typeof(ShowLabels), ref iEnum))
            {
                v.ShowLabels = (ShowLabels)iEnum;
            }

            while (true)             // loop through elements of network
            {
                tr.Read(); tr.MoveToContent();

                if (Lex.Eq(tr.Name, name + "Column"))
                {
                    v.QueryColumn = ResultsViewProps.DeserializeQueryColumn(q, tr);
                    //tr.Read(); tr.MoveToContent();
                }

                else if (Lex.Eq(tr.Name, "Color"))
                {
                    v.Color = ColorDimension.Deserialize("Color", q, tr);
                    //tr.Read(); tr.MoveToContent();
                }

                else if (Lex.Eq(tr.Name, "Size"))
                {
                    v.Size = SizeDimension.Deserialize("Size", q, tr);
                    //tr.Read(); tr.MoveToContent();
                }

                else if (Lex.Eq(tr.Name, "Shape"))
                {
                    v.Shape = ShapeDimension.Deserialize("Shape", q, tr);
                    //tr.Read(); tr.MoveToContent();
                }

                else if (Lex.Eq(tr.Name, "TooltipFields"))
                {
                    v.TooltipFields = TooltipDimensionDef.Deserialize("TooltipFields", q, tr);
                    //tr.Read(); tr.MoveToContent();
                }

                else if (tr.NodeType == XmlNodeType.EndElement &&                 // end of props
                         Lex.Eq(tr.Name, name))
                {
                    break;
                }

                else
                {
                    throw new Exception("Unexpected element: " + tr.Name);
                }
            }

            return(v);
        }
Esempio n. 2
0
/// <summary>
/// Deserialize
/// </summary>
/// <param name="q"></param>
/// <param name="tr"></param>
/// <param name="view"></param>
/// <returns></returns>

        public static bool Deserialize(
            Query q,
            XmlTextReader tr,
            ResultsViewProps view)
        {
            Enum   iEnum = null;
            bool   b1    = false;
            string txt   = "";
            int    i1    = -1;
            double d1    = -1;

            if (!Lex.Eq(tr.Name, "NetworkProperties"))
            {
                return(false);
            }

            if (view.NetworkProperties == null)
            {
                view.NetworkProperties = new NetworkProperties();
            }

            NetworkProperties p = view.NetworkProperties;

            //if (XmlUtil.GetEnumAttribute(tr, "GraphDirectedness", typeof(GraphDirectedness), ref iEnum))
            //	p.GraphDirectedness = (GraphDirectedness)iEnum;

            //LayoutSettingsMx s = p.LayoutSettings; // layout settings

            //if (XmlUtil.GetEnumAttribute(tr, "LayoutType", typeof(LayoutType), ref iEnum))
            //	s.LayoutType = (LayoutType)iEnum;

            //if (XmlUtil.GetEnumAttribute(tr, "LayoutStyle", typeof(LayoutStyle), ref iEnum))
            //	s.LayoutStyle = (LayoutStyle)iEnum;
            //XmlUtil.GetDoubleAttribute(tr, "GroupRectanglePenWidth", ref s.GroupRectanglePenWidth);
            //if (XmlUtil.GetEnumAttribute(tr, "IntergroupEdgeStyle", typeof(IntergroupEdgeStyle), ref iEnum))
            //	s.IntergroupEdgeStyle = (IntergroupEdgeStyle)iEnum;
            //XmlUtil.GetBoolAttribute(tr, "ImproveLayoutOfGroups", ref s.ImproveLayoutOfGroups);
            //XmlUtil.GetIntAttribute(tr, "MaximumVerticesPerBin", ref s.MaximumVerticesPerBin);
            //XmlUtil.GetIntAttribute(tr, "BinLength", ref s.BinLength);
            //XmlUtil.GetFloatAttribute(tr, "FruchtermanReingoldC", ref s.FruchtermanReingoldC);
            //XmlUtil.GetIntAttribute(tr, "FruchtermanReingoldIterations", ref s.FruchtermanReingoldIterations);
            //XmlUtil.GetIntAttribute(tr, "Margin", ref s.Margin);

            //if (XmlUtil.GetEnumAttribute(tr, "VertexGroupMethod", typeof(VertexGroupMethodMx), ref iEnum))
            //	p.VertexGroupMethod = (VertexGroupMethodMx)iEnum;
            //XmlUtil.GetBoolAttribute(tr, "GroupingDisabled", ref p.GroupingDisabled);
            //XmlUtil.GetDoubleAttribute(tr, "GraphScale", ref p.GraphScale);

            if (tr.IsEmptyElement)
            {
                return(true);        // return if no elements
            }
            while (true)             // loop through elements of network
            {
                tr.Read(); tr.MoveToContent();

                if (Lex.Eq(tr.Name, "Vertex1"))
                {
                    p.Vertex1 = VertexMx.Deserialize("Vertex1", q, tr);
                }

                else if (Lex.Eq(tr.Name, "Vertex2"))
                {
                    p.Vertex2 = VertexMx.Deserialize("Vertex2", q, tr);
                }

                else if (Lex.Eq(tr.Name, "Edge"))
                {
                    p.Edge = EdgeMx.Deserialize("Edge", q, tr);
                }

                else if (Lex.Eq(tr.Name, "GroupByQc"))
                {
                    p.GroupByQc = ResultsViewProps.DeserializeQueryColumn(q, tr);
                    tr.Read(); tr.MoveToContent();
                }

                else if (tr.NodeType == XmlNodeType.EndElement &&                 // end of props
                         Lex.Eq(tr.Name, "NetworkProperties"))
                {
                    break;
                }

                else
                {
                    throw new Exception("Unexpected element: " + tr.Name);
                }
            }

            return(true);
        }