예제 #1
0
        private string UpdateModuleParams(GraphicalModule gm)
        {
            string ans     = null;
            string command = $"mmGetModuleParams(\"{ParentForm.TabInstantiation(TabPage)}::{gm.Name}\")";
            string res;

            Request("return " + command);
            res = GetAnswer(ref ans);
            if (String.IsNullOrWhiteSpace(res) && !stopQueued)
            {
                string[] stuff = (ans).Split(new char[] { '\u0001' }, StringSplitOptions.None);
                int      len   = stuff.Count();
                // don't forget the trailing element since we conclude with one last separator!
                if (len > 1 && (len - 1) % 4 == 1)
                {
                    string module = stuff[0];
                    for (int x = 1; x < len - 1; x += 4)
                    {
                        string slotname = stuff[x];
                        // +1 description
                        // +2 typedescription
                        //MegaMol.SimpleParamRemote.ParameterTypeDescription ptd = new MegaMol.SimpleParamRemote.ParameterTypeDescription();
                        //ptd.SetFromHexStringDescription(stuff[x + 2]);
                        string slotvalue = stuff[x + 3];
                        var    keys      = gm.ParameterValues.Keys.ToList();
                        foreach (Data.ParamSlot p in keys)
                        {
                            if (p.Name.Equals(slotname))
                            {
                                if (!p.Type.ValuesEqual(gm.ParameterValues[p], slotvalue))
                                {
                                    gm.ParameterValues[p] = slotvalue;
                                    ParentForm.ParamChangeDetected();
                                }
                                //if (ptd.Type == MegaMol.SimpleParamRemote.ParameterType.FlexEnumParam) {
                                if (p.Type.TypeName == "MMFENU")
                                {
                                    //int numVals = ptd.ExtraSettings.Keys.Count() / 2;
                                    p.Type = p.TypeFromTypeInfo(StringToByteArray(stuff[x + 2]));
                                }
                            }
                        }
                    }
                }
                else
                {
                    ParentForm.listBoxLog.Log(Util.Level.Error, $"invalid response to {command}");
                }
            }
            else
            {
                ParentForm.listBoxLog.Log(Util.Level.Error, $"Error in {command}: {res}");
            }

            return(res);
        }