Exemple #1
0
 private void FrontCoverImgScan_ScanStarted(object sender, ImgScan.ScanStartedEventArgs e)
 {
     Debug.WriteLine("FrontCoverImgScan_ScanStarted");
     this.WorkingGifImage.Visibility = Visibility.Visible;
 }
Exemple #2
0
        private Rect GetScannerArea(ImgScan.ICTwainSupportedSizes? size, ImgScan.ICTwainOrientations? orientation, int? dpi)
        {
            if (!size.HasValue || !orientation.HasValue || !dpi.HasValue) return Rect.Empty;

            Rect area = Rect.Empty;
            double margin = 0.1 * dpi.Value;
            double width = 0;
            double height = 0;

            switch (size.Value)
            {
                case ImgScan.ICTwainSupportedSizes.A4:
                    width = 8.27 * dpi.Value - 2 * margin;
                    height = 11.69 * dpi.Value - 2 * margin;
                    break;
                case ImgScan.ICTwainSupportedSizes.A5:
                    width = 5.83 * dpi.Value - 2 * margin;
                    height = 8.27 * dpi.Value - 2 * margin;
                    break;
                default:
                    break;
            }

            switch (orientation.Value)
            {
                case ImgScan.ICTwainOrientations.Portrait:
                    area = new Rect(margin, margin, width, height);
                    break;
                case ImgScan.ICTwainOrientations.Landscape:
                    area = new Rect(margin, margin, height, width);
                    break;
                default:
                    break;
            }

            return area;
        }
Exemple #3
0
 private void TableOfContentsImgScan_ScanPageStarted(object sender, ImgScan.ScanStartedEventArgs e)
 {
     Debug.WriteLine("TableOfContentsImgScan_ScanPageStarted");
 }
Exemple #4
0
        private void FrontCoverImgScan_ScanFinished(object sender, ImgScan.ScanEventArgs e)
        {
            Debug.WriteLine(String.Format("FrontCoverImgScan_ScanFinished: [{0}] {1}", e.PagePosition, e.ScannedFilename));

            SetMainWindowTopmost();
            this.WorkingGifImage.Visibility = Visibility.Visible;

            FrontCoverImgEdit.Page = e.PagePosition;
            FrontCoverThumbnails.DefaultThumbnailCaption = "Obálka";
            CurrentBookInfoBox.SetImageChanged(PartOfBook.FrontCover);
            ShowMainImgEdit(PartOfBook.FrontCover);

            if (File.Exists(e.ScannedFilename))
            {
                if (!String.IsNullOrEmpty(Settings.Default.ScannerPageSize))
                {
                    ImgScan.DeviceUICapabilities.ImageCapabilities capabilities = FrontCoverImgScan.DeviceCapabilities.TwainICapabilities;

                    if (capabilities.PaperSizeValue.HasValue && capabilities.PaperSizeValue.Value != ImgScan.ICTwainSupportedSizes.None)
                    {
                        if (FrontCoverImgScan.AvailableDeviceCapabilities.TwainICapabilities.AvailablePaperSizes == null ||
                            FrontCoverImgScan.AvailableDeviceCapabilities.TwainICapabilities.AvailablePaperSizes.Contains(capabilities.PaperSizeValue.Value) == false)
                        {
                            Rect area = GetScannerArea(capabilities.PaperSizeValue, capabilities.PaperOrientationValue, capabilities.ResolutionValue);
                            if (!area.IsEmpty)
                            {
                                FrontCoverImgEdit.SetSelectionRectangle((int)area.Left, (int)area.Top, (int)area.Width, (int)area.Height);
                                FrontCoverImgEdit.CropImage();
                                FrontCoverImgEdit.SaveImageAs(CurrentBookInfoBox.GetFullName(PartOfBook.FrontCover));
                            }
                        }
                    }
                }
            }

            StopTimer();
            GetAvailableMemory(true);
            SetMenuButtonsEnabled();
            this.WorkingGifImage.Visibility = Visibility.Hidden;
            this.Cursor = null;
        }
Exemple #5
0
 private void TableOfContentsImgScan_ScanPageFinished(object sender, ImgScan.ScanEventArgs e)
 {
     Debug.WriteLine(String.Format("TableOfContentsImgScan_ScanPageFinished: [{0}] {1}", e.PagePosition, e.ScannedFilename));
 }
Exemple #6
0
        private void TableOfContentsImgScan_ScanFinished(object sender, ImgScan.ScanEventArgs e)
        {
            Debug.WriteLine(String.Format("TableOfContentsImgScan_ScanFinished: [{0}] {1}", e.PagePosition, e.ScannedFilename));

            SetMainWindowTopmost();
            this.WorkingGifImage.Visibility = Visibility.Visible;

            TableOfContentsImgEdit.Page = e.PagePosition;
            ShowMainImgEdit(PartOfBook.TableOfContents);
            CurrentBookInfoBox.SetImageChanged(PartOfBook.TableOfContents);

            if (File.Exists(e.ScannedFilename))
            {
                if (!String.IsNullOrEmpty(Settings.Default.ScannerPageSize))
                {
                    ImgScan.DeviceUICapabilities.ImageCapabilities capabilities = TableOfContentsImgScan.DeviceCapabilities.TwainICapabilities;

                    if (capabilities.PaperSizeValue.HasValue && capabilities.PaperSizeValue.Value != ImgScan.ICTwainSupportedSizes.None)
                    {
                        if (TableOfContentsImgScan.AvailableDeviceCapabilities.TwainICapabilities.AvailablePaperSizes == null ||
                            TableOfContentsImgScan.AvailableDeviceCapabilities.TwainICapabilities.AvailablePaperSizes.Contains(capabilities.PaperSizeValue.Value) == false)
                        {
                            Rect area = GetScannerArea(capabilities.PaperSizeValue, capabilities.PaperOrientationValue, capabilities.ResolutionValue);
                            if (!area.IsEmpty)
                            {
                                Debug.WriteLine("=> TableOfContentsImgEdit.CropImage");
                                TableOfContentsImgEdit.SetSelectionRectangle((int)area.Left, (int)area.Top, (int)area.Width, (int)area.Height);
                                TableOfContentsImgEdit.CropImage();
                            }
                        }
                    }
                }

                if (Settings.Default.ScanRotateEvenPage && ((TableOfContentsImgEdit.PageCount) % 2 == 0))
                {
                    if (Convert.ToBoolean(TableOfContentsImgScan.DeviceCapabilities.TwainCapabilities.IsAutoRotationEnabled) &&
                        Convert.ToBoolean(TableOfContentsImgScan.AvailableDeviceCapabilities.TwainCapabilities.IsAutoRotationEnabled) == false)
                    {
                        Debug.WriteLine("=> TableOfContentsImgEdit.Flip");
                        TableOfContentsImgEdit.Flip();
                    }
                }

                if (TableOfContentsImgEdit.Page == 0)
                {
                    Debug.WriteLine("=> TableOfContentsImgEdit.SaveImageAs");
                    TableOfContentsImgEdit.SaveImageAs(CurrentBookInfoBox.GetFullName(PartOfBook.TableOfContents));
                }
            }

            StopTimer();
            GetAvailableMemory(true);
            SetMenuButtonsEnabled();
            this.WorkingGifImage.Visibility = Visibility.Hidden;
            this.Cursor = null;
        }
Exemple #7
0
        private void SetScannerTrace(ImgScan.TraceOutputType type)
        {
            this.FrontCoverImgScan.ErrorTraceOutputType = type;
            this.TableOfContentsImgScan.ErrorTraceOutputType = type;

            if (type == ImgScan.TraceOutputType.File)
            {
                string errorFilePath = System.IO.Path.Combine(Logger.LOG_PATH, String.Format("ScanLog{0:yyyyMMdd}.txt", DateTime.Now));
                this.FrontCoverImgScan.ErrorFilePath = errorFilePath;
                this.TableOfContentsImgScan.ErrorFilePath = errorFilePath;
            }
        }
Exemple #8
0
 private void SetScannerPageSize(ImgScan.ICTwainSupportedSizes size)
 {
     this.ScannerPageSizeNoneButton.IsChecked = (size == ImgScan.ICTwainSupportedSizes.None);
     this.ScannerPageSizeA4Button.IsChecked = (size == ImgScan.ICTwainSupportedSizes.A4);
     this.ScannerPageSizeA5Button.IsChecked = (size == ImgScan.ICTwainSupportedSizes.A5);
     Settings.Default.ScannerPageSize = size.ToString();
 }
Exemple #9
0
 private void SetScannerPageOrientation(ImgScan.ICTwainOrientations orientation)
 {
     this.ScannerPageOrientationPortraitButton.IsChecked = (orientation == ImgScan.ICTwainOrientations.Portrait);
     this.ScannerPageOrientationLandscapeButton.IsChecked = (orientation == ImgScan.ICTwainOrientations.Landscape);
     Settings.Default.ScannerPageOrientation = orientation.ToString();
 }