mirror of
https://github.com/soukoku/ntwain.git
synced 2026-01-26 13:39:47 +08:00
Added identity calls and other ds utilities.
This commit is contained in:
@@ -8,6 +8,8 @@ namespace SampleConsole
|
||||
{
|
||||
internal class Program
|
||||
{
|
||||
// CONSOLE won't work yet until I got a message loop going.
|
||||
|
||||
static void Main(string[] args)
|
||||
{
|
||||
TwainPlatform.PreferLegacyDSM = true;
|
||||
|
||||
103
samples/WinForm32/Form1.Designer.cs
generated
103
samples/WinForm32/Form1.Designer.cs
generated
@@ -28,12 +28,107 @@
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||
this.Text = "Form1";
|
||||
btnSelect = new System.Windows.Forms.Button();
|
||||
label1 = new System.Windows.Forms.Label();
|
||||
lblDefault = new System.Windows.Forms.Label();
|
||||
label2 = new System.Windows.Forms.Label();
|
||||
lblCurrent = new System.Windows.Forms.Label();
|
||||
btnEnumSources = new System.Windows.Forms.Button();
|
||||
listSources = new System.Windows.Forms.ListBox();
|
||||
SuspendLayout();
|
||||
//
|
||||
// btnSelect
|
||||
//
|
||||
btnSelect.Location = new System.Drawing.Point(12, 12);
|
||||
btnSelect.Name = "btnSelect";
|
||||
btnSelect.Size = new System.Drawing.Size(151, 23);
|
||||
btnSelect.TabIndex = 0;
|
||||
btnSelect.Text = "Select default source";
|
||||
btnSelect.UseVisualStyleBackColor = true;
|
||||
btnSelect.Click += btnSelect_Click;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
label1.AutoSize = true;
|
||||
label1.Location = new System.Drawing.Point(12, 51);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new System.Drawing.Size(98, 15);
|
||||
label1.TabIndex = 1;
|
||||
label1.Text = "Default Source = ";
|
||||
//
|
||||
// lblDefault
|
||||
//
|
||||
lblDefault.AutoSize = true;
|
||||
lblDefault.Location = new System.Drawing.Point(115, 51);
|
||||
lblDefault.Name = "lblDefault";
|
||||
lblDefault.Size = new System.Drawing.Size(24, 15);
|
||||
lblDefault.TabIndex = 2;
|
||||
lblDefault.Text = "NA";
|
||||
//
|
||||
// label2
|
||||
//
|
||||
label2.AutoSize = true;
|
||||
label2.Location = new System.Drawing.Point(12, 81);
|
||||
label2.Name = "label2";
|
||||
label2.Size = new System.Drawing.Size(97, 15);
|
||||
label2.TabIndex = 3;
|
||||
label2.Text = "Current Source =";
|
||||
//
|
||||
// lblCurrent
|
||||
//
|
||||
lblCurrent.AutoSize = true;
|
||||
lblCurrent.Location = new System.Drawing.Point(115, 81);
|
||||
lblCurrent.Name = "lblCurrent";
|
||||
lblCurrent.Size = new System.Drawing.Size(24, 15);
|
||||
lblCurrent.TabIndex = 4;
|
||||
lblCurrent.Text = "NA";
|
||||
//
|
||||
// btnEnumSources
|
||||
//
|
||||
btnEnumSources.Location = new System.Drawing.Point(12, 114);
|
||||
btnEnumSources.Name = "btnEnumSources";
|
||||
btnEnumSources.Size = new System.Drawing.Size(151, 23);
|
||||
btnEnumSources.TabIndex = 5;
|
||||
btnEnumSources.Text = "Enumerate sources";
|
||||
btnEnumSources.UseVisualStyleBackColor = true;
|
||||
btnEnumSources.Click += btnEnumSources_Click;
|
||||
//
|
||||
// listSources
|
||||
//
|
||||
listSources.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left;
|
||||
listSources.FormattingEnabled = true;
|
||||
listSources.ItemHeight = 15;
|
||||
listSources.Location = new System.Drawing.Point(12, 143);
|
||||
listSources.Name = "listSources";
|
||||
listSources.Size = new System.Drawing.Size(279, 289);
|
||||
listSources.TabIndex = 6;
|
||||
//
|
||||
// Form1
|
||||
//
|
||||
AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
ClientSize = new System.Drawing.Size(800, 450);
|
||||
Controls.Add(listSources);
|
||||
Controls.Add(btnEnumSources);
|
||||
Controls.Add(lblCurrent);
|
||||
Controls.Add(label2);
|
||||
Controls.Add(lblDefault);
|
||||
Controls.Add(label1);
|
||||
Controls.Add(btnSelect);
|
||||
Name = "Form1";
|
||||
Text = "TWAIN Test";
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Button btnSelect;
|
||||
private System.Windows.Forms.Label label1;
|
||||
private System.Windows.Forms.Label lblDefault;
|
||||
private System.Windows.Forms.Label label2;
|
||||
private System.Windows.Forms.Label lblCurrent;
|
||||
private System.Windows.Forms.Button btnEnumSources;
|
||||
private System.Windows.Forms.ListBox listSources;
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,64 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<root>
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
|
||||
Reference in New Issue
Block a user