public EdgeConnectorListener(BaseGraphView _graphView) { GraphView = _graphView; }
public void SetUp(BaseNode _nodeViewModel, CommandDispatcher _commandDispatcher, BaseGraphView _graphView) { Model = _nodeViewModel; CommandDispatcher = _commandDispatcher; Owner = _graphView; // 绑定 BindingProperties(); InitializePorts(); RefreshPorts(); foreach (var fieldInfo in Model.GetNodeFieldInfos()) { // 如果不是接口,跳过 if (!PortViews.TryGetValue(fieldInfo.Name, out NodePortView portView)) { continue; } if (portView.direction != Direction.Input) { continue; } if (portView.orientation != Orientation.Horizontal) { continue; } var box = new VisualElement { name = fieldInfo.Name }; box.AddToClassList("port-input-element"); if (Utility_Attribute.TryGetFieldInfoAttribute(fieldInfo, out ShowAsDrawer showAsDrawer)) { BindableElement fieldDrawer = UIElementsFactory.CreateField(String.Empty, fieldInfo.FieldType, Model.GetFieldInfoValue(fieldInfo), (newValue) => { IBindableProperty property; if (!string.IsNullOrEmpty(showAsDrawer.targetBindablePropertyName) && (property = Model.GetBindableProperty(showAsDrawer.targetBindablePropertyName)) != null) { property.ValueBoxed = newValue; Owner.SetDirty(); } }); if (fieldDrawer != null) { box.Add(fieldDrawer); box.visible = !portView.Model.IsConnected; portView.onConnected += () => { box.visible = false; }; portView.onDisconnected += () => { box.visible = !portView.connected; }; } } else { box.visible = false; box.style.height = portView.style.height; } inputContainerElement.Add(box); } }