public void LoadConstraintsFromXML(System.Xml.XmlNode node, GOM_ResourceArrays resources)
        {
            GOM_Interface_Constraint	constraint;
            GOM_Constraint_Set			constraint_set;
            string						editingMode;
            for (int i = 0; i < node.ChildNodes.Count; i++)
            {
                if (System.String.Compare(node.ChildNodes[i].Name, GOM_TAGS.ON_POSITION_CHANGE, true) == 0)
                {
                    editingMode = "default";
                    for (int j = 0; j < node.ChildNodes[i].Attributes.Count; j++)
                    {
                        if (System.String.Compare(node.ChildNodes[i].Attributes[j].Name, GOM_TAGS.EDITING_MODE, true) == 0)
                        {
                            editingMode = node.ChildNodes[i].Attributes[j].Value;
                        }
                    }

                    constraint_set = new GOM_Constraint_Set();
                    constraint_set.EditingMode = editingMode;

                    for (int j = 0; j < node.ChildNodes[i].ChildNodes.Count; j++)
                    {
                        constraint = GOM_Utility.LoadConstraintFromXML(node.ChildNodes[i].ChildNodes[j],resources.Points);
                        if (constraint != null)
                        {
                            constraint_set.Add(constraint);
                        }
                    }

                    Constraints.Add(constraint_set);
                }
            }
        }
Пример #2
0
        public GOM_Object_Group()
        {
            m_id		= Guid.NewGuid().ToString("D");
            m_xOffset	= 0;
            m_yOffset	= 0;
            m_rotation	= 0;

            m_boundingBox = new System.Drawing.RectangleF();

            rgObjects	= new GOM_Objects();

            GOM_Constraint_Set	constraintSet;

            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);
        }
Пример #3
0
        /// <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
        }
Пример #4
0
        /// <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();
        }