Example #1
0
 private void OnImageDataReceived(byte[] imageData, byte sender)
 {
     Application.Current.Dispatcher.Invoke(() => {
         MainWindow w = WPFHelper.GetCurrentMainWindow();
         w.SetPrevImage(imageData);
     });
 }
Example #2
0
        internal async void Analyze(object sender, RoutedEventArgs e)
        {
            if (WPFHelper.GetCurrentMainWindow().currentImageSource == null)
            {
                return;
            }
            ((Button)sender).IsEnabled = false;
            uiItemsMatched.Clear();
            uiItemsUnknown.Clear();

            using (Tesseract.Page p = engine.Process((Bitmap)Bitmap.FromFile(WPFHelper.GetCurrentMainWindow().currentImageSource), PageSegMode.Auto)) {
                StringParser  instance = new StringParser(ruleset);
                ParsingResult result   = null;
                string[]      split    = p.GetText().Split('\n');
                string[]      ready    = split.Where((s) => { return(!string.IsNullOrWhiteSpace(s)); }).ToArray();
                try {
                    result = await Task.Run(() => { return(instance.Parse(ready)); });
                }
                catch (ParsingEntryNotFoundException) {
                    string[] modified = new string[ready.Length + 1];
                    modified[0] = ruleset.startMarkers[0];
                    ready.CopyTo(modified, 1);
                    result = await Task.Run(() => { return(instance.Parse(modified)); });
                }
                ConstructUI(result.parsed, uiItemsMatched);
                ConstructUI(result.unknown, uiItemsUnknown);
            }
            ((Button)sender).IsEnabled = true;
        }
Example #3
0
        private void UITEM_ShowDetails_Click(object sender, RoutedEventArgs e)
        {
            MainWindow w = WPFHelper.GetCurrentMainWindow();

            w.INFO_MainName_Text.Text              = asociatedItem.userFriendlyName;
            w.INFO_ORC_Text.Text                   = asociatedItem.ocrNames.Merge(',');
            w.INFO_CurrentValue_Text.Text          = asociatedItem.currentPrice.ToString();
            w.INFO_PricesBefore_Text.Text          = asociatedItem.pricesInThePast.Merge(',');
            w.INFO_AmountBought_Text.Text          = asociatedItem.totalPurchased.ToString();
            w.MAIN_ItemInfoOverlay_Grid.Visibility = Visibility.Visible;
            w.INFO_RegisterItem_Button.IsEnabled   = !asociatedItem.isRegistered;
            w.INFO_MainName_Text.IsEnabled         = !asociatedItem.isRegistered;
            w.currentItemBeingInspected            = this;
        }