@@ -87,7 +87,7 @@ public event WebBrowserNavigatedEventHandler Navigated
8787 /// </summary>
8888 /// <param name="pathToAboutBoxHtml">For example, use
8989 /// <see cref="FileLocationUtilities.GetFileDistributedWithApplication(string[])"/>(
90- /// "DistFiles", "AboutBox.htm")</param>
90+ /// "DistFiles", "AboutBox.htm"). This also can accept a file URI. </param>
9191 /// <param name="useFullVersionNumber"><c>false</c> to display only the first three
9292 /// parts of the version number, i.e. "MajorVersion.MinorVersion.Build",
9393 /// <c>true</c> to display the full version number as found in Application.ProductVersion.
@@ -99,7 +99,10 @@ public SILAboutBox(string pathToAboutBoxHtml, bool useFullVersionNumber = false,
9999 SilLogoVariant logoVariant = SilLogoVariant . Random )
100100 {
101101 _assembly = Assembly . GetEntryAssembly ( ) ; // assembly;
102- _pathToAboutBoxHtml = pathToAboutBoxHtml ;
102+ _pathToAboutBoxHtml =
103+ Uri . TryCreate ( pathToAboutBoxHtml , UriKind . Absolute , out var uri ) && uri . IsFile
104+ ? uri . LocalPath
105+ : pathToAboutBoxHtml ;
103106 InitializeComponent ( ) ;
104107 _versionNumber . Text = useFullVersionNumber ? Application . ProductVersion :
105108 GetShortVersionInfo ( ) ;
@@ -282,28 +285,7 @@ private void SILAboutBoxShown(object sender, EventArgs e)
282285 _browser . Navigate ( _pathToAboutBoxHtml ) ;
283286 else
284287 {
285- // Note: the following comment also applies to the case where HandleMissingLinkTargets tweaks
286- // the HTML, but hopefully that will be rare in production code.
287- // Create a temporary file with the DependencyMarker replaced with our collected Acknowledgements.
288- // This file will be deleted OnClosed.
289- // This means that if your project uses the DependencyMarker in your html file, you will not be able to
290- // link to a file on a relative path for css styles or images.
291- // ----------
292- // Comments on possible ways around this limitation from John Thomson:
293- // 1.Document that an About Box HTML file which uses dependency injection must live in its own folder
294- // with all dependent files, and copy the whole folder to a temp folder.
295- // (could work but is a nuisance, especially for anyone who doesn't need any dependencies)
296- // 2.Document that an About Box HTML file which uses dependency injection may only use a few common kinds
297- // of relative links, search for matching links, and copy the appropriate files to a temp directory along
298- // with the temp file.
299- // (I rather like this idea. A fairly simple regular expression will search for src or rel followed by a value
300- // with no path separators...something like(src | rel) = (['"])([^/\]*)\1 (or something similar...
301- // handle white space...). That will catch all references to images, stylesheets, and scripts,
302- // and if the bit of the RegEx that matches the filename corresponds to an existing file in the same folder
303- // as the HTML we can just copy it. Unless they're doing relative paths to different folders that will do it,
304- // and I think it's reasonable to have SOME restrictions in the interests of simplicity.
305- // ----------
306- _tempAboutBoxHtmlFile = new TempFile ( newHtmlContents ) ;
288+ _tempAboutBoxHtmlFile = HtmlUtils . CreatePatchedTempHtmlFile ( newHtmlContents , _pathToAboutBoxHtml ) ;
307289 _browser . Navigate ( _tempAboutBoxHtmlFile . Path ) ;
308290 }
309291 }
0 commit comments