Skip to content

Commit

Permalink
Merge branch 'release/0.9.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
takuya-takeuchi committed Aug 18, 2018
2 parents f7982e4 + 7a5bb04 commit 0bb9718
Show file tree
Hide file tree
Showing 90 changed files with 4,824 additions and 5,844 deletions.
1 change: 1 addition & 0 deletions examples/FrameworkTester/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<viewModels:ViewModelLocator x:Key="Locator" d:IsDataSource="True" />

<!-- Conveters -->
<converters:HResultToStringConveter x:Key="HResultToStringConveter"/>
<converters:IntegerToHexStringConveter x:Key="IntegerToHexStringConveter" />
<converters:BooleanToVisibilityConverter x:Key="HiddenIfFalse"
IsHidden="True"
Expand Down
35 changes: 35 additions & 0 deletions examples/FrameworkTester/Converters/HResultToStringConveter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using System;
using System.Windows.Data;
using WinBiometricDotNet.Runtime.InteropServices;
using HRESULT = System.Int32;

namespace FrameworkTester.Converters
{

public sealed class HResultToStringConveter : IValueConverter
{

#region Methods

#region Overrids

public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if (value is HRESULT hresult)
return $"0x{hresult:X8} ({Marshal.GetWinBiometricExceptionFromHR(hresult).Message})";

throw new ArgumentException();
}

public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new ArgumentException();
}

#endregion

#endregion

}

}
1 change: 1 addition & 0 deletions examples/FrameworkTester/FrameworkTester.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
</ApplicationDefinition>
<Compile Include="Controls\ObservableContentControl.cs" />
<Compile Include="Converters\BooleanToVisibilityConverter.cs" />
<Compile Include="Converters\HResultToStringConveter.cs" />
<Compile Include="Converters\IntegerToHexStringConveter.cs" />
<Compile Include="DesignTimes\ChildWindowViewModel.cs" />
<Compile Include="DesignTimes\WinBioAcquireFocusViewModel.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public DataTemplate GetProperty
set;
}

public DataTemplate Identity
public DataTemplate Identify
{
get;
set;
Expand Down Expand Up @@ -133,8 +133,8 @@ public override DataTemplate SelectTemplate(object item, DependencyObject contai
return this.GetEvent;
if (item is AsyncResultGetProperty)
return this.GetProperty;
if (item is AsyncResultIdentity)
return this.Identity;
if (item is AsyncResultIdentify)
return this.Identify;
if (item is AsyncResultSetProperty)
return this.SetProperty;
if (item is AsyncResultVerify)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ void ControlUnitPrivileged(Session session,

IEnumerable<BiometricUnit> EnumBiometricUnits();

IEnumerable<FingerPosition> EnumEnrollments(Session session, BiometricUnit unit);
IEnumerable<FingerPosition> EnumEnrollments(Session session, uint unitId);

IEnumerable<BiometricServiceProvider> EnumServiceProviders();

Expand Down Expand Up @@ -159,9 +159,9 @@ void SetCredential(CredentialTypes credentialType,

void UnregisterEventMonitor(Session session);

VerifyResult Verify(Session session, BiometricUnit unit, FingerPosition position);
VerifyResult Verify(Session session, FingerPosition position);

void VerifyWithCallback(Session session, BiometricUnit unit, FingerPosition position);
void VerifyWithCallback(Session session, FingerPosition position);

void Wait(Session session);

Expand Down
18 changes: 6 additions & 12 deletions examples/FrameworkTester/Services/WinBiometricService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,9 @@ public IEnumerable<BiometricUnit> EnumBiometricUnits()
return WinBiometric.EnumBiometricUnits();
}

public IEnumerable<FingerPosition> EnumEnrollments(Session session, BiometricUnit unit)
public IEnumerable<FingerPosition> EnumEnrollments(Session session, uint unitId)
{
return WinBiometric.EnumEnrollments(session, unit);
return WinBiometric.EnumEnrollments(session, unitId);
}

public IEnumerable<BiometricServiceProvider> EnumServiceProviders()
Expand Down Expand Up @@ -411,23 +411,17 @@ public void UnregisterEventMonitor(Session session)
WinBiometric.UnregisterEventMonitor(session);
}

public VerifyResult Verify(Session session, BiometricUnit unit, FingerPosition position)
public VerifyResult Verify(Session session, FingerPosition position)
{
if (unit == null)
throw new ArgumentNullException(nameof(unit));

return WinBiometric.Verify(session, unit, position);
return WinBiometric.Verify(session, position);
}

public void VerifyWithCallback(Session session, BiometricUnit unit, FingerPosition position)
public void VerifyWithCallback(Session session, FingerPosition position)
{
if (unit == null)
throw new ArgumentNullException(nameof(unit));

WinBiometric.Verified -= Verified;
WinBiometric.Verified += Verified;

WinBiometric.VerifyWithCallback(session, unit, position);
WinBiometric.VerifyWithCallback(session, position);
}

public void Wait(Session session)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ protected override void ProcessMessage(IntPtr hwnd, IntPtr wParam, IntPtr lParam
this.Result = result;
this.Session = result.Session;

if(result.Parameter is AsyncResultIdentity identity)
if(result.Parameter is AsyncResultIdentify identity)
{
this.IdentityRepository.Add(identity.Identity);
}
Expand Down
6 changes: 3 additions & 3 deletions examples/FrameworkTester/ViewModels/MainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -226,11 +226,11 @@ private void OnEventMonitored(object sender, EventMonitoredEventArgs e)
switch (e.EventType)
{
case EventTypes.Unclaimed:
var u = e.Unclaimed;
var u = e.EventParameter as UnclaimedEvent;
message = $"[{dt}] [{e.OperationStatus}] [Unclaimed] UnidId: {u.UnidId}, RejectDetail: {u.RejectDetail}";
break;
case EventTypes.UnclaimedIdentify:
var ui = e.UnclaimedIdentify;
var ui = e.EventParameter as UnclaimedIdentifyEvent;
message = $"[{dt}] [{e.OperationStatus}] [UnclaimedIdentify] UnidId: {ui.UnidId}, RejectDetail: {ui.RejectDetail}, FingerPosition: {ui.FingerPosition}";

string subMessage = null;
Expand All @@ -256,7 +256,7 @@ private void OnEventMonitored(object sender, EventMonitoredEventArgs e)
message = $"{message}, {subMessage}";
break;
case EventTypes.Error:
var err = e.Error;
var err = e.EventParameter as ErrorEvent;
message = $"[{dt}] [{e.OperationStatus}] [Error] ErrorCode: {err.ErrorCode}";
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using FrameworkTester.ViewModels.Interfaces;
using GalaSoft.MvvmLight.Command;
using WinBiometricDotNet;
using WinBiometricDotNet.Runtime.InteropServices;

namespace FrameworkTester.ViewModels
{
Expand Down Expand Up @@ -135,24 +136,8 @@ public override RelayCommand ExecuteCommand
var session = this.HandleRepository.SelectedHandle.Session;
var result = this.BiometricService.CaptureSample(session);

var text = "OK";
switch (result.OperationStatus)
{
case OperationStatus.OK:
text = "OK";
break;
case OperationStatus.BadCapture:
text = "BadCapture";
break;
case OperationStatus.Canceled:
text = "Canceled";
break;
case OperationStatus.Unknown:
text = "Unknown";
break;
}
this.Result = Marshal.GetWinBiometricExceptionFromHR(result.OperationStatus).Message;

this.Result = text;
this.RejectDetail = result.RejectDetail;
this.SampleSize = result.SampleSize;
this.UnitId = result.UnitId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using FrameworkTester.ViewModels.Interfaces;
using GalaSoft.MvvmLight.Command;
using WinBiometricDotNet;
using WinBiometricDotNet.Runtime.InteropServices;

namespace FrameworkTester.ViewModels
{
Expand Down Expand Up @@ -280,21 +281,7 @@ private void WinBiometricOnSampleCaptured(object sender, CaptureSampleEventArgs
this.WaitCallback = false;
});

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.Result = Marshal.GetWinBiometricExceptionFromHR(e.Result.OperationStatus).Message;

this.RejectDetail = e.Result.RejectDetail;
this.SampleSize = e.Result.SampleSize;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using FrameworkTester.ViewModels.Interfaces;
using GalaSoft.MvvmLight.Command;
using WinBiometricDotNet;
using WinBiometricDotNet.Runtime.InteropServices;

namespace FrameworkTester.ViewModels
{
Expand Down Expand Up @@ -30,24 +31,7 @@ public override RelayCommand ExecuteCommand
var session = this.HandleRepository.SelectedHandle.Session;
var result = this.BiometricService.CaptureEnroll(session);

switch (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.MoreData:
this.Result = "MoreData";
break;
case OperationStatus.Unknown:
this.Result = "Unknown";
break;
}
this.Result = Marshal.GetWinBiometricExceptionFromHR(result.OperationStatus).Message;

this.RejectDetail = result.RejectDetail;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using FrameworkTester.ViewModels.Interfaces;
using GalaSoft.MvvmLight.Command;
using WinBiometricDotNet;
using WinBiometricDotNet.Runtime.InteropServices;

namespace FrameworkTester.ViewModels
{
Expand Down Expand Up @@ -129,24 +130,7 @@ private void WinBiometricEnrollCaptured(object sender, EnrollCapturedEventArgs e
this.WaitCallback = false;
});

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.MoreData:
this.Result = "MoreData";
break;
case OperationStatus.Unknown:
this.Result = "Unknown";
break;
}
this.Result = Marshal.GetWinBiometricExceptionFromHR(e.Result.OperationStatus).Message;

this.RejectDetail = e.Result.RejectDetail;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public override RelayCommand ExecuteCommand
this._FingerPositions.Clear();

var session = this.HandleRepository.SelectedHandle.Session;
var positions = this.BiometricService.EnumEnrollments(session, this.SelectedUnit);
var positions = this.BiometricService.EnumEnrollments(session, this.SelectedUnit.UnitId);
var resuls = new List<KeyValuePair<string, bool>>();
foreach (var value in Enum.GetValues(typeof(FingerPosition)).Cast<FingerPosition>())
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using GalaSoft.MvvmLight.Command;
using GalaSoft.MvvmLight.Ioc;
using WinBiometricDotNet;
using WinBiometricDotNet.Runtime.InteropServices;

namespace FrameworkTester.ViewModels
{
Expand Down Expand Up @@ -199,24 +200,7 @@ private void WinBiometricIdentified(object sender, IdentifiedEventArgs e)
this.WaitCallback = false;
});

switch (e.Result.OperationStatus)
{
case OperationStatus.OK:
this.Result = "OK";
break;
case OperationStatus.Canceled:
this.Result = "Canceled";
break;
case OperationStatus.NoMatch:
this.Result = "NoMatch";
break;
case OperationStatus.BadCapture:
this.Result = "BadCapture";
break;
case OperationStatus.Unknown:
this.Result = "Unknown";
break;
}
this.Result = Marshal.GetWinBiometricExceptionFromHR(e.Result.OperationStatus).Message;

var result = e.Result;
this.Type = result.Identity.Type;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using FrameworkTester.ViewModels.Interfaces;
using GalaSoft.MvvmLight.Command;
using WinBiometricDotNet;
using WinBiometricDotNet.Runtime.InteropServices;

namespace FrameworkTester.ViewModels
{
Expand Down Expand Up @@ -129,18 +130,7 @@ private void WinBiometricSensorLocated(object sender, LocateSensorEventArgs e)
this.WaitCallback = false;
});

switch (e.OperationStatus)
{
case OperationStatus.OK:
this.Result = "OK";
break;
case OperationStatus.Canceled:
this.Result = "Canceled";
break;
case OperationStatus.Unknown:
this.Result = "Unknown";
break;
}
this.Result = Marshal.GetWinBiometricExceptionFromHR(e.OperationStatus).Message;

this.UnitId = e.UnitId;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public override RelayCommand ExecuteCommand
this.UpdateUIImmediately();

var session = this.HandleRepository.SelectedHandle.Session;
var result = this.BiometricService.Verify(session, this.SelectedUnit, this.SelectedFingerPosition);
var result = this.BiometricService.Verify(session, this.SelectedFingerPosition);

this.Result = "OK";

Expand Down
Loading

0 comments on commit 0bb9718

Please sign in to comment.