Skip to content
This repository has been archived by the owner on Nov 17, 2020. It is now read-only.

Added support for LightPath #21

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/TestVb/MainForm.vb
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ Public Class MainForm
settings.ShowTwainUI = useUICheckBox.Checked
settings.ShowProgressIndicatorUI = showProgressIndicatorUICheckBox.Checked
settings.UseDuplex = useDuplexCheckBox.Checked
settings.UseFilmScanner = False
settings.Resolution = If(blackAndWhiteCheckBox.Checked, ResolutionSettings.Fax, ResolutionSettings.ColourPhotocopier)
settings.Area = If(Not checkBoxArea.Checked, Nothing, areaSettings)
settings.ShouldTransferAllPages = True
Expand Down
56 changes: 46 additions & 10 deletions src/TwainDotNet/DataSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,23 @@ public bool SupportsDuplex
}
}

public bool SupportsFilmScanner
{
get
{
try
{
var cap = new Capability(Capabilities.Lightpath, TwainType.Int16, _applicationId, SourceId);
// return ((Lightpath)cap.GetBasicValue().Int16Value) != Lightpath.Transmissive;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was there a problem using this check?

return true;
}
catch
{
return false;
}
}
}

public void NegotiateColour(ScanSettings scanSettings)
{
try
Expand Down Expand Up @@ -203,6 +220,27 @@ public void NegotiateDuplex(ScanSettings scanSettings)
// Do nothing if the data source does not support the requested capability
}
}
public void NegotiateLightPath(ScanSettings scanSettings)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New line here please.

{
try
{
if (scanSettings.UseFilmScanner.HasValue && SupportsFilmScanner)
{
if (scanSettings.UseFilmScanner.Value == true)
{
Capability.SetBasicCapability(Capabilities.Lightpath, (ushort)Lightpath.Transmissive, TwainType.UInt16, _applicationId, SourceId);
}
else
{
Capability.SetBasicCapability(Capabilities.Lightpath, (ushort)Lightpath.Reflective, TwainType.UInt16, _applicationId, SourceId);
}
}
}
catch
{
// Do nothing if the data source does not support the requested capability
}
}

public void NegotiateOrientation(ScanSettings scanSettings)
{
Expand Down Expand Up @@ -310,6 +348,7 @@ public bool Open(ScanSettings settings)
NegotiateTransferCount(settings);
NegotiateFeeder(settings);
NegotiateDuplex(settings);
NegotiateLightPath(settings);

if (settings.UseDocumentFeeder == true &&
settings.Page != null)
Expand Down Expand Up @@ -561,16 +600,13 @@ public void Close()
Message.DisableDS,
userInterface);

if (result != TwainResult.Failure)
{
result = Twain32Native.DsmIdentity(
_applicationId,
IntPtr.Zero,
DataGroup.Control,
DataArgumentType.Identity,
Message.CloseDS,
SourceId);
}
result = Twain32Native.DsmIdentity(
_applicationId,
IntPtr.Zero,
DataGroup.Control,
DataArgumentType.Identity,
Message.CloseDS,
SourceId);
}
}
}
Expand Down
18 changes: 18 additions & 0 deletions src/TwainDotNet/ScanSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,24 @@ public bool? UseDocumentFeeder
}
}

bool? _useFilmScanner;

/// <summary>
/// Indicates if the transmitted light film SCanner should be used as the light source.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'SCanner' -> 'scanner'.

/// </summary>
public bool? UseFilmScanner
{
get { return _useFilmScanner; }
set
{
if (value != _useFilmScanner)
{
_useFilmScanner = value;
OnPropertyChanged("UseFilmScanner");
}
}
}

bool? _useAutoFeeder;

/// <summary>
Expand Down
1 change: 1 addition & 0 deletions src/TwainDotNet/TwainDotNet.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
<Compile Include="TwainNative\CapabilityArrayValue.cs" />
<Compile Include="TwainNative\CapabilityEnumValue.cs" />
<Compile Include="TwainNative\CapabilityOneValue.cs" />
<Compile Include="TwainNative\Lightpath.cs" />
<Compile Include="TwainNative\Command.cs" />
<Compile Include="TwainNative\Compression.cs" />
<Compile Include="TwainNative\ConditionCode.cs" />
Expand Down
16 changes: 16 additions & 0 deletions src/TwainDotNet/TwainNative/Lightpath.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TwainDotNet.TwainNative
{
/// <summary>
/// Twain spec ICAP_Lightpath values.
/// </summary>
public enum Lightpath : short
{
Reflective = 0,
Transmissive = 1
}
}