public static extern ReturnCode DsmWinNew( [In, Out] TWIdentity origin, [In, Out] TWIdentity destination, DataGroups dg, DataArgumentType dat, Message msg, [In, Out] TWSetupFileXfer data);
private void Session_TransferReady(object sender, TransferReadyEventArgs e) { var transferMechanism = Session.CurrentSource.Capabilities.ICapXferMech.GetCurrent(); if (transferMechanism == XferMech.File) { var formats = Session.CurrentSource.Capabilities.ICapImageFileFormat.GetValues(); var scannerImageFormat = formats.Contains(FileFormat.Tiff) ? FileFormat.Tiff : FileFormat.Bmp; var fileSetup = new TWSetupFileXfer { Format = scannerImageFormat, FileName = GetUniqueName(Path.GetTempPath(), "twain-test", "." + scannerImageFormat) }; } }
void Session_TransferReady(object sender, TransferReadyEventArgs e) { var mech = session.CurrentSource.Capabilities.ICapXferMech.GetCurrent(); if (mech == XferMech.File) { var formats = session.CurrentSource.Capabilities.ICapImageFileFormat.GetValues(); var wantFormat = formats.Contains(FileFormat.Tiff) ? FileFormat.Tiff : FileFormat.Bmp; var fileSetup = new TWSetupFileXfer { Format = wantFormat, FileName = GetUniqueName(Path.GetTempPath(), "twain-test", "." + wantFormat) }; session.CurrentSource.DGControl.SetupFileXfer.Set(fileSetup); } }
public static ReturnCode DsmEntry( TWIdentity origin, TWIdentity destination, Message msg, TWSetupFileXfer data) { if (PlatformInfo.Current.IsWindows) { if (PlatformInfo.Current.UseNewWinDSM) { return(NativeMethods.DsmWinNew(origin, destination, DataGroups.Control, DataArgumentType.SetupFileXfer, msg, data)); } else { return(NativeMethods.DsmWinOld(origin, destination, DataGroups.Control, DataArgumentType.SetupFileXfer, msg, data)); } } else if (PlatformInfo.Current.IsLinux) { return(NativeMethods.DsmLinux(origin, destination, DataGroups.Control, DataArgumentType.SetupFileXfer, msg, data)); } throw new PlatformNotSupportedException(); }
public ReturnCode Set(TWSetupFileXfer setupFileXfer) { Session.VerifyState(4, 6, DataGroups.Control, DataArgumentType.SetupFileXfer, Message.Set); return(Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, Message.Set, setupFileXfer)); }
public ReturnCode GetDefault(out TWSetupFileXfer setupFileXfer) { Session.VerifyState(4, 6, DataGroups.Control, DataArgumentType.SetupFileXfer, Message.GetDefault); setupFileXfer = new TWSetupFileXfer(); return(Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, Message.GetDefault, setupFileXfer)); }
public static string ChangeExtensionByFormat(this TWSetupFileXfer fileInfo, string currentFilePath) { string finalFile = null; switch (fileInfo.Format) { case FileFormat.Bmp: finalFile = Path.ChangeExtension(currentFilePath, ".bmp"); break; case FileFormat.Dejavu: finalFile = Path.ChangeExtension(currentFilePath, ".dejavu"); break; case FileFormat.Exif: finalFile = Path.ChangeExtension(currentFilePath, ".exit"); break; case FileFormat.Fpx: finalFile = Path.ChangeExtension(currentFilePath, ".fpx"); break; case FileFormat.Jfif: finalFile = Path.ChangeExtension(currentFilePath, ".jpg"); break; case FileFormat.Jp2: finalFile = Path.ChangeExtension(currentFilePath, ".jp2"); break; case FileFormat.Jpx: finalFile = Path.ChangeExtension(currentFilePath, ".jpx"); break; case FileFormat.Pdf: case FileFormat.PdfA: case FileFormat.PdfA2: finalFile = Path.ChangeExtension(currentFilePath, ".pdf"); break; case FileFormat.Pict: finalFile = Path.ChangeExtension(currentFilePath, ".pict"); break; case FileFormat.Png: finalFile = Path.ChangeExtension(currentFilePath, ".png"); break; case FileFormat.Spiff: finalFile = Path.ChangeExtension(currentFilePath, ".spiff"); break; case FileFormat.Tiff: case FileFormat.TiffMulti: finalFile = Path.ChangeExtension(currentFilePath, ".tif"); break; case FileFormat.Xbm: finalFile = Path.ChangeExtension(currentFilePath, ".xbm"); break; default: finalFile = Path.ChangeExtension(currentFilePath, ".unknown"); break; } return(finalFile); }