Skip to content

Commit

Permalink
[Add] Ink Recognition preload
Browse files Browse the repository at this point in the history
  • Loading branch information
WXRIW committed Aug 3, 2024
1 parent e481b84 commit ebd8430
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions Ink Canvas/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -760,6 +760,9 @@ private void Window_Loaded(object sender, RoutedEventArgs e)

TextBlockVersion.Text = Assembly.GetExecutingAssembly().GetName().Version.ToString();
LogHelper.WriteLogToFile("Ink Canvas Loaded", LogHelper.LogType.Event);

PreloadIALibrary();

isLoaded = true;
}

Expand Down Expand Up @@ -791,6 +794,23 @@ private void Window_Closed(object sender, EventArgs e)
LogHelper.WriteLogToFile("Ink Canvas closed", LogHelper.LogType.Event);
}

private static void PreloadIALibrary()
{
GC.KeepAlive(typeof(InkAnalyzer));
GC.KeepAlive(typeof(AnalysisAlternate));
GC.KeepAlive(typeof(InkDrawingNode));
var analyzer = new InkAnalyzer();
analyzer.AddStrokes(new StrokeCollection() {
new Stroke(new StylusPointCollection() {
new StylusPoint(114,514),
new StylusPoint(191,9810),
new StylusPoint(7,21),
new StylusPoint(123,789),
})
});
analyzer.Analyze();
}

private void LoadSettings(bool isStartup = true)
{
if (File.Exists(App.RootPath + settingsFileName))
Expand Down

0 comments on commit ebd8430

Please sign in to comment.