Exemplo n.º 1
0
        public static List <Bitmap> StartScan()
        {
            List <Bitmap> result = new List <Bitmap>();

            if (Program.config.SavePath == "")
            {
                Program.ShowError("Vui lòng chọn thư mục lưu kết quả");
                return(result);
            }

            if (!PathWritable(Program.config.SavePath))
            {
                Program.ShowError("Thư mục lưu kết quả không được quyền ghi dữ liệu");
                return(result);
            }

            if (Program.config.ScannerID == "")
            {
                Program.ShowError("Vui lòng chọn máy quét!");
                return(result);
            }

            //Load settings
            ScanSettings settings = new ScanSettings();

            settings.color      = Program.config.ScanColor;
            settings.dpi        = Program.config.ScanDpi;
            settings.adf        = Program.config.ScanADF;
            settings.tryFlatbed = Program.config.ScanTryFlatbed;

            try
            {
                result = WIAScanner.Scan(Program.config.ScannerID, settings);
                //Call garbage collector
                GC.Collect();
            }
            catch (Exception ex)
            {
                Program.ShowError(ex);
            }
            return(result);
        }
Exemplo n.º 2
0
        public static void StartScan()
        {
            if (Program.config.SavePath == "")
            {
                Program.ShowError("Cannot start scanning, no save path defined");
                return;
            }

            if (!PathWritable(Program.config.SavePath))
            {
                Program.ShowError("Provided path is not writable");
                return;
            }

            if (Program.config.ScannerID == "")
            {
                Program.ShowError("Cannot start scanning, no scanner device selected.");
                return;
            }

            //Load settings
            ScanSettings settings = new ScanSettings();

            settings.color      = Program.config.ScanColor;
            settings.dpi        = Program.config.ScanDpi;
            settings.adf        = Program.config.ScanADF;
            settings.tryFlatbed = Program.config.ScanTryFlatbed;

            try
            {
                SaveImages(WIAScanner.Scan(Program.config.ScannerID, settings));

                //Call garbage collector
                GC.Collect();
            }
            catch (Exception ex)
            {
                Program.ShowError(ex);
            }
        }