Added identity calls and other ds utilities.

This commit is contained in:
Eugene Wang
2023-04-01 19:15:41 -04:00
parent ca298f1f77
commit a779ee6b0e
11 changed files with 286 additions and 120 deletions

View File

@@ -20,6 +20,18 @@ namespace WinForm32
twain = new TwainSession(Assembly.GetExecutingAssembly().Location);
twain.StateChanged += Twain_StateChanged;
twain.DefaultSourceChanged += Twain_DefaultSourceChanged;
twain.CurrentSourceChanged += Twain_CurrentSourceChanged;
}
private void Twain_CurrentSourceChanged(TwainSession arg1, TW_IDENTITY_LEGACY ds)
{
lblCurrent.Text = ds.ProductName;
}
private void Twain_DefaultSourceChanged(TwainSession arg1, TW_IDENTITY_LEGACY ds)
{
lblDefault.Text = ds.ProductName;
}
private static void Twain_StateChanged(TwainSession session, STATE state)
@@ -35,7 +47,6 @@ namespace WinForm32
var hwnd = this.Handle;
var rc = twain.DGControl.Parent.OpenDSM(ref hwnd);
Debug.WriteLine($"OpenDSM={rc}");
}
protected override void OnClosing(CancelEventArgs e)
@@ -45,5 +56,19 @@ namespace WinForm32
base.OnClosing(e);
}
private void btnSelect_Click(object sender, EventArgs e)
{
twain.DGControl.Identity.UserSelect();
}
private void btnEnumSources_Click(object sender, EventArgs e)
{
listSources.Items.Clear();
foreach (var ds in twain.GetSources())
{
listSources.Items.Add(ds);
}
}
}
}