-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from michaldivis/vNext
v1.0.4
- Loading branch information
Showing
18 changed files
with
802 additions
and
712 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,75 +1,53 @@ | ||
using DarkHtmlViewer; | ||
using Microsoft.Extensions.Logging.Abstractions; | ||
using Microsoft.Extensions.Logging; | ||
using System; | ||
using System.Drawing; | ||
using System.IO; | ||
using System.Reflection; | ||
using System.Threading.Tasks; | ||
using System.Windows; | ||
|
||
namespace DarkHtmlViewerBasicDemo; | ||
|
||
public partial class App : Application | ||
{ | ||
protected override async void OnStartup(StartupEventArgs e) | ||
protected override void OnStartup(StartupEventArgs e) | ||
{ | ||
base.OnStartup(e); | ||
|
||
await CheckCompatibilityAsync(); | ||
CheckCompatibility(); | ||
|
||
//configure logger | ||
HtmlViewer.ConfigureLogger(() => NullLoggerFactory.Instance); | ||
HtmlViewer.ConfigureLogger(() => LoggerFactory.Create(c => | ||
{ | ||
c.SetMinimumLevel(LogLevel.Debug); | ||
c.AddDebug(); | ||
})); | ||
|
||
var appLocation = Assembly.GetExecutingAssembly().Location; | ||
var htmlAssetsDir = Path.Combine(Path.GetDirectoryName(appLocation), "Files"); | ||
var appDirName = Path.GetDirectoryName(appLocation)!; | ||
var htmlAssetsDir = Path.Combine(appDirName, "Files"); | ||
|
||
HtmlViewer.ConfigureVirtualHostNameToFolderMappingSettings(new VirtualHostNameToFolderMappingSettings | ||
{ | ||
IsEnabled = true, | ||
Hostname = "darkassets.local", | ||
FolderPath = htmlAssetsDir, | ||
AccessKind = Microsoft.Web.WebView2.Core.CoreWebView2HostResourceAccessKind.Allow | ||
}); | ||
|
||
HtmlViewer.ConfigureDefaultBackgroundColor(Color.Navy); | ||
HtmlViewer.ConfigureDefaultBackgroundColor(Color.FromArgb(255, 24, 24, 24)); | ||
|
||
MainWindow = new DemoView(); | ||
MainWindow.Show(); | ||
} | ||
|
||
private static async Task CheckCompatibilityAsync() | ||
private static void CheckCompatibility() | ||
{ | ||
var basicWatch = new System.Diagnostics.Stopwatch(); | ||
var fullWatch = new System.Diagnostics.Stopwatch(); | ||
|
||
//check compatibility - basic | ||
try | ||
{ | ||
basicWatch.Start(); | ||
HtmlViewer.CheckBasicCompatibility(); | ||
basicWatch.Stop(); | ||
} | ||
catch (Exception ex) | ||
{ | ||
Console.WriteLine(ex); | ||
} | ||
|
||
return; | ||
|
||
//check compatibility - full | ||
try | ||
{ | ||
fullWatch.Start(); | ||
await HtmlViewer.CheckFullCompatibilityAsync(); | ||
fullWatch.Stop(); | ||
} | ||
catch (Exception ex) | ||
{ | ||
Console.WriteLine(ex); | ||
} | ||
|
||
Console.WriteLine($"Basic: {basicWatch.ElapsedMilliseconds}ms"); | ||
Console.WriteLine($"Full: {fullWatch.ElapsedMilliseconds}ms"); | ||
Console.WriteLine(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.