Exemple #1
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);
        }
Exemple #2
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;
        }
Exemple #3
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);
        }
Exemple #4
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;
        }