상속: System.Windows.Controls.UserControl
        //Scanner Click Event
        private void btnScan_Click(object sender, EventArgs e)
        {
            try
            {
                // Select the scanner from list
                var device = lbDevices.SelectedItem as Scanner;
                this.txtProgress.Text="You selected "+device+" as your Scanner";
                if (device == null)
                {
                    System.Windows.MessageBox.Show("Please select a device.", "Warning");
                    return;
                }
                // Scan
                var image = device.Scan();
                //List to hold images
                List<WIA.ImageFile> wiaImagesList = new List<WIA.ImageFile>();
                //Add to list
                wiaImagesList.Add(image);
                if (wiaImagesList.Count() == 0)
                { return; }
                this.txtProgress.Text = "Scanning in Progress...........";
                //creat pdf
                PdfDocument doc = new PdfDocument();
                string destination = @"C:\ScannerFolder\" + DateTime.Now.ToString("yyyy-MM-dd HHmmss") + ".pdf";
                string tempDestination = @"C:\TempScannerFolder" + DateTime.Now.ToString("yyyy-MM-dd HHmmss") + ".pdf";

                //create folder to store image
                System.IO.Directory.CreateDirectory(folderName);
                System.IO.Directory.CreateDirectory(tempFolderName);

                foreach (WIA.ImageFile img in wiaImagesList)
                {
                    //For each image to be scanned
                    string tempFilename = @"C:\ScannerFolder\" + rtbResult.Text + DateTime.Now.ToString("yyyy-MM-dd HHmmss") + ".tiff";
                    string filename = @"C:\TempScannerFolder\" + rtbResult.Text + DateTime.Now.ToString("yyyy-MM-dd HHmmss") + ".tiff";// can get barcode from rtbResult.Text to save image as barcode

                    //save the tiff
                    image.SaveFile(filename);

                    //add image to the pdf and Custom user control and save
                    doc.Pages.Add(new PdfPage());
                    XGraphics xgr = XGraphics.FromPdfPage(doc.Pages[0]);
                    XImage imgX = XImage.FromFile(filename);
                    xgr.DrawImage(imgX, 0, 0);

                    //save to destinatin folder
                    doc.Save(destination);

                    //doc.Save(tempFilename);
                    showPath.Text += destination;
                    tempList.Add(destination);
                    doc.Close();

                    this.txtProgress.Text = "Scanning complete, converting to PDF";

                    // User control to display pdf
                    var uc = new UserControl1(destination);
                    this.windowsFormsHost1.Child = uc;
                }

                //Convert Wia imageFile to a bitmap
                Bitmap bmp = ConvertImageToBitmap(image);
                DateTime dtStart = DateTime.Now;

                //read barcode form Bitmap
                string[] barcode = ReadBarcodeFromBitmap(bmp);

                // Show the results in a message box
                string result = string.Empty;
                if (barcode != null)
                {
                    foreach (String code in barcode){
                        result += code;
                        }
                    }
                    else{
                        result += "Failed to find a barcode.";
                    }
                    //Show barcode
                    rtbResult.Text = result;
                    GetDocumentType();
                 }
            catch (Exception)
            {
                System.Windows.MessageBox.Show("A scanner error occoured, check feeder");
            }
        }