Exemple #1
0
 /// <summary>
 /// Raises the <see cref="TransferReady"/> event.
 /// </summary>
 /// <param name="e"></param>
 protected virtual void OnTransferReady(TransferReadyEventArgs e)
 {
     ExternalInvoke(() =>
     {
         var handler = TransferReady;
         handler?.Invoke(this, e);
     });
 }
Exemple #2
0
        private void DoTransferRoutine()
        {
            var xMech = GetTransferMechs();

            TW_PENDINGXFERS pending = default;
            var             rc      = DGControl.PendingXfers.Get(ref pending);

            if (rc == ReturnCode.Success)
            {
                do
                {
                    var readyArgs = new TransferReadyEventArgs(CurrentSource, pending.Count, pending.EndOfJob)
                    {
                        CancelAll = _disableDSNow
                    };
                    OnTransferReady(readyArgs);


                    #region actually handle xfer

                    if (readyArgs.CancelAll || _disableDSNow)
                    {
                        rc = DGControl.PendingXfers.Reset(ref pending);
                    }
                    else
                    {
                        if (!readyArgs.CancelCurrent)
                        {
                            if (xMech.ImageMech.HasValue)
                            {
                                switch (xMech.ImageMech.Value)
                                {
                                case XferMech.Memory:
                                    rc = DoImageMemoryXfer();
                                    break;

                                case XferMech.File:
                                    rc = DoImageFileXfer();
                                    break;

                                case XferMech.MemFile:
                                    rc = DoImageMemoryFileXfer();
                                    break;

                                case XferMech.Native:
                                default:     // always assume native
                                    rc = DoImageNativeXfer();
                                    break;
                                }
                            }
                            if (xMech.AudioMech.HasValue)
                            {
                                switch (xMech.AudioMech.Value)
                                {
                                case XferMech.File:
                                    rc = DoAudioFileXfer();
                                    break;

                                case XferMech.Native:
                                default:     // always assume native
                                    rc = DoAudioNativeXfer();
                                    break;
                                }
                            }
                        }

                        if (rc != ReturnCode.Success)// && StopOnTransferError)
                        {
                            // end xfer without setting rc to exit (good/bad?)
                            DGControl.PendingXfers.Reset(ref pending);
                        }
                        else
                        {
                            rc = DGControl.PendingXfers.EndXfer(ref pending);
                        }
                    }
                    #endregion
                } while (rc == ReturnCode.Success && pending.Count != 0 && !_disableDSNow);
            }
            else
            {
                HandleXferReturnCode(rc);
            }

            if (_disableDSNow)
            {
                DGControl.UserInterface.DisableDS(ref _lastEnableUI, false);
            }
        }
Exemple #3
0
 void ITwainSessionInternal.SafeSyncableRaiseEvent(TransferReadyEventArgs e)
 {
     SafeSyncableRaiseOnEvent(OnTransferReady, TransferReady, e);
 }
Exemple #4
0
 /// <summary>
 /// Called when a data transfer is ready.
 /// </summary>
 /// <param name="e">The <see cref="TransferReadyEventArgs"/> instance containing the event data.</param>
 protected virtual void OnTransferReady(TransferReadyEventArgs e)
 {
 }