Skip to content

Commit

Permalink
Added a textblock, displayed when geoinfo is null but InternetSync is…
Browse files Browse the repository at this point in the history
… enabled
  • Loading branch information
Tyrrrz committed Jan 13, 2017
1 parent bcaf227 commit db0750c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
9 changes: 8 additions & 1 deletion LightBulb/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,11 @@ public TimeSpan SunsetTime
public GeolocationInfo GeoInfo
{
get { return _geoInfo; }
set { Set(ref _geoInfo, value); }
set
{
Set(ref _geoInfo, value);
RaisePropertyChanged(() => GeoinfoNotNull);
}
}

[IgnoreDataMember]
Expand All @@ -151,5 +155,8 @@ public double SunsetTimeHours
get { return SunsetTime.TotalHours; }
set { SunsetTime = TimeSpan.FromHours(value); }
}

[IgnoreDataMember]
public bool GeoinfoNotNull => GeoInfo != null;
}
}
17 changes: 15 additions & 2 deletions LightBulb/Views/GeolocationSettingsPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,15 @@
<WrapPanel Margin="5,0,5,5"
Orientation="Horizontal"
Visibility="{Binding Settings.IsInternetTimeSyncEnabled, Converter={StaticResource BoolToVisibilityConverter}}">
<Image Height="16" Source="{Binding Settings.GeoInfo.CountryFlag, IsAsync=True}" />
<TextBlock Margin="3,0,0,0" VerticalAlignment="Center">
<!-- Geoinfo is set -->
<Image Height="16"
VerticalAlignment="Center"
Source="{Binding Settings.GeoInfo.CountryFlag, IsAsync=True}"
Visibility="{Binding Settings.GeoinfoNotNull, Converter={StaticResource BoolToVisibilityConverter}, ConverterParameter=Collapsed}" />
<TextBlock Margin="3,0,0,0"
VerticalAlignment="Center"
TextWrapping="Wrap"
Visibility="{Binding Settings.GeoinfoNotNull, Converter={StaticResource BoolToVisibilityConverter}, ConverterParameter=Collapsed}">
<Run Foreground="{DynamicResource PrimaryTextBrush}" Text="{Binding Settings.GeoInfo.City, Mode=OneWay, TargetNullValue=Unknown}" />
<Run Text="/" />
<Run Foreground="{DynamicResource PrimaryTextBrush}" Text="{Binding Settings.GeoInfo.Country, Mode=OneWay, TargetNullValue=Unknown}" />
Expand All @@ -84,6 +91,12 @@
<Run Foreground="{DynamicResource PrimaryTextBrush}" Text="{Binding Settings.GeoInfo.Longitude, Mode=OneWay, TargetNullValue=xx}" />
<Run Text="long" /><Run Text=")" />
</TextBlock>
<!-- Geoinfo is not set -->
<TextBlock VerticalAlignment="Center"
Text="Geographical location is undetermined"
TextWrapping="Wrap"
ToolTip="If this message doesn't disappear after some time, it might mean that the geolocation server is down"
Visibility="{Binding Settings.GeoinfoNotNull, Converter={StaticResource InvertBoolToVisibilityConverter}, ConverterParameter=Collapsed}" />
</WrapPanel>
</StackPanel>
</Page>

0 comments on commit db0750c

Please sign in to comment.