private static INodeField ValueDisplay(ITypeDefinition typeDef, object x)
        {
            INodeField output = Constructor.NodeField(x.ToString()).WithValue("Displayed", Constructor.RigidTypeDefinitionManager(typeDef.DefaultValue, null, "DefaultDisplay"), false).WithFlowOutput();

            output.DisplayedValue.Value = x;
            return(output);
        }
        private void NumberOfLetters_PropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            if (e.PropertyName is not nameof(ILaminarValue.Value))
            {
                return;
            }

            int NewNumberOfKeys = (int)NumberOfLetters.GetInput <double>();

            if (NewNumberOfKeys > Keys.VisualComponentList.Count)
            {
                for (int i = Keys.Count; i < NewNumberOfKeys; i++)
                {
                    INodeField newField = Constructor.NodeField($"Letter {i+1}").WithInput <Keys>();
                    newField.GetValue(INodeField.InputKey).PropertyChanged += AnyKey_PropertyChanged;
                    Keys.Add(newField);
                }
            }
            else if (NewNumberOfKeys < Keys.Count)
            {
                for (int i = Keys.Count; i >= NewNumberOfKeys; i--)
                {
                    Keys.RemoveAt(i);
                }
            }

            AnyKey_PropertyChanged(null, new PropertyChangedEventArgs(nameof(ILaminarValue.Value)));
        }
        private static JObject CreateFieldJsonObject(INodeField field)
        {
            var obj = new JObject();

            obj["name"]      = field.Name;
            obj["valueType"] = GetValueTypeString();
            if (field.IsArray)
            {
                obj["isArray"] = true;
            }
            return(obj);

            string GetValueTypeString()
            {
                switch (field)
                {
                case StringNodeField nf: return("string");

                case BooleanNodeField nf: return("boolean");

                case NumberNodeField nf: return("number");

                case AliasNodeField nf: return(nf.Alias.Identifier);

                case EnumNodeField nf: return(nf.Enum.Identifier);
                }

                throw new InvalidOperationException($"Unknown field type: '{field.GetType()}'");
            }
        }
Esempio n. 4
0
        public static INodeField NodeField(string fieldName)
        {
            INodeField output = Laminar.New <INodeField>();

            output.Name = fieldName;

            return(output);
        }
Esempio n. 5
0
        private void RegisterContainer(INodeContainer container, int index)
        {
            INodeField newField = Constructor.NodeField(container.NameLabel.LabelText.Value).WithValue("display", ((InputNodeContainer <InputNode>)container).GetValue(null), true);

            container.NameLabel.LabelText.OnChange += s =>
            {
                newField.Name.Value = s;
            };
            newField.GetValue("display").OnChange += (o) =>
            {
                ((InputNodeContainer <InputNode>)container).SetValue(_scriptInstance, o);
            };
            AllInputs.Insert(index, newField);
        }
Esempio n. 6
0
        private void PushField(INodeField field)
        {
            if (field == null)
            {
                throw new ArgumentNullException(nameof(field));
            }

            if (this.fields.Any(f => f.Name == field.Name))
            {
                throw new Exceptions.DuplicateFieldNameException(this.typeIdentifier, field.Name);
            }

            this.fields.Add(field);
        }
Esempio n. 7
0
 public static void SetOutput(this INodeField nodeField, object value) => nodeField[INodeField.OutputKey] = value;
Esempio n. 8
0
 public static T GetOutput <T>(this INodeField nodeField) => (T)nodeField[INodeField.OutputKey];
Esempio n. 9
0
 public static object GetOutput(this INodeField nodeField) => nodeField[INodeField.OutputKey];
Esempio n. 10
0
 public static INodeField WithOutput <T>(this INodeField nodeField, bool isUserEditable = false)
 {
     nodeField.AddValue <T>(INodeField.OutputKey, isUserEditable);
     return(nodeField);
 }
Esempio n. 11
0
 public static INodeField WithInput <T>(this INodeField nodeField, bool isUserEditable = true)
 {
     nodeField.AddValue <T>(INodeField.InputKey, isUserEditable);
     return(nodeField);
 }
Esempio n. 12
0
 public static INodeField WithValue <T>(this INodeField nodeField, object valueKey, bool isUserEditable)
 {
     nodeField.AddValue <T>(valueKey, isUserEditable);
     return(nodeField);
 }
Esempio n. 13
0
 public static INodeField WithOutput <T>(this INodeField nodeField)
 {
     nodeField.AddValue <T>(INodeField.OutputKey, false);
     return(nodeField);
 }
Esempio n. 14
0
 public static INodeField WithInput <T>(this INodeField nodeField)
 {
     nodeField.AddValue <T>(INodeField.InputKey, true);
     return(nodeField);
 }
Esempio n. 15
0
 /// <summary>
 /// Attempt to get a field by name.
 /// </summary>
 /// <param name="name">Name of the field to get</param>
 /// <param name="field">Found field</param>
 /// <returns>True if found, otherwise false</returns>
 public bool TryGetField(string name, out INodeField field)
 {
     field = this.Fields.FirstOrDefault(f => f.Name == name);
     return(field != null);
 }