Skip to content

Commit

Permalink
Fix bug where timer interval was sometimes set to 0
Browse files Browse the repository at this point in the history
  • Loading branch information
t1m0thyj committed Jul 15, 2018
1 parent 21f088d commit 16b982a
Show file tree
Hide file tree
Showing 56 changed files with 25 additions and 23 deletions.
12 changes: 6 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
.vs/
DesktopBridge/AppPackages/
DesktopBridge/BundleArtifacts/
bin/
obj/
output/
src/*/images
src/packages/
uwp/AppPackages/
uwp/BundleArtifacts/

DesktopBridge/*.pfx
DesktopBridge/DesktopBridge.wapproj.user
DesktopBridge/Package.StoreAssociation.xml
DesktopBridge/_pkginfo.txt
images.zip
settings.conf
uwp/*.pfx
uwp/DesktopBridge.wapproj.user
uwp/Package.StoreAssociation.xml
uwp/_pkginfo.txt
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Port of macOS Mojave Dynamic Desktop feature to Windows 10, available for downlo
[![Gitter chat](https://badges.gitter.im/gitterHQ/gitter.png)](https://gitter.im/t1m0thyj/WinDynamicDesktop)
[![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=H8ZZXM9ABRJFU)

<a href='//www.microsoft.com/store/apps/9NM8N7DQ3Z5F?ocid=badge'><img src='https://assets.windowsphone.com/85864462-9c82-451e-9355-a3d5f874397a/English_get-it-from-MS_InvariantCulture_Default.png' alt='Microsoft Store' width='180'/></a>
<a href='//www.microsoft.com/store/apps/9NM8N7DQ3Z5F?ocid=badge'><img src='https://assets.windowsphone.com/85864462-9c82-451e-9355-a3d5f874397a/English_get-it-from-MS_InvariantCulture_Default.png' alt='Microsoft Store' width='160'/></a>

## How do I use this?

Expand All @@ -25,7 +25,7 @@ When the Dynamic Desktop feature was announced for macOS Mojave which shifts thr

Yes. By default WinDynamicDesktop uses the Mojave wallpapers, but if you create an `images.conf` file in the same folder as the EXE you can customize the images that are used. The default `images.conf` can be found [here](src/images.conf). It is formatted in JSON and must contain the following values:

* `themeName` - String which is the name of the wallpaper theme shown in the user interface
* `themeName` - String which is the name of the wallpaper theme (e.g., "Mojave Default")
* `imagesZipUri` - String containing URL to download images.zip file from, or *null* if the content in the images subfolder is provided by the user
* `imageFilename` - String containing the filename of each wallpaper image, with `{0}` substituted for the image number
* `dayImageList` - Array of numbers listing the image numbers to display throughout the day (between sunrise and sunset)
Expand Down
4 changes: 2 additions & 2 deletions src/AppContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ private void OnExitItemClick(object sender, EventArgs e)

private void OnBalloonTipClicked(object sender, EventArgs e)
{
if (notifyIcon.BalloonTipText == "Update Available")
if (notifyIcon.BalloonTipTitle == "Update Available")
{
System.Diagnostics.Process.Start(UpdateChecker.updateLink);
}
Expand Down Expand Up @@ -200,7 +200,7 @@ private void OnDownloadDialogClosed(object sender, EventArgs e)
Environment.Exit(0);
}
}
else if (JsonConfig.settings.location == null)
else if (locationDialog == null)
{
_wcsService.RunScheduler();
BackgroundNotify();
Expand Down
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("1.3.1")]
[assembly: AssemblyVersion("1.4.0")]
//[assembly: AssemblyFileVersion("1.0.0.0")]
9 changes: 3 additions & 6 deletions src/UpdateChecker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public static void CheckManual()
else
{
MessageBox.Show("You already have the latest version of WinDynamicDesktop installed.",
"Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
"Up To Date", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}

Expand Down Expand Up @@ -118,8 +118,7 @@ public static void TryCheckAuto()
if (JsonConfig.settings.lastUpdateCheck != null)
{
DateTime lastUpdateCheck = DateTime.Parse(JsonConfig.settings.lastUpdateCheck);
long tickDiff = Math.Max(0, DateTime.Now.Ticks - lastUpdateCheck.Ticks);
int dayDiff = (new TimeSpan(tickDiff)).Days;
int dayDiff = (new TimeSpan(DateTime.Now.Ticks - lastUpdateCheck.Ticks)).Days;

if (dayDiff < 7)
{
Expand All @@ -129,9 +128,7 @@ public static void TryCheckAuto()

CheckAuto();

DateTime today = DateTime.Now;
DateTime lastMonday = today.AddDays(DayOfWeek.Monday - today.DayOfWeek);
JsonConfig.settings.lastUpdateCheck = lastMonday.ToString("yyyy-MM-dd");
JsonConfig.settings.lastUpdateCheck = DateTime.Now.ToString("yyyy-MM-dd");
JsonConfig.SaveConfig();
}
}
Expand Down
15 changes: 10 additions & 5 deletions src/WallpaperChangeScheduler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,16 @@ private int GetImageNumber(DateTime startTime, TimeSpan timerLength)
return (int)(elapsedTime.Ticks / timerLength.Ticks);
}

private void StartTimer(long tickInterval)
private void StartTimer(long tickInterval, TimeSpan maxInterval)
{
if (tickInterval < TimeSpan.TicksPerMillisecond)
{
tickInterval += maxInterval.Ticks;
}

TimeSpan interval = new TimeSpan(tickInterval);

wallpaperTimer.Interval = Math.Max(1, (int)interval.TotalMilliseconds);
wallpaperTimer.Interval = (int)interval.TotalMilliseconds;
wallpaperTimer.Start();
}

Expand Down Expand Up @@ -136,9 +141,9 @@ private void UpdateDayImage()
TimeSpan dayTime = todaysData.SunsetTime - todaysData.SunriseTime;
TimeSpan timerLength = new TimeSpan(dayTime.Ticks / dayImages.Length);
int imageNumber = GetImageNumber(todaysData.SunriseTime, timerLength);

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

if (dayImages[imageNumber] != lastImageId)
{
Expand All @@ -156,7 +161,7 @@ private void UpdateNightImage()
int imageNumber = GetImageNumber(day1Data.SunsetTime, timerLength);

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

if (nightImages[imageNumber] != lastImageId)
{
Expand Down
2 changes: 1 addition & 1 deletion src/WinDynamicDesktop.sln
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ VisualStudioVersion = 15.0.27428.2043
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WinDynamicDesktop", "WinDynamicDesktop.csproj", "{D752C033-AB46-423A-8611-E2E2A40CA80F}"
EndProject
Project("{C7167F0D-BC9F-4E6E-AFE1-012C56B48DB5}") = "DesktopBridge", "..\DesktopBridge\DesktopBridge.wapproj", "{D10BBBDF-EFCF-4051-9BFD-9B0AFCD30EE4}"
Project("{C7167F0D-BC9F-4E6E-AFE1-012C56B48DB5}") = "DesktopBridge", "..\uwp\DesktopBridge.wapproj", "{D10BBBDF-EFCF-4051-9BFD-9B0AFCD30EE4}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.

0 comments on commit 16b982a

Please sign in to comment.