diff --git a/Core/Bridge/TweetDeckBridge.cs b/Core/Bridge/TweetDeckBridge.cs index 2bd087cd..25e49809 100644 --- a/Core/Bridge/TweetDeckBridge.cs +++ b/Core/Bridge/TweetDeckBridge.cs @@ -117,10 +117,6 @@ public void OnTweetSound(){ }); } - public void OnNotificationReady(){ - notification.InvokeSafe(notification.OnNotificationReady); - } - public void DisplayTooltip(string text, bool showInNotification){ if (showInNotification){ notification.InvokeSafe(() => notification.DisplayTooltip(text)); diff --git a/Core/FormNotification.Designer.cs b/Core/FormNotification.Designer.cs index fa6e1e20..18b7ea85 100644 --- a/Core/FormNotification.Designer.cs +++ b/Core/FormNotification.Designer.cs @@ -30,6 +30,7 @@ private void InitializeComponent() { this.timerProgress = new System.Windows.Forms.Timer(this.components); this.progressBarTimer = new TweetDck.Core.Controls.FlatProgressBar(); this.toolTip = new System.Windows.Forms.ToolTip(this.components); + this.timerDisplayDelay = new System.Windows.Forms.Timer(this.components); this.SuspendLayout(); // // panelBrowser @@ -61,6 +62,11 @@ private void InitializeComponent() { this.progressBarTimer.Size = new System.Drawing.Size(284, 4); this.progressBarTimer.TabIndex = 1; // + // timerDisplayDelay + // + this.timerDisplayDelay.Interval = 17; + this.timerDisplayDelay.Tick += new System.EventHandler(this.timerDisplayDelay_Tick); + // // FormNotification // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -88,5 +94,6 @@ private void InitializeComponent() { private Controls.FlatProgressBar progressBarTimer; private System.Windows.Forms.Timer timerProgress; private System.Windows.Forms.ToolTip toolTip; + private System.Windows.Forms.Timer timerDisplayDelay; } } \ No newline at end of file diff --git a/Core/FormNotification.cs b/Core/FormNotification.cs index 83adc2fd..4d4dcca0 100644 --- a/Core/FormNotification.cs +++ b/Core/FormNotification.cs @@ -128,6 +128,7 @@ public FormNotification(FormBrowser owner, PluginManager pluginManager, Notifica #endif browser.IsBrowserInitializedChanged += Browser_IsBrowserInitializedChanged; + browser.LoadingStateChanged += Browser_LoadingStateChanged; browser.FrameLoadEnd += Browser_FrameLoadEnd; if (!flags.HasFlag(NotificationFlags.DisableScripts)){ @@ -193,6 +194,11 @@ private IntPtr MouseHookProc(int nCode, IntPtr wParam, IntPtr lParam){ // event handlers + private void timerDisplayDelay_Tick(object sender, EventArgs e){ + OnNotificationReady(); + timerDisplayDelay.Stop(); + } + private void timerHideProgress_Tick(object sender, EventArgs e){ if (Bounds.Contains(Cursor.Position) || FreezeTimer || ContextMenuOpen)return; @@ -221,6 +227,15 @@ private void Browser_IsBrowserInitializedChanged(object sender, IsBrowserInitial } } + private void Browser_LoadingStateChanged(object sender, LoadingStateChangedEventArgs e){ + if (!e.IsLoading && browser.Address != "about:blank"){ + this.InvokeSafe(() => { + Visible = true; // ensures repaint before moving the window to a visible location + timerDisplayDelay.Start(); + }); + } + } + private void Browser_FrameLoadEnd(object sender, FrameLoadEndEventArgs e){ if (e.Frame.IsMain && notificationJS != null && browser.Address != "about:blank" && !flags.HasFlag(NotificationFlags.DisableScripts)){ ScriptLoader.ExecuteScript(e.Frame, notificationJS, NotificationScriptIdentifier); diff --git a/Resources/Scripts/notification.js b/Resources/Scripts/notification.js index 5c662066..cf98b096 100644 --- a/Resources/Scripts/notification.js +++ b/Resources/Scripts/notification.js @@ -146,9 +146,4 @@ document.body.addEventListener("mouseleave", function(){ document.body.classList.remove("td-hover"); }); - - // - // Block: Page fully loaded. - // - $TD.onNotificationReady(); -})($TD); \ No newline at end of file +})($TD);