Skip to content

Commit

Permalink
Remove BarcodeScannerFormInput (#563)
Browse files Browse the repository at this point in the history
  • Loading branch information
mstefarov committed Mar 22, 2024
1 parent 7910517 commit c1854d9
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 103 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,6 @@

<Border x:Name="ErrorBorder" BorderThickness="1" BorderBrush="Red" Visibility="Collapsed" />
<TextBlock Text="!" Background="Transparent" Width="10" Foreground="Red" Visibility="Collapsed" HorizontalAlignment="Right" VerticalAlignment="Center" x:Name="ErrorInfo" />
<Button Grid.Column="1" Content="&#xec5a;" FontFamily="Segoe MDL2 Assets" Visibility="Collapsed" x:Name="BarcodeScannerButton" />
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="ShowCharacterCount" Value="false">
Expand All @@ -163,12 +162,6 @@
<Trigger Property="ShowCharacterCount" Value="true">
<Setter TargetName="CharacterCountPanel" Property="Visibility" Value="Visible"/>
</Trigger>
<Trigger Property="IsBarcodeScannerEnabled" Value="false">
<Setter TargetName="BarcodeScannerButton" Property="Visibility" Value="Collapsed"/>
</Trigger>
<Trigger Property="IsBarcodeScannerEnabled" Value="true">
<Setter TargetName="BarcodeScannerButton" Property="Visibility" Value="Visible"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
Expand Down Expand Up @@ -211,13 +204,6 @@
</DataTemplate>
</Setter.Value>
</Setter>
<Setter Property="BarcodeScannerFormInputTemplate">
<Setter.Value>
<DataTemplate>
<primitives:TextFormInputView ShowCharacterCount="false" IsBarcodeScannerEnabled="true" Element="{Binding}" IsEnabled="{Binding IsEditable}" />
</DataTemplate>
</Setter.Value>
</Setter>
<Setter Property="DateTimePickerFormInputTemplate">
<Setter.Value>
<DataTemplate>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ namespace Esri.ArcGISRuntime.Toolkit.UI.Controls
/// <summary>
/// A visual feature editor form controlled by a <see cref="FeatureForm"/> definition.
/// </summary>
/// <seealso cref="Esri.ArcGISRuntime.Data.FeatureTable.FeatureFormDefinition"/>
/// <seealso cref="Esri.ArcGISRuntime.Data.ArcGISFeatureTable.FeatureFormDefinition"/>
/// <seealso cref="Esri.ArcGISRuntime.Mapping.FeatureLayer.FeatureFormDefinition"/>
public partial class FeatureFormView
{
Expand Down Expand Up @@ -255,7 +255,6 @@ public ScrollBarVisibility VerticalScrollBarVisibility
uint min = 0;
if (element.Input is TextAreaFormInput area) { max = area.MaxLength; min = area.MinLength; }
else if (element.Input is TextBoxFormInput tb) { max = tb.MaxLength; min = tb.MinLength; }
else if (element.Input is BarcodeScannerFormInput bar) { max = bar.MaxLength; min = bar.MinLength; }
if (max > 0 && min > 0)
return string.Format(Properties.Resources.GetString("FeatureFormOutsideLengthRange")!, min, max);
if (max > 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,7 @@ protected override void PrepareContainerForItemOverride(DependencyObject element
{
if (element is ContentPresenter presenter)
{
if (item is BarcodeScannerFormInput)
{
presenter.ContentTemplate = BarcodeScannerFormInputTemplate;
}
else if (item is ComboBoxFormInput)
if (item is ComboBoxFormInput)
{
presenter.ContentTemplate = ComboBoxFormInputTemplate;
}
Expand Down Expand Up @@ -63,22 +59,6 @@ protected override void PrepareContainerForItemOverride(DependencyObject element
base.PrepareContainerForItemOverride(element, item);
}

/// <summary>
/// Template used for rendering a <see cref="BarcodeScannerFormInput"/>.
/// </summary>
/// <seealso cref="TextFormInputView"/>
public DataTemplate BarcodeScannerFormInputTemplate
{
get { return (DataTemplate)GetValue(BarcodeScannerFormInputTemplateProperty); }
set { SetValue(BarcodeScannerFormInputTemplateProperty, value); }
}

/// <summary>
/// Identifies the <see cref="BarcodeScannerFormInputTemplate"/> dependency property.
/// </summary>
public static readonly DependencyProperty BarcodeScannerFormInputTemplateProperty =
DependencyProperty.Register(nameof(BarcodeScannerFormInputTemplate), typeof(DataTemplate), typeof(FieldFormElementItemsControl), new PropertyMetadata(null));

/// <summary>
/// Template used for rendering a <see cref="ComboBoxFormInput"/>.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,21 +47,6 @@ public override void OnApplyTemplate()
UpdateErrorMessages();
}

/// <summary>
/// Gets or sets the template for the <see cref="BarcodeScannerFormInput"/> element.
/// </summary>
public DataTemplate? BarcodeScannerFormInputTemplate
{
get { return (DataTemplate)GetValue(BarcodeScannerFormInputTemplateProperty); }
set { SetValue(BarcodeScannerFormInputTemplateProperty, value); }
}

/// <summary>
/// Identifies the <see cref="BarcodeScannerFormInputTemplate"/> dependency property.
/// </summary>
public static readonly DependencyProperty BarcodeScannerFormInputTemplateProperty =
DependencyProperty.Register(nameof(BarcodeScannerFormInputTemplate), typeof(DataTemplate), typeof(FieldFormElementView), new PropertyMetadata(null));

/// <summary>
/// Gets or sets the template for the <see cref="ComboBoxFormInput"/> element.
/// </summary>
Expand Down Expand Up @@ -138,7 +123,7 @@ public override void OnApplyTemplate()
DependencyProperty.Register(nameof(TextAreaFormInputTemplate), typeof(DataTemplate), typeof(FieldFormElementView), new PropertyMetadata(null));

/// <summary>
/// Gets or sets the template for the <see cref="BarcodeScannerFormInput"/> element.
/// Gets or sets the template for the <see cref="TextBoxFormInputTemplate"/> element.
/// </summary>
public DataTemplate? TextBoxFormInputTemplate
{
Expand All @@ -165,7 +150,6 @@ public FieldTemplateSelector(FieldFormElementView parent)
{
return elm.Input switch
{
BarcodeScannerFormInput => _parent.BarcodeScannerFormInputTemplate,
ComboBoxFormInput => _parent.ComboBoxFormInputTemplate,
SwitchFormInput => _parent.SwitchFormInputTemplate,
DateTimePickerFormInput => _parent.DateTimePickerFormInputTemplate,
Expand Down
51 changes: 2 additions & 49 deletions src/Toolkit/Toolkit/UI/Controls/FeatureForm/TextFormInputView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
namespace Esri.ArcGISRuntime.Toolkit.Primitives
{
/// <summary>
/// Text input for the <see cref="TextAreaFormInput"/>, <see cref="TextBoxFormInput"/> and <see cref="BarcodeScannerFormInput"/> inputs.
/// Text input for the <see cref="TextAreaFormInput"/> and <see cref="TextBoxFormInput"/> inputs.
/// </summary>
public class TextFormInputView : Control
{
Expand Down Expand Up @@ -44,36 +44,9 @@ public override void OnApplyTemplate()
_textInput.LostFocus += TextInput_LostFocus;
}
ConfigureTextBox();
var barcodeButton = GetTemplateChild("BarcodeScannerButton") as ButtonBase;
if (barcodeButton is not null)
{
#if !NET6_0_OR_GREATER
barcodeButton.Visibility = Visibility.Collapsed; // Barcode scanner API not available in NETFX without external dependency
#else
barcodeButton.Click += BarcodeButton_Click;
#endif
}
UpdateValidationState();
}

private void BarcodeButton_Click(object sender, RoutedEventArgs e)
{
#if NET6_0_OR_GREATER
//TODO...
/*
var scanner = await Windows.Devices.PointOfService.BarcodeScanner.GetDefaultAsync();
var claimedScanner = await scanner.ClaimScannerAsync();
if (claimedScanner != null)
{
claimedScanner.DataReceived += (s,e) =>
{
};
await claimedScanner.EnableAsync();
}*/
#endif
}

private void ConfigureTextBox()
{
if (_textInput != null)
Expand All @@ -88,11 +61,6 @@ private void ConfigureTextBox()
_textInput.AcceptsReturn = false;
_textInput.MaxLength = (int)box.MaxLength;
}
else if (Element?.Input is BarcodeScannerFormInput bar)
{
_textInput.AcceptsReturn = false;
_textInput.MaxLength = (int)bar.MaxLength;
}
_textInput.Text = Element?.Value?.ToString();
}
}
Expand All @@ -101,7 +69,7 @@ private void TextInput_KeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Enter)
{
if (Element?.Input is TextBoxFormInput || Element?.Input is BarcodeScannerFormInput)
if (Element?.Input is TextBoxFormInput)
{
Apply();
}
Expand Down Expand Up @@ -172,21 +140,6 @@ public int MaxLines
public static readonly DependencyProperty MaxLinesProperty =
DependencyProperty.Register(nameof(MaxLines), typeof(int), typeof(TextFormInputView), new PropertyMetadata(1));

/// <summary>
/// Gets or sets a value indicating whether the barcode scanner button is available.
/// </summary>
public bool IsBarcodeScannerEnabled
{
get { return (bool)GetValue(IsBarcodeScannerEnabledProperty); }
set { SetValue(IsBarcodeScannerEnabledProperty, value); }
}

/// <summary>
/// Identifies the <see cref="IsBarcodeScannerEnabled"/> dependency property.
/// </summary>
public static readonly DependencyProperty IsBarcodeScannerEnabledProperty =
DependencyProperty.Register(nameof(IsBarcodeScannerEnabled), typeof(bool), typeof(TextFormInputView), new PropertyMetadata(false));

/// <summary>
/// Gets or sets a value indicating whether the character count is visible.
/// </summary>
Expand Down

0 comments on commit c1854d9

Please sign in to comment.