Ejemplo n.º 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;
        }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
0
        protected MyNodeView(MyNodeConfig nodeInfo, GraphControl owner)
            : base("")
        {
            NodeInfo = nodeInfo;
            Owner = owner;

            m_icon = nodeInfo.BigImage;

            m_iconItem = new NodeImageItem(m_icon, 48, 48, false, false);
            m_iconItem.Tag = 0;
            m_descItem = new NodeLabelItem("");

            AddItem(m_iconItem);
            AddItem(m_descItem);
        }
Ejemplo n.º 4
0
        protected MyNodeView(MyNodeConfig nodeConfig, GraphControl owner)
            : base("")
        {
            Owner = owner;

            Config = nodeConfig;

            m_icon = nodeConfig.BigImage;

            m_iconItem = new NodeImageItem(m_icon, 48, 48, false, false)
            {
                IsPassive = true,
                Tag = 0
            };
            m_descItem = new NodeLabelItem("")
            {
                IsPassive = true
            };

            AddItem(m_iconItem);
            AddItem(m_descItem);
        }
Ejemplo n.º 5
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);
 }