Beispiel #1
0
 public void add(FileDone fileDone, Ocr _ocr, out LuceneEngine luceneEngine)
 {
     FileDone finded = filesDone.FirstOrDefault(x => x.filePath == fileDone.filePath);
     if (finded == null)
     {
         _ocr.OcrStart(fileDone.filePath, false);
         filesDone.Add(fileDone);
         luceneEngine = new LuceneEngine(_ocr._words, true);
     }
     else
     {
         if (!ByteArrayCompare(finded.fileHash,fileDone.fileHash))
         {
             filesDone.Remove(finded);
             filesDone.Add(fileDone);
             _ocr.OcrStart(fileDone.filePath, true);
             luceneEngine = new LuceneEngine(_ocr._words,true);
         }
         else
         {
             _ocr.OcrStart(fileDone.filePath, false);
             luceneEngine = new LuceneEngine(_ocr._words, false);
         }
     }
 }
 public MainWindow()
 {
     InitializeComponent();
     main = new FilesDone();
     main.loadFilesDoneList();
     this.Closed += new EventHandler(MainWindow_Closed);
     listView.ItemsSource = main.filesDone;
     if (main.filesDone.Count != 0)
     {
         loadImage(main.filesDone.First());
         FileDone newFile = new FileDone(main.filesDone.First().filePath, main.filesDone.First().fileName);
         main.add(newFile, _ocr, out luceneEngine);
     }
 }
        private void btn_add_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();
            openFileDialog.Filter = "Graphic Files (.jpg)|*.jpg|All Files (*.*)|*.*";
            openFileDialog.FilterIndex = 1;
            unloadImage();
            bool? userClickedOK = openFileDialog.ShowDialog();

            // Process input if the user clicked OK.
            if (userClickedOK == true)
            {
                // Open the selected file to read.
                FileDone newFile = new FileDone(openFileDialog.FileName, openFileDialog.SafeFileName);
                main.add(newFile,_ocr, out luceneEngine);
                loadImage(newFile);
            }
        }
        private void loadImage(FileDone file)
        {
            ImageBrush imageBrush = new ImageBrush();
            BitmapImage bitmapImage = new BitmapImage();

            bitmapImage.BeginInit();
            bitmapImage.CacheOption = BitmapCacheOption.OnLoad;
            bitmapImage.UriSource = new Uri(file.filePath);
            bitmapImage.EndInit();
            MainCanvas.Width = bitmapImage.PixelWidth;
            MainCanvas.Height = bitmapImage.PixelHeight;
            imageBrush.ImageSource = bitmapImage;
            MainCanvas.Background = imageBrush;
        }