Exemple #1
0
        public void Scan(out IDocument document, IDocument.FormatType formatType = IDocument.FormatType.JPG)
        {
            switch (formatType)
            {
            case IDocument.FormatType.TXT:
                document = new TextDocument("TextScan" + ScanCounter.ToString("0000.##") + ".txt");
                break;

            case IDocument.FormatType.PDF:
                document = new PDFDocument("PDFScan" + ScanCounter.ToString("0000.##") + ".pdf");
                break;

            case IDocument.FormatType.JPG:
                document = new TextDocument("ImageScan" + ScanCounter.ToString("0000.##") + ".jpg");
                break;

            default:
                throw new Exception();
            }

            if (state == IDevice.State.on)
            {
                ScanCounter++;
                Console.WriteLine($"{ DateTime.Now } Scan: { document.GetFileName() }");
            }
        }
Exemple #2
0
        public void Scan(out IDocument document, IDocument.FormatType formatType)
        {
            DateTime dateTime = DateTime.Now;
            string   value    = String.Format("{0:D4}", ScanCounter++);

            if (formatType == IDocument.FormatType.TXT)
            {
                document = new PDFDocument("TXTScan" + value + ".txt");
                Console.WriteLine(dateTime + " " + document.GetFileName());
            }

            else if (formatType == IDocument.FormatType.PDF)
            {
                document = new TextDocument("PDFScan" + value + ".pdf");
                Console.WriteLine(dateTime + " " + document.GetFileName());
            }

            else if (formatType == IDocument.FormatType.JPG)
            {
                document = new TextDocument("JPGScan" + value + ".jpg");
                Console.WriteLine(dateTime + " " + document.GetFileName());
            }
            else
            {
                document = null;
            }
        }
        public void Scan(out IDocument document, IDocument.FormatType formatType = IDocument.FormatType.JPG)
        {
            if (state == IDevice.State.on)
            {
                switch (formatType)
                {
                case IDocument.FormatType.PDF:
                    document = new PDFDocument("PDFScan" + ScanCounter + ".pdf");
                    break;

                case IDocument.FormatType.JPG:
                    document = new ImageDocument("ImageScan" + ScanCounter + ".jpg");
                    break;

                case IDocument.FormatType.TXT:
                    document = new TextDocument("TextScan" + ScanCounter + ".txt");
                    break;

                default:
                    document = null;
                    break;
                }

                if (document != null)
                {
                    Console.WriteLine("{0} Scan: {1}",
                                      DateTime.Now.ToString("yyyy.MM.dd HH:mm:ss"),
                                      document.GetFileName());
                    ScanCounter++;
                }
            }
            else
            {
                document = null;
            }
        }