Exemple #1
0
//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
        private bool StartScan()
        {
            try
            {
                ScanFinished = false;
                DisableAllButtons(false);
                ScannedPageCount = 0;
                ChageStatusText("Status: Es wird gescannt");
                ScanSettings = new ScanSettings();
                ScanSettings.UseDocumentFeeder          = InsertionCheckBox.Checked;
                ScanSettings.AbortWhenNoPaperDetectable = false;
                ScanSettings.UseAutoFeeder           = InsertionCheckBox.Checked;
                ScanSettings.ShowTwainUI             = VendorToolCheckBox.Checked;
                ScanSettings.ShowProgressIndicatorUI = true;
                ScanSettings.Area = null;
                ScanSettings.ShouldTransferAllPages = true;
                ScanSettings.UseDuplex = DoubleSidedCheckBox.Checked;
                var QualitySettings = new ResolutionSettings();
                QualitySettings.Dpi = 200;
                if (GreyCheckBox.Checked)
                {
                    QualitySettings.ColourSetting = ColourSetting.GreyScale;
                }
                else
                {
                    QualitySettings.ColourSetting = ColourSetting.Colour;
                }
                ScanSettings.Resolution = QualitySettings;
                ScanSettings.Rotation   = new RotationSettings()
                {
                    AutomaticRotate          = RotationCorrectionCheckBox.Checked,
                    AutomaticBorderDetection = EdgeDetectionCheckBox.Checked
                };
                try
                {
                    TwainLib.StartScanning(ScanSettings);
                }
                catch (TwainException ex)
                {
                    MessageBox.Show(ex.Message);
                    DisableAllButtons(true);
                    EnableButtons();
                    this.Focus();
                    ChageStatusText("Status:");
                }
                return(true);
            }
            catch (Exception ex)
            {
                Program.MeldeFehler(ex.Message + "\n" + ex.StackTrace);
                Environment.Exit(1);
                return(false);
            }
        }
Exemple #2
0
//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
        private void ScannerSelectionButton_Click(object sender, EventArgs e)
        {
            try
            {
                TwainLib.SelectSource();
            }
            catch (Exception ex)
            {
                Program.MeldeFehler("Bei diesen Fehler hilft es oft die Konfigurationsdatei(Settings.cfg) zu löschen:\n\n" + Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "\n" + ex.Message + "\n" + ex.StackTrace);
                Environment.Exit(1);
            }
        }
Exemple #3
0
//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
        private bool SaveSettings()
        {
            ProgramSettings.ScannerProductName    = TwainLib.GetSelectedSource();
            ProgramSettings.UseInsertion          = InsertionCheckBox.Checked;
            ProgramSettings.UseDoubleSided        = DoubleSidedCheckBox.Checked;
            ProgramSettings.UseGrey               = GreyCheckBox.Checked;
            ProgramSettings.CheckIfEmpty          = CheckIfEmptyCheckBox.Checked;
            ProgramSettings.UseEdgeDetection      = EdgeDetectionCheckBox.Checked;
            ProgramSettings.UseRotationCorrection = RotationCorrectionCheckBox.Checked;
            ProgramSettings.UseVendorTool         = VendorToolCheckBox.Checked;
            ProgramSettings.Save();
            return(true);
        }
Exemple #4
0
//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
        private void Form1_Shown(object sender, EventArgs e)
        {
            try
            {
                AllPagesTabControl.TabPages.Clear();
                CurPageControl  = new PageControl(AllPagesTabControl);
                ProgramSettings = new Settings();
                ProgramSettings.Load();
                InsertionCheckBox.Checked          = ProgramSettings.UseInsertion;
                DoubleSidedCheckBox.Checked        = ProgramSettings.UseDoubleSided;
                GreyCheckBox.Checked               = ProgramSettings.UseGrey;
                CheckIfEmptyCheckBox.Checked       = ProgramSettings.CheckIfEmpty;
                EdgeDetectionCheckBox.Checked      = ProgramSettings.UseEdgeDetection;
                RotationCorrectionCheckBox.Checked = ProgramSettings.UseRotationCorrection;
                VendorToolCheckBox.Checked         = ProgramSettings.UseVendorTool;
                this.Size = new Size(ProgramSettings.SizeX, ProgramSettings.SizeY);
                Form1_ResizeEnd(null, null);
                this.Text     = "Scanner Tool  (v" + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString() + ")";
                AllButtons    = new MaterialRaisedButton[] { ScannerSelectionButton, ResetScanButton, AddScanButton, ScanAndSendFastButton, ScanAndSaveFastButton, SendButton, SaveButton, MovePageForwardButton, MovePageBackButton, RotateImageButton, DeletePageButton };
                AllCheckBoxes = new MaterialCheckBox[] { InsertionCheckBox, DoubleSidedCheckBox, GreyCheckBox, EdgeDetectionCheckBox, RotationCorrectionCheckBox, CheckIfEmptyCheckBox, VendorToolCheckBox };
                try
                {
                    olook = new Outlook.Application();
                }
                catch
                {
                    MessageBox.Show("Ihr Outlook wurde nicht ordnungsgemäß installiert.");
                    Environment.Exit(1075);
                }
                ResetTwain(0);
                if (!string.IsNullOrEmpty(ProgramSettings.ScannerProductName))
                {
                    TwainLib.SelectSource(ProgramSettings.ScannerProductName);
                }
                GC.Collect();
            }
            catch (Exception ex)
            {
                Program.MeldeFehler(ex.Message + "\n" + ex.StackTrace);
                Environment.Exit(1);
            }
        }