public void Evaluate(int SpreadMax) { if (FInSource.IsChanged) { FOutTrigger.SliceCount = SpreadMax; for (int i = 0; i < SpreadMax; i++) { FOutTrigger[i] = new HardwareTrigger() { Source = FInSource[i] }; } } }
protected override void OnCreate(Bundle savedInstanceState) { Log.Debug(TAG, "OnCreate"); base.OnCreate(savedInstanceState); lock (DatabaseContext.DbLocker) { using (DatabaseContext db = new DatabaseContext(gs.DatabasePathBase)) { scriptHardware = db.Scripts.Include(x => x.Commands).Include(x => x.TriggerPort).FirstOrDefault(x => x.Id == Intent.Extras.GetInt(nameof(ScriptModel.Id), 0)); } } TopLayout = FindViewById <LinearLayoutCompat>(Resource.Id.script_top_layout); FooterLayout = FindViewById <LinearLayoutCompat>(Resource.Id.script_footer_layout); CardTitle.Text = GetText(Resource.String.script_edit_title); CardSubtitle.Text = GetText(Resource.String.script_edit_subtitle); DeleteScript = new AppCompatButton(this) { Text = GetText(Resource.String.delete_title) }; DeleteScript.SetTextColor(Color.DarkRed); DeleteScript.LayoutParameters = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent); FooterLayout.AddView(DeleteScript); ButtonOk.Tag = scriptHardware.Id; CommandsScript = new AppCompatButton(this) { Text = $"{GetString(Resource.String.commands_title)} ({scriptHardware.Commands.Count})" }; CommandsScript.LayoutParameters = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent); TopLayout.AddView(CommandsScript); StartScript = new AppCompatButton(this) { Text = GetText(Resource.String.run_the_script_title), Enabled = scriptHardware.Commands.Count > 0 }; StartScript.LayoutParameters = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent); TopLayout.AddView(StartScript); ScriptName.Text = scriptHardware.Name; if (scriptHardware.TriggerPort != null) { AutorunTrigger.Checked = true; PortTrigger.Enabled = true; HardwareTrigger.Enabled = true; StateTrigger.Enabled = true; int indexPosition = Hardwares.Keys.ToList().IndexOf(scriptHardware.TriggerPort.HardwareId); HardwareTrigger.SetSelection(indexPosition); PortsList_UpdateSpinner(scriptHardware.TriggerPort.HardwareId, ref PortTrigger, scriptHardware.TriggerPort.Id);//, ref Ports string[] statuses = Resources.GetStringArray(Resource.Array.script_trigger_port_states_array); if (scriptHardware.TriggerPortState == true) { indexPosition = Array.IndexOf(statuses, GetString(Resource.String.abc_capital_on)); } else if (scriptHardware.TriggerPortState == false) { indexPosition = Array.IndexOf(statuses, GetString(Resource.String.abc_capital_off)); } else { indexPosition = Array.IndexOf(statuses, GetString(Resource.String.abc_capital_switch)); } StateTrigger.SetSelection(indexPosition); } }