diff --git a/AboutPage/CheckForUpdatesPage.cs b/AboutPage/CheckForUpdatesPage.cs index 26c550e2a..5812cfd58 100644 --- a/AboutPage/CheckForUpdatesPage.cs +++ b/AboutPage/CheckForUpdatesPage.cs @@ -104,7 +104,7 @@ namespace MatterHackers.MatterControl.AboutPage UserSettings.Instance.set(UserSettingsKey.UpdateFeedType, releaseCode); } - UpdateControlData.Instance.CheckForUpdateUserRequested(); + UpdateControlData.Instance.CheckForUpdate(); }; currentFeedAndDropDownContainer.AddChild(releaseOptionsDropList); diff --git a/AboutPage/UpdateControlData.cs b/AboutPage/UpdateControlData.cs index 9471bc536..10ee1a2d9 100644 --- a/AboutPage/UpdateControlData.cs +++ b/AboutPage/UpdateControlData.cs @@ -33,6 +33,7 @@ using System.Diagnostics; using System.IO; using System.Net; using System.Threading; +using System.Timers; using MatterHackers.Agg; using MatterHackers.Agg.Platform; using MatterHackers.Agg.UI; @@ -53,10 +54,6 @@ namespace MatterHackers.MatterControl public int DownloadPercent { get { return downloadPercent; } } - public enum UpdateRequestType { UserRequested, Automatic, FirstTimeEver }; - - private UpdateRequestType updateRequestType; - public enum UpdateStatusStates { MayBeAvailable, CheckingForUpdate, UpdateAvailable, UpdateDownloading, ReadyToInstall, UpToDate, UnableToConnectToServer, UpdateRequired }; private bool WaitingToCompleteTransaction() @@ -112,7 +109,8 @@ namespace MatterHackers.MatterControl } } - static bool haveShowUpdateRequired = false; + private static bool haveShowUpdateRequired = false; + private void SetUpdateStatus(UpdateStatusStates updateStatus) { if (this.updateStatus != updateStatus) @@ -178,16 +176,10 @@ namespace MatterHackers.MatterControl return updateStatus == UpdateStatusStates.UpdateAvailable && ApplicationSettings.Instance.get(LatestVersionRequest.VersionKey.UpdateRequired) == "True"; } - private set {} + private set { } } - public void CheckForUpdateUserRequested() - { - updateRequestType = UpdateRequestType.UserRequested; - CheckForUpdate(); - } - - private void CheckForUpdate() + public void CheckForUpdate() { if (!WaitingToCompleteTransaction()) { @@ -222,7 +214,8 @@ namespace MatterHackers.MatterControl else { SetUpdateStatus(UpdateStatusStates.UpdateAvailable); - if (updateRequestType == UpdateRequestType.FirstTimeEver) + bool firstUpdateRequest = ApplicationSettings.Instance.GetClientToken() == null; + if (firstUpdateRequest) { UiThread.RunOnIdle(() => { @@ -329,7 +322,7 @@ namespace MatterHackers.MatterControl { this.downloadPercent = (int)(e.BytesReceived * 100 / downloadSize); } - UiThread.RunOnIdle(() => UpdateStatusChanged.CallEvents(this, e) ); + UiThread.RunOnIdle(() => UpdateStatusChanged.CallEvents(this, e)); } private void DownloadCompleted(object sender, AsyncCompletedEventArgs e) @@ -366,14 +359,6 @@ namespace MatterHackers.MatterControl if (ApplicationSettings.Instance.GetClientToken() != null || OemSettings.Instance.CheckForUpdatesOnFirstRun) { - if (ApplicationSettings.Instance.GetClientToken() == null) - { - updateRequestType = UpdateRequestType.FirstTimeEver; - } - else - { - updateRequestType = UpdateRequestType.Automatic; - } //If we have already requested an update once, check on load CheckForUpdate(); } @@ -387,6 +372,16 @@ namespace MatterHackers.MatterControl SetUpdateStatus(UpdateStatusStates.UpdateAvailable); } } + + // Now that we are running, check for an update every 24 hours. + var aTimer = new System.Timers.Timer(24 * 60 * 60 * 1000); //one day in milliseconds + aTimer.Elapsed += new ElapsedEventHandler(CheckForUpdateDaily); + aTimer.Start(); + } + + private void CheckForUpdateDaily(object source, ElapsedEventArgs e) + { + CheckForUpdate(); } public void OnUpdateStatusChanged(EventArgs e) @@ -456,4 +451,4 @@ namespace MatterHackers.MatterControl return false; } } -} +} \ No newline at end of file diff --git a/AboutPage/UpdateControlView.cs b/AboutPage/UpdateControlView.cs index d4d9b2814..4c042e761 100644 --- a/AboutPage/UpdateControlView.cs +++ b/AboutPage/UpdateControlView.cs @@ -69,7 +69,7 @@ namespace MatterHackers.MatterControl }; checkUpdateLink.Click += (s, e) => { - UpdateControlData.Instance.CheckForUpdateUserRequested(); + UpdateControlData.Instance.CheckForUpdate(); }; this.AddChild(checkUpdateLink); diff --git a/ConfigurationPage/ApplicationSettings/ApplicationSettingsView.cs b/ConfigurationPage/ApplicationSettings/ApplicationSettingsView.cs index cbf094f3a..42b218778 100644 --- a/ConfigurationPage/ApplicationSettings/ApplicationSettingsView.cs +++ b/ConfigurationPage/ApplicationSettings/ApplicationSettingsView.cs @@ -297,7 +297,7 @@ namespace MatterHackers.MatterControl.ConfigurationPage { UiThread.RunOnIdle(() => { - UpdateControlData.Instance.CheckForUpdateUserRequested(); + UpdateControlData.Instance.CheckForUpdate(); DialogWindow.Show(); }); }; diff --git a/PartPreviewWindow/PartPreviewContent.cs b/PartPreviewWindow/PartPreviewContent.cs index df951a2f4..feff05b4d 100644 --- a/PartPreviewWindow/PartPreviewContent.cs +++ b/PartPreviewWindow/PartPreviewContent.cs @@ -126,7 +126,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow { UiThread.RunOnIdle(() => { - UpdateControlData.Instance.CheckForUpdateUserRequested(); + UpdateControlData.Instance.CheckForUpdate(); DialogWindow.Show(); }); }); diff --git a/Submodules/agg-sharp b/Submodules/agg-sharp index 33844d2fc..d1ec47c70 160000 --- a/Submodules/agg-sharp +++ b/Submodules/agg-sharp @@ -1 +1 @@ -Subproject commit 33844d2fce5ae02bd7abe24009bda6ac292a5e6f +Subproject commit d1ec47c70e3b85634fed4742266de42409c6cfee