From 40b5c98d7f5ab503891f230f4b69fba3717f129d Mon Sep 17 00:00:00 2001 From: Serhiy Perevoznyk Date: Fri, 1 Oct 2021 11:02:17 +0200 Subject: [PATCH] Added addtional option to set hardware events tracing --- Redist/Swelio32.dll | Bin 1138688 -> 1138688 bytes Redist/Swelio64.dll | Bin 1321472 -> 1321472 bytes Samples/C#/EIDTestApp/EIDTestApp.csproj | 8 ++++- Samples/C#/EIDTestApp/FormMain.cs | 11 ++---- Samples/C#/EIDTestApp/Program.cs | 8 +++++ .../Properties/Resources.Designer.cs | 4 +-- .../Properties/Settings.Designer.cs | 4 +-- Samples/C#/EIDTestApp/app.config | 2 +- Swelio.Engine/Swelio.Engine/Manager.cs | 32 ++++++++++++++++-- Swelio.Engine/Swelio.Engine/NativeMethods.cs | 2 +- 10 files changed, 52 insertions(+), 19 deletions(-) diff --git a/Redist/Swelio32.dll b/Redist/Swelio32.dll index 1898ec48c94401947d97cd8d8f580c1fd1884f10..1cbbc2b85ffd0564863b615a5524a9c9adeac97f 100644 GIT binary patch delta 215 zcmZoT;M#D&b%OyT^QnVj&Bl!F#*B>HjTxC1R7!XA?%@y=XgyiN+g!`Rz(4gsN23E1 z14HZ~7KZkBRZKw448$xz%nHP8K+F!r96-zo#9Tnk4a7V^%)9+v6`$EWYoHa03_t)h zg~11ipLp{#JTc`52{FLrcz|pXAU5#fXD~2>%T14$kpyRezyTTK9-u0!Df delta 215 zcmZoT;M#D&b%OyTb4YhcvoT}4F(c!4V@9S0mD0_&dpHCI7)p7XYdIMBryf}3z{J21 zdx(YM%$fFgRZKw448$xz%nHP8K+F!r96-zo#9Tnk4a7V^%)9+v6`$EWYoHa03_t)h zhrtJkpLp{#JTc`52{FLrcz|pXAU5#fXD~2>%T14$kpyRezyTTK8?{6K{O diff --git a/Redist/Swelio64.dll b/Redist/Swelio64.dll index ec22117a5f5ffa39deab0257779e91ada9c122fe..a151ec645e8eca9c8b0eaf90a34d49c5642b12a9 100644 GIT binary patch delta 207 zcmZp;63}oZV1of8^NoXH&Bl!F#*B>HjTxEb7KnF?eq<12@MyhM!rgk3f9ipbra4Ru z42Rn@7BT@bGZ3=?F)I+W0Wmuea{w_X5OV=BHxTmxF)tAF0WtsfjD-S!w5);FBr*U2 z&?p8UAU?q;$Z+Dl07!@dCdUJ0i-0hbAcM#UxZL#lX9Ofc?%clnjDVstBX9fN_X0pH O2*g6$@4gpSwgLc(rblZ4 delta 207 zcmZp;63}oZV1of8^V05+W@E;7V@Ag9#*9pI3&fjkKQIU~FqHDNp5&i;po2wq4if{z z;WOkJ8Hibcm=%cGfS4VKIe?fGh`E568;E&;m=}oofS7-K#zKKVTGl{o5*dI1 zXcmJH5T9TaWH|9&03^f!lj8xhML?KIkU``FTyFaOGXjzzcW&Q(MnF-Sk*EFcdjTL8 O1Y)7>ci#&uTLAzk!9+*^ diff --git a/Samples/C#/EIDTestApp/EIDTestApp.csproj b/Samples/C#/EIDTestApp/EIDTestApp.csproj index 5c56cb5..6c26e5a 100755 --- a/Samples/C#/EIDTestApp/EIDTestApp.csproj +++ b/Samples/C#/EIDTestApp/EIDTestApp.csproj @@ -16,7 +16,7 @@ 3.5 - v4.0 + v4.7 publish\ true @@ -43,6 +43,7 @@ prompt 4 x86 + false pdbonly @@ -51,6 +52,7 @@ TRACE prompt 4 + false true @@ -59,6 +61,7 @@ full x86 prompt + false bin\x86\Release\ @@ -67,6 +70,7 @@ pdbonly x86 prompt + false true @@ -77,6 +81,7 @@ true GlobalSuppressions.cs prompt + false bin\x64\Release\ @@ -87,6 +92,7 @@ true GlobalSuppressions.cs prompt + false diff --git a/Samples/C#/EIDTestApp/FormMain.cs b/Samples/C#/EIDTestApp/FormMain.cs index 8764194..b90fbd2 100755 --- a/Samples/C#/EIDTestApp/FormMain.cs +++ b/Samples/C#/EIDTestApp/FormMain.cs @@ -6,17 +6,8 @@ //used for purposes other than as intended. using System; -using System.IO; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; using System.Drawing; -using System.Text; using System.Windows.Forms; -using System.Diagnostics; -using System.Runtime.InteropServices; -using System.Security.Cryptography; -using System.Security.Cryptography.X509Certificates; using Swelio.Engine; namespace EIDTestApp @@ -192,6 +183,8 @@ private void ActivateCardEventsTracing() engine.CardInserted += new EventHandler(engine_CardInserted); engine.CardRemoved += new EventHandler(engine_CardRemoved); engine.ReadersListChanged += new EventHandler(engine_ReadersListChanged); + engine.TraceHardwareEvents = true; + engine.TraceServiceEvents = true; engine.TraceEvents = true; } diff --git a/Samples/C#/EIDTestApp/Program.cs b/Samples/C#/EIDTestApp/Program.cs index e96ffe2..61946bd 100755 --- a/Samples/C#/EIDTestApp/Program.cs +++ b/Samples/C#/EIDTestApp/Program.cs @@ -12,9 +12,17 @@ static class Program [STAThread] static void Main() { + + if (Environment.OSVersion.Version.Major >= 6) + SetProcessDPIAware(); + Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new FormMain()); } + + [System.Runtime.InteropServices.DllImport("user32.dll")] + private static extern bool SetProcessDPIAware(); + } } \ No newline at end of file diff --git a/Samples/C#/EIDTestApp/Properties/Resources.Designer.cs b/Samples/C#/EIDTestApp/Properties/Resources.Designer.cs index 3ca48f5..4cf52e3 100755 --- a/Samples/C#/EIDTestApp/Properties/Resources.Designer.cs +++ b/Samples/C#/EIDTestApp/Properties/Resources.Designer.cs @@ -1,7 +1,7 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:4.0.30319.18408 +// Runtime Version:4.0.30319.42000 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -19,7 +19,7 @@ namespace EIDTestApp.Properties { // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class Resources { diff --git a/Samples/C#/EIDTestApp/Properties/Settings.Designer.cs b/Samples/C#/EIDTestApp/Properties/Settings.Designer.cs index ec6a5bc..4cc3e69 100755 --- a/Samples/C#/EIDTestApp/Properties/Settings.Designer.cs +++ b/Samples/C#/EIDTestApp/Properties/Settings.Designer.cs @@ -1,7 +1,7 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:4.0.30319.18408 +// Runtime Version:4.0.30319.42000 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -12,7 +12,7 @@ namespace EIDTestApp.Properties { [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "12.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.10.0.0")] internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); diff --git a/Samples/C#/EIDTestApp/app.config b/Samples/C#/EIDTestApp/app.config index fcd0c93..245587d 100755 --- a/Samples/C#/EIDTestApp/app.config +++ b/Samples/C#/EIDTestApp/app.config @@ -1,3 +1,3 @@ - + diff --git a/Swelio.Engine/Swelio.Engine/Manager.cs b/Swelio.Engine/Swelio.Engine/Manager.cs index 14aa115..ebc9b41 100644 --- a/Swelio.Engine/Swelio.Engine/Manager.cs +++ b/Swelio.Engine/Swelio.Engine/Manager.cs @@ -21,6 +21,7 @@ public sealed class Manager : IDisposable private List readers; private bool traceEvents; private bool traceServiceEvents; + private bool traceHardwareEvents; private ReaderCallbackDelegate InternalCallbackDelegate; @@ -30,6 +31,8 @@ public sealed class Manager : IDisposable public Manager() { readers = new List(); + traceHardwareEvents = true; + traceServiceEvents = true; InternalCallbackDelegate = new ReaderCallbackDelegate(EventTracer); } @@ -98,10 +101,23 @@ private void EventTracer(ref int readerNumber, ref int eventCode, IntPtr userCon } break; case CardEvent.ReadersChange: - ReloadReadersList(); - if (ReadersListChanged != null) + int newReadersCount = NativeMethods.GetReadersCount(); + if ( (newReadersCount != readers.Count) && traceHardwareEvents) { - ReadersListChanged(this, EventArgs.Empty); + ReloadReadersList(); + if (ReadersListChanged != null) + { + ReadersListChanged(this, EventArgs.Empty); + } + } + else + { + //Just continue to trace events + if (Active) + { + StopEventsTracing(); + StartEventsTracing(); + } } break; case CardEvent.UnknownEvent: @@ -142,6 +158,16 @@ public bool TraceServiceEvents NativeMethods.IgnoreServiceEvents(!value); } } + + public bool TraceHardwareEvents + { + get { return traceHardwareEvents; } + set + { + traceHardwareEvents = value; + } + } + public event EventHandler CardInserted; public event EventHandler CardRemoved; public event EventHandler ReadersListChanged; diff --git a/Swelio.Engine/Swelio.Engine/NativeMethods.cs b/Swelio.Engine/Swelio.Engine/NativeMethods.cs index b9b3e18..5865819 100644 --- a/Swelio.Engine/Swelio.Engine/NativeMethods.cs +++ b/Swelio.Engine/Swelio.Engine/NativeMethods.cs @@ -2151,7 +2151,7 @@ public static void RemoveCallback() } - public static void IgnoreServiceEvents(bool valie) + public static void IgnoreServiceEvents(bool value) { if (IsWOW64()) {