/// <summary> /// Create a copy of current graphic object /// </summary> /// <returns></returns> public GOM_Interface_Graphic_Object Clone() { GOM_Object_Group obj; obj = new GOM_Object_Group(); obj.m_id = this.m_id; obj.m_xOffset = this.m_xOffset; obj.m_yOffset = this.m_yOffset; obj.m_rotation = this.m_rotation; for (int i = 0; i < this.rgObjects.Count; i++) { obj.rgObjects.Add(this.rgObjects[i].Clone()); } return obj; }
public static GOM_Object_Group CreateGroupObject(GOM_Objects rgObjs) { GOM_Object_Group group = null; System.Drawing.PointF pt; System.Drawing.RectangleF rc; if (rgObjs.Count > 0) { float minX, minY; rc = rgObjs[0].BoundingBox; pt = rgObjs[0].PointToCanvas(new System.Drawing.PointF(rc.Left, rc.Top)); minX = pt.X; minY = pt.Y; for (int i = 0; i < rgObjs.Count; i++) { rc = rgObjs[i].BoundingBox; pt = rgObjs[i].PointToCanvas(new System.Drawing.PointF(rc.Left, rc.Top)); minX = System.Math.Min(minX, pt.X); minY = System.Math.Min(minY, pt.Y); pt = rgObjs[i].PointToCanvas(new System.Drawing.PointF(rc.Left, rc.Bottom)); minX = System.Math.Min(minX, pt.X); minY = System.Math.Min(minY, pt.Y); pt = rgObjs[i].PointToCanvas(new System.Drawing.PointF(rc.Right, rc.Top)); minX = System.Math.Min(minX, pt.X); minY = System.Math.Min(minY, pt.Y); pt = rgObjs[i].PointToCanvas(new System.Drawing.PointF(rc.Right, rc.Bottom)); minX = System.Math.Min(minX, pt.X); minY = System.Math.Min(minY, pt.Y); } group = new GOM_Object_Group(); for (int i = 0; i < rgObjs.Count; i++) { rgObjs[i].xOffset -= minX; rgObjs[i].yOffset -= minY; group.rgObjects.Add(rgObjs[i]); } group.xOffset = minX; group.yOffset = minY; } group.CalculateBoundingBox(); return group; }