private void clickBindNewCommand(object sender, EventArgs e) { int type = bindTypePicker.SelectedIndex; string _id = bindCommandPicker.SelectedItem.ToString(); Setting_Device_Commmand[] temp = SettingsController.commands; Setting_Device_Commmand[] commands; if (temp == null) { commands = new Setting_Device_Commmand[1]; } else { int size = temp.Length == 0 ? 1 : temp.Length; commands = new Setting_Device_Commmand[size]; for (int i = 0; i < temp.Length; i++) { commands[i] = temp[i]; } } commands[commands.Length - 1] = new Setting_Device_Commmand() { type = (SettingDeviceCommandType)type, deviceName = _device.id, id = _id }; SettingsController.resyncCommands(commands); Device.BeginInvokeOnMainThread(() => { syncCommands(); }); }
private void clickRemoveCommand(object sender, EventArgs e) { string id = ((Button)sender).Parent.FindByName <Label>("_idLabel").Text; Setting_Device_Commmand[] temp = SettingsController.commands; Setting_Device_Commmand[] list = new Setting_Device_Commmand[temp.Length - 1]; int count = 0; foreach (Setting_Device_Commmand comm in temp) { if (comm.id != id) { list[count] = comm; count++; } } SettingsController.resyncCommands(list); Device.BeginInvokeOnMainThread(() => { syncCommands(); }); }