Skip to content

Commit 1f91a40

Browse files
authored
Merge pull request #546 from TheJoeFin/dev
Add arch check to WinAI support
2 parents 75bd0e7 + 0570140 commit 1f91a40

File tree

5 files changed

+15
-5
lines changed

5 files changed

+15
-5
lines changed

Text-Grab-Package/Package.appxmanifest

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<Identity
1313
Name="40087JoeFinApps.TextGrab"
1414
Publisher="CN=153F3B0F-BA3D-4964-8098-71AC78A1DF6A"
15-
Version="4.9.4.0" />
15+
Version="4.9.5.0" />
1616

1717
<Properties>
1818
<DisplayName>Text Grab</DisplayName>

Text-Grab/Text-Grab.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
2424
<RuntimeIdentifiers>win-x86;win-x64;win-arm64</RuntimeIdentifiers>
2525
<EnableMsixTooling>false</EnableMsixTooling>
26-
<Version>4.9.4</Version>
26+
<Version>4.9.5</Version>
2727
</PropertyGroup>
2828

2929
<ItemGroup>

Text-Grab/Utilities/WindowsAiUtilities.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using Microsoft.Windows.AI.Imaging;
44
using System;
55
using System.Drawing;
6+
using System.Runtime.InteropServices;
67
using System.Text;
78
using System.Threading.Tasks;
89
using Text_Grab.Extensions;
@@ -19,6 +20,13 @@ public static bool CanDeviceUseWinAI()
1920
if (!AppUtilities.IsPackaged() || OSInterop.IsWindows10())
2021
return false;
2122

23+
// Today, Windows AI Text Recognition is only supported on ARM64
24+
Architecture arch = RuntimeInformation.ProcessArchitecture;
25+
if (arch != Architecture.Arm64)
26+
return false;
27+
28+
// After checking for Arm64 the remainder checks should be good to catch supporting devices
29+
2230
try
2331
{
2432
AIFeatureReadyState readyState = TextRecognizer.GetReadyState();

Text-Grab/Views/FullscreenGrab.xaml.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -422,8 +422,6 @@ private static async Task LoadOcrLanguages(ComboBox languagesComboBox, bool usin
422422

423423
count++;
424424
}
425-
if (languagesComboBox.SelectedIndex == -1)
426-
languagesComboBox.SelectedIndex = 0;
427425
}
428426

429427
IReadOnlyList<Language> possibleOCRLanguages = OcrEngine.AvailableRecognizerLanguages;
@@ -444,6 +442,10 @@ private static async Task LoadOcrLanguages(ComboBox languagesComboBox, bool usin
444442

445443
count++;
446444
}
445+
446+
// if no lang is set, select the first one
447+
if (languagesComboBox.SelectedIndex == -1)
448+
languagesComboBox.SelectedIndex = 0;
447449
}
448450

449451
private void NewEditTextMenuItem_Click(object sender, RoutedEventArgs e)

build-unpackaged.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ dotnet publish "$PSScriptRoot\$Project\$Project.csproj" `
3838
-v minimal `
3939
-o $BuildPathX64 `
4040
-p:EnableMsixTooling=true `
41-
-p:PublishReadyToRun=true `
41+
-p:PublishReadyToRun=false `
4242
-p:PublishSingleFile=true `
4343
-p:CopyOutputSymbolsToPublishDirectory=false `
4444
--nologo

0 commit comments

Comments
 (0)