Beispiel #1
0
        protected override void OnLoad(EventArgs e)
        {
            lblPath.Text = SavePath;


            //get list of devices available
            devices = WIAScanner.ListaDispositivos().ToList();

            foreach (var device in devices)
            {
                //+ "(" + device.Server + ")"
                lbDevices.Items.Add(device.Name);
            }
            //check if device is not available
            if (lbDevices.Items.Count != 0)
            {
                lbDevices.SelectedIndex = 0;
            }

            cTamanho.Items.Add((WIAPageSize)WIAPageSize.A4);
            cTamanho.Items.Add((WIAPageSize)WIAPageSize.Legal);
            cTamanho.Items.Add((WIAPageSize)WIAPageSize.Letter);
            cTamanho.SelectedIndex = 0;

            /*
             * cTamanho.Items.Add(new KeyValuePair<WIAPageSize, string>(WIAPageSize.A4, "A4"));
             * cTamanho.Items.Add(new KeyValuePair<WIAPageSize, string>(WIAPageSize.Legal, "Legal"));
             * cTamanho.Items.Add(new KeyValuePair<WIAPageSize, string>(WIAPageSize.Letter, "Letter"));
             */
            cFonte.Items.Add((WIAScanner.TipoLeituraDocumento)WIAScanner.TipoLeituraDocumento.Feeder);
            cFonte.Items.Add((WIAScanner.TipoLeituraDocumento)WIAScanner.TipoLeituraDocumento.FeederDuplex);
            cFonte.Items.Add((WIAScanner.TipoLeituraDocumento)WIAScanner.TipoLeituraDocumento.FlatBed);
            cFonte.SelectedIndex = 0;
            base.OnLoad(e);
        }
Beispiel #2
0
        private void doScan(WIAScanQuality scanQuality)
        {
            try
            {
                //get list of devices available

                if (lbDevices.Items.Count == 0)
                {
                    MessageBox.Show("You do not have any WIA devices.");
                }
                else
                {
                    // get the selected scanner
                    var device = devices[lbDevices.SelectedIndex];

                    //get images from scanner
                    //var pages_to_scan = 2;
                    WIAScanner.CaminhoArquivo = lblPath.Text;                     // @"C:\temp\pictures\";
                    //images = WIAScanner.Scan(device.DeviceID, WIAPageSize.A4,WIAScanner.TipoLeituraDocumento.FeederDuplex);
                    images = WIAScanner.Scan(device.DeviceID, (WIAPageSize)cTamanho.SelectedItem, (WIAScanner.TipoLeituraDocumento)cFonte.SelectedItem);
                    pages  = images.Count;
                    HashSet <string> mensagens = WIAScanner.Mensagens;
                    string           ret       = "";
                    foreach (string mens in mensagens)
                    {
                        ret = ret + "\n" + mens;
                    }
                    if (images != null)
                    {
                        foreach (KeyValuePair <string, Image> image in images)
                        {
                            pic_scan.Image = image.Value;
                            pic_scan.Show();
                            pic_scan.SizeMode = PictureBoxSizeMode.StretchImage;
                            currentImage      = new Bitmap(image.Value);
                            btnSave.Enabled   = true;
                            currentPage       = 0;
                        }
                    }
                    if (ret.Length > 0)
                    {
                        MessageBox.Show(ret);
                    }
                }
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.Message);
            }
        }