private void DetectPageLanguagesDialog_Load(object sender, EventArgs e)
        {
            string[] supportedLanguages = _ocrEngine.LanguageManager.GetSupportedLanguages();
            if (supportedLanguages == null || supportedLanguages.Length <= 0)
            {
                return;
            }

            Dictionary <string, string> languagesDictionary = new Dictionary <string, string>();

            string[] friendlyNames = new string[supportedLanguages.Length];

            int i = 0;

            foreach (string language in supportedLanguages)
            {
                friendlyNames[i] = MyLanguage.GetLanguageFriendlyName(language);
                languagesDictionary.Add(friendlyNames[i], language);
                i++;
            }

            Array.Sort(friendlyNames, 1, friendlyNames.Length - 1);
            foreach (string friendlyName in friendlyNames)
            {
                MyLanguage ml = new MyLanguage(languagesDictionary[friendlyName], friendlyName, -1);
                _lbSuggestedLanguages.Items.Add(ml);
            }

            UpdateUIState();
        }
Exemplo n.º 2
0
        private void _btnDetectLanguages_Click(object sender, EventArgs e)
        {
            _lbPageLanguages.Items.Clear();
            string[] suggestedLanguages = new string[_lbSuggestedLanguages.SelectedItems.Count];
            int      index = 0;

            foreach (MyLanguage language in _lbSuggestedLanguages.SelectedItems)
            {
                suggestedLanguages[index] = language.Language;
                index++;
            }

            string[] pageLanguages = _ocrPage.DetectLanguages(suggestedLanguages);
            if (pageLanguages != null && pageLanguages.Length > 0)
            {
                foreach (string lang in pageLanguages)
                {
                    string friendlyName = MyLanguage.GetLanguageFriendlyName(lang);
                    _lbPageLanguages.Items.Add(friendlyName);
                }
            }
        }
Exemplo n.º 3
0
        public void Activate(IOcrEngine ocrEngine, IOcrPage ocrPage, ListBox tvZonesList, IOcrZoneCollection zones)
        {
            _ocrEngine   = ocrEngine;
            _ocrPage     = ocrPage;
            _lbZonesList = tvZonesList;
            _zones       = zones;

            // Initialize the combo boxes
            OcrZoneType[] zoneTypes = ocrEngine.ZoneManager.GetSupportedZoneTypes();
            foreach (OcrZoneType zoneType in zoneTypes)
            {
                _typeComboBox.Items.Add(zoneType);
            }

            // Get the languages supported by this engine and fill the list box
            string[] languages           = ocrEngine.LanguageManager.GetSupportedLanguages();
            string[] additionalLanguages = ocrEngine.LanguageManager.GetAdditionalLanguages();
            Dictionary <string, string> languagesDictionary = new Dictionary <string, string>();

            string[] friendlyNames = new string[languages.Length + additionalLanguages.Length];
            int      i             = 0;

            foreach (string language in languages)
            {
                friendlyNames[i] = MyLanguage.GetLanguageFriendlyName(language);
                languagesDictionary.Add(friendlyNames[i], language);
                i++;
            }
            foreach (string language in additionalLanguages)
            {
                friendlyNames[i] = MyLanguage.GetLanguageFriendlyName(language);
                languagesDictionary.Add(friendlyNames[i], language);
                i++;
            }

            Array.Sort(friendlyNames, 1, friendlyNames.Length - 1);

            MyLanguage ml = new MyLanguage(String.Empty, "None", -1);

            _languageComboBox.Items.Add(ml);
            foreach (string friendlyName in friendlyNames)
            {
                ml = new MyLanguage(languagesDictionary[friendlyName], friendlyName, -1);
                _languageComboBox.Items.Add(ml);
            }

            List <ViewPerspectiveItem> zoneViewPerspectiveValues = new List <ViewPerspectiveItem>();

            zoneViewPerspectiveValues.AddRange(new ViewPerspectiveItem[] {
                new ViewPerspectiveItem(RasterViewPerspective.TopLeft, "TopLeft"),
                new ViewPerspectiveItem(RasterViewPerspective.TopLeft90, "TopLeft90"),
                new ViewPerspectiveItem(RasterViewPerspective.TopLeft180, "TopLeft180"),
                new ViewPerspectiveItem(RasterViewPerspective.TopLeft270, "TopLeft270")
            });
            _zoneViewPerspectiveComboBox.Items.AddRange(zoneViewPerspectiveValues.ToArray());

            List <TextDirectionItem> zoneTextDirectionValues = new List <TextDirectionItem>();

            zoneTextDirectionValues.AddRange(new TextDirectionItem[] {
                new TextDirectionItem(OcrTextDirection.LeftToRight, "LeftToRight"),
                new TextDirectionItem(OcrTextDirection.TopToBottom, "TopToBottom")
            });
            _zoneTextDirectionComboBox.Items.AddRange(zoneTextDirectionValues.ToArray());

            // These events cannot be hooked into from the designer,
            // so we will do them in here
            _leftTextBox.GotFocus   += new EventHandler(_areaTextBox_GotFocus);
            _topTextBox.GotFocus    += new EventHandler(_areaTextBox_GotFocus);
            _widthTextBox.GotFocus  += new EventHandler(_areaTextBox_GotFocus);
            _heightTextBox.GotFocus += new EventHandler(_areaTextBox_GotFocus);

            _leftTextBox.LostFocus   += new EventHandler(_areaTextBox_LostFocus);
            _topTextBox.LostFocus    += new EventHandler(_areaTextBox_LostFocus);
            _widthTextBox.LostFocus  += new EventHandler(_areaTextBox_LostFocus);
            _heightTextBox.LostFocus += new EventHandler(_areaTextBox_LostFocus);

            _nameTextBox.LostFocus += new EventHandler(_textTextBox_LostFocus);

            UpdateUIState();
        }