void UpdateSwipeItems() { if (_contentView == null || _actionView != null) { return; } SwipeItems items = GetSwipeItemsByDirection(); if (items == null || items.Count == 0) { return; } _actionView = new LinearLayoutCompat(_context); using (var layoutParams = new LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent)) _actionView.LayoutParameters = layoutParams; _actionView.Orientation = LinearLayoutCompat.Horizontal; var swipeItems = new List <AView>(); foreach (var item in items) { AView swipeItem = null; if (item is SwipeItem formsSwipeItem) { formsSwipeItem.PropertyChanged += OnSwipeItemPropertyChanged; swipeItem = CreateSwipeItem(formsSwipeItem); _actionView.AddView(swipeItem); _swipeItems.Add(formsSwipeItem, swipeItem); } if (item is SwipeItemView formsSwipeItemView) { formsSwipeItemView.PropertyChanged += OnSwipeItemPropertyChanged; swipeItem = CreateSwipeItemView(formsSwipeItemView); _actionView.AddView(swipeItem); UpdateSwipeItemViewLayout(formsSwipeItemView); _swipeItems.Add(formsSwipeItemView, swipeItem); } swipeItems.Add(swipeItem); } AddView(_actionView); _contentView?.BringToFront(); _actionView.Layout(0, 0, _contentView.Width, _contentView.Height); LayoutSwipeItems(swipeItems); swipeItems.Clear(); }
protected void TypesCommand_ItemSelected(object sender, AdapterView.ItemSelectedEventArgs e) { //command_executer_id = -1; //command_executer_parameter = null; int Position = TypesCommand.SelectedItemPosition; selected_type_command_name = Resources.GetStringArray(Resource.Array.commands_types_array)[Position]; string command_type_array_item_port = GetString(Resource.String.command_type_array_item_port); string command_type_array_item_controller = GetString(Resource.String.command_type_array_item_controller); string command_type_array_item_transfer = GetString(Resource.String.command_type_array_item_transit); //if (AbstractSettingsManage.Command != null) //{ // switch (AbstractSettingsManage.Command.TypeCommand) // { // case TypesCommands.Port: // command_type_array_item_port = GetString(Resource.String.command_type_array_item_port); // if (selected_type_command_name != command_type_array_item_port) // { // return; // } // break; // case TypesCommands.Controller: // if (selected_type_command_name != command_type_array_item_controller) // { // return; // } // break; // case TypesCommands.Exit: // if (selected_type_command_name != command_type_array_item_transfer) // { // return; // } // break; // } //} Log.Debug(TAG, $"TypesCommand_ItemSelected({selected_type_command_name}) - Position:{Position}"); CommandConfigForm.RemoveAllViews(); if (selected_type_command_name == command_type_array_item_port) { SelectedTypeCommand = TypesCommands.Port; about_selected_command.Text = GetString(Resource.String.about_selected_command_port_title); CommandConfigFormBody = LayoutInflater.Inflate(Resource.Layout.FormPortCommand, CommandConfigForm, false) as LinearLayoutCompat; AppCompatSpinner Controllers = CommandConfigFormBody.FindViewById <AppCompatSpinner>(Resource.Id.spinnerControllerPortCommand); AppCompatSpinner Ports = CommandConfigFormBody.FindViewById <AppCompatSpinner>(Resource.Id.spinnerPortCommand); AppCompatSpinner States = CommandConfigFormBody.FindViewById <AppCompatSpinner>(Resource.Id.spinnerStateCommand); SettingsManageKit = new SettingsManagePort(this, Controllers, Ports, States); } else if (selected_type_command_name == command_type_array_item_controller) { SelectedTypeCommand = TypesCommands.Controller; about_selected_command.Text = GetString(Resource.String.about_selected_command_controller_title); CommandConfigFormBody = LayoutInflater.Inflate(Resource.Layout.FormControllerCommand, CommandConfigForm, false) as LinearLayoutCompat; AppCompatSpinner Controllers = CommandConfigFormBody.FindViewById <AppCompatSpinner>(Resource.Id.spinnerControllerCommand); EditText CommandText = CommandConfigFormBody.FindViewById <EditText>(Resource.Id.editTextParametrControllerCommand); SettingsManageKit = new SettingsManageController(this, Controllers, CommandText); } else if (selected_type_command_name == command_type_array_item_transfer) { SelectedTypeCommand = TypesCommands.Exit; about_selected_command.Text = GetString(Resource.String.about_selected_command_transit_title); CommandConfigFormBody = LayoutInflater.Inflate(Resource.Layout.FormTransferCommand, CommandConfigForm, false) as LinearLayoutCompat; AppCompatSpinner Scriptes = CommandConfigFormBody.FindViewById <AppCompatSpinner>(Resource.Id.spinnerCommandScript); AppCompatSpinner Steps = CommandConfigFormBody.FindViewById <AppCompatSpinner>(Resource.Id.spinnerCommandStepScript); SettingsManageKit = new SettingsManageTransfer(this, Scriptes, Steps); } else { } CommandConfigForm.AddView(CommandConfigFormBody); }
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); } }