Beispiel #1
0
        private static void ParameterNodeTypeChanged(object sender, HyperGraph.Items.AcceptNodeSelectionChangedEventArgs args)
        {
            if (sender is HyperGraph.Items.NodeDropDownItem)
            {
                var item    = (HyperGraph.Items.NodeDropDownItem)sender;
                var node    = item.Node;
                var newType = AsEnumValue <ParamSourceType>(item.Items[args.Index], ParamSourceTypeNames);

                //  We might have to change the input/output settings on this node
                bool isOutput = newType == ParamSourceType.Output;
                var  oldItems = new List <HyperGraph.NodeItem>(node.Items);
                foreach (var i in oldItems)
                {
                    if (i is ShaderFragmentNodeItem)
                    {
                        // if this is a node item with exactly 1 input/output
                        // and it is not in the correct direction, then we have to change it.
                        //  we can't change directly. We need to delete and recreate this node item.
                        var fragItem = (ShaderFragmentNodeItem)i;
                        if ((fragItem.Output.Enabled ^ fragItem.Input.Enabled) == true &&
                            (fragItem.Output.Enabled) != (isOutput == false))
                        {
                            var newItem = new ShaderFragmentNodeItem(
                                fragItem.Name, fragItem.Type, fragItem.ArchiveName,
                                isOutput ? true : false, isOutput ? false : true);
                            node.RemoveItem(fragItem);
                            node.AddItem(newItem);
                        }
                    }
                }
            }
        }
Beispiel #2
0
 private string TypeFromNodeItem(ShaderFragmentNodeItem nodeItem)
 {
     if (nodeItem.ArchiveName != null && nodeItem.ArchiveName.Length != 0)
     {
         var param = _shaderFragments.GetParameter(nodeItem.ArchiveName);
         return((param != null) ? param.Type : string.Empty);
     }
     return(nodeItem.Type);
 }