-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInitializeConnection.cs
More file actions
63 lines (56 loc) · 1.66 KB
/
Copy pathInitializeConnection.cs
File metadata and controls
63 lines (56 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using PCSC;
using PCSC.Exceptions;
using PCSC.Utils;
namespace CardPersonalizationApp
{
public partial class InitializeConnection : Form
{
public SCardContext? hContext;
public SCardReader? hReader;
public string[]? szReaders;
public static string? selectedReader { get; set; }
public InitializeConnection()
{
InitializeComponent();
}
private void BtnInit_Click(object sender, EventArgs e)
{
if (CbReader.Items.Count > 0)
{
return;
}
hContext = new SCardContext();
hContext.Establish(SCardScope.System);
szReaders = hContext.GetReaders();
if (szReaders.Length <= 0)
throw new PCSCException(
SCardError.NoReadersAvailable,
"Could not find any Smartcard reader."
);
CbReader.Items.AddRange(szReaders);
CbReader.SelectedIndex = 0;
}
private void BtnConfirm_Click(object sender, EventArgs e)
{
if (CbReader.SelectedIndex == -1)
{
MessageBox.Show("Please select a reader");
return;
}
this.Hide();
CardPersonalizationApp form = new();
form.Show();
form.FormClosed += (s, args) => this.Show();
selectedReader = CbReader.Text;
}
}
}