Ejemplo n.º 1
0
        internal BlockNodeVertex(VisualScriptBlockViewModel viewModel)
        {
            ViewModel   = viewModel;
            InputSlots  = new ObservableCollection <object>();
            OutputSlots = new ObservableCollection <object>();

            // Add initial slots (if any)
            foreach (var slot in viewModel.Block.Slots)
            {
                var slots         = slot.Direction == SlotDirection.Input ? InputSlots : OutputSlots;
                var slotViewModel = new VisualScriptSlotViewModel(viewModel, slot);
                slots.Add(slotViewModel);
                viewModel.Slots.Add(slot, slotViewModel);
            }

            // Setup listener to be aware of future changes
            viewModel.Block.Slots.CollectionChanged += Slots_CollectionChanged;
        }
        private async Task AddBlockViewModel(Block block)
        {
            using (var transaction = editor.UndoRedoService.CreateTransaction(TransactionFlags.KeepParentsAlive))
            {
                var viewModel       = new VisualScriptBlockViewModel(this, block);
                var blockNodeVertex = new BlockNodeVertex(viewModel);

                // Update initial diagnostics (if any)
                foreach (var diagnostic in editor.Diagnostics.Where(x => x.BlockId.HasValue && x.BlockId.Value == block.Id))
                {
                    viewModel.Diagnostics.Add(diagnostic);
                }

                blocks.Add(blockNodeVertex);
                blockMapping.Add(block, blockNodeVertex);

                // (Re)generate slots
                await this.method.RegenerateSlots(block);

                editor.UndoRedoService.SetName(transaction, "Added block");
            }
        }
Ejemplo n.º 3
0
 public VisualScriptSlotViewModel(VisualScriptBlockViewModel block, Slot slot) : base(block.SafeArgument(nameof(block)).ServiceProvider)
 {
     this.Block    = block;
     this.slot     = slot;
     this.slotNode = block.Method.Editor.Session.AssetNodeContainer.GetOrCreateNode(slot);
 }