Exemplo n.º 1
0
        internal void AutoPositionShape(EntityTypeShape entityTypeShape)
        {
            //determine initial nextX/nextY position and if we're going to start adding horizontally or vertically...
            if (_nextShapeX == null || _nextShapeY == null)
            {
                decimal diagramWidth  = DiagramWidth;
                decimal diagramHeight = DiagramHeight;
                if (diagramHeight > diagramWidth)
                {
                    _addVertical = true;
                    _nextShapeX  = diagramWidth + .75M;
                    _nextShapeY  = .75M;
                    _maxY        = diagramHeight;
                }
                else
                {
                    _addVertical = false;
                    _nextShapeX  = .75M;
                    _nextShapeY  = diagramHeight + .75M;
                    _maxX        = diagramWidth;
                }
            }

            //set position and size for the current element
            entityTypeShape.Top    = _nextShapeY.Value;
            entityTypeShape.Left   = _nextShapeX.Value;
            entityTypeShape.Width  = 1.5M;
            entityTypeShape.Height = 2M;

            //increase nextx/nexty depending on if we're adding horizontally or vertically
            if (_addVertical)
            {
                _nextShapeY = _nextShapeY.Value + 2.5M;
                if (_nextShapeY > _maxY)
                {
                    _nextShapeY = null;
                }
            }
            else
            {
                _nextShapeX = _nextShapeX.Value + 2M;
                if (_nextShapeX > _maxX)
                {
                    _nextShapeX = null;
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Adds an entity type shape to the diagram
        /// </summary>
        /// <param name="entityType">Model entity type to add to the diagram.</param>
        /// <returns>An EntityTypeShape object</returns>
        public EntityTypeShape AddEntityTypeShape(ModelEntityType entityType)
        {
            if (entityType == null)
            {
                throw new ArgumentNullException("entityType");
            }

            EntityTypeShape ets = EntityTypeShapes.FirstOrDefault(es => es.EntityType == entityType);

            if (ets == null)
            {
                ets          = new EntityTypeShape(ParentFile, this, entityType);
                ets.Removed += new EventHandler(ets_Removed);
                _entityTypeShapes.Add(ets.EntityTypeName, ets);
            }
            return(ets);
        }