Example #1
0
        private void btnScan_Click(object sender, EventArgs e)
        {
            try
            {
                List <Image> images = WIAScanner.Scan((string)lbDevices.SelectedItem);
                foreach (Image image in images)
                {
                    switch (Properties.Settings.Default.FileExtension)
                    {
                    case 0:
                        image.Save(GetFilePath(Properties.Settings.Default.SavePath) + DateTime.Now.ToString("yyyy-MM-dd HHmmss") + ".jpeg", ImageFormat.Jpeg);
                        break;

                    case 1:
                        image.Save(GetFilePath(Properties.Settings.Default.SavePath) + DateTime.Now.ToString("yyyy-MM-dd HHmmss") + ".bmp", ImageFormat.Bmp);
                        break;

                    case 2:
                        image.Save(GetFilePath(Properties.Settings.Default.SavePath) + DateTime.Now.ToString("yyyy-MM-dd HHmmss") + ".png", ImageFormat.Png);
                        break;

                    case 3:
                        image.Save(GetFilePath(Properties.Settings.Default.SavePath) + DateTime.Now.ToString("yyyy-MM-dd HHmmss") + ".gif", ImageFormat.Gif);
                        break;
                    }
                }
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.Message);
            }
        }
Example #2
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            List <string> devices = WIAScanner.GetDevices();

            foreach (string device in devices)
            {
                lbDevices.Items.Add(device);
            }

            if (lbDevices.Items.Count == 0)
            {
                MessageBox.Show("You do not have any WIA devices.");
            }
            else
            {
                lbDevices.SelectedIndex = Properties.Settings.Default.SelectScanner;
            }
        }