protected void StartRoundBtn_Click(object sender, EventArgs e) { // Disable GUI Elements prevBtn.Enabled = nextBtn.Enabled = startRoundBtn.Enabled = false; foreach (var btn in teamSlots) { btn.Enabled = false; } // Send data to the scouts var adapter = BluetoothIO.Adapter; WaitingOnScouts = 0; for (int i = 0; i < Config.RegisteredDevices.Count; ++i) { // Get the device var scout = Config.RegisteredDevices[i]; var device = adapter.GetRemoteDevice(scout); // Establish a connection with the scout ScoutMasterConnection connection; if (BluetoothIO.Connections.Count <= i) { connection = new ScoutMasterConnection(device); connection.Start(); BluetoothIO.Connections.Add(connection); } else { connection = (BluetoothIO.Connections[i] as ScoutMasterConnection); if (!connection.Active) { connection = new ScoutMasterConnection(device); connection.Start(); BluetoothIO.Connections[i] = connection; } } if (connection == null) { continue; } // Send over the selected team's info on the next update loop // TODO: Open assign scout devices GUI ++WaitingOnScouts; connection.SendRoundInfo(i, Event.Current.CurrentRoundIndex); } UpdateUI(); }
private void NextRoundBtn_Click(object sender, EventArgs e) { if (Event.Current == null) { Event.Current = new Event() { Name = "Test Event", }; } // If no team is selected, get one first if (SelectedTeam == null) { StartActivityForResult (typeof(TeamActivity), GET_TEAM_CONNECT_REQUEST); return; } ShowToast("Assigning selected team(s)...", ToastLength.Short); // Setup the next round var round = new Round(); /*round.TeamData.Length*/ for (int i = 0; i < Config.RegisteredDevices.Count; ++i) { round.TeamData[i] = new TeamData(SelectedTeam); } Event.Current.Rounds.Add(round); ++Event.Current.CurrentRoundIndex; // TODO: Assign Teams to scouts automatically based on tablet color // Send data to the scouts var adapter = BluetoothIO.Adapter; for (int i = 0; i < Config.RegisteredDevices.Count; ++i) { // Get the device var scout = Config.RegisteredDevices[i]; var device = adapter.GetRemoteDevice(scout); // Establish a connection with the scout ScoutMasterConnection connection; if (BluetoothIO.Connections.Count <= i) { connection = new ScoutMasterConnection(device); connection.Start(); BluetoothIO.Connections.Add(connection); } else { connection = (BluetoothIO.Connections[i] as ScoutMasterConnection); } if (connection == null) { continue; } // Send over the selected team's info on the next update loop connection.SendRoundInfo(i, Event.Current.CurrentRoundIndex); } }