コード例 #1
0
        private void _scanWorker_ProgressChanged(object sender, ProgressChangedEventArgs e)
        {
            ScanningWindows.ScanningAutomatic scan = (ScanningWindows.ScanningAutomatic)ContentArea.Content;
            double progress = (Convert.ToDouble(e.ProgressPercentage) / Convert.ToDouble(scan.txtDelay.Text)) * 10;

            scan.prProgress.Value = progress;
        }
コード例 #2
0
 private void BtnAutoScan_Click(object sender, RoutedEventArgs e)
 {
     ScanningWindows.ScanningAutomatic scan = (ScanningWindows.ScanningAutomatic)ContentArea.Content;
     scan.prProgress.Minimum      = 0;
     scan.prProgress.Maximum      = 100;
     scan.prProgress.Visibility   = Visibility.Visible;
     _scanWorker.ProgressChanged += _scanWorker_ProgressChanged;
     scan.btnAutoScan.Visibility  = Visibility.Collapsed;
     scan.btnStopScanning.Click  += BtnStopScanning_Click;
     _scanWorker.RunWorkerAsync(Convert.ToInt32(scan.txtDelay.Text));
 }
コード例 #3
0
        private void _scanWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            switch (_scanMode)
            {
            case ScanningMode.Manual:
                System.Drawing.Image image = ScannerHelper.Scan();
                _scannedImages.Add(image);
                DisplayedPage = _scannedImages.Count - 1;
                e.Result      = image;
                break;

            case ScanningMode.Automatic:
                BackgroundWorker back = (BackgroundWorker)sender;
                while (!back.CancellationPending)
                {
                    back.ReportProgress(0);
                    this.Dispatcher.Invoke(() =>
                    {
                        ScanningWindows.ScanningAutomatic scan = (ScanningWindows.ScanningAutomatic)ContentArea.Content;
                        loadingOverlay.Visibility       = Visibility.Visible;
                        scan.btnStopScanning.Visibility = Visibility.Collapsed;
                        ReadyButton.Visibility          = Visibility.Collapsed;
                    });
                    System.Drawing.Image image2 = ScannerHelper.Scan();
                    _scannedImages.Add(image2);
                    DisplayedPage = _scannedImages.Count - 1;
                    this.Dispatcher.Invoke(() =>
                    {
                        ScanningWindows.ScanningAutomatic scan = (ScanningWindows.ScanningAutomatic)ContentArea.Content;
                        loadingOverlay.Visibility       = Visibility.Collapsed;
                        scan.btnStopScanning.Visibility = Visibility.Visible;
                    });
                    for (int i = 1; i <= Convert.ToInt32(e.Argument) * 10; i++)
                    {
                        if (!back.CancellationPending)
                        {
                            System.Threading.Thread.Sleep(100);
                            back.ReportProgress(i);
                        }
                    }
                }
                break;
            }
        }
コード例 #4
0
        private void _scanWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            switch (_scanMode)
            {
            case ScanningMode.Manual:
                System.Drawing.Image image = (System.Drawing.Image)e.Result;
                scanImage.Source          = ConvertImageToImageSource(image);
                loadingOverlay.Visibility = Visibility.Hidden;
                ReadyButton.Visibility    = Visibility.Visible;
                break;

            case ScanningMode.Automatic:
                ScanningWindows.ScanningAutomatic scan = (ScanningWindows.ScanningAutomatic)ContentArea.Content;
                scan.prProgress.Visibility      = Visibility.Collapsed;
                scan.btnAutoScan.Visibility     = Visibility.Visible;
                scan.btnStopScanning.Visibility = Visibility.Collapsed;
                break;
            }
        }
コード例 #5
0
        private void btnScanMode_Click(object sender, RoutedEventArgs e)
        {
            Button send = (Button)sender;

            foreach (object modeButton in modeMenu.Children)
            {
                Button button = (Button)modeButton;
                if (button != send)
                {
                    button.Background = new SolidColorBrush(ColorScheme.MenuDarker);
                    button.Foreground = new SolidColorBrush(Colors.Black);
                    button.FontWeight = FontWeights.Normal;
                }
            }

            send.Background = new SolidColorBrush(ColorScheme.GlobalBlue);
            send.Foreground = new SolidColorBrush(Colors.White);
            send.FontWeight = FontWeights.Medium;

            switch (send.Name)
            {
            case "btnScanModeManual":
                _scanMode = ScanningMode.Manual;
                ScanningWindows.ScanningManual scanManual = new ScanningWindows.ScanningManual();
                scanManual.btnManualScan.Click += BtnManualScan_Click;
                ContentArea.Content             = scanManual;
                break;

            case "btnScanModeAutomatic":
                _scanMode = ScanningMode.Automatic;
                ScanningWindows.ScanningAutomatic scanAuto = new ScanningWindows.ScanningAutomatic();
                scanAuto.btnAutoScan.Click += BtnAutoScan_Click;
                ContentArea.Content         = scanAuto;
                break;
            }
        }