private void btnScan_Click(object sender, EventArgs e)
        {
            try
            {
                WIA.CommonDialog dialog = new WIA.CommonDialog();

                ImageFile scannedImage = null;
                scannedImage = dialog.ShowAcquireImage(
                    WiaDeviceType.ScannerDeviceType,
                    WiaImageIntent.UnspecifiedIntent,
                    WiaImageBias.MaximizeQuality,
                    FormatID.wiaFormatPNG,
                    true, true, false);
                if (scannedImage != null)
                {
                    WIA.Vector vector = scannedImage.FileData;
                    byte[]     b      = (byte[])vector.get_BinaryData();

                    System.Drawing.Image img = System.Drawing.Image.FromStream(new System.IO.MemoryStream(b));
                    pictureBox1.Image  = img;
                    pictureBox1.Height = img.Height;
                    pictureBox1.Width  = img.Width;
                    pictureBox1.Image  = img;
                }
            }catch (Exception ex)
            {
                Scanner   scanner = new Scanner();
                ArrayList list    = scanner.ADFScan();
                if (list.Count <= 0)
                {
                    MessageBox.Show("خطا در دستیابی به اسکنر ، لطفا از وصل بودن کابلهای اسکنر اطمینان حاصل کنید" + "\n" + ex.Message);
                }
                else
                {
                    WIA.Vector vector = ((ImageFile)list[0]).FileData;
                    byte[]     b      = (byte[])vector.get_BinaryData();

                    System.Drawing.Image img = System.Drawing.Image.FromStream(new System.IO.MemoryStream(b));
                    pictureBox1.Image  = img;
                    pictureBox1.Height = img.Height;
                    pictureBox1.Width  = img.Width;
                    pictureBox1.Image  = img;
                }
            }
        }