internal static void StaticInvoke(CommandProcessorContext cpc, InheritanceConnector inheritanceConnector)
        {
            // if there was a circular inheritance, this connector will be deleted, if so, we just return
            if (inheritanceConnector.IsDeleted)
            {
                return;
            }

            var viewModel = inheritanceConnector.GetRootViewModel();

            Debug.Assert(
                viewModel != null, "Unable to find root view model from inheritance connector: " + inheritanceConnector.AccessibleName);

            if (viewModel != null)
            {
                var modelEntityTypeBase = viewModel.ModelXRef.GetExisting(inheritanceConnector.ModelElement) as EntityTypeBaseType;
                if (modelEntityTypeBase != null)
                {
                    var modelEntity  = modelEntityTypeBase.Parent as EntityType;
                    var modelDiagram = viewModel.ModelXRef.GetExisting(inheritanceConnector.Diagram) as Diagram;
                    Debug.Assert(modelEntity != null && modelDiagram != null);
                    if (modelEntity != null &&
                        modelDiagram != null)
                    {
                        var cmd = new CreateInheritanceConnectorCommand(modelDiagram, modelEntity);
                        CommandProcessor.InvokeSingleCommand(cpc, cmd);
                        var modelInheritanceConnector = cmd.InheritanceConnector;
                        viewModel.ModelXRef.Add(modelInheritanceConnector, inheritanceConnector, viewModel.EditingContext);
                    }
                }
            }
        }
        internal static void StaticInvoke(CommandProcessorContext cpc, InheritanceConnector inheritanceConnector)
        {
            // if there was a circular inheritance, this connector will be deleted, if so, we just return
            if (inheritanceConnector.IsDeleted)
            {
                return;
            }

            var viewModel = inheritanceConnector.GetRootViewModel();
            Debug.Assert(
                viewModel != null, "Unable to find root view model from inheritance connector: " + inheritanceConnector.AccessibleName);

            if (viewModel != null)
            {
                var modelEntityTypeBase = viewModel.ModelXRef.GetExisting(inheritanceConnector.ModelElement) as EntityTypeBaseType;
                if (modelEntityTypeBase != null)
                {
                    var modelEntity = modelEntityTypeBase.Parent as EntityType;
                    var modelDiagram = viewModel.ModelXRef.GetExisting(inheritanceConnector.Diagram) as Diagram;
                    Debug.Assert(modelEntity != null && modelDiagram != null);
                    if (modelEntity != null
                        && modelDiagram != null)
                    {
                        var cmd = new CreateInheritanceConnectorCommand(modelDiagram, modelEntity);
                        CommandProcessor.InvokeSingleCommand(cpc, cmd);
                        var modelInheritanceConnector = cmd.InheritanceConnector;
                        viewModel.ModelXRef.Add(modelInheritanceConnector, inheritanceConnector, viewModel.EditingContext);
                    }
                }
            }
        }
Example #3
0
        internal static void StaticInvoke(CommandProcessorContext cpc, InheritanceConnector inheritanceConnector, Guid domainPropertyId)
        {
            // The situation where inheritanceConnector.IsDeleted to be true is when the user is trying to create circular inheritance.
            // In that case, the inheritance connector creation is aborted but this rule could still be fired.
            if (inheritanceConnector.IsDeleted ||
                inheritanceConnector.IsDeleting)
            {
                return;
            }

            Connector modelInheritanceConnector = null;

            var viewModel = inheritanceConnector.GetRootViewModel();

            Debug.Assert(viewModel != null, "Unable to find root view model from inheritance connector: " + viewModel);
            if (viewModel != null)
            {
                modelInheritanceConnector = viewModel.ModelXRef.GetExisting(inheritanceConnector) as Model.Designer.InheritanceConnector;
                if (modelInheritanceConnector == null)
                {
                    InheritanceConnectorAdd.StaticInvoke(cpc, inheritanceConnector);
                    modelInheritanceConnector = viewModel.ModelXRef.GetExisting(inheritanceConnector) as Model.Designer.InheritanceConnector;
                }
            }

            // we should have a connector unless its been deleted due to circular inheritance checks
            Debug.Assert(
                modelInheritanceConnector != null || (modelInheritanceConnector == null && inheritanceConnector.IsDeleted),
                "We could not locate an underlying model item to change for this Inheritance connector");
            if (modelInheritanceConnector != null)
            {
                if (domainPropertyId == LinkShape.EdgePointsDomainPropertyId)
                {
                    List <KeyValuePair <double, double> > points = null;
                    if (inheritanceConnector.ManuallyRouted &&
                        inheritanceConnector.EdgePoints.Count > 0)
                    {
                        points = new List <KeyValuePair <double, double> >(inheritanceConnector.EdgePoints.Count);
                        foreach (EdgePoint point in inheritanceConnector.EdgePoints)
                        {
                            points.Add(new KeyValuePair <double, double>(point.Point.X, point.Point.Y));
                        }
                    }

                    if (points != null)
                    {
                        var cmd = new SetConnectorPointsCommand(modelInheritanceConnector, points);
                        CommandProcessor.InvokeSingleCommand(cpc, cmd);
                    }
                }
                else if (domainPropertyId == LinkShape.ManuallyRoutedDomainPropertyId)
                {
                    // if the connectors are not manually routed (the connectors are auto layout), we need to clear our the layout information in our model.
                    if (inheritanceConnector.ManuallyRouted == false &&
                        modelInheritanceConnector.ConnectorPoints != null &&
                        modelInheritanceConnector.ConnectorPoints.Count > 0)
                    {
                        var points = new List <KeyValuePair <double, double> >();
                        var setConnectorPointsCmd = new SetConnectorPointsCommand(modelInheritanceConnector, points);
                        CommandProcessor.InvokeSingleCommand(cpc, setConnectorPointsCmd);
                    }

                    var cmd = new UpdateDefaultableValueCommand <bool>(
                        modelInheritanceConnector.ManuallyRouted, inheritanceConnector.ManuallyRouted);
                    CommandProcessor.InvokeSingleCommand(cpc, cmd);
                }
            }
        }
Example #4
0
 internal InheritanceConnectorChange(InheritanceConnector inheritanceConnector, Guid domainPropertyId)
     : base(inheritanceConnector)
 {
     _domainPropertyId = domainPropertyId;
 }
 internal InheritanceConnectorAdd(InheritanceConnector inheritanceConnector)
     : base(inheritanceConnector)
 {
 }
        internal static void StaticInvoke(CommandProcessorContext cpc, InheritanceConnector inheritanceConnector, Guid domainPropertyId)
        {
            // The situation where inheritanceConnector.IsDeleted to be true is when the user is trying to create circular inheritance.
            // In that case, the inheritance connector creation is aborted but this rule could still be fired.
            if (inheritanceConnector.IsDeleted
                || inheritanceConnector.IsDeleting)
            {
                return;
            }

            Connector modelInheritanceConnector = null;

            var viewModel = inheritanceConnector.GetRootViewModel();
            Debug.Assert(viewModel != null, "Unable to find root view model from inheritance connector: " + viewModel);
            if (viewModel != null)
            {
                modelInheritanceConnector = viewModel.ModelXRef.GetExisting(inheritanceConnector) as Model.Designer.InheritanceConnector;
                if (modelInheritanceConnector == null)
                {
                    InheritanceConnectorAdd.StaticInvoke(cpc, inheritanceConnector);
                    modelInheritanceConnector = viewModel.ModelXRef.GetExisting(inheritanceConnector) as Model.Designer.InheritanceConnector;
                }
            }

            // we should have a connector unless its been deleted due to circular inheritance checks
            Debug.Assert(
                modelInheritanceConnector != null || (modelInheritanceConnector == null && inheritanceConnector.IsDeleted),
                "We could not locate an underlying model item to change for this Inheritance connector");
            if (modelInheritanceConnector != null)
            {
                if (domainPropertyId == LinkShape.EdgePointsDomainPropertyId)
                {
                    List<KeyValuePair<double, double>> points = null;
                    if (inheritanceConnector.ManuallyRouted
                        && inheritanceConnector.EdgePoints.Count > 0)
                    {
                        points = new List<KeyValuePair<double, double>>(inheritanceConnector.EdgePoints.Count);
                        foreach (EdgePoint point in inheritanceConnector.EdgePoints)
                        {
                            points.Add(new KeyValuePair<double, double>(point.Point.X, point.Point.Y));
                        }
                    }

                    if (points != null)
                    {
                        var cmd = new SetConnectorPointsCommand(modelInheritanceConnector, points);
                        CommandProcessor.InvokeSingleCommand(cpc, cmd);
                    }
                }
                else if (domainPropertyId == LinkShape.ManuallyRoutedDomainPropertyId)
                {
                    // if the connectors are not manually routed (the connectors are auto layout), we need to clear our the layout information in our model.
                    if (inheritanceConnector.ManuallyRouted == false
                        && modelInheritanceConnector.ConnectorPoints != null
                        && modelInheritanceConnector.ConnectorPoints.Count > 0)
                    {
                        var points = new List<KeyValuePair<double, double>>();
                        var setConnectorPointscmd = new SetConnectorPointsCommand(modelInheritanceConnector, points);
                        CommandProcessor.InvokeSingleCommand(cpc, setConnectorPointscmd);
                    }

                    var cmd = new UpdateDefaultableValueCommand<bool>(
                        modelInheritanceConnector.ManuallyRouted, inheritanceConnector.ManuallyRouted);
                    CommandProcessor.InvokeSingleCommand(cpc, cmd);
                }
            }
        }
 internal InheritanceConnectorChange(InheritanceConnector inheritanceConnector, Guid domainPropertyId)
     : base(inheritanceConnector)
 {
     _domainPropertyId = domainPropertyId;
 }
 internal InheritanceConnectorAdd(InheritanceConnector inheritanceConnector)
     : base(inheritanceConnector)
 {
 }