Click here to Skip to main content
15,887,746 members
Home / Discussions / C#
   

C#

 
GeneralRe: New Object Pool Library Pin
Justin-A-Miller20-Nov-19 3:48
Justin-A-Miller20-Nov-19 3:48 
QuestionHow to scan all pages with one click as below: Pin
Member 1094325619-Nov-19 1:36
Member 1094325619-Nov-19 1:36 
AnswerRe: How to scan all pages with one click as below: Pin
Richard MacCutchan19-Nov-19 1:50
mveRichard MacCutchan19-Nov-19 1:50 
GeneralRe: How to scan all pages with one click as below: Pin
Member 1094325619-Nov-19 1:59
Member 1094325619-Nov-19 1:59 
GeneralRe: How to scan all pages with one click as below: Pin
Richard MacCutchan19-Nov-19 2:19
mveRichard MacCutchan19-Nov-19 2:19 
GeneralRe: How to scan all pages with one click as below: Pin
Member 1094325619-Nov-19 2:27
Member 1094325619-Nov-19 2:27 
GeneralRe: How to scan all pages with one click as below: Pin
Richard MacCutchan19-Nov-19 2:32
mveRichard MacCutchan19-Nov-19 2:32 
GeneralRe: How to scan all pages with one click as below: Pin
Member 1094325619-Nov-19 3:31
Member 1094325619-Nov-19 3:31 
i wrote a while loop to check it until the device is loaded by it's not working.
Here are my code:

try
                {

                    object[] items = await Task.Run<object[]>(() =>
                    {

                        var deviceManager = new DeviceManager();
                        List<object> result = new List<object>();

                       
                        for (int i = 1; i <= deviceManager.DeviceInfos.Count; i++) // Loop Through the get List Of Devices.
                        {
                            if (deviceManager.DeviceInfos[i].Type != WiaDeviceType.ScannerDeviceType) // Skip device If it is not a scanner
                            {
                                continue;
                            }
                            //new
                            result.Add(deviceManager.DeviceInfos[i].Properties["Name"].get_Value());
                        }
                        return result.ToArray();
                       

                    });

                    foreach (var item in items)
                    {
                        lstListOfScanner.Items.Add(item);
                    }
                
            }
                catch (COMException ex)
                {
                    MessageBox.Show(ex.Message);
                }

            int n = 1;
            bool continueRunning2 = true;
            try
            {
                await Task.Run(() =>
                {
                    var deviceManager = new DeviceManager();

                    DeviceInfo AvailableScanner = null;

                    for (int i = 1; i <= deviceManager.DeviceInfos.Count; i++)
                    {
                        if (deviceManager.DeviceInfos[i].Type != WiaDeviceType.ScannerDeviceType) // Skip device If it is not a scanner
                        {
                            continue;
                        }

                        AvailableScanner = deviceManager.DeviceInfos[i];
                        break;
                    }
                    /*
                     if (AvailableScanner == null)
                     {
                         return;
                     }
                     */
                    var device = AvailableScanner.Connect();
                    while (AvailableScanner != null)
                    {

                        var ScanerItem = device.Items[1];
                        var imgFile = (ImageFile)ScanerItem.Transfer();

                        var data = (byte[])imgFile.FileData.get_BinaryData();
                        var bitmap = GetBitmapFromRawData(imgFile.Width, imgFile.Height, data);

                        var Path = @"C:\Users\...\Desktop\test\" + n + ".jpg"; // save the image in some path with filename.
                        n++;
                        bitmap.Save(Path, System.Drawing.Imaging.ImageFormat.Jpeg);
                    }
                });
            }
            catch (COMException ex)
            {

                MessageBox.Show(ex.Message);
            }

GeneralRe: How to scan all pages with one click as below: Pin
Richard MacCutchan19-Nov-19 3:40
mveRichard MacCutchan19-Nov-19 3:40 
GeneralRe: How to scan all pages with one click as below: Pin
Member 1094325619-Nov-19 3:52
Member 1094325619-Nov-19 3:52 
GeneralRe: How to scan all pages with one click as below: Pin
Richard MacCutchan19-Nov-19 4:02
mveRichard MacCutchan19-Nov-19 4:02 
GeneralRe: How to scan all pages with one click as below: Pin
Member 1094325619-Nov-19 4:08
Member 1094325619-Nov-19 4:08 
GeneralRe: How to scan all pages with one click as below: Pin
Richard MacCutchan19-Nov-19 4:13
mveRichard MacCutchan19-Nov-19 4:13 
GeneralRe: How to scan all pages with one click as below: Pin
Member 1094325619-Nov-19 4:30
Member 1094325619-Nov-19 4:30 
GeneralRe: How to scan all pages with one click as below: Pin
Richard MacCutchan19-Nov-19 4:45
mveRichard MacCutchan19-Nov-19 4:45 
AnswerRe: How to scan all pages with one click as below: Pin
Pete O'Hanlon19-Nov-19 2:02
mvePete O'Hanlon19-Nov-19 2:02 
GeneralRe: How to scan all pages with one click as below: Pin
Member 1094325619-Nov-19 2:23
Member 1094325619-Nov-19 2:23 
GeneralRe: How to scan all pages with one click as below: Pin
Pete O'Hanlon19-Nov-19 2:37
mvePete O'Hanlon19-Nov-19 2:37 
GeneralRe: How to scan all pages with one click as below: Pin
Pete O'Hanlon19-Nov-19 2:38
mvePete O'Hanlon19-Nov-19 2:38 
GeneralRe: How to scan all pages with one click as below: Pin
Member 1094325619-Nov-19 2:50
Member 1094325619-Nov-19 2:50 
GeneralRe: How to scan all pages with one click as below: Pin
Pete O'Hanlon19-Nov-19 22:40
mvePete O'Hanlon19-Nov-19 22:40 
GeneralRe: How to scan all pages with one click as below: Pin
Member 1094325620-Nov-19 0:35
Member 1094325620-Nov-19 0:35 
GeneralRe: How to scan all pages with one click as below: Pin
Pete O'Hanlon20-Nov-19 0:49
mvePete O'Hanlon20-Nov-19 0:49 
GeneralRe: How to scan all pages with one click as below: Pin
Member 1094325620-Nov-19 4:17
Member 1094325620-Nov-19 4:17 
GeneralRe: How to scan all pages with one click as below: Pin
Pete O'Hanlon20-Nov-19 5:15
mvePete O'Hanlon20-Nov-19 5:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.