Beispiel #1
0
        public Node CreateNode()
        {
            Node addColorNode = new Node(GetNodeName());
             addColorNode.Location = new Point(200, 50);
             var color = new NodeLabelItem("Color", true, false, new[] {
            typeof(ShaderTypes.float3),
            typeof(ShaderTypes.float4) },
            null) { Tag = 1 };
             var imageIn = new NodeLabelItem("Image", true, false, new[] { typeof(ShaderTypes.sampler2D) }, null) { Tag = 2 };
             var imageOut = new NodeImageItem(Properties.Resources.DefaultImage,
                                          64,
                                          64,
                                          false,
                                          true,
                                          null,
                                          new[] { typeof(Image) }) { Tag = 3 };

             addColorNode.AddItem(color);
             addColorNode.AddItem(imageIn);
             addColorNode.AddItem(imageOut);

             addColorNode.ParentModule = this;

             return addColorNode;
        }
Beispiel #2
0
        private void ColorNode_MouseDown(object sender, MouseEventArgs e)
        {
            var colorNode = new Node("Color");
            colorNode.Location = new Point(200, 50);
            var redChannel = new NodeSliderItem("R", 64.0f, 16.0f, 0, 1.0f, 0.0f);
            var greenChannel = new NodeSliderItem("G", 64.0f, 16.0f, 0, 1.0f, 0.0f);
            var blueChannel = new NodeSliderItem("B", 64.0f, 16.0f, 0, 1.0f, 0.0f);
            var colorItem = new NodeColorItem("Color", Color.Black, NodeIOMode.Output) { Tag = TagType.COLOR };

            EventHandler<NodeItemEventArgs> channelChangedDelegate = delegate(object s, NodeItemEventArgs args)
            {
                var red = redChannel.Value;
                var green = greenChannel.Value;
                var blue = blueChannel.Value;
                colorItem.Color = Color.FromArgb((int)Math.Round(red * 255), (int)Math.Round(green * 255), (int)Math.Round(blue * 255));
            };
            redChannel.ValueChanged += channelChangedDelegate;
            greenChannel.ValueChanged += channelChangedDelegate;
            blueChannel.ValueChanged += channelChangedDelegate;

            colorNode.AddItem(redChannel);
            colorNode.AddItem(greenChannel);
            colorNode.AddItem(blueChannel);

            colorItem.Clicked += new EventHandler<NodeItemEventArgs>(OnColClicked);
            colorNode.AddItem(colorItem);

            this.DoDragDrop(colorNode, DragDropEffects.Copy);
        }
Beispiel #3
0
        public Node CreateNode()
        {
            var colorNode = new Node(GetNodeName());
             colorNode.Location = new Point(200, 50);
             var redChannel = new NodeSliderItem("R", 64.0f, 16.0f, 0, 1.0f, 0.0f, false, false) { Tag = "red" };
             var greenChannel = new NodeSliderItem("G", 64.0f, 16.0f, 0, 1.0f, 0.0f, false, false) { Tag = "green" };
             var blueChannel = new NodeSliderItem("B", 64.0f, 16.0f, 0, 1.0f, 0.0f, false, false) { Tag = "blue" };
             var colorItem = new NodeColorItem("Color", Color.Black, false, true, null, new[] {
            typeof(ShaderTypes.float3) })
            { Tag = "out" };

             EventHandler<NodeItemEventArgs> channelChangedDelegate = delegate(object sender, NodeItemEventArgs args)
             {
            var red = redChannel.Value;
            var blue = blueChannel.Value;
            var green = greenChannel.Value;
            colorItem.Color = Color.FromArgb((int)Math.Round(red * 255), (int)Math.Round(green * 255), (int)Math.Round(blue * 255));
            colorItem.OutputData = new ShaderTypes.float3()
            {
               x = red,
               y = green,
               z = blue
            };
             };
             redChannel.ValueChanged += channelChangedDelegate;
             greenChannel.ValueChanged += channelChangedDelegate;
             blueChannel.ValueChanged += channelChangedDelegate;
             EventHandler<NodeItemEventArgs> endDragDelegate = delegate(object sender, NodeItemEventArgs args)
             {
            var outArgs = new NodeItemEventArgs(colorItem);
            args.Item.Node.UpdateOutput(outArgs);
             };
             redChannel.EndDrag += endDragDelegate;
             greenChannel.EndDrag += endDragDelegate;
             blueChannel.EndDrag += endDragDelegate;

             colorNode.AddItem(redChannel);
             colorNode.AddItem(greenChannel);
             colorNode.AddItem(blueChannel);

             colorItem.Clicked += new EventHandler<NodeItemEventArgs>(OnColClicked);
             colorNode.AddItem(colorItem);

             colorNode.ParentModule = this;

             colorItem.OutputData = new ShaderTypes.float3()
             {
            x = 0,
            y = 0,
            z = 0
             };

             return colorNode;
        }
Beispiel #4
0
        public ExampleForm()
        {
            InitializeComponent();

            graphControl.CompatibilityStrategy = new TagTypeCompatibility();

            var someNode = new Node("My Title");
            someNode.Location = new Point(500, 100);
            var check1Item = new NodeCheckboxItem("Check 1", true, false) { Tag = 31337 };
            someNode.AddItem(check1Item);
            someNode.AddItem(new NodeCheckboxItem("Check 2", true, false) { Tag = 42f });

            graphControl.AddNode(someNode);

            var colorNode = new Node("Color");
            colorNode.Location = new Point(200, 50);
            var redChannel		= new NodeSliderItem("R", 64.0f, 16.0f, 0, 1.0f, 0.0f, false, false);
            var greenChannel	= new NodeSliderItem("G", 64.0f, 16.0f, 0, 1.0f, 0.0f, false, false);
            var blueChannel		= new NodeSliderItem("B", 64.0f, 16.0f, 0, 1.0f, 0.0f, false, false);
            var colorItem		= new NodeColorItem("Color", Color.Black, false, true) { Tag = 1337 };

            EventHandler<NodeItemEventArgs> channelChangedDelegate = delegate(object sender, NodeItemEventArgs args)
            {
                var red = redChannel.Value;
                var green = blueChannel.Value;
                var blue = greenChannel.Value;
                colorItem.Color = Color.FromArgb((int)Math.Round(red * 255), (int)Math.Round(green * 255), (int)Math.Round(blue * 255));
            };
            redChannel.ValueChanged		+= channelChangedDelegate;
            greenChannel.ValueChanged	+= channelChangedDelegate;
            blueChannel.ValueChanged	+= channelChangedDelegate;

            colorNode.AddItem(redChannel);
            colorNode.AddItem(greenChannel);
            colorNode.AddItem(blueChannel);

            colorItem.Clicked += new EventHandler<NodeItemEventArgs>(OnColClicked);
            colorNode.AddItem(colorItem);
            graphControl.AddNode(colorNode);

            var textureNode = new Node("Texture");
            textureNode.Location = new Point(300, 150);
            var imageItem = new NodeImageItem(Properties.Resources.example, 64, 64, false, true) { Tag = 1000f };
            imageItem.Clicked += new EventHandler<NodeItemEventArgs>(OnImgClicked);
            textureNode.AddItem(imageItem);
            graphControl.AddNode(textureNode);

            graphControl.ConnectionAdded	+= new EventHandler<AcceptNodeConnectionEventArgs>(OnConnectionAdded);
            graphControl.ConnectionAdding	+= new EventHandler<AcceptNodeConnectionEventArgs>(OnConnectionAdding);
            graphControl.ConnectionRemoving += new EventHandler<AcceptNodeConnectionEventArgs>(OnConnectionRemoved);
            graphControl.ShowElementMenu	+= new EventHandler<AcceptElementLocationEventArgs>(OnShowElementMenu);

            graphControl.Connect(colorItem, check1Item);
        }
Beispiel #5
0
        private static Node CreateNodeFromType(Type type)
        {
            Node node = new Node(type.FullName);
            node.Tag = type;
            if (typeof (IExecutable).IsAssignableFrom(type))
            {
                NodeLabelItem item = new NodeLabelItem("Exec", true, false);
                item.Input.ConnectorType = NodeConnectorType.Exec;
                node.AddItem(item);
                node.BackColor = Color.Silver;
            }

            if (typeof (WorkflowFunction).IsAssignableFrom(type))
            {
                node.BackColor = Color.LightGreen;
            }

            if (typeof (WorkflowEventReceiver).IsAssignableFrom(type))
            {
                node.BackColor = Color.Salmon;
            }

            //execute pins
            foreach (var pin in type.GetPins(PinType.Execute))
            {
                NodeLabelItem item = new NodeLabelItem(pin.Name, false, true);
                item.Output.ConnectorType = NodeConnectorType.Exec;
                node.AddItem(item);
            }

            foreach (var pin in type.GetPins(PinType.Input))
            {
                NodeLabelItem item = new NodeLabelItem(pin.Name, true, false);
                node.AddItem(item);
            }

            foreach (var pin in type.GetPins(PinType.Output))
            {
                NodeLabelItem nodeLabelItem = new NodeLabelItem(pin.Name, false, true);
                nodeLabelItem.Tag = pin.GetPropertyType();
                node.AddItem(nodeLabelItem);
            }
            return node;
        }
Beispiel #6
0
        public Node CreateNode()
        {
            Node outputNode = new Node(GetNodeName());

              NodeItem item = new NodeLabelItem("Output", true, false, new[] { typeof(ShaderTypes.float4) }, null);
              item.Tag = "out";
              outputNode.AddItem(item);
              outputNode.ParentModule = this;

              return outputNode;
        }
Beispiel #7
0
        public Node CreateNode()
        {
            var colorMixerNode = new Node(GetNodeName());
              colorMixerNode.Location = new Point(200, 50);
              var color1 = new NodeColorItem("Color 1", Color.Black, true, false, new[] {
             typeof(ShaderTypes.float3),
             typeof(ShaderTypes.float4) },
             null) { Tag = 1 };
              var color2 = new NodeColorItem("Color 2", Color.Black, true, false, new[] {
             typeof(ShaderTypes.float3),
             typeof(ShaderTypes.float4) },
             null) { Tag = 2 };
              var color3 = new NodeColorItem("Result", Color.Black, false, true, null, new [] {
             typeof(ShaderTypes.float3)})
             { Tag = 3 };

              colorMixerNode.AddItem(color1);
              colorMixerNode.AddItem(color2);
              colorMixerNode.AddItem(color3);

              colorMixerNode.ParentModule = this;

              return colorMixerNode;
        }
Beispiel #8
0
        public Node CreateNode()
        {
            Node textureNode = new Node(GetNodeName());

              NodeItem imageItem = new Graph.Items.NodeImageItem(Properties.Resources.DefaultImage, 64, 64, false, true, null, new[] { typeof(ShaderTypes.sampler2D) }) { Tag = "out" };
              textureNode.AddItem(imageItem);

              ShaderTypes.sampler2D sampler = new ShaderTypes.sampler2D();
              sampler.path = "./DefaultImage.png";
              imageItem.OutputData = sampler;
              SetImage(textureNode, sampler.path);

              textureNode.ParentModule = this;

              return textureNode;
        }
Beispiel #9
0
        public Node CreateNode()
        {
            Node outputNode = new Node(GetNodeName());

              var hposNode = new NodeLabelItem("hpos", false, true, null, new[] { typeof(ShaderTypes.float4) });
              var uv0Node = new NodeLabelItem("uv0", false, true, null, new[] { typeof(ShaderTypes.float2) });
              var uv1Node = new NodeLabelItem("uv1", false, true, null, new[] { typeof(ShaderTypes.float2) });
              var uv2Node = new NodeLabelItem("uv2", false, true, null, new[] { typeof(ShaderTypes.float2) });
              var uv3Node = new NodeLabelItem("uv3", false, true, null, new[] { typeof(ShaderTypes.float2) });
              var wsEyeRayNode = new NodeLabelItem("wsEyeRay", false, true, null, new[] { typeof(ShaderTypes.float3) });

              outputNode.AddItem(hposNode);
              outputNode.AddItem(uv0Node);
              outputNode.AddItem(uv1Node);
              outputNode.AddItem(uv2Node);
              outputNode.AddItem(uv3Node);
              outputNode.AddItem(wsEyeRayNode);

              outputNode.ParentModule = this;
              outputNode.Tag = "IN.";

              return outputNode;
        }
Beispiel #10
0
 private void TextureNode_MouseDown(object sender, MouseEventArgs e)
 {
     var textureNode = new Node("Texture");
     textureNode.Location = new Point(300, 150);
     var imageItem = new NodeImageItem(Properties.Resources.example, 64, 64, false, true);
     imageItem.Clicked += new EventHandler<NodeItemEventArgs>(OnImgClicked);
     textureNode.AddItem(imageItem);
     this.DoDragDrop(textureNode, DragDropEffects.Copy);
 }
Beispiel #11
0
 private void SomeNode_MouseDown(object sender, MouseEventArgs e)
 {
     var node = new Node("Some node");
     node.AddItem(new NodeLabelItem("Entry 1", true, false));
     node.AddItem(new NodeLabelItem("Entry 2", true, false));
     node.AddItem(new NodeLabelItem("Entry 3", false, true));
     node.AddItem(new NodeTextBoxItem("TEXTTEXT", false, true));
     node.AddItem(new NodeDropDownItem(new string[] { "1", "2", "3", "4" }, 0, false, false));
     this.DoDragDrop(node, DragDropEffects.Copy);
 }
 private void rebuildGraph(GraphControl graph)
 {
     Dictionary<String, CConnectionFields> inputs = new Dictionary<String, CConnectionFields>();
     Dictionary<String, CConnectionFields> outputs = new Dictionary<String, CConnectionFields>();
     foreach(CNodeFields node in m_graphFields.Nodes)
     {
         m_idNameMap.Add(node.id, node.name);
         Node n = new Node(node.Title);
         n.Location = node.Location;
         foreach(CNodeItemFields item in node.Items)
         {
             String name = "";
             if(item.name != null)
                 name = item.name.Split(':')[1];
             if (item.Input != null)
             {
                 foreach (CConnectionFields conn in item.Input)
                 {
                     if (!inputs.ContainsKey(conn.id))
                         inputs.Add(conn.id, conn);
                 }
             }
             if (item.Output != null)
             {
                 foreach (CConnectionFields conn in item.Output)
                 {
                     if (!outputs.ContainsKey(conn.id))
                         outputs.Add(conn.id, conn);
                 }
             }
             switch (item.ItemType)
             {
                 case "Graph.Items.NodeCompositeItem":
                     {
                         NodeCompositeItem temp = new NodeCompositeItem(item.IOMode);
                         temp.Name = name;
                         foreach(CItemPartFields part in item.ItemParts)
                         {
                             switch(part.PartType)
                             {
                                 case "Graph.Items.ItemTextBoxPart":
                                     {
                                         ItemTextBoxPart p = new ItemTextBoxPart(part.Text);
                                         p.Name = part.name;
                                         temp.AddPart(p);
                                     }
                                     break;
                                 default:
                                     {
                                     }
                                     break;
                             }
                         }
                         if (item.Tag != null)
                             temp.Tag = TagFactory.GetTagObject(item.Tag);
                         if (temp.Name.Contains("button_"))
                             temp.Clicked += m_parentForm.GetConvMouseHandler();
                         m_itemMap.Add(item.id, temp);
                         m_idNameMap.Add(item.id, name);
                         n.AddItem(temp);
                     }
                     break;
                 case "Graph.Items.NodeTextBoxItem":
                     {
                         NodeTextBoxItem temp = new NodeTextBoxItem(item.Text, item.IOMode);
                         temp.Name = name;
                         if (item.Tag != null)
                             temp.Tag = TagFactory.GetTagObject(item.Tag);
                         m_itemMap.Add(item.id, temp);
                         m_idNameMap.Add(item.id, name);
                         n.AddItem(temp);
                     }
                     break;
                 case "Graph.Items.NodeLabelItem":
                     {
                         NodeLabelItem temp = new NodeLabelItem(item.Text, item.IOMode);
                         temp.Name = name;
                         if (item.Tag != null)
                             temp.Tag = TagFactory.GetTagObject(item.Tag);
                         m_itemMap.Add(item.id, temp);
                         m_idNameMap.Add(item.id, name);
                         if (temp.Name == "EditNodeItem")
                             temp.Clicked += m_parentForm.GetEditMouseHandler();
                         n.AddItem(temp);
                     }
                     break;
                 default:
                     {
                         //NodeItem temp = new NodeItem(item.IOMode);
                     }
                     break;
             }
         }
         graph.AddNode(n);
     }
     rebuildConnections(graph, inputs, outputs);
 }
Beispiel #13
0
 private void lblConvoNode_MouseDown(object sender, MouseEventArgs e)
 {
     List<Node> nodes = (List<Node>)graphCtrl.Nodes;
     String nodeName = m_settings.Attributes["[Default]"]["DEFAULTNODENAME"] + "_" + getConvNodeCount().ToString().PadLeft(4, '0');
     var node = new Node("Conversation Node");
     var nodeNameItem = new NodeTextBoxItem(nodeName);
     nodeNameItem.Name = "NodeName";
     node.AddItem(nodeNameItem);
     NodeTextBoxItem displayText = new NodeTextBoxItem("Enter NPC text", NodeIOMode.None);
     displayText.Name = "DisplayText";
     node.AddItem(displayText);
     var inputLabel = new NodeLabelItem("Conversation input", NodeIOMode.Input) { Tag = TagType.LABEL };
     inputLabel.Name = nodeName + "_in";
     node.AddItem(inputLabel);
     var editNode = new NodeLabelItem("Click Here To Edit Output List");
     editNode.Name = "EditNodeItem";
     editNode.Clicked += new EventHandler<NodeItemEventArgs>(editOutputListNode_MouseDown);
     node.AddItem(editNode);
     NodeCompositeItem firstButton = new NodeCompositeItem(NodeIOMode.Output) { Tag = TagType.TEXTBOX };
     firstButton.Name = "button_1";
     ItemTextBoxPart btnText = new ItemTextBoxPart("Enter player text");
     btnText.Name = "ConvText";
     ItemTextBoxPart btnMethod = new ItemTextBoxPart("Enter script method");
     btnMethod.Name = "ConvMethod";
     firstButton.AddPart(btnText);
     firstButton.AddPart(btnMethod);
     firstButton.Clicked += new EventHandler<NodeItemEventArgs>(editConvNode_MouseDown);
     node.AddItem(firstButton);
     this.DoDragDrop(node, DragDropEffects.Copy);
 }
Beispiel #14
0
 private void CompNode_MouseDown(object sender, MouseEventArgs e)
 {
     var compNode = new Node("Composite Node");
     compNode.Location = new Point(300, 150);
     var compItem = new NodeCompositeItem(NodeIOMode.Output) { Tag = TagType.COMPOSITE };
     var compTxtPart = new ItemTextBoxPart("Test text");
     compItem.AddPart(compTxtPart);
     var compTxtPart2 = new ItemTextBoxPart("Test 2 text with really long text");
     compItem.AddPart(compTxtPart2);
     compNode.AddItem(compItem);
     this.DoDragDrop(compNode, DragDropEffects.Copy);
 }
Beispiel #15
0
 private void lblEndNode_MouseDown(object sender, MouseEventArgs e)
 {
     var node = new Node("Conversation End");
     node.AddItem(new NodeTextBoxItem("Enter text"));
     String name = "Conversation_End_" + getEndNodeCount().ToString().PadLeft(3, '0');
     var endLabel = new NodeLabelItem(name, NodeIOMode.Input) { Tag = TagType.TEXTBOX };
     endLabel.Name = "NodeName";
     node.AddItem(endLabel);
     node.AddItem(new NodeTextBoxItem(m_currentPluginSettings.Attributes["[Default]"]["DEFAULTEXITMETHOD"]));
     this.DoDragDrop(node, DragDropEffects.Copy);
 }
Beispiel #16
0
 private void SomeNode_MouseDown(object sender, MouseEventArgs e)
 {
     var node = new Node("Some node");
     node.AddItem(new NodeLabelItem("Entry 1", NodeIOMode.Input) { Tag = TagType.COLOR });
     node.AddItem(new NodeLabelItem("Entry 2", NodeIOMode.Input) { Tag = TagType.IMAGE });
     node.AddItem(new NodeLabelItem("Entry 3", NodeIOMode.Input) { Tag = TagType.TEXTBOX });
     node.AddItem(new NodeTextBoxItem("TEXTTEXT", NodeIOMode.Output) { Tag = TagType.TEXTBOX });
     node.AddItem(new NodeDropDownItem(new string[] { "1", "2", "3", "4" }, 0, NodeIOMode.Output) { Tag = TagType.TEXTBOX });
     var compItem = new NodeCompositeItem(NodeIOMode.InOut) { Tag = TagType.COMPOSITE };
     var txtPart = new ItemTextBoxPart("Test text");
     compItem.AddPart(txtPart);
     node.AddItem(compItem);
     this.DoDragDrop(node, DragDropEffects.Copy);
 }
Beispiel #17
0
 private void lblStartNode_MouseDown(object sender, MouseEventArgs e)
 {
     var node = new Node("Conversation Start");
     var startLabel = new NodeLabelItem("Conversation_Start", NodeIOMode.Output) { Tag = TagType.LABEL };
     startLabel.Name = "NodeName";
     node.AddItem(startLabel);
     this.DoDragDrop(node, DragDropEffects.Copy);
 }