private void RenderPreview(ComboBoxEdit imageComboBox, CardinalityShape cardi)
        {
            switch (imageComboBox.EditValue.ToString())
            {
            case "0, 1": cardi.setValue(0, 1);
                break;

            case "1, 1": cardi.setValue(1, 1);
                break;

            case "0, n": cardi.setValue(0, -1);
                break;

            case "1, n": cardi.setValue(1, -1);
                break;
            }

            panelDoubleBuffered1.Refresh();
        }
Esempio n. 2
0
        public static void DrawCardinalitiesLine(Graphics g, CardinalityShape cardi, int EntityEdgeCardiPlace, int pos, int numCardi, Color backgroundColor)
        {
            EntityShape       entity = cardi.Entity;
            RelationshipShape rel    = cardi.Relationship;

            //debug
            //g.DrawLine(new Pen(Color.Red, 1), entity.CenterPoint, rel.CenterPoint);

            Point centerRelationship = rel.CenterPoint;
            Point centerEntity       = entity.CenterPoint;

            Point TopLeft     = entity.Location;
            Point BottomRight = new Point(entity.Location.X + entity.Width, entity.Location.Y + entity.Height);

            int stepX = pos * entity.Width / (numCardi + 1);
            int stepY = pos * entity.Height / (numCardi + 1);

            Bitmap myCardi = GetCardinalitiesShape(cardi, EntityEdgeCardiPlace, backgroundColor);

            Point EntityStartPos = getStartPos(EntityEdgeCardiPlace, (ShapeBase)entity, TopLeft, BottomRight, stepX, stepY, myCardi);
            Point EntityCardiPos = getCardiPos(EntityEdgeCardiPlace, (ShapeBase)entity, TopLeft, BottomRight, stepX, stepY, myCardi);

            if (rel.type != RelationshipType.AssociativeEntity)
            {
                g.DrawImage(myCardi, EntityCardiPos);
                g.DrawLine(ThongSo.ConectiveLinePen, EntityStartPos, centerRelationship);
            }
            else //nếu relationship là Associative Entity
            {
                Point TopLeftRel     = rel.Location;
                Point BottomRightRel = new Point(rel.Location.X + rel.Width, rel.Location.Y + rel.Height);

                int AssEdgeCardiPlace = 0, index = 0;
                rel.getCardiPosition(cardi, ref AssEdgeCardiPlace, ref index);

                int stepXRel = (index + 1) * rel.Width / (rel.cardiplaces[AssEdgeCardiPlace - 1].Count + 1);
                int stepYRel = (index + 1) * rel.Height / (rel.cardiplaces[AssEdgeCardiPlace - 1].Count + 1);

                //cardi 1, 1
                CardinalityShape cardi1 = new CardinalityShape();
                cardi1.setValue(1, 1);

                //lấy cardi của đầu bên kia Relationship
                CardinalityShape cardi2 = new CardinalityShape();
                foreach (CardinalityShape card in cardi.Relationship.cardinalities)
                {
                    if (card != cardi)
                    {
                        cardi2 = card;
                    }
                }

                Bitmap CardiAtEn  = GetCardinalitiesShape(cardi1, EntityEdgeCardiPlace, backgroundColor);
                Bitmap CardiAtRel = GetCardinalitiesShape(cardi2, AssEdgeCardiPlace, backgroundColor);

                Point AssStartPos = getStartPos(AssEdgeCardiPlace, (ShapeBase)rel, TopLeftRel, BottomRightRel, stepXRel, stepYRel, CardiAtRel);
                Point AssCardiPos = getCardiPos(AssEdgeCardiPlace, (ShapeBase)rel, TopLeftRel, BottomRightRel, stepXRel, stepYRel, CardiAtRel);

                g.DrawImage(CardiAtEn, EntityCardiPos);
                g.DrawImage(CardiAtRel, AssCardiPos);
                g.DrawLine(ThongSo.ConectiveLinePen, EntityStartPos, AssStartPos);
            }
        }