MultiCondition


Node Information
Compares multiple values with specified conditions, if all conditions are met then TRUE will be called else FALSE will be called.
General Information
• This node has other options, you can view them by clicking on the info button, this also means according to the node you might be able to add more ports than what is already listed.
Visual
Visual

Ports
Text Type DataType Accepts IsList CustomAcception
A IN Object ONE FALSE FALSE
== IN OP NONE FALSE FALSE
B IN Object ONE FALSE FALSE
True OUT RUN MULTIPLE FALSE FALSE
False OUT RUN MULTIPLE FALSE FALSE

Source
namespace Korduene.KGraph.Nodes.Conditions
{
    [IsNode("MultiCondition")]
    public class MultiCondition : Node
    {
        Port a = new Port(PortType.IN, typeof(object), AcceptsLinks.ONE, "A");
        Port c = new Port(PortType.IN, typeof(OP), AcceptsLinks.NONE, "==");
        Port b = new Port(PortType.IN, typeof(object), AcceptsLinks.ONE, "B");
        Port tr = new Port(PortType.OUT, typeof(RUN), AcceptsLinks.MULTIPLE, "True");
        Port fl = new Port(PortType.OUT, typeof(RUN), AcceptsLinks.MULTIPLE, "False");
        public MultiCondition()
        {
            NodeType = KGraph.NodeType.Method;
            this.Name = "MultiCondition";
            AddPort(a);
            AddPort(c);
            c.CanEditText = true;
            AddPort(b);
            AddPort(tr);
            AddPort(fl);
            OptionsAvilable = true;
            CreateMenu();
            Information = "Compares multiple values with specified conditions, if all conditions are met then TRUE will be called else FALSE will be called.";
        }
        void CreateMenu()
        {
            System.Windows.Controls.ContextMenu menu = new System.Windows.Controls.ContextMenu();
            System.Windows.Controls.MenuItem addVariable = new System.Windows.Controls.MenuItem();
            addVariable.Header = "Add Variable";
            System.Windows.Controls.MenuItem addOperator = new System.Windows.Controls.MenuItem();
            addOperator.Header = "Add Operator";
            addVariable.Click += addVariable_Click;
            addOperator.Click += addOperator_Click;
            menu.Items.Add(addVariable);
            menu.Items.Add(addOperator);
            InfoContextMenu = menu;
        }
        void addVariable_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            Port aa = new Port(PortType.IN, typeof(OP), AcceptsLinks.ONE, "==");
            aa.IsRemovable = true;
            aa.CanEditText = true;
            AddPort(aa);
        }
        void addOperator_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            string name = GetABC(PortCount);
            Port aa = new Port(PortType.IN, typeof(object), AcceptsLinks.NONE, name);
            aa.IsRemovable = true;
            AddPort(aa);
        }
        public override string Code()
        {
            string code = "if(";
            foreach (var p in Ports)
            {
                if (p.PortType == PortType.IN && p.DataType == typeof(OP))
                {
                    code += " " + p.Text + " ";
                }
                else if (p.PortType != PortType.OUT)
                {
                    code += GetValue(p);
                }
            }
            code += ")\r\n{\r\n " + GetValue(tr) + "\r\n}\r\n else \r\n{ \r\n " + GetValue(fl) + " \r\n}";
            return code;
        }
    }
}