Ejemplo n.º 1
0
        public Node_Const(ULNode node) : base(node)
        {
            if (node.ControlOutputs.Count != 1)
            {
                node.ControlOutputs.Clear();
                node.ControlOutputs.AddRange(new string[1]);
            }

            int output_count = 0;

            foreach (var co in node.ControlOutputs)
            {
                GetPinOutputPos(output_count, out int x, out int y);
                PinOuts.Add(new ControlPinOut(this, output_count, "out", x, y));
                output_count++;
            }

            {
                GetPinOutputPos(output_count++, out int x, out int y);
                PinOuts.Add(new DataPinOut(this, new ULArg()
                {
                    Name = "condition", TypeID = "System.Boolean"
                }, 0, x, y));
            }
        }
Ejemplo n.º 2
0
        public Node_Entry(ULNode node) : base(node)
        {
            if (node.ControlOutputs.Count != 1)
            {
                node.ControlOutputs.Clear();
                node.ControlOutputs.AddRange(new string[1]);
            }

            int output_count = 0;

            foreach (var co in node.ControlOutputs)
            {
                GetPinOutputPos(output_count, out int x, out int y);
                PinOuts.Add(new ControlPinOut(this, output_count, "start", x, y));
                output_count++;
            }
        }
Ejemplo n.º 3
0
        public IF_Node(ULNode node) : base(node)
        {
            //if (node.ControlInputs.Count != 1)
            //{
            //    node.ControlInputs.Clear();
            //    node.ControlInputs.Add("");
            //}
            if (node.ControlOutputs.Count != 2)
            {
                node.ControlOutputs.Clear();
                node.ControlOutputs.AddRange(new string[2]);
            }
            if (node.Inputs.Count != 1)
            {
                node.Inputs.Clear();
                node.Inputs.AddRange(new string[1]);
            }


            int input_count  = 0;
            int output_count = 0;

            //foreach (var ci in node.ControlInputs)
            {
                GetPinInputPos(input_count, out int x, out int y);
                PinIns.Add(new ControlPinIn(this, input_count, "in", x, y));
                input_count++;
            }
            foreach (var co in node.ControlOutputs)
            {
                GetPinOutputPos(output_count, out int x, out int y);
                PinOuts.Add(new ControlPinOut(this, output_count, output_count == 0?"true":"false", x, y));
                output_count++;
            }
            {
                GetPinInputPos(input_count++, out int x, out int y);
                PinIns.Add(new DataPinIn(this, new ULArg()
                {
                    Name = "condition", TypeID = "System.Boolean"
                }, 0, x, y));
            }
        }
Ejemplo n.º 4
0
        public MethodNode(ULNode node) : base(node)
        {
            //if (node.ControlInputs.Count == 0)
            //{
            //    node.ControlInputs.Add("");
            //}
            if (node.ControlOutputs.Count == 0)
            {
                node.ControlOutputs.Add("");
            }
            int control_input_count  = 0;
            int control_output_count = 0;



            //foreach (var ci in node.ControlInputs)
            {
                GetPinInputPos(control_input_count, out int x, out int y);
                PinIns.Add(new ControlPinIn(this, control_input_count, "in", x, y));
                control_input_count++;
            }
            foreach (var co in node.ControlOutputs)
            {
                GetPinOutputPos(control_output_count, out int x, out int y);
                PinOuts.Add(new ControlPinOut(this, control_output_count, "out", x, y));
                control_output_count++;
            }
            var member = Model.Data.GetMember(node.Name);

            if (member != null)
            {
                int data_input_count  = 0;
                int data_output_count = 0;
                if (node.Inputs.Count == 0)
                {
                    for (int i = 0; i < member.Graph.Args.Count; i++)
                    {
                        node.Inputs.Add("");
                    }
                }

                int left_width  = 0;
                int right_width = 0;



                foreach (var a in member.Graph.Args)
                {
                    GetPinInputPos(data_input_count + control_input_count, out int x, out int y);
                    PinIns.Add(new DataPinIn(this, a, data_input_count, x, y));
                    left_width = Math.Max(left_width, PinIns[PinIns.Count - 1].Name.Length * font_size);
                    data_input_count++;
                }

                foreach (var a in member.Graph.Outputs)
                {
                    GetPinOutputPos(data_output_count + control_output_count, out int x, out int y);
                    PinOuts.Add(new DataPinOut(this, a, data_output_count, x, y));
                    right_width = Math.Max(right_width, PinOuts[PinOuts.Count - 1].Name.Length * font_size);
                    data_output_count++;
                }

                _width = left_width + right_width + 5;
            }

            _width = Math.Max(100, _width);
        }
Ejemplo n.º 5
0
        public NodeBase(ULNode n)
        {
            node     = n;
            _PinIns  = new List <IPinIn>();
            _PinOuts = new List <IPinOut>();

            int control_input_count  = 0;
            int control_output_count = 0;


            foreach (var ci in node.Inputs)
            {
                GetPinInputPos(control_input_count, out int x, out int y);
                if (string.IsNullOrEmpty(ci.TypeID))
                {
                    PinIns.Add(new ControlPinIn(this, control_input_count, ci.Name, x, y));
                }
                else
                {
                    PinIns.Add(new DataPinIn(this, ci, control_input_count, x, y));
                }
                control_input_count++;
            }

            foreach (var co in node.Outputs)
            {
                GetPinOutputPos(control_output_count, out int x, out int y);
                if (string.IsNullOrEmpty(co.TypeID))
                {
                    PinOuts.Add(new ControlPinOut(this, control_output_count, co.Name, x, y));
                }
                else
                {
                    PinOuts.Add(new DataPinOut(this, co, control_output_count, x, y));
                }
                control_output_count++;
            }

            int left_width  = 0;
            int right_width = 0;

            //计算宽度
            foreach (var ci in PinIns)
            {
                left_width = Math.Max(left_width, ci.Name.Length * font_size);
            }
            foreach (var co in PinOuts)
            {
                right_width = Math.Max(right_width, co.Name.Length * font_size);
            }

            _width = left_width + right_width + 20;
            _width = Math.Max(100, _width);
            _width = Math.Max(font_size * Title.Length, _width);

            //重新计算端口位置
            for (int i = 0; i < PinIns.Count; i++)
            {
                GetPinInputPos(i, out int x, out int y);
                PinIns[i].LocalX = x;
                PinIns[i].LocalY = y;
            }

            for (int i = 0; i < PinOuts.Count; i++)
            {
                GetPinOutputPos(i, out int x, out int y);
                PinOuts[i].LocalX = x;
                PinOuts[i].LocalY = y;
            }
        }