Qian.BarcodeScanner.WPF 1.0.0

dotnet add package Qian.BarcodeScanner.WPF --version 1.0.0
                    
NuGet\Install-Package Qian.BarcodeScanner.WPF -Version 1.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Qian.BarcodeScanner.WPF" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Qian.BarcodeScanner.WPF" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Qian.BarcodeScanner.WPF" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Qian.BarcodeScanner.WPF --version 1.0.0
                    
#r "nuget: Qian.BarcodeScanner.WPF, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Qian.BarcodeScanner.WPF@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Qian.BarcodeScanner.WPF&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Qian.BarcodeScanner.WPF&version=1.0.0
                    
Install as a Cake Tool

BarcodeScanner

Project Overview

BarcodeScanner is a WPF library for handling input from keyboards and barcode scanners. It provides flexible input mode support, including keyboard-only input, barcode scanner-only input, and a combined input mode. This library allows developers to easily integrate barcode scanner functionality into WPF applications.


Features

  • Supports Multiple Input Modes:

    • Keyboard Input (KeyboardInput)
    • Barcode Scanner Input (BarcodeScannerInput)
    • Combined Input (BothInput)
  • Device Management:

    • Add and remove known devices.
    • Cache device input states for improved performance.
  • Event Support:

    • Provides the ScanCode routed event for handling barcode scanner input.
  • Easy Integration:

    • Quickly bind to WPF controls using attached properties and event handlers.

Quick Start

1. Installation

Add the Qian.BarcodeScanner.WPF project to your solution and reference it in your WPF project.


2. Usage Example

XAML Example
<Window
    x:Class="YourNamespace.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:qian="clr-namespace:Qian.BarcodeScanner;assembly=Qian.BarcodeScanner"
    Title="Barcode Scanner Demo"
    Width="525"
    Height="350"
    qian:BarcodeScannerManager.ScanCode="Window_ScanCode">
    <StackPanel>
        <TextBlock>BarcodeScannerInput:</TextBlock>
        <TextBox
            Width="300"
            Height="30"
            Margin="10"
            qian:BarcodeScannerManager.InputMode="BarcodeScannerInput" />
        
        <TextBlock>KeyboardInput:</TextBlock>
        <TextBox
            Width="300"
            Height="30"
            Margin="10"
            qian:BarcodeScannerManager.InputMode="KeyboardInput" />
        
        <TextBlock>BothInput:</TextBlock>
        <TextBox
            Width="300"
            Height="30"
            Margin="10"
            qian:BarcodeScannerManager.InputMode="BothInput" />
        
        <TextBlock x:Name="txtScanCode" />
    </StackPanel>
</Window>
Code-Behind Example
using System.Windows;
using Qian.BarcodeScanner;

namespace YourNamespace
{
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }

        private void Window_ScanCode(object sender, ScanCodeEventArgs e)
        {
            txtScanCode.Text = $"Scanned Code: {e.ScanCode}";
        }
    }
}

Input Modes

  • KeyboardInput: Supports keyboard input only.
  • BarcodeScannerInput: Supports barcode scanner input only.
  • BothInput: Supports both keyboard and barcode scanner input.

Events

  • ScanCode:
    Triggered when barcode scanner input is completed, providing the scanned string.

Device Management

Add Known Devices

BarcodeScannerManager.AddBarcodeScannerKnownDevice("DevicePath");
BarcodeScannerManager.AddKeyboardKnownDevice("DevicePath");

Remove Known Devices

BarcodeScannerManager.RemoveKnownDevice(deviceInfo);

Contribution

Feel free to submit issues and contribute to the code!


License

This project is licensed under the MIT License.

Product Compatible and additional computed target framework versions.
.NET net6.0-windows7.0 is compatible.  net7.0-windows was computed.  net8.0-windows was computed.  net9.0-windows was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0 196 3/27/2025