Uses resx string and added updated some properties.

This commit is contained in:
soukoku
2014-04-17 07:11:39 -04:00
parent a91d5aa4f2
commit b6ee9dfed9
12 changed files with 349 additions and 188 deletions

View File

@@ -1,4 +1,5 @@
using NTwain.Values;
using NTwain.Properties;
using NTwain.Values;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -28,7 +29,7 @@ namespace NTwain.Data
public static CapReadOut ReadValue(TWCapability capability)
{
if (capability == null) { throw new ArgumentNullException("capability"); }
if (capability.Container == IntPtr.Zero) { throw new ArgumentException("Capability contains no data.", "capability"); }
if (capability.Container == IntPtr.Zero) { throw new ArgumentException(Resources.CapHasNoData, "capability"); }
IntPtr baseAddr = IntPtr.Zero;
try
@@ -57,7 +58,7 @@ namespace NTwain.Data
ContainerType = capability.ContainerType,
}.ReadRangeValue(baseAddr);
default:
throw new ArgumentException(string.Format("Capability has invalid container type {0}.", capability.ContainerType), "capability");
throw new ArgumentException(string.Format(Resources.CapHasBadContainer, capability.ContainerType), "capability");
}
}
finally

View File

@@ -688,10 +688,10 @@ namespace NTwain.Data
void SetOneValue(TWOneValue value)
{
if (value == null) { throw new ArgumentNullException("value"); }
if (ContainerType != Values.ContainerType.OneValue) { throw new ArgumentException(Resources.BadContainerType, "value"); }
ContainerType = Values.ContainerType.OneValue;
// since one value can only house UInt32 we will not allow type size > 4
if (TypeReader.GetItemTypeSize(value.ItemType) > 4) { throw new ArgumentException("Invalid one value type"); }
if (TypeReader.GetItemTypeSize(value.ItemType) > 4) { throw new ArgumentException(string.Format(Resources.BadValueType, "TWOneValue")); }
_hContainer = MemoryManager.Instance.Allocate((uint)Marshal.SizeOf(value));
if (_hContainer != IntPtr.Zero)
@@ -704,7 +704,7 @@ namespace NTwain.Data
void SetEnumValue(TWEnumeration value)
{
if (value == null) { throw new ArgumentNullException("value"); }
if (ContainerType != Values.ContainerType.Enum) { throw new ArgumentException(Resources.BadContainerType, "value"); }
ContainerType = Values.ContainerType.Enum;
Int32 valueSize = value.ItemOffset + value.ItemList.Length * TypeReader.GetItemTypeSize(value.ItemType);
@@ -730,10 +730,10 @@ namespace NTwain.Data
void SetRangeValue(TWRange value)
{
if (value == null) { throw new ArgumentNullException("value"); }
if (ContainerType != Values.ContainerType.Range) { throw new ArgumentException(Resources.BadContainerType, "value"); }
ContainerType = Values.ContainerType.Range;
// since range value can only house UInt32 we will not allow type size > 4
if (TypeReader.GetItemTypeSize(value.ItemType) > 4) { throw new ArgumentException("Invalid range value type"); }
if (TypeReader.GetItemTypeSize(value.ItemType) > 4) { throw new ArgumentException(string.Format(Resources.BadValueType, "TWRange")); }
_hContainer = MemoryManager.Instance.Allocate((uint)Marshal.SizeOf(value));
if (_hContainer != IntPtr.Zero)
@@ -1297,7 +1297,7 @@ namespace NTwain.Data
/// <summary>
/// Tag identifying an information.
/// </summary>
public ushort InfoID { get { return _infoID; } }
public ExtendedImageInfo InfoID { get { return (ExtendedImageInfo)_infoID; } }
/// <summary>
/// Item data type.
/// </summary>