Exemple #1
0
        /// <summary>
        /// Loads single preview image from specified path
        /// </summary>
        /// <param name="pathToImage"></param>
        private void LoadPreviewImage(string pathToImage)
        {
            FileInfo fileInfo = new FileInfo(pathToImage);

            if (!ResolutionUtility.CheckImageSize(fileInfo))
            {
                return;
            }

            // load image metadata to check width and height
            BitmapFrame bitmapFrame = BitmapFrame.Create(new Uri(pathToImage), BitmapCreateOptions.DelayCreation, BitmapCacheOption.None);

            if (bitmapFrame.PixelWidth < 1200 || bitmapFrame.PixelHeight < 1700)
            {
                DialogManager.ShowImageSizeWarning(fileInfo.Name);
            }

            var newItem = new ImagePreviewViewModel(pathToImage, Path.GetFileName(pathToImage), fileInfo.Length);

            newItem.ImageFileFormat = fileInfo.Extension;
            this.PreviewImages.Add(newItem);

            this.InitialPreviewPanelVisibility = Visibility.Collapsed;
            this.CurrentStage = ResultProcessingStages.GotImagesToRecognize;
        }
Exemple #2
0
        /// <summary>
        /// Loads preview images by provided file paths
        /// </summary>
        /// <param name="files">File paths</param>
        private void LoadPreviewImages(string[] files)
        {
            if (files.Length == 0)
            {
                return;
            }

            foreach (string file in files)
            {
                FileInfo fileInfo = new FileInfo(file);

                if (!ResolutionUtility.CheckImageSize(fileInfo))
                {
                    continue;
                }

                // load image metadata to check width and height
                var bitmapFrame = BitmapFrame.Create(new Uri(file), BitmapCreateOptions.DelayCreation, BitmapCacheOption.None);
                if (bitmapFrame.PixelWidth < 1200 || bitmapFrame.PixelHeight < 1700)
                {
                    DialogManager.ShowImageSizeWarning();
                }

                var newItem = new ImagePreviewViewModel(file, Path.GetFileName(file), fileInfo.Length);
                newItem.ImageFileFormat = fileInfo.Extension;
                this.PreviewImages.Add(newItem);
            }

            this.InitialPreviewPanelVisibility = Visibility.Collapsed;
            this.SelectedPreviewImage          = this.PreviewImages.First();
        }
        /// <summary>
        /// Loads template image located by specified path
        /// </summary>
        /// <param name="path">Path to image</param>
        private void LoadTemplateImageFromFile(string path)
        {
            double monitorWidth, monitorHeight;

            ResolutionUtility.GetMonitorResolution(out monitorWidth, out monitorHeight);

            FileInfo fileInfo = new FileInfo(path);

            this.ImageSizeInBytes  = fileInfo.Length;
            this.TemplateImageName = fileInfo.Name;
            this.ImageFileFormat   = fileInfo.Extension;

            if (!ResolutionUtility.CheckImageSize(fileInfo))
            {
                return;
            }

            this.TemplateImage = new BitmapImage(new Uri("file://" + path));

            if (this.TemplateImage.PixelWidth < 1200 || this.TemplateImage.PixelHeight < 1700)
            {
                DialogManager.ShowImageSizeWarning();
            }

            ZoomKoefficient = monitorWidth / this.TemplateImage.PixelWidth < 1
                ? monitorWidth / this.TemplateImage.PixelWidth
                : 1;

            this.OnPropertyChanged(nameof(this.PageScale));
        }