/// <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 GOM_Link(System.Xml.XmlNode node, GOM_ResourceArrays resources)
        {
            m_startStyle	= GOMLib.GOM_Terminal_Style.None;
            m_endStyle		= GOMLib.GOM_Terminal_Style.Triangle;
            m_drawingStyle	= new GOMLib.GOM_Style_Drawing();
            m_linkingStyle	= GOM_Linking_Style.Line;
            m_keyPts		= new GOM_Points();

            m_drawingStyle.id = "default";

            LoadFromXML(node, resources);
        }
        public GOM_Link(GOM_Interface_Graphic_Object startObj, GOM_Point startPt, GOM_Interface_Graphic_Object endObj, GOM_Point endPt, GOM_Style_Drawing drawingStyle, GOM_Linking_Style linkingStyle, GOM_Terminal_Style startStyle, GOM_Terminal_Style endStyle)
        {
            m_startObj		= startObj;
            m_endObj		= endObj;
            m_startPt		= startPt;
            m_endPt			= endPt;
            m_startStyle	= startStyle;
            m_endStyle		= endStyle;
            m_drawingStyle	= drawingStyle;
            m_linkingStyle	= linkingStyle;
            m_keyPts		= new GOM_Points();

            m_drawingStyle.id = "default";
        }
 /// <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;
 }
 public static GOM_Link CreateLink(GOM_Interface_Graphic_Object startObj, GOM_Point startPt, GOM_Interface_Graphic_Object endObj, GOM_Point endPt, GOM_Points keyPoints)
 {
     GOM_Style_Drawing drawing = new GOMLib.GOM_Style_Drawing();
     drawing.drawingStyle.Color = System.Drawing.Color.Gray;
     GOM_Link link = new GOMLib.GOM_Link(startObj, startPt,
         endObj, endPt,
         drawing,
         GOMLib.GOM_Linking_Style.Line,
         GOMLib.GOM_Terminal_Style.None,
         GOMLib.GOM_Terminal_Style.None);
     if ( keyPoints!=null && keyPoints.Count>0 )
     {
         link.m_linkingStyle = GOMLib.GOM_Linking_Style.Polyline;
         link.m_keyPts = keyPoints;
     }
     return link;
 }
 /// <summary>
 /// The constructor of GOM_Drawing_Line
 /// </summary>
 /// <param name="startPoint">The start-point of the line</param>
 /// <param name="endPoint">The end-point of the line</param>
 /// <param name="style">The drawing style of line</param>
 public GOM_Drawing_Line(GOM_Point startPoint, GOM_Point endPoint, GOM_Style_Drawing style)
 {
     m_points = new GOM_Points();
     m_points.Add(startPoint);
     m_points.Add(endPoint);
     m_style = style;
 }
 public GOM_Drawing_Line( System.Xml.XmlNode node, GOM_ResourceArrays resources)
 {
     m_points = new GOM_Points();
     LoadFromXML(node, resources);
 }
        /// <summary>
        /// Clone a drawing operation
        /// </summary>
        /// <param name="drawing">The original drawing operation</param>
        /// <returns>If successful, a drawing operation is returned. Otherwise, null is returned.</returns>
        private GOM_Interface_Drawing CloneDrawing(GOM_Interface_Drawing drawing)
        {
            if (drawing is GOM_Drawing_Line)
            {
                return new GOM_Drawing_Line(Points(drawing.Points[0].id), Points(drawing.Points[1].id), DrawingStyles(drawing.Style.id));
            }

            if (drawing is GOM_Drawing_Arc)
            {
                return new GOM_Drawing_Arc(Points(drawing.Points[0].id), Points(drawing.Points[1].id), Points(drawing.Points[2].id), Points(drawing.Points[3].id), DrawingStyles(drawing.Style.id), 0);
            }

            if (drawing is GOM_Drawing_Bezier)
            {
                GOM_Points	rgPts;

                rgPts = new GOM_Points();

                for (int i = 0; i < drawing.Points.Count; i++)
                {
                    rgPts.Add(Points(drawing.Points[i].id));
                }

                return new GOM_Drawing_Bezier(rgPts, DrawingStyles(drawing.Style.id));
            }

            return null;
        }
 /// <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;
 }
        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;
        }
 public GOM_ResourceArrays( GOM_Points points, GOM_Drawing_Styles drawingStyles, GOM_Filling_Styles fillingStyles )
     : this(points, drawingStyles, fillingStyles, null)
 {
 }
 public GOM_ResourceArrays( GOM_Points points )
     : this(points, null, null, null)
 {
 }
 public GOM_Point GetPointByName(string name)
 {
     GOM_Points others = new GOM_Points();
     others.Add(m_Top_Connector);
     others.Add(m_Bottom_Connector);
     others.Add(m_Left_Connector);
     others.Add(m_Right_Connector);
     others.Add(m_Rotation_Point);
     others.Add(m_SW_Resize_Point);
     others.Add(m_NE_Resize_Point);
     others.Add(m_SE_Resize_Point);
     others.Add(m_NW_Resize_Point);
     return others[name];
 }
 private GOM_Points LoadPointsFromXML(System.Xml.XmlNode node)
 {
     GOM_Points points = new GOM_Points();
     for( int i=0; i<node.ChildNodes.Count; i++ )
     {
         if ( string.Compare(node.ChildNodes[i].Name,GOM_TAGS.POINT,true) == 0 )
         {
             GOM_Point pt = new GOM_Point();
             pt.LoadFromXML(node.ChildNodes[i], null);
             points.Add(pt);
         }
     }
     return points;
 }
        private GOM_Points GetDrawingPoints()
        {
            GOM_Points points = new GOM_Points();
            for( int i=0; i<rgDrawings.Count; i++ )
            {
                GOM_Interface_Drawing drawing = rgDrawings[i];
                for( int j=0; j<drawing.Points.Count; j++ )
                {
                    if ( drawing.Points[j].id == null || drawing.Points[j].id.Length<= 0 )
                    {
                        drawing.Points[j].id = Guid.NewGuid().ToString("D");
                    }

                    if ( points[drawing.Points[j].id] == null )
                    {
                        points.Add( drawing.Points[j] );
                    }
                }
            }
            return points;
        }
        /// <summary>
        /// Clone a filling operation
        /// </summary>
        /// <param name="filling">The original filling operation</param>
        /// <returns>If successful, a drawing operation is returned. Otherwise, null is returned.</returns>
        private GOM_Interface_Filling CloneFilling(GOM_Interface_Filling filling)
        {
            if (filling is GOM_Filling_Ellipse)
            {
                return new GOM_Filling_Ellipse(Points(filling.Points[0].id), Points(filling.Points[1].id), FillingStyles(filling.Style.id));
            }

            if (filling is GOM_Filling_FillPath)
            {
                GOM_Drawings	drawings;

                drawings = new GOM_Drawings();

                for (int i = 0; i < ((GOM_Filling_FillPath)filling).Drawings.Count; i++)
                {
                    drawings.Add(CloneDrawing(((GOM_Filling_FillPath)filling).Drawings[i]));
                }

                return new GOM_Filling_FillPath(drawings, FillingStyles(filling.Style.id));
            }

            if (filling is GOM_Filling_Pie)
            {
                return new GOM_Filling_Pie(Points(filling.Points[0].id), Points(filling.Points[1].id), Points(filling.Points[2].id), Points(filling.Points[3].id), FillingStyles(filling.Style.id));
            }

            if (filling is GOM_Filling_Polygon)
            {
                GOM_Points	rgPts;

                rgPts = new GOM_Points();

                for (int i = 0; i < filling.Points.Count; i++)
                {
                    rgPts.Add(Points(filling.Points[i].id));
                }

                return new GOM_Filling_Polygon(rgPts, FillingStyles(filling.Style.id));
            }

            if (filling is GOM_Filling_Rectangle)
            {
                return new GOM_Filling_Rectangle(Points(filling.Points[0].id), Points(filling.Points[1].id), FillingStyles(filling.Style.id));
            }

            return null;
        }
 /// <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;
 }
 /// <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;
 }
 public GOM_ResourceArrays( GOM_Points points, GOM_Drawing_Styles drawingStyles, GOM_Filling_Styles fillingStyles, GOM_Objects objects )
 {
     m_points = points;
     m_drawingStyles = drawingStyles;
     m_fillingStyles = fillingStyles;
     m_objects = objects;
 }
 public GOM_Filling_Rectangle(System.Xml.XmlNode node, GOM_ResourceArrays resources)
 {
     m_points = new GOM_Points();
     LoadFromXML(node, resources);
 }
 /// <summary>
 /// The constructor of GOM_Drawing_Bezier
 /// </summary>
 /// <param name="points">The points used to define the bezier curve</param>
 /// <param name="style">The drawing style of the bezier curve</param>
 public GOM_Drawing_Bezier(GOM_Points points, GOM_Style_Drawing style)
 {
     m_style = style;
     m_points = points;
 }
 /// <summary>
 /// The constructor of GOM_Drawing_Arc
 /// </summary>
 /// <param name="leftTop">The left top corner of the bounding box of the ellipse which the arc belongs to</param>
 /// <param name="rightDown">The right down corner of the bounding box of the ellipse which the arc belongs to</param>
 /// <param name="startPoint">The start-point of the arc</param>
 /// <param name="endPoint">The end-point of the arc</param>
 /// <param name="style">The drawing style of the arc</param>
 public GOM_Drawing_Arc(GOM_Point leftTop, GOM_Point rightDown, GOM_Point startPoint, GOM_Point endPoint, GOM_Style_Drawing style, float rotateAngle)
 {
     m_points = new GOM_Points();
     m_points.Add(leftTop);
     m_points.Add(rightDown);
     m_points.Add(startPoint);
     m_points.Add(endPoint);
     m_style = style;
     m_rotateAngle = rotateAngle;
 }
        /// <summary>
        /// The constructor of GOM_Object_Primitive
        /// </summary>
        public GOM_Object_Primitive()
        {
            m_id		= Guid.NewGuid().ToString("D");
            m_xOffset	= 0;
            m_yOffset	= 0;
            m_rotation	= 0;
            m_template	= null;

            GOM_Constraint_Set	constraintSet;

            m_boundingBox = new System.Drawing.RectangleF(0, 0, 0, 0);

            m_Top_Connector = new GOM_Point();
            m_Top_Connector.id = GOM_Special_Point_Name.TOP_CONNECTOR;
            m_Top_Connector.Connectable = true;

            m_Bottom_Connector = new GOM_Point();
            m_Bottom_Connector.id = GOM_Special_Point_Name.BOTTOM_CONNECTOR;
            m_Bottom_Connector.Connectable = true;

            m_Left_Connector = new GOM_Point();
            m_Left_Connector.id = GOM_Special_Point_Name.LEFT_CONNECTOR;
            m_Left_Connector.Connectable = true;

            m_Right_Connector = new GOM_Point();
            m_Right_Connector.id = GOM_Special_Point_Name.RIGHT_CONNECTOR;
            m_Right_Connector.Connectable = true;

            m_SE_Resize_Point			= new GOM_Point();
            m_SE_Resize_Point.id		= GOM_Special_Point_Name.SE_RESIZING_POINT;
            constraintSet				= new GOM_Constraint_Set();
            constraintSet.EditingMode	= "default";
            constraintSet.Add(new GOM_Resizing_SE_Constraint(this, m_SE_Resize_Point));
            m_SE_Resize_Point.Constraints.Add(constraintSet);

            m_NW_Resize_Point			= new GOM_Point();
            m_NW_Resize_Point.id		= GOM_Special_Point_Name.NW_RESIZING_POINT;
            constraintSet				= new GOM_Constraint_Set();
            constraintSet.EditingMode	= "default";
            constraintSet.Add(new GOM_Resizing_NW_Constraint(this, m_NW_Resize_Point));
            m_NW_Resize_Point.Constraints.Add(constraintSet);

            m_SW_Resize_Point			= new GOM_Point();
            m_SW_Resize_Point.id		= GOM_Special_Point_Name.SW_RESIZING_POINT;
            constraintSet				= new GOM_Constraint_Set();
            constraintSet.EditingMode	= "default";
            constraintSet.Add(new GOM_Resizing_SW_Constraint(this, m_SW_Resize_Point));
            m_SW_Resize_Point.Constraints.Add(constraintSet);

            m_NE_Resize_Point			= new GOM_Point();
            m_NE_Resize_Point.id		= GOM_Special_Point_Name.NE_RESIZING_POINT;
            constraintSet				= new GOM_Constraint_Set();
            constraintSet.EditingMode	= "default";
            constraintSet.Add(new GOM_Resizing_NE_Constraint(this, m_NE_Resize_Point));
            m_NE_Resize_Point.Constraints.Add(constraintSet);

            m_Rotation_Point			= new GOM_Point();
            m_Rotation_Point.id			= GOM_Special_Point_Name.ROTATION_POINT;
            constraintSet				= new GOM_Constraint_Set();
            constraintSet.EditingMode	= "default";
            constraintSet.Add(new GOM_Rotation_Constraint(this, m_Rotation_Point));
            m_Rotation_Point.Constraints.Add(constraintSet);

            innerText		= "";
            font			= new System.Drawing.Font("Tahoma", 10);
            fontColor		= System.Drawing.Color.Black;
            extScale		= false;
            extRotate		= false;
            extConnect		= false;
            keepAspectRatio = false;

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