Ejemplo n.º 1
0
Archivo: Node.cs Proyecto: lukaspj/CGF
 public void UpdateOutput(NodeItemEventArgs args)
 {
     if (OutputChanged != null)
     {
         OutputChanged(this, args);
     }
 }
Ejemplo n.º 2
0
        void slider_ValueChanged(object sender, NodeItemEventArgs e)
        {
            NodeSliderItem slider = (NodeSliderItem)sender;

            if (Node is MyGateInput)
            {
                (Node as MyGateInput).SetWeight((e.Item as NodeSliderItem).Value);
            }
        }
Ejemplo n.º 3
0
        void slider_ValueChanged(object sender, NodeItemEventArgs e)
        {
            NodeSliderItem slider = (NodeSliderItem)sender;
            int index = (int)slider.Tag;

            if (Node is MyUserInput)
            {
                (Node as MyUserInput).SetUserInput(index, (e.Item as NodeSliderItem).Value);
            }
        }
Ejemplo n.º 4
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;
        }
Ejemplo n.º 5
0
 void OnImgClicked(object sender, NodeItemEventArgs e)
 {
     MessageBox.Show("IMAGE");
 }
Ejemplo n.º 6
0
 void OnColClicked(object sender, NodeItemEventArgs e)
 {
     MessageBox.Show("Color");
 }
Ejemplo n.º 7
0
 public void SetNodeOutputColor(Node node, Color color)
 {
     var nodeItem3 = (NodeColorItem)node.Items.FirstOrDefault(item => item.Tag.Equals(3));
       nodeItem3.Color = color;
       var args = new NodeItemEventArgs(nodeItem3);
       nodeItem3.OutputData = HelperMethods.Float3FromColor(color);
       node.UpdateOutput(args);
 }
Ejemplo n.º 8
0
 public void UpdateOutput(NodeItemEventArgs args)
 {
     if (OutputChanged != null) OutputChanged(this, args);
 }
Ejemplo n.º 9
0
        public void HandleConnectionAdded(NodeConnection connection, bool input)
        {
            NodeConnector connector;
             Node node;
             NodeItem colorFromItem = null;
             NodeImageItem imageFromItem = null;
             NodeImageItem imageOutputItem = null;

             if (input)
            node = connection.To.Node;
             else
            node = connection.From.Node;
             NodeItem colorToItem = (NodeItem)node.Items.FirstOrDefault(item => item.Tag.Equals(1));
             NodeItem imageToItem = (NodeItem)node.Items.FirstOrDefault(item => item.Tag.Equals(2));
             imageOutputItem = (NodeImageItem)node.Items.FirstOrDefault(item => item.Tag.Equals(3));

             var outArgs = new NodeItemEventArgs(imageOutputItem);

             foreach (NodeConnection conn in node.Connections)
             {
            if (conn.To.Item == null)
               continue;
            if (conn.To.Item == imageToItem)
               imageFromItem = conn.From.Item as NodeImageItem;
            if (conn.To.Item == colorToItem)
               colorFromItem = conn.From.Item;
             }

             if (!colorHandlerDict.ContainsKey(node) && colorFromItem != null && imageFromItem != null)
             {
            colorHandlerDict[node] = (sender, args) =>
            {
               if (imageFromItem != null && colorFromItem != null)
               {
                  imageOutputItem.Image = AddColor(HelperMethods.ColorFromFloatStruct(colorFromItem.OutputData), imageFromItem.Image);
                  node.UpdateOutput(outArgs);
               }
            };
            colorFromItem.Node.OutputChanged += colorHandlerDict[node];
             }

             if (!imageHandlerDict.ContainsKey(node) && imageFromItem != null && colorFromItem != null)
             {
            imageHandlerDict[node] = (sender, args) =>
            {
               if (imageFromItem != null && colorFromItem != null)
               {
                  imageOutputItem.Image = AddColor(HelperMethods.ColorFromFloatStruct(colorFromItem.OutputData), imageFromItem.Image);
                  node.UpdateOutput(outArgs);
               }
            };
            imageFromItem.Node.OutputChanged += imageHandlerDict[node];
             }

             if (imageFromItem != null && colorFromItem != null)
             {
            imageOutputItem.Image = AddColor(HelperMethods.ColorFromFloatStruct(colorFromItem.OutputData), imageFromItem.Image);
            node.UpdateOutput(outArgs);
             }
        }
Ejemplo n.º 10
0
 private void editOutputListNode_MouseDown(object sender, NodeItemEventArgs e)
 {
     if(e.Item != null)
     {
         m_nodeEdit.EditingNode = e.Item.Node;
         m_nodeEdit.Settings = m_currentPluginSettings;
         m_nodeEdit.ShowDialog(this);
     }
 }
Ejemplo n.º 11
0
 private void editConvNode_MouseDown(object sender, NodeItemEventArgs e)
 {
     if (e.Item != null)
     {
         m_partEdit.Node = e.Item as NodeCompositeItem;
         m_partEdit.ShowDialog(this);
     }
 }