Added progress indications

This commit is contained in:
2015-12-02 21:48:48 +01:00
parent f2b760e549
commit a77bf79119
6 changed files with 38 additions and 22 deletions
+3 -1
View File
@@ -61,7 +61,7 @@ namespace HueUWP
lights.ForEach(l => SetLightValues(l));
}
public async void GetAllLights(ObservableCollection<Light> alllights)
public async Task<String> GetAllLights(ObservableCollection<Light> alllights)
{
// List<Light> lightlist = new List<Light>();
try {
@@ -91,6 +91,8 @@ namespace HueUWP
Debug.WriteLine(e.StackTrace);
Debug.WriteLine("Could not get all lights.");
}
return string.Empty;
}
+3 -1
View File
@@ -24,7 +24,9 @@
<TextBlock RelativePanel.AlignLeftWithPanel="True" FontSize="24" Margin="20,10,0,0">Hue Lights</TextBlock>
</RelativePanel>
<StackPanel Grid.Row="1" Margin="0,10,0,0">
<ProgressRing Grid.Row="1" Height="60" Width="60" RelativePanel.AlignHorizontalCenterWithPanel="True" Margin=" 0,10,0,10" IsActive="True" Name="Loading" />
<StackPanel Grid.Row="1" Margin="0,10,0,0" Name="LightListPanel" Visibility="Collapsed">
<ListView x:Name="myListView" ItemsSource="{Binding}" IsItemClickEnabled="True" ItemClick="myListView_ItemClick">
<ListView.ItemTemplate>
<DataTemplate x:Name="dataTemplate">
+16 -3
View File
@@ -5,6 +5,7 @@ using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using System.Threading.Tasks;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.Storage;
@@ -46,8 +47,21 @@ namespace HueUWP
//LOCAL_SETTINGS.Values["port"] = 8000;
NetworkHandler nwh = new NetworkHandler();
api = new APIHandler(nwh);
}
protected override void OnNavigatedTo(NavigationEventArgs e)
{
Load_Lights();
}
private async void Load_Lights()
{
_lightsViewModel.Clear();
api.GetAllLights(_lightsViewModel);
Loading.IsActive = true;
await api.GetAllLights(_lightsViewModel);
Loading.IsActive = false;
}
public void ToggleSwitch_Tapped(object sender, TappedRoutedEventArgs e)
@@ -76,8 +90,7 @@ namespace HueUWP
private void RefreshButton_Click(object sender, RoutedEventArgs e)
{
_lightsViewModel.Clear();
api.GetAllLights(_lightsViewModel);
Load_Lights();
}
private void myListView_ItemClick(object sender, ItemClickEventArgs e)
-10
View File
@@ -138,15 +138,5 @@ namespace HueUWP
return response;
}
public async Task<String> Test()
{
var response = await Get( "111bb033202ac68b5812245c22f77eb/lights");
if (string.IsNullOrEmpty(response))
await new MessageDialog("Error while setting username. ….").ShowAsync();
return response;
}
}
}
+11 -5
View File
@@ -30,11 +30,17 @@
<StackPanel Margin="20">
<TextBlock FontSize="16">User ID</TextBlock>
<TextBox Margin="0,10,0,10" Text="{x:Bind SettingsViewModel.ID, Mode=OneWay}" IsEnabled="False"/>
<Button Margin="0,10,0,10" Name="UpdateID" Click="UpdateID_Click">
<StackPanel Orientation="Horizontal">
<TextBlock FontFamily="Segoe MDL2 Assets" FontSize="10" Margin="10" Text="&#xE72C;" /><TextBlock FontSize="10" Margin="10" Text="Request new" />
</StackPanel>
</Button>
<StackPanel Orientation="Horizontal" Margin="0,10,0,10">
<Button Name="UpdateID" Click="UpdateID_Click">
<StackPanel Orientation="Horizontal">
<TextBlock FontFamily="Segoe MDL2 Assets" FontSize="15" Margin="5, 9, 5, 5" Text="&#xE72C;" />
<TextBlock FontSize="15" Margin="5" Text="Request new" />
</StackPanel>
</Button>
<ProgressRing Height="35" Width="35" Margin="20, 0, 0, 0" IsActive="False" Name="UserIdProgress" />
</StackPanel>
</StackPanel>
</StackPanel>
</Grid>
+5 -2
View File
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using System.Threading.Tasks;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
@@ -34,8 +35,10 @@ namespace HueUWP
private async void UpdateID_Click(object sender, RoutedEventArgs e)
{
await api.Register();
SettingsViewModel.Update();
UserIdProgress.IsActive = true;
await api.Register();
UserIdProgress.IsActive = false;
SettingsViewModel.Update();
}
protected override void OnNavigatedTo(NavigationEventArgs e)