/// <summary>
        /// The constructor of GOM_Template
        /// </summary>
        public GOM_Template()
        {
            id				= "";
            extScale		= false;
            extRotate		= false;
            extConnect		= false;
            keepAspectRatio	= false;

            rgPoints		= new GOM_Points();
            rgEditingModes	= new GOM_Strings();
            rgDrawings		= new GOM_Drawings();
            rgFillings		= new GOM_Fillings();
            rgDrawingStyles = new GOM_Drawing_Styles();
            rgFillingStyles = new GOM_Filling_Styles();

            GOM_Style_Drawing	drawing;
            GOM_Style_Filling	filling;

            drawing		= new GOM_Style_Drawing();
            drawing.id	= "default";
            rgDrawingStyles.Add(drawing);

            filling		= new GOM_Style_Filling();
            filling.id	= "default";
            rgFillingStyles.Add(filling);
        }
        public void LoadFromXML(System.Xml.XmlNode node, GOM_ResourceArrays resources)
        {
            GOM_Point				leftTop		= null;
            GOM_Point				rightDown	= null;
            GOM_Style_Filling		style;

            style = resources.FillingStyles["default"];

            for (int i = 0; i < node.Attributes.Count; i++)
            {
                if (System.String.Compare(node.Attributes[i].Name, GOM_TAGS.STYLE, true) == 0)
                {
                    style = resources.FillingStyles[node.Attributes[i].Value];
                }
                if (System.String.Compare(node.Attributes[i].Name, GOM_TAGS.LEFT_TOP, true) == 0)
                {
                    leftTop = resources.Points[node.Attributes[i].Value];
                }
                if (System.String.Compare(node.Attributes[i].Name, GOM_TAGS.RIGHT_DOWN, true) == 0)
                {
                    rightDown = resources.Points[node.Attributes[i].Value];
                }
            }

            if ((leftTop == null) || (rightDown == null))
            {
                throw new Exception("Missing points in rectangle filling");
            }

            if (style == null)
            {
                throw new Exception("Missing style in rectangle filling");
            }

            this.m_points.Add(leftTop);
            this.m_points.Add(rightDown);
            this.m_style = style;
        }
        /// <summary>
        /// Add a drawing or filling style to current template
        /// </summary>
        /// <param name="node">The XML node that represents a drawing or filling style</param>
        private void LoadStyleFromXML(System.Xml.XmlNode node)
        {
            if (System.String.Compare(node.Name, GOM_TAGS.DRAWING_STYLE, true) == 0)
            {
                GOM_Style_Drawing	style = new GOM_Style_Drawing();

                style.LoadFromXML( node, null );

                rgDrawingStyles.AddAndReplace(style);
            }

            if (System.String.Compare(node.Name, GOM_TAGS.FILLING_STYLE, true) == 0)
            {
                GOM_Style_Filling	style = new GOM_Style_Filling();

                style.LoadFromXML( node, null );

                rgFillingStyles.AddAndReplace(style);
            }
        }
        public void LoadFromXML(System.Xml.XmlNode node, GOM_ResourceArrays resources)
        {
            GOM_Point			pt;
            GOM_Points			rgPoints;
            GOM_Style_Filling	style;

            style = resources.FillingStyles["default"];
            rgPoints = new GOM_Points();

            for (int i = 0; i < node.Attributes.Count; i++)
            {
                if (System.String.Compare(node.Attributes[i].Name, GOM_TAGS.STYLE, true) == 0)
                {
                    style = resources.FillingStyles[node.Attributes[i].Value];
                }
            }

            for (int i = 0; i < node.ChildNodes.Count; i++)
            {
                if (System.String.Compare(node.ChildNodes[i].Name, GOM_TAGS.VERTEX, true) == 0)
                {
                    for (int j = 0; j < node.ChildNodes[i].Attributes.Count; j++)
                    {
                        if (System.String.Compare(node.ChildNodes[i].Attributes[j].Name, GOM_TAGS.POINT, true) == 0)
                        {
                            pt = resources.Points[node.ChildNodes[i].Attributes[j].Value];

                            if (pt == null)
                            {
                                throw new Exception("Missing points in polygon filling");
                            }

                            rgPoints.Add(pt);
                        }
                    }
                }
            }

            if (style == null)
            {
                throw new Exception("Missing style in polygon fillin");
            }

            this.m_points = rgPoints;
            this.m_style  = style;
        }
 /// <summary>
 /// The constructor of GOM_Filling_Rectangle
 /// </summary>
 /// <param name="leftTop">The top left corner of the rectangle</param>
 /// <param name="righgDown">The right down corner of the rectangle</param>
 /// <param name="style">The filling style to fill the rectangle</param>
 public GOM_Filling_Rectangle(GOM_Point leftTop, GOM_Point righgDown, GOM_Style_Filling style)
 {
     m_points = new GOM_Points();
     m_points.Add(leftTop);
     m_points.Add(righgDown);
     m_style = style;
 }
 /// <summary>
 /// The constructor of GOM_Filling_Polygon
 /// </summary>
 /// <param name="points">The vertices of the polygon</param>
 /// <param name="style">The filling style to fill the polygon</param>
 public GOM_Filling_Polygon(GOM_Points points, GOM_Style_Filling style)
 {
     m_points = points;
     m_style = style;
 }
 /// <summary>
 /// The constructor of GOM_Filling_Pie
 /// </summary>
 /// <param name="leftTop">The top left corner of the bounding box of the ellipse which the pie belongs to</param>
 /// <param name="rightDown">The right down corner of the bounding box of the ellipse which the pie belongs to</param>
 /// <param name="startPoint">The start-point of the pie</param>
 /// <param name="endPoint">The end-point of the pie</param>
 /// <param name="style">The filling style to fill the pie</param>
 public GOM_Filling_Pie(GOM_Point leftTop, GOM_Point rightDown, GOM_Point startPoint, GOM_Point endPoint, GOM_Style_Filling style)
 {
     m_points = new GOM_Points();
     m_points.Add(leftTop);
     m_points.Add(rightDown);
     m_points.Add(startPoint);
     m_points.Add(endPoint);
     m_style = style;
 }
        public void LoadFromXML(System.Xml.XmlNode node, GOM_ResourceArrays resources)
        {
            GOM_Drawings			drawings;
            GOM_Style_Filling		style;

            style = resources.FillingStyles["default"];
            drawings = new GOM_Drawings();

            for (int i = 0; i < node.Attributes.Count; i++)
            {
                if (System.String.Compare(node.Attributes[i].Name, GOM_TAGS.STYLE, true) == 0)
                {
                    style = resources.FillingStyles[node.Attributes[i].Value];
                }
            }

            for (int i = 0; i < node.ChildNodes.Count; i++)
            {
                GOM_Utility.LoadDrawingFromXML(node.ChildNodes[i], drawings, resources);
            }

            if (style == null)
            {
                throw new Exception("Missing style in polygon fillin");
            }

            this.m_style = style;
            this.m_drawings = drawings;
        }
 /// <summary>
 /// The constructor of GOM_Filling_FillPath
 /// </summary>
 /// <param name="drawings">A list of drawing operation</param>
 /// <param name="style">The filling style to fill the path</param>
 public GOM_Filling_FillPath(GOM_Drawings drawings, GOM_Style_Filling style)
 {
     m_points = new GOM_Points();
     m_style = style;
     m_drawings = drawings;
 }
        /// <summary>
        /// Initialize the graphic object according to a given template
        /// </summary>
        /// <param name="template"></param>
        public void InitializeFromTemplate(GOM_Template template)
        {
            //Initialize property
            this.m_template			= template;
            this.extConnect			= template.extConnect;
            this.extRotate			= template.extRotate;
            this.extScale			= template.extScale;
            this.keepAspectRatio	= template.keepAspectRatio;
            //Clear up existing data
            this.rgPoints.Clear();
            this.rgFillings.Clear();
            this.rgDrawings.Clear();
            this.rgEditingModes.Clear();
            this.rgDrawingStyles.Clear();
            this.rgFillingStyles.Clear();
            //Initialize editing mode
            for (int i = 0; i < template.rgEditingModes.Count; i++)
            {
                this.rgEditingModes.Add(template.rgEditingModes[i]);
            }
            //Initialize drawing styles
            for (int i = 0; i < template.rgDrawingStyles.Count; i++)
            {
                GOM_Style_Drawing	style;

                style = new GOM_Style_Drawing();
                style.id = template.rgDrawingStyles[i].id;
                style.drawingStyle = (System.Drawing.Pen)template.rgDrawingStyles[i].drawingStyle.Clone();

                this.rgDrawingStyles.Add(style);
            }
            //Initialize filling styles
            for (int i = 0; i < template.rgFillingStyles.Count; i++)
            {
                GOM_Style_Filling	style;

                style = new GOM_Style_Filling();
                style.id = template.rgFillingStyles[i].id;
                style.fillingStyle = (System.Drawing.Brush)template.rgFillingStyles[i].fillingStyle.Clone();

                this.rgFillingStyles.Add(style);
            }
            //Initialize basic properties of points
            for (int i = 0; i < template.rgPoints.Count; i++)
            {
                GOM_Point	pt;

                pt = new GOM_Point();
                pt.id = template.rgPoints[i].id;
                pt.x = template.rgPoints[i].x;
                pt.y = template.rgPoints[i].y;
                pt.Connectable = template.rgPoints[i].Connectable;
                pt.Controllable = template.rgPoints[i].Controllable;

                this.rgPoints.Add(pt);
            }
            //Initialize drawing operations
            for (int i = 0; i < template.rgDrawings.Count; i++)
            {
                rgDrawings.Add(CloneDrawing(template.rgDrawings[i]));
            }
            //Initialize filling operations
            for (int i = 0; i < template.rgFillings.Count; i++)
            {
                rgFillings.Add(CloneFilling(template.rgFillings[i]));
            }
            //Initialize constraints of points
            for (int i = 0; i < template.rgPoints.Count; i++)
            {
                for (int j = 0; j < template.rgPoints[i].Constraints.Count; j++)
                {
                    GOM_Constraint_Set	constraintSet;

                    constraintSet = new GOM_Constraint_Set();

                    for (int k = 0; k < template.rgPoints[i].Constraints[j].Count; k++)
                    {
                        constraintSet.Add(CloneConstraint(template.rgPoints[i].Constraints[j][k]));
                    }

                    rgPoints[i].Constraints.Add(constraintSet);
                }
            }

            CalculateBoundingBox();

            //from template
            #region new_modified
            if (template.var_list != null)
            {
                var_list = template.var_list.clone();
            }

            if (template.res_list != null)
            {
                res_list = template.res_list.clone();
            }
            #endregion
        }