public static NodeSignal BuildWith(FieldSignalName SignalName, FieldDataType DataType, FieldBool Forced, FieldConstant ForcedValue) { //build fields Dictionary <FieldIdentifier, FieldBase> mutableFields = new Dictionary <FieldIdentifier, FieldBase>(); mutableFields.Add(new FieldIdentifier(m_SignalIdName), new FieldGuid()); mutableFields.Add(new FieldIdentifier(m_SignalNameName), SignalName); mutableFields.Add(new FieldIdentifier(m_ForcedName), Forced); mutableFields.Add(new FieldIdentifier(m_ForcedValueName), ForcedValue); mutableFields.Add(new FieldIdentifier(m_CommentName), new FieldString()); //Add Fields here: mutableFields.Add(new FieldIdentifier(m_CodeName), Code); //build children KeyedNodeCollection <NodeBase> mutableChildren = new KeyedNodeCollection <NodeBase>(); mutableChildren.Add(NodeValue.BuildWith(DataType)); //Add Children here: mutableChildren.Add(SomeChild); //build node NodeSignal Builder = new NodeSignal( new ReadOnlyDictionary <FieldIdentifier, FieldBase>(mutableFields), new ReadOnlyCollection <NodeBase>(mutableChildren)); return(Builder); }
public NodeAnalogInput SetForced(FieldBool Forced) { if (Forced == null) { throw new ArgumentNullException(m_ForcedName); } return(new NodeAnalogInput(this.SetField(new FieldIdentifier(m_ForcedName), Forced), ChildCollection)); }
public NodePageCollection SetLogicRoot(FieldBool LogicRoot) { if (LogicRoot == null) { throw new ArgumentNullException(m_LogicRootName); } return(new NodePageCollection(this.SetField(new FieldIdentifier(m_LogicRootName), LogicRoot), ChildCollection)); }
public NodeDiscreteOutput SetForcedValue(FieldBool ForcedValue) { if (ForcedValue == null) { throw new ArgumentNullException(m_ForcedValueName); } return(new NodeDiscreteOutput(this.SetField(new FieldIdentifier(m_ForcedValueName), ForcedValue), ChildCollection)); }
public NodeDriver SetRunning(FieldBool Running) { if (Running == null) { throw new ArgumentNullException(m_RunningName); } return(new NodeDriver(this.SetField(new FieldIdentifier(m_RunningName), Running), ChildCollection)); }
public NodeRuntimeApplication SetTryMode(FieldBool TryMode) { if (TryMode == null) { throw new ArgumentNullException(m_TryModeName); } return(new NodeRuntimeApplication(this.SetField(new FieldIdentifier(m_TryModeName), TryMode), ChildCollection)); }
public NodeRuntimeApplication SetExecuteOnStartup(FieldBool ExecuteOnStartup) { if (ExecuteOnStartup == null) { throw new ArgumentNullException(m_ExecuteOnStartupName); } return(new NodeRuntimeApplication(this.SetField(new FieldIdentifier(m_ExecuteOnStartupName), ExecuteOnStartup), ChildCollection)); }
public static NodeRuntimeApplication BuildWith( FieldIdentifier Code, FieldGuid TypeId, FieldGuid RuntimeId, FieldString Address, FieldBase64 Configuration, FieldBool ExecuteOnStartup, NodePageCollection Logic, NodeDeviceConfiguration DeviceConfiguration) { var rta = NodeRuntimeApplication.BuildWith( Code, TypeId, RuntimeId, Address, Configuration, ExecuteOnStartup); rta = rta.SetLogic(Logic); return(rta.SetDeviceConfiguration(DeviceConfiguration)); }
public FormDialog AddFieldBool(string title, string choiceLeft, string choiceRight, string dataname, Predicate <bool> condition) { FieldBool field = new FieldBool(); field.Title = title; field.Dataname = dataname; field.Condition = condition; field.ChoiceLeft = choiceLeft; field.ChoiceRight = choiceRight; fields.Add(field); return(this); }
public static NodeRuntimeApplication BuildWith( FieldIdentifier Code, FieldGuid TypeId, FieldGuid RuntimeId, FieldString Address, FieldBase64 Configuration, FieldBool ExecuteOnStartup) { //build fields Dictionary <FieldIdentifier, FieldBase> mutableFields = new Dictionary <FieldIdentifier, FieldBase>(); mutableFields.Add(new FieldIdentifier(m_CodeName), Code); mutableFields.Add(new FieldIdentifier(m_TypeIdName), TypeId); mutableFields.Add(new FieldIdentifier(m_RuntimeIdName), RuntimeId); mutableFields.Add(new FieldIdentifier(m_AddressName), Address); mutableFields.Add(new FieldIdentifier(m_ConfigurationName), Configuration); mutableFields.Add(new FieldIdentifier(m_ExecuteOnStartupName), ExecuteOnStartup); mutableFields.Add(new FieldIdentifier(m_TryModeName), new FieldBool(false)); //Add Fields here: mutableFields.Add(new FieldIdentifier("Code"), Code); //build children KeyedNodeCollection <NodeBase> mutableChildren = new KeyedNodeCollection <NodeBase>(); var pc = NodePageCollection.BuildWith( new FieldPageCollectionName(m_LogicName) ); pc = pc.SetLogicRoot(new FieldBool(true)); mutableChildren.Add(pc); mutableChildren.Add( NodeDeviceConfiguration.BuildWith( new ReadOnlyCollection <NodeDriver>(new Collection <NodeDriver>()) )); //Add Children here: mutableChildren.Add(SomeChild); //build node NodeRuntimeApplication Builder = new NodeRuntimeApplication( new ReadOnlyDictionary <FieldIdentifier, FieldBase>(mutableFields), new ReadOnlyCollection <NodeBase>(mutableChildren)); return(Builder); }
private void DialogResponse(object sender, DialogResponseEventArgs e) { if (CanQuit && e.DialogButton == SampSharp.GameMode.Definitions.DialogButton.Right) { FormDialogEventArgs retArgs = new FormDialogEventArgs(); retArgs.Player = (Player)e.Player; retArgs.Data = datas; retArgs.Exited = true; Response?.Invoke(this, retArgs); return; } if (e.ListItem > fields.Count) { Show((Player)e.Player); return; } if (e.ListItem == fields.Count) // It's over the count so it's after the last field { FormDialogEventArgs retArgs = new FormDialogEventArgs(); retArgs.Player = (Player)e.Player; retArgs.Data = datas; retArgs.Exited = false; Response?.Invoke(this, retArgs); return; } if (fields[e.ListItem] is FieldBool) { FieldBool field = (FieldBool)fields[e.ListItem]; MessageDialog dialog = new MessageDialog(Title, field.Title, field.ChoiceLeft, field.ChoiceRight); dialog.Response += (sender, e) => { if (!field.Condition(e.DialogButton == DialogButton.Left)) { dialog.Show(e.Player); return; } datas[field.Dataname] = e.DialogButton == DialogButton.Left; Show((Player)e.Player); }; dialog.Show(e.Player); return; } else { Field field = fields[e.ListItem]; InputDialog dialog = new InputDialog(Title, field.Title, field.Hidden, "Continuer", "Retour"); switch (field) { case FieldNumber fn: dialog.Response += (sender, e) => { int res = 0; if (!int.TryParse(e.InputText, out res) || !fn.Condition(res)) { dialog.Show(e.Player); return; } datas[field.Dataname] = res; Show((Player)e.Player); }; break; case FieldFloat ff: dialog.Response += (sender, e) => { float res = 0; if (!float.TryParse(e.InputText, out res) || !ff.Condition(res)) { dialog.Show(e.Player); return; } datas[field.Dataname] = res; Show((Player)e.Player); }; break; case FieldString fs: dialog.Response += (sender, e) => { if (!fs.Condition(e.InputText)) { dialog.Show(e.Player); return; } datas[field.Dataname] = e.InputText; Show((Player)e.Player); }; break; } ; dialog.Show(e.Player); return; } }