private static void HandleAddLoopBorrowTunnel(object parameter, IEnumerable <IViewModel> selection, ICompositionHost host, DocumentEditSite site) { var structureViewModels = selection.OfType <LoopViewModel>().WhereNotNull(); if (structureViewModels.Any()) { using (var transaction = structureViewModels.First().TransactionManager.BeginTransaction("Add Borrow Tunnels", TransactionPurpose.User)) { foreach (var structureViewModel in structureViewModels) { SMRect leftRect, rightRect; BorderNodeViewModelHelpers.FindBorderNodePositions(structureViewModel, out leftRect, out rightRect); var model = (Structure)structureViewModel.Model; LoopBorrowTunnel borrowTunnel = model.MakeBorderNode <LoopBorrowTunnel>(); LoopTerminateLifetimeTunnel loopTerminateLifetimeTunnel = model.MakeBorderNode <LoopTerminateLifetimeTunnel>(); borrowTunnel.TerminateLifetimeTunnel = loopTerminateLifetimeTunnel; loopTerminateLifetimeTunnel.BeginLifetimeTunnel = borrowTunnel; // Set both as rules were not consistently picking right one to adjust to other. borrowTunnel.Top = leftRect.Y; borrowTunnel.Left = leftRect.X; loopTerminateLifetimeTunnel.Top = borrowTunnel.Top; loopTerminateLifetimeTunnel.Left = rightRect.X; } transaction.Commit(); } } }
public LoopBorrowTunnelViewModel(LoopBorrowTunnel loopBorrowTunnel) : base(loopBorrowTunnel, @"Resources\Diagram\Nodes\ImmutableBorrowNode.png") { }