Пример #1
0
        protected override void InvokeInternal(CommandProcessorContext cpc)
        {
            var nExistingTypeShapeCount =
                _entity.GetAntiDependenciesOfType <EntityTypeShape>().Count(ets => ets.Diagram.Id == _diagram.Id.Value);

            Debug.Assert(
                nExistingTypeShapeCount == 0,
                "There is already Entity Type Shape for entity :" + _entity.Name + " in the diagram " + _diagram.Name);

            if (nExistingTypeShapeCount == 0)
            {
                var shape = new EntityTypeShape(_diagram, null);
                _diagram.AddEntityTypeShape(shape);

                shape.EntityType.SetRefName(_entity);
                shape.Width.Value = DEFAULTWIDTH;

                // The DSL will set the correct locations for the shapes at a later point, but we need to provide initial values for X and Y in the meantime
                // so that we can construct the shape. We're using random numbers here to ensure that if the DSL fails for some reason, new shapes do not
                // stack directly on top of each other.
                shape.PointX.Value = _rand.NextDouble() * 12.0;
                shape.PointY.Value = _rand.NextDouble() * 32.0;

                if (_fillColor != EntityDesignerDiagramConstant.EntityTypeShapeDefaultFillColor)
                {
                    shape.FillColor.Value = _fillColor;
                }

                XmlModelHelper.NormalizeAndResolve(shape);

                _created = shape;
            }
        }