コード例 #1
0
        // Note: ViewModel methods are only used for internal update related to Quantum events
        // If you want to add a block or link, please use GraphicsCompositorViewModel through Asset property
        private void AddLinkViewModel(Link link)
        {
            BlockNodeVertex source, target;

            if (!blockMapping.TryGetValue(link.Source.Owner, out source) ||
                !blockMapping.TryGetValue(link.Target.Owner, out target))
            {
                throw new InvalidOperationException("Could not find source or target block when creating a link");
            }

            VisualScriptSlotViewModel linkSource, linkTarget;

            if (!source.ViewModel.Slots.TryGetValue(link.Source, out linkSource) ||
                !target.ViewModel.Slots.TryGetValue(link.Target, out linkTarget))
            {
                throw new InvalidOperationException("Could not find source or target slot when creating a link");
            }

            var viewModel    = new VisualScriptLinkViewModel(this, link, linkSource, linkTarget);
            var linkNodeEdge = new LinkNodeEdge(viewModel, source, target);

            // Update initial diagnostics (if any)
            foreach (var diagnostic in editor.Diagnostics.Where(x => x.LinkId.HasValue && x.LinkId.Value == link.Id))
            {
                linkNodeEdge.ViewModel.Diagnostics.Add(diagnostic);
            }

            links.Add(linkNodeEdge);
            linkMapping.Add(link, linkNodeEdge);

            // Add ourselves to slot.Links
            linkSource.Links.Add(viewModel);
            linkTarget.Links.Add(viewModel);
        }
コード例 #2
0
ファイル: LinkNodeEdge.cs プロジェクト: Beefr/xenko-wd
 internal LinkNodeEdge(VisualScriptLinkViewModel viewModel, BlockNodeVertex source, BlockNodeVertex target) : base(source, target)
 {
     ViewModel  = viewModel;
     SourceSlot = viewModel.SourceSlot;
     TargetSlot = viewModel.TargetSlot;
     if (SourceSlot == null || TargetSlot == null)
     {
         throw new InvalidOperationException("Could not find appropriate slots for this link");
     }
 }