private async void btnConnection_Click(object sender, RoutedEventArgs e) { if (SpherosDiscovered.SelectedItem != null) { SpheroInformation information = (SpheroInformation)SpherosDiscovered.SelectedItem; SpheroConnection connection = await SpheroConnectionProvider.CreateConnection(information); if (connection == null) { MessageBox.Show("Connection failed"); } else { App.CurrentConnection = connection; NavigationService.Navigate(new Uri("/MacroPage.xaml", UriKind.RelativeOrAbsolute)); } } }
public static async Task <JediSphero> GetSpheroAsync() { IEnumerable <SpheroInformation> spheros = await SpheroConnectionProvider.DiscoverSpheros(); SpheroInformation spheroInfo = spheros.FirstOrDefault(); if (spheroInfo == null) { return(null); } SpheroConnection connection = await SpheroConnectionProvider.CreateConnection(spheroInfo); if (connection == null) { return(null); } var spheroDevice = new JediSphero(connection); return(spheroDevice); }