public override void OnExecute(Connector prevConnector) { base.OnExecute(prevConnector); NodePropertyPort portObject = NodeGraphManager.FindNodePropertyPort(this, "Objects"); List <NodePort> connectedPorts; NodeGraphManager.FindConnectedPorts(portObject, out connectedPorts); if (0 < connectedPorts.Count) { foreach (var connectedPort in connectedPorts) { NodePropertyPort port = connectedPort as NodePropertyPort; string result = string.Empty; if (null != port.Value) { result = string.Format("{0}", port.Value.ToString()); NodeGraphManager.AddScreenLog(Owner, result); } } } else { ExecutionState = NodeExecutionState.Failed; } }
public override void OnCreate() { PortLHS = createPort("Lhs", true, true); PortRHS = createPort("Rhs", true, true); PortOutput = createPort("Output", false, false); base.OnCreate(); }
public FrameworkElement CreateBoolEditor() { NodePropertyPort port = ViewModel.Model as NodePropertyPort; CheckBox textBox = new CheckBox(); textBox.IsChecked = ( bool )port.Value; textBox.SetBinding(CheckBox.IsCheckedProperty, CreateBinding(port, "Value", null)); return(textBox); }
public FrameworkElement CreateColorEditor() { NodePropertyPort port = ViewModel.Model as NodePropertyPort; ColorPicker picker = new ColorPicker(); picker.SelectedColor = ( Color )port.Value; picker.SetBinding(ColorPicker.SelectedColorProperty, CreateBinding(port, "Value", null)); return(picker); }
public override void OnCreate() { NodePropertyPort port = NodeGraphManager.CreateNodePropertyPort( false, Guid.NewGuid(), this, false, typeof(ObservableCollection <T>), Array, "Array", true); port.DynamicPropertyPortValueChanged += ArrayPort_DynamicPropertyPortValueChanged; base.OnCreate(); }
public FrameworkElement CreateStringEditor() { NodePropertyPort port = ViewModel.Model as NodePropertyPort; TextBoxEx textBox = new TextBoxEx(); textBox.Text = port.Value.ToString(); textBox.SetBinding(TextBox.TextProperty, CreateBinding(port, "Value", null)); return(textBox); }
private void CreatePropertyEditor() { NodePropertyPort port = ViewModel.Model as NodePropertyPort; if (port.HasEditor) { Type type = port.ValueType; if (typeof(bool) == type) { PropertyEditor = CreateBoolEditor(); } else if (typeof(string) == type) { PropertyEditor = CreateStringEditor(); } else if (typeof(byte) == type) { PropertyEditor = CreateByteEditor(); } else if (typeof(short) == type) { PropertyEditor = CreateShortEditor(); } else if (typeof(int) == type) { PropertyEditor = CreateIntEditor(); } else if (typeof(long) == type) { PropertyEditor = CreateLongEditor(); } else if (typeof(float) == type) { PropertyEditor = CreateFloatEditor(); } else if (typeof(double) == type) { PropertyEditor = CreateDoubleEditor(); } else if (type.IsEnum) { PropertyEditor = CreateEnumEditor(); } else if (typeof(Color) == type) { PropertyEditor = CreateColorEditor(); } if (null != PropertyEditor) { PropertyEditorVisibility = Visibility.Visible; } } }
private void EnumComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { NodePropertyPort port = ViewModel.Model as NodePropertyPort; ComboBox comboBox = PropertyEditor as ComboBox; if (null != comboBox) { port.Value = comboBox.SelectedItem; } }
public FrameworkElement CreateDoubleEditor() { NodePropertyPort port = ViewModel.Model as NodePropertyPort; NumericTextBox textBox = new NumericTextBox(); textBox.IsInteger = false; textBox.Text = port.Value.ToString(); textBox.SetBinding(TextBox.TextProperty, CreateBinding(port, "Value", new DoubleToStringConverter())); return(textBox); }
public override void OnCreate() { Type type = typeof(T); NodePropertyPort port = NodeGraphManager.CreateNodePropertyPort( false, Guid.NewGuid(), this, false, type, Activator.CreateInstance(type), "Value", true, null, ""); port.DynamicPropertyPortValueChanged += ValuePort_PropertyPortValueChanged; base.OnCreate(); }
public Binding CreateBinding(NodePropertyPort port, string propertyName, IValueConverter converter) { var binding = new Binding(propertyName) { Source = port, Mode = BindingMode.TwoWay, Converter = converter, UpdateSourceTrigger = UpdateSourceTrigger.Default, ValidatesOnDataErrors = true, ValidatesOnExceptions = true }; return(binding); }
public override void OnExecute(Connector prevConnector) { base.OnExecute(prevConnector); NodePropertyPort portOutputArray = NodeGraphManager.FindNodePropertyPort(this, "Array"); ObservableCollection <object> array = portOutputArray.Value as ObservableCollection <object>; array.Clear(); NodePropertyPort portObjects = NodeGraphManager.FindNodePropertyPort(this, "Objects"); List <NodePort> connectedPorts; NodeGraphManager.FindConnectedPorts(portObjects, out connectedPorts); foreach (var connectedPort in connectedPorts) { NodePropertyPort portObject = connectedPort as NodePropertyPort; array.Add(portObject.Value); } }
public override void OnExecute(Connector prevConnector) { base.OnExecute(prevConnector); NodePropertyPort portA = NodeGraphManager.FindNodePropertyPort(this, "A"); NodePropertyPort portB = NodeGraphManager.FindNodePropertyPort(this, "B"); List <NodePort> connectedPorts; NodeGraphManager.FindConnectedPorts(portA, out connectedPorts); NodePropertyPort otherPortA = (0 < connectedPorts.Count) ? connectedPorts[0] as NodePropertyPort : null; int a = (null != otherPortA) ? ( int )otherPortA.Value : A; NodeGraphManager.FindConnectedPorts(portB, out connectedPorts); NodePropertyPort otherPortB = (0 < connectedPorts.Count) ? connectedPorts[0] as NodePropertyPort : null; int b = (null != otherPortB) ? ( int )otherPortB.Value : B; Result = a - b; RaisePropertyChanged("Result"); }
public FrameworkElement CreateEnumEditor() { NodePropertyPort port = ViewModel.Model as NodePropertyPort; Array array = Enum.GetValues(port.ValueType); int selectedIndex = -1; for (int i = 0; i < array.Length; ++i) { if (port.Value.ToString() == array.GetValue(i).ToString()) { selectedIndex = i; break; } } ComboBox comboBox = new ComboBox(); comboBox.SelectionChanged += EnumComboBox_SelectionChanged; comboBox.ItemsSource = array; comboBox.SelectedIndex = selectedIndex; return(comboBox); }
public override void OnExecute(Connector prevConnector) { base.OnExecute(prevConnector); NodePropertyPort portInputArray = NodeGraphManager.FindNodePropertyPort(this, "Array"); NodePropertyPort portArrayElement = NodeGraphManager.FindNodePropertyPort(this, "ArrayElement"); NodePropertyPort portArrayIndex = NodeGraphManager.FindNodePropertyPort(this, "ArrayIndex"); NodeFlowPort loopBodyPort = NodeGraphManager.FindNodeFlowPort(this, "LoopBody"); List <NodePort> connectedPorts; NodeGraphManager.FindConnectedPorts(portInputArray, out connectedPorts); ObservableCollection <object> array = portInputArray.Value as ObservableCollection <object>; if (1 == connectedPorts.Count) { NodePropertyPort portOutputArray = connectedPorts[0] as NodePropertyPort; array = portOutputArray.Value as ObservableCollection <object>; } Connector connector = (1 == loopBodyPort.Connectors.Count) ? loopBodyPort.Connectors[0] : null; if ((null != array) && (null != connector)) { for (int i = 0; i < array.Count; ++i) { portArrayIndex.Value = i; portArrayElement.Value = array[i]; connector.OnPreExecute(); connector.OnExecute(); connector.OnPostExecute(); } } }
private void ValuePort_PropertyPortValueChanged(NodePropertyPort port, object prevValue, object newValue) { Value = (T)port.Value; RegisterStateChange(); }
private void ArrayPort_DynamicPropertyPortValueChanged(NodePropertyPort port, object prevValue, object newValue) { Array = port.Value as ObservableCollection <T>; Array.CollectionChanged += _Array_CollectionChanged; }
public NodePropertyPortViewModel(NodePropertyPort nodeProperty) : base(nodeProperty) { Model = nodeProperty; }