diff --git a/src/OutlookGoogleCalendarSync/Forms/MainForm.cs b/src/OutlookGoogleCalendarSync/Forms/MainForm.cs index ca95c7c5..9a4fa914 100644 --- a/src/OutlookGoogleCalendarSync/Forms/MainForm.cs +++ b/src/OutlookGoogleCalendarSync/Forms/MainForm.cs @@ -599,18 +599,25 @@ public void Sync_Click(object sender, EventArgs e) { public enum SyncNotes { QuotaExhaustedInfo, + QuotaExhaustedPreviously, RecentSubscription, SubscriptionPendingExpire, SubscriptionExpired, NotLogFile } public void SyncNote(SyncNotes syncNote, Object extraData, Boolean show = true) { - if (!this.tbSyncNote.Visible && !show) return; //Already hidden + if (this.Visible && !this.tbSyncNote.Visible && !show) return; //Already hidden String note = ""; String url = ""; String urlStub = "https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=E595EQ7SNDBHA&item_name="; String cr = "\r\n"; + + if (syncNote == SyncNotes.QuotaExhaustedInfo && !show && this.tbSyncNote.Text.Contains("quota is exhausted")) { + syncNote = SyncNotes.QuotaExhaustedPreviously; + show = true; + } + switch (syncNote) { case SyncNotes.QuotaExhaustedInfo: note = " Google's daily free calendar quota is exhausted!" + cr + @@ -618,6 +625,18 @@ public void SyncNote(SyncNotes syncNote, Object extraData, Boolean show = true) " get yourself guaranteed quota for just £1/month."; url = urlStub + "OGCS Premium for " + Settings.Instance.GaccountEmail; break; + case SyncNotes.QuotaExhaustedPreviously: + DateTime utcNow = DateTime.UtcNow; + DateTime quotaReset = utcNow.Date.AddHours(8).AddMinutes(utcNow.Minute); + if ((quotaReset - utcNow).Ticks < 0) quotaReset = quotaReset.AddDays(1); + int delayHours = (int)(quotaReset - DateTime.Now).TotalHours + 1; + note = "Google's daily free calendar quota was exhausted!" + cr + + " Syncs were delayed "+ delayHours +" hours until 08:00GMT " + cr + + " Get yourself guaranteed quota for just £1/month."; + url = urlStub + "OGCS Premium for " + Settings.Instance.GaccountEmail; + System.Threading.Thread hide = new System.Threading.Thread(() => { System.Threading.Thread.Sleep((delayHours + 3) * 60 * 60 * 1000); SyncNote(SyncNotes.QuotaExhaustedPreviously, null, false); }); + hide.Start(); + break; case SyncNotes.RecentSubscription: note = " " + cr + " Thank you for your subscription and support! " + cr + @@ -771,10 +790,12 @@ private void Main_Load(object sender, EventArgs e) { } public void MainFormShow() { + this.tbSyncNote.ScrollBars = RichTextBoxScrollBars.None; //Reset scrollbar this.Show(); //Show minimised back in taskbar this.ShowInTaskbar = true; this.WindowState = FormWindowState.Normal; this.TopMost = true; + this.tbSyncNote.ScrollBars = RichTextBoxScrollBars.Vertical; //Show scrollbar if necessary this.Show(); //Now restore this.TopMost = false; this.Refresh();