Added ToStrings for some types

This commit is contained in:
Eugene Wang
2021-04-21 13:03:41 -04:00
parent 20216b52a7
commit 192a2c0219
2 changed files with 69 additions and 11 deletions

View File

@@ -115,7 +115,7 @@ namespace TWAINWorkingGroup
/// Used for strings that go up to 32-bytes... /// Used for strings that go up to 32-bytes...
/// </summary> /// </summary>
[StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Ansi)] [StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Ansi)]
public struct TW_STR32 public partial struct TW_STR32
{ {
/// <summary> /// <summary>
/// We're stuck with this, because marshalling with packed alignment /// We're stuck with this, because marshalling with packed alignment
@@ -280,7 +280,7 @@ namespace TWAINWorkingGroup
/// Used for strings that go up to 64-bytes... /// Used for strings that go up to 64-bytes...
/// </summary> /// </summary>
[StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Ansi)] [StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Ansi)]
public struct TW_STR64 public partial struct TW_STR64
{ {
/// <summary> /// <summary>
/// We're stuck with this, because marshalling with packed alignment /// We're stuck with this, because marshalling with packed alignment
@@ -462,7 +462,7 @@ namespace TWAINWorkingGroup
/// Used for strings that go up to 128-bytes... /// Used for strings that go up to 128-bytes...
/// </summary> /// </summary>
[StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Ansi)] [StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Ansi)]
public struct TW_STR128 public partial struct TW_STR128
{ {
/// <summary> /// <summary>
/// We're stuck with this, because marshalling with packed alignment /// We're stuck with this, because marshalling with packed alignment
@@ -694,7 +694,7 @@ namespace TWAINWorkingGroup
/// Used for strings that go up to 256-bytes... /// Used for strings that go up to 256-bytes...
/// </summary> /// </summary>
[StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Ansi)] [StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Ansi)]
public struct TW_STR255 public partial struct TW_STR255
{ {
/// <summary> /// <summary>
/// We're stuck with this, because marshalling with packed alignment /// We're stuck with this, because marshalling with packed alignment
@@ -1030,7 +1030,7 @@ namespace TWAINWorkingGroup
/// Fixed point structure type. /// Fixed point structure type.
/// </summary> /// </summary>
[StructLayout(LayoutKind.Sequential, Pack = 2)] [StructLayout(LayoutKind.Sequential, Pack = 2)]
public struct TW_FIX32 public partial struct TW_FIX32
{ {
public short Whole; public short Whole;
public ushort Frac; public ushort Frac;
@@ -1040,7 +1040,7 @@ namespace TWAINWorkingGroup
/// Defines a frame rectangle in ICAP_UNITS coordinates. /// Defines a frame rectangle in ICAP_UNITS coordinates.
/// </summary> /// </summary>
[StructLayout(LayoutKind.Sequential, Pack = 2)] [StructLayout(LayoutKind.Sequential, Pack = 2)]
public struct TW_FRAME public partial struct TW_FRAME
{ {
public TW_FIX32 Left; public TW_FIX32 Left;
public TW_FIX32 Top; public TW_FIX32 Top;
@@ -2112,7 +2112,7 @@ namespace TWAINWorkingGroup
/// A general way to describe the version of software that is running. /// A general way to describe the version of software that is running.
/// </summary> /// </summary>
[StructLayout(LayoutKind.Sequential, Pack = 2, CharSet = CharSet.Ansi)] [StructLayout(LayoutKind.Sequential, Pack = 2, CharSet = CharSet.Ansi)]
public struct TW_VERSION public partial struct TW_VERSION
{ {
public ushort MajorNum; public ushort MajorNum;
public ushort MinorNum; public ushort MinorNum;
@@ -2131,7 +2131,7 @@ namespace TWAINWorkingGroup
/// situations... /// situations...
/// </summary> /// </summary>
[StructLayout(LayoutKind.Sequential, Pack = 2, CharSet = CharSet.Ansi)] [StructLayout(LayoutKind.Sequential, Pack = 2, CharSet = CharSet.Ansi)]
public struct TW_IDENTITY public partial struct TW_IDENTITY
{ {
public ulong Id; public ulong Id;
public TW_VERSION Version; public TW_VERSION Version;
@@ -2143,7 +2143,7 @@ namespace TWAINWorkingGroup
public TW_STR32 ProductName; public TW_STR32 ProductName;
} }
[StructLayout(LayoutKind.Sequential, Pack = 2, CharSet = CharSet.Ansi)] [StructLayout(LayoutKind.Sequential, Pack = 2, CharSet = CharSet.Ansi)]
public struct TW_IDENTITY_LEGACY public partial struct TW_IDENTITY_LEGACY
{ {
public uint Id; public uint Id;
public TW_VERSION Version; public TW_VERSION Version;
@@ -2156,7 +2156,7 @@ namespace TWAINWorkingGroup
private UInt64 Padding; // accounts for Id and SupportedGroups private UInt64 Padding; // accounts for Id and SupportedGroups
} }
[StructLayout(LayoutKind.Sequential, Pack = 2, CharSet = CharSet.Ansi)] [StructLayout(LayoutKind.Sequential, Pack = 2, CharSet = CharSet.Ansi)]
public struct TW_IDENTITY_LINUX64 public partial struct TW_IDENTITY_LINUX64
{ {
public ulong Id; public ulong Id;
public TW_VERSION Version; public TW_VERSION Version;
@@ -2168,7 +2168,7 @@ namespace TWAINWorkingGroup
public TW_STR32 ProductName; public TW_STR32 ProductName;
} }
[StructLayout(LayoutKind.Sequential, Pack = 2, CharSet = CharSet.Ansi)] [StructLayout(LayoutKind.Sequential, Pack = 2, CharSet = CharSet.Ansi)]
public struct TW_IDENTITY_MACOSX public partial struct TW_IDENTITY_MACOSX
{ {
public uint Id; public uint Id;
public TW_VERSION Version; public TW_VERSION Version;

View File

@@ -0,0 +1,58 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace TWAINWorkingGroup
{
// contains my additions
partial struct TW_STR32
{
public override string ToString()
{
return Get();
}
}
partial struct TW_STR64
{
public override string ToString()
{
return Get();
}
}
partial struct TW_STR128
{
public override string ToString()
{
return Get();
}
}
partial struct TW_STR255
{
public override string ToString()
{
return Get();
}
}
partial struct TW_IDENTITY
{
public override string ToString()
{
return $"{Manufacturer} - {ProductName} {Version} (TWAIN {ProtocolMajor}.{ProtocolMinor})";
}
}
partial struct TW_VERSION
{
public override string ToString()
{
return $"{MajorNum}.{MinorNum}";
}
}
}