Exemplo n.º 1
0
        public override void UpdateView()
        {
            base.UpdateView();

            MyUserInput userInputNode = Node as MyUserInput;

            ShowValues = userInputNode.ShowValues;

            int newSlidersCount = userInputNode.ConvertToBinary ? 1 : userInputNode.OutputSize;
            if (newSlidersCount != sliders.Count)
            {
                sliders.ForEach(s => RemoveItem(s));

                for (int i = 0; i < newSlidersCount; i++)
                {
                    NodeSliderItem slider = new NodeSliderItem(null, 0, 0, 0, 1, 0, false, false);
                    slider.Tag = i;
                    slider.ValueChanged += slider_ValueChanged;

                    sliders.Add(slider);
                    AddItem(slider);
                }
            }
            SetSlidersToDefault();
        }
Exemplo n.º 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, 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);

            EventHandler<NodeItemEventArgs> channelChangedDelegate = delegate(object s, 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);

            this.DoDragDrop(colorNode, DragDropEffects.Copy);
        }
Exemplo n.º 3
0
        public override void UpdateView()
        {
            base.UpdateView();

            if (slider == null && Node != null)
            {
                slider = new NodeSliderItem(null, 0, 0, 0, 1, (Node as MyGateInput).GetWeight(), false, false);
                slider.ValueChanged += slider_ValueChanged;
                AddItem(slider);
            }
        }
Exemplo 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;
        }
Exemplo n.º 5
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);
        }
Exemplo n.º 6
0
 private void SetText(NodeSliderItem slider)
 {
     slider.Text = ShowValues ? slider.Value.ToString("n2") : null;
 }