Example #1
0
        internal static void StaticInvoke(CommandProcessorContext cpc, EntityTypeShape entityTypeShape, Guid domainPropertyId)
        {
            var viewModel = entityTypeShape.GetRootViewModel();

            Debug.Assert(viewModel != null, "Unable to find root view model from entity type shape:" + entityTypeShape.AccessibleName);

            if (viewModel != null)
            {
                var modelEntityShape = viewModel.ModelXRef.GetExisting(entityTypeShape) as Model.Designer.EntityTypeShape;

                // If ModelXRef does not contain about model EntityTypeShape,try to get the information through DSL Model Element
                if (modelEntityShape == null)
                {
                    var modelDiagram = viewModel.ModelXRef.GetExisting(viewModel.GetDiagram()) as Diagram;
                    var entityType   = viewModel.ModelXRef.GetExisting(entityTypeShape.ModelElement) as EntityType;
                    Debug.Assert(modelDiagram != null, "Why Escher Diagram is null?");
                    Debug.Assert(entityType != null, "Why there is no XRef between Escher EntityType and DSL EntityT?");
                    if (modelDiagram != null &&
                        entityType != null)
                    {
                        modelEntityShape =
                            entityType.GetAntiDependenciesOfType <Model.Designer.EntityTypeShape>()
                            .FirstOrDefault(ets => ets.Diagram.Id == modelDiagram.Id.Value);
                    }

                    if (modelEntityShape != null)
                    {
                        viewModel.ModelXRef.Add(modelEntityShape, entityTypeShape, cpc.EditingContext);
                    }
                }

                // if modelentityshape is still null, create one
                if (modelEntityShape == null)
                {
                    EntityTypeShapeAdd.StaticInvoke(cpc, entityTypeShape);
                    modelEntityShape = viewModel.ModelXRef.GetExisting(entityTypeShape) as Model.Designer.EntityTypeShape;
                }
                Debug.Assert(modelEntityShape != null);
                if (modelEntityShape != null)
                {
                    if (domainPropertyId == NodeShape.AbsoluteBoundsDomainPropertyId)
                    {
                        var cp = new CommandProcessor(cpc);
                        cp.EnqueueCommand(
                            new UpdateDefaultableValueCommand <double>(modelEntityShape.PointX, entityTypeShape.AbsoluteBounds.X));
                        cp.EnqueueCommand(
                            new UpdateDefaultableValueCommand <double>(modelEntityShape.PointY, entityTypeShape.AbsoluteBounds.Y));
                        cp.EnqueueCommand(
                            new UpdateDefaultableValueCommand <double>(modelEntityShape.Width, entityTypeShape.AbsoluteBounds.Width));
                        cp.Invoke();
                    }
                    else if (domainPropertyId == NodeShape.IsExpandedDomainPropertyId)
                    {
                        var cmd = new UpdateDefaultableValueCommand <bool>(modelEntityShape.IsExpanded, entityTypeShape.IsExpanded);
                        CommandProcessor.InvokeSingleCommand(cpc, cmd);
                    }
                }
            }
        }
        internal static void StaticInvoke(CommandProcessorContext cpc, EntityTypeShape entityTypeShape, Guid domainPropertyId)
        {
            var viewModel = entityTypeShape.GetRootViewModel();
            Debug.Assert(viewModel != null, "Unable to find root view model from entity type shape:" + entityTypeShape.AccessibleName);

            if (viewModel != null)
            {
                var modelEntityShape = viewModel.ModelXRef.GetExisting(entityTypeShape) as Model.Designer.EntityTypeShape;

                // If ModelXRef does not contain about model EntityTypeShape,try to get the information through DSL Model Element
                if (modelEntityShape == null)
                {
                    var modelDiagram = viewModel.ModelXRef.GetExisting(viewModel.GetDiagram()) as Diagram;
                    var entityType = viewModel.ModelXRef.GetExisting(entityTypeShape.ModelElement) as EntityType;
                    Debug.Assert(modelDiagram != null, "Why Escher Diagram is null?");
                    Debug.Assert(entityType != null, "Why there is no XRef between Escher EntityType and DSL EntityT?");
                    if (modelDiagram != null
                        && entityType != null)
                    {
                        modelEntityShape =
                            entityType.GetAntiDependenciesOfType<Model.Designer.EntityTypeShape>()
                            .FirstOrDefault(ets => ets.Diagram.Id == modelDiagram.Id.Value);
                    }

                    if (modelEntityShape != null)
                    {
                        viewModel.ModelXRef.Add(modelEntityShape, entityTypeShape, cpc.EditingContext);
                    }
                }

                // if modelentityshape is still null, create one
                if (modelEntityShape == null)
                {
                    EntityTypeShapeAdd.StaticInvoke(cpc, entityTypeShape);
                    modelEntityShape = viewModel.ModelXRef.GetExisting(entityTypeShape) as Model.Designer.EntityTypeShape;
                }
                Debug.Assert(modelEntityShape != null);
                if (modelEntityShape != null)
                {
                    if (domainPropertyId == NodeShape.AbsoluteBoundsDomainPropertyId)
                    {
                        var cp = new CommandProcessor(cpc);
                        cp.EnqueueCommand(
                            new UpdateDefaultableValueCommand<double>(modelEntityShape.PointX, entityTypeShape.AbsoluteBounds.X));
                        cp.EnqueueCommand(
                            new UpdateDefaultableValueCommand<double>(modelEntityShape.PointY, entityTypeShape.AbsoluteBounds.Y));
                        cp.EnqueueCommand(
                            new UpdateDefaultableValueCommand<double>(modelEntityShape.Width, entityTypeShape.AbsoluteBounds.Width));
                        cp.Invoke();
                    }
                    else if (domainPropertyId == NodeShape.IsExpandedDomainPropertyId)
                    {
                        var cmd = new UpdateDefaultableValueCommand<bool>(modelEntityShape.IsExpanded, entityTypeShape.IsExpanded);
                        CommandProcessor.InvokeSingleCommand(cpc, cmd);
                    }
                }
            }
        }
Example #3
0
        internal static void StaticInvoke(CommandProcessorContext cpc, EntityTypeShape entityTypeShape)
        {
            var viewModel = entityTypeShape.GetRootViewModel();

            Debug.Assert(viewModel != null, "Unable to find root view model from entity-type-shape:" + entityTypeShape.AccessibleName);
            if (viewModel != null)
            {
                var entityType = viewModel.ModelXRef.GetExisting(entityTypeShape.ModelElement) as EntityType;
                var diagram    = viewModel.ModelXRef.GetExisting(entityTypeShape.Diagram) as Diagram;
                Debug.Assert(entityType != null && diagram != null);
                if (entityType != null &&
                    diagram != null)
                {
                    var cmd = new CreateEntityTypeShapeCommand(diagram, entityType);
                    CommandProcessor.InvokeSingleCommand(cpc, cmd);
                    var modelEntityShape = cmd.EntityTypeShape;
                    Debug.Assert(modelEntityShape != null);
                    viewModel.ModelXRef.Add(modelEntityShape, entityTypeShape, viewModel.EditingContext);
                }
            }
        }
        internal static void StaticInvoke(CommandProcessorContext cpc, EntityTypeShape entityTypeShape)
        {
            var viewModel = entityTypeShape.GetRootViewModel();

            Debug.Assert(viewModel != null, "Unable to find root view model from entity-type-shape:" + entityTypeShape.AccessibleName);
            if (viewModel != null)
            {
                var entityType = viewModel.ModelXRef.GetExisting(entityTypeShape.ModelElement) as EntityType;
                var diagram = viewModel.ModelXRef.GetExisting(entityTypeShape.Diagram) as Diagram;
                Debug.Assert(entityType != null && diagram != null);
                if (entityType != null
                    && diagram != null)
                {
                    var cmd = new CreateEntityTypeShapeCommand(diagram, entityType);
                    CommandProcessor.InvokeSingleCommand(cpc, cmd);
                    var modelEntityShape = cmd.EntityTypeShape;
                    Debug.Assert(modelEntityShape != null);
                    viewModel.ModelXRef.Add(modelEntityShape, entityTypeShape, viewModel.EditingContext);
                }
            }
        }