Skip to content

Commit

Permalink
Fix IndexOutOfRangeException caused by edge case when wallpaper changes
Browse files Browse the repository at this point in the history
  • Loading branch information
t1m0thyj committed Aug 28, 2018
1 parent 677dfed commit 9951e9b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.0.1")]
[assembly: AssemblyVersion("2.0.2")]
//[assembly: AssemblyFileVersion("1.0.0.0")]
12 changes: 12 additions & 0 deletions src/WallpaperChangeScheduler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,12 @@ private void UpdateDayImage()
TimeSpan timerLength = new TimeSpan(dayTime.Ticks / dayImages.Length);
int imageNumber = GetImageNumber(todaysData.SunriseTime, timerLength);

if (imageNumber >= dayImages.Length)
{
UpdateNightImage();
return;
}

StartTimer(todaysData.SunriseTime.Ticks + timerLength.Ticks * (imageNumber + 1)
- DateTime.Now.Ticks, timerLength);

Expand All @@ -180,6 +186,12 @@ private void UpdateNightImage()
TimeSpan timerLength = new TimeSpan(nightTime.Ticks / nightImages.Length);
int imageNumber = GetImageNumber(day1Data.SunsetTime, timerLength);

if (imageNumber >= nightImages.Length)
{
UpdateDayImage();
return;
}

StartTimer(day1Data.SunsetTime.Ticks + timerLength.Ticks * (imageNumber + 1)
- DateTime.Now.Ticks, timerLength);

Expand Down
2 changes: 1 addition & 1 deletion uwp/Package.appxmanifest
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest" xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities" xmlns:desktop="http://schemas.microsoft.com/appx/manifest/desktop/windows10" IgnorableNamespaces="uap mp rescap desktop">
<Identity Name="38719TimothyJohnson.WinDynamicDesktop" Publisher="CN=3C822DA5-D64C-40A9-A84A-5502C3EDD8CD" Version="2.0.1.0" />
<Identity Name="38719TimothyJohnson.WinDynamicDesktop" Publisher="CN=3C822DA5-D64C-40A9-A84A-5502C3EDD8CD" Version="2.0.2.0" />
<Properties>
<DisplayName>WinDynamicDesktop</DisplayName>
<PublisherDisplayName>Timothy Johnson</PublisherDisplayName>
Expand Down

0 comments on commit 9951e9b

Please sign in to comment.