Skip to content

Commit 14f1a45

Browse files
committed
fix(Avalonia): prevent running OCR on text
1 parent e93f64f commit 14f1a45

2 files changed

Lines changed: 21 additions & 0 deletions

File tree

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using System.Globalization;
2+
using Avalonia.Data.Converters;
3+
4+
namespace SnapX.Avalonia.Converters;
5+
6+
public class EqualsToParameterConverter : IValueConverter
7+
{
8+
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
9+
{
10+
if (value == null || parameter == null)
11+
return false;
12+
13+
return string.Equals(value.ToString(), parameter.ToString(), StringComparison.OrdinalIgnoreCase);
14+
}
15+
16+
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
17+
{
18+
throw new NotImplementedException();
19+
}
20+
}

SnapX.Avalonia/Views/HomePageView.axaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@
219219
Click="OCRImageClick"
220220
Command="{Binding OCRImageCommand, DataType=viewModels1:HomePageViewModel}"
221221
IconSource="ImageAltText"
222+
IsEnabled="{Binding task.Type, Converter={StaticResource EqualsToParameterConverter}, ConverterParameter=image}"
222223
IsVisible="{Binding Source={x:Static core1:FeatureFlags.DisableOCR}, Converter={StaticResource NegateBool}}"
223224
Text="{x:Static core:Lang.UI_OCRImage}"
224225
ToolTip.Tip="{x:Static core:Lang.UI_OCRImage_ToolTip}" />

0 commit comments

Comments
 (0)