-
Open Visual Studio 2015 and create a new project - Blank App (Universal Windows)
-
Click Tools -> NuGet Package Manager -> Package Manager Console
-
Open
MainPage.xaml
and add the following between the<Grid>
tags:
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="200" />
</Grid.RowDefinitions>
<StackPanel Margin="0,50,0,0">
<TextBox x:Name="usernameTextBox" InputScope="EmailSmtpAddress" PlaceholderText="username" />
<PasswordBox x:Name="passwordTextBox" PlaceholderText="password" />
<Button x:Name="loginButton" Content="Login" Click="loginButton_Click" />
<ListBox x:Name="deviceListBox" ItemsSource="{Binding}" MaxHeight="200">
<ListBox.ItemTemplate>
<DataTemplate>
<TextBlock Grid.Row="0" Text="{Binding Name}" />
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</StackPanel>
<ListBox x:Name="logListBox" Grid.Row="1" />
-
Open
MainPage.xaml.cs
and addusing Particle.SDK;
to the top of theUsings
section -
Open
MainPage.xaml.cs
and add the following inside theMainPage
class:
private async void loginButton_Click(object sender, RoutedEventArgs e)
{
logListBox.Items.Insert(0, "Login");
bool success = await ParticleCloud.SharedCloud.LoginAsync(usernameTextBox.Text, passwordTextBox.Password);
logListBox.Items.Insert(0, $"Login: {success}");
if (!success)
return;
logListBox.Items.Insert(0, "GetDevices");
var devices = await ParticleCloud.SharedCloud.GetDevicesAsync();
logListBox.Items.Insert(0, $"GetDevices: {devices.Count} devices");
deviceListBox.DataContext = devices;
}
-
Press
F5
-
Enter your credentials in the
username
andpassword
field then clickLogin