Tattakashi123 / t

Automatically exported from code.google.com/p/twaindotnet
0 stars 0 forks source link

Modifitication to DataSourceManager.StartScan and testWPF.window1 #6

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Just my consideration and suggestion. 

1.
/**********************************************/
For DataSourceManager
if scanning is canceled, EndingScan() should be called?
/**********************************************/
public void StartScan(ScanSettings settings)
        {
            bool Scanned = false;
            try
            {
                _messageHook.UseFilter = true;
                Scanned = DataSource.Open(settings);
            }
            catch (TwainException e)
            {
                DataSource.Close();
                EndingScan();
                throw e;
            }
            finally
            {
                if (!Scanned)
                    EndingScan(); 
            }

        }

2.

/****************************************/
for TestWPF.Window1
following code just move 'IsEnabled = true;' to last line to enable the 
interface even the scaning is canceled.
/****************************************/

 private void scanButton_Click(object sender, RoutedEventArgs e)
        {
            IsEnabled = false;

            _settings = new ScanSettings()
            {
                UseDocumentFeeder = useAdfCheckBox.IsChecked == true,
                ShowTwainUI = useTwainUICheckBox.IsChecked == true,
                Resolution= new ResolutionSettings()
                {
                    Dpi= 400
                }
            };

            try
            {
                if (SourceUserSelected.IsChecked == true)
                {
                    _twain.SelectSource(ManualSource.SelectedItem.ToString
());
                }

                _twain.StartScanning(_settings);
            }
            catch (TwainException ex)
            {
                MessageBox.Show(ex.Message);
            }

            IsEnabled = true;
        }

3.
/************************************************************/
For DataSource

even if the ShowUI is set to false, is it still reasonable to set the 
capalility to what from interface initially. and further more user can 
modify with launched UI?
/************************************************************/

public bool Open(ScanSettings settings)
        {

            OpenSource();

            //if (!settings.ShowTwainUI)
            //{
                NegotiateTransferCount(settings);
                NegotiateFeeder(settings);
                NegotiateDuplex(settings);

                if (settings.Resolution != null)
                {
                    NegotiateColour(settings);
                    NegotiateResolution(settings);
                }
            //}

            return Enable(settings);
        }

Original issue reported on code.google.com by carl...@hotmail.com on 24 Sep 2009 at 4:31

GoogleCodeExporter commented 8 years ago
All good suggestions.

For point #3 my scanner ignores the settings negotiated before the TWAIN UI is 
displayed but perhaps this works on your scanner. Either way I'm happy to try 
it.

Original comment by luke.qui...@gmail.com on 29 Sep 2009 at 1:22

GoogleCodeExporter commented 8 years ago

Original comment by luke.qui...@gmail.com on 29 Sep 2009 at 1:24