示例#1
0
        public GraphParameterValue GetCustomParameter(string name)
        {
            GraphParameterValue v = null;

            nameMap.TryGetValue(name, out v);
            return(v);
        }
示例#2
0
        public void PopulateGraphParams()
        {
            if (!isDirty)
            {
                return;
            }

            Graph p = parentGraph;

            foreach (string k in Parameters.Keys)
            {
                GraphParameterValue realParam = Parameters[k];
                string[]            split     = k.Split('.');
                if (split.Length < 2)
                {
                    continue;
                }
                if (p.HasParameterValue(split[0], split[1]))
                {
                    realParam.AssignValue(p.GetParameterValue(split[0], split[1]));
                }
            }

            foreach (GraphParameterValue realParam in CustomParameters)
            {
                if (p.HasParameterValue(Id, realParam.Name))
                {
                    realParam.AssignValue(p.GetParameterValue(Id, realParam.Name));
                }
            }

            isDirty = false;
        }
示例#3
0
 private void GraphParameterValue_OnGraphParameterTypeChanged(GraphParameterValue param)
 {
     if (param == Param)
     {
         DisplayDefaultParam();
     }
 }
示例#4
0
        protected void BuildParameterCustom(GraphParameterValue v)
        {
            try
            {
                PropertyInfo info2 = v.GetType().GetProperty("Value");

                if (v.Value is double || v.Value is float || v.Value is int || v.Type == NodeType.Float)
                {
                    NumberSlider sp = new NumberSlider();
                    sp.Set(v.Min, v.Max, info2, v);
                    Stack.Children.Add(sp);
                }
                else if (v.Value is bool || v.Type == NodeType.Bool)
                {
                    ToggleControl tc = new ToggleControl(v.Name, info2, v);
                    Stack.Children.Add(tc);
                }
                else if (v.Type == NodeType.Float2 || v.Type == NodeType.Float3 || v.Type == NodeType.Float4)
                {
                    VectorSlider vs = new VectorSlider(info2, v, v.Min, v.Max, v.Type);
                    Stack.Children.Add(vs);
                }
                else if (v.Value is MVector || v.Type == NodeType.Color || v.Type == NodeType.Gray)
                {
                    ColorSelect cs = new ColorSelect(info2, v);
                    Stack.Children.Add(cs);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.StackTrace);
            }
        }
示例#5
0
 private void GraphParameterValue_OnGraphParameterUpdate(GraphParameterValue param)
 {
     if (GraphInst != null && !updatingParams && param.ParentGraph == GraphInst)
     {
         TryAndProcess();
     }
 }
示例#6
0
 public void Set(GraphParameterValue v, string id = "")
 {
     Param = v;
     Params.Set(v, false);
     Id = id;
     DisplayDefaultParam();
 }
示例#7
0
 public CustomParameter(GraphParameterValue v, string id = "")
 {
     InitializeComponent();
     Param = v;
     Params.Set(v, false);
     DisplayDefaultParam();
     Id = id;
 }
示例#8
0
 private void GraphParameterValue_OnGraphParameterUpdate(GraphParameterValue param)
 {
     if (GraphInst != null)
     {
         if (GraphInst.Parameters.Values.Contains(param) || GraphInst.CustomParameters.Contains(param))
         {
             GraphInst.TryAndProcess();
         }
     }
 }
示例#9
0
 /// <summary>
 /// This is used for Custom Parameters
 /// And is used in CustomParameterEditor
 /// </summary>
 /// <param name="v"></param>
 /// <param name="id"></param>
 /// <param name="isReadOnly"></param>
 /// <param name="ignore"></param>
 public ParameterView(GraphParameterValue v, string id = "", bool isReadOnly = false, params string[] ignore)
 {
     InitializeComponent();
     Param      = v;
     IsReadOnly = isReadOnly;
     Params.Set(v, ignore, false, true);
     Id = id;
     InitNameField();
     DisplayDefaultParam();
     Collapse();
 }
示例#10
0
 /// <summary>
 /// This is for listing Promoted Graph Parameters
 /// And is used in GraphParameterEditor
 /// </summary>
 /// <param name="title"></param>
 /// <param name="id"></param>
 /// <param name="v"></param>
 /// <param name="ignore"></param>
 public ParameterView(string title, string id, GraphParameterValue v, params string[] ignore)
 {
     InitializeComponent();
     Param      = v;
     IsReadOnly = true;
     Params.Set(v, ignore, false, true);
     Id = id;
     ParamName.Placeholder = "Parameter Name";
     ParamName.Set(title);
     DisplayDefaultParam();
     Collapse();
 }
示例#11
0
 /// <summary>
 /// This is for listing Promoted Graph Parameters
 /// And is used in GraphParameterEditor
 /// </summary>
 /// <param name="title"></param>
 /// <param name="id"></param>
 /// <param name="v"></param>
 /// <param name="ignore"></param>
 public ParameterView(string title, string id, GraphParameterValue v, params string[] ignore)
 {
     InitializeComponent();
     Param      = v;
     IsReadOnly = true;
     Params.Set(v, ignore, false, true);
     Id = id;
     ParamName.Placeholder = Properties.Resources.TITLE_PARAMETER_NAME;
     ParamName.Set(title);
     DisplayDefaultParam();
     Collapse();
 }
 private void AddParam_Click(object sender, RoutedEventArgs e)
 {
     if (graph != null)
     {
         int    index           = graph.CustomParameters.Count;
         string name            = "Param" + index;
         GraphParameterValue gp = new GraphParameterValue(name, 0, "", NodeType.Float);
         graph.AddCustomParameter(gp);
         ParameterView cp = new ParameterView(gp, gp.Id, false, "Name");
         cp.OnRemove += Cp_OnRemove;
         Stack.Children.Add(cp);
     }
 }
示例#13
0
        private void ParentGraph_OnGraphParameterUpdate(GraphParameterValue param)
        {
            isDirty = true;
            PopulateGraphParams();
            List <GraphInstanceNode> nodes = GraphInst.InstanceNodes;

            if (nodes != null)
            {
                foreach (GraphInstanceNode n  in nodes)
                {
                    n.isDirty = true;
                    n.PopulateGraphParams();
                }
            }

            TriggerValueChange();
        }
示例#14
0
 private void GraphInst_OnGraphParameterUpdate(GraphParameterValue param)
 {
     TriggerValueChange();
 }
示例#15
0
        ParameterInputType GetParamInputType(GraphParameterValue v)
        {
            ParameterInputType ptype = v.InputType;

            if (ptype == ParameterInputType.FloatInput && v.Type == NodeType.Float2)
            {
                ptype = ParameterInputType.Float2Input;
            }
            else if (ptype == ParameterInputType.FloatSlider && v.Type == NodeType.Float2)
            {
                ptype = ParameterInputType.Float2Slider;
            }
            else if (ptype == ParameterInputType.FloatInput && v.Type == NodeType.Float3)
            {
                ptype = ParameterInputType.Float3Input;
            }
            else if (ptype == ParameterInputType.FloatSlider && v.Type == NodeType.Float3)
            {
                ptype = ParameterInputType.Float3Slider;
            }
            else if (ptype == ParameterInputType.FloatInput && v.Type == NodeType.Float4)
            {
                ptype = ParameterInputType.Float4Input;
            }
            else if (ptype == ParameterInputType.FloatSlider && v.Type == NodeType.Float4)
            {
                ptype = ParameterInputType.Float4Slider;
            }
            else if (ptype == ParameterInputType.Color && v.Type == NodeType.Float)
            {
                ptype = ParameterInputType.FloatInput;
            }
            else if (ptype == ParameterInputType.Color && v.Type == NodeType.Bool)
            {
                ptype = ParameterInputType.Toggle;
            }
            else if (ptype == ParameterInputType.IntInput && v.Type == NodeType.Float2)
            {
                ptype = ParameterInputType.Int2Input;
            }
            else if (ptype == ParameterInputType.IntSlider && v.Type == NodeType.Float2)
            {
                ptype = ParameterInputType.Int2Slider;
            }
            else if (ptype == ParameterInputType.IntInput && v.Type == NodeType.Float3)
            {
                ptype = ParameterInputType.Int3Input;
            }
            else if (ptype == ParameterInputType.IntSlider && v.Type == NodeType.Float3)
            {
                ptype = ParameterInputType.Int3Slider;
            }
            else if (ptype == ParameterInputType.IntInput && v.Type == NodeType.Float4)
            {
                ptype = ParameterInputType.Int4Input;
            }
            else if (ptype == ParameterInputType.IntSlider && v.Type == NodeType.Float4)
            {
                ptype = ParameterInputType.Int4Slider;
            }

            return(ptype);
        }
示例#16
0
        protected void BuildParameter(string parameter, GraphParameterValue v, Node n)
        {
            try
            {
                PropertyInfo info1 = n.GetType().GetProperty(parameter);
                PropertyInfo info2 = v.GetType().GetProperty("Value");

                if (info1 == null)
                {
                    if (v.Value is float)
                    {
                        NumberInput np = new NumberInput(NumberInputType.Float, v, info2);
                        Stack.Children.Add(np);
                    }
                    else if (v.Value is int)
                    {
                        NumberInput np = new NumberInput(NumberInputType.Int, v, info2);
                        Stack.Children.Add(np);
                    }
                    else if (v.Value is bool)
                    {
                        ToggleControl tc = new ToggleControl("True", info2, v);
                        Stack.Children.Add(tc);
                    }
                }
                else
                {
                    if (v.Value is float || v.Value is int)
                    {
                        SliderAttribute sl = info1.GetCustomAttribute <SliderAttribute>();

                        if (sl != null)
                        {
                            NumberSlider inp = new NumberSlider(sl, info2, v);
                            Stack.Children.Add(inp);
                        }
                        else if (v.Value is float)
                        {
                            NumberInput np = new NumberInput(NumberInputType.Float, v, info2);
                            Stack.Children.Add(np);
                        }
                        else if (v.Value is int)
                        {
                            NumberInput np = new NumberInput(NumberInputType.Int, v, info2);
                            Stack.Children.Add(np);
                        }
                    }
                    else if (v.Value is bool)
                    {
                        ToggleControl tc = new ToggleControl(v.Name, info2, v);
                        Stack.Children.Add(tc);
                    }
                    else if (v.Value is Vector4)
                    {
                        ColorSelect cs = new ColorSelect(info2, v);
                        Stack.Children.Add(cs);
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.StackTrace);
            }
        }