diff --git a/Core/FormBrowser.cs b/Core/FormBrowser.cs index 030b5a7f..94547daa 100644 --- a/Core/FormBrowser.cs +++ b/Core/FormBrowser.cs @@ -391,7 +391,7 @@ public void OnIntroductionClosed(bool showGuide, bool allowDataCollection){ } if (showGuide){ - ShowChildForm(new FormGuide()); + FormGuide.Show(); } } diff --git a/Core/Other/FormAbout.cs b/Core/Other/FormAbout.cs index 94e69314..132c38d7 100644 --- a/Core/Other/FormAbout.cs +++ b/Core/Other/FormAbout.cs @@ -33,7 +33,7 @@ private void FormAbout_HelpButtonClicked(object sender, CancelEventArgs e){ } private void ShowGuide(){ - new FormGuide().Show(); + FormGuide.Show(); Close(); } } diff --git a/Core/Other/FormGuide.cs b/Core/Other/FormGuide.cs index 0964e386..31040454 100644 --- a/Core/Other/FormGuide.cs +++ b/Core/Other/FormGuide.cs @@ -34,23 +34,37 @@ public static bool CheckGuideUrl(string url, out string hash){ } } + public static void Show(string hash = null){ + string url = GuideUrl+(hash ?? string.Empty); + FormGuide guide = FormManager.TryFind<FormGuide>(); + + if (guide == null){ + FormBrowser owner = FormManager.TryFind<FormBrowser>(); + + if (owner != null){ + owner.TriggerAnalyticsEvent(AnalyticsFile.Event.OpenGuide); + new FormGuide(url, owner).Show(owner); + } + } + else{ + guide.Reload(url); + guide.Activate(); + } + } + private readonly ChromiumWebBrowser browser; - public FormGuide(string hash = null){ + private FormGuide(string url, Form owner){ InitializeComponent(); Text = Program.BrandName+" Guide"; - FormBrowser owner = FormManager.TryFind<FormBrowser>(); - if (owner != null){ Size = new Size(owner.Size.Width*3/4, owner.Size.Height*3/4); VisibleChanged += (sender, args) => this.MoveToCenter(owner); - - owner.TriggerAnalyticsEvent(AnalyticsFile.Event.OpenGuide); } - this.browser = new ChromiumWebBrowser(GuideUrl+(hash ?? string.Empty)){ + this.browser = new ChromiumWebBrowser(url){ MenuHandler = new ContextMenuGuide(), JsDialogHandler = new JavaScriptDialogHandler(), LifeSpanHandler = new LifeSpanHandler(), @@ -73,8 +87,16 @@ public FormGuide(string hash = null){ Program.UserConfig.ZoomLevelChanged += Config_ZoomLevelChanged; } + private void Reload(string url){ + browser.LoadingStateChanged += browser_LoadingStateChanged; + browser.Dock = DockStyle.None; + browser.Location = ControlExtensions.InvisibleLocation; + browser.Load("about:blank"); + browser.Load(url); + } + private void browser_LoadingStateChanged(object sender, LoadingStateChangedEventArgs e){ - if (!e.IsLoading){ + if (!e.IsLoading && browser.Address != "about:blank"){ this.InvokeAsyncSafe(() => { browser.Location = Point.Empty; browser.Dock = DockStyle.Fill; diff --git a/Core/Utils/BrowserUtils.cs b/Core/Utils/BrowserUtils.cs index 045d41b1..2c4d2ee6 100644 --- a/Core/Utils/BrowserUtils.cs +++ b/Core/Utils/BrowserUtils.cs @@ -71,7 +71,7 @@ public static void OpenExternalBrowser(string url){ switch(CheckUrl(url)){ case UrlCheckResult.Fine: if (FormGuide.CheckGuideUrl(url, out string hash)){ - new FormGuide(hash).Show(); + FormGuide.Show(hash); } else{ WindowsUtils.OpenAssociatedProgram(url); diff --git a/Resources/Guide/script.js b/Resources/Guide/script.js index 517a5601..317fef0c 100644 --- a/Resources/Guide/script.js +++ b/Resources/Guide/script.js @@ -71,6 +71,7 @@ var init = function(){ if (element && element.tagName === "SUMMARY"){ element.click(); + element.blur(); element.scrollIntoView(true); if (window.innerWidth === 0){