示例#1
0
        /// <summary>
        /// Deserialize
        /// </summary>
        /// <param name="name"></param>
        /// <param name="q"></param>
        /// <param name="tr"></param>
        /// <returns></returns>

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

            EdgeMx e = new EdgeMx();

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

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

            XmlUtil.GetBoolAttribute(tr, "IncludeEdgeVertex", ref e.IncludeEdgeVertex);

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

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

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

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

                else if (Lex.Eq(tr.Name, "TooltipFields"))
                {
                    e.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(e);
        }
示例#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);
        }