Esempio n. 1
0
        /// <summary>
        /// Serialize Network View Properties
        /// </summary>
        /// <param name="tw"></param>

        public void Serialize(XmlTextWriter tw)
        {
            if (!NetworkPropertiesEnabled)
            {
                return;
            }

            tw.WriteStartElement("NetworkProperties");

            //tw.WriteAttributeString("GraphDirectedness", GraphDirectedness.ToString());

            LayoutSettingsMx s = LayoutSettings;             // layout settings

            //tw.WriteAttributeString("LayoutType", s.LayoutType.ToString());
            //tw.WriteAttributeString("LayoutStyle", s.LayoutStyle.ToString());
            //tw.WriteAttributeString("GroupRectanglePenWidth", s.GroupRectanglePenWidth.ToString());
            //tw.WriteAttributeString("IntergroupEdgeStyle", s.IntergroupEdgeStyle.ToString());
            //tw.WriteAttributeString("ImproveLayoutOfGroups", s.ImproveLayoutOfGroups.ToString());
            //tw.WriteAttributeString("MaximumVerticesPerBin", s.MaximumVerticesPerBin.ToString());
            //tw.WriteAttributeString("BinLength", s.BinLength.ToString());
            //tw.WriteAttributeString("FruchtermanReingoldC", s.FruchtermanReingoldC.ToString());
            //tw.WriteAttributeString("FruchtermanReingoldIterations", s.FruchtermanReingoldIterations.ToString());
            //tw.WriteAttributeString("Margin", s.Margin.ToString());

            //tw.WriteAttributeString("VertexGroupMethod", VertexGroupMethod.ToString());
            //tw.WriteAttributeString("GroupingDisabled", GroupingDisabled.ToString());
            //tw.WriteAttributeString("GraphScale", GraphScale.ToString());

            Vertex1.Serialize("Vertex1", tw);
            Vertex2.Serialize("Vertex1", tw);

            Edge.Serialize("Edge", tw);
            ResultsViewProps.SerializeQueryColumn(GroupByQc, "GroupByQc", tw);

            tw.WriteEndElement();             // NetworkProperties
            return;
        }
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);
        }