1
0
mirror of https://github.com/chylex/TweetDuck.git synced 2025-05-04 08:34:07 +02:00

Add a "splash screen" (show window immediately and seamlessly display browser when ready)

Closes 
This commit is contained in:
chylex 2017-04-03 18:03:46 +02:00
parent c8cbf70a28
commit c78c63285e
3 changed files with 24 additions and 6 deletions

View File

@ -32,6 +32,7 @@ private void InitializeComponent() {
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = TweetDck.Core.Utils.BrowserUtils.BackgroundColor;
this.ClientSize = new System.Drawing.Size(324, 386);
this.Icon = Properties.Resources.icon;
this.Location = TweetDck.Core.Controls.ControlExtensions.InvisibleLocation;

View File

@ -83,7 +83,10 @@ public FormBrowser(PluginManager pluginManager, UpdaterSettings updaterSettings)
this.browser.LoadError += browser_LoadError;
this.browser.RegisterAsyncJsObject("$TD", new TweetDeckBridge(this, notification));
this.browser.RegisterAsyncJsObject("$TDP", plugins.Bridge);
browser.BrowserSettings.BackgroundColor = (uint)BrowserUtils.BackgroundColor.ToArgb();
browser.Dock = DockStyle.None;
browser.Location = ControlExtensions.InvisibleLocation;
Controls.Add(browser);
Controls.Add(new MenuStrip{ Visible = false }); // fixes Alt freezing the program in Win 10 Anniversary Update
@ -112,6 +115,8 @@ public FormBrowser(PluginManager pluginManager, UpdaterSettings updaterSettings)
this.updates = new UpdateHandler(browser, this, updaterSettings);
this.updates.UpdateAccepted += updates_UpdateAccepted;
this.updates.UpdateDismissed += updates_UpdateDismissed;
RestoreWindow();
}
private void ShowChildForm(Form form){
@ -126,10 +131,17 @@ public void ForceClose(){
// window setup
private void SetupWindow(){
private void RestoreWindow(){
Config.BrowserWindow.Restore(this, true);
prevState = WindowState;
isLoaded = true;
}
private void OnLoaded(){
if (!isLoaded){
browser.Location = Point.Empty;
browser.Dock = DockStyle.Fill;
isLoaded = true;
}
}
private void UpdateTrayIcon(){
@ -144,13 +156,15 @@ private void browser_LoadingStateChanged(object sender, LoadingStateChangedEvent
browser.AddWordToDictionary(word);
}
BeginInvoke(new Action(SetupWindow));
BeginInvoke(new Action(OnLoaded));
browser.LoadingStateChanged -= browser_LoadingStateChanged;
}
}
private void browser_FrameLoadEnd(object sender, FrameLoadEndEventArgs e){
if (e.Frame.IsMain && BrowserUtils.IsTweetDeckWebsite(e.Frame)){
e.Frame.ExecuteJavaScriptAsync(BrowserUtils.BackgroundColorFix);
UpdateProperties();
ScriptLoader.ExecuteFile(e.Frame, "code.js");
ReinjectCustomCSS(Config.CustomBrowserCSS);
@ -229,9 +243,8 @@ private void Config_TrayBehaviorChanged(object sender, EventArgs e){
}
private void trayIcon_ClickRestore(object sender, EventArgs e){
isLoaded = false;
Show();
SetupWindow();
RestoreWindow();
Activate();
UpdateTrayIcon();
}

View File

@ -6,6 +6,7 @@
using System.Windows.Forms;
using CefSharp;
using System.Text.RegularExpressions;
using System.Drawing;
namespace TweetDck.Core.Utils{
static class BrowserUtils{
@ -28,6 +29,9 @@ public static string HeaderUserAgent{
}
}
public static readonly Color BackgroundColor = Color.FromArgb(28, 99, 153);
public const string BackgroundColorFix = "let e=document.createElement('style');document.head.appendChild(e);e.innerHTML='body::before{background:#1c6399!important}'";
public static readonly string[] DictionaryWords = {
"tweetdeck", "TweetDeck", "tweetduck", "TweetDuck", "TD"
};