public async void ShowBrowseDestination()
        {
            try
            {
                var openFileDialog = new OpenFileDialog()
                {
                    Filter = "PDF Files|*.pdf", InitialDirectory = $@"{_model.ComboItems[0].FolderPath}"
                };
                if (openFileDialog.ShowDialog() != true)
                {
                    return;
                }
                AcrobatProcess();
                await Task.Delay(500);

                var file = new FileInfo(openFileDialog.FileName);
                //App.Current.Dispatcher.Invoke(() => {

                File.Copy(file.FullName, $"{_model.TempFolder}{file.Name}", true);
                // });


                if (inputFormat.IsMatch(file.Name.Split('.')[0]) != true)
                {
                    ShowClosePDFDocument();
                    await ShowErrorMessage("Incorrect Format", "The next format was expected => {Model}_{DateCode}.pdf");

                    _model.IsMsgVisible = false;
                    return;
                }


                try
                {
                    _model.DestinationFile = new cFileInfo()
                    {
                        FullName = file.Name.Split('.')[0],
                        Model    = file.Name.Split('_')[0],
                        DateCode = file.Name.Split('_')[1].Split('.')[0],
                        Family   = file.Directory.Name,
                        FullPathWithExtension = file.FullName,
                        TimeCreation          = file.CreationTime.ToString("d"),
                        TimeLastAccess        = file.LastAccessTime.ToString("d"),
                        TimeLastWrite         = file.LastWriteTime.ToString("d")
                    };

                    activeWindow.FindChild <WebBrowser>("pdfview").Navigate($"{_model.DestinationFile.FullPathWithExtension}");
                }
                catch
                {
                    _model.DestinationFile = null;
                }
            }
            catch (Exception ex)
            {
                await ShowErrorMessage(message : ex.Message);

                _model.IsMsgVisible = false;
            }
        }
        public void ShowSearch()
        {
            if (_model.FullPathToSearch == null)
            {
                return;
            }

            try
            {
                if (File.Exists($"{_model.FullPathToSearch}.pdf"))
                {
                    File.Copy($@"{_model.FullPathToSearch}.pdf", $@"{_model.TempFolder}{_model.FileNameAdded}.pdf", true);
                    activeWindow.FindChild <WebBrowser>("pdfview").Navigate($@"{_model.TempFolder}{_model.FileNameAdded}.pdf");
                    //_model.Header = $@"tmp\{_model.FileNameAdded}";

                    Visibilities(false);
                }
                else
                {
                    ShowErrorMessage("File NOT Found");
                }
            }
            catch (Exception ex)
            {
                ShowErrorMessage(message: ex.Message);
            }
        }
예제 #3
0
 public void ShowSearch()
 {
     if (activeWindow.FindChild <TransitioningContentControl>("contentControl").Content is SearchView)
     {
         return;
     }
     activeWindow.FindChild <TransitioningContentControl>("contentControl").Content = new SearchView();
 }
예제 #4
0
        public async void Scan()
        {
            _model.VisibilityHeader = Visibility.Hidden;
            var pAsync = await activeWindow.ShowProgressAsync("Status", "Starting...", false, s_without_animation);

            pAsync.SetIndeterminate();
            await Task.Delay(500);

            var scanner = new ScannerService();

            activeWindow.FindChild <WebBrowser>("pdfview").Navigate("about:blank");

            if (File.Exists($"{_model.TempFolder}Preview.pdf"))
            {
                AcrobatProcess();
                await Task.Delay(500);

                File.Delete($"{_model.TempFolder}Preview.pdf");
            }


            var file = await Task <ImageFile> .Factory.StartNew(() => scanner.Scan(pAsync, _model.ColorSetting)).ContinueWith(async(t) =>
            {
                try
                {
                    if (t != null)
                    {
                        var converter           = new ScannerImageConverter(_model.TempFolder);
                        _model.OpenedFileName   = "Preview";
                        _model.FileNameToSave   = _model.OpenedFileName;
                        _model.OpenedFileFolder = _model.TempFolder;
                        _model.ScannedImage     = converter.ConvertScannedImage(t.Result);
                        var saveResult          = converter.SaveOnPDF(_model.ScannedImage as BitmapFrame, pAsync);

                        _model.FullPathOpenedFile = $@"{_model.TempFolder}{_model.OpenedFileName}";
                        await pAsync.CloseAsync();
                        _model.SaveAsEnable     = true;
                        _model.VisibilityHeader = Visibility.Visible;
                        App.Current.Dispatcher.Invoke(() => {
                            activeWindow.FindChild <WebBrowser>("pdfview").Navigate($"{_model.FullPathOpenedFile}.pdf");
                        });
                    }
                    else
                    {
                        _model.ScannedImage = null;
                        _model.SaveAsEnable = false;
                    }
                }
                catch (Exception ex)
                {
                    ControlsErrorState();
                    await pAsync.CloseAsync();
                    ShowErrorMessage(message: ex.Message);
                    _model.ScannedImage     = null;
                    _model.VisibilityHeader = (string.IsNullOrWhiteSpace(_model.OpenedFileName)) ? Visibility.Hidden : Visibility.Visible;
                }
            });
        }
예제 #5
0
        private Button GetButton(MetroWindow window, string buttonName)
        {
            var windowButtonCommands = window.FindChild <WindowButtonCommands>("PART_WindowButtonCommands");

            Assert.NotNull(windowButtonCommands);

            var button = windowButtonCommands.Template.FindName(buttonName, windowButtonCommands) as Button;

            Assert.NotNull(button);

            return(button);
        }
        public void ShowFullScreen()
        {
            if (_model.FileNameSelected == null)
            {
                return;
            }
            var fullView = new Views.FullWindowView();

            fullView.Fullpdfview.Navigate($@"{_model.FileNameSelected.FullPathWithExtension}");
            var vm_fullView = new FullWindowModel()
            {
                TitleWindow = $@"OPENED FILE: {_model.FileNameSelected.FullName}"
            };

            fullView.DataContext = vm_fullView;
            fullView.Closing    += (s, e) =>
            {
                AcrobatProcess();
                activeWindow.FindChild <WebBrowser>("pdfview").Navigate($"{_model.FileNameSelected.FullPathWithExtension}");
            };
            fullView.ShowDialog();
        }
예제 #7
0
 public static void AssertWindowCommandsColor(this MetroWindow window, Color color)
 {
     Assert.True(window.RightWindowCommands.Items.Cast <Button>().Select(x => ((SolidColorBrush)x.Foreground).Color).All(x => x == color));
     Assert.Equal(color, ((SolidColorBrush)window.FindChild <WindowButtonCommands>("PART_WindowButtonCommands").Foreground).Color);
 }