internal static void StaticInvoke(CommandProcessorContext cpc, AssociationConnector associationConnector, Guid domainPropertyId) { var viewModel = associationConnector.GetRootViewModel(); Debug.Assert(viewModel != null, "Unable to find root view model from AssociationConnector: " + associationConnector); if (viewModel != null) { Connector modelAssociationConnector = viewModel.ModelXRef.GetExisting(associationConnector) as Model.Designer.AssociationConnector; if (modelAssociationConnector == null) { AssociationConnectorAdd.StaticInvoke(cpc, associationConnector); modelAssociationConnector = viewModel.ModelXRef.GetExisting(associationConnector) as Model.Designer.AssociationConnector; } Debug.Assert(modelAssociationConnector != null); if (modelAssociationConnector != null) { if (domainPropertyId == LinkShape.EdgePointsDomainPropertyId) { List <KeyValuePair <double, double> > points = null; if (associationConnector.ManuallyRouted && associationConnector.EdgePoints.Count > 0) { points = new List <KeyValuePair <double, double> >(associationConnector.EdgePoints.Count); foreach (EdgePoint point in associationConnector.EdgePoints) { points.Add(new KeyValuePair <double, double>(point.Point.X, point.Point.Y)); } } if (points != null) { var cmd = new SetConnectorPointsCommand(modelAssociationConnector, points); CommandProcessor.InvokeSingleCommand(cpc, cmd); } } else if (domainPropertyId == LinkShape.ManuallyRoutedDomainPropertyId) { // if the connectors are not manually routed, we need to clean up all the connector points in the association connectors. if (associationConnector.ManuallyRouted == false && modelAssociationConnector.ConnectorPoints != null && modelAssociationConnector.ConnectorPoints.Count > 0) { var points = new List <KeyValuePair <double, double> >(); var setConnectorPointCmd = new SetConnectorPointsCommand(modelAssociationConnector, points); CommandProcessor.InvokeSingleCommand(cpc, setConnectorPointCmd); } var cmd = new UpdateDefaultableValueCommand <bool>( modelAssociationConnector.ManuallyRouted, associationConnector.ManuallyRouted); CommandProcessor.InvokeSingleCommand(cpc, cmd); } } } }
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); } } }