From 332a670818113e646033fd9f8c4ec973009a21ae Mon Sep 17 00:00:00 2001 From: Takuya Takeuchi Date: Sun, 29 Jul 2018 20:41:57 +0900 Subject: [PATCH] Initial commit (move from other my open source repository) --- .gitignore | 306 + WinBiometricDotNet.sln | 39 + examples/FrameworkTester/App.config | 6 + examples/FrameworkTester/App.xaml | 16 + examples/FrameworkTester/App.xaml.cs | 11 + .../WinBioAcquireFocusViewModel.cs | 27 + .../WinBioCaptureSampleViewModel.cs | 78 + ...inBioCaptureSampleWithCallbackViewModel.cs | 84 + .../WinBioCloseSessionViewModel.cs | 27 + .../WinBioEnumBiometricUnitsViewModel.cs | 34 + .../DesignTimes/WinBioOpenSessionViewModel.cs | 33 + .../WinBioReleaseFocusViewModel.cs | 27 + .../FrameworkTester/FrameworkTester.csproj | 204 + .../Helpers/BitmapSourceHelper.cs | 28 + .../Properties/AssemblyInfo.cs | 53 + .../Properties/Resources.Designer.cs | 71 + .../FrameworkTester/Properties/Resources.resx | 117 + .../Properties/Settings.Designer.cs | 30 + .../Properties/Settings.settings | 7 + .../Services/DispatcherService.cs | 41 + .../Services/FrameNavigationService.cs | 154 + .../Services/Interfaces/IDispatcherService.cs | 14 + .../Interfaces/IFrameNavigationService.cs | 16 + .../Interfaces/IWinBiometricService.cs | 132 + .../ViewModels/Interfaces/IMainViewModel.cs | 40 + .../IWinBioAcquireFocusViewModel.cs | 10 + .../IWinBioCaptureSampleViewModel.cs | 61 + ...inBioCaptureSampleWithCallbackViewModel.cs | 15 + .../IWinBioCloseSessionViewModel.cs | 8 + .../IWinBioEnumBiometricUnitsViewModel.cs | 17 + .../Interfaces/IWinBioOpenSessionViewModel.cs | 16 + .../IWinBioReleaseFocusViewModel.cs | 10 + .../ViewModels/Interfaces/IWinBioViewModel.cs | 26 + .../ViewModels/MainViewModel.cs | 138 + .../ViewModels/ViewModelLocator.cs | 107 + .../ViewModels/WinBioAcquireFocusViewModel.cs | 75 + .../WinBioCaptureSampleViewModel.cs | 278 + ...inBioCaptureSampleWithCallbackViewModel.cs | 304 + .../ViewModels/WinBioCloseSessionViewModel.cs | 75 + .../WinBioEnumBiometricUnitsViewModel.cs | 90 + .../ViewModels/WinBioOpenSessionViewModel.cs | 92 + .../ViewModels/WinBioReleaseFocusViewModel.cs | 75 + .../FrameworkTester/Views/MainWindow.xaml | 86 + .../FrameworkTester/Views/MainWindow.xaml.cs | 15 + .../Views/WinBioAcquireFocus.xaml | 45 + .../Views/WinBioAcquireFocus.xaml.cs | 28 + .../Views/WinBioCaptureSample.xaml | 174 + .../Views/WinBioCaptureSample.xaml.cs | 15 + .../WinBioCaptureSampleWithCallback.xaml | 174 + .../WinBioCaptureSampleWithCallback.xaml.cs | 15 + .../Views/WinBioCloseSession.xaml | 45 + .../Views/WinBioCloseSession.xaml.cs | 15 + .../Views/WinBioEnumBiometricUnits.xaml | 65 + .../Views/WinBioEnumBiometricUnits.xaml.cs | 15 + .../Views/WinBioOpenSession.xaml | 56 + .../Views/WinBioOpenSession.xaml.cs | 15 + .../Views/WinBioReleaseFocus.xaml | 45 + .../Views/WinBioReleaseFocus.xaml.cs | 28 + examples/FrameworkTester/packages.config | 6 + .../BiometricCapabilities.cs | 26 + .../WinBiometricDotNet/BiometricPoolType.cs | 17 + .../BiometricSensorSubType.cs | 15 + sources/WinBiometricDotNet/BiometricType.cs | 62 + sources/WinBiometricDotNet/BiometricUnit.cs | 100 + .../BiometricUnitVersion.cs | 37 + sources/WinBiometricDotNet/CaptureSample.cs | 69 + .../CaptureSampleEventArgs.cs | 30 + .../WinBiometricDotNet/CaptureSampleResult.cs | 51 + .../Interop/SafeNativeMethods.cs | 5907 +++++++++++++++++ sources/WinBiometricDotNet/OperationStatus.cs | 17 + .../SampleCapturedHandler.cs | 6 + sources/WinBiometricDotNet/Session.cs | 29 + sources/WinBiometricDotNet/WinBiometric.cs | 310 + .../WinBiometricDotNet.csproj | 19 + .../WinBiometricException.cs | 60 + 75 files changed, 10589 insertions(+) create mode 100644 .gitignore create mode 100644 WinBiometricDotNet.sln create mode 100644 examples/FrameworkTester/App.config create mode 100644 examples/FrameworkTester/App.xaml create mode 100644 examples/FrameworkTester/App.xaml.cs create mode 100644 examples/FrameworkTester/DesignTimes/WinBioAcquireFocusViewModel.cs create mode 100644 examples/FrameworkTester/DesignTimes/WinBioCaptureSampleViewModel.cs create mode 100644 examples/FrameworkTester/DesignTimes/WinBioCaptureSampleWithCallbackViewModel.cs create mode 100644 examples/FrameworkTester/DesignTimes/WinBioCloseSessionViewModel.cs create mode 100644 examples/FrameworkTester/DesignTimes/WinBioEnumBiometricUnitsViewModel.cs create mode 100644 examples/FrameworkTester/DesignTimes/WinBioOpenSessionViewModel.cs create mode 100644 examples/FrameworkTester/DesignTimes/WinBioReleaseFocusViewModel.cs create mode 100644 examples/FrameworkTester/FrameworkTester.csproj create mode 100644 examples/FrameworkTester/Helpers/BitmapSourceHelper.cs create mode 100644 examples/FrameworkTester/Properties/AssemblyInfo.cs create mode 100644 examples/FrameworkTester/Properties/Resources.Designer.cs create mode 100644 examples/FrameworkTester/Properties/Resources.resx create mode 100644 examples/FrameworkTester/Properties/Settings.Designer.cs create mode 100644 examples/FrameworkTester/Properties/Settings.settings create mode 100644 examples/FrameworkTester/Services/DispatcherService.cs create mode 100644 examples/FrameworkTester/Services/FrameNavigationService.cs create mode 100644 examples/FrameworkTester/Services/Interfaces/IDispatcherService.cs create mode 100644 examples/FrameworkTester/Services/Interfaces/IFrameNavigationService.cs create mode 100644 examples/FrameworkTester/Services/Interfaces/IWinBiometricService.cs create mode 100644 examples/FrameworkTester/ViewModels/Interfaces/IMainViewModel.cs create mode 100644 examples/FrameworkTester/ViewModels/Interfaces/IWinBioAcquireFocusViewModel.cs create mode 100644 examples/FrameworkTester/ViewModels/Interfaces/IWinBioCaptureSampleViewModel.cs create mode 100644 examples/FrameworkTester/ViewModels/Interfaces/IWinBioCaptureSampleWithCallbackViewModel.cs create mode 100644 examples/FrameworkTester/ViewModels/Interfaces/IWinBioCloseSessionViewModel.cs create mode 100644 examples/FrameworkTester/ViewModels/Interfaces/IWinBioEnumBiometricUnitsViewModel.cs create mode 100644 examples/FrameworkTester/ViewModels/Interfaces/IWinBioOpenSessionViewModel.cs create mode 100644 examples/FrameworkTester/ViewModels/Interfaces/IWinBioReleaseFocusViewModel.cs create mode 100644 examples/FrameworkTester/ViewModels/Interfaces/IWinBioViewModel.cs create mode 100644 examples/FrameworkTester/ViewModels/MainViewModel.cs create mode 100644 examples/FrameworkTester/ViewModels/ViewModelLocator.cs create mode 100644 examples/FrameworkTester/ViewModels/WinBioAcquireFocusViewModel.cs create mode 100644 examples/FrameworkTester/ViewModels/WinBioCaptureSampleViewModel.cs create mode 100644 examples/FrameworkTester/ViewModels/WinBioCaptureSampleWithCallbackViewModel.cs create mode 100644 examples/FrameworkTester/ViewModels/WinBioCloseSessionViewModel.cs create mode 100644 examples/FrameworkTester/ViewModels/WinBioEnumBiometricUnitsViewModel.cs create mode 100644 examples/FrameworkTester/ViewModels/WinBioOpenSessionViewModel.cs create mode 100644 examples/FrameworkTester/ViewModels/WinBioReleaseFocusViewModel.cs create mode 100644 examples/FrameworkTester/Views/MainWindow.xaml create mode 100644 examples/FrameworkTester/Views/MainWindow.xaml.cs create mode 100644 examples/FrameworkTester/Views/WinBioAcquireFocus.xaml create mode 100644 examples/FrameworkTester/Views/WinBioAcquireFocus.xaml.cs create mode 100644 examples/FrameworkTester/Views/WinBioCaptureSample.xaml create mode 100644 examples/FrameworkTester/Views/WinBioCaptureSample.xaml.cs create mode 100644 examples/FrameworkTester/Views/WinBioCaptureSampleWithCallback.xaml create mode 100644 examples/FrameworkTester/Views/WinBioCaptureSampleWithCallback.xaml.cs create mode 100644 examples/FrameworkTester/Views/WinBioCloseSession.xaml create mode 100644 examples/FrameworkTester/Views/WinBioCloseSession.xaml.cs create mode 100644 examples/FrameworkTester/Views/WinBioEnumBiometricUnits.xaml create mode 100644 examples/FrameworkTester/Views/WinBioEnumBiometricUnits.xaml.cs create mode 100644 examples/FrameworkTester/Views/WinBioOpenSession.xaml create mode 100644 examples/FrameworkTester/Views/WinBioOpenSession.xaml.cs create mode 100644 examples/FrameworkTester/Views/WinBioReleaseFocus.xaml create mode 100644 examples/FrameworkTester/Views/WinBioReleaseFocus.xaml.cs create mode 100644 examples/FrameworkTester/packages.config create mode 100644 sources/WinBiometricDotNet/BiometricCapabilities.cs create mode 100644 sources/WinBiometricDotNet/BiometricPoolType.cs create mode 100644 sources/WinBiometricDotNet/BiometricSensorSubType.cs create mode 100644 sources/WinBiometricDotNet/BiometricType.cs create mode 100644 sources/WinBiometricDotNet/BiometricUnit.cs create mode 100644 sources/WinBiometricDotNet/BiometricUnitVersion.cs create mode 100644 sources/WinBiometricDotNet/CaptureSample.cs create mode 100644 sources/WinBiometricDotNet/CaptureSampleEventArgs.cs create mode 100644 sources/WinBiometricDotNet/CaptureSampleResult.cs create mode 100644 sources/WinBiometricDotNet/Interop/SafeNativeMethods.cs create mode 100644 sources/WinBiometricDotNet/OperationStatus.cs create mode 100644 sources/WinBiometricDotNet/SampleCapturedHandler.cs create mode 100644 sources/WinBiometricDotNet/Session.cs create mode 100644 sources/WinBiometricDotNet/WinBiometric.cs create mode 100644 sources/WinBiometricDotNet/WinBiometricDotNet.csproj create mode 100644 sources/WinBiometricDotNet/WinBiometricException.cs diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..834db45 --- /dev/null +++ b/.gitignore @@ -0,0 +1,306 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore + +# User-specific files +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ + +# Visual Studio 2015 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUNIT +*.VisualState.xml +TestResult.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Visual Studio Code +.settings/ +.vscode/ +tsconfig.json +jsconfig.json + +# CMake +CMakeCache.txt +CMakeFiles +CMakeScripts +Testing +Makefile +cmake_install.cmake +install_manifest.txt +compile_commands.json +CTestTestfile.cmake +build + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ +**/Properties/launchSettings.json + +*_i.c +*_p.c +*_i.h +*.ilk +*.meta +*.obj +*.pch +*.pdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding add-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# TODO: Comment the next line if you want to checkin your web deploy settings +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# The packages folder can be ignored because of Package Restore +**/packages/* +# except build/, which is used as an MSBuild target. +!**/packages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/packages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Typescript v1 declaration files +typings/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# JetBrains Rider +.idea/ +*.sln.iml + +# CodeRush +.cr/ + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs diff --git a/WinBiometricDotNet.sln b/WinBiometricDotNet.sln new file mode 100644 index 0000000..661d635 --- /dev/null +++ b/WinBiometricDotNet.sln @@ -0,0 +1,39 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.27703.2000 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{4011A92D-1064-4209-8443-8D0A292F8EF8}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WinBiometricDotNet", "sources\WinBiometricDotNet\WinBiometricDotNet.csproj", "{769F29E5-2778-4D05-A841-79633A9CD147}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "examples", "examples", "{A417F340-6BF3-4E3D-A2D7-524F097434FB}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FrameworkTester", "examples\FrameworkTester\FrameworkTester.csproj", "{019372F1-1888-4253-B3B9-9EE5EFDF15B5}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {769F29E5-2778-4D05-A841-79633A9CD147}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {769F29E5-2778-4D05-A841-79633A9CD147}.Debug|Any CPU.Build.0 = Debug|Any CPU + {769F29E5-2778-4D05-A841-79633A9CD147}.Release|Any CPU.ActiveCfg = Release|Any CPU + {769F29E5-2778-4D05-A841-79633A9CD147}.Release|Any CPU.Build.0 = Release|Any CPU + {019372F1-1888-4253-B3B9-9EE5EFDF15B5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {019372F1-1888-4253-B3B9-9EE5EFDF15B5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {019372F1-1888-4253-B3B9-9EE5EFDF15B5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {019372F1-1888-4253-B3B9-9EE5EFDF15B5}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {769F29E5-2778-4D05-A841-79633A9CD147} = {4011A92D-1064-4209-8443-8D0A292F8EF8} + {019372F1-1888-4253-B3B9-9EE5EFDF15B5} = {A417F340-6BF3-4E3D-A2D7-524F097434FB} + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {9F162973-A013-4E17-9336-552A31A46A74} + EndGlobalSection +EndGlobal diff --git a/examples/FrameworkTester/App.config b/examples/FrameworkTester/App.config new file mode 100644 index 0000000..3a4868f --- /dev/null +++ b/examples/FrameworkTester/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/examples/FrameworkTester/App.xaml b/examples/FrameworkTester/App.xaml new file mode 100644 index 0000000..ffbda07 --- /dev/null +++ b/examples/FrameworkTester/App.xaml @@ -0,0 +1,16 @@ + + + + + + + \ No newline at end of file diff --git a/examples/FrameworkTester/App.xaml.cs b/examples/FrameworkTester/App.xaml.cs new file mode 100644 index 0000000..c978298 --- /dev/null +++ b/examples/FrameworkTester/App.xaml.cs @@ -0,0 +1,11 @@ +using System.Windows; + +namespace FrameworkTester +{ + /// + /// App.xaml の相互作用ロジック + /// + public partial class App : Application + { + } +} diff --git a/examples/FrameworkTester/DesignTimes/WinBioAcquireFocusViewModel.cs b/examples/FrameworkTester/DesignTimes/WinBioAcquireFocusViewModel.cs new file mode 100644 index 0000000..ab06ac5 --- /dev/null +++ b/examples/FrameworkTester/DesignTimes/WinBioAcquireFocusViewModel.cs @@ -0,0 +1,27 @@ +using FrameworkTester.ViewModels.Interfaces; +using GalaSoft.MvvmLight.Command; + +namespace FrameworkTester.DesignTimes +{ + + public sealed class WinBioAcquireFocusViewModel : IWinBioAcquireFocusViewModel + { + + public RelayCommand ExecuteCommand + { + get; + } + + public string Name + { + get; + } + + public string Result + { + get; + } + + } + +} \ No newline at end of file diff --git a/examples/FrameworkTester/DesignTimes/WinBioCaptureSampleViewModel.cs b/examples/FrameworkTester/DesignTimes/WinBioCaptureSampleViewModel.cs new file mode 100644 index 0000000..9522796 --- /dev/null +++ b/examples/FrameworkTester/DesignTimes/WinBioCaptureSampleViewModel.cs @@ -0,0 +1,78 @@ +using System.Windows.Media.Imaging; +using FrameworkTester.ViewModels.Interfaces; +using GalaSoft.MvvmLight.Command; + +namespace FrameworkTester.DesignTimes +{ + + public sealed class WinBioCaptureSampleViewModel : IWinBioCaptureSampleViewModel + { + + public BitmapSource CaptureImage + { + get; + } + + public int CaptureImageWidth + { + get; + } + + public int CaptureImageHeight + { + get; + } + + public int CaptureImageHorizontalResolution + { + get; + } + + public int CaptureImageVerticalResolution + { + get; + } + + public int CaptureImageScanHorizontalResolution + { + get; + } + + public int CaptureImageScanVerticalResolution + { + get; + } + + public RelayCommand ExecuteCommand + { + get; + } + + public string Name + { + get; + } + + public uint RejectDetail + { + get; + } + + public string Result + { + get; + } + + public uint SampleSize + { + get; + } + + public uint UnitId + { + get; + } + + } + +} \ No newline at end of file diff --git a/examples/FrameworkTester/DesignTimes/WinBioCaptureSampleWithCallbackViewModel.cs b/examples/FrameworkTester/DesignTimes/WinBioCaptureSampleWithCallbackViewModel.cs new file mode 100644 index 0000000..b2fdd43 --- /dev/null +++ b/examples/FrameworkTester/DesignTimes/WinBioCaptureSampleWithCallbackViewModel.cs @@ -0,0 +1,84 @@ +using System.Windows.Media.Imaging; +using FrameworkTester.ViewModels.Interfaces; +using GalaSoft.MvvmLight.Command; + +namespace FrameworkTester.DesignTimes +{ + + public sealed class WinBioCaptureSampleWithCallbackViewModel : IWinBioCaptureSampleWithCallbackViewModel + { + + public BitmapSource CaptureImage + { + get; + } + + public int CaptureImageWidth + { + get; + } + + public int CaptureImageHeight + { + get; + } + + public int CaptureImageHorizontalResolution + { + get; + } + + public int CaptureImageVerticalResolution + { + get; + } + + public int CaptureImageScanHorizontalResolution + { + get; + } + + public int CaptureImageScanVerticalResolution + { + get; + } + + public RelayCommand ExecuteCommand + { + get; + } + + public bool Loop + { + get; + set; + } + + public string Name + { + get; + } + + public uint RejectDetail + { + get; + } + + public string Result + { + get; + } + + public uint SampleSize + { + get; + } + + public uint UnitId + { + get; + } + + } + +} \ No newline at end of file diff --git a/examples/FrameworkTester/DesignTimes/WinBioCloseSessionViewModel.cs b/examples/FrameworkTester/DesignTimes/WinBioCloseSessionViewModel.cs new file mode 100644 index 0000000..6fb518e --- /dev/null +++ b/examples/FrameworkTester/DesignTimes/WinBioCloseSessionViewModel.cs @@ -0,0 +1,27 @@ +using FrameworkTester.ViewModels.Interfaces; +using GalaSoft.MvvmLight.Command; + +namespace FrameworkTester.DesignTimes +{ + + public sealed class WinBioCloseSessionViewModel : IWinBioCloseSessionViewModel + { + + public RelayCommand ExecuteCommand + { + get; + } + + public string Name + { + get; + } + + public string Result + { + get; + } + + } + +} \ No newline at end of file diff --git a/examples/FrameworkTester/DesignTimes/WinBioEnumBiometricUnitsViewModel.cs b/examples/FrameworkTester/DesignTimes/WinBioEnumBiometricUnitsViewModel.cs new file mode 100644 index 0000000..a0f4aa1 --- /dev/null +++ b/examples/FrameworkTester/DesignTimes/WinBioEnumBiometricUnitsViewModel.cs @@ -0,0 +1,34 @@ +using System.Collections.ObjectModel; +using FrameworkTester.ViewModels.Interfaces; +using GalaSoft.MvvmLight.Command; +using WinBiometricDotNet; + +namespace FrameworkTester.DesignTimes +{ + + public sealed class WinBioEnumBiometricUnitsViewModel : IWinBioEnumBiometricUnitsViewModel + { + + public RelayCommand ExecuteCommand + { + get; + } + + public string Name + { + get; + } + + public string Result + { + get; + } + + public ObservableCollection Units + { + get; + } + + } + +} \ No newline at end of file diff --git a/examples/FrameworkTester/DesignTimes/WinBioOpenSessionViewModel.cs b/examples/FrameworkTester/DesignTimes/WinBioOpenSessionViewModel.cs new file mode 100644 index 0000000..c0b5798 --- /dev/null +++ b/examples/FrameworkTester/DesignTimes/WinBioOpenSessionViewModel.cs @@ -0,0 +1,33 @@ +using System; +using FrameworkTester.ViewModels.Interfaces; +using GalaSoft.MvvmLight.Command; + +namespace FrameworkTester.DesignTimes +{ + + public sealed class WinBioOpenSessionViewModel : IWinBioOpenSessionViewModel + { + + public RelayCommand ExecuteCommand + { + get; + } + + public string Name + { + get; + } + + public string Result + { + get; + } + + public IntPtr SessionHandle + { + get; + } + + } + +} \ No newline at end of file diff --git a/examples/FrameworkTester/DesignTimes/WinBioReleaseFocusViewModel.cs b/examples/FrameworkTester/DesignTimes/WinBioReleaseFocusViewModel.cs new file mode 100644 index 0000000..0aa0439 --- /dev/null +++ b/examples/FrameworkTester/DesignTimes/WinBioReleaseFocusViewModel.cs @@ -0,0 +1,27 @@ +using FrameworkTester.ViewModels.Interfaces; +using GalaSoft.MvvmLight.Command; + +namespace FrameworkTester.DesignTimes +{ + + public sealed class WinBioReleaseFocusViewModel : IWinBioReleaseFocusViewModel + { + + public RelayCommand ExecuteCommand + { + get; + } + + public string Name + { + get; + } + + public string Result + { + get; + } + + } + +} \ No newline at end of file diff --git a/examples/FrameworkTester/FrameworkTester.csproj b/examples/FrameworkTester/FrameworkTester.csproj new file mode 100644 index 0000000..b458859 --- /dev/null +++ b/examples/FrameworkTester/FrameworkTester.csproj @@ -0,0 +1,204 @@ + + + + + Debug + AnyCPU + {019372F1-1888-4253-B3B9-9EE5EFDF15B5} + WinExe + FrameworkTester + FrameworkTester + v4.6.2 + 512 + {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 4 + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + true + false + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + false + true + + + + ..\..\packages\CommonServiceLocator.2.0.2\lib\net45\CommonServiceLocator.dll + + + ..\..\packages\MvvmLightLibs.5.4.1\lib\net45\GalaSoft.MvvmLight.dll + + + ..\..\packages\MvvmLightLibs.5.4.1\lib\net45\GalaSoft.MvvmLight.Extras.dll + + + ..\..\packages\MvvmLightLibs.5.4.1\lib\net45\GalaSoft.MvvmLight.Platform.dll + + + + + ..\..\packages\MvvmLightLibs.5.4.1\lib\net45\System.Windows.Interactivity.dll + + + + + + + + + 4.0 + + + + + + + + MSBuild:Compile + Designer + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + WinBioAcquireFocus.xaml + + + WinBioCaptureSample.xaml + + + WinBioCaptureSampleWithCallback.xaml + + + WinBioCloseSession.xaml + + + WinBioEnumBiometricUnits.xaml + + + WinBioOpenSession.xaml + + + WinBioReleaseFocus.xaml + + + MSBuild:Compile + Designer + + + App.xaml + Code + + + MainWindow.xaml + Code + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + + + Code + + + True + True + Resources.resx + + + True + Settings.settings + True + + + ResXFileCodeGenerator + Resources.Designer.cs + + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + + + + + + {769f29e5-2778-4d05-a841-79633a9cd147} + WinBiometricDotNet + + + + + \ No newline at end of file diff --git a/examples/FrameworkTester/Helpers/BitmapSourceHelper.cs b/examples/FrameworkTester/Helpers/BitmapSourceHelper.cs new file mode 100644 index 0000000..22b0334 --- /dev/null +++ b/examples/FrameworkTester/Helpers/BitmapSourceHelper.cs @@ -0,0 +1,28 @@ +using System; +using System.Linq; +using System.Windows.Media; +using System.Windows.Media.Imaging; + +namespace FrameworkTester.Helpers +{ + + internal sealed class BitmapSourceHelper + { + + public static BitmapSource ToBitmapSource(byte[] image, int width, int height, double dpiX, double dpiY) + { + unsafe + { + fixed (byte* p = &image[0]) + { + var palette = new BitmapPalette(Enumerable.Range(0, 256).Select(i => Color.FromRgb((byte)i, (byte)i, (byte)i)).ToList()); + + // capture sample image does not contain stride gap + return BitmapFrame.Create(width, height, dpiX, dpiY, PixelFormats.Indexed8, palette, (IntPtr)p, image.Length, width); + } + } + } + + } + +} diff --git a/examples/FrameworkTester/Properties/AssemblyInfo.cs b/examples/FrameworkTester/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..24e387d --- /dev/null +++ b/examples/FrameworkTester/Properties/AssemblyInfo.cs @@ -0,0 +1,53 @@ +using System.Reflection; +using System.Runtime.InteropServices; +using System.Windows; + +// アセンブリに関する一般情報は以下の属性セットをとおして制御されます。 +// アセンブリに関連付けられている情報を変更するには、 +// これらの属性値を変更してください。 +[assembly: AssemblyTitle("Windows Biometric Framework Tester")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Takuya Takeuchi")] +[assembly: AssemblyProduct("Windows Biometric Framework Tester")] +[assembly: AssemblyCopyright("Copyright © 2018 Takuya Takeuchi All Rights Reserved.")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// ComVisible を false に設定すると、このアセンブリ内の型は COM コンポーネントから +// 参照できなくなります。COM からこのアセンブリ内の型にアクセスする必要がある場合は、 +// その型の ComVisible 属性を true に設定してください。 +[assembly: ComVisible(false)] + +//ローカライズ可能なアプリケーションのビルドを開始するには、 +//.csproj ファイルの CultureYouAreCodingWith を +// 内部で設定します。たとえば、 +//ソース ファイルで英語を使用している場合、 を en-US に設定します。次に、 +//下の NeutralResourceLanguage 属性のコメントを解除します。下の行の "en-US" を +//プロジェクト ファイルの UICulture 設定と一致するよう更新します。 + +//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] + + +[assembly: ThemeInfo( + ResourceDictionaryLocation.None, //テーマ固有のリソース ディクショナリが置かれている場所 + //(リソースがページ、 + //またはアプリケーション リソース ディクショナリに見つからない場合に使用されます) + ResourceDictionaryLocation.SourceAssembly //汎用リソース ディクショナリが置かれている場所 + //(リソースがページ、 + //アプリケーション、またはいずれのテーマ固有のリソース ディクショナリにも見つからない場合に使用されます) +)] + + +// アセンブリのバージョン情報は次の 4 つの値で構成されています: +// +// メジャー バージョン +// マイナー バージョン +// ビルド番号 +// Revision +// +// すべての値を指定するか、次を使用してビルド番号とリビジョン番号を既定に設定できます +// 既定値にすることができます: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/examples/FrameworkTester/Properties/Resources.Designer.cs b/examples/FrameworkTester/Properties/Resources.Designer.cs new file mode 100644 index 0000000..03ae4a8 --- /dev/null +++ b/examples/FrameworkTester/Properties/Resources.Designer.cs @@ -0,0 +1,71 @@ +//------------------------------------------------------------------------------ +// +// このコードはツールによって生成されました。 +// ランタイム バージョン:4.0.30319.42000 +// +// このファイルへの変更は、以下の状況下で不正な動作の原因になったり、 +// コードが再生成されるときに損失したりします +// +//------------------------------------------------------------------------------ + +namespace FrameworkTester.Properties +{ + + + /// + /// ローカライズされた文字列などを検索するための、厳密に型指定されたリソース クラスです。 + /// + // このクラスは StronglyTypedResourceBuilder クラスによって ResGen + // または Visual Studio のようなツールを使用して自動生成されました。 + // メンバーを追加または削除するには、.ResX ファイルを編集して、/str オプションと共に + // ResGen を実行し直すか、または VS プロジェクトをリビルドします。 + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources + { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() + { + } + + /// + /// このクラスで使用されるキャッシュされた ResourceManager インスタンスを返します。 + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager + { + get + { + if ((resourceMan == null)) + { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("FrameworkTester.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// 厳密に型指定されたこのリソース クラスを使用して、すべての検索リソースに対し、 + /// 現在のスレッドの CurrentUICulture プロパティをオーバーライドします。 + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture + { + get + { + return resourceCulture; + } + set + { + resourceCulture = value; + } + } + } +} diff --git a/examples/FrameworkTester/Properties/Resources.resx b/examples/FrameworkTester/Properties/Resources.resx new file mode 100644 index 0000000..ffecec8 --- /dev/null +++ b/examples/FrameworkTester/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/examples/FrameworkTester/Properties/Settings.Designer.cs b/examples/FrameworkTester/Properties/Settings.Designer.cs new file mode 100644 index 0000000..cf7c758 --- /dev/null +++ b/examples/FrameworkTester/Properties/Settings.Designer.cs @@ -0,0 +1,30 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace FrameworkTester.Properties +{ + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase + { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default + { + get + { + return defaultInstance; + } + } + } +} diff --git a/examples/FrameworkTester/Properties/Settings.settings b/examples/FrameworkTester/Properties/Settings.settings new file mode 100644 index 0000000..8f2fd95 --- /dev/null +++ b/examples/FrameworkTester/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/examples/FrameworkTester/Services/DispatcherService.cs b/examples/FrameworkTester/Services/DispatcherService.cs new file mode 100644 index 0000000..4f353ad --- /dev/null +++ b/examples/FrameworkTester/Services/DispatcherService.cs @@ -0,0 +1,41 @@ +using System; +using System.Threading.Tasks; +using System.Windows.Threading; +using FrameworkTester.Services.Interfaces; + +namespace FrameworkTester.Services +{ + + public sealed class DispatcherService : IDispatcherService + { + + #region フィールド + + private readonly Dispatcher _Dispatcher; + + #endregion + + #region コンストラクタ + + public DispatcherService(Dispatcher dispatcher) + { + this._Dispatcher = dispatcher; + } + + #endregion + + #region メソッド + + public async Task SafeAction(Action action) + { + if (!this._Dispatcher.CheckAccess()) + await this._Dispatcher.InvokeAsync(action); + else + action.Invoke(); + } + + #endregion + + } + +} diff --git a/examples/FrameworkTester/Services/FrameNavigationService.cs b/examples/FrameworkTester/Services/FrameNavigationService.cs new file mode 100644 index 0000000..912b470 --- /dev/null +++ b/examples/FrameworkTester/Services/FrameNavigationService.cs @@ -0,0 +1,154 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Media; +using FrameworkTester.Services.Interfaces; + +namespace FrameworkTester.Services +{ + + public sealed class FrameNavigationService : IFrameNavigationService, INotifyPropertyChanged + { + + #region Events + + public event PropertyChangedEventHandler PropertyChanged; + + #endregion + + #region Fields + + private readonly Dictionary _PagesByKey; + + private readonly List _Historic; + + private string _CurrentPageKey; + + #endregion + + #region Constructors + + public FrameNavigationService() + { + this._PagesByKey = new Dictionary(); + this._Historic = new List(); + } + + #endregion + + #region Properties + + public string CurrentPageKey + { + get + { + return this._CurrentPageKey; + } + private set + { + if (this._CurrentPageKey == value) + { + return; + } + + this._CurrentPageKey = value; + this.OnPropertyChanged(); + } + } + + public object Parameter + { + get; + private set; + } + + #endregion + + #region Methods + + public void GoBack() + { + if (this._Historic.Count > 1) + { + this._Historic.RemoveAt(this._Historic.Count - 1); + this.NavigateTo(this._Historic.Last(), null); + } + } + + public void NavigateTo(string pageKey) + { + this.NavigateTo(pageKey, null); + } + + public void NavigateTo(string pageKey, object parameter) + { + lock (this._PagesByKey) + { + if (!this._PagesByKey.ContainsKey(pageKey)) + throw new ArgumentException($"No such page: {pageKey}", pageKey); + + if (GetDescendantFromName(Application.Current.MainWindow, "Frame") is Frame frame) + { + frame.Source = this._PagesByKey[pageKey]; + } + + this.Parameter = parameter; + this._Historic.Add(pageKey); + this.CurrentPageKey = pageKey; + } + } + + public void Configure(string key, Uri pageType) + { + lock (this._PagesByKey) + { + if (this._PagesByKey.ContainsKey(key)) + { + this._PagesByKey[key] = pageType; + } + else + { + this._PagesByKey.Add(key, pageType); + } + } + } + + private static FrameworkElement GetDescendantFromName(DependencyObject parent, string name) + { + var count = VisualTreeHelper.GetChildrenCount(parent); + if (count < 1) + return null; + + for (var i = 0; i < count; i++) + { + if (!(VisualTreeHelper.GetChild(parent, i) is FrameworkElement frameworkElement)) + continue; + + if (frameworkElement.Name == name) + return frameworkElement; + + frameworkElement = GetDescendantFromName(frameworkElement, name); + if (frameworkElement != null) + return frameworkElement; + } + return null; + } + + #region Helpers + + private void OnPropertyChanged([CallerMemberName] string propertyName = null) + { + var handler = this.PropertyChanged; + handler?.Invoke(this, new PropertyChangedEventArgs(propertyName)); + } + + #endregion + + #endregion + } + +} diff --git a/examples/FrameworkTester/Services/Interfaces/IDispatcherService.cs b/examples/FrameworkTester/Services/Interfaces/IDispatcherService.cs new file mode 100644 index 0000000..9add2f4 --- /dev/null +++ b/examples/FrameworkTester/Services/Interfaces/IDispatcherService.cs @@ -0,0 +1,14 @@ +using System; +using System.Threading.Tasks; + +namespace FrameworkTester.Services.Interfaces +{ + + public interface IDispatcherService + { + + Task SafeAction(Action action); + + } + +} diff --git a/examples/FrameworkTester/Services/Interfaces/IFrameNavigationService.cs b/examples/FrameworkTester/Services/Interfaces/IFrameNavigationService.cs new file mode 100644 index 0000000..9d13d78 --- /dev/null +++ b/examples/FrameworkTester/Services/Interfaces/IFrameNavigationService.cs @@ -0,0 +1,16 @@ +using GalaSoft.MvvmLight.Views; + +namespace FrameworkTester.Services.Interfaces +{ + + public interface IFrameNavigationService : INavigationService + { + + object Parameter + { + get; + } + + } + +} \ No newline at end of file diff --git a/examples/FrameworkTester/Services/Interfaces/IWinBiometricService.cs b/examples/FrameworkTester/Services/Interfaces/IWinBiometricService.cs new file mode 100644 index 0000000..2605f14 --- /dev/null +++ b/examples/FrameworkTester/Services/Interfaces/IWinBiometricService.cs @@ -0,0 +1,132 @@ +using System; +using System.Collections.Generic; +using FrameworkTester.Services.Interfaces; +using WinBiometricDotNet; + +namespace FrameworkTester.Services.Interfaces +{ + + public interface IWinBiometricService + { + + void AcquireFocus(); + + CaptureSampleResult CaptureSample(); + + void CaptureSampleWithCallback(); + + void CloseSession(); + + IEnumerable EnumBiometricUnits(); + + Session OpenSession(); + + void ReleaseFocus(); + + } + +} + + +namespace FrameworkTester.Services +{ + + public sealed class WinBiometricService : IWinBiometricService + { + + #region Events + + public static event SampleCapturedHandler SampleCaptured; + + #endregion + + #region Fields + #endregion + + #region Constructors + #endregion + + #region Properties + + private Session _Session; + + #endregion + + #region Methods + + public void AcquireFocus() + { + WinBiometric.AcquireFocus(); + } + + public CaptureSampleResult CaptureSample() + { + if (this._Session == null) + throw new Exception("There is no opened session."); + + WinBiometric.SampleCaptured -= SampleCaptured; + WinBiometric.SampleCaptured += SampleCaptured; + + return WinBiometric.CaptureSample(this._Session); + } + + public void CaptureSampleWithCallback() + { + if (this._Session == null) + throw new Exception("There is no opened session."); + + WinBiometric.SampleCaptured -= SampleCaptured; + WinBiometric.SampleCaptured += SampleCaptured; + + WinBiometric.CaptureSampleWithCallback(this._Session); + } + + public void CloseSession() + { + if (this._Session == null) + throw new Exception("There is no opened session."); + + WinBiometric.CloseSession(this._Session); + this._Session = null; + } + + public IEnumerable EnumBiometricUnits() + { + return WinBiometric.EnumBiometricUnits(); + } + + public Session OpenSession() + { + Session session = null; + + if (this._Session != null) + { + WinBiometric.CloseSession(this._Session); + this._Session = null; + } + + session = WinBiometric.OpenSession(); + this._Session = session; + + return session; + } + + public void ReleaseFocus() + { + WinBiometric.ReleaseFocus(); + } + + #region Overrids + #endregion + + #region Event Handlers + #endregion + + #region Helpers + #endregion + + #endregion + + } + +} \ No newline at end of file diff --git a/examples/FrameworkTester/ViewModels/Interfaces/IMainViewModel.cs b/examples/FrameworkTester/ViewModels/Interfaces/IMainViewModel.cs new file mode 100644 index 0000000..d9f3464 --- /dev/null +++ b/examples/FrameworkTester/ViewModels/Interfaces/IMainViewModel.cs @@ -0,0 +1,40 @@ +using System.Collections.ObjectModel; +using GalaSoft.MvvmLight.Command; +using WinBiometricDotNet; + +namespace FrameworkTester.ViewModels.Interfaces +{ + + public interface IMainViewModel + { + + IWinBioViewModel CurrentTestTarget + { + get; + set; + } + + BiometricUnit CurrentUnit + { + get; + set; + } + + RelayCommand LoadedCommand + { + get; + } + + ObservableCollection TestTargets + { + get; + } + + ObservableCollection Units + { + get; + } + + } + +} diff --git a/examples/FrameworkTester/ViewModels/Interfaces/IWinBioAcquireFocusViewModel.cs b/examples/FrameworkTester/ViewModels/Interfaces/IWinBioAcquireFocusViewModel.cs new file mode 100644 index 0000000..aec312c --- /dev/null +++ b/examples/FrameworkTester/ViewModels/Interfaces/IWinBioAcquireFocusViewModel.cs @@ -0,0 +1,10 @@ +using System; + +namespace FrameworkTester.ViewModels.Interfaces +{ + + public interface IWinBioAcquireFocusViewModel : IWinBioViewModel + { + } + +} diff --git a/examples/FrameworkTester/ViewModels/Interfaces/IWinBioCaptureSampleViewModel.cs b/examples/FrameworkTester/ViewModels/Interfaces/IWinBioCaptureSampleViewModel.cs new file mode 100644 index 0000000..93576ac --- /dev/null +++ b/examples/FrameworkTester/ViewModels/Interfaces/IWinBioCaptureSampleViewModel.cs @@ -0,0 +1,61 @@ +using System.Windows.Media.Imaging; + +namespace FrameworkTester.ViewModels.Interfaces +{ + + public interface IWinBioCaptureSampleViewModel : IWinBioViewModel + { + + BitmapSource CaptureImage + { + get; + } + + int CaptureImageWidth + { + get; + } + + int CaptureImageHeight + { + get; + } + + int CaptureImageHorizontalResolution + { + get; + } + + int CaptureImageVerticalResolution + { + get; + } + + int CaptureImageScanHorizontalResolution + { + get; + } + + int CaptureImageScanVerticalResolution + { + get; + } + + uint RejectDetail + { + get; + } + + uint SampleSize + { + get; + } + + uint UnitId + { + get; + } + + } + +} \ No newline at end of file diff --git a/examples/FrameworkTester/ViewModels/Interfaces/IWinBioCaptureSampleWithCallbackViewModel.cs b/examples/FrameworkTester/ViewModels/Interfaces/IWinBioCaptureSampleWithCallbackViewModel.cs new file mode 100644 index 0000000..012ab22 --- /dev/null +++ b/examples/FrameworkTester/ViewModels/Interfaces/IWinBioCaptureSampleWithCallbackViewModel.cs @@ -0,0 +1,15 @@ +namespace FrameworkTester.ViewModels.Interfaces +{ + + public interface IWinBioCaptureSampleWithCallbackViewModel : IWinBioCaptureSampleViewModel + { + + bool Loop + { + get; + set; + } + + } + +} \ No newline at end of file diff --git a/examples/FrameworkTester/ViewModels/Interfaces/IWinBioCloseSessionViewModel.cs b/examples/FrameworkTester/ViewModels/Interfaces/IWinBioCloseSessionViewModel.cs new file mode 100644 index 0000000..dd3f83f --- /dev/null +++ b/examples/FrameworkTester/ViewModels/Interfaces/IWinBioCloseSessionViewModel.cs @@ -0,0 +1,8 @@ +namespace FrameworkTester.ViewModels.Interfaces +{ + + public interface IWinBioCloseSessionViewModel : IWinBioViewModel + { + } + +} \ No newline at end of file diff --git a/examples/FrameworkTester/ViewModels/Interfaces/IWinBioEnumBiometricUnitsViewModel.cs b/examples/FrameworkTester/ViewModels/Interfaces/IWinBioEnumBiometricUnitsViewModel.cs new file mode 100644 index 0000000..440ffa4 --- /dev/null +++ b/examples/FrameworkTester/ViewModels/Interfaces/IWinBioEnumBiometricUnitsViewModel.cs @@ -0,0 +1,17 @@ +using System.Collections.ObjectModel; +using WinBiometricDotNet; + +namespace FrameworkTester.ViewModels.Interfaces +{ + + public interface IWinBioEnumBiometricUnitsViewModel : IWinBioViewModel + { + + ObservableCollection Units + { + get; + } + + } + +} \ No newline at end of file diff --git a/examples/FrameworkTester/ViewModels/Interfaces/IWinBioOpenSessionViewModel.cs b/examples/FrameworkTester/ViewModels/Interfaces/IWinBioOpenSessionViewModel.cs new file mode 100644 index 0000000..52f0fe4 --- /dev/null +++ b/examples/FrameworkTester/ViewModels/Interfaces/IWinBioOpenSessionViewModel.cs @@ -0,0 +1,16 @@ +using System; + +namespace FrameworkTester.ViewModels.Interfaces +{ + + public interface IWinBioOpenSessionViewModel : IWinBioViewModel + { + + IntPtr SessionHandle + { + get; + } + + } + +} diff --git a/examples/FrameworkTester/ViewModels/Interfaces/IWinBioReleaseFocusViewModel.cs b/examples/FrameworkTester/ViewModels/Interfaces/IWinBioReleaseFocusViewModel.cs new file mode 100644 index 0000000..112edcf --- /dev/null +++ b/examples/FrameworkTester/ViewModels/Interfaces/IWinBioReleaseFocusViewModel.cs @@ -0,0 +1,10 @@ +using System; + +namespace FrameworkTester.ViewModels.Interfaces +{ + + public interface IWinBioReleaseFocusViewModel : IWinBioViewModel + { + } + +} diff --git a/examples/FrameworkTester/ViewModels/Interfaces/IWinBioViewModel.cs b/examples/FrameworkTester/ViewModels/Interfaces/IWinBioViewModel.cs new file mode 100644 index 0000000..7f26b63 --- /dev/null +++ b/examples/FrameworkTester/ViewModels/Interfaces/IWinBioViewModel.cs @@ -0,0 +1,26 @@ +using GalaSoft.MvvmLight.Command; + +namespace FrameworkTester.ViewModels.Interfaces +{ + + public interface IWinBioViewModel + { + + RelayCommand ExecuteCommand + { + get; + } + + string Name + { + get; + } + + string Result + { + get; + } + + } + +} \ No newline at end of file diff --git a/examples/FrameworkTester/ViewModels/MainViewModel.cs b/examples/FrameworkTester/ViewModels/MainViewModel.cs new file mode 100644 index 0000000..d032489 --- /dev/null +++ b/examples/FrameworkTester/ViewModels/MainViewModel.cs @@ -0,0 +1,138 @@ +using System; +using System.Collections.ObjectModel; +using System.Linq; +using System.Reflection; +using System.Threading.Tasks; +using FrameworkTester.Services.Interfaces; +using FrameworkTester.ViewModels.Interfaces; +using GalaSoft.MvvmLight; +using GalaSoft.MvvmLight.Command; +using GalaSoft.MvvmLight.Ioc; +using WinBiometricDotNet; + +namespace FrameworkTester.ViewModels +{ + public class MainViewModel : ViewModelBase, IMainViewModel + { + + #region Events + #endregion + + #region Fields + + private readonly IDispatcherService _DispatcherService; + + private readonly IWinBiometricService _WinBiometricService; + + private readonly IFrameNavigationService _NavigationService; + + #endregion + + #region Constructors + + public MainViewModel() + { + this._DispatcherService = SimpleIoc.Default.GetInstance(); + this._WinBiometricService = SimpleIoc.Default.GetInstance(); + this._NavigationService = SimpleIoc.Default.GetInstance(); + + var winBio = typeof(IWinBioViewModel); + foreach (var type in Assembly.GetExecutingAssembly() + .GetTypes() + .OrderBy(type => type.FullName) + .Where(type => type != winBio && !type.IsInterface && type.GetInterfaces() + .Contains(winBio)).Select(Activator.CreateInstance) + .Where(type => type is ViewModelBase) + .Cast()) + { + this._TestTargets.Add(type); + } + + foreach (var unit in this._WinBiometricService.EnumBiometricUnits()) + this._Units.Add(unit); + } + + #endregion + + #region Properties + + private IWinBioViewModel _CurrentTestTarget; + + public IWinBioViewModel CurrentTestTarget + { + get + { + return this._CurrentTestTarget; + } + set + { + this._CurrentTestTarget = value; + this.RaisePropertyChanged(); + + this._NavigationService.NavigateTo(value.Name); + } + } + + private BiometricUnit _CurrentUnit; + + public BiometricUnit CurrentUnit + { + get + { + return this._CurrentUnit; + } + set + { + this._CurrentUnit = value; + this.RaisePropertyChanged(); + } + } + + private RelayCommand _LoadedCommand; + + public RelayCommand LoadedCommand + { + get + { + return this._LoadedCommand ?? (this._LoadedCommand = new RelayCommand(async () => + { + await Task.Run(() => + { + this._DispatcherService.SafeAction(() => + { + if (this._TestTargets.Any()) + this.CurrentTestTarget = this._TestTargets.FirstOrDefault(); + + if (this._Units.Any()) + this.CurrentUnit = this._Units.FirstOrDefault(); + }); + }); + })); + } + } + + private readonly ObservableCollection _TestTargets = new ObservableCollection(); + + public ObservableCollection TestTargets => this._TestTargets; + + private readonly ObservableCollection _Units = new ObservableCollection(); + + public ObservableCollection Units => this._Units; + + #endregion + + #region Methods + + #region Overrids + #endregion + + #region Event Handlers + #endregion + + #region Helpers + #endregion + + #endregion + + } +} \ No newline at end of file diff --git a/examples/FrameworkTester/ViewModels/ViewModelLocator.cs b/examples/FrameworkTester/ViewModels/ViewModelLocator.cs new file mode 100644 index 0000000..ce8abc9 --- /dev/null +++ b/examples/FrameworkTester/ViewModels/ViewModelLocator.cs @@ -0,0 +1,107 @@ +/* + In App.xaml: + + + + + In the View: + DataContext="{Binding Source={StaticResource Locator}, Path=ViewModelName}" + + You can also use Blend to do all this with the tool's support. + See http://www.galasoft.ch/mvvm +*/ + +using System; +using System.Linq; +using System.Reflection; +using System.Windows; +using CommonServiceLocator; +using FrameworkTester.Services; +using FrameworkTester.Services.Interfaces; +using FrameworkTester.ViewModels.Interfaces; +using GalaSoft.MvvmLight; +using GalaSoft.MvvmLight.Ioc; + +namespace FrameworkTester.ViewModels +{ + /// + /// This class contains static references to all the view models in the + /// application and provides an entry point for the bindings. + /// + public class ViewModelLocator + { + /// + /// Initializes a new instance of the ViewModelLocator class. + /// + public ViewModelLocator() + { + ServiceLocator.SetLocatorProvider(() => SimpleIoc.Default); + + ////if (ViewModelBase.IsInDesignModeStatic) + ////{ + //// // Create design time view services and models + //// SimpleIoc.Default.Register(); + ////} + ////else + ////{ + //// // Create run time view services and models + //// SimpleIoc.Default.Register(); + ////} + + SimpleIoc.Default.Register(() => new DispatcherService(Application.Current.Dispatcher)); + SimpleIoc.Default.Register(); + + var navigationService = new FrameNavigationService(); + var winBio = typeof(IWinBioViewModel); + foreach (var type in Assembly.GetExecutingAssembly() + .GetTypes() + .OrderBy(type => type.FullName) + .Where(type => type != winBio && !type.IsInterface && type.GetInterfaces() + .Contains(winBio)).Select(Activator.CreateInstance) + .Where(type => type is ViewModelBase) + .Cast()) + { + navigationService.Configure(type.Name, new Uri($"pack://application:,,,/Views/{type.Name}.xaml", UriKind.Absolute)); + } + + SimpleIoc.Default.Register(() => navigationService); + SimpleIoc.Default.Register(); + + SimpleIoc.Default.Register(); + SimpleIoc.Default.Register(); + SimpleIoc.Default.Register(); + SimpleIoc.Default.Register(); + SimpleIoc.Default.Register(); + SimpleIoc.Default.Register(); + SimpleIoc.Default.Register(); + } + + public IMainViewModel Main + { + get + { + return ServiceLocator.Current.GetInstance(); + } + } + + public IWinBioAcquireFocusViewModel AcquireFocus => ServiceLocator.Current.GetInstance(); + + public IWinBioCaptureSampleViewModel WinBioCaptureSample => ServiceLocator.Current.GetInstance(); + + public IWinBioCaptureSampleWithCallbackViewModel WinBioCaptureSampleWithCallback => ServiceLocator.Current.GetInstance(); + + public IWinBioCloseSessionViewModel WinBioCloseSession => ServiceLocator.Current.GetInstance(); + + public IWinBioEnumBiometricUnitsViewModel WinBioEnumBiometricUnits => ServiceLocator.Current.GetInstance(); + + public IWinBioOpenSessionViewModel WinBioOpenSession => ServiceLocator.Current.GetInstance(); + + public IWinBioReleaseFocusViewModel ReleaseFocus => ServiceLocator.Current.GetInstance(); + + public static void Cleanup() + { + // TODO Clear the ViewModels + } + } +} \ No newline at end of file diff --git a/examples/FrameworkTester/ViewModels/WinBioAcquireFocusViewModel.cs b/examples/FrameworkTester/ViewModels/WinBioAcquireFocusViewModel.cs new file mode 100644 index 0000000..f3fb786 --- /dev/null +++ b/examples/FrameworkTester/ViewModels/WinBioAcquireFocusViewModel.cs @@ -0,0 +1,75 @@ +using System; +using System.Windows; +using FrameworkTester.Services.Interfaces; +using FrameworkTester.ViewModels.Interfaces; +using GalaSoft.MvvmLight; +using GalaSoft.MvvmLight.Command; +using GalaSoft.MvvmLight.Ioc; + +namespace FrameworkTester.ViewModels +{ + + public sealed class WinBioAcquireFocusViewModel : ViewModelBase, IWinBioAcquireFocusViewModel + { + + #region Fields + + private readonly IWinBiometricService _Service; + + #endregion + + #region Constructors + + public WinBioAcquireFocusViewModel() + { + this._Service = SimpleIoc.Default.GetInstance(); + } + + #endregion + + #region Properties + + private RelayCommand _ExecuteCommand; + + public RelayCommand ExecuteCommand + { + get + { + return this._ExecuteCommand ?? (this._ExecuteCommand = new RelayCommand(() => + { + try + { + this._Service.AcquireFocus(); + this.Result = "OK"; + } + catch (Exception e) + { + MessageBox.Show(e.Message); + this.Result = "FAIL"; + } + })); + } + } + + public string Name => "WinBioAcquireFocus"; + + private string _Result; + + public string Result + { + get + { + return this._Result; + } + private set + { + this._Result = value; + this.RaisePropertyChanged(); + } + } + + #endregion + + } + +} \ No newline at end of file diff --git a/examples/FrameworkTester/ViewModels/WinBioCaptureSampleViewModel.cs b/examples/FrameworkTester/ViewModels/WinBioCaptureSampleViewModel.cs new file mode 100644 index 0000000..0401fca --- /dev/null +++ b/examples/FrameworkTester/ViewModels/WinBioCaptureSampleViewModel.cs @@ -0,0 +1,278 @@ +using System; +using System.Windows; +using System.Windows.Media.Imaging; +using FrameworkTester.Helpers; +using FrameworkTester.Services.Interfaces; +using FrameworkTester.ViewModels.Interfaces; +using GalaSoft.MvvmLight; +using GalaSoft.MvvmLight.Command; +using GalaSoft.MvvmLight.Ioc; +using WinBiometricDotNet; + +namespace FrameworkTester.ViewModels +{ + + public sealed class WinBioCaptureSampleViewModel : ViewModelBase, IWinBioCaptureSampleViewModel + { + + #region Fields + + private readonly IWinBiometricService _Service; + + #endregion + + #region Constructors + + public WinBioCaptureSampleViewModel() + { + this._Service = SimpleIoc.Default.GetInstance(); + } + + #endregion + + #region Properties + + private BitmapSource _CaptureImage; + + public BitmapSource CaptureImage + { + get + { + return this._CaptureImage; + } + private set + { + this._CaptureImage = value; + this.RaisePropertyChanged(); + } + } + + private int _CaptureImageWidth; + + public int CaptureImageWidth + { + get + { + return this._CaptureImageWidth; + } + private set + { + this._CaptureImageWidth = value; + this.RaisePropertyChanged(); + } + } + + private int _CaptureImageHeight; + + public int CaptureImageHeight + { + get + { + return this._CaptureImageHeight; + } + private set + { + this._CaptureImageHeight = value; + this.RaisePropertyChanged(); + } + } + + private int _CaptureImageHorizontalResolution; + + public int CaptureImageHorizontalResolution + { + get + { + return this._CaptureImageHorizontalResolution; + } + private set + { + this._CaptureImageHorizontalResolution = value; + this.RaisePropertyChanged(); + } + } + + private int _CaptureImageVerticalResolution; + + public int CaptureImageVerticalResolution + { + get + { + return this._CaptureImageVerticalResolution; + } + private set + { + this._CaptureImageVerticalResolution = value; + this.RaisePropertyChanged(); + } + } + + private int _CaptureImageScanHorizontalResolution; + + public int CaptureImageScanHorizontalResolution + { + get + { + return this._CaptureImageScanHorizontalResolution; + } + private set + { + this._CaptureImageScanHorizontalResolution = value; + this.RaisePropertyChanged(); + } + } + + private int _CaptureImageScanVerticalResolution; + + public int CaptureImageScanVerticalResolution + { + get + { + return this._CaptureImageScanVerticalResolution; + } + private set + { + this._CaptureImageScanVerticalResolution = value; + this.RaisePropertyChanged(); + } + } + + private RelayCommand _ExecuteCommand; + + public RelayCommand ExecuteCommand + { + get + { + return this._ExecuteCommand ?? (this._ExecuteCommand = new RelayCommand(() => + { + try + { + this.Result = "WAIT"; + var ressult = this._Service.CaptureSample(); + this.Result = "OK"; + + switch (ressult.OperationStatus) + { + case OperationStatus.OK: + this.Result = "OK"; + break; + case OperationStatus.BadCapture: + this.Result = "BadCapture"; + break; + case OperationStatus.Canceled: + this.Result = "Canceled"; + break; + case OperationStatus.Unknown: + this.Result = "Unknown"; + break; + } + + this.RejectDetail = ressult.RejectDetail; + this.SampleSize = ressult.SampleSize; + this.UnitId = ressult.UnitId; + + var captureSample = ressult.Sample; + if (captureSample != null) + { + var image = BitmapSourceHelper.ToBitmapSource(captureSample.Image, + captureSample.Width, + captureSample.Height, + captureSample.HorizontalImageResolution, + captureSample.VerticalImageResolution); + if (image.CanFreeze) + image.Freeze(); + this.CaptureImage = image; + + this.CaptureImageWidth = captureSample.Width; + this.CaptureImageHeight = captureSample.Height; + this.CaptureImageHorizontalResolution = captureSample.HorizontalImageResolution; + this.CaptureImageVerticalResolution = captureSample.VerticalImageResolution; + this.CaptureImageScanHorizontalResolution = captureSample.HorizontalScanResolution; + this.CaptureImageScanVerticalResolution = captureSample.VerticalScanResolution; + } + else + { + this.CaptureImageWidth = -1; + this.CaptureImageHeight = -1; + this.CaptureImageHorizontalResolution = -1; + this.CaptureImageVerticalResolution = -1; + this.CaptureImageScanHorizontalResolution = -1; + this.CaptureImageScanVerticalResolution = -1; + } + } + catch (Exception e) + { + MessageBox.Show(e.Message); + this.Result = "FAIL"; + } + })); + } + } + + public string Name => "WinBioCaptureSample"; + + private string _Result; + + public string Result + { + get + { + return this._Result; + } + private set + { + this._Result = value; + this.RaisePropertyChanged(); + } + } + + private uint _RejectDetail; + + public uint RejectDetail + { + get + { + return this._RejectDetail; + } + private set + { + this._RejectDetail = value; + this.RaisePropertyChanged(); + } + } + + private uint _SampleSize; + + public uint SampleSize + { + get + { + return this._SampleSize; + } + private set + { + this._SampleSize = value; + this.RaisePropertyChanged(); + } + } + + private uint _UnitId; + + public uint UnitId + { + get + { + return this._UnitId; + } + private set + { + this._UnitId = value; + this.RaisePropertyChanged(); + } + } + + #endregion + + } + +} \ No newline at end of file diff --git a/examples/FrameworkTester/ViewModels/WinBioCaptureSampleWithCallbackViewModel.cs b/examples/FrameworkTester/ViewModels/WinBioCaptureSampleWithCallbackViewModel.cs new file mode 100644 index 0000000..9a780d1 --- /dev/null +++ b/examples/FrameworkTester/ViewModels/WinBioCaptureSampleWithCallbackViewModel.cs @@ -0,0 +1,304 @@ +using System; +using System.Windows; +using System.Windows.Media.Imaging; +using FrameworkTester.Helpers; +using FrameworkTester.Services.Interfaces; +using FrameworkTester.ViewModels.Interfaces; +using GalaSoft.MvvmLight; +using GalaSoft.MvvmLight.Command; +using GalaSoft.MvvmLight.Ioc; +using WinBiometricDotNet; + +namespace FrameworkTester.ViewModels +{ + + public sealed class WinBioCaptureSampleWithCallbackViewModel : ViewModelBase, IWinBioCaptureSampleWithCallbackViewModel + { + + #region Fields + + private readonly IWinBiometricService _Service; + + #endregion + + #region Constructors + + public WinBioCaptureSampleWithCallbackViewModel() + { + this._Service = SimpleIoc.Default.GetInstance(); + WinBiometric.SampleCaptured += this.WinBiometricOnSampleCaptured; + } + + #endregion + + #region Properties + + private BitmapSource _CaptureImage; + + public BitmapSource CaptureImage + { + get + { + return this._CaptureImage; + } + private set + { + this._CaptureImage = value; + this.RaisePropertyChanged(); + } + } + + private int _CaptureImageWidth; + + public int CaptureImageWidth + { + get + { + return this._CaptureImageWidth; + } + private set + { + this._CaptureImageWidth = value; + this.RaisePropertyChanged(); + } + } + + private int _CaptureImageHeight; + + public int CaptureImageHeight + { + get + { + return this._CaptureImageHeight; + } + private set + { + this._CaptureImageHeight = value; + this.RaisePropertyChanged(); + } + } + + private int _CaptureImageHorizontalResolution; + + public int CaptureImageHorizontalResolution + { + get + { + return this._CaptureImageHorizontalResolution; + } + private set + { + this._CaptureImageHorizontalResolution = value; + this.RaisePropertyChanged(); + } + } + + private int _CaptureImageVerticalResolution; + + public int CaptureImageVerticalResolution + { + get + { + return this._CaptureImageVerticalResolution; + } + private set + { + this._CaptureImageVerticalResolution = value; + this.RaisePropertyChanged(); + } + } + + private int _CaptureImageScanHorizontalResolution; + + public int CaptureImageScanHorizontalResolution + { + get + { + return this._CaptureImageScanHorizontalResolution; + } + private set + { + this._CaptureImageScanHorizontalResolution = value; + this.RaisePropertyChanged(); + } + } + + private int _CaptureImageScanVerticalResolution; + + public int CaptureImageScanVerticalResolution + { + get + { + return this._CaptureImageScanVerticalResolution; + } + private set + { + this._CaptureImageScanVerticalResolution = value; + this.RaisePropertyChanged(); + } + } + + private RelayCommand _ExecuteCommand; + + public RelayCommand ExecuteCommand + { + get + { + return this._ExecuteCommand ?? (this._ExecuteCommand = new RelayCommand(() => + { + try + { + this.Result = "WAIT"; + this._Service.CaptureSampleWithCallback(); + } + catch (Exception e) + { + MessageBox.Show(e.Message); + this.Result = "FAIL"; + } + })); + } + } + + private bool _Loop; + + public bool Loop + { + get + { + return this._Loop; + } + set + { + this._Loop = value; + this.RaisePropertyChanged(); + } + } + + public string Name => "WinBioCaptureSampleWithCallback"; + + private string _Result; + + public string Result + { + get + { + return this._Result; + } + private set + { + this._Result = value; + this.RaisePropertyChanged(); + } + } + + private uint _RejectDetail; + + public uint RejectDetail + { + get + { + return this._RejectDetail; + } + private set + { + this._RejectDetail = value; + this.RaisePropertyChanged(); + } + } + + private uint _SampleSize; + + public uint SampleSize + { + get + { + return this._SampleSize; + } + private set + { + this._SampleSize = value; + this.RaisePropertyChanged(); + } + } + + private uint _UnitId; + + public uint UnitId + { + get + { + return this._UnitId; + } + private set + { + this._UnitId = value; + this.RaisePropertyChanged(); + } + } + + #endregion + + #region Methods + + #region Event Handlers + + private void WinBiometricOnSampleCaptured(object sender, CaptureSampleEventArgs e) + { + switch (e.Result.OperationStatus) + { + case OperationStatus.OK: + this.Result = "OK"; + break; + case OperationStatus.BadCapture: + this.Result = "BadCapture"; + break; + case OperationStatus.Canceled: + this.Result = "Canceled"; + break; + case OperationStatus.Unknown: + this.Result = "Unknown"; + break; + } + + this.RejectDetail = e.Result.RejectDetail; + this.SampleSize = e.Result.SampleSize; + this.UnitId = e.Result.UnitId; + + var captureSample = e.Result.Sample; + if (captureSample != null) + { + var image = BitmapSourceHelper.ToBitmapSource(captureSample.Image, + captureSample.Width, + captureSample.Height, + captureSample.HorizontalImageResolution, + captureSample.VerticalImageResolution); + if (image.CanFreeze) + image.Freeze(); + this.CaptureImage = image; + + this.CaptureImageWidth = captureSample.Width; + this.CaptureImageHeight = captureSample.Height; + this.CaptureImageHorizontalResolution = captureSample.HorizontalImageResolution; + this.CaptureImageVerticalResolution = captureSample.VerticalImageResolution; + this.CaptureImageScanHorizontalResolution = captureSample.HorizontalScanResolution; + this.CaptureImageScanVerticalResolution = captureSample.VerticalScanResolution; + } + else + { + this.CaptureImageWidth = -1; + this.CaptureImageHeight = -1; + this.CaptureImageHorizontalResolution = -1; + this.CaptureImageVerticalResolution = -1; + this.CaptureImageScanHorizontalResolution = -1; + this.CaptureImageScanVerticalResolution = -1; + } + } + + #endregion + + #endregion + + } + +} \ No newline at end of file diff --git a/examples/FrameworkTester/ViewModels/WinBioCloseSessionViewModel.cs b/examples/FrameworkTester/ViewModels/WinBioCloseSessionViewModel.cs new file mode 100644 index 0000000..aff96e8 --- /dev/null +++ b/examples/FrameworkTester/ViewModels/WinBioCloseSessionViewModel.cs @@ -0,0 +1,75 @@ +using System; +using System.Windows; +using FrameworkTester.Services.Interfaces; +using FrameworkTester.ViewModels.Interfaces; +using GalaSoft.MvvmLight; +using GalaSoft.MvvmLight.Command; +using GalaSoft.MvvmLight.Ioc; + +namespace FrameworkTester.ViewModels +{ + + public sealed class WinBioCloseSessionViewModel : ViewModelBase, IWinBioCloseSessionViewModel + { + + #region Fields + + private readonly IWinBiometricService _Service; + + #endregion + + #region Constructors + + public WinBioCloseSessionViewModel() + { + this._Service = SimpleIoc.Default.GetInstance(); + } + + #endregion + + #region Properties + + private RelayCommand _ExecuteCommand; + + public RelayCommand ExecuteCommand + { + get + { + return this._ExecuteCommand ?? (this._ExecuteCommand = new RelayCommand(() => + { + try + { + this._Service.CloseSession(); + this.Result = "OK"; + } + catch (Exception e) + { + MessageBox.Show(e.Message); + this.Result = "FAIL"; + } + })); + } + } + + public string Name => "WinBioCloseSession"; + + private string _Result; + + public string Result + { + get + { + return this._Result; + } + private set + { + this._Result = value; + this.RaisePropertyChanged(); + } + } + + #endregion + + } + +} \ No newline at end of file diff --git a/examples/FrameworkTester/ViewModels/WinBioEnumBiometricUnitsViewModel.cs b/examples/FrameworkTester/ViewModels/WinBioEnumBiometricUnitsViewModel.cs new file mode 100644 index 0000000..ef4beaf --- /dev/null +++ b/examples/FrameworkTester/ViewModels/WinBioEnumBiometricUnitsViewModel.cs @@ -0,0 +1,90 @@ +using System; +using System.Collections.ObjectModel; +using System.Windows; +using FrameworkTester.Services.Interfaces; +using FrameworkTester.ViewModels.Interfaces; +using GalaSoft.MvvmLight; +using GalaSoft.MvvmLight.Command; +using GalaSoft.MvvmLight.Ioc; +using WinBiometricDotNet; + +namespace FrameworkTester.ViewModels +{ + + public sealed class WinBioEnumBiometricUnitsViewModel : ViewModelBase, IWinBioEnumBiometricUnitsViewModel + { + + #region Fields + + private readonly IWinBiometricService _Service; + + #endregion + + #region Constructors + + public WinBioEnumBiometricUnitsViewModel() + { + this._Service = SimpleIoc.Default.GetInstance(); + } + + #endregion + + #region Properties + + private RelayCommand _ExecuteCommand; + + public RelayCommand ExecuteCommand + { + get + { + return this._ExecuteCommand ?? (this._ExecuteCommand = new RelayCommand(() => + { + try + { + this._Units.Clear(); + foreach (var unit in this._Service.EnumBiometricUnits()) + this._Units.Add(unit); + + this.Result = "OK"; + } + catch (Exception e) + { + MessageBox.Show(e.Message); + this.Result = "FAIL"; + } + })); + } + } + + public string Name => "WinBioEnumBiometricUnits"; + + private string _Result; + + public string Result + { + get + { + return this._Result; + } + private set + { + this._Result = value; + this.RaisePropertyChanged(); + } + } + + private readonly ObservableCollection _Units = new ObservableCollection(); + + public ObservableCollection Units + { + get + { + return this._Units; + } + } + + #endregion + + } + +} \ No newline at end of file diff --git a/examples/FrameworkTester/ViewModels/WinBioOpenSessionViewModel.cs b/examples/FrameworkTester/ViewModels/WinBioOpenSessionViewModel.cs new file mode 100644 index 0000000..9319462 --- /dev/null +++ b/examples/FrameworkTester/ViewModels/WinBioOpenSessionViewModel.cs @@ -0,0 +1,92 @@ +using System; +using System.Windows; +using FrameworkTester.Services.Interfaces; +using FrameworkTester.ViewModels.Interfaces; +using GalaSoft.MvvmLight; +using GalaSoft.MvvmLight.Command; +using GalaSoft.MvvmLight.Ioc; + +namespace FrameworkTester.ViewModels +{ + + public sealed class WinBioOpenSessionViewModel : ViewModelBase, IWinBioOpenSessionViewModel + { + + #region Fields + + private readonly IWinBiometricService _Service; + + #endregion + + #region Constructors + + public WinBioOpenSessionViewModel() + { + this._Service = SimpleIoc.Default.GetInstance(); + } + + #endregion + + #region Properties + + private RelayCommand _ExecuteCommand; + + public RelayCommand ExecuteCommand + { + get + { + return this._ExecuteCommand ?? (this._ExecuteCommand = new RelayCommand(() => + { + try + { + var session = this._Service.OpenSession(); + this.SessionHandle = session.Handle; + + this.Result = "OK"; + } + catch (Exception e) + { + MessageBox.Show(e.Message); + this.Result = "FAIL"; + } + })); + } + } + + public string Name => "WinBioOpenSession"; + + private string _Result; + + public string Result + { + get + { + return this._Result; + } + private set + { + this._Result = value; + this.RaisePropertyChanged(); + } + } + + private IntPtr _SessionHandle; + + public IntPtr SessionHandle + { + get + { + return this._SessionHandle; + } + private set + { + this._SessionHandle = value; + this.RaisePropertyChanged(); + } + } + + #endregion + + } + +} \ No newline at end of file diff --git a/examples/FrameworkTester/ViewModels/WinBioReleaseFocusViewModel.cs b/examples/FrameworkTester/ViewModels/WinBioReleaseFocusViewModel.cs new file mode 100644 index 0000000..42e608d --- /dev/null +++ b/examples/FrameworkTester/ViewModels/WinBioReleaseFocusViewModel.cs @@ -0,0 +1,75 @@ +using System; +using System.Windows; +using FrameworkTester.Services.Interfaces; +using FrameworkTester.ViewModels.Interfaces; +using GalaSoft.MvvmLight; +using GalaSoft.MvvmLight.Command; +using GalaSoft.MvvmLight.Ioc; + +namespace FrameworkTester.ViewModels +{ + + public sealed class WinBioReleaseFocusViewModel : ViewModelBase, IWinBioReleaseFocusViewModel + { + + #region Fields + + private readonly IWinBiometricService _Service; + + #endregion + + #region Constructors + + public WinBioReleaseFocusViewModel() + { + this._Service = SimpleIoc.Default.GetInstance(); + } + + #endregion + + #region Properties + + private RelayCommand _ExecuteCommand; + + public RelayCommand ExecuteCommand + { + get + { + return this._ExecuteCommand ?? (this._ExecuteCommand = new RelayCommand(() => + { + try + { + this._Service.ReleaseFocus(); + this.Result = "OK"; + } + catch (Exception e) + { + MessageBox.Show(e.Message); + this.Result = "FAIL"; + } + })); + } + } + + public string Name => "WinBioReleaseFocus"; + + private string _Result; + + public string Result + { + get + { + return this._Result; + } + private set + { + this._Result = value; + this.RaisePropertyChanged(); + } + } + + #endregion + + } + +} \ No newline at end of file diff --git a/examples/FrameworkTester/Views/MainWindow.xaml b/examples/FrameworkTester/Views/MainWindow.xaml new file mode 100644 index 0000000..8ba03b8 --- /dev/null +++ b/examples/FrameworkTester/Views/MainWindow.xaml @@ -0,0 +1,86 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/FrameworkTester/Views/MainWindow.xaml.cs b/examples/FrameworkTester/Views/MainWindow.xaml.cs new file mode 100644 index 0000000..0831d1d --- /dev/null +++ b/examples/FrameworkTester/Views/MainWindow.xaml.cs @@ -0,0 +1,15 @@ +using System.Windows; + +namespace FrameworkTester.Views +{ + /// + /// MainWindow.xaml の相互作用ロジック + /// + public partial class MainWindow : Window + { + public MainWindow() + { + this.InitializeComponent(); + } + } +} diff --git a/examples/FrameworkTester/Views/WinBioAcquireFocus.xaml b/examples/FrameworkTester/Views/WinBioAcquireFocus.xaml new file mode 100644 index 0000000..3fed1c4 --- /dev/null +++ b/examples/FrameworkTester/Views/WinBioAcquireFocus.xaml @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + +