Skip to content

Commit

Permalink
Merge pull request #361 from TheJoeFin/dev
Browse files Browse the repository at this point in the history
Merging 4.2 dev into main
  • Loading branch information
TheJoeFin authored Nov 10, 2023
2 parents ec6e6fe + f309d90 commit 0359c95
Show file tree
Hide file tree
Showing 21 changed files with 591 additions and 106 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/buildDev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: "Build Text Grab"
on:
push:
branches: [dev]

env:
PROJECT_PATH: "Text-Grab/Text-Grab.csproj"

jobs:
build:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2

- uses: actions/setup-dotnet@v1
with:
dotnet-version: "6.0.x"

# - run: dotnet build ${{ env.PROJECT_PATH }} -c Release

# - run: dotnet test ${{ env.PROJECT_PATH }} -c Release --no-build --no-restore --verbosity normal

- run: dotnet publish ${{ env.PROJECT_PATH }} -c Release --self-contained -r win-x64 -p:PublishSingleFile=true -o publish

- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: Text-Grab
path: .publish/*.exe
# Text-Grab\Text-Grab\Text-Grab\bin\Release\net6.0-windows10.0.20348.0\win-x64\publish\
# Text-Grab\Text-Grab\bin\Release\net6.0-windows10.0.20348.0\win-x64\publish\Text-Grab.exe

# "C:\Users\josep\source\repos\TheJoeFin\Text-Grab\Text-Grab\bin\Release\net6.0-windows10.0.20348.0\win-x64\publish\Text-Grab.exe"
13 changes: 7 additions & 6 deletions Tests/OcrTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Windows.Media.Imaging;
using Text_Grab;
using Text_Grab.Controls;
using Text_Grab.Interfaces;
using Text_Grab.Models;
using Text_Grab.Utilities;
using Windows.Globalization;
Expand Down Expand Up @@ -231,7 +232,7 @@ public async Task TesseractFontSample()

// When
Language englishLanguage = new("eng");
OcrOutput tessoutput = await TesseractHelper.GetOcrOutputFromBitmap(scaledBMP, englishLanguage);
OcrOutput tessoutput = await TesseractHelper.GetOcrOutputFromBitmap(scaledBMP, englishLanguage, englishLanguage.LanguageTag);

if (tessoutput.RawOutput == "Cannot find tesseract.exe")
return;
Expand All @@ -243,7 +244,7 @@ public async Task TesseractFontSample()
[WpfFact]
public async Task GetTessLanguages()
{
string expected = "eng,equ";
string expected = "eng";
List<string> actualStrings = await TesseractHelper.TesseractLangsAsStrings();
string joinedString = string.Join(',', actualStrings.ToArray());

Expand All @@ -253,13 +254,13 @@ public async Task GetTessLanguages()
[WpfFact]
public async Task GetTesseractStrongLanguages()
{
List<Language> expectedList = new()
List<ILanguage> expectedList = new()
{
new Language("eng"),
new Language("equ")
new TessLang("eng"),
// new TessLang("equ")
};

List<Language> actualList = await TesseractHelper.TesseractLanguages();
List<ILanguage> actualList = await TesseractHelper.TesseractLanguages();

string expectedAbbreviatedName = string.Join(',', expectedList.Select(l => l.AbbreviatedName).ToArray());
string actualAbbreviatedName = string.Join(',', actualList.Select(l => l.AbbreviatedName).ToArray());
Expand Down
16 changes: 16 additions & 0 deletions Tests/QrCodeTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using Text_Grab.Utilities;
using ZXing.QrCode.Internal;

namespace Tests;

public class QrCodeTests
{
[Fact]
public void generateSvgImage()
{
string testString = "This is only a test";
var svg = BarcodeUtilities.GetSvgQrCodeForText(testString, ErrorCorrectionLevel.L);

Assert.NotNull(svg);
}
}
2 changes: 1 addition & 1 deletion Tests/Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0-preview-23503-02" />
<PackageReference Include="xunit" Version="2.6.0" />
<PackageReference Include="xunit" Version="2.6.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.3">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
Expand Down
2 changes: 1 addition & 1 deletion Text-Grab-Package/Package.appxmanifest
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<Identity
Name="40087JoeFinApps.TextGrab"
Publisher="CN=153F3B0F-BA3D-4964-8098-71AC78A1DF6A"
Version="4.1.4.0" />
Version="4.2.0.0" />

<Properties>
<DisplayName>Text Grab</DisplayName>
Expand Down
3 changes: 3 additions & 0 deletions Text-Grab/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@
<setting name="UseHistory" serializeAs="String">
<value>True</value>
</setting>
<setting name="TesseractPath" serializeAs="String">
<value />
</setting>
</Text_Grab.Properties.Settings>
</userSettings>
</configuration>
48 changes: 40 additions & 8 deletions Text-Grab/Controls/QrCodeWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,16 @@
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
Title="Text Grab QR Code"
Width="400"
Height="550"
Height="600"
Closing="FluentWindow_Closing"
mc:Ignorable="d">
<Window.Resources>
<ui:ImageIcon x:Key="TextGrabIcon" Source="/Text-Grab;component/Images/TealSelect40.png" />
</Window.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
Expand All @@ -29,24 +31,54 @@
Margin="2,2,2,0"
Padding="8,2"
Icon="{StaticResource TextGrabIcon}" />
<StackPanel
<TextBox
x:Name="QrCodeTextBox"
Grid.Row="1"
HorizontalAlignment="Center"
Orientation="Horizontal">
Margin="12,0"
TextChanged="QrCodeTextBox_TextChanged" />
<StackPanel Grid.Row="2" Orientation="Horizontal">
<local:CollapsibleButton
x:Name="SaveButton"
ButtonText="Save as file..."
Margin="12,0,0,0"
ButtonText="PNG..."
Click="SaveButton_Click"
SymbolText="" />
<local:CollapsibleButton
x:Name="SvgButton"
ButtonText="Svg..."
Click="SvgButton_Click"
SymbolText="" />
<local:CollapsibleButton
x:Name="CopyButton"
ButtonText="Copy to clipboard"
ButtonText="Copy PNG to clipboard"
Click="CopyButton_Click"
SymbolText="" />
</StackPanel>
<StackPanel
Grid.Row="3"
Height="36"
Orientation="Horizontal">
<TextBlock
Margin="12,0"
VerticalAlignment="Center"
Text="Error Correction Level" />
<ComboBox
x:Name="ErrorCorrectionComboBox"
VerticalAlignment="Center"
Foreground="{DynamicResource TextFillColorPrimaryBrush}"
SelectionChanged="ErrorCorrectionComboBox_SelectionChanged">
<ComboBoxItem
Content="Low, up to 7%"
IsSelected="True"
Tag="L" />
<ComboBoxItem Content="Medium, up to 15%" Tag="M" />
<ComboBoxItem Content="Quality, up to 25%" Tag="Q" />
<ComboBoxItem Content="High, up to 30%" Tag="H" />
</ComboBox>
</StackPanel>
<TextBlock
x:Name="LengthErrorTextBlock"
Grid.Row="2"
Grid.Row="4"
Padding="20,4"
HorizontalAlignment="Center"
d:Visibility="Visible"
Expand All @@ -58,7 +90,7 @@
</TextBlock>
<Image
Name="CodeImage"
Grid.Row="3"
Grid.Row="5"
Margin="0"
MouseLeftButtonDown="CodeImage_MouseLeftButtonDown" />
</Grid>
Expand Down
Loading

0 comments on commit 0359c95

Please sign in to comment.