public static extern ReturnCode DsmLinux( [In, Out] TWIdentity origin, [In, Out] TWIdentity destination, DataGroups dg, DataArgumentType dat, Message msg, [In, Out] TWEntryPoint data);
public static extern ReturnCode DsmLinux64( [In, Out] TW_IDENTITY origin, [In, Out] TW_IDENTITY destination, DataGroups dg, DataArgumentType dat, Message msg, ref TW_EVENT data);
public static extern ReturnCode DsmMac64( [In, Out] TW_IDENTITY origin, IntPtr zero, DataGroups dg, DataArgumentType dat, Message msg, [In, Out] TW_IDENTITY data);
public static extern ReturnCode DsmMac64( [In, Out] TW_IDENTITY origin, [In, Out] TW_IDENTITY destination, DataGroups dg, DataArgumentType dat, Message msg, ref TW_FILESYSTEM data);
ReturnCode HandleCallback(TWIdentity origin, TWIdentity destination, DataGroups dg, DataArgumentType dat, Message msg, IntPtr data) { if (origin != null && CurrentSource != null && origin.Id == CurrentSource.Identity.Id && _state >= 5) { PlatformInfo.Current.Log.Debug("Thread {0}: CallbackHandler at state {1} with MSG={2}.", Thread.CurrentThread.ManagedThreadId, State, msg); // spec says we must handle this on the thread that enabled the DS. // by using the internal dispatcher this will be the case. // In any event the trick to get this thing working is to return from the callback first // before trying to process the msg or there will be unpredictable errors. // changed to sync invoke instead of begininvoke for hp scanjet. if (origin.ProductName.IndexOf("scanjet", StringComparison.OrdinalIgnoreCase) > -1) { _msgLoopHook?.Invoke(() => { HandleSourceMsg(msg); }); } else { _msgLoopHook?.BeginInvoke(() => { HandleSourceMsg(msg); }); } return(ReturnCode.Success); } return(ReturnCode.Failure); }
public static Result <SqlSetup> FromDataGroups(DataGroups dataGroups, string adapterName) { var connectionsGroup = dataGroups.ConnectionsGroup; var commandsGroup = dataGroups.CommandsGroup; var adaptersGroup = dataGroups.AdaptersGroup; return (from adapterGraph in adaptersGroup.RequireGroup(adapterName) from connectionName in adapterGraph.RequireValue("connection") from connectionGroup in connectionsGroup.RequireGroup(connectionName) let commandName = adaptersGroup.GetValue("command").DefaultTo(() => adapterName) from commandGraph in commandsGroup.RequireGroup(commandName) let connection = new Connection(connectionGroup) from connectionString in SqlConnectionString.FromConnection(connection) from command in Command.FromGroup(commandGraph) from parameters in Data.Parameters.Parameters.FromGroup(adapterGraph.GetGroup("parameters")) from fields in Data.Fields.Fields.FromGroup(adapterGraph.GetGroup("fields")) select new SqlSetup(connectionsGroup.GetGroup("attributes")) { CommandText = command.Text, CommandTimeout = command.CommandTimeout, ConnectionString = connectionString, Parameters = parameters, Fields = fields }); }
public static extern ReturnCode DsmLinux( [In, Out] TWIdentity origin, IntPtr zero, DataGroups dg, DataArgumentType dat, Message msg, [In, Out] TWIdentity data);
public static extern ReturnCode DsmLinux32( [In, Out] TW_IDENTITY origin, IntPtr zero, DataGroups dg, DataArgumentType dat, Message msg, [In, Out] TW_ENTRYPOINT data);
public static extern ReturnCode DsmLinux32( [In, Out] TW_IDENTITY origin, [In, Out] TW_IDENTITY destination, DataGroups dg, DataArgumentType dat, Message msg, ref TW_JPEGCOMPRESSION data);
protected Adapters(DataGroups dataGroups, StringHash <Adapter <T> > adapters, StringSet validAdapters, Predicate <string> isValidAdapterName) { this.dataGroups = dataGroups; this.adapters = new StringHash <Adapter <T> >(true, adapters); this.validAdapters = new StringSet(true, validAdapters); this.isValidAdapterName = isValidAdapterName; }
/// <summary> /// Direct DSM_Entry call with full arguments for custom values. /// </summary> /// <param name="group">The group.</param> /// <param name="dat">The dat.</param> /// <param name="message">The message.</param> /// <param name="data">The data.</param> /// <returns></returns> public ReturnCode DsmEntry( DataGroups group, DataArgumentType dat, Message message, IntPtr data) { _session.VerifyState(3, 7, group, dat, message); return(Dsm.DsmEntry(_session.AppId, _session.CurrentSource.Identity, group, dat, message, data)); }
/// <summary> /// Initializes a new instance of the <see cref="TwainStateException"/> class. /// </summary> /// <param name="currentState">The actual state number.</param> /// <param name="minStateExpected">The minimum state allowed.</param> /// <param name="maxStateExpected">The maximum state allowed.</param> /// <param name="dataGroup">The data group used.</param> /// <param name="argumentType">The data argument type used.</param> /// <param name="twainMessage">The twain message used.</param> /// <param name="message">The message.</param> public TwainStateException(int currentState, int minStateExpected, int maxStateExpected, DataGroups dataGroup, DataArgumentType argumentType, Message twainMessage, string message) : base(default(ReturnCode), message) { ActualState = currentState; MinStateExpected = minStateExpected; MaxStateExpected = maxStateExpected; DataGroup = dataGroup; ArgumentType = argumentType; TwainMessage = twainMessage; }
ReturnCode Handle32BitCallback(TW_IDENTITY origin, TW_IDENTITY destination, DataGroups dg, DataArgumentType dat, Message msg, IntPtr data) { // from the docs this needs to return Success // before handling the msg thus BeginInvoke is used. Debug.WriteLine($"Thread {Thread.CurrentThread.ManagedThreadId}: {nameof(Handle32BitCallback)}({dg}, {dat}, {msg}, {data})"); InternalBeginInvoke(() => { Debug.WriteLine($"Thread {Thread.CurrentThread.ManagedThreadId}: in BeginInvoke {nameof(Handle32BitCallback)}({dg}, {dat}, {msg}, {data})"); HandleSourceMsg(msg); }); Debug.WriteLine($"Thread {Thread.CurrentThread.ManagedThreadId}: after BeginInvoke {nameof(Handle32BitCallback)}({dg}, {dat}, {msg}, {data})"); return(ReturnCode.Success); }
public Adapters(DataGroups dataGroups, params string[] validAdapterNames) { this.dataGroups = dataGroups; adapters = new StringHash <Adapter <T> >(true); validAdapters = new StringSet(true); if (validAdapterNames.Length == 0) { isValidAdapterName = _ => true; } else { isValidAdapterName = adapterName => adapterName.IsNotEmpty() && validAdapters.Contains(adapterName); validAdapters.AddRange(validAdapterNames); } }
///// <summary> ///// Specifies which DSM to use. ///// </summary> ///// <param name="legacyDsm"></param> ///// <returns></returns> //public TwainConfigurationBuilder UseDsm(bool legacyDsm = false) //{ // if (legacyDsm) // { // if (_64bit) throw new InvalidOperationException("Cannot use legacy DSM under 64bit."); // } // _legacy = legacyDsm; // return this; //} /// <summary> /// Specifies what kind of data the app can to handle from TWAIN devices. /// </summary> /// <param name="image"></param> /// <param name="audio"></param> /// <returns></returns> public TwainConfigBuilder HandlesDataType(bool image = true, bool audio = false) { DataGroups dg = DataGroups.None; if (image) { dg |= DataGroups.Image; } if (audio) { dg |= DataGroups.Audio; } if (dg == DataGroups.None) { throw new InvalidOperationException(MsgText.NoDataTypesSpecified); } _dg = dg; return(this); }
/// <summary> /// Filter Samples /// </summary> /// <param name="samples"></param> /// <returns></returns> private List <SampleData> FilterSamples(List <SampleData> samples) { var filtered = new List <SampleData>(); List <FilteredDataItem> dataItems = null; lock (_lock) dataItems = filteredDataItems.ToList(); if (dataItems != null) { // Archive foreach (var dataGroup in DataGroups.FindAll(o => o.CaptureMode == CaptureMode.ARCHIVE)) { var newFiltered = FilterSamples(samples, dataGroup); foreach (var sample in newFiltered) { if (!filtered.Exists(o => o.DeviceId == sample.DeviceId && o.Id == sample.Id)) { sample.SetStreamDataType(StreamDataType.ARCHIVED_SAMPLE); filtered.Add(sample); } } } // Current foreach (var dataGroup in DataGroups.FindAll(o => o.CaptureMode == CaptureMode.CURRENT)) { var newFiltered = FilterSamples(samples, dataGroup); foreach (var sample in newFiltered) { if (!filtered.Exists(o => o.DeviceId == sample.DeviceId && o.Id == sample.Id)) { sample.SetStreamDataType(StreamDataType.CURRENT_SAMPLE); filtered.Add(sample); } } } } return(filtered); }
public void Constructor_Sets_Correct_Properties() { // just some non-default values to test int state = 3; int minState = 4; int maxState = 5; DataGroups dataGroup = DataGroups.Control; DataArgumentType argumentType = DataArgumentType.AudioNativeXfer; Message twainMessage = Message.Copy; string message = "THIS IS A TEST."; TwainStateException target = new TwainStateException(state, minState, maxState, dataGroup, argumentType, twainMessage, message); Assert.AreEqual(state, target.ActualState, "State mismatch."); Assert.AreEqual(minState, target.MinStateExpected, "Minimum mismatch."); Assert.AreEqual(maxState, target.MaxStateExpected, "Maximum mismatch."); Assert.AreEqual(dataGroup, target.DataGroup, "DataGroup mismatch."); Assert.AreEqual(argumentType, target.ArgumentType, "ArgumentType mismatch."); Assert.AreEqual(twainMessage, target.TwainMessage, "TwainMessage mismatch."); Assert.AreEqual(message, target.Message, "Message mismatch."); }
public static void LoadSavedData(DataGroups dataGroup) { // Supporting.Log("Loading Saved Data"); switch (dataGroup) { case DataGroups.Sound: { float musicVolume = PlayerPrefs.GetFloat(MUSIC_VOLUME_KEY, 0); bool musicMuted = PlayerPrefs.GetInt(MUSIC_MUTED_KEY, 0) >= 1 ? true : false; // adjust Audio SoundController.instance.SetMusicVolume(musicVolume); SoundController.instance.SetMusicVolume(!musicMuted); // adjust Canvas elements CanvasController.instance.ShowMusicVolume(musicVolume); CanvasController.instance.ToggleMusicVolume(!musicMuted); float SFXVolume = PlayerPrefs.GetFloat(SFX_VOLUME_KEY, 0); bool SFXMuted = PlayerPrefs.GetInt(SFX_MUTED_KEY, 0) >= 1 ? true : false; // adjust Audio SoundController.instance.SetSFXVolume(SFXVolume); SoundController.instance.SetSFXVolume(!SFXMuted); // adjust Canvas elements CanvasController.instance.ShowSFXVolume(SFXVolume); CanvasController.instance.ToggleSFXVolume(!SFXMuted); break; } case DataGroups.Score: { GameController.instance.highScore = PlayerPrefs.GetInt(HIGHSCORE_KEY, 0); break; } default: { break; } } }
ReturnCode DoIt(Message msg, ref DataGroups value) { if (Is32Bit) { if (IsWin) { return(NativeMethods.DsmWin32(Session.Config.App32, Session.CurrentSource.Identity32, DataGroups.Control, DataArgumentType.XferGroup, msg, ref value)); } if (IsLinux) { return(NativeMethods.DsmLinux32(Session.Config.App32, Session.CurrentSource.Identity32, DataGroups.Control, DataArgumentType.XferGroup, msg, ref value)); } if (IsMac) { return(NativeMethods.DsmMac32(Session.Config.App32, Session.CurrentSource.Identity32, DataGroups.Control, DataArgumentType.XferGroup, msg, ref value)); } } if (IsWin) { return(NativeMethods.DsmWin64(Session.Config.App32, Session.CurrentSource.Identity32, DataGroups.Control, DataArgumentType.XferGroup, msg, ref value)); } if (IsLinux) { return(NativeMethods.DsmLinux64(Session.Config.App32, Session.CurrentSource.Identity32, DataGroups.Control, DataArgumentType.XferGroup, msg, ref value)); } if (IsMac) { return(NativeMethods.DsmMac64(Session.Config.App32, Session.CurrentSource.Identity32, DataGroups.Control, DataArgumentType.XferGroup, msg, ref value)); } return(ReturnCode.Failure); }
public byte[] GetBytes() { var array = new byte[GetSize()]; int index = 0; // IDBLOCK. IDBlock.Write(array, ref index); int hdBlockIndex = index; // HDBLOCK. HDBlock.Write(array, ref index); HDBlock.WriteFileComment(array, ref index, hdBlockIndex); HDBlock.WriteProgramBlock(array, ref index, hdBlockIndex); HDBlock.WriteFirstDataGroupLink(array, index, hdBlockIndex); // DGBLOCKs. DataGroups.Write(array, ref index); return(array); }
private static extern ReturnCodes DataSourceStatus( [In, Out] Identity origin, [In] Identity destination, DataGroups dataGroup, DataAttributeTypes dataAttributeType, Messages message, [In, Out] Status status);
private static extern ReturnCodes DataSourceUserInterface( [In, Out] Identity origin, [In, Out] Identity destination, DataGroups dataGroup, DataAttributeTypes dataAttributeType, Messages message, UserInterface userInterface);
private static extern ReturnCodes DataSourceManagerStatus( [In, Out] Identity origin, IntPtr zeroPointer, DataGroups dataGroup, DataAttributeTypes dataAttributeType, Messages message, [In, Out] Status statusReply);
private static extern ReturnCodes DataSourcePendingXfer( [In, Out] Identity origin, [In] Identity destination, DataGroups dataGroup, DataAttributeTypes dataAttributeType, Messages message, [In, Out] PendingXfersInterop pendingXfer);
/// <summary> /// Initializes a new instance of the <see cref="TwainSession"/> class. /// </summary> /// <param name="supportedGroups">The supported groups.</param> public TwainSession(DataGroups supportedGroups) : this(TWIdentity.CreateFromAssembly(supportedGroups, Assembly.GetEntryAssembly())) { }
private static extern ReturnCodes DataSourceManagerParent( [In, Out] Identity origin, IntPtr zeroPointer, DataGroups dataGroup, DataAttributeTypes dataAttributeType, Messages message, ref IntPtr handle);
private static extern ReturnCodes DataSourceEvent( [In, Out] Identity origin, [In, Out] Identity destination, DataGroups dataGroup, DataAttributeTypes dataAttributeType, Messages message, ref EventInterop eventReply);
private static extern ReturnCodes DataSourceImageInfo( [In, Out] Identity origin, [In] Identity destination, DataGroups dataGroup, DataAttributeTypes dataAttributeType, Messages message, [In, Out] ImageInfoInterop imageInfo);
/// <summary> /// Verifies the session is within the specified state range (inclusive). Throws /// <see cref="TwainStateException" /> if violated. /// </summary> /// <param name="session">The session.</param> /// <param name="allowedMinimum">The allowed minimum.</param> /// <param name="allowedMaximum">The allowed maximum.</param> /// <param name="group">The triplet data group.</param> /// <param name="dataArgumentType">The triplet data argument type.</param> /// <param name="message">The triplet message.</param> /// <exception cref="TwainStateException"></exception> public static void VerifyState(this ITwainSessionInternal session, int allowedMinimum, int allowedMaximum, DataGroups group, DataArgumentType dataArgumentType, Message message) { if (session.EnforceState && (session.State < allowedMinimum || session.State > allowedMaximum)) { throw new TwainStateException(session.State, allowedMinimum, allowedMaximum, group, dataArgumentType, message, string.Format(CultureInfo.InvariantCulture, "TWAIN state {0} does not match required range {1}-{2} for operation {3}-{4}-{5}.", session.State, allowedMinimum, allowedMaximum, group, dataArgumentType, message)); } }
private static extern ReturnCodes DataSourceCapability( [In, Out] Identity origin, [In] Identity destination, DataGroups dataGroup, DataAttributeTypes dataAttributeType, Messages message, [In, Out] Capability capability);
public List<ITestData> GetEntries(DataGroups dataGroup) { return this.GetEntries(dataGroup.ToString()); }
/// <summary> /// The transfer group determines the kind of data being passed from the Source to the Application. /// By default a TWAIN Source must default to DG_IMAGE. Currently the only other data group /// supported is DG_AUDIO, which is a feature supported by some digital cameras. /// </summary> /// <param name="value">The value.</param> /// <returns></returns> public ReturnCode Set(DataGroups value) { return(DoIt(Message.Set, ref value)); }
/// <summary> /// Returns the Data Group (the type of data) for the upcoming transfer. The Source is required to /// only supply one of the DGs specified in the SupportedGroups field of origin. /// </summary> /// <param name="value">The value.</param> /// <returns></returns> public ReturnCode Get(ref DataGroups value) { return(DoIt(Message.Get, ref value)); }
public List<ITestData> GetEntries(DataGroups dataGroup, string fileMatch) { return this.GetEntries(dataGroup.ToString(), fileMatch); }
private static extern ReturnCodes DataSourceImageNativeXfer( [In, Out] Identity origin, [In] Identity destination, DataGroups dataGroup, DataAttributeTypes dataAttributeType, Messages message, ref IntPtr dibPointer);
/// <summary> /// FilterSamples from DataGroup /// </summary> /// <param name="samples"></param> /// <param name="dataGroup"></param> /// <returns></returns> private List <SampleData> FilterSamples(List <SampleData> samples, DataGroup dataGroup) { var filtered = new List <SampleData>(); List <FilteredDataItem> dataItems = null; lock (_lock) dataItems = filteredDataItems.ToList(); if (dataItems != null) { var deviceIds = new List <string>(); // Find all of the FilteredDataItems that match each Sample foreach (var sample in samples) { bool match = dataItems.Exists(o => o.DataGroupId == dataGroup.Id && o.DeviceId == sample.DeviceId && o.DataItemId == sample.Id); if (match && !filtered.Exists(o => o.DeviceId == sample.DeviceId && o.Id == sample.Id)) { if (!deviceIds.Exists(o => o == sample.DeviceId)) { deviceIds.Add(sample.DeviceId); } filtered.Add(sample); } } if (filtered.Count > 0) { // Include other DataGroups foreach (var groupName in dataGroup.IncludedDataGroups) { // Find group by name var includedGroup = DataGroups.Find(o => o.Name == groupName); if (includedGroup != null) { List <SampleData> storedSamples = null; lock (_lock) storedSamples = storedCurrentSamples.ToList(); if (!storedSamples.IsNullOrEmpty()) { // Filter out any DeviceIds that weren't updated var samplesToFilter = new List <SampleData>(); foreach (var deviceId in deviceIds) { samplesToFilter.AddRange(storedSamples.FindAll(o => o.DeviceId == deviceId)); } // Filter Samples using the Included Group's Filters var storedFiltered = FilterSamples(samplesToFilter, includedGroup); foreach (var sample in storedFiltered) { // Add to list if new if (!filtered.Exists(o => o.DeviceId == sample.DeviceId && o.Id == sample.Id && o.Timestamp >= sample.Timestamp)) { filtered.Add(sample); } } } } } } } return(filtered); }
public List <ITestData> GetEntries(DataGroups dataGroup) { return(this.GetEntries(dataGroup.ToString())); }
public List <ITestData> GetEntries(DataGroups dataGroup, string fileMatch) { return(this.GetEntries(dataGroup.ToString(), fileMatch)); }
/// <summary> /// The transfer group determines the kind of data being passed from the Source to the Application. /// By default a TWAIN Source must default to DG_IMAGE. Currently the only other data group /// supported is DG_AUDIO, which is a feature supported by some digital cameras. /// </summary> /// <param name="value">The value.</param> /// <returns></returns> public ReturnCode Set(DataGroups value) { Session.VerifyState(6, 6, DataGroups.Control, DataArgumentType.XferGroup, Message.Set); return(Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, DataGroups.Control, DataArgumentType.XferGroup, Message.Set, ref value)); }
/// <summary> /// Загрузить конфигурацию из файла /// </summary> public bool Load(string fileName, out string errMsg) { SetToDefault(); try { XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(fileName); // загрузка параметров XmlNode paramsNode = xmlDoc.DocumentElement.SelectSingleNode("Params"); if (paramsNode != null) { foreach (XmlElement paramElem in paramsNode.ChildNodes) { string name = paramElem.GetAttribute("name").ToLowerInvariant(); string val = paramElem.GetAttribute("value"); if (name == "serverpath") { ServerPath = val; } else if (name == "usecertificate") { UseCertificate = Convert.ToBoolean(val); } else if (name == "applicationname") { ApplicationName = val; } } } // загрузка групп чтения данных XmlNode dataGroupsNode = xmlDoc.DocumentElement.SelectSingleNode("DataGroups"); if (dataGroupsNode != null) { foreach (XmlElement dataGroupElem in dataGroupsNode.ChildNodes) { DataGroup dataGroup = new DataGroup(); dataGroup.Name = dataGroupElem.GetAttribute("name"); dataGroup.Active = dataGroupElem.GetAttrAsBool("active"); XmlNodeList dataItemNodes = dataGroupElem.SelectNodes("DataItem"); foreach (XmlElement dataItemElem in dataItemNodes) { DataItem dataItem = new DataItem(); dataItem.Name = dataItemElem.GetAttribute("name"); dataItem.Id = dataItemElem.GetAttribute("id"); dataItem.Active = dataItemElem.GetAttrAsBool("active"); dataItem.Signal = dataItemElem.GetAttrAsInt("updateRate"); dataItem.Mode = dataItemElem.GetAttribute("mode"); dataGroup.DataItems.Add(dataItem); } DataGroups.Add(dataGroup); } } // загрузка групп приёма событий XmlNode eventGroupsNode = xmlDoc.DocumentElement.SelectSingleNode("EventGroups"); if (eventGroupsNode != null) { foreach (XmlElement eventGroupElem in eventGroupsNode.ChildNodes) { EventGroup eventGroup = new EventGroup(); eventGroup.Name = eventGroupElem.GetAttribute("name"); eventGroup.UpdateRate = eventGroupElem.GetAttrAsInt("updateRate"); eventGroup.MaxSize = eventGroupElem.GetAttrAsInt("maxSize"); eventGroup.SimpleEvents = eventGroupElem.GetAttrAsBool("simpleEvents"); eventGroup.TrackingEvents = eventGroupElem.GetAttrAsBool("trackingEvents"); eventGroup.ConditionEvents = eventGroupElem.GetAttrAsBool("conditionEvents"); eventGroup.HighSeverity = eventGroupElem.GetAttrAsInt("highSeverity"); eventGroup.LowSeverity = eventGroupElem.GetAttrAsInt("lowSeverity"); XmlNodeList catNodes = eventGroupElem.SelectNodes("Category"); foreach (XmlElement catElem in catNodes) { eventGroup.Categories.Add(catElem.GetAttribute("name"), catElem.GetAttrAsInt("id")); } EventGroups.Add(eventGroup); } } // загрузка команд XmlNode commandsNode = xmlDoc.DocumentElement.SelectSingleNode("Commands"); if (commandsNode != null) { foreach (XmlElement commandElem in commandsNode.ChildNodes) { Command command = new Command(); command.ItemName = commandElem.GetAttribute("itemName"); command.ItemPath = commandElem.GetAttribute("itemPath"); command.TypeName = commandElem.GetAttribute("typeName"); command.CmdNum = commandElem.GetAttrAsInt("cmdNum"); Commands.Add(command); } } errMsg = ""; return(true); } catch (Exception ex) { errMsg = CommPhrases.LoadKpSettingsError + ":\r\n" + ex.Message; return(false); } }
/// <summary> /// Performs the TWAIN transfer routine at state 6. /// </summary> public static void DoTransferRoutine(ITwainSessionInternal session) { #region get xfer types bool xferImage = true; // default to always xfer image bool xferAudio = false; DataGroups xferGroup = DataGroups.None; XferMech imgXferMech = XferMech.Native; XferMech audXferMech = XferMech.Native; if (session.DGControl.XferGroup.Get(ref xferGroup) == ReturnCode.Success) { xferAudio = (xferGroup & DataGroups.Audio) == DataGroups.Audio; // check for Plustek OpticSlim 2680H, this scanner returns wrong xferGroup after first scanning if (session.CurrentSource.Identity.ProductName.IndexOf("Plustek", StringComparison.OrdinalIgnoreCase) > -1 && session.CurrentSource.Identity.ProductName.IndexOf("OpticSlim", StringComparison.OrdinalIgnoreCase) > -1 && session.CurrentSource.Identity.ProductName.IndexOf("2680H", StringComparison.OrdinalIgnoreCase) > -1) { xferImage = true; } else { xferImage = xferGroup == DataGroups.None || (xferGroup & DataGroups.Image) == DataGroups.Image; } } // some DS end up getting none but we will assume it's image if (xferImage) { imgXferMech = session.CurrentSource.Capabilities.ICapXferMech.GetCurrent(); } if (xferAudio) { var mech = session.CurrentSource.Capabilities.ACapXferMech.GetCurrent(); } #endregion var pending = new TWPendingXfers(); var rc = session.DGControl.PendingXfers.Get(pending); if (rc == ReturnCode.Success) { do { #region raise xfer ready var preXferArgs = new TransferReadyEventArgs(session.CurrentSource, pending.Count, pending.EndOfJob);; session.SafeSyncableRaiseEvent(preXferArgs); #endregion #region actually handle xfer if (preXferArgs.CancelAll || session.CloseDSRequested) { rc = session.DGControl.PendingXfers.Reset(pending); } else { if (!preXferArgs.CancelCurrent) { if (xferImage) { switch (imgXferMech) { case XferMech.Memory: rc = DoImageMemoryXfer(session); break; case XferMech.File: rc = DoImageFileXfer(session); break; case XferMech.MemFile: rc = DoImageMemoryFileXfer(session); break; case XferMech.Native: default: // always assume native rc = DoImageNativeXfer(session); break; } } if (xferAudio) { switch (audXferMech) { case XferMech.File: rc = DoAudioFileXfer(session); break; case XferMech.Native: default: // always assume native rc = DoAudioNativeXfer(session); break; } } } if (rc != ReturnCode.Success && session.StopOnTransferError) { // end xfer without setting rc to exit (good/bad?) session.DGControl.PendingXfers.Reset(pending); } else { rc = session.DGControl.PendingXfers.EndXfer(pending); } } #endregion } while (rc == ReturnCode.Success && pending.Count != 0 && !session.CloseDSRequested); } else { HandleReturnCode(session, rc); } // some poorly written scanner drivers return failure on EndXfer so also check for pending count now. // this may break with other sources but we'll see if (//pending.Count == 0 && session.State > 5) { session.ChangeState(5, true); session.DisableSource(); } }