1
0
mirror of https://github.com/chylex/TweetDuck.git synced 2025-04-22 18:15:47 +02:00

Redo OnNotificationReady call to use LoadingStateChanged with a delay

This commit is contained in:
chylex 2017-01-08 02:16:40 +01:00
parent 7ff9e23283
commit d5141ed020
4 changed files with 23 additions and 10 deletions

View File

@ -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));

View File

@ -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;
}
}

View File

@ -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);

View File

@ -146,9 +146,4 @@
document.body.addEventListener("mouseleave", function(){
document.body.classList.remove("td-hover");
});
//
// Block: Page fully loaded.
//
$TD.onNotificationReady();
})($TD);
})($TD);