public GOM_ResourceArrays( GOM_Templates templates )
 {
     m_templates = templates;
 }
        /// <summary>
        /// Load a primitive object from a string
        /// </summary>
        /// <param name="strXml">The string that contains the definition of the primitive object</param>
        /// <param name="rgTemplates">The list of known templates</param>
        /// <returns>If successful, a primitve object is returned. Otherwise, an exception will be thrown out</returns>
        public static GOM_Object_Primitive LoadFromString(string strXml, GOM_Templates rgTemplates)
        {
            System.Xml.XmlDocument	doc;

            doc = new System.Xml.XmlDocument();
            doc.LoadXml(strXml);

            return LoadFromXml(doc.DocumentElement, rgTemplates);
        }
        /// <summary>
        /// Load a primitive object from a node of XML tree
        /// </summary>
        /// <param name="node">The node which is the root of the XML tree</param>
        /// <param name="rgTemplates">The list of known templates</param>
        /// <returns>If successful, a primitve object is returned. Otherwise, an exception will be thrown out</returns>
        public static GOM_Object_Primitive LoadFromXml(System.Xml.XmlNode node, GOM_Templates rgTemplates)
        {
            GOM_Object_Primitive	primitive = null;

            if (System.String.Compare(node.Name, GOM_TAGS.GRAPHIC_OBJECT) != 0)
            {
                throw new Exception("Invalid input. Not a graphic object node!");
            }

            primitive = new GOM_Object_Primitive();
            //Load properties of the graphic object
            for (int i = 0; i < node.Attributes.Count; i++)
            {
                if (System.String.Compare(node.Attributes[i].Name, GOM_TAGS.ID, true) == 0)
                {
                    primitive.id = node.Attributes[i].Value;
                }
                if (System.String.Compare(node.Attributes[i].Name, GOM_TAGS.TYPE, true) == 0)
                {
                    if (!node.Attributes[i].Value.Equals("primitive"))
                    {
                        throw new Exception("Invalid input. Not a primitive object node!");
                    }
                }
                if (System.String.Compare(node.Attributes[i].Name, GOM_TAGS.X_OFFSET, true) == 0)
                {
                    primitive.m_xOffset = float.Parse(node.Attributes[i].Value);
                }
                if (System.String.Compare(node.Attributes[i].Name, GOM_TAGS.Y_OFFSET, true) == 0)
                {
                    primitive.m_yOffset = float.Parse(node.Attributes[i].Value);
                }
                if (System.String.Compare(node.Attributes[i].Name, GOM_TAGS.ROTATION, true) == 0)
                {
                    primitive.m_rotation = float.Parse(node.Attributes[i].Value);
                }
                if (System.String.Compare(node.Attributes[i].Name, GOM_TAGS.TEMPLATE, true) == 0)
                {
                    for (int j = 0; j < rgTemplates.Count; j++)
                    {
                        if (rgTemplates[j].id.Equals(node.Attributes[i].Value))
                        {
                            primitive.m_template = rgTemplates[j];
                        }
                    }

                    if (primitive.m_template == null)
                    {
                        throw new Exception("Unknown template");
                    }
                }
            }

            if (primitive.m_template == null)
            {
                throw new Exception("Can not find template of the graphic object");
            }
            //Initialize the graphic object according to the template
            primitive.InitializeFromTemplate(primitive.m_template);
            //Update status of the graphic object
            for (int i = 0; i < node.ChildNodes.Count; i++)
            {
                if (System.String.Compare(node.ChildNodes[i].Name, GOM_TAGS.POINTS, true) == 0)
                {
                    primitive.UpdatePoints(node.ChildNodes[i]);
                }
                if (System.String.Compare(node.ChildNodes[i].Name, GOM_TAGS.STYLES, true) == 0)
                {
                    primitive.UpdateStyles(node.ChildNodes[i]);
                }
                if (System.String.Compare(node.ChildNodes[i].Name, GOM_TAGS.TEXT, true) == 0)
                {
                    primitive.LoadText(node.ChildNodes[i]);
                }
                #region new_modfied
                //Load attribute
                if (System.String.Compare(node.ChildNodes[i].Name, "attribute", true) == 0)
                {
                    for (int j = 0; j < node.ChildNodes[i].ChildNodes.Count; j++)
                    {
                        primitive.LoadVarFromXML(node.ChildNodes[i].ChildNodes[j], j);
                    }
                }
                //Load restrictions
                if (System.String.Compare(node.ChildNodes[i].Name, "restrictions", true) == 0)
                {
                    for (int j = 0; j < node.ChildNodes[i].ChildNodes.Count; j++)
                    {
                        primitive.LoadRestrictionFromXML(node.ChildNodes[i].ChildNodes[j], j);
                    }
                }
                #endregion
            }

            return primitive;
        }
        /// <summary>
        /// Load a primitive object from a file
        /// </summary>
        /// <param name="fileName">The name of file that contains the definition of the primitive object</param>
        /// <param name="rgTemplates">The list of known templates</param>
        /// <returns>If successful, a primitve object is returned. Otherwise, an exception will be thrown out</returns>
        public static GOM_Object_Primitive LoadFromFile(string fileName, GOM_Templates rgTemplates)
        {
            System.Xml.XmlDocument	doc;

            doc = new System.Xml.XmlDocument();
            doc.Load(fileName);

            return LoadFromXml(doc.DocumentElement, rgTemplates);
        }