private void AddConns(int connNumber) { if (connNumber == 1) { RemoveInputPortFromNode(InputPorts.Last()); } else { for (var i = 0; i < connNumber - 2; i++) { AddInputPortToNode("Item" + (i + 1), typeof(object)); } } }
private void minusButton_Click(object sender, RoutedEventArgs e) { if (InputPorts.Count <= 1) { return; } RemoveInputPortFromNode(InputPorts.Last()); Calculate(); if (InputPorts.Count != 1) { return; } var grid = ControlElements[0] as Grid; if (grid != null) { grid.Children[1].IsEnabled = false; } }
public void StartCSharpCompilation(object sender, EventArgs eventArgs) { if (TopComment.Visibility == Visibility.Visible) { TopComment.Visibility = Visibility.Hidden; TopComment.HostNode_PropertyChanged(null, null); } scriptingControl.CurrentFile.ScriptContent = scriptingControl.TextEditor.Text; // Define the Input for the Script try { mScriptCompiler = new Lazy <CSharpScriptCompiler>(); //Compile and execute current script var result = mScriptCompiler.Value.Compile(scriptingControl.CurrentFile as CSharpScriptFile); if (result.GetType() == typeof(CompilerErrorCollection)) { var compilerErrors = new StringBuilder(); var compilerErrorCollection = result as CompilerErrorCollection; if (compilerErrorCollection == null) { throw new InvalidOperationException( "Unable to compile scripts: " + compilerErrors); } foreach (var actError in compilerErrorCollection) { compilerErrors.Append("" + actError + Environment.NewLine); } TopComment.Text = compilerErrors.ToString(); TopComment.Visibility = Visibility.Visible; TopComment.HostNode_PropertyChanged(null, null); throw new InvalidOperationException( "Unable to compile scripts: " + compilerErrors); } var parameter = mScriptCompiler.Value.ScriptMethod.GetParameters(); var counter = 0; foreach (var para in parameter) { if (counter < InputPorts.Count) { if (para.ParameterType.IsGenericType) { InputPorts[counter].MultipleConnectionsAllowed = true; InputPorts[counter].DataType = para.ParameterType.GetGenericArguments()[0]; } else { InputPorts[counter].DataType = para.ParameterType; } InputPorts[counter].Name = para.Name; } else { if (para.ParameterType.IsGenericType) { AddInputPortToNode(para.Name, para.ParameterType.GetGenericArguments()[0], true); } else { AddInputPortToNode(para.Name, para.ParameterType); } } counter++; } while (counter < InputPorts.Count()) { RemoveInputPortFromNode(InputPorts.Last()); } Calculate(); TopComment.Text = ""; TopComment.Visibility = Visibility.Collapsed; } catch (Exception e) { TopComment.Text = e.ToString(); TopComment.Visibility = Visibility.Visible; TopComment.HostNode_PropertyChanged(null, null); Console.WriteLine(e.Message); } }